HD CEN DestroyEntity EntityPrizeDrop (#1718)

This commit is contained in:
sozud 2024-10-02 18:04:22 -07:00 committed by GitHub
parent c90cbfaebe
commit b6152f5ac8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 317 additions and 316 deletions

View File

@ -19,6 +19,8 @@ aluric_subweapons_idx = 0x80180F38;
aluric_subweapons_id = 0x80180F4C;
g_goldCollectTexts = 0x80180F60;
c_GoldPrizes = 0x80180F88;
g_SubweaponAnimPrizeDrop = 0x80180FB0;
D_80180EB8 = 0x80181010;
c_HeartPrizes = 0x80181018;
g_bigRedFireballAnim = 0x80181044;
g_ESoulStealOrbAngles = 0x801811FC;
@ -67,14 +69,7 @@ AllocEntity = 0x80194A28;
SetStep = 0x80194DF8;
InitializeEntity = 0x80194EC8;
CheckFieldCollision = 0x80195114;
PrizeDropFall = 0x80195668;
PrizeDropFall2 = 0x801956EC;
CollectHeart = 0x80195848;
CollectGold = 0x801958C8;
CollectSubweapon = 0x801959A4;
CollectHeartVessel = 0x80195ABC;
CollectLifeVessel = 0x80195B60;
DestroyCurrentEntity = 0x80195BB0;
EntityPrizeDrop = 0x80195BD8;
EntityExplosion = 0x8019644C;
BlinkItem = 0x80196548;

View File

@ -26,7 +26,7 @@ extern u16 aluric_subweapons_id[];
#include "../collect_life_vessel.h"
INCLUDE_ASM("st/cen/nonmatchings/e_collect", DestroyCurrentEntity);
#include "../destroy_current_entity.h"
INCLUDE_RODATA("st/cen/nonmatchings/e_collect", D_hd_8018D4F8);
@ -48,7 +48,9 @@ INCLUDE_RODATA("st/cen/nonmatchings/e_collect", D_hd_8018D538);
INCLUDE_RODATA("st/cen/nonmatchings/e_collect", D_hd_8018D540);
INCLUDE_ASM("st/cen/nonmatchings/e_collect", EntityPrizeDrop);
extern s16 D_80180EB8[];
extern u8* g_SubweaponAnimPrizeDrop[];
#include "../entity_prize_drop.h"
// TODO: needs g_ExplosionYVelocities, g_ExplosionAnimations
INCLUDE_ASM("st/cen/nonmatchings/e_collect", EntityExplosion);

View File

@ -0,0 +1,2 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
static void DestroyCurrentEntity(u16 id) { DestroyEntity(g_CurrentEntity); }

View File

@ -182,315 +182,10 @@ Entity* func_801939C4(void) {
return g_CurrentEntity;
}
#else
static void DestroyCurrentEntity(u16 id) { DestroyEntity(g_CurrentEntity); }
#include "destroy_current_entity.h"
#endif
// if self->params & 0x8000 then the item will not disappear
void EntityPrizeDrop(Entity* self) {
Collider collider;
Primitive* prim;
u16 itemId;
s16 index;
s32 primIndex;
s32 subWeaponId;
s32 subWeaponId_;
// if self->params & 0x8000 then the item will not disappear
itemId = self->params & 0x7FFF;
if (self->step) {
#if defined(VERSION_PSP)
if (g_PlayableCharacter == PLAYER_MARIA) {
AnimateEntity(g_MariaSubweaponAnimPrizeDrop[itemId], self);
} else {
AnimateEntity(g_SubweaponAnimPrizeDrop[itemId], self);
}
#else
AnimateEntity(g_SubweaponAnimPrizeDrop[itemId], self);
#endif
}
#if defined(VERSION_US) && STAGE != STAGE_ST0
if (self->step > 1 && self->step < 5 && self->hitFlags) {
#else
if (self->step && self->step < 5 && self->hitFlags) {
#endif
self->step = 5;
}
#if STAGE == STAGE_ST0
self->palette = 0x100;
#else
self->palette = 0;
#endif
if ((u8)self->unk6D[0] >= 0x18 && !(g_GameTimer & 2) && self->params != 1) {
self->palette = 0x815F;
}
switch (self->step) {
case 0:
InitializeEntity(g_InitializeData0);
self->zPriority = g_unkGraphicsStruct.g_zEntityCenter - 0x14;
self->drawMode = DRAW_DEFAULT;
#if STAGE == STAGE_ST0
if (itemId >= 23) {
#else
if (itemId > 23) {
#endif
itemId = self->params = 0;
}
#if defined(VERSION_PSP)
if (g_PlayableCharacter == PLAYER_MARIA && itemId >= 0xE &&
itemId < 23) {
switch (itemId) {
case 14:
itemId = self->params = 15;
break;
case 15:
itemId = self->params = 14;
break;
case 21:
itemId = self->params = 16;
break;
case 17:
itemId = self->params = 17;
break;
case 19:
itemId = 19; // causes a lot of regswaps
self->params = 19;
break;
default:
itemId = self->params = 0;
break;
}
}
#endif
if (itemId >= 14 && itemId < 23
#if defined(VERSION_PSP)
&& g_PlayableCharacter != PLAYER_MARIA
#endif
) {
subWeaponId_ = aluric_subweapons_id[g_Status.subWeapon];
if (itemId == subWeaponId_) {
itemId = 1;
self->params = 1;
}
}
if (!itemId || itemId == 2) {
self->hitboxWidth = 4;
}
break;
case 1:
g_api.CheckCollision(self->posX.i.hi, self->posY.i.hi, &collider, 0);
if (collider.effects & EFFECT_NOTHROUGH_PLUS) {
DestroyEntity(self);
} else {
self->step++;
#if !(defined VERSION_BETA || STAGE == STAGE_ST0)
index = self->ext.equipItemDrop.castleFlag;
if (index) {
index--;
g_CastleFlags[(index >> 3) + COLLECT_FLAGS_START] |=
1 << (index & 7);
}
#endif
}
if (!itemId) {
self->ext.equipItemDrop.fallSpeed = FIX(-1);
self->ext.equipItemDrop.gravity = 0x800;
}
break;
case 2:
#if STAGE == STAGE_ST0
if (self->velocityX < 0) {
#else
if (self->velocityY < 0) {
#endif
g_api.CheckCollision(
self->posX.i.hi, self->posY.i.hi - 7, &collider, 0);
if (collider.effects & EFFECT_NOTHROUGH) {
self->velocityY = 0;
}
}
MoveEntity();
g_api.CheckCollision(
self->posX.i.hi, self->posY.i.hi + 7, &collider, 0);
if (itemId) {
if (collider.effects & EFFECT_NOTHROUGH && self->velocityY > 0) {
self->velocityX = 0;
self->velocityY = 0;
self->posY.i.hi += collider.unk18;
self->ext.equipItemDrop.aliveTimer = 0xF0;
self->step++;
} else {
FallEntity();
}
CheckFieldCollision(D_80180EB8, 2);
} else if (collider.effects & EFFECT_NOTHROUGH) {
self->posY.i.hi += collider.unk18;
self->ext.equipItemDrop.aliveTimer = 0x60;
self->step++;
} else {
PrizeDropFall();
}
break;
case 3:
PrizeDropFall2(itemId);
if (!(self->params & 0x8000) && !--self->ext.equipItemDrop.aliveTimer) {
if (itemId) {
self->ext.equipItemDrop.aliveTimer = 80;
} else {
self->ext.equipItemDrop.aliveTimer = 64;
}
self->step++;
}
break;
case 4:
PrizeDropFall2(itemId);
if (--self->ext.equipItemDrop.aliveTimer) {
if (self->ext.equipItemDrop.aliveTimer & 2) {
self->animCurFrame = 0;
}
} else {
DestroyEntity(self);
return;
}
break;
case 5:
if (itemId < 2) {
CollectHeart(itemId);
} else if (itemId < 12) {
CollectGold(itemId);
#if STAGE != STAGE_ST0
} else if (itemId == 12) {
CollectHeartVessel();
#endif
} else if (itemId < 14) {
#if defined VERSION_BETA || STAGE == STAGE_ST0
DestroyCurrentEntity();
#else
DestroyCurrentEntity(itemId);
#endif
} else if (itemId < 23) {
CollectSubweapon(itemId);
#if STAGE != STAGE_ST0
} else if (itemId == 23) {
CollectLifeVessel();
#endif
} else {
DestroyEntity(self);
return;
}
break;
#if !(defined VERSION_BETA || STAGE == STAGE_ST0)
case 6:
#endif
case 7:
switch (self->step_s) {
case 0:
self->animCurFrame = 0;
if (itemId >= 14 && itemId < 23) {
#if defined(VERSION_PSP)
if (g_PlayableCharacter == PLAYER_MARIA) {
subWeaponId = maria_subweapons_id[g_Status.mariaSubWeapon];
if (itemId == subWeaponId) {
itemId = 1;
self->params = 1;
}
} else {
subWeaponId = aluric_subweapons_id[g_Status.subWeapon];
if (itemId == subWeaponId) {
itemId = 1;
self->params = 1;
}
}
#else
subWeaponId = aluric_subweapons_id[g_Status.subWeapon];
if (itemId == subWeaponId) {
itemId = 1;
self->params = 1;
}
#endif
}
primIndex = g_api.AllocPrimitives(PRIM_GT4, 1);
if (primIndex != -1) {
self->primIndex = primIndex;
self->flags |= FLAG_HAS_PRIMS;
prim = &g_PrimBuf[primIndex];
prim->tpage = 0x1A;
prim->clut = 0x170;
#if defined VERSION_BETA || STAGE == STAGE_ST0
prim->u0 = prim->u2 = 0;
prim->v0 = prim->v1 = 0;
prim->u1 = prim->u3 = 0x20;
prim->v2 = prim->v3 = 0x20;
prim->r0 = prim->r1 = prim->r2 = prim->r3 = 0x80;
prim->g0 = prim->g1 = prim->g2 = prim->g3 = 0x80;
prim->b0 = prim->b1 = prim->b2 = prim->b3 = 0x80;
#else
prim->u0 = prim->u2 = prim->v0 = prim->v1 = 0;
prim->u1 = prim->u3 = prim->v2 = prim->v3 = 0x20;
prim->r0 = prim->r1 = prim->r2 = prim->r3 = prim->g0 =
prim->g1 = prim->g2 = prim->g3 = prim->b0 = prim->b1 =
prim->b2 = prim->b3 = 128;
#endif
prim->drawMode = DRAW_HIDE;
prim->priority = self->zPriority + 1;
self->step_s++;
}
break;
case 1:
MoveEntity();
g_api.CheckCollision(
self->posX.i.hi, self->posY.i.hi + 7, &collider, 0);
if (collider.effects & EFFECT_NOTHROUGH && self->velocityY > 0) {
self->velocityX = 0;
self->velocityY = 0;
self->posY.i.hi += collider.unk18;
self->step_s++;
} else {
FallEntity();
}
CheckFieldCollision(D_80180EB8, 2);
self->animCurFrame = 0;
if (self->ext.equipItemDrop.unk8A) {
self->ext.equipItemDrop.unk8A--;
} else {
prim = &g_PrimBuf[self->primIndex];
prim->x0 = prim->x2 = self->posX.i.hi - 1;
prim->x1 = prim->x3 = self->posX.i.hi + 1;
prim->y0 = prim->y1 = self->posY.i.hi - 1;
prim->y2 = prim->y3 = self->posY.i.hi + 1;
prim->drawMode = DRAW_TPAGE2 | DRAW_TPAGE | DRAW_COLORS |
DRAW_UNK02 | DRAW_TRANSP;
}
break;
case 2:
PrizeDropFall2(itemId);
prim = &g_PrimBuf[self->primIndex];
self->ext.equipItemDrop.unk8A++;
if (self->ext.equipItemDrop.unk8A < 17) {
index = self->ext.equipItemDrop.unk8A;
self->animCurFrame = 0;
} else {
index = 32 - self->ext.equipItemDrop.unk8A;
prim->r0 = (prim->r1 = (prim->r2 = (prim->r3 -= 8)));
prim->g0 = (prim->g1 = (prim->g2 = (prim->g3 -= 8)));
prim->b0 = (prim->b1 = (prim->b2 = (prim->b3 -= 8)));
}
prim->x0 = prim->x2 = self->posX.i.hi - index;
prim->x1 = prim->x3 = self->posX.i.hi + index;
prim->y0 = prim->y1 = self->posY.i.hi - index;
prim->y2 = prim->y3 = self->posY.i.hi + index;
if (self->ext.equipItemDrop.unk8A == 32) {
g_api.FreePrimitives(self->primIndex);
self->flags &= ~FLAG_HAS_PRIMS;
self->ext.equipItemDrop.aliveTimer = 208;
self->step = 3;
self->step_s = 0;
}
break;
}
break;
}
}
#include "entity_prize_drop.h"
extern u16 g_InitializeEntityData0[];

307
src/st/entity_prize_drop.h Normal file
View File

@ -0,0 +1,307 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
// if self->params & 0x8000 then the item will not disappear
void EntityPrizeDrop(Entity* self) {
Collider collider;
Primitive* prim;
u16 itemId;
s16 index;
s32 primIndex;
s32 subWeaponId;
s32 subWeaponId_;
// if self->params & 0x8000 then the item will not disappear
itemId = self->params & 0x7FFF;
if (self->step) {
#if defined(VERSION_PSP)
if (g_PlayableCharacter == PLAYER_MARIA) {
AnimateEntity(g_MariaSubweaponAnimPrizeDrop[itemId], self);
} else {
AnimateEntity(g_SubweaponAnimPrizeDrop[itemId], self);
}
#else
AnimateEntity(g_SubweaponAnimPrizeDrop[itemId], self);
#endif
}
#if defined(VERSION_US) && STAGE != STAGE_ST0
if (self->step > 1 && self->step < 5 && self->hitFlags) {
#else
if (self->step && self->step < 5 && self->hitFlags) {
#endif
self->step = 5;
}
#if STAGE == STAGE_ST0
self->palette = 0x100;
#else
self->palette = 0;
#endif
if ((u8)self->unk6D[0] >= 0x18 && !(g_GameTimer & 2) && self->params != 1) {
self->palette = 0x815F;
}
switch (self->step) {
case 0:
InitializeEntity(g_InitializeData0);
self->zPriority = g_unkGraphicsStruct.g_zEntityCenter - 0x14;
self->drawMode = DRAW_DEFAULT;
#if STAGE == STAGE_ST0
if (itemId >= 23) {
#else
if (itemId > 23) {
#endif
itemId = self->params = 0;
}
#if defined(VERSION_PSP)
if (g_PlayableCharacter == PLAYER_MARIA && itemId >= 0xE &&
itemId < 23) {
switch (itemId) {
case 14:
itemId = self->params = 15;
break;
case 15:
itemId = self->params = 14;
break;
case 21:
itemId = self->params = 16;
break;
case 17:
itemId = self->params = 17;
break;
case 19:
itemId = 19; // causes a lot of regswaps
self->params = 19;
break;
default:
itemId = self->params = 0;
break;
}
}
#endif
if (itemId >= 14 && itemId < 23
#if defined(VERSION_PSP)
&& g_PlayableCharacter != PLAYER_MARIA
#endif
) {
subWeaponId_ = aluric_subweapons_id[g_Status.subWeapon];
if (itemId == subWeaponId_) {
itemId = 1;
self->params = 1;
}
}
if (!itemId || itemId == 2) {
self->hitboxWidth = 4;
}
break;
case 1:
g_api.CheckCollision(self->posX.i.hi, self->posY.i.hi, &collider, 0);
if (collider.effects & EFFECT_NOTHROUGH_PLUS) {
DestroyEntity(self);
} else {
self->step++;
#if !(defined VERSION_BETA || STAGE == STAGE_ST0)
index = self->ext.equipItemDrop.castleFlag;
if (index) {
index--;
g_CastleFlags[(index >> 3) + COLLECT_FLAGS_START] |=
1 << (index & 7);
}
#endif
}
if (!itemId) {
self->ext.equipItemDrop.fallSpeed = FIX(-1);
self->ext.equipItemDrop.gravity = 0x800;
}
break;
case 2:
#if STAGE == STAGE_ST0
if (self->velocityX < 0) {
#else
if (self->velocityY < 0) {
#endif
g_api.CheckCollision(
self->posX.i.hi, self->posY.i.hi - 7, &collider, 0);
if (collider.effects & EFFECT_NOTHROUGH) {
self->velocityY = 0;
}
}
MoveEntity();
g_api.CheckCollision(
self->posX.i.hi, self->posY.i.hi + 7, &collider, 0);
if (itemId) {
if (collider.effects & EFFECT_NOTHROUGH && self->velocityY > 0) {
self->velocityX = 0;
self->velocityY = 0;
self->posY.i.hi += collider.unk18;
self->ext.equipItemDrop.aliveTimer = 0xF0;
self->step++;
} else {
FallEntity();
}
CheckFieldCollision(D_80180EB8, 2);
} else if (collider.effects & EFFECT_NOTHROUGH) {
self->posY.i.hi += collider.unk18;
self->ext.equipItemDrop.aliveTimer = 0x60;
self->step++;
} else {
PrizeDropFall();
}
break;
case 3:
PrizeDropFall2(itemId);
if (!(self->params & 0x8000) && !--self->ext.equipItemDrop.aliveTimer) {
if (itemId) {
self->ext.equipItemDrop.aliveTimer = 80;
} else {
self->ext.equipItemDrop.aliveTimer = 64;
}
self->step++;
}
break;
case 4:
PrizeDropFall2(itemId);
if (--self->ext.equipItemDrop.aliveTimer) {
if (self->ext.equipItemDrop.aliveTimer & 2) {
self->animCurFrame = 0;
}
} else {
DestroyEntity(self);
return;
}
break;
case 5:
if (itemId < 2) {
CollectHeart(itemId);
} else if (itemId < 12) {
CollectGold(itemId);
#if STAGE != STAGE_ST0
} else if (itemId == 12) {
CollectHeartVessel();
#endif
} else if (itemId < 14) {
#if defined VERSION_BETA || STAGE == STAGE_ST0
DestroyCurrentEntity();
#else
DestroyCurrentEntity(itemId);
#endif
} else if (itemId < 23) {
CollectSubweapon(itemId);
#if STAGE != STAGE_ST0
} else if (itemId == 23) {
CollectLifeVessel();
#endif
} else {
DestroyEntity(self);
return;
}
break;
#if !(defined VERSION_BETA || STAGE == STAGE_ST0)
case 6:
#endif
case 7:
switch (self->step_s) {
case 0:
self->animCurFrame = 0;
if (itemId >= 14 && itemId < 23) {
#if defined(VERSION_PSP)
if (g_PlayableCharacter == PLAYER_MARIA) {
subWeaponId = maria_subweapons_id[g_Status.mariaSubWeapon];
if (itemId == subWeaponId) {
itemId = 1;
self->params = 1;
}
} else {
subWeaponId = aluric_subweapons_id[g_Status.subWeapon];
if (itemId == subWeaponId) {
itemId = 1;
self->params = 1;
}
}
#else
subWeaponId = aluric_subweapons_id[g_Status.subWeapon];
if (itemId == subWeaponId) {
itemId = 1;
self->params = 1;
}
#endif
}
primIndex = g_api.AllocPrimitives(PRIM_GT4, 1);
if (primIndex != -1) {
self->primIndex = primIndex;
self->flags |= FLAG_HAS_PRIMS;
prim = &g_PrimBuf[primIndex];
prim->tpage = 0x1A;
prim->clut = 0x170;
#if defined VERSION_BETA || STAGE == STAGE_ST0
prim->u0 = prim->u2 = 0;
prim->v0 = prim->v1 = 0;
prim->u1 = prim->u3 = 0x20;
prim->v2 = prim->v3 = 0x20;
prim->r0 = prim->r1 = prim->r2 = prim->r3 = 0x80;
prim->g0 = prim->g1 = prim->g2 = prim->g3 = 0x80;
prim->b0 = prim->b1 = prim->b2 = prim->b3 = 0x80;
#else
prim->u0 = prim->u2 = prim->v0 = prim->v1 = 0;
prim->u1 = prim->u3 = prim->v2 = prim->v3 = 0x20;
prim->r0 = prim->r1 = prim->r2 = prim->r3 = prim->g0 =
prim->g1 = prim->g2 = prim->g3 = prim->b0 = prim->b1 =
prim->b2 = prim->b3 = 128;
#endif
prim->drawMode = DRAW_HIDE;
prim->priority = self->zPriority + 1;
self->step_s++;
}
break;
case 1:
MoveEntity();
g_api.CheckCollision(
self->posX.i.hi, self->posY.i.hi + 7, &collider, 0);
if (collider.effects & EFFECT_NOTHROUGH && self->velocityY > 0) {
self->velocityX = 0;
self->velocityY = 0;
self->posY.i.hi += collider.unk18;
self->step_s++;
} else {
FallEntity();
}
CheckFieldCollision(D_80180EB8, 2);
self->animCurFrame = 0;
if (self->ext.equipItemDrop.unk8A) {
self->ext.equipItemDrop.unk8A--;
} else {
prim = &g_PrimBuf[self->primIndex];
prim->x0 = prim->x2 = self->posX.i.hi - 1;
prim->x1 = prim->x3 = self->posX.i.hi + 1;
prim->y0 = prim->y1 = self->posY.i.hi - 1;
prim->y2 = prim->y3 = self->posY.i.hi + 1;
prim->drawMode = DRAW_TPAGE2 | DRAW_TPAGE | DRAW_COLORS |
DRAW_UNK02 | DRAW_TRANSP;
}
break;
case 2:
PrizeDropFall2(itemId);
prim = &g_PrimBuf[self->primIndex];
self->ext.equipItemDrop.unk8A++;
if (self->ext.equipItemDrop.unk8A < 17) {
index = self->ext.equipItemDrop.unk8A;
self->animCurFrame = 0;
} else {
index = 32 - self->ext.equipItemDrop.unk8A;
prim->r0 = (prim->r1 = (prim->r2 = (prim->r3 -= 8)));
prim->g0 = (prim->g1 = (prim->g2 = (prim->g3 -= 8)));
prim->b0 = (prim->b1 = (prim->b2 = (prim->b3 -= 8)));
}
prim->x0 = prim->x2 = self->posX.i.hi - index;
prim->x1 = prim->x3 = self->posX.i.hi + index;
prim->y0 = prim->y1 = self->posY.i.hi - index;
prim->y2 = prim->y3 = self->posY.i.hi + index;
if (self->ext.equipItemDrop.unk8A == 32) {
g_api.FreePrimitives(self->primIndex);
self->flags &= ~FLAG_HAS_PRIMS;
self->ext.equipItemDrop.aliveTimer = 208;
self->step = 3;
self->step_s = 0;
}
break;
}
break;
}
}