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

Attach an integer or variable to a unit?

Status
Not open for further replies.
Level 8
Joined
Jul 29, 2010
Messages
319
I've tried using custom values like in this trigger.
but it never seems to actually change the units custom value, through hours of testing I'm certain it isn't my trigger that is responsible.
  • Damage Matrix
    • Events
    • Conditions
    • Actions
      • Set Y[2] = 1
      • Set Z[2] = 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
              • (Base Damage of Alpha[Y[2]] for weapon index 1) Greater than (Base Damage of Alpha[Z[2]] for weapon index 1)
            • Then - Actions
              • Set Y[2] = (Y[2] + 1)
              • Set Z[2] = 1
              • Special Effect - Create a special effect attached to the overhead of Alpha[Y[2]] using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • RecievedPriorityPoint[2] Equal to False
                • Then - Actions
                  • Unit - Set the custom value of Alpha[Y[2]] to ((Custom value of Alpha[Y[2]]) + 1)
                • Else - Actions
            • Else - Actions
              • Set Z[2] = (Z[2] + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Z[2] Greater than or equal to ActivePlayerUnits
                • Then - Actions
                  • Set Z[2] = 1
                  • Set Y[2] = (Y[2] + 1)
                • Else - Actions
Basically i need an integer or value to be "attached" to the unit so that later triggers can check this units "value" essentially, but i'm struggling to do so.
  • 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
                  • -------- Amount Of "Priority" Added to unit --------
                  • Set Value = (Value + 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
As i previously stated, custom values don't seem to work, Using this trigger to display the units Custom Value ingame always returns a 0 even though it should be +1
  • Display unit custom value
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
    • Actions
      • Set Selectedunit = (Triggering unit)
      • Game - Display to (All players) the text: (String((Custom value of Selectedunit)))
All help is incredibly appreciated :D

EDIT: For refence these are the triggers responsible for assigning unit Variables
  • 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[1]] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
  • Variables
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Set U[1] = 1
      • Set Z[2] = 1
      • Set REGIONS[1] = Region 000 Copy 7 <gen>
      • Set REGIONS[2] = Region 000 Copy 6 <gen>
      • Set REGIONS[3] = Region 000 Copy 5 <gen>
      • Set REGIONS[4] = Region 000 Copy 4 <gen>
      • Set REGIONS[5] = Region 000 Copy 3 <gen>
      • Set REGIONS[6] = Region 000 <gen>
      • Set REGIONS[7] = Region 000 Copy <gen>
      • Set REGIONS[8] = Region 000 Copy 2 <gen>
      • Set ActivePlayers = (Number of players in (All players controlled by a User player))
      • 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 = (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 12
Joined
Mar 24, 2011
Messages
1,082
Your variable naming does not help decipher the code...
I am not entirely sure you understand how loops work either...

You should look up a tutorial on indexing.

Edit// Ignore this bit, I got confused by your variable naming. ActivePlayerUnits >>> ActivePlayerUnitsCount
Your initialization triggers (0.01 & 0.05 sek elapsed) are registering the wrong things on the wrong places.
This particular part:
  • For each (Integer A) from 1 to ActivePlayers, do (Actions)
    • empty.gif
      line.gif
      joinbottomminus.gif
      actions.gif
      Loop - Actions
      • empty.gif
        line.gif
        empty.gif
        join.gif
        set.gif
        Set U[4] = (U[4] + 1)
      • empty.gif
        line.gif
        empty.gif
        joinbottom.gif
        playergroup.gif
        Player Group - Add (Player(U[4])) to PlayersPlaying
  • empty.gif
    joinminus.gif
    playergroup.gif
    Player Group - Pick every player in PlayersPlaying and do (Actions)
    • empty.gif
      line.gif
      joinbottomminus.gif
      actions.gif
      Loop - Actions
      • empty.gif
        line.gif
        empty.gif
        joinbottom.gif
        set.gif
        Set ActivePlayerUnits = (ActivePlayerUnits + (Number of units in (Units owned by (Picked player))))

regards
-Ned
 
Level 8
Joined
Jul 29, 2010
Messages
319
Your variable naming does not help decipher the code...
I am not entirely sure you understand how loops work either...

You should look up a tutorial on indexing.

Edit// Ignore this bit, I got confused by your variable naming. ActivePlayerUnits >>> ActivePlayerUnitsCount
Your initialization triggers (0.01 & 0.05 sek elapsed) are registering the wrong things on the wrong places.
This particular part:

regards
-Ned
If i was able to use the units custom value than i'd be able to work this all out myself, i just can't figure out why custom value isn't working :/
 
Status
Not open for further replies.
Top