Merge pull request #681 from notyourav/em

create enemy struct and enemy flags
This commit is contained in:
Theo 2023-12-30 20:07:35 -08:00 committed by GitHub
commit bd1be092aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
88 changed files with 375 additions and 345 deletions

View File

@ -258,17 +258,17 @@ _08004162:
ands r2, r4
pop {r4, pc}
thumb_func_start sub_08004168
sub_08004168: @ 0x08004168
thumb_func_start SnapToTile
SnapToTile: @ 0x08004168
ldr r3, _08004384 @ =0x000FFFFF
ldr r1, _08004388 @ =0x00080000
ldr r2, [r0, #0x2c]
bics r2, r3
adds r2, r2, r1
ldr r2, [r0, #0x2c] // x
bics r2, r3 // align to grid
adds r2, r1 // add half of a tile
str r2, [r0, #0x2c]
ldr r2, [r0, #0x30]
ldr r2, [r0, #0x30] // y
bics r2, r3
adds r2, r2, r1
adds r2, r1
str r2, [r0, #0x30]
bx lr

View File

@ -105,7 +105,7 @@ GenericConfused: @ 0x08001242
cmp r2, #0x1c
bne _08001282
push {r0}
bl sub_0804AA1C
bl EnemyDetachFX
pop {r0}
_08001282:
ldr r1, _08001364 @ =0x00001800

View File

@ -12,7 +12,35 @@
#include "entity.h"
#include "projectile.h"
bool32 EnemyInit(Entity* this);
#define EM_FLAG_BOSS (1 << 0)
#define EM_FLAG_BOSS_KILLED (1 << 1)
#define EM_FLAG_HAS_HOME (1 << 2)
#define EM_FLAG_NO_DEATH_FX (1 << 3)
#define EM_FLAG_SUPPORT (1 << 4)
#define EM_FLAG_CAPTAIN (1 << 5)
#define EM_FLAG_MONITORED (1 << 6)
typedef struct {
Entity base;
Entity* child;
u8 idx;
u8 enemyFlags;
u8 rangeX;
u8 rangeY;
s16 homeX;
s16 homeY;
/*0x74*/ union SplitHWord field_0x74;
/*0x76*/ union SplitHWord field_0x76;
/*0x78*/ union SplitHWord field_0x78;
/*0x7a*/ union SplitHWord field_0x7a;
/*0x7c*/ union SplitWord field_0x7c;
/*0x80*/ union SplitHWord field_0x80;
/*0x82*/ union SplitHWord field_0x82;
/*0x84*/ union SplitHWord cutsceneBeh;
/*0x86*/ union SplitHWord field_0x86;
} Enemy;
bool32 EnemyInit(Enemy* this);
/**
* 0: _OnTick
* 1: _OnCollision
@ -25,13 +53,13 @@ u32 GetNextFunction(Entity*);
void EnemyFunctionHandler(Entity*, EntityActionArray);
void EnemyFunctionHandlerAfterCollision(Entity*, void (*const[])());
void GenericKnockback(Entity*);
Entity* CreateDeathFx(Entity*, u32, u32);
void EnemyCreateDeathFX(Enemy*, u32, u32);
void sub_0804A720(Entity*);
bool32 sub_08049FDC(Entity*, u32);
Entity* Create0x68FX(Entity*, u32);
void SetChildOffset(Entity*, s32, s32, s32);
Entity* CreateProjectileWithParent(Entity*, u8, u8);
Entity* EnemyCreateFX(Entity*, u32);
void EnemySetFXOffset(Entity*, s32, s32, s32);
Entity* EnemyCreateProjectile(Entity*, u32, u32);
void GenericDeath(Entity*);
void sub_08002724(void*, u8*);
@ -44,13 +72,13 @@ Entity* sub_08049DF4(u32);
u32 sub_0804A044(Entity*, Entity*, u32);
s32 sub_080012DC(Entity*);
void sub_0804AA1C(Entity*);
void EnemyDetachFX(Entity*);
bool32 sub_08049F1C(Entity*, Entity*, s32);
bool32 PlayerInRange(Entity*, u32, s32);
void sub_0804A4E4(Entity*, Entity*);
void EnemyCopyParams(Entity*, Entity*);
void GenericKnockback2(Entity*);
typedef enum {
enum {
/*0x00*/ OCTOROK,
/*0x01*/ CHUCHU,
/*0x02*/ LEEVER,
@ -154,7 +182,7 @@ typedef enum {
/*0x64*/ ENEMY_64,
/*0x65*/ TREE_ITEM,
/*0x66*/ ENEMY_66
} Enemy;
};
void Octorok();
void Chuchu();

View File

@ -61,7 +61,7 @@ extern void sub_080027EA(Entity*, u32, u32);
extern void sub_080028E0(Entity*);
extern u32 sub_080040A2(Entity*);
extern u32 sub_080040D8(Entity*, u8*, s32, s32);
extern void sub_08004168(Entity*);
extern void SnapToTile(Entity*);
extern u32 sub_0800419C(Entity*, Entity*, u32, u32);
extern u32 sub_080041DC(Entity*, u32, u32);
extern void sub_080042BA(Entity*, u32);
@ -81,7 +81,7 @@ extern void UpdateUIElements(void);
extern void sub_0801E104(void);
extern void sub_08030118(u32);
extern void sub_0803C0AC(Entity*);
extern void sub_08049CF4(Entity*);
extern void EnemyDisableRespawn(Entity*);
extern u32 sub_0804A024(Entity*, u32, u32);
extern u32 IsMinishItem(u32);
extern void DisableRandomDrops();

View File

@ -88,10 +88,10 @@ typedef struct {
u8 area;
u8 room;
u16 unk_02;
u32 unk_04;
u32 enemyBits;
} RoomMemory;
extern RoomMemory* gUnk_020354B0;
extern RoomMemory* gCurrentRoomMemory;
extern RoomMemory gRoomMemory[];
// Packets used to store which entities to load in a room

View File

@ -88,7 +88,7 @@ SECTIONS {
. = 0x000344A0; gUnk_020344A0 = .;
. = 0x000344B0; gBG2Buffer = .;
. = 0x00034CB0; gBG0Buffer = .;
. = 0x000354B0; gUnk_020354B0 = .;
. = 0x000354B0; gCurrentRoomMemory = .;
. = 0x000354B4; gManagerCount = .;
. = 0x000354C0; gUnk_020354C0 = .;
. = 0x00035540; gzHeap = .;
@ -386,7 +386,6 @@ SECTIONS {
src/code_08049CD4.o(.text); /* enemyUtils.c */
src/code_08049DF4.o(.text);
src/enemyUtils.o(.text);
src/createEnemy.o(.text);
src/enterPortalSubtask.o(.text);
src/room.o(.text);
src/roomInit.o(.text);

View File

@ -1,5 +1,6 @@
#include "global.h"
#include "room.h"
#include "enemy.h"
extern void MemFill32(u32, void*, u32);
@ -8,35 +9,35 @@ RoomMemory* sub_08049D88(void);
void ClearRoomMemory(void) {
MemFill32(0xFFFFFFFF, gRoomMemory, 0x40);
gUnk_020354B0 = gRoomMemory;
gCurrentRoomMemory = gRoomMemory;
}
void sub_08049CF4(GenericEntity* ent) {
u8 field_0x6c = ent->field_0x6c.HALF.LO;
if (field_0x6c & 0x80) {
gUnk_020354B0->unk_04 |= 1 << (field_0x6c & 0x1f);
void EnemyDisableRespawn(Enemy* ent) {
u8 idx = ent->idx;
if (idx & 0x80) {
gCurrentRoomMemory->enemyBits |= 1 << (idx & 0x1f);
}
}
u32 sub_08049D1C(u32 arg0) {
u32 bitmask = gUnk_020354B0->unk_04 >> arg0;
u32 EnemyEnableRespawn(u32 arg0) {
u32 bitmask = gCurrentRoomMemory->enemyBits >> arg0;
u32 output = 1;
output &= ~bitmask;
return output;
}
void UpdateRoomTracker(void) {
gUnk_020354B0 = gRoomMemory;
gCurrentRoomMemory = gRoomMemory;
do {
if (gUnk_020354B0->area == gRoomControls.area && gUnk_020354B0->room == gRoomControls.room) {
sub_08049DCC(gUnk_020354B0);
if (gCurrentRoomMemory->area == gRoomControls.area && gCurrentRoomMemory->room == gRoomControls.room) {
sub_08049DCC(gCurrentRoomMemory);
return;
}
gUnk_020354B0++;
gCurrentRoomMemory++;
} while (gUnk_020354B0 < gRoomMemory + 8);
gUnk_020354B0 = sub_08049D88();
} while (gCurrentRoomMemory < gRoomMemory + 8);
gCurrentRoomMemory = sub_08049D88();
}
RoomMemory* sub_08049D88(void) {
@ -54,7 +55,7 @@ RoomMemory* sub_08049D88(void) {
rm->room = gRoomControls.room;
rm->unk_02 = 0xFFFF;
rm->unk_04 = 0;
rm->enemyBits = 0;
sub_08049DCC(rm);

View File

@ -10,8 +10,6 @@
extern Entity* gUnk_020000B0;
extern Entity* (*const gUnk_080D3BE8[])(void);
extern void ReplaceMonitoredEntity(Entity*, Entity*);
Entity* sub_08049DF4(u32 arg0) {
if (gUnk_020000B0 != NULL) {
return gUnk_020000B0;
@ -311,21 +309,3 @@ bool32 sub_0804A4BC(u8* arg0, u8* arg1, s32 arg2, u32 arg3) {
return TRUE;
}
void sub_0804A4E4(Entity* entA, Entity* entB) {
GenericEntity* r5 = (GenericEntity*)entA;
GenericEntity* r6 = (GenericEntity*)entB;
r6->field_0x6c.HALF.HI = (r5->field_0x6c.HALF.HI & 0x40) | 4;
r6->field_0x6c.HALF.LO = r5->field_0x6c.HALF.LO;
r6->field_0x70.HALF.LO = r5->field_0x70.HALF.LO;
r6->field_0x70.HALF.HI = r5->field_0x70.HALF.HI;
r6->field_0x6e.HALF.LO = r5->field_0x6e.HALF.LO;
r6->field_0x6e.HALF.HI = r5->field_0x6e.HALF.HI;
CopyPositionAndSpriteOffset(&r5->base, &r6->base);
if (r5->field_0x6c.HALF.HI & 0x40) {
ReplaceMonitoredEntity(&r5->base, &r6->base);
}
}

View File

@ -247,7 +247,7 @@ s32 CalculateDamage(Entity* org, Entity* tgt) {
}
health = org->health - damage;
if (org->kind == ENEMY) {
if ((((GenericEntity*)org)->field_0x6c.HALF.HI & 1) != 0)
if (((Enemy*)org)->enemyFlags & EM_FLAG_BOSS)
SoundReqClipped(org, SFX_BOSS_HIT);
else
SoundReqClipped(org, SFX_HIT);

View File

@ -1,23 +0,0 @@
#include "enemy.h"
/** Unsets bitfield 0x80 before calling GetNextFunction, so that the enemyFunction 1 is not called. */
void EnemyFunctionHandlerAfterCollision(Entity* entity, void (*const fntable[])()) {
u32 idx;
entity->contactFlags &= ~0x80;
idx = GetNextFunction(entity);
entity->contactFlags |= 0x80;
fntable[idx](entity);
}
Entity* CreateEnemy(u32 subtype, u32 form) {
Entity* enemy;
enemy = GetEmptyEntity();
if (enemy != NULL) {
enemy->kind = ENEMY;
enemy->id = subtype;
enemy->type = form;
AppendEntityToList(enemy, 4);
}
return enemy;
}

View File

@ -81,7 +81,7 @@ void AcroBandit(AcroBanditEntity* this) {
gUnk_080012C8[index](super);
} else {
AcroBandit_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
}
@ -150,7 +150,7 @@ void AcroBandit_OnCollision(AcroBanditEntity* this) {
}
if (super->confusedTime)
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
EnemyFunctionHandlerAfterCollision(super, AcroBandit_Functions);
}

View File

@ -83,7 +83,7 @@ void sub_08030150(ArmosEntity* this) {
void Armos(ArmosEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)&gUnk_080CE124);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
sub_08030150(this);
}
@ -101,7 +101,7 @@ void sub_080301D4(ArmosEntity* this) {
sub_080309E8(this);
}
if (super->confusedTime != 0) {
Create0x68FX(super, 0x1c);
EnemyCreateFX(super, 0x1c);
}
this->unk_81 = super->health;
EnemyFunctionHandlerAfterCollision(super, gUnk_080CE124);

View File

@ -55,7 +55,7 @@ void BallChainSoldier_OnKnockback(BallChainSoldierEntity* this) {
}
void BallChainSoldier_OnDeath(BallChainSoldierEntity* this) {
CreateDeathFx(super, 0xff, 0x57);
EnemyCreateDeathFX((Enemy*)super, 0xff, 0x57);
}
void BallChainSoldier_OnGrabbed(BallChainSoldierEntity* this) {
@ -64,7 +64,7 @@ void BallChainSoldier_OnGrabbed(BallChainSoldierEntity* this) {
void BallChainSoldier_Init(BallChainSoldierEntity* this) {
Entity* entity;
sub_0804A720(super);
entity = CreateProjectileWithParent(super, BALL_AND_CHAIN, 0);
entity = EnemyCreateProjectile(super, BALL_AND_CHAIN, 0);
if (entity == NULL)
return;

View File

@ -70,7 +70,7 @@ void Beetle_OnDeath(BeetleEntity* this) {
entity->subtimer--;
super->parent = NULL;
}
CreateDeathFx(super, 0xf0, 0);
EnemyCreateDeathFX((Enemy*)super, 0xf0, 0);
}
}

View File

@ -42,7 +42,7 @@ const s8 gUnk_080CFFC4[8];
void BowMoblin(Entity* this) {
EnemyFunctionHandler(this, BowMoblin_Functions);
SetChildOffset(this, 0, 1, -0x18);
EnemySetFXOffset(this, 0, 1, -0x18);
}
void BowMoblin_OnTick(BowMoblinEntity* this) {
@ -53,7 +53,7 @@ void BowMoblin_OnCollision(BowMoblinEntity* this) {
Entity* pEVar1;
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, (EntityActionArray)BowMoblin_Functions);
if ((super->contactFlags & 0x80) != 0) {
@ -213,7 +213,7 @@ void sub_0803C400(BowMoblinEntity* this) {
switch (++super->timer) {
case 1:
super->direction = super->animationState << 2;
projectile = CreateProjectileWithParent(super, ARROW_PROJECTILE, super->animationState >> 1);
projectile = EnemyCreateProjectile(super, ARROW_PROJECTILE, super->animationState >> 1);
if (projectile) {
super->child = projectile;
projectile->direction = (super->direction + 4) & 0x18;

View File

@ -153,7 +153,7 @@ void BusinessScrub_Action2(BusinessScrubEntity* this) {
unk = 1;
sub_080290FC(this);
if (super->frame & 1) {
Entity* entity = CreateProjectileWithParent(super, DEKU_SEED_PROJECTILE, 0);
Entity* entity = EnemyCreateProjectile(super, DEKU_SEED_PROJECTILE, 0);
if (entity != NULL) {
entity->parent = super;
entity->direction = super->direction;
@ -220,7 +220,7 @@ void BusinessScrub_Action3(BusinessScrubEntity* this) {
super->timer = 30;
super->subtimer = 5;
sub_080290E0(this, 0);
iVar1 = Create0x68FX(super, FX_STARS);
iVar1 = EnemyCreateFX(super, FX_STARS);
if (iVar1 != NULL) {
iVar1->spritePriority.b0 = 3;
iVar1->z.HALF.HI -= 12;
@ -236,7 +236,7 @@ void BusinessScrub_Action3(BusinessScrubEntity* this) {
sub_0800445C(super);
}
extern void sub_0804AA1C(Entity*);
extern void EnemyDetachFX(Entity*);
void sub_08028F0C(BusinessScrubEntity*);
void BusinessScrub_Action4(BusinessScrubEntity* this) {
@ -244,7 +244,7 @@ void BusinessScrub_Action4(BusinessScrubEntity* this) {
super->timer = 48;
if (super->subtimer) {
if (--super->subtimer == 0) {
sub_0804AA1C(super);
EnemyDetachFX(super);
}
} else if (sub_08028FDC(this) || this->unk_80) {
this->unk_80 = 0;
@ -380,7 +380,7 @@ void sub_08028F0C(BusinessScrubEntity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->unk_7c;
super->interactType = INTERACTION_NONE;
sub_0804AA1C(super);
EnemyDetachFX(super);
super->direction = (GetAnimationState(super) << 3);
sub_080290E0(this, 3);
this->unk_80 = 1;

View File

@ -127,7 +127,7 @@ void sub_08045CE0(BusinessScrubPrologueEntity* this) {
r6 = 1;
sub_0804604C(this);
if (super->frame & 1) {
entity = CreateProjectileWithParent(super, DEKU_SEED_PROJECTILE, 0);
entity = EnemyCreateProjectile(super, DEKU_SEED_PROJECTILE, 0);
if (entity != NULL) {
entity->parent = super;
entity->direction = super->direction;
@ -190,7 +190,7 @@ void sub_08045E14(BusinessScrubPrologueEntity* this) {
super->action = 5;
super->subAction = 0;
sub_08046030(this, 0);
entity = Create0x68FX(super, FX_STARS);
entity = EnemyCreateFX(super, FX_STARS);
if (entity != NULL) {
entity->spritePriority.b0 = 3;
entity->z.HALF.HI -= 0xc;
@ -329,7 +329,7 @@ void sub_08046078(BusinessScrubPrologueEntity* this) {
super->child->action = 0xff;
}
sub_0804AA1C(super);
EnemyDetachFX(super);
}
void (*const BusinessScrubPrologue_Functions[])(Entity*) = {

View File

@ -81,7 +81,7 @@ void Chuchu(ChuchuEntity* this) {
this->unk_81 = index;
Chuchu_Functions[GetNextFunction(super)](this);
if (this->unk_68->type == 0x1c) {
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
} else if (super->type == 2) {
sub_0801FB34(this);
}
@ -117,14 +117,14 @@ void Chuchu_OnCollision(ChuchuEntity* this) {
if (health) {
if (super->contactFlags == 0x94) {
sub_0801FB68(this);
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
InitializeAnimation(super, 6);
} else if (this->unk_80 != health) {
sub_0801FB68(this);
InitializeAnimation(super, 6);
}
} else {
sub_0804AA1C(super);
EnemyDetachFX(super);
super->zVelocity = 0;
InitializeAnimation(super, 9);
}
@ -134,7 +134,7 @@ void Chuchu_OnCollision(ChuchuEntity* this) {
void Chuchu_OnGrabbed(ChuchuEntity* this) {
if (!sub_0806F520(super) && super->confusedTime) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
InitializeAnimation(super, 6);
} else {
if (super->animIndex != 8) {
@ -158,9 +158,9 @@ void Chuchu_OnDeath(ChuchuEntity* this) {
if (super->type == 0) {
GenericDeath(super);
} else if (super->type == 1) {
CreateDeathFx(super, 0xf2, 0);
EnemyCreateDeathFX((Enemy*)super, 0xf2, 0);
} else {
CreateDeathFx(super, 0xf1, 0);
EnemyCreateDeathFX((Enemy*)super, 0xf1, 0);
}
}
@ -289,7 +289,7 @@ void sub_0801F2F8(ChuchuEntity* this) {
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
sub_0801F340(this);
sub_0804AA1C(super);
EnemyDetachFX(super);
}
}
@ -488,7 +488,7 @@ void sub_0801F6F8(ChuchuEntity* this) {
if (super->frame & ANIM_DONE) {
super->action = 4;
super->speed = 0x20;
sub_0804AA1C(super);
EnemyDetachFX(super);
InitializeAnimation(super, 2);
}
}
@ -561,7 +561,7 @@ void sub_0801F884(ChuchuEntity* this) {
if (super->subtimer) {
super->subtimer--;
} else {
Entity* entity = Create0x68FX(super, FX_LIGHTNING_STRIKE);
Entity* entity = EnemyCreateFX(super, FX_LIGHTNING_STRIKE);
if (entity != NULL) {
entity->type2 = 64;
super->action = 4;
@ -653,7 +653,7 @@ void sub_0801FA78(ChuchuEntity* this) {
super->action = 1;
super->spriteSettings.draw = 0;
InitializeAnimation(super, 4);
sub_0804AA1C(super);
EnemyDetachFX(super);
}
}
@ -663,7 +663,7 @@ void sub_0801FAAC(ChuchuEntity* this) {
if (super->frame & ANIM_DONE) {
sub_0801FB14(this);
super->speed = 0x20;
sub_0804AA1C(super);
EnemyDetachFX(super);
}
}
@ -707,7 +707,7 @@ void sub_0801FB68(ChuchuEntity* this) {
case 2:
super->action = 10;
super->hitType = 92;
sub_0804AA1C(super);
EnemyDetachFX(super);
break;
}

View File

@ -283,9 +283,9 @@ void ChuchuBoss_OnDeath(ChuchuBossEntity* this) {
break;
case 1:
if (this->unk_7d-- == 0) {
((GenericEntity*)super->child)->field_0x6c.HALF.HI |= 2;
((Enemy*)super->child)->enemyFlags |= EM_FLAG_BOSS_KILLED;
this->unk_68->unk_6d.unk1 = 1;
((GenericEntity*)super->parent)->field_0x6c.HALF.HI |= 2;
((Enemy*)super->parent)->enemyFlags |= EM_FLAG_BOSS_KILLED;
parent = super->child;
child = super->parent;
this->unk_68->base.health = 0;

View File

@ -41,7 +41,7 @@ void (*const gUnk_080CF4F0[])(CloudPiranhaEntity*) = {
void CloudPiranha(CloudPiranhaEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)&gUnk_080CF4F0);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
void CloudPiranha_OnTick(CloudPiranhaEntity* this) {
@ -55,7 +55,7 @@ void CloudPiranha_OnTick(CloudPiranhaEntity* this) {
void CloudPiranha_OnCollision(CloudPiranhaEntity* this) {
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, gUnk_080CF4F0);
if ((super->contactFlags & 0x80) != 0) {

View File

@ -50,7 +50,7 @@ void CuccoAggr(Entity* this) {
gUnk_080012C8[index](this);
} else {
CuccoAggr_Functions[GetNextFunction(this)](this);
SetChildOffset(this, 0, 1, -0x10);
EnemySetFXOffset(this, 0, 1, -0x10);
sub_080391B4((CuccoAggrEntity*)this);
}
}
@ -74,7 +74,7 @@ void CuccoAggr_OnCollision(CuccoAggrEntity* this) {
}
if (super->confusedTime) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, CuccoAggr_Functions);

View File

@ -67,7 +67,7 @@ extern void (*const gUnk_080CAB58[])(DarkNutEntity*);
void DarkNut(DarkNutEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)DarkNut_Functions);
SetChildOffset(super, 0, 1, -22);
EnemySetFXOffset(super, 0, 1, -22);
}
void DarkNut_OnTick(DarkNutEntity* this) {
@ -82,7 +82,7 @@ void DarkNut_OnCollision(DarkNutEntity* this) {
super->hitType = 81;
sub_08021218(this, 8, DirectionToAnimationState(super->knockbackDirection ^ 0x10));
sub_08021588(this);
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
break;
case 0x16:
super->action = 11;
@ -90,7 +90,7 @@ void DarkNut_OnCollision(DarkNutEntity* this) {
super->hitType = 81;
sub_08021218(this, 8, DirectionToAnimationState(super->knockbackDirection ^ 0x10));
sub_08021588(this);
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
break;
case 0x4b:
if (super->action == 13 || super->action == 15 || super->action == 19 || super->action == 18)
@ -128,7 +128,7 @@ void DarkNut_OnCollision(DarkNutEntity* this) {
if (super->health != this->unk_78) {
sub_08021588(this);
sub_08021390(this);
sub_0804AA1C(super);
EnemyDetachFX(super);
}
break;
}
@ -240,7 +240,7 @@ void sub_08020F48(DarkNutEntity* this) {
super->action = 14;
sub_08021218(this, 13, uVar2 >> 3);
pEVar3 = CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 1);
pEVar3 = EnemyCreateProjectile(super, DARK_NUT_SWORD_SLASH, 1);
if (pEVar3) {
pEVar3->parent = super;
super->child = pEVar3;
@ -272,7 +272,7 @@ void sub_08020FE4(DarkNutEntity* this) {
if (--super->timer == 0) {
super->action = 12;
sub_08021218(this, 9, super->animationState);
sub_0804AA1C(super);
EnemyDetachFX(super);
}
}
@ -286,7 +286,7 @@ void sub_08021010(DarkNutEntity* this) {
void sub_08021038(DarkNutEntity* this) {
if (super->child == NULL && super->frame) {
Entity* pEVar2 = (Entity*)CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 0);
Entity* pEVar2 = (Entity*)EnemyCreateProjectile(super, DARK_NUT_SWORD_SLASH, 0);
if (pEVar2) {
pEVar2->parent = super;
super->child = pEVar2;
@ -325,7 +325,7 @@ void sub_080210E4(DarkNutEntity* this) {
Entity* entity;
super->frame &= ~1;
entity = CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 2);
entity = EnemyCreateProjectile(super, DARK_NUT_SWORD_SLASH, 2);
if (entity != NULL) {
entity->parent = super;
super->child = entity;
@ -594,7 +594,7 @@ void sub_0802159C(DarkNutEntity* this) {
super->frame = 0;
super->hitType = 0x51;
entity = CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 3);
entity = EnemyCreateProjectile(super, DARK_NUT_SWORD_SLASH, 3);
if (entity != NULL) {
entity->parent = super;
super->child = entity;
@ -615,7 +615,7 @@ void sub_08021600(DarkNutEntity* this) {
super->frame = 0;
super->hitType = 0x51;
entity = CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 4);
entity = EnemyCreateProjectile(super, DARK_NUT_SWORD_SLASH, 4);
if (entity != NULL) {
entity->parent = super;
super->child = entity;

View File

@ -50,7 +50,7 @@ void DoorMimic_OnCollision(DoorMimicEntity* this) {
void DoorMimic_OnDeath(DoorMimicEntity* this) {
SetTile(this->unk_7c, this->unk_7e, super->collisionLayer);
CreateFx(super, FX_POT_SHATTER, 0);
sub_08049CF4(super);
EnemyDisableRespawn(super);
DeleteThisEntity();
}

View File

@ -90,7 +90,7 @@ void Enemy4D_OnKnockback(Enemy4DEntity* this) {
}
void Enemy4D_OnDeath(Enemy4DEntity* this) {
CreateDeathFx(super, 0xff, 0x57);
EnemyCreateDeathFX((Enemy*)super, 0xff, 0x57);
}
void Enemy4D_OnGrabbed(Enemy4DEntity* this) {
@ -100,7 +100,7 @@ void Enemy4D_Init(Enemy4DEntity* this) {
Entity* projectile;
sub_0804A720(super);
projectile = CreateProjectileWithParent(super, BALL_AND_CHAIN, 0);
projectile = EnemyCreateProjectile(super, BALL_AND_CHAIN, 0);
if (projectile != NULL) {
projectile->parent = super;
super->child = projectile;

View File

@ -65,7 +65,7 @@ void Enemy50(Enemy50Entity* this) {
DeleteThisEntity();
}
Enemy50_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
void Enemy50_OnTick(Enemy50Entity* this) {
@ -93,7 +93,7 @@ void Enemy50_OnCollision(Enemy50Entity* this) {
if (super->confusedTime != 0) {
super->animationState = super->knockbackDirection >> 4;
InitializeAnimation(super, super->animationState + 7);
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
if (super->health != this->unk_7a) {
if (super->type == 0) {

View File

@ -44,7 +44,7 @@ void sub_0803F528(GhiniEntity*);
void Ghini(GhiniEntity* this) {
Ghini_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
void Ghini_OnTick(GhiniEntity* this) {
@ -69,7 +69,7 @@ void Ghini_OnCollision(GhiniEntity* this) {
if (super->confusedTime != 0) {
super->animationState = super->knockbackDirection >> 4;
InitializeAnimation(super, super->animationState + 7);
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
if (super->health != this->unk_7a) {
this->unk_7a = super->health;

View File

@ -44,7 +44,7 @@ extern Entity* gUnk_020000B0;
void Gibdo(Entity* this) {
EnemyFunctionHandler(this, Gibdo_Functions);
SetChildOffset(this, 0, 1, -0x15);
EnemySetFXOffset(this, 0, 1, -0x15);
}
void Gibdo_OnTick(GibdoEntity* this) {
@ -83,7 +83,7 @@ void Gibdo_OnCollision(GibdoEntity* this) {
}
}
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, Gibdo_Functions);
}
@ -192,7 +192,7 @@ void sub_0803775C(GibdoEntity* this) {
if (--super->timer == 0) {
stalfos = CreateEnemy(STALFOS, 0);
if (stalfos != NULL) {
sub_0804A4E4(super, stalfos);
EnemyCopyParams(super, stalfos);
Gibdo_MoveObjectsToStalfos(this, stalfos);
}
DeleteEntity(super);

View File

@ -300,7 +300,7 @@ void sub_0802D33C(GleerokEntity* this) {
}
unk_84->entities[i]->health = 0;
((GenericEntity*)unk_84->entities[i])->field_0x6c.HALF.HI |= 1;
((Enemy*)(unk_84->entities[i]))->enemyFlags |= EM_FLAG_BOSS;
unk_84->ent2->health = 0;
unk_84->ent2->type2 = 0;
unk_84->ent2->spriteSettings.draw &= ~1;
@ -815,7 +815,7 @@ void sub_0802DCE0(GleerokEntity* this) {
}
} else {
if (this->unk_84->ent2->subtimer == 0) {
super->child = CreateProjectileWithParent(super, GLEEROK_PROJECTILE, 0);
super->child = EnemyCreateProjectile(super, GLEEROK_PROJECTILE, 0);
if (super->child != NULL) {
super->child->direction = this->unk_84->filler[5].unk0.HALF.HI;
@ -883,7 +883,7 @@ void sub_0802DDD8(GleerokEntity* this) {
}
if (this->unk_84->ent2->subtimer == 1) {
super->child = CreateProjectileWithParent(super, GLEEROK_PROJECTILE, r2);
super->child = EnemyCreateProjectile(super, GLEEROK_PROJECTILE, r2);
if (super->child != NULL) {
super->child->direction = this->unk_84->filler[5].unk0.HALF.HI;
super->child->type2 = this->unk_84->ent2->frame & 0xf;
@ -1160,7 +1160,7 @@ void sub_0802E300(GleerokEntity* this) {
heap->ent2->timer = 24;
} else {
if ((gRoomTransition.frameCount & 0xf) == 0) {
CreateProjectileWithParent(super, GLEEROK_PROJECTILE, 0x3);
EnemyCreateProjectile(super, GLEEROK_PROJECTILE, 0x3);
}
}

View File

@ -39,7 +39,7 @@ extern const s8 gUnk_080CD464[];
void Helmasaur(HelmasaurEntity* this) {
if (super->type == 0) {
EnemyFunctionHandler(super, (EntityActionArray)Helmasaur_Functions);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
} else {
gUnk_080CD3FC[super->action](this);
}
@ -63,7 +63,7 @@ void Helmasaur_OnCollision(HelmasaurEntity* this) {
}
}
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, Helmasaur_Functions);

View File

@ -51,7 +51,7 @@ void sub_080327E0(KeatonEntity* this);
void Keaton(KeatonEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Keaton_Functions);
SetChildOffset(super, 0, 1, -18);
EnemySetFXOffset(super, 0, 1, -18);
}
void Keaton_OnTick(KeatonEntity* this) {
@ -75,7 +75,7 @@ void Keaton_OnCollision(KeatonEntity* this) {
}
}
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, Keaton_Functions);
}
@ -262,7 +262,7 @@ void sub_08032794(KeatonEntity* this) {
void sub_080327C8(KeatonEntity* this) {
Entity* child;
child = CreateProjectileWithParent(super, KEATON_DAGGER, 0);
child = EnemyCreateProjectile(super, KEATON_DAGGER, 0);
if (child != NULL) {
child->parent = super;
super->child = child;

View File

@ -54,7 +54,7 @@ extern const OffsetCoords gUnk_080D0154[];
void Lakitu(LakituEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Lakitu_Functions);
SetChildOffset(super, 0, 1, -16);
EnemySetFXOffset(super, 0, 1, -16);
}
void Lakitu_OnTick(LakituEntity* this) {
@ -96,7 +96,7 @@ void Lakitu_OnCollision(LakituEntity* this) {
}
if (super->confusedTime) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, Lakitu_Functions);
@ -128,7 +128,7 @@ void sub_0803C86C(LakituEntity* this) {
}
void Lakitu_Initialize(LakituEntity* this) {
Entity* cloud = CreateProjectileWithParent(super, 17, 0);
Entity* cloud = EnemyCreateProjectile(super, 17, 0);
if (cloud == NULL) {
return;
}
@ -313,7 +313,7 @@ void Lakitu_SpawnLightning(LakituEntity* this) {
Entity* lightning;
const OffsetCoords* offset;
lightning = CreateProjectileWithParent(super, LAKITU_LIGHTNING, 0);
lightning = EnemyCreateProjectile(super, LAKITU_LIGHTNING, 0);
if (lightning == NULL) {
return;

View File

@ -39,7 +39,7 @@ enum {
void Leever(LeeverEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Leever_Functions);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
void Leever_OnTick(LeeverEntity* this) {
@ -53,7 +53,7 @@ void Leever_OnCollision(LeeverEntity* this) {
}
} else {
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
}
EnemyFunctionHandlerAfterCollision(super, Leever_Functions);
@ -63,7 +63,7 @@ void Leever_OnDeath(LeeverEntity* this) {
if (super->type == LeeverForm_Red) {
GenericDeath(super);
} else {
CreateDeathFx(super, 0xf1, 0);
EnemyCreateDeathFX((Enemy*)super, 0xf1, 0);
}
}

View File

@ -31,7 +31,7 @@ extern void (*const gUnk_080CC714[])(LikeLikeEntity*);
void LikeLike(Entity* this) {
EnemyFunctionHandler(this, LikeLike_Functions);
SetChildOffset(this, 0, 1, -0x10);
EnemySetFXOffset(this, 0, 1, -0x10);
}
void LikeLike_OnTick(LikeLikeEntity* this) {
@ -63,7 +63,7 @@ void LikeLike_OnCollision(LikeLikeEntity* this) {
}
if (super->confusedTime) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, LikeLike_Functions);

View File

@ -36,7 +36,7 @@ static void (*const MiniSlime_Functions[])(MiniSlimeEntity*) = {
void MiniSlime(MiniSlimeEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)MiniSlime_Functions);
SetChildOffset(super, 0, 1, -8);
EnemySetFXOffset(super, 0, 1, -8);
}
void MiniSlime_OnTick(MiniSlimeEntity* this) {
@ -51,7 +51,7 @@ void MiniSlime_OnTick(MiniSlimeEntity* this) {
void MiniSlime_OnCollision(MiniSlimeEntity* this) {
if (super->confusedTime)
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
EnemyFunctionHandlerAfterCollision(super, MiniSlime_Functions);
}

View File

@ -43,7 +43,7 @@ void sub_080332E8(MulldozerEntity*, s32);
void Mulldozer(MulldozerEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Mulldozer_Functions);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
void Mulldozer_OnInit(MulldozerEntity* this) {
@ -52,7 +52,7 @@ void Mulldozer_OnInit(MulldozerEntity* this) {
void Mulldozer_OnCollision(MulldozerEntity* this) {
if (super->confusedTime != 0) {
Create0x68FX(super, 0x1c);
EnemyCreateFX(super, 0x1c);
}
EnemyFunctionHandlerAfterCollision(super, Mulldozer_Functions);
if ((super->contactFlags & 0x80) != 0) {

View File

@ -24,7 +24,7 @@ extern const s8 gUnk_080CA17E[2];
// Main
void Octorok(Entity* this) {
EnemyFunctionHandler(this, Octorok_Functions);
SetChildOffset(this, 0, 1, -16);
EnemySetFXOffset(this, 0, 1, -16);
}
// Idle
@ -35,7 +35,7 @@ void Octorok_OnTick(Entity* this) {
// Touch player
void Octorok_OnCollision(Entity* this) {
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
EnemyCreateFX(this, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, Octorok_Functions);
}
@ -45,7 +45,7 @@ void Octorok_OnDeath(Entity* this) {
if (this->type == 0) {
GenericDeath(this);
} else {
CreateDeathFx(this, 241, 0);
EnemyCreateDeathFX((Enemy*)this, 241, 0);
}
}
@ -127,7 +127,7 @@ void Octorok_Move(Entity* this) {
void Octorok_ShootNut(Entity* this) {
GetNextFrame(this);
if (this->frame & 1) {
Entity* entity = CreateProjectileWithParent(this, ROCK_PROJECTILE, 0);
Entity* entity = EnemyCreateProjectile(this, ROCK_PROJECTILE, 0);
if (entity != NULL) {
const s8* off;
entity->direction = this->direction;

View File

@ -342,7 +342,7 @@ void OctorokBoss_Init(OctorokBossEntity* this) {
(this->heap)->field_0x2 = 0;
(this->heap)->tailCount = 5;
super->spriteRendering.b0 = 3;
this->field_0x6c.HALF.HI |= 1;
((Enemy*)this)->enemyFlags |= EM_FLAG_BOSS;
this->unk_76 = 0xa0;
this->unk_74 = 0xa0;
this->angle.HWORD = 0;
@ -556,7 +556,7 @@ void OctorokBoss_Action1(OctorokBossEntity* this) {
case LEG_FR:
case LEG_FL:
case LEG_BL:
if ((((OctorokBossEntity*)super->parent)->field_0x6c.HALF.HI & 2) != 0) {
if (((Enemy*)super->parent)->enemyFlags & EM_FLAG_BOSS_KILLED) {
DeleteThisEntity();
}
if (this->heap->mouthObject->base.health == 1) {
@ -676,7 +676,7 @@ void OctorokBoss_Action1(OctorokBossEntity* this) {
this->heap->fallingStonesTimer--;
if ((gRoomTransition.frameCount & 3) == 0) {
// Falling stones
CreateProjectileWithParent(super, OCTOROK_BOSS_PROJECTILE, 3);
EnemyCreateProjectile(super, OCTOROK_BOSS_PROJECTILE, 3);
}
}
OctorokBoss_Action1_SubActions[super->subAction](this);
@ -883,7 +883,7 @@ void OctorokBoss_Action1_Attack_Type2_3(OctorokBossEntity* this) {
}
void OctorokBoss_ExecuteAttackSpitRock(OctorokBossEntity* this) {
super->child = CreateProjectileWithParent(super, OCTOROK_BOSS_PROJECTILE, 0);
super->child = EnemyCreateProjectile(super, OCTOROK_BOSS_PROJECTILE, 0);
if (super->child != NULL) {
super->child->parent = super;
super->child->direction = ((u8) - this->angle.HALF.HI ^ 0x80);
@ -1002,7 +1002,7 @@ void OctorokBoss_ExecuteAttackFreeze(OctorokBossEntity* this) {
} else {
this->timer--;
if ((gRoomTransition.frameCount & 3) == 0) {
super->child = CreateProjectileWithParent(super, OCTOROK_BOSS_PROJECTILE, 2);
super->child = EnemyCreateProjectile(super, OCTOROK_BOSS_PROJECTILE, 2);
if (super->child != NULL) {
super->child->parent = super;
super->child->direction = (u8) - this->angle.HALF.HI ^ 0x80;
@ -1022,7 +1022,7 @@ void OctorokBoss_Burning(OctorokBossEntity* this) {
this->heap->fallingStonesTimer--;
if ((gRoomTransition.frameCount & 7) == 0) {
// Falling stones
CreateProjectileWithParent(super, OCTOROK_BOSS_PROJECTILE, 3);
EnemyCreateProjectile(super, OCTOROK_BOSS_PROJECTILE, 3);
}
}
SetAffineInfo(super, this->unk_76, this->unk_74, this->angle.HWORD);

View File

@ -26,7 +26,7 @@ void OctorokGolden(Entity* this) {
gUnk_080012C8[index](this);
} else {
OctorokGolden_Functions[GetNextFunction(this)](this);
SetChildOffset(this, 0, 1, -0x10);
EnemySetFXOffset(this, 0, 1, -0x10);
}
}
@ -36,7 +36,7 @@ void OctorokGolden_OnTick(Entity* this) {
void OctorokGolden_OnCollision(Entity* this) {
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
EnemyCreateFX(this, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, OctorokGolden_Functions);
@ -47,7 +47,7 @@ void OctorokGolden_OnDeath(Entity* this) {
SetGlobalFlag(this->type2);
}
CreateDeathFx(this, 0xff, ITEM_RUPEE100);
EnemyCreateDeathFX((Enemy*)this, 0xff, ITEM_RUPEE100);
}
void sub_08037CE4(Entity* this) {
@ -83,7 +83,7 @@ static void sub_08037D54(Entity* this) {
this->frame ^= 2;
if (this->frame & 0x2) {
Entity* proj = CreateProjectileWithParent(this, ROCK_PROJECTILE, 0);
Entity* proj = EnemyCreateProjectile(this, ROCK_PROJECTILE, 0);
if (proj) {
const s8* ptr;
s32 dir;

View File

@ -47,7 +47,7 @@ enum {
void Peahat(PeahatEntity* this) {
if (super->type == PeahatForm_Torso) {
EnemyFunctionHandler(super, (EntityActionArray)Peahat_Functions);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
} else {
gPeahatPropellerFunctions[super->action](this);
}
@ -94,7 +94,7 @@ void Peahat_OnCollision(PeahatEntity* this) {
}
if (super->confusedTime)
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
EnemyFunctionHandlerAfterCollision(super, Peahat_Functions);
}
@ -267,14 +267,14 @@ void Peahat_Stunned(PeahatEntity* this) {
void Peahat_RepairPropeller(PeahatEntity* this) {
if ((super->subtimer != 0) && (--super->subtimer == 0)) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
if (sub_0800442E(super) || (--super->timer == 0)) {
super->action = 9;
super->zVelocity = Q_16_16(1.5);
super->direction = Random() & 0x1f;
sub_0804AA1C(super);
EnemyDetachFX(super);
super->animationState = PeahatAnimation_RepairPropeller;
InitializeAnimation(super, super->animationState);
}
@ -282,14 +282,14 @@ void Peahat_RepairPropeller(PeahatEntity* this) {
void Peahat_Recover(PeahatEntity* this) {
if ((super->subtimer != 0) && (--super->subtimer == 0)) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
if (sub_0800442E(super) || (--super->timer == 0)) {
super->action = 8;
super->timer = 240;
super->direction = Random() & 0x1f;
sub_0804AA1C(super);
EnemyDetachFX(super);
}
}

View File

@ -185,7 +185,7 @@ void sub_080240B8(PestoEntity* this) {
Entity* entity;
this->unk_83 = 0;
entity = CreateProjectileWithParent(super, DIRT_BALL_PROJECTILE, this->unk_83);
entity = EnemyCreateProjectile(super, DIRT_BALL_PROJECTILE, this->unk_83);
if (entity != NULL) {
super->child = entity;
entity->parent = super;
@ -428,7 +428,7 @@ void sub_080244E8(PestoEntity* this) {
super->z.HALF.HI -= 0xe;
this->unk_78 -= 0xe;
entity = CreateProjectileWithParent(super, DIRT_BALL_PROJECTILE, this->unk_83);
entity = EnemyCreateProjectile(super, DIRT_BALL_PROJECTILE, this->unk_83);
if (entity != NULL) {
entity->parent = super;
entity->z.HALF.HI += 0xe;
@ -451,7 +451,7 @@ void sub_080244E8(PestoEntity* this) {
super->z.HALF.HI -= 0xe;
this->unk_78 -= 0xe;
entity = CreateProjectileWithParent(super, DIRT_BALL_PROJECTILE, this->unk_83);
entity = EnemyCreateProjectile(super, DIRT_BALL_PROJECTILE, this->unk_83);
if (entity != NULL) {
entity->parent = super;
entity->z.HALF.HI += 0xe;

View File

@ -56,7 +56,7 @@ extern const s8 gUnk_080CC0C2[];
void Puffstool(PuffstoolEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Puffstool_Functions);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
void Puffstool_OnTick(PuffstoolEntity* this) {
@ -71,7 +71,7 @@ void Puffstool_OnCollide(PuffstoolEntity* this) {
/* ... */
break;
case 0x1b:
sub_0804AA1C(super);
EnemyDetachFX(super);
tmp = gUnk_080CBFE8[(*(Entity**)&super->contactedEntity)->type];
if (tmp < this->unk_82) {
@ -132,7 +132,7 @@ void sub_08025180(PuffstoolEntity* this) {
super->timer = Random();
super->animationState = (((*(Entity**)&super->contactedEntity)->direction ^ 0x10) >> 3);
InitializeAnimation(super, super->animationState + 4);
sub_0804AA1C(super);
EnemyDetachFX(super);
}
void sub_080251AC(PuffstoolEntity* this) {
@ -291,7 +291,7 @@ void sub_080254B4(PuffstoolEntity* this) {
sub_080256B4(this);
} else {
super->action = 0xc;
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
InitializeAnimation(super, 0);
}
@ -375,7 +375,7 @@ void sub_0802563C(PuffstoolEntity* this) {
super->hitType = 0x82;
this->unk_82 = 240;
sub_080256B4(this);
sub_0804AA1C(super);
EnemyDetachFX(super);
} else if (this->unk_84 < 120) {
u32 tmp3 = gUnk_080CBFF8[this->unk_84 >> 4];
if ((this->unk_84 & tmp3) == 0) {

View File

@ -49,7 +49,7 @@ void RockChuchu_OnCollision(Entity* this) {
#ifndef EU
entity->iframes = -8;
#endif
sub_0804A4E4(this, entity);
EnemyCopyParams(this, entity);
this->action = 2;
COLLISION_OFF(this);
this->spriteSettings.draw = 0;

View File

@ -42,7 +42,7 @@ u32 sub_0803163C(RopeEntity* this);
void Rope(RopeEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Rope_Functions);
SetChildOffset(super, 0, 1, -16);
EnemySetFXOffset(super, 0, 1, -16);
}
void Rope_OnTick(RopeEntity* this) {
@ -62,7 +62,7 @@ void Rope_OnCollision(RopeEntity* this) {
sub_08031600(this);
}
if (super->confusedTime) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, Rope_Functions);
}

View File

@ -45,7 +45,7 @@ void RopeGolden(RopeGoldenEntity* this) {
gUnk_080012C8[x](super);
} else {
RopeGolden_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
}
@ -61,7 +61,7 @@ void RopeGolden_OnTick(RopeGoldenEntity* this) {
void RopeGolden_OnCollision(RopeGoldenEntity* this) {
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, RopeGolden_Functions);
}
@ -70,7 +70,7 @@ void RopeGolden_OnDeath(RopeGoldenEntity* this) {
if ((super->gustJarState & 2) == 0) {
SetGlobalFlag(super->type2);
}
CreateDeathFx(super, 0xff, ITEM_RUPEE100);
EnemyCreateDeathFX((Enemy*)super, 0xff, ITEM_RUPEE100);
}
void sub_08038258(RopeGoldenEntity* this) {

View File

@ -48,7 +48,7 @@ void RupeeLike(RupeeLikeEntity* this) {
sub_08001290(super, uVar1);
} else {
RupeeLike_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
} else {
sub_080293DC(this);
@ -80,7 +80,7 @@ void RupeeLike_OnCollision(RupeeLikeEntity* this) {
EnqueueSFX(SFX_PLACE_OBJ);
} else {
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
}
}
@ -88,7 +88,7 @@ void RupeeLike_OnCollision(RupeeLikeEntity* this) {
}
void RupeeLike_OnDeath(RupeeLikeEntity* this) {
CreateDeathFx(super, 0xff, gUnk_080CCC34[this->unk_84 * 3 + super->type]);
EnemyCreateDeathFX((Enemy*)super, 0xff, gUnk_080CCC34[this->unk_84 * 3 + super->type]);
}
void RupeeLike_OnGrabbed(RupeeLikeEntity* this) {

View File

@ -30,7 +30,7 @@ void sub_08038B90(ScissorsBeetleEntity*);
void ScissorsBeetle(Entity* this) {
EnemyFunctionHandler(this, ScissorsBeetle_Functions);
SetChildOffset(this, 0, 1, -0x10);
EnemySetFXOffset(this, 0, 1, -0x10);
}
void ScissorsBeetle_OnTick(ScissorsBeetleEntity* this) {
@ -40,7 +40,7 @@ void ScissorsBeetle_OnTick(ScissorsBeetleEntity* this) {
void ScissorsBeetle_OnCollision(ScissorsBeetleEntity* this) {
Entity* child;
if (super->confusedTime) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, ScissorsBeetle_Functions);

View File

@ -40,7 +40,7 @@ static void (*const Slime_Functions[])(SlimeEntity*) = {
void Slime(SlimeEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Slime_Functions);
SetChildOffset(super, 0, 1, -12);
EnemySetFXOffset(super, 0, 1, -12);
}
void Slime_OnTick(SlimeEntity* this) {
@ -58,7 +58,7 @@ void Slime_OnCollision(SlimeEntity* this) {
}
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
}
@ -149,7 +149,7 @@ void sub_08045178(SlimeEntity* this, Entity* child, int h, int v) {
if (child == NULL)
return;
sub_0804A4E4(super, child);
EnemyCopyParams(super, child);
if (sub_080B1AF0(child, h, v))
return;

View File

@ -23,7 +23,7 @@ void Sluggula(Entity* this) {
if (this->type == 1) {
EnemyFunctionHandler(this, Sluggula_Functions);
SetChildOffset(this, 0, 1, -0x10);
EnemySetFXOffset(this, 0, 1, -0x10);
} else if (this->type == 0) {
if (this->z.HALF.HI == 0) {
u32 idx = sub_080012DC(this);
@ -34,7 +34,7 @@ void Sluggula(Entity* this) {
}
gUnk_080CBDD4[GetNextFunction(this)](this);
SetChildOffset(this, 0, 1, -0x10);
EnemySetFXOffset(this, 0, 1, -0x10);
} else {
sub_08023E10(this);
}
@ -46,7 +46,7 @@ void Sluggula_OnTick(Entity* this) {
void Sluggula_OnCollision(Entity* this) {
if (this->confusedTime)
Create0x68FX(this, FX_STARS);
EnemyCreateFX(this, FX_STARS);
if (this->type == 1) {
EnemyFunctionHandlerAfterCollision(this, Sluggula_Functions);
@ -130,7 +130,7 @@ void sub_08023CE0(Entity* this) {
if (this->frame & ANIM_DONE) {
Entity* entity = CreateEnemy(SLUGGULA, 1);
if (entity != NULL) {
sub_0804A4E4(this, entity);
EnemyCopyParams(this, entity);
DeleteThisEntity();
}
} else {

View File

@ -42,7 +42,7 @@ extern const Hitbox* const gUnk_080CC944[];
void SpearMoblin(SpearMoblinEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)SpearMoblin_Functions);
SetChildOffset(super, 0, 1, -0x20);
EnemySetFXOffset(super, 0, 1, -0x20);
if (super->child && super->child->next) {
CopyPosition(super, super->child);
}
@ -54,7 +54,7 @@ void SpearMoblin_OnTick(SpearMoblinEntity* this) {
void SpearMoblin_OnCollision(SpearMoblinEntity* this) {
if (super->confusedTime != 0)
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
EnemyFunctionHandlerAfterCollision(super, SpearMoblin_Functions);
if (super->contactFlags & 0x80) {

View File

@ -22,7 +22,7 @@ extern const s8 gUnk_080CD318[];
void SpikedBeetle(Entity* this) {
EnemyFunctionHandler(this, SpikedBeetle_Functions);
SetChildOffset(this, 0, 1, -0x10);
EnemySetFXOffset(this, 0, 1, -0x10);
}
void SpikedBeetle_OnTick(Entity* this) {
@ -63,7 +63,7 @@ void SpikedBeetle_OnCollision(Entity* this) {
}
}
if (this->confusedTime) {
Create0x68FX(this, FX_STARS);
EnemyCreateFX(this, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, SpikedBeetle_Functions);
}

View File

@ -36,7 +36,7 @@ extern u32 sub_0804A024(Entity*, u32, u32);
void SpinyBeetle(Entity* this) {
EnemyFunctionHandler(this, SpinyBeetle_Functions);
SetChildOffset(this, 0, 1, -0x10);
EnemySetFXOffset(this, 0, 1, -0x10);
}
void SpinyBeetle_OnTick(SpinyBeetleEntity* this) {
@ -45,7 +45,7 @@ void SpinyBeetle_OnTick(SpinyBeetleEntity* this) {
void SpinyBeetle_OnCollision(SpinyBeetleEntity* this) {
if (super->confusedTime) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, SpinyBeetle_Functions);

View File

@ -27,7 +27,7 @@ extern Entity* gUnk_020000B0;
void SpinyChuchu(SpinyChuchuEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)SpinyChuchu_Functions);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
void SpinyChuchu_OnTick(SpinyChuchuEntity* this) {
@ -55,13 +55,13 @@ void SpinyChuchu_OnCollision(SpinyChuchuEntity* this) {
case 0x18:
case 0x19:
case 0x1a:
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
super->action = 5;
super->hitType = 0x5c;
InitializeAnimation(super, 1);
}
} else if (super->contactFlags == 0x94) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
super->action = 5;
InitializeAnimation(super, 1);
}
@ -216,7 +216,7 @@ void sub_0802281C(SpinyChuchuEntity* this) {
super->action = 2;
super->speed = 0x20;
InitializeAnimation(super, 0);
sub_0804AA1C(super);
EnemyDetachFX(super);
}
}

View File

@ -48,7 +48,7 @@ u32 sub_08039B28(StalfosEntity*);
void Stalfos(StalfosEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)&Stalfos_Functions);
SetChildOffset(super, 0, 1, -0x12);
EnemySetFXOffset(super, 0, 1, -0x12);
}
void Stalfos_OnTick(StalfosEntity* this) {
@ -92,7 +92,7 @@ void Stalfos_OnCollision(StalfosEntity* this) {
r1 = super->child;
if (r1 == NULL) {
if (super->action < 9) {
r1 = CreateProjectileWithParent(super, STALFOS_PROJECTILE, 1);
r1 = EnemyCreateProjectile(super, STALFOS_PROJECTILE, 1);
if (r1 != NULL) {
r1->frameIndex = super->animationState << 1;
r1->type2 = 2;
@ -112,14 +112,14 @@ void Stalfos_OnCollision(StalfosEntity* this) {
super->flags2 &= 0xfb;
}
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, Stalfos_Functions);
}
void Stalfos_OnDeath(StalfosEntity* this) {
if (super->type == 0) {
CreateDeathFx(super, 0xf3, 0);
EnemyCreateDeathFX((Enemy*)super, 0xf3, 0);
} else {
GenericDeath(super);
}
@ -143,7 +143,7 @@ void Stalfos_SubAction1(StalfosEntity* this) {
void Stalfos_SubAction2(StalfosEntity* this) {
Entity* projectile = super->child;
if (projectile == NULL) {
projectile = CreateProjectileWithParent(super, STALFOS_PROJECTILE, 1);
projectile = EnemyCreateProjectile(super, STALFOS_PROJECTILE, 1);
if (projectile != NULL) {
projectile->frameIndex = super->animationState << 1;
projectile->type2 = 1;
@ -396,7 +396,7 @@ void sub_08039A00(StalfosEntity* this, u32 param_2) {
}
void sub_08039A20(StalfosEntity* this) {
Entity* projectile = CreateProjectileWithParent(super, BONE_PROJECTILE, 0);
Entity* projectile = EnemyCreateProjectile(super, BONE_PROJECTILE, 0);
if (projectile != NULL) {
projectile->direction = super->direction;
this->unk_7c = 0x3c;
@ -431,7 +431,7 @@ void sub_08039A70(StalfosEntity* this) {
void sub_08039AD4(StalfosEntity* this) {
u32 position = sub_08039B28(this);
if (position != 0xffff) {
Entity* projectile = CreateProjectileWithParent(super, STALFOS_PROJECTILE, super->type2);
Entity* projectile = EnemyCreateProjectile(super, STALFOS_PROJECTILE, super->type2);
if (projectile != NULL) {
projectile->parent = super;
super->action = 0xb;

View File

@ -38,7 +38,7 @@ static void (*const Tektite_Functions[])(TektiteEntity*) = {
void Tektite(TektiteEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Tektite_Functions);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
void Tektite_OnTick(TektiteEntity* this) {
@ -60,7 +60,7 @@ static const u8 gUnk_080CDEF8[] = {
void Tektite_OnCollision(TektiteEntity* this) {
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, Tektite_Functions);
if ((super->contactFlags & 0x80) != 0) {

View File

@ -33,7 +33,7 @@ static void (*const TektiteGolden_Functions[])(TektiteGoldenEntity*) = {
void TektiteGolden(TektiteGoldenEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)TektiteGolden_Functions);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
void TektiteGolden_OnTick(TektiteGoldenEntity* this) {
@ -48,7 +48,7 @@ void TektiteGolden_OnTick(TektiteGoldenEntity* this) {
void TektiteGolden_OnCollision(TektiteGoldenEntity* this) {
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, TektiteGolden_Functions);
if (super->contactFlags == 0x94) {
@ -78,7 +78,7 @@ void TektiteGolden_OnDeath(TektiteGoldenEntity* this) {
} else {
uVar1 = ITEM_RUPEE100;
}
CreateDeathFx(super, 0xff, uVar1);
EnemyCreateDeathFX((Enemy*)super, 0xff, uVar1);
}
void TektiteGolden_OnConfused(TektiteGoldenEntity* this) {

View File

@ -122,7 +122,7 @@ void TorchTrap_Reset(TorchTrapEntity* this) {
}
void TorchTrap_CreateProjectile(TorchTrapEntity* this) {
Entity* proj = CreateProjectileWithParent(super, TORCH_TRAP_PROJECTILE, 0);
Entity* proj = EnemyCreateProjectile(super, TORCH_TRAP_PROJECTILE, 0);
if (proj) {
u16 speed = super->speed;
if (super->speed) {

View File

@ -15,7 +15,7 @@ typedef struct {
static bool32 ShouldSpawnTreeItem(TreeItemEntity*);
extern void sub_08049CF4(Entity*);
extern void EnemyDisableRespawn(Entity*);
const u8 gTreeItemDropTables[][16] = {
{ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
@ -74,7 +74,7 @@ void TreeItem(TreeItemEntity* this) {
break;
}
sub_08049CF4(super);
EnemyDisableRespawn(super);
DeleteThisEntity();
}

View File

@ -43,7 +43,7 @@ typedef struct VaatiArm_HeapStruct {
VaatiArm_HeapStruct1 s1[5];
} VaatiArm_HeapStruct;
extern void sub_0804AA1C(Entity*);
extern void EnemyDetachFX(Entity*);
static u32 sub_080437DC(VaatiArmEntity*);
static bool32 sub_08043C98(VaatiArmEntity*);
@ -835,7 +835,7 @@ static void sub_08043130(VaatiArmEntity* this) {
if (super->spriteSettings.draw == 0) {
super->subAction = 9;
super->timer = 60;
sub_0804AA1C(super);
EnemyDetachFX(super);
}
}
}
@ -913,7 +913,7 @@ void sub_080432A8(VaatiArmEntity* this) {
super->subAction = 1;
super->timer = 0x1e;
((VaatiArm_HeapStruct*)super->myHeap)->s1[0].unk04.HWORD = 0x4000;
sub_0804AA1C(&((VaatiArm_HeapStruct*)super->myHeap)->entities[4]->base);
EnemyDetachFX(&((VaatiArm_HeapStruct*)super->myHeap)->entities[4]->base);
}
}
@ -1066,7 +1066,7 @@ static void sub_08043580(VaatiArmEntity* this) {
entity->collisionFlags = entity->collisionFlags | 0x10;
entity->hitType = 0x39;
entity->hitbox = (Hitbox*)&gUnk_080FD538;
sub_0804AA1C(super);
EnemyDetachFX(super);
}
}
@ -1443,7 +1443,7 @@ static void sub_08043D08(VaatiArmEntity* this) {
entity->flags &= ~ENT_COLLIDE;
entity->spriteSettings.draw = 0;
InitializeAnimation(entity, 0x13);
sub_0804AA1C(entity);
EnemyDetachFX(entity);
fx = CreateFx(entity, FX_GIANT_EXPLOSION4, 0);
if (fx != NULL) {
fx->x.HALF.HI += gUnk_080D13E9[super->type2];

View File

@ -213,7 +213,7 @@ void sub_08044868(VaatiBallEntity* this) {
if (vaati->unk_86 > 1) {
u8 draw = super->spriteSettings.draw;
if (draw == 1 && this->unk_84 == 0) {
vaati = (VaatiBallEntity*)CreateProjectileWithParent(super, V1_DARK_MAGIC_PROJECTILE, 0);
vaati = (VaatiBallEntity*)EnemyCreateProjectile(super, V1_DARK_MAGIC_PROJECTILE, 0);
if (vaati) {
vaati->base.type2 = 1;
vaati->base.parent = super;
@ -303,7 +303,7 @@ void sub_080449F8(VaatiBallEntity* this) {
this->unk_74++;
draw = super->spriteSettings.draw;
if (draw) {
vaati = (VaatiBallEntity*)CreateProjectileWithParent(super, V1_EYE_LASER, 0);
vaati = (VaatiBallEntity*)EnemyCreateProjectile(super, V1_EYE_LASER, 0);
if (vaati) {
vaati->base.y.HALF.HI += 4;
vaati->base.parent = super;

View File

@ -62,7 +62,7 @@ const u16 gUnk_080CDE98[] = { 0xc0, 0x100, 0x140, 0x180 };
void VaatiEyesMacro(VaatiEyesMacroEntity* this) {
VaatiEyesMacro_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
void VaatiEyesMacro_OnTick(VaatiEyesMacroEntity* this) {
@ -98,7 +98,7 @@ void VaatiEyesMacro_OnCollision(VaatiEyesMacroEntity* this) {
}
}
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, (EntityActionArray)VaatiEyesMacro_Functions);
}

View File

@ -369,7 +369,7 @@ void VaatiRebornEnemyType0Action4(VaatiRebornEnemyEntity* this) {
super->subtimer = 0;
}
if ((super->subtimer < 0x10) &&
(entity = CreateProjectileWithParent(super, V1_FIRE_PROJECTILE, this->unk_84), entity != NULL)) {
(entity = EnemyCreateProjectile(super, V1_FIRE_PROJECTILE, this->unk_84), entity != NULL)) {
entity->subtimer = super->subtimer;
entity->parent = super;
entity->z.HALF.HI = super->z.HALF.HI;
@ -456,7 +456,7 @@ void VaatiRebornEnemyType0Action6(VaatiRebornEnemyEntity* this) {
if (--super->timer == 0) {
this->unk_74++;
SoundReq(SFX_150);
target = CreateProjectileWithParent(super, V1_DARK_MAGIC_PROJECTILE, 0);
target = EnemyCreateProjectile(super, V1_DARK_MAGIC_PROJECTILE, 0);
if (target != NULL) {
PositionRelative(super, target, 0, Q_16_16(-16.0));
target->parent = super;

View File

@ -436,7 +436,7 @@ void VaatiTransfiguredType0Action4(VaatiTransfiguredEntity* this) {
super->timer = gUnk_080D0ABF[((u32)super->animationState << 1 | 1)];
} else {
if ((super->timer & 7) == 0) {
CreateProjectileWithParent(super, V2_PROJECTILE, super->subtimer);
EnemyCreateProjectile(super, V2_PROJECTILE, super->subtimer);
}
if (((super->subtimer != 0) && (1 < super->animationState)) && (super->timer < 6)) {
super->timer = 128;
@ -482,7 +482,7 @@ void VaatiTransfiguredType0Action5(VaatiTransfiguredEntity* this) {
} else {
if (super->subtimer) {
if ((super->timer & 7) == 0) {
CreateProjectileWithParent(super, V2_PROJECTILE, super->subtimer);
EnemyCreateProjectile(super, V2_PROJECTILE, super->subtimer);
}
if (super->timer < 6) {
super->timer = 64;
@ -490,7 +490,7 @@ void VaatiTransfiguredType0Action5(VaatiTransfiguredEntity* this) {
}
} else {
if ((super->timer & 0xf) == 0) {
entity = CreateProjectileWithParent(super, V2_PROJECTILE, 2);
entity = EnemyCreateProjectile(super, V2_PROJECTILE, 2);
if (entity != NULL) {
entity->type2 = 0;
if (this->unk_81 != 0) {
@ -534,7 +534,7 @@ void VaatiTransfiguredType0Action6(VaatiTransfiguredEntity* this) {
} else {
if (super->subtimer) {
if ((super->timer & 7) == 0) {
CreateProjectileWithParent(super, V2_PROJECTILE, super->subtimer);
EnemyCreateProjectile(super, V2_PROJECTILE, super->subtimer);
}
if (super->timer < 6) {
super->timer = 128;
@ -542,7 +542,7 @@ void VaatiTransfiguredType0Action6(VaatiTransfiguredEntity* this) {
}
} else {
if ((super->timer & 0x1f) == 0) {
pEVar2 = CreateProjectileWithParent(super, V2_PROJECTILE, 2);
pEVar2 = EnemyCreateProjectile(super, V2_PROJECTILE, 2);
if (pEVar2 != NULL) {
pEVar2->type2 = 1;
pEVar2->y.HALF.HI += -0x20;

View File

@ -30,7 +30,7 @@ extern const s8 gUnk_080CD0B0[];
void WallMaster(WallMasterEntity* this) {
WallMaster_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
void WallMaster_OnTick(WallMasterEntity* this) {
@ -55,7 +55,7 @@ void WallMaster_OnCollision(WallMasterEntity* this) {
super->knockbackDuration -= 4;
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, (EntityActionArray)WallMaster_Functions);

View File

@ -34,7 +34,7 @@ extern const s8 gUnk_080CD740[];
void WallMaster2(WallMaster2Entity* this) {
WallMaster2_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
void WallMaster2_OnTick(WallMaster2Entity* this) {
@ -53,7 +53,7 @@ void WallMaster2_OnCollision(WallMaster2Entity* this) {
break;
}
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, (EntityActionArray)WallMaster2_Functions);
}

View File

@ -13,7 +13,7 @@ extern void (*const WizzrobeFire_Actions[])(WizzrobeEntity*);
void WizzrobeFire(WizzrobeEntity* this) {
WizzrobeFire_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
void WizzrobeFire_OnTick(WizzrobeEntity* this) {
@ -22,7 +22,7 @@ void WizzrobeFire_OnTick(WizzrobeEntity* this) {
void WizzrobeFire_OnCollision(WizzrobeEntity* this) {
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, WizzrobeFire_Functions);
if (super->health == 0) {
@ -40,7 +40,7 @@ void WizzrobeFire_Init(WizzrobeEntity* this) {
super->timer = 40;
super->subtimer = 96;
sub_0802F888(this);
projectile = CreateProjectileWithParent(super, FIRE_PROJECTILE, 0);
projectile = EnemyCreateProjectile(super, FIRE_PROJECTILE, 0);
if (projectile != NULL) {
super->child = projectile;
projectile->parent = super;
@ -96,7 +96,7 @@ void WizzrobeFire_Action2(WizzrobeEntity* this) {
break;
case 6:
if (EntityInRectRadius(super, &gPlayerEntity.base, 0xa0, 0xa0) && CheckOnScreen(super)) {
Entity* projectile = CreateProjectileWithParent(super, FIRE_PROJECTILE, 1);
Entity* projectile = EnemyCreateProjectile(super, FIRE_PROJECTILE, 1);
if (projectile != NULL) {
projectile->direction = super->direction & 0x18;
}

View File

@ -14,7 +14,7 @@ extern void (*const WizzrobeIce_Actions[])(WizzrobeEntity*);
void WizzrobeIce(WizzrobeEntity* this) {
WizzrobeIce_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
void WizzrobeIce_OnTick(WizzrobeEntity* this) {
@ -23,7 +23,7 @@ void WizzrobeIce_OnTick(WizzrobeEntity* this) {
void WizzrobeIce_OnCollision(WizzrobeEntity* this) {
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, WizzrobeIce_Functions);
if (super->contactFlags == 0x87) {
@ -49,7 +49,7 @@ void WizzrobeIce_Init(WizzrobeEntity* this) {
super->timer = 40;
super->subtimer = 96;
sub_0802F888(this);
projectile = CreateProjectileWithParent(super, ICE_PROJECTILE, 0);
projectile = EnemyCreateProjectile(super, ICE_PROJECTILE, 0);
if (projectile != NULL) {
super->child = projectile;
projectile->parent = super;
@ -103,7 +103,7 @@ void WizzrobeIce_Action2(WizzrobeEntity* this) {
break;
case 0xa:
if (EntityInRectRadius(super, &gPlayerEntity.base, 0xa0, 0xa0) && CheckOnScreen(super)) {
Entity* projectile = CreateProjectileWithParent(super, ICE_PROJECTILE, 1);
Entity* projectile = EnemyCreateProjectile(super, ICE_PROJECTILE, 1);
if (projectile != NULL) {
projectile->direction = super->direction & 0x18;
}

View File

@ -21,7 +21,7 @@ void sub_0802F8E4(WizzrobeEntity*);
void WizzrobeWind(WizzrobeEntity* this) {
WizzrobeWind_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
EnemySetFXOffset(super, 0, 1, -0x10);
}
void WizzrobeWind_OnTick(WizzrobeEntity* this) {
@ -30,7 +30,7 @@ void WizzrobeWind_OnTick(WizzrobeEntity* this) {
void WizzrobeWind_OnCollision(WizzrobeEntity* this) {
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, WizzrobeWind_Functions);
if (super->contactFlags == 0x87) {
@ -66,7 +66,7 @@ void WizzrobeWind_Init(WizzrobeEntity* this) {
super->subtimer = 96;
sub_0802F888(this);
}
projectile = CreateProjectileWithParent(super, WIND_PROJECTILE, 0);
projectile = EnemyCreateProjectile(super, WIND_PROJECTILE, 0);
if (projectile != NULL) {
super->parent = projectile;
projectile->parent = super;
@ -119,7 +119,7 @@ void WizzrobeWind_Action2(WizzrobeEntity* this) {
break;
case 8:
if (EntityInRectRadius(super, &gPlayerEntity.base, 0xa0, 0xa0) && CheckOnScreen(super)) {
Entity* projectile = CreateProjectileWithParent(super, WIND_PROJECTILE, 1);
Entity* projectile = EnemyCreateProjectile(super, WIND_PROJECTILE, 1);
if (projectile != NULL) {
projectile->direction = super->direction & 0x18;
}
@ -190,7 +190,7 @@ void WizzrobeWind_Action3(WizzrobeEntity* this) {
parent->spriteSettings.draw = 0;
InitializeAnimation(super, super->animationState >> 1);
} else if (super->timer == 8) {
parent = CreateProjectileWithParent(super, WIND_PROJECTILE, 1);
parent = EnemyCreateProjectile(super, WIND_PROJECTILE, 1);
if (parent != NULL) {
parent->direction = super->direction & 0x18;
}

View File

@ -1,5 +1,5 @@
#include "enemyUtils.h"
#include "enemy.h"
#include "definitions.h"
#include "entity.h"
#include "functions.h"
@ -8,7 +8,8 @@
#include "projectile.h"
#include "save.h"
extern void sub_08049CF4(Entity*);
extern void EnemyDisableRespawn(Entity*);
extern void ReplaceMonitoredEntity(Entity*, Entity*);
extern EnemyDefinition gEnemyDefinitions[];
@ -33,6 +34,24 @@ const struct_080D3D94 gUnk_080D3D94[] = {
const u16 gUnk_080D3E74[] = { 2373, 1105, 2324, 21568, 4177, 16656, 1365, 21760, 8209, 0, 20480, 5, 0, 0 };
void EnemyCopyParams(Entity* src, Entity* dest) {
Enemy* em_src = (Enemy*)src;
Enemy* em_dest = (Enemy*)dest;
em_dest->enemyFlags = (em_src->enemyFlags & EM_FLAG_MONITORED) | EM_FLAG_HAS_HOME;
em_dest->idx = em_src->idx;
em_dest->homeX = em_src->homeX;
em_dest->homeY = em_src->homeY;
em_dest->rangeX = em_src->rangeX;
em_dest->rangeY = em_src->rangeY;
CopyPositionAndSpriteOffset(&em_src->base, &em_dest->base);
if (em_src->enemyFlags & EM_FLAG_MONITORED) {
ReplaceMonitoredEntity(&em_src->base, &em_dest->base);
}
}
const EnemyDefinition* GetEnemyDefinition(Entity* entity) {
const EnemyDefinition* definition = &gEnemyDefinitions[entity->id];
if (definition->gfx == 0xffff) {
@ -41,7 +60,7 @@ const EnemyDefinition* GetEnemyDefinition(Entity* entity) {
return definition;
}
bool32 EnemyInit(GenericEntity* this) {
bool32 EnemyInit(Enemy* this) {
if ((super->flags & ENT_DID_INIT) == 0) {
const EnemyDefinition* definition = GetEnemyDefinition(super);
if (LoadEnemySprite(super, definition) == FALSE) {
@ -68,19 +87,19 @@ bool32 EnemyInit(GenericEntity* this) {
super->hurtType = 0x41;
}
UpdateSpriteForCollisionLayer(super);
if ((this->field_0x6c.HALF.HI & 0x20) != 0) {
if (this->enemyFlags & EM_FLAG_CAPTAIN) {
u32 uVar4 = gUnk_080D3E74[super->id >> 3] >> ((super->id & 7) << 1) & 3;
if (uVar4 != 0) {
Entity* object = CreateObject(MULLDOZER_SPAWN_POINT, uVar4 - 1, 0);
if (object != NULL) {
object->timer = super->flags;
object->subtimer = super->spriteSettings.draw;
object->spritePriority.b0 = 3;
object->parent = super;
CopyPosition(super, object);
super->flags &= ~ENT_COLLIDE;
Entity* spawn_pt = CreateObject(MULLDOZER_SPAWN_POINT, uVar4 - 1, 0);
if (spawn_pt != NULL) {
spawn_pt->timer = super->flags;
spawn_pt->subtimer = super->spriteSettings.draw;
spawn_pt->spritePriority.b0 = 3;
spawn_pt->parent = super;
CopyPosition(super, spawn_pt);
COLLISION_OFF(super);
super->spriteSettings.draw = 0;
this->field_0x6c.HALF.HI |= 0x10;
this->enemyFlags |= EM_FLAG_SUPPORT;
}
}
}
@ -111,65 +130,66 @@ bool32 LoadEnemySprite(Entity* entity, const EnemyDefinition* definition) {
return TRUE;
}
void sub_0804A720(GenericEntity* this) {
void sub_0804A720(Entity* parent) {
int iVar2;
const struct_080D3D94* pbVar3;
GenericEntityData* ptr;
Enemy* this = (Enemy*)parent;
if ((this->field_0x6c.HALF.HI & 4) != 0) {
if (this->enemyFlags & EM_FLAG_HAS_HOME) {
return;
}
pbVar3 = &gUnk_080D3D94[super->id];
ptr = (GenericEntityData*)&this->field_0x68;
ptr = (GenericEntityData*)&this->child;
if (ptr->field_0x7c.BYTES.byte2 == 0) {
this->field_0x6e.HALF.LO = pbVar3->unk_0;
this->rangeX = pbVar3->unk_0;
} else {
this->field_0x6e.HALF.LO = ptr->field_0x7c.BYTES.byte2;
this->rangeX = ptr->field_0x7c.BYTES.byte2;
}
if (ptr->field_0x7c.BYTES.byte3 == 0) {
this->field_0x6e.HALF.HI = pbVar3->unk_1;
this->rangeY = pbVar3->unk_1;
} else {
this->field_0x6e.HALF.HI = ptr->field_0x7c.BYTES.byte3;
this->rangeY = ptr->field_0x7c.BYTES.byte3;
}
if (ptr->cutsceneBeh.HWORD != 0) {
this->field_0x70.HALF.LO = ptr->cutsceneBeh.HWORD + gRoomControls.origin_x;
this->homeX = ptr->cutsceneBeh.HWORD + gRoomControls.origin_x;
} else {
iVar2 = this->field_0x6e.HALF.LO * 4;
iVar2 = this->rangeX * 4;
if (super->x.HALF.HI >= iVar2) {
this->field_0x70.HALF.LO = super->x.HALF_U.HI - 4 * this->field_0x6e.HALF.LO;
this->homeX = super->x.HALF_U.HI - 4 * this->rangeX;
} else {
this->field_0x70.HALF.LO = 0;
this->homeX = 0;
}
}
if (ptr->field_0x86.HWORD != 0) {
this->field_0x70.HALF.HI = ptr->field_0x86.HWORD + gRoomControls.origin_y;
this->homeY = ptr->field_0x86.HWORD + gRoomControls.origin_y;
} else {
iVar2 = this->field_0x6e.HALF.HI * 4;
iVar2 = this->rangeY * 4;
if (super->y.HALF.HI >= iVar2) {
this->field_0x70.HALF.HI = super->y.HALF.HI - iVar2;
this->homeY = super->y.HALF.HI - iVar2;
} else {
this->field_0x70.HALF.HI = 0;
this->homeY = 0;
}
}
this->field_0x6c.HALF.HI |= 4;
this->enemyFlags |= EM_FLAG_HAS_HOME;
}
void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem);
void EnemyCreateDeathFX(Enemy* parent, u32 parentId, u32 fixedItem);
void GenericDeath(Entity* this) {
CreateDeathFx((GenericEntity*)this, this->id, 0);
EnemyCreateDeathFX((Enemy*)this, this->id, 0);
}
void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem) {
void EnemyCreateDeathFX(Enemy* parent, u32 parentId, u32 fixedItem) {
DeathFxObject* deathFx;
DeathFxObject* deathFx2;
u8 bVar3;
if ((parent->field_0x6c.HALF.HI & 1) != 0) {
if ((parent->field_0x6c.HALF.HI & 2) != 0) {
if (parent->enemyFlags & EM_FLAG_BOSS) {
if (parent->enemyFlags & EM_FLAG_BOSS_KILLED) {
return;
}
deathFx = (DeathFxObject*)CreateObject(DEATH_FX, parent->base.id, 0);
@ -179,7 +199,7 @@ void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem) {
deathFx->unk6c = 1;
PositionRelative(&(parent->base), &(deathFx->base), 0, 1);
deathFx->base.parent = &(parent->base);
parent->field_0x6c.HALF.HI |= 2;
parent->enemyFlags |= EM_FLAG_BOSS_KILLED;
if ((parent->base.id == 0x37) && (gRoomTransition.field_0x39 != 0)) {
DeleteThisEntity();
}
@ -190,7 +210,7 @@ void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem) {
} else {
int tmp = parent->base.gustJarState & 2;
if (tmp == 0) {
sub_08049CF4(&(parent->base));
EnemyDisableRespawn(&(parent->base));
gSave.enemies_killed++;
parent->base.gustJarState |= 2;
parent->base.timer = 255;
@ -204,7 +224,7 @@ void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem) {
deathFx2->base.child = &(parent->base);
CopyPosition(&(parent->base), &(deathFx2->base));
}
if ((parent->field_0x6c.HALF.HI & 8) != 0) {
if (parent->enemyFlags & EM_FLAG_NO_DEATH_FX) {
deathFx2->unk6c |= 8;
DeleteEntity(&(parent->base));
return;
@ -245,7 +265,7 @@ void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem) {
}
}
Entity* CreateProjectileWithParent(Entity* parent, u32 projectileId, u32 projectileType) {
Entity* EnemyCreateProjectile(Entity* parent, u32 projectileId, u32 projectileType) {
Entity* projectile;
projectile = CreateProjectile(projectileId);
@ -256,11 +276,11 @@ Entity* CreateProjectileWithParent(Entity* parent, u32 projectileId, u32 project
return projectile;
}
void SetChildOffset(Entity* entity, s32 xOffset, s32 yOffset, s32 zOffset) {
void EnemySetFXOffset(Entity* entity, s32 xOffset, s32 yOffset, s32 zOffset) {
Entity* other;
GenericEntity* this = (GenericEntity*)entity;
Enemy* this = (Enemy*)entity;
other = *(Entity**)&this->field_0x68;
other = this->child;
if (other != NULL) {
other->spriteRendering.b3 = super->spriteRendering.b3;
other->spriteOrientation.flipY = super->spriteOrientation.flipY;
@ -271,22 +291,44 @@ void SetChildOffset(Entity* entity, s32 xOffset, s32 yOffset, s32 zOffset) {
}
}
Entity* Create0x68FX(Entity* parent, u32 fxType) {
Entity* EnemyCreateFX(Entity* parent, u32 fxType) {
Entity* fx;
GenericEntity* this = (GenericEntity*)parent;
Enemy* this = (Enemy*)parent;
if ((*(Entity**)&this->field_0x68 == NULL) && (fx = CreateFx(super, fxType, 0), fx != NULL)) {
*(Entity**)&this->field_0x68 = fx;
if (this->child == NULL && (fx = CreateFx(super, fxType, 0), fx != NULL)) {
this->child = fx;
} else {
fx = NULL;
}
return fx;
}
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;
void EnemyDetachFX(Entity* entity) {
Enemy* this = (Enemy*)entity;
if (this->child != NULL) {
this->child->parent = NULL;
this->child = NULL;
}
}
/** Unsets bitfield 0x80 before calling GetNextFunction, so that the enemyFunction 1 is not called. */
void EnemyFunctionHandlerAfterCollision(Entity* entity, void (*const fntable[])()) {
u32 idx;
entity->contactFlags &= ~0x80;
idx = GetNextFunction(entity);
entity->contactFlags |= 0x80;
fntable[idx](entity);
}
Entity* CreateEnemy(u32 subtype, u32 form) {
Entity* enemy;
enemy = GetEmptyEntity();
if (enemy != NULL) {
enemy->kind = ENEMY;
enemy->id = subtype;
enemy->type = form;
AppendEntityToList(enemy, 4);
}
return enemy;
}

View File

@ -21,7 +21,7 @@ void DeleteAllEntities(void);
void sub_0805E98C(void);
extern void UnloadOBJPalette2(Entity*);
extern void sub_08017744(Entity*);
extern void sub_0804AA1C(Entity*);
extern void EnemyDetachFX(Entity*);
void ClearDeletedEntity(Entity*);
extern void ram_ClearAndUpdateEntities(void);
@ -369,7 +369,7 @@ void DeleteEntity(Entity* ent) {
zFree(ent->myHeap);
ent->myHeap = NULL;
if (ent->kind == ENEMY) {
sub_0804AA1C(ent);
EnemyDetachFX(ent);
}
COLLISION_OFF(ent);
ent->spriteSettings.draw = 0;

View File

@ -16,6 +16,7 @@
#include "message.h"
#include "room.h"
#include "sound.h"
#include "enemy.h"
enum FightManager_State { Init, WaitForFlag, WaitForDone };
@ -112,7 +113,7 @@ void FightManager_LoadFight(FightManager* this) {
while (prop->kind != 0xFF) {
ent = LoadRoomEntity(prop++);
if ((ent != NULL) && (ent->kind == ENEMY)) {
((GenericEntity*)ent)->field_0x6c.HALF.HI |= 0x40;
((Enemy*)ent)->enemyFlags |= EM_FLAG_MONITORED;
FightManagerHelper_Monitor(monitor, ent, counter++);
}
if (counter >= 7) {

View File

@ -340,7 +340,7 @@ void TempleOfDropletsManager_Type6_Action2(TempleOfDropletsManager* this) {
case PL_STATE_WALK:
if (sub_0805A73C(this)) {
super->action++;
sub_08004168(&gPlayerEntity.base);
SnapToTile(&gPlayerEntity.base);
gPlayerEntity.base.animationState = 4;
RequestPriorityDuration((Entity*)this, 600);
SetPlayerControl(0xFF);

View File

@ -681,7 +681,7 @@ void KinstoneMenu_080A4528(void) {
entity->subtimer = entity->id;
entity->id = 0x56;
} else {
EnemyInit(entity);
EnemyInit((Enemy*)entity);
entity->subtimer = entity->id;
entity->id = 0x66;
}

View File

@ -50,7 +50,7 @@ void Bush_Init(BushEntity* this) {
if (super->type == 3) {
Bush_Action2SubAction5(this);
}
sub_08004168(super);
SnapToTile(super);
if (super->type == 4) {
Bush_Action2SubAction5(this);
}

View File

@ -11,7 +11,7 @@ void CrackingGround(Entity* this) {
if (this->action == 0) {
this->action = 1;
this->timer = 20;
sub_08004168(this);
SnapToTile(this);
} else {
if (this->timer-- == 0) {
sub_0807B7D8(0x35, COORD_TO_TILE(this), this->collisionLayer);

View File

@ -326,7 +326,7 @@ void sub_080969A4(CrenelBeanSproutEntity* this) {
void sub_08096A78(CrenelBeanSproutEntity* this) {
SetGlobalFlag(WATERBEAN_PUT);
InitAnimationForceUpdate(super, (super->type >> 1) + 8);
sub_08004168(super);
SnapToTile(super);
super->y.HALF.HI += 4;
super->action = 3;
SetTile(0x403b, COORD_TO_TILE(super), super->collisionLayer);

View File

@ -37,7 +37,7 @@ void Flame_Init(FlameEntity* this) {
break;
case 2:
super->timer = 15;
sub_08004168(super);
SnapToTile(super);
break;
case 3:
CopyPosition(super->parent, super);

View File

@ -186,7 +186,7 @@ void Minecart_Action3(MinecartEntity* this) {
gPlayerEntity.base.animationState = super->animationState << 1;
gPlayerEntity.base.direction = super->direction;
gPlayerEntity.base.flags |= PL_MINISH;
sub_08004168(super);
SnapToTile(super);
InitAnimationForceUpdate(super, super->animationState + 0xc);
SoundReq(SFX_PLY_VO4);
SoundReq(SFX_139);
@ -219,7 +219,7 @@ void Minecart_Action3(MinecartEntity* this) {
}
void Minecart_Action4(MinecartEntity* this) {
sub_08004168(super);
SnapToTile(super);
CopyPosition(super, &gPlayerEntity.base);
switch (GetActTile(super)) {
case 0x67:

View File

@ -6,6 +6,7 @@
*/
#include "entity.h"
#include "sound.h"
#include "enemy.h"
void MulldozerSpawnPoint_Init(Entity*);
void MulldozerSpawnPoint_Action1(Entity*);
@ -37,6 +38,6 @@ void MulldozerSpawnPoint_Action1(Entity* this) {
parent = this->parent;
parent->flags = this->timer;
parent->spriteSettings.draw = this->subtimer;
((GenericEntity*)parent)->field_0x6c.HALF.HI &= 0xef;
((Enemy*)parent)->enemyFlags &= ~EM_FLAG_SUPPORT;
}
}

View File

@ -41,7 +41,7 @@ void Object53_Init(Entity* this) {
this->spriteRendering.b3 = 2;
this->zVelocity = Q_16_16(2.625);
InitializeAnimation(this, gUnk_08122288[this->type].animationState);
sub_08004168(this);
SnapToTile(this);
}
void Object53_Action1(Entity* this) {

View File

@ -23,7 +23,7 @@ void Object70_Init(Entity* this) {
this->spriteSettings.draw = 1;
this->frameIndex = this->type + 0xb;
if (this->type != 0) {
sub_08004168(this);
SnapToTile(this);
gPlayerEntity.base.spriteOrientation.flipY = 3;
if ((gPlayerEntity.base.spritePriority.b0) != 7) {
this->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0 + 1;

View File

@ -106,13 +106,13 @@ void PushableStatue_SubAction0(PushableStatueEntity* this) {
this->unk_83 = 1;
index = gPlayerEntity.base.animationState;
ptr = &gUnk_08120CB4[index];
PositionRelative(super, &gPlayerEntity.base, *(ptr) << 0x10, *(ptr + 1) << 0x10);
PositionRelative(super, &gPlayerEntity.base, Q_16_16(ptr[0]), Q_16_16(ptr[1]));
}
tileType = GetTileType(this->unk_84, super->collisionLayer);
if (tileType != 0x400b) {
switch (sub_0808968C(tileType)) {
case 1:
super->direction = (((tileType - 0xc) & 3) << 3);
super->direction = DirectionFromAnimationState((tileType - 0xc) & 3);
sub_08089538(this);
break;
case 0:
@ -133,7 +133,7 @@ void PushableStatue_SubAction0(PushableStatueEntity* this) {
gPlayerState.flags |= PL_BUSY;
gPlayerEntity.base.x.HALF.LO = 0;
gPlayerEntity.base.y.HALF.LO = 0;
super->direction = (gPlayerEntity.base.animationState ^ 4) << 2;
super->direction = Direction8FromAnimationState(AnimationStateFlip180(gPlayerEntity.base.animationState));
sub_08089538(this);
}
}
@ -181,7 +181,7 @@ void sub_080894C8(PushableStatueEntity* this) {
void sub_080894FC(PushableStatueEntity* this) {
u32 index;
for (index = 0; index <= 7; index++) {
for (index = 0; index < 8; index++) {
if (super == gRoomVars.puzzleEntities[index]) {
gRoomVars.puzzleEntities[index] = NULL;
break;

View File

@ -168,7 +168,7 @@ void SmallIceBlock_Action4(SmallIceBlockEntity* this) {
x = ((rand >> 0x10) % 9) - 4;
y = rand & 0xf;
obj->spritePriority.b0 = 3;
PositionRelative(super, obj, x * 0x10000, -y * 0x10000);
PositionRelative(super, obj, Q_16_16(x), Q_16_16(-y));
}
}
}

View File

@ -588,7 +588,7 @@ static void PlayerFall(PlayerEntity* this) {
}
static void PlayerFallInit(PlayerEntity* this) {
sub_08004168(super);
SnapToTile(super);
gPlayerState.flags |= PL_BUSY | PL_DROWNING;
gPlayerState.flags &= ~PL_BURNING;
@ -962,7 +962,7 @@ static void PlayerDrownInit(PlayerEntity* this) {
SoundReq(SFX_WATER_SPLASH);
} else {
if (!(gPlayerState.flags & PL_FLAGS10000))
sub_08004168(super);
SnapToTile(super);
CreateFx(super, FX_WATER_SPLASH, 0);

View File

@ -2559,7 +2559,7 @@ bool32 HasSwordEquipped(void) {
u32 sub_0807A180(Entity* param_1, Entity* param_2, u32 param_3, u32 param_4) {
GenericEntity stackEntity;
PositionRelative(param_1, &stackEntity.base, 0, -0x40000);
PositionRelative(param_1, &stackEntity.base, 0, Q_16_16(-4.0));
stackEntity.base.animationState = param_1->animationState;
return sub_08003FDE(&stackEntity.base, param_2, param_3, param_4);
}
@ -2933,7 +2933,7 @@ void sub_0807AB44(Entity* this, s32 xOffset, s32 yOffset) {
object = CreateObject(FLAME, 1, 0);
if (object != NULL) {
PositionRelative(this, object, xOffset << 0x10, yOffset << 0x10);
sub_08004168(object);
SnapToTile(object);
sub_0807B7D8(ptr[3], COORD_TO_TILE(object), object->collisionLayer);
}
} else {

View File

@ -86,7 +86,7 @@ void GleerokProjectile_Init(GleerokProjectileEntity* this) {
super->x.HALF.HI += gUnk_08129980[Random() & 7];
super->y.HALF.HI += gUnk_08129988[Random() & 0xf];
}
sub_08004168(super);
SnapToTile(super);
InitializeAnimation(super, 0);
break;
}

View File

@ -150,7 +150,7 @@ void OctorokBossProjectile_Action1(OctorokBossProjectileEntity* this) {
return;
}
for (index = 0; index < 3; ++index) {
super->child = CreateProjectileWithParent(super, OCTOROK_BOSS_PROJECTILE, 1);
super->child = EnemyCreateProjectile(super, OCTOROK_BOSS_PROJECTILE, 1);
if (super->child != NULL) {
super->child->parent = super->parent;
super->child->direction = super->direction + gUnk_08129ADC[index];

View File

@ -157,7 +157,7 @@ void sub_080ABE04(Entity* this) {
}
this->x.HALF.HI = newX + ((0xe0 & rand) >> 1);
this->y.HALF.HI += ((0xf & rand) << 4);
sub_08004168(this);
SnapToTile(this);
InitializeAnimation(this, 0);
SoundReq(SFX_12D);
}

View File

@ -1,3 +1,5 @@
// TODO: original name is probably floor.c
#include "area.h"
#include "common.h"
#include "flags.h"
@ -7,10 +9,11 @@
#include "manager/bombableWallManager.h"
#include "object.h"
#include "room.h"
#include "enemy.h"
static void sub_0804B058(EntityData* dat);
extern void sub_0801AC98(void);
extern u32 sub_08049D1C(u32);
extern u32 EnemyEnableRespawn(u32);
extern void** gCurrentRoomProperties;
extern void*** gAreaTable[];
@ -122,9 +125,7 @@ void sub_0804AF0C(Entity* ent, const EntityData* dat) {
ent->y.HALF.HI = dat->yPos + gRoomControls.origin_y;
break;
case 0x20:
// TODO: for enemies, I think this is for delayed spawn
// see mulldozerSpawnPoint.c
((GenericEntity*)ent)->field_0x6c.HALF.HI |= 0x20;
((Enemy*)ent)->enemyFlags |= EM_FLAG_CAPTAIN;
ent->x.HALF.HI = dat->xPos + gRoomControls.origin_x;
ent->y.HALF.HI = dat->yPos + gRoomControls.origin_y;
break;
@ -196,10 +197,10 @@ static void sub_0804B058(EntityData* dat) {
uVar2 = 0;
do {
if ((uVar2 < 0x20) && ((dat->kind & 0xF) == 3)) {
if (sub_08049D1C(uVar2) != 0) {
if (EnemyEnableRespawn(uVar2) != 0) {
ent = LoadRoomEntity(dat);
if ((ent != NULL) && (ent->kind == ENEMY)) {
((GenericEntity*)ent)->field_0x6c.HALF.LO = uVar2 | 0x80;
((Enemy*)ent)->idx = uVar2 | 0x80;
}
}
} else {