• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[General] AI attacking Player 1 instead of Player 2 ( Player 2 is controlled by player 1)

Level 11
Joined
Sep 30, 2017
Messages
169
Hello everyone!

I have a small problem here, I'm making an Ai using jasscraft, i'm very new to it and still trying to learn it, have set the ai to build custom units and buildings and everything is going excapt one thing, The Attacking, I want this ai to attack player 2(Blue) but it always attack player 1(Red) and i don't know why, in this map Player 1(Red) controls Player 2(Blue).

I have also checked the globals and it is set to:

player user = Player(2)

call SuicideOnPlayerEx(M7,M7,M7,user)

yet still goes and attack player 1, Can anybody give a tip?
 
When setting/storing the player in a variable in a script (like you did):
player user = Player(2) --> it is important to know that Player(2) in the AI script is Player 3 (Teal) in game.

Since Player 3 (Teal) does not exist on the map, or is at least NOT an enemy of the AI using this script, the AI just attacks a random enemy instead (usually the closest one, but it I think it tends to attack a random enemy)
Setting --> player user = Player(1) should do the trick. This way it will attack Player 2 (Blue)

Basically indexing starts from 0 in the scripts, so Player(0) in the script is actually Player 1 (Red) in game, Player(11) would be Player 12 (Brown) etc...
 
When setting/storing the player in a variable in a script (like you did):
player user = Player(2) --> it is important to know that Player(2) in the AI script is Player 3 (Teal) in game.

Since Player 3 (Teal) does not exist on the map, or is at least NOT an enemy of the AI using this script, the AI just attacks a random enemy instead (usually the closest one, but it I think it tends to attack a random enemy)
Setting --> player user = Player(1) should do the trick. This way it will attack Player 2 (Blue)

Basically indexing starts from 0 in the scripts, so Player(0) in the script is actually Player 1 (Red) in game, Player(11) would be Player 12 (Brown) etc...
Yeah you are right!
I tried to set to (1) and worked perfectly! I didn't really that this script starts players from 0. Thank you very much bro!
 
Back
Top