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

How to make a triggered AI move randomly

Status
Not open for further replies.
Level 2
Joined
Feb 13, 2011
Messages
10
Hi, I have simple question, now I'm editing a map to have a simple AI to practice with, so I created a lot of regions in certain points of the map. I wanna make the unit move randomly to all marked regions (like it's searching for something) and if there is a player in it's visual area make the unit attack him.
 
Level 2
Joined
Feb 13, 2011
Messages
10
Actually what I want is order the unit to go randomly to certain regions not only one, for example; I have 76 regions and 1 unit. Every 20 seconds, a trigger order the unit to attack-move randomly to anoter region.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
This is the example trigger:
  • Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Region[1] = Region 000 <gen>
      • Set Region[2] = Region 001 <gen>
      • Set Region[3] = Region 002 <gen>
      • Set Region[4] = Region 003 <gen>
      • Set Region[5] = Region 004 <gen>
  • Event
    • Events
      • Time - Every 20.00 seconds of game time
    • Conditions
    • Actions
      • Unit - Order *YourAI* to Attack-Move To (Center of Region[(Random integer number between 1 and 5)])
When creating the "Region" variable, tick the "Array" box
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
To add to defskull's answer:

If the regions are large, you could order them to move to a random point in a region:

  • Untitled Trigger 030
    • Events
    • Conditions
    • Actions
      • Set point = (Random point in Region[(Random integer number between 1 and 5)])
      • Unit - Order unit to Attack-Move To point
      • Custom script: call RemoveLocation(udg_point)
Or if the regions are small and you don't want/need to order the units to a random point you should pre-set the points in an init trigger:
  • Untitled Trigger 031
    • Events
    • Conditions
    • Actions
      • Set points[1] = (Center of Region1)
      • Set points[2] = (Center of Region2)
      • Set points[3] = (Center of Region3)
and then order units to move:
  • Unit - Order unit to Attack-Move To points[(Random integer number between 1 and 3)]
 
Status
Not open for further replies.
Top