Help with spell

Linconius

New Member
Reaction score
0
Her is the spell.

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 &gt;= 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 &gt; 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;A071&#039;)
        call SetUnitAbilityLevel(SRDummy<i>, &#039;A071&#039;, GetUnitAbilityLevel(SROwner<i>, &#039;A038&#039;))
        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;B01Q&#039;) &gt; 0) then
            return true
        endif
        if( GetUnitAbilityLevel(GetSummonedUnit(), &#039;B01R&#039;) &gt; 0) then
            return true
        endif
        if( GetUnitAbilityLevel(GetSummonedUnit(), &#039;B01S&#039;) &gt; 0) then
            return true
        endif
        if( GetUnitAbilityLevel(GetSummonedUnit(), &#039;B01T&#039;) &gt; 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) &lt; 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(), &quot;Stage 1&quot; )
            loop
                call GroupRefresh(g)
                set u = FirstOfGroup(g)
                exitwhen u == null
                call DisplayTextToForce( GetPlayersAll(), &quot;Stage 2&quot; )
                call PauseUnit(u, true)
                call SetUnitInvulnerable(u, true)
                call SetUnitVertexColor(u, 255, 255, 255, 0)
                call DisplayTextToForce( GetPlayersAll(), &quot;Stage 3&quot; )
                call SetUnitXY(u, SRTargetX<i>, SRTargetY<i>)
                call DisplayTextToForce( GetPlayersAll(), &quot;Stage 4&quot; )
                call SetUnitFacing(u, SRAngle<i>)
                call SelectUnitAddForPlayer(u, p)
                call GroupRemoveUnit(g, u)
                call DisplayTextToForce( GetPlayersAll(), &quot;Stage 5&quot; )
            endloop
            call DisplayTextToForce( GetPlayersAll(), &quot;Stage 6&quot; )
            call IssueTargetOrderById(SRDummy<i>, 852274, SROwner<i>)
            call DisplayTextToForce( GetPlayersAll(), &quot;Stage 7&quot; )
            call SetUnitXY(SROwner<i>, SRTargetX<i>, SRTargetY<i>)
            call DisplayTextToForce( GetPlayersAll(), &quot;Stage 8&quot; )
            call SetUnitFacing(SROwner<i>, SRAngle<i>)
            call DisplayTextToForce( GetPlayersAll(), &quot;Stage 9&quot; )// &lt;---- 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(&quot;Abilities\\Weapons\\WaterElementalMissile\\WaterElementalMissile.mdl&quot;, SROwner<i>, &quot;origin&quot;))
            call SetUnitXY(SROwner<i>, SRTargetX<i>, SRTargetY<i>)
            call SetUnitFacing(SROwner<i>, SRAngle<i> + 180)
            if b then
                call IssueTargetOrder(SROwner<i>, &quot;attack&quot;, 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(&quot;Abilities\\Weapons\\WaterElementalMissile\\WaterElementalMissile.mdl&quot;, u, &quot;origin&quot;))
                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, &quot;attack&quot;, 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;A038&#039;)
        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 &gt; 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.
 

Linconius

New Member
Reaction score
0
The globals were private, but i took the private part out too see if it would work that way. And the problem is that the dummy does not cast wand of illusion multiple times.

And the spell can have up to 8000 instances(limit of array), so pretty close to MUI.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top