What kind of damage formula can I use for defense to achieve a highly scalable potency?

I'm a bit stuck on one particular aspect of my game, and that's how defense is factoring into how damage is calculated. I already know how I want the raw damage input to be calculated: The attack stat the skill uses, plus any buffs/debuffs applied directly to the stat (such as attack up, attack down), multiplied by the skill's Power (a number such as 100 that represents the true multiplier, which in that case would be 1x, 170 would be 1.7x, etc.). Then after the defense reduces that, the total damage would be further multiplied by active defensive buffs, elemental resistances, or status effects that enhance damage (such as being frozen doubling all physical damage taken, for example). This would produce the final damage amount.

What I want is for the characters' stats to be linearly scaled from a low value to a very high value (think going from 30 attack at level 1 to 3000 attack at level 100), where each level gives an across-the-board percentile bonus to all stats, meaning characters will maintain their statistical ratios across all levels. There is one defensive stat, with much of the bulk of defensive play coming from active skills and random chance mechanics like dodging and blocking (which reduce damage instead of negating it, because there is no such thing as missing in this game --- you always deal damage if you attack).

The part I have an issue with is that I've always worked with formulas that assume defense is static, not something that grows. Making a formula that gives flat reduction with percentage reduction on top is easy and works for that, but it doesn't scale well and won't work here, so I can't use my usual methods. The effect of attacking stats on damage is currently quadratic, but I'm not sure how to make defense scale quadratically to keep up with it. I want defense to have a logarithmic effect on the amount of damage taken proportional to the raw damage (attack times power), but only have to scale based on its statistical value rather than have a power multiplier like attacks do. My initial desire was to have something like Fallout 4's ratio-based defense, but I'm not math-savvy enough to figure that kind of thing out on my own or know if it would actually achieve what I want. That being something that can scale very high and have extreme differences in attack and defense without breaking the game (certain skills/characters doing no damage while others one-shot the enemy). I would have consulted Epic Battle Fantasy's method since that's what I'm mainly inspired by, but I can't find any documentation on that.

So, for the more mathematically inclined among you, how can I achieve this? If you need more details, I'll give whatever I have.
skill's power multiplier (usually 1.0) * user's attack * user's attack / target's defense.

as long as attack and defense are equal your damage always equals your attack stat * the skill's multiplier, regardless of what number you use. it can be 10 or 100000.

epic battle fantasy uses skill's power * user's attack / target's defense. but enemies have single digit defense compensated by huge HP.
skill's power multiplier (usually 1.0) * user's attack * user's attack / target's defense.

as long as attack and defense are equal your damage always equals your attack stat * the skill's multiplier, regardless of what number you use. it can be 10 or 100000.

epic battle fantasy uses skill's power * user's attack / target's defense. but enemies have single digit defense compensated by huge HP.
Thank you, this fixed almost every issue I was having. The original formula I wanted to use was ((Attacker Stat x Attacker Buffs/Debuffs) x Power) x (100 / (100 + ((Defender Defense x Defender Buffs/Debuffs) / 31.4159) ^ 2)) x Defender Elemental Resistances x Status Bonuses x Defender Active Damage Reduction = Final Damage which was vastly over-complicated and didn't do what I wanted it to unless HP stopped scaling, which I wanted it to. The one you gave me also makes it very easy for the player to crunch numbers.

Also, if I could ask another question since I'm on the topic of formulas...

I have an agility stat that I want to determine evasion chance and critical hit rate by comparing itself to the enemy's. If I want two opponents of equal agility to have a 50% chance of dodging each others' attacks (which is damage reduction instead of a miss), how can I compare their agility stats to get their evasion % chance without going above 100% or below 0%?
for that agility check I'd use 2 formulas:

if attacker's AGI <= target's AGI
hit chance = 0.5 * (attacker's AGI / target's AGI)**2
else
hit chance = 1 - 0.5 * (target's AGI / attacker's AGI)**2

with that if attacker and target have the same AGI the hit chance is 50%.
if attacker has double the target's AGI the hit chance is 87.5%.
if target has double the attacker's AGI the hit chance is 12.5%.
as the difference in AGI grows the hit chance gets bigger or smaller but it never hits 100% or 0%. because of math.

if you want smaller differences in AGI to be more important you can replace the **2 for **3 or **4, it makes hit chance change faster but still never hits 0% or 100%.

how you'd actually implement this depends on what engine you're using. it should be easy if you know where to look. or just say what engine and ask how lol
for that agility check I'd use 2 formulas:

if attacker's AGI <= target's AGI
hit chance = 0.5 * (attacker's AGI / target's AGI)**2
else
hit chance = 1 - 0.5 * (target's AGI / attacker's AGI)**2

with that if attacker and target have the same AGI the hit chance is 50%.
if attacker has double the target's AGI the hit chance is 87.5%.
if target has double the attacker's AGI the hit chance is 12.5%.
as the difference in AGI grows the hit chance gets bigger or smaller but it never hits 100% or 0%. because of math.

if you want smaller differences in AGI to be more important you can replace the **2 for **3 or **4, it makes hit chance change faster but still never hits 0% or 100%.

how you'd actually implement this depends on what engine you're using. it should be easy if you know where to look. or just say what engine and ask how lol
Thanks. I've been collaborating with some other friends of mine who know math better than me. They also gave me a formula similar in function to this, but that one was apparently a sigmoid function that goes Evasion Chance: 1 / (1 + (Evasiveness/Enemy Evasiveness * 0.5/(1-0.5)) ^ -2) which would form a float which I would then multiply by 100 and then use a random number generator between 1 and 100, a result lower than the evasion chance causing evade to activate on that hit.

I ended up wanting to split Agility into two evasiveness and critical stats so I could make agility govern both but make them occur at different rates, so now I have that one formula and a critical hit one that uses the critical stat instead of the evasiveness stat, resulting in a similar distribution to what you described but biased more towards a 10-20% critical chance. Not sure if this is more or less complicated, but both of them seem to work fine.

As for engine, I'm going to be using RPG Maker to test out some of the more basic things and get a feel for what I want in this game, but I'll have to move to Godot afterwards because RPG maker just isn't capable of some of the things I want. A shame, considering I know it fairly well.

Honestly, the formulas were the hardest part so far. Everything else has proven to be relatively easy, and it probably will be until I have to start implementing all the programming. Have to write out the story before I do that.

Original thread: https://forums.rpgmakerweb.com/threads/what-kind-of-damage-formula-can-i-use-for-defense-to-achieve-a-highly-scalable-potency.182218/