Editing Damage Formulas

  • Thread starter Thread starter Sega Chief
  • Start date Start date
Status
Not open for further replies.
S

Sega Chief

Guest
In short, is this possible? I think that a re-balance of FF7's battles needs something to be done with it's formulas. I've done what I can with fine-tuning, cuts, and other tricks but that can only go so far.

What I was specifically interested in was cutting down the Physical formula's dependency on Level, repurposing formulas for pulling other stats for calcs that use VIT or SPR instead of STR or MAG (I saw Stamina being used in a FF6 mod in place of Vigor/Magic for certain attacks and healing spells which created some interesting depth), adjusting the multipliers for Ultimate Weapon formulas, and giving magic attacks a critical hit check. How viable would any of these be?
 
I can tell you that changing calculations directly requires exe editing. Some of it can be difficult.

All of these are hard coded.
 
I can tell you that changing calculations directly requires exe editing. Some of it can be difficult.

All of these are hard coded.
Yeah, I've got a tool that I've used before to make small changes to the exe. What I'm looking for is some addresses or documentation on how the formulas are structured. So for instance is it possible to make the formula reference other stats, change the numbers used for the calculation, or to 'dummy out' parts of it? If there's no info on where the formulas are stored, do you have any recommendations for how to figure out where they are?
 
I love how that page isn't linked to by the FF7 section, I had no idea it existed.
 
Yeah, I've got a tool that I've used before to make small changes to the exe. What I'm looking for is some addresses or documentation on how the formulas are structured. So for instance is it possible to make the formula reference other stats, change the numbers used for the calculation, or to 'dummy out' parts of it? If there's no info on where the formulas are stored, do you have any recommendations for how to figure out where they are?
That page could use some offsets, couldn't it? As for other stats, that's mostly based on whether or not you make it a physical or magical action. There are also some hard-coded considerations in there, but those are documented. I can offer some help if you tell me what you need.

I love how that page isn't linked to by the FF7 section, I had no idea it existed.
Because it's very technical. Most people that come to the wiki don't want that level of detail.
 
That page could use some offsets, couldn't it? As for other stats, that's mostly based on whether or not you make it a physical or magical action. There are also some hard-coded considerations in there, but those are documented. I can offer some help if you tell me what you need.
Offsets are the spice of life.

I guess what I'm needing is the addresses for as many of these functions as possible, or some advice on how to track them down and make the changes. I'm hoping the physical formula is easy to change at least, though I can see the multipliers being a problem if there's no space to extend the calculation used for some of them (though a formula adjustment might be enough on it's own; the major problems they cause mostly comes in when damage starts to creep toward 5000).

So what I've been doing is some number crunching and looking for a way to adjust the physical attack formula that isn't too drastic and which a) pushes the emphasis away from character level and more toward the actual character attack instead and b) falls within some nice ranges for progression based more heavily on equipment. Here's what I've got:

