Help with spell. UnitGroup Error

Linconius

New Member
Reaction score
0
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 = 'A038'
        private constant integer DummyID = 'h001'
        private constant integer IllusionAbilityID = 'A071'
        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, 'BTLF', 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, 'B01Q') > 0 or /*
        */GetUnitAbilityLevel(u, 'B01R') > 0 or /*
        */GetUnitAbilityLevel(u, 'B01S') > 0 or /*
        */GetUnitAbilityLevel(u, 'B01T') > 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
 

Laiev

Hey Listen!!
Reaction score
188
You forgot the [ljass]CreateGroup()[/ljass] :p.

Is impossible to add units to a null group.
 

Linconius

New Member
Reaction score
0
I see, I was setting g = Illusions, which meant they were the same group. I changes it to GroupAddGroup(Illusion, g) and it works fine :) ty +rep
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      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