• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Help establishing an appropriate Computer for each player

Status
Not open for further replies.
Level 6
Joined
Mar 17, 2012
Messages
105
solved

Take a 5 player game where each player has an allied Computer player, such that:

Player 1 (Red) allied to Player 6 (Orange)
Player 2 (Blue) allied to Player 7 (Green)
Player 3 (Teal) allied to Player 8 (Pink)

In a trigger, a Human controlled unit does an action (lets say, casts an ability). When this ability is cast, a Footman is created, owned by the appropriate allied Computer player. This function works for each player (Red, Blue, Teal, Purple, Yellow). I'd like this to be able to work without an If/Then/Else statement for each player. I've tried using Array Player variables and Player Group variables but have been unable to figure anything out. Does anyone have any ideas?
 
Last edited:
Use a player[array] variable. Initialisize the variable at start of the game with correct input:

  • Set Ally[PlayerNumberOf(HumanPlayer)] = Player(PlayerNumberOf(AlliedComp))
So for example if Player(1) is a human player, and Player(6) is his computer ally -> "Set Ally[1] = Player(6)".

So when a unit by Player(1) would cast an ability you could create a footman for Player(6):

  • Unit - Create a Footman for Ally[PlayerNumberOf(TriggeingPlayer)]
 
Status
Not open for further replies.
Top