What math formula to use?

Started by
4 comments, last by Atrix256 13 years, 10 months ago
Generic question I know :)

Im planning a game where the user can modify his weapon with addons, and I need to calculate the value of the weapon.

Example: The player has a club which has a base damage of 4, but he can add nails to the club.
The first nail he adds increases damage alot, with 50% to a total of 6.
The second nail increases damage too, but not quite as much, say maybe 35%
And every additional nail adds less and less extra damage.

The important thing is that the sum of extra damage should never exceed 100%, but it might be close to it.

I havent done real math since I went to school, but I think I remember 2nd degree algebra had nice graphs that never quite hit a designed value?

Or am I grasping at straws here?

Be gentle :)
Advertisement
In short you want a convergent geometric series.

The one I know off the the top of my head that satisfies what you want is the old "Xeno's Paradox."

1/2, 1/4, 1/8, 1/16, ...

50%, 25%, 12.5%, 6.25%, ...

However, you will be better off if you just pick some number of max-upgrades and divide that up. There is a point that you will be wasting computational time on calculating something that will not have any significant meaning. That you will have to determine as you see how the game is played.
2nd degree algebra won't help much here. Exponential functions are what you are looking for:


with:
d = the damage of the club
a = the maximum extra damage of the club
b = a fraction, which defines how much damage the nails do
c = the damage of the club without nails
n = the total number of nails in the club

Your example:

gives:
n=0 d=4
n=1 d=7
n=2 d=8.5
n=4 d=9.625
n=8 d=9.977

If you have any questions, please ask...

Emiel
Exponential functions are exactly what I am looking for when calculating addons on weapons.

And just as excellent, Gustavef's method fits perfectly into my xp<>level calculations.

So now im upper happy.

Thanks to both of you :)
Quote:Original post by Thanamos
Exponential functions are exactly what I am looking for when calculating addons on weapons.

And just as excellent, Gustavef's method fits perfectly into my xp<>level calculations.

So now im upper happy.

Thanks to both of you :)


You should be aware that while using an equation is nice, you can lose a lot of control in the balancing of weapons. It's not that difficult to hard code values if you find the balance isn't how you like it, and it can be very computationally simple.
yep, listen to lazy, being able to specify values by hand is the superior method.

Being able to specify the values by hand you can put in the values of one of the before mentioned equation if you'd like to, but can also tweak them by hand if they dont quite match up to what you want.

If you were making a game where designers were working with you, they would definitely want the hand entered values so they could balance things (:

This topic is closed to new replies.

Advertisement