Skip to main content
Tweeted twitter.com/#!/StackGameDev/status/270512425458089984

I have some DOT  (damage over time) implementation problems. My game runs on 30 FPS speed. Current implementation is: let's say the hero castcasts a spell which makedeals 1 damage per second. So onOn every frame iI do (pseudo code):

damage_done = getRandomDamage() * delta_time;

I accumulate damage and when it becomes more thenthan 0 then, I 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 aare not precise enough to sum 30 circulating decimals and have exactexactly 1 in the end. But HP is a discrete value and that's why 1 DPS will not haveresult in 1 damage after 1 second, because the value will be 0.9999....0.9999... instead. It's not sosuch a big deal when you have 100000 DPS - +/- 1, ±1 damage will not be noticeable. But what if iI have 1, 55 DPS? How do modern RPG's implemented DOT'sRPGs implement DOTs?

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?

I have some DOT  (damage over time) implementation problems. My game runs on 30 FPS speed. Current implementation is: let's say the hero casts a spell which deals 1 damage per second. On every frame I do (pseudo code):

damage_done = getRandomDamage() * delta_time;

I accumulate damage and when it becomes more than 0, I 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 are not precise enough to sum 30 circulating decimals and have exactly 1 in the end. But HP is a discrete value and that's why 1 DPS will not result in 1 damage after 1 second, because the value will be 0.9999... instead. It's not such a big deal when you have 100000 DPS, ±1 damage will not be noticeable. But what if I have 1,5 DPS? How do modern RPGs implement DOTs?

added 230 characters in body
Source Link
Denis Ermolin
  • 242
  • 1
  • 3
  • 12

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?

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;

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. 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?

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?

Source Link
Denis Ermolin
  • 242
  • 1
  • 3
  • 12

DOT implementation

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;

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. 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?