- Joined
- Feb 8, 2015
- Messages
- 123
So for my latest dip into the WC3 Editor I finally decided to learn JASS. It's been going well, except that I struggle with carrying groups through time(rs).
I think I can best explain my issue by explaining the spell I'm making.
Hellfury Strike - Slams a target foe in melee range, dealing damage. If 3 or more enemies are within range of the main target this ability deals double damage, but is distributed evenly among all targets.
Now this part of the trigger ability works! However, the ability may be further modified by the so-called "Arms of Astaroth" (or AoA for short) upgrade. This should make the ability do an additional 25% lingering damage over 5 seconds.
This is the part I'm struggling with.
The trouble is that, however I try, the group doesn't seem to get properly passed to the AoA_dot function (after the timer expiration).
I've also tried using a global variable, some udg_HeFu_group; adding units to that and saving its handle, but it amounts to the same thing - which is to say; nothing.
BJDebugMsgs confirm that that the AoAactive boolean IS TRUE! And the counter properly ticks up each of the 5 expected times.
However, the number of units getting passed to the AoA_dot function is always zero, regardless of me saving/loading the group handle of a local or global variable.
Again, I'm new to JASS. If there's a simpler and/or better way of passing groups around to delayed actions - or if there's anything else inherently offputting about my trigger - then I'm happy to take advice!
I think I can best explain my issue by explaining the spell I'm making.
Hellfury Strike - Slams a target foe in melee range, dealing damage. If 3 or more enemies are within range of the main target this ability deals double damage, but is distributed evenly among all targets.
Now this part of the trigger ability works! However, the ability may be further modified by the so-called "Arms of Astaroth" (or AoA for short) upgrade. This should make the ability do an additional 25% lingering damage over 5 seconds.
This is the part I'm struggling with.
JASS:
function Trig_HellfuryStrike_Conditions takes nothing returns boolean
return (GetSpellAbilityId() == 'A00I')
endfunction
function TargetCondition takes nothing returns boolean
if IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) then
return false
elseif IsUnitType(GetFilterUnit(), UNIT_TYPE_ETHEREAL) then
return false
elseif IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING) then
return false
elseif IsUnitDeadBJ(GetFilterUnit()) then
return false
elseif not IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) then
return false
else
return true
endif
endfunction
function AoA_dot takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local unit pu
local unit cast = LoadUnitHandle(udg_Spell_Table, id, 1)
local real damage = LoadReal(udg_Spell_Table, id, 2)
local group ug = LoadGroupHandle(udg_Spell_Table, id, 3)
local integer count = LoadInteger(udg_Spell_Table, id, 4) + 1
call SaveInteger(udg_Spell_Table, id, 4, count)
if (count < 5) then
loop
set pu = FirstOfGroup(ug)
exitwhen (pu == null)
call UnitDamageTarget(cast, pu, damage, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Feedback\\SpellBreakerAttack.mdl", GetUnitX(pu), GetUnitY(pu)))
call GroupRemoveUnit(ug, pu)
endloop
call TimerStart(t, 1.0, false, function AoA_dot)
else
// clean memory
call FlushChildHashtable(udg_Spell_Table, id)
call PauseTimer(t)
call DestroyTimer(t)
endif
call DestroyGroup(ug)
set ug = null
set pu = null
set cast = null
set t = null
endfunction
function Trig_HellfuryStrike_Actions takes nothing returns nothing
local unit cast = GetTriggerUnit()
local unit targ = GetSpellTargetUnit()
local real x = GetSpellTargetX()
local real y = GetSpellTargetY()
local real damage = 100
local real aoe = 200
local group ug = CreateGroup()
local unit pu
local integer targetcount = 1
local filterfunc targetfilter = Filter(function TargetCondition)
/* If ARMS OF ASTAROTH is not active, these are not needed
but must be declared here for locality.
*/
local timer t = CreateTimer()
local integer id = GetHandleId(t)
local boolean AoAactive = (udg_HF_activeHellion[GetUnitUserData(cast)] == 1) // this looks wierd, I reckon, but it DOES work like I want it to
call GroupEnumUnitsInRange(ug, x, y, aoe, targetfilter)
if AoAactive then
call SaveGroupHandle(udg_Spell_Table, id, 3, ug)
endif
set targetcount = CountUnitsInGroup(ug)
if (targetcount >= 4) then
// AoE spread damage
set damage = (damage*2)/targetcount
loop
set pu = FirstOfGroup(ug)
exitwhen (pu == null)
call UnitDamageTarget(cast, pu, damage, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_ENHANCED, null) // Hero damage, ignore armor
call DestroyEffect(AddSpecialEffect("Abilities\\Weapons\\DemolisherFireMissile\\DemolisherFireMissile.mdl", GetUnitX(pu) , GetUnitY(pu)))
call GroupRemoveUnit(ug, pu)
endloop
else
// Single target damage
call UnitDamageTarget(cast, targ, damage, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_ENHANCED, null)
call DestroyEffect(AddSpecialEffect("Abilities\\Weapons\\DemolisherFireMissile\\DemolisherFireMissile.mdl", GetUnitX(targ) , GetUnitY(targ)))
endif
/*
Save additional info for ARMS OF ASTAROTH dot damage
*/
if AoAactive then
call SaveUnitHandle(udg_Spell_Table, id, 1, cast)
call SaveReal(udg_Spell_Table, id, 2, damage/20)
call SaveInteger(udg_Spell_Table, id, 4, 0)
call TimerStart(t, 1.0, false, function AoA_dot)
endif
call DestroyFilter(targetfilter)
call DestroyGroup(ug)
set ug = null
set t = null
set cast = null
set targ = null
set pu = null
endfunction
The trouble is that, however I try, the group doesn't seem to get properly passed to the AoA_dot function (after the timer expiration).
I've also tried using a global variable, some udg_HeFu_group; adding units to that and saving its handle, but it amounts to the same thing - which is to say; nothing.
BJDebugMsgs confirm that that the AoAactive boolean IS TRUE! And the counter properly ticks up each of the 5 expected times.
However, the number of units getting passed to the AoA_dot function is always zero, regardless of me saving/loading the group handle of a local or global variable.
Again, I'm new to JASS. If there's a simpler and/or better way of passing groups around to delayed actions - or if there's anything else inherently offputting about my trigger - then I'm happy to take advice!


