• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] Player Not Equal to Is Playing <-- This does not seem to work properly.

Level 2
Joined
Dec 12, 2023
Messages
5
Hi, I want a simple trigger that at the start of the game removes any units of a player that is not playing.

I have this trigger but it does not work, it seems the logic is very straight forward so I am confused on what's happening.
The players are "User" and so I want to clean up their units if that slot is not filled.

Thanks in advance!

  • Events
    • Time - Elapsed game time is 2.00 seconds
  • Actions
    • Player Group - Pick every player in (All players) and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Picked player) slot status) Not equal to Is playing
          • Then - Actions
            • Unit Group - Pick every unit in (Units in (Playable map area) owned by (Picked player)) and do (Actions)
              • Loop - Actions
                • Unit - Remove (Picked unit) from the game
          • Else - Actions
 
The issue stems from a subtle detail of how "All Players" is implemented. When your map starts, Warcraft 3 runs some logic to set-up the globals used for GUI and such--such as initializing the player group "All Players". It's done so via this code in InitBlizzardGlobals:
JASS:
    set bj_FORCE_ALL_PLAYERS = CreateForce()
    call ForceEnumPlayers(bj_FORCE_ALL_PLAYERS, nil)

"ForceEnumPlayers" is responsible for filling up the player group (a.k.a. "force"), but it fills it up with all playing players. So when you're using "All players", you're really only getting the list of players that are active/playing the game. So that's why your removal code never gets executed--it never goes through any of the players that aren't playing!

To fix this, I recommend looping through all possible players (1 to 24), and performing the check on each potential player. I've included some sample code and a sample map below.

Just note that my condition first checks if the player controller is User or Computer, in case you want to allow users controlled by computers to keep their units. Definitely feel free to tweak it to fit your map. :)
  • Remove Units For Unused Players
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • -------- Loop through all potential players --------
      • For each (Integer A) from 1 to 24, do (Actions)
        • Loop - Actions
          • -------- If they are controlled by a user or computer, and are not playing --------
          • -------- then pick all their units and remove them from the map --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (((Player((Integer A))) controller) Equal to User) or (((Player((Integer A))) controller) Equal to Computer)
              • ((Player((Integer A))) slot status) Not equal to Is playing
            • Then - Actions
              • Game - Display to (All players) the text: (Removing units for player + (Name of (Player((Integer A)))))
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units in (Playable map area) owned by (Player((Integer A)))) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
            • Else - Actions
 

Attachments

  • PlayerStatusSample.w3m
    18.6 KB · Views: 2
Level 2
Joined
Dec 12, 2023
Messages
5
Hey man thank you for taking the time to explain it to me!

I swear there are always these tiny things in the World Editor that if you don't know might just drive you crazy
 
Top