• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

AI attacking multiple players

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

I'm having a problem with the AI and I'm hoping one of you knows the solution.

In my map, the player has two allies and three enemies. The idea was to have each ally attacking one of the enemy bases. When the enemy base is destroyed, they should turn to another enemy base. And here's the problem: the AI attacks the original enemy smoothly. But when the original enemy is destroyed, the ally won't do anything, even if I start an new AI Script for them.

Does one of you know a way to make the AI first attacking one player, and when it is defeated, attacks another player? Thanks in advance!

PS. If you need additional information, just let me know.
 
Level 13
Joined
Dec 19, 2020
Messages
237
can you show the priority list from the AI editor?/is this a scripted AI?

It is an AI made in JassCraft.

[. Jass] // ==========================================================================
// Dark Council - Purple
// ==========================================================================
globals

player enemy = PlayerEx(7)

constant integer Fezgrel = 'O00M'
constant integer Warlock = 'n001'
constant integer Necrolyte = 'n002'
constant integer Spearthrower = 'o00P'

endglobals

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

call CampaignAI(FORTRESS, null)
call SetReplacements(5,5,5)
call SetPeonsRepair (true)
call SetSlowChopping (false)

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

call SetBuildUnitEx(1,1,1, FORTRESS)
call SetBuildUnitEx(2,2,2, PEON)
call SetBuildUnitEx(7,7,7, BURROW)
call SetBuildUnitEx(1,1,1, ORC_ALTAR)
call SetBuildUnitEx(1,1,1, FORGE)
call SetBuildUnitEx(10,10,10, PEON)
call SetBuildUnitEx(2,2,2, ORC_BARRACKS)
call SetBuildUnitEx(2,2,2, LODGE)
call SetBuildUnitEx(2,2,2, BESTIARY)
call SetBuildUnitEx(3,3,3, ORC_WATCH_TOWER)

call CampaignDefenderEx(1,1,1, Necrolyte)
call CampaignDefenderEx(3,3,3, GRUNT)
call CampaignDefenderEx(3,3,3, Spearthrower)
call CampaignDefenderEx(2,2,2, RAIDER)
call CampaignDefenderEx(2,2,2, Warlock)

call WaitForSignal()

//* Wave 1 *
call InitAssaultGroup()
call CampaignAttackerEx(4,4,4, RAIDER)
call CampaignAttackerEx(4,4,4, Spearthrower)
call CampaignAttackerEx(2,2,2, Warlock)
call CampaignAttackerEx(1,1,1, Necrolyte)
call SuicideOnPlayer(M7,enemy)

//* Wave 2 *
call InitAssaultGroup()
call CampaignAttackerEx(4,4,4, GRUNT)
call CampaignAttackerEx(4,4,4, Spearthrower)
call CampaignAttackerEx(2,2,2, Warlock)
call CampaignAttackerEx(1,1,1, Necrolyte)
call SuicideOnPlayer(M7,enemy)

//* Wave 3 *
call InitAssaultGroup()
call CampaignAttackerEx(4,4,4, GRUNT)
call CampaignAttackerEx(4,4,4, Spearthrower)
call CampaignAttackerEx(2,2,2, Warlock)
call CampaignAttackerEx(1,1,1, Necrolyte)
call CampaignAttackerEx(1,1,1, Fezgrel)
call SuicideOnPlayer(M9,enemy)

loop

//* Wave 4 *
call InitAssaultGroup()
call CampaignAttackerEx(4,4,4, RAIDER)
call CampaignAttackerEx(4,4,4, Spearthrower)
call CampaignAttackerEx(2,2,2, Warlock)
call CampaignAttackerEx(1,1,1, Necrolyte)
call SuicideOnPlayer(M7,enemy)

//* Wave 5 *
call InitAssaultGroup()
call CampaignAttackerEx(4,4,4, GRUNT)
call CampaignAttackerEx(4,4,4, Spearthrower)
call CampaignAttackerEx(2,2,2, Warlock)
call CampaignAttackerEx(1,1,1, Necrolyte)
call SuicideOnPlayer(M7,enemy)

//* Wave 6 *
call InitAssaultGroup()
call CampaignAttackerEx(4,4,4, GRUNT)
call CampaignAttackerEx(4,4,4, Spearthrower)
call CampaignAttackerEx(2,2,2, Warlock)
call CampaignAttackerEx(1,1,1, Necrolyte)
call CampaignAttackerEx(1,1,1, Fezgrel)
call SuicideOnPlayer(M9,enemy)

//* Wave 7 *
call InitAssaultGroup()
call CampaignAttackerEx(4,4,4, RAIDER)
call CampaignAttackerEx(4,4,4, Spearthrower)
call CampaignAttackerEx(2,2,2, Warlock)
call CampaignAttackerEx(1,1,1, Necrolyte)
call SuicideOnPlayer(M7,enemy)

//* Wave 8 *
call InitAssaultGroup()
call CampaignAttackerEx(4,4,4, GRUNT)
call CampaignAttackerEx(4,4,4, Spearthrower)
call CampaignAttackerEx(2,2,2, Warlock)
call CampaignAttackerEx(1,1,1, Necrolyte)
call SuicideOnPlayer(M7,enemy)

//* Wave 9 *
call InitAssaultGroup()
call CampaignAttackerEx(4,4,4, GRUNT)
call CampaignAttackerEx(4,4,4, Spearthrower)
call CampaignAttackerEx(2,2,2, Warlock)
call CampaignAttackerEx(1,1,1, Necrolyte)
call CampaignAttackerEx(1,1,1, Fezgrel)
call SuicideOnPlayer(M9,enemy)

endloop
endfunction

[/.Jass]

This is the one I've made as the original ai. The following ai (which should start when player 7 is destroyed) follows the same pattern.
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
I have never scripted AI, and haven't done a lot of jass so maybe someone else can come and be more helpful, but if you are writing this - shouldn't it be simple enough to set a player variable "CurrentEnemy" and have the attacks sent to it.

then add a filter that before attacking - checks if the first enemy player is dead, and if so change - "CurrentEnemy" to the next enemy.

seems like a pretty simple few lines of code to add that should deal with it.
 
Level 13
Joined
Dec 19, 2020
Messages
237
I have never scripted AI, and haven't done a lot of jass so maybe someone else can come and be more helpful, but if you are writing this - shouldn't it be simple enough to set a player variable "CurrentEnemy" and have the attacks sent to it.

then add a filter that before attacking - checks if the first enemy player is dead, and if so change - "CurrentEnemy" to the next enemy.

seems like a pretty simple few lines of code to add that should deal with it.

I would like to try it, but I've never made such a filter. Do you have an example? Because it sounds promising.
 
Never start an AI before the player gets the units. This might be the case with your player transferring trick to attack each base. Look how Blizzard did it in Twilight of the Gods for each base of the undead (yes, those are 3 different undead players, if you have yet to notice).

So, in summary: target eliminated --> change owner of all units --> start AI script
 
Level 13
Joined
Dec 19, 2020
Messages
237
Never start an AI before the player gets the units. This might be the case with your player transferring trick to attack each base. Look how Blizzard did it in Twilight of the Gods for each base of the undead (yes, those are 3 different undead players, if you have yet to notice).

So, in summary: target eliminated --> change owner of all units --> start AI script

Thanks for the reply! adly for me, I've no players left to transfer the units to :(
Luckily, I've made some triggers, so the players are attacking without the use of an AI. Despite this, thanks for your advice! I will keep it in mind when making maps in the future.
 
Status
Not open for further replies.
Top