• 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.

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

Level 7
Joined
Sep 30, 2017
Messages
102
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?
 
Level 28
Joined
Dec 3, 2020
Messages
996
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...
 
Level 7
Joined
Sep 30, 2017
Messages
102
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!
 
Top