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

Variables bug

Status
Not open for further replies.
Level 2
Joined
May 15, 2019
Messages
14
Hello I've created a variable that is supposed to do a simple multiplication but when the orange player is playing it makes a mistake.

I've looked at all my other triggers and nothing seems to conflict with the orange player.

Here are the two ways I tried to do the math :

  • Setvariables
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players matching (((Matching player) slot status) Equal to Is playing).) and do (Set VariableSet player[1] = (Player number of (Picked player)))
      • Set VariableSet Creep_amount[2] = (30 x player[1])
  • Setvariables
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players matching (((Matching player) slot status) Equal to Is playing).) and do (Set VariableSet Creep_amount[2] = (30 x (Player number of (Picked player))))
The thing is that it's working perfectly except when orange is here.
 
Level 2
Joined
May 15, 2019
Messages
14
Solved it !

I did an addition instead :

  • Setvariables
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 1 (Red) slot status) Equal to Is playing
        • Then - Actions
          • Set VariableSet Creep_amount[2] = (Creep_amount[2] + 30)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 2 (Blue) slot status) Equal to Is playing
        • Then - Actions
          • Set VariableSet Creep_amount[2] = (Creep_amount[2] + 30)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 3 (Teal) slot status) Equal to Is playing
        • Then - Actions
          • Set VariableSet Creep_amount[2] = (Creep_amount[2] + 30)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 4 (Purple) slot status) Equal to Is playing
        • Then - Actions
          • Set VariableSet Creep_amount[2] = (Creep_amount[2] + 30)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 5 (Yellow) slot status) Equal to Is playing
        • Then - Actions
          • Set VariableSet Creep_amount[2] = (Creep_amount[2] + 30)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 6 (Orange) slot status) Equal to Is playing
        • Then - Actions
          • Set VariableSet Creep_amount[2] = (Creep_amount[2] + 30)
        • Else - Actions
  • [/trigger[/spoiler]
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Something like this should work:
  • Actions
    • Set VariableSet TempForce = (All players matching ((((Matching player) slot status) Equal to Is playing) and (((Matching player) controller) Equal to User)).)
    • Set VariableSet Creep_Amount = (30 x (Number of players in TempForce))
    • Custom script: call DestroyForce(udg_TempForce)
TempForce + the Custom script is used to prevent a memory leak.

Whenever you do something like "All players matching conditions..." you're creating a Player Group that will remain in the game's memory until you manually destroy it. It's important to get rid of it since it will help free up the game's memory and thus improve map performance. A minor leak here and there is not the end of the world, but you should definitely be on top of them because there are situations in which you could create A LOT of memory leaks.
 
Last edited:
Level 24
Joined
Jun 26, 2020
Messages
1,852
I'm not sure if you get noticed but do you know what means "Player Number"? Because I believe you think is the number of players in a group, but is not, is the position on the list of the players, Player 1 red, Player 2 blue, Player 3 teal, etc. When you use "Pick every player in group" and set your number to "Player Number of picked Player" you are constantly changing the number to the number of that players until the last of that group and your variable stays with the last value.
 
Status
Not open for further replies.
Top