more of daycare done

This commit is contained in:
DizzyEggg 2017-11-14 23:25:07 +01:00
parent 95949c772e
commit 0310be3007
5 changed files with 72 additions and 139 deletions

View File

@ -7,137 +7,6 @@
thumb_func_start sub_8070AC4
sub_8070AC4: @ 8070AC4
push {r4-r7,lr}
sub sp, 0x4
adds r6, r0, 0
movs r7, 0
movs r5, 0
_08070ACE:
movs r0, 0x8C
adds r4, r5, 0
muls r4, r0
adds r0, r6, r4
movs r1, 0x5
bl GetBoxMonData
cmp r0, 0
beq _08070AEE
adds r1, r6, 0
adds r1, 0x88
adds r1, r4
ldr r0, [r1]
adds r0, 0x1
str r0, [r1]
adds r7, 0x1
_08070AEE:
adds r5, 0x1
cmp r5, 0x1
bls _08070ACE
movs r1, 0x8C
lsls r1, 1
adds r0, r6, r1
ldr r0, [r0]
cmp r0, 0
bne _08070B34
cmp r7, 0x2
bne _08070B34
subs r1, 0x4
adds r0, r6, r1
ldrb r0, [r0]
cmp r0, 0xFF
bne _08070B34
adds r0, r6, 0
bl daycare_relationship_score
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
bl Random
lsls r0, 16
lsrs r0, 16
movs r1, 0x64
muls r0, r1
ldr r1, =0x0000ffff
bl __udivsi3
cmp r4, r0
bls _08070B34
bl TriggerPendingDaycareEgg
_08070B34:
movs r0, 0x8E
lsls r0, 1
adds r1, r6, r0
ldrb r0, [r1]
adds r0, 0x1
strb r0, [r1]
lsls r0, 24
lsrs r0, 24
cmp r0, 0xFF
bne _08070BC0
bl GetEggStepsToSubtract
lsls r0, 24
lsrs r6, r0, 24
movs r5, 0
ldr r0, =gPlayerPartyCount
ldrb r0, [r0]
cmp r5, r0
bcs _08070BC0
ldr r4, =gPlayerParty
_08070B5C:
adds r0, r4, 0
movs r1, 0x2D
bl GetMonData
cmp r0, 0
beq _08070BB4
adds r0, r4, 0
movs r1, 0x4
bl GetMonData
cmp r0, 0
bne _08070BB4
adds r0, r4, 0
movs r1, 0x20
bl GetMonData
adds r1, r0, 0
str r1, [sp]
cmp r0, 0
beq _08070BA8
cmp r0, r6
bcc _08070B98
subs r0, r6
b _08070B9A
.pool
_08070B98:
subs r0, r1, 0x1
_08070B9A:
str r0, [sp]
adds r0, r4, 0
movs r1, 0x20
mov r2, sp
bl SetMonData
b _08070BB4
_08070BA8:
ldr r0, =gSpecialVar_0x8004
strh r5, [r0]
movs r0, 0x1
b _08070BC2
.pool
_08070BB4:
adds r4, 0x64
adds r5, 0x1
ldr r0, =gPlayerPartyCount
ldrb r0, [r0]
cmp r5, r0
bcc _08070B5C
_08070BC0:
movs r0, 0
_08070BC2:
add sp, 0x4
pop {r4-r7}
pop {r1}
bx r1
.pool
thumb_func_end sub_8070AC4
thumb_func_start sub_8070BD0
sub_8070BD0: @ 8070BD0
push {lr}
@ -145,7 +14,7 @@ sub_8070BD0: @ 8070BD0
ldr r0, [r0]
ldr r1, =0x00003030
adds r0, r1
bl sub_8070AC4
bl _DoEggActions_CheckHatch
lsls r0, 24
lsrs r0, 24
pop {r1}
@ -332,8 +201,8 @@ _08070D46:
bx r1
thumb_func_end sub_8070D1C
thumb_func_start daycare_relationship_score
daycare_relationship_score: @ 8070D4C
thumb_func_start GetDaycareCompatibilityScore
GetDaycareCompatibilityScore: @ 8070D4C
push {r4-r7,lr}
mov r7, r10
mov r6, r9
@ -481,7 +350,7 @@ _08070E5C:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end daycare_relationship_score
thumb_func_end GetDaycareCompatibilityScore
thumb_func_start daycare_relationship_score_from_savegame
daycare_relationship_score_from_savegame: @ 8070E6C
@ -490,7 +359,7 @@ daycare_relationship_score_from_savegame: @ 8070E6C
ldr r0, [r0]
ldr r1, =0x00003030
adds r0, r1
bl daycare_relationship_score
bl GetDaycareCompatibilityScore
lsls r0, 24
lsrs r0, 24
pop {r1}

