[Trigger] Array Integer Change

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).
 
Level 3
Joined
May 7, 2009
Messages
21
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
 
Level 8
Joined
Aug 3, 2008
Messages
391
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.
 
Top