Skip to content

Instantly share code, notes, and snippets.

@Zbizu
Created December 9, 2021 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zbizu/6a4aaef3e9d9cb37526604d35cb836a7 to your computer and use it in GitHub Desktop.
Save Zbizu/6a4aaef3e9d9cb37526604d35cb836a7 to your computer and use it in GitHub Desktop.
poison condition damage formula
function getValue(x)
local flipped = 0
if x % 10 > 5 then
flipped = 1
end
local f
if (x + flipped) % 2 == 1 then
f = math.floor
else
f = math.ceil
end
return f((20/x) * (1 + math.sin(math.pi * x)))
end
for i = 1, 22 do print(getValue(i)) end
@Zbizu
Copy link
Author

Zbizu commented Dec 9, 2021

formula for taking damage while being poisoned in a role-playing game

input: amount of damage player receives
output: how many times will the player take this amount of damage (eg. 1 damage 20 times, 2 damage 10 times)

Example:
let's say you're DM and the player gets poisoned for 100 damage
you sum f(1) + ... + f(n) until the sum is equal or greater than 100.
If your sum is greater than 100, you don't count the last tick.
The end result is that the player takes n damage f(n) times and n decreases until it reaches zero.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment