• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Indexing Problem with Triggers?

Status
Not open for further replies.
Level 11
Joined
Aug 6, 2009
Messages
697
I have a problem with the trigger below, it works as long as one person is casting it, but breaks if two people cast at the same time. From what I can tell, the Indexing seems to get mixed up somewhere but I have no clue to where. I used dynamic indexing before and it broke. Then, I changed to Linked Lists, and that worked, for a time. After copying and pasting about 5 functions at a time in the trigger, everything melted down and returned to being broken. Also, I am using Jass NewGen v2.09.

JASS:
function PSStart takes unit u, unit u2, real a, real b, real c, real d, real e, real f, integer i returns nothing

    set udg_PS_SpellCount = udg_PS_SpellCount + 1
    if udg_PS_SpellCount == 1 then

        call EnableTrigger( gg_trg_ProjectileSystem2 )

    endif

    if udg_PS_RecycleSize == 0 then
        set udg_PS_MaxIndex = udg_PS_MaxIndex + 1
        set udg_TempSpellID = udg_PS_MaxIndex
    else
        set udg_PS_RecycleSize = udg_PS_RecycleSize - 1
        set udg_TempSpellID = udg_PS_RecycleStack[udg_PS_RecycleSize]
    endif
 
    set udg_PS_SpellNext[udg_TempSpellID] = 0
    set udg_PS_SpellNext[udg_PS_SpellLast] = udg_TempSpellID
    set udg_PS_SpellPrev[udg_TempSpellID] = udg_PS_SpellLast
    set udg_PS_SpellLast = udg_TempSpellID

    set udg_PS_Caster[udg_TempSpellID] = u
    set udg_PS_Unit[udg_TempSpellID] = u2
    set udg_PS_Timer[udg_TempSpellID] = a
    set udg_PS_Angle[udg_TempSpellID] = b
    set udg_PS_Offset[udg_TempSpellID] = c
    set udg_PS_Damage[udg_TempSpellID] = d
    set udg_PS_MaxDistance[udg_TempSpellID] = e
    set udg_PS_Number2[udg_TempSpellID] = i
    set udg_PS_Detect[udg_TempSpellID] = f


