diff --git a/src/st/no3/48A84.c b/src/st/no3/48A84.c index 40625dae4..b3e431f4f 100644 --- a/src/st/no3/48A84.c +++ b/src/st/no3/48A84.c @@ -236,7 +236,121 @@ void EntityUnkId30(Entity* self) { } } -INCLUDE_ASM("st/no3/nonmatchings/48A84", EntityUnkId31); +void EntityUnkId31(Entity* self) { + Entity* entity; + u16* hitboxPtr; + u16 animFrameIdx; + u16 animCurFrame; + s16 i; + + entity = self - 2; + if (self->step == 0) { + InitializeEntity(D_80180B24); + self->zPriority++; + CreateEntityFromCurrentEntity(E_ID_30, self + 1); + (self + 1)->params = 1; + } + if (self->ext.prim) { + animFrameIdx = (self->animFrameIdx - 1) * 2; + if (entity->step_s == 1) { + hitboxPtr = D_80182FC8 + animFrameIdx; + } else { + hitboxPtr = D_80182FE8 + animFrameIdx; + } + + if (self->facingLeft) { + self->posX.i.hi = entity->posX.i.hi - *hitboxPtr++; + } else { + self->posX.i.hi = entity->posX.i.hi + *hitboxPtr++; + } + self->posY.i.hi = entity->posY.i.hi + *hitboxPtr++; + } else { + self->posX.i.hi = entity->posX.i.hi; + self->posY.i.hi = entity->posY.i.hi; + } + self->facingLeft = entity->facingLeft; + animCurFrame = entity->animCurFrame; + if (self->flags & FLAG_DEAD) { + hitboxPtr = D_80182F9C; + PlaySfxPositional(0x684); + + for (i = 0; i < 3; i++) { + entity = AllocEntity(&g_Entities[224], &g_Entities[256]); + if (entity) { + CreateEntityFromCurrentEntity(E_ID_32, entity); + if (self->facingLeft != 0) { + entity->posX.i.hi -= *hitboxPtr++; + } else { + entity->posX.i.hi += *hitboxPtr++; + } + entity->posY.i.hi += *hitboxPtr++; + entity->params = i; + entity->facingLeft = self->facingLeft; + } + } + + hitboxPtr = D_80182FA8; + for (i = 0; i < 8; i++) { + entity = AllocEntity(&g_Entities[224], &g_Entities[256]); + + if (!entity) { + break; + } + + CreateEntityFromCurrentEntity(E_EXPLOSION, entity); + entity->params = ((self->zPriority + 1) << 8) + 1; + if (self->facingLeft != 0) { + entity->posX.i.hi -= *hitboxPtr++; + } else { + entity->posX.i.hi += *hitboxPtr++; + } + entity->posY.i.hi += *hitboxPtr++; + } + + DestroyEntity(self); + DestroyEntity(self + 1); + return; + } + + if (!self->ext.prim) { + if (animCurFrame >= 86) { + animCurFrame -= 10; + } else if (animCurFrame > 72) { + animCurFrame -= 3; + } else if (animCurFrame < 57) { + animCurFrame = 49; + } else { + animCurFrame -= 6; + } + + if (animCurFrame != 78) { + if ((entity->step == 3) && ((u8)entity->ext.timer.t != 0)) { + self->animCurFrame = animCurFrame + 58; + } else { + self->animCurFrame = animCurFrame; + } + } + } else { + animCurFrame = self->animCurFrame; + } + + if (animCurFrame > 81) { + animCurFrame -= 62; + } else if (animCurFrame > 75) { + animCurFrame -= 59; + } else if (animCurFrame > 62) { + animCurFrame -= 56; + } else if (animCurFrame > 50) { + animCurFrame -= 50; + } else { + animCurFrame -= 49; + } + hitboxPtr = &D_80182E1C[animCurFrame * 8]; + self->hitboxOffX = *hitboxPtr++; + self->hitboxOffY = *hitboxPtr++; + self->hitboxWidth = *hitboxPtr++; + self->hitboxHeight = *hitboxPtr++; +} // some sort of explosion INCLUDE_ASM("st/no3/nonmatchings/48A84", EntityExplosion3); diff --git a/src/st/no3/no3.h b/src/st/no3/no3.h index 894011d40..b3b78b611 100644 --- a/src/st/no3/no3.h +++ b/src/st/no3/no3.h @@ -52,6 +52,8 @@ typedef enum EntityIDs { /* 0x15 */ E_ID_15 = 0x15, /* 0x17 */ E_BG_LIGHTNING = 0x17, /* 0x27 */ E_FALLING_ROCK_2 = 0x27, + /* 0x30 */ E_ID_30 = 0x30, + /* 0x32 */ E_ID_32 = 0x32, /* 0x35 */ E_SPLASH_WATER = 0x35, /* 0x36 */ E_SURFACING_WATER, /* 0x37 */ E_SIDE_WATER_SPLASH, @@ -88,6 +90,10 @@ extern s16 D_80182A38[]; extern u8 D_80182A48[]; extern u16 D_80182A4C[]; extern u16 D_80182E1C[]; +extern u16 D_80182F9C[]; +extern u16 D_80182FA8[]; +extern u16 D_80182FC8[]; +extern u16 D_80182FE8[]; extern u16 D_80180AD0[]; extern u16 g_EInitGeneric[]; extern u16 D_80180AF4[];