Yes. The code does divide by the 256 that I just posted in my previous post... In three different functions (The parent functions to the child function you were probably looking at.).... (It's actually like hitting two birds with one stone, because it's shifting the other bits due to multiplying other numbers as well.)
Function 1 shifts 9 bits... 8 from the percent, 1 from actual dividing of attack - defense... I think
Function 2 shifts 16 bits.... 8 from the percent, and 8 from the percentArg. And same with Function 3.
If Cloak is not in use;
And if ailment success /= 0 (if there is one);
And if base damage > 0;
((Base Damage *
((Relative Power/200) + 1)) * ability_mul * multi_mod /100) * def_mod
"Relative Power" = User's Elemental Power - Target's Elemental Resist"ability_mul" = Ability effect multipliers (see respective multiplier effects), defaults to 1 when there is no effect
"multi_mod" = 100% for primary, 50% secondary, 30% tertiary, 10% everyone else
"def_mod" = 100% for normal, 50% for 50% damage off, 40% for 60% off, 10% for 90%
Fixed! (I think?)
Formulas: (Mostly a WIP, so you can probably confrrm them, if you want.)
Added Damage: (Left out crit/multi_mod/effect_mod)
max(0, max(0, ((userAttack - targetDef) / 2) + abilityPower) * (1 + (Relative Power/400)))
max(0, max(0, ((userAttack - targetDef) / 2) + abilityPower) * (1 + ( Int(Relative Power*256/400)/256 )))
max(0, max(0, ((userAttack - targetDef) / 2) + abilityPower) * (1 + ( Int(Relative Power*0.64)/256 )))
Multiplier: (Left out crit/multi_mod/effect_mod)
max(0, max(0, (userAttack - targetDef) / 2) * (1 + (Relative Power/400))) * abilityPower / 10
max(0, max(0, (userAttack - targetDef) / 2) * (1 + ( Int(Relative Power*256/400)/256 ))) * abilityPower / 10
max(0, max(0, (userAttack - targetDef) / 2) * (1 + ( Int(Relative Power*0.64)/256 ))) * abilityPower / 10
Effect Only:
((Base Damage * (1 + (Relative Power/200))) * ability_mul * multi_mod /100) * def_mod
((Base Damage * (1 + ( Int(Relative Power*256/200)/256 ))) * ability_mul * multi_mod /100) * def_mod
((Base Damage * (1 + ( Int(Relative Power*1.28)/256 ))) * ability_mul * multi_mod /100) * def_mod
Where /200 and /400 occur, there is a rounding error, because the game rounds off to the nearest 1/256th before actually multiplying to anything.... To fix the rounding error, multiply the numerator by 256, get a decimal number, remove the decimal places, and then divide by 256 (To undo what you multiplied by earlier. Because * 256/256 is *1, which doesn't change anything.)
By the way, you left out multi_mod and effect_mod from your healing formula. (I'm going to assume the majority of the damage functions use these, so you can probably abbreviate on them.)
080AFF28 = get_summons_total(addr) addr is where to list the summons.
080AFF7C = get_summon_address(summon)
080AFF94 = obtain_summon(summon)
080AFFAC = get_elemental_levels(pc,pc_ram_addr,sp) pc can be 0-7 for PCs, or 8+ for enemies.; Return 0.
080B0028 = get_elemental_level(pc,element)
080B005C = get_enemy_elemental_attr(enemy)
080B0084 = update_elemental_pow_resist(pc_slot, pow_res_ram_addr) Includes base levels and djinn, not sure about item bonuses.
080B0144 = find_matching_class(pc,pc__ram_addr,item)
080B0288 = get_class_address(class)
080B0298 = Djinn set/removal calculations (grabs/updates class ID (possibly abilities too)? and links update_elemental_pow_resist)
080B02D4 = Call 080B0298.
080B02DC = toElementalHexPercent(Relative ePower, eHalfEffective) (Converts to hex percentage. (Multiply by 1.28 or 0.64 and add 256. Equivalent to (1 + Relative Power / 200) and (1 + Relative Power / 400), but those have a rounding error.) In parent function mult. with value and shift out 8 bits.) It’s like converting 100 to +50% in hex. (If eHalf, +25%) (150% and 125%)
080B0378 = Random Number Generator //Returns 16-bit (x0000-xFFFF)
080B039C = Return random number x0-x63.
080B03AC = calcAttack(attack,targetDef,power,Relative ePower) targetDef could be 100%, 50%, or 0% of value depending on effect. Used by Added Damage & Multiplier
Return max(0, max(0, ((userAttack - targetDef) / 2) + abilityPower) * (1 + (Int(Relative ePower*256/400)/256)))
080B03E0 = calcCast(abilityPower,Relative ePower,percent) (From left?) elemental pow/resist related *Called from Summon and Effect Only formulas…
Return abilityPower * (1 + (Int(Relative ePower*256/200)/256) * hexPercent
080B0408 = calcHeal(Same as above, but it multiples arg r1 by 2 and subtracts by 200 at beginning.) (From Center?) *Called from Healing formula(s).
Return abilityPower * ((Int(ePower*256/100)/256) * hexPercent
080B0434 = get_elemental_attr(pc)
080B0460 = get_item_criticals(pc_addr)
080B04BC = unleash_check(pc) Returns ability to cast. (Unleash if chance succeeds, or attack.)
080B0514 = Base Ability Effect Success Chances?
080B06A8 = Return 1 if enemy found in table 080C6B18, else 0.
080B06C8 = Return 1 if enemy found in table 080C6B76, else 0.
080B06E8 = is_vulnerable/weakness(pc_addr, ability_effect)
080B0740 = Ability_Effect_Revives(ability_effect) //If effect revives, return 1, else 0.
080B075C = Calculate_Ailment_Success(attacker,defender,element,effect,percentMod)
I figure the three functions calcAttack, calcCast, calcHeal, are the base calculations, while the battle mechanics themselves use modifiers like multi_mod, effect_mod, and def_mod.
It appears that PP Recovery doesn't have a random value that gets added.