- Joined
- Jul 26, 2008
- Messages
- 1,009
Alright I've created a Track spell that allows the caster to get every unit in range that's a hero or unit and ping them. It also gives shared vision at level 3. It's really a pretty basic spell.
However the spell continuously pings a single unit instead of all the units in range. Why is this? The loop nullifies the unit once it's gone once through.
Note: If he has the ability change track 1 'cht1', then he tracks heroes. If it's change track 2 'cht2', then he tracks units.
However the spell continuously pings a single unit instead of all the units in range. Why is this? The loop nullifies the unit once it's gone once through.
Note: If he has the ability change track 1 'cht1', then he tracks heroes. If it's change track 2 'cht2', then he tracks units.
JASS:
scope Track initializer InitTrig_Track
globals
private constant integer SpellID = 'trac' //Spell Rawcode //Buff Rawcode
private constant real dur = 3. //Periodic of timer
private unit cast
endglobals
private struct Data
unit c
unit t
static method create takes unit caster, unit temp returns Data
local Data D = Data.allocate()
set D.c = caster
set D.t = temp
return D
endmethod
endstruct
private function Track_Conditions takes nothing returns boolean
return GetSpellAbilityId() == SpellID
endfunction
private function Track_Timer takes nothing returns nothing
local timer tim = GetExpiredTimer()
local Data D = Data(GetTimerData(tim))
call UnitShareVision(D.t, GetOwningPlayer(D.c), false)
call ReleaseTimer(tim)
call D.destroy()
endfunction
private function GroupUnitConditions takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(cast)) == true and IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) == true and GetWidgetLife(GetFilterUnit()) >= 1
endfunction
private function GroupHeroConditions takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(cast)) == true and IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) == false and GetWidgetLife(GetFilterUnit()) >= 1
endfunction
private function Track_Actions takes nothing returns nothing
local timer tim = NewTimer()
local Data D = Data.create(GetTriggerUnit(), null)
local real cX = GetUnitX(D.c)
local real cY = GetUnitY(D.c)
local real rad = 1200. * GetUnitAbilityLevel(D.c, SpellID)
local group g = CreateGroup()
local unit t
set cast = D.c
if GetUnitAbilityLevel(D.c, 'cht1') == 1 then
call GroupEnumUnitsInRange(g, cX, cY, rad, Filter(function GroupUnitConditions))
elseif GetUnitAbilityLevel(D.c, 'cht2') == 1 then
call GroupEnumUnitsInRange(g, cX, cY, rad, Filter(function GroupHeroConditions))
endif
loop
set t = FirstOfGroup(g)
exitwhen t == null
call PingMinimap(GetUnitX(t), GetUnitY(t), 1.5*GetUnitAbilityLevel(D.c, SpellID))
call BJDebugMsg(GetUnitName(t))
if GetUnitAbilityLevel(D.c, SpellID) == 3 then
call UnitShareVision(t, GetOwningPlayer(D.c), true)
set D.t = t
call SetTimerData(tim, D)
call TimerStart(tim, 3.0, false, function Track_Timer)
endif
set t = null
endloop
call DestroyGroup(g)
set g = null
set t = null
set tim = null
endfunction
//===========================================================================
public function InitTrig_Track takes nothing returns nothing
local trigger Track = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( Track, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( Track, Condition( function Track_Conditions ) )
call TriggerAddAction( Track, function Track_Actions )
endfunction
endscope