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

AI player targeting units

Status
Not open for further replies.
Level 13
Joined
Dec 19, 2020
Messages
237
Hello guys!

Recently, an event occured and I can't figure out what causes it. So here we go.

In the map, there are two enemy players, which are supposed to attack the player's base. The AI scripts for this was made with JASSCRAFT. So this is the problem:
The first enemy player (player 7) is attacking the player's base as it is supposed to do. The second enemy player (player 2) is not attacking the player's base, but the nearest unit of the player. This causes problems for the gameplay (not a lot of pressure on your own base for example).

I think the problem is not in the AI Script. I've given player two the AI script which belongs to player 7 (the functioning player), but player 2 keeps targeting the nearest unit.
The remaining problem is that I don't know what the problem could be. I guess it's in the map, but I don't know what.

Is there someone who knows what the problem could be or has experienced the same kind of issue? Thanks in advance!

PS. If necessary, I could post my map in this thread so you can see it for yourself.
 
Level 13
Joined
Dec 19, 2020
Messages
237
Exact script for both players, as in exact copy? Does both AI have tech access in complete for the script to run?

I have worked with AI script in the past and mirroring is a common tactic in my book, so I assume it's tech access problem.

For both questions, the answer is yes. Player 2 and 7 are using the same techtree. Because the problem occured by player 2, I decided to use the script from player 7 for player 2.

It seems to me that the AI script for player 2 is running, because it builds, harvests and trains defense and attack groups as it should do. It goed wrong when player 2 sends the trained attack wave. Instead of sending it at the player's base, it sends it to the players nearest unit.

The script for player 2:

[.Jass] // ==========================================================================
// Tychrel Elite Guard - Blue
// ==========================================================================
globals
player user = PlayerEx(1)

constant integer Ranger = 'u001'
constant integer Devout = 'u000'
constant integer GSW = 'nskg'
constant integer BA = 'nskf'
constant integer MM = 'nskm'
constant integer Tychrel = 'U002'
constant integer Tomb = 'u009'
constant integer Research_Pit = 'u007'

endglobals

//============================================================================
// main
//============================================================================
function main takes nothing returns nothing

call CampaignAI(NECROPOLIS_3,null)
call SetReplacements(5,5,5)
call SetPeonsRepair (true)
call SetSlowChopping (true)

//*****************************
//*Building/Defense
//*****************************

call SetBuildUnitEx(1,1,1, NECROPOLIS_3)
call SetBuildUnitEx(5,5,5, ACOLYTE)
call SetBuildUnitEx(5,5,5, GHOUL)
call SetBuildUnitEx(6,6,6, ZIGGURAT_1)
call SetBuildUnitEx(1,1,1, UNDEAD_ALTAR)
call SetBuildUnitEx(1,1,1, GRAVEYARD)
call SetBuildUnitEx(1,1,1, TOMB_OF_RELICS)
call SetBuildUnitEx(2,2,2, DAMNED_TEMPLE)
call SetBuildUnitEx(2,2,2, SLAUGHTERHOUSE)
call SetBuildUnitEx(2,2,2, CRYPT)
call SetBuildUnitEx(4,4,4, ZIGGURAT_2)
call SetBuildUnitEx(2,2,2, ZIGGURAT_FROST)
call SetBuildUnitEx(1,1,1, Research_Pit)
call SetBuildUnitEx(2,2,2, Tomb)

call CampaignDefenderEx(2,2,2, ABOMINATION)
call CampaignDefenderEx(3,3,3, GSW)
call CampaignDefenderEx(2,2,2, BA)
call CampaignDefenderEx(2,2,2, MM)
call CampaignDefenderEx(1,1,1, NECRO)
call CampaignDefenderEx(1,1,1, Devout)
call CampaignDefenderEx(1,1,1, OBSIDIAN_STATUE)

call WaitForSignal()

//*WAVE 1 *
call InitAssaultGroup()
call CampaignAttackerEx(3,3,3, GSW)
call CampaignAttackerEx(3,3,3, ABOMINATION)
call CampaignAttackerEx(2,2,2, BA)
call CampaignAttackerEx(2,2,2, MM)
call CampaignAttackerEx(2,2,2, MEAT_WAGON)
call SuicideOnPlayer(M7,user)

