Skip to content

Commit

Permalink
label contact flags
Browse files Browse the repository at this point in the history
  • Loading branch information
hytopoulos committed Dec 31, 2023
1 parent bd1be09 commit 5049daa
Show file tree
Hide file tree
Showing 96 changed files with 142 additions and 128 deletions.
10 changes: 10 additions & 0 deletions include/collision.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@

/** Collisions. */

enum {
COL_LANTERN = 0x7,
COL_SMALL_GUST = 0x13,
COL_BOOMERANG = 0x14,
COL_ARROW = 0x15,
COL_BIG_GUST = 0x1b,
COL_PACCI = 0x1d,
COL_SWORD_BEAM = 0x21,
};

typedef enum {
COL_NONE = 0x0,
COL_NORTH_WEST = 0x2,
Expand Down
2 changes: 2 additions & 0 deletions include/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ typedef enum {
DirectionNorthWest = 0x1c, /**< North West. */
} Direction;

#define CONTACT_TAKE_DAMAGE 0x80

typedef struct {
void* entity1;
void* entity2;
Expand Down
4 changes: 2 additions & 2 deletions src/collision.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ CollisionResult CollisionNoOp(Entity* org, Entity* tgt, u32 direction, ColSettin
// target: item
CollisionResult CollisionGroundItem(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
COLLISION_OFF(tgt);
tgt->contactFlags = org->hurtType | 0x80;
tgt->contactFlags = org->hurtType | CONTACT_TAKE_DAMAGE;
if ((tgt->type == 0x5F || tgt->type == 0x60) && sub_08081420(tgt))
tgt->health = 0;
return RESULT_COLLISION_WITHOUT_SET;
Expand Down Expand Up @@ -503,7 +503,7 @@ CollisionResult sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSetting
sub_08079D84();
org->iframes = 90;
} else {
gPlayerEntity.base.contactFlags = tgt->hurtType | 0x80;
gPlayerEntity.base.contactFlags = tgt->hurtType | CONTACT_TAKE_DAMAGE;
gPlayerEntity.base.iframes = 12;
gPlayerEntity.base.knockbackDuration = 16;
gPlayerEntity.base.knockbackDirection = DirectionTurnAround(direction);
Expand Down
2 changes: 1 addition & 1 deletion src/enemy/acroBandits.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void AcroBandit_OnTick(AcroBanditEntity* this) {
void AcroBandit_OnCollision(AcroBanditEntity* this) {
Entity* brother;

if (super->contactFlags != 0x80 && super->contactFlags != 0x81) {
if (super->contactFlags != CONTACT_TAKE_DAMAGE && super->contactFlags != (CONTACT_TAKE_DAMAGE | 0x1)) {
if (super->type == 1) {
if (super->action < 7 && super->knockbackDuration != 0) {
brother = super->child;
Expand Down
2 changes: 1 addition & 1 deletion src/enemy/armos.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ bool32 sub_080305BC(ArmosEntity* this) {

bool32 sub_08030650(ArmosEntity* this) {
if (super->type == 0) {
if (super->contactFlags == 0x80) {
if (super->contactFlags == CONTACT_TAKE_DAMAGE) {
return 1;
}
} else if (this->unk_80 != 2) {
Expand Down
4 changes: 2 additions & 2 deletions src/enemy/beetle.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void Beetle_OnTick(BeetleEntity* this) {

void Beetle_OnCollision(BeetleEntity* this) {
switch (super->contactFlags) {
case 0x80:
case CONTACT_TAKE_DAMAGE:
if (gPlayerState.framestate == PL_STATE_CLIMB) {
Beetle_OnTick(this);
} else {
Expand All @@ -50,7 +50,7 @@ void Beetle_OnCollision(BeetleEntity* this) {
InitializeAnimation(super, 6);
}
break;
case 0x93:
case CONTACT_TAKE_DAMAGE | 0x13:
Beetle_OnTick(this);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/enemy/bobomb.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void Bobomb_OnTick(BobombEntity* this) {
}

void Bobomb_OnCollision(BobombEntity* this) {
if (super->contactFlags & 0x80) {
if (super->contactFlags & CONTACT_TAKE_DAMAGE) {
switch (super->contactFlags & 0x7f) {
case 0:
case 1:
Expand Down
2 changes: 1 addition & 1 deletion src/enemy/bowMoblin.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void BowMoblin_OnCollision(BowMoblinEntity* this) {
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, (EntityActionArray)BowMoblin_Functions);
if ((super->contactFlags & 0x80) != 0) {
if (super->contactFlags & CONTACT_TAKE_DAMAGE) {
sub_0803C5F0(this);
pEVar1 = super->child;
if (pEVar1 != NULL) {
Expand Down
2 changes: 1 addition & 1 deletion src/enemy/chaser.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void sub_0802B540(Entity* this) {

void sub_0802B56C(Entity* this) {
GetNextFrame(this);
if (this->contactFlags & 0x80) {
if (this->contactFlags & CONTACT_TAKE_DAMAGE) {
this->speed = 0x40;
}

Expand Down
4 changes: 2 additions & 2 deletions src/enemy/chuchuBoss.c
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ void sub_080272D4(ChuchuBossEntity* this) {
super->hitbox->height = (u32)((0x10000 / this->unk_74.HALF_U.HI) * 5) >> 6;
if (*(char*)&this->unk_84 == 0)
break;
if ((super->contactFlags & 0x80) != 0) {
if (super->contactFlags & CONTACT_TAKE_DAMAGE) {
if (super->iframes != 0) {
((ChuchuBossEntity*)super->child)->unk_68->base.iframes = super->iframes;
super->child->parent->iframes = super->iframes;
Expand Down Expand Up @@ -1697,7 +1697,7 @@ bool32 sub_08027AA4(ChuchuBossEntity* this) {
s32 iVar4;
Helper* pHelper;

if ((super->contactFlags & 0x80) == 0) {
if ((super->contactFlags & CONTACT_TAKE_DAMAGE) == 0) {
return FALSE;
}
switch (super->contactFlags & 0x7f) {
Expand Down
2 changes: 1 addition & 1 deletion src/enemy/cloudPiranha.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void CloudPiranha_OnCollision(CloudPiranhaEntity* this) {
EnemyCreateFX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, gUnk_080CF4F0);
if ((super->contactFlags & 0x80) != 0) {
if (super->contactFlags & CONTACT_TAKE_DAMAGE) {
if (super->hitType == 0x5a) {
switch (super->contactFlags & 0x3f) {
case 0x14:
Expand Down
2 changes: 1 addition & 1 deletion src/enemy/crow.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void Crow_OnTick(CrowEntity* this) {
}

void Crow_OnCollision(CrowEntity* this) {
if (super->contactFlags & 0x80) {
if (super->contactFlags & CONTACT_TAKE_DAMAGE) {
if ((super->contactFlags & 0x3f) == 0) {
COLLISION_OFF(super);
super->subtimer = 16;
Expand Down
3 changes: 2 additions & 1 deletion src/enemy/darkNut.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ void sub_080210E4(DarkNutEntity* this) {
}

sub_08021644(this);
if ((super->frame & 0x10) && (!ProcessMovement0(super) || (super->child && (super->child->contactFlags & 0x80)))) {
if ((super->frame & 0x10) &&
(!ProcessMovement0(super) || (super->child && (super->child->contactFlags & CONTACT_TAKE_DAMAGE)))) {
sub_080213D0(this, 0);
} else {
if (--this->unk_76 == 0)
Expand Down
8 changes: 4 additions & 4 deletions src/enemy/enemy50.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ void Enemy50_OnCollision(Enemy50Entity* this) {
sub_08041134(this);
sub_0803F6EC(this);
}
if (super->hitType == 0x25 && super->contactFlags == 0x80) {
if (super->hitType == 0x25 && super->contactFlags == CONTACT_TAKE_DAMAGE) {
super->action = 8;
InitializeAnimation(super, 3);
} else {
if (super->contactFlags == 0x80) {
if (super->contactFlags == CONTACT_TAKE_DAMAGE) {
this->unk_7c = 0x78;
sub_08041128(this);
}
if (super->contactFlags == 0x9d) {
if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) {
super->zVelocity = Q_16_16(1.5);
}
if (super->confusedTime != 0) {
Expand Down Expand Up @@ -422,7 +422,7 @@ void sub_0804122C(Enemy50Entity* this) {

#ifndef EU
bool32 sub_08041300(Enemy50Entity* this) {
if ((super->hitType == 0x25) && (super->contactFlags == 0x80)) {
if ((super->hitType == 0x25) && (super->contactFlags == CONTACT_TAKE_DAMAGE)) {
return TRUE;
} else {
return super->action == 8 || super->action == 9;
Expand Down
6 changes: 3 additions & 3 deletions src/enemy/eyegore.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ void Eyegore_OnTick(EyegoreEntity* this) {
void Eyegore_OnCollision(EyegoreEntity* this) {
u32 tmp;

if ((super->contactFlags == 0x95) || (super->contactFlags == 0x8e)) {
if ((super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x15)) || (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xe))) {
Entity* entity = super->contactedEntity;
tmp = (((entity->direction + 4) & 0x18) ^ 0x10) >> 3;
if (tmp == super->animationState) {
if ((tmp & 1) != 0) {
if (0x10 < ((entity->y.HALF.HI + entity->z.HALF.HI) - (super->y.HALF.HI + super->z.HALF.HI)) + 0x14U) {
} else {
if (super->contactFlags == 0x8e) {
if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xe)) {
super->health = 0;
} else {
super->health--;
Expand All @@ -105,7 +105,7 @@ void Eyegore_OnCollision(EyegoreEntity* this) {
EnqueueSFX(SFX_BUTTON_PRESS);
sub_08031344(this);
} else {
if (super->contactFlags == 0x8e) {
if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xe)) {
super->health = 0;
} else {
super->health--;
Expand Down
2 changes: 1 addition & 1 deletion src/enemy/flyingPot.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void FlyingPot_OnTick(FlyingPotEntity* this) {
void FlyingPot_OnCollision(FlyingPotEntity* this) {
sub_08037418(this);

if (super->contactFlags == 0x9D) {
if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) {
super->action = FLYING_POT_ACTION_6;
COLLISION_OFF(super);
super->zVelocity = Q_16_16(2.625);
Expand Down
2 changes: 1 addition & 1 deletion src/enemy/flyingSkull.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void FlyingSkull_OnTick(FlyingSkullEntity* this) {
void FlyingSkull_OnCollision(FlyingSkullEntity* this) {
sub_0803A100(this);

if (super->contactFlags == 0x9d) {
if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) {
super->action = 7;
COLLISION_OFF(super);
super->zVelocity = Q_16_16(2.625);
Expand Down
4 changes: 2 additions & 2 deletions src/enemy/ghini.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ void Ghini_OnCollision(GhiniEntity* this) {
sub_0803F630(this);
sub_0803F6EC(this);
}
if ((super->hitType == 0x25) && (super->contactFlags == 0x80)) {
if ((super->hitType == 0x25) && (super->contactFlags == CONTACT_TAKE_DAMAGE)) {
super->action = 8;
InitializeAnimation(super, 3);
} else {
if (super->contactFlags == 0x9d) {
if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1d)) {
super->zVelocity = 0x18000;
}
if (super->confusedTime != 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/enemy/gibdo.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void Gibdo_OnTick(GibdoEntity* this) {
}

void Gibdo_OnCollision(GibdoEntity* this) {
if (super->contactFlags == 0x87) {
if (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x7)) {
if (super->action == 0x6) {
sub_08037ACC(this);
}
Expand All @@ -62,7 +62,7 @@ void Gibdo_OnCollision(GibdoEntity* this) {
Gibdo_CreateObjects(this);
} else {
if (super->action != 0x6) {
if (super->hitType == 0x27 && super->contactFlags == 0x80) {
if (super->hitType == 0x27 && super->contactFlags == CONTACT_TAKE_DAMAGE) {
sub_08037A14(this);
} else {
if ((u8)(super->action - 1) < 2) {
Expand Down
4 changes: 2 additions & 2 deletions src/enemy/gleerok.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ void sub_0802D86C(GleerokEntity* this) {
}
}

if ((super->contactFlags & 0x80) && this->unk_74 == 0) {
if ((super->contactFlags & CONTACT_TAKE_DAMAGE) && this->unk_74 == 0) {
if ((super->contactFlags & 0x7f) == 0x1d) {
super->zVelocity = Q_16_16(3.0);
super->parent->subAction = 4;
Expand Down Expand Up @@ -1039,7 +1039,7 @@ void sub_0802E0B8(GleerokEntity* this) {
super->type2 = 4;
InitializeAnimation(super, 0x4e);
} else {
if (super->contactFlags & 0x80) {
if (super->contactFlags & CONTACT_TAKE_DAMAGE) {
if (super->iframes > 0) {
SoundReq(SFX_BOSS_HIT);
}
Expand Down
2 changes: 1 addition & 1 deletion src/enemy/hangingSeed.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void HangingSeed_OnTick(Entity* this) {
}

void HangingSeed_OnCollision(Entity* this) {
if (this->contactFlags & 0x80) {
if (this->contactFlags & CONTACT_TAKE_DAMAGE) {
CreateFx(this, FX_BUSH, 0x80);
DeleteThisEntity();
}
Expand Down
2 changes: 1 addition & 1 deletion src/enemy/keaton.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void Keaton_Action3(KeatonEntity* this) {
}

void Keaton_Action4(KeatonEntity* this) {
if (super->child && (super->child->contactFlags & 0x80)) {
if (super->child && (super->child->contactFlags & CONTACT_TAKE_DAMAGE)) {
sub_0803275C(this);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/enemy/leever.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void Leever_OnTick(LeeverEntity* this) {
}

void Leever_OnCollision(LeeverEntity* this) {
if (super->contactFlags == 0x80) {
if (super->contactFlags == CONTACT_TAKE_DAMAGE) {
if (super->action == 3) {
this->unk_74 = 1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/enemy/likeLike.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ void LikeLike_OnCollision(LikeLikeEntity* this) {
} else {
if (super->action == 7) {
LikeLike_ReleasePlayer(this);
} else if (super->contactFlags & 0x80) {
u8 tmp = super->contactFlags & ~0x80;
} else if (super->contactFlags & CONTACT_TAKE_DAMAGE) {
u8 tmp = super->contactFlags & ~CONTACT_TAKE_DAMAGE;
if (tmp == 0) {
super->action = 7;
super->timer = 95;
Expand Down
4 changes: 2 additions & 2 deletions src/enemy/madderpillar.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ void sub_0802A098(MadderpillarEntity* this) {

void sub_0802A0F8(MadderpillarEntity* this) {
if (super->health != 0) {
if ((super->contactFlags & 0x80) && super->iframes != 0) {
if ((super->contactFlags & CONTACT_TAKE_DAMAGE) && super->iframes != 0) {
Entity* entity = super;
u32 i;
for (i = 0; i < 6; i++) {
Expand Down Expand Up @@ -549,7 +549,7 @@ void sub_0802A16C(MadderpillarEntity* this) {
}

void sub_0802A18C(MadderpillarEntity* this) {
if (super->contactFlags & 0x80) {
if (super->contactFlags & CONTACT_TAKE_DAMAGE) {
switch (super->contactFlags & 0x7f) {
case 0:
case 1:
Expand Down
4 changes: 2 additions & 2 deletions src/enemy/mazaalBracelet.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void MazaalBracelet_OnCollision(MazaalBraceletEntity* this) {

if (super->type < 2) {
if (super->action != 0x2b) {
if ((0 < super->iframes) && ((super->contactFlags == 0x95 || (super->contactFlags == 0x8e)))) {
if ((0 < super->iframes) && ((super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x15) || (super->contactFlags == (CONTACT_TAKE_DAMAGE | 0xe))))) {
super->action = 0x28;
COLLISION_OFF(super);
entity = (MazaalBraceletEntity*)super->parent;
Expand Down Expand Up @@ -1299,7 +1299,7 @@ u32 sub_0803B870(MazaalBraceletEntity* this) {
Entity* entity;

entity = super->child;
if ((entity->contactFlags & 0x80) != 0 && (gPlayerState.flags & PL_CAPTURED)) {
if ((entity->contactFlags & CONTACT_TAKE_DAMAGE) != 0 && (gPlayerState.flags & PL_CAPTURED)) {
super->action = 0x18;
super->timer = 68;
super->spriteSettings.draw = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/enemy/moldworm.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void Moldworm_OnCollision(MoldwormEntity* this) {
super->iframes = -8;
this->unk_7f = 0;
this->unk_7b = 0;
if (super->contactFlags == 0x80 || super->contactFlags == 0x9e) {
if (super->contactFlags == CONTACT_TAKE_DAMAGE || super->contactFlags == (CONTACT_TAKE_DAMAGE | 0x1e)) {
super->type2 = 0;
this->unk_80 = 0x14;
} else {
Expand Down Expand Up @@ -441,15 +441,15 @@ void sub_08023894(MoldwormEntity* this) {
}

void sub_0802390C(MoldwormEntity* this) {
if (super->contactFlags & 0x80) {
if (super->contactFlags & CONTACT_TAKE_DAMAGE) {
Entity* ent = super->child;
do {
ent->iframes = super->iframes;
} while (ent = ent->child, ent != NULL);
} else {
Entity* ent = super->child;
do {
if (ent->contactFlags & 0x80) {
if (ent->contactFlags & CONTACT_TAKE_DAMAGE) {
u8 bVar2 = 0xff - ent->health;
if (bVar2 != 0) {
u32 tmp;
Expand Down
2 changes: 1 addition & 1 deletion src/enemy/mulldozer.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void Mulldozer_OnCollision(MulldozerEntity* this) {
EnemyCreateFX(super, 0x1c);
}
EnemyFunctionHandlerAfterCollision(super, Mulldozer_Functions);
if ((super->contactFlags & 0x80) != 0) {
if ((super->contactFlags & CONTACT_TAKE_DAMAGE) != 0) {
switch (super->contactFlags & 0x3f) {
case 2:
case 3:
Expand Down
Loading

0 comments on commit 5049daa

Please sign in to comment.