GoGoJJTech
(☞゚ヮ゚)☞ http://GoGoJJTech.com ☜(゚ヮ゚☜)
- 2,475
- Posts
- 12
- Years
- Age 26
- Earth
- Seen Dec 9, 2016
Double Wild Pokémon Battles in Emerald
So I ported what was on this thread, which was ported from Jambo51's 649 patch.
Simply put, it's the same thing, you just need a bunch of changes :P
Before I put the code up, I'll list the issues:
So the code:
generate.asm is not present in the FireRed versions of this implementation. The reason is that this function is actually from FireRed. Since it's not present in Emerald, I just copied it. Just thought you might want to know since this'd make the overall size of this hack larger than the FireRed one. :)
1.asm generates a table
0005 = 0x5
000D = 0xD
the 5 is the percent chance that a double wild battle will occur. To have double wild battles every single time, you'd put 0x64 (100 in decimal)
0xD is the tile in the tileset that it will occur in. The tiles I have here are the grass tiles used in general areas in Emerald, tileset 0 of course.
0xFEFE ends the table, so be sure to keep it at the end!
This hack does not allow double wild Pokémon if the player only has one Pokémon available to battle!
So I ported what was on this thread, which was ported from Jambo51's 649 patch.
Simply put, it's the same thing, you just need a bunch of changes :P
Before I put the code up, I'll list the issues:
- You can use the bag twice (two pokeballs for example [dunno how it's handled in Unova games])
- You can run twice (Can't escape! Got away safely! [still dunno how it works in Unova games])
- Upon fainting, it asks if you want to send out the next Pokémon or run. If both faint, it does it twice (still have no idea how it works in blah blah blah games)
- The Pokémon in slot 0 (the one on the right) is the one displayed when you successfully catch
- Only the 0th Pokémon (the one on the right again) is faded in the battle intro
So the code:
Spoiler:
1.asm:
2.asm:
3.asm:
4.asm:
5.asm:
6.asm:
7.asm:
pokeball.asm:
generate.asm:
Spoiler:
Code:
.thumb
/*0xB4F30 - 05 49 08 47
0xB4F48 - XX+1 XX XX 08
0xB06D4 - 00 00*/
str r0, [sp]
ldr r0, .opponent_slot
mov r1, r6 @Pokemon
mov r2, r7 @Level
mov r3, #0x20
ldr r4, .pokemon_make_with_nature
bl linker_4
mov r1, #0
mov r2, #0
loop_1:
mov r4, #0x64
ldr r0, .party_slot
add r0, #0x56
mul r4, r1
add r0, r0, r4
ldrh r0, [r0]
cmp r0, #0
bne add_1
increment:
add r1, #1
cmp r1, #6
bne loop_1
cmp r2, #2
blt back_1
ldr r1, .offset
ldr r2, .save_block_1
ldr r2, [r2]
ldrb r3, [r2, #4] @bank
lsl r3, r3, #2
add r1, r1, r3
ldr r1, [r1]
ldrb r3, [r2, #5] @map
lsl r3, r3, #2
add r1, r1, r3
ldr r1, [r1]
ldr r1, [r1]
ldr r3, [r1, #0x10]
ldr r2, .tileset_table
cmp r3, r2
bne back_1
bl get_block_id
mov r2, #0
loop_2:
mov r1, pc
add r1, #0x92
lsl r3, r2, #2
add r1, r1, r3
ldrh r3, [r1]
cmp r0, r3
beq calculation
ldr r1, .end
cmp r1, r3
beq back_1
add r2, #1
b loop_2
add_1:
add r2, #1
b increment
back_1:
mov r0, #0
ldr r1, .battle_flag
str r0, [r1]
back_2:
add sp, sp, #0xC
pop {r4-r7, pc}
get_block_id:
push {lr}
ldr r0, .npc_state
ldrh r1, [r0, #0x12] @Y
ldrh r0, [r0, #0x10] @X
ldr r4, .getter
bl linker_4
pop {pc}
calculation:
ldrb r4, [r1, #2]
cmp r4, #0x63
bhi doubletwo
bl random
mov r1, #0x64
bl mod_func
doublethree:
add r1, r4, #0
cmp r0, r1
bge back_1
double:
mov r0, #1
ldr r1, .battle_flag
str r0, [r1]
ldr r4, .rand_grass
bl linker_4
ldr r1, [sp, #0x10]
ldr r1, [r1, #4]
lsl r0, r0, #2
add r0, r0, r1
ldrh r4, [r0, #2]
ldr r1, .generate
bl linker_1
mov r7, r0
bl random
mov r1, #0x19
bl mod_func
ldr r0, .opponent_slot
add r0, #0x64
mov r1, r4 @Pokemon
mov r2, r7 @Level
mov r3, #0x20
ldr r4, .pokemon_make_with_nature
bl linker_4
b back_2
doubletwo:
mov r0, #0
b doublethree
mod_func:
ldr r3, .mod_addr
bx r3
random:
ldr r2, .rand
bx r2
linker_1:
bx r1
linker_4:
bx r4
.word 0x0005000D
.word 0x000501C6
.word 0x000501C7
.hword 0xFEFE
.align 2
.opponent_slot: .word 0x02024744
.pokemon_make_with_nature: .word 0x08067E90+1
.party_slot: .word 0x020244EC
.battle_flag: .word 0x02022FEC
.offset: .word 0x08486578
.save_block_1: .word 0x03005D8C
.tileset_table: .word 0x083DF704
.npc_state: .word 0x02037350
.getter: .word 0x08088224+1
.end: .word 0x0000FEFE
.mod_addr: .word 0x082E7BE0+1
.rand: .word 0x0806F5CC+1
.rand_grass: .word 0x080B4AC8+1
.generate: .word 0x08E40900+1 @pointer to generate.asm+1
Spoiler:
Code:
.thumb
.align 2
/*0x3ED80 - 00 48 00 47 JJ+1 JJ JJ 08*/
ldr r0, [r1]
cmp r0, #5
beq .L_1
mov r1, #1
and r0, r1
cmp r0, #0
bne .L_0
.L_1:
ldr r1, =0x803ED8A+1
bx r1
.L_0:
ldr r1, =0x803EE06+1
bx r1
Spoiler:
Code:
.thumb
.align 2
/*4A60A - 00 47
4A654 - ZZ+1 ZZ ZZ 08*/
ldr r0, =0x2022FEC
ldr r0, [r0]
cmp r0, #5
beq double
audio:
ldr r0, =0x161
ldr r1, =0x80A3778+1
bl jump
ldr r1, =0x804A60E+1
jump:
bx r1
double:
ldr r0, =0x2024084+0x58
mov r1, #0x58
lsl r1, r1, #1
add r1, r0, r1
ldrh r0, [r0, #0x28]
ldrh r1, [r1, #0x28]
add r0, r0, r1
cmp r0, #0
beq audio
ldr r1, =0x804A616+1
bx r1
Spoiler:
Code:
.thumb
.align 2
/*0x56318 - 30 47
0x5634C - MM+1 MM MM 08
0x566BC - 00 00
0x56702 - 00 00
0x5674E - 00 00
0x5679E - 00 00
0x56DF2 - 08 1C
0x56D14 - 00 00
0x56D40 - 00 00
0x56D60 - 00 00
0x56D7E - 04 1C
0x5671C - 0C 42 02 02
0x56840 - 0C 42 02 02
0x56DC0 - 0C 42 02 02
0x56E20 - 0C 42 02 02*/
ldr r6, =0x2022FEC
ldr r6, [r6]
cmp r6, #5
bne normal
ldr r6, =0x2024084+0x58
ldrh r6, [r6, #0x28]
cmp r6, #0
bne case_1
case_2:
mov r0, #3
b back
case_1:
mov r0, #1
b back
normal:
mov r1, #1
eor r0, r1
back:
ldr r6, =0x202420C
ldr r1, =0x805631C+1
bx r1
Spoiler:
Code:
.thumb
.align 2
/*0x56850 - 00 48 00 47 NN+1 NN NN 08*/
push {r4, r5, lr}
ldr r4, =0x02024744
ldr r0, =0x0202420C
ldrb r0, [r0]
lsr r0, r0, #1
mov r1, #0x64
mul r0, r1
add r0, r0, r4
add r4, r0, #0
mov r1, #0xb
ldr r2, =0x08056858+1
bx r2
Spoiler:
Code:
.thumb
.align 2
/*0x568D2 - 00 47
0x568F4 - UU+1 UU UU 08*/
ldr r0, =0x02024744
ldr r1, =0x0202420C
ldrb r1, [r1]
lsr r1, r1, #1
mov r2, #0x64
mul r1, r2
add r0, r1, r0
mov r1, #0xb
ldr r2, =0x080568D4+1
bx r2
Spoiler:
Code:
.thumb
.align 2
/*0x170E50 - 10 47
0x170ED8 - QQ+1 QQ QQ 08*/
ldr r2, =0x02038437
ldr r0, =0x02022FEC
ldr r0, [r0]
cmp r0, #5
bne normal
ldr r0, =0x02024084+0x58
mov r1, #0x58
lsl r1, r1, #1
add r1, r0, r1
ldrh r1, [r1, #0x28]
cmp r1, #0
beq normal
mov r1, #3
strb r1, [r2]
normal:
mov r8, r2
ldr r0, =0x08170E52+1
bx r0
Spoiler:
Code:
.thumb
/*Change all 95 E3 0F 08 to the pointer (+1) to this routine, and please do the change before inserting the routine!!!!!!!!!!!!!!!!!!*/
ldr r1, .battle_flag
ldr r1, [r1]
cmp r1, #5
bne normal
ldr r1, .struct
mov r2, #0x58
lsl r2, r2, #1
add r2, r1, r2
ldrh r1, [r1, #0x28]
ldrh r2, [r2, #0x28]
mul r1, r2
cmp r1, #0
bne two_mon
normal:
ldr r1, .pokeball
bx r1
two_mon:
push {r4,r5, lr}
mov r0, #0
mov r1, #2
ldr r2, .string_shown
ldr r3, .bag_print
ldr r4, .texter
bl jump
pop {r4,r5, pc}
jump:
bx r4
.align 2
.battle_flag: .word 0x2022FEC
.pokeball: .word 0x80FE394+1
.struct: .word 0x2024084+0x58
.bag_print: .word 0x81ABBBC+1
.texter: .word 0x081ABB4C+1
.string_shown: .word 0x08E40A00 @Pointer to text
Spoiler:
Code:
.thumb
PUSH {R4,R5,LR}
MOV R4, R0
LDRB R0, [R4,#1]
LDRB R1, [R4]
CMP R0, R1
BCC loc_1
LDRB R5, [R4]
B loc_2
loc_1: LDRB R5, [R4,#1]
LDRB R0, [R4]
loc_2: SUB R4, R0, R5
ADD R4, #1
LSL R4, R4, #0x18
LSR R4, R4, #0x18
LDR R3, =0x806F5CC+1 @rand
BL linker
LSL R0, R0, #0x10
LSR R0, R0, #0x10
MOV R1, R4
LDR R3, =0x82E7650+1 @__modsi3
BL linker
LSL R0, R0, #0x18
LSR R0, R0, #0x18
ADD R0, R5, R0
LSL R0, R0, #0x18
LSR R0, R0, #0x18
POP {R4,R5}
POP {R1}
BX R1
linker: bx R3
generate.asm is not present in the FireRed versions of this implementation. The reason is that this function is actually from FireRed. Since it's not present in Emerald, I just copied it. Just thought you might want to know since this'd make the overall size of this hack larger than the FireRed one. :)
1.asm generates a table
Code:
.word 0x0005000D
.word 0x000501C6
.word 0x000501C7
.hword 0xFEFE
0005 = 0x5
000D = 0xD
the 5 is the percent chance that a double wild battle will occur. To have double wild battles every single time, you'd put 0x64 (100 in decimal)
0xD is the tile in the tileset that it will occur in. The tiles I have here are the grass tiles used in general areas in Emerald, tileset 0 of course.
0xFEFE ends the table, so be sure to keep it at the end!
This hack does not allow double wild Pokémon if the player only has one Pokémon available to battle!