HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Attacking AI

03-05-2007, 01:13 AM#1
Castlemaster
I'm working on an arena style map and am having trouble with how the waves attack.

I tried to copy Orc GLadiators commands for it but it's protected. First I spawn the waves in the gates. Then I make the waves in the gates attack the center of the map in case the heroes crowd the gate. Once the wave monsters move a little into the arena I tell them to attack-move-to position of a random hero (the PC's). Problem is that they will target hero A, and then hero B will be between the wave monster and hero A, but the wave monster will not attack hero B at all, sometimes not even when hero B attacks the wave monster.

My question is how do I make the wave monsters randomly choose a target to attack, but intercept any other ones in their path (like when I use the attack-move-to command in WCIII).

My second question pertains to the AI while attacking. Using triggers, I want to make a small percent of each wave mob (10-20%) randomly switch targets every 10 seconds. I want the wave monsters chosen to be a random few of the entire group, and attack any of the random heroes.

My second question: Using triggers, how do I choose a few random units in a unitgroup (variable) to go attack a random hero. I know how to pick a random hero, I just dont know how to say, "I want 3 out of 10 wave monsters to each choose a random target and attack it." Each monster would be assigned random hero individually (I don't want a bum rush of one hero).

Thanks ahead of time.
03-05-2007, 01:37 AM#2
Pyrogasm
For question 1: Use a trigger that checks for units around the attacking monster and does different things accordingly. Example:
At the start of your wave:
Set TempGroup equal to (Units in (Playable Map Area) matching ((Matching unit) is a Hero = true))
Set Unit_To_Attack equal to (Random unit from (TempGroup))
Then set your "attacking unit", however you do it, to the variable Attacking_Unit.
Periodic Check:
Collapse Events
Time - Every 0.2 seconds of Game-Time
Conditions
Collapse Actions
Set TempPoint = Position of (Attacking_Unit)
Set TempGroup equal to (Units within 300.00 of TempPoint matching (Owner of (Matching unit) equal to (Enemy of (Attacking_Unit)))
Custom script: call RemoveLocation(udg_TempPoint)
Collapse If (All conditions are true) then do (Actions), else do (Actions)
Collapse If - Conditions
TempGroup is empty
Collapse Then - Actions
Unit - Order Attacking_Unit to Attack Unit_To_Attack
Collapse Else - Actions
Set TempPoint equal to (Position of (Unit_To_Attack)
Unit - Order Attacking_Unit to Attack Move to TempPoint
Custom script: call RemoveLocation(udg_TempPoint)