endfunction
  • Custom script: call PSStart(udg_SKHA_Caster[udg_SKHA_Loop], udg_DR_Units[udg_DR_Number], udg_SKHA_Timer2[udg_SKHA_Loop],udg_DR_Angle, 80, udg_SKHA_Damage[udg_SKHA_Loop], 3000, 150, udg_DR_Number)
  • SuperKamehameha2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (|cff00ffffR|r)|cff3399ffSuper Kamehameha|r
    • Actions
      • Set TempInt = (Player number of (Owner of (Triggering unit)))
      • Set SKHA_MaxIndex = (SKHA_MaxIndex + 1)
      • Set SKHA_Caster[SKHA_MaxIndex] = (Triggering unit)
      • Set SKHA_Timer[SKHA_MaxIndex] = 5.35
      • Set SKHA_Timer2[SKHA_MaxIndex] = 4.10
      • Set SKHA_Damage[SKHA_MaxIndex] = (((2.00 x (((Real((Strength of SKHA_Caster[SKHA_MaxIndex] (Include bonuses)))) + (Real((Intelligence of SKHA_Caster[SKHA_MaxIndex] (Include bonuses))))) x (Real((Level of (|cff00ffffR|r)|cff3399ffSuper Kamehameha|r for SKHA_Caster[SKHA_MaxIndex]))))) / SKHA_
      • Set SKHA_Boolean[SKHA_MaxIndex] = False
      • Set SKHA_Casting[SKHA_MaxIndex] = True
      • Set TempPoint = (Position of SKHA_Caster[SKHA_MaxIndex])
      • Set TempPoint2 = (Target point of ability being cast)
      • Set SKHA_Angle[SKHA_MaxIndex] = (Angle from TempPoint to TempPoint2)
      • Custom script: call RemoveLocation(udg_TempPoint2)
      • Set TempPoint2 = (TempPoint offset by 20.00 towards ((Facing of SKHA_Caster[SKHA_MaxIndex]) - 90.00) degrees)
      • Unit - Create 1 KHADummy3 for (Owner of SKHA_Caster[SKHA_MaxIndex]) at TempPoint2 facing TempReal degrees
      • Set SKHA_Dummy[SKHA_MaxIndex] = (Last created unit)
      • Set SKHA_Size[SKHA_MaxIndex] = 15.00
      • Special Effect - Create a special effect attached to the origin of SKHA_Caster[SKHA_MaxIndex] using DustWave.mdx
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect attached to the origin of SKHA_Caster[SKHA_MaxIndex] using Abilities\Spells\Other\Charm\CharmTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call StartSound(udg_SKHA_Sound1[udg_TempInt])
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Custom script: call RemoveLocation(udg_TempPoint2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SKHA_MaxIndex Equal to 1
        • Then - Actions
          • Trigger - Turn on SuperKamehamehaLoop2 <gen>
        • Else - Actions

  • SuperKamehamehaLoop2
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer SKHA_Loop) from 1 to SKHA_MaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SKHA_Casting[SKHA_Loop] Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SKHA_Timer[SKHA_Loop] Greater than 0.00
                • Then - Actions
                  • Animation - Play SKHA_Caster[SKHA_Loop]'s Spell Channel animation
                  • Set SKHA_Timer[SKHA_Loop] = (SKHA_Timer[SKHA_Loop] - 0.03)
                  • Set SKHA_Size[SKHA_Loop] = (SKHA_Size[SKHA_Loop] + 2.00)
                  • Animation - Change SKHA_Dummy[SKHA_Loop]'s size to (SKHA_Size[SKHA_Loop]%, 15.00%, 15.00%) of its original size
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • SKHA_Timer2[SKHA_Loop] Greater than 0.00
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • SKHA_Boolean[SKHA_Loop] Equal to False
                        • Then - Actions
                          • Set TempInt = (Player number of (Owner of SKHA_Caster[SKHA_Loop]))
                          • Animation - Play SKHA_Caster[SKHA_Loop]'s Spell Throw animation
                          • Unit - Remove SKHA_Dummy[SKHA_Loop] from the game
                          • Custom script: call StartSound(udg_SKHA_Sound2[udg_TempInt])
                          • Set SKHA_Boolean[SKHA_Loop] = True
                          • Set TempPoint = (Position of SKHA_Caster[SKHA_Loop])
                          • Set DR_Point = (TempPoint offset by 80.00 towards SKHA_Angle[SKHA_Loop] degrees)
                          • Custom script: set udg_DR_UnitType = 'h00G'
                          • Set DR_Player = (Owner of SKHA_Caster[SKHA_Loop])
                          • Set DR_Angle = SKHA_Angle[SKHA_Loop]
                          • Trigger - Run DummyRecycler <gen> (checking conditions)
                          • Custom script: call PSStart(udg_SKHA_Caster[udg_SKHA_Loop], udg_DR_Units[udg_DR_Number], udg_SKHA_Timer2[udg_SKHA_Loop],udg_DR_Angle, 80, udg_SKHA_Damage[udg_SKHA_Loop], 3000, 150, udg_DR_Number)
                          • Custom script: call RemoveLocation(udg_DR_Point)
                          • Custom script: call RemoveLocation(udg_TempPoint)
                        • Else - Actions
                      • Set SKHA_Timer2[SKHA_Loop] = (SKHA_Timer2[SKHA_Loop] - 0.03)
                    • Else - Actions
                      • Set SKHA_Casting[SKHA_Loop] = False
                      • Set SKHA_Angle[SKHA_Loop] = SKHA_Angle[SKHA_MaxIndex]
                      • Set SKHA_Boolean[SKHA_Loop] = SKHA_Boolean[SKHA_MaxIndex]
                      • Set SKHA_Caster[SKHA_Loop] = SKHA_Caster[SKHA_MaxIndex]
                      • Set SKHA_Caster[SKHA_MaxIndex] = No unit
                      • Set SKHA_Casting[SKHA_Loop] = SKHA_Casting[SKHA_MaxIndex]
                      • Set SKHA_Damage[SKHA_Loop] = SKHA_Damage[SKHA_MaxIndex]
                      • Set SKHA_Dummy[SKHA_Loop] = SKHA_Dummy[SKHA_MaxIndex]
                      • Set SKHA_Dummy[SKHA_MaxIndex] = No unit
                      • Set SKHA_Size[SKHA_Loop] = SKHA_Size[SKHA_MaxIndex]
                      • Set SKHA_Timer[SKHA_Loop] = SKHA_Timer[SKHA_MaxIndex]
                      • Set SKHA_Timer2[SKHA_Loop] = SKHA_Timer2[SKHA_MaxIndex]
                      • Set SKHA_MaxIndex = (SKHA_MaxIndex - 1)
                      • Set SKHA_Loop = (SKHA_Loop - 1)
            • Else - Actions
              • Set SKHA_Casting[SKHA_Loop] = False
              • Set SKHA_Angle[SKHA_Loop] = SKHA_Angle[SKHA_MaxIndex]
              • Set SKHA_Boolean[SKHA_Loop] = SKHA_Boolean[SKHA_MaxIndex]
              • Set SKHA_Caster[SKHA_Loop] = SKHA_Caster[SKHA_MaxIndex]
              • Set SKHA_Caster[SKHA_MaxIndex] = No unit
              • Set SKHA_Casting[SKHA_Loop] = SKHA_Casting[SKHA_MaxIndex]
              • Set SKHA_Damage[SKHA_Loop] = SKHA_Damage[SKHA_MaxIndex]
              • Set SKHA_Dummy[SKHA_Loop] = SKHA_Dummy[SKHA_MaxIndex]
              • Set SKHA_Dummy[SKHA_MaxIndex] = No unit
              • Set SKHA_Size[SKHA_Loop] = SKHA_Size[SKHA_MaxIndex]
              • Set SKHA_Timer[SKHA_Loop] = SKHA_Timer[SKHA_MaxIndex]
              • Set SKHA_Timer2[SKHA_Loop] = SKHA_Timer2[SKHA_MaxIndex]
              • Set SKHA_MaxIndex = (SKHA_MaxIndex - 1)
              • Set SKHA_Loop = (SKHA_Loop - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SKHA_MaxIndex Equal to 0
            • Then - Actions
              • Trigger - Turn off (This trigger)
              • Skip remaining actions
            • Else - Actions

  • Actions
    • Custom script: local real x
    • Custom script: local real y
    • Set TempSpellID = 0
    • For each (Integer PS_Loop) from 1 to PS_SpellCount, do (Actions)
      • Loop - Actions
        • Set TempSpellID = PS_SpellNext[TempSpellID]
        • Set PS_Timer[TempSpellID] = (PS_Timer[TempSpellID] - 0.03)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • PS_Timer[TempSpellID] Greater than or equal to 0.00
          • Then - Actions
            • Set TempPoint = (Position of PS_Caster[TempSpellID])
            • Set DR_Point = (Position of PS_Unit[TempSpellID])
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • PS_MaxDistance[TempSpellID] Greater than (Distance between TempPoint and DR_Point)
              • Then - Actions
                • Set DR_Player = (Owner of PS_Unit[TempSpellID])
                • Set DR_Angle = PS_Angle[TempSpellID]
                • Custom script: set udg_DR_UnitType = GetUnitTypeId(udg_PS_Unit[udg_TempSpellID])
                • Trigger - Run DummyRecycler <gen> (checking conditions)
                • Set PS_Counter[TempSpellID] = (PS_Counter[TempSpellID] + 1)
                • Set PS_Number[PS_Counter[TempSpellID]] = DR_Number
                • Custom script: set x = GetUnitX(udg_PS_Unit[udg_TempSpellID]) + udg_PS_Offset[udg_TempSpellID] * Cos(udg_PS_Angle[udg_TempSpellID] * bj_DEGTORAD)
                • Custom script: set y = GetUnitY(udg_PS_Unit[udg_TempSpellID]) + udg_PS_Offset[udg_TempSpellID] * Sin(udg_PS_Angle[udg_TempSpellID] * bj_DEGTORAD)
                • Custom script: call SetUnitX(udg_PS_Unit[udg_TempSpellID],x)
                • Custom script: call SetUnitY(udg_PS_Unit[udg_TempSpellID],y)
              • Else - Actions
            • Set PS_Counter2[TempSpellID] = 0
            • For each (Integer PS_Loop2[0]) from 1 to PS_Counter[TempSpellID], do (Actions)
              • Loop - Actions
                • Set PS_Counter2[TempSpellID] = (PS_Counter2[TempSpellID] + 1)
                • Set TempPoint2 = (Position of DR_Units[PS_Counter2[TempSpellID]])
                • Set TempGroup = (Units within PS_Detect[TempSpellID] of TempPoint2 matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an ally of (Owner of PS_Unit[TempSpellID])) Equal to False) and (((Matching unit) is alive) Equal to True))))
                • Unit Group - Pick every unit in TempGroup and do (Actions)
                  • Loop - Actions
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • ((Picked unit) is in TempGroup2) Equal to False
                      • Then - Actions
                        • Unit - Cause PS_Caster[TempSpellID] to damage (Picked unit), dealing PS_Damage[TempSpellID] damage of attack type Hero and damage type Normal
                        • Unit Group - Add (Picked unit) to TempGroup2
                        • Unit Group - Remove (Picked unit) from TempGroup
                      • Else - Actions
                • Custom script: call RemoveLocation(udg_TempPoint2)
                • Custom script: call DestroyGroup(udg_TempGroup)
                • Custom script: set udg_TempGroup = CreateGroup()
            • Unit Group - Remove all units of TempGroup2 from TempGroup2
            • Custom script: call RemoveLocation(udg_TempPoint)
            • Custom script: call RemoveLocation(udg_DR_Point)
          • Else - Actions
            • Set PS_Counter2[TempSpellID] = 0
            • For each (Integer PS_Loop2[1]) from 1 to PS_Counter[TempSpellID], do (Actions)
              • Loop - Actions
                • Set PS_Counter2[TempSpellID] = (PS_Counter2[TempSpellID] + 1)
                • Set TempInt = PS_Counter2[TempSpellID]
                • Custom script: call DREnd(udg_PS_Number[udg_TempInt])
            • Custom script: call DREnd(udg_PS_Number2[udg_TempSpellID])
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • PS_SpellLast Equal to TempSpellID
              • Then - Actions
                • Set PS_SpellLast = PS_SpellPrev[TempSpellID]
              • Else - Actions
            • Set PS_RecycleStack[PS_RecycleSize] = TempSpellID
            • Set PS_RecycleSize = (PS_RecycleSize + 1)
            • Set PS_SpellNext[PS_SpellPrev[TempSpellID]] = PS_SpellNext[TempSpellID]
            • Set PS_SpellPrev[PS_SpellNext[TempSpellID]] = PS_SpellPrev[TempSpellID]
            • Set PS_SpellCount = (PS_SpellCount - 1)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • PS_SpellCount Equal to 0
              • Then - Actions
                • Trigger - Turn off (This trigger)
              • Else - Actions
 
