- 4
- Posts
- 9
- Years
- Seen Sep 9, 2017
Changing the experience gain formula (Emerald)
** The purpose of this research isn't to learn the EXP calculation formula. We already know that. The purpose is to give offsets we can use to easily change the formula.
The exact point where the game yanks a Pokemon's experience yield is here:
At which point one of the following calculations occur:
Basically:
Is always calculated, and then split according to how many Pokemon participated in the battle. This is that calculation in full:
You can modify these opcodes however you like.
Before these opcodes:
....and here:
** The purpose of this research isn't to learn the EXP calculation formula. We already know that. The purpose is to give offsets we can use to easily change the formula.
The exact point where the game yanks a Pokemon's experience yield is here:
Code:
0804A4A4 LDRB R2, [R0,#pokemon_base.exp_yield]
Code:
if ( v0 )
{
v8 = (unsigned int)(battle_participants[unk_202420D].level
* pokemon_basestats[battle_participants[unk_202420D].species].exp_yield
/ 7 << 16) >> 17;
v9 = v8 / v4;
*v1 = v9;
if ( !(v9 << 16) )
*v1 = 1;
word_20243CC[27] = v8 / v0;
if ( !(v8 / v0 << 16) )
word_20243CC[27] = 1;
}
else
{
v10 = (battle_participants[unk_202420D].level
* pokemon_basestats[battle_participants[unk_202420D].species].exp_yield
/ 7 & 0xFFFF)
/ v4;
*v1 = v10;
if ( !(v10 << 16) )
*v1 = 1;
word_20243CC[27] = 0;
}
Code:
(exp_yield * level / 7) & 0xFFFF
Code:
ROM:0804A4A4 42 7A LDRB R2, [R0,#pokemon_base.exp_yield]
ROM:0804A4A6 2A 31 ADDS R1, #0x2A @ '*'
ROM:0804A4A8 08 78 LDRB R0, [R1]
ROM:0804A4AA 50 43 MULS R0, R2
ROM:0804A4AC 07 21 MOVS R1, #7
ROM:0804A4AE 9D F2 47 F8 BL __divsi3
ROM:0804A4B2 00 04 LSLS R0, R0, #0x10
ROM:0804A4B4 01 0C LSRS R1, R0, #0x10
Before these opcodes:
- R0 is pokemon_base, the struct with all the information about the species of Pokemon we just KO'd.
- R1 contains knowledge about the specific Pokemon we battled, such as its level (offset 0x2A).
- R1 must contain the total EXP to split between the battling Pokemon.
Code:
ROM:0804A4C8 00 04 LSLS R0, R0, #0x10
ROM:0804A4CA 00 28 CMP R0, #0
ROM:0804A4CC 01 D1 BNE loc_804A4D2
ROM:0804A4CE 01 20 MOVS R0, #1
ROM:0804A4D0 08 80 STRH R0, [R1]
Code:
ROM:0804A4DE 00 04 LSLS R0, R0, #0x10
ROM:0804A4E0 00 28 CMP R0, #0
ROM:0804A4E2 18 D1 BNE loc_804A516
ROM:0804A4E4 01 20 MOVS R0, #1
ROM:0804A4E6 28 80 STRH R0, [R5]
ROM:0804A4E8 15 E0 B loc_804A516