How would I use Quadratic equations to calculate damage falloff?

So, here’s the score. A system I’ve been tinkering with is about making damage fall off based on the distance.

Though I tried using a direct linear falloff equation, that’s not quite what I am needing.

So, after some digging (and being reminded that math is probably one of the more crucial subjects in high-school if you want to do game-development) I’ve figured out that the nice, gentle curve I am looking for is to be found in a quadratic equation.

So, with the help of a little web-widget I found the curve

Ax^2 + Bx + C = 0

Where A is -.9, B is 0 and C is 1. This would give me a nice curve where I can have the tail end of the explosion still do damage.

Thing is, I am at a loss as to how to factor this down into a format that I can use to calculate Y where X is the distance.

If it helps, it’d be in terms of percentages and multipliers. So, this curve would be the template to use to calculate the multiplier to apply against the total damage to be dealt. That also frees be up to feeding it the range as a variable itself (well, i’d have to reduce it down but that kind of math I can handle.) So, therefore if the total range is 25 units as radius and the maximum damage is 75, I can easily just take the distance of the object, calculate that against the maximum range to get the percentage (divided by 100… or just not multiplying it BY 100 at the tail end of those calculations to figure that bit out.) Then I can take that value and filter it through this equation so that if the distance is X then it will result in Y which will be the multiplier to use for the total damage.

So, therefore, assuming distance is 25 units away, total range is 50 units, I’m left with a value of 0.5 that I can then use on the X to get Y which will be what I multiply the total damage by in order to get the “reduced falloff” damage value.

So, I’ve been able to figure out the equation I’ll need and the right settings/values to use to define it… but factoring it down into a format that I can use in this system is where I’m having a bit of trouble here.

Anyone with a math-mind willing to help out here?

Are you talking about taking -0.9x^2 + 1 = 0 and solving for x?
it would be -0.9x^2 = -1
1.1111 = x^2
so…
plus or minus the sqrt of 1.111… = x

Actually it’d be to solve it for Y.

Assuming that X is the relative distance from the epicenter of the blast, using this algorithm it would be needed to calculate the multiplier to apply to the base damage value so as to get the proper amount of damage to apply.

That said, I managed to get some help from a couple other people. One person from Reddit clued me in that the “0” at the end of the equation was actually the Y value I needed so from there it’s not so beastly to figure out. I know what X would be (it’s the distance from the epicenter where 0 is at the center and 1 is at the tail edge… the -.9 is the curve which I will admit is a bit of a cheat because I had to use a little online widget to figure that out… and the rest is basically reducing the equation to workable parts.

That said, my brother in law clued me in that the inverse square law is the proper way of calculating the damage fall off in these kinds of situations so I’m looking into that… but for my purposes the system that I was able to hack together with the quadratic curve works well enough.

So, assuming that the enemy is halfway between, the X value would be 0.5. So:
-0.9x^2 + Bx + C = Y
-0.9(.5^2) + 0x + 1 = Y
-0.9(.25) + 1 = Y (Drop the “0x” as that is essentially “0”)
-.225 + 1 = Y
.775 = Y

So, assuming the base damage is 50 points of damage, take base damage amount, multiply by Y (.775) leaves the value that should be applied is 38.75 points of damage.

I guess this would be a nice way because you can figure out what the distance values are pretty easily by taking the distance from the epicenter, calculate that against the total radius of the blast itself and go from there… So, say the blast radius is 253 units and the enemy is 198 units (I’m trying to use random values) you take the distance and divide that from the total radius. (198/253=0.783)

… Even though it has been figured out, I still wish I paid better attention in math class. (Protip: if you want to be a game-dev, do your math homework.)

You just looking for the line of code that calculates it?
float outValue = 1 - 0.9f * (intValue * inValue)