decomp deathFx.c

This commit is contained in:
Henny022p
2022-02-09 00:15:58 +01:00
parent 9360acdcc6
commit 61e780fb2a
7 changed files with 379 additions and 560 deletions
+91 -86
View File
@@ -1,9 +1,11 @@
#define NENT_DEPRECATED
#include "entity.h"
#include "definitions.h"
#include "functions.h"
#include "object.h"
#include "save.h"
#include "projectile.h"
#include "object/deathFx.h"
extern void sub_08049CF4(Entity*);
@@ -21,45 +23,45 @@ const EnemyDefinition* GetEnemyDefinition(Entity* entity) {
return definition;
}
bool32 EnemyInit(Entity* this) {
if ((this->flags & ENT_DID_INIT) == 0) {
const EnemyDefinition* definition = GetEnemyDefinition(this);
if (LoadEnemySprite(this, definition) == FALSE) {
bool32 EnemyInit(GenericEntity* this) {
if ((super->flags & ENT_DID_INIT) == 0) {
const EnemyDefinition* definition = GetEnemyDefinition(super);
if (LoadEnemySprite(super, definition) == FALSE) {
return FALSE;
}
this->flags |= ENT_DID_INIT;
super->flags |= ENT_DID_INIT;
if (definition->spriteFlags.collision != 0) {
COLLISION_ON(this);
COLLISION_ON(super);
}
this->spriteIndex = definition->spriteIndex;
if (this->spriteSettings.draw == 0) {
this->spriteSettings.draw = definition->spriteFlags.draw;
super->spriteIndex = definition->spriteIndex;
if (super->spriteSettings.draw == 0) {
super->spriteSettings.draw = definition->spriteFlags.draw;
}
this->spritePriority.b1 = definition->spriteFlags.spritePriority;
this->spriteSettings.shadow = definition->spriteFlags.shadow;
if (this->speed == 0) {
this->speed = definition->speed;
super->spritePriority.b1 = definition->spriteFlags.spritePriority;
super->spriteSettings.shadow = definition->spriteFlags.shadow;
if (super->speed == 0) {
super->speed = definition->speed;
}
this->flags2 = definition->flags2;
this->hitType = definition->damageType;
this->hitbox = (Hitbox*)definition->ptr.hitbox;
this->health = definition->health;
if (this->hurtType == 0) {
this->hurtType = 0x41;
super->flags2 = definition->flags2;
super->hitType = definition->damageType;
super->hitbox = (Hitbox*)definition->ptr.hitbox;
super->health = definition->health;
if (super->hurtType == 0) {
super->hurtType = 0x41;
}
UpdateSpriteForCollisionLayer(this);
UpdateSpriteForCollisionLayer(super);
if ((this->field_0x6c.HALF.HI & 0x20) != 0) {
u32 uVar4 = gUnk_080D3E74[this->id >> 3] >> ((this->id & 7) << 1) & 3;
u32 uVar4 = gUnk_080D3E74[super->id >> 3] >> ((super->id & 7) << 1) & 3;
if (uVar4 != 0) {
Entity* object = CreateObject(OBJECT_A9, uVar4 - 1, 0);
if (object != NULL) {
object->actionDelay = this->flags;
object->field_0xf = this->spriteSettings.draw;
object->actionDelay = super->flags;
object->field_0xf = super->spriteSettings.draw;
object->spritePriority.b0 = 3;
object->parent = this;
CopyPosition(this, object);
this->flags &= ~ENT_COLLIDE;
this->spriteSettings.draw = 0;
object->parent = super;
CopyPosition(super, object);
super->flags &= ~ENT_COLLIDE;
super->spriteSettings.draw = 0;
this->field_0x6c.HALF.HI |= 0x10;
}
}
@@ -93,29 +95,29 @@ bool32 LoadEnemySprite(Entity* entity, const EnemyDefinition* definition) {
ASM_FUNC("asm/non_matching/enemyUtils/sub_0804A720.inc", void sub_0804A720(Entity* this))
void CreateDeathFx(Entity* param_1, u32 param_2, u32 param_3);
void sub_0804A7D4(Entity* param_1) {
CreateDeathFx(param_1, (u32)param_1->id, 0);
void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem);
void sub_0804A7D4(Entity* this) {
CreateDeathFx((GenericEntity*)this, this->id, 0);
}
void CreateDeathFx(Entity* param_1, u32 param_2, u32 param_3) {
Entity* pEVar2;
Entity* pEVar3;
void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem) {
DeathFxObject* deathFx;
DeathFxObject* deathFx2;
u8 bVar3;
if ((param_1->field_0x6c.HALF.HI & 1) != 0) {
if ((param_1->field_0x6c.HALF.HI & 2) != 0) {
if ((parent->field_0x6c.HALF.HI & 1) != 0) {
if ((parent->field_0x6c.HALF.HI & 2) != 0) {
return;
}
pEVar2 = CreateObject(DEATH_FX, param_1->id, 0);
if (pEVar2 == NULL) {
deathFx = (DeathFxObject*)CreateObject(DEATH_FX, parent->base.id, 0);
if (deathFx == NULL) {
return;
}
pEVar2->field_0x6c.HALF.LO = 1;
PositionRelative(param_1, pEVar2, 0, 1);
pEVar2->parent = param_1;
param_1->field_0x6c.HALF.HI |= 2;
if ((param_1->id == '7') && (gRoomTransition.field_0x39 != 0)) {
deathFx->unk6c = 1;
PositionRelative(&(parent->base), &(deathFx->base), 0, 1);
deathFx->base.parent = &(parent->base);
parent->field_0x6c.HALF.HI |= 2;
if ((parent->base.id == 0x37) && (gRoomTransition.field_0x39 != 0)) {
DeleteThisEntity();
}
sub_0807CD9C();
@@ -123,56 +125,56 @@ void CreateDeathFx(Entity* param_1, u32 param_2, u32 param_3) {
DeleteThisEntity();
return;
} else {
int tmp = param_1->field_0x3a & 2;
int tmp = parent->base.field_0x3a & 2;
if (tmp == 0) {
sub_08049CF4(param_1);
sub_08049CF4(&(parent->base));
gSave.unk50 += 1;
param_1->field_0x3a |= 2;
param_1->actionDelay = 0xff;
SetDefaultPriority(param_1, 3);
pEVar3 = CreateObject(DEATH_FX, param_1->id, 0);
if (pEVar3 != NULL) {
pEVar3->field_0x6c.HALF.LO = tmp;
pEVar3->field_0x6c.HALF.HI = param_2;
pEVar3->field_0x6e.HALF.LO = param_3;
pEVar3->parent = param_1;
pEVar3->child = param_1;
CopyPosition(param_1, pEVar3);
parent->base.field_0x3a |= 2;
parent->base.actionDelay = 0xff;
SetDefaultPriority(&(parent->base), 3);
deathFx2 = (DeathFxObject*)CreateObject(DEATH_FX, parent->base.id, 0);
if (deathFx2 != NULL) {
deathFx2->unk6c = tmp;
deathFx2->parentId = parentId;
deathFx2->item = fixedItem;
deathFx2->base.parent = &(parent->base);
deathFx2->base.child = &(parent->base);
CopyPosition(&(parent->base), &(deathFx2->base));
}
if ((param_1->field_0x6c.HALF.HI & 8) != 0) {
pEVar3->field_0x6c.HALF.LO |= 8;
DeleteEntity(param_1);
if ((parent->field_0x6c.HALF.HI & 8) != 0) {
deathFx2->unk6c |= 8;
DeleteEntity(&(parent->base));
return;
}
if ((param_1->bitfield & 0x7f) == 0x13) {
bVar3 = param_1->field_0x1c & 0xf;
if ((parent->base.bitfield & 0x7f) == 0x13) {
bVar3 = parent->base.field_0x1c & 0xf;
if (bVar3 != 1) {
if ((bVar3 == 2) && (pEVar3 != NULL)) {
pEVar3->field_0x6c.HALF.LO |= 2;
if ((bVar3 == 2) && (deathFx2 != NULL)) {
deathFx2->unk6c |= 2;
}
} else {
if (pEVar3 != NULL) {
pEVar3->field_0x6c.HALF.LO |= 4;
if (deathFx2 != NULL) {
deathFx2->unk6c |= 4;
}
}
pEVar3->parent = NULL;
deathFx2->base.parent = NULL;
DeleteThisEntity();
return;
}
}
if (param_1->actionDelay == 0) {
if (parent->base.actionDelay == 0) {
DeleteThisEntity();
} else {
if (--param_1->actionDelay == 0) {
param_1->spriteSettings.draw = 0;
SetDefaultPriority(param_1, 0);
if (--parent->base.actionDelay == 0) {
parent->base.spriteSettings.draw = 0;
SetDefaultPriority(&(parent->base), 0);
} else {
if (param_1->actionDelay < 9) {
if (param_1->spriteSettings.draw != 0) {
param_1->spriteSettings.draw = 0;
if (parent->base.actionDelay < 9) {
if (parent->base.spriteSettings.draw) {
parent->base.spriteSettings.draw = 0;
} else {
param_1->spriteSettings.draw = 1;
parent->base.spriteSettings.draw = 1;
}
}
}
@@ -194,32 +196,35 @@ Entity* CreateProjectileWithParent(Entity* parent, u32 projectileId, u32 project
void SetChildOffset(Entity* entity, s32 xOffset, s32 yOffset, s32 zOffset) {
Entity* other;
GenericEntity* this = (GenericEntity*)entity;
other = *(Entity**)&entity->field_0x68;
other = *(Entity**)&this->field_0x68;
if (other != NULL) {
other->spriteRendering.b3 = entity->spriteRendering.b3;
other->spriteOrientation.flipY = entity->spriteOrientation.flipY;
other->x.HALF.HI = entity->x.HALF.HI + xOffset;
other->y.HALF.HI = entity->y.HALF.HI + yOffset;
other->z.HALF.HI = entity->z.HALF.HI + zOffset;
other->collisionLayer = entity->collisionLayer;
other->spriteRendering.b3 = super->spriteRendering.b3;
other->spriteOrientation.flipY = super->spriteOrientation.flipY;
other->x.HALF.HI = super->x.HALF.HI + xOffset;
other->y.HALF.HI = super->y.HALF.HI + yOffset;
other->z.HALF.HI = super->z.HALF.HI + zOffset;
other->collisionLayer = super->collisionLayer;
}
}
Entity* sub_0804A9FC(Entity* parent, u32 fxType) {
Entity* fx;
GenericEntity* this = (GenericEntity*)parent;
if ((*(Entity**)&parent->field_0x68 == NULL) && (fx = CreateFx(parent, fxType, 0), fx != NULL)) {
*(Entity**)&parent->field_0x68 = fx;
if ((*(Entity**)&this->field_0x68 == NULL) && (fx = CreateFx(super, fxType, 0), fx != NULL)) {
*(Entity**)&this->field_0x68 = fx;
} else {
fx = NULL;
}
return fx;
}
void sub_0804AA1C(Entity* param_1) {
if (*(Entity**)&param_1->field_0x68 != NULL) {
(*(Entity**)&param_1->field_0x68)->parent = NULL;
*(Entity**)&param_1->field_0x68 = NULL;
void sub_0804AA1C(Entity* entity) {
GenericEntity* this = (GenericEntity*)entity;
if (*(Entity**)&this->field_0x68 != NULL) {
(*(Entity**)&this->field_0x68)->parent = NULL;
*(Entity**)&this->field_0x68 = NULL;
}
}
+260
View File
@@ -0,0 +1,260 @@
#include "global.h"
#define NENT_DEPRECATED
#include "entity.h"
#include "sound.h"
#include "functions.h"
#include "object/deathFx.h"
#include "enemy.h"
void sub_08081790(DeathFxObject* this);
void DeathFx_Delete(DeathFxObject* this);
void DeathFx_Action0(DeathFxObject* this);
void DeathFx_Action1(DeathFxObject* this);
void DeathFx_Action2(DeathFxObject* this);
void DeathFx(Entity* this) {
static void (*const DeathFx_Actions[])(DeathFxObject*) = {
DeathFx_Action0,
DeathFx_Action1,
DeathFx_Action2,
};
DeathFx_Actions[this->action]((DeathFxObject*)this);
}
void DeathFx_Action0(DeathFxObject* this) {
static const u8 gUnk_0811EC08[] = {
0, 64, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
static const u8 gUnk_0811EC20[] = {
26,
14,
26,
26,
};
Entity* parent;
int uVar4;
u32 tmp;
if (this->unk6c & 1) {
super->spriteIndex = 0x65;
super->action = 2;
super->direction = 0;
super->speed = 0x40;
super->collisionLayer = 2;
UpdateSpriteForCollisionLayer(&this->base);
super->spriteRendering.b0 = 3;
if (super->actionDelay == 0) {
tmp = 0x80;
} else {
tmp = super->actionDelay;
super->actionDelay = 0;
}
sub_0805EC9C(super, tmp, tmp, 0);
LoadSwapGFX(super, 4, 0);
InitAnimationForceUpdate(super, 0);
SoundReq(SFX_BOSS_EXPLODE);
} else {
if (this->unk6c & 0xc) {
sub_08081790(this);
DeathFx_Delete(this);
} else {
if (this->unk6c & 2) {
InitializeAnimation(&this->base, 2);
} else {
super->spritePriority.b0 = 3;
uVar4 = gUnk_0811EC08[super->type >> 2];
uVar4 >>= ((super->type % 4) << 1);
uVar4 &= 3;
parent = super->parent;
if (parent != NULL) {
parent->actionDelay = gUnk_0811EC20[uVar4];
}
InitializeAnimation(&this->base, uVar4);
}
}
super->action = 1;
EnqueueSFX(SFX_FF);
}
SetDefaultPriority(super, 3);
}
void DeathFx_Action1(DeathFxObject* this) {
GetNextFrame(super);
if (super->frame & 0x80) {
sub_08081790(this);
DeathFx_Delete(this);
} else {
if ((super->frame & 1) != 0) {
super->spritePriority.b0 = 4;
}
}
}
void DeathFx_Action2(DeathFxObject* this) {
UpdateAnimationSingleFrame(super);
if (super->frame & 0x80) {
DeathFx_Delete(this);
} else {
if ((super->frame & 1) != 0) {
LinearMoveUpdate(super);
}
}
}
void DeathFx_DropRandom9(DeathFxObject* this);
void DeathFx_DropRandom13(DeathFxObject* this);
void DeathFx_DropRandom1(DeathFxObject* this);
void DeathFx_DropRandom14(DeathFxObject* this);
void DeathFx_DropFixedItem(DeathFxObject* this);
void sub_08081790(DeathFxObject* this) {
static void (*const DeathFx_DropFunctions[])(DeathFxObject*) = {
DeathFx_DropRandom9, DeathFx_DropRandom13, DeathFx_DropRandom1, DeathFx_DropRandom14,
DeathFx_DropRandom9, DeathFx_DropRandom9, DeathFx_DropRandom9, DeathFx_DropRandom9,
DeathFx_DropRandom9, DeathFx_DropRandom9, DeathFx_DropRandom9, DeathFx_DropRandom9,
DeathFx_DropRandom9, DeathFx_DropRandom9, DeathFx_DropRandom9, DeathFx_DropFixedItem,
};
static const u8 gUnk_0811EC64[] = {
[OCTOROK] = 6,
[CHUCHU] = 6,
[LEEVER] = 6,
[PEAHAT] = 6,
[ROLLOBITE] = 0,
[DARK_NUT] = 11,
[HANGING_SEED] = 0,
[BEETLE] = 6,
[KEESE] = 6,
[DOOR_MIMIC] = 0,
[ROCK_CHUCHU] = 10,
[SPINY_CHUCHU] = 6,
[CUCCO_CHICK_AGGR] = 6,
[MOLDORM] = 7,
[ENEMY_E] = 6,
[MOLDWORM] = 6,
[SLUGGULA] = 6,
[PESTO] = 0,
[PUFFSTOOL] = 6,
[CHUCHU_BOSS] = 6,
[LIKE_LIKE] = 6,
[SPEAR_MOBLIN] = 8,
[BUSINESS_SCRUB] = 0,
[RUPEE_LIKE] = 8,
[MADDERPILLAR] = 6,
[WATER_DROP] = 6,
[WALL_MASTER] = 8,
[BOMB_PEAHAT] = 10,
[SPARK] = 6,
[CHASER] = 0,
[SPIKED_BEETLE] = 6,
[SENSOR_BLADE_TRAP] = 0,
[HELMASAUR] = 6,
[FALLING_BOULDER] = 0,
[BOBOMB] = 10,
[WALL_MASTER_2] = 8,
[GLEEROK] = 6,
[VAATI_EYES_MACRO] = 0,
[TEKTITE] = 6,
[WIZZROBE_WIND] = 6,
[WIZZROBE_FIRE] = 6,
[WIZZROBE_ICE] = 6,
[ARMOS] = 11,
[EYEGORE] = 9,
[ROPE] = 6,
[SMALL_PESTO] = 1,
[ACRO_BANDIT] = 6,
[BLADE_TRAP] = 0,
[KEATON] = 7,
[CROW] = 6,
[MULLDOZER] = 6,
[BOMBAROSSA] = 6,
[WISP] = 0,
[SPINY_BEETLE] = 6,
[MAZAAL_HEAD] = 6,
[MAZAAL_MACRO] = 6,
[MAZAAL_HAND] = 6,
[OCTOROK_BOSS] = 6,
[FLYING_POT] = 6,
[GOBDO] = 6,
[OCTOROK_GOLDEN] = 6,
[TEKTITE_GOLDEN] = 6,
[ROPE_GOLDEN] = 6,
[CLOUD_PIRANHA] = 6,
[SCISSORS_BEETLE] = 7,
[CUCCO_AGGR] = 6,
[STALFOS] = 7,
[FLYING_SKULL] = 6,
[MAZAAL_BRACELET] = 6,
[TAKKURI] = 6,
[BOW_MOBLIN] = 8,
[LAKITU] = 6,
[LAKITU_CLOUD] = 6,
[TORCH_TRAP] = 6,
[VAATI_REBORN_ENEMY] = 6,
[VAATI_PROJECTILE] = 6,
[BALL_CHAIN_SOLIDER] = 8,
[ENEMY_4D] = 8,
[GHINI] = 6,
[VAATI_TRANSFIGURED] = 6,
[ENEMY_50] = 6,
[VAATI_WRATH] = 6,
[VAATI_ARM] = 12,
[DUST] = 0,
[VAATI_BALL] = 6,
[OCTOROK2] = 6,
[SLIME] = 6,
[MINI_SLIME] = 6,
[FIREBALL_GUY] = 6,
[MINI_FIREBALL_GUY] = 6,
[VAATI_TRANSFIGURED_EYE] = 6,
[BUSINESS_SCRUB_PROLOGUE] = 0,
[GYORG_FEMALE] = 6,
[GYORG_MALE] = 6,
[CURTAIN] = 0,
[VAATI_WRATH_EYE] = 6,
[GYORG_CHILD] = 12,
[GYORG_FEMALE_EYE] = 6,
[GYORG_MALE_EYE] = 6,
[GYORG_FEMALE_MOUTH] = 6,
[ENEMY_64] = 6,
[TREE_ITEM] = 6,
[ENEMY_66] = 6,
6,
6,
6,
6,
6,
6,
6,
6,
6,
};
if (this->parentId < 0xf0) {
CreateRandomItemDrop(super, gUnk_0811EC64[this->parentId]);
} else {
DeathFx_DropFunctions[this->parentId - 0xf0](this);
}
}
void DeathFx_DropRandom9(DeathFxObject* this) {
CreateRandomItemDrop(super, 9);
}
void DeathFx_DropRandom13(DeathFxObject* this) {
CreateRandomItemDrop(super, 13);
}
void DeathFx_DropRandom14(DeathFxObject* this) {
CreateRandomItemDrop(super, 14);
}
void DeathFx_DropRandom1(DeathFxObject* this) {
CreateRandomItemDrop(super, 1);
}
u32 CreateItemDrop(Entity* arg0, u32 itemID, u32 itemParameter);
void DeathFx_DropFixedItem(DeathFxObject* this) {
CreateItemDrop(super, this->item, 0);
}
void DeathFx_Delete(DeathFxObject* this) {
DeleteThisEntity();
}