diff options
| author | notyourav <65437533+notyourav@users.noreply.github.com> | 2022-03-06 21:58:20 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-06 21:58:20 -0800 |
| commit | 80f9adac2009bbc774a463e1828884c1fbcf3e6f (patch) | |
| tree | b9394a0b2d657f2208c6c042d9f50c268ef08a0d /src/object | |
| parent | 4aa967e8d59f9d3999ac86d7de3cd054578b2633 (diff) | |
| parent | 51aeb674ccc5776fe831ed77f31eb1ba144368c8 (diff) | |
Merge pull request #432 from hatal175/housedoorinterior
Diffstat (limited to 'src/object')
| -rw-r--r-- | src/object/houseDoorExterior.c | 2 | ||||
| -rw-r--r-- | src/object/houseDoorInterior.c | 105 |
2 files changed, 106 insertions, 1 deletions
diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c index f7eb966c..1627c7e8 100644 --- a/src/object/houseDoorExterior.c +++ b/src/object/houseDoorExterior.c @@ -164,7 +164,7 @@ void sub_0808692C(Entity* this) { static u8 sub_08086954(Entity* this) { if (sub_0800445C(this)) { - if (sub_0806ED9C(this, 6, 20) >= 0 && gPlayerEntity.animationState == 0 && + if (GetAnimationStateInRectRadius(this, 6, 20) >= 0 && gPlayerEntity.animationState == 0 && (u16)gPlayerState.field_0x90 == 0x400 && gPlayerState.jump_status == 0) { this->actionDelay--; } diff --git a/src/object/houseDoorInterior.c b/src/object/houseDoorInterior.c new file mode 100644 index 00000000..6ca11ef6 --- /dev/null +++ b/src/object/houseDoorInterior.c @@ -0,0 +1,105 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "flags.h" +#include "sound.h" +#include "functions.h" +#include "npc.h" + +typedef struct { + Entity base; + u8 filler[0x15]; + u8 unk7d; + u8 filler2[0x8]; + u16 doorFlags; +} HouseDoorInteriorEntity; + +void HouseDoorInterior_Init(HouseDoorInteriorEntity*); +void HouseDoorInterior_Action1(HouseDoorInteriorEntity*); +void HouseDoorInterior_Delete(HouseDoorInteriorEntity*); + +typedef struct { + u8 frameIndex; + u8 type2; +} PACKED HouseDoorInteriorFrameIndices_struct; + +static const HouseDoorInteriorFrameIndices_struct HouseDoorInteriorFrameIndices[] = { + { -1, 0 }, { -1, 0 }, { 0, 0 }, { 0, 3 }, { 2, 2 }, { 2, 2 }, +}; + +void HouseDoorInterior(Entity* this) { + static void (*const actionFuncs[])(HouseDoorInteriorEntity*) = { + HouseDoorInterior_Init, + HouseDoorInterior_Action1, + HouseDoorInterior_Delete, + }; + actionFuncs[this->action]((HouseDoorInteriorEntity*)this); +} + +typedef struct { + u16 animationState; + u16 unk2; + u16 x; + u16 y; +} gUnk_081227CC_struct; + +static const gUnk_081227CC_struct gUnk_081227CC[] = { + { 0x0, 0x400, 0x6, 0x10 }, + { 0x2, 0x100, 0x10, 0x6 }, + { 0x4, 0x800, 0x6, 0x10 }, + { 0x6, 0x200, 0x10, 0x6 }, +}; + +void HouseDoorInterior_Init(HouseDoorInteriorEntity* this) { + static const Hitbox HouseDoorInteriorHitbox = { + 0, 0, { 5, 3, 3, 5 }, 6, 6, + }; + + const HouseDoorInteriorFrameIndices_struct* ptr; + + if (this->doorFlags && CheckFlags(this->doorFlags)) { + DeleteThisEntity(); + } + super->action = 1; + super->spriteSettings.draw = 1; + this->unk7d = super->actionDelay; + super->spritePriority.b0 = 7; + super->hitbox = (Hitbox*)&HouseDoorInteriorHitbox; + super->actionDelay = 8; + ptr = HouseDoorInteriorFrameIndices + super->type; + if (ptr->frameIndex == 0xff) { + super->frameIndex = super->type2; + } else { + super->frameIndex = ptr->frameIndex; + super->type2 = ptr->type2; + } +} + +void HouseDoorInterior_Action1(HouseDoorInteriorEntity* this) { + const gUnk_081227CC_struct* ptr; + + if (this->doorFlags && CheckFlags(this->doorFlags)) { + super->action = 2; + SoundReq(SFX_111); + return; + } + + if (sub_0800445C(super) && this->unk7d == 0) { + ptr = gUnk_081227CC + super->type2; + if (GetAnimationStateInRectRadius(super, ptr->x, ptr->y) >= 0 && + ptr->animationState == gPlayerEntity.animationState && gPlayerState.field_0x90 & ptr->unk2) { + --super->actionDelay; + } + } else { + super->actionDelay = 8; + } + + if (super->actionDelay == 0) { + super->action = 2; + sub_08078AC0(8, 0, 0); + SoundReq(SFX_111); + } +} + +void HouseDoorInterior_Delete(HouseDoorInteriorEntity* this) { + DeleteThisEntity(); +} |
