View Single Post
Old July 28th, 2009, 05:04 PM
Korronensu's Avatar
Scrap Punk
Join Date: Nov 2008
Age: 24
Nature: Adamant
Send a message via AIM to Korronensu Send a message via Yahoo to Korronensu
Originally Posted by JPAN View Post

While it is possible to make code that changes the amount of experience on a pokemon, I have no way of reproducing the level up routine without messing up some of the status gains, at the moment. As such, I give here a code that will allow you to give a pokemon experience, but for it to level up, it is necessary to fight a battle. Also, this code has several limits. First, you can only add up to 32767 exp points (0x7fff). Any bigger and the pokemon will crash your game. Also, if the experience surpasses that of the needed to gain a level, the pokemon will present, on the status screen, a full blue experience bar with a transparent middle, and the numbers will be mixed with question marks.

If you still want it, here it is.
b507 push {r0-r2, lr}
4804 ldr r0, 0x0203f408 ;Growth block data storage address
6800 ldr r0, [r0]
4904 ldr r1, 0x020370C2 ;var 0x8005 used for storing the exp value
8809 ldrh r1, [r1]
2280 mov r2, 0x80
0912 lsl r2, 0x8
418a cmp r1,r2 ; checks if exp is between "safe" values
db02 blt add_exp
bd07 pop {r0-r2, pc}
6842 add_exp: ldr r2, [r0+0x4]
188a add r2, r2, r1 ; adds the experience
6042 str r2, [r0+0x4]
bd07 pop {r0-r2, pc}

And in the compiled version
07 b5 04 48 00 68 04 49 09 88 80 22 12 02 91 42
04 db 07 bd 08 f4 03 02 c2 70 03 02 42 68 8a 18
42 60 07 bd

Edit: As promissed, some more examples of what to do with this code

Catch the pokerus
This code here allows you to cure, immunize and catch the pokemon virus. To make it work, put in var 0x8005 a number between 0x1 and 0xf to give it, 0x0 to cure but not immunize and 0x10 or higher to immunize the pokemon, preventing him to ever catch the virus again (even with this code)
b507 push {r0-r2, lr}
4806 ldr r0, 0x0203f414 ;Misc block data storage address
6800 ldr r0, [r0]
4906 ldr r1, 0x020370C2 ;var 0x8005, keeps pokerus new status
7802 ldrb r2, [r0]
2a0f cmp r2, 0xf ; if immune, do nothing
dc02 bgt end
8809 ldrh r1, [r1] ;time to remain, bigger than 10 to immunize
2910 cmp r1, 0x10
db00 blt infect
2110 mov r1, 0x10
7001 infect:strb r1, [r0]
bd07 end:pop {r0-r2, lr}

Compiled and ready
07 B5 06 48 00 68 06 49 02 78 0F 2A 04 DC 09 88
10 29 00 DB 10 21 01 70 07 BD 00 00 14 F4 03 02
C2 70 03 02

EV related material
Several codes that allow you to manipulate Contest stats and Effort values. This following "Stat table" is used in all the following examples
Value -> Stat
0x0 -> HP EV
0x1 -> Attack EV
0x2 -> Defense EV
0x3 -> Speed EV
0x4 -> Special Attack EV
0x5 -> Special Defense EV
0x6 -> Coolness
0x7 -> Beauty
0x8 -> Cuteness
0x9 -> Smartness
0xa -> Toughness
0xb -> Feel (not used in Fire Red, so if needed, any new stat)

Any of the following EV codes only work correctly if the value is present on the table. Using others results in the unexpected.

Reading EV's/Contest stats
This one code reads the values of the stat placed on variable 0x8005, and places the result on that variable, a number from 0x0 - 0xff.
b507 push {r0-r2, lr}
4803 ldr r0, 0x0203f410 ;Effort block data storage address
6800 ldr r0, [r0]
4903 ldr r1, 0x020370C2 ;0x8005 for effort type
880a ldrh r2, [r1]
5c82 ldrb r2, [r0 + r2]
800a strh r2, [r1] ;stores effort value on variable
bd07 pop {r0-r2, pc}

Ready to use version
07 B5 03 48 00 68 03 49 0A 88 82 5C 0A 80 07 BD
10 F4 03 02 C2 70 03 02

Adding to EV/Contest stats
This code allows you to change the values of both EV's and Contest Stats, but it works differently on both situations. Place the value to add, between 0x0 - 0xff on var 0x8006 and a table value on 0x8007.
Adding EV obeys the 512 limit, so only values up to a total of 512 will be accepted. On both the Contest and EV, adding a value that is bigger than the allowed will cause the code to add only up to that limit, meaning that adding efforts that surpass 512 after adding will add only up to 512, and adding values that exceed 0xff will make the value 0xff.
b51f push {r0-r4, lr}
4811 ldr r0, 0x0203f410 ;Effort block data storage address
6800 ldr r0, [r0]
4911 ldr r1, 0x020370C4 ; use 8006 for storing given points and 0x8005 for effort type
6809 ldr r1, [r1]
040a lsr r2, r1, 0x10 ;value to increase effort-contest stats by
0c09 lsl r1, r1, 0x10 ;stat to increase
0c12 lsl r2, r2 0x10
2906 cmp r1, 0x6
db02 blt Effort
290c cmp r1, 0xc
db0d blt Contest
bd1f pop {r0-r4, pc}

1c13 Effort: add r3, r2, 0x0
2500 mov r5, 0x0

5d44 loop:ldrb r4, [r0 + r5]
18e3 add r3, r3, r4
3501 add r5, 0x1
2d06 cmp r5, 0x6
d1fa bne loop

2420 mov r4, 0x20
0124 lsl r4, r4, 0x4
429c cmp r4, r3
dc01 bgt Contest
e00f b Checkmax

5c43 Contest:ldrb r3, [r0 + r1]
18d2 add r2, r2, r3
23ff mov r3, 0xff
429a cmp r2, r3
dd01 ble add_value
22ff mov r2 , 0xff
0000 nop
5411 add_value: strb r2 , [r0 + r1]
bd1f pop {r0-r4,pc}

1a9b checkmax: sub r3, r3, r2
1ae2 sub r2, r4, r3
2a00 cmp r2, 0x0
dbf6 bgt add_value
bd1f pop {r0-r4,pc}

Ready version
3F B5 11 48 00 68 11 49 09 68 0A 04 09 0C 12 0C
00 00 06 29 02 DB 0C 29 0D DB 3F BD 13 1C 00 25
44 5D E3 18 01 35 06 2D FA D1 20 24 24 01 9C 42
01 DC 0D E0 00 00 43 5C D2 18 FF 23 9A 42 01 DD
FF 22 00 00 42 54 3F BD 10 F4 03 02 C4 70 03 02
9B 1A 45 5C 5B 1B E2 1A 00 2A F3 DC 3F BD

Erasing all EV's
This last code receives nothing and returns nothing, changing only all EV's to 0.
b505 push {r0-r1, lr}
4803 ldr r0, 0x0203f410 ;Effort block data storage address
6800 ldr r0, [r0]
2100 mov r1, 0x0
6001 str r1, [r0]
8081 strh r1, [r0 + 0x4]
bd05 pop {r0-r2,pc}
0000 garbage

Ready version
03 B5 03 48 00 68 00 21 01 60 81 80 03 BD 00 00
10 F4 03 02

And that is all for now. Feel free to ask for any other codes. Next time I post here I will bring a "teaching Attacks" code, a dumbed down "move tutor".

Now HERE is some much needed info. Thanks so much for that. I hope Score_Under finds this.
Reply With Quote