• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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