Roku
New Member
- Reaction score
- 3
Hey, well im trying to make this triggered spell, which works like this: the unit places down the healing stream totem (ward), and then units withing 600 range of the totem get healed every 2 sec, based of the heroes int. Here's my trigger:
Basically the thing i dont understand is that whenever i use the function "set affected[pa] = null" all the remaining actions of the trigger get skipped. Doesnt matter where i insert it, all the other things after it get ignored. I would need this, so if a unit leaves the 600 range of the totem, it doesnt get healed anymore. Any help appreciated!
JASS:
scope LHT
globals
//**************************************************************************************************
private constant integer SumUnit = 039;o001039; // Ward Rawcode
private constant real HealBase = 100 // Totem Base-Heal
private constant real TotemRadius = 600 // The AoE affected by the totem
private constant real Interval = 2 // Healing Interval
private constant real LifeSpawn = 60 // The totem's duration
//**************************************************************************************************
private location array Totloc
private integer pt
private unit array caster
private integer pc
private unit array affected
private integer pa
endglobals
struct LHT
unit caster
real heal
real dur = 0
location tl
endstruct
private function Cond takes nothing returns boolean
return GetUnitTypeId(GetSummonedUnit()) == SumUnit
endfunction
private function Unit_Filter takes nothing returns boolean
if IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(caster[pc])) then
return false
endif
if(IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)) then
return false
endif
if(IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE))then
return false
endif
if GetUnitTypeId(GetFilterUnit()) == SumUnit then
return false
endif
return true
endfunction
private function setaffected takes nothing returns nothing
local unit a = GetEnumUnit()
//call PingMinimapLocForForce(bj_FORCE_ALL_PLAYERS, GetUnitLoc(a), 2)
//set affected[pa] = null
set pa = GetUnitIndex(a)
set affected[pa] = a
set a = null
endfunction
private function Heal takes nothing returns boolean
local LHT data = ABCT_GetData()
local real h = data.heal
local unit a
local group af
local location sp = data.tl
local location p
local unit u
call BJDebugMsg("Healing...")
//set affected[pa] = null
call BJDebugMsg("Healing2...")
call PingMinimapLocForForce(bj_FORCE_ALL_PLAYERS, Totloc[pt], 2)
set af = GetUnitsInRangeOfLocMatching(TotemRadius, Totloc[pt], Condition(function Unit_Filter))
call ForGroup(af, function setaffected)
set a = affected[pa]
set p = GetUnitLoc(a)
call CreateNUnitsAtLoc( 1, 039;h005039;, GetOwningPlayer(a), p, bj_UNIT_FACING ) // Adding a dummy buff to the affected units
set u = bj_lastCreatedUnit
call UnitAddAbility(u, 039;A022039;)
call IssueTargetOrder( u, "bloodlust", a )
call UnitApplyTimedLife(u, 039;BTLF039;, 2.00)
if data.dur == LifeSpawn then
call data.destroy()
set data.dur = 0
return true
else
set data.dur = data.dur + Interval
//call PingMinimapLocForForce(bj_FORCE_ALL_PLAYERS, GetUnitLoc(a), 2)
call BJDebugMsg("Healing...")
call SetUnitState(a, UNIT_STATE_LIFE, GetUnitState(a, UNIT_STATE_LIFE) - (h/50 + HealBase))
endif
call DestroyGroup(af)
//call RemoveLocation(sp)
call RemoveLocation(p)
set af = null
set a = null
set u = null
//set sp = null
set p = null
return false
endfunction
private function action takes nothing returns nothing
local LHT data = LHT.create()
local unit c = GetSummoningUnit()
local unit s = GetSummonedUnit()
local location sp = GetUnitLoc(s)
local integer i = GetHeroInt(c,true)
local real cr = I2R(i)
local group af
set pt = GetUnitIndex(s)
set Totloc[pt] = GetUnitLoc(s)
set pc = GetUnitIndex(c)
set caster[pc] = c
//set af = GetUnitsInRangeOfLocMatching(TotemRadius, sp, Condition(function Unit_Filter))
//call ForGroup(af, function setaffected)
set data.tl = sp
set data.heal = cr
call PingMinimapLocForForce(bj_FORCE_ALL_PLAYERS, data.tl, 2)
call ABCT_Start(function Heal, data, Interval)
call RemoveLocation(sp)
call DestroyGroup(af)
set af = null
set c = null
set s = null
set sp = null
endfunction
//===========================================================================
function InitTrig_Totem takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SUMMON )
call TriggerAddCondition( t, Condition( function Cond) )
call TriggerAddAction( t, function action )
endfunction
endscope
Basically the thing i dont understand is that whenever i use the function "set affected[pa] = null" all the remaining actions of the trigger get skipped. Doesnt matter where i insert it, all the other things after it get ignored. I would need this, so if a unit leaves the 600 range of the totem, it doesnt get healed anymore. Any help appreciated!