• 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] Array Integer Change

Status
Not open for further replies.
Level 3
Joined
May 7, 2009
Messages
21
In the TD I'm working on, each player has 5 towers. To keep track of which tower has accomplished which requirements for a CustomSkill, they are essentially booleans:

EnabledCustomSkill1[PlayerNumber + 1] = True

So, basically

Tower 1 = [PlayerNumber + 1]
Tower 2 = [PlayerNumber + 2]
Tower 3 = [PlayerNumber + 3]
Tower 4 = [PlayerNumber + 4]
Tower 5 = [PlayerNumber + 5]

So my question is, is there an easy way to change all of the "[PlayerNumber + 1]" in my triggers to "[PlayerNumber + 2/3/4/5]" for when I copy/paste the triggers for the other towers? Gettin close to done with the triggers for the first tower and would rather not have to go through and manually change each one (there's an asston of em). Also, I don't know JASS (just in case that's an issue).
 
No problem:

  • Red Squire 1 Copy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Ability being cast) Equal to Squire ) and ((Triggering unit) Equal to SetRed1)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • EnabledSquire8[((Player number of (Triggering player)) + 1)] Equal to True
        • Then - Actions
          • Unit - Replace (Triggering unit) with a Squire (Mastered) using The old unit's relative life and mana
          • Set SetRed1 = (Last replaced unit)
          • Selection - Select (Last replaced unit)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • EnabledSquire7[((Player number of (Triggering player)) + 1)] Equal to True
            • Then - Actions
              • Unit - Replace (Triggering unit) with a Squire (Level 7) using The old unit's relative life and mana
              • Set SetRed1 = (Last replaced unit)
              • Selection - Select (Last replaced unit)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • EnabledSquire6[((Player number of (Triggering player)) + 1)] Equal to True
                • Then - Actions
                  • Unit - Replace (Triggering unit) with a Squire (Level 6) using The old unit's relative life and mana
                  • Set SetRed1 = (Last replaced unit)
                  • Selection - Select (Last replaced unit)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • EnabledSquire5[((Player number of (Triggering player)) + 1)] Equal to True
                    • Then - Actions
                      • Unit - Replace (Triggering unit) with a Squire (Level 5) using The old unit's relative life and mana
                      • Set SetRed1 = (Last replaced unit)
                      • Selection - Select (Last replaced unit)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • EnabledSquire4[((Player number of (Triggering player)) + 1)] Equal to True
                        • Then - Actions
                          • Unit - Replace (Triggering unit) with a Squire (Level 4) using The old unit's relative life and mana
                          • Set SetRed1 = (Last replaced unit)
                          • Selection - Select (Last replaced unit)
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • EnabledSquire3[((Player number of (Triggering player)) + 1)] Equal to True
                            • Then - Actions
                              • Unit - Replace (Triggering unit) with a Squire (Level 3) using The old unit's relative life and mana
                              • Set SetRed1 = (Last replaced unit)
                              • Selection - Select (Last replaced unit)
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • EnabledSquire2[((Player number of (Triggering player)) + 1)] Equal to True
                                • Then - Actions
                                  • Unit - Replace (Triggering unit) with a Squire (Level 2) using The old unit's relative life and mana
                                  • Set SetRed1 = (Last replaced unit)
                                  • Selection - Select (Last replaced unit)
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • EnabledSquire1[((Player number of (Triggering player)) + 1)] Equal to True
                                    • Then - Actions
                                      • Unit - Replace (Triggering unit) with a Squire (Level 1) using The old unit's relative life and mana
                                      • Set SetRed1 = (Last replaced unit)
                                      • Selection - Select (Last replaced unit)
                                    • Else - Actions
                                      • Do nothing
Thanks again
 
First, make a unit-type array variable. Should look like this:
  • Actions
    • Set Squire[1] = Squire (Level 1)
    • Set Squire[2] = Squire (Level 2)
    • Set Squire[3] = Squire (Level 3)
    • Set Squire[4] = Squire (Level 4)
    • Set Squire[5] = Squire (Level 5)
    • Set Squire[6] = Squire (Level 6)
    • Set Squire[7] = Squire (Level 7)
    • Set Squire[8] = Squire (Mastered)
Then apply this trigger:

  • Red Squire
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Ability being cast) Equal to Squire) and ((Triggering unit) Equal to SetRed1)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Custom value of (Triggering unit)) Less than 1
        • Then - Actions
          • Unit - Set the custom value of (Triggering unit) to 1
        • Else - Actions
          • Unit - Set the custom value of (Triggering unit) to ((Custom value of (Triggering unit)) + 1)
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of (Triggering unit)) Equal to (Integer A)
            • Then - Actions
              • Unit - Replace (Triggering unit) with a Squire[(Integer A)] using The old unit's relative life and mana
              • Set SetRed = (Last replaced unit)
              • Selection - Select (Last replaced unit)
            • Else - Actions


Try. If it fails, then I don't know.
 
Status
Not open for further replies.
Back
Top