more of daycare done

This commit is contained in:
DizzyEggg 2017-11-14 21:43:23 +01:00
parent a972de7bca
commit 95949c772e
10 changed files with 316 additions and 904 deletions

View File

@ -8,879 +8,6 @@
thumb_func_start GetEggMoves
GetEggMoves: @ 80703C8
push {r4-r7,lr}
mov r7, r8
push {r7}
mov r8, r1
movs r6, 0
movs r4, 0
movs r1, 0xB
bl GetMonData
lsls r0, 16
lsrs r3, r0, 16
movs r2, 0
ldr r5, =gEggMoves
ldrh r1, [r5]
ldr r7, =0x00004e20
adds r0, r3, r7
cmp r1, r0
bne _080703F8
movs r4, 0x1
b _0807041A
.pool
_080703F8:
adds r0, r2, 0x1
lsls r0, 16
lsrs r2, r0, 16
ldr r0, =0x00000471
ldr r5, =gEggMoves
cmp r2, r0
bhi _0807041A
lsls r0, r2, 1
adds r0, r5
ldrh r1, [r0]
ldr r7, =0x00004e20
adds r0, r3, r7
cmp r1, r0
bne _080703F8
adds r0, r2, 0x1
lsls r0, 16
lsrs r4, r0, 16
_0807041A:
movs r2, 0
lsls r0, r4, 1
adds r0, r5
ldrh r0, [r0]
ldr r1, =0x00004e20
cmp r0, r1
bhi _08070456
adds r7, r5, 0
adds r3, r1, 0
_0807042C:
lsls r1, r2, 1
add r1, r8
adds r0, r4, r2
lsls r0, 1
adds r0, r7
ldrh r0, [r0]
strh r0, [r1]
adds r0, r6, 0x1
lsls r0, 16
lsrs r6, r0, 16
adds r0, r2, 0x1
lsls r0, 16
lsrs r2, r0, 16
cmp r2, 0x9
bhi _08070456
adds r0, r4, r2
lsls r0, 1
adds r0, r5
ldrh r0, [r0]
cmp r0, r3
bls _0807042C
_08070456:
lsls r0, r6, 24
lsrs r0, 24
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r1}
bx r1
.pool
thumb_func_end GetEggMoves
thumb_func_start daycare_build_child_moveset
daycare_build_child_moveset: @ 8070470
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0xC
adds r7, r0, 0
mov r10, r1
mov r9, r2
movs r0, 0
str r0, [sp]
movs r6, 0
ldr r5, =gUnknown_02024A4C
movs r2, 0
ldr r4, =gUnknown_02024A28
ldr r3, =gUnknown_02024A30
_08070490:
lsls r1, r6, 1
adds r0, r1, r5
strh r2, [r0]
adds r0, r1, r4
strh r2, [r0]
adds r1, r3
strh r2, [r1]
adds r0, r6, 0x1
lsls r0, 16
lsrs r6, r0, 16
cmp r6, 0x3
bls _08070490
movs r6, 0
ldr r2, =gUnknown_02024A38
movs r1, 0
_080704AE:
lsls r0, r6, 1
adds r0, r2
strh r1, [r0]
adds r0, r6, 0x1
lsls r0, 16
lsrs r6, r0, 16
cmp r6, 0x9
bls _080704AE
movs r6, 0
ldr r2, =gUnknown_020249C4
movs r1, 0
_080704C4:
lsls r0, r6, 1
adds r0, r2
strh r1, [r0]
adds r0, r6, 0x1
lsls r0, 16
lsrs r6, r0, 16
cmp r6, 0x31
bls _080704C4
adds r0, r7, 0
movs r1, 0xB
bl GetMonData
lsls r0, 16
lsrs r0, 16
ldr r1, =gUnknown_020249C4
bl GetLevelUpMovesBySpecies
lsls r0, 24
lsrs r0, 24
str r0, [sp, 0x4]
movs r6, 0
ldr r1, =gUnknown_02024A28
mov r8, r1
_080704F2:
adds r5, r6, 0
adds r5, 0xD
mov r0, r10
adds r1, r5, 0
bl GetBoxMonData
lsls r4, r6, 1
mov r2, r8
adds r1, r4, r2
strh r0, [r1]
mov r0, r9
adds r1, r5, 0
bl GetBoxMonData
ldr r1, =gUnknown_02024A4C
adds r4, r1
strh r0, [r4]
adds r0, r6, 0x1
lsls r0, 16
lsrs r6, r0, 16
cmp r6, 0x3
bls _080704F2
ldr r1, =gUnknown_02024A38
adds r0, r7, 0
bl GetEggMoves
lsls r0, 24
lsrs r0, 24
mov r8, r0
movs r6, 0
_0807052E:
ldr r0, =gUnknown_02024A28
lsls r1, r6, 1
adds r2, r1, r0
ldrh r1, [r2]
mov r9, r0
cmp r1, 0
beq _080705A4
movs r5, 0
cmp r5, r8
bcs _08070596
adds r4, r2, 0
ldr r2, =0x0000ffff
_08070546:
ldr r0, =gUnknown_02024A38
lsls r1, r5, 1
adds r1, r0
ldrh r0, [r4]
ldrh r1, [r1]
cmp r0, r1
bne _0807058C
adds r1, r0, 0
adds r0, r7, 0
str r2, [sp, 0x8]
bl GiveMoveToMon
lsls r0, 16
lsrs r0, 16
ldr r2, [sp, 0x8]
cmp r0, r2
bne _08070596
ldrh r1, [r4]
adds r0, r7, 0
bl DeleteFirstMoveAndGiveMoveToMon
b _08070596
.pool
_0807058C:
adds r0, r5, 0x1
lsls r0, 16
lsrs r5, r0, 16
cmp r5, r8
bcc _08070546
_08070596:
adds r0, r6, 0x1
lsls r0, 16
lsrs r6, r0, 16
ldr r3, =gUnknown_02024A28
mov r9, r3
cmp r6, 0x3
bls _0807052E
_080705A4:
movs r6, 0
_080705A6:
lsls r0, r6, 1
mov r2, r9
adds r1, r0, r2
ldrh r1, [r1]
adds r2, r0, 0
adds r6, 0x1
mov r8, r6
cmp r1, 0
beq _08070608
movs r5, 0
ldr r0, =gUnknown_02024A28
adds r4, r2, r0
ldr r6, =0x0000ffff
mov r9, r0
_080705C2:
ldr r3, =0x00000121
adds r0, r5, r3
lsls r0, 16
lsrs r0, 16
bl ItemIdToBattleMoveId
ldrh r1, [r4]
lsls r0, 16
lsrs r0, 16
cmp r1, r0
bne _080705FE
lsls r1, r5, 24
lsrs r1, 24
adds r0, r7, 0
bl CanMonLearnTMHM
cmp r0, 0
beq _080705FE
ldrh r1, [r4]
adds r0, r7, 0
bl GiveMoveToMon
lsls r0, 16
lsrs r0, 16
cmp r0, r6
bne _080705FE
ldrh r1, [r4]
adds r0, r7, 0
bl DeleteFirstMoveAndGiveMoveToMon
_080705FE:
adds r0, r5, 0x1
lsls r0, 16
lsrs r5, r0, 16
cmp r5, 0x39
bls _080705C2
_08070608:
mov r1, r8
lsls r0, r1, 16
lsrs r6, r0, 16
cmp r6, 0x3
bls _080705A6
movs r6, 0
mov r2, r9
ldrh r0, [r2]
ldr r3, =gUnknown_02024A30
mov r10, r3
cmp r0, 0
beq _08070672
mov r4, r9
ldr r0, =gUnknown_02024A4C
mov r9, r0
mov r12, r10
_08070628:
movs r5, 0
lsls r2, r6, 1
adds r6, 0x1
mov r8, r6
adds r3, r2, r4
_08070632:
lsls r0, r5, 1
add r0, r9
ldrh r2, [r3]
adds r1, r2, 0
ldrh r0, [r0]
cmp r1, r0
bne _08070654
cmp r1, 0
beq _08070654
ldr r1, [sp]
adds r0, r1, 0x1
lsls r0, 16
lsrs r0, 16
str r0, [sp]
lsls r1, 1
add r1, r12
strh r2, [r1]
_08070654:
adds r0, r5, 0x1
lsls r0, 16
lsrs r5, r0, 16
cmp r5, 0x3
bls _08070632
mov r1, r8
lsls r0, r1, 16
lsrs r6, r0, 16
cmp r6, 0x3
bhi _08070672
lsls r0, r6, 1
adds r0, r4
ldrh r0, [r0]
cmp r0, 0
bne _08070628
_08070672:
movs r6, 0
mov r2, r10
ldrh r0, [r2]
cmp r0, 0
beq _080706FC
_0807067C:
movs r5, 0
adds r3, r6, 0x1
mov r8, r3
ldr r0, [sp, 0x4]
cmp r5, r0
bcs _080706E4
ldr r2, =0x0000ffff
_0807068A:
ldr r1, =gUnknown_020249C4
lsls r0, r5, 1
adds r0, r1
ldrh r1, [r0]
cmp r1, 0
beq _080706D8
lsls r0, r6, 1
mov r3, r10
adds r4, r0, r3
ldrh r0, [r4]
cmp r0, r1
bne _080706D8
adds r1, r0, 0
adds r0, r7, 0
str r2, [sp, 0x8]
bl GiveMoveToMon
lsls r0, 16
lsrs r0, 16
ldr r2, [sp, 0x8]
cmp r0, r2
bne _080706E4
ldrh r1, [r4]
adds r0, r7, 0
bl DeleteFirstMoveAndGiveMoveToMon
b _080706E4
.pool
_080706D8:
adds r0, r5, 0x1
lsls r0, 16
lsrs r5, r0, 16
ldr r0, [sp, 0x4]
cmp r5, r0
bcc _0807068A
_080706E4:
mov r1, r8
lsls r0, r1, 16
lsrs r6, r0, 16
cmp r6, 0x3
bhi _080706FC
ldr r0, =gUnknown_02024A30
lsls r1, r6, 1
adds r1, r0
ldrh r1, [r1]
mov r10, r0
cmp r1, 0
bne _0807067C
_080706FC:
add sp, 0xC
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end daycare_build_child_moveset
thumb_func_start sub_8070710
sub_8070710: @ 8070710
adds r2, r0, 0
movs r1, 0x8C
lsls r1, 1
adds r0, r2, r1
movs r1, 0
str r1, [r0]
movs r3, 0x8E
lsls r3, 1
adds r0, r2, r3
strb r1, [r0]
bx lr
thumb_func_end sub_8070710
thumb_func_start sub_8070728
sub_8070728: @ 8070728
push {lr}
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
ldr r1, =0x00003030
adds r0, r1
bl sub_8070710
pop {r0}
bx r0
.pool
thumb_func_end sub_8070728
thumb_func_start incense_effects
incense_effects: @ 8070744
push {r4-r7,lr}
adds r4, r0, 0
adds r5, r1, 0
ldrh r1, [r4]
movs r7, 0xB4
lsls r7, 1
cmp r1, r7
beq _0807075C
movs r0, 0xAF
lsls r0, 1
cmp r1, r0
bne _0807079E
_0807075C:
adds r0, r5, 0
movs r1, 0xC
bl GetBoxMonData
lsls r0, 16
lsrs r6, r0, 16
adds r0, r5, 0
adds r0, 0x8C
movs r1, 0xC
bl GetBoxMonData
lsls r0, 16
lsrs r2, r0, 16
ldrh r0, [r4]
cmp r0, r7
bne _08070788
cmp r6, 0xDD
beq _08070788
cmp r2, 0xDD
beq _08070788
movs r0, 0xCA
strh r0, [r4]
_08070788:
ldrh r1, [r4]
movs r0, 0xAF
lsls r0, 1
cmp r1, r0
bne _0807079E
cmp r6, 0xDC
beq _0807079E
cmp r2, 0xDC
beq _0807079E
movs r0, 0xB7
strh r0, [r4]
_0807079E:
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end incense_effects
thumb_func_start sub_80707A4
sub_80707A4: @ 80707A4
push {r4-r6,lr}
adds r6, r0, 0
adds r4, r1, 0
adds r0, r4, 0
movs r1, 0xC
bl GetBoxMonData
adds r5, r0, 0
adds r4, 0x8C
adds r0, r4, 0
movs r1, 0xC
bl GetBoxMonData
cmp r5, 0xCA
beq _080707C6
cmp r0, 0xCA
bne _080707E2
_080707C6:
movs r4, 0xAC
lsls r4, 1
adds r0, r6, 0
adds r1, r4, 0
bl GiveMoveToMon
lsls r0, 16
ldr r1, =0xffff0000
cmp r0, r1
bne _080707E2
adds r0, r6, 0
adds r1, r4, 0
bl DeleteFirstMoveAndGiveMoveToMon
_080707E2:
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_80707A4
thumb_func_start sub_80707EC
sub_80707EC: @ 80707EC
push {r4-r7,lr}
mov r7, r8
push {r7}
sub sp, 0x4
adds r7, r0, 0
adds r6, r1, 0
movs r4, 0
movs r0, 0x1
mov r8, r0
_080707FE:
movs r0, 0x8C
muls r0, r4
adds r5, r7, r0
adds r0, r5, 0
movs r1, 0xB
bl GetBoxMonData
lsls r1, r4, 1
add r1, sp
strh r0, [r1]
lsls r0, 16
lsrs r0, 16
cmp r0, 0x84
bne _08070826
adds r0, r4, 0
mov r1, r8
eors r0, r1
strb r0, [r6]
strb r4, [r6, 0x1]
b _0807083E
_08070826:
adds r0, r5, 0
bl GetBoxMonGender
lsls r0, 24
lsrs r0, 24
cmp r0, 0xFE
bne _0807083E
strb r4, [r6]
adds r0, r4, 0
mov r1, r8
eors r0, r1
strb r0, [r6, 0x1]
_0807083E:
adds r0, r4, 0x1
lsls r0, 16
lsrs r4, r0, 16
cmp r4, 0x1
bls _080707FE
ldrb r0, [r6]
lsls r0, 1
add r0, sp
ldrh r0, [r0]
bl GetEggSpecies
lsls r0, 16
lsrs r4, r0, 16
cmp r4, 0x1D
bne _08070870
movs r1, 0x8C
lsls r1, 1
adds r0, r7, r1
ldr r0, [r0]
movs r1, 0x80
lsls r1, 8
ands r0, r1
cmp r0, 0
beq _08070870
movs r4, 0x20
_08070870:
ldr r0, =0x00000183
cmp r4, r0
bne _0807088C
movs r1, 0x8C
lsls r1, 1
adds r0, r7, r1
ldr r0, [r0]
movs r1, 0x80
lsls r1, 8
ands r0, r1
cmp r0, 0
beq _0807088C
movs r4, 0xC1
lsls r4, 1
_0807088C:
ldrb r0, [r6, 0x1]
lsls r0, 1
add r0, sp
ldrh r0, [r0]
cmp r0, 0x84
bne _080708B4
ldrb r1, [r6]
movs r0, 0x8C
muls r0, r1
adds r0, r7, r0
bl GetBoxMonGender
lsls r0, 24
lsrs r0, 24
cmp r0, 0xFE
beq _080708B4
ldrb r1, [r6, 0x1]
ldrb r0, [r6]
strb r0, [r6, 0x1]
strb r1, [r6]
_080708B4:
adds r0, r4, 0
add sp, 0x4
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r1}
bx r1
.pool
thumb_func_end sub_80707EC
thumb_func_start sub_80708C8
sub_80708C8: @ 80708C8
push {r4-r6,lr}
sub sp, 0x6C
adds r6, r0, 0
add r5, sp, 0x64
adds r1, r5, 0
bl sub_80707EC
add r4, sp, 0x68
strh r0, [r4]
adds r0, r4, 0
adds r1, r6, 0
bl incense_effects
ldrh r1, [r4]
mov r0, sp
adds r2, r6, 0
bl sub_8070A0C
mov r0, sp
adds r1, r6, 0
bl InheritIVs
ldrb r0, [r5, 0x1]
movs r2, 0x8C
adds r1, r0, 0
muls r1, r2
adds r1, r6, r1
ldrb r0, [r5]
muls r2, r0
adds r2, r6, r2
mov r0, sp
bl daycare_build_child_moveset
ldrh r0, [r4]
cmp r0, 0xAC
bne _08070918
mov r0, sp
adds r1, r6, 0
bl sub_80707A4
_08070918:
mov r2, sp
adds r2, 0x6A
movs r0, 0x1
strb r0, [r2]
mov r0, sp
movs r1, 0x2D
bl SetMonData
ldr r0, =gPlayerParty
movs r1, 0xFA
lsls r1, 1
adds r0, r1
mov r1, sp
movs r2, 0x64
bl memcpy
bl CompactPartySlots
bl CalculatePlayerPartyCount
adds r0, r6, 0
bl sub_8070710
add sp, 0x6C
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_80708C8
thumb_func_start sub_8070954
sub_8070954: @ 8070954
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
sub sp, 0x18
adds r7, r0, 0
adds r5, r1, 0
adds r6, r2, 0
lsls r5, 16
lsrs r5, 16
lsls r6, 24
lsrs r6, 24
movs r4, 0
str r4, [sp]
str r4, [sp, 0x4]
str r4, [sp, 0x8]
str r4, [sp, 0xC]
adds r1, r5, 0
movs r2, 0x5
movs r3, 0x20
bl CreateMon
movs r0, 0x12
add r0, sp
mov r8, r0
strb r4, [r0]
movs r1, 0x4
add r0, sp, 0x10
strh r1, [r0]
mov r4, sp
adds r4, 0x13
movs r0, 0x1
mov r9, r0
mov r0, r9
strb r0, [r4]
adds r0, r7, 0
movs r1, 0x26
add r2, sp, 0x10
bl SetMonData
ldr r2, =gEggName
adds r0, r7, 0
movs r1, 0x2
bl SetMonData
lsls r2, r5, 3
subs r2, r5
lsls r2, 2
ldr r0, =gBaseStats + 0x11 @ egg cycles offset
adds r2, r0
adds r0, r7, 0
movs r1, 0x20
bl SetMonData
adds r0, r7, 0
movs r1, 0x24
mov r2, r8
bl SetMonData
adds r0, r7, 0
movs r1, 0x3
adds r2, r4, 0
bl SetMonData
cmp r6, 0
beq _080709E6
add r2, sp, 0x14
movs r0, 0xFD
strb r0, [r2]
adds r0, r7, 0
movs r1, 0x23
bl SetMonData
_080709E6:
mov r2, sp
adds r2, 0x15
mov r0, r9
strb r0, [r2]
adds r0, r7, 0
movs r1, 0x2D
bl SetMonData
add sp, 0x18
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_8070954
thumb_func_start sub_8070A0C
sub_8070A0C: @ 8070A0C
push {r4-r6,lr}
mov r6, r9
mov r5, r8
push {r5,r6}
sub sp, 0x14
adds r6, r0, 0
adds r5, r1, 0
lsls r5, 16
lsrs r5, 16
movs r0, 0x8C
lsls r0, 1
adds r2, r0
ldr r0, [r2]
movs r1, 0x1
mov r8, r1
str r1, [sp]
str r0, [sp, 0x4]
movs r4, 0
str r4, [sp, 0x8]
str r4, [sp, 0xC]
adds r0, r6, 0
adds r1, r5, 0
movs r2, 0x5
movs r3, 0x20
bl CreateMon
movs r0, 0x12
add r0, sp
mov r9, r0
strb r4, [r0]
movs r1, 0x4
add r0, sp, 0x10
strh r1, [r0]
mov r4, sp
adds r4, 0x13
mov r1, r8
strb r1, [r4]
adds r0, r6, 0
movs r1, 0x26
add r2, sp, 0x10
bl SetMonData
ldr r2, =gEggName
adds r0, r6, 0
movs r1, 0x2
bl SetMonData
lsls r2, r5, 3
subs r2, r5
lsls r2, 2
ldr r0, =gBaseStats + 0x11 @ egg cycles offset
adds r2, r0
adds r0, r6, 0
movs r1, 0x20
bl SetMonData
adds r0, r6, 0
movs r1, 0x24
mov r2, r9
bl SetMonData
adds r0, r6, 0
movs r1, 0x3
adds r2, r4, 0
bl SetMonData
add sp, 0x14
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_8070A0C
thumb_func_start sp0B8_daycare
sp0B8_daycare: @ 8070AA8
push {lr}
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
ldr r1, =0x00003030
adds r0, r1
bl sub_80708C8
pop {r0}
bx r0
.pool
thumb_func_end sp0B8_daycare
thumb_func_start sub_8070AC4
sub_8070AC4: @ 8070AC4
push {r4-r7,lr}

