When spell is cast, creates multiple illusions of self, and moves self and illusions around target. The problem is that the illusions are not added to the illusion group, which means that "Stage 6" isn't reached, ad therefore the illusions remain paused and invulnerable. I cannot see any errors, please help, cause ive hit a wall :banghead:
JASS:
scope SRScope initializer Initialize
globals
private constant integer AbilityID = 039;A038039;
private constant integer DummyID = 039;h001039;
private constant integer IllusionAbilityID = 039;A071039;
private constant integer array NumberOfIllusions[]//Set each level limit in Initialize function.
private constant real Offset = 100.00
private constant real Duration = 6.00
private constant string Effect = "Abilities\\Weapons\\WaterElementalMissile\\WaterElementalMissile.mdl"
private constant string Attachment = "origin"
private unit LastIllusion
endglobals
private struct Struct
unit TrigUnit
player TrigPlayer
unit TargetUnit
player TargetPlayer
integer Level
real CastX
real CastY
real TargetX
real TargetY
real Angle
group Illusions
integer Index
endstruct
//SRTimer Start=======================================================
private function Timer takes nothing returns nothing
local timer t = GetExpiredTimer()
local Struct Data = GetTimerData(t)
//call GroupClear(SRGroup[SRData.Index])
//call DestroyEffect(SREffect[SRData.Index])
//call ReleaseTimer(t)
//set SROwner[SRData.Index] = null
//set SRTarget[SRData.Index] = null
//set SRDummy[SRData.Index] = null
//set SROwnerX[SRData.Index] = 0.00
//set SROwnerY[SRData.Index] = 0.00
//set SRTargetX[SRData.Index] = 0.00
//set SRTargetY[SRData.Index] = 0.00
//set SRAngle[SRData.Index] = 0
//set SREffect[SRData.Index] = null
call Data.destroy()
endfunction
private function CreateIllusion takes player P, integer ID, integer Level, unit Target returns unit
local unit u
local boolean b
local unit d = CreateUnit(P, DummyID, GetUnitX(Target), GetUnitY(Target), 0)
call UnitApplyTimedLife(d, 039;BTLF039;, 1.00)
call UnitAddAbility(d, ID)
call SetUnitAbilityLevel(d, ID, Level)
call IssueTargetOrderById(d, 852274, Target)
loop
if not (LastIllusion == null) then
set u = LastIllusion
set LastIllusion = null
set b = true
endif
exitwhen b
endloop
return u
endfunction
//SRTimer Finish======================================================
//SRCast Actions Start================================================
private function CastActions takes nothing returns nothing
local timer t
local unit u
local group g
local integer i
local integer iT
local boolean b
local boolean bT
local real r
local effect array e
local Struct Data = Struct.create()
set Data.TrigUnit = GetTriggerUnit()
set Data.TrigPlayer = GetOwningPlayer(Data.TrigUnit)
set Data.TargetUnit = GetSpellTargetUnit()
set Data.TargetPlayer = GetOwningPlayer(Data.TargetUnit)
set Data.Level = GetUnitAbilityLevel(Data.TrigUnit, AbilityID)
set Data.CastX = GetUnitX(Data.TrigUnit)
set Data.CastY = GetUnitY(Data.TrigUnit)
set Data.TargetX = GetUnitX(Data.TargetUnit)
set Data.TargetY = GetUnitY(Data.TargetUnit)
set Data.Angle = GetAngleXY(Data.CastX, Data.CastY, Data.TargetX, Data.TargetY)
set Data.Illusions = NewGroup()
set r = 360.00 / I2R(NumberOfIllusions[Data.Level])
set b = IsUnitAlly(Data.TrigUnit, Data.TargetPlayer)
set bT = false
set iT = 0
loop
if e[iT] == null then
set e[iT] = AddSpecialEffectTarget(Effect, Data.TrigUnit, Attachment)
set bT = true
endif
set iT = iT + 1
exitwhen bT
endloop
call SetUnitVertexColor(Data.TrigUnit, 255, 255, 255, 0)
call SetUnitInvulnerable(Data.TrigUnit, true)
call SetUnitXY(Data.TrigUnit, Data.TargetX, Data.TargetY)
set iT = 0
loop
call GroupRefresh(Data.Illusions)
set g = Data.Illusions
loop
call GroupRefresh(g)
set u = FirstOfGroup(g)
exitwhen u == null
call DisplayTextToForce( GetPlayersAll(), "Stage 2" )
call PauseUnit(u, true)
call SetUnitInvulnerable(u, true)
call SetUnitVertexColor(u, 255, 255, 255, 0)
call DisplayTextToForce( GetPlayersAll(), "Stage 3" )
call SetUnitXY(u, Data.TargetX, Data.TargetY)
call DisplayTextToForce( GetPlayersAll(), "Stage 4" )
call SetUnitFacing(u, Data.Angle)
call SelectUnitAddForPlayer(u, Data.TrigPlayer)
call GroupRemoveUnit(g, u)
call DisplayTextToForce( GetPlayersAll(), "Stage 5" )
endloop
exitwhen iT >= NumberOfIllusions[Data.Level]
set u = CreateIllusion(Data.TrigPlayer, IllusionAbilityID, Data.Level, Data.TrigUnit)//<----------Says 0
call GroupAddUnit(Data.Illusions, u) //<----------Also Says 0
set iT = iT + 1
endloop
set Data.Angle = Data.Angle + (r * I2R(GetRandomInt(0, NumberOfIllusions[Data.Level])))
call SetUnitInvulnerable(Data.TrigUnit, false)
call SetUnitVertexColor(Data.TrigUnit, 255, 255, 255, 255)
call SetUnitXY(Data.TrigUnit, GetOffsetX(Data.TargetX, Data.Angle, Offset), GetOffsetY(Data.TargetY, Data.Angle, Offset))
call SetUnitFacing(Data.TrigUnit, Data.Angle + 180.00)
if not b then
call IssueTargetOrder(Data.TrigUnit, "attack", Data.TargetUnit)
endif
call SelectUnitAddForPlayer(Data.TrigUnit, Data.TrigPlayer)
set g = Data.Illusions
call DisplayTextToForce( GetPlayersAll(), "Units in Data.Illusions: " + I2S(CountUnitsInGroup(Data.Illusions)))
call DisplayTextToForce( GetPlayersAll(), "Units in g: " + I2S(CountUnitsInGroup(g)))
loop
call DisplayTextToForce( GetPlayersAll(), "Stage 6" )//<----------This part of code not reached.
call GroupRefresh(g)
set u = FirstOfGroup(g)
exitwhen u == null
set Data.Angle = Data.Angle + r
call PauseUnit(u, false)
call SetUnitInvulnerable(u, false)
call SetUnitVertexColor(u, 255, 255, 255, 255)
call DisplayTextToForce( GetPlayersAll(), "Stage 7" )
set bT = false
set iT = 0
loop
if e[iT] == null then
set e[iT] = AddSpecialEffectTarget(Effect, u, Attachment)
set bT = true
endif
set iT = iT + 1
exitwhen bT
endloop
call SetUnitXY(u, GetOffsetX(Data.TargetX, Data.Angle, Offset), GetOffsetY(Data.TargetY, Data.Angle, Offset))
call SetUnitFacing(u, Data.Angle + 180.00)
if not b then
call IssueTargetOrder(u, "attack", Data.TargetUnit)
endif
call SelectUnitAddForPlayer(u, Data.TrigPlayer)
call GroupRemoveUnit(g, u)
endloop
set iT = 0
loop
exitwhen e[iT] == null
call SFXExpire(Duration, e[iT])
set iT = iT + 1
endloop
set t = NewTimerEx(Data)
call TimerStart(t, Duration, false, function Timer)
endfunction
//SRCast Actions Finish===============================================
//SRSummon Actions Start==============================================
private function SummonActions takes nothing returns boolean
local unit u = GetSummonedUnit()
if GetUnitAbilityLevel(u, 039;B01Q039;) > 0 or /*
*/GetUnitAbilityLevel(u, 039;B01R039;) > 0 or /*
*/GetUnitAbilityLevel(u, 039;B01S039;) > 0 or /*
*/GetUnitAbilityLevel(u, 039;B01T039;) > 0 then
set LastIllusion = u
endif
return false
endfunction
//SRSummon Actions Finish=============================================
//SRInitialize Actions Start==========================================
private function Initialize takes nothing returns nothing
local trigger t = CreateTrigger()
call GT_RegisterStartsEffectEvent(t, AbilityID)
call TriggerAddAction(t, function CastActions)
set t = CreateTrigger()
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SUMMON, function SummonActions)
//Level 1 is equivilant to NumberOfIllusions[0].
set NumberOfIllusions[0] = 2
set NumberOfIllusions[1] = 2
set NumberOfIllusions[2] = 2
set NumberOfIllusions[3] = 2
endfunction
//SRInitialize Actions Finish=========================================
endscope