Last edited:
Level 37
Joined
Jul 22, 2015
Messages
3,485
First off, please use [code=jass][/code] to post Jass/vJass code, not [code][/code] tags. Also, do you not indent your code or is that just a pasting problem with the Hive? If the latter, use the plain text editor (paper + wrench icon on the top right of the message box) when you paste the code.

Second, from what trigger are you calling PSStart from? Also, is TempSpellID used in other triggers that can fire off during the loop?
 
Level 11
Joined
Aug 6, 2009
Messages
697
First off, please use [code=jass][/code] to post Jass/vJass code, not [code][/code] tags. Also, do you not indent your code or is that just a pasting problem with the Hive? If the latter, use the plain text editor (paper + wrench icon on the top right of the message box) when you paste the code.

Second, from what trigger are you calling PSStart from? Also, is TempSpellID used in other triggers that can fire off during the loop?
Sorry, I just started trying to implement JASS with my GUI to make things easier so I can just use 'call *blabla*'. I did not indent my code, I know I should have, but these are very basic functions so I figured I did not have to improve readability. I will fix it now however, and add the trigger that is calling PSStart. TempSpellID is not used in anything else yet, however it should work fine even if it was being used in other things.
 
Level 11
Joined
Aug 6, 2009
Messages
697
Update:I would love if someone could solve this problem, but if you could just confirm that the indexing is right I would love that.However, I have decided to scrap everything here and just try to redo it in MPI.

