Howdy! So uh, yeah. Here's a topic in which we can organize the games' formulas and discuss them a bit. This first post will be separated into two sections; confirmed through code and unconfirmed through code (such formulas may have unknown variables that are as of yet undocumented). Organization will be a little lackluster until we have a decent proportion of the game's formulas in here.

Vanilla Agility/Turn Order The following section explains how PC turns are calculated. Turn Order:

Randomized agility has priority;

PCs have priority over enemies;

Left-most slots have priority;

Agility x 0-FFFF (or ran) = RAN

LSR 14 RAN = #

Agility + #

÷ 2 for additional turns only.

So if Agility = x64 (100 decimal) and ran = xFFFF, then you multiply them;

RAN = 63FF9C

LSR 14 in a programmer's calculator;

# = 6

Add 6 to 100 Agility

= 106

If it's not the first turn (as in second, third, etc. turns);

106 ÷ 2 = 53

It boils down to:

(Agility + Agility*(0~6%))*(Multi-turn penalty) Multi-turn penalty = 1 if it's a character's first action that turn, and 0.5 otherwise.

Maximum agility values to ensure desired turn order.

PC1: 999

PC2: 940 (941 if right of PC1)

PC3: 884 (885 if right of PC2)

PC4: 832 (833 if right of PC3)

Enemies, on the other hand, are much simpler. For 4 turns, agility decrements by 1/6th each turn. For 3 turns, by 1/4th. For 2 turns, by 1/2. Turns are normally capped at 4, manually adding more to an enemy's RAM will result in every turn after the first one having only half of its agility value.

0811D0A8 = Check for 4 turns, branch if not equal - Turn 2: 5/6 agility ; Turn 3: 4/6 agility ; Turn 4: 1/2 agility

0811D0D0 = Check for 3 turns, branch if not equal - Turn 2: 3/4 agility ; Turn 3: 1/2 agility

0811D0EE = Check for 2 turns, branch if not equal - Turn 2: 1/2 agility

Ailment Success (((((((Attacker's elemental level - Defender's elemental level) - Floor(Defender's luck / 2)) * 3) + effect's base chance + (vulnerabity's 25)) * multi_arg) / 100) >= rnd()) Where "rnd()" is a random number from 0-99 (x00 to x63), and "multi_arg" (previously known as "unk_arg") is for diminishing success rates based on the amount of targets the effect can be used on:

First (Primary Target) = 100%

Second (Next to the target) = 60%

Third = 30%

Fourth = 30%

Fifth = 30%

Sixth = 30%

Notes:

x52 = "82 - May force target out of battle" is always 0% when class is not NPC. (0% for player characters?)

These generate three random numbers... This would make, for example, a chance of 50% (one) to be 87.5% (three), I think.

x43 = "67 - Inflicts Seal"

x50 = "80 - Inflicts Death Curse"

x55 = "85 - May inflict Stun"[/spoiler]

Base success rates (assigned in the function at 080B0514):

Spoiler for Base Rates in GS2 (with examples) :

080B0660 - 70% (12/13 - Def debuffs) 080B0664 - 75% (16/17 - eRes debuffs) 080B0668 - 30% (22 - Charm) 080B066C - 45% (24 - Sleep) 080B0670 - 55% (18/19 - Poison/Venom, 25 - Seal) 080B0674 - 25% (26 - Haunt) 080B0678 - 20% (27 - Instant Death) 080B067C - 65% (20 - Delusion, HP Drain) 080B0680 - 35% (21 - Confuse, 34 - HP to 1) 080B0684 - Flat 60% (56 - Revive to 50%) 080B0688 - Flat 90% (57 - Revive to 80%) 080B068C - Flat 70% (73 - Revive to 60%) 080B0690 - 60% (8/9 - Attack debuffs, 28 - Curse, 32 - PP Drain, 80 - Curse) 080B0694 - 50% (35 - May ignore 50% of Def) 080B0698 - 40% (23 - Stun, 85 - Stun) 080B069C - Flat 100% (Def buffs, eRes buffs, Regen, Reflect, Break... seems to be the default for anything that either shouldn't fail or has its success rate calculated differently)

Ailment Recovery Note: 5 or fewer turns must remain for this chance to occur.

(((Luck * 3) - (Turns * 5) + base_chance) * 655) >= rand() Random number is 16-bit (Up to xFFFF)

If chance was 100% and you multiplied by 655, you'd get xFFDC. Evidently, 656 would make x10040.

Base chances of recovering from an ailment, etc:

Healing This one is pretty simple.

If current HP > 0:

Restored HP = ((Base Value*ePower)/100) + (0~3) If restored HP > max HP, overwrite with Max HP. Else add restored HP to current.

The 0~3 is basically calculated like so:

(0~3) = 3 AND rand()

Where rand() is a 16-bit value up to xFFFF. Change the 3 to change the amount that can be added to the final result.

I don't think it uses RNG when calculating the amount to restore outside of battle.

Regenerate/Coatlicue Another easy one that's similar to the Healing formula, minus how the amount to heal is calculated:

If Duration > 0:

((Duration + 1)*Max HP))/10 So basically, having about 5 turns before the effect ends will net you 60% regeneration for that first turn. 3 turns will be 40%, 8 turns would be 90%, and so forth. You will be healed before the duration counter goes down at the end of the round.

Poison/Venom This one is pretty similar to Regenerate, in that it reads the corresponding ailment value from the unit's RAM before making the calculations.

Located at 0812593C, it skips the calculation if Poison = 0; otherwise:

(Poison * Max HP)/10 A Poison value of 1 (regular poison) will deal about 10% of your Max HP in damage and a Poison value of 2 (venom) will deal about 20%. As an FYI, you can technically go higher than 2 despite there not being a graphic for anything higher than that (or even an effect for it). I should also mention that this does not actually apply in the field; that seems to be coded strictly for Poison values 1 and 2, and those are fixed at 5% for regular poison and 10% for venom as far as I can tell.

However, the field formula works a little differently. It only works if your Poison value is either 1 or 2, and each value uses a slightly different calculation. What I like about them is how they only deal roughly half damage when not in battle... Well anyway, here they are.

Poison:

(Max HP + 10) / 20 Venom:

(Max HP + 5) / 10 Summon ePow Boosts ((Tier x Tier) + Tier) x 5 "Tier" is a RAM value ranging from 1-4, depending on how many djinn of a single element are used in a summon. This formula doesn't account for differences when you follow a weaker summon with a stronger one, and the text that displays will only give you the difference (or, if the boost would put you above the 200 ePower cap, the difference between what it normally would be and the cap).

The boosts are normally 10-30-60-100 for each tier.

The formula reads more like this in the code:

((Tier x Tier) + Tier) = Tier2

(Tier2 x 4) + Tier2

So yeah! I'll work on scouring other topics for fomulas in a bit; please post any that you can think of, I would greatly appreciate it!