EnHitTag OK (#482)

* EnHitTag all matching, data still not imported

* rename loop counter variable to i

* imported data

* use generated reloc

* cleanup

* name func_80BE20E8, document with ITEM00_RUPEE_GREEN enum, use if-return-implication in WaitForHit

* add switchflag param macro

* use previously unused pCylinder as function arguments

* use THIS macro and change switchflag macro to take actor pointer

* space between var declaration and code

* format

* rename pCylinder to cylinder

* rename cylinder to collider

* change ColliderCylinder* to pad

Co-authored-by: retro <retro@DESKTOP-KGV19SQ.localdomain>
This commit is contained in:
retro 2021-12-06 21:50:59 +00:00 committed by GitHub
parent 08cf506be7
commit 5b7df3f1ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 60 additions and 16 deletions

3
spec
View File

@ -4938,8 +4938,7 @@ beginseg
name "ovl_En_Hit_Tag"
compress
include "build/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.o"
include "build/data/ovl_En_Hit_Tag/ovl_En_Hit_Tag.data.o"
include "build/data/ovl_En_Hit_Tag/ovl_En_Hit_Tag.reloc.o"
include "build/src/overlays/actors/ovl_En_Hit_Tag/ovl_En_Hit_Tag_reloc.o"
endseg
beginseg

View File

@ -14,9 +14,8 @@ void EnHitTag_Init(Actor* thisx, GlobalContext* globalCtx);
void EnHitTag_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnHitTag_Update(Actor* thisx, GlobalContext* globalCtx);
void func_80BE20E8(EnHitTag* this, GlobalContext* globalCtx);
void EnHitTag_WaitForHit(EnHitTag* this, GlobalContext* globalCtx);
#if 0
const ActorInit En_Hit_Tag_InitVars = {
ACTOR_EN_HIT_TAG,
ACTORCAT_ITEMACTION,
@ -29,21 +28,65 @@ const ActorInit En_Hit_Tag_InitVars = {
(ActorFunc)NULL,
};
// static ColliderCylinderInit sCylinderInit = {
static ColliderCylinderInit D_80BE21F0 = {
{ COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_CYLINDER, },
{ ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, },
static ColliderCylinderInit sCylinderInit = {
{
COLTYPE_NONE,
AT_NONE,
AC_ON | AC_TYPE_PLAYER,
OC1_ON | OC1_TYPE_PLAYER,
OC2_TYPE_1,
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0xF7CFFFFF, 0x00, 0x00 },
TOUCH_NONE | TOUCH_SFX_NORMAL,
BUMP_ON,
OCELEM_NONE,
},
{ 16, 32, 0, { 0, 0, 0 } },
};
#endif
void EnHitTag_Init(Actor* thisx, GlobalContext* globalCtx) {
s32 pad;
EnHitTag* this = THIS;
extern ColliderCylinderInit D_80BE21F0;
Actor_SetScale(&this->actor, 1.0f);
this->actionFunc = EnHitTag_WaitForHit;
Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit);
Collider_UpdateCylinder(&this->actor, &this->collider);
if (Flags_GetSwitch(globalCtx, ENHITTAG_GET_SWITCHFLAG(thisx))) {
Actor_MarkForDeath(&this->actor);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hit_Tag/EnHitTag_Init.s")
void EnHitTag_Destroy(Actor* thisx, GlobalContext* globalCtx) {
EnHitTag* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hit_Tag/EnHitTag_Destroy.s")
Collider_DestroyCylinder(globalCtx, &this->collider);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hit_Tag/func_80BE20E8.s")
void EnHitTag_WaitForHit(EnHitTag* this, GlobalContext* globalCtx) {
Vec3f dropLocation;
s32 i;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hit_Tag/EnHitTag_Update.s")
if (this->collider.base.acFlags & AC_HIT) {
play_sound(NA_SE_SY_GET_RUPY);
Actor_MarkForDeath(&this->actor);
dropLocation.x = this->actor.world.pos.x;
dropLocation.y = this->actor.world.pos.y;
dropLocation.z = this->actor.world.pos.z;
for (i = 0; i < 3; i++) {
Item_DropCollectible(globalCtx, &dropLocation, ITEM00_RUPEE_GREEN);
}
} else {
CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
}
}
void EnHitTag_Update(Actor* thisx, GlobalContext* globalCtx) {
EnHitTag* this = THIS;
this->actionFunc(this, globalCtx);
}

View File

@ -7,9 +7,11 @@ struct EnHitTag;
typedef void (*EnHitTagActionFunc)(struct EnHitTag*, GlobalContext*);
#define ENHITTAG_GET_SWITCHFLAG(thisx) (s32)(((thisx)->params & 0xFE00) >> 9)
typedef struct EnHitTag {
/* 0x0000 */ Actor actor;
/* 0x0144 */ char unk_144[0x4C];
/* 0x0144 */ ColliderCylinder collider;
/* 0x0190 */ EnHitTagActionFunc actionFunc;
} EnHitTag; // size = 0x194

View File

@ -16068,7 +16068,7 @@
0x80BE1E9C:("EnNimotsu_Draw",),
0x80BE2030:("EnHitTag_Init",),
0x80BE20BC:("EnHitTag_Destroy",),
0x80BE20E8:("func_80BE20E8",),
0x80BE20E8:("EnHitTag_WaitForHit",),
0x80BE21A0:("EnHitTag_Update",),
0x80BE2260:("func_80BE2260",),
0x80BE2330:("func_80BE2330",),