//*WAVE 2 *
call InitAssaultGroup()
call CampaignAttackerEx(2,2,2, GSW)
call CampaignAttackerEx(2,2,2, ABOMINATION)
call CampaignAttackerEx(1,1,1, MM)
call CampaignAttackerEx(2,2,2, BA)
call CampaignAttackerEx(1,1,1, OBSIDIAN_STATUE)
call CampaignAttackerEx(2,2,2, NECRO)
call CampaignAttackerEx(2,2,2, Devout)
call SuicideOnPlayer(M7,user)

//*WAVE 3 *
call InitAssaultGroup()
call CampaignAttackerEx(3,3,3, ABOMINATION)
call CampaignAttackerEx(3,3,3, BA)
call CampaignAttackerEx(2,2,2, NECRO)
call CampaignAttackerEx(2,2,2, Devout)
call CampaignAttackerEx(1,1,1, OBSIDIAN_STATUE)
call CampaignAttackerEx(1,1,1, Tychrel)
call SuicideOnPlayer(M6,user)

loop
//*WAVE 4 *
call InitAssaultGroup()
call CampaignAttackerEx(3,3,3, GSW)
call CampaignAttackerEx(3,3,3, ABOMINATION)
call CampaignAttackerEx(2,2,2, BA)
call CampaignAttackerEx(2,2,2, MM)
call CampaignAttackerEx(2,2,2, MEAT_WAGON)
call SuicideOnPlayer(M7,user)

//*WAVE 5 *
call InitAssaultGroup()
call CampaignAttackerEx(2,2,2, GSW)
call CampaignAttackerEx(2,2,2, ABOMINATION)
call CampaignAttackerEx(1,1,1, MM)
call CampaignAttackerEx(2,2,2, BA)
call CampaignAttackerEx(1,1,1, OBSIDIAN_STATUE)
call CampaignAttackerEx(2,2,2, NECRO)
call CampaignAttackerEx(2,2,2, Devout)
call SuicideOnPlayer(M7,user)

//*WAVE 6 *
call InitAssaultGroup()
call CampaignAttackerEx(3,3,3, ABOMINATION)
call CampaignAttackerEx(3,3,3, BA)
call CampaignAttackerEx(2,2,2, NECRO)
call CampaignAttackerEx(2,2,2, Devout)
call CampaignAttackerEx(1,1,1, OBSIDIAN_STATUE)
call CampaignAttackerEx(1,1,1, Tychrel)
call SuicideOnPlayer(M9,user)

endloop
endfunction

[./Jass]


The script for player 7:

[.Jass] // ==========================================================================
// Cult of the Dead - Green
// ==========================================================================
globals
player user = PlayerEx(1)

constant integer Ranger = 'u001'
constant integer Devout = 'u000'

endglobals

//============================================================================
// main
//============================================================================
function main takes nothing returns nothing

call CampaignAI(NECROPOLIS_3,null)
call SetReplacements(5,5,5)
call SetPeonsRepair (true)
call SetSlowChopping (true)

//*****************************
//*Building/Defense
//*****************************

call SetBuildUnitEx(1,1,1, NECROPOLIS_3)
call SetBuildUnitEx(5,5,5, ACOLYTE)
call SetBuildUnitEx(5,5,5, GHOUL)
call SetBuildUnitEx(6,6,6, ZIGGURAT_1)
call SetBuildUnitEx(1,1,1, UNDEAD_ALTAR)
call SetBuildUnitEx(1,1,1, GRAVEYARD)
call SetBuildUnitEx(1,1,1, TOMB_OF_RELICS)
call SetBuildUnitEx(2,2,2, DAMNED_TEMPLE)
call SetBuildUnitEx(2,2,2, SLAUGHTERHOUSE)
call SetBuildUnitEx(2,2,2, CRYPT)
call SetBuildUnitEx(2,2,2, ZIGGURAT_2)
call SetBuildUnitEx(1,1,1, ZIGGURAT_FROST)

