HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Periodic Timer Clarification

09-15-2008, 08:29 PM#1
Kyrbi0
Alright, I've always been really uptight about using Periodic Timers in my (GUI) triggers for custom race abilities, because I was under the impression that more than 1-2 would slow down the game noticeably (which I was trying to avoid).

So I've been using stuff like "Unit is Attacked" and "Unit is given an Order", or "Unit Casts a Spell", etc, to detect different things for different spells, where perhaps a Periodic Timer would've been better/cleaner/faster/etc.

Then Szythe comes on and says (source post):

Quote:
Originally Posted by Szythe
It all depends on how often the periodics are run, and what you do in them. I'm planning on a 0.025 timer to just set every flag's x/y, which should do absolutely nothing to slow the game down. If, on the other hand, you are doing heavy calculations or leaking something every time the periodic is run, then they can bring the game to a halt very quickly.

~~~

So my question is, what can you tell me about the usage of Periodic Timers? Specifically, how many can I have before the game slows down (if ever?), and what kinds of things done with Periodic Timers that can be bad?

(for reference, I would normally be using this to keep custom Auras updated on affected units, and stuff like that... ?)

Help would be appreciated (i.e. +Rep).
09-15-2008, 09:28 PM#2
burningice95
If you do use periodic timers, make sure you never use .01 intervals. .03-.05 is much better, and you can't tell the difference.
09-15-2008, 09:28 PM#3
the-thingy
Quote:
Specifically, how many can I have before the game slows down (if ever?)
Depends on the system in question really - with the Frozen Orb spell I made (link), I can get 2, MAYBE 3, simultaneous instances going (the heavy stuff is running on a single 0.03s periodic trigger, but X instances on 1 trigger is probably the same as 1 instance on X triggers, right?) but each instance has ~8 projeticles moving at any one time. I would consider that much stuff to be bad (since it's pushing things quite a bit for me)

What exactly are you doing/planning on doing with periodic timers/triggers though? Might be able to give a more specific answer since there's going to be an obvious difference between setting some variables and doing a small few actions vs. doing a bunch of fancy things

EDIT: Oops, didn't see this bit
Quote:
(for reference, I would normally be using this to keep custom Auras updated on affected units, and stuff like that... ?)
I doubt that'd be likely to cause much lag (but that depends on what exactly keeping auras updated involves) - if you're just checking for buffs and adding/removing abilities and setting ability levels, it'd probably be OK (and that could be done at ~0.5 - 1s interval which would make it less likely to cause lag)
09-15-2008, 09:34 PM#4
moyack
The problem is not how many timers you have running in a game, but how heavy is the code run in the looping functions.
09-16-2008, 12:08 AM#5
Zerzax
What about coordinate/angular calculations (in general)? Say SquareRoot, Cos, Sin, Atan2, etc.? Just curious, because in my spell I'm knocking units into each other and often the timer will need to change angles / distances (with a .035 interval) if the target unit moves around.
09-16-2008, 12:40 AM#6
Captain Griffen
SquareRoot ain't too fast, but the trig functions are lightning fast, faster than an empty function call.
09-16-2008, 12:42 AM#7
Zerzax
Nope, no lag. Nice spell too, I really like it.

EDIT: hmm, squareroot is damn useful, I'm assuming Pow(base, (1/2)) is even slower?
09-16-2008, 02:12 AM#8
TKF
Quote:
Originally Posted by Litany
The only thing that will really bog you down is creating new units. Everything else should be fine as long as you're coding properly. What the-thingy is talking about, for example--that's easy, and if coded properly he could have dozens of copies of it running simultaneously no problem. 8 projectiles, hell 80 projectiles, moving at a time is nothing.
Perhaps not 8, but 80 is something. Even with a excellent coding, I say moving 80 units (projectiles) with an interval of 0.05-0.08 sec would be noticeable.

wc3 engine weakness is basically handling a lot of units, especially instant moving them at any rate also. If there is a map which is capable to have 80 projectiles without lagg, I would like to see that myself. I don't believe that is nothing until I see it with my own eyes.


______________

Personally I prefer to use casting/attacked events and such, I try to avoid timers myself. I develop ways to use ingame stuff as much as possible.

Simple example: Projectile system without periodic trigger for detection

Eliminate the need for triggered projectile detection, by adding ability which units which kills the projectiles within certain range (modified phönix fire). Instead of having 2 rapid periodics, you have only 1 for projectile trigger. Just an example....
09-16-2008, 03:41 AM#9
emjlr3
I have had trouble getting more then 60-70 at a time going at .035 with non-exquisite math and physics, along with a groupenum or two

there is no way I can see 150 working, even when simply moving them in a straight line with no fluff, WC3 don't work that well
09-16-2008, 04:37 AM#10
Kyrbi0
Ok, these are some examples of triggers that could be "optimized" with periodic event timers:

Trigger:
Headhunt Aura
Collapse Events
Unit - A unit Is attacked
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Attacking unit) has buff Headhunt Aura 1 ) Equal to True
Collapse Then - Actions
Unit - Add Headhunt Aura 1 (+Atk Speed) to (Attacking unit)
Collapse Else - Actions
Unit - Remove Headhunt Aura 1 (+Atk Speed) from (Attacking unit)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Attacking unit) has buff Headhunt Aura 2 ) Equal to True
Collapse Then - Actions
Unit - Add Headhunt Aura 2 (+Atk Speed) to (Attacking unit)
Collapse Else - Actions
Unit - Remove Headhunt Aura 2 (+Atk Speed) from (Attacking unit)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Attacking unit) has buff Headhunt Aura 3 ) Equal to True
Collapse Then - Actions
Unit - Add Headhunt Aura 3 (+Atk Speed) to (Attacking unit)
Collapse Else - Actions
Unit - Remove Headhunt Aura 3 (+Atk Speed) from (Attacking unit)