View File

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

10
include/egg_hatch.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef GUARD_EGG_HATCH_H
#define GUARD_EGG_HATCH_H
void ScriptHatchMon(void);
bool8 sub_8071614(void);
void EggHatch(void);
u8 GetEggStepsToSubtract(void);
u16 sub_80722E0(void);
#endif // GUARD_EGG_HATCH_H

View File

@ -10,6 +10,7 @@
#include "rng.h"
#include "main.h"
#include "moves.h"
#include "egg_hatch.h"
#define EGG_MOVES_ARRAY_COUNT 10
#define EGG_LVL_UP_MOVES_ARRAY_COUNT 50
@ -22,6 +23,7 @@ extern u16 ItemIdToBattleMoveId(u16);
// this file's functions
static void ClearDaycareMonMisc(struct DaycareMiscMon *misc);
void SetInitialEggData(struct Pokemon *mon, u16 species, struct DayCare *daycare);
u8 GetDaycareCompatibilityScore(struct DayCare *daycare);
// RAM buffers used to assist with BuildEggMoveset()
EWRAM_DATA static u16 sHatchedEggLevelUpMoves[EGG_LVL_UP_MOVES_ARRAY_COUNT] = {0};
@ -818,3 +820,54 @@ void GiveEggFromDaycare(void)
{
_GiveEggFromDaycare(&gSaveBlock1Ptr->daycare);
}
bool8 _DoEggActions_CheckHatch(struct DayCare *daycare)
{
u32 i, validEggs = 0;
for (i = 0; i < DAYCARE_MON_COUNT; i++)
{
if (GetBoxMonData(&daycare->mons[i].mon, MON_DATA_SANITY_BIT2))
daycare->mons[i].steps++, validEggs++;
}
// try to trigger poke sex
if (daycare->offspringPersonality == 0 && validEggs == 2 && (daycare->mons[1].steps & 0xFF) == 0xFF)
{
u8 loveScore = GetDaycareCompatibilityScore(daycare);
if (loveScore > (Random() * 100u) / USHRT_MAX)
TriggerPendingDaycareEgg();
}
if (++daycare->stepCounter == 255) // hatch an egg
{
u32 steps;
u8 toSub = GetEggStepsToSubtract();
for (i = 0; i < gPlayerPartyCount; i++)
{
if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
continue;
if (GetMonData(&gPlayerParty[i], MON_DATA_SANITY_BIT1))
continue;
steps = GetMonData(&gPlayerParty[i], MON_DATA_FRIENDSHIP);
if (steps != 0) // subtract needed steps
{
if (steps >= toSub)
steps -= toSub;
else
steps -= 1;
SetMonData(&gPlayerParty[i], MON_DATA_FRIENDSHIP, &steps);
}
else // hatch the egg
{
gSpecialVar_0x8004 = i;
return TRUE;
}
}
}
return FALSE; // no hatching
}

View File

@ -1,5 +1,6 @@
#include "global.h"
#include "pokemon.h"
#include "egg_hatch.h"
#include "pokedex.h"
#include "items.h"
#include "script.h"