- Joined
- Apr 5, 2011
- Messages
- 245
It's a piece of code that performs Magina's Mana Void. It works well but how does it look at all and do you see leaks I have not seen?
Updated:
Old:
Updated:
JASS:
library SpellManaVoid requires Assist
//=== Settings ===
globals
private constant integer ABILCODE = 'X003'
private constant string SFX = "Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl"
//----------------
private constant real RADIUS = 150
endglobals
struct SpellManaVoid extends array
private static real array DAMAGE_KOEF
private static method onInit takes nothing returns nothing
set DAMAGE_KOEF[1] = 0.6
set DAMAGE_KOEF[2] = 0.85
set DAMAGE_KOEF[3] = 1.1
endmethod
//----------------
private static method dealDamage takes nothing returns boolean
set Assist.workUnit = GetFilterUnit()
if IsUnitEnemy(Assist.workUnit, Event.triggerPlayer) and not IsUnitType(Assist.workUnit, UNIT_TYPE_MECHANICAL) and not IsUnitType(Assist.workUnit, UNIT_TYPE_MAGIC_IMMUNE) then
call vGDC.dealDamage(Event.triggerUnit, Assist.workUnit, Assist.workReal, MAGIC)
endif
return false
endmethod
static method checkEffect takes nothing returns nothing
local real x
local real y
if Event.abilcode == ABILCODE then
set x = GetWidgetX(Event.targetUnit)
set y = GetWidgetY(Event.targetUnit)
call DestroyEffect(AddSpecialEffect(SFX, x, y))
set Assist.workReal = (GetUnitState(Event.targetUnit, UNIT_STATE_MAX_MANA) - GetUnitState(Event.targetUnit, UNIT_STATE_MANA)) * DAMAGE_KOEF[GetUnitAbilityLevel(Event.triggerUnit, ABILCODE)]
call GroupEnumUnitsInRange(Assist.workGroup, x, y, RADIUS, Condition(function thistype.dealDamage))
endif
endmethod
endstruct
endlibrary
JASS:
library SpellManaVoid
//=== Settings ===
globals
private constant integer ABILCODE = 'X003'
private constant real RADIUS = 150
private constant string SFX = "Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl"
endglobals
struct SpellManaVoid
private static real array DAMAGE_KOEF
private static method onInit takes nothing returns nothing
set DAMAGE_KOEF[1] = 0.6
set DAMAGE_KOEF[2] = 0.85
set DAMAGE_KOEF[3] = 1.1
endmethod
//----------------
private static real damage
private static group g = CreateGroup()
private static method dealDamage takes nothing returns boolean
local unit u = GetFilterUnit()
if IsUnitEnemy(u, p) and not IsUnitType(u, UNIT_TYPE_MECHANICAL) and not IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE) then
call vGDC.dealDamage(Event.triggerUnit, u, damage, MAGIC)
endif
set u = null
return false
endmethod
static method checkEffect takes nothing returns nothing
local real x
local real y
if Event.abilcode == ABILCODE then
set x = GetWidgetX(Event.targetUnit)
set y = GetWidgetY(Event.targetUnit)
call DestroyEffect(AddSpecialEffect(SFX, x, y))
set damage = (GetUnitState(Event.targetUnit, UNIT_STATE_MAX_MANA) - GetUnitState(Event.targetUnit, UNIT_STATE_MANA)) * DAMAGE_KOEF[GetUnitAbilityLevel(Event.triggerUnit, ABILCODE)]
call ClearGroup(g)
call GroupEnumUnitsInRange(g, x, y, RADIUS, Condition(function thistype.dealDamage))
call DestroyGroup(g)
set g = null
endif
endmethod
endstruct
endlibrary
Last edited: