• 🏆 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] kill the hero of non-existing player

Status
Not open for further replies.
My map is set to 12 players only users. How do I create a trigger that detect if a player is not in game and to kill his hero. I mean not when the player leaves but if there is a player in game. Is it active.

I ask because the units are on the map and when i start the game the units are there, no matter if there is a player to control them or not.

( my map contains one hero for each player, so there is only one unit to kill.)
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
JASS:
if (GetPlayerSlotState(<player>) != PLAYER_SLOT_STATE_PLAYING) then
    call KillUnit(<unit>)
endif

You would also like to detect if the player is no human user:

JASS:
if ((GetPlayerSlotState(<player>) != PLAYER_SLOT_STATE_PLAYING) or (GetPlayerController(<player>) != MAP_CONTROL_USER)) then
    call KillUnit(<unit>)
endif
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Sounds like you do not use jass. You can write it with multiple Custom Script actions in GUI yes, one for each line. Those functions are also available in GUI though. See condition type Player Slot State Comparison, Player Controller Comparison and Unit - Kill as action.
 
Level 2
Joined
Nov 21, 2010
Messages
29
Just do it in GUI, if you don't know how to use JASS. Something like:
  • Remove Heroes
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) slot status) Equal to Is playing
            • Then - Actions
              • -------- Something --------
            • Else - Actions
              • Set UnitGroup = (Units owned by (Player((Integer A))))
              • Unit Group - Pick every unit in UnitGroup and do (Unit - Remove (Picked unit) from the game)
              • Custom script: call DestroyGroup(udg_UnitGroup)
If for some reason you want the other units to stay and just the hero gone, change
  • Set UnitGroup = (Units owned by (Player((Integer A))))
to
  • Set UnitGroup = (Units owned by (Player((Integer A))) matching (((Picked unit) is A Hero) Equal to True))
Hope it helped!
 
Ofc you have to replace the placeholders <unit>/<player> by what you want.
I do.

I tried it simpler, to test for one player.

  • Conditions
  • (player 3)Teal controller) equal to none
  • Actions
  • Unit - kill mountain king 0003 <gen>
He does not die. what the player staus should be when i start from world editor? computer,none,passive..? i want him to die if there is no player to control him.
 
Level 2
Joined
Nov 21, 2010
Messages
29
I do.


I tried it simpler, to test for one player.

  • Conditions
  • (player 3)Teal controller) equal to none
  • Actions
  • Unit - kill mountain king 0003 <gen>
He does not die. what the player staus should be when i start from world editor? computer,none,passive..? i want him to die if there is no player to control him.

First of all, what event did you use? Just wondering, but it should be pretty early, something like after 1 second of gametime. You can also turn the trigger around if you want, making a trigger that adds heroes based on the number of players. If you want that instead I'll post it.

Seconds, your condition should be
  • (Player 3 (Teal) controller) Not equal to User
instead of none, to avoid the problem of someone accidently adding a computer player resulting in the removal not triggering. (unless you want to AI ofcourse).
 
The trigger does not work ;(;(;( (it has 2 secs) (why does not work it's all logical ;( ). Also, your idea, for creation trigger, is not an option, because the units have item set of items that they drop on death.
Still if there can set with trigger an item table I don't think this changes that the command trigger for player controller works.... idk
 
Last edited:
Level 13
Joined
Mar 24, 2010
Messages
950
Baskeys trigger should work..

  • For each (Integer A) from 1 to 12, 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 in (Playable map area) owned by (Player((Integer A)))) and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
        • Else - Actions
maybe this is easier for u to read? just do that. but make sure to remove unitgroup leak like his trigger above

also not sure what you were doing in your post with your trigger but your condition is wrong, try this
  • (Player 3 (Teal) slot status) Not equal to Is playing
 
Level 2
Joined
Nov 21, 2010
Messages
29
Baskeys trigger should work..

  • For each (Integer A) from 1 to 12, 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 in (Playable map area) owned by (Player((Integer A)))) and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
        • Else - Actions
maybe this is easier for u to read? just do that. but make sure to remove unitgroup leak like his trigger above

also not sure what you were doing in your post with your trigger but your condition is wrong, try this
  • (Player 3 (Teal) slot status) Not equal to Is playing

Yeah, yours is better than mine, my bad. Still, my original trigger should work, so you can just directly copy that into your map.
 
Status
Not open for further replies.
Top