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

AI Routine with triggers help

Status
Not open for further replies.
Level 3
Joined
Feb 25, 2018
Messages
15
Hi everyone. so I have this map where you create a village. I'd like the created villagers to go about their lives, but I'm not sure how to make it work.

In my mind what would happen is that you would have a priority list attached to each villager through a hashtable, which would assign orders.

for example -

idle
go to work
work
go home
sleep
flee

what would be best is if the game would be able to detect if the villager was idle and then assign him an order based on his list of priorities. if the villager is attacked, he would be forced to flee until he could be idle again.

the problem is that I can't think of a way to directly find out if a villager has stopped to assign him a task. the only way I can imagine is to loop through every single villager every second or so to find idle villagers, but that sounds like it could really affect performance, especially if there are tonnes of villagers.

am I going about this the wrong way?
 
Level 13
Joined
Oct 12, 2016
Messages
769
the only way I can imagine is to loop through every single villager every second or so to find idle villagers
I actually do your idea on my map, but I check every 3 seconds to not make it so intensive.
I also put these units into different permanent unit groups depending on the situation (they change which of these pre-made unit groups they are in depending on some triggers that check conditions)

Every 3 seconds, I pick all units in each unit group, and assign them a specific task.
I also do the AoS thing and have regions EVERYWHERE to tell a specific unit to go to a specific point depending on where it is and what unit group it is in.
 
Status
Not open for further replies.
Top