[Old Formula]
x = ( Actor's Level * Actor's (M)Attack ) / 32
y = ( Actor's Level + Actor's (M)Attack ) / 32
z = Actor's (M)Attack + ( x * y )
z = z * ( 512 - target's defense ) * Attack's Power
Damage = z / 4096

[Proposed Fix]
x = ( Actor's Level + Actor's (M)Attack) / 2
y = ( Actor's Level + Actor's (M)Attack )/ 32
z = Actor's (M)Attack + ( x * y )
z = z * ( 512 - target's defense ) * Attack's Power
Damage = z / 4096

The value in X loses the multiplication between Lv and Attack, with a smaller division, which makes it scale a lot less while still getting a reasonable value out for the rest of the calculation to use. This is the scaling of physical damage using the proposed formula (hoping I've worked this out right):

[Lv.99 + 200 Attack vs. 100 Defence]
X = 150
Y = 9
Z1 = 1550
Z2 = 10316800
Damage = 2519

[Lv.99 + 200 Attack vs. 200 Defence]
X = 150
Y = 9
Z1 = 1550
Z2 = 7737600
Damage = 1889

[Lv.75 + 200 Attack vs. 100 Defence]
X = 138
Y = 9
Z1 = 1442
Z2 = 9505664
Damage = 2343

[Lv.50 + 200 Attack vs. 100 Defence]
X = 125
Y = 8
Z1 = 1200
Z2 = 7910400
Damage = 1931

[Lv.25 + 200 Attack vs. 100 Defence]
X = 113
Y = 7
Z1 = 991
Z2 = 6532672
Damage = 1595

[Lv.25 + 100 Attack vs. 100 Defence]
X = 63
Y = 4
Z1 = 352
Z2 = 2320384
Damage = 567

[Lv.10 + 200 Attack vs. 100 Defence]

X = 105
Y = 7
Z1 = 935
Z2 = 6163520
Damage = 1505

[Lv.10 + 50 Attack vs. 100 Defence]
X = 55
Y = 2
Z1 = 485
Z2 = 1054720
Damage = 258

So there's a nice upper range of 2500 (excluding multipliers) at the top levels + equipment, while the lower levels deal good chunks of damage with a decent low-high range that makes your set-up much more noticeable during the early stages of the game (whereas before you'd be looking at a difference of maybe 20-50 damage going through Lv.7-20).

Another part of getting physical attacks balanced properly is dealing with the crazy multipliers and reductions that the game adds (and stacks) to damage. As numbers get higher, these reductions/multipliers become more and more potent which makes it nearly impossible to get things under control. Reducing these %s would help things immensely:

Critical Hit:
Damage = Damage * 3 / 2 (1.5% increase)

Berserk:
Damage = Damage * 4 / 3 (1.25 increase)

Long Range Reduction
Damage = Damage / 4 * 3 (25% reduction)

Defend Reduction
Damage = Damage / 4 * 3 (25% reduction)
 
Random thought: of the built in formula, X5 is pretty simple [base of Damage = (Actor's (M)Attack + Actor's Level) * 6 + (Attack's Power * 22) - which doesn't take many things into account].

It's possible in theory to change the actor's attack and level from an AI script, so you could set your attacks to always use formula 5 with some standard attack power, and then from within the AI script, alter the enemy's Attack value to whatever you wanted to effectively implement your own formula without having to alter the exe. Want to do different damage when the player is level 50+? Check for that in your AI script and increase the enemy attack accordingly.

For that matter, you could also alter the enemy's defence values in their setup scripts based on player level if you wanted to tune how easy they are to harm.

(Plug: that's something I'd like to build support for into Conformer to make it easier to do.... ;)

Of course this is all based on the enemy's AI. I'm not familiar with how much of this, if any, you can do from the player's side of things.
 
That page could use some offsets, couldn't it? As for other stats, that's mostly based on whether or not you make it a physical or magical action. There are also some hard-coded considerations in there, but those are documented. I can offer some help if you tell me what you need.
Because it's very technical. Most people that come to the wiki don't want that level of detail.
Everything on there is very technical so that reason makes no sense to me, if someone can understand all the stuff about file formats then this damage algorithm is simple.
 
Random thought: of the built in formula, X5 is pretty simple [base of Damage = (Actor's (M)Attack + Actor's Level) * 6 + (Attack's Power * 22) - which doesn't take many things into account].

It's possible in theory to change the actor's attack and level from an AI script, so you could set your attacks to always use formula 5 with some standard attack power, and then from within the AI script, alter the enemy's Attack value to whatever you wanted to effectively implement your own formula without having to alter the exe. Want to do different damage when the player is level 50+? Check for that in your AI script and increase the enemy attack accordingly.

For that matter, you could also alter the enemy's defence values in their setup scripts based on player level if you wanted to tune how easy they are to harm.

(Plug: that's something I'd like to build support for into Conformer to make it easier to do.... ;)

Of course this is all based on the enemy's AI. I'm not familiar with how much of this, if any, you can do from the player's side of things.
Does X5 check for things like Berserk, Critical hits, and long range though? I thought it was used with a magic formula. And while you can change the actor's level and attack stats in-battle, I'm not sure if you can tell the AI to use a different damage formula; at least, I don't have anything in my OP Code notes about it. Adjusting every character/enemy's attack, defence, and level prior to every attack would take a very long time to implement as a system. Though I could maybe add a calc into the character AI that divides down their Level by some amount so that it's less potent in physical damage calculations but that would mess around with Magical accuracy/evasion, stealing, etc.
 
Does X5 check for things like Berserk, Critical hits, and long range though? I thought it was used with a magic formula. And while you can change the actor's level and attack stats in-battle, I'm not sure if you can tell the AI to use a different damage formula; at least, I don't have anything in my OP Code notes about it. Adjusting every character/enemy's attack, defence, and level prior to every attack would take a very long time to implement as a system. Though I could maybe add a calc into the character AI that divides down their Level by some amount so that it's less potent in physical damage calculations but that would mess around with Magical accuracy/evasion, stealing, etc.
X5 should not do Berserk and Critical. It is only used as a magic formula in a vanilla game, but 15 suddenly becomes physical with physical attack accuracy. If that page doesn't state it checks for something then it doesn't.
There isn't any way to change the action's damage calculation before the action is performed. If you want another action with a different damage calculation then you'll have to create a new one.
 
X5 should not do Berserk and Critical. It is only used as a magic formula in a vanilla game, but 15 suddenly becomes physical with physical attack accuracy. If that page doesn't state it checks for something then it doesn't.
There isn't any way to change the action's damage calculation before the action is performed. If you want another action with a different damage calculation then you'll have to create a new one.
I thought so; changing it in AI for every enemy would be far too cumbersome in any case. A lot of enemies are already using AI to adjust stats for other things so it would turn into a bit of a mess.

So is it possible to adjust the formulas stored in the .exe? Do you happen to know the offset they're stored at? Even with just that, I can start looking at it and try to figure it out.
 
So is it possible to adjust the formulas stored in the .exe? Do you happen to know the offset they're stored at? Even with just that, I can start looking at it and try to figure it out.
In some fashion, yes, they can be edited. I know where they are all stored too, but I can't offer those until tomorrow.

Everything on there is very technical so that reason makes no sense to me, if someone can understand all the stuff about file formats then this damage algorithm is simple.
Quite true, but it IS linked to from the damage calculation page. It's not a straight shot. I still have two or three wiki pages of RAM values that aren't linked to anywhere. Check my contributions if you can figure out how to get to my user page.
 
Random thought: of the built in formula, X5 is pretty simple [base of Damage = (Actor's (M)Attack + Actor's Level) * 6 + (Attack's Power * 22) - which doesn't take many things into account].
I haven't tried it but off the top of my head, wouldn't X4 [MaxHP * (Strength / 32)] be better for that?
You could just set the strength to 32 and then perform whatever damage calculation you like in your script, temporarily store it to the using actor's max hp, perform the attack and then reset the maximum hp back to its original value.

About Conformer, would a minor quality of life update to allow empty / comment-only lines inside functions be a possibility in the not too remote future?
Awesome initiative on that project regardless, I was pondering writing a simple compiler for the battle scripts myself but... well, I would probably never have gotten around to it so great that someone did  ;D
 
Not sure if this already discussed but... Enemy Target Magic defence is doubled on battle start at 5D08DF (Ally data does not get doubled when they are target).

Urgh... I bet it's doubling all enemy stats too.  Wanna have a peak, NFITC1 :P
 
Last edited:
Physical Defense is doubled at 5D08CE, but that's the only other one.
 
Thanks :) Why does it do this?  Is this just like a lame last minute tweak they came up with?
 
Thanks :) Why does it do this?  Is this just like a lame last minute tweak they came up with?
There's literally no point to it as it could be offset by some divisor later in the calculation.

ex:
Code: [Select]
Code:
x = ( Actor's Level * Actor's (M)Attack ) / 32y = ( Actor's Level + Actor's (M)Attack ) / 32z = Actor's (M)Attack + ( x * y )z = z * ( 256 - target's defense ) * Attack's PowerDamage = z / 2048
See? By changing the divisor at the last slot there and the defense modifier it will still produce the same results.
f1(x,y,z) = f2(x,y,z)
Unless there's some insane reason that f1 is somehow faster than f2, there is literally no reason to write an algorithm like this.
 
Also a note.  I had to change these for my mod:

{Menu potion, hi-potion, x-potion, ether, turbo ether to 25, 100, 1000, 10, 100
00716D83 = 6A 19
00716E11 = 6A 64 90 90 90
0071716F = 68 E8 03 00 00
00716EA2 = 6A 0A
00716F30 = 6A 64

{menu HP, MP
#6CBA6A
#6cbbbf
 
One more note.  This time, how the stupid stat section works.  People may find this useful.

Primary Stats
Code: [Select]
Code:
Strength = Base + LvBonus + MateriaBonus + WepArmAccBonus + PowerSourceAgility = Base + LvBonus + MateriaBonus + WepArmAccBonus + SpeedSource Vitality =  Base + LvBonus + MateriaBonus + WepArmAccBonus + GuardSource Magic = Base + LvBonus + MateriaBonus + WepArmAccBonus + MagicSourceIntellect = Base + LvBonus + MateriaBonus + WepArmAccBonus + MindSource Luck = Base + LvBonus + MateriaBonus + WepArmAccBonus + LuckSource
Secondary Stats
Code: [Select]
Code:
Attack = Strength + WeaponStrengthAccuracy (%) = WeaponAccuracy Defence = Vitality + ArmourDefenceEvasion (%) = (Agility / 4) + ArmourEvasionMagic Attack = MagicMagic Def = Intellect + ArmourMagicDefenceMagic Evasion (%) = ArmourMagicEvasion
OK, let's just get this out of the way...  Primary stats are largely worthless in working out what your battle strengths are.  The secondary stats are what you should be looking at, but they use the primary stats in their calculations.  Agility and Luck are the exceptions, as they have no secondary stat.

Take the Strength stat as an example...

Code: [Select]
Code:
Strength = Base + LvBonus + MateriaBonus + WepArmAccBonus + PowerSource
Base (initial Strength given to you at start of game)
LvBonus (Strength added at each level)
MateriaBonus (Strength added or subtracted by equipped materia)
WepArmAccBonus (Strength added by equipping Weapon / Armour / Accessory.  Note that only Accessories come with a description informing the player of the stat bonus.  This is probably an oversight).
PowerSource (+1 for each source, maximum sources allowed = 255).

So all that is used in determining the Strength stat. 

Next, the secondary stat, Attack:

Code: [Select]
Code:
Attack = Strength + WeaponStrength
The Weapon's strength is added.  Note that this is NOT the same as the bonus that was added to Strength.  This is the actual power of the weapon, which you can see in Equip.

The Attack stat, like all secondary stats, is limited to 255.  So what does that mean?  It means that as long as Attack is 255, that's as good as it gets.  Giving your character 255 power sources + other bonuses is worthless if the Attack stat is already 255.

What you have to realize is that the game designers have made this whole system more complicated than it needs to be.  All the stats can be amalgamated together and the final stat menu will look like this:

Code: [Select]
Code:
AttackAttack Accuracy (%)DefenceEvasion (%)Magic AttackMagic DefenceMagic Evasion (%)AgilityLuck
In most RPGs this is how it is done, except the stats are named as in the Primary stat names of FF7.

Look at it another way...
Code: [Select]
Code:
Strength = Base + LvBonus + MateriaBonus + WepArmAccBonus + PowerSource
Code: [Select]
Code:
Attack = Strength + WeaponStrength
Can be amalagmated to
Code: [Select]
Code:
Attack (or better named "Strength") = Base + LvBonus + MateriaBonus + WepArmAccBonus + PowerSource + WeaponStrength

What I am doing for Reunion is:

-Making Base stats lower

-Massively reducing LvBonus and making it so players gain different bonuses depending on type.  For example, Barrett will gain far more strength than Aerith, who will in turn gain more magic.

-Tweaking MateriaBonus

- Tweaking Accessory Bonus, removing all Weapon bonuses, and possibly removing all armour bonuses.

-Limiting the number of sources a player can collect / use to 10 of each.

- Tweaking Weapon/Armour strength and Accuracy, Evasion, Magic Evasion.
 
Last edited:
You left out Spirit, btw. In the vanilla game that's all that influences MEvade.

Here's how I think it should be:
Code: [Select]
Code:
Strength = Base + LvBonus + PowerSourceAttack = Strength + MateriaBonus + WepArmAccBonus* + WeaponStrength
*I just call this "EquipBonus"

This way the "Primary" stat never decreases and it's Attack that fluctuates.

They probably shouldn't be referred to as "Primary/Secondary" stats, however. That implies (to me) they're all separate stats from each other. I've always called them "Base/Final" stats, but that's just me.
 
Status
Not open for further replies.
Back
Top