View File

@ -1343,7 +1343,7 @@ ScriptGiveEgg: @ 80F92C8
lsrs r1, 16
mov r0, sp
movs r2, 0x1
bl sub_8070954
bl CreateEgg
add r2, sp, 0x64
movs r0, 0x1
strb r0, [r2]

View File

@ -18,5 +18,5 @@ gUnknown_0832B6E0:: @ 832B6E0
gUnknown_0832B6F8:: @ 832B6F8
.incbin "baserom.gba", 0x32b6f8, 0x10
gEggName:: @ 832B708
sJapaneseEggNickname:: @ 832B708
.string "$" @ "tamago" ("egg" in Japanese)

View File

@ -193,8 +193,8 @@ gSpecials:: @ 81DBA64
def_special sub_8138B80
def_special sp0B5_daycare
def_special sp0B6_daycare
def_special sub_8070728
def_special sp0B8_daycare
def_special RejectEggFromDayCare
def_special GiveEggFromDaycare
def_special sp0B9_daycare_relationship_comment
def_special sub_8070C58
def_special StoreSelectedPokemonInDaycare

View File

@ -1,6 +1,6 @@
#ifndef GUARD_DAYCARE
#define GUARD_DAYCARE
#define EGG_HATCH_LEVEL 5
#endif // GUARD_DAYCARE

