- Joined
- Apr 25, 2011
- Messages
- 73
I need help with:
The problem is that it never goes into the "IF"s. So it won't leave the loop. And probably this means it leaks...
Anyway, when I cast it, it lags a little and then it works pretty well.
My main problems are:
1. The lag when I cast the spell.
2. The Illusion does not die / disappear if the Target is dead... And that is because it never gets the loop.
I seems that the lag goes away if I replace
with
But this method seems like it doesn't go through the loop at all...
I think I might need timers... But I'm not that good at timers...
If you guys have any idea how to get rid of the lag and get out of the loop please let me know...
JASS:
function Trig_Illusion_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A002'
endfunction
function Trig_Illusion_Actions takes nothing returns nothing
local unit t = GetSpellTargetUnit()
local unit c = GetTriggerUnit()
local integer i = GetUnitTypeId(t)
local integer l = GetUnitAbilityLevel(c, 'A002' )
local real x = GetUnitX(t)
local real y = GetUnitY(t)
local player p1 = GetOwningPlayer(c)
local player p2 = GetOwningPlayer(t)
local unit m = CreateUnit( p1, i, x, y, bj_UNIT_FACING )
call SetUnitColor( m, GetPlayerColor(p2) )
call UnitAddAbility(m, 'Aloc')
call UnitApplyTimedLife(m, 'BTLF', I2R(l))
call SetUnitPathing( m, false )
call SetUnitVertexColor(m, 100, 100, 100, 50)
call SetUnitInvulnerable( m, true )
loop
call IssueTargetOrder( m, "attack" , t )
if GetUnitState( t , UNIT_STATE_LIFE) <= 0 then
set m = null
endif
if GetUnitState( m , UNIT_STATE_LIFE) <= 0 then
set m = null
endif
exitwhen m == null
endloop
call RemoveUnit(m)
set m = null
set t = null
set c = null
set p1 = null
set p2 = null
endfunction
//===========================================================================
function InitTrig_Illusion takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Condition( function Trig_Illusion_Conditions ) )
call TriggerAddAction( t, function Trig_Illusion_Actions )
endfunction
The problem is that it never goes into the "IF"s. So it won't leave the loop. And probably this means it leaks...
Anyway, when I cast it, it lags a little and then it works pretty well.
My main problems are:
1. The lag when I cast the spell.
2. The Illusion does not die / disappear if the Target is dead... And that is because it never gets the loop.
I seems that the lag goes away if I replace
JASS:
if GetUnitState( m , UNIT_STATE_LIFE) <= 0 then
JASS:
if GetUnitState( m , UNIT_STATE_LIFE) <= GetUnitState( m , UNIT_STATE_MAX_LIFE) then
But this method seems like it doesn't go through the loop at all...
I think I might need timers... But I'm not that good at timers...
If you guys have any idea how to get rid of the lag and get out of the loop please let me know...