FUN WITH FORMULAS

Posts

Pages: first 12345 next last
Red_Nova
The all around prick
8611
So. Damage formulas.

I've seen some pretty crazy and complicated ones from looking at database entries, and sometimes often it's hard to imagine what the creators were thinking (or what hallucinations they were having) when they came up with them. So why not share a few formulas and talk about why you like or dislike some of them? If you know something cool or an interesting technique, share that too!

Personally, I'm not a big fan of super complicated formulas. 90% of my damage calculations can be boiled down to:
a.atk - b.def

Swapping out attack and defense for their magic counterparts for magical attacks. It's simple, effective, and easy for players to understand just how much damage they'll inflict an enemy by doing a little math. Pair that with an ability to compare your character's stats to the enemy's in battle and players will have much more control over the party's actions than they probably would otherwise.

Though a flaw in this style is that you'd probably have to make some sacrifices when it comes to damage progression. Having enemies in later stages of the game with proportionally higher stats will mean there might not be a bigger difference in strengths than there was before, and the damage inflicted might not fluctuate as much as it would otherwise.

Did you know that you can use variables in your damage formulas? Adding
v[x]
in the formula will return the value of the variable you specified as x.

What's that? The help box in Ace already tells you that? Okay, well, here's another one: Did you know that you can inflict states in the damage formulas? Adding one of these two
a.add_state(x) b.add_state(x)

will add state x to either the user or the target! A more creative application can break the engine's normal scope limits by adding a semicolon
a.add_state(x); b.add_state(x)
to inflict a state on both the target and the subject!

Did you also know that you can actually use conditional branches in those formulas? Say you have a healing spell that also adds a powerful buff, but you only want the buff to apply when you're in battle. Here's how you do it:
if $game_party.in_battle; b.add_state(x); end; #rest of formula goes here


So there's some nifty things I found with damage formulas. What about you? What's a typical damage formula you find yourself falling back on? Why do you like it? Do you know some other cool non-numerical tidbits? Share them here.
kentona
Your mom is a hero
20844
What's a typical damage formula you find yourself falling back on?

*goes and looks up RM2k3's default unchangeable damage formula*

"that one."
I like a.atk^2/b.def - the simplest multiplicative formula there is. It lets you give enemies a defense and attack rating close to the players (or even more wild swings in either direction) without doing excessive/no damage.
kentona
Your mom is a hero
20844
Anywho, the correct answer is:
(100 / (100 + b.def)) * a.atk
I'm just going to steal Jude's post in reply to a blog I deleted a ways back because I really like it:

author=Jude
I think having two formulas goes against a transparent system. If you are that concerned with enemies dealing a non-trivial amount of damage even at high defensive values, consider scaling damage reduction from defense off of the idea of "effective HP," which is an increasingly popular solution in modern western RPGs. Basically, you scale the effectiveness of defense based on how many more hits it allows an actor to sustain rather than how much defense reduces the amount of damage per hit.

If that doesn't make sense, observe these formulas and this shitty unlabeled graph I made in ten seconds:

Modifier = 100 / (100 + Defense)
Damage = Modifier * Attack



In the graph, X represents the number of hits the target can sustain while Y represents the amount of armor the target has. For this graph I used a constant Attack of 100 and a constant Health of 1000. As you can see, every 10 points of Defense increases the number of hits a target can sustain by 1.



This second graph shows armor as X and damage as Y. At 0 armor, 100 damage is received. At 50 armor, 66 damage is received. At 100 armor, 50 damage is received. You can see how the formula has "diminishing returns" built into it without having to compare two different equations and taking the better of the two--the rules are consistent across the board which allows for transparency. Keep in mind that the "diminishing returns" are applied to damage mitigation, while the hits vs armor graph clearly shows there are no diminishing returns in the way that actually matters (how many hits can I take?).



author=Jude
author=GreatRedSpirit
Do you have any links to mechanics on games or what games use that use the scaling dmage to # of hits you talk about? I'm interested in it but I'm not sure where to start with educating myself further on the concept. The most related thing I've done is planning # of attacks to kill a character or enemy in enemy and encounter design. I'm definitely going to think about it for the future at least.
Off the top of my head: Diablo 3, World of Warcraft, League of Legends.

