FUN WITH FORMULAS

Posts

Red_Nova
Sir Redd of Novus: He who made Prayer of the Faithless that one time, and that was pretty dang rad! :D
9192
Are we having fun yet?
author=Red_Nova
Are we having fun yet?

Yeah! Yeah! Yeah! No no.
@GRS> I'm think 'user' in there is 'self' or 'a', and 'item' could be retrieved from '@actions'. Though @actions contain instances of Game_Action, instead of Game_BaseItem, and that *might* just cause issues.

I remember fiddling with this stuff when I tried to do a 'rage' skill, which dealt more damage the more times it is used, and even more damage if used consecutively on the same target. It didn't work out well...
It's possible, I haven't looked into how GameActions all work but honestly fuck the original code. Having access to the backend (well, parts of) means having the choice of throwing out the garbage when needed. It also means being able to deal with other shortcomings (variance and multipliers) in a more streamline fashion. Looking into weird twisted solutions is a Rm2k style solution and I'd rather just flatten and try to do it better.
See, this is what happens when you give game developers more choice and freedom - complete frustration and roadblocks!

Hence:
author=kentona
What's a typical damage formula you find yourself falling back on?
*goes and looks up RM2k3's default unchangeable damage formula*

"that one."


Know your limits. Play within it.






(facetious post is facetious)
let me tell you what I think about how states are handled
Warning, lots of math ahead!

author=Irog
What matters with damage in general is how many hits the target can take. So the damage formula needs to be examined in parallel with HP.

For example, based on the reasoning on the standard formula, Damage = (100 / (100 + def)) * atk leads to

Hits = HP / Damage = HP * (100 + def) / (100 * atk)

so raising def by 1 is equivalent to raising HP by 1%. Thus, we could replace the damage computation formula by Damage = atk and have the armor giving extra % of HP instead of defense points.

You know, one cool thing about this topic is that it's forcing me to really think about how the math works rather than just churn the formulas through a bunch of possibilities in a spreadsheet and evaluate them that way (as I did originally).

I hadn't previously considered HP as part of the equation, but doing so makes it a lot easier to showcase the deficiencies of the formula you listed. So that's pretty awesome. Let's start again with your basic formula:

Hits = HP * (100 + DEF) / (100 * ATK)

What's actually happening here is that there are two scaling values in the numerator that determines durability (HP and DEF), but only one in the denominator to determine damage (ATK). Basically, in an extremely simplified sense, the formula is in the following form:

Hits = Durability ^ 2 / Damage

From that it's easy to see why the formula gets out of control at higher numbers. Eventually the squaring effect on the durability side completely overwhelms the damage side. For example, if Durability = 500, we'd need 250,000 Damage for the formula to balance. That's obviously ridiculous. One way to bring it back to equilibrium would be the following:

Hits = Durability ^ 2 / Damage ^ 2

After the revision, both sides scale equally effectively. Now consider the formula I recommended earlier:

Damage = (ATK ^ 2) / (DEF + ATK)

Hits = HP * (DEF + ATK) / ATK ^ 2

Because I'm squaring ATK, I'm compensating for the fact that HP and DEF are multiplied in the numerator, which in turn allows the formula to scale to any amount without getting out of control. However, the observant among you might notice I have an extra + ATK in numerator, which (if we follow the prior formula) should be for "durability," not damage. What's up?

What's up is that I made a mistake. But it wasn't very apparent in my testing because additive values tend to get hidden by the size of the multiplicative values. This "hiding" effect is actually one of the reasons the original (100 / (100 + DEF)) * ATK formula appears to behave properly when in fact it doesn't. To illustrate, let's rewrite the original formula again, but this time put Hits and ATK on the same side of the equation.

Hits * (100 * ATK) = HP * (100 + DEF)

Next let's eliminate the muddying 100 values so we can more clearly see what's going on with the variables:

Hits * ATK = HP * DEF

We can now see clearly that if Hits is held constant, we're more or less saying that ATK = HP * DEF. Eww. As I previously suggested, one solution to this is to hold DEF constant. And now we see why this works. Or we could hold HP constant instead, which may sound odd, but anyone familiar with Warsong knows it's been done before.