call CampaignDefenderEx(3,3,3, ABOMINATION)
call CampaignDefenderEx(3,3,3, Ranger)
call CampaignDefenderEx(2,2,2, NECRO)
call CampaignDefenderEx(2,2,2, Devout)
call CampaignDefenderEx(1,1,1, OBSIDIAN_STATUE)

call WaitForSignal()

//*WAVE 1 *
call InitAssaultGroup()
call CampaignAttackerEx(3,3,3, GHOUL)
call CampaignAttackerEx(3,3,3, ABOMINATION)
call CampaignAttackerEx(4,4,4, Ranger)
call SuicideOnPlayer(M6,user)

//*WAVE 2 *
call InitAssaultGroup()
call CampaignAttackerEx(2,2,2, GHOUL)
call CampaignAttackerEx(2,2,2, ABOMINATION)
call CampaignAttackerEx(3,3,3, Ranger)
call CampaignAttackerEx(2,2,2, MEAT_WAGON)
call CampaignAttackerEx(1,1,1, OBSIDIAN_STATUE)
call SuicideOnPlayer(M6,user)

//*WAVE 3 *
call InitAssaultGroup()
call CampaignAttackerEx(3,3,3, ABOMINATION)
call CampaignAttackerEx(3,3,3, Ranger)
call CampaignAttackerEx(2,2,2, NECRO)
call CampaignAttackerEx(2,2,2, Devout)
call SuicideOnPlayer(M6,user)

loop

//*WAVE 4 *
call InitAssaultGroup()
call CampaignAttackerEx(3,3,3, GHOUL)
call CampaignAttackerEx(3,3,3, ABOMINATION)
call CampaignAttackerEx(4,4,4, Ranger)
call SuicideOnPlayer(M6,user)

//*WAVE 5 *
call InitAssaultGroup()
call CampaignAttackerEx(2,2,2, GHOUL)
call CampaignAttackerEx(2,2,2, ABOMINATION)
call CampaignAttackerEx(3,3,3, Ranger)
call CampaignAttackerEx(2,2,2, MEAT_WAGON)
call CampaignAttackerEx(1,1,1, OBSIDIAN_STATUE)
call SuicideOnPlayer(M6,user)

//*WAVE 6 *
call InitAssaultGroup()
call CampaignAttackerEx(3,3,3, ABOMINATION)
call CampaignAttackerEx(3,3,3, Ranger)
call CampaignAttackerEx(2,2,2, NECRO)
call CampaignAttackerEx(2,2,2, Devout)
call SuicideOnPlayer(M6,user)

endloop
endfunction
[./Jass]

If you enter my map (see my previous post), you can see what I mean. Just move one unit near the blue base, out of the way they should go to attack your base, and they will come to attack the unit in no time :(
 
Are you certain the other two factions are not supply blocked or time blocked? From my test, I see that the first blue wave Abomination is missing one unit (it does not have time to build this unit in time for the original wave). In addition, it's also possible that the next wave also sets in by the time they arrive, given the distance covered by the AI to reach the base.

I suggest trying to increase the time between waves and calculate the food the enemy has by the time that wave hits (along with one previous wave to be safe). The Gray faction also works properly in my run (had it engage the nearest unit, I would have been blindsided, but that did not happen).
 
Level 13
Joined
Dec 19, 2020
Messages
237
Are you certain the other two factions are not supply blocked or time blocked? From my test, I see that the first blue wave Abomination is missing one unit (it does not have time to build this unit in time for the original wave). In addition, it's also possible that the next wave also sets in by the time they arrive, given the distance covered by the AI to reach the base.

I suggest trying to increase the time between waves and calculate the food the enemy has by the time that wave hits (along with one previous wave to be safe). The Gray faction also works properly in my run (had it engage the nearest unit, I would have been blindsided, but that did not happen).

Thanks! I will take a look at it and return the results later.

Edit: Did what you advised. Didn't work. Both Blue and Gray kept stalking me :)
Luckily, I've found an alternate solution, which works, so the map should work fine.
 
Last edited:
Status
Not open for further replies.
Top