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

Creating a Suicide AI

Status
Not open for further replies.
Level 2
Joined
Mar 21, 2009
Messages
7
I've noticed in Blizzard campaign maps where there are waves of armies spawn that instead of issuing attack-move order to units, they're using a custom AI to do it. I decided to extract the one used in the last Rexxar mission (o03Bx08.ai) out and try to implement it in a castle defense map.

Can anyone explain to me how does this AI work?
JASS:
globals
    integer user = 3
endglobals

function main takes nothing returns nothing
	call CampaignAI(HOUSE,null)
	
	call PrepFullSuicide()
	loop
		loop 
			exitwhen CommandsWaiting() == 0
			set user = GetLastCommand()
			call PopLastCommand()
		endloop
		call SuicideUnitB(FOOTMAN,user)
		call SuicideUnitB('h004',user)
		call SuicideUnitB(RIFLEMAN,user)
		call SuicideUnitB('h005',user)
		call SuicideUnitB(KNIGHT,user)
		call SuicideUnitB('h006',user)
		call SuicideUnitB('h007',user)
		call SuicideUnitB('nchp',user)
		call SuicideUnitB('nhym',user)
	endloop

endfunction

Also, is this more efficient than just using trigger to issue order everytime a wave of enemies spawns?
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Functionally, the "suicide" AI just sends units to attack and die (suicide as in no retreat), possibly with additional pathfinding/searching to make sure they attack the enemy. So I think the humble attack move is more efficient, although the efficiency difference is really insignificant compared to everything else going on in the map.
 
Status
Not open for further replies.
Top