Another option games have employed is to add an additional multiplier for ATK rather than hold constant either HP or DEF. If we use the constant 100 for this ATK multiplier, the new formula becomes:

Hits * ATK * 100 = HP * DEF

This is only a temporary solution, however, since once HP or DEF far exceed 100 the formula falls apart. It also doesn't work with small values. If HP = 100, DEF = 10, and Hits = 10, then ATK = 1. That's unacceptable. So the formula gets patched again with an extra +100 to DEF.

Hits * ATK * 100 = HP * (DEF + 100)

As I hope you're noticing, we're not actually solving anything at this point. Instead we're just adding in numbers to cover up the problem and hope that people won't notice. It seems to work with certain numbers (namely those we're testing), but the fundamental design of the formula is off. I feel we can do better.

I started looking at how various other games handled this. Diablo 3 appears to have dropped DEF altogether. WoW and Skyrim both simply cap your DEF (technically they cap "damage reduction," but that's essentially what DEF is in this case). And then there's League of Legends.

League of Legends is a mess when it comes to calculations, and I'm not going to go into all the weird junk they pull to try to force things to add up properly. Instead, I'm just going to mention something clever they do to solve the above issue: add multiplicative effects to ATK. Namely they include both Attack Speed and Critical Strike, making their formula:

Hits * (ATK * Attack Speed * Critical Strike Chance) * 100 = HP * (DEF + 100)

Now the astute among you may see that we still have an unbalanced formula, since there are three multiplier effects on the left (ATK, Attack Speed, Crit Chance) and only two on the right (HP and DEF). League of Legends "corrects" this by capping both Attack Speed and Critical Strike at 2.5 each, but I wouldn't really say that's a sound correction. But it is another take on how one might create logical scaling on both sides of the formula. For example, simply eliminate Crit Chance and we have something that looks perfectly reasonable:

Hits * ATK * Attack Speed = HP * DEF

So I hope that clears things up for some people, and maybe opens up some new possibilities for what formulas you can use for your game. I, for one, am pretty excited about all of this and will be making adjustments. To what I'm not entirely sure, but now that I have a better understanding of the math behind it all it should be easier to avoid dumb things like make one's durability scale off of the enemy's ATK.


author=Irog
In the development of MinST, I started with constant damage formula, thinking of enhancing it later with attack and defense dependencies. But it didn't happen due to the limitations of console display. I'm now thinking to push the simplicity even further : have all attacks causing 1 damage so HP become a direct measure of how many hits the unit can take. What do thing about it?

I'm a bit confused here. If all attacks do exactly one damage, what's the purpose of having different weapons, spells, abilities, or even attack stat? You could give players multiple attacks per round, but isn't that the same thing as saying they're just doing multiple damage?
author=hedge1
Damage = (ATK ^ 2) / (DEF + ATK)

Hits = HP * (DEF + ATK) / ATK ^ 2

Because I'm squaring ATK, I'm compensating for the fact that HP and DEF are multiplied in the numerator, which in turn allows the formula to scale to any amount without getting out of control. However, the observant among you might notice I have an extra + ATK in numerator, which (if we follow the prior formula) should be for "durability," not damage. What's up?

What's up is that I made a mistake. But it wasn't very apparent in my testing because additive values tend to get hidden by the size of the multiplicative values. This "hiding" effect is actually one of the reasons the original (100 / (100 + DEF)) * ATK formula appears to behave properly when in fact it doesn't. To illustrate, let's rewrite the original formula again, but this time put Hits and ATK on the same side of the equation.


Damage = (ATK ^ 2) / (DEF + ATK) will always result in damage going up when ATK goes up, unless you plug in negative numbers that is. Further, doubling ATK and DEF will always double the damage, tripling them will tripple the damage and so on. Unlike the (100 / (100 + DEF)) * ATK formula, (ATK ^ 2) / (DEF + ATK) will keep behaving.

To properly analyze the formula, lets take you "Hits" formula and rewrite it:

Hits = HP * (DEF + ATK) / ATK ^ 2
Hits = HP * ((DEF / ATK ^ 2) + (ATK / ATK ^ 2))
Hits = HP * ((DEF / ATK ^ 2) + (1 / ATK))
Hits = HP * DEF / ATK ^ 2 + HP / ATK

Rewritten like this, ATK only appears as a divisor and now suddenly durability no longer appears to increase as ATK increases. This has always been the case. You need to be careful when the same variable appears as both dividend and divisor.
@ hedge1

Sorry for confusing you. I forgot to mention the Action Point system of my game.

Each unit has Action Points and consumes some to move and attack. Units don't have attack or defense stat but differ in HP, Action Point cost per move, and weapon range. Depending on how well the player moves, the unit can deliver 1 to 3 attacks in a round.

I want the player to focus on strategy and moves so I'm thinking to make the damage system as simple as possible. And I wonder how much I should simplify the damage computation formula.
Question! How do I utilize some of these formulas for my game (ACE)?

Like, if I wanted to use ATK / (DEF / ATK + 1) , where would I put it, and how would I adjust it for skills?
Red_Nova
Sir Redd of Novus: He who made Prayer of the Faithless that one time, and that was pretty dang rad! :D
9192
The top right section in the skills tab is where you place your formula. Just copy/paste it into all the skills you want that particular formula to apply to, and make whatever adjustments you deem fit for different skills. The formula you see in the linked screen is the attacker's attack stat minus the target's defense stat, then subtract the result by the target's current MP.
author=Crystalgate
Damage = (ATK ^ 2) / (DEF + ATK)will always result in damage going up when ATK goes up, unless you plug in negative numbers that is. Further, doubling ATK and DEF will always double the damage, tripling them will tripple the damage and so on. Unlike the (100 / (100 + DEF)) * ATK formula, (ATK ^ 2) / (DEF + ATK) will keep behaving.

To properly analyze the formula, lets take you "Hits" formula and rewrite it:

Hits = HP * (DEF + ATK) / ATK ^ 2
Hits = HP * ((DEF / ATK ^ 2) + (ATK / ATK ^ 2))
Hits = HP * ((DEF / ATK ^ 2) + (1 / ATK))
Hits = HP * DEF / ATK ^ 2 + HP / ATK

Rewritten like this, ATK only appears as a divisor and now suddenly durability no longer appears to increase as ATK increases. This has always been the case. You need to be careful when the same variable appears as both dividend and divisor.

I re-read your post like three times thinking I made another snafu, but I'm actually alright, fortunately, though still in a position where I'm agreeing with you that I should recant my earlier statement.

So here's where I'm OK: I wasn't saying that increasing ATK with the formula wouldn't increase damage. I always knew more ATK was a good thing.

Here's where I'm wrong: I was saying that ATK was impacting the formula in ways that weren't beneficial.

I would have responded sooner to your statement but it actually took a bit of time to figure out exactly why I had included the extra +ATK initially (go me for not taking notes on the topic). On the surface it looks like a big mistake, since it garbles the numbers and eliminates the ability to make player-sensical number scaling.

On the flip side, however, it prevents ATK from scaling out of control if a power-leveled character hits an early game target. Without the extra +ATK, a mere 548 ATK could deal 30,000 damage to a 10 DEF target. I don't mind easily killing a 10 DEF target. But I do mind how awkward it feels for 548 ATK to do 30,000 damage, especially when it's generally doing around 550 damage. Furthermore, by raising DEF from 10 to 50, damage falls to just 6,000. Again, that feels really awkward (even though on a hits-to-kill basis it makes perfect sense).

So to prevent the awkwardness, I included the extra +ATK. Now your 548 ATK does 1076 damage instead of 30,000. Not as much fun, but much more expected. It also helps prevent an unexpectedly powerful foe from doing a random party wipe.

On final thing to say is that I appreciate your rejiggering of the formula. It's really nice how you can present a point through the way the mathematical formula is presented.


author=Irog
@ hedge1

Sorry for confusing you. I forgot to mention the Action Point system of my game.

Each unit has Action Points and consumes some to move and attack. Units don't have attack or defense stat but differ in HP, Action Point cost per move, and weapon range. Depending on how well the player moves, the unit can deliver 1 to 3 attacks in a round.

I want the player to focus on strategy and moves so I'm thinking to make the damage system as simple as possible. And I wonder how much I should simplify the damage computation formula.

My favorite game of all time is Shining Force II, and one of the reasons is because it is a game heavily focused on map placement of your characters, not on their raw power or general ability usage. It ends up being a simple formula that's easy to learn and difficult to master. And it prevents you from ever having Orlandu just running around winning the battle for you solo.

So in that regard, I endorse your game design, and I think it could work. Three comments though.

First, if you're going to have multiple attacks in a round, ensure they're fast and don't waste time. I'd say even the sword slashes from FFT would be too long. Look for animations of 1-2 seconds or less.

Second, make sure that the optimal strategy isn't always to move as little as possible to maximize damage. Since 3 attacks is literally 300% damage versus one, it's easy to just sit back and wait for the enemy to move towards you and do one damage, while you counter for three damage next turn.

Third, a good rule to follow is the simpler your game, the shorter it should be. So you're probably not looking at a long game. That's probably for the best though, since it gives you a greater chance to finish it and, if it's popular, gives you a reason to make a sequel.


author=Feldschlacht IV
Question! How do I utilize some of these formulas for my game (ACE)?

Like, if I wanted to use ATK / (DEF / ATK + 1) , where would I put it, and how would I adjust it for skills?

I'd suggest using 2 * ATK / (DEF / ATK + 1) instead. This way, if ATK = DEF, you'll do damage = ATK. Otherwise, damage will be half of your ATK. Up to you though.
author=hedge1
Here's where I'm wrong: I was saying that ATK was impacting the formula in ways that weren't beneficial.

I would have responded sooner to your statement but it actually took a bit of time to figure out exactly why I had included the extra +ATK initially (go me for not taking notes on the topic). On the surface it looks like a big mistake, since it garbles the numbers and eliminates the ability to make player-sensical number scaling.

On the flip side, however, it prevents ATK from scaling out of control if a power-leveled character hits an early game target. Without the extra +ATK, a mere 548 ATK could deal 30,000 damage to a 10 DEF target. I don't mind easily killing a 10 DEF target. But I do mind how awkward it feels for 548 ATK to do 30,000 damage, especially when it's generally doing around 550 damage. Furthermore, by raising DEF from 10 to 50, damage falls to just 6,000. Again, that feels really awkward (even though on a hits-to-kill basis it makes perfect sense).


A better way to control this is to feed in actor or target level (or both) into the formula, instead of using attack again. It's a very predictable number you can design around too.
author=Feldschlacht IV
Question! How do I utilize some of these formulas for my game (ACE)?

Like, if I wanted to use ATK / (DEF / ATK + 1) , where would I put it, and how would I adjust it for skills?


ATK / (DEF / ATK + 1) is written as a.atk / (b.def / a.atk + 1). As for the rest of the skills, it depends on what you want them to do. Do you want a skill that deals x% of a standard attack, one that deals +50 damage, but the +50 damage is also reduced by defense or a skill that penetrates 50% of enemy defense? If you can't figure out how make a skill work in a certain way, I can walk you trough it.
okay, I found this formula in my notes txt file, with no explanation or source:

(5+slv)*sqrt(a.str/b.vit*(a.atk*x*skill_power)*a.lv/16) - b.def


thoughts? anyone know what this is from?
Red_Nova
Sir Redd of Novus: He who made Prayer of the Faithless that one time, and that was pretty dang rad! :D
9192
My eyes popped out of their sockets trying to decipher that. How does that even work?!
Craze
why would i heal when i could equip a morningstar
15170
it looks like a final fantasy-based formula. they LOVE square roots and multiples of 8.
unity
You're magical to me.
12540
author=Red_Nova
My eyes popped out of their sockets trying to decipher that. How does that even work?!


Yeah, my brain hurts just trying to parse that >.<;;;

author=Craze
it looks like a final fantasy-based formula. they LOVE square roots and multiples of 8.


Dammit, Square!
unity
You're magical to me.
12540
*brain explodes *