# Transplanting an EXP System in Pokémon

Discussion in 'NDS - ROM Hacking and Translations' started by Drayano, Jan 5, 2012.

# Transplanting an EXP System in Pokémon

2,650 Views
1. ### Drayano.

Member
Oct 26, 2008
United Kingdom
Anyone who's played most of the Pokémon games probably knows already that Black/White have a different EXP system that scales the EXP according to the level difference between the opponents, whereas every other Pokémon game simply has a static amount dependent on the species and level. I was wondering if it's possible to take that Black/White experience system and somehow put it in a different DS Pokémon game - namely, Heart Gold/Soul Silver.

The problem is I literally have no idea where to begin on something like this. I have no idea where in the data the exp formula is contained, not sure how I'd change it, etcetera. If anyone could give me some pointers on how to go about doing it (assuming it's not too much hassle, if it is I'll probably drop it anyway since I don't know if it'll be particularly effective due to other problems) I'd appreciate it.

If it's any help, the experience formula in B/W takes this format:

Whereas the one in every other Pokémon game including HGSS has this format:

If it's important...
• a is either 1 or 1.5, dependent on if the opponent is owned by a trainer or not.
• t is 1, 1.5 or 1.7 dependent on whether the used Pokémon originally belonged to the trainer using it.
• b is the base experience of a Pokémon species, a value which depends entirely on the Pokémon being fought (i.e. Blissey has a value of 255 in any non BW game)
• e is 1.5 if the Pokémon holds a Lucky Egg.
• L is the level of the Pokémon who was defeated and thus giving exp.
• s is the number of Pokémon who participated in a fight against the defeated opponent. It's also affected in some ways by the EXP. Share item.
• p refers to an upgrade which can be obtained in BW only for temporary times and can take several discrete values such as 0.5, 0.66, 0.8, 1.2, 1.5 and 2. For Gen IV purposes it's not important.
Feel free to shoot me down since I can't see something like this being simple at all, though, just thought it'd be worth asking regardless.

2. ### rastsan8 baller, Death Wizard,

Member
May 28, 2008
toronto
you know that action replay code that doubles triples or otherwise increases the exp... that area is where the programming is for handling that (or near abouts). EIther it points to a specific pokemons exp (the static point in memory which can be different for every pokemon) or it points to that formula. Either way put a breakpoint and work backwords or forwards until you find the asm that looks like that formula.

I would first try to figure how to make that formula in asm then search for it. After that its a simple redirect to the bigger and or rewrite of the smaller code.

3. ### Drayano.

Member
Oct 26, 2008
United Kingdom
Okay, so for HG/SS that'd be (2* EXP):
9223E7EA 0000319C
0223E7EC 60080040
0223E7F0 309C1C28
D0000000 00000000

And Black is (2* EXP):
521CB52C 59A8437E
023AE840 59A8437E
023AE844 51A80040
123AE848 00004770
021CB52C F988F1E3
D2000000 00000000

White is (2* EXP):
521CB54C 59A8437E
023AE840 59A8437E
023AE844 51A80040
123AE848 00004770
021CB54C F978F1E3
D2000000 00000000

...Regrettably I know basically no ASM and I'm clueless on how to insert a breakpoint ;; I do apologise as I'm pretty sure you've given me some very helpful advice there, I'm just a little too clueless >.>;

edit: After some thought I probably won't implement this anyway, but thank you for the help you gave.

Member
Sep 14, 2009
hospital
is seem +4 .... if i not wrong is offset right (on left side)? is seem on that offset is same manipulation BW and HGSS...

sorry if my comment is useless XD

but is possible to change exp formula's.

5. ### rastsan8 baller, Death Wizard,

Member
May 28, 2008
toronto
hopefully there won't be a size constraint and he won't have to add any code. You are going to need to dissect those codes and see what information is being held at those points in memory. If it points directly to where the arm9/overlay resides in memory then this shouldn't be a big deal but if it points to another file.... still not a big deal. take a look at the code after attaching crystaltile2 to an emulator... (sounds confusing but relative search anything - that can be found - in game- then use the memory dump that comes up to look at where that code is pointing to. View that spot in ct2 in asm view and take your time figuring out what does what.
The problem with using ct2 to edit the asm is you have to know how to parse the asm code exactly. You can still edit it with other tools if ct2 gives you problems.
Oh, With an action replay code actually now that I think about it just copy the asm directly over it from the one game to the other. the only problem with that last idea is that any arcodes after this that reflect exp will cause problems.
head over to kodewerx for their info on action replay code structure and the various ways of doing things. This is actually very do- able.

Please do not get discouraged by the what is being said and take the time to just look at it. looking at nds machine code isn't that scary... confusing at first maybe but not that big a deal.

edit after looking it seems that its either referring to three points in memory or the exp code is redundantly held in three points in memory. Either can be worked with.

6. ### Prof. 9GBAtemp Fan

Member
Jun 17, 2008
The Netherlands
I gave this a try just now.

::Black/White Experience Formula (very inaccurate)
5223E78C 43485C10
E2000740 0000002C
B406B500 5C2A5C11
300A0048 310A1889
E922F0F2 1C014340
BC0EDF0D 31014341
5C104801 BD004348
00002D74 00000000
0223E78C FFD8F5C1
1223E790 00002105
D2000000 00000000

This is my custom routine.

Code:
```push r14
push r1,r2
ldr r1,[r2,r0]		; r1 = L
ldrb r2,[r5,r0]		; r2 = Lp (does it get the Level for the victorious Pokemon or the Pokemon that gets Exp?)

lsl r0,r1,0x01		; 2 * L
add r0,0x0A		; 2L + 10
add r1,r1,r2		; L + Lp
add r1,0x0A		; L + Lp + 10
blx 0x020F2998		; (2L + 10)/(L + Lp + 10)	(very inaccurate)
mul r0,r0		; ((2L + 10)/(L + Lp + 10))^2
mov r1,r0
swi 0x0D		; ((2L + 10)/(L + Lp + 10))^0.5 (very inaccurate)
mul r0,r1		; ((2L + 10)/(L + Lp + 10))^2.5

pop r1,r2

mul r0,r1		; b * multiplier
add r0,0x01		; b * multiplier + 1
ldr r0,=0x00002D74
ldrb r0,[r2,r0]		; r0 = L
mul r0,r1		; L * b * multiplier + 1
pop r15            ; back to the main Exp routine```
It works in theory, but it's so inaccurate that the Exp you gain becomes about 1 if you're higher-leveled than the opponent. I'm not sure how to fix that (it involves a lot of bitshifting, I believe).

7. ### rastsan8 baller, Death Wizard,

Member
May 28, 2008
toronto
this is my point you know what to look for so look for the beginning of this near that area in memory in the one game whose exp code you want to copy...
so look for it instead of making it up...
Yeah I am so lazy I am making you do it, as I don't really have any interest in doing this myself I just know it can be done.