• 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.

[Trigger] How to remove a player's pre-placed units if player is not playing?

Status
Not open for further replies.
Level 6
Joined
Jul 8, 2008
Messages
150
This is my current trigger that occurs at map ini. I've also tried many different versions of it, but nothing has worked so far.

  • 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
          • Set NotPlaying_Group = (Units owned by (Picked player))
          • Unit Group - Pick every unit in NotPlaying_Group and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
          • Custom script: call DestroyGroup(udg_NotPlaying_Group)
        • Else - Actions
          • Player - Limit training of Heroes to 1 for (Picked player)
          • Player - Set (Picked player) Current gold to 1500
          • Player - Turn Gives bounty On for (Picked player)
          • Hero - Make (Picked player) Heroes gain 85.00% experience from future kills
 
Last edited:
Well, if you have 4 players it would be like this:
  • Player Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) slot status) Not equal to Is playing
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by (Player((Integer A)))) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
            • Else - Actions
              • Player - Limit training of Heroes to 1 for (Player((Integer A)))
              • Player - Set (Player((Integer A))) Current gold to 1500
              • Player - Turn Gives bounty Off for (Player((Integer A)))
              • Hero - Make (Player((Integer A))) Heroes gain 85.00% experience from future kills
I think it should work. Just replace "4" with however many players you would like to have and add or edit the information to suit your map.
Although it might just be easier to add the units via a trigger, based on whether the player is playing or not and remove the "Create starting units for player" trigger..
 
Level 6
Joined
Sep 5, 2007
Messages
264
Wait until you've finished looping though all the players before destroying the units, put all the units in NotPlaying_Group into another group, then destroy NotPlaying_Group.

After you've looped through the players, all the "non-playing" units should be in one group... DESTROY THEM, then DESTROY THE GROUP!! :mwahaha:

Sorry, got a little carried away there :xxd:
 
Level 12
Joined
Aug 22, 2008
Messages
911
Trigger Correction

  • Player Group - Pick every player in (Players matching (Matching Player is playing) equal to True) and do (Actions)
    • Loop - Actions
      • Set NotPlaying_Group = (Units owned by (Picked player))
      • Unit Group - Pick every unit in NotPlaying_Group and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the
      • Custom script: call DestroyGroup(udg_NotPlaying_Group)
Corrected your trigger.
Make one for your filled player slots, you should.
May the Force be with you!
EDIT: Mephisto's solution is better. The Force is strong with you!
 
Status
Not open for further replies.
Top