View File

@ -386,4 +386,7 @@ enum
ITEM_OLD_SEA_MAP, // 0x178
};
#define NUM_TECHNICAL_MACHINES 50
#define NUM_HIDDEN_MACHINES 8
#endif // GUARD_ITEMS_H

View File

@ -652,6 +652,7 @@ void sub_806A12C(u16 trainerSpriteId, u8 bankIdentity);
u8 GetSecretBaseTrainerPicIndex(void);
bool8 TryIncrementMonLevel(struct Pokemon *mon);
void BoxMonToMon(struct BoxPokemon *srcMon, struct Pokemon *dstMon);
u8 GetLevelUpMovesBySpecies(u16 species, u16 *moves);
#include "sprite.h"

View File

@ -12,16 +12,28 @@
#include "moves.h"
#define EGG_MOVES_ARRAY_COUNT 10
#define EGG_LVL_UP_MOVES_ARRAY_COUNT 50
extern u16 gMoveToLearn;
extern u8 GetCursorSelectionMonId(void);
extern u16 ItemIdToBattleMoveId(u16);
// this file's functions
static void ClearDaycareMonMisc(struct DaycareMiscMon *misc);
void SetInitialEggData(struct Pokemon *mon, u16 species, struct DayCare *daycare);
// RAM buffers used to assist with BuildEggMoveset()
EWRAM_DATA static u16 sHatchedEggLevelUpMoves[EGG_LVL_UP_MOVES_ARRAY_COUNT] = {0};
EWRAM_DATA static u16 sHatchedEggFatherMoves[4] = {0};
EWRAM_DATA static u16 sHatchedEggFinalMoves[4] = {0};
EWRAM_DATA static u16 sHatchedEggEggMoves[EGG_MOVES_ARRAY_COUNT] = {0};
EWRAM_DATA static u16 sHatchedEggMotherMoves[4] = {0};
#include "data/pokemon/egg_moves.h"
extern const u8 sJapaneseEggNickname[];
u8 *GetMonNick(struct Pokemon *mon, u8 *dest)
{
u8 nickname[POKEMON_NAME_LENGTH * 2];
@ -521,4 +533,288 @@ void InheritIVs(struct Pokemon *egg, struct DayCare *daycare)
}
}
// Counts the number of egg moves a pokemon learns and stores the moves in
// the given array.
static u8 GetEggMoves(struct Pokemon *pokemon, u16 *eggMoves)
{
u16 eggMoveIdx;
u16 numEggMoves;
u16 species;
u16 i;
numEggMoves = 0;
eggMoveIdx = 0;
species = GetMonData(pokemon, MON_DATA_SPECIES);
for (i = 0; i < ARRAY_COUNT(gEggMoves) - 1; i++)
{
if (gEggMoves[i] == species + EGG_MOVES_SPECIES_OFFSET)
{
eggMoveIdx = i + 1;
break;
}
}
for (i = 0; i < EGG_MOVES_ARRAY_COUNT; i++)
{
if (gEggMoves[eggMoveIdx + i] > EGG_MOVES_SPECIES_OFFSET)
{
// TODO: the curly braces around this if statement are required for a matching build.
break;
}
eggMoves[i] = gEggMoves[eggMoveIdx + i];
numEggMoves++;
}
return numEggMoves;
}
void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, struct BoxPokemon *mother)
{
u16 numSharedParentMoves;
u32 numLevelUpMoves;
u16 numEggMoves;
u16 i, j;
numSharedParentMoves = 0;
for (i = 0; i < 4; i++)
{
sHatchedEggMotherMoves[i] = 0;
sHatchedEggFatherMoves[i] = 0;
sHatchedEggFinalMoves[i] = 0;
}
for (i = 0; i < EGG_MOVES_ARRAY_COUNT; i++)
sHatchedEggEggMoves[i] = 0;
for (i = 0; i < EGG_LVL_UP_MOVES_ARRAY_COUNT; i++)
sHatchedEggLevelUpMoves[i] = 0;
numLevelUpMoves = GetLevelUpMovesBySpecies(GetMonData(egg, MON_DATA_SPECIES), sHatchedEggLevelUpMoves);
for (i = 0; i < 4; i++)
{
sHatchedEggFatherMoves[i] = GetBoxMonData(father, MON_DATA_MOVE1 + i);
sHatchedEggMotherMoves[i] = GetBoxMonData(mother, MON_DATA_MOVE1 + i);
}
numEggMoves = GetEggMoves(egg, sHatchedEggEggMoves);
for (i = 0; i < 4; i++)
{
if (sHatchedEggFatherMoves[i] != MOVE_NONE)
{
for (j = 0; j < numEggMoves; j++)
{
if (sHatchedEggFatherMoves[i] == sHatchedEggEggMoves[j])
{
if (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == 0xffff)
DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFatherMoves[i]);
break;
}
}
}
else
{
break;
}
}
for (i = 0; i < 4; i++)
{
if (sHatchedEggFatherMoves[i] != MOVE_NONE)
{
for (j = 0; j < NUM_TECHNICAL_MACHINES + NUM_HIDDEN_MACHINES; j++)
{
if (sHatchedEggFatherMoves[i] == ItemIdToBattleMoveId(ITEM_TM01 + j) && CanMonLearnTMHM(egg, j))
{
if (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == 0xffff)
DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFatherMoves[i]);
}
}
}
}
for (i = 0; i < 4; i++)
{
if (sHatchedEggFatherMoves[i] == MOVE_NONE)
break;
for (j = 0; j < 4; j++)
{
if (sHatchedEggFatherMoves[i] == sHatchedEggMotherMoves[j] && sHatchedEggFatherMoves[i] != MOVE_NONE)
sHatchedEggFinalMoves[numSharedParentMoves++] = sHatchedEggFatherMoves[i];
}
}
for (i = 0; i < 4; i++)
{
if (sHatchedEggFinalMoves[i] == MOVE_NONE)
break;
for (j = 0; j < numLevelUpMoves; j++)
{
if (sHatchedEggLevelUpMoves[j] != MOVE_NONE && sHatchedEggFinalMoves[i] == sHatchedEggLevelUpMoves[j])
{
if (GiveMoveToMon(egg, sHatchedEggFinalMoves[i]) == 0xffff)
DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFinalMoves[i]);
break;
}
}
}
}
void RemoveEggFromDayCare(struct DayCare *daycare)
{
daycare->offspringPersonality = 0;
daycare->stepCounter = 0;
}
void RejectEggFromDayCare(void)
{
RemoveEggFromDayCare(&gSaveBlock1Ptr->daycare);
}
void AlterEggSpeciesWithIncenseItem(u16 *species, struct DayCare *daycare)
{
u16 motherItem, fatherItem;
if (*species == SPECIES_WYNAUT || *species == SPECIES_AZURILL)
{
motherItem = GetBoxMonData(&daycare->mons[0].mon, MON_DATA_HELD_ITEM);
fatherItem = GetBoxMonData(&daycare->mons[1].mon, MON_DATA_HELD_ITEM);
if (*species == SPECIES_WYNAUT && motherItem != ITEM_LAX_INCENSE && fatherItem != ITEM_LAX_INCENSE)
{
*species = SPECIES_WOBBUFFET;
}
if (*species == SPECIES_AZURILL && motherItem != ITEM_SEA_INCENSE && fatherItem != ITEM_SEA_INCENSE)
{
*species = SPECIES_MARILL;
}
}
}
void GiveVoltTackleIfLightBall(struct Pokemon *mon, struct DayCare *daycare)
{
u32 motherItem = GetBoxMonData(&daycare->mons[0].mon, MON_DATA_HELD_ITEM);
u32 fatherItem = GetBoxMonData(&daycare->mons[1].mon, MON_DATA_HELD_ITEM);
if (motherItem == ITEM_LIGHT_BALL || fatherItem == ITEM_LIGHT_BALL)
{
if (GiveMoveToMon(mon, MOVE_VOLT_TACKLE) == 0xFFFF)
DeleteFirstMoveAndGiveMoveToMon(mon, MOVE_VOLT_TACKLE);
}
}
u16 DetermineEggSpeciesAndParentSlots(struct DayCare *daycare, u8 *parentSlots)
{
u16 i;
u16 species[2];
u16 eggSpecies;
// Determine which of the daycare mons is the mother and father of the egg.
// The 0th index of the parentSlots array is considered the mother slot, and the
// 1st index is the father slot.
for (i = 0; i < 2; i++)
{
species[i] = GetBoxMonData(&daycare->mons[i].mon, MON_DATA_SPECIES);
if (species[i] == SPECIES_DITTO)
{
parentSlots[0] = i ^ 1;
parentSlots[1] = i;
}
else if (GetBoxMonGender(&daycare->mons[i].mon) == MON_FEMALE)
{
parentSlots[0] = i;
parentSlots[1] = i ^ 1;
}
}
eggSpecies = GetEggSpecies(species[parentSlots[0]]);
if (eggSpecies == SPECIES_NIDORAN_F && daycare->offspringPersonality & 0x8000)
{
eggSpecies = SPECIES_NIDORAN_M;
}
if (eggSpecies == SPECIES_ILLUMISE && daycare->offspringPersonality & 0x8000)
{
eggSpecies = SPECIES_VOLBEAT;
}
// Make Ditto the "mother" slot if the other daycare mon is male.
if (species[parentSlots[1]] == SPECIES_DITTO && GetBoxMonGender(&daycare->mons[parentSlots[0]].mon) != MON_FEMALE)
{
u8 temp = parentSlots[1];
parentSlots[1] = parentSlots[0];
parentSlots[0] = temp;
}
return eggSpecies;
}
void _GiveEggFromDaycare(struct DayCare *daycare) // give_egg
{
struct Pokemon egg;
u16 species;
u8 parentSlots[2]; // 0th index is "mother" daycare slot, 1st is "father"
bool8 isEgg;
species = DetermineEggSpeciesAndParentSlots(daycare, parentSlots);
AlterEggSpeciesWithIncenseItem(&species, daycare);
SetInitialEggData(&egg, species, daycare);
InheritIVs(&egg, daycare);
BuildEggMoveset(&egg, &daycare->mons[parentSlots[1]].mon, &daycare->mons[parentSlots[0]].mon);
if (species == SPECIES_PICHU)
GiveVoltTackleIfLightBall(&egg, daycare);
isEgg = TRUE;
SetMonData(&egg, MON_DATA_IS_EGG, &isEgg);
gPlayerParty[PARTY_SIZE - 1] = egg;
CompactPartySlots();
CalculatePlayerPartyCount();
RemoveEggFromDayCare(daycare);
}
void CreateEgg(struct Pokemon *mon, u16 species, bool8 setHotSpringsLocation)
{
u8 metLevel;
u16 ball;
u8 language;
u8 metLocation;
u8 isEgg;
CreateMon(mon, species, EGG_HATCH_LEVEL, 0x20, FALSE, 0, FALSE, 0);
metLevel = 0;
ball = ITEM_POKE_BALL;
language = LANGUAGE_JAPANESE;
SetMonData(mon, MON_DATA_POKEBALL, &ball);
SetMonData(mon, MON_DATA_NICKNAME, sJapaneseEggNickname);
SetMonData(mon, MON_DATA_FRIENDSHIP, &gBaseStats[species].eggCycles);
SetMonData(mon, MON_DATA_MET_LEVEL, &metLevel);
SetMonData(mon, MON_DATA_LANGUAGE, &language);
if (setHotSpringsLocation)
{
metLocation = 253; // hot springs; see PokemonSummaryScreen_PrintEggTrainerMemo
SetMonData(mon, MON_DATA_MET_LOCATION, &metLocation);
}
isEgg = TRUE;
SetMonData(mon, MON_DATA_IS_EGG, &isEgg);
}
void SetInitialEggData(struct Pokemon *mon, u16 species, struct DayCare *daycare)
{
u32 personality;
u16 ball;
u8 metLevel;
u8 language;
personality = daycare->offspringPersonality;
CreateMon(mon, species, EGG_HATCH_LEVEL, 0x20, TRUE, personality, FALSE, 0);
metLevel = 0;
ball = ITEM_POKE_BALL;
language = LANGUAGE_JAPANESE;
SetMonData(mon, MON_DATA_POKEBALL, &ball);
SetMonData(mon, MON_DATA_NICKNAME, sJapaneseEggNickname);
SetMonData(mon, MON_DATA_FRIENDSHIP, &gBaseStats[species].eggCycles);
SetMonData(mon, MON_DATA_MET_LEVEL, &metLevel);
SetMonData(mon, MON_DATA_LANGUAGE, &language);
}
void GiveEggFromDaycare(void)
{
_GiveEggFromDaycare(&gSaveBlock1Ptr->daycare);
}

