Her is the spell.
The problem I am having is that the SRDummy does not cast the spell 852274 (Wand of Illusion) multiple times. It gets up to "Stage 9", which is past when the unit is ordered to re cast the spell. This means that it does not complete the spell. Please help, because I can't see any errors. The Conditions for the summoning trigger are just the buff Illusion on the summoned unit.
JASS:
scope SRScope initializer SRInitialize
globals
integer SRLimit = 0
unit array SROwner
unit array SRTarget
unit array SRDummy
real array SROwnerX
real array SROwnerY
real array SRTargetX
real array SRTargetY
real array SRAngle
group array SRGroup
effect array SREffect
endglobals
struct SRStruct
integer Index
endstruct
private function SRGetOwner takes unit u returns integer
local boolean b = false
local integer r = 0
local integer i = 0
loop
exitwhen i > SRLimit
if u == SROwner<i> then
set b = true
if SRGroup<i> == null then
set SRGroup<i> = CreateGroup()
endif
set r = i
endif
set i = i + 1
endloop
set i = 0
if not b then
loop
exitwhen b
if SROwner<i> == null then
set r = i
set SROwner<i> = u
if SRGroup<i> == null then
set SRGroup<i> = CreateGroup()
endif
set b = true
else
if i >= SRLimit then
set SRLimit = i + 1
set SRGroup[SRLimit] = CreateGroup()
endif
endif
set i = i + 1
endloop
endif
return r
endfunction
private function SRGetDummy takes unit u returns integer
local boolean b = false
local integer r = 0
local integer i = 0
loop
exitwhen i > SRLimit or b
if u == SRDummy<i> then
set r = i
set b = true
endif
set i = i + 1
endloop
return r
endfunction
//SRTimer Start=======================================================
private function SRTimer takes nothing returns nothing
local timer t = GetExpiredTimer()
local SRStruct SRData = 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 SRData.destroy()
endfunction
//SRTimer Finish======================================================
//SRCast Actions Start================================================
private function SRCastActions takes nothing returns nothing
local integer i = SRGetOwner(GetTriggerUnit())
set SRTarget<i> = GetSpellTargetUnit()
set SROwnerX<i> = GetUnitX(SROwner<i>)
set SROwnerY<i> = GetUnitY(SROwner<i>)
set SRTargetX<i> = GetUnitX(SRTarget<i>)
set SRTargetY<i> = GetUnitY(SRTarget<i>)
call SetUnitVertexColor(SROwner<i>, 255, 255, 255, 0)
call SetUnitInvulnerable(SROwner<i>, true)
call SetUnitXY(SROwner<i>, SRTargetX<i>, SRTargetY<i>)
set SRDummy<i> = CreateDummy(GetOwningPlayer(SROwner<i>), 1.00, SRTargetX<i>, SRTargetY<i>)
call UnitAddAbility(SRDummy<i>, 039;A071039;)
call SetUnitAbilityLevel(SRDummy<i>, 039;A071039;, GetUnitAbilityLevel(SROwner<i>, 039;A038039;))
call IssueTargetOrderById(SRDummy<i>, 852274, SROwner<i>)
endfunction
//SRCast Actions Finish===============================================
//SRSummon Actions Start==============================================
private function SRSummonConditions takes nothing returns boolean
if( GetUnitAbilityLevel(GetSummonedUnit(), 039;B01Q039;) > 0) then
return true
endif
if( GetUnitAbilityLevel(GetSummonedUnit(), 039;B01R039;) > 0) then
return true
endif
if( GetUnitAbilityLevel(GetSummonedUnit(), 039;B01S039;) > 0) then
return true
endif
if( GetUnitAbilityLevel(GetSummonedUnit(), 039;B01T039;) > 0) then
return true
endif
return false
endfunction
private function SRSummonActions takes nothing returns nothing
local timer t
local SRStruct SRData = SRStruct.create()
local integer i = SRGetDummy(GetSummoningUnit())
local integer l = 1
local boolean b = (SROwner<i> == SRTarget<i>)
local player p = GetOwningPlayer(SROwner<i>)
local unit u
local group g
call GroupAddUnit(SRGroup<i>, GetSummonedUnit())
set g = SRGroup<i>
set SRData.Index = i
set SRTargetX<i> = GetUnitX(SRTarget<i>)
set SRTargetY<i> = GetUnitY(SRTarget<i>)
set SRAngle<i> = GetAngleXY(SROwnerX<i>, SROwnerY<i>, SRTargetX<i>, SRTargetY<i>)
if CountUnitsInGroup(g) < 2 then
call SetUnitInvulnerable(SROwner<i>, true)
call SetUnitVertexColor(SROwner<i>, 255, 255, 255, 0)
call SetUnitXY(SROwner<i>, SRTargetX<i>, SRTargetY<i>)
call SetUnitFacing(SROwner<i>, SRAngle<i>)
call SelectUnitAddForPlayer(SROwner<i>, p)
call DisplayTextToForce( GetPlayersAll(), "Stage 1" )
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, SRTargetX<i>, SRTargetY<i>)
call DisplayTextToForce( GetPlayersAll(), "Stage 4" )
call SetUnitFacing(u, SRAngle<i>)
call SelectUnitAddForPlayer(u, p)
call GroupRemoveUnit(g, u)
call DisplayTextToForce( GetPlayersAll(), "Stage 5" )
endloop
call DisplayTextToForce( GetPlayersAll(), "Stage 6" )
call IssueTargetOrderById(SRDummy<i>, 852274, SROwner<i>)
call DisplayTextToForce( GetPlayersAll(), "Stage 7" )
call SetUnitXY(SROwner<i>, SRTargetX<i>, SRTargetY<i>)
call DisplayTextToForce( GetPlayersAll(), "Stage 8" )
call SetUnitFacing(SROwner<i>, SRAngle<i>)
call DisplayTextToForce( GetPlayersAll(), "Stage 9" )// <---- Problem is here.
else
set SRAngle<i> = SRAngle<i> + (120 * GetRandomInt(0, 2))
call SetUnitInvulnerable(SROwner<i>, false)
call SetUnitVertexColor(SROwner<i>, 255, 255, 255, 255)
call SFXExpire(6.00, AddSpecialEffectTarget("Abilities\\Weapons\\WaterElementalMissile\\WaterElementalMissile.mdl", SROwner<i>, "origin"))
call SetUnitXY(SROwner<i>, SRTargetX<i>, SRTargetY<i>)
call SetUnitFacing(SROwner<i>, SRAngle<i> + 180)
if b then
call IssueTargetOrder(SROwner<i>, "attack", SRTarget<i>)
endif
call SelectUnitAddForPlayer(SROwner<i>, p)
loop
call GroupRefresh(g)
set u = FirstOfGroup(g)
exitwhen u == null
set SRAngle<i> = SRAngle<i> + (120 * l)
call PauseUnit(u, false)
call SetUnitInvulnerable(u, false)
call SetUnitVertexColor(u, 255, 255, 255, 255)
call SFXExpire(6.00, AddSpecialEffectTarget("Abilities\\Weapons\\WaterElementalMissile\\WaterElementalMissile.mdl", u, "origin"))
call SetUnitXY(u, GetOffsetX(SRTargetX<i>, SRAngle<i>, 100), GetOffsetY(SRTargetY<i>, SRAngle<i>, 100))
call SetUnitFacing(u, SRAngle<i> + 180)
if b then
call IssueTargetOrder(u, "attack", SRTarget<i>)
endif
call SelectUnitAddForPlayer(u, p)
call GroupRemoveUnit(g, u)
set l = l + 1
endloop
set t = NewTimerEx(SRData)
call TimerStart(t, 6, false, function SRTimer)
endif
call SRData.destroy()
endfunction
//SRSummon Actions Finish=============================================
//SRInitialize Actions Start==========================================
private function SRInitialize takes nothing returns nothing
local integer i
local trigger t = CreateTrigger()
call GT_RegisterStartsEffectEvent(t, 039;A038039;)
call TriggerAddAction(t, function SRCastActions)
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SUMMON)
call TriggerAddCondition(t, Condition(function SRSummonConditions))
call TriggerAddAction(t, function SRSummonActions)
set i = 0
loop
exitwhen i > SRLimit
set SRGroup<i> = CreateGroup()
set i = i + 1
endloop
endfunction
//SRInitialize Actions Finish=========================================
endscope</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>
The problem I am having is that the SRDummy does not cast the spell 852274 (Wand of Illusion) multiple times. It gets up to "Stage 9", which is past when the unit is ordered to re cast the spell. This means that it does not complete the spell. Please help, because I can't see any errors. The Conditions for the summoning trigger are just the buff Illusion on the summoned unit.