Hi.
I'm having a problem with this trigger that I don't know how to solve. It keeps crashig the game.
The trigger is an ability that casts multiple Entangling Roots in an area.
Here is my trigger:
I've tried a lot of different things. I found out that it works, if I add a 0.5 second wait in the loop. -But then it casts very slow. I want this to be instant. (Almost like Rooftrellen's ulti in DotA.) If the wait is 0.4 sec or below, the game crashes.
I believe the crash is caused by an endless loop, but I have no idea why or how to fix it.
I've tested the ability without the trigger, it works as it is supposed to (doing nothing). I've also tested 'A00B' (Entangling Roots), it also works. -It costs 1 mana, my dummy unit has 5000, it has 99999 cast range and 0 cooldown.
Help appriciated. =)
I'm having a problem with this trigger that I don't know how to solve. It keeps crashig the game.
The trigger is an ability that casts multiple Entangling Roots in an area.
Here is my trigger:
JASS:
function Trig_Entangling_Roots_Conditions takes nothing returns boolean
return (GetSpellAbilityId() == 'A00A')
endfunction
function EnemiesInRange_func takes nothing returns boolean
return (IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true) and (GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.405) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_GROUND) == true)
endfunction
function Trig_Entangling_Roots_Actions takes nothing returns nothing
local integer i = GetUnitAbilityLevel(GetTriggerUnit(), 'A00A')
local location loc = GetSpellTargetLoc()
local real x = GetLocationX(loc)
local real y = GetLocationY(loc)
local unit u = CreateUnit(GetOwningPlayer(GetTriggerUnit()), 'h005', x, y, 270)
local unit t
local real range = 400
local group g = CreateGroup()
if (i == 2) then
set range = 450
elseif (i == 3) then
set range = 500
elseif (i == 4) then
set range = 600
endif
call UnitAddAbility(u, 'A00B')
call SetUnitAbilityLevel(u, 'A00B', i)
call UnitApplyTimedLife(u, 'BTLF', 10)
call GroupEnumUnitsInRange(g, x, y, range, Filter(function EnemiesInRange_func))
if (CountUnitsInGroup(g) > 0) then
loop
exitwhen CountUnitsInGroup(g) == 0
set t = FirstOfGroup(g)
call GroupRemoveUnit(g, t)
call IssueTargetOrder(u, "entanglingroots", t)
set t = null
endloop
endif
call DestroyGroup(g)
call RemoveLocation(loc)
set loc = null
set g = null
set u = null
endfunction
//===========================================================================
function InitTrig_Entangling_Roots takes nothing returns nothing
local trigger Entangling_Roots = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( Entangling_Roots, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( Entangling_Roots, Condition( function Trig_Entangling_Roots_Conditions ) )
call TriggerAddAction( Entangling_Roots, function Trig_Entangling_Roots_Actions )
endfunction
I've tried a lot of different things. I found out that it works, if I add a 0.5 second wait in the loop. -But then it casts very slow. I want this to be instant. (Almost like Rooftrellen's ulti in DotA.) If the wait is 0.4 sec or below, the game crashes.
I believe the crash is caused by an endless loop, but I have no idea why or how to fix it.
I've tested the ability without the trigger, it works as it is supposed to (doing nothing). I've also tested 'A00B' (Entangling Roots), it also works. -It costs 1 mana, my dummy unit has 5000, it has 99999 cast range and 0 cooldown.
Help appriciated. =)