• 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.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Trigger Design

Status
Not open for further replies.
Level 4
Joined
Dec 9, 2008
Messages
52
Ok here's a problem I came across that I've solved, but I'm pretty sure is just some crude hack. I'm looking to see if any experienced people have a more kosher way of solving this.

I have some basic AI for a couple dozen units, and I have to check on them every second to make sure they're not being stupid. That's not the issue. The issue is how do I stagger my calls so I don't have 99% of the game time not being used to compute their AI, and then 1% of the game time being lagged by having to do a lot of work in a few microseconds.

My solution is to assign each unit a random number between 1 and 100, and then I make a call every 1/100th of a second. And then I check each unit's random number, and if it matches which 100th of a second it is, it does the action. This way everything is staggered. I realize, however that this is a pretty ghetto way of doing things and would like input on perhaps a more standardized method for solving my problem.

Thanks!
 
Status
Not open for further replies.
Top