• 🏆 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] Replace unit + variables + loops

Status
Not open for further replies.
Level 3
Joined
May 7, 2009
Messages
21
I'm making a TD based off of Final Fantasy Tactics. The general idea is you get 5 towers and each start off at one of two classes then as you upgrade, more classes become available, yadda yadda yadda. But, in order to keep it so each tower has to fulfill requirements for a new class (example: Player 3's Tower 2 has upgraded to Monk Level 3, so it can change its class to Geomancer Level 1, but Player 3's Towers 1, 3, 4, and 5 are only Monk levels 1 and 2 so therefore cannot upgrade to the Geomancer class yet), I've made a big list of variables that are constantly being checked.

Partial example for changing Tower 1 to the Archer Job Class:

  • Change Archer 1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Archer
      • (Triggering unit) Equal to Tower1[(Player number of (Triggering player))]
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • EnabledArcher8[(((Player number of (Triggering player)) x 5) - 4)] Equal to True
        • Then - Actions
          • Unit - Replace (Triggering unit) with a Archer (Mastered) using The old unit's relative life and mana
          • Set Tower1[(Player number of (Triggering player))] = (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
              • EnabledArcher7[(((Player number of (Triggering player)) x 5) - 4)] Equal to True
            • Then - Actions
              • Unit - Replace (Triggering unit) with a Archer (Level 7) using The old unit's relative life and mana
              • Set Tower1[(Player number of (Triggering player))] = (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
                  • EnabledArcher6[(((Player number of (Triggering player)) x 5) - 4)] Equal to True
                • Then - Actions
                  • Unit - Replace (Triggering unit) with a Archer (Level 6) using The old unit's relative life and mana
                  • Set Tower1[(Player number of (Triggering player))] = (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
                      • EnabledArcher5[(((Player number of (Triggering player)) x 5) - 4)] Equal to True
                    • Then - Actions
                      • Unit - Replace (Triggering unit) with a Archer (Level 5) using The old unit's relative life and mana
                      • Set Tower1[(Player number of (Triggering player))] = (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
                          • EnabledArcher4[(((Player number of (Triggering player)) x 5) - 4)] Equal to True
                        • Then - Actions
                          • Unit - Replace (Triggering unit) with a Archer (Level 4) using The old unit's relative life and mana
                          • Set Tower1[(Player number of (Triggering player))] = (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
                              • EnabledArcher3[(((Player number of (Triggering player)) x 5) - 4)] Equal to True
                            • Then - Actions
                              • Unit - Replace (Triggering unit) with a Archer (Level 3) using The old unit's relative life and mana
                              • Set Tower1[(Player number of (Triggering player))] = (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
                                  • EnabledArcher2[(((Player number of (Triggering player)) x 5) - 4)] Equal to True
                                • Then - Actions
                                  • Unit - Replace (Triggering unit) with a Archer (Level 2) using The old unit's relative life and mana
                                  • Set Tower1[(Player number of (Triggering player))] = (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
                                      • EnabledArcher1[(((Player number of (Triggering player)) x 5) - 4)] Equal to True
                                    • Then - Actions
                                      • Unit - Replace (Triggering unit) with a Archer (Level 1) using The old unit's relative life and mana
                                      • Set Tower1[(Player number of (Triggering player))] = (Last replaced unit)
                                      • Selection - Select (Last replaced unit)
                                    • Else - Actions
                                      • Game - Display to Player 1 (Red), at offset (0.00, 0.00) the text: The Archer Job Clas...
Now, normally I would just have a variable for each Tower+Level, and use a boolean to check if, say,
  • Conditions - Archer5 [Player Number of (Triggering Player)] = True
with a total array number of 8 (8 players for the map), but since each player's 5 towers have different requirements, i have a total number for each array of 40 (8 players x 5 towers). Now, in order to check, as you can see from the example trigger, it's
  • Conditions - EnabledArcher5[(((Player number of (Triggering player)) x 5) - 4)] Equal to True
for Tower 1, a separate trigger for Tower 2:
  • Conditions - EnabledArcher5[(((Player number of (Triggering player)) x 5) - 3)] Equal to True
Tower 3
  • Conditions - EnabledArcher5[(((Player number of (Triggering player)) x 5) - 2)] Equal to True
Etc.

Basically, my question is, does anyone have any advice on how to implement a loop system to cut down these enormous triggers? Not to mention having to make 5 of each? Don't get me wrong, so far everything works without a hitch, but it's taking an assload of time. I haven't been able to figure out a loop system because there's 40 towers but only 8 levels per tower, so I can't make IntegerA match up. Hmmmm.... as I'm writing this... maybe IntegerA divided by 5 might work somewhere....
 
Status
Not open for further replies.
Top