- Joined
- Sep 6, 2007
- Messages
- 440
JASS:
function Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A005'
endfunction
function AndConditions takes nothing returns boolean
return GetBooleanAnd(IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false, IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true)
endfunction
function Attract takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer i = GetHandleInt(t, "i") + 1
local real X
local real Y
local unit S
local unit V
local unit U
local group G
if i == 10 then
call GetHandleUnit(t, "s")
call RemoveUnit(S)
call FlushHandleLocals(t)
call DestroyTimer(t)
else
call SetHandleInt(t, "i", i + 1)
set S = GetHandleUnit(t, "s")
set X = GetHandleReal(t, "x")
set Y = GetHandleReal(t, "y")
set G = GetHandleGroup(t, "g")
set U = GetHandleUnit(t, "u")
call GroupEnumUnitsInRangeOfLoc(G, Location(X, Y), I2R(GetUnitAbilityLevel(U, 'A004') * 300), Condition(function AndConditions))
set V = GetFilterUnit()
call UnitDamageTarget(S, V, R2I(GetUnitState(V, UNIT_STATE_MANA) * 5), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MIND, WEAPON_TYPE_WHOKNOWS)
call SetUnitState(V, UNIT_STATE_MANA, R2I(GetUnitState(V, UNIT_STATE_MANA) - 20))
endif
set t = null
endfunction
function Twisted_Mind takes nothing returns nothing
local location L = GetSpellTargetLoc()
local unit U = GetSpellAbilityUnit()
local group G = GetUnitsInRangeOfLocMatching(I2R(GetUnitAbilityLevel(U, 'A004') * 300), L, Condition(function AndConditions))
local unit S
local timer t = CreateTimer()
local real X = GetLocationX(L)
local real Y = GetLocationY(L)
call CreateNUnitsAtLoc(1, 'h001', GetOwningPlayer(U), L, 270.)
set S = GetLastCreatedUnit()
call UnitAddAbility(S, 'A003')
call UnitRemoveAbility(S, 'A003')
call SetUnitFlyHeight(S, -770.00, 400.00)
call SetHandleHandle(t, "g", G)
call SetHandleHandle(t, "s", S)
call SetHandleHandle(t, "u", U)
call SetHandleReal(t, "x", X)
call SetHandleReal(t, "y", Y)
call TimerStart(t, 1., true, function Attract)
endfunction
function InitTrig_Twisted_Mind takes nothing returns nothing
set gg_trg_Twisted_Mind = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Twisted_Mind, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_Twisted_Mind, Condition(function Conditions))
call TriggerAddAction(gg_trg_Twisted_Mind, function Twisted_Mind)
endfunction
What I'm trying to do here is, a unit casts a spell at a point, then it will create a dummy unit and then for every sec for 10 seconds at total, this will deal damage to units in range of caster's ability level * 300. But it's not working. I think problem lies with the group... What should I do here?