View File

@ -23,6 +23,7 @@
#include "m4a.h"
#include "window.h"
#include "abilities.h"
#include "daycare.h"
#include "battle.h" // to get rid of later
struct EggHatchData
@ -327,7 +328,7 @@ static void CreatedHatchedMon(struct Pokemon *egg, struct Pokemon *temp)
pokerus = GetMonData(egg, MON_DATA_POKERUS);
obedience = GetMonData(egg, MON_DATA_OBEDIENCE);
CreateMon(temp, species, 5, 32, TRUE, personality, 0, 0);
CreateMon(temp, species, EGG_HATCH_LEVEL, 32, TRUE, personality, 0, 0);
for (i = 0; i < 4; i++)
{
@ -393,19 +394,19 @@ void ScriptHatchMon(void)
AddHatchedMonToParty(gSpecialVar_0x8004);
}
static bool8 sub_807158C(struct DaycareData* daycare, u8 daycareId)
static bool8 sub_807158C(struct DayCare *daycare, u8 daycareId)
{
u8 nick[0x20];
struct DaycareMon* daycareMon = &daycare->mons[daycareId];
struct DaycareMon *daycareMon = &daycare->mons[daycareId];
GetBoxMonNick(&daycareMon->mon, nick);
if (daycareMon->mail.itemId != 0
&& (StringCompareWithoutExtCtrlCodes(nick, daycareMon->monName) != 0
|| StringCompareWithoutExtCtrlCodes(gSaveBlock2Ptr->playerName, daycareMon->OT_name) != 0))
if (daycareMon->misc.mail.itemId != 0
&& (StringCompareWithoutExtCtrlCodes(nick, daycareMon->misc.monName) != 0
|| StringCompareWithoutExtCtrlCodes(gSaveBlock2Ptr->playerName, daycareMon->misc.OT_name) != 0))
{
StringCopy(gStringVar1, nick);
TVShowConvertInternationalString(gStringVar2, daycareMon->OT_name, daycareMon->language_maybe);
TVShowConvertInternationalString(gStringVar3, daycareMon->monName, daycareMon->unknown);
TVShowConvertInternationalString(gStringVar2, daycareMon->misc.OT_name, daycareMon->misc.gameLanguage);
TVShowConvertInternationalString(gStringVar3, daycareMon->misc.monName, daycareMon->misc.monLanguage);
return TRUE;
}
return FALSE;

View File

@ -544,23 +544,7 @@ gUnknown_020249B4: @ 20249B4
.space 0x8
.include "src/rng.o"
.align 2
gUnknown_020249C4: @ 20249C4
.space 0x64
gUnknown_02024A28: @ 2024A28
.space 0x8
gUnknown_02024A30: @ 2024A30
.space 0x8
gUnknown_02024A38: @ 2024A38
.space 0x14
gUnknown_02024A4C: @ 2024A4C
.space 0x8
.include "src/daycare.o"
.include "src/load_save.o"
gUnknown_02031C58: @ 2031C58