DOT implementation
Posted
by
Denis Ermolin
on Game Development
See other posts from Game Development
or by Denis Ermolin
Published on 2012-11-19T10:43:08Z
Indexed on
2012/11/19
11:35 UTC
Read the original article
Hit count: 282
I have some DOT(damage over time) implementation problems. My game runs on 30 FPS speed. Current implementation is: let's say hero cast spell which make 1 damage per second. So on every frame i do (pseudo code):
damage_done = getRandomDamage() * delta_time;
I accumulate damage and when it becomes more then 0 then subtract rounded damage from current health and so on. With 30 FPS and 1 DPS it will be 1/33 = 0.05...
We know that floats a not precise enough to sum 30 circulating decimals and have exact 1 in the end. But HP is discrete value and that's why 1 DPS will not have 1 damage after 1 second because value will be 0.9999....
. It's not so big deal when you have 100000 DPS - +/- 1
damage will not be noticeable. But if i have 1, 5 DPS? How modern RPG's implemented DOT's?
© Game Development or respective owner