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

How To Detect Amount Of Players Using Triggers

Status
Not open for further replies.
Level 2
Joined
Oct 11, 2012
Messages
14
Hi, is it possible to create a trigger or triggers to detect how many players are present at game start and spawn a ship per player that is present without using variables and scripts?

If yes, please show me how.
 
Level 2
Joined
Oct 11, 2012
Messages
14
Appreciate the time and effort you put into this. Rep added. Albeit I do regret not elaborating because now I'm still unable to complete my task :(

What I wanted to do was create 8 regions (region 1 is for player 1 and so forth) and ask for help on creating a trigger that detects the amount of players present in the game. If there was 4 players in the game then 4 players will each receive a boat in their respective regions; player 1 gets boat in region 1, player 4 gets boat in region 4.
 
Level 11
Joined
Oct 31, 2010
Messages
1,057
for this , i dont know how to use arrays that much so i have to use 12 triggers for this.
a trigger for player 1 , player 2 , player 3 , player 4 and so on...
Event = Map initialisation
Action = if player 1 red controller is user then create a ship for player 1 at region else do nothing
-----------------------
Event = Map initialisation
Action = if player 2 red controller is user then create a ship for player 2 at region else do nothing
------------------------
but i think using arrays could make this become only 1 trigger
 
Level 2
Joined
Oct 11, 2012
Messages
14
arrays?

EDIT: Nevermind, I think I can pull this off but ultimately it may come in handy sometime in the future I hope. Thanks for the help.
 
This is only set for 4 players, you can add more. Without a variable this will be too long.
  • Init
    • Event
      • Map initialization
    • Conditions
    • Actions
      • Set Temp_Point[1] = (Center of Player 1 <gen>)
      • Set Temp_Point[2] = (Center of Player 2 <gen>)
      • Set Temp_Point[3] = (Center of Player 3 <gen>)
      • Set Temp_Point[4] = (Center of Player 4 <gen>)
      • 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) and (((Picked player) controller) Equal to User)
            • Then: Actions
              • Unit - Create 1 YourUnit for (Picked player) at Temp_Point[(Player number of (Picked player))] facing Default View degrees
              • Custom script: call RemoveLocation(udg_Temp_Point[GetPlayerId(GetEnumPlayer())])
            • Else: Actions
Edit:
Don't fear to variables.
They are very useful, in this case, when you create a unit in a location, you generate a leak. With the variable you fix that problem.

An array variable is like this Unit[1], [] is the array part, you can use the same variable name and only change the array number to store different units for example. If you assign the same array value to other thing, will overwrite the older value.

Temp_Point is an array point variable in this case.
 
Last edited:
Level 2
Joined
Oct 11, 2012
Messages
14
This is only set for 4 players, you can add more. Without a variable this will be too long.
  • Init
    • Event
      • Map initialization
    • Conditions
    • Actions
      • Set Temp_Point[1] = (Center of Player 1 <gen>)
      • Set Temp_Point[2] = (Center of Player 2 <gen>)
      • Set Temp_Point[3] = (Center of Player 3 <gen>)
      • Set Temp_Point[4] = (Center of Player 4 <gen>)
      • 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) and (((Picked player) controller) Equal to User)
            • Then: Actions
              • Unit - Create 1 YourUnit for (Picked player) at Temp_Point[(Player number of (Picked player))] facing Default View degrees
              • Custom script: call RemoveLocation(udg_Temp_Point[GetPlayerId(GetEnumPlayer())])
            • Else: Actions
Edit: Temp_Point is an array point variable.

I still haven't gotten around to learning variables yet.
 
Level 2
Joined
Oct 11, 2012
Messages
14
It is no problem. I will take a look.

EDIT: It is more complicated than I thought.. It will take time to figure and learn from it ><

EDIT2: Almost got through.. still hard! anyways solved. rep added.
 
Last edited:
Status
Not open for further replies.
Top