diff options
| author | octorock <79596758+octorock@users.noreply.github.com> | 2023-12-28 14:59:23 +0100 |
|---|---|---|
| committer | octorock <79596758+octorock@users.noreply.github.com> | 2023-12-28 14:59:23 +0100 |
| commit | 768efa50b308be03737d7eae2a1069627ea48b79 (patch) | |
| tree | 447c266172ef82df68bfd6d4737acb499f2b1a9d /src/enemy | |
| parent | b6a94d5062076ce53a00609e1e661b9da9e7ee5b (diff) | |
| parent | dae4c669913c3dc4248291f2d843ac39525b2738 (diff) | |
Merge branch 'master' into tilemap-docs
Diffstat (limited to 'src/enemy')
46 files changed, 287 insertions, 275 deletions
diff --git a/src/enemy/acroBandits.c b/src/enemy/acroBandits.c index 072ca4e0..67e7ad64 100644 --- a/src/enemy/acroBandits.c +++ b/src/enemy/acroBandits.c @@ -445,7 +445,7 @@ void AcroBandit_Type1Action4(Entity* this) { } } - if (this->direction & 0xf) + if (this->direction & (0x3 | DirectionEast | DIR_DIAGONAL)) this->spriteSettings.flipX = (this->direction >> 4 ^ 1); ProcessMovement0(this); @@ -486,7 +486,7 @@ void AcroBandit_Type1Action6(Entity* this) { this->action = 7; dir = fallDirections[this->field_0x74.HALF.LO * 5 + this->type2]; this->direction = dir; - if (dir >= 0x10) { + if (dir >= DirectionSouth) { this->spriteSettings.flipX = 1; } else { this->spriteSettings.flipX = 0; @@ -570,7 +570,7 @@ static void sub_080322E8(Entity* this) { } } else { u8 tmp = this->direction; - if (tmp & 0xF) { + if (tmp & (0x3 | DirectionEast | DIR_DIAGONAL)) { tmp >>= 4; tmp ^= 1; if (tmp != this->spriteSettings.flipX) { diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c index ace73b7f..451d9aea 100644 --- a/src/enemy/beetle.c +++ b/src/enemy/beetle.c @@ -105,7 +105,8 @@ void sub_080218CC(Entity* this) { if (this->subAction == 0) { this->subAction = 1; this->spriteSettings.draw = 1; - this->direction = ((sub_08049F84(this, 1) ^ 0x10) + gUnk_080CB5DC[Random() & 7]) & 0x1f; + this->direction = ((sub_08049F84(this, 1) ^ 0x10) + gUnk_080CB5DC[Random() & 7]) & + (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest); this->speed = 0x100; this->zVelocity = Q_16_16(1.125); } @@ -244,9 +245,9 @@ void sub_08021B64(Entity* this) { this->zVelocity = Q_16_16(1.0); ((u8*)&this->field_0x86)[1] = 0; if (gPlayerEntity.direction != 0xff) { - this->direction = 0x10 ^ gPlayerEntity.direction; + this->direction = DirectionSouth ^ gPlayerEntity.direction; } else { - this->direction = (gPlayerEntity.animationState << 2) ^ 0x10; + this->direction = (gPlayerEntity.animationState << 2) ^ DirectionSouth; } InitializeAnimation(this, 5); } else { diff --git a/src/enemy/bladeTrap.c b/src/enemy/bladeTrap.c index 86fe70d0..5f8306bd 100644 --- a/src/enemy/bladeTrap.c +++ b/src/enemy/bladeTrap.c @@ -10,18 +10,20 @@ #include "room.h" #include "object.h" +#define DIR_NOT_MOVING_CHECK 0x80 + void BladeTrap(Entity* this) { if (this->action == 0) { this->action = 1; this->child = GetCurrentRoomProperty(this->type); UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD); } - if (!(this->direction & 0x80)) { + if (!(this->direction & DIR_NOT_MOVING_CHECK)) { LinearMoveUpdate(this); } if (!(--this->field_0x74.HWORD)) { - if (!(this->direction & 0x80)) { + if (!(this->direction & DIR_NOT_MOVING_CHECK)) { EnqueueSFX(SFX_METAL_CLINK); } UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD); diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c index bfc8f092..ad7ceff0 100644 --- a/src/enemy/bobomb.c +++ b/src/enemy/bobomb.c @@ -62,7 +62,7 @@ void Bobomb_OnCollision(Entity* this) { this->zVelocity = Q_16_16(1.5); this->speed = 0; this->field_0x80.HALF.HI = 1; - InitializeAnimation(this, this->direction >> 4 | 6); + InitializeAnimation(this, this->direction >> 4 | IdleWest); break; } } @@ -123,7 +123,7 @@ void sub_0802C83C(Entity* this) { } else { this->field_0x82.HALF.LO = 2; this->timer = 120; - InitializeAnimation(this, (this->direction >> 4) | 6); + InitializeAnimation(this, (this->direction >> 4) | IdleWest); COLLISION_OFF(this); this->hitType = 0x6e; } @@ -147,7 +147,7 @@ void sub_0802C8D8(Entity* this) { this->action = 1; this->timer = 60; this->subtimer = 0; - this->direction = (Random() & 0x18) | 4; + this->direction = (Random() & 0x18) | DIR_DIAGONAL; this->carryFlags = 0; this->gustJarFlags = 0x12; this->field_0x82.HALF.LO = 0; @@ -163,7 +163,7 @@ void sub_0802C91C(Entity* this) { if (this->field_0x82.HALF.LO) { if (this->collisions != COL_NONE) { sub_0800417E(this, this->collisions); - InitializeAnimation(this, (this->direction >> 4) | 2); + InitializeAnimation(this, (this->direction >> 4) | IdleEast); } if (--this->timer == 0) { sub_0802CBC4(this); @@ -180,7 +180,7 @@ void sub_0802C91C(Entity* this) { } if (--this->timer == 0) { this->timer = 60; - this->direction = (this->direction + 8) & 0x1c; + this->direction = (this->direction + 8) & (DirectionWest | DIR_DIAGONAL); InitializeAnimation(this, this->direction >> 4); } } @@ -196,7 +196,7 @@ void sub_0802C9D0(Entity* this) { this->spritePriority.b1 = 0; this->field_0x82.HALF.HI = 1; sub_0802CC18(this); - InitializeAnimation(this, (this->direction >> 4) | 6); + InitializeAnimation(this, (this->direction >> 4) | IdleWest); GetNextFrame(this); } @@ -210,7 +210,7 @@ void sub_0802CA10(Entity* this) { } } else { this->field_0x82.HALF.HI = 2; - this->direction = (((gPlayerEntity.animationState) << 2) | 4) & 0x1c; + this->direction = (((gPlayerEntity.animationState) << 2) | IdleSouth) & (DIR_DIAGONAL | DirectionWest); sub_0802CC18(this); GetNextFrame(this); } @@ -234,8 +234,8 @@ void sub_0802CA94(Entity* this) { this->speed = 0; this->field_0x82.HALF.HI = 0; this->field_0x80.HALF.HI = 0; - this->direction = ((gPlayerEntity.animationState << 2) | 4) & 0x1c; - InitializeAnimation(this, (this->direction >> 4) | 6); + this->direction = ((gPlayerEntity.animationState << 2) | IdleSouth) & (DirectionWest | DIR_DIAGONAL); + InitializeAnimation(this, (this->direction >> 4) | IdleWest); } void sub_0802CAF8(Entity* this) { @@ -264,7 +264,7 @@ void sub_0802CB68(Entity* this) { this->action = 1; this->subAction = 0; this->direction = Random() & 0x18; - this->direction |= 4; + this->direction |= IdleSouth; COLLISION_ON(this); if (this->field_0x82.HALF.LO) { this->timer = 200; diff --git a/src/enemy/bombPeahat.c b/src/enemy/bombPeahat.c index c8d4a14b..939fcf13 100644 --- a/src/enemy/bombPeahat.c +++ b/src/enemy/bombPeahat.c @@ -141,10 +141,10 @@ void sub_0802A9A8(Entity* this) { this->field_0x82.HWORD = 1; if (this->field_0x80.HALF.LO) { this->x.HALF.HI = gRoomControls.scroll_x - 0x10; - this->direction = 8; + this->direction = DirectionEast; } else { this->x.HALF.HI = gRoomControls.scroll_x + 0x100; - this->direction = 0x18; + this->direction = DirectionWest; } this->y.HALF.HI = gRoomControls.scroll_y + 0x40; this->timer = 128; @@ -221,7 +221,7 @@ void sub_0802AAC0(Entity* this) { #ifndef EU this->field_0x78.HALF.LO = 0; this->field_0x78.HALF.HI = 4; - this->direction = 0xff; + this->direction = DIR_NONE; #endif InitializeAnimation(this, 0); } diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index cce55c43..e87d5588 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -25,14 +25,14 @@ void sub_08029078(Entity*); void sub_080290E0(Entity*, u32); void sub_080290FC(Entity*); bool32 sub_0802915C(Entity*); -bool32 sub_080291DC(Entity*); +bool32 BusinessScrub_CheckRefillFitsBag(Entity*); void sub_0802922C(Entity*); void sub_0802925C(Entity*); extern const struct SalesOffering gUnk_080CC954[]; extern const u8 kinstoneTypes[]; extern void (*const BusinessScrub_Functions[])(Entity*); -extern void (*const gUnk_080CC9E0[])(Entity*); +extern void (*const BusinessScrub_Actions[])(Entity*); extern const u8 gUnk_080CCA04[]; struct SalesOffering { @@ -42,8 +42,8 @@ struct SalesOffering { u16 field_0x4; u16 field_0x6; u8 offeredItem; /**< @see Item */ - u8 field_0x9; - u16 field_0xa; + u8 item_subtype; + u16 local_flag; }; void BusinessScrub(Entity* this) { @@ -51,7 +51,7 @@ void BusinessScrub(Entity* this) { } void BusinessScrub_OnTick(Entity* this) { - gUnk_080CC9E0[this->action](this); + BusinessScrub_Actions[this->action](this); } void BusinessScrub_OnCollision(Entity* this) { @@ -75,12 +75,12 @@ void BusinessScrub_OnGrabbed(Entity* this) { /* ... */ } -void sub_08028994(Entity* this) { +void BusinessScrub_Action0(Entity* this) { this->subtimer = 0; this->field_0x78.HWORD = this->x.HALF.HI; this->field_0x7a.HWORD = this->y.HALF.HI; this->animationState = 0; - this->direction = 0x10; + this->direction = DirectionSouth; sub_08028E9C(this); if ((*(u8*)this->field_0x7c.WORD & 1) || CheckFlags(this->field_0x86.HWORD)) { this->action = 4; @@ -97,7 +97,7 @@ void sub_08028994(Entity* this) { } } -void sub_08028A48(Entity* this) { +void BusinessScrub_Action1(Entity* this) { if (this->timer != 0) { this->timer--; } else if (sub_08028F98(this, 0)) { @@ -107,7 +107,7 @@ void sub_08028A48(Entity* this) { } } -void sub_08028A74(Entity* this) { +void BusinessScrub_Action2(Entity* this) { u32 unk; GetNextFrame(this); @@ -185,7 +185,7 @@ void sub_08028A74(Entity* this) { } } -void sub_08028BC4(Entity* this) { +void BusinessScrub_Action3(Entity* this) { Entity* iVar1; switch (this->subAction) { @@ -227,7 +227,7 @@ void sub_08028BC4(Entity* this) { extern void sub_0804AA1C(Entity*); void sub_08028F0C(Entity*); -void sub_08028C84(Entity* this) { +void BusinessScrub_Action4(Entity* this) { if (--this->timer == 0) { this->timer = 48; if (this->subtimer) { @@ -244,21 +244,21 @@ void sub_08028C84(Entity* this) { sub_08028F0C(this); } -void sub_08028CE8(Entity* this) { +void BusinessScrub_Action5(Entity* this) { struct SalesOffering* offer = (struct SalesOffering*)this->field_0x7c.WORD; u32 subtype; if ((gMessage.doTextBox & 0x7f) == 0 && sub_0802915C(this) && !sub_08056338()) { if (offer->price <= gSave.stats.rupees) { - if (sub_080291DC(this)) { + if (BusinessScrub_CheckRefillFitsBag(this)) { /* Bag full. */ MessageFromTarget(TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x04)); SetPlayerControl(0); } else { ModRupees(-offer->price); switch (offer->field_0x0 >> 2) { - case 0: - subtype = offer->field_0x9; + case 0: // random kinstone + subtype = offer->item_subtype; if (subtype == KINSTONE_RANDOM) { subtype = kinstoneTypes[Random() & 7]; } @@ -273,13 +273,13 @@ void sub_08028CE8(Entity* this) { SetLocalFlag(KS_B06); #endif return; - case 1: - CreateItemEntity(offer->offeredItem, offer->field_0x9, 0); + case 1: // refill, bottle, specific kinstone + CreateItemEntity(offer->offeredItem, offer->item_subtype, 0); this->timer = 4; sub_0802922C(this); return; - case 2: - CreateItemEntity(offer->offeredItem, offer->field_0x9, 0); + case 2: // grip ring + CreateItemEntity(offer->offeredItem, offer->item_subtype, 0); this->timer = 8; sub_0802922C(this); return; @@ -298,7 +298,7 @@ void sub_08028CE8(Entity* this) { sub_080290E0(this, 0); } -void sub_08028DE8(Entity* this) { +void BusinessScrub_Action6(Entity* this) { if (gPlayerEntity.action == PLAYER_ITEMGET) { if (this->field_0x80.HALF.HI == 0) { SetPlayerControl(1); @@ -316,15 +316,15 @@ void sub_08028DE8(Entity* this) { } } -void sub_08028E40(Entity* this) { +void BusinessScrub_Action7(Entity* this) { if ((gMessage.doTextBox & 0x7f) == 0) { struct SalesOffering* offer = (struct SalesOffering*)this->field_0x7c.WORD; this->action = 4; this->subAction = gMessage.doTextBox & 0x7f; this->timer = 1; - if (CheckLocalFlag(offer->field_0xa) == 0) { - SetLocalFlag(offer->field_0xa); + if (!CheckLocalFlag(offer->local_flag)) { + SetLocalFlag(offer->local_flag); } SetPlayerControl(0); } @@ -332,7 +332,7 @@ void sub_08028E40(Entity* this) { GetNextFrame(this); } -void sub_08028E84(Entity* this) { +void BusinessScrub_Action8(Entity* this) { if (UpdateFuseInteraction(this)) { this->action = 4; this->timer = 1; @@ -344,7 +344,7 @@ bool32 sub_08029198(const struct SalesOffering*); void sub_08028E9C(Entity* this) { const struct SalesOffering* offer = &gUnk_080CC954[this->type]; if (sub_08029198(offer) && (offer->field_0x0 & 2)) { - offer = &gUnk_080CC954[offer->field_0xa]; + offer = &gUnk_080CC954[offer->local_flag]; } this->field_0x7c.WORD = (u32)offer; this->field_0x80.HALF.LO = 0; @@ -353,21 +353,21 @@ void sub_08028E9C(Entity* this) { void sub_08028EDC(Entity* this) { const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD; if (sub_08029198(offer) && (offer->field_0x0 & 2)) { - offer = &gUnk_080CC954[offer->field_0xa]; + offer = &gUnk_080CC954[offer->local_flag]; this->field_0x7c.WORD = (u32)offer; } } void sub_08028F0C(Entity* this) { - if (this->interactType == 2) { + if (this->interactType == INTERACTION_FUSE) { this->action = 8; - this->interactType = 0; - sub_0806F118(this); - } else if (this->interactType != 0) { + this->interactType = INTERACTION_NONE; + InitializeNPCFusion(this); + } else if (this->interactType != INTERACTION_NONE) { u16 dialog; const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD; - this->interactType = 0; + this->interactType = INTERACTION_NONE; sub_0804AA1C(this); this->direction = (GetAnimationState(this) << 3); sub_080290E0(this, 3); @@ -456,8 +456,8 @@ void sub_080290FC(Entity* this) { if (this->timer != 0) { this->timer--; if ((this->timer < 16) && ((this->timer & 1) == 0)) { - s32 sVar3 = ((this->direction & 0x10) != 0) ? -1 : 1; - if ((this->direction & 8) != 0) { + s32 sVar3 = (this->direction & DirectionSouth) ? -1 : 1; + if (this->direction & DirectionEast) { this->x.HALF.HI += ((this->timer & 8) != 0) ? -sVar3 : sVar3; } else { this->y.HALF.HI += ((this->timer & 8) != 0) ? sVar3 : -sVar3; @@ -502,7 +502,7 @@ bool32 sub_08029198(const struct SalesOffering* offer) { return 0; } } else { - tmp = CheckLocalFlag(offer->field_0xa); + tmp = CheckLocalFlag(offer->local_flag); } if (tmp == 0) { @@ -512,7 +512,7 @@ bool32 sub_08029198(const struct SalesOffering* offer) { return TRUE; } -bool32 sub_080291DC(Entity* this) { +bool32 BusinessScrub_CheckRefillFitsBag(Entity* this) { const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD; switch (offer->offeredItem) { @@ -540,7 +540,7 @@ void sub_0802922C(Entity* this) { SetGlobalFlag(AKINDO_BOTTLE_SELL); // It only matters here that ITEM_BOMBS10 is here and some item that is higher // Not sure about the original code - case ITEM_ARROWS10: + case ITEM_ARROWS30: case ITEM_BOMBS10: default: sub_080290E0(this, 3); @@ -564,18 +564,18 @@ void sub_08029270(Entity* this) { // clang-format off const struct SalesOffering gUnk_080CC954[] = { - {0x06, 0x00, 0xffff, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x0f), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x02), 0x09, 0xff, 0x0001}, - {0x04, 0x00, 0x001e, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x0e), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x02), 0x6f, 0xff, 0xffff}, - {0x04, 0x00, 0x001e, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x0b), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x02), 0x6c, 0xff, 0xffff}, - {0x08, 0x00, 0x0028, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x0c), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x11), 0x44, 0xff, 0xffff}, - {0x00, 0x00, 0x0064, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x0d), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x02), 0x5c, 0xff, 0xffff}, - {0x04, 0x00, 0x0014, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x10), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x11), 0x1c, 0xff, 0xffff}, + {0x06, 0x00, 0xffff, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x0f), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x02), ITEM_BOW, 0xff, 0x0001}, + {0x04, 0x00, 30, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x0e), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x02), ITEM_ARROWS30, 0xff, 0xffff}, + {0x04, 0x00, 30, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x0b), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x02), ITEM_BOMBS10, 0xff, 0xffff}, + {0x08, 0x00, 40, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x0c), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x11), ITEM_GRIP_RING, 0xff, 0xffff}, + {0x00, 0x00, 100, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x0d), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x02), ITEM_KINSTONE, 0xff, 0xffff}, + {0x04, 0x00, 20, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x10), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x11), ITEM_BOTTLE1, 0xff, 0xffff}, {0x0c, 0x00, 0xffff, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x12), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x13), 0xff, 0xff, 0x0046}, - {0x04, 0x00, 0x0064, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x13), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x02), 0x5c, 0x75, 0xffff}, + {0x04, 0x00, 100, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x13), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x02), ITEM_KINSTONE, 0x75, 0xffff}, #ifdef EU - {0x00, 0x00, 0x0064, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x0d), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x02), 0x5c, 0xff, 0xffff}, + {0x00, 0x00, 100, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x0d), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x02), ITEM_KINSTONE, 0xff, 0xffff}, #else - {0x00, 0x00, 0x00C8, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x0d), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x02), 0x5c, 0xff, 0xffff}, + {0x00, 0x00, 200, TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x0d), TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x02), ITEM_KINSTONE, 0xff, 0xffff}, #endif }; @@ -590,16 +590,16 @@ void (*const BusinessScrub_Functions[])(Entity*) = { BusinessScrub_OnGrabbed, }; -void (*const gUnk_080CC9E0[])(Entity*) = { - sub_08028994, - sub_08028A48, - sub_08028A74, - sub_08028BC4, - sub_08028C84, - sub_08028CE8, - sub_08028DE8, - sub_08028E40, - sub_08028E84, +void (*const BusinessScrub_Actions[])(Entity*) = { + BusinessScrub_Action0, + BusinessScrub_Action1, + BusinessScrub_Action2, + BusinessScrub_Action3, + BusinessScrub_Action4, + BusinessScrub_Action5, + BusinessScrub_Action6, + BusinessScrub_Action7, + BusinessScrub_Action8, }; const u8 gUnk_080CCA04[] = { diff --git a/src/enemy/businessScrubPrologue.c b/src/enemy/businessScrubPrologue.c index ba7349e9..657d9d0b 100644 --- a/src/enemy/businessScrubPrologue.c +++ b/src/enemy/businessScrubPrologue.c @@ -66,7 +66,7 @@ void sub_08045C3C(BusinessScrubPrologueEntity* this) { super->subtimer = 0; this->unk_78 = super->x.HALF.HI; this->unk_7a = super->y.HALF.HI; - super->animationState = 0; + super->animationState = IdleNorth; super->direction = 0x10; super->action = 5; super->timer = 120; @@ -75,7 +75,7 @@ void sub_08045C3C(BusinessScrubPrologueEntity* this) { sub_08046030(this, 0); sub_08095C48(super); StartCutscene(super, script_BusinessScrubIntro); - sub_0807DD50(super); + InitScriptForNPC(super); } void sub_08045CA4(BusinessScrubPrologueEntity* this) { @@ -200,7 +200,7 @@ void sub_08045E14(BusinessScrubPrologueEntity* this) { } void sub_08045EC8(BusinessScrubPrologueEntity* this) { - sub_0807DD94(super, 0); + ExecuteScriptAndHandleAnimation(super, NULL); } void sub_08045ED4(BusinessScrubPrologueEntity* this) { diff --git a/src/enemy/chaser.c b/src/enemy/chaser.c index 895c13f1..40f365c2 100644 --- a/src/enemy/chaser.c +++ b/src/enemy/chaser.c @@ -34,7 +34,7 @@ void sub_0802B540(Entity* this) { this->timer--; } else { u32 direction = sub_0804A024(this, 1, 0xc); - if (direction != 0xff) { + if (direction != DIR_NONE) { this->action = 2; this->speed = 0x40; this->direction = direction; diff --git a/src/enemy/chuchuBoss.c b/src/enemy/chuchuBoss.c index 79c6eeaa..c53a1483 100644 --- a/src/enemy/chuchuBoss.c +++ b/src/enemy/chuchuBoss.c @@ -554,7 +554,7 @@ void sub_080262A8(ChuchuBossEntity* this) { super->timer = 1; sub_080276F4(super, 6, 1); if (super->type2 == 0) { - gPlayerState.animation = 0x104; + gPlayerState.animation = ANIM_WALK; this->unk_84->unk_03 = 1; } else { this->unk_7c = 0; diff --git a/src/enemy/cuccoChickAggr.c b/src/enemy/cuccoChickAggr.c index ca4f3585..6611126b 100644 --- a/src/enemy/cuccoChickAggr.c +++ b/src/enemy/cuccoChickAggr.c @@ -119,10 +119,11 @@ void sub_08022AA4(Entity* this) { if (!sub_08049FA0(this) && (rand >> 8) & 3) { this->direction = sub_08049EE4(this); } else { - this->direction = (rand >> 0x10) & 0x1f; + this->direction = + (rand >> 0x10) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest); } - if (this->direction & 0xf) + if (this->direction & (0x3 | DirectionEast | DIR_DIAGONAL)) this->spriteSettings.flipX = (this->direction >> 4) ^ 1; } @@ -144,7 +145,7 @@ void sub_08022B44(Entity* this) { this->zVelocity = Q_16_16(0.75); this->direction = GetFacingDirection(this, &gPlayerEntity); - if (this->direction & 0xf) + if (this->direction & (0x3 | DIR_DIAGONAL | DirectionEast)) this->spriteSettings.flipX = (this->direction >> 4) ^ 1; EnqueueSFX(SFX_VO_CHEEP); diff --git a/src/enemy/dust.c b/src/enemy/dust.c index ead2273a..9b2bec8a 100644 --- a/src/enemy/dust.c +++ b/src/enemy/dust.c @@ -37,9 +37,9 @@ typedef struct { #define DUST_SPRITE_INDEX 0x1eb #endif -void sub_08044134(DustEntity*); -void sub_0804414C(DustEntity*); -void sub_0804415C(DustEntity*); +void Dust_OnTick(DustEntity*); +void Dust_OnCollision(DustEntity*); +void Dust_OnGrabbed(DustEntity*); void sub_080441E0(DustEntity*); void sub_080442A0(DustEntity*); void sub_080441CC(DustEntity*); @@ -56,15 +56,15 @@ extern void* sub_080AD8F0(u32, u32); extern const s8 gUnk_08126EE4[]; void (*const Dust_Functions[])(Entity*) = { - (EntityActionPtr)sub_08044134, (EntityActionPtr)sub_0804414C, GenericKnockback, GenericDeath, GenericConfused, - (EntityActionPtr)sub_0804415C, + (EntityActionPtr)Dust_OnTick, (EntityActionPtr)Dust_OnCollision, GenericKnockback, GenericDeath, GenericConfused, + (EntityActionPtr)Dust_OnGrabbed, }; void Dust(Entity* this) { Dust_Functions[GetNextFunction(this)](this); } -void sub_08044134(DustEntity* this) { +void Dust_OnTick(DustEntity* this) { static void (*const Dust_Actions[])(DustEntity*) = { sub_080441E0, sub_080442A0, @@ -72,11 +72,11 @@ void sub_08044134(DustEntity* this) { Dust_Actions[super->action](this); } -void sub_0804414C(DustEntity* this) { +void Dust_OnCollision(DustEntity* this) { EnemyFunctionHandlerAfterCollision(super, Dust_Functions); } -void sub_0804415C(DustEntity* this) { +void Dust_OnGrabbed(DustEntity* this) { static void (*const Dust_SubActions[])(DustEntity*) = { sub_080441BC, sub_080441C4, diff --git a/src/enemy/enemy4D.c b/src/enemy/enemy4D.c index 7e0ee931..9fe5532b 100644 --- a/src/enemy/enemy4D.c +++ b/src/enemy/enemy4D.c @@ -108,7 +108,7 @@ void Enemy4D_Init(Enemy4DEntity* this) { super->child = projectile; COLLISION_ON(super); super->spriteSettings.draw = TRUE; - super->animationState = 2; + super->animationState = IdleEast; this->unk_7b = 0; this->unk_7c = 0; this->unk_7e = 0x28; diff --git a/src/enemy/enemy50.c b/src/enemy/enemy50.c index 7e47330c..dceedf13 100644 --- a/src/enemy/enemy50.c +++ b/src/enemy/enemy50.c @@ -75,51 +75,49 @@ void Enemy50_OnTick(Enemy50Entity* this) { Enemy50_Actions[super->action](this); } -void sub_08040B9C(Enemy50Entity* this) { +void Enemy50_OnCollision(Enemy50Entity* this) { if (super->action == 8 || super->action == 9) { super->animationState = 0xff; InitializeAnimation(super, (super->knockbackDirection >> 4 ^ 1) + 1); sub_08041134(this); sub_0803F6EC(this); } - if (super->hitType == 0x25) { + if (super->hitType == 0x25 && super->contactFlags == 0x80) { + super->action = 8; + InitializeAnimation(super, 3); + } else { if (super->contactFlags == 0x80) { - super->action = 8; - InitializeAnimation(super, 3); - goto _08040C9C; + this->unk_7c = 0x78; + sub_08041128(this); } - } else if (super->contactFlags == 0x80) { - this->unk_7c = 0x78; - sub_08041128(this); - } - if (super->contactFlags == 0x9d) { - super->zVelocity = Q_16_16(1.5); - } - if (super->confusedTime != 0) { - super->animationState = super->knockbackDirection >> 4; - InitializeAnimation(super, super->animationState + 7); - Create0x68FX(super, FX_STARS); - } - if (super->health != this->unk_7a) { - if (super->type == 0) { + if (super->contactFlags == 0x9d) { + super->zVelocity = Q_16_16(1.5); + } + if (super->confusedTime != 0) { super->animationState = super->knockbackDirection >> 4; InitializeAnimation(super, super->animationState + 7); - } else { - if (super->iframes > 0) { - *((u8*)&super->iframes) |= 0x80; + Create0x68FX(super, FX_STARS); + } + if (super->health != this->unk_7a) { + if (super->type == 0) { + super->animationState = super->knockbackDirection >> 4; + InitializeAnimation(super, super->animationState + 7); + } else { + if (super->iframes > 0) { + *((u8*)&super->iframes) |= 0x80; + } + super->flags |= 0x80; + super->health = 0xff; + super->action = 0xa; + super->timer = 60; } - super->flags |= 0x80; - super->health = 0xff; - super->action = 0xa; - super->timer = 60; + this->unk_7a = super->health; } - this->unk_7a = super->health; } -_08040C9C: EnemyFunctionHandlerAfterCollision(super, Enemy50_Functions); } -void sub_08040CAC(Enemy50Entity* this) { +void Enemy50_OnKnockback(Enemy50Entity* this) { GetNextFrame(super); GenericKnockback2(super); if (super->type == 0) { @@ -137,7 +135,7 @@ void sub_08040CAC(Enemy50Entity* this) { } } -void sub_08040D30(Enemy50Entity* this) { +void Enemy50_OnConfused(Enemy50Entity* this) { if (super->animIndex != 7 && super->animIndex != 8) { InitializeAnimation(super, super->animationState + 7); } @@ -153,7 +151,7 @@ void sub_08040D30(Enemy50Entity* this) { } } -void sub_08040D90(Enemy50Entity* this) { +void Enemy50_OnGrabbed(Enemy50Entity* this) { if (sub_0806F520(super)) { Enemy50_SubActions[super->subAction](this); } else { @@ -436,7 +434,8 @@ bool32 sub_08041300(Enemy50Entity* this) { #endif void (*const Enemy50_Functions[])(Enemy50Entity*) = { - Enemy50_OnTick, sub_08040B9C, sub_08040CAC, (void (*)(Enemy50Entity*))GenericDeath, sub_08040D30, sub_08040D90, + Enemy50_OnTick, Enemy50_OnCollision, Enemy50_OnKnockback, (void (*)(Enemy50Entity*))GenericDeath, + Enemy50_OnConfused, Enemy50_OnGrabbed, }; void (*const Enemy50_Actions[])(Enemy50Entity*) = { Enemy50_Init, Enemy50_Action1, Enemy50_Action2, Enemy50_Action3, Enemy50_Action4, Enemy50_Action5, diff --git a/src/enemy/eyegore.c b/src/enemy/eyegore.c index 40cc1eca..fe4fbe2e 100644 --- a/src/enemy/eyegore.c +++ b/src/enemy/eyegore.c @@ -146,7 +146,7 @@ void Eyegore_OnGrabbed(EyegoreEntity* this) { void Eyegore_Init(EyegoreEntity* this) { sub_0804A720(super); super->action = 1; - super->animationState = 2; + super->animationState = IdleEast; super->x.HALF.HI &= 0xfff0; super->y.HALF.HI = (super->y.HALF.HI & 0xfff0) + 0xc; this->unk_6d |= 8; @@ -198,7 +198,7 @@ void Eyegore_Action3(EyegoreEntity* this) { GetNextFrame(super); if ((super->frame & ANIM_DONE) != 0) { super->flags |= ENT_COLLIDE; - super->animationState = 2; + super->animationState = IdleEast; sub_08030E58(this); InitializeAnimation(super, 2); sub_08030FB4(this); @@ -242,7 +242,7 @@ void Eyegore_Action5(EyegoreEntity* this) { GetNextFrame(super); switch (super->frame & 7) { case 1: - if (super->animationState != 2) { + if (super->animationState != IdleEast) { if (super->animationState >= 3) { this->unk_7f = (super->animationState - 1) & 3; } else { @@ -266,7 +266,7 @@ void Eyegore_Action5(EyegoreEntity* this) { if (sub_08049FDC(super, 1)) { sub_08030E58(this); } else { - if (super->animationState == 2) { + if (super->animationState == IdleEast) { super->action = 6; super->flags &= ~ENT_COLLIDE; InitializeAnimation(super, 0xe); diff --git a/src/enemy/fireballGuy.c b/src/enemy/fireballGuy.c index db1bf3da..3eb404a1 100644 --- a/src/enemy/fireballGuy.c +++ b/src/enemy/fireballGuy.c @@ -117,7 +117,7 @@ void sub_08045524(Entity* this) { this->zVelocity = Q_16_16(1.75); tmp = sub_0804A024(this, 1, 8); - if (tmp != 0xff && (Random() & 3) == 0) { + if (tmp != DIR_NONE && (Random() & 3) == 0) { this->timer = Random() & 3; this->direction = DirectionRound(tmp); } else { diff --git a/src/enemy/gleerok.c b/src/enemy/gleerok.c index c1a569a3..b04a0d24 100644 --- a/src/enemy/gleerok.c +++ b/src/enemy/gleerok.c @@ -1128,7 +1128,7 @@ void sub_0802E300(GleerokEntity* this) { this->unk_79 &= ~0x80; heap = this->unk_84; - dir = sub_0806F5A4(GetFacingDirection(super, &gPlayerEntity)) << 3; + dir = GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)) << 3; index = 0; ptr2 = &this->unk_80; tmp = 0; diff --git a/src/enemy/gyorgMale.c b/src/enemy/gyorgMale.c index fe9a7358..60d0b8fd 100644 --- a/src/enemy/gyorgMale.c +++ b/src/enemy/gyorgMale.c @@ -164,8 +164,8 @@ void sub_08046930(GyorgMaleEntity* this) { return; super->subAction = 1; super->timer = 1; - super->animationState = 0; - super->direction = 0; + super->animationState = IdleNorth; + super->direction = IdleNorth; #ifdef EU super->speed = 0x200; #else diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c index db2b004a..0edf083c 100644 --- a/src/enemy/helmasaur.c +++ b/src/enemy/helmasaur.c @@ -215,9 +215,9 @@ void sub_0802BE80(Entity* this) { } void sub_0802BEBC(Entity* this) { - this->direction ^= 0x10; + this->direction ^= DirectionSouth; ProcessMovement2(this); - this->direction ^= 0x10; + this->direction ^= DirectionSouth; if (!sub_080044EC(this, Q_16_16(0.125))) { sub_0802C1C0(this); } diff --git a/src/enemy/lakituCloud.c b/src/enemy/lakituCloud.c index 6e2c7091..23ff2274 100644 --- a/src/enemy/lakituCloud.c +++ b/src/enemy/lakituCloud.c @@ -89,7 +89,7 @@ void sub_0803CD6C(Entity* this) { void sub_0803CDA8(Entity* this) { UpdateAnimationSingleFrame(this); - if ((this->direction & 0x80) == 0) { + if (!(this->direction & DIR_NOT_MOVING_CHECK)) { LinearMoveUpdate(this); } @@ -123,7 +123,7 @@ void sub_0803CE14(Entity* this) { UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD); direction = this->direction; - if (direction & 0x80) { + if (direction & DIR_NOT_MOVING_CHECK) { return; } diff --git a/src/enemy/leever.c b/src/enemy/leever.c index 5baa8d06..2e07b2c6 100644 --- a/src/enemy/leever.c +++ b/src/enemy/leever.c @@ -71,7 +71,8 @@ void Leever_Idle(Entity* this) { if (Leever_PlayerInRange(this, Random() & 0x1f)) { this->action = 2; this->spriteSettings.draw = TRUE; - this->direction = (GetFacingDirection(this, gUnk_020000B0) + gLeeverDrift[Random() & 1]) & 0x1f; + this->direction = + (GetFacingDirection(this, gUnk_020000B0) + gLeeverDrift[Random() & 1]) & (0x3 | DirectionNorthWest); InitializeAnimation(this, LeeverAnimation_DigUp); UpdateSpriteForCollisionLayer(this); } else { diff --git a/src/enemy/madderpillar.c b/src/enemy/madderpillar.c index ff5d0ffc..a37e5d9b 100644 --- a/src/enemy/madderpillar.c +++ b/src/enemy/madderpillar.c @@ -369,16 +369,16 @@ void sub_08029EEC(Entity* this) { void sub_08029F0C(Entity* this) { switch (this->direction >> 3) { - case 0: + case 0: // UP this->field_0x78.HWORD = this->y.HALF.HI - 0x10; break; - case 1: + case 1: // RIGHT this->field_0x78.HWORD = this->x.HALF.HI + 0x10; break; - case 2: + case 2: // DOWN this->field_0x78.HWORD = this->y.HALF.HI + 0x10; break; - case 3: + case 3: // LEFT this->field_0x78.HWORD = this->x.HALF.HI - 0x10; break; } @@ -386,25 +386,25 @@ void sub_08029F0C(Entity* this) { bool32 sub_08029F48(Entity* this) { switch (this->direction >> 3) { - case 0: + case 0: // UP if (this->y.HALF.HI <= this->field_0x78.HWORD) { this->y.HALF.HI = this->field_0x78.HWORD; return TRUE; } break; - case 1: + case 1: // RIGHT if (this->x.HALF.HI >= this->field_0x78.HWORD) { this->x.HALF.HI = this->field_0x78.HWORD; return TRUE; } break; - case 2: + case 2: // DOWN if (this->y.HALF.HI >= this->field_0x78.HWORD) { this->y.HALF.HI = this->field_0x78.HWORD; return TRUE; } break; - case 3: + case 3: // LEFT if (this->x.HALF.HI <= this->field_0x78.HWORD) { this->x.HALF.HI = this->field_0x78.HWORD; return TRUE; diff --git a/src/enemy/mazaalBracelet.c b/src/enemy/mazaalBracelet.c index d21e8636..9180ae73 100644 --- a/src/enemy/mazaalBracelet.c +++ b/src/enemy/mazaalBracelet.c @@ -509,7 +509,7 @@ void sub_0803A8B8(Entity* this) { this->action = 0x10; this->timer = 30; - this->direction = 0; + this->direction = DirectionNorth; this->speed = 0x80; ptr = gUnk_080CED6C; @@ -553,7 +553,7 @@ void sub_0803A978(Entity* this) { sub_08004596(this, 0x10); } LinearMoveUpdate(this); - if (this->direction == 0x10) { + if (this->direction == DirectionSouth) { this->action = 0x12; this->timer = 3; COLLISION_OFF(this); @@ -1225,7 +1225,10 @@ void sub_0803B724(Entity* param_1) { void sub_0803B798(void) { gPlayerState.jump_status = 0x41; gPlayerState.field_0xa = 0; - gPlayerState.flags &= ~(0xffff0000 | PL_CAPTURED); + gPlayerState.flags &= + ~(PL_CAPTURED | PL_FLAGS10000 | PL_GYORG_FIGHT | PL_ROLLING | PL_MOLDWORM_CAPTURED | PL_IN_HOLE | + PL_MOLDWORM_RELEASED | PL_CLONING | PL_USE_LANTERN | PL_PARACHUTE | PL_CONVEYOR_PUSHED | PL_ENTER_MINECART | + PL_SWORD_THRUST | PL_USE_OCARINA | PL_CLIMBING | PL_FLAGS40000000 | PL_FLAGS80000000); gPlayerEntity.flags |= ENT_COLLIDE; gPlayerEntity.zVelocity = Q_16_16(1.5); gPlayerEntity.z.HALF.HI = -10; diff --git a/src/enemy/mazaalHead.c b/src/enemy/mazaalHead.c index a6a9ad92..1a027a87 100644 --- a/src/enemy/mazaalHead.c +++ b/src/enemy/mazaalHead.c @@ -561,7 +561,7 @@ void sub_0803473C(Entity* this) { if (roomX + 0xe0 < this->x.HALF.HI) { return; } - this->direction = 8; + this->direction = DirectionEast; } else { if (playerX + 4 >= this->x.HALF.HI) { return; @@ -569,7 +569,7 @@ void sub_0803473C(Entity* this) { if (roomX + 0x90 > this->x.HALF.HI) { return; } - this->direction = 0x18; + this->direction = DirectionWest; } LinearMoveUpdate(this); } @@ -581,7 +581,7 @@ void sub_080347B4(Entity* this) { if (roomX + 0xe0 < this->x.HALF.HI) { return; } - this->direction = 8; + this->direction = DirectionEast; } else { if (playerX + 4 >= this->x.HALF.HI) { return; @@ -589,7 +589,7 @@ void sub_080347B4(Entity* this) { if (roomX + 0x90 > this->x.HALF.HI) { return; } - this->direction = 0x18; + this->direction = DirectionWest; } LinearMoveUpdate(this); } diff --git a/src/enemy/moldorm.c b/src/enemy/moldorm.c index facad891..3d0daa83 100644 --- a/src/enemy/moldorm.c +++ b/src/enemy/moldorm.c @@ -209,7 +209,7 @@ void sub_08022F14(Entity* this) { } this->direction += this->field_0x78.HALF.LO; - this->direction &= 0x1f; + this->direction &= DirectionNorthWest | 0x3; this->animationState = ((this->direction + 2) & 0x1c) >> 2; this->frameIndex = this->animationState; diff --git a/src/enemy/mulldozer.c b/src/enemy/mulldozer.c index 854235de..f8b79c7e 100644 --- a/src/enemy/mulldozer.c +++ b/src/enemy/mulldozer.c @@ -53,7 +53,7 @@ void Mulldozer_OnInit(MulldozerEntity* this) { Mulldozer_Actions[super->action](this); } -void sub_08032CAC(MulldozerEntity* this) { +void Mulldozer_OnCollision(MulldozerEntity* this) { if (super->confusedTime != 0) { Create0x68FX(super, 0x1c); } @@ -80,7 +80,7 @@ void sub_08032CAC(MulldozerEntity* this) { } } -void sub_08032D3C(MulldozerEntity* this) { +void Mulldozer_OnKnockback(MulldozerEntity* this) { if (--super->subtimer == 0) { super->subtimer = 2; super->animationState = (super->animationState + 1) & 7; @@ -90,7 +90,7 @@ void sub_08032D3C(MulldozerEntity* this) { GenericKnockback(super); } -void nullsub_157(MulldozerEntity* this) { +void Mulldozer_OnGrabbed(MulldozerEntity* this) { } void Mulldozer_Init(MulldozerEntity* this) { @@ -465,11 +465,11 @@ bool32 sub_08033364(MulldozerEntity* this) { void (*const Mulldozer_Functions[])(MulldozerEntity*) = { Mulldozer_OnInit, - sub_08032CAC, - sub_08032D3C, + Mulldozer_OnCollision, + Mulldozer_OnKnockback, (void (*)(MulldozerEntity*))GenericDeath, (void (*)(MulldozerEntity*))GenericConfused, - nullsub_157, + Mulldozer_OnGrabbed, }; void (*const Mulldozer_Actions[])(MulldozerEntity*) = { Mulldozer_Init, Mulldozer_Action1, Mulldozer_Action2, Mulldozer_Action3, diff --git a/src/enemy/octorokGolden.c b/src/enemy/octorokGolden.c index 815c7411..12be6a8f 100644 --- a/src/enemy/octorokGolden.c +++ b/src/enemy/octorokGolden.c @@ -2,6 +2,7 @@ #include "map.h" #include "enemy.h" #include "player.h" +#include "item.h" void (*const OctorokGolden_Functions[])(Entity*); void (*const gUnk_080CF484[])(Entity*); @@ -40,7 +41,7 @@ void OctorokGolden_OnDeath(Entity* this) { SetGlobalFlag(this->type2); } - CreateDeathFx(this, 0xff, 0x58); + CreateDeathFx(this, 0xff, ITEM_RUPEE100); } void sub_08037CE4(Entity* this) { diff --git a/src/enemy/peahat.c b/src/enemy/peahat.c index 7b5ead2a..a6ba87da 100644 --- a/src/enemy/peahat.c +++ b/src/enemy/peahat.c @@ -182,7 +182,8 @@ void Peahat_ChargeStart(Entity* this) { this->action = 3; this->timer = 120; this->speed = 192; - this->direction = (GetFacingDirection(this, gUnk_020000B0) + gUnk_080CA5D4[Random() & 1]) & 0x1f; + this->direction = + (GetFacingDirection(this, gUnk_020000B0) + gUnk_080CA5D4[Random() & 1]) & (0x3 | DirectionNorthWest); } } else { sub_080205F8(this); @@ -226,6 +227,8 @@ void Peahat_ChargeEnd(Entity* this) { } } +#define DIR_NONE 0xff + void Peahat_Stunned(Entity* this) { switch (this->animationState) { default: @@ -236,7 +239,7 @@ void Peahat_Stunned(Entity* this) { this->hitType = 0x71; } - if (this->direction == 0xff) + if (this->direction == DIR_NONE) this->direction = this->knockbackDirection; ProcessMovement0(this); @@ -364,7 +367,7 @@ void sub_08020604(Entity* this) { this->direction = sub_08049EE4(this); } else { this->direction += this->field_0x80.HALF.LO; - this->direction &= 0x1f; + this->direction &= (0x3 | DirectionNorthWest); } } diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c index 9c211fcc..35146f8e 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -387,7 +387,7 @@ void sub_080244E8(Entity* this) { if (tmp == 0) { this->field_0x80.HALF.LO++; this->timer = 12; - this->direction = 0x10; + this->direction = DirectionSouth; this->speed = tmp; this->cutsceneBeh.HALF.LO = 0; this->flags2 &= 0xfc; @@ -554,13 +554,13 @@ void sub_08024940(Entity* this) { } void sub_080249DC(Entity* this) { - u8 direction = ((this->direction + 2) & 0x1c) >> 2; + u8 direction = ((this->direction + 2) & DirectionNorthWest) >> 2; this->animationState = direction; InitializeAnimation(this, this->animationState); } void sub_080249F4(Entity* this) { - u32 direction = ((this->direction + 2) & 0x1f); + u32 direction = ((this->direction + 2) & (0x3 | DirectionNorthWest)); direction >>= 2; if (direction != this->animationState) { this->animationState = direction; @@ -770,8 +770,8 @@ void sub_08024D00(Entity* this) { this->field_0x80.HALF.LO++; this->timer = (Random() & 0xf) + 32; - this->direction += this->field_0x80.HALF.HI ? 4 : 0x1c; - this->direction &= 0x1f; + this->direction += this->field_0x80.HALF.HI ? DirectionNorthEast : DirectionNorthWest; + this->direction &= 0x3 | DirectionNorthWest; this->field_0x80.HALF.HI ^= 0x40; sub_08024A14(this, 3, 0x10); @@ -783,8 +783,8 @@ void sub_08024D00(Entity* this) { this->timer = (Random() & 0x1f) + 32; } else { if (--this->subtimer == 0) { - this->direction += this->field_0x80.HALF.HI ? 1 : 0x1f; - this->direction &= 0x1f; + this->direction += this->field_0x80.HALF.HI ? 1 : (0x3 | DirectionNorthWest); + this->direction &= 0x3 | DirectionNorthWest; this->subtimer = 16; sub_080249DC(this); diff --git a/src/enemy/puffstool.c b/src/enemy/puffstool.c index bd354489..e13c6d5d 100644 --- a/src/enemy/puffstool.c +++ b/src/enemy/puffstool.c @@ -339,7 +339,7 @@ void sub_080255AC(Entity* this) { } tmp -= 7; - this->direction = (GetFacingDirection(ent, this) + tmp) & 0x1f; + this->direction = (GetFacingDirection(ent, this) + tmp) & (0x3 | DirectionNorthWest); } if (this->field_0x78.HWORD == 0) { @@ -379,7 +379,7 @@ void sub_080256B4(Entity* this) { this->action = 1; this->timer = (Random() & 3) + 4; this->subtimer = 30; - this->direction = (this->direction + 7 + ((s32)Random() % 7) * 4) & 0x1c; + this->direction = (this->direction + 7 + ((s32)Random() % 7) * 4) & DirectionNorthWest; this->field_0x78.HWORD = gUnk_080CC000[Random() & 0xf]; this->field_0x7a.HALF.LO = ((s32)Random() % 0x18) << 1; this->field_0x7a.HALF.HI = 0; diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c index bbc4a051..5e61c320 100644 --- a/src/enemy/rollobite.c +++ b/src/enemy/rollobite.c @@ -40,7 +40,7 @@ void Rollobite_OnCollision(Entity* this) { if (this->hitType == 34 && this->health != 0xff) { this->action = 4; this->zVelocity = Q_16_16(2.0); - this->direction = 0xff; + this->direction = DIR_NONE; this->health = 0xff; this->hitType = 35; InitializeAnimation(this, this->animationState + 8); @@ -50,7 +50,7 @@ void Rollobite_OnCollision(Entity* this) { if (this->action == 4 || this->action == 5) { this->action = 4; this->timer = 180; - this->direction = 0xff; + this->direction = DIR_NONE; InitializeAnimation(this, this->animationState + 0x10); } } @@ -75,7 +75,7 @@ void Rollobite_OnGrabbed(Entity* this) { if (this->subAction < 3 && !sub_0806F520(this)) { this->action = 4; COLLISION_ON(this); - this->direction = 0xff; + this->direction = DIR_NONE; InitializeAnimation(this, this->animationState + 0x10); } else { gUnk_080CA6A4[this->subAction](this); @@ -108,7 +108,7 @@ void sub_080207A8(Entity* this) { COLLISION_ON(this); this->spritePriority.b0 = 4; this->gustJarState &= 0xfb; - this->direction ^= 0x10; + this->direction ^= DirectionSouth; this->zVelocity = Q_16_16(1.5); this->speed = 0x80; InitializeAnimation(this, this->animationState + 0x10); @@ -194,7 +194,7 @@ void Rollobite_RolledUp(Entity* this) { if (unk == 1) EnqueueSFX(SFX_PLACE_OBJ); - if ((this->direction & 0x80) == 0) + if (!(this->direction & DIR_NOT_MOVING_CHECK)) ProcessMovement2(this); } } @@ -249,8 +249,8 @@ void sub_08020A7C(Entity* this) { if (sub_08049FA0(this) == 0) { u32 tmp = DirectionRoundUp(sub_08049EE4(this)); - if ((state ^ 0x10) == tmp) - state ^= 0x10; + if ((state ^ DirectionSouth) == tmp) + state ^= DirectionSouth; } this->direction = state; diff --git a/src/enemy/ropeGolden.c b/src/enemy/ropeGolden.c index b8921b9a..32535b12 100644 --- a/src/enemy/ropeGolden.c +++ b/src/enemy/ropeGolden.c @@ -10,6 +10,7 @@ #include "enemy.h" #include "physics.h" #include "player.h" +#include "item.h" void RopeGolden_OnTick(Entity*); void RopeGolden_OnCollision(Entity*); @@ -58,7 +59,7 @@ void RopeGolden_OnDeath(Entity* this) { if ((this->gustJarState & 2) == 0) { SetGlobalFlag(this->type2); } - CreateDeathFx(this, 0xff, 0x58); + CreateDeathFx(this, 0xff, ITEM_RUPEE100); } void sub_08038258(Entity* this) { @@ -130,7 +131,7 @@ void sub_08038304(Entity* this) { } this->field_0x7a.HALF.LO = this->field_0x78.HALF.HI; this->field_0x78.HALF.HI = cVar2; - this->direction = (this->direction + cVar2) & 0x18; + this->direction = (this->direction + cVar2) & DirectionWest; } else { this->direction = this->field_0x78.HALF.LO; } diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c index 39a8e586..ab1b3c0f 100644 --- a/src/enemy/rupeeLike.c +++ b/src/enemy/rupeeLike.c @@ -218,7 +218,7 @@ void sub_08029688(Entity* this) { void sub_0802969C(Entity* this) { u32 bVar1; - if ((this->direction & 0xf) != 0) { + if (this->direction & (0x3 | DIR_DIAGONAL | DirectionEast)) { bVar1 = this->direction >> 4; if (bVar1 != this->animationState) { diff --git a/src/enemy/sensorBladeTrap.c b/src/enemy/sensorBladeTrap.c index 627a75bb..87fea681 100644 --- a/src/enemy/sensorBladeTrap.c +++ b/src/enemy/sensorBladeTrap.c @@ -42,16 +42,16 @@ void sub_0802BA18(Entity* this) { this->direction = direction; switch (direction >> 3) { - case 0: + case 0: // UP this->field_0x7a.HWORD = this->y.HALF.HI - this->field_0x7c.HALF.HI; break; - case 1: + case 1: // RIGHT this->field_0x7a.HWORD = this->x.HALF.HI + this->field_0x7c.HALF.LO; break; - case 2: + case 2: // DOWN this->field_0x7a.HWORD = this->y.HALF.HI + this->field_0x7c.HALF.HI; break; - case 3: + case 3: // LEFT this->field_0x7a.HWORD = this->x.HALF.HI - this->field_0x7c.HALF.LO; break; } @@ -62,19 +62,19 @@ void sub_0802BA8C(Entity* this) { sub_0802BB10(this); } else { switch (this->direction >> 3) { - case 0: + case 0: // UP if (this->field_0x7a.HWORD >= this->y.HALF.HI) sub_0802BB10(this); break; - case 1: + case 1: // RIGHT if (this->field_0x7a.HWORD <= this->x.HALF.HI) sub_0802BB10(this); break; - case 2: + case 2: // DOWN if (this->field_0x7a.HWORD <= this->y.HALF.HI) sub_0802BB10(this); break; - case 3: + case 3: // LEFT if (this->field_0x7a.HWORD >= this->x.HALF.HI) sub_0802BB10(this); break; @@ -91,7 +91,7 @@ void sub_0802BAFC(Entity* this) { void sub_0802BB10(Entity* this) { this->action = 3; this->speed = 0xc0; - this->direction = this->direction ^ 0x10; + this->direction = this->direction ^ DirectionSouth; EnqueueSFX(SFX_METAL_CLINK); } diff --git a/src/enemy/smallPesto.c b/src/enemy/smallPesto.c index 490da140..1997c4df 100644 --- a/src/enemy/smallPesto.c +++ b/src/enemy/smallPesto.c @@ -91,8 +91,8 @@ void sub_08031714(Entity* this) { if (sub_08049FA0(this) == 0 && (this->subtimer & 1) != 0) { this->direction = sub_08049EE4(this); } else { - this->direction += 0x18; - this->direction = ((Random() & 0xe) + this->direction) & 0x1f; + this->direction += DirectionWest; + this->direction = ((Random() & 0xe) + this->direction) & (0x3 | DirectionNorthWest); } sub_080317E0(this); } diff --git a/src/enemy/spark.c b/src/enemy/spark.c index 26ea7c79..91efe2ff 100644 --- a/src/enemy/spark.c +++ b/src/enemy/spark.c @@ -60,7 +60,7 @@ void sub_0802B35C(Entity* this) { if (--this->subtimer == 0) { this->subtimer = 120; - this->direction += is_head ? 0x08 : 0x18; + this->direction += is_head ? DirectionEast : DirectionWest; this->direction = DirectionRound(this->direction); } } else { diff --git a/src/enemy/spearMoblin.c b/src/enemy/spearMoblin.c index 29c2584f..0a6765b5 100644 --- a/src/enemy/spearMoblin.c +++ b/src/enemy/spearMoblin.c @@ -176,7 +176,7 @@ void sub_08028488(Entity* this) { this->timer = (Random() & 7) * 3 + 64; break; case 4: - this->direction = (this->direction + 0x10) & 0x18; + this->direction = (this->direction + 0x10) & DirectionWest; /* fallthrough */ case 1: default: @@ -265,7 +265,7 @@ void sub_08028604(Entity* this) { this->timer = this->timer + 0x10; this->field_0x82.HALF.HI--; } - this->direction = (iVar3 + 4U) & 0x18; + this->direction = (iVar3 + 4U) & DirectionWest; iVar3 = Direction8ToAnimationState(this->direction); } } else { diff --git a/src/enemy/spikedBeetle.c b/src/enemy/spikedBeetle.c index 36deab65..6cb42502 100644 --- a/src/enemy/spikedBeetle.c +++ b/src/enemy/spikedBeetle.c @@ -107,7 +107,7 @@ void sub_0802B7A4(Entity* this) { this->timer = gUnk_080CD314[Random() & 3]; this->speed = 0x60; sub_0802B960(this); - if (this->direction != 0xff) { + if (this->direction != DIR_NONE) { u32 animation = this->direction >> 3; if (animation != this->animationState) { this->animationState = animation & 3; diff --git a/src/enemy/stalfos.c b/src/enemy/stalfos.c index 098a4c8a..9ea94452 100644 --- a/src/enemy/stalfos.c +++ b/src/enemy/stalfos.c @@ -73,7 +73,7 @@ void Stalfos_OnTick(StalfosEntity* this) { } } -void sub_0803933C(StalfosEntity* this) { +void Stalfos_OnCollision(StalfosEntity* this) { Entity* r0; Entity* r1; u32 r2; @@ -120,7 +120,7 @@ void sub_0803933C(StalfosEntity* this) { EnemyFunctionHandlerAfterCollision(super, Stalfos_Functions); } -void sub_08039418(StalfosEntity* this) { +void Stalfos_OnDeath(StalfosEntity* this) { if (super->type == 0) { CreateDeathFx(super, 0xf3, 0); } else { @@ -128,7 +128,7 @@ void sub_08039418(StalfosEntity* this) { } } -void sub_08039438(StalfosEntity* this) { +void Stalfos_OnGrabbed(StalfosEntity* this) { if (sub_0806F520(super)) { Stalfos_SubActions[super->subAction](this); } @@ -453,33 +453,32 @@ u32 sub_08039B28(StalfosEntity* this) { const u16* ptr; const s8* ptr2; - if (super->child == NULL) { - ptr2 = &gUnk_080CF930[super->animationState * 2]; - pos = COORD_TO_TILE_OFFSET(super, -ptr2[0], -ptr2[1]); - - tileType = GetMetaTileType(pos, (u32)super->collisionLayer); - ptr = gUnk_080CF938; - do { - if (ptr[0] != tileType) { - ptr += 2; - } else { - goto found; - } - } while (ptr[0] != 0); + if (super->child != NULL) { + return (u16)-1; } - return 0xffff; -found: - super->type2 = ptr[1]; - return pos; + ptr2 = &gUnk_080CF930[super->animationState * 2]; + pos = COORD_TO_TILE_OFFSET(super, -ptr2[0], -ptr2[1]); + tileType = GetMetaTileType(pos, (u32)super->collisionLayer); + ptr = gUnk_080CF938; + + do { + if (ptr[0] == tileType) { + super->type2 = ptr[1]; + return pos; + } + ptr += 2; + } while (ptr[0] != 0); + + return (u16)-1; } void (*const Stalfos_Functions[])(StalfosEntity*) = { Stalfos_OnTick, - sub_0803933C, + Stalfos_OnCollision, (void (*)(StalfosEntity*))GenericKnockback, - sub_08039418, + Stalfos_OnDeath, (void (*)(StalfosEntity*))GenericConfused, - sub_08039438, + Stalfos_OnGrabbed, }; void (*const Stalfos_Actions[])(StalfosEntity*) = { Stalfos_Init, Stalfos_Action1, Stalfos_Action2, Stalfos_Action3, Stalfos_Action4, Stalfos_Action5, diff --git a/src/enemy/tektite.c b/src/enemy/tektite.c index a5d58c33..be027d6a 100644 --- a/src/enemy/tektite.c +++ b/src/enemy/tektite.c @@ -159,7 +159,7 @@ void sub_0802F300(Entity* this) { } else if (this->collisions != COL_NONE) { sub_0800417E(this, this->collisions); } else if ((GetVvvAtEntity(this) & 0xf0) == 0x50) { // VVV_240 and VVV_241? - this->direction = (this->direction + 0x10) & 0x1f; + this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest); } if (--this->timer == 0) { @@ -214,6 +214,6 @@ static void sub_0802F45C(Entity* this) { this->direction = sub_08049F84(this, 1); } else { temp = (Random() & 0xf) + 0x18; - this->direction = (temp + this->direction) & 0x1f; + this->direction = (temp + this->direction) & (0x3 | DirectionNorthWest); } } diff --git a/src/enemy/tektiteGolden.c b/src/enemy/tektiteGolden.c index 0eb576ca..43b6bd3e 100644 --- a/src/enemy/tektiteGolden.c +++ b/src/enemy/tektiteGolden.c @@ -7,6 +7,7 @@ #include "collision.h" #include "enemy.h" +#include "item.h" #include "functions.h" void sub_08038168(Entity*); @@ -70,9 +71,9 @@ void TektiteGolden_OnDeath(Entity* this) { SetGlobalFlag(this->type2); } if (this->type != 0) { - uVar1 = 0x59; + uVar1 = ITEM_RUPEE200; } else { - uVar1 = 0x58; + uVar1 = ITEM_RUPEE100; } CreateDeathFx(this, 0xff, uVar1); } @@ -135,7 +136,7 @@ void sub_08038048(Entity* this) { } else if (this->collisions != COL_NONE) { sub_0800417E(this, this->collisions); } else if ((GetVvvAtEntity(this) & 0xf0) == 0x50) { // VVV_240 and VVV_241? - this->direction = (this->direction + 0x10) & 0x1f; + this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest); } if (--this->timer == 0) { @@ -184,6 +185,6 @@ void sub_08038168(Entity* this) { this->direction = sub_08049F84(this, 1); } else { temp = (Random() & 0xf) + 0x18; - this->direction = (temp + this->direction) & 0x1f; + this->direction = (temp + this->direction) & (0x3 | DirectionNorthWest); } } diff --git a/src/enemy/vaatiBall.c b/src/enemy/vaatiBall.c index 7095b875..e1075076 100644 --- a/src/enemy/vaatiBall.c +++ b/src/enemy/vaatiBall.c @@ -74,7 +74,7 @@ void sub_0804468C(Entity* this) { case 0: this->action = 1; this->timer = 1; - this->direction = (this->field_0x78.HALF.HI * 8) & 0x1f; + this->direction = (this->field_0x78.HALF.HI * 8) & (0x3 | DirectionNorthWest); this->field_0x78.HALF.LO = 0; this->field_0x82.HALF.HI = 0; this->spriteSettings.draw = 0; @@ -123,7 +123,7 @@ void sub_0804474C(Entity* this) { if (--this->timer == 0) { this->timer = 2; this->direction++; - this->direction &= 0x1f; + this->direction &= 0x3 | DirectionNorthWest; } LinearMoveUpdate(this); UpdateAnimationSingleFrame(this); @@ -253,7 +253,7 @@ void sub_080449F8(Entity* this) { this->timer = 4; this->direction++; - this->direction &= 0x1f; + this->direction &= 0x3 | DirectionNorthWest; if (vaati->field_0x80.HALF.LO == 0) vaati->field_0x74.HALF.LO = 1; break; @@ -266,9 +266,9 @@ void sub_080449F8(Entity* this) { } break; case 1: - this->direction = (this->direction + 0x10) & 0x1f; + this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest); LinearMoveUpdate(this); - this->direction = (this->direction + 0x10) & 0x1f; + this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest); this->timer = 2; break; case 3: @@ -324,7 +324,7 @@ void sub_08044B04(Entity* this) { if (--this->timer == 0) { this->timer = this->field_0x78.HALF.LO ? 4 : 2; this->direction++; - this->direction &= 0x1f; + this->direction &= 0x3 | DirectionNorthWest; } if (--this->subtimer == 0) { if (this->timer != 2) { @@ -346,11 +346,11 @@ void sub_08044B04(Entity* this) { case 1: if (--this->timer == 0) { this->timer = 6; - this->direction = (this->direction + 1) & 0x1f; + this->direction = (this->direction + 1) & (0x3 | DirectionNorthWest); if (++this->subtimer == 0x30) { u32 direction = sub_080045B4(this, vaati->x.HALF.HI, vaati->y.HALF.HI - 0x10); this->speed = 0; - this->direction = (direction + 16) & 0x1f; + this->direction = (direction + 16) & (0x3 | DirectionNorthWest); this->timer = 16; this->subtimer = 16; this->field_0x74.HALF.LO++; @@ -485,18 +485,18 @@ void sub_08044E74(Entity* this, u32 state) { switch (state) { case 2: this->action = 2; - this->direction += 0x18; - this->direction &= 0x1f; + this->direction += DirectionWest; + this->direction &= 0x3 | DirectionNorthWest; PositionRelative(this->parent, this, 0, Q_16_16(-16.0)); this->speed = 12288; LinearMoveUpdate(this); - this->direction += 0x8; - this->direction &= 0x1f; + this->direction += DirectionEast; + this->direction &= 0x3 | DirectionNorthWest; this->speed = 1280; LinearMoveUpdate(this); break; case 1: - this->direction = (this->direction + 8) & 0x1f; + this->direction = (this->direction + 8) & (0x3 | DirectionNorthWest); break; case 0: if (this->field_0x78.HALF.LO) { @@ -507,9 +507,9 @@ void sub_08044E74(Entity* this, u32 state) { } while (this->timer-- != 3); break; case 1: - this->direction = (this->direction + 0x10) & 0x1f; + this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest); LinearMoveUpdate(this); - this->direction = (this->direction + 0x10) & 0x1f; + this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest); break; } } else { diff --git a/src/enemy/vaatiEyesMacro.c b/src/enemy/vaatiEyesMacro.c index 1dac37a1..fd8c503c 100644 --- a/src/enemy/vaatiEyesMacro.c +++ b/src/enemy/vaatiEyesMacro.c @@ -233,7 +233,7 @@ void sub_0802EFB8(Entity* this) { collisionData = GetCollisionDataAtMetaTilePos(TILE(this->x.HALF.HI, this->y.HALF.HI) + gUnk_080B4488[((uVar1) >> 3)], 1); if (collisionData != 0) { - this->direction = 0xff; + this->direction = DIR_NONE; } else { this->timer = (rand & 3) + 1; this->direction = (uVar1 & 0x18); @@ -252,7 +252,7 @@ void sub_0802F04C(Entity* this) { return; } switch (this->direction >> 3) { - case 0: + case 0: // UP if (((oldY & 0xf) > 8) && ((this->y.HALF.HI & 0xf) < 9)) { this->timer--; oldY = (this->y.HALF.HI & 0xfff0) + 8; @@ -264,7 +264,7 @@ void sub_0802F04C(Entity* this) { return; } break; - case 1: + case 1: // RIGHT if (((oldX & 0xf) < 8) && ((this->x.HALF.HI & 0xf) >= 8)) { this->timer--; oldX = (this->x.HALF.HI & 0xfff0) + 8; @@ -276,7 +276,7 @@ void sub_0802F04C(Entity* this) { return; } break; - case 2: + case 2: // DOWN if (((oldY & 0xf) < 8) && ((this->y.HALF.HI & 0xf) >= 8)) { this->timer--; oldY = (this->y.HALF.HI & 0xfff0) + 8; @@ -288,7 +288,7 @@ void sub_0802F04C(Entity* this) { return; } break; - default: + default: // LEFT if (((oldX & 0xf) >= 9) && ((this->x.HALF.HI & 0xf) < 9)) { this->timer--; oldX = (this->x.HALF.HI & 0xfff0) + 8; diff --git a/src/enemy/vaatiProjectile.c b/src/enemy/vaatiProjectile.c index 95730d9f..985e1369 100644 --- a/src/enemy/vaatiProjectile.c +++ b/src/enemy/vaatiProjectile.c @@ -188,7 +188,7 @@ void VaatiProjectileFunction0Action5(Entity* this) { void VaatiProjectileFunction0Action6(Entity* this) { if (--this->timer == 0) { this->action = 7; - this->direction = 0x10; + this->direction = DirectionSouth; this->speed = 0x300; } sub_0803E444(this); diff --git a/src/enemy/vaatiRebornEnemy.c b/src/enemy/vaatiRebornEnemy.c index b6a257eb..50144071 100644 --- a/src/enemy/vaatiRebornEnemy.c +++ b/src/enemy/vaatiRebornEnemy.c @@ -103,7 +103,7 @@ void VaatiRebornEnemyType0Action0(Entity* this) { this->timer = 0; this->field_0x76.HALF.LO = 0; this->spriteSettings.draw = 1; - this->direction = 0xff; + this->direction = DIR_NONE; this->spritePriority.b0 = 4; this->z.WORD = 0; this->field_0x80.HALF.LO = 2; @@ -149,12 +149,12 @@ void VaatiRebornEnemyType0Action1(Entity* this) { this->action = 2; this->field_0x74.HALF.LO = 0; this->timer = 16; - this->direction = 0xff; + this->direction = DIR_NONE; } else { if ((this->field_0x86.HALF.LO != 0) || (this->field_0x80.HALF.LO != 0)) { - this->direction = ((Random() & 0x80) >> 3) | 8; + this->direction = ((Random() & 0x80) >> 3) | DirectionEast; } else { - this->direction = 0xff; + this->direction = DIR_NONE; } } } else { @@ -165,7 +165,7 @@ void VaatiRebornEnemyType0Action1(Entity* this) { this->field_0x74.HALF.HI = this->field_0x74.HALF.LO & 0x80; this->field_0x74.HALF.LO = 0; this->timer = 192; - this->direction = 0xff; + this->direction = DIR_NONE; this->spriteSettings.draw = 1; InitAnimationForceUpdate(this, 0); } @@ -176,7 +176,7 @@ void VaatiRebornEnemyType0Action1(Entity* this) { case 0: this->action = 4; this->timer = 160; - this->direction = 0xff; + this->direction = DIR_NONE; this->cutsceneBeh.HALF.LO = 0xff; InitAnimationForceUpdate(this, 1); break; @@ -184,21 +184,21 @@ void VaatiRebornEnemyType0Action1(Entity* this) { this->action = 6; this->field_0x74.HALF.LO = 0; this->timer = 0; - this->direction = 0xff; + this->direction = DIR_NONE; break; case 3: this->action = 5; this->field_0x74.HALF.LO = 0; this->subtimer = 32; - this->direction = 0xff; + this->direction = DIR_NONE; break; case 2: this->field_0x74.HALF.LO = 0; this->timer = 32; if ((this->field_0x86.HALF.LO != 0) || (this->field_0x80.HALF.LO != 0)) { - this->direction = ((Random() & 0x80) >> 3) | 8; + this->direction = ((Random() & 0x80) >> 3) | DirectionEast; } else { - this->direction = 0xff; + this->direction = DIR_NONE; } break; } @@ -340,7 +340,7 @@ void VaatiRebornEnemyType0Action4(Entity* this) { this->action = 1; this->cutsceneBeh.HALF.LO = 0xff; this->timer = 1; - this->direction = (this->direction + 0x10) & 0x1f; + this->direction = (this->direction + 0x10) & (0x3 | DirectionNorthWest); InitAnimationForceUpdate(this, 0); } else { if ((this->frame & 0x10) != 0) { @@ -369,7 +369,7 @@ void VaatiRebornEnemyType0Action5(Entity* this) { if (this->field_0x80.HALF.LO == 0) { this->action = 1; this->timer = 1; - this->direction = 0xff; + this->direction = DIR_NONE; InitAnimationForceUpdate(this, 0); return; } @@ -394,7 +394,7 @@ void VaatiRebornEnemyType0Action5(Entity* this) { this->field_0x86.HALF.HI++; this->subtimer = (Random() & 0x3f) + 64; uVar3 = GetFacingDirection(this, &gPlayerEntity); - this->direction = (uVar3 & 0x10) | 8; + this->direction = (uVar3 & 0x10) | DirectionEast; } else { this->field_0x74.HALF.LO++; this->field_0x86.HALF.HI = 0; @@ -408,7 +408,7 @@ void VaatiRebornEnemyType0Action5(Entity* this) { this->action = 1; this->field_0x74.HALF.LO = 0; this->timer = 1; - this->direction = 0xff; + this->direction = DIR_NONE; } break; } @@ -557,7 +557,7 @@ void VaatiRebornEnemyType2Action0(Entity* this) { this->field_0x74.HALF.LO = 1; this->field_0x74.HALF.HI = 0; this->spriteOffsetY = -2; - this->direction = 0xff; + this->direction = DIR_NONE; PositionRelative(source, this, 0, Q_16_16(2.0)); InitAnimationForceUpdate(this, 2); } @@ -601,7 +601,7 @@ void VaatiRebornEnemyType2Action1(Entity* this) { void VaatiRebornEnemyType3Action0(Entity* this) { this->action = 1; this->field_0x74.HALF.LO = 0; - this->direction = 0xff; + this->direction = DIR_NONE; this->spriteOffsetY = -1; InitAnimationForceUpdate(this, this->field_0x74.HALF.LO); sub_0803DC0C(this); @@ -621,7 +621,7 @@ void VaatiRebornEnemyType3Action1(Entity* this) { } else { if (this->field_0x74.HALF.LO != 0) { this->field_0x74.HALF.LO = 0; - this->direction = 0xff; + this->direction = DIR_NONE; InitAnimationForceUpdate(this, 2); } } @@ -855,7 +855,7 @@ void VaatiRebornEnemyType0PreAction(Entity* this) { this->field_0x7c = this->y; } if (this->field_0x76.HALF.LO == 0) { - if ((this->direction == 0xff) || sub_08049FA0(this)) { + if ((this->direction == DIR_NONE) || sub_08049FA0(this)) { if (this->field_0x80.HALF.LO == 0) { this->animationState = (this->animationState + 1) & 3; this->spriteOffsetX = gUnk_080D04D3[this->animationState]; @@ -863,7 +863,7 @@ void VaatiRebornEnemyType0PreAction(Entity* this) { return; } bVar1 = sub_08049EE4(this); - this->direction = (bVar1 & 0x10) | 8; + this->direction = (bVar1 & 0x10) | DirectionEast; this->field_0x76.HALF.LO = 0x10; } else { this->field_0x76.HALF.LO--; diff --git a/src/enemy/vaatiTransfigured.c b/src/enemy/vaatiTransfigured.c index 5e3ccd6b..6b58c2af 100644 --- a/src/enemy/vaatiTransfigured.c +++ b/src/enemy/vaatiTransfigured.c @@ -888,7 +888,7 @@ void sub_080406A0(Entity* this) { this->direction = tmp + 0x1f; } } - this->direction &= 0x1f; + this->direction &= 0x3 | DirectionNorthWest; this->field_0x86.HALF.LO = uVar5; } @@ -974,7 +974,7 @@ void sub_08040770(Entity* this) { this->direction = tmp3 + 0x1F; } } - this->direction &= 0x1F; + this->direction &= 0x3 | DirectionNorthWest; this->field_0x86.HALF.LO = tmp2; } diff --git a/src/enemy/vaatiWrath.c b/src/enemy/vaatiWrath.c index b7c9fd3a..1c4e74ac 100644 --- a/src/enemy/vaatiWrath.c +++ b/src/enemy/vaatiWrath.c @@ -383,7 +383,7 @@ void VaatiWrathType0Action7(Entity* this) { UpdateAnimationSingleFrame(this); if (gRoomControls.origin_y + 0x48 != this->y.HALF.HI) { this->speed = 0x100; - this->direction = ((gRoomControls.origin_y + 0x48) >= this->y.HALF.HI) ? 0x10 : 0; + this->direction = ((gRoomControls.origin_y + 0x48) >= this->y.HALF.HI) ? DirectionSouth : DirectionNorth; LinearMoveUpdate(this); } else { if (--this->timer == 0) { @@ -398,7 +398,7 @@ void VaatiWrathType0Action8(Entity* this) { LinearMoveUpdate(this); if (((gRoomControls.origin_x + 0x20) > this->x.HALF.HI) || ((gRoomControls.origin_x + 0x140) < this->x.HALF.HI)) { if (0x3f < this->speed) { - this->direction ^= 0x10; + this->direction ^= DirectionSouth; } } if (--this->timer == 0) { @@ -451,7 +451,7 @@ void VaatiWrathType0ActionA(Entity* this) { if (this->field_0x7a.HALF.HI == 0xf0) { this->action = 0xb; this->subAction = 0; - this->direction = 0; + this->direction = DirectionNorth; this->speed = 0x100; this->zVelocity = Q_16_16(1.125); ChangeObjPalette(this, 0x16b); @@ -521,7 +521,7 @@ void VaatiWrathType0ActionC(Entity* this) { if (this->z.HALF.HI < -4) { this->subAction = 1; this->timer = 120; - this->direction = 0x10; + this->direction = DirectionSouth; this->speed = 0x80; } break; @@ -998,8 +998,8 @@ void sub_0804235C(Entity* this) { void VaatiWrathType0PreAction(Entity* this) { int temp; if ((gRoomTransition.field_0x38 & 2) == 0) { - if (gSave.timers[3] != 0) { - gSave.timers[3]--; + if (gSave.vaati_timer != 0) { + gSave.vaati_timer--; } else { temp = gPlayerState.framestate_last; switch (temp) { |