Trigger:
Bat Swarm
Collapse Events
Unit - A unit Is attacked
Collapse Conditions
(Unit-type of (Attacking unit)) Equal to Vampire Bat
(Current research level of Bat Swarm for (Owner of (Attacking unit))) Equal to 1
Collapse Actions
Unit - Set level of Bat Swarm for (Attacking unit) to (Number of units in (Units within 250.00 of (Position of (Attacking unit)) matching (((Unit-type of (Matching unit)) Equal to Vampire Bat) and ((Owner of (Matching unit)) Equal to (Owner of (Attacking unit))))))

Trigger:
Blur Brew
Collapse Events
Unit - A unit Is attacked
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Attacked unit) has buff Blur Brew ) Equal to True
Collapse Then - Actions
Unit - Add [Dummy] Evasion - Blur Brew to (Attacked unit)
Collapse Else - Actions
Unit - Remove [Dummy] Evasion - Blur Brew from (Attacked unit)

Stuff like that? Might be more...
09-16-2008, 06:45 AM#11
grim001
Quote:
Originally Posted by burningice95
If you do use periodic timers, make sure you never use .01 intervals. .03-.05 is much better, and you can't tell the difference.

0.025 is the lowest that makes any noticeable visual difference.
09-16-2008, 11:43 AM#12
TKF
Lithany I get problems with moving 40 "projectiles" and it lagg extremely with 0.05. I don't understand why you claim moving 80 projectile isn't noticeable.

I use GUI so it may be major, but I would like to see the code with my own eyes which makes moving 80 projectiles smoothly, cuz my movement trigger is extremely laggy.
09-16-2008, 12:12 PM#13
Captain Griffen
If you use GUI, you obviously don't care about performance.

TKF, I've had hundreds of units moving smoothly without any problem.

Quote:
EDIT: hmm, squareroot is damn useful, I'm assuming Pow(base, (1/2)) is even slower?

I presume a lot more so. SquareRoot shouldn't be that slow, but you rarely need it (better to compare the squares). Pow needs to be more general, so is slower.
09-16-2008, 12:21 PM#14
Anitarf
Kyrbi0, you have two problems:
  • You're using GUI, which makes your code slow and leaky.
  • You're approaching your problems the wrong way, many of them don't need periodic solutions.
09-16-2008, 01:08 PM#15
TKF
Quote:
Originally Posted by Captain Griffen
TKF, I've had hundreds of units moving smoothly without any problem.
If you do, how? My current GUI is being used in missile war. If you can make 3000 units move without fps lockdown, that would be nice. Minimim 1000!