Oh... Links... Here's one Google found for me about League of Legends' formula, which is actually identical to the one I posted: http://www.reignofgaming.net/blogs/a-different-view/diff-the-ender/21061-diminishing-returns-fact-or-false-rp-contest


author=Jude
author=GreatRedSpirit
Cool, thanks Jude.
And there are a few ways you can manipulate this, but I think it's easiest to adjust the numerator in the modifier equation. For example....

10 / (100 + Defense) increases the number of hits by 1 for every 1 point of defense.

It all depends on how meaningful you want one point of defense to mean and how many hits you want your guys to be able to handle in general.

Diablo 3 actually uses two modifiers because it factors both armor and resistances into it, so the final damage equation is ArmorMod * ResistMod * Power = Damage. I don't know what the numerator/denominator are for the modifiers exactly as they are different for Armor and Resist because they scale differently (armor and resist have about a 10:1 ratio in D3), but it still resembles the 100 / (100 + Defense) formula. Also, because ArmorMod and ResistMod are multiplicative some interesting things emerge. Basically, if you have a lot of armor then resistance becomes more valuable... but if you have more resistance then armor becomes more valuable.

For elements though, I actually prefer the jRPG standard of double damage or half damage to something numerical, because I like elements when they are context and situationally relevant rather than another number you want to keep increasing with every piece of equipment, but that is just preference. It definitely works better for the MMO format where individual players are expected to take on a specific role for a diverse amount of content, though.

Edit: I found D3's:

Resistances estimated formula was:
Reduction % = 1 / (0.010003987 + (2.9972987 / Resistance))

Armor estimated formula was:
Reduction % = 1 / (0.0099975592 + (30.001944 / Armor))

Theirs is a little more complex but you can see how it still uses the defensive stat in the numerator to get that number of hits scaling. And you can see where I said armor and resist have a 10:1 ratio in effectiveness too. Basically, if you make a spreadsheet with columns for each of these variables you can find the right balance for your game, if you choose this method of damage calculation.

I really like this method in general but don't use it for Necropolis because one of my design goals is for there to be attacks which deal multiple-but-weaker hits to be more effective against lightly armored targets than single powerful attacks, and the best way to achieve this is a straight up (Attack - Defense) * Hits = Damage formula.



