Skip to content

Commit

Permalink
EntityStatue (#1615)
Browse files Browse the repository at this point in the history
Thanks to sonicdcer
  • Loading branch information
sozud authored Sep 16, 2024
1 parent eaef9d3 commit 005f5ca
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/symbols.us.bomar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ BottomCornerText = 0x80197CBC;
EntityClockRoomController = 0x80197FEC;
EntityClockHands = 0x80198574;
EntityBirdcageDoor = 0x80198688;
EntityStatue = 0x80198944;
UnkPolyFunc2 = 0x80199868;
PrimDecreaseBrightness = 0x801998E8;
EntityLifeUpSpawn = 0x8019994C;
Expand Down
6 changes: 6 additions & 0 deletions include/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,11 @@ typedef struct {
/* 0x80 */ u16 state;
} ET_Birdcage;

typedef struct {
/* 0x7C */ u16 timer;
/* 0x7E */ u16 step;
} ET_Statue;

// ====== RIC ENTITIES ======

// ==========================
Expand Down Expand Up @@ -1938,6 +1943,7 @@ typedef union { // offset=0x7C
ET_StrongWargDeathBeams strongWargDeathBeams;
ET_ClockRoom clockRoom;
ET_Birdcage birdcage;
ET_Statue statue;
} Ext;

#define SYNC_FIELD(struct1, struct2, field_name) \
Expand Down
119 changes: 117 additions & 2 deletions src/boss/mar/17FEC.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,124 @@ void EntityBirdcageDoor(Entity* self) {
}
}

INCLUDE_ASM("boss/mar/nonmatchings/17FEC", func_us_801988F8);
void UpdateStatueTiles(s32 tilePos, s32 tile) {
u32 i;

for (i = 0; i < 6; i++) {
g_Tilemap.fg[tilePos] = tile;
tilePos++;
g_Tilemap.fg[tilePos] = tile;
tilePos += 15;
}
}

extern u16 D_us_80181288[];
extern u16 D_us_8018128C[];
extern s32 D_us_801812A0[];

// Entity ID 0x19
void EntityStatue(Entity* self) {
Entity* entity = &self[2];
Entity* statueGear = &self[11];
u16 params = self->params;
u16* temp_a0;
u16* fakeVar;

switch (self->step) {
case 0:
InitializeEntity(g_eInitGeneric2);
self->animSet = ANIMSET_OVL(1);
self->animCurFrame = params + 10;
self->hitboxWidth = 16;
self->hitboxHeight = 32;
self->zPriority = 0x40;

if (g_Statues[params] == 0) {
self->posX.i.hi += D_us_80181288[params];
if (self->params != 0) {
UpdateStatueTiles(2, 0x597);
} else {
UpdateStatueTiles(12, 0x597);
}
} else {
self->posX.i.hi += D_us_8018128C[params];
if (self->params != 0) {
UpdateStatueTiles(2, 0);
} else {
UpdateStatueTiles(12, 0);
}
}

self->ext.statue.step = g_Statues[params];
self->posY.i.hi -= 58;

// Create shadow for the statue
CreateEntityFromCurrentEntity(E_DUMMY_1D, entity);
entity->animSet = ANIMSET_OVL(1);
entity->animCurFrame = params + 10;
entity->zPriority = 0x3F;
entity->drawFlags = FLAG_DRAW_UNK8;
entity->blendMode = 0x10;
entity->flags = FLAG_DESTROY_IF_OUT_OF_CAMERA | FLAG_POS_CAMERA_LOCKED |
FLAG_KEEP_ALIVE_OFFCAMERA;
entity->posY.i.hi += 8;
break;

INCLUDE_ASM("boss/mar/nonmatchings/17FEC", func_us_80198944);
case 1:
//! FAKE
fakeVar = g_Statues;
temp_a0 = fakeVar;
temp_a0 += params;
if (*temp_a0 != self->ext.statue.step) {
self->ext.statue.step = *temp_a0;
if (self->ext.statue.step == 0) {
statueGear->ext.statue.step = 2;
} else {
statueGear->ext.statue.step = 1;
}
self->hitboxState = 2;
self->step++;
PlaySfxPositional(0x609);
}
break;

case 2:
GetPlayerCollisionWith(self, 0x10, 0x20, 0x13);
if (self->step_s == 0) {
if (self->ext.statue.step != 0) {
if (self->params != 0) {
UpdateStatueTiles(2, 0);
} else {
UpdateStatueTiles(12, 0);
}
}
self->ext.statue.timer = 96;
self->step_s++;
}

if (self->ext.statue.step != 0) {
self->posX.val += D_us_801812A0[params];
} else {
self->posX.val -= D_us_801812A0[params];
}

if (--self->ext.statue.timer == 0) {
if (self->ext.statue.step == 0) {
if (self->params != 0) {
UpdateStatueTiles(2, 0x597);
} else {
UpdateStatueTiles(12, 0x597);
}
}
statueGear->ext.statue.step = 0;
self->hitboxState = 0;
self->step_s = 0;
self->step--;
}
break;
}
entity->posX.i.hi = self->posX.i.hi;
}

INCLUDE_ASM("boss/mar/nonmatchings/17FEC", func_us_80198C74);

Expand Down

0 comments on commit 005f5ca

Please sign in to comment.