I redid it in MPI twice with the same problem, except this time, the timer does not seem to mess up. However, the unit group array does not seem to have units in it for the 2nd caster. This means that damage is not applied, and the units are not removed at the end. Yet, it still maintains the beam look, it shoots forward until it hits max distance for both the casters.

I have been trying to get this spell to work for the past 2+ weeks, and am tired of redoing it over and over again, each in a new way. My only and final conclusion, is that something is happening on the JASS side of things in my triggers (convert to custom text). However, since I am a novice to JASS, I cannot troubleshoot the possible problem (If I even am right). So I decided to ask my friend for help in making the spell in JASS. These are my current thoughts on this extremely frustrating problem.

Below are the new triggers in GUI format. Please note, some things may look weird and out of place, but I was just desperate, trying everything I could think of.

  • SuperKamehameha3
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (|cff00ffffR|r)|cff3399ffSuper Kamehameha|r
    • Actions
      • Set TempInt = (Player number of (Owner of (Triggering unit)))
      • Game - Display to (All players) the text: (String(TempInt))
      • Set SKH_Caster[TempInt] = (Triggering unit)
      • Set SKH_Casting[TempInt] = True
      • Set SKH_Timer[TempInt] = 5.35
      • Set SKH_Timer2[TempInt] = 4.10
      • Set SKH_Boolean[TempInt] = True
      • Set SKH_Boolean2[TempInt] = True
      • Set TempPoint = (Position of SKH_Caster[TempInt])
      • Set TempPoint2 = (Target point of ability being cast)
      • Set SKH_Angle[TempInt] = (Angle from TempPoint to TempPoint2)
      • Custom script: call RemoveLocation(udg_TempPoint2)
      • Set TempPoint2 = (TempPoint offset by 20.00 towards ((Facing of SKH_Caster[TempInt]) - 85.00) degrees)
      • Unit - Create 1 KHADummy3 for (Player(TempInt)) at TempPoint2 facing Default building facing degrees
      • Set SKH_Dummy[TempInt] = (Last created unit)
      • Set SKH_Size[TempInt] = 15.00
      • Animation - Change SKH_Dummy[TempInt]'s size to (SKH_Size[TempInt]%, 100.00%, 100.00%) of its original size
      • Custom script: call StartSound(udg_SKH_Sound[udg_TempInt])
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Custom script: call RemoveLocation(udg_TempPoint2)
      • Trigger - Turn on SuperKamehameha3Loop <gen>

  • SuperKamehameha3Loop
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Custom script: local integer i = 0
      • Custom script: set udg_TempInt = 0
      • Custom script: loop
      • Custom script: set i = i + 1
      • Custom script: set udg_TempInt2 = i
      • Custom script: exitwhen i > 12
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SKH_Casting[TempInt2] Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SKH_Timer[TempInt2] Greater than 0.00
            • Then - Actions
              • Set SKH_Timer[TempInt2] = (SKH_Timer[TempInt2] - 0.04)
              • Animation - Play SKH_Caster[TempInt2]'s Spell Channel animation
              • Set SKH_Size[TempInt2] = (SKH_Size[TempInt2] + 2.00)
              • Animation - Change SKH_Dummy[TempInt2]'s size to (SKH_Size[TempInt2]%, 100.00%, 100.00%) of its original size
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SKH_Timer2[TempInt2] Greater than 0.00
                • Then - Actions
                  • Set SKH_Timer2[TempInt2] = (SKH_Timer2[TempInt2] - 0.04)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • SKH_Boolean[TempInt2] Equal to True
                    • Then - Actions
                      • Set SKH_Boolean[TempInt2] = False
                      • Animation - Play SKH_Caster[TempInt2]'s Spell Throw animation
                      • Unit - Remove SKH_Dummy[TempInt2] from the game
                      • Custom script: call StartSound(udg_SKH_Sound2[udg_TempInt2])
                      • Set TempPoint = (Position of SKH_Caster[TempInt2])
                      • Set TempPoint2 = (TempPoint offset by 80.00 towards SKH_Angle[TempInt2] degrees)
                      • Game - Display to (All players) the text: (String(TempInt2))
                      • Unit - Create 1 SKHADummy (Level 5) for (Player(TempInt2)) at TempPoint2 facing SKH_Angle[TempInt2] degrees
                      • Set SKH_Dummy2[TempInt2] = (Last created unit)
                      • Unit Group - Add SKH_Dummy2[TempInt2] to SKH_DummyGroup[TempInt2]
                      • Custom script: call RemoveLocation(udg_TempPoint)
                      • Custom script: call RemoveLocation(udg_TempPoint2)
                    • Else - Actions
                  • Set TempPoint = (Position of SKH_Caster[TempInt2])
                  • Set TempPoint2 = (Position of SKH_Dummy2[TempInt2])
                  • Set TempReal = (Distance between TempPoint and TempPoint2)
                  • Custom script: call RemoveLocation(udg_TempPoint)
                  • Custom script: call RemoveLocation(udg_TempPoint2)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • TempReal Less than or equal to 3000.00
                    • Then - Actions
                      • Set TempPoint = (Position of SKH_Dummy2[TempInt2])
                      • Set TempPoint2 = (TempPoint offset by 80.00 towards SKH_Angle[TempInt2] degrees)
                      • Custom script: call SetUnitX(udg_SKH_Dummy2[udg_TempInt2], GetLocationX(udg_TempPoint2))
                      • Custom script: call SetUnitY(udg_SKH_Dummy2[udg_TempInt2],GetLocationY(udg_TempPoint2))
                      • Unit - Create 1 SKHADummy (Level 5) for (Player(TempInt2)) at TempPoint facing SKH_Angle[TempInt2] degrees
                      • Game - Display to (All players) the text: (String(TempInt2))
                      • Unit Group - Add (Last created unit) to SKH_DummyGroup[TempInt2]
                      • Custom script: call RemoveLocation(udg_TempPoint)
                      • Custom script: call RemoveLocation(udg_TempPoint2)
                    • Else - Actions
                  • Unit Group - Pick every unit in SKH_DummyGroup[TempInt2] and do (Actions)
                    • Loop - Actions
                      • Set TempPoint = (Position of (Picked unit))
                      • Set TempGroup = (Units within 200.00 of TempPoint matching ((((Matching unit) is A structure) Equal to False) or ((((Matching unit) belongs to an ally of (Player(TempInt2))) Equal to False) and ((((Matching unit) is dead) Equal to False) and (((Matching unit) has buff Invuln
                      • Unit Group - Pick every unit in TempGroup and do (Actions)
                        • Loop - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • ((Picked unit) is in TempGroup2) Equal to False
                            • Then - Actions
                              • Unit Group - Add (Picked unit) to TempGroup2
                              • Unit - Cause SKH_Caster[TempInt2] to damage (Picked unit), dealing SKH_Damage[TempInt2] damage of attack type Hero and damage type Normal
                            • Else - Actions
                      • Custom script: call RemoveLocation(udg_TempPoint)
                      • Custom script: call DestroyGroup(udg_TempGroup)
                      • Custom script: set udg_TempGroup = CreateGroup()
                  • Unit Group - Remove all units of TempGroup2 from TempGroup2
                • Else - Actions
                  • Set SKH_Casting[TempInt2] = False
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SKH_Boolean2[TempInt2] Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: test2
              • Set SKH_Boolean2[TempInt2] = False
              • Unit Group - Pick every unit in SKH_DummyGroup[TempInt2] and do (Actions)
                • Loop - Actions
                  • Game - Display to (All players) the text: (Name of (Picked unit))
                  • Unit - Remove (Picked unit) from the game
                  • Unit Group - Remove (Picked unit) from SKH_DummyGroup[TempInt2]
              • Custom script: call DestroyGroup(udg_SKH_DummyGroup[udg_TempInt2])
              • Custom script: set udg_SKH_DummyGroup[udg_TempInt2] = CreateGroup()
            • Else - Actions
          • Set TempInt = 0
          • For each (Integer A) from 1 to 12, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SKH_Boolean2[(Integer A)] Equal to False
                • Then - Actions
                  • Set TempInt = (TempInt + 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • TempInt Equal to 12
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
                • Else - Actions
      • Custom script: endloop

Below are the above triggers in the same order, just converted to custom text.

JASS:
function Trig_SuperKamehameha3_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A009' ) ) then
        return false
    endif
    return true
endfunction

function Trig_SuperKamehameha3_Actions takes nothing returns nothing
    set udg_TempInt = GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))
    call DisplayTextToForce( GetPlayersAll(), I2S(udg_TempInt) )
    set udg_SKH_Caster[udg_TempInt] = GetTriggerUnit()
    set udg_SKH_Casting[udg_TempInt] = true
    set udg_SKH_Timer[udg_TempInt] = 5.35
    set udg_SKH_Timer2[udg_TempInt] = 4.10
    set udg_SKH_Boolean[udg_TempInt] = true
    set udg_SKH_Boolean2[udg_TempInt] = true
    set udg_TempPoint = GetUnitLoc(udg_SKH_Caster[udg_TempInt])
    set udg_TempPoint2 = GetSpellTargetLoc()
    set udg_SKH_Angle[udg_TempInt] = AngleBetweenPoints(udg_TempPoint, udg_TempPoint2)
    call RemoveLocation(udg_TempPoint2)
    set udg_TempPoint2 = PolarProjectionBJ(udg_TempPoint, 20.00, ( GetUnitFacing(udg_SKH_Caster[udg_TempInt]) - 85.00 ))
    call CreateNUnitsAtLoc( 1, 'h00F', ConvertedPlayer(udg_TempInt), udg_TempPoint2, bj_UNIT_FACING )
    set udg_SKH_Dummy[udg_TempInt] = GetLastCreatedUnit()
    set udg_SKH_Size[udg_TempInt] = 15.00
    call SetUnitScalePercent( udg_SKH_Dummy[udg_TempInt], udg_SKH_Size[udg_TempInt], 100, 100 )
    call StartSound(udg_SKH_Sound[udg_TempInt])
    call RemoveLocation(udg_TempPoint)
    call RemoveLocation(udg_TempPoint2)
    call EnableTrigger( gg_trg_SuperKamehameha3Loop )
endfunction

//===========================================================================
function InitTrig_SuperKamehameha3 takes nothing returns nothing
    set gg_trg_SuperKamehameha3 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_SuperKamehameha3, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_SuperKamehameha3, Condition( function Trig_SuperKamehameha3_Conditions ) )
    call TriggerAddAction( gg_trg_SuperKamehameha3, function Trig_SuperKamehameha3_Actions )
endfunction

JASS:
function Trig_SuperKamehameha3Loop_Func007Func001Func003A takes nothing returns nothing
    call DisplayTextToForce( GetPlayersAll(), GetUnitName(GetEnumUnit()) )
    call RemoveUnit( GetEnumUnit() )
    call GroupRemoveUnitSimple( GetEnumUnit(), udg_SKH_DummyGroup[udg_TempInt2] )
endfunction

function Trig_SuperKamehameha3Loop_Func007Func001C takes nothing returns boolean
    if ( not ( udg_SKH_Boolean2[udg_TempInt2] == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_SuperKamehameha3Loop_Func007Func003Func001Func002C takes nothing returns boolean
    if ( not ( udg_TempInt == 12 ) ) then
        return false
    endif
    return true
endfunction

function Trig_SuperKamehameha3Loop_Func007Func003Func001C takes nothing returns boolean
    if ( not ( udg_SKH_Boolean2[GetForLoopIndexA()] == false ) ) then
        return false
    endif
    return true
endfunction

function Trig_SuperKamehameha3Loop_Func007Func004Func001Func003C takes nothing returns boolean
    if ( not ( udg_SKH_Boolean[udg_TempInt2] == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_SuperKamehameha3Loop_Func007Func004Func001Func009C takes nothing returns boolean
    if ( not ( udg_TempReal <= 3000.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func002002003001 takes nothing returns boolean
    return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false )
endfunction

function Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func002002003002001 takes nothing returns boolean
    return ( IsUnitAlly(GetFilterUnit(), ConvertedPlayer(udg_TempInt2)) == false )
endfunction

function Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func002002003002002001 takes nothing returns boolean
    return ( IsUnitDeadBJ(GetFilterUnit()) == false )
endfunction

function Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func002002003002002002 takes nothing returns boolean
    return ( UnitHasBuffBJ(GetFilterUnit(), 'Bvul') == false )
endfunction

function Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func002002003002002 takes nothing returns boolean
    return GetBooleanAnd( Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func002002003002002001(), Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func002002003002002002() )
endfunction

function Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func002002003002 takes nothing returns boolean
    return GetBooleanAnd( Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func002002003002001(), Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func002002003002002() )
endfunction

function Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func002002003 takes nothing returns boolean
    return GetBooleanOr( Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func002002003001(), Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func002002003002() )
endfunction

function Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func003Func001C takes nothing returns boolean
    if ( not ( IsUnitInGroup(GetEnumUnit(), udg_TempGroup2) == false ) ) then
        return false
    endif
    return true
endfunction

function Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func003A takes nothing returns nothing
    if ( Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func003Func001C() ) then
        call GroupAddUnitSimple( GetEnumUnit(), udg_TempGroup2 )
        call UnitDamageTargetBJ( udg_SKH_Caster[udg_TempInt2], GetEnumUnit(), udg_SKH_Damage[udg_TempInt2], ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
    else
    endif
endfunction

function Trig_SuperKamehameha3Loop_Func007Func004Func001Func010A takes nothing returns nothing
    set udg_TempPoint = GetUnitLoc(GetEnumUnit())
    set udg_TempGroup = GetUnitsInRangeOfLocMatching(200.00, udg_TempPoint, Condition(function Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func002002003))
    call ForGroupBJ( udg_TempGroup, function Trig_SuperKamehameha3Loop_Func007Func004Func001Func010Func003A )
    call RemoveLocation(udg_TempPoint)
    call DestroyGroup(udg_TempGroup)
    set udg_TempGroup = CreateGroup()
endfunction

function Trig_SuperKamehameha3Loop_Func007Func004Func001C takes nothing returns boolean
    if ( not ( udg_SKH_Timer2[udg_TempInt2] > 0.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_SuperKamehameha3Loop_Func007Func004C takes nothing returns boolean
    if ( not ( udg_SKH_Timer[udg_TempInt2] > 0.00 ) ) then
        return false
    endif
    return true
endfunction

function Trig_SuperKamehameha3Loop_Func007C takes nothing returns boolean
    if ( not ( udg_SKH_Casting[udg_TempInt2] == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_SuperKamehameha3Loop_Actions takes nothing returns nothing
    local integer i = 0
    set udg_TempInt = 0
    loop
    set i = i + 1
    set udg_TempInt2 = i
    exitwhen i > 12
    if ( Trig_SuperKamehameha3Loop_Func007C() ) then
        if ( Trig_SuperKamehameha3Loop_Func007Func004C() ) then
            set udg_SKH_Timer[udg_TempInt2] = ( udg_SKH_Timer[udg_TempInt2] - 0.04 )
            call SetUnitAnimation( udg_SKH_Caster[udg_TempInt2], "Spell Channel" )
            set udg_SKH_Size[udg_TempInt2] = ( udg_SKH_Size[udg_TempInt2] + 2.00 )
            call SetUnitScalePercent( udg_SKH_Dummy[udg_TempInt2], udg_SKH_Size[udg_TempInt2], 100, 100 )
        else
            if ( Trig_SuperKamehameha3Loop_Func007Func004Func001C() ) then
                set udg_SKH_Timer2[udg_TempInt2] = ( udg_SKH_Timer2[udg_TempInt2] - 0.04 )
                if ( Trig_SuperKamehameha3Loop_Func007Func004Func001Func003C() ) then
                    set udg_SKH_Boolean[udg_TempInt2] = false
                    call SetUnitAnimation( udg_SKH_Caster[udg_TempInt2], "Spell Throw" )
                    call RemoveUnit( udg_SKH_Dummy[udg_TempInt2] )
                    call StartSound(udg_SKH_Sound2[udg_TempInt2])
                    set udg_TempPoint = GetUnitLoc(udg_SKH_Caster[udg_TempInt2])
                    set udg_TempPoint2 = PolarProjectionBJ(udg_TempPoint, 80.00, udg_SKH_Angle[udg_TempInt2])
                    call DisplayTextToForce( GetPlayersAll(), I2S(udg_TempInt2) )
                    call CreateNUnitsAtLoc( 1, 'h00G', ConvertedPlayer(udg_TempInt2), udg_TempPoint2, udg_SKH_Angle[udg_TempInt2] )
                    set udg_SKH_Dummy2[udg_TempInt2] = GetLastCreatedUnit()
                    call GroupAddUnitSimple( udg_SKH_Dummy2[udg_TempInt2], udg_SKH_DummyGroup[udg_TempInt2] )
                    call RemoveLocation(udg_TempPoint)
                    call RemoveLocation(udg_TempPoint2)
                else
                endif
                set udg_TempPoint = GetUnitLoc(udg_SKH_Caster[udg_TempInt2])
                set udg_TempPoint2 = GetUnitLoc(udg_SKH_Dummy2[udg_TempInt2])
                set udg_TempReal = DistanceBetweenPoints(udg_TempPoint, udg_TempPoint2)
                call RemoveLocation(udg_TempPoint)
                call RemoveLocation(udg_TempPoint2)
                if ( Trig_SuperKamehameha3Loop_Func007Func004Func001Func009C() ) then
                    set udg_TempPoint = GetUnitLoc(udg_SKH_Dummy2[udg_TempInt2])
                    set udg_TempPoint2 = PolarProjectionBJ(udg_TempPoint, 80.00, udg_SKH_Angle[udg_TempInt2])
                    call SetUnitX(udg_SKH_Dummy2[udg_TempInt2], GetLocationX(udg_TempPoint2))
                    call SetUnitY(udg_SKH_Dummy2[udg_TempInt2],GetLocationY(udg_TempPoint2))
                    call CreateNUnitsAtLoc( 1, 'h00G', ConvertedPlayer(udg_TempInt2), udg_TempPoint, udg_SKH_Angle[udg_TempInt2] )
                    call DisplayTextToForce( GetPlayersAll(), I2S(udg_TempInt2) )
                    call GroupAddUnitSimple( GetLastCreatedUnit(), udg_SKH_DummyGroup[udg_TempInt2] )
                    call RemoveLocation(udg_TempPoint)
                    call RemoveLocation(udg_TempPoint2)
                else
                endif
                call ForGroupBJ( udg_SKH_DummyGroup[udg_TempInt2], function Trig_SuperKamehameha3Loop_Func007Func004Func001Func010A )
                call GroupRemoveGroup( udg_TempGroup2, udg_TempGroup2 )
            else
                set udg_SKH_Casting[udg_TempInt2] = false
            endif
        endif
    else
        if ( Trig_SuperKamehameha3Loop_Func007Func001C() ) then
            call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_277" )
            set udg_SKH_Boolean2[udg_TempInt2] = false
            call ForGroupBJ( udg_SKH_DummyGroup[udg_TempInt2], function Trig_SuperKamehameha3Loop_Func007Func001Func003A )
            call DestroyGroup(udg_SKH_DummyGroup[udg_TempInt2])
            set udg_SKH_DummyGroup[udg_TempInt2] = CreateGroup()
        else
        endif
        set udg_TempInt = 0
        set bj_forLoopAIndex = 1
        set bj_forLoopAIndexEnd = 12
        loop
            exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
            if ( Trig_SuperKamehameha3Loop_Func007Func003Func001C() ) then
                set udg_TempInt = ( udg_TempInt + 1 )
                if ( Trig_SuperKamehameha3Loop_Func007Func003Func001Func002C() ) then
                    call DisableTrigger( GetTriggeringTrigger() )
                else
                endif
            else
            endif
            set bj_forLoopAIndex = bj_forLoopAIndex + 1
        endloop
    endif
    endloop
endfunction

//===========================================================================
function InitTrig_SuperKamehameha3Loop takes nothing returns nothing
    set gg_trg_SuperKamehameha3Loop = CreateTrigger(  )
    call DisableTrigger( gg_trg_SuperKamehameha3Loop )
    call TriggerRegisterTimerEventPeriodic( gg_trg_SuperKamehameha3Loop, 0.04 )
    call TriggerAddAction( gg_trg_SuperKamehameha3Loop, function Trig_SuperKamehameha3Loop_Actions )
endfunction
 
The problem looks like a error on Blizzard's side and maybe some code limits, think its called OP limit or thread crashing... Not entirely sure however if you switch the movement system to a unit group you should get much better results and turn off the collision detection until a better possibility for detection is posted/found then the indexing should start working again. I didn't spot any errors in the indexing so in my opinion I can confirm it looks clear/good.
 
Level 11
Joined
Dec 19, 2012
Messages
411
Make sure that your group array size of "SKH_DummyGroup" is set to 12 inside the variable editor. And I hope your 2nd caster isn't the same player?(as your trigger is MPI)

Improvement : I would suggest you to use this : Visualize: Dynamic Indexing as your current indexing method is not that effective, even though your indexing method has nothing wrong, but it limited to MPI which a spell usually suppose to be MUI.

And also, there is no need to convert GUI to JASS as it would make the code looks more uglier and harder to read, just remains it as GUI format.
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
1.) Debug all counters in your spell and identify.
2.) Remove all of your DestroyGroup() functions and test if it works properly, if it does then the problem is on destroygroup.
3.) Unit groups array is only the problem? Allocate it just like what you did from the other data members onCast ( casting trigger ) dunno why you'd use that unit group array onLoop without creating it on a casting trigger. Before you create you must check if it is nulled. Some of the CreateGroup() functions are not needed if they are already declared by a global variable ( tempgroup )

If none of them work then try to attach a demo map to let us easily identify the problem.

Edit: MPI is not generally recommended for this type of spells, use the Linked List or what they said.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Oh sorry. I never saw that you updated :p it seems others were to get your answer though.

And I hope your 2nd caster isn't the same player?(as your trigger is MPI)
MPI is not generally recommended for this type of spells
This is definitely the issue then. Linked list worked because it made your spell MUI, where as your previous setup made it MPI (meaning only once per player).

there is no need to convert GUI to JASS as it would make the code looks more uglier and harder to read, just remains it as GUI format.
This ^
 
Level 11
Joined
Aug 6, 2009
Messages
697
I used both Dynamic Indexing and Linked Lists, but the same problem occurs. Yes, the other unit is owned by a different player.

Make sure that your group array size of "SKH_DummyGroup" is set to 12 inside the variable editor.

I have never heard of this being a problem. I just changed it to 12 and it worked. You are my hero.

1.) Debug all counters in your spell and identify.
2.) Remove all of your DestroyGroup() functions and test if it works properly, if it does then the problem is on destroygroup.

I have done all this before in my long 2-3 weeks of making this spell/system work, it did not fix anything.

And also, there is no need to convert GUI to JASS as it would make the code looks more uglier and harder to read, just remains it as GUI format.

I converted it to JASS because I suspected it might've been a problem on Blizzard's side since I could not come up with anything else, but I cannot troubleshoot JASS, I am a novice.

Some of the CreateGroup() functions are not needed if they are already declared by a global variable ( tempgroup )

I do have to recreate them otherwise it will not work in my spell 100% of the time. If I destroy the group, I would have to recreate it, global or not. If I did not recreate the group, it would not be able to detect any unit that has been in the group at least once.

Before you create you must check if it is nulled.

I did this before when I was making a spell, but I recall it not working 100% of the time for some reason. I could destroy the group, but then it would not recreate. It would look something like:

JASS:
if udg_SomeGroup[udg_TempInt] == null then
set udg_SomeGroup[udg_TempInt] = CreateGroup()
endif

For some reason, the above code did not work 100% of the time, but I will return to doing it unless it doesn't work again :/.

MPI is not generally recommended for this type of spells, use the Linked List or what they said.

Improvement : I would suggest you to use this : Visualize: Dynamic Indexing as your current indexing method is not that effective, even though your indexing method has nothing wrong, but it limited to MPI which a spell usually suppose to be MUI.

I did use Linked Lists and Dynamic Indexing as said above, if my Dynamic Indexing is not good, then blame the person's tutorial I took it from :/. I think Dynamic Indexing is fine the way he did it, however ( makes sense to me at least :p ). I am using MPI to make things simpler for me, I plan to make a bunch of spells that combo into each other, and the way I see it, MPI makes it a whole lot easier on my life.

Oh sorry. I never saw that you updated :p it seems others were to get your answer though.

No problem, I thought you hated me because after re-reading some of the things I said, I realized some of it may have come off as hostile or insulting, so I am sorry for that.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
I have never heard of this being a problem. I just changed it to 12 and it worked. You are my hero.
Unit group arrays are initialized weird. The default size is 1, which means that only indexes 0 and 1 will be created on map init. Any other indexes before that will be null. The same applies to timers and... other things I can't remember from the top of my head. It's best to just leave the default size as is and just check to see if the unit group is null before creating it.
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
I do have to recreate them otherwise it will not work in my spell 100% of the time. If I destroy the group, I would have to recreate it, global or not. If I did not recreate the group, it would not be able to detect any unit that has been in the group at least once.

^ for the dummy group that have array its okay to recreate them but im pointing at the temp group variable, you see that you already created the tempgroup by using the matching filters so you can remove the ( set tempgroup = CreateGroup() ) line after the destroygroup(tempgroup).
 
Level 11
Joined
Aug 6, 2009
Messages
697
^ for the dummy group that have array its okay to recreate them but im pointing at the temp group variable, you see that you already created the tempgroup by using the matching filters so you can remove the ( set tempgroup = CreateGroup() ) line after the destroygroup(tempgroup).
I am saying even with the filters it does not work 100%, so I have to destroy then recreate. Unless I am doing something wrong, that's the problem I get sometimes.
 
Status
Not open for further replies.
Top