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

[Trigger] I need help with a trigger :(

Status
Not open for further replies.
Level 1
Joined
Jan 11, 2006
Messages
4
Well, basically I have preset units on the map for each player and I want to remove the units owned by the player if there is no player in that slot. How should I do this in a leak free way?
 
Level 14
Joined
Jun 13, 2007
Messages
1,432
Try this: Events:Map initialization
Conditions: none
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) Equal to Is playing
Then - Actions
Unit Group - Pick every unit in (Units owned by (Picked player) and do (Unit - remove (Picked unit))
Else - Actions
Do nothing
 
Last edited:
Level 9
Joined
May 27, 2006
Messages
498
Unit Group - Pick every unit in (Units owned by Player 1 (Red)) and do (Unit - Hide (Picked unit))

Its much better to remove unit than to hide it, cause hiding just makes the unit kinda "invisible", noncontrollable and paused, but the unit still exists and takes the memory.
And you forgot to change from "Player 1 (Red)" to "(Picked player)".
 
Level 4
Joined
Dec 4, 2007
Messages
76
Well, the way guy there has it will remove the unit if the player is playing. So change it up to this:

Code:
RemovePlayerUnit
    Events
        Time - Elapsed game time is 1.00 seconds
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Player 1 (Red) slot status) Equal to Has left the game
                (Player 1 (Red) slot status) Equal to Is unused
    Actions
        Unit Group - Pick every unit in (Units owned by Player 1 (Red)) and do (Actions)
            Loop - Actions
                Unit - Remove (Picked unit) from the game

Of course you would have to do this for each player, and it isint leak free (Im a noob when it comes to fixing leaks) but it gets the job done rather nicely.
 
Level 6
Joined
Nov 28, 2007
Messages
203
@ Syltman:
This doesn't work, because of
  • If - Conditions
    • ((Picked player) slot status) Equal to Is playing
It will only trigger if every player is playing.

@leetsoul
You can do it like this:
  • Events
    • Time - Elapsed game time is 1.00 seconds
  • Conditions
  • Actions
    • Player Group - Pick every player in (All players matching (((Matching player) slot status) Not equal to Is playing)) and do (Actions)
      • Loop - 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
 
Level 4
Joined
Dec 4, 2007
Messages
76
If you do it that way hump, it will only remove them if they arent playing, and because battle.net classifies wether or not someone is playing by where they are when game starts (while map is loading) it wont remove players that drop or get disconnected before map is done loading, my way makes sure both ways get removed.
 
Level 6
Joined
Dec 28, 2007
Messages
111
Try this: Events:Map initialization
Conditions: none
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) Equal to Is playing
Then - Actions
Unit Group - Pick every unit in (Units owned by (Picked player) and do (Unit - remove (Picked unit))
Else - Actions
Do nothing


Can u tell me how to loop :)
 
Level 6
Joined
Nov 28, 2007
Messages
203
  • Events
    • Map initialization
  • Conditions
  • 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) Equal to Is playing
          • Then - Actions
            • Unit Group - Pick every unit in (Units owned by (Picked player) and do (Unit - remove (Picked unit))
          • Else - Actions
            • Do nothing
The loop is from 'Player Group - Pick every player in player group'

For loops: here's GhostWolf's tutorial about loops and arrays: http://www.hiveworkshop.com/forums/showthread.php?t=45561
 
Status
Not open for further replies.
Top