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

Wanting to create a decent "Search and destroy" AI

Status
Not open for further replies.
to attack the nearest enemy u use a unit group and detect how far the unit is from the nearest unit with a real distance check.
^ i wouldnt do it that way tho.

instead pick a random point in the map and order the unit to attack move there. every couple seconds check if the unit has an order equal to stop.
if the unit is equal to stop order it to attack move to a new point.

i believe u can also use the wander ability and just give it to the unit and he will wander around the map until he finds something to attack
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
Actually it is as I wrote (tested it just now).
If you have unit with Wander ability and that unit has "can flee" set to true, he will flee every time he takes (like a creep that has no attack)
If "can flee" is set to false, he won't flee after each attack, however he will periodically still stop attacking to move somewhere because of Wander ability.

To conclude:
Wander still forces the unit to move periodically, even if that unit is currently engaged in combat and has Can Flee either True or False.

A unit with Wander ability and "Stats - Can Flee: True" will flee when it takes damage; if "can Flee" is false, it won't flee after taking damage.
 
Level 3
Joined
Sep 9, 2009
Messages
658
I did something similar like this. I added the players to a group then I made a loop and for each loop I set a variable as a player's starting position. Then I make the units and order them to attack move to a random starting position.


  • Player Group - Pick every player in TheAlliance and do (Actions)
    • Loop - Actions
      • Set Base_Loc[(Player number of (Picked player))] = ((Picked player) start location)
  • For each (Integer UnitInteger) from 1 to 5, do (Actions)
    • Loop - Actions
      • Set RPos = (Random point in Spawn Point <gen>)
      • Unit - Create 1 Ghoul for Player 11 (Dark Green) at RPos facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack-Move To Base_Loc[(Random integer number between 4 and 6)]
      • Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation (udg_RPos)
EDIT:
And I just want something a little bit more advanced then "Pick random unit on map, attack move towards it"
I misread this. Please disregard my post. Oh, I might be wrong on this one but instead of checking if it has issued order stopped every few seconds, wouldn't making it patrol to a random point in the map every few seconds be better, if only because that would require less triggers?
 
Last edited:
yes patrol would be ok but it would only move between 2 points.

with the random point way u only need 3 triggers.
one trigger for adding units to group when the unit enters the map area.
one for removing the dead units from the group when they die or are removed from the map.
and one to loop through the group and check if they are already issued an order.
 
Level 8
Joined
Oct 12, 2011
Messages
483
The way the AI system in maddeem's MineralZ is that:
1. He creates the creeps
2. He orders 1/3 of the creeps to attack random enemy units
2 a. If a unit gets attacked, it is added to an "attackable" unit group
2 b. If the creep is unable to attack the target unit in some duration, it is order to target a different random unit
3. He orders the remaining 2/3 of the creeps to attack the units in the "attackable" unit group

Not sure if this is applicable to your map
 
Level 3
Joined
Sep 9, 2009
Messages
658
@deathismyfriend when you say check if the order is stop do you mean

  • (Current Order of Picked unit) equal to order(stop) true?
I just remembered trying that once. Nothing happened when I used that condition so I always thought that AI controlled units have a different order than stop when they're not moving.
 
Level 6
Joined
Jan 16, 2013
Messages
68
@deathismyfriend when you say check if the order is stop do you mean

  • (Current Order of Picked unit) equal to order(stop) true?
I just remembered trying that once. Nothing happened when I used that condition so I always thought that AI controlled units have a different order than stop when they're not moving.

That is correct. When testing if the AI is not doing anything never use stop. Instead use none. That means that they have no order at all. I know, it's weird but it's true. Try it out!
 
Status
Not open for further replies.
Top