How do you make AI randomly follow units?

Status
Not open for further replies.
Level 20
Joined
Feb 24, 2009
Messages
2,999
Good question, the solutions aren't hard, but they're many.
The simplest thing to do would be something like this:

  • Melee Initialization
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by GhostAI) and do (Actions)
        • Loop - Actions
          • Set tmp_unit = (Random unit from (Units in (Playable map area) matching ((Owner of (Matching unit)) Not equal to GhostAI)))
          • Unit - Order (Picked unit) to Attack tmp_unit
          • Custom script: call RemoveUnit(udg_tmp_unit)
You can change the timer value, to keep them chasing after the same person longer.

This is nice and simple, it has it's problems. For e.g. if a unit kills the one it's following you may find it sat still for several seconds before the trigger runs again, neither does it check to see if the ghost has nearly caught a unit, a simple condition along the lines of if units are within x of picked unit would solve that though.

If this isn't quite good enough for you feel free to post back with some more detail on what you want it to do and I'd be happy to assist you further :)
 
Status
Not open for further replies.
Top