Merge pull request #360 from hatal175/tingleSiblings

This commit is contained in:
notyourav
2022-02-06 02:08:35 -08:00
committed by GitHub
7 changed files with 124 additions and 311 deletions
+123 -32
View File
@@ -2,12 +2,15 @@
#include "entity.h"
#include "npc.h"
#include "functions.h"
#include "item.h"
extern void sub_08064DE4(Entity*);
extern void sub_08064D78(Entity*);
extern void sub_08064EE8(Entity*);
extern void (*const gUnk_0810FBFC[])(Entity*);
void (*const TingleSiblings_Actions[])(Entity*);
const u8 gUnk_0810FC50[];
const u16 TingleSiblings_MessageIndices[][9];
void TingleSiblings(Entity* this) {
if ((this->flags & ENT_SCRIPTED) != 0) {
@@ -18,7 +21,7 @@ void TingleSiblings(Entity* this) {
}
void sub_08064D78(Entity* this) {
gUnk_0810FBFC[this->action](this);
TingleSiblings_Actions[this->action](this);
}
void sub_08064D90(Entity* this) {
@@ -40,25 +43,26 @@ void sub_08064DCC(Entity* this) {
InitAnimationForceUpdate(this, 2);
this->action = 1;
}
/*
void sub_08064DE4(Entity* this) {
u32 bVar1;
switch (this->action) {
case 0:
this->action = 1;
this->spriteSettings = this->spriteSettings & 0xfc | 1;
this->animationState = '\x04';
sub_0807DD50(this);
this->action = 1;
this->spriteSettings.draw = 1;
this->animationState = 4;
sub_0807DD50(this);
break;
case 1:
if (this->interactType == 2) {
this->action = 2;
this->interactType = 0;
GetFacingDirection(this, &gPlayerEntity);
InitAnimationForceUpdate(this, sub_0806F5A4());
sub_0806F118(this);
} else {
sub_0807DD94(this, 0);
}
if (this->interactType == 2) {
this->action = 2;
this->interactType = 0;
InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)));
sub_0806F118(this);
} else {
sub_0807DD94(this, 0);
}
break;
case 2:
if (UpdateFuseInteraction(this)) {
@@ -67,30 +71,27 @@ void sub_08064DE4(Entity* this) {
}
break;
}
{
u8 bVar1 = this->frame;
u8 bVar5 = bVar1 & 0xf;
this->frame = bVar5 ^ bVar1;
if (bVar1 & 0xf) {
Entity* fx = CreateFx(this, bVar5 == 3 ? 0x2a : 0x29, 0);
if (fx && bVar5 == 2) {
fx->spriteSettings.flipX = 1;
}
bVar1 = this->frame & 0xf;
this->frame ^= bVar1;
if (bVar1) {
Entity* fx = CreateFx(this, bVar1 == 3 ? FX_CONFETTI_LARGE : FX_CONFETTI, 0);
if (fx && bVar1 == 2) {
fx->spriteSettings.flipX = 1;
}
}
}*/
ASM_FUNC("asm/non_matching/tingleSiblings/sub_08064DE4.inc", void sub_08064DE4(Entity* this))
}
void sub_08064EA4(Entity* this) {
this->field_0x68.HALF.LO = sub_0801E99C(this);
switch (this->type) {
case 0:
if ((CheckKinstoneFused(0x59) != 0) && (GetInventoryValue(0xc) == 0)) {
if ((CheckKinstoneFused(0x59) != 0) && (GetInventoryValue(ITEM_MAGIC_BOOMERANG) == 0)) {
this->field_0x68.HALF.LO = 0;
}
break;
case 3:
if ((CheckKinstoneFused(0x5a) != 0) && (GetInventoryValue(0xc) == 0)) {
if ((CheckKinstoneFused(0x5a) != 0) && (GetInventoryValue(ITEM_MAGIC_BOOMERANG) == 0)) {
this->field_0x68.HALF.LO = 0;
}
break;
@@ -100,10 +101,85 @@ void sub_08064EA4(Entity* this) {
sub_08078784(this, this->field_0x68.HALF.LO);
}
ASM_FUNC("asm/non_matching/tingleSiblings/sub_08064EE8.inc", void sub_08064EE8(Entity* this))
void sub_08064EE8(Entity* this) {
u32 bVar1;
Entity* fxEnt;
u32 confettiFx;
ASM_FUNC("asm/non_matching/tingleSiblings/sub_08064F28.inc",
void sub_08064F28(Entity* this, ScriptExecutionContext* context))
UpdateAnimationSingleFrame(this);
bVar1 = this->frame & 0xf;
this->frame ^= bVar1;
if (bVar1) {
if (bVar1 != 3) {
confettiFx = FX_CONFETTI;
} else {
confettiFx = FX_CONFETTI_LARGE;
}
fxEnt = CreateFx(this, confettiFx, 0);
if (fxEnt && bVar1 == 2) {
fxEnt->spriteSettings.flipX = 1;
}
}
}
void sub_08064F28(Entity* this, ScriptExecutionContext* context) {
u32 roomFlag;
u32 bVar2;
int iVar3;
int iVar4;
u32 uVar5;
context->condition = 0;
roomFlag = gUnk_0810FC50[this->type];
if (CheckRoomFlag(roomFlag) == 0) {
bVar2 = gSave.unk141[sub_08002632(this)];
if (bVar2 >= 2) {
uVar5 = 3;
} else {
iVar3 = GetInventoryValue(ITEM_MAGIC_BOOMERANG);
uVar5 = 2;
if (iVar3 == 0) {
uVar5 = (-bVar2 | bVar2) >> 0x1f;
}
}
iVar4 = 0xffffffff;
} else {
if (CheckGlobalFlag(0x3a) == 0) {
iVar4 = 100 - gSave.unk117;
if (iVar4 < 1) {
uVar5 = 8;
iVar4 = 0;
SetGlobalFlag(0x3a);
context->condition = 1;
} else {
uVar5 = 7;
if (9 < iVar4) {
uVar5 = 6;
}
if (0x27 < iVar4) {
uVar5 = 5;
}
if (0x45 < iVar4) {
uVar5 = 4;
}
}
} else {
uVar5 = 8;
iVar4 = 0;
}
}
MessageNoOverlap(TingleSiblings_MessageIndices[this->type][uVar5], this);
if (iVar4 > 0) {
gMessage.field_0x10 = (u16)iVar4;
}
if (CheckRoomFlag(roomFlag) == 0) {
SetRoomFlag(roomFlag);
} else {
ClearRoomFlag(roomFlag);
}
}
void TingleSiblings_Fusion(Entity* this) {
u32 tmp;
@@ -119,3 +195,18 @@ void TingleSiblings_Fusion(Entity* this) {
sub_08064EE8(this);
}
}
void (*const TingleSiblings_Actions[])(Entity*) = {
sub_08064D90,
sub_08064DA0,
sub_08064DCC,
};
const u16 TingleSiblings_MessageIndices[][9] = {
{ 0x3f01, 0x3f02, 0x3f03, 0x3f04, 0x3f1b, 0x3f1c, 0x3f1d, 0x3f1e, 0x3f1f },
{ 0x3f05, 0x3f06, 0x3f07, 0x3f07, 0x3f20, 0x3f21, 0x3f22, 0x3f23, 0x3f24 },
{ 0x3f08, 0x3f09, 0x3f09, 0x3f09, 0x3f25, 0x3f26, 0x3f27, 0x3f28, 0x3f29 },
{ 0x3f0a, 0x3f0b, 0x3f0c, 0x3f0d, 0x3f2a, 0x3f2b, 0x3f2c, 0x3f2d, 0x3f2e },
};
const u8 gUnk_0810FC50[] = { 0, 0, 0, 0 };