I also use arctan for accuracy algorithms because I <3 that curve (but I'd just as soon ditch accuracy entirely so w/evs)
Craze
i bet she's a diva with a potion popping problem
14360
atk * 2 - def. sometimes i add a base value so that there's some leeway for the defense to overtake attack but you still deal damage.

in general, i like your attack value to be the damage you do. so, a simple forumula like atk * 2 - def, assuming enemies have defense about equal to your attack, means you'll be dealing damage equal to your attack. this can help the player consciously or subconsciously realize when they're hitting a high-defense or low-defense enemy, too!

if an ff uses a formula, don't use it. it's shit and terrible. FEW STATS, LITTLE FUSS
yo i'm like real bad at math and shit so everyone contributing to this topic are the real mvps
Red_Nova
The all around prick
8611
author=kentona
Anywho, the correct answer is:
(100 / (100 + b.def)) * a.atk


author=GRS
beautiful breakdown


Holy crap GRS that is a excellent breakdown!

author=Craze
atk * 2 - def. sometimes i add a base value so that there's some leeway for the defense to overtake attack but you still deal damage.

in general, i like your attack value to be the damage you do. so, a simple forumula like atk * 2 - def, assuming enemies have defense about equal to your attack, means you'll be dealing damage equal to your attack. this can help the player consciously or subconsciously realize when they're hitting a high-defense or low-defense enemy, too!


So then, just from looking at this formula, what's the point of enemies even having defense? I guess you can have defense buffs and debuffs, but is there any other method of defense manipulation?

if an ff uses a formula, don't use it. it's shit and terrible. FEW STATS, LITTLE FUSS


Yeah, pretty much this.
Craze
i bet she's a diva with a potion popping problem
14360
Hmm, do you think that Dragon Quest games shouldn't have defense? That formula is literally the DQ formula multiplied by 8 (they use atk / 2 - def / 4). each piece of armor gives only a little defense compared to a single weapon's stat total, but weapons are a single slot for atk while armor typically has head/body/shoes depending on the dq game. i find that this applies for a lot of rpgs. my mvlympics project has a 4:3:2 ratio for the costs and stat power of weapons/body/head armors, for example (yes 5 > 4 but because not all stat budget goes into one stat, it works)

I would say that having a SINGLE mitigation stat is 100% pointless in any game, and that you're better off just having armor give straight damage reduction or more HP. If you have defense and magic defense, or steel vs psionic vs justice or whatever, I think that opens up far more interesting equips.

tbh i'd be happy with no mitigation stats on enemies ever because HP is SO much more transparent and immediately comprehensible than DEF/MDF. just use a little icon next to the name if they resist physical or lightning or whatever

but now i'm just spewing crazy talk so w/e
Since I use RM2K3, it isn't much use thinking about formulas since you have very little control over them without doing some pretty serious battle eventing. I've looked into Alter AILA Genesis's battle eventing and fuck that. Even though you can't change the formula, you can make it work a little more intuitively, and the numbers Craze uses in his guide are pretty good at doing that. I highly recommend it if anyone else is still using RM2K3: http://rpgmaker.net/articles/371/

So basically:

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

That said, I agree that using a simple formula based on ((x*atk)-def) is the best way of going about this. I don't really see the point in getting more complex than that.
Red_Nova
The all around prick
8611
author=Craze
Hmm, do you think that Dragon Quest games shouldn't have defense? That formula is literally the DQ formula multiplied by 8 (they use atk / 2 - def / 4). each piece of armor gives only a little defense compared to a single weapon's stat total, but weapons are a single slot for atk while armor typically has head/body/shoes depending on the dq game. i find that this applies for a lot of rpgs. my mvlympics project has a 4:3:2 ratio for the costs and stat power of weapons/body/head armors, for example (yes 5 > 4 but because not all stat budget goes into one stat, it works)

I would say that having a SINGLE mitigation stat is 100% pointless in any game, and that you're better off just having armor give straight damage reduction or more HP. If you have defense and magic defense, or steel vs psionic vs justice or whatever, I think that opens up far more interesting equips.

tbh i'd be happy with no mitigation stats on enemies ever because HP is SO much more transparent and immediately comprehensible than DEF/MDF. just use a little icon next to the name if they resist physical or lightning or whatever

but now i'm just spewing crazy talk so w/e


I'm not saying defense shouldn't be there, but that formula leaves me wondering what the purpose of defense is. Fighting an enemy with high defense doesn't seem like it'd have any difference in strategy than an enemy with low defense.
What I usually use now is:
(base * mult) + atk * (atk_base_rate * mult) - def * (def_base_rate)
Which is basically what craze said earlier, with the addition of a multiplier. I'm using this formula mainly for those skills that have 'higher levels' and such. The skills in the same hierarchy have the same base and atk_base_rate, and the value of mult determines what tier the skill is. def_base_rate usually stays constant, but may increase/decrease depending on circumstances.

Oh yeah for VXA, you can do pretty much anything you can do with the script editor, in the damage formula box. You can play a movie (like a cut-in scene before performing a planetary destruction jutsu or something), perform some fancy-schmancy animation stuff, and what have you. Problem is, the formula box is tiny, and has a character limit. To go around this, you extend the Game_Battler class in the script editor like:
class Game_Battler > Game_BattlerBase
  def yer_custom_formula_tat_iz_too_long
    do_stuff
    return damage_inflicted #don't forget this line if you want this to deal damage
  end
end

and just call that method in the formula box:
yer_custom_formula_tat_iz_too_long
author=Red_Nova
author=Craze
Hmm, do you think that Dragon Quest games shouldn't have defense? That formula is literally the DQ formula multiplied by 8 (they use atk / 2 - def / 4). each piece of armor gives only a little defense compared to a single weapon's stat total, but weapons are a single slot for atk while armor typically has head/body/shoes depending on the dq game. i find that this applies for a lot of rpgs. my mvlympics project has a 4:3:2 ratio for the costs and stat power of weapons/body/head armors, for example (yes 5 > 4 but because not all stat budget goes into one stat, it works)

I would say that having a SINGLE mitigation stat is 100% pointless in any game, and that you're better off just having armor give straight damage reduction or more HP. If you have defense and magic defense, or steel vs psionic vs justice or whatever, I think that opens up far more interesting equips.

tbh i'd be happy with no mitigation stats on enemies ever because HP is SO much more transparent and immediately comprehensible than DEF/MDF. just use a little icon next to the name if they resist physical or lightning or whatever

but now i'm just spewing crazy talk so w/e
I'm not saying defense shouldn't be there, but that formula leaves me wondering what the purpose of defense is. Fighting an enemy with high defense doesn't seem like it'd have any difference in strategy than an enemy with low defense.

This is why we have spells and skills and multiple weapon types and weaknesses and resistances and status effects and I could go on...
Craze
i bet she's a diva with a potion popping problem
14360
yeah red_nova i really don't get what you're saying lol. defense will still change the numbers? i mean look at metal slimes!

also regarding that article sated linked, i just cleaned it up a bit to be less mean. just don't read the comments.
kentona
Your mom is a hero
20844
author=Craze
yeah red_nova i really don't get what you're saying lol. defense will still change the numbers? i mean look at metal slimes!

also regarding that article sated linked, i just cleaned it up a bit to be less mean. just don't read the comments.

I like that sated and I came to exactly the same place at the same time about that change.
It's almost as if I got a notice about it because I'd posted in that article before!

EDIT:

"All your notices are about other people's games articles".
Red_Nova
The all around prick
8611
It was this statement that set off the confusion, particularly the bold segments:

author=craze
in general, i like your attack value to be the damage you do.so, a simple forumula like atk * 2 - def, assuming enemies have defense about equal to your attack, means you'll be dealing damage equal to your attack. this can help the player consciously or subconsciously realize when they're hitting a high-defense or low-defense enemy, too!

Now that I actually took the time to try out the formula, I see what you really meant. For some reason, I thought the assumption of enemies having defense equal to attack was true for all enemies, so I was wondering what the point of even having a defense stat was if it was just going to get cancelled out. I get what you're saying now. Sorry for the confusion!

Mental note: Make sure to check out formulas before commenting on them to avoid stupid mental lapses. Also, don't post less than thirty minutes after waking up.
Craze
i bet she's a diva with a potion popping problem
14360
yeah i didn't mean... everything, lol. just as a baseline!

the general idea when intereacting with craze as a dev is that i hate numbers and want the player to have to think about them the least amount possible. things should just make sense. this is why so many of my games are flexible character creation engines -- you have a basic guideline (Argent gets a lot of physical unique items in W&R, but Nynavae gets more Lunar items), and then your actual abilities tend to improve what they need to improve to succeed. to me, the most important thing about numbers in vidya is that the player can grasp and then ignore them. (and there's no mitigation stat in W&R, so your Lunar stat is your base Lunar damage (ability multipliers aside). hnnng i love it. simplicity is key)

obviously there are other schools of thought! even i didn't use to think this way -- i was convinced that ten+ attributes and complex formulae were the way to go. but fuck that shit. ain't nobody got time for that. now i make shitty, experiemental games with only two stats! (don't play obelisk: devilkillers, it is horrible. but you can try it if you want)

to be honest, my dragon to chase is to make an rpg with no text. at all. who needs fancy damage formulas when you're pitting your sword icons against their heart icons??? i haven't had the ephinanies or five required to make that work, though.



unity
You're magical to me.
12403
Is it possible with formulas to, say, damage an enemy and then heal the hero 50% of that damage, all in the same skill?
kentona
Your mom is a hero
20844
Something like this?

class Game_Battler > Game_BattlerBase
def yer_custom_formula_tat_iz_too_long
do_stuff to calculate damage_inflicted
hero.add_hp_or_whatevs(damage_inflicted/2)
return damage_inflicted #don't forget this line if you want this to deal damage
end
end
Pages: first 12345 next last