mirror of
https://github.com/pret/pmd-red.git
synced 2026-09-30 21:08:47 -05:00
GroundLives_Add
This commit is contained in:
1095
asm/ground_lives.s
1095
asm/ground_lives.s
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,24 @@
|
||||
|
||||
#include "structs/str_position.h"
|
||||
|
||||
static inline void SetUnkInGroundEvent(const CompactPos *posPtr, PixelPos *dst)
|
||||
{
|
||||
if (!(posPtr->xFlags & 4)) {
|
||||
s32 x = posPtr->xTiles << 11;
|
||||
dst->x = x;
|
||||
if (posPtr->xFlags & 2) {
|
||||
dst->x += 0x400;
|
||||
}
|
||||
}
|
||||
if (!(posPtr->yFlags & 4)) {
|
||||
s32 y = posPtr->yTiles << 11;
|
||||
dst->y = y;
|
||||
if (posPtr->yFlags & 2) {
|
||||
dst->y += 0x400;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s16 FindGroundEvent(u32 flags, PixelPos *arg1, PixelPos *arg2);
|
||||
|
||||
#endif // GUARD_GROUND_EVENT_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "structs/str_position.h"
|
||||
|
||||
// ground_lives.s
|
||||
s16 sub_80A7AE8(s16);
|
||||
s32 sub_80A7AE8(s16);
|
||||
s16 sub_80A8FD8(s32, PixelPos*);
|
||||
|
||||
#endif // GUARD_GROUND_LIVES_H
|
||||
|
||||
@@ -207,11 +207,12 @@ void InitScriptData(ScriptData *a0);
|
||||
u8 GroundScriptCheckLockCondition(Action *param_1, s16 param_2);
|
||||
void InitAction2(Action *action);
|
||||
void GetFunctionScript(Action *param_1, ScriptInfoSmall *script, s16 index);
|
||||
bool8 sub_809D684(Action *action, ScriptInfoSmall *scriptInfo);
|
||||
bool8 GroundScriptLockCond(Action *param_1, s16 index, s32 param_3);
|
||||
bool8 ActionResetScriptData(Action *param_1, const DebugLocation *unused);
|
||||
bool8 GroundScript_ExecutePP(Action *, s32 *, ScriptInfoSmall *, const DebugLocation *unused);
|
||||
const ScriptCommand *FindLabel(Action *action, s32 r1);
|
||||
const ScriptCommand *ResolveJump(Action *action, s32 r1);
|
||||
void InitActionWithParams(Action *action, const CallbackData *callbacks, void *parent, s16 group, s8 sector);
|
||||
void InitActionWithParams(Action *action, const CallbackData *callbacks, void *parent, s32 group, s32 sector);
|
||||
|
||||
#endif // GUARD_GROUND_SCRIPT_H
|
||||
|
||||
@@ -153,7 +153,7 @@ u32 sub_801D178(void)
|
||||
if (sUnknown_203B250->unkC != GetPlayerPokemonStruct())
|
||||
goto _ret4;
|
||||
|
||||
if (sub_80A7AE8(7) < 0)
|
||||
if ((s16) sub_80A7AE8(7) < 0)
|
||||
return 0;
|
||||
|
||||
pokeStruct = sub_808D3F8();
|
||||
|
||||
@@ -408,7 +408,7 @@ bool8 sub_809A8B8(s32 param_1, s32 param_2)
|
||||
}
|
||||
|
||||
if (local_28 != -1) {
|
||||
s32 sVar3 = sub_80A7AE8(local_28);
|
||||
s32 sVar3 = (s16) sub_80A7AE8(local_28);
|
||||
if (sVar3 >= 0) {
|
||||
unkPtr->unk0 = local_28;
|
||||
unkPtr->speciesID = sub_80A8BFC(sVar3);
|
||||
|
||||
@@ -12,10 +12,8 @@ typedef struct GroundEvent
|
||||
s16 unk4; // scriptID or group?
|
||||
s8 unk6; // sector
|
||||
s32 unk8;
|
||||
s32 unkC;
|
||||
s32 unk10;
|
||||
s32 unk14;
|
||||
s32 unk18;
|
||||
PixelPos unkC;
|
||||
PixelPos unk14;
|
||||
const ScriptCommand *unk1C;
|
||||
} GroundEvent;
|
||||
|
||||
@@ -121,30 +119,6 @@ void GroundEvent_Cancel(s32 scriptID, s32 sector)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void SetUnkInGroundEvent(const CompactPos *posPtr, s32 *dst)
|
||||
{
|
||||
if (!(posPtr->xFlags & 4)) {
|
||||
s32 unk = posPtr->xTiles << 11;
|
||||
dst[0] = unk;
|
||||
if (posPtr->xFlags & 2) {
|
||||
dst[0] = unk + 0x400;
|
||||
}
|
||||
}
|
||||
if (!(posPtr->yFlags & 4)) {
|
||||
s32 unk = posPtr->yTiles << 11;
|
||||
dst[1] = unk;
|
||||
if (posPtr->yFlags & 2) {
|
||||
dst[1] = unk + 0x400;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct TestStruct
|
||||
{
|
||||
s32 unk0;
|
||||
s32 unk4;
|
||||
};
|
||||
|
||||
s32 GroundEvent_Add(s32 id, const GroundEventData *eventData, s32 group, s32 sector)
|
||||
{
|
||||
s32 i;
|
||||
@@ -153,8 +127,8 @@ s32 GroundEvent_Add(s32 id, const GroundEventData *eventData, s32 group, s32 sec
|
||||
s32 sector_s32 = (s8) sector;
|
||||
const ScriptRef *script;
|
||||
GroundEvent *ptr;
|
||||
struct TestStruct r;
|
||||
s32 sp[2];
|
||||
PixelPos pos;
|
||||
PixelPos resultPos;
|
||||
|
||||
ASM_MATCH_TRICK(sector_s32);
|
||||
|
||||
@@ -193,13 +167,13 @@ s32 GroundEvent_Add(s32 id, const GroundEventData *eventData, s32 group, s32 sec
|
||||
break;
|
||||
}
|
||||
|
||||
r = (struct TestStruct) {eventData->kind << 11, eventData->unk1 << 11};
|
||||
SetUnkInGroundEvent(&eventData->pos, sp);
|
||||
pos = (PixelPos) {eventData->kind << 11, eventData->unk1 << 11};
|
||||
SetUnkInGroundEvent(&eventData->pos, &resultPos);
|
||||
|
||||
ptr->unkC = sp[0];
|
||||
ptr->unk14 = sp[0] + r.unk0;
|
||||
ptr->unk10 = sp[1];
|
||||
ptr->unk18 = sp[1] + r.unk4;
|
||||
ptr->unkC.x = resultPos.x;
|
||||
ptr->unk14.x = resultPos.x + pos.x;
|
||||
ptr->unkC.y = resultPos.y;
|
||||
ptr->unk14.y = resultPos.y + pos.y;
|
||||
ptr->unk1C = eventData->script->script;
|
||||
|
||||
GroundLives_CancelBlank_2();
|
||||
@@ -238,10 +212,10 @@ s16 FindGroundEvent(u32 flags, PixelPos *arg1, PixelPos *arg2)
|
||||
for (i = 0; i < 0x20; i = (s16)(i + 1), ptr++) {
|
||||
if (ptr->unk2 != -1
|
||||
&& (ptr->unk8 & flags)
|
||||
&& ptr->unkC < arg2->x
|
||||
&& ptr->unk14 > arg1->x
|
||||
&& ptr->unk10 < arg2->y
|
||||
&& ptr->unk18 > arg1->y)
|
||||
&& ptr->unkC.x < arg2->x
|
||||
&& ptr->unk14.x > arg1->x
|
||||
&& ptr->unkC.y < arg2->y
|
||||
&& ptr->unk14.y > arg1->y)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
@@ -257,8 +231,8 @@ UNUSED static s16 UnusedFindGroundEvent(u32 flags, PixelPos *arg1, PixelPos *arg
|
||||
for (i = 0; i < 0x20; i = (s16)(i + 1), ptr++) {
|
||||
if (ptr->unk2 != -1 && (ptr->unk8 & flags)) {
|
||||
PixelPos resultPos = {0};
|
||||
resultPos.x = (ptr->unkC + ptr->unk14) / 2;
|
||||
resultPos.y = (ptr->unk10 + ptr->unk18) / 2;
|
||||
resultPos.x = (ptr->unkC.x + ptr->unk14.x) / 2;
|
||||
resultPos.y = (ptr->unkC.y + ptr->unk14.y) / 2;
|
||||
if (resultPos.x < arg2->x
|
||||
&& resultPos.x > arg1->x
|
||||
&& resultPos.y < arg2->y
|
||||
|
||||
@@ -8,13 +8,18 @@
|
||||
#include "event_flag.h"
|
||||
#include "pokemon.h"
|
||||
#include "friend_area.h"
|
||||
#include "random.h"
|
||||
#include "code_8099328.h"
|
||||
#include "code_80958E8.h"
|
||||
#include "debug.h"
|
||||
#include "other_random.h"
|
||||
|
||||
struct GroundLivesMeta_Sub1
|
||||
{
|
||||
// size: 0xC
|
||||
u32 unk0;
|
||||
u32 unk4;
|
||||
u32 unk8;
|
||||
s32 unk8;
|
||||
};
|
||||
|
||||
struct unkStruct_3001B80
|
||||
@@ -28,6 +33,18 @@ struct unkStruct_3001B80
|
||||
};
|
||||
IWRAM_INIT struct unkStruct_3001B80 *gGroundLivesMeta = NULL;
|
||||
|
||||
// TODO: Merge with code 809C5C4
|
||||
struct Tempsub_809CD68Struct
|
||||
{
|
||||
s32 unk0;
|
||||
s32 unk4;
|
||||
s32 unk8;
|
||||
u8 unkC;
|
||||
s32 unk10;
|
||||
s32 unk14;
|
||||
u8 unk18;
|
||||
};
|
||||
|
||||
struct unkStruct_3001B84_sub
|
||||
{
|
||||
// size: 0x1F0
|
||||
@@ -35,17 +52,32 @@ struct unkStruct_3001B84_sub
|
||||
s16 unk2;
|
||||
s16 unk4;
|
||||
s8 unk6;
|
||||
u8 fill8[0x14 - 0x8];
|
||||
s16 unk8;
|
||||
s32 unkC;
|
||||
s32 unk10;
|
||||
PixelPos unk14;
|
||||
u8 fill1C[0x11C-0x1C];
|
||||
s8 unk1C;
|
||||
PixelPos unk20;
|
||||
PixelPos unk28;
|
||||
PixelPos unk30;
|
||||
Action unk38;
|
||||
u32 unk11C;
|
||||
u8 fill120[0x13C - 0x120];
|
||||
struct Tempsub_809CD68Struct unk120;
|
||||
s16 unk13C;
|
||||
s16 unk13E;
|
||||
u8 fill140[4];
|
||||
s16 unk140;
|
||||
s8 unk142;
|
||||
PixelPos unk144;
|
||||
PixelPos unk14C;
|
||||
u8 fill14C[0x170-0x154];
|
||||
PixelPos unk154;
|
||||
u8 unk15C;
|
||||
s8 unk15D;
|
||||
u16 unk15E;
|
||||
u16 unk160;
|
||||
s32 unk164;
|
||||
u16 unk168;
|
||||
u16 unk16A;
|
||||
u8 fill16C[1];
|
||||
struct UnkGroundSpriteStruct unk170;
|
||||
};
|
||||
|
||||
@@ -60,7 +92,7 @@ IWRAM_INIT struct unkStruct_3001B84 *gGroundLives = NULL;
|
||||
|
||||
extern void DeleteGroundLives(void);
|
||||
void GroundLives_Delete(s32);
|
||||
s16 GroundLives_Add(s32 id, const GroundLivesData*, s32 group, s32 sector);
|
||||
s32 GroundLives_Add(s32 id_, const GroundLivesData *ptr, s32 group_, s32 sector_);
|
||||
const struct GroundScriptHeader *GetGroundScript(s16 a0, DebugLocation *);
|
||||
extern DebugLocation gUnknown_811808C;
|
||||
extern u8 gUnknown_8118098[];
|
||||
@@ -223,7 +255,7 @@ void GroundLives_CancelBlank_2(void)
|
||||
|
||||
s32 sub_80A7B94(s16 *a0);
|
||||
|
||||
s16 sub_80A7AE8(s16 a0)
|
||||
s32 sub_80A7AE8(s16 a0)
|
||||
{
|
||||
s32 i;
|
||||
struct unkStruct_3001B84_sub *ptr;
|
||||
@@ -259,8 +291,10 @@ UNUSED static s16 sub_80A7B40(s32 a0_)
|
||||
struct GroundLiveTypeData
|
||||
{
|
||||
s16 unk0;
|
||||
u8 fill2[4];
|
||||
s16 unk2;
|
||||
const char *unk4;
|
||||
u8 unk8;
|
||||
u8 unk9;
|
||||
};
|
||||
|
||||
extern const struct GroundLiveTypeData gGroundLivesTypeData_811E63C[];
|
||||
@@ -428,4 +462,395 @@ s32 sub_80A7B94(s16 *a0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern const s16 gUnknown_81180F0[];
|
||||
extern const s16 gUnknown_81180FC[];
|
||||
|
||||
s32 sub_80A7DDC(s16 *a0, s16 *speciesDst)
|
||||
{
|
||||
const struct GroundLiveTypeData *dataPtr;
|
||||
s32 ret = (s16) sub_80A7B94(a0);
|
||||
|
||||
*speciesDst = MONSTER_NONE;
|
||||
if (*a0 == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
dataPtr = &gGroundLivesTypeData_811E63C[*a0];
|
||||
if (dataPtr->unk0 == 3) {
|
||||
if (*a0 >= 10 && *a0 < 14) {
|
||||
s32 val;
|
||||
s32 sp[4];
|
||||
s32 id = *a0 - 10;
|
||||
|
||||
if (sub_8098F88()) {
|
||||
*speciesDst = gUnknown_81180F0[id];
|
||||
if (*speciesDst == 0) {
|
||||
*a0 = -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sub_80023E4(9)) {
|
||||
val = sub_808D6A4(sp);
|
||||
}
|
||||
else {
|
||||
val = sub_808D654(sp);
|
||||
}
|
||||
|
||||
if (id < val) {
|
||||
PokemonStruct1 *monStrPtr = &gRecruitedPokemonRef->pokemon[sp[id]];
|
||||
*speciesDst = monStrPtr->speciesNum;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (*a0 >= 14 && *a0 <= 29) {
|
||||
FriendAreaCapacity fAreaCapacity;
|
||||
u8 map = sub_8002658(GetScriptVarValue(NULL, GROUND_MAP));
|
||||
|
||||
if (map != 0) {
|
||||
s32 id = *a0 - 14;
|
||||
GetFriendAreaCapacity2(map, &fAreaCapacity, FALSE, FALSE);
|
||||
if (id < fAreaCapacity.maxPokemon) {
|
||||
PokemonStruct1 *monStrPtr = &gRecruitedPokemonRef->pokemon[fAreaCapacity.unk8 + id];
|
||||
if (sub_80023E4(9)) {
|
||||
if (PokemonFlag1(monStrPtr) && !monStrPtr->isTeamLeader) {
|
||||
*speciesDst = monStrPtr->speciesNum;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (PokemonFlag1(monStrPtr) && !monStrPtr->isTeamLeader && !IsMonPartner(monStrPtr)) {
|
||||
*speciesDst = monStrPtr->speciesNum;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*a0 = -1;
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
switch (*a0) {
|
||||
case 1:
|
||||
case 6:
|
||||
case 33:
|
||||
*speciesDst = sub_808D3BC()->speciesNum;
|
||||
break;
|
||||
case 2:
|
||||
case 7:
|
||||
case 34:
|
||||
*speciesDst = sub_808D3F8()->speciesNum;
|
||||
break;
|
||||
case 3:
|
||||
case 8:
|
||||
case 35:
|
||||
*speciesDst = GetPlayerPokemonStruct()->speciesNum;
|
||||
break;
|
||||
case 36:
|
||||
*speciesDst = gUnknown_81180FC[RandInt(15)];
|
||||
return -1;
|
||||
case 32: {
|
||||
s32 friendSpecies = (s16) GetScriptVarValue(NULL, NEW_FRIEND_KIND);
|
||||
if (friendSpecies != MONSTER_NONE) {
|
||||
*speciesDst = friendSpecies;
|
||||
}
|
||||
else {
|
||||
*a0 = -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
case 30:
|
||||
case 31: {
|
||||
u8 dungId;
|
||||
u32 outMain, outSub;
|
||||
struct unkStruct_8096AF8 unkStruct;
|
||||
|
||||
*speciesDst = MONSTER_PORYGON;
|
||||
if (sub_8099328(&dungId)) {
|
||||
GetScriptVarScenario(SCENARIO_SELECT, &outMain, &outSub);
|
||||
sub_8096AF8(&unkStruct, outSub, dungId);
|
||||
if (unkStruct.unk0) {
|
||||
if (*a0 == 30) {
|
||||
*speciesDst = unkStruct.clientSpecies;
|
||||
}
|
||||
else {
|
||||
*speciesDst = unkStruct.targetSpecies;
|
||||
}
|
||||
}
|
||||
|
||||
if (*speciesDst == 0) {
|
||||
*a0 = -1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
default:
|
||||
if (*speciesDst == 0) {
|
||||
*speciesDst = dataPtr->unk2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern const char gUnknown_811811C[];
|
||||
|
||||
extern void sub_809CD68(struct Tempsub_809CD68Struct *dst);
|
||||
|
||||
extern bool8 GetCurrentDungeonBounds(PixelPos *a0, PixelPos *a1);
|
||||
extern void sub_80A7428(struct UnkGroundSpriteStruct *ptr, s32 a1_, s32 monsterId_, s32 a3);
|
||||
extern void SetPredefinedScript(Action *param_1, s16 index, const ScriptCommand *param_3);
|
||||
extern bool8 ExecutePredefinedScript(Action *param_1, s32 *param_2, s16 index, const DebugLocation *debug);
|
||||
extern void sub_809D170(s32 r0, s32 r1);
|
||||
|
||||
extern const CallbackData gGroundLivesCallbacks[];
|
||||
extern const DebugLocation gUnknown_8118170;
|
||||
extern const DebugLocation gUnknown_811817C;
|
||||
extern const DebugLocation gUnknown_8118188;
|
||||
|
||||
void sub_80A9750(struct unkStruct_3001B84_sub *ptr, u16 a1);
|
||||
|
||||
s32 GroundLives_Add(s32 id_, const GroundLivesData *ptr, s32 group_, s32 sector_)
|
||||
{
|
||||
s32 id = (s16) id_;
|
||||
s32 group = (s16) group_;
|
||||
s32 sector = (s8) sector_;
|
||||
struct unkStruct_3001B84_sub *livesPtr;
|
||||
const struct GroundLiveTypeData *typeDataPtr;
|
||||
const ScriptCommand *scrCommand;
|
||||
s16 sp12, species;
|
||||
bool8 var24;
|
||||
bool8 r8;
|
||||
s32 r7;
|
||||
|
||||
sp12 = ptr->kind;
|
||||
r8 = FALSE;
|
||||
r7 = (s16) sub_80A7DDC(&sp12, &species);
|
||||
|
||||
if (sp12 == -1)
|
||||
return -1;
|
||||
|
||||
switch (r7) {
|
||||
case 0:
|
||||
id = 0;
|
||||
break;
|
||||
case 1:
|
||||
id = 1;
|
||||
break;
|
||||
case 2:
|
||||
if (GetScriptVarValue(NULL, PARTNER1_KIND) == 0) {
|
||||
r7 = 1;
|
||||
}
|
||||
id = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
typeDataPtr = &gGroundLivesTypeData_811E63C[sp12];
|
||||
if (id < 0) {
|
||||
switch (sp12) {
|
||||
case 0x21:
|
||||
if (gGroundLives->array[0].unk2 == 1)
|
||||
return -1;
|
||||
id = sub_80A7AE8(sp12);
|
||||
break;
|
||||
case 0x23:
|
||||
if (gGroundLives->array[0].unk2 == 3)
|
||||
return -1;
|
||||
id = sub_80A7AE8(sp12);
|
||||
break;
|
||||
default:
|
||||
id = sub_80A7AE8(sp12);
|
||||
break;
|
||||
}
|
||||
|
||||
if (id < 0) {
|
||||
s32 i = 3;
|
||||
livesPtr = &gGroundLives->array[3];
|
||||
|
||||
for (; i < UNK_3001B84_ARR_COUNT; i = (s16)(i + 1), livesPtr++) {
|
||||
if (livesPtr->unk2 == -1) {
|
||||
id = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (id < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
livesPtr = &gGroundLives->array[id];
|
||||
Log(0, gUnknown_811811C, id, sp12, typeDataPtr->unk0, group, sector);
|
||||
var24 = (livesPtr->unk2 == -1);
|
||||
livesPtr->unk0 = id;
|
||||
livesPtr->unk2 = sp12;
|
||||
livesPtr->unk4 = group;
|
||||
livesPtr->unk6 = sector;
|
||||
livesPtr->unk8 = species;
|
||||
sub_809CD68(&livesPtr->unk120);
|
||||
livesPtr->unk120.unk0 = 9;
|
||||
|
||||
switch (typeDataPtr->unk0) {
|
||||
case 1:
|
||||
livesPtr->unk11C = 0x2300181D;
|
||||
livesPtr->unk120.unk0 = 1;
|
||||
break;
|
||||
case 2:
|
||||
livesPtr->unk11C = 0x23001000;
|
||||
break;
|
||||
case 3:
|
||||
livesPtr->unk11C = 0x2300068D;
|
||||
break;
|
||||
case 6:
|
||||
livesPtr->unk11C = 0x2000000D;
|
||||
break;
|
||||
case 7:
|
||||
livesPtr->unk11C = 0x20000;
|
||||
break;
|
||||
case 8:
|
||||
livesPtr->unk11C = 0;
|
||||
break;
|
||||
case 9:
|
||||
livesPtr->unk11C = 0xC0000;
|
||||
break;
|
||||
case 10:
|
||||
livesPtr->unk11C = 0x20010000;
|
||||
break;
|
||||
default:
|
||||
livesPtr->unk11C = 0x2300068D;
|
||||
break;
|
||||
}
|
||||
|
||||
livesPtr->unkC = typeDataPtr->unk8 << 11;
|
||||
livesPtr->unk10 = typeDataPtr->unk9 << 11;
|
||||
livesPtr->unk14.x = livesPtr->unkC / 2;
|
||||
livesPtr->unk14.y = livesPtr->unk10 / 2;
|
||||
livesPtr->unk1C = ptr->unk1;
|
||||
SetUnkInGroundEvent(&ptr->pos, &livesPtr->unk20);
|
||||
if (var24) {
|
||||
struct GroundLivesMeta_Sub1 *metaPtr;
|
||||
|
||||
livesPtr->unk142 = livesPtr->unk1C;
|
||||
livesPtr->unk144.x = livesPtr->unk20.x - livesPtr->unk14.x;
|
||||
livesPtr->unk14C.x = livesPtr->unk20.x + livesPtr->unk14.x;
|
||||
livesPtr->unk144.y = livesPtr->unk20.y - livesPtr->unk14.y;
|
||||
livesPtr->unk14C.y = livesPtr->unk20.y + livesPtr->unk14.y;
|
||||
livesPtr->unk154.x = livesPtr->unk154.y = 0;
|
||||
livesPtr->unk13C = r7;
|
||||
metaPtr = &gGroundLivesMeta->unk0[r7];
|
||||
metaPtr->unk8 = -1;
|
||||
metaPtr->unk0 = 0;
|
||||
metaPtr->unk4 = 0;
|
||||
if (livesPtr->unk2 >= 14 && livesPtr->unk2 <= 29) {
|
||||
livesPtr->unk140 = OtherRandInt(0x12);
|
||||
}
|
||||
else {
|
||||
livesPtr->unk140 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (livesPtr->unk11C & 0x800) {
|
||||
livesPtr->unk13E = FindGroundEvent(0x20, &livesPtr->unk144, &livesPtr->unk14C);
|
||||
}
|
||||
else {
|
||||
livesPtr->unk13E = -1;
|
||||
}
|
||||
|
||||
GetCurrentDungeonBounds(&livesPtr->unk28, &livesPtr->unk30);
|
||||
if (var24) {
|
||||
livesPtr->unk15D = -1;
|
||||
livesPtr->unk15E = 0x300;
|
||||
livesPtr->unk160 = 1;
|
||||
livesPtr->unk164 = 0;
|
||||
livesPtr->unk168 = 0x807;
|
||||
livesPtr->unk15C = 1;
|
||||
livesPtr->unk16A = 0;
|
||||
sub_80A7428(&livesPtr->unk170, livesPtr->unk2, livesPtr->unk8, livesPtr->unk11C);
|
||||
}
|
||||
|
||||
if (!var24) {
|
||||
if (sub_809D684(&livesPtr->unk38, &gGroundLivesMeta->unk32C)) {
|
||||
s32 r10;
|
||||
s32 r9;
|
||||
// Note: these ptr variables are unfortunately a fakematch, but I was not able to match the function without them...
|
||||
u16 *ptr1;
|
||||
s8 *ptr2;
|
||||
|
||||
if (livesPtr->unk38.scriptData2.savedState != 0) {
|
||||
r10 = livesPtr->unk38.scriptData2.unk24;
|
||||
r9 = livesPtr->unk38.scriptData2.unk26;
|
||||
|
||||
ptr1 = &livesPtr->unk38.scriptData.unk24;
|
||||
ptr2 = &livesPtr->unk38.scriptData.unk26;
|
||||
}
|
||||
else {
|
||||
r10 = livesPtr->unk38.scriptData.unk24;
|
||||
r9 = livesPtr->unk38.scriptData.unk26;
|
||||
|
||||
ptr1 = &livesPtr->unk38.scriptData.unk24;
|
||||
ptr2 = &livesPtr->unk38.scriptData.unk26;
|
||||
}
|
||||
|
||||
InitAction2(&livesPtr->unk38);
|
||||
InitActionWithParams(&livesPtr->unk38, gGroundLivesCallbacks, livesPtr, group, sector);
|
||||
GroundScript_ExecutePP(&livesPtr->unk38, NULL, &gGroundLivesMeta->unk32C, &gUnknown_8118170);
|
||||
ptr2++;ptr2--;
|
||||
*ptr1 = r10;
|
||||
*ptr2 = r9;
|
||||
r8 = TRUE;
|
||||
}
|
||||
else {
|
||||
InitAction2(&livesPtr->unk38);
|
||||
InitActionWithParams(&livesPtr->unk38, gGroundLivesCallbacks, livesPtr, group, sector);
|
||||
}
|
||||
}
|
||||
else {
|
||||
InitActionWithParams(&livesPtr->unk38, gGroundLivesCallbacks, livesPtr, group, sector);
|
||||
}
|
||||
|
||||
scrCommand = ptr->scripts[1];
|
||||
if (scrCommand == NULL) {
|
||||
scrCommand = gFunctionScriptTable[19].script;
|
||||
}
|
||||
SetPredefinedScript(&livesPtr->unk38, 1, scrCommand);
|
||||
|
||||
scrCommand = ptr->scripts[2];
|
||||
if (scrCommand == NULL) {
|
||||
scrCommand = gFunctionScriptTable[4].script;
|
||||
}
|
||||
SetPredefinedScript(&livesPtr->unk38, 2, scrCommand);
|
||||
|
||||
scrCommand = ptr->scripts[3];
|
||||
if (scrCommand == NULL) {
|
||||
scrCommand = gFunctionScriptTable[6].script;
|
||||
}
|
||||
SetPredefinedScript(&livesPtr->unk38, 3, scrCommand);
|
||||
|
||||
if (ptr->scripts[0] != NULL) {
|
||||
SetPredefinedScript(&livesPtr->unk38, 0, ptr->scripts[0]);
|
||||
if (!var24 && !r8 && !(livesPtr->unk11C & 0x1800)) {
|
||||
GroundScript_ExecutePP(&livesPtr->unk38, NULL, &gGroundLivesMeta->unk32C, &gUnknown_811817C);
|
||||
livesPtr->unk38.scriptData.unk24 = livesPtr->unk160 | livesPtr->unk15E;
|
||||
livesPtr->unk38.scriptData.unk26 = livesPtr->unk142;
|
||||
}
|
||||
ExecutePredefinedScript(&livesPtr->unk38, NULL, 0, &gUnknown_8118188);
|
||||
}
|
||||
else if (r8) {
|
||||
livesPtr->unk15C = 1;
|
||||
livesPtr->unk142 = livesPtr->unk38.scriptData.unk26;
|
||||
sub_80A9750(livesPtr, livesPtr->unk38.scriptData.unk24);
|
||||
}
|
||||
|
||||
if (typeDataPtr->unk0 == 1 && var24) {
|
||||
sub_809D170(1, id);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -31,7 +31,6 @@ extern bool8 GroundScriptNotify(void *, s32);
|
||||
extern const CallbackData gGroundScriptNullCallbacks;
|
||||
extern const DebugLocation gUnknown_8117538[];
|
||||
|
||||
extern void InitActionWithParams(Action *action, const CallbackData *callbacks, void *parent, s16 group, s8 sector);
|
||||
extern void sub_80A2D00(unkStruct_3001B70 *);
|
||||
extern void sub_80A2D68(unkStruct_3001B70 *);
|
||||
extern void sub_80A2D88(unkStruct_3001B70 *);
|
||||
|
||||
@@ -315,13 +315,10 @@ void InitAction(Action *a0)
|
||||
InitScriptData(&a0->scriptData2);
|
||||
}
|
||||
|
||||
void InitActionWithParams(Action *action, const CallbackData *callbacks, void *parent, s16 group, s8 sector)
|
||||
void InitActionWithParams(Action *action, const CallbackData *callbacks, void *parent, s32 group, s32 sector)
|
||||
{
|
||||
s32 group_s32;
|
||||
s32 sector_s32;
|
||||
|
||||
group_s32 = group;
|
||||
sector_s32 = sector;
|
||||
s32 group_s32 = (s16) group;
|
||||
s32 sector_s32 = (s8) sector;
|
||||
|
||||
InitAction(action);
|
||||
|
||||
@@ -360,28 +357,28 @@ bool8 sub_809D678(Action *action)
|
||||
return action->scriptData.savedState == 0 ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
bool8 sub_809D684(Action *action, ScriptCommand **scriptPtr)
|
||||
bool8 sub_809D684(Action *action, ScriptInfoSmall *scriptInfo)
|
||||
{
|
||||
if(action->scriptData.savedState != 0)
|
||||
{
|
||||
if(action->scriptData.savedScript.ptr != 0)
|
||||
{
|
||||
if(action->scriptData.savedScript.ptr2 == *scriptPtr) return 1;
|
||||
if(action->scriptData.savedScript.ptr2 == scriptInfo->ptr) return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(action->scriptData.script.ptr2 == *scriptPtr) return 1;
|
||||
if(action->scriptData.script.ptr2 == scriptInfo->ptr) return 1;
|
||||
}
|
||||
}
|
||||
if(action->scriptData2.savedState != 0)
|
||||
{
|
||||
if(action->scriptData2.savedScript.ptr != 0)
|
||||
{
|
||||
if(action->scriptData2.savedScript.ptr2 == *scriptPtr) return 1;
|
||||
if(action->scriptData2.savedScript.ptr2 == scriptInfo->ptr) return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(action->scriptData2.script.ptr2 == *scriptPtr) return 1;
|
||||
if(action->scriptData2.script.ptr2 == scriptInfo->ptr) return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -3237,7 +3234,7 @@ s32 sub_80A14E8(Action *action, u8 idx, u32 r2, s32 r3)
|
||||
s32 r4;
|
||||
PixelPos sp_318;
|
||||
PixelPos sp_320;
|
||||
s32 r5 = sub_80A7AE8(r2);
|
||||
s32 r5 = (s16) sub_80A7AE8(r2);
|
||||
if(r5 >= 0) {
|
||||
r4 = (r3 << 8);
|
||||
action->callbacks->getHitboxCenter(action->parentObject, &sp_318);
|
||||
|
||||
Reference in New Issue
Block a user