• 🏆 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!

Variable returning wrong value

Status
Not open for further replies.
Level 8
Joined
Jul 29, 2010
Messages
319
'ActivePlayerUnits' should be giving me a number equal to the number of units on the map owned by friendly players (including myself) but it always returns 0, what's exactly am I doing wrong? all help is appreciated :D
  • For each (Integer A) from 1 to ActivePlayers, do (Actions)
    • Loop - Actions
      • Set U[4] = (U[4] + 1)
      • Player Group - Add (Player(U[4])) to PlayersPlaying
  • Player Group - Pick every player in PlayersPlaying and do (Actions)
    • Loop - Actions
      • Set ActivePlayerUnits = (Number of units in (Units owned by (Picked player)))
  • Game - Display to (All players) the text: (Active Players = + (String(ActivePlayers)))
  • Game - Display to (All players) the text: (Players Playing= + (String((Number of players in (All players controlled by a User player)))))
  • Game - Display to (All players) the text: (Active Units = + (String(ActivePlayerUnits)))
 
Level 8
Joined
Jul 29, 2010
Messages
319
Do this:
  • Set ActivePlayerUnits = ActivePlayerUnits + (Number of units in (Units owned by (Picked player)))
Currently ActivePlayerUnits is being overwritten every loop iteration, not added to.
Thank you for pointing that out, i'm hoping you could help me with these triggers also.

This trigger is responsible for giving every unit on the map a variable
  • Player Units Index
    • Events
      • Time - Elapsed game time is 0.05 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to ActivePlayers, do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units owned by (Player(U[1]))) and do (Actions)
            • Loop - Actions
              • For each (Integer B) from 1 to ActivePlayerUnits, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Picked unit) Equal to Alpha[Y[1]]
                          • (Picked unit) Equal to Alpha[Z[1]]
                    • Then - Actions
                    • Else - Actions
                      • Set Alpha[Y[1]] = (Picked unit)
                      • Set Alpha[Z[1]] = (Picked unit)
                      • Set U[2] = (U[2] + 1)
                      • Set U[1] = (U[1] + 1)
                      • Floating Text - Create floating text that reads (String(U[2])) above Alpha[Y[U[2]]] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
This trigger is supposed to act as a filter, by checking all unit variables to see which has the highest maximum HP, and then add a custom point value, however, I've found that the custom value will not increase and i can't quite fiure out why. Probably doesn't help that I haven't slept for 36 hours :/
  • Health Matrix
    • Events
    • Conditions
    • Actions
      • Set Y[1] = 1
      • Set Z[1] = 1
      • For each (Integer A) from 1 to ActivePlayerUnits, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Max HP of Alpha[Y[1]]) Greater than (Max HP of Alpha[Z[1]])
            • Then - Actions
              • Set Y[1] = (Y[1] + 1)
              • Set Z[1] = 1
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • RecievedPriorityPoint[1] Equal to False
                • Then - Actions
                  • Unit - Set the custom value of Alpha[Y[1]] to ((Custom value of Alpha[Y[1]]) + 1)
                • Else - Actions
            • Else - Actions
              • Set Z[1] = (Z[1] + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Z[1] Greater than or equal to ActivePlayerUnits
                • Then - Actions
                  • Set Z[1] = 1
                  • Set Y[1] = (Y[1] + 1)
                • Else - Actions
 
Status
Not open for further replies.
Top