• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Trigger] Indexing in my spells bugs

Status
Not open for further replies.
Level 6
Joined
May 27, 2009
Messages
94
Hello I would like some help for two spells I'm making which I've attempted to learn indexing for due to the fact I would like the spell to be able to stack.
But every time I've attempted I've ran into a couple of problems

  • Ghost of the past
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Ghost of the past10
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GOTP_INDEX Equal to 0
        • Then - Actions
          • Trigger - Turn on Ghost of the past Copy <gen>
        • Else - Actions
      • Set GOTP_INDEX = (GOTP_INDEX + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GOTP_INDEX Greater than GOTP_INDEXMAX
        • Then - Actions
          • Set GOTP_INDEX2[GOTP_INDEX] = GOTP_INDEX
          • Set GOTP_INDEXMAX = GOTP_INDEX
        • Else - Actions
      • Set GOTP_INDEX3 = GOTP_INDEX2[GOTP_INDEX]
      • Set GOTP_Caster[GOTP_INDEX3] = (Triggering unit)
      • Set GOTP_target[GOTP_INDEX3] = (Target unit of ability being cast)
      • Set GOTP_time_between_ghost_summon[GOTP_INDEX3] = 50
      • Set GOTP_summon_ammount[GOTP_INDEX3] = (1 + (2 x (Level of Ghost of the past10 for (Triggering unit))))
      • Game - Display to (All players) the text: (String(GOTP_INDEX))
      • Game - Display to (All players) the text: (String(GOTP_summon_ammount[GOTP_Loop]))
  • Ghost of the past Copy
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer GOTP_Loop) from 1 to GOTP_INDEX, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: (String(GOTP_Loop))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GOTP_summon_ammount[GOTP_Loop] Greater than 0
            • Then - Actions
              • Set GOTP_timer_integer[GOTP_Loop] = (GOTP_timer_integer[GOTP_Loop] + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • GOTP_time_between_ghost_summon[GOTP_Loop] Equal to GOTP_timer_integer[GOTP_Loop]
                • Then - Actions
                  • Set GOTP_summon_ammount[GOTP_Loop] = (GOTP_summon_ammount[GOTP_Loop] - 1)
                  • Game - Display to (All players) the text: (String(GOTP_summon_ammount[GOTP_Loop]))
                  • Set GOTP_location = (Position of GOTP_target[GOTP_Loop])
                  • Unit - Create 1 Ghost of the past for (Owner of GOTP_Caster[GOTP_Loop]) at GOTP_location facing Default building facing degrees
                  • Unit - Order (Last created unit) to Attack GOTP_target[GOTP_Loop]
                  • Set GOTP_timer_integer[GOTP_Loop] = 0
                  • Custom script: call RemoveLocation(udg_GOTP_location)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • GOTP_summon_ammount[GOTP_Loop] Equal to 0
                    • Then - Actions
                      • Set GOTP_INDEX2[GOTP_INDEX] = GOTP_INDEX2[GOTP_INDEX]
                      • Set GOTP_INDEX2[GOTP_INDEX] = GOTP_Loop
                      • Set GOTP_INDEX = (GOTP_INDEX - 1)
                      • Game - Display to (All players) the text: (String(GOTP_INDEX))
                    • Else - Actions
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • GOTP_INDEX Less than or equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions


  • Katon Fire bullet Release
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Katon: Fire Bullet Release
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • KFBR_index_size Equal to 0
        • Then - Actions
          • Trigger - Turn on Katon Fire Bullet Release LOOP2 <gen>
        • Else - Actions
      • Set KFBR_index_size = (KFBR_index_size + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • KFBR_index_size Greater than KFBR_maxsize
        • Then - Actions
          • Set KFBR_index[KFBR_index_size] = KFBR_index_size
          • Set KFBR_maxsize = KFBR_index_size
        • Else - Actions
      • Set KFBR_indexy3 = KFBR_index[KFBR_index_size]
      • Set KFBR_caster[KFBR_indexy3] = (Triggering unit)
      • Set KFBR_target[KFBR_indexy3] = (Target unit of ability being cast)
      • Set KFBR_damage[KFBR_indexy3] = ((Real((Intelligence of (Triggering unit) (Include bonuses)))) x (0.25 + (0.25 x (Real((Level of Katon: Fire Bullet Release for (Triggering unit)))))))
      • Set KFBR_ammount[KFBR_indexy3] = 5
  • Katon Fire Bullet Release LOOP2
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • For each (Integer KFBR_loop) from 1 to KFBR_index_size, do (Actions)
        • Loop - Actions
          • Set KFBR_ammount[KFBR_loop] = (KFBR_ammount[KFBR_loop] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • KFBR_ammount[KFBR_loop] Greater than 0
            • Then - Actions
              • Set KFBR_point_Copy = (Position of KFBR_target[KFBR_loop])
              • Set KFBR_point = (Position of KFBR_caster[KFBR_loop])
              • Unit - Create 1 Katon: Fire Bullet Release for (Owner of KFBR_caster[KFBR_loop]) at KFBR_point facing KFBR_point_Copy
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • KFBR_index_size_Copy Equal to 0
                • Then - Actions
                  • Trigger - Turn on Katon Fire Bullet Release LOOP1 <gen>
                • Else - Actions
              • Set KFBR_index_size_Copy = (KFBR_index_size_Copy + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • KFBR_index_size_Copy Greater than KFBR_maxsize_Copy
                • Then - Actions
                  • Set KFBR_index_Copy[KFBR_index_size_Copy] = KFBR_index_size_Copy
                  • Set KFBR_maxsize_Copy = KFBR_index_size_Copy
                • Else - Actions
              • Set KFBR_indexy3 = KFBR_index_Copy[KFBR_index_size_Copy]
              • Set KFBR_missle[KFBR_indexy3] = (Last created unit)
              • Set KFBR_caster_Copy[KFBR_indexy3] = KFBR_caster[KFBR_loop]
              • Set KFBR_target_Copy[KFBR_indexy3] = KFBR_target[KFBR_loop]
              • Set KFBR_damage_Copy[KFBR_indexy3] = KFBR_damage[KFBR_loop]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • KFBR_ammount[KFBR_loop] Equal to 0
            • Then - Actions
              • Set KFBR_index[KFBR_index_size] = KFBR_index[KFBR_index_size]
              • Set KFBR_index[KFBR_loop] = KFBR_index[KFBR_loop]
              • Set KFBR_maxsize = (KFBR_maxsize - 1)
              • Set KFBR_index_size = (KFBR_index_size - 1)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • KFBR_index_size Equal to 0
            • Then - Actions
              • Trigger - Turn off (This trigger)
            • Else - Actions
  • Katon Fire Bullet Release LOOP1
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer KFBR_loop_Copy) from 1 to KFBR_index_size_Copy, do (Actions)
        • Loop - Actions
          • Set KFBR_point = (Position of KFBR_missle[KFBR_loop_Copy])
          • Set KFBR_point_Copy = (Position of KFBR_target_Copy[KFBR_loop_Copy])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between KFBR_point and KFBR_point_Copy) Greater than or equal to 15.00
            • Then - Actions
              • Set KFBR_point_Copy_Copy = (KFBR_point offset by 15.00 towards (Angle from KFBR_point to KFBR_point_Copy) degrees)
              • Unit - Move KFBR_missle[KFBR_loop_Copy] instantly to KFBR_point_Copy_Copy
              • Custom script: call RemoveLocation(udg_KFBR_point_Copy_Copy)
            • Else - Actions
              • Unit - Kill KFBR_missle[KFBR_loop_Copy]
              • Unit - Cause KFBR_caster_Copy[KFBR_loop_Copy] to damage KFBR_target_Copy[KFBR_loop_Copy], dealing KFBR_damage_Copy[KFBR_loop_Copy] damage of attack type Spells and damage type Normal
              • Set KFBR_index_Copy[KFBR_index_size_Copy] = KFBR_index_Copy[KFBR_index_size_Copy]
              • Set KFBR_maxsize_Copy = (KFBR_maxsize_Copy - 1)
              • Set KFBR_index_size_Copy = (KFBR_index_size_Copy - 1)
          • Custom script: call RemoveLocation(udg_KFBR_point)
          • Custom script: call RemoveLocation(udg_KFBR_point_Copy)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • KFBR_index_size_Copy Equal to 0
            • Then - Actions
              • Trigger - Turn off (This trigger)
            • Else - Actions

Thanks in advance.
 
thats an overkill of variables. Its taking most of my brain power to process why you have so many useless index variables.
Edit1: Well ill tell you this neither of those are MUI
Edit2: If no one fixes it can you post the map, id like to see for myself whats wrong with it exactly through trigger editor.
 
here you are a good example for indexing
first set the maximum array value, try to set it to a proper value around 4-5.
  • Init
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Ability
    • Actions
      • Set Get = False
      • For each (Integer A) from 1 to Max, do (Actions) [loop till the maximum size given in an init trigger]
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Get Equal to False
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Recycle[(Integer A)] Equal to True [checks if the integer A slot is free]
                • Then - Actions
                  • Set Index = (Integer A)
                  • Set Get= True [with this the trigger only choose the first free slot]
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Integer A) Equal to Max
                    • Then - Actions
                      • Set Max = (Max + 1) [if the current size is not enought it increases it]
                      • Set Recycle[Max] = True
                    • Else - Actions
            • Else - Actions
      • Set Caster[Index] = (Triggering unit)
      • Set Timer[Index] = (2.00 + (Real((Level of Ability for Caster[Index]))))
      • Set Etc.... [other things you want to store example locations or damage]
      • Set Has[Index] = True [this will check if the trigger still have to run for that unit]
      • Set Count = (Count + 1) [counts the number of units casted the spell]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Loop <gen>
        • Else - Actions
  • Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Integer) from 1 to Max, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Has[Integer] Equal to True
            • Then - Actions
              • [Things you want to do]
              • Set Has[Index] = False
              • Set Count = (Count - 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Count Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
 
Status
Not open for further replies.
Back
Top