Merge branch 'master' into tilemap-docs

This commit is contained in:
octorock
2023-12-31 02:12:41 +01:00
549 changed files with 15821 additions and 15437 deletions
+19 -17
View File
@@ -1,6 +1,8 @@
.ifndef GUARD_ASM_MACROS_ENTITY_INC
.set GUARD_ASM_MACROS_ENTITY_INC, 1
.set DEFAULT_POOL, 0xF
.set ENTITY_TYPE_ENEMY, 0x3
.set ENTITY_TYPE_SIGN, 0x5
.set ENTITY_TYPE_OBJECT, 0x6
@@ -14,7 +16,7 @@
.macro object_minish_lilypad x, y, room_property, collision=0
.byte ENTITY_TYPE_OBJECT | ((\collision) << 4)
.byte 0x0F
.byte DEFAULT_POOL
.byte OBJECT_MINISH_LILYPAD
.byte 0x00
.byte \room_property
@@ -25,7 +27,7 @@
.macro object_item x, y, item, flag, collision=0
.byte ENTITY_TYPE_OBJECT | ((\collision) << 4)
.byte 0x0F
.byte DEFAULT_POOL
.byte OBJECT_ITEM
.byte \item
.byte 0x00
@@ -37,7 +39,7 @@
.macro enemy_octorok x, y, bound_x, bound_y, bound_tile_width, bound_tile_height, collision=0
.byte ENTITY_TYPE_ENEMY | ((\collision) << 4)
.byte 0x0F
.byte DEFAULT_POOL
.byte ENEMY_OCTOROK
.byte 0x00, 0x00, 0x00
.byte \bound_tile_width, \bound_tile_height
@@ -47,7 +49,7 @@
.macro enemy_chuchu x, y, bound_x, bound_y, bound_tile_width, bound_tile_height, collision=0
.byte ENTITY_TYPE_ENEMY | ((\collision) << 4)
.byte 0x0F
.byte DEFAULT_POOL
.byte ENEMY_CHUCHU
.byte 0x00, 0x00, 0x00
.byte \bound_tile_width, \bound_tile_height
@@ -57,16 +59,16 @@
.macro enemy_tree_item x, y, unknown, collision=0
.byte ENTITY_TYPE_ENEMY | ((\collision) << 4)
.byte 0x0F
.byte DEFAULT_POOL
.byte ENEMY_TREE_ITEM
.byte \unknown, 0x00, 0x00, 0x00, 0x00
.2byte \x, \y
.2byte 0x00, 0x00
.endm
.macro entity_raw type:req, subtype:req, collision=0, unknown:req, paramA=0, paramB=0, x=0, y=0, paramC=0
.macro entity_raw type:req, subtype:req, collision=0, pool:req, paramA=0, paramB=0, x=0, y=0, paramC=0
.byte \type | ((\collision) << 4)
.byte \unknown
.byte \pool
.byte \subtype
.byte \paramA
.4byte \paramB
@@ -91,24 +93,24 @@
.2byte \flag2
.endm
.macro manager subtype:req, collision=0, unknown=0xf, paramA=0, paramB=0, x=0, y=0, paramC=0
entity_raw type=9, subtype=\subtype, collision=\collision, unknown=\unknown, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC
.macro manager subtype:req, collision=0, pool=DEFAULT_POOL, paramA=0, paramB=0, x=0, y=0, paramC=0
entity_raw type=9, subtype=\subtype, collision=\collision, pool=\pool, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC
.endm
.macro object_raw subtype:req, collision=0, unknown=0xf, paramA=0, paramB=0, x=0, y=0, paramC=0
entity_raw type=6, subtype=\subtype, collision=\collision, unknown=\unknown, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC
.macro object_raw subtype:req, collision=0, pool=DEFAULT_POOL, paramA=0, paramB=0, x=0, y=0, paramC=0
entity_raw type=6, subtype=\subtype, collision=\collision, pool=\pool, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC
.endm
.macro enemy_raw subtype:req, collision=0, unknown=0xf, paramA=0, paramB=0, x=0, y=0, paramC=0
entity_raw type=3, subtype=\subtype, collision=\collision, unknown=\unknown, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC
.macro enemy_raw subtype:req, collision=0, pool=DEFAULT_POOL, paramA=0, paramB=0, x=0, y=0, paramC=0
entity_raw type=3, subtype=\subtype, collision=\collision, pool=\pool, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC
.endm
.macro npc_raw subtype:req, collision=0, unknown=0x4f, paramA=0, paramB=0, x=0, y=0, script:req
entity_raw type=7, subtype=\subtype, collision=\collision, unknown=\unknown, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\script
.macro npc_raw subtype:req, collision=0, pool=0x4f, paramA=0, paramB=0, x=0, y=0, script:req
entity_raw type=7, subtype=\subtype, collision=\collision, pool=\pool, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\script
.endm
.macro projectile_raw subtype:req, collision=0, unknown=0xf, paramA=0, paramB=0, x=0, y=0, paramC=0
entity_raw type=4, subtype=\subtype, collision=\collision, unknown=\unknown, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC
.macro projectile_raw subtype:req, collision=0, pool=DEFAULT_POOL, paramA=0, paramB=0, x=0, y=0, paramC=0
entity_raw type=4, subtype=\subtype, collision=\collision, pool=\pool, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC
.endm
.macro entity_list_end
+25 -23
View File
@@ -10,41 +10,43 @@ CheckBits: @ 0x08000F10
ldr r3, _08000F50 @ =ram_CheckBits
bx r3
thumb_func_start sub_08000F14
sub_08000F14: @ 0x08000F14
// sum 3 drop probability vectors
thumb_func_start SumDropProbabilities
SumDropProbabilities: @ 0x08000F14
push {r4, r5, r6}
movs r4, #0x1e
movs r4, #30 // vector addition for 16 shorts in reverse
_08000F18:
ldrsh r5, [r1, r4]
ldrsh r6, [r2, r4]
adds r5, r5, r6
ldrsh r6, [r3, r4]
adds r5, r5, r6
strh r5, [r0, r4]
ldrsh r5, [r1, r4] // row 1
ldrsh r6, [r2, r4] // + row 2
adds r5, r6
ldrsh r6, [r3, r4] // + row 3
adds r5, r6
strh r5, [r0, r4] // store in output
subs r4, #2
bpl _08000F18
pop {r4, r5, r6}
bx lr
thumb_func_start sub_08000F2C
sub_08000F2C: @ 0x08000F2C
// sum 3 drop probabilities, clamp to 0, return scalar sum
thumb_func_start SumDropProbabilities2
SumDropProbabilities2: @ 0x08000F2C
push {r4, r5, r6, r7}
movs r4, #0x1e
movs r7, #0
movs r4, #30
movs r7, #0 // sum
_08000F32:
ldrsh r5, [r1, r4]
ldrsh r6, [r2, r4]
adds r5, r5, r6
ldrsh r6, [r3, r4]
adds r5, r5, r6
bpl _08000F40
ldrsh r5, [r1, r4] // row 1
ldrsh r6, [r2, r4] // + row 2
adds r5, r6
ldrsh r6, [r3, r4] // + row 3
adds r5, r6
bpl positive_drop_chance // clamp to 0
movs r5, #0
_08000F40:
strh r5, [r0, r4]
adds r7, r7, r5
positive_drop_chance:
strh r5, [r0, r4] // store in output
adds r7, r5
subs r4, #2
bpl _08000F32
adds r0, r7, #0
adds r0, r7, #0 // return sum
pop {r4, r5, r6, r7}
bx lr
.align 2, 0
+1 -1
View File
@@ -18,7 +18,7 @@ EnemyUpdate: @ 0x080011C4
bne _080011EA
bl DeleteThisEntity
_080011DC:
bl EntityIsDeleted
bl EntityDisabled
cmp r0, #0
bne _0800120A
adds r0, r4, #0
+1 -1
View File
@@ -18,7 +18,7 @@ ProjectileUpdate: @ 0x08016AE4
bne _08016B0A
bl DeleteThisEntity
_08016AFC:
bl EntityIsDeleted
bl EntityDisabled
cmp r0, #0
bne _08016B22
adds r0, r4, #0
+1 -1
View File
@@ -59,7 +59,7 @@ gUnk_080FED58:: @ 080FED58
.incbin "data_080FC8A4/gUnk_080FED58.bin"
@ kinstone.c
gUnk_080FED98:: @ 080FED98
gLilypadRails:: @ 080FED98
.4byte gUnk_080FEDA4
.4byte gUnk_080FEDDA
.4byte gUnk_080FEDF8
+617 -617
View File
File diff suppressed because it is too large Load Diff
+82 -82
View File
@@ -156,108 +156,108 @@ typedef enum {
/*0x66*/ ENEMY_66
} Enemy;
void Octorok(Entity*);
void Chuchu(Entity*);
void Leever(Entity*);
void Peahat(Entity*);
void Rollobite(Entity*);
void DarkNut(Entity*);
void HangingSeed(Entity*);
void Beetle(Entity*);
void Keese(Entity*);
void DoorMimic(Entity*);
void RockChuchu(Entity*);
void SpinyChuchu(Entity*);
void CuccoChickAggr(Entity*);
void Moldorm(Entity*);
void EnemyE(Entity*);
void Moldworm(Entity*);
void Sluggula(Entity*);
void Pesto(Entity*);
void Puffstool(Entity*);
void ChuchuBoss(Entity*);
void LikeLike(Entity*);
void SpearMoblin(Entity*);
void BusinessScrub(Entity*);
void RupeeLike(Entity*);
void Madderpillar(Entity*);
void WaterDrop(Entity*);
void WallMaster(Entity*);
void BombPeahat(Entity*);
void Spark(Entity*);
void Chaser(Entity*);
void SpikedBeetle(Entity*);
void SensorBladeTrap(Entity*);
void Helmasaur(Entity*);
void FallingBoulder(Entity*);
void Bobomb(Entity*);
void WallMaster2(Entity*);
void Octorok();
void Chuchu();
void Leever();
void Peahat();
void Rollobite();
void DarkNut();
void HangingSeed();
void Beetle();
void Keese();
void DoorMimic();
void RockChuchu();
void SpinyChuchu();
void CuccoChickAggr();
void Moldorm();
void EnemyE();
void Moldworm();
void Sluggula();
void Pesto();
void Puffstool();
void ChuchuBoss();
void LikeLike();
void SpearMoblin();
void BusinessScrub();
void RupeeLike();
void Madderpillar();
void WaterDrop();
void WallMaster();
void BombPeahat();
void Spark();
void Chaser();
void SpikedBeetle();
void SensorBladeTrap();
void Helmasaur();
void FallingBoulder();
void Bobomb();
void WallMaster2();
void Gleerok();
void VaatiEyesMacro(Entity*);
void Tektite(Entity*);
void VaatiEyesMacro();
void Tektite();
void WizzrobeWind();
void WizzrobeFire();
void WizzrobeIce();
void Armos();
void Eyegore();
void Rope(Entity*);
void SmallPesto(Entity*);
void AcroBandit(Entity*);
void BladeTrap(Entity*);
void Keaton(Entity*);
void Crow(Entity*);
void Rope();
void SmallPesto();
void AcroBandit();
void BladeTrap();
void Keaton();
void Crow();
void Mulldozer();
void Bombarossa(Entity*);
void Wisp(Entity*);
void SpinyBeetle(Entity*);
void MazaalHead(Entity*);
void MazaalMacro(Entity*);
void MazaalHand(Entity*);
void Bombarossa();
void Wisp();
void SpinyBeetle();
void MazaalHead();
void MazaalMacro();
void MazaalHand();
void OctorokBoss();
void FlyingPot(Entity*);
void Gibdo(Entity*);
void OctorokGolden(Entity*);
void TektiteGolden(Entity*);
void RopeGolden(Entity*);
void FlyingPot();
void Gibdo();
void OctorokGolden();
void TektiteGolden();
void RopeGolden();
void CloudPiranha();
void ScissorsBeetle(Entity*);
void CuccoAggr(Entity*);
void ScissorsBeetle();
void CuccoAggr();
void Stalfos();
void FlyingSkull(Entity*);
void MazaalBracelet(Entity*);
void Takkuri(Entity*);
void BowMoblin(Entity*);
void Lakitu(Entity*);
void LakituCloud(Entity*);
void TorchTrap(Entity*);
void VaatiRebornEnemy(Entity*);
void VaatiProjectile(Entity*);
void BallChainSoldier(Entity*);
void FlyingSkull();
void MazaalBracelet();
void Takkuri();
void BowMoblin();
void Lakitu();
void LakituCloud();
void TorchTrap();
void VaatiRebornEnemy();
void VaatiProjectile();
void BallChainSoldier();
void Enemy4D();
void Ghini();
void VaatiTransfigured(Entity*);
void VaatiTransfigured();
void Enemy50();
void VaatiWrath(Entity*);
void VaatiArm(Entity*);
void Dust(Entity*);
void VaatiBall(Entity*);
void Slime(Entity*);
void MiniSlime(Entity*);
void FireballGuy(Entity*);
void MiniFireballGuy(Entity*);
void VaatiTransfiguredEye(Entity*);
void BusinessScrubPrologue(Entity*);
void VaatiWrath();
void VaatiArm();
void Dust();
void VaatiBall();
void Slime();
void MiniSlime();
void FireballGuy();
void MiniFireballGuy();
void VaatiTransfiguredEye();
void BusinessScrubPrologue();
void GyorgFemale();
void GyorgMale();
void Curtain(Entity*);
void VaatiWrathEye(Entity*);
void Curtain();
void VaatiWrathEye();
void GyorgChild();
void GyorgFemaleEye();
void GyorgMaleEye();
void GyorgFemaleMouth();
void Enemy64();
void TreeItem(Entity*);
void Enemy66(Entity*);
void TreeItem();
void Enemy66();
extern void (*const gUnk_080012C8[])(Entity*);
+20
View File
@@ -0,0 +1,20 @@
#ifndef VAATIWRATH_H
#define VAATIWRATH_H
#include "enemy.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[5];
/*0x6d*/ u8 unk_6d;
/*0x6e*/ u8 unused2[10];
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
/*0x7a*/ u8 unused3[1];
/*0x7b*/ u8 unk_7b;
/*0x7c*/ u16 unk_7c;
/*0x7e*/ u16 unk_7e;
/*0x80*/ u8 unused4[4];
/*0x84*/ u8 unk_84;
} VaatiWrathEntity;
#endif // VAATIWRATH_H
+22 -17
View File
@@ -6,7 +6,9 @@
#include "color.h"
#include "sprite.h"
#define MAX_ENTITIES 71
#define MAX_ENTITIES 72
#define MAX_MANAGERS 32
#define MAX_AUX_PLAYER_ENTITIES 7
/** Kinds of Entity's supported by the game. */
typedef enum {
@@ -38,6 +40,8 @@ typedef enum {
typedef enum {
ENT_DID_INIT = 0x1, /**< Graphics and other data loaded. */
ENT_SCRIPTED = 0x2, /**< Execute in a scripted environment. */
ENT_UNUSED1 = 0x4, /**< Unused delete flag. */
ENT_UNUSED2 = 0x8, /**< Unused delete flag. */
ENT_DELETED = 0x10, /**< Queue deletion next frame. */
ENT_PERSIST = 0x20, /**< Persist between rooms. */
ENT_COLLIDE = 0x80, /**< Collide with other Entity's. */
@@ -216,9 +220,6 @@ typedef struct Entity_ {
/*0x62*/ u8 spriteOffsetX;
/*0x63*/ s8 spriteOffsetY;
/*0x64*/ void* myHeap; /**< Heap data allocated with #zMalloc. */
#ifndef NENT_DEPRECATED
GENERIC_ENTITY_FIELDS
#endif
} Entity;
typedef struct {
@@ -238,6 +239,15 @@ typedef struct LinkedList {
Entity* first;
} LinkedList;
/**
* LinkedList's which point to allocate Entities.
* These work together with Entity.prev and Entity.next fields
* to allow the iteration of all Entity's.
*/
extern LinkedList gEntityLists[9];
extern GenericEntity gAuxPlayerEntities[MAX_AUX_PLAYER_ENTITIES];
extern GenericEntity gEntities[MAX_ENTITIES];
typedef void(EntityAction)(Entity*);
typedef void (*EntityActionPtr)(Entity*);
typedef void (*const* EntityActionArray)(Entity*);
@@ -283,7 +293,7 @@ Entity* CreateEnemy(u32 id, u32 type);
Entity* CreateNPC(u32 id, u32 type, u32 type2);
Entity* CreateObject(u32 id, u32 type, u32 type2);
Entity* CreateObjectWithParent(Entity* parent, u32 id, u32 type, u32 type2);
Entity* CreateItemGetEntity(void);
Entity* CreateAuxPlayerEntity(void);
Entity* CreateFx(Entity* parent, u32 type, u32 type2);
/// @}
@@ -386,12 +396,15 @@ Entity* FindEntity(u32 kind, u32 id, u32 listIndex, u32 type, u32 type2);
* @param entity Entity to set the priority of.
* @param prio #Priority level.
*/
void SetDefaultPriority(Entity* entity, u32 prio);
void SetEntityPriority(Entity* entity, u32 prio);
/**
* Check if entity will be deleted next frame.
* Check if entity is disabled. Entities are disabled if:
* - They are deleted.
* - There is an event and the entity doesn't have priority
* (n/a if entity is in action 0).
*/
bool32 EntityIsDeleted(Entity* entity);
bool32 EntityDisabled(Entity* entity);
/**
* Check if system or entity is blocking updates.
@@ -477,18 +490,10 @@ void SetInitializationPriority(void);
/**
* Reset the system update priority.
*/
void ResetSystemPriority(void);
void ClearEventPriority(void);
void sub_0805E958(void);
/**
* LinkedList's which point to allocate Entities.
* These work together with Entity.prev and Entity.next fields
* to allow the iteration of all Entity's.
*/
extern LinkedList gEntityLists[9];
extern Entity gItemGetEntities[7];
typedef struct {
u8 unk_0;
u8 unk_1;
+1 -1
View File
@@ -76,7 +76,7 @@ extern void sub_08030118(u32);
extern void sub_0803C0AC(Entity*);
extern void SetRoomTrackerFlag(Entity*);
extern u32 sub_0804A024(Entity*, u32, u32);
extern u32 sub_080542AC(u32);
extern u32 IsMinishItem(u32);
extern void DisableRandomDrops();
extern void EnableRandomDrops(void);
extern s32 sub_08056338(void);
+1 -1
View File
@@ -197,7 +197,7 @@ typedef enum {
WORLD_EVENT_TYPE_8, // set a tile type
WORLD_EVENT_TYPE_9, // LoadRoomEntity and set some tile type
WORLD_EVENT_TYPE_BEANSTALK,
WORLD_EVENT_TYPE_11, // LoadRoomEntity and set gRoomVars.field_0x8c
WORLD_EVENT_TYPE_11, // LoadRoomEntity and set gRoomVars.entityRails
WORLD_EVENT_TYPE_12,
WORLD_EVENT_TYPE_13,
WORLD_EVENT_TYPE_14,
+3 -1
View File
@@ -5,8 +5,10 @@
#include "entity.h"
#include "structures.h"
#define MESSAGE_ACTIVE 0x7f
typedef struct {
u8 doTextBox;
u8 state;
u8 unk;
u8 textSpeed;
u8 unk3; // HI?
-26
View File
@@ -1,26 +0,0 @@
#ifndef NEW_PLAYER_H
#define NEW_PLAYER_H
#include "entity.h"
// TODO Use new player entity struct everywhere once it is fully discovered.
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u32 unk_68;
/*0x6c*/ u8 unk_6c;
/*0x6d*/ u8 unk_6d;
/*0x6e*/ u8 unk_6e;
/*0x6f*/ u8 unk_6f;
/*0x70*/ Entity* unk_70;
/*0x74*/ Entity* unk_74;
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
/*0x7a*/ u16 unk_7a;
/*0x7c*/ u32 unk_7c;
/*0x80*/ u8 unk_80[8];
} PlayerEntity;
#define gNewPlayerEntity (*(PlayerEntity*)&gPlayerEntity)
#endif // NEW_PLAYER_H
-3
View File
@@ -1,9 +1,6 @@
#ifndef DEATHFX_H
#define DEATHFX_H
#ifndef NENT_DEPRECATED
#error "deathFx.h requires new entities"
#endif
#include "entity.h"
typedef struct {
+13
View File
@@ -0,0 +1,13 @@
#ifndef HOUSESIGN_H
#define HOUSESIGN_H
#include "entity.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[24];
/*0x80*/ s16 unk_80;
/*0x82*/ s16 unk_82;
} HouseSignEntity;
#endif // HOUSESIGN_H
+13
View File
@@ -0,0 +1,13 @@
#ifndef ITEMFORSALE_H
#define ITEMFORSALE_H
#include "object.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68[0x18];
/*0x80*/ u16 unk_80;
/*0x82*/ u16 unk_82;
} ItemForSaleEntity;
#endif // ITEMFORSALE_H
+20
View File
@@ -0,0 +1,20 @@
#ifndef LINKANIMATION_H
#define LINKANIMATION_H
#include "entity.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 storeDrawFlags;
/*0x69*/ u8 storeFlags;
/*0x6a*/ u8 storeIFrames;
/*0x6b*/ u8 storeField7;
/*0x6c*/ u8 storeKeepFacing;
/*0x6d*/ u8 storeFieldA;
/*0x6e*/ u8 storeField27;
/*0x6f*/ u8 storeMobility;
/*0x70*/ u32 storeStateFlags;
/*0x74*/ u8 store8A;
} LinkAnimationEntity;
#endif // LINKANIMATION_H
+25
View File
@@ -0,0 +1,25 @@
#ifndef PUSHABLEFURNITURE_H
#define PUSHABLEFURNITURE_H
#include "object.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68[0x8];
/*0x70*/ u16 unk_70;
/*0x72*/ u16 unk_72;
/*0x74*/ u16 unk_74;
/*0x76*/ u16 unk_76;
/*0x78*/ u8 unk_78[0x2];
/*0x7a*/ u16 unk_7a;
/*0x7c*/ u16 unk_7c;
/*0x7e*/ u16 unk_7e;
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
/*0x83*/ u8 unk_83;
/*0x84*/ u8 unk_84[0x2];
/*0x86*/ u16 unk_86;
} PushableFurnitureEntity;
#endif // PUSHABLEFURNITURE_H
+36 -21
View File
@@ -4,6 +4,23 @@
#include "global.h"
#include "entity.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ union SplitWord unk_68;
/*0x6c*/ u8 unk_6c;
/*0x6d*/ u8 unk_6d;
/*0x6e*/ u8 unk_6e;
/*0x6f*/ u8 unk_6f;
/*0x70*/ Entity* unk_70;
/*0x74*/ Entity* unk_74;
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
/*0x7a*/ u16 unk_7a;
/*0x7c*/ union SplitWord unk_7c;
/*0x80*/ union SplitWord unk_80;
/*0x84*/ union SplitWord unk_84;
} PlayerEntity;
enum PlayerActions {
PLAYER_INIT,
PLAYER_NORMAL,
@@ -244,29 +261,27 @@ typedef struct {
} PlayerMacroEntry ALIGNED(2);
typedef enum {
PLAYER_INPUT_1 = 0x1, // A
PLAYER_INPUT_2 = 0x2, // B
PLAYER_INPUT_8 = 0x8, // A sub_080782C0, sub_0807953C, PlayerUpdateSwimming, sub_08076518. ItemForSale_Action2
PLAYER_INPUT_10 = 0x10, // B sub_0807953C, ToggleDiving, sub_08076518, ItemForSale_Action2
PLAYER_INPUT_20 = 0x20, // R sub_0807953C
PLAYER_INPUT_40 = 0x40, // A CrenelBeanSprout_Action1
PLAYER_INPUT_80 =
INPUT_USE_ITEM1 = 0x1, // A
INPUT_USE_ITEM2 = 0x2, // B
INPUT_INTERACT = 0x8, // A sub_080782C0, sub_0807953C, PlayerUpdateSwimming, sub_08076518. ItemForSale_Action2
INPUT_CANCEL = 0x10, // B sub_0807953C, ToggleDiving, sub_08076518, ItemForSale_Action2
INPUT_CONTEXT = 0x20, // R sub_0807953C
INPUT_40 = 0x40, // A CrenelBeanSprout_Action1
INPUT_ACTION =
0x80, // R sub_08073584, IsPreventedFromUsingItem, sub_080782C0, CrenelBeanSprout_Action1, ItemForSale_Action2
PLAYER_INPUT_RIGHT = 0x100,
PLAYER_INPUT_LEFT = 0x200,
PLAYER_INPUT_UP = 0x400,
PLAYER_INPUT_DOWN = 0x800,
PLAYER_INPUT_ANY_DIRECTION = 0xf00,
PLAYER_INPUT_1000 = 0x1000, // L, where is it set? sub_080782C0
PLAYER_INPUT_8000 = 0x8000, // R, IsTryingToPickupObject, sub_08076518
// TODO What is the result of u32 result = (s32) - (keys & 0x200) >> 0x1f & 0x1000;?
INPUT_RIGHT = 0x100,
INPUT_LEFT = 0x200,
INPUT_UP = 0x400,
INPUT_DOWN = 0x800,
INPUT_ANY_DIRECTION = 0xf00,
INPUT_FUSE = 0x1000, // L, where is it set? sub_080782C0
INPUT_LIFT_THROW = 0x8000, // R, IsTryingToPickupObject, sub_08076518
} PlayerInputState;
typedef struct {
/*0x0*/ u16 heldInput; /**< Input currently held @see PlayerInputState */
/*0x2*/ u16 newInput; /**< New input this frame @see PlayerInputState */
/*0x4*/ u32 field_0x94;
/*0x4*/ u32 unused;
/*0x8*/ u16 playerMacroWaiting;
/*0xa*/ u16 playerMacroHeldKeys;
/*0xc*/ PlayerMacroEntry* playerMacro;
@@ -536,7 +551,7 @@ typedef struct {
/*0x09*/ u8 _hasAllFigurines;
/*0x0a*/ u8 charm;
/*0x0b*/ u8 picolyteType;
/*0x0c*/ u8 itemButtons[2];
/*0x0c*/ u8 equipped[2];
/*0x0e*/ u8 bottles[4];
/*0x12*/ u8 effect;
/*0x13*/ u8 hasAllFigurines;
@@ -588,9 +603,9 @@ extern const u8 gQuiverSizes[];
extern Entity* gPlayerClones[];
extern PlayerState gPlayerState;
extern Entity gPlayerEntity;
extern PlayerEntity gPlayerEntity;
void DoPlayerAction(Entity*);
void DoPlayerAction(PlayerEntity*);
bool32 CheckInitPauseMenu(void);
void SetPlayerControl(PlayerControlMode mode);
void ResetActiveItems(void);
@@ -722,7 +737,7 @@ s32 AddInteractableObject(Entity*, u32, u32);
void RemoveInteractableObject(Entity*);
s32 GetInteractableObjectIndex();
void sub_08078AC0(u32, u32, u32);
void sub_08078B48(void);
void PausePlayer(void);
void sub_08078E84(Entity*, Entity*);
void sub_08078FB0(Entity*);
void sub_080792BC(s32, u32, u32);
+13
View File
@@ -0,0 +1,13 @@
#ifndef PLAYERITEMBOTTLE_H
#define PLAYERITEMBOTTLE_H
#include "entity.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 bottleIndex; /**< @see Item */
/*0x69*/ u8 unused[6];
/*0x6f*/ u8 bottleContent; /**< @see Item */
} PlayerItemBottleEntity;
#endif // PLAYERITEMBOTTLE_H
+13 -16
View File
@@ -61,29 +61,26 @@ typedef struct {
extern RoomControls gRoomControls;
typedef struct {
/* 0x00 */ u8 field_0x0;
/* 0x01 */ u8 filler_0x1;
/* 0x00 */ bool8 didEnterScrolling;
/* 0x01 */ bool8 destructableManagerLoaded;
/* 0x02 */ bool8 randomDropsDisabled;
/* 0x03 */ u8 field_0x3;
/* 0x04 */ u8 field_0x4;
/* 0x05 */ u8 filler1[1];
/* 0x03 */ bool8 remFlagUnused;
/* 0x04 */ u8 numKinstoneDrops;
/* 0x05 */ u8 numKinstoneDropsPrevFrame;
/* 0x06 */ u8 shopItemType;
/* 0x07 */ u8 shopItemType2;
/* 0x08 */ u8 field_0x8;
/* 0x08 */ u8 unused;
/* 0x09 */ u8 fight_bgm;
/* 0x0a */ u8 unk2;
/* 0x0b */ u8 filler2;
/* 0x0a */ u8 needHealthDrop;
/* 0x0c */ s16 lightLevel;
/* 0x0e */ u16 specialTileCount; // Number of previous values for special tiles stored in gMetaTilesForSpecialTiles
/* 0x10 */ u8 unk_10[4];
/* 0x14 */ u32 flags;
/* 0x18 */ u32 unk3;
/* 0x1c */ u8 filler4[44];
/* 0x0e */ u16 tileEntityCount; // Number of previous values for special tiles stored in gMetaTilesForSpecialTiles
/* 0x10 */ u8 graphicsGroups[4];
/* 0x14 */ u8 flags[52];
/* 0x48 */ Droptable currentAreaDroptable;
/* 0x68 */ u32 animFlags;
/* 0x6c */ void* field_0x6c[8];
/* 0x8c */ void* field_0x8c[8];
/* 0xac */ Entity* entities[8];
/* 0x6c */ void* properties[8];
/* 0x8c */ void* entityRails[8];
/* 0xac */ Entity* puzzleEntities[8];
} RoomVars;
static_assert(sizeof(RoomVars) == 0xCC);
extern RoomVars gRoomVars;
+2 -2
View File
@@ -205,8 +205,8 @@ extern ItemBehavior gActiveItems[MAX_ACTIVE_ITEMS];
static_assert(sizeof(gActiveItems) == 0x70);
typedef struct {
u8 sys_priority; // system requested priority
u8 ent_priority; // entity requested priority
u8 event_priority; // system requested priority
u8 ent_priority; // entity requested priority
u8 queued_priority;
u8 queued_priority_reset;
Entity* requester;
+2 -2
View File
@@ -128,8 +128,8 @@ SECTIONS {
. = 0x000010A0; gRoomTransition = .;
. = 0x00001150; gRand = .;
. = 0x00001160; gPlayerEntity = .;
. = 0x000011E8; gItemGetEntities = .;
. = 0x000015A0; gUnk_030015A0 = .;
. = 0x000011E8; gAuxPlayerEntities = .;
. = 0x000015A0; gEntities = .;
. = 0x00003BE0; gCarriedEntity = .;
. = 0x00003C70; gUnk_03003C70 = .;
. = 0x00003D70; gEntityLists = .;
+123 -122
View File
@@ -28,7 +28,7 @@ extern u8 gUpdateVisibleTiles;
extern u16 gMapDataTopSpecial[];
extern u16 gMapDataBottomSpecial[];
extern const u8 gGlobalGfxAndPalettes[];
extern const u8 gUnk_081091E4[];
extern const u8 gEntityListLUT[];
typedef struct {
u16 tileType;
@@ -173,7 +173,7 @@ u32 UpdatePlayerCollision(void) {
s32 framestate;
u32 tmp2;
u32 tmp3;
// There are some weird assignment necessary to access gPlayerEntity.animationState correctly.
// There are some weird assignment necessary to access gPlayerEntity.base.animationState correctly.
u32 animationState1;
u32 animationState2;
u32 animationState3;
@@ -193,40 +193,40 @@ u32 UpdatePlayerCollision(void) {
return 0;
}
if (gPlayerState.dash_state != 0 || gPlayerEntity.action == PLAYER_CLIMB) {
direction = gPlayerEntity.direction;
if (gPlayerState.dash_state != 0 || gPlayerEntity.base.action == PLAYER_CLIMB) {
direction = gPlayerEntity.base.direction;
} else {
direction = gPlayerState.direction;
}
if (((direction & (DIR_NOT_MOVING_CHECK | 0x3)) == 0) && (gPlayerState.field_0xa == 0)) {
index = sub_0807BDB8(&gPlayerEntity, direction >> 2);
index = sub_0807BDB8(&gPlayerEntity.base, direction >> 2);
if (index != 0xff && (gRoomControls.scroll_flags & 4) == 0) {
ptr1 = &gUnk_080B4490[index * 2];
if (GetCollisionDataAtMetaTilePos(COORD_TO_TILE_OFFSET(&gPlayerEntity, -ptr1[0], -ptr1[1]),
gPlayerEntity.collisionLayer) == COLLISION_DATA_255) {
if (GetCollisionDataAtMetaTilePos(COORD_TO_TILE_OFFSET(&gPlayerEntity.base, -ptr1[0], -ptr1[1]),
gPlayerEntity.base.collisionLayer) == COLLISION_DATA_255) {
if ((((gPlayerState.flags & (PL_FLAGS10000 | PL_FLAGS2)) != 0) ||
((gPlayerState.sword_state & 0x10) != 0)) ||
((sub_080806BC(gPlayerEntity.x.HALF.HI - gRoomControls.origin_x,
gPlayerEntity.y.HALF.HI - gRoomControls.origin_y, index, 5) == 0 &&
((sub_080806BC(gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x,
gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y, index, 5) == 0 &&
(((gPlayerState.heldObject != 0 || ((gPlayerState.field_0x1c & 0xf) != 0)) ||
(sub_0807BD14(&gPlayerEntity, index) == 0)))))) {
(sub_0807BD14(&gPlayerEntity.base, index) == 0)))))) {
return 3;
}
gPlayerEntity.direction = (index << 3);
gPlayerEntity.base.direction = (index << 3);
return 0xf;
}
}
}
mapLayer = GetLayerByIndex(gPlayerEntity.collisionLayer);
ptr1 = &gUnk_080B4468[gPlayerEntity.animationState & 6];
position = COORD_TO_TILE_OFFSET(&gPlayerEntity, -ptr1[0], -ptr1[1]);
tileType = GetMetaTileType(position, gPlayerEntity.collisionLayer);
mapLayer = GetLayerByIndex(gPlayerEntity.base.collisionLayer);
ptr1 = &gUnk_080B4468[gPlayerEntity.base.animationState & 6];
position = COORD_TO_TILE_OFFSET(&gPlayerEntity.base, -ptr1[0], -ptr1[1]);
tileType = GetMetaTileType(position, gPlayerEntity.base.collisionLayer);
if (tileType < 0x4000) {
direction = GetVvvForMetaTileType(tileType);
} else {
direction = tileType;
}
animationState1 = gPlayerEntity.animationState;
animationState1 = gPlayerEntity.base.animationState;
animationState2 = animationState1 & 0xff;
switch (direction) {
@@ -234,7 +234,7 @@ u32 UpdatePlayerCollision(void) {
if (sub_0801A458(mapLayer, position, 2) == 0) {
return 0;
}
mapLayer->mapData[position] = 0x4001 + (gPlayerEntity.animationState >> 1);
mapLayer->mapData[position] = 0x4001 + (gPlayerEntity.base.animationState >> 1);
if ((gPlayerState.flags & PL_MINISH) != 0) {
gPlayerState.pushedObject = 0xc0;
} else {
@@ -242,42 +242,42 @@ u32 UpdatePlayerCollision(void) {
}
gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
gPlayerEntity.base.x.HALF.LO = 0;
gPlayerEntity.base.y.HALF.LO = 0;
gPlayerEntity.base.direction = Direction8FromAnimationState(gPlayerEntity.base.animationState);
return 1;
case VVV_40:
if ((gPlayerState.flags & PL_MINISH) != 0) {
return 0;
}
gPlayerEntity.action = gPlayerEntity.action;
gPlayerEntity.base.action = gPlayerEntity.base.action;
if (gPlayerState.field_0xa != 0) {
return 0;
}
if ((Direction8FromAnimationState(gPlayerEntity.animationState)) - gPlayerState.direction !=
if ((Direction8FromAnimationState(gPlayerEntity.base.animationState)) - gPlayerState.direction !=
DirectionNorth) {
return 0;
}
if ((gPlayerEntity.direction & DIR_NOT_MOVING_CHECK) != 0) {
if ((gPlayerEntity.base.direction & DIR_NOT_MOVING_CHECK) != 0) {
return 0;
}
if (GetCollisionDataAtMetaTilePos(position, gPlayerEntity.collisionLayer) != COLLISION_DATA_15) {
if (GetCollisionDataAtMetaTilePos(position, gPlayerEntity.base.collisionLayer) != COLLISION_DATA_15) {
return 0;
}
if (sub_08079778() == 0) {
return 0;
}
ptr1 = &gUnk_080B4478[gPlayerEntity.animationState & 6];
transition = sub_08080734((gPlayerEntity.x.HALF.HI - gRoomControls.origin_x) + ptr1[0],
(gPlayerEntity.y.HALF.HI - gRoomControls.origin_y) + ptr1[1]);
ptr1 = &gUnk_080B4478[gPlayerEntity.base.animationState & 6];
transition = sub_08080734((gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x) + ptr1[0],
(gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y) + ptr1[1]);
if (transition == NULL) {
return 0;
}
if ((gPlayerEntity.animationState & 2) != 0) {
gPlayerEntity.y.HALF.HI = gRoomControls.origin_y + transition->startY + 6;
if ((gPlayerEntity.base.animationState & 2) != 0) {
gPlayerEntity.base.y.HALF.HI = gRoomControls.origin_y + transition->startY + 6;
} else {
gPlayerEntity.x.HALF.HI = gRoomControls.origin_x + transition->startX;
gPlayerEntity.base.x.HALF.HI = gRoomControls.origin_x + transition->startX;
}
sub_08078AC0(4, 0, 1);
return 0;
@@ -286,18 +286,18 @@ u32 UpdatePlayerCollision(void) {
return 0;
}
// Start moving the boulder.
mapLayer->mapData[position] = SPECIAL_META_TILE_28 + (gPlayerEntity.animationState / 2);
mapLayer->mapData[position] = SPECIAL_META_TILE_28 + (gPlayerEntity.base.animationState / 2);
gPlayerState.pushedObject = 0xa0;
gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
gPlayerEntity.type = 1;
gPlayerEntity.base.x.HALF.LO = 0;
gPlayerEntity.base.y.HALF.LO = 0;
gPlayerEntity.base.direction = Direction8FromAnimationState(gPlayerEntity.base.animationState);
gPlayerEntity.base.type = 1;
return 1;
case VVV_112:
if ((gPlayerState.field_0x35 & 0x80) == 0) {
if ((gPlayerEntity.frame & 1) != 0) {
if ((gPlayerEntity.base.frame & 1) != 0) {
if (sub_0801A9F0(gPlayerState.field_0x35 << 2, tileType, position) != 0) {
return 1;
}
@@ -310,15 +310,15 @@ u32 UpdatePlayerCollision(void) {
if (gPlayerState.flags & PL_MINISH) {
return 0;
}
if (gPlayerEntity.animationState != IdleNorth) {
if (gPlayerEntity.base.animationState != IdleNorth) {
return 0;
}
gHUD.rActionInteractTile = R_ACTION_READ;
if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_40)) == 0) {
if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_40)) == 0) {
return 0;
}
gPlayerState.mobility = 1;
sub_080A7CFC(position, gPlayerEntity.collisionLayer);
sub_080A7CFC(position, gPlayerEntity.base.collisionLayer);
return 1;
case VVV_26:
if ((animationState1 & 0xff) != 0) {
@@ -328,22 +328,22 @@ u32 UpdatePlayerCollision(void) {
return 0;
}
gHUD.rActionInteractTile = R_ACTION_OPEN;
if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) {
if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_INTERACT)) == 0) {
return 0;
}
gPlayerState.mobility = 1;
OpenSmallChest(position, gPlayerEntity.collisionLayer);
OpenSmallChest(position, gPlayerEntity.base.collisionLayer);
return 2;
case VVV_113:
if (HasDungeonSmallKey() == 0) {
return 0;
}
gHUD.rActionInteractTile = R_ACTION_OPEN;
if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) {
if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_INTERACT)) == 0) {
return 0;
}
gPlayerState.mobility = 1;
sub_0804B388(position, gPlayerEntity.collisionLayer);
sub_0804B388(position, gPlayerEntity.base.collisionLayer);
return 2;
case VVV_61:
case SPECIAL_META_TILE_64 ... SPECIAL_META_TILE_72:
@@ -358,62 +358,62 @@ u32 UpdatePlayerCollision(void) {
return 0;
}
#endif
if ((Direction8FromAnimationState(gPlayerEntity.animationState)) - gPlayerState.direction !=
if ((Direction8FromAnimationState(gPlayerEntity.base.animationState)) - gPlayerState.direction !=
DirectionNorth) {
return 0;
}
if ((gPlayerEntity.direction & 0x80) != 0) {
if ((gPlayerEntity.base.direction & 0x80) != 0) {
return 0;
}
if (gPlayerEntity.subtimer < 6) {
if (gPlayerEntity.base.subtimer < 6) {
return 0;
}
gPlayerState.jump_status = 0x81;
gPlayerState.flags |= PL_USE_PORTAL;
gPlayerState.queued_action = PLAYER_USEPORTAL;
gPlayerEntity.zVelocity = 0x20000;
COLLISION_OFF(&gPlayerEntity);
gPlayerEntity.base.zVelocity = 0x20000;
COLLISION_OFF(&gPlayerEntity.base);
return 1;
case SPECIAL_META_TILE_11:
if (sub_0801A2B0(mapLayer, position, 8) == 0) {
return 0;
}
if ((gPlayerEntity.collisionLayer == 3) && (gMapTop.mapData[position] == SPECIAL_META_TILE_11)) {
gMapTop.mapData[position] = SPECIAL_META_TILE_12 + (gPlayerEntity.animationState >> 1);
if ((gPlayerEntity.base.collisionLayer == 3) && (gMapTop.mapData[position] == SPECIAL_META_TILE_11)) {
gMapTop.mapData[position] = SPECIAL_META_TILE_12 + (gPlayerEntity.base.animationState >> 1);
} else {
mapLayer->mapData[position] = SPECIAL_META_TILE_12 + (gPlayerEntity.animationState >> 1);
mapLayer->mapData[position] = SPECIAL_META_TILE_12 + (gPlayerEntity.base.animationState >> 1);
}
gPlayerState.pushedObject = 0xa0;
gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
gPlayerEntity.base.x.HALF.LO = 0;
gPlayerEntity.base.y.HALF.LO = 0;
gPlayerEntity.base.direction = Direction8FromAnimationState(gPlayerEntity.base.animationState);
return 1;
case SPECIAL_META_TILE_90:
if (sub_0801A2B0(mapLayer, position, 2) == 0) {
return 0;
}
// Move ice block.
mapLayer->mapData[position] = SPECIAL_META_TILE_91 + (gPlayerEntity.animationState >> 1);
mapLayer->mapData[position] = SPECIAL_META_TILE_91 + (gPlayerEntity.base.animationState >> 1);
gPlayerState.pushedObject = 0x98;
gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
gPlayerEntity.base.x.HALF.LO = 0;
gPlayerEntity.base.y.HALF.LO = 0;
gPlayerEntity.base.direction = Direction8FromAnimationState(gPlayerEntity.base.animationState);
return 1;
case SPECIAL_META_TILE_54:
if (sub_0801A2B0(mapLayer, position, 0xb) == 0) {
return 0;
}
mapLayer->mapData[position] = SPECIAL_META_TILE_55 + (gPlayerEntity.animationState >> 1);
mapLayer->mapData[position] = SPECIAL_META_TILE_55 + (gPlayerEntity.base.animationState >> 1);
gPlayerState.pushedObject = 0xa0;
gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
gPlayerEntity.base.x.HALF.LO = 0;
gPlayerEntity.base.y.HALF.LO = 0;
gPlayerEntity.base.direction = Direction8FromAnimationState(gPlayerEntity.base.animationState);
return 1;
case SPECIAL_META_TILE_62:
if ((animationState1 & 0xff) != 0) {
@@ -422,25 +422,25 @@ u32 UpdatePlayerCollision(void) {
if (((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) != 0) {
return 0;
}
if ((gPlayerEntity.frame & 2) == 0) {
if ((gPlayerEntity.base.frame & 2) == 0) {
return 0;
}
mapLayer->mapData[position] = SPECIAL_META_TILE_63;
gPlayerState.pushedObject = 0x82;
gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
gPlayerEntity.base.x.HALF.LO = 0;
gPlayerEntity.base.y.HALF.LO = 0;
gPlayerEntity.base.direction = Direction8FromAnimationState(gPlayerEntity.base.animationState);
return 1;
case VVV_114:
if ((gPlayerState.field_0x35 & 0x80) != 0) {
return 0;
}
if ((gPlayerEntity.frame & 1) == 0) {
if ((gPlayerEntity.base.frame & 1) == 0) {
return 0;
}
position = sub_0801A570(&gPlayerEntity, 1);
position = sub_0801A570(&gPlayerEntity.base, 1);
if (position == 0xffff) {
return 0;
}
@@ -450,7 +450,7 @@ u32 UpdatePlayerCollision(void) {
index = 0;
tmp3 = 0;
while (index < 3) {
if ((((*(u32*)(&(gPlayerClones[0])->field_0x6c)) & (1 << index)) != 0) &&
if ((((*(u32*)(&(((GenericEntity*)gPlayerClones[0]))->field_0x6c)) & (1 << index)) != 0) &&
(sub_0801A570(gPlayerClones[index], 0) == position)) {
tmp3++;
}
@@ -463,20 +463,20 @@ u32 UpdatePlayerCollision(void) {
if (pushedBlock == NULL) {
return 0;
}
pushedBlock->direction = Direction8FromAnimationState(gPlayerEntity.animationState);
pushedBlock->direction = Direction8FromAnimationState(gPlayerEntity.base.animationState);
pushedBlock->x.HALF.HI = ((position & 0xfff & 0x3f) << 4) + 8 + gRoomControls.origin_x;
pushedBlock->y.HALF.HI = ((position & 0xfc0) >> 2) + 8 + gRoomControls.origin_y;
pushedBlock->collisionLayer = gPlayerEntity.collisionLayer;
pushedBlock->collisionLayer = gPlayerEntity.base.collisionLayer;
gPlayerState.pushedObject = 0xa0;
gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = pushedBlock->direction;
gPlayerEntity.base.x.HALF.LO = 0;
gPlayerEntity.base.y.HALF.LO = 0;
gPlayerEntity.base.direction = pushedBlock->direction;
return 1;
case SPECIAL_META_TILE_43 ... SPECIAL_META_TILE_45:
if (sub_0801A370(mapLayer, position) != 0) {
mapLayer->mapData[position] = SPECIAL_META_TILE_48 + ((gPlayerEntity.animationState & 4) >> 2);
mapLayer->mapData[position] = SPECIAL_META_TILE_48 + ((gPlayerEntity.base.animationState & 4) >> 2);
if ((gPlayerState.flags & PL_MINISH) != 0) {
gPlayerState.pushedObject = 0xa0;
} else {
@@ -484,9 +484,9 @@ u32 UpdatePlayerCollision(void) {
}
gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
gPlayerEntity.base.x.HALF.LO = 0;
gPlayerEntity.base.y.HALF.LO = 0;
gPlayerEntity.base.direction = Direction8FromAnimationState(gPlayerEntity.base.animationState);
return 1;
} else {
return 0;
@@ -495,7 +495,7 @@ u32 UpdatePlayerCollision(void) {
if (sub_0801A458(mapLayer, position, 8) == 0) {
return 0;
}
mapLayer->mapData[position] = SPECIAL_META_TILE_75 + (gPlayerEntity.animationState >> 1);
mapLayer->mapData[position] = SPECIAL_META_TILE_75 + (gPlayerEntity.base.animationState >> 1);
if ((gPlayerState.flags & PL_MINISH) != 0) {
gPlayerState.pushedObject = 0xc0;
} else {
@@ -503,21 +503,21 @@ u32 UpdatePlayerCollision(void) {
}
gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
gPlayerEntity.base.x.HALF.LO = 0;
gPlayerEntity.base.y.HALF.LO = 0;
gPlayerEntity.base.direction = Direction8FromAnimationState(gPlayerEntity.base.animationState);
return 1;
case SPECIAL_META_TILE_82:
if (gPlayerState.field_0x35 != 0) {
return 0;
}
SetMetaTile(SPECIAL_META_TILE_84, position, gPlayerEntity.collisionLayer);
SetMetaTile(SPECIAL_META_TILE_84, position, gPlayerEntity.base.collisionLayer);
return 4;
case SPECIAL_META_TILE_83:
if (gPlayerState.field_0x35 != 6) {
return 0;
}
SetMetaTile(SPECIAL_META_TILE_84, position, gPlayerEntity.collisionLayer);
SetMetaTile(SPECIAL_META_TILE_84, position, gPlayerEntity.base.collisionLayer);
return 4;
case SPECIAL_META_TILE_85:
position--;
@@ -526,12 +526,12 @@ u32 UpdatePlayerCollision(void) {
if (gPlayerState.field_0x35 != 0) {
return 0;
}
if ((gPlayerEntity.y.HALF.HI & 0xf) < 10) {
if ((gPlayerEntity.base.y.HALF.HI & 0xf) < 10) {
return 0;
}
for (index = 0; index < 3; index++) {
if (sub_0801A8D0(gPlayerClones[index], 0) == position) {
SetMetaTile(SPECIAL_META_TILE_89, position, gPlayerEntity.collisionLayer);
SetMetaTile(SPECIAL_META_TILE_89, position, gPlayerEntity.base.collisionLayer);
return 4;
}
}
@@ -543,12 +543,12 @@ u32 UpdatePlayerCollision(void) {
if (gPlayerState.field_0x35 != 6) {
return 0;
}
if ((gPlayerEntity.x.HALF.HI & 0xf) < 10) {
if ((gPlayerEntity.base.x.HALF.HI & 0xf) < 10) {
return 0;
}
for (index = 0; index < 3; index++) {
if (sub_0801A8D0(gPlayerClones[index], 6) == position) {
SetMetaTile(SPECIAL_META_TILE_89, position, gPlayerEntity.collisionLayer);
SetMetaTile(SPECIAL_META_TILE_89, position, gPlayerEntity.base.collisionLayer);
return 4;
}
}
@@ -562,30 +562,30 @@ u32 UpdatePlayerCollision(void) {
if (((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) != 0) {
return 0;
}
if ((gPlayerEntity.frame & 1) == 0) {
if ((gPlayerEntity.base.frame & 1) == 0) {
return 0;
}
SetMetaTile(SPECIAL_META_TILE_116, position, gPlayerEntity.collisionLayer);
SetMetaTile(SPECIAL_META_TILE_116, position, gPlayerEntity.base.collisionLayer);
gPlayerState.pushedObject = 0xa0;
gPlayerState.queued_action = PLAYER_PUSH;
gPlayerState.flags |= PL_BUSY;
gPlayerEntity.x.HALF.LO = 0;
gPlayerEntity.y.HALF.LO = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
gPlayerEntity.base.x.HALF.LO = 0;
gPlayerEntity.base.y.HALF.LO = 0;
gPlayerEntity.base.direction = Direction8FromAnimationState(gPlayerEntity.base.animationState);
return 1;
case SPECIAL_META_TILE_125:
animationState3 = gPlayerEntity.animationState;
animationState3 = gPlayerEntity.base.animationState;
if ((animationState2) != 4) {
return 0;
}
if (((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) != 0) {
return 0;
}
if ((gPlayerEntity.frame & 1) == 0) {
if ((gPlayerEntity.base.frame & 1) == 0) {
return 0;
}
SetMetaTile(SPECIAL_META_TILE_116, position, gPlayerEntity.collisionLayer);
SetVvvAtMetaTilePos(VVV_13, position, gPlayerEntity.collisionLayer);
SetMetaTile(SPECIAL_META_TILE_116, position, gPlayerEntity.base.collisionLayer);
SetVvvAtMetaTilePos(VVV_13, position, gPlayerEntity.base.collisionLayer);
return 1;
default:
return 0;
@@ -598,11 +598,11 @@ bool32 sub_0801A2B0(MapLayer* mapLayer, u32 position, u32 collisionType) {
s16 y;
u16 temp4;
uVar1 = gUnk_080B4488[gPlayerEntity.animationState >> 1];
uVar1 = gUnk_080B4488[gPlayerEntity.base.animationState >> 1];
if ((((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) == 0) &&
((gPlayerEntity.frame & 1) != 0)) {
((gPlayerEntity.base.frame & 1) != 0)) {
position = (u16)(position - (-uVar1)); // necessary for match
temp4 = GetVvvForMetaTileType(GetMetaTileType(position, gPlayerEntity.collisionLayer));
temp4 = GetVvvForMetaTileType(GetMetaTileType(position, gPlayerEntity.base.collisionLayer));
switch (temp4) {
case 0x52:
break;
@@ -634,16 +634,16 @@ bool32 sub_0801A370(MapLayer* mapLayer, u32 position) {
s32 offset;
s32 temp;
if ((gPlayerEntity.animationState & 2) == 0) {
if ((gPlayerEntity.base.animationState & 2) == 0) {
return FALSE;
}
if (!sub_0801A4F8()) {
return FALSE;
}
topLayer = GetLayerByIndex(2);
offset = gUnk_080B4488[gPlayerEntity.animationState >> 1];
offset = gUnk_080B4488[gPlayerEntity.base.animationState >> 1];
pos = position + offset;
tileType = GetMetaTileType(pos, gPlayerEntity.collisionLayer);
tileType = GetMetaTileType(pos, gPlayerEntity.base.collisionLayer);
switch (tileType) {
case SPECIAL_META_TILE_43:
pos += offset;
@@ -654,7 +654,7 @@ bool32 sub_0801A370(MapLayer* mapLayer, u32 position) {
if (topLayer->collisionData[pos - 0x80] == 0x46) {
return FALSE;
}
switch ((u16)GetVvvForMetaTileType(GetMetaTileType(pos, gPlayerEntity.collisionLayer))) {
switch ((u16)GetVvvForMetaTileType(GetMetaTileType(pos, gPlayerEntity.base.collisionLayer))) {
case 0x52:
return FALSE;
case 0x26:
@@ -687,10 +687,10 @@ bool32 sub_0801A370(MapLayer* mapLayer, u32 position) {
bool32 sub_0801A458(MapLayer* mapLayer, u32 position, u32 collisionType) {
u32 tileType;
u32 pos;
s32 offset = gUnk_080B4488[gPlayerEntity.animationState >> 1];
s32 offset = gUnk_080B4488[gPlayerEntity.base.animationState >> 1];
if (sub_0801A4F8()) {
pos = position + offset;
tileType = GetMetaTileType(pos, gPlayerEntity.collisionLayer);
tileType = GetMetaTileType(pos, gPlayerEntity.base.collisionLayer);
switch (GetVvvForMetaTileType(tileType)) {
case 0x52:
case 0x26:
@@ -720,18 +720,18 @@ bool32 sub_0801A4F8(void) {
if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) != 0) {
return FALSE;
}
if (gPlayerState.direction != gPlayerEntity.direction) {
if (gPlayerState.direction != gPlayerEntity.base.direction) {
return FALSE;
}
tmp = (((gPlayerEntity.direction + 4) & DirectionWest) >> 3);
if ((gUnk_080B44A0[tmp] & gPlayerEntity.collisions) == 0) {
tmp = (((gPlayerEntity.base.direction + 4) & DirectionWest) >> 3);
if ((gUnk_080B44A0[tmp] & gPlayerEntity.base.collisions) == 0) {
return FALSE;
}
} else {
if (((gPlayerState.field_0x35 | gPlayerState.direction) & DIR_NOT_MOVING_CHECK) != 0) {
return FALSE;
}
if ((gPlayerEntity.frame & 1) == 0) {
if ((gPlayerEntity.base.frame & 1) == 0) {
return FALSE;
}
}
@@ -932,9 +932,10 @@ u32 sub_0801A8D0(Entity* this, u32 param_2) {
bool32 sub_0801A980(void) {
u16 tileType;
const s16* ptr;
GetLayerByIndex(gPlayerEntity.collisionLayer);
ptr = &gUnk_080B44A8[gPlayerEntity.animationState & 6];
tileType = GetMetaTileType(COORD_TO_TILE_OFFSET(&gPlayerEntity, -ptr[0], -ptr[1]), gPlayerEntity.collisionLayer);
GetLayerByIndex(gPlayerEntity.base.collisionLayer);
ptr = &gUnk_080B44A8[gPlayerEntity.base.animationState & 6];
tileType =
GetMetaTileType(COORD_TO_TILE_OFFSET(&gPlayerEntity.base, -ptr[0], -ptr[1]), gPlayerEntity.base.collisionLayer);
if (tileType < 0x4000) {
GetVvvForMetaTileType(tileType);
}
@@ -972,7 +973,7 @@ bool32 sub_0801A9F0(u32 param_1, u32 param_2, u32 param_3) {
}
if (cond) {
return sub_0801AA58(&gPlayerEntity, param_3, param_1);
return sub_0801AA58(&gPlayerEntity.base, param_3, param_1);
}
return FALSE;
@@ -1091,7 +1092,7 @@ u32 GetMetaTileSetIndexForSpecialTile(u32 metaTilePosAndLayer, u32 mapDataClone)
u32 count;
ptr = gMetaTilesForSpecialTiles;
count = gRoomVars.specialTileCount;
count = gRoomVars.tileEntityCount;
for (index = 0; index < count; ptr++, index++) {
if (metaTilePosAndLayer == ptr->metaTilePosAndLayer) {
return ptr->metaTileIndex * 4;
@@ -1157,7 +1158,7 @@ void sub_0801AD6C(const Data* param_1, u32 tilePosition) {
entity->y.HALF.HI = tmpY1 + gRoomControls.origin_y;
entity->collisionLayer = 0;
ResolveCollisionLayer(entity);
AppendEntityToList(entity, gUnk_081091E4[entity->kind]);
AppendEntityToList(entity, gEntityListLUT[entity->kind]);
}
} else {
manager = GetEmptyManager();
@@ -1171,7 +1172,7 @@ void sub_0801AD6C(const Data* param_1, u32 tilePosition) {
*(u16*)(&manager[1].timer + 10) = tmpX2 + gRoomControls.origin_x;
tmpY2 = (s16)((tilePosition & 0xfc0) >> 2) + 8;
*(u16*)(&manager[1].timer + 12) = tmpY2 + gRoomControls.origin_y;
AppendEntityToList((Entity*)manager, gUnk_081091E4[manager->kind]);
AppendEntityToList((Entity*)manager, gEntityListLUT[manager->kind]);
}
}
}
@@ -1231,11 +1232,11 @@ void SetMultipleTiles(const TileData* tileData, u32 basePosition, u32 layer) {
void StoreMetaTileForSpecialTile(u32 metaTileIndex, u32 metaTilePos, u32 layer) {
u32 index;
if ((metaTileIndex < 0x4000) && (gRoomTransition.field30 == 0)) {
index = gRoomVars.specialTileCount;
index = gRoomVars.tileEntityCount;
if (index < 0x100) {
gMetaTilesForSpecialTiles[index].metaTileIndex = metaTileIndex;
gMetaTilesForSpecialTiles[index].metaTilePosAndLayer = (layer << 12) | metaTilePos;
gRoomVars.specialTileCount = index + 1;
gRoomVars.tileEntityCount = index + 1;
}
}
}
@@ -1249,7 +1250,7 @@ void DeleteLoadedTileEntity(u32 metaTilePos, s32 layer) {
layer = layer << 12;
metaTilePosAndLayer = metaTilePos | layer;
ptr = gMetaTilesForSpecialTiles;
count = gRoomVars.specialTileCount;
count = gRoomVars.tileEntityCount;
t = 0;
if (t >= count) {
@@ -1258,7 +1259,7 @@ void DeleteLoadedTileEntity(u32 metaTilePos, s32 layer) {
if (metaTilePosAndLayer == ptr->metaTilePosAndLayer) {
count--;
gRoomVars.specialTileCount = count;
gRoomVars.tileEntityCount = count;
ptr[0] = ptr[count];
return;
}
@@ -1270,7 +1271,7 @@ void DeleteLoadedTileEntity(u32 metaTilePos, s32 layer) {
}
}
count--;
gRoomVars.specialTileCount = count;
gRoomVars.tileEntityCount = count;
ptr = gMetaTilesForSpecialTiles;
ptr[t] = ptr[count];
}
-1
View File
@@ -1,4 +1,3 @@
#define NENT_DEPRECATED
#include "global.h"
#include "room.h"
+8 -9
View File
@@ -1,4 +1,3 @@
#define NENT_DEPRECATED
#include "asm.h"
#include "global.h"
#include "entity.h"
@@ -25,8 +24,8 @@ Entity* sub_08049E18(void) {
!(gPlayerState.flags &
(PL_BUSY | PL_DROWNING | PL_CAPTURED | PL_USE_PORTAL | PL_HIDDEN | PL_DISABLE_ITEMS | PL_FALLING | PL_FROZEN |
PL_IN_MINECART | PL_PIT_IS_EXIT | PL_MOLDWORM_CAPTURED | PL_IN_HOLE | PL_CONVEYOR_PUSHED | PL_CLIMBING))) {
gUnk_020000B0 = &gPlayerEntity;
return &gPlayerEntity;
gUnk_020000B0 = &gPlayerEntity.base;
return &gPlayerEntity.base;
}
return NULL;
}
@@ -36,8 +35,8 @@ Entity* sub_08049E4C(void) {
!(gPlayerState.flags & (PL_BUSY | PL_DROWNING | PL_CAPTURED | PL_USE_PORTAL | PL_HIDDEN | PL_MINISH |
PL_DISABLE_ITEMS | PL_FALLING | PL_FROZEN | PL_IN_MINECART | PL_PIT_IS_EXIT |
PL_MOLDWORM_CAPTURED | PL_IN_HOLE | PL_CONVEYOR_PUSHED | PL_CLIMBING))) {
gUnk_020000B0 = &gPlayerEntity;
return &gPlayerEntity;
gUnk_020000B0 = &gPlayerEntity.base;
return &gPlayerEntity.base;
}
return NULL;
}
@@ -46,15 +45,15 @@ Entity* sub_08049E80(void) {
if ((gPlayerState.field_0x3c != 0) || !(gPlayerState.flags & PL_MINISH)) {
return NULL;
}
gUnk_020000B0 = &gPlayerEntity;
return &gPlayerEntity;
gUnk_020000B0 = &gPlayerEntity.base;
return &gPlayerEntity.base;
}
Entity* sub_08049EB0(void) {
if ((gPlayerState.field_0x3c == 0) &&
!(gPlayerState.flags & (PL_MOLDWORM_CAPTURED | PL_DISABLE_ITEMS | PL_MINISH | PL_CAPTURED))) {
gUnk_020000B0 = &gPlayerEntity;
return &gPlayerEntity;
gUnk_020000B0 = &gPlayerEntity.base;
return &gPlayerEntity.base;
}
return NULL;
}
+13 -13
View File
@@ -137,40 +137,40 @@ void UpdatePlayerInput(void) {
gPlayerState.playerInput.heldInput = state;
gPlayerState.playerInput.newInput = state & prevState;
// Calculate the direction from the currently held input.
gPlayerState.direction = gUnk_08109202[(state & PLAYER_INPUT_ANY_DIRECTION) >> 8];
gPlayerState.direction = gUnk_08109202[(state & INPUT_ANY_DIRECTION) >> 8];
}
u32 ConvInputToState(u32 keys) {
u32 result;
if (keys & L_BUTTON) {
result = 0x1000;
result = INPUT_FUSE;
} else {
result = 0;
}
if (keys & R_BUTTON) {
result |= PLAYER_INPUT_20;
result |= PLAYER_INPUT_8000;
result |= PLAYER_INPUT_80;
result |= INPUT_CONTEXT;
result |= INPUT_LIFT_THROW;
result |= INPUT_ACTION;
}
if (keys & A_BUTTON) {
result |= PLAYER_INPUT_8;
result |= PLAYER_INPUT_40 | PLAYER_INPUT_1;
result |= INPUT_INTERACT;
result |= INPUT_40 | INPUT_USE_ITEM1;
}
if (keys & B_BUTTON) {
result |= PLAYER_INPUT_10;
result |= PLAYER_INPUT_2;
result |= INPUT_CANCEL;
result |= INPUT_USE_ITEM2;
}
if (keys & DPAD_RIGHT) {
result |= PLAYER_INPUT_RIGHT;
result |= INPUT_RIGHT;
}
if (keys & DPAD_LEFT) {
result |= PLAYER_INPUT_LEFT;
result |= INPUT_LEFT;
}
if (keys & DPAD_UP) {
result |= PLAYER_INPUT_UP;
result |= INPUT_UP;
}
if (keys & DPAD_DOWN) {
result |= PLAYER_INPUT_DOWN;
result |= INPUT_DOWN;
}
return result;
}
+39 -39
View File
@@ -64,8 +64,8 @@ void CollisionMain(void) {
u32 prio;
// pick highest priority
prio = gPriorityHandler.sys_priority;
if (gPriorityHandler.sys_priority <= gPriorityHandler.ent_priority)
prio = gPriorityHandler.event_priority;
if (gPriorityHandler.event_priority <= gPriorityHandler.ent_priority)
prio = gPriorityHandler.ent_priority;
// if any priority is set, dont do collision
@@ -75,10 +75,10 @@ void CollisionMain(void) {
doCollision = &ram_CollideAll;
// Check to see if we should disable collision this frame
if (gPlayerState.controlMode != CONTROL_ENABLED) {
u32 flags = gPlayerEntity.flags;
COLLISION_OFF(&gPlayerEntity);
u32 flags = gPlayerEntity.base.flags;
COLLISION_OFF(&gPlayerEntity.base);
doCollision();
gPlayerEntity.flags = flags; // reset collision to before
gPlayerEntity.base.flags = flags; // reset collision to before
} else {
doCollision();
}
@@ -89,7 +89,7 @@ void RegisterPlayerHitbox(void) {
gUnk_02018EA0 = (LinkedList2*)&gUnk_03003C70[0].last;
gUnk_03003C70[0].last = &gUnk_03003C70[0].last;
gUnk_03003C70[0].first = &gUnk_03003C70[0].last;
gUnk_03003C70[0].node = &gPlayerEntity;
gUnk_03003C70[0].node = &gPlayerEntity.base;
}
u32 sub_0801766C(Entity* this) {
@@ -212,7 +212,7 @@ bool32 IsColliding(Entity* this, Entity* that) {
bool32 IsCollidingPlayer(Entity* this) {
if (PlayerCanBeMoved())
return IsColliding(this, &gPlayerEntity);
return IsColliding(this, &gPlayerEntity.base);
return FALSE;
}
@@ -248,7 +248,7 @@ s32 CalculateDamage(Entity* org, Entity* tgt) {
}
health = org->health - damage;
if (org->kind == ENEMY) {
if ((org->field_0x6c.HALF.HI & 1) != 0)
if ((((GenericEntity*)org)->field_0x6c.HALF.HI & 1) != 0)
SoundReqClipped(org, SFX_BOSS_HIT);
else
SoundReqClipped(org, SFX_HIT);
@@ -277,8 +277,8 @@ void sub_08017940(Entity* org, Entity* tgt) {
r1 = 0;
r1 = (u32)(org == &gPlayerEntity ? gPlayerEntity.knockbackDuration
: (tgt == &gPlayerEntity ? tgt->knockbackDuration : 0)) >>
r1 = (u32)(org == &gPlayerEntity.base ? gPlayerEntity.base.knockbackDuration
: (tgt == &gPlayerEntity.base ? tgt->knockbackDuration : 0)) >>
3;
// Anything requiring the evaluation of r1 could be written here.
@@ -464,7 +464,7 @@ CollisionResult sub_08017CBC(Entity* org, Entity* tgt, u32 direction, ColSetting
CollisionResult sub_08017D28(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
gPlayerState.mobility = 1;
org->field_0x7a.HWORD = 600;
((GenericEntity*)org)->field_0x7a.HWORD = 600;
org->knockbackDuration = 12;
org->iframes = 16;
org->knockbackSpeed = 640;
@@ -484,7 +484,7 @@ CollisionResult sub_08017D6C(Entity* org, Entity* tgt, u32 direction, ColSetting
y = 0xac2;
} else {
tgt->contactFlags = 0xcb;
tgt->field_0x78.HALF.HI = org->hurtType;
((GenericEntity*)tgt)->field_0x78.HALF.HI = org->hurtType;
x = org->hurtType;
y = 0xae4;
}
@@ -498,17 +498,17 @@ CollisionResult sub_08017DD4(Entity* org, Entity* tgt, u32 direction, ColSetting
tgt->damage &= ~0x80;
else
tgt->damage = 4;
gPlayerEntity.health = CalculateDamage(&gPlayerEntity, tgt);
gPlayerEntity.base.health = CalculateDamage(&gPlayerEntity.base, tgt);
tgt->iframes = -12;
if ((gPlayerState.flags & PL_MINISH) == 0) {
sub_08079D84();
org->iframes = 90;
} else {
gPlayerEntity.contactFlags = tgt->hurtType | 0x80;
gPlayerEntity.iframes = 12;
gPlayerEntity.knockbackDuration = 16;
gPlayerEntity.knockbackDirection = DirectionTurnAround(direction);
gPlayerEntity.knockbackSpeed = 640;
gPlayerEntity.base.contactFlags = tgt->hurtType | 0x80;
gPlayerEntity.base.iframes = 12;
gPlayerEntity.base.knockbackDuration = 16;
gPlayerEntity.base.knockbackDirection = DirectionTurnAround(direction);
gPlayerEntity.base.knockbackSpeed = 640;
}
if (tgt->iframes == 0)
tgt->iframes = -1;
@@ -526,19 +526,19 @@ CollisionResult sub_08017E88(Entity* org, Entity* tgt, u32 direction, ColSetting
CollisionResult sub_08017EB0(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (tgt->damage == 0)
return RESULT_NO_COLLISION;
if (org == &gPlayerEntity) {
if (org == &gPlayerEntity.base) {
u32 prevDamage = tgt->damage;
tgt->damage = 8;
gPlayerEntity.health = CalculateDamage(&gPlayerEntity, tgt);
gPlayerEntity.base.health = CalculateDamage(&gPlayerEntity.base, tgt);
tgt->damage = prevDamage;
gPlayerEntity.knockbackDuration = 12;
gPlayerEntity.iframes = 16;
gPlayerEntity.knockbackSpeed = 384;
gPlayerEntity.base.knockbackDuration = 12;
gPlayerEntity.base.iframes = 16;
gPlayerEntity.base.knockbackSpeed = 384;
} else if (org->kind == PLAYER_ITEM && org->id == PL_ITEM_SHIELD) {
org->knockbackDuration = 8;
org->iframes = -6;
org->knockbackSpeed = 384;
gPlayerEntity.iframes = 0x80;
gPlayerEntity.base.iframes = 0x80;
}
if (tgt->iframes == 0)
tgt->iframes = -1;
@@ -551,7 +551,7 @@ CollisionResult sub_08017F3C(Entity* org, Entity* tgt, u32 direction, ColSetting
CollisionResult sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (tgt->confusedTime == 0) {
if (org == &gPlayerEntity) {
if (org == &gPlayerEntity.base) {
if (PlayerCanBeMoved() &&
#ifdef EU
(gPlayerState.flags & (PL_MINISH | PL_BUSY)) == 0 &&
@@ -580,7 +580,7 @@ CollisionResult sub_08017F40(Entity* org, Entity* tgt, u32 direction, ColSetting
} else {
org->health = 0;
}
} else if (tgt->kind == ENEMY && org == &gPlayerEntity) {
} else if (tgt->kind == ENEMY && org == &gPlayerEntity.base) {
sub_08004484(tgt, org);
}
return RESULT_NO_COLLISION;
@@ -647,7 +647,7 @@ CollisionResult sub_080180E8(Entity* org, Entity* tgt, u32 direction, ColSetting
CollisionResult sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (tgt->confusedTime == 0) {
if (org == &gPlayerEntity) {
if (org == &gPlayerEntity.base) {
if (PlayerCanBeMoved() &&
#ifdef EU
(gPlayerState.flags & (PL_MINISH | PL_BUSY)) == 0 &&
@@ -659,10 +659,10 @@ CollisionResult sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSetting
gPlayerState.field_0xa |= 0x80;
gPlayerState.flags |= PL_DISABLE_ITEMS;
gPlayerState.jump_status = 0;
COLLISION_OFF(&gPlayerEntity);
gPlayerEntity.spriteRendering.b3 = tgt->spriteRendering.b3;
gPlayerEntity.spriteOrientation.flipY = tgt->spriteOrientation.flipY;
gPlayerEntity.iframes = 0xff;
COLLISION_OFF(&gPlayerEntity.base);
gPlayerEntity.base.spriteRendering.b3 = tgt->spriteRendering.b3;
gPlayerEntity.base.spriteOrientation.flipY = tgt->spriteOrientation.flipY;
gPlayerEntity.base.iframes = 0xff;
tgt->iframes = -8;
PutAwayItems();
return RESULT_COLLISION;
@@ -670,14 +670,14 @@ CollisionResult sub_08018168(Entity* org, Entity* tgt, u32 direction, ColSetting
} else {
org->health = 0;
}
} else if ((tgt->kind == ENEMY) && (org == &gPlayerEntity)) {
sub_08004484(tgt, &gPlayerEntity);
} else if ((tgt->kind == ENEMY) && (org == &gPlayerEntity.base)) {
sub_08004484(tgt, &gPlayerEntity.base);
}
return RESULT_NO_COLLISION;
}
CollisionResult sub_08018228(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (org == &gPlayerEntity && PlayerCanBeMoved())
if (org == &gPlayerEntity.base && PlayerCanBeMoved())
sub_08004484(tgt, org);
return RESULT_NO_COLLISION;
}
@@ -694,7 +694,7 @@ CollisionResult sub_08018250(Entity* org, Entity* tgt, u32 direction, ColSetting
}
CollisionResult CollisionMazaalShrinkRay(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
if (org == &gPlayerEntity)
if (org == &gPlayerEntity.base)
PlayerShrinkByRay();
else
org->health = 0;
@@ -716,12 +716,12 @@ CollisionResult sub_080182A8(Entity* org, Entity* tgt, u32 direction, ColSetting
CollisionResult CollisionDefault(Entity* org, Entity* tgt, u32 direction, ColSettings* settings) {
u32 confused = 0;
if (tgt->confusedTime && tgt->kind == ENEMY && org == &gPlayerEntity) {
if (tgt->confusedTime && tgt->kind == ENEMY && org == &gPlayerEntity.base) {
sub_08004484(tgt, org);
confused = 1;
}
if ((org->kind == PLAYER_ITEM && org->id == PL_ITEM_SHIELD) &&
gPlayerEntity.animationState ==
gPlayerEntity.base.animationState ==
AnimationStateFlip180(Direction8ToAnimationState(DirectionRoundUp(direction)))) {
return RESULT_NO_COLLISION;
}
@@ -780,11 +780,11 @@ CollisionResult CollisionDefault(Entity* org, Entity* tgt, u32 direction, ColSet
SoundReqClipped(tgt, SFX_HIT);
}
} else if (org->id == PL_ITEM_SHIELD) {
gPlayerEntity.iframes = 0x80;
gPlayerEntity.base.iframes = 0x80;
}
}
if (tgt->kind == PLAYER_ITEM && org->id == PL_ITEM_SHIELD) {
gPlayerEntity.iframes = 0x80;
gPlayerEntity.base.iframes = 0x80;
}
return RESULT_COLLISION;
}
+2 -2
View File
@@ -742,7 +742,7 @@ void Fuse_Action0(void) {
}
void Fuse_Action1(void) {
if ((gMessage.doTextBox & 0x7F) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
MenuFadeIn(4, 0);
gFuseInfo.fusionState = FUSION_STATE_4;
gFuseInfo.action = 2;
@@ -768,7 +768,7 @@ void Fuse_Action2(void) {
}
void Fuse_Action3(void) {
if ((gMessage.doTextBox & 0x7f) == 0) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
if (gFuseInfo.entity != NULL) {
gFuseInfo.entity->updatePriority = gFuseInfo.prevUpdatePriority;
}
+4 -4
View File
@@ -53,7 +53,7 @@ void sub_080535AC(void) {
void sub_080535F4(void) {
if (gFadeControl.active == 0) {
ResetSystemPriority();
ClearEventPriority();
gMenu.overlayType = 2;
}
}
@@ -235,7 +235,7 @@ void sub_08053758(void) {
gScreen.bg1.control = 0x1c4e;
gScreen.bg2.control = 0x1dc1;
SoundReq(BGM_STORY);
ResetSystemPriority();
ClearEventPriority();
SetFade(FADE_IN_OUT | FADE_INSTANT, 0x100);
}
@@ -345,7 +345,7 @@ void sub_08053A1C(void) {
}
void sub_08053A5C(void) {
if (((gMessage.doTextBox & 0x7f) == 0) && --gMenu.transitionTimer == 0) {
if (((gMessage.state & MESSAGE_ACTIVE) == 0) && --gMenu.transitionTimer == 0) {
gMenu.overlayType++;
SetFade(FADE_IN_OUT | FADE_INSTANT, 8);
}
@@ -452,7 +452,7 @@ void sub_08053B74(void) {
gMenu.overlayType++;
gUpdateVisibleTiles = 1;
LoadRoomEntityList(gUnk_080FCDE0);
ResetSystemPriority();
ClearEventPriority();
ResetEntityPriority();
SetFade(FADE_IN_OUT | FADE_INSTANT, 0x100);
}
+346 -327
View File
@@ -4,85 +4,104 @@
*
* @brief Acro Bandits enemy
*/
#include "enemy.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[4];
/*0x6c*/ u8 unk_6c;
/*0x6d*/ u8 unused2[1];
/*0x6e*/ u8 unk_6e;
/*0x6f*/ u8 unk_6f;
/*0x70*/ u16 unk_70;
/*0x72*/ u16 unk_72;
/*0x74*/ union SplitHWord unk_74;
/*0x76*/ union SplitHWord unk_76;
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
/*0x7a*/ u8 unk_7a;
/*0x7b*/ u8 unused6[1];
/*0x7c*/ Entity* unk_7c;
} AcroBanditEntity;
extern Entity* gUnk_020000B0;
static void sub_08031E48(Entity* this, Entity* child);
static void sub_08032290(Entity* this);
static bool32 sub_080322A4(Entity* this);
static void sub_08032338(Entity* this);
static void sub_080322E8(Entity* this);
static bool32 sub_08031E04(Entity* this);
static void sub_08031E48(AcroBanditEntity* this, AcroBanditEntity* child);
static void sub_08032290(AcroBanditEntity* this);
static bool32 sub_080322A4(AcroBanditEntity* this);
static void sub_08032338(AcroBanditEntity* this);
static void sub_080322E8(AcroBanditEntity* this);
static bool32 sub_08031E04(AcroBanditEntity* this);
void AcroBandit_OnTick(Entity* this);
void AcroBandit_OnCollision(Entity* this);
void AcroBandit_OnKnockback(Entity* this);
void GenericDeath(Entity* this);
void GenericConfused(Entity* this);
void AcroBandit_OnGrabbed(Entity* this);
void AcroBandit_Type0(Entity* this);
void AcroBandit_Type1(Entity* this);
void AcroBandit_Type0Action0(Entity* this);
void AcroBandit_Type0Action1(Entity* this);
void AcroBandit_Type0Action2(Entity* this);
void AcroBandit_Type0Action3(Entity* this);
void AcroBandit_Type0Action4(Entity* this);
void AcroBandit_Type0Action5(Entity* this);
void AcroBandit_Type0Action6(Entity* this);
void AcroBandit_Type0Action7(Entity* this);
void AcroBandit_Type0Action8(Entity* this);
void AcroBandit_Type1Init(Entity* this);
void AcroBandit_Type1Action1(Entity* this);
void AcroBandit_Type1Action2(Entity* this);
void AcroBandit_Type1Action3(Entity* this);
void AcroBandit_Type1Action4(Entity* this);
void AcroBandit_Type1Action5(Entity* this);
void AcroBandit_Type1Action6(Entity* this);
void AcroBandit_Type1Action7(Entity* this);
void AcroBandit_Type1Action8(Entity* this);
void AcroBandit_Type1Action9(Entity* this);
void AcroBandit_OnTick(AcroBanditEntity* this);
void AcroBandit_OnCollision(AcroBanditEntity* this);
void AcroBandit_OnKnockback(AcroBanditEntity* this);
void AcroBandit_OnGrabbed(AcroBanditEntity* this);
void AcroBandit_Type0(AcroBanditEntity* this);
void AcroBandit_Type1(AcroBanditEntity* this);
void AcroBandit_Type0Action0(AcroBanditEntity* this);
void AcroBandit_Type0Action1(AcroBanditEntity* this);
void AcroBandit_Type0Action2(AcroBanditEntity* this);
void AcroBandit_Type0Action3(AcroBanditEntity* this);
void AcroBandit_Type0Action4(AcroBanditEntity* this);
void AcroBandit_Type0Action5(AcroBanditEntity* this);
void AcroBandit_Type0Action6(AcroBanditEntity* this);
void AcroBandit_Type0Action7(AcroBanditEntity* this);
void AcroBandit_Type0Action8(AcroBanditEntity* this);
void AcroBandit_Type1Init(AcroBanditEntity* this);
void AcroBandit_Type1Action1(AcroBanditEntity* this);
void AcroBandit_Type1Action2(AcroBanditEntity* this);
void AcroBandit_Type1Action3(AcroBanditEntity* this);
void AcroBandit_Type1Action4(AcroBanditEntity* this);
void AcroBandit_Type1Action5(AcroBanditEntity* this);
void AcroBandit_Type1Action6(AcroBanditEntity* this);
void AcroBandit_Type1Action7(AcroBanditEntity* this);
void AcroBandit_Type1Action8(AcroBanditEntity* this);
void AcroBandit_Type1Action9(AcroBanditEntity* this);
static void (*const AcroBandit_Functions[])(Entity*) = {
AcroBandit_OnTick, AcroBandit_OnCollision, AcroBandit_OnKnockback,
GenericDeath, GenericConfused, AcroBandit_OnGrabbed,
static void (*const AcroBandit_Functions[])(AcroBanditEntity*) = {
AcroBandit_OnTick,
AcroBandit_OnCollision,
AcroBandit_OnKnockback,
(void (*)(AcroBanditEntity*))GenericDeath,
(void (*)(AcroBanditEntity*))GenericConfused,
AcroBandit_OnGrabbed,
};
void AcroBandit(Entity* this) {
void AcroBandit(AcroBanditEntity* this) {
s32 index;
index = sub_080012DC(this);
index = sub_080012DC(super);
if (index) {
if ((this->gustJarState & 1) == 0)
if ((super->gustJarState & 1) == 0)
sub_08032338(this);
gUnk_080012C8[index](this);
gUnk_080012C8[index](super);
} else {
AcroBandit_Functions[GetNextFunction(this)](this);
SetChildOffset(this, 0, 1, -0x10);
AcroBandit_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
}
}
void AcroBandit_OnTick(Entity* this) {
static void (*const typeFuncs[])(Entity*) = {
void AcroBandit_OnTick(AcroBanditEntity* this) {
static void (*const typeFuncs[])(AcroBanditEntity*) = {
AcroBandit_Type0,
AcroBandit_Type1,
};
typeFuncs[this->type](this);
typeFuncs[super->type](this);
}
void AcroBandit_OnCollision(Entity* this) {
void AcroBandit_OnCollision(AcroBanditEntity* this) {
Entity* brother;
if (this->contactFlags != 0x80 && this->contactFlags != 0x81) {
if (this->type == 1) {
if (this->action < 7 && this->knockbackDuration != 0) {
brother = this->child;
if (super->contactFlags != 0x80 && super->contactFlags != 0x81) {
if (super->type == 1) {
if (super->action < 7 && super->knockbackDuration != 0) {
brother = super->child;
if (brother != NULL) {
brother->parent = this->parent;
brother->parent = super->parent;
do {
brother->action = 5;
brother->spritePriority.b1 = 1;
@@ -90,469 +109,469 @@ void AcroBandit_OnCollision(Entity* this) {
brother->iframes = -12;
} while (brother = brother->child, brother != NULL);
}
if (this->parent != NULL) {
this->parent->child = this->child;
if (super->parent != NULL) {
super->parent->child = super->child;
} else {
if (this->child != NULL)
this->parent = this;
if (super->child != NULL)
super->parent = super;
}
this->action = 9;
this->spritePriority.b1 = 1;
if (this->knockbackDirection < 0x10) {
this->spriteSettings.flipX = 0;
super->action = 9;
super->spritePriority.b1 = 1;
if (super->knockbackDirection < 0x10) {
super->spriteSettings.flipX = 0;
} else {
this->spriteSettings.flipX = 1;
super->spriteSettings.flipX = 1;
}
InitializeAnimation(this, 14);
InitializeAnimation(super, 14);
}
if (this->health == 0) {
this->knockbackDirection = DirectionNormalize((this->knockbackDirection + (7 & Random())) - 4);
this->knockbackDuration += this->type2 * 3;
if (super->health == 0) {
super->knockbackDirection = DirectionNormalize((super->knockbackDirection + (7 & Random())) - 4);
super->knockbackDuration += super->type2 * 3;
sub_08032338(this);
}
}
if (this->knockbackDuration != 0 && this->frame & 0x10) {
if (this->type == 0) {
this->action = 8;
if (super->knockbackDuration != 0 && super->frame & 0x10) {
if (super->type == 0) {
super->action = 8;
} else {
this->action = 9;
super->action = 9;
}
if (this->knockbackDirection < 0x10) {
this->spriteSettings.flipX = 0;
if (super->knockbackDirection < 0x10) {
super->spriteSettings.flipX = 0;
} else {
this->spriteSettings.flipX = 1;
super->spriteSettings.flipX = 1;
}
this->spritePriority.b1 = 1;
InitializeAnimation(this, 14);
super->spritePriority.b1 = 1;
InitializeAnimation(super, 14);
}
}
if (this->confusedTime)
Create0x68FX(this, FX_STARS);
if (super->confusedTime)
Create0x68FX(super, FX_STARS);
EnemyFunctionHandlerAfterCollision(this, AcroBandit_Functions);
EnemyFunctionHandlerAfterCollision(super, AcroBandit_Functions);
}
void AcroBandit_OnKnockback(Entity* this) {
if (this->iframes > 0)
GravityUpdate(this, Q_8_8(24.0));
void AcroBandit_OnKnockback(AcroBanditEntity* this) {
if (super->iframes > 0)
GravityUpdate(super, Q_8_8(24.0));
GenericKnockback(this);
GenericKnockback(super);
}
void AcroBandit_OnGrabbed(Entity* this) {
void AcroBandit_OnGrabbed(AcroBanditEntity* this) {
}
void AcroBandit_Type0(Entity* this) {
static void (*const AcroBandit_Type0_Actions[])(Entity*) = {
void AcroBandit_Type0(AcroBanditEntity* this) {
static void (*const AcroBandit_Type0_Actions[])(AcroBanditEntity*) = {
AcroBandit_Type0Action0, AcroBandit_Type0Action1, AcroBandit_Type0Action2,
AcroBandit_Type0Action3, AcroBandit_Type0Action4, AcroBandit_Type0Action5,
AcroBandit_Type0Action6, AcroBandit_Type0Action7, AcroBandit_Type0Action8,
};
AcroBandit_Type0_Actions[this->action](this);
AcroBandit_Type0_Actions[super->action](this);
}
void AcroBandit_Type0Action0(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->field_0x74.HWORD = this->x.HALF.HI;
this->field_0x76.HWORD = this->y.HALF.HI;
this->field_0x78.HALF.HI = Random();
void AcroBandit_Type0Action0(AcroBanditEntity* this) {
sub_0804A720(super);
super->action = 1;
this->unk_74.HWORD = super->x.HALF.HI;
this->unk_76.HWORD = super->y.HALF.HI;
this->unk_79 = Random();
}
void AcroBandit_Type0Action1(Entity* this) {
void AcroBandit_Type0Action1(AcroBanditEntity* this) {
u32 rand;
s32 x;
s32 y;
if (this->timer != 0) {
this->timer--;
if (super->timer != 0) {
super->timer--;
} else {
if (sub_08049FDC(this, 1) != 0) {
if (sub_08049FDC(super, 1) != 0) {
rand = Random();
x = this->field_0x74.HWORD + ((s32)rand % 5) * 0x10 - 0x20;
y = this->field_0x76.HWORD + ((s32)(rand >> 4) % 5) * 0x10 - 0x20;
if (GetCollisionDataAtWorldCoords(x, y, this->collisionLayer) == 0) {
this->action = 2;
this->spriteSettings.draw = 1;
this->x.HALF.HI = x;
this->y.HALF.HI = y;
InitializeAnimation(this, 0);
x = this->unk_74.HWORD + ((s32)rand % 5) * 0x10 - 0x20;
y = this->unk_76.HWORD + ((s32)(rand >> 4) % 5) * 0x10 - 0x20;
if (GetCollisionDataAtWorldCoords(x, y, super->collisionLayer) == 0) {
super->action = 2;
super->spriteSettings.draw = 1;
super->x.HALF.HI = x;
super->y.HALF.HI = y;
InitializeAnimation(super, 0);
}
}
}
}
void AcroBandit_Type0Action2(Entity* this) {
void AcroBandit_Type0Action2(AcroBanditEntity* this) {
static const u8 timers[] = { 2, 2, 2, 3, 3, 3, 3, 4 };
GetNextFrame(this);
if (this->frame & 1) {
this->frame = 0;
COLLISION_ON(this);
GetNextFrame(super);
if (super->frame & 1) {
super->frame = 0;
COLLISION_ON(super);
} else {
if (this->frame & ANIM_DONE) {
this->action = 0x3;
this->timer = timers[Random() & 7];
InitializeAnimation(this, 1);
if (super->frame & ANIM_DONE) {
super->action = 0x3;
super->timer = timers[Random() & 7];
InitializeAnimation(super, 1);
}
}
}
void AcroBandit_Type0Action3(Entity* this) {
void AcroBandit_Type0Action3(AcroBanditEntity* this) {
if (sub_08031E04(this)) {
this->action = 5;
if (this->x.HALF.HI > gUnk_020000B0->x.HALF.HI) {
this->spriteSettings.flipX = 0;
super->action = 5;
if (super->x.HALF.HI > gUnk_020000B0->x.HALF.HI) {
super->spriteSettings.flipX = 0;
} else {
this->spriteSettings.flipX = 1;
super->spriteSettings.flipX = 1;
}
InitializeAnimation(this, 3);
InitializeAnimation(super, 3);
} else {
if ((this->frame & 1) && this->timer) {
this->frame &= 0xfe;
this->timer--;
if ((super->frame & 1) && super->timer) {
super->frame &= 0xfe;
super->timer--;
}
GetNextFrame(this);
if (this->timer == 0) {
this->action = 4;
COLLISION_OFF(this);
InitializeAnimation(this, 2);
GetNextFrame(super);
if (super->timer == 0) {
super->action = 4;
COLLISION_OFF(super);
InitializeAnimation(super, 2);
}
}
}
void AcroBandit_Type0Action4(Entity* this) {
void AcroBandit_Type0Action4(AcroBanditEntity* this) {
static const u8 timers[] = { 60, 60, 90, 120, 120, 120, 120, 150 };
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 1;
this->timer = timers[Random() & 7];
this->spriteSettings.draw = 0;
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 1;
super->timer = timers[Random() & 7];
super->spriteSettings.draw = 0;
}
}
void AcroBandit_Type0Action5(Entity* this) {
Entity *a, *b;
void AcroBandit_Type0Action5(AcroBanditEntity* this) {
AcroBanditEntity *a, *b;
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
if (gEntCount < MAX_ENTITIES - 4) {
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
if (gEntCount < MAX_ENTITIES - 5) {
u32 tmp = Random();
tmp &= 3;
a = CreateEnemy(ACRO_BANDIT, 1);
a->type2 = 0;
a->parent = NULL;
a->field_0x74.HALF.LO = tmp;
a = (AcroBanditEntity*)CreateEnemy(ACRO_BANDIT, 1);
a->base.type2 = 0;
a->base.parent = NULL;
a->unk_74.HALF.LO = tmp;
sub_08031E48(this, a);
a->child = CreateEnemy(ACRO_BANDIT, 1);
a->base.child = CreateEnemy(ACRO_BANDIT, 1);
b = a->child;
b->type2 = 1;
b->parent = a;
b->field_0x74.HALF.LO = tmp;
b = (AcroBanditEntity*)a->base.child;
b->base.type2 = 1;
b->base.parent = &a->base;
b->unk_74.HALF.LO = tmp;
sub_08031E48(this, b);
b->child = CreateEnemy(ACRO_BANDIT, 1);
b->base.child = CreateEnemy(ACRO_BANDIT, 1);
a = b->child;
a->type2 = 2;
a->parent = b;
a->field_0x74.HALF.LO = tmp;
a = (AcroBanditEntity*)b->base.child;
a->base.type2 = 2;
a->base.parent = &b->base;
a->unk_74.HALF.LO = tmp;
sub_08031E48(this, a);
a->child = CreateEnemy(ACRO_BANDIT, 1);
a->base.child = CreateEnemy(ACRO_BANDIT, 1);
b = a->child;
b->type2 = 3;
b->parent = a;
b->field_0x74.HALF.LO = tmp;
b = (AcroBanditEntity*)a->base.child;
b->base.type2 = 3;
b->base.parent = &a->base;
b->unk_74.HALF.LO = tmp;
sub_08031E48(this, b);
b->child = CreateEnemy(ACRO_BANDIT, 1);
b->base.child = CreateEnemy(ACRO_BANDIT, 1);
a = b->child;
a->type2 = 4;
a->parent = b;
a->child = NULL;
a->field_0x74.HALF.LO = tmp;
a = (AcroBanditEntity*)b->base.child;
a->base.type2 = 4;
a->base.parent = &b->base;
a->base.child = NULL;
a->unk_74.HALF.LO = tmp;
sub_08031E48(this, a);
this->action = 6;
this->timer = 20;
this->spritePriority.b0 = 7;
InitializeAnimation(this, 7);
super->action = 6;
super->timer = 20;
super->spritePriority.b0 = 7;
InitializeAnimation(super, 7);
}
} else {
if (this->frame & 1) {
this->frame = 0;
COLLISION_OFF(this);
if (super->frame & 1) {
super->frame = 0;
COLLISION_OFF(super);
}
}
}
void AcroBandit_Type0Action6(Entity* this) {
GetNextFrame(this);
if (--this->timer == 0) {
this->action = 7;
COLLISION_OFF(this);
this->timer = 5;
this->spriteSettings.draw = 0;
void AcroBandit_Type0Action6(AcroBanditEntity* this) {
GetNextFrame(super);
if (--super->timer == 0) {
super->action = 7;
COLLISION_OFF(super);
super->timer = 5;
super->spriteSettings.draw = 0;
}
}
void AcroBandit_Type0Action7(Entity* this) {
if ((this->timer & 0xF) == 0) {
if (this->timer == 80) {
DeleteEntity(this);
void AcroBandit_Type0Action7(AcroBanditEntity* this) {
if ((super->timer & 0xF) == 0) {
if (super->timer == 80) {
DeleteEntity(super);
} else {
this->action = 1;
this->timer = 180;
super->action = 1;
super->timer = 180;
}
}
}
void AcroBandit_Type0Action8(Entity* this) {
if (this->frame & ANIM_DONE) {
this->action = 1;
this->timer = 180;
this->spriteSettings.draw = 0;
void AcroBandit_Type0Action8(AcroBanditEntity* this) {
if (super->frame & ANIM_DONE) {
super->action = 1;
super->timer = 180;
super->spriteSettings.draw = 0;
} else {
GetNextFrame(this);
if ((this->frame & 0xf) == 2) {
COLLISION_OFF(this);
GetNextFrame(super);
if ((super->frame & 0xf) == 2) {
COLLISION_OFF(super);
}
}
}
static bool32 sub_08031E04(Entity* this) {
static bool32 sub_08031E04(AcroBanditEntity* this) {
static const s8 gUnk_080CE5C0[] = { -32, 0, 0, 32, 32, 0, 0, 0 };
Entity* ent;
Entity* entity;
const s8* tmp;
ent = sub_08049DF4(1);
if (ent == NULL)
entity = sub_08049DF4(1);
if (entity == NULL)
return FALSE;
tmp = &gUnk_080CE5C0[this->frame & 6];
return EntityWithinDistance(this, ent->x.HALF.HI + tmp[0], ent->y.HALF.HI + tmp[1], 0x50);
tmp = &gUnk_080CE5C0[super->frame & 6];
return EntityWithinDistance(super, entity->x.HALF.HI + tmp[0], entity->y.HALF.HI + tmp[1], 0x50);
}
static void sub_08031E48(Entity* this, Entity* child) {
CopyPosition(this, child);
child->field_0x6c.HALF.LO = this->field_0x6c.HALF.LO;
child->field_0x70.HALF.LO = this->field_0x70.HALF.LO;
child->field_0x70.HALF.HI = this->field_0x70.HALF.HI;
child->field_0x6e.HALF.LO = this->field_0x6e.HALF.LO;
child->field_0x6e.HALF.HI = this->field_0x6e.HALF.HI;
child->field_0x7c.WORD = (s32)this;
static void sub_08031E48(AcroBanditEntity* this, AcroBanditEntity* child) {
CopyPosition(super, &child->base);
child->unk_6c = this->unk_6c;
child->unk_70 = this->unk_70;
child->unk_72 = this->unk_72;
child->unk_6e = this->unk_6e;
child->unk_6f = this->unk_6f;
child->unk_7c = super;
}
void AcroBandit_Type1(Entity* this) {
static void (*const AcroBandit_Type1_Actions[])(Entity*) = {
void AcroBandit_Type1(AcroBanditEntity* this) {
static void (*const AcroBandit_Type1_Actions[])(AcroBanditEntity*) = {
AcroBandit_Type1Init, AcroBandit_Type1Action1, AcroBandit_Type1Action2, AcroBandit_Type1Action3,
AcroBandit_Type1Action4, AcroBandit_Type1Action5, AcroBandit_Type1Action6, AcroBandit_Type1Action7,
AcroBandit_Type1Action8, AcroBandit_Type1Action9,
};
AcroBandit_Type1_Actions[this->action](this);
AcroBandit_Type1_Actions[super->action](this);
}
void AcroBandit_Type1Init(Entity* this) {
this->action = 1;
this->spritePriority.b1 = 1;
this->zVelocity = Q_16_16(4.0);
this->z.HALF.HI = (4 - this->type2) * 0xe;
this->field_0x78.HALF.HI = Random();
InitializeAnimation(this, 4);
void AcroBandit_Type1Init(AcroBanditEntity* this) {
super->action = 1;
super->spritePriority.b1 = 1;
super->zVelocity = Q_16_16(4.0);
super->z.HALF.HI = (4 - super->type2) * 0xe;
this->unk_79 = Random();
InitializeAnimation(super, 4);
}
void AcroBandit_Type1Action1(Entity* this) {
void AcroBandit_Type1Action1(AcroBanditEntity* this) {
int draw;
this->z.WORD -= this->zVelocity;
this->zVelocity -= Q_16_16(3.0 / 32.0);
super->z.WORD -= super->zVelocity;
super->zVelocity -= Q_16_16(3.0 / 32.0);
if (this->z.HALF.HI < 1) {
draw = this->spriteSettings.draw;
if (super->z.HALF.HI < 1) {
draw = super->spriteSettings.draw;
if (!draw)
EnqueueSFX(SFX_12B);
this->spriteSettings.draw = 1;
super->spriteSettings.draw = 1;
}
draw = this->spriteSettings.draw;
draw = super->spriteSettings.draw;
if (draw == 1)
GetNextFrame(this);
GetNextFrame(super);
if (this->zVelocity <= 0) {
this->action = 2;
COLLISION_ON(this);
InitializeAnimation(this, 5);
if (super->zVelocity <= 0) {
super->action = 2;
COLLISION_ON(super);
InitializeAnimation(super, 5);
}
}
void AcroBandit_Type1Action2(Entity* this) {
void AcroBandit_Type1Action2(AcroBanditEntity* this) {
static const u16 banditGravity[] = { Q_8_8(22.0), Q_8_8(19.0), Q_8_8(16.0), Q_8_8(13.0), Q_8_8(11.0) };
GravityUpdate(this, banditGravity[this->type2]);
if (this->type2 * -0xe <= this->z.HALF.HI) {
this->action = 3;
this->timer = 20;
this->z.HALF.HI = this->type2 * -0xe;
if (this->parent != NULL)
this->spritePriority.b1 = 0;
InitializeAnimation(this, 6);
GravityUpdate(super, banditGravity[super->type2]);
if (super->type2 * -0xe <= super->z.HALF.HI) {
super->action = 3;
super->timer = 20;
super->z.HALF.HI = super->type2 * -0xe;
if (super->parent != NULL)
super->spritePriority.b1 = 0;
InitializeAnimation(super, 6);
}
}
void AcroBandit_Type1Action3(Entity* this) {
GetNextFrame(this);
if ((this->frame & ANIM_DONE) && ((this->parent != NULL) || (--this->timer == 0))) {
this->action = 4;
this->direction = sub_08049F84(this, 1);
*(u8*)&this->field_0x76 = 0;
if (this->child != NULL) {
InitializeAnimation(this, 9);
void AcroBandit_Type1Action3(AcroBanditEntity* this) {
GetNextFrame(super);
if ((super->frame & ANIM_DONE) && ((super->parent != NULL) || (--super->timer == 0))) {
super->action = 4;
super->direction = sub_08049F84(super, 1);
this->unk_76.HALF.LO = 0;
if (super->child != NULL) {
InitializeAnimation(super, 9);
} else {
InitializeAnimation(this, 8);
InitializeAnimation(super, 8);
}
}
}
void AcroBandit_Type1Action4(Entity* this) {
void AcroBandit_Type1Action4(AcroBanditEntity* this) {
Entity* parent;
if (!sub_080322A4(this)) {
parent = this->parent;
parent = super->parent;
if (parent == NULL) {
if (sub_08049FDC(this, 1)) {
if ((++this->field_0x78.HALF.HI & 7) == 0) {
sub_08004596(this, GetFacingDirection(this, gUnk_020000B0));
if (sub_08049FDC(super, 1)) {
if ((++this->unk_79 & 7) == 0) {
sub_08004596(super, GetFacingDirection(super, gUnk_020000B0));
}
this->field_0x76.HALF.LO = 0;
this->unk_76.HALF.LO = 0;
} else {
if (this->field_0x76.HALF.LO) {
(this->field_0x76.HALF.LO)--;
sub_08004596(this, this->field_0x7a.HALF.LO);
if (this->unk_76.HALF.LO) {
(this->unk_76.HALF.LO)--;
sub_08004596(super, this->unk_7a);
} else {
this->field_0x76.HALF.LO = 0x10;
if (sub_08049FA0(this) == 0 && (Random() & 1)) {
this->field_0x7a.HALF.LO = sub_08049EE4(this);
this->unk_76.HALF.LO = 0x10;
if (sub_08049FA0(super) == 0 && (Random() & 1)) {
this->unk_7a = sub_08049EE4(super);
} else {
this->field_0x7a.HALF.LO = Random() & 30;
this->unk_7a = Random() & 30;
}
}
}
if (this->direction & (0x3 | DirectionEast | DIR_DIAGONAL))
this->spriteSettings.flipX = (this->direction >> 4 ^ 1);
if (super->direction & (0x3 | DirectionEast | DIR_DIAGONAL))
super->spriteSettings.flipX = (super->direction >> 4 ^ 1);
ProcessMovement0(this);
ProcessMovement0(super);
} else {
if (this->field_0x76.HALF.HI == 0) {
if (EntityWithinDistance(this, parent->x.HALF.HI, parent->y.HALF.HI, 1) == 0) {
this->field_0x76.HALF.HI = 1;
this->direction = GetFacingDirection(this, parent);
if (this->unk_76.HALF.HI == 0) {
if (EntityWithinDistance(super, parent->x.HALF.HI, parent->y.HALF.HI, 1) == 0) {
this->unk_76.HALF.HI = 1;
super->direction = GetFacingDirection(super, parent);
sub_080322E8(this);
LinearMoveUpdate(this);
LinearMoveUpdate(super);
}
} else {
this->direction = GetFacingDirection(this, parent);
super->direction = GetFacingDirection(super, parent);
sub_080322E8(this);
LinearMoveUpdate(this);
if (this->x.HALF.HI == parent->x.HALF.HI && this->y.HALF.HI == parent->y.HALF.HI)
this->field_0x76.HALF.HI = 0;
LinearMoveUpdate(super);
if (super->x.HALF.HI == parent->x.HALF.HI && super->y.HALF.HI == parent->y.HALF.HI)
this->unk_76.HALF.HI = 0;
}
}
GetNextFrame(this);
GetNextFrame(super);
}
}
void AcroBandit_Type1Action5(Entity* this) {
if (GravityUpdate(this, Q_8_8(32.0)))
void AcroBandit_Type1Action5(AcroBanditEntity* this) {
if (GravityUpdate(super, Q_8_8(32.0)))
return;
sub_08032290(this);
}
void AcroBandit_Type1Action6(Entity* this) {
void AcroBandit_Type1Action6(AcroBanditEntity* this) {
static const u8 fallDirections[] = { 0x8, 0x1c, 0x11, 0x2, 0x15, 0xc, 0x0, 0x15, 0x6, 0x19,
0x10, 0x4, 0x19, 0xa, 0x1d, 0x14, 0x8, 0x1d, 0xe, 0x1 };
Entity* tmp;
u32 dir;
if (this->timer == 0) {
this->action = 7;
dir = fallDirections[this->field_0x74.HALF.LO * 5 + this->type2];
this->direction = dir;
if (super->timer == 0) {
super->action = 7;
dir = fallDirections[this->unk_74.HALF.LO * 5 + super->type2];
super->direction = dir;
if (dir >= DirectionSouth) {
this->spriteSettings.flipX = 1;
super->spriteSettings.flipX = 1;
} else {
this->spriteSettings.flipX = 0;
super->spriteSettings.flipX = 0;
}
this->speed = 0xf0;
this->zVelocity = Q_16_16(1.125);
this->spritePriority.b1 = 1;
InitializeAnimation(this, 12);
super->speed = 0xf0;
super->zVelocity = Q_16_16(1.125);
super->spritePriority.b1 = 1;
InitializeAnimation(super, 12);
}
if (this->child == NULL) {
for (tmp = this->parent; tmp != NULL; tmp = tmp->parent) {
if (super->child == NULL) {
for (tmp = super->parent; tmp != NULL; tmp = tmp->parent) {
if (tmp->health != 0)
tmp->timer = 0;
}
this->timer = 0;
super->timer = 0;
}
}
void AcroBandit_Type1Action7(Entity* this) {
ProcessMovement2(this);
void AcroBandit_Type1Action7(AcroBanditEntity* this) {
ProcessMovement2(super);
if (sub_080044EC(this, 0x2000) == 0)
this->action = 8;
if (sub_080044EC(super, 0x2000) == 0)
super->action = 8;
}
void AcroBandit_Type1Action8(Entity* this) {
GetNextFrame(this);
if (this->frame & 1) {
this->frame = 0;
this->frameDuration = (Random() & 0x30) + 30;
void AcroBandit_Type1Action8(AcroBanditEntity* this) {
GetNextFrame(super);
if (super->frame & 1) {
super->frame = 0;
super->frameDuration = (Random() & 0x30) + 30;
} else {
if (this->frame & ANIM_DONE) {
this->action = 9;
InitializeAnimation(this, 13);
if (super->frame & ANIM_DONE) {
super->action = 9;
InitializeAnimation(super, 13);
}
}
}
void AcroBandit_Type1Action9(Entity* this) {
if (GravityUpdate(this, Q_8_8(24.0)) == 0) {
if (this->frame & ANIM_DONE) {
((Entity*)this->field_0x7c.WORD)->timer--;
void AcroBandit_Type1Action9(AcroBanditEntity* this) {
if (GravityUpdate(super, Q_8_8(24.0)) == 0) {
if (super->frame & ANIM_DONE) {
this->unk_7c->timer--;
DeleteEntity(this);
DeleteEntity(super);
} else {
GetNextFrame(this);
GetNextFrame(super);
if ((this->frame & 0xf) == 2)
COLLISION_OFF(this);
if ((super->frame & 0xf) == 2)
COLLISION_OFF(super);
}
}
}
static void sub_08032290(Entity* this) {
this->action = 6;
this->timer = 12;
InitializeAnimation(this, 11);
static void sub_08032290(AcroBanditEntity* this) {
super->action = 6;
super->timer = 12;
InitializeAnimation(super, 11);
}
static bool32 sub_080322A4(Entity* this) {
if (this->child != NULL && (this->child->z.HALF.HI + 8) >= this->z.HALF.HI) {
if (this->z.HALF.HI) {
this->action = 5;
this->z.HALF.HI = this->child->z.HALF.HI + 8;
InitializeAnimation(this, 11);
static bool32 sub_080322A4(AcroBanditEntity* this) {
if (super->child != NULL && (super->child->z.HALF.HI + 8) >= super->z.HALF.HI) {
if (super->z.HALF.HI) {
super->action = 5;
super->z.HALF.HI = super->child->z.HALF.HI + 8;
InitializeAnimation(super, 11);
return TRUE;
} else {
sub_08032290(this);
@@ -562,25 +581,25 @@ static bool32 sub_080322A4(Entity* this) {
return FALSE;
}
static void sub_080322E8(Entity* this) {
if (this->field_0x78.HALF.LO) {
if (--this->field_0x78.HALF.LO == 0) {
u32 flipX = this->spriteSettings.flipX;
this->spriteSettings.flipX = flipX ^ 1;
static void sub_080322E8(AcroBanditEntity* this) {
if (this->unk_78) {
if (--this->unk_78 == 0) {
u32 flipX = super->spriteSettings.flipX;
super->spriteSettings.flipX = flipX ^ 1;
}
} else {
u8 tmp = this->direction;
u8 tmp = super->direction;
if (tmp & (0x3 | DirectionEast | DIR_DIAGONAL)) {
tmp >>= 4;
tmp ^= 1;
if (tmp != this->spriteSettings.flipX) {
this->field_0x78.HALF.LO = 6;
if (tmp != super->spriteSettings.flipX) {
this->unk_78 = 6;
}
}
}
}
static void sub_08032338(Entity* this) {
if ((((Entity*)this->field_0x7c.WORD)->timer += 15) != 80)
this->field_0x6c.HALF.LO = 0;
static void sub_08032338(AcroBanditEntity* this) {
if ((this->unk_7c->timer += 15) != 80)
this->unk_6c = 0;
}
+4 -6
View File
@@ -4,8 +4,6 @@
*
* @brief Armos enemy
*/
#define NENT_DEPRECATED
#include "collision.h"
#include "common.h"
#include "enemy.h"
@@ -64,8 +62,8 @@ void sub_080300C4(void) {
void sub_080300E8(void) {
if (gRoomTransition.armos_data.field_0xae != 0xff) {
const u16* ptr = &gRoomTransition.armos_data.data[gRoomTransition.armos_data.field_0xae * 2];
gPlayerEntity.x.HALF.HI = ptr[0];
gPlayerEntity.y.HALF.HI = ptr[1] + 0xc;
gPlayerEntity.base.x.HALF.HI = ptr[0];
gPlayerEntity.base.y.HALF.HI = ptr[1] + 0xc;
gRoomTransition.armos_data.field_0xae = 0xff;
}
}
@@ -96,7 +94,7 @@ void sub_080301BC(ArmosEntity* this) {
}
void sub_080301D4(ArmosEntity* this) {
if ((super->action == 1) && (super->contactedEntity == &gPlayerEntity)) {
if ((super->action == 1) && (super->contactedEntity == &gPlayerEntity.base)) {
super->iframes = -0x1e;
}
if ((super->health != 0) && (super->health != this->unk_81)) {
@@ -432,7 +430,7 @@ bool32 sub_0803086C(ArmosEntity* this) {
if (GetMetaTileType(metaTilePos, super->collisionLayer) == SPECIAL_META_TILE_73) {
if (CheckPlayerInRegion(centerX, centerY, 2, 0xc) != 0) {
if (CheckPlayerInRegion(centerX, centerY - 4, 2, 4) != 0) {
gPlayerEntity.spritePriority.b0 = 3;
gPlayerEntity.base.spritePriority.b0 = 3;
DoExitTransition(this->unk_7c);
gRoomTransition.armos_data.field_0xae = this->unk_80;
return TRUE;
+12 -7
View File
@@ -1,6 +1,11 @@
#define NENT_DEPRECATED
#include "entity.h"
/**
* @file ballChainSoldier.c
* @ingroup Enemies
*
* @brief Ball Chain Soldier enemy
*/
#include "enemy.h"
#include "entity.h"
#include "functions.h"
typedef struct {
@@ -57,14 +62,14 @@ void BallChainSoldier_OnGrabbed(BallChainSoldierEntity* this) {
}
void BallChainSoldier_Init(BallChainSoldierEntity* this) {
Entity* ent;
Entity* entity;
sub_0804A720(super);
ent = CreateProjectileWithParent(super, BALL_AND_CHAIN, 0);
if (ent == NULL)
entity = CreateProjectileWithParent(super, BALL_AND_CHAIN, 0);
if (entity == NULL)
return;
ent->parent = super;
super->child = ent;
entity->parent = super;
super->child = entity;
COLLISION_ON(super);
super->spriteSettings.draw = 1;
super->animationState = Random() & 3;
+188 -182
View File
@@ -4,44 +4,50 @@
*
* @brief Beetle enemy
*/
#include "enemy.h"
#include "functions.h"
u32 sub_08021D00(Entity*);
void sub_08021D44(Entity* this, u32 direction);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[30];
/*0x86*/ u8 unk_86;
/*0x87*/ u8 unk_87;
} BeetleEntity;
extern void (*const Beetle_Functions[])(Entity*);
extern void (*const gUnk_080CB5A8[])(Entity*);
extern void (*const gUnk_080CB5C8[])(Entity*);
extern void (*const gUnk_080CB5D4[])(Entity*);
u32 sub_08021D00(BeetleEntity*);
void sub_08021D44(BeetleEntity* this, u32 direction);
extern void (*const Beetle_Functions[])(BeetleEntity*);
extern void (*const gUnk_080CB5A8[])(BeetleEntity*);
extern void (*const gUnk_080CB5C8[])(BeetleEntity*);
extern void (*const gUnk_080CB5D4[])(BeetleEntity*);
extern const s8 gUnk_080CB5DC[];
extern const s8 gUnk_080CB5E4[];
void Beetle(Entity* this) {
EnemyFunctionHandler(this, Beetle_Functions);
void Beetle(BeetleEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Beetle_Functions);
}
void Beetle_OnTick(Entity* this) {
gUnk_080CB5A8[this->action](this);
void Beetle_OnTick(BeetleEntity* this) {
gUnk_080CB5A8[super->action](this);
}
void Beetle_OnCollision(Entity* this) {
switch (this->contactFlags) {
void Beetle_OnCollision(BeetleEntity* this) {
switch (super->contactFlags) {
case 0x80:
if (gPlayerState.framestate == PL_STATE_CLIMB) {
Beetle_OnTick(this);
} else {
this->action = 5;
this->timer = 180;
this->subtimer = 0;
COLLISION_OFF(this);
this->spritePriority.b0 = 3;
CopyPositionAndSpriteOffset(&gPlayerEntity, this);
this->z.HALF.HI = -1;
((u8*)&this->field_0x86)[1] = 1;
InitializeAnimation(this, 6);
super->action = 5;
super->timer = 180;
super->subtimer = 0;
COLLISION_OFF(super);
super->spritePriority.b0 = 3;
CopyPositionAndSpriteOffset(&gPlayerEntity.base, super);
super->z.HALF.HI = -1;
this->unk_87 = 1;
InitializeAnimation(super, 6);
}
break;
case 0x93:
@@ -49,289 +55,289 @@ void Beetle_OnCollision(Entity* this) {
break;
}
if (this->health == 0)
this->knockbackDuration = 0;
if (super->health == 0)
super->knockbackDuration = 0;
EnemyFunctionHandlerAfterCollision(this, Beetle_Functions);
EnemyFunctionHandlerAfterCollision(super, Beetle_Functions);
}
void Beetle_OnDeath(Entity* this) {
if (this->type == 0) {
GenericDeath(this);
void Beetle_OnDeath(BeetleEntity* this) {
if (super->type == 0) {
GenericDeath(super);
} else {
Entity* ent = this->parent;
if (ent != NULL) {
ent->subtimer--;
this->parent = NULL;
Entity* entity = super->parent;
if (entity != NULL) {
entity->subtimer--;
super->parent = NULL;
}
CreateDeathFx(this, 0xf0, 0);
CreateDeathFx(super, 0xf0, 0);
}
}
void Beetle_OnGrabbed(Entity* this) {
if (sub_0806F520(this)) {
gUnk_080CB5C8[this->subAction](this);
void Beetle_OnGrabbed(BeetleEntity* this) {
if (sub_0806F520(super)) {
gUnk_080CB5C8[super->subAction](this);
} else {
this->action = 3;
this->z.HALF.HI = 0;
InitializeAnimation(this, 2);
super->action = 3;
super->z.HALF.HI = 0;
InitializeAnimation(super, 2);
}
}
void sub_0802187C(Entity* this) {
this->subAction = 2;
void sub_0802187C(BeetleEntity* this) {
super->subAction = 2;
}
void nullsub_130(Entity* this) {
void nullsub_130(BeetleEntity* this) {
}
void sub_08021888(Entity* this) {
if (sub_0806F3E4(this))
void sub_08021888(BeetleEntity* this) {
if (sub_0806F3E4(super))
Beetle_OnDeath(this);
}
void Beetle_Initialize(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->gustJarFlags = 1;
InitializeAnimation(this, 3);
void Beetle_Initialize(BeetleEntity* this) {
sub_0804A720(super);
super->action = 1;
super->gustJarFlags = 1;
InitializeAnimation(super, 3);
}
void sub_080218B4(Entity* this) {
gUnk_080CB5D4[this->type2](this);
void sub_080218B4(BeetleEntity* this) {
gUnk_080CB5D4[super->type2](this);
}
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]) &
(0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest);
this->speed = 0x100;
this->zVelocity = Q_16_16(1.125);
void sub_080218CC(BeetleEntity* this) {
if (super->subAction == 0) {
super->subAction = 1;
super->spriteSettings.draw = 1;
super->direction = ((sub_08049F84(super, 1) ^ 0x10) + gUnk_080CB5DC[Random() & 7]) &
(0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest);
super->speed = 0x100;
super->zVelocity = Q_16_16(1.125);
}
GetNextFrame(this);
if (this->frame & 1) {
ProcessMovement2(this);
if (sub_080044EC(this, 0x1c00) == 0)
this->frameDuration = 1;
GetNextFrame(super);
if (super->frame & 1) {
ProcessMovement2(super);
if (sub_080044EC(super, 0x1c00) == 0)
super->frameDuration = 1;
}
if (this->frame & ANIM_DONE) {
this->action = 2;
this->timer = (Random() & 0x38) + 8;
this->subtimer = 1;
COLLISION_ON(this);
this->speed = 0x180;
InitializeAnimation(this, 0);
if (super->frame & ANIM_DONE) {
super->action = 2;
super->timer = (Random() & 0x38) + 8;
super->subtimer = 1;
COLLISION_ON(super);
super->speed = 0x180;
InitializeAnimation(super, 0);
}
}
void sub_08021984(Entity* this) {
if (this->subAction == 0) {
this->subAction = 1;
COLLISION_ON(this);
this->spriteSettings.draw = 3;
this->z.HALF.HI = -0x80;
this->spriteRendering.b3 = 1;
this->spriteOrientation.flipY = 1;
void sub_08021984(BeetleEntity* this) {
if (super->subAction == 0) {
super->subAction = 1;
COLLISION_ON(super);
super->spriteSettings.draw = 3;
super->z.HALF.HI = -0x80;
super->spriteRendering.b3 = 1;
super->spriteOrientation.flipY = 1;
EnqueueSFX(SFX_12D);
}
if (GravityUpdate(this, Q_8_8(24.0)) == 0) {
this->action = 2;
this->timer = 16;
this->subtimer = 1;
this->spriteSettings.draw = 1;
this->speed = 0x180;
((u8*)&this->field_0x86)[0] = 60;
InitializeAnimation(this, 0);
UpdateSpriteForCollisionLayer(this);
if (GravityUpdate(super, Q_8_8(24.0)) == 0) {
super->action = 2;
super->timer = 16;
super->subtimer = 1;
super->spriteSettings.draw = 1;
super->speed = 0x180;
this->unk_86 = 60;
InitializeAnimation(super, 0);
UpdateSpriteForCollisionLayer(super);
}
}
void sub_08021A10(Entity* this) {
GetNextFrame(this);
if (EntityInRectRadius(this, &gPlayerEntity, 120, 80) && sub_08021D00(this) == 0) {
if (--this->timer == 0) {
this->action = 3;
this->timer = (Random() & 0x3f) + 30;
sub_08021D44(this, this->direction);
InitializeAnimation(this, 2);
void sub_08021A10(BeetleEntity* this) {
GetNextFrame(super);
if (EntityInRectRadius(super, &gPlayerEntity.base, 120, 80) && sub_08021D00(this) == 0) {
if (--super->timer == 0) {
super->action = 3;
super->timer = (Random() & 0x3f) + 30;
sub_08021D44(this, super->direction);
InitializeAnimation(super, 2);
}
}
}
void sub_08021A64(Entity* this) {
void sub_08021A64(BeetleEntity* this) {
if (!sub_08021D00(this)) {
if (--this->timer == 0) {
this->action = 2;
this->timer = (Random() & 0x1F) + 30;
InitializeAnimation(this, 0);
if (--super->timer == 0) {
super->action = 2;
super->timer = (Random() & 0x1F) + 30;
InitializeAnimation(super, 0);
}
if (--this->subtimer == 0) {
if (--super->subtimer == 0) {
u32 tmp;
this->subtimer = 8;
tmp = sub_08049F84(this, 1);
super->subtimer = 8;
tmp = sub_08049F84(super, 1);
if (tmp == 0xff) {
this->action = 7;
InitializeAnimation(this, 1);
super->action = 7;
InitializeAnimation(super, 1);
return;
}
sub_08021D44(this, tmp);
}
ProcessMovement0(this);
GetNextFrame(this);
ProcessMovement0(super);
GetNextFrame(super);
}
}
void sub_08021AD8(Entity* this) {
GetNextFrame(this);
if (this->frame & 1) {
if (this->timer != 0) {
void sub_08021AD8(BeetleEntity* this) {
GetNextFrame(super);
if (super->frame & 1) {
if (super->timer != 0) {
u32 tmp;
this->timer = 0;
tmp = sub_08049F84(this, 1);
super->timer = 0;
tmp = sub_08049F84(super, 1);
if (tmp == 0xff) {
this->action = 2;
this->timer = 8;
InitializeAnimation(this, 0);
super->action = 2;
super->timer = 8;
InitializeAnimation(super, 0);
return;
}
this->direction = (u8)tmp;
super->direction = (u8)tmp;
EnqueueSFX(SFX_PLY_JUMP);
}
ProcessMovement2(this);
if (!GravityUpdate(this, Q_8_8(24.0)))
this->frameDuration = 1;
ProcessMovement2(super);
if (!GravityUpdate(super, Q_8_8(24.0)))
super->frameDuration = 1;
}
if (this->frame & ANIM_DONE) {
this->action = 2;
this->timer = 20;
((u8*)&this->field_0x86)[0] = 60;
InitializeAnimation(this, 0);
if (super->frame & ANIM_DONE) {
super->action = 2;
super->timer = 20;
this->unk_86 = 60;
InitializeAnimation(super, 0);
}
}
void sub_08021B64(Entity* this) {
void sub_08021B64(BeetleEntity* this) {
if (gPlayerState.flags & PL_DROWNING) {
this->action = 3;
this->z.WORD = 0;
InitializeAnimation(this, 2);
super->action = 3;
super->z.WORD = 0;
InitializeAnimation(super, 2);
} else {
s32 iVar4 = 1;
if (gPlayerState.framestate != PL_STATE_JUMP && gPlayerState.framestate != PL_STATE_CAPE) {
if (sub_0807953C())
iVar4 = this->type * 3 + 8;
iVar4 = super->type * 3 + 8;
iVar4 = this->timer - iVar4;
iVar4 = super->timer - iVar4;
if (iVar4 < 0)
iVar4 = 0;
this->timer = (u8)iVar4;
super->timer = (u8)iVar4;
}
if (gPlayerState.flags & (PL_DISABLE_ITEMS | PL_CAPTURED))
iVar4 = 0;
if (iVar4 == 0) {
this->action = 6;
this->zVelocity = Q_16_16(1.0);
((u8*)&this->field_0x86)[1] = 0;
if (gPlayerEntity.direction != 0xff) {
this->direction = DirectionSouth ^ gPlayerEntity.direction;
super->action = 6;
super->zVelocity = Q_16_16(1.0);
this->unk_87 = 0;
if (gPlayerEntity.base.direction != 0xff) {
super->direction = DirectionSouth ^ gPlayerEntity.base.direction;
} else {
this->direction = (gPlayerEntity.animationState << 2) ^ DirectionSouth;
super->direction = (gPlayerEntity.base.animationState << 2) ^ DirectionSouth;
}
InitializeAnimation(this, 5);
InitializeAnimation(super, 5);
} else {
gPlayerState.mobility |= 0x80;
gPlayerState.speed_modifier -= 0x50;
gPlayerState.attachedBeetleCount++;
CopyPositionAndSpriteOffset(&gPlayerEntity, this);
this->x.HALF.HI += gUnk_080CB5E4[(this->subtimer++ & 0xe) >> 1];
this->z.HALF.HI--;
GetNextFrame(this);
CopyPositionAndSpriteOffset(&gPlayerEntity.base, super);
super->x.HALF.HI += gUnk_080CB5E4[(super->subtimer++ & 0xe) >> 1];
super->z.HALF.HI--;
GetNextFrame(super);
}
}
}
void sub_08021C58(Entity* this) {
GetNextFrame(this);
if (this->frame & 1) {
ProcessMovement2(this);
if (GravityUpdate(this, Q_8_8(24.0)) == 0)
this->frameDuration = 1;
void sub_08021C58(BeetleEntity* this) {
GetNextFrame(super);
if (super->frame & 1) {
ProcessMovement2(super);
if (GravityUpdate(super, Q_8_8(24.0)) == 0)
super->frameDuration = 1;
}
if (this->frame & ANIM_DONE) {
this->action = 2;
this->timer = 60;
this->subtimer = 1;
COLLISION_ON(this);
this->spritePriority.b0 = 4;
((u8*)&this->field_0x86)[0] = 60;
InitializeAnimation(this, 0);
if (super->frame & ANIM_DONE) {
super->action = 2;
super->timer = 60;
super->subtimer = 1;
COLLISION_ON(super);
super->spritePriority.b0 = 4;
this->unk_86 = 60;
InitializeAnimation(super, 0);
}
}
void sub_08021CD0(Entity* this) {
if ((this->frame & ANIM_DONE) == 0)
GetNextFrame(this);
void sub_08021CD0(BeetleEntity* this) {
if ((super->frame & ANIM_DONE) == 0)
GetNextFrame(super);
if (sub_08049F84(this, 1) == 0xff)
if (sub_08049F84(super, 1) == 0xff)
return;
this->action = 3;
InitializeAnimation(this, 2);
super->action = 3;
InitializeAnimation(super, 2);
}
u32 sub_08021D00(Entity* this) {
u32 sub_08021D00(BeetleEntity* this) {
u32 ret;
if (((u8*)&this->field_0x86)[0]) {
((u8*)&this->field_0x86)[0]--;
if (this->unk_86) {
this->unk_86--;
ret = 0;
} else if (PlayerInRange(this, 1, 0x10) == 0) {
} else if (PlayerInRange(super, 1, 0x10) == 0) {
ret = 0;
} else {
this->action = 4;
this->timer = 1;
this->zVelocity = Q_16_16(1.5);
InitializeAnimation(this, 4);
super->action = 4;
super->timer = 1;
super->zVelocity = Q_16_16(1.5);
InitializeAnimation(super, 4);
ret = 1;
}
return ret;
}
void sub_08021D44(Entity* this, u32 direction) {
void sub_08021D44(BeetleEntity* this, u32 direction) {
direction = DirectionRoundUp(direction);
this->direction = direction;
super->direction = direction;
if (DirectionIsHorizontal(direction)) {
this->speed = 0x180;
super->speed = 0x180;
} else {
this->speed = 0xc0;
super->speed = 0xc0;
}
}
// clang-format off
void (*const Beetle_Functions[])(Entity*) = {
void (*const Beetle_Functions[])(BeetleEntity*) = {
Beetle_OnTick,
Beetle_OnCollision,
GenericKnockback,
(void (*)(BeetleEntity*))GenericKnockback,
Beetle_OnDeath,
GenericConfused,
(void (*)(BeetleEntity*))GenericConfused,
Beetle_OnGrabbed,
};
void (*const gUnk_080CB5A8[])(Entity*) = {
void (*const gUnk_080CB5A8[])(BeetleEntity*) = {
Beetle_Initialize,
sub_080218B4,
sub_08021A10,
@@ -342,13 +348,13 @@ void (*const gUnk_080CB5A8[])(Entity*) = {
sub_08021CD0,
};
void (*const gUnk_080CB5C8[])(Entity*) = {
void (*const gUnk_080CB5C8[])(BeetleEntity*) = {
sub_0802187C,
nullsub_130,
sub_08021888,
};
void (*const gUnk_080CB5D4[])(Entity*) = {
void (*const gUnk_080CB5D4[])(BeetleEntity*) = {
sub_080218CC,
sub_08021984,
};
+18 -13
View File
@@ -4,28 +4,33 @@
*
* @brief Blade Trap enemy
*/
#include "sound.h"
#include "entity.h"
#include "room.h"
#include "object.h"
#include "room.h"
#include "sound.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u16 unk_74;
} BladeTrapEntity;
#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);
void BladeTrap(BladeTrapEntity* this) {
if (super->action == 0) {
super->action = 1;
super->child = GetCurrentRoomProperty(super->type);
UpdateRailMovement(super, (u16**)&super->child, &this->unk_74);
}
if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
LinearMoveUpdate(this);
if (!(super->direction & DIR_NOT_MOVING_CHECK)) {
LinearMoveUpdate(super);
}
if (!(--this->field_0x74.HWORD)) {
if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
if (!(--this->unk_74)) {
if (!(super->direction & DIR_NOT_MOVING_CHECK)) {
EnqueueSFX(SFX_METAL_CLINK);
}
UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD);
UpdateRailMovement(super, (u16**)&super->child, &this->unk_74);
}
}
+183 -175
View File
@@ -4,315 +4,323 @@
*
* @brief Bobomb enemy
*/
#include "asm.h"
#include "collision.h"
#include "sound.h"
#include "enemy.h"
#include "object.h"
#include "functions.h"
#include "object.h"
#include "sound.h"
void sub_0802CB68(Entity*);
void sub_0802CBC4(Entity*);
void sub_0802CC18(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[24];
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
/*0x83*/ u8 unk_83;
} BobombEntity;
extern void (*const Bobomb_Functions[])(Entity*);
extern void (*const gUnk_080CD5EC[])(Entity*);
extern void (*const gUnk_080CD600[])(Entity*);
extern void (*const gUnk_080CD618[])(Entity*);
void sub_0802CB68(BobombEntity* this);
void sub_0802CBC4(BobombEntity* this);
void sub_0802CC18(BobombEntity* this);
void Bobomb(Entity* this) {
EnemyFunctionHandler(this, Bobomb_Functions);
extern void (*const Bobomb_Functions[])(BobombEntity*);
extern void (*const gUnk_080CD5EC[])(BobombEntity*);
extern void (*const gUnk_080CD600[])(BobombEntity*);
extern void (*const gUnk_080CD618[])(BobombEntity*);
void Bobomb(BobombEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Bobomb_Functions);
}
void Bobomb_OnTick(Entity* this) {
gUnk_080CD5EC[this->action](this);
void Bobomb_OnTick(BobombEntity* this) {
gUnk_080CD5EC[super->action](this);
}
void Bobomb_OnCollision(Entity* this) {
if (this->contactFlags & 0x80) {
switch (this->contactFlags & 0x7f) {
void Bobomb_OnCollision(BobombEntity* this) {
if (super->contactFlags & 0x80) {
switch (super->contactFlags & 0x7f) {
case 0:
case 1:
if (this->field_0x82.HALF.LO) {
this->knockbackDuration = 0;
gPlayerEntity.knockbackDuration = 4;
if (this->unk_82) {
super->knockbackDuration = 0;
gPlayerEntity.base.knockbackDuration = 4;
}
return;
case 0xe:
case 0x14:
case 0x15:
case 0x16:
this->action = 3;
this->knockbackDuration = 0;
super->action = 3;
super->knockbackDuration = 0;
sub_0802CBC4(this);
return;
}
this->field_0x82.HALF.LO++;
this->field_0x80.HALF.LO = 28;
switch (this->field_0x82.HALF.LO) {
this->unk_82++;
this->unk_80 = 28;
switch (this->unk_82) {
case 1:
sub_0802CB68(this);
EnqueueSFX(SFX_14D);
break;
case 2:
this->action = 3;
this->hitType = 0x6e;
this->subtimer = 1;
this->zVelocity = Q_16_16(1.5);
this->speed = 0;
this->field_0x80.HALF.HI = 1;
InitializeAnimation(this, this->direction >> 4 | IdleWest);
super->action = 3;
super->hitType = 0x6e;
super->subtimer = 1;
super->zVelocity = Q_16_16(1.5);
super->speed = 0;
this->unk_81 = 1;
InitializeAnimation(super, super->direction >> 4 | IdleWest);
break;
}
}
EnemyFunctionHandlerAfterCollision(this, Bobomb_Functions);
EnemyFunctionHandlerAfterCollision(super, Bobomb_Functions);
}
void Bobomb_OnGrabbed(Entity* this) {
if (this->subAction < 3 && !sub_0806F520(this)) {
this->subAction = 0;
this->subtimer = 1;
this->z.HALF.HI = 0;
if (this->field_0x82.HALF.LO != 2) {
this->speed = this->field_0x82.HALF.LO ? 0x200 : 0x80;
void Bobomb_OnGrabbed(BobombEntity* this) {
if (super->subAction < 3 && !sub_0806F520(super)) {
super->subAction = 0;
super->subtimer = 1;
super->z.HALF.HI = 0;
if (this->unk_82 != 2) {
super->speed = this->unk_82 ? 0x200 : 0x80;
}
this->zVelocity = Q_16_16(1.5);
this->field_0x82.HALF.HI = 0;
this->field_0x80.HALF.HI = 0;
super->zVelocity = Q_16_16(1.5);
this->unk_83 = 0;
this->unk_81 = 0;
} else {
this->z.HALF.HI = -1;
gUnk_080CD600[this->subAction](this);
if (this->timer != 0) {
GetNextFrame(this);
super->z.HALF.HI = -1;
gUnk_080CD600[super->subAction](this);
if (super->timer != 0) {
GetNextFrame(super);
}
}
}
void sub_0802C820(Entity* this) {
this->subAction = 1;
this->gustJarTolerance = 60;
void sub_0802C820(BobombEntity* this) {
super->subAction = 1;
super->gustJarTolerance = 60;
}
void sub_0802C82C(Entity* this) {
sub_0806F4E8(this);
void sub_0802C82C(BobombEntity* this) {
sub_0806F4E8(super);
}
void sub_0802C834(Entity* this) {
sub_0806F3E4(this);
void sub_0802C834(BobombEntity* this) {
sub_0806F3E4(super);
}
void sub_0802C83C(Entity* this) {
if (this->field_0x82.HALF.LO) {
if (--this->timer == 0) {
this->action = 3;
switch (gPlayerEntity.animationState & 6) {
void sub_0802C83C(BobombEntity* this) {
if (this->unk_82) {
if (--super->timer == 0) {
super->action = 3;
switch (gPlayerEntity.base.animationState & 6) {
case 2:
this->x.HALF.HI -= 6;
super->x.HALF.HI -= 6;
break;
case 6:
this->x.HALF.HI += 6;
super->x.HALF.HI += 6;
break;
}
sub_0802CBC4(this);
} else {
sub_0802CC18(this);
COLLISION_OFF(this);
this->hitType = 0x6e;
COLLISION_OFF(super);
super->hitType = 0x6e;
}
} else {
this->field_0x82.HALF.LO = 2;
this->timer = 120;
InitializeAnimation(this, (this->direction >> 4) | IdleWest);
COLLISION_OFF(this);
this->hitType = 0x6e;
this->unk_82 = 2;
super->timer = 120;
InitializeAnimation(super, (super->direction >> 4) | IdleWest);
COLLISION_OFF(super);
super->hitType = 0x6e;
}
}
void nullsub_149(Entity* this) {
void nullsub_149(BobombEntity* this) {
/* ... */
}
void sub_0802C8B8(Entity* this) {
this->action = 3;
void sub_0802C8B8(BobombEntity* this) {
super->action = 3;
sub_0802CBC4(this);
}
void Bobomb_OnDeath(Entity* this) {
GenericDeath(this);
this->spriteSettings.draw = 0;
void Bobomb_OnDeath(BobombEntity* this) {
GenericDeath(super);
super->spriteSettings.draw = 0;
}
void sub_0802C8D8(Entity* this) {
this->action = 1;
this->timer = 60;
this->subtimer = 0;
this->direction = (Random() & 0x18) | DIR_DIAGONAL;
this->carryFlags = 0;
this->gustJarFlags = 0x12;
this->field_0x82.HALF.LO = 0;
this->field_0x82.HALF.HI = 0;
this->field_0x80.HALF.LO = 0;
this->field_0x80.HALF.HI = 0;
InitializeAnimation(this, this->direction >> 4);
void sub_0802C8D8(BobombEntity* this) {
super->action = 1;
super->timer = 60;
super->subtimer = 0;
super->direction = (Random() & 0x18) | DIR_DIAGONAL;
super->carryFlags = 0;
super->gustJarFlags = 0x12;
this->unk_82 = 0;
this->unk_83 = 0;
this->unk_80 = 0;
this->unk_81 = 0;
InitializeAnimation(super, super->direction >> 4);
}
void sub_0802C91C(Entity* this) {
GetNextFrame(this);
ProcessMovement0(this);
if (this->field_0x82.HALF.LO) {
if (this->collisions != COL_NONE) {
sub_0800417E(this, this->collisions);
InitializeAnimation(this, (this->direction >> 4) | IdleEast);
void sub_0802C91C(BobombEntity* this) {
GetNextFrame(super);
ProcessMovement0(super);
if (this->unk_82) {
if (super->collisions != COL_NONE) {
sub_0800417E(super, super->collisions);
InitializeAnimation(super, (super->direction >> 4) | IdleEast);
}
if (--this->timer == 0) {
if (--super->timer == 0) {
sub_0802CBC4(this);
} else {
if ((this->timer & 0xf) == 8) {
CreateDustSmall(this);
if ((super->timer & 0xf) == 8) {
CreateDustSmall(super);
}
sub_0802CC18(this);
}
} else {
if (this->collisions != COL_NONE) {
sub_0800417E(this, this->collisions);
InitializeAnimation(this, this->direction >> 4);
if (super->collisions != COL_NONE) {
sub_0800417E(super, super->collisions);
InitializeAnimation(super, super->direction >> 4);
}
if (--this->timer == 0) {
this->timer = 60;
this->direction = (this->direction + 8) & (DirectionWest | DIR_DIAGONAL);
InitializeAnimation(this, this->direction >> 4);
if (--super->timer == 0) {
super->timer = 60;
super->direction = (super->direction + 8) & (DirectionWest | DIR_DIAGONAL);
InitializeAnimation(super, super->direction >> 4);
}
}
}
void sub_0802C9B8(Entity* this) {
gUnk_080CD618[this->subAction](this);
void sub_0802C9B8(BobombEntity* this) {
gUnk_080CD618[super->subAction](this);
}
void sub_0802C9D0(Entity* this) {
this->subAction = 1;
COLLISION_OFF(this);
this->spritePriority.b1 = 0;
this->field_0x82.HALF.HI = 1;
void sub_0802C9D0(BobombEntity* this) {
super->subAction = 1;
COLLISION_OFF(super);
super->spritePriority.b1 = 0;
this->unk_83 = 1;
sub_0802CC18(this);
InitializeAnimation(this, (this->direction >> 4) | IdleWest);
GetNextFrame(this);
InitializeAnimation(super, (super->direction >> 4) | IdleWest);
GetNextFrame(super);
}
void sub_0802CA10(Entity* this) {
void sub_0802CA10(BobombEntity* this) {
if (gPlayerState.heldObject != 5) {
if (--this->timer == 0) {
if (--super->timer == 0) {
sub_0802CBC4(this);
} else {
sub_0802CC18(this);
GetNextFrame(this);
GetNextFrame(super);
}
} else {
this->field_0x82.HALF.HI = 2;
this->direction = (((gPlayerEntity.animationState) << 2) | IdleSouth) & (DIR_DIAGONAL | DirectionWest);
this->unk_83 = 2;
super->direction = (((gPlayerEntity.base.animationState) << 2) | IdleSouth) & (DIR_DIAGONAL | DirectionWest);
sub_0802CC18(this);
GetNextFrame(this);
GetNextFrame(super);
}
}
void sub_0802CA6C(Entity* this) {
if (--this->timer == 0) {
void sub_0802CA6C(BobombEntity* this) {
if (--super->timer == 0) {
sub_0802CBC4(this);
} else {
sub_0802CC18(this);
GetNextFrame(this);
GetNextFrame(super);
}
}
void sub_0802CA94(Entity* this) {
this->action = 3;
COLLISION_OFF(this);
this->subtimer = 1;
this->spritePriority.b1 = 1;
this->zVelocity = Q_16_16(1.5);
this->speed = 0;
this->field_0x82.HALF.HI = 0;
this->field_0x80.HALF.HI = 0;
this->direction = ((gPlayerEntity.animationState << 2) | IdleSouth) & (DirectionWest | DIR_DIAGONAL);
InitializeAnimation(this, (this->direction >> 4) | IdleWest);
void sub_0802CA94(BobombEntity* this) {
super->action = 3;
COLLISION_OFF(super);
super->subtimer = 1;
super->spritePriority.b1 = 1;
super->zVelocity = Q_16_16(1.5);
super->speed = 0;
this->unk_83 = 0;
this->unk_81 = 0;
super->direction = ((gPlayerEntity.base.animationState << 2) | IdleSouth) & (DirectionWest | DIR_DIAGONAL);
InitializeAnimation(super, (super->direction >> 4) | IdleWest);
}
void sub_0802CAF8(Entity* this) {
if (--this->timer == 0) {
void sub_0802CAF8(BobombEntity* this) {
if (--super->timer == 0) {
sub_0802CBC4(this);
} else {
if (this->field_0x80.HALF.HI && sub_080044EC(this, 0x2800) == 1) {
if (this->unk_81 && sub_080044EC(super, 0x2800) == 1) {
EnqueueSFX(SFX_PLACE_OBJ);
}
sub_0802CC18(this);
RegisterCarryEntity(this);
if (this->subtimer && this->z.HALF.HI == 0) {
this->subtimer = 0;
COLLISION_ON(this);
this->hitType = 0x6e;
RegisterCarryEntity(super);
if (super->subtimer && super->z.HALF.HI == 0) {
super->subtimer = 0;
COLLISION_ON(super);
super->hitType = 0x6e;
}
GetNextFrame(this);
GetNextFrame(super);
}
}
void nullsub_150(Entity* this) {
void nullsub_150(BobombEntity* this) {
/* ... */
}
void sub_0802CB68(Entity* this) {
this->action = 1;
this->subAction = 0;
this->direction = Random() & 0x18;
this->direction |= IdleSouth;
COLLISION_ON(this);
if (this->field_0x82.HALF.LO) {
this->timer = 200;
this->speed = 0x200;
InitializeAnimation(this, (this->direction >> 4) | 2);
void sub_0802CB68(BobombEntity* this) {
super->action = 1;
super->subAction = 0;
super->direction = Random() & 0x18;
super->direction |= IdleSouth;
COLLISION_ON(super);
if (this->unk_82) {
super->timer = 200;
super->speed = 0x200;
InitializeAnimation(super, (super->direction >> 4) | 2);
} else {
this->timer = 60;
this->speed = 0x80;
InitializeAnimation(this, this->direction >> 4);
super->timer = 60;
super->speed = 0x80;
InitializeAnimation(super, super->direction >> 4);
}
}
void sub_0802CBC4(Entity* this) {
Entity* ent;
void sub_0802CBC4(BobombEntity* this) {
Entity* entity;
this->action = 4;
this->spriteSettings.draw = 0;
COLLISION_OFF(this);
this->health = 0;
if (this->field_0x82.HALF.HI) {
super->action = 4;
super->spriteSettings.draw = 0;
COLLISION_OFF(super);
super->health = 0;
if (this->unk_83) {
PlayerDropHeldObject();
}
FreeCarryEntity(this);
FreeCarryEntity(super);
ent = CreateObjectWithParent(this, SMOKE_PARTICLE, 0, 0);
if (ent != NULL) {
ent->collisionLayer = this->collisionLayer;
entity = CreateObjectWithParent(super, SMOKE_PARTICLE, 0, 0);
if (entity != NULL) {
entity->collisionLayer = super->collisionLayer;
}
}
void sub_0802CC18(Entity* this) {
if (--this->field_0x80.HALF.LO == 0) {
this->field_0x80.HALF.LO = 28;
void sub_0802CC18(BobombEntity* this) {
if (--this->unk_80 == 0) {
this->unk_80 = 28;
EnqueueSFX(SFX_14D);
}
}
// clang-format off
void (*const Bobomb_Functions[])(Entity*) = {
void (*const Bobomb_Functions[])(BobombEntity*) = {
Bobomb_OnTick,
Bobomb_OnCollision,
GenericKnockback,
(void (*)(BobombEntity*))GenericKnockback,
Bobomb_OnDeath,
GenericConfused,
(void (*)(BobombEntity*))GenericConfused,
Bobomb_OnGrabbed,
};
void (*const gUnk_080CD5EC[])(Entity*) = {
void (*const gUnk_080CD5EC[])(BobombEntity*) = {
sub_0802C8D8,
sub_0802C91C,
sub_0802C9B8,
@@ -320,7 +328,7 @@ void (*const gUnk_080CD5EC[])(Entity*) = {
nullsub_150,
};
void (*const gUnk_080CD600[])(Entity*) = {
void (*const gUnk_080CD600[])(BobombEntity*) = {
sub_0802C820,
sub_0802C82C,
sub_0802C834,
@@ -329,7 +337,7 @@ void (*const gUnk_080CD600[])(Entity*) = {
sub_0802C8B8,
};
void (*const gUnk_080CD618[])(Entity*) = {
void (*const gUnk_080CD618[])(BobombEntity*) = {
sub_0802C9D0,
sub_0802CA10,
sub_0802CA6C,
+409 -397
View File
File diff suppressed because it is too large Load Diff
+12 -7
View File
@@ -1,8 +1,13 @@
#define NENT_DEPRECATED
#include "entity.h"
/**
* @file bombarossa.c
* @ingroup Enemies
*
* @brief Bombarossa enemy
*/
#include "enemy.h"
#include "room.h"
#include "entity.h"
#include "object.h"
#include "room.h"
typedef struct {
Entity base;
@@ -39,12 +44,12 @@ void Bombarossa_OnTick(BombarossaEntity* this) {
}
void Bombarossa_OnCollision(BombarossaEntity* this) {
Entity* ent;
Entity* entity;
switch (super->contactFlags & 0x7f) {
default:
ent = CreateObject(SMOKE_PARTICLE, 0, 0);
if (ent != NULL) {
CopyPosition(super, ent);
entity = CreateObject(SMOKE_PARTICLE, 0, 0);
if (entity != NULL) {
CopyPosition(super, entity);
}
DeleteThisEntity();
case 1:
+6 -9
View File
@@ -4,11 +4,8 @@
*
* @brief Bow Moblin enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "entity.h"
#include "enemy.h"
#include "entity.h"
#include "functions.h"
typedef struct {
@@ -270,16 +267,16 @@ void sub_0803C4B0(BowMoblinEntity* this) {
bool32 sub_0803C568(BowMoblinEntity* this) {
if (this->unk_0x81 == 0) {
Entity* ent = sub_08049DF4(1);
if (ent != NULL) {
Entity* entity = sub_08049DF4(1);
if (entity != NULL) {
if (this->unk_0x82 == 2) {
if (sub_0806FC80(super, ent, 0x30)) {
if (sub_0806FC80(super, entity, 0x30)) {
return TRUE;
}
}
if (sub_0806FC80(super, ent, 0x40)) {
u32 direction = (GetFacingDirection(super, ent) + 4) & 0x18;
if (sub_0806FC80(super, entity, 0x40)) {
u32 direction = (GetFacingDirection(super, entity) + 4) & 0x18;
direction = direction >> 2;
if (direction == super->animationState) {
return TRUE;
+244 -230
View File
@@ -4,7 +4,6 @@
*
* @brief Business Scrub enemy
*/
#include "asm.h"
#include "enemy.h"
#include "functions.h"
@@ -16,24 +15,6 @@
#include "save.h"
#include "tiles.h"
void sub_08028E9C(Entity*);
void sub_08028EDC(Entity*);
bool32 sub_08028F98(Entity*, u32);
bool32 sub_08028FDC(Entity*);
void sub_08028FFC(Entity*);
void sub_08029078(Entity*);
void sub_080290E0(Entity*, u32);
void sub_080290FC(Entity*);
bool32 sub_0802915C(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 BusinessScrub_Actions[])(Entity*);
extern const u8 gUnk_080CCA04[];
struct SalesOffering {
u8 field_0x0;
@@ -46,131 +27,164 @@ struct SalesOffering {
u16 local_flag;
};
void BusinessScrub(Entity* this) {
EnemyFunctionHandler(this, BusinessScrub_Functions);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u16 unk_74;
/*0x76*/ u16 unk_76;
/*0x78*/ u16 unk_78;
/*0x7a*/ u16 unk_7a;
/*0x7c*/ const struct SalesOffering* unk_7c;
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unused2[4];
/*0x86*/ u16 unk_86;
} BusinessScrubEntity;
void sub_08028E9C(BusinessScrubEntity*);
void sub_08028EDC(BusinessScrubEntity*);
bool32 sub_08028F98(BusinessScrubEntity*, u32);
bool32 sub_08028FDC(BusinessScrubEntity*);
void sub_08028FFC(BusinessScrubEntity*);
void sub_08029078(BusinessScrubEntity*);
void sub_080290E0(BusinessScrubEntity*, u32);
void sub_080290FC(BusinessScrubEntity*);
bool32 sub_0802915C(BusinessScrubEntity*);
bool32 BusinessScrub_CheckRefillFitsBag(BusinessScrubEntity*);
void sub_0802922C(BusinessScrubEntity*);
void sub_0802925C(BusinessScrubEntity*);
extern const struct SalesOffering gUnk_080CC954[];
extern const u8 kinstoneTypes[];
extern void (*const BusinessScrub_Functions[])(BusinessScrubEntity*);
extern void (*const BusinessScrub_Actions[])(BusinessScrubEntity*);
extern const u8 gUnk_080CCA04[];
void BusinessScrub(BusinessScrubEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)BusinessScrub_Functions);
}
void BusinessScrub_OnTick(Entity* this) {
BusinessScrub_Actions[this->action](this);
void BusinessScrub_OnTick(BusinessScrubEntity* this) {
BusinessScrub_Actions[super->action](this);
}
void BusinessScrub_OnCollision(Entity* this) {
Entity* pEVar1;
void BusinessScrub_OnCollision(BusinessScrubEntity* this) {
Entity* fx;
if (this->hitType == 1 && (this->contactFlags & 0x7f) == 0x42) {
this->action = 3;
this->subAction = 0;
this->timer = 40;
COLLISION_OFF(this);
if (super->hitType == 1 && (super->contactFlags & 0x7f) == 0x42) {
super->action = 3;
super->subAction = 0;
super->timer = 40;
COLLISION_OFF(super);
sub_080290E0(this, 4);
pEVar1 = CreateFx(this, FX_BUSH, 0);
if (pEVar1 != NULL) {
pEVar1->z.HALF.HI -= 8;
fx = CreateFx(super, FX_BUSH, 0);
if (fx != NULL) {
fx->z.HALF.HI -= 8;
}
EnqueueSFX(SFX_EM_DEKUSCRUB_HIT);
}
}
void BusinessScrub_OnGrabbed(Entity* this) {
void BusinessScrub_OnGrabbed(BusinessScrubEntity* 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 = DirectionSouth;
void BusinessScrub_Action0(BusinessScrubEntity* this) {
super->subtimer = 0;
this->unk_78 = super->x.HALF.HI;
this->unk_7a = super->y.HALF.HI;
super->animationState = 0;
super->direction = DirectionSouth;
sub_08028E9C(this);
if ((*(u8*)this->field_0x7c.WORD & 1) || CheckFlags(this->field_0x86.HWORD)) {
this->action = 4;
this->timer = 120;
this->spritePriority.b1 = 1;
if ((*(u8*)this->unk_7c & 1) || CheckFlags(this->unk_86)) {
super->action = 4;
super->timer = 120;
super->spritePriority.b1 = 1;
sub_0802925C(this);
sub_080290E0(this, 0);
} else {
this->timer = 0;
this->field_0x76.HWORD = COORD_TO_TILE(this);
this->field_0x74.HWORD = GetMetaTileIndex(this->field_0x76.HWORD, this->collisionLayer);
this->hurtType = 0x41;
super->timer = 0;
this->unk_76 = COORD_TO_TILE(super);
this->unk_74 = GetMetaTileIndex(this->unk_76, super->collisionLayer);
super->hurtType = 0x41;
sub_08028FFC(this);
}
}
void BusinessScrub_Action1(Entity* this) {
if (this->timer != 0) {
this->timer--;
void BusinessScrub_Action1(BusinessScrubEntity* this) {
if (super->timer != 0) {
super->timer--;
} else if (sub_08028F98(this, 0)) {
sub_08029078(this);
this->subAction = 0;
this->subtimer = 1;
super->subAction = 0;
super->subtimer = 1;
}
}
void BusinessScrub_Action2(Entity* this) {
void BusinessScrub_Action2(BusinessScrubEntity* this) {
u32 unk;
GetNextFrame(this);
switch (this->subAction) {
GetNextFrame(super);
switch (super->subAction) {
case 0:
unk = 1;
if (this->frame & ANIM_DONE) {
this->subAction = 1;
this->timer = 60;
this->subtimer = 16;
if (super->frame & ANIM_DONE) {
super->subAction = 1;
super->timer = 60;
super->subtimer = 16;
sub_08028FDC(this);
sub_080290E0(this, 1);
}
break;
case 1:
unk = 1;
if (--this->timer == 0) {
this->subAction = 2;
this->timer = 32;
this->subtimer = 0;
if (--super->timer == 0) {
super->subAction = 2;
super->timer = 32;
super->subtimer = 0;
sub_08028FDC(this);
sub_080290E0(this, 2);
} else if (--this->subtimer == 0) {
} else if (--super->subtimer == 0) {
if (sub_08028FDC(this)) {
sub_080290E0(this, 1);
}
this->subtimer = 16;
super->subtimer = 16;
}
break;
case 2:
unk = 1;
sub_080290FC(this);
if (this->frame & 1) {
Entity* ent = CreateProjectileWithParent(this, DEKU_SEED_PROJECTILE, 0);
if (ent != NULL) {
ent->parent = this;
ent->direction = this->direction;
this->frame &= ~1;
this->subAction = 3;
if (super->frame & 1) {
Entity* entity = CreateProjectileWithParent(super, DEKU_SEED_PROJECTILE, 0);
if (entity != NULL) {
entity->parent = super;
entity->direction = super->direction;
super->frame &= ~1;
super->subAction = 3;
}
}
break;
case 3:
unk = 2;
if (this->frame & ANIM_DONE) {
this->subAction = 4;
this->timer = 80;
if (super->frame & ANIM_DONE) {
super->subAction = 4;
super->timer = 80;
sub_080290E0(this, 1);
}
break;
case 4:
unk = 2;
if (--this->timer == 0) {
if (--super->timer == 0) {
if (sub_08028F98(this, 0)) {
this->subAction = 1;
this->timer = 60;
this->subtimer = 16;
super->subAction = 1;
super->timer = 60;
super->subtimer = 16;
sub_08028FDC(this);
} else {
sub_08028FFC(this);
this->subAction = 0;
this->timer = 80;
this->subtimer = 0;
super->subAction = 0;
super->timer = 80;
super->subtimer = 0;
}
return;
}
@@ -179,76 +193,76 @@ void BusinessScrub_Action2(Entity* this) {
if (!sub_08028F98(this, unk)) {
sub_08028FFC(this);
this->subAction = 0;
this->timer = 80;
this->subtimer = 0;
super->subAction = 0;
super->timer = 80;
super->subtimer = 0;
}
}
void BusinessScrub_Action3(Entity* this) {
void BusinessScrub_Action3(BusinessScrubEntity* this) {
Entity* iVar1;
switch (this->subAction) {
switch (super->subAction) {
case 0:
if (this->timer == 0) {
if (this->frame & ANIM_DONE) {
this->subAction = 1;
if (super->timer == 0) {
if (super->frame & ANIM_DONE) {
super->subAction = 1;
sub_08028FDC(this);
sub_080290E0(this, 5);
this->spritePriority.b1 = 1;
super->spritePriority.b1 = 1;
}
} else {
this->timer--;
super->timer--;
}
break;
case 1:
if (this->frame & ANIM_DONE) {
this->action = 4;
this->subAction = 0;
this->timer = 30;
this->subtimer = 5;
if (super->frame & ANIM_DONE) {
super->action = 4;
super->subAction = 0;
super->timer = 30;
super->subtimer = 5;
sub_080290E0(this, 0);
iVar1 = Create0x68FX(this, FX_STARS);
iVar1 = Create0x68FX(super, FX_STARS);
if (iVar1 != NULL) {
iVar1->spritePriority.b0 = 3;
iVar1->z.HALF.HI -= 12;
SetDefaultPriority(iVar1, PRIO_MESSAGE);
SetEntityPriority(iVar1, PRIO_MESSAGE);
}
SetFlag(this->field_0x86.HWORD);
SetFlag(this->unk_86);
sub_0802925C(this);
}
break;
}
GetNextFrame(this);
sub_0800445C(this);
GetNextFrame(super);
sub_0800445C(super);
}
extern void sub_0804AA1C(Entity*);
void sub_08028F0C(Entity*);
void sub_08028F0C(BusinessScrubEntity*);
void BusinessScrub_Action4(Entity* this) {
if (--this->timer == 0) {
this->timer = 48;
if (this->subtimer) {
if (--this->subtimer == 0) {
sub_0804AA1C(this);
void BusinessScrub_Action4(BusinessScrubEntity* this) {
if (--super->timer == 0) {
super->timer = 48;
if (super->subtimer) {
if (--super->subtimer == 0) {
sub_0804AA1C(super);
}
} else if (sub_08028FDC(this) || this->field_0x80.HALF.LO) {
this->field_0x80.HALF.LO = 0;
} else if (sub_08028FDC(this) || this->unk_80) {
this->unk_80 = 0;
sub_080290E0(this, 0);
}
}
GetNextFrame(this);
sub_0800445C(this);
GetNextFrame(super);
sub_0800445C(super);
sub_08028F0C(this);
}
void BusinessScrub_Action5(Entity* this) {
struct SalesOffering* offer = (struct SalesOffering*)this->field_0x7c.WORD;
void BusinessScrub_Action5(BusinessScrubEntity* this) {
struct SalesOffering* offer = (struct SalesOffering*)this->unk_7c;
u32 subtype;
if ((gMessage.doTextBox & 0x7f) == 0 && sub_0802915C(this) && !sub_08056338()) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0 && sub_0802915C(this) && !sub_08056338()) {
if (offer->price <= gSave.stats.rupees) {
if (BusinessScrub_CheckRefillFitsBag(this)) {
/* Bag full. */
@@ -265,9 +279,9 @@ void BusinessScrub_Action5(Entity* this) {
CreateItemEntity(offer->offeredItem, subtype, 0);
this->action = 6;
this->timer = 4;
this->field_0x80.HALF.HI = 0;
super->action = 6;
super->timer = 4;
this->unk_81 = 0;
sub_080290E0(this, 3);
#if defined(USA) || defined(DEMO_USA)
SetLocalFlag(KS_B06);
@@ -275,12 +289,12 @@ void BusinessScrub_Action5(Entity* this) {
return;
case 1: // refill, bottle, specific kinstone
CreateItemEntity(offer->offeredItem, offer->item_subtype, 0);
this->timer = 4;
super->timer = 4;
sub_0802922C(this);
return;
case 2: // grip ring
CreateItemEntity(offer->offeredItem, offer->item_subtype, 0);
this->timer = 8;
super->timer = 8;
sub_0802922C(this);
return;
}
@@ -292,95 +306,95 @@ void BusinessScrub_Action5(Entity* this) {
}
}
sub_0800445C(this);
this->action = 4;
this->timer = 48;
sub_0800445C(super);
super->action = 4;
super->timer = 48;
sub_080290E0(this, 0);
}
void BusinessScrub_Action6(Entity* this) {
if (gPlayerEntity.action == PLAYER_ITEMGET) {
if (this->field_0x80.HALF.HI == 0) {
void BusinessScrub_Action6(BusinessScrubEntity* this) {
if (gPlayerEntity.base.action == PLAYER_ITEMGET) {
if (this->unk_81 == 0) {
SetPlayerControl(1);
this->field_0x80.HALF.HI = 1;
this->unk_81 = 1;
}
} else {
MessageFromTarget(TEXT_INDEX(TEXT_BUSINESS_SCRUB, 0x02));
this->action = 4;
this->field_0x80.HALF.HI = 0;
this->timer = 1;
super->action = 4;
this->unk_81 = 0;
super->timer = 1;
sub_08028EDC(this);
SetPlayerControl(0);
sub_0800445C(this);
GetNextFrame(this);
sub_0800445C(super);
GetNextFrame(super);
}
}
void BusinessScrub_Action7(Entity* this) {
if ((gMessage.doTextBox & 0x7f) == 0) {
struct SalesOffering* offer = (struct SalesOffering*)this->field_0x7c.WORD;
void BusinessScrub_Action7(BusinessScrubEntity* this) {
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
struct SalesOffering* offer = (struct SalesOffering*)this->unk_7c;
this->action = 4;
this->subAction = gMessage.doTextBox & 0x7f;
this->timer = 1;
super->action = 4;
super->subAction = gMessage.state & MESSAGE_ACTIVE;
super->timer = 1;
if (!CheckLocalFlag(offer->local_flag)) {
SetLocalFlag(offer->local_flag);
}
SetPlayerControl(0);
}
sub_0800445C(this);
GetNextFrame(this);
sub_0800445C(super);
GetNextFrame(super);
}
void BusinessScrub_Action8(Entity* this) {
if (UpdateFuseInteraction(this)) {
this->action = 4;
this->timer = 1;
void BusinessScrub_Action8(BusinessScrubEntity* this) {
if (UpdateFuseInteraction(super)) {
super->action = 4;
super->timer = 1;
}
}
bool32 sub_08029198(const struct SalesOffering*);
void sub_08028E9C(Entity* this) {
const struct SalesOffering* offer = &gUnk_080CC954[this->type];
void sub_08028E9C(BusinessScrubEntity* this) {
const struct SalesOffering* offer = &gUnk_080CC954[super->type];
if (sub_08029198(offer) && (offer->field_0x0 & 2)) {
offer = &gUnk_080CC954[offer->local_flag];
}
this->field_0x7c.WORD = (u32)offer;
this->field_0x80.HALF.LO = 0;
this->unk_7c = offer;
this->unk_80 = 0;
}
void sub_08028EDC(Entity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
void sub_08028EDC(BusinessScrubEntity* this) {
const struct SalesOffering* offer = this->unk_7c;
if (sub_08029198(offer) && (offer->field_0x0 & 2)) {
offer = &gUnk_080CC954[offer->local_flag];
this->field_0x7c.WORD = (u32)offer;
this->unk_7c = offer;
}
}
void sub_08028F0C(Entity* this) {
if (this->interactType == INTERACTION_FUSE) {
this->action = 8;
this->interactType = INTERACTION_NONE;
InitializeNPCFusion(this);
} else if (this->interactType != INTERACTION_NONE) {
void sub_08028F0C(BusinessScrubEntity* this) {
if (super->interactType == INTERACTION_FUSE) {
super->action = 8;
super->interactType = INTERACTION_NONE;
InitializeNPCFusion(super);
} else if (super->interactType != INTERACTION_NONE) {
u16 dialog;
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
const struct SalesOffering* offer = (const struct SalesOffering*)this->unk_7c;
this->interactType = INTERACTION_NONE;
sub_0804AA1C(this);
this->direction = (GetAnimationState(this) << 3);
super->interactType = INTERACTION_NONE;
sub_0804AA1C(super);
super->direction = (GetAnimationState(super) << 3);
sub_080290E0(this, 3);
this->field_0x80.HALF.LO = 1;
this->timer = 32;
this->subtimer = 0;
this->unk_80 = 1;
super->timer = 32;
super->subtimer = 0;
if (sub_08029198(offer)) {
dialog = offer->field_0x6;
} else {
if ((offer->field_0x0 & 0xfc) != 0xc) {
this->action = 5;
super->action = 5;
} else {
this->action = 7;
super->action = 7;
}
dialog = offer->field_0x4;
SetPlayerControl(1);
@@ -390,16 +404,16 @@ void sub_08028F0C(Entity* this) {
}
}
bool32 sub_08028F98(Entity* this, u32 param_2) {
Entity* ent = sub_08049DF4(1);
if (ent == NULL || EntityInRectRadius(this, ent, 0x28, 0x28)) {
bool32 sub_08028F98(BusinessScrubEntity* this, u32 param_2) {
Entity* entity = sub_08049DF4(1);
if (entity == NULL || EntityInRectRadius(super, entity, 0x28, 0x28)) {
return FALSE;
}
if (param_2 != 2) {
u32 distance = param_2 ? 0x58 : 0x50;
if (!EntityInRectRadius(this, ent, distance, distance)) {
if (!EntityInRectRadius(super, entity, distance, distance)) {
return FALSE;
}
}
@@ -407,67 +421,67 @@ bool32 sub_08028F98(Entity* this, u32 param_2) {
return TRUE;
}
bool32 sub_08028FDC(Entity* this) {
u32 direction = DirectionRoundUp(sub_08049F84(this, 1));
if (direction == this->direction) {
bool32 sub_08028FDC(BusinessScrubEntity* this) {
u32 direction = DirectionRoundUp(sub_08049F84(super, 1));
if (direction == super->direction) {
return FALSE;
} else {
this->direction = direction;
super->direction = direction;
return TRUE;
}
}
void sub_08028FFC(Entity* this) {
this->action = 1;
COLLISION_OFF(this);
this->spritePriority.b1 = 0;
UnloadGFXSlots(this);
UnloadOBJPalette(this);
this->spriteVramOffset = 0xe8;
this->palette.b.b0 = 2;
this->palette.b.b4 = 2;
this->spriteIndex = 0xa7;
this->x.HALF.HI = this->field_0x78.HWORD;
this->y.HALF.HI = this->field_0x7a.HWORD;
InitializeAnimation(this, 0);
SetMetaTile(SPECIAL_META_TILE_34, this->field_0x76.HWORD, this->collisionLayer);
void sub_08028FFC(BusinessScrubEntity* this) {
super->action = 1;
COLLISION_OFF(super);
super->spritePriority.b1 = 0;
UnloadGFXSlots(super);
UnloadOBJPalette(super);
super->spriteVramOffset = 0xe8;
super->palette.b.b0 = 2;
super->palette.b.b4 = 2;
super->spriteIndex = 0xa7;
super->x.HALF.HI = this->unk_78;
super->y.HALF.HI = this->unk_7a;
InitializeAnimation(super, 0);
SetMetaTile(SPECIAL_META_TILE_34, this->unk_76, super->collisionLayer);
}
void sub_08029078(Entity* this) {
this->action = 2;
COLLISION_ON(this);
this->spritePriority.b1 = 1;
if (LoadFixedGFX(this, 0x72) == 0) {
DeleteEntity(this);
void sub_08029078(BusinessScrubEntity* this) {
super->action = 2;
COLLISION_ON(super);
super->spritePriority.b1 = 1;
if (LoadFixedGFX(super, 0x72) == 0) {
DeleteEntity(super);
} else {
LoadObjPalette(this, 0x6e);
this->spriteIndex = 0xd0;
LoadObjPalette(super, 0x6e);
super->spriteIndex = 0xd0;
sub_08028FDC(this);
sub_080290E0(this, 1);
SetMetaTile(this->field_0x74.HWORD, this->field_0x76.HWORD, this->collisionLayer);
SetMetaTile(this->unk_74, this->unk_76, super->collisionLayer);
}
}
void sub_080290E0(Entity* this, u32 param_2) {
InitializeAnimation(this, this->direction >> 3 | gUnk_080CCA04[param_2]);
void sub_080290E0(BusinessScrubEntity* this, u32 param_2) {
InitializeAnimation(super, super->direction >> 3 | gUnk_080CCA04[param_2]);
}
void sub_080290FC(Entity* this) {
if (this->timer != 0) {
this->timer--;
if ((this->timer < 16) && ((this->timer & 1) == 0)) {
s32 sVar3 = (this->direction & DirectionSouth) ? -1 : 1;
if (this->direction & DirectionEast) {
this->x.HALF.HI += ((this->timer & 8) != 0) ? -sVar3 : sVar3;
void sub_080290FC(BusinessScrubEntity* this) {
if (super->timer != 0) {
super->timer--;
if ((super->timer < 16) && ((super->timer & 1) == 0)) {
s32 sVar3 = (super->direction & DirectionSouth) ? -1 : 1;
if (super->direction & DirectionEast) {
super->x.HALF.HI += ((super->timer & 8) != 0) ? -sVar3 : sVar3;
} else {
this->y.HALF.HI += ((this->timer & 8) != 0) ? sVar3 : -sVar3;
super->y.HALF.HI += ((super->timer & 8) != 0) ? sVar3 : -sVar3;
}
}
}
}
bool32 sub_0802915C(Entity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
bool32 sub_0802915C(BusinessScrubEntity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->unk_7c;
switch (offer->offeredItem) {
case ITEM_GRIP_RING:
@@ -512,8 +526,8 @@ bool32 sub_08029198(const struct SalesOffering* offer) {
return TRUE;
}
bool32 BusinessScrub_CheckRefillFitsBag(Entity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->field_0x7c.WORD;
bool32 BusinessScrub_CheckRefillFitsBag(BusinessScrubEntity* this) {
const struct SalesOffering* offer = (const struct SalesOffering*)this->unk_7c;
switch (offer->offeredItem) {
case ITEM_BOMBS10:
@@ -529,11 +543,11 @@ bool32 BusinessScrub_CheckRefillFitsBag(Entity* this) {
return FALSE;
}
void sub_0802922C(Entity* this) {
void sub_0802922C(BusinessScrubEntity* this) {
const struct SalesOffering* offer;
this->action = 6;
this->field_0x80.HALF.HI = 0;
offer = (const struct SalesOffering*)this->field_0x7c.WORD;
super->action = 6;
this->unk_81 = 0;
offer = (const struct SalesOffering*)this->unk_7c;
switch (offer->offeredItem) {
case ITEM_BOTTLE1:
@@ -548,17 +562,17 @@ void sub_0802922C(Entity* this) {
}
}
void sub_0802925C(Entity* this) {
AddInteractableWhenBigFuser(this, GetFusionToOffer(this));
void sub_0802925C(BusinessScrubEntity* this) {
AddInteractableWhenBigFuser(super, GetFusionToOffer(super));
}
void sub_08029270(Entity* this) {
if (this->action == 0) {
this->action++;
this->spriteSettings.draw = 1;
InitializeAnimation(this, 0xe);
void sub_08029270(BusinessScrubEntity* this) {
if (super->action == 0) {
super->action++;
super->spriteSettings.draw = 1;
InitializeAnimation(super, 0xe);
} else {
GetNextFrame(this);
GetNextFrame(super);
}
}
@@ -581,16 +595,16 @@ const struct SalesOffering gUnk_080CC954[] = {
const u8 kinstoneTypes[] = { 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75 };
void (*const BusinessScrub_Functions[])(Entity*) = {
void (*const BusinessScrub_Functions[])(BusinessScrubEntity*) = {
BusinessScrub_OnTick,
BusinessScrub_OnCollision,
GenericKnockback,
GenericDeath,
GenericConfused,
(void (*)(BusinessScrubEntity*))GenericKnockback,
(void (*)(BusinessScrubEntity*))GenericDeath,
(void (*)(BusinessScrubEntity*))GenericConfused,
BusinessScrub_OnGrabbed,
};
void (*const BusinessScrub_Actions[])(Entity*) = {
void (*const BusinessScrub_Actions[])(BusinessScrubEntity*) = {
BusinessScrub_Action0,
BusinessScrub_Action1,
BusinessScrub_Action2,
+35 -30
View File
@@ -1,6 +1,11 @@
#define NENT_DEPRECATED
#include "entity.h"
/**
* @file businessScrubPrologue.c
* @ingroup Enemies
*
* @brief Business Scrub Prologue enemy
*/
#include "enemy.h"
#include "entity.h"
#include "functions.h"
typedef struct {
@@ -39,7 +44,7 @@ void BusinessScrubPrologue_OnTick(BusinessScrubPrologueEntity* this) {
}
void BusinessScrubPrologue_OnCollision(BusinessScrubPrologueEntity* this) {
Entity* ent;
Entity* entity;
if (super->hitType == 1) {
if ((super->contactFlags & 0x7f) == 0x42) {
super->action = 4;
@@ -47,14 +52,14 @@ void BusinessScrubPrologue_OnCollision(BusinessScrubPrologueEntity* this) {
super->timer = 40;
super->flags &= ~ENT_COLLIDE;
sub_08046030(this, 4);
ent = CreateFx(super, FX_BUSH, 0);
if (ent != NULL) {
ent->z.HALF.HI -= 8;
entity = CreateFx(super, FX_BUSH, 0);
if (entity != NULL) {
entity->z.HALF.HI -= 8;
}
gPlayerState.field_0x27[0] = 0xff;
EnqueueSFX(SFX_EM_DEKUSCRUB_HIT);
SetDefaultPriority(super, PRIO_MESSAGE);
SetEntityPriority(super, PRIO_MESSAGE);
}
}
}
@@ -93,7 +98,7 @@ void nullsub_24(BusinessScrubPrologueEntity* this) {
}
void sub_08045CE0(BusinessScrubPrologueEntity* this) {
Entity* ent;
Entity* entity;
u32 r6;
GetNextFrame(super);
@@ -122,10 +127,10 @@ void sub_08045CE0(BusinessScrubPrologueEntity* this) {
r6 = 1;
sub_0804604C(this);
if (super->frame & 1) {
ent = CreateProjectileWithParent(super, DEKU_SEED_PROJECTILE, 0);
if (ent != NULL) {
ent->parent = super;
ent->direction = super->direction;
entity = CreateProjectileWithParent(super, DEKU_SEED_PROJECTILE, 0);
if (entity != NULL) {
entity->parent = super;
entity->direction = super->direction;
super->frame &= 0xfe;
super->subAction = 3;
}
@@ -165,7 +170,7 @@ void sub_08045CE0(BusinessScrubPrologueEntity* this) {
}
void sub_08045E14(BusinessScrubPrologueEntity* this) {
Entity* ent;
Entity* entity;
gPlayerState.field_0x27[0] = 0xff;
switch (super->subAction) {
case 0:
@@ -185,11 +190,11 @@ void sub_08045E14(BusinessScrubPrologueEntity* this) {
super->action = 5;
super->subAction = 0;
sub_08046030(this, 0);
ent = Create0x68FX(super, FX_STARS);
if (ent != NULL) {
ent->spritePriority.b0 = 3;
ent->z.HALF.HI -= 0xc;
SetDefaultPriority(ent, PRIO_MESSAGE);
entity = Create0x68FX(super, FX_STARS);
if (entity != NULL) {
entity->spritePriority.b0 = 3;
entity->z.HALF.HI -= 0xc;
SetEntityPriority(entity, PRIO_MESSAGE);
}
}
break;
@@ -233,12 +238,12 @@ void nullsub_25(BusinessScrubPrologueEntity* this) {
}
bool32 sub_08045F54(BusinessScrubPrologueEntity* this, u32 arg2) {
Entity* ent = sub_08049DF4(1);
Entity* entity = sub_08049DF4(1);
u32 r3;
if (ent == NULL)
if (entity == NULL)
return 0;
if (EntityInRectRadius(super, ent, 0x20, 0x20))
if (EntityInRectRadius(super, entity, 0x20, 0x20))
return 0;
if (arg2 == 2)
return 1;
@@ -247,7 +252,7 @@ bool32 sub_08045F54(BusinessScrubPrologueEntity* this, u32 arg2) {
r3 = 0x58;
}
if (EntityInRectRadius(super, ent, r3, r3))
if (EntityInRectRadius(super, entity, r3, r3))
return 1;
return 0;
}
@@ -292,17 +297,17 @@ void sub_0804604C(BusinessScrubPrologueEntity* this) {
void sub_08046078(BusinessScrubPrologueEntity* this) {
s32 index;
Entity* ent;
Entity* entity;
const u16* ptr;
gPlayerState.field_0x27[0] = 0;
ptr = gUnk_080D1A4E;
for (index = 0; index <= 4; index++) {
ent = CreateFx(super, FX_DEATH, 0x40);
entity = CreateFx(super, FX_DEATH, 0x40);
if (ent != NULL) {
ent->x.HALF.HI = gRoomControls.origin_x + *ptr;
if (entity != NULL) {
entity->x.HALF.HI = gRoomControls.origin_x + *ptr;
ptr++;
ent->y.HALF.HI = gRoomControls.origin_y + *ptr;
entity->y.HALF.HI = gRoomControls.origin_y + *ptr;
ptr++;
}
}
@@ -314,9 +319,9 @@ void sub_08046078(BusinessScrubPrologueEntity* this) {
RestorePrevTileEntity(0x7a6, 1);
RestorePrevTileEntity(0x7a7, 1);
ent = CreateFx(super, FX_BIG_EXPLOSION2, 0x40);
if (ent != NULL) {
CopyPosition(super, ent);
entity = CreateFx(super, FX_BIG_EXPLOSION2, 0x40);
if (entity != NULL) {
CopyPosition(super, entity);
EnqueueSFX(SFX_184);
}
-1
View File
@@ -4,7 +4,6 @@
*
* @brief Chaser enemy
*/
#include "enemy.h"
#include "functions.h"
+424 -413
View File
File diff suppressed because it is too large Load Diff
+24 -25
View File
@@ -1,4 +1,3 @@
#define NENT_DEPRECATED
/**
* @file chuchuBoss.c
* @ingroup Enemies
@@ -6,8 +5,8 @@
* @brief Chuchu Boss enemy
*/
#include "enemy.h"
#include "object.h"
#include "functions.h"
#include "object.h"
#include "tiles.h"
typedef struct {
@@ -270,7 +269,7 @@ void ChuchuBoss_OnDeath(ChuchuBossEntity* this) {
Entity* child;
Entity* parent;
sub_08078B48();
PausePlayer();
if (super->type == 0) {
if (super->subAction != 12) {
super->subAction = 12;
@@ -464,9 +463,9 @@ void sub_08026090(ChuchuBossEntity* this) {
}
CopyPosition(super->child, super);
} else {
sub_08078B48();
PausePlayer();
if (super->timer-- == 0) {
gRoomControls.camera_target = &gPlayerEntity;
gRoomControls.camera_target = &gPlayerEntity.base;
DeleteThisEntity();
}
}
@@ -542,8 +541,8 @@ void sub_08026110(ChuchuBossEntity* this) {
void sub_0802626C(ChuchuBossEntity* this) {
gPauseMenuOptions.disabled = 1;
gUnk_080CC20C[this->unk_84->unk_03](this);
if (gPlayerEntity.action != PLAYER_ROOMTRANSITION && gPlayerEntity.action != PLAYER_ROOM_EXIT) {
sub_08078B48();
if (gPlayerEntity.base.action != PLAYER_ROOMTRANSITION && gPlayerEntity.base.action != PLAYER_ROOM_EXIT) {
PausePlayer();
}
}
@@ -560,7 +559,7 @@ void sub_080262A8(ChuchuBossEntity* this) {
this->unk_7c = 0;
this->unk_7d = 0x1e;
this->unk_84->unk_03 = 3;
gPlayerEntity.animationState = 0;
gPlayerEntity.base.animationState = 0;
gRoomControls.camera_target = super;
gRoomControls.scrollSpeed = 1;
SetMetaTile(SPECIAL_META_TILE_34, TILE_POS(8, 11), LAYER_BOTTOM);
@@ -568,7 +567,7 @@ void sub_080262A8(ChuchuBossEntity* this) {
}
void sub_08026328(ChuchuBossEntity* this) {
if (gPlayerEntity.action != PLAYER_ROOMTRANSITION) {
if (gPlayerEntity.base.action != PLAYER_ROOMTRANSITION) {
this->unk_7d = 0x78;
this->unk_84->unk_03++;
sub_08078AC0(10, 0, 0);
@@ -578,20 +577,20 @@ void sub_08026328(ChuchuBossEntity* this) {
void sub_08026358(ChuchuBossEntity* this) {
u32 bVar1;
if (gPlayerEntity.action != PLAYER_ROOM_EXIT) {
if (gPlayerEntity.base.action != PLAYER_ROOM_EXIT) {
bVar1 = --this->unk_7d;
if (bVar1 == 0) {
this->unk_7c = 0;
this->unk_7d = 0x1e;
this->unk_84->unk_03++;
gPlayerEntity.animationState = 0;
gPlayerEntity.base.animationState = 0;
gRoomControls.camera_target = super;
gRoomControls.scrollSpeed = 1;
} else if (bVar1 < 0x61) {
if (bVar1 < 0x5c) {
gPlayerEntity.animationState = 4;
gPlayerEntity.base.animationState = 4;
} else {
gPlayerEntity.animationState = 2;
gPlayerEntity.base.animationState = 2;
}
}
}
@@ -657,7 +656,7 @@ void sub_080264D4(ChuchuBossEntity* this) {
void sub_0802650C(ChuchuBossEntity* this) {
if (((ChuchuBossEntity*)super->child)->unk_81 == 0) {
this->unk_84->unk_03++;
gRoomControls.camera_target = &gPlayerEntity;
gRoomControls.camera_target = &gPlayerEntity.base;
}
sub_08027870(this);
}
@@ -683,7 +682,7 @@ void sub_08026580(ChuchuBossEntity* this) {
super->speed = 0;
super->subAction = 2;
this->unk_7c = 0x3c;
super->direction = GetFacingDirection(super, &gPlayerEntity);
super->direction = GetFacingDirection(super, &gPlayerEntity.base);
if (this->unk_84->unk_04 == 2) {
this->unk_80 = 0x48;
this->unk_81 += 16;
@@ -733,7 +732,7 @@ void sub_08026634(ChuchuBossEntity* this) {
super->speed = 0x180;
} else {
if ((gRoomTransition.frameCount & 0x7f) == 0) {
super->direction = GetFacingDirection(super, &gPlayerEntity);
super->direction = GetFacingDirection(super, &gPlayerEntity.base);
}
if (this->unk_84->unk_04 == 2) {
super->speed = 0x100;
@@ -795,7 +794,7 @@ void sub_08026808(ChuchuBossEntity* this) {
if (pEVar4->unk_78.HALF_U.HI > 0xb0) {
pEVar4->unk_78.HALF_U.HI -= 8;
} else {
super->direction = GetFacingDirection(super, &gPlayerEntity);
super->direction = GetFacingDirection(super, &gPlayerEntity.base);
super->subAction = 4;
pEVar4->unk_78.HALF_U.HI = 0xa0;
pEVar5->unk_78.HALF_U.HI = 0xa0;
@@ -1127,7 +1126,7 @@ void sub_08026E1C(ChuchuBossEntity* this) {
}
if ((sub_08027C54(this)) && this->unk_84->unk_04 == 2) {
sub_08027C7C(this, 0x3f);
sub_08078B48();
PausePlayer();
}
}
@@ -1156,7 +1155,7 @@ void sub_08026FA4(ChuchuBossEntity* this) {
ChuchuBossEntity* pEVar3;
ChuchuBossEntity* pEVar4;
sub_08078B48();
PausePlayer();
COLLISION_OFF(super);
pEVar4 = (ChuchuBossEntity*)super->child;
pEVar3 = (ChuchuBossEntity*)super->parent;
@@ -1203,9 +1202,9 @@ void sub_08027064(ChuchuBossEntity* this) {
SoundReq(SFX_PLY_JUMP);
}
if (this->unk_84->unk_03 != 0) {
if (super->y.HALF.HI != gPlayerEntity.y.HALF.HI) {
if (super->y.HALF.HI != gPlayerEntity.base.y.HALF.HI) {
if ((gRoomTransition.frameCount & 0xf) == 0) {
if (super->y.HALF.HI > gPlayerEntity.y.HALF.HI) {
if (super->y.HALF.HI > gPlayerEntity.base.y.HALF.HI) {
this->unk_84->unk_0c = 0;
} else {
this->unk_84->unk_0c = 0x10;
@@ -1245,7 +1244,7 @@ void sub_08027064(ChuchuBossEntity* this) {
*(char*)((int)pEVar10 + 0x84) = 1;
uVar2 = 0;
if (this->unk_84->unk_03 > 1) {
if (super->x.HALF.HI > gPlayerEntity.x.HALF.HI) {
if (super->x.HALF.HI > gPlayerEntity.base.x.HALF.HI) {
uVar2 = 24;
} else {
uVar2 = 8;
@@ -1362,7 +1361,7 @@ void sub_080272D4(ChuchuBossEntity* this) {
if (sub_08027C54(super->child) == 0 || ((ChuchuBossEntity*)super->child)->unk_84->unk_04 != 2) {
SoundReq(SFX_BOSS_HIT);
} else {
sub_08078B48();
PausePlayer();
gRoomControls.camera_target = super->child;
gPauseMenuOptions.disabled = 1;
gRoomControls.camera_target->subAction = 9;
@@ -1787,8 +1786,8 @@ void sub_08027BBC(ChuchuBossEntity* this) {
*(u8*)((int)pEVar6 + 0x85) = 1;
}
super->animationState = super->direction >> 2;
if (super->y.HALF.HI != gPlayerEntity.y.HALF.HI) {
if (super->y.HALF.HI > gPlayerEntity.y.HALF.HI) {
if (super->y.HALF.HI != gPlayerEntity.base.y.HALF.HI) {
if (super->y.HALF.HI > gPlayerEntity.base.y.HALF.HI) {
this->unk_84->unk_0c = 0;
} else {
this->unk_84->unk_0c = 0x10;
-2
View File
@@ -4,8 +4,6 @@
*
* @brief Cloud Piranha enemy
*/
#define NENT_DEPRECATED
#include "collision.h"
#include "enemy.h"
#include "functions.h"
+7 -2
View File
@@ -1,6 +1,11 @@
#define NENT_DEPRECATED
#include "entity.h"
/**
* @file crow.c
* @ingroup Enemies
*
* @brief Crow enemy
*/
#include "enemy.h"
#include "entity.h"
#include "functions.h"
typedef struct {
+18 -13
View File
@@ -1,6 +1,11 @@
#define NENT_DEPRECATED
#include "entity.h"
/**
* @file cuccoAggr.c
* @ingroup Enemies
*
* @brief Cucco Aggr enemy
*/
#include "enemy.h"
#include "entity.h"
#include "functions.h"
typedef struct {
@@ -168,7 +173,7 @@ void sub_08038F20(CuccoAggrEntity* this) {
}
void sub_08038F44(CuccoAggrEntity* this) {
super->direction = GetFacingDirection(&gPlayerEntity, super);
super->direction = GetFacingDirection(&gPlayerEntity.base, super);
sub_080390F8(this);
ProcessMovement0(super);
sub_080044EC(super, 0x1800);
@@ -188,7 +193,7 @@ void sub_08038FA0(CuccoAggrEntity* this) {
if (this->unk_78) {
if ((this->unk_78-- & 0x7) == 0) {
sub_08004596(super, GetFacingDirection(super, &gPlayerEntity));
sub_08004596(super, GetFacingDirection(super, &gPlayerEntity.base));
}
sub_080390F8(this);
@@ -273,7 +278,7 @@ void sub_08039120(CuccoAggrEntity* this) {
void sub_08039140(CuccoAggrEntity* this) {
super->action = 6;
super->timer = Random();
super->direction = GetFacingDirection(super, &gPlayerEntity);
super->direction = GetFacingDirection(super, &gPlayerEntity.base);
super->z.HALF.HI = -4;
this->unk_78 = 0xb4;
sub_080390F8(this);
@@ -292,13 +297,13 @@ bool32 CuccoAggr_IsOutsideScroll(CuccoAggrEntity* this) {
void sub_080391B4(CuccoAggrEntity* this) {
if (this->unk_7a) {
if ((this->unk_7b++ & 0x1f) == 0) {
Entity* ent = CreateEnemy(CUCCO_AGGR, 2);
if (ent != NULL) {
Entity* entity = CreateEnemy(CUCCO_AGGR, 2);
if (entity != NULL) {
u32 rand = (Random() & 0x17);
const PosOffset* ptr = &gCuccoAggrSpawnPoints[rand];
ent->x.HALF.HI = gRoomControls.scroll_x + ptr->x;
ent->y.HALF.HI = gRoomControls.scroll_y + ptr->y;
ent->collisionLayer = super->collisionLayer;
entity->x.HALF.HI = gRoomControls.scroll_x + ptr->x;
entity->y.HALF.HI = gRoomControls.scroll_y + ptr->y;
entity->collisionLayer = super->collisionLayer;
}
}
}
@@ -317,10 +322,10 @@ void sub_08039218(CuccoAggrEntity* this) {
}
void CuccoAggr_CreateFx(CuccoAggrEntity* this) {
Entity* ent = CreateFx(super, gCuccoAggrFx[super->type], 0);
Entity* entity = CreateFx(super, gCuccoAggrFx[super->type], 0);
if (ent != NULL) {
ent->x.HALF.HI += gCuccoAggrFxHorizontalOffsets[super->spriteSettings.flipX];
if (entity != NULL) {
entity->x.HALF.HI += gCuccoAggrFxHorizontalOffsets[super->spriteSettings.flipX];
}
}
+2 -3
View File
@@ -4,7 +4,6 @@
*
* @brief Cucco Chick Aggr enemy
*/
#include "enemy.h"
#include "functions.h"
@@ -138,12 +137,12 @@ u32 sub_08022B20(Entity* this) {
if (!sub_08049DF4(2))
return 0;
return EntityInRectRadius(this, &gPlayerEntity, 36, 36);
return EntityInRectRadius(this, &gPlayerEntity.base, 36, 36);
}
void sub_08022B44(Entity* this) {
this->zVelocity = Q_16_16(0.75);
this->direction = GetFacingDirection(this, &gPlayerEntity);
this->direction = GetFacingDirection(this, &gPlayerEntity.base);
if (this->direction & (0x3 | DIR_DIAGONAL | DirectionEast))
this->spriteSettings.flipX = (this->direction >> 4) ^ 1;
+6
View File
@@ -1,3 +1,9 @@
/**
* @file curtain.c
* @ingroup Enemies
*
* @brief Curtain enemy
*/
#include "enemy.h"
#include "entity.h"
+297 -283
View File
@@ -4,38 +4,52 @@
*
* @brief Dark Nut enemy
*/
#include "enemy.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u8 unk_74;
/*0x75*/ u8 unk_75;
/*0x76*/ u16 unk_76;
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
/*0x7a*/ u8 unk_7a;
/*0x7b*/ u8 unk_7b;
/*0x7c*/ u8 unk_7c;
/*0x7d*/ u8 unused2[7];
/*0x84*/ u8 unk_84;
} DarkNutEntity;
typedef struct {
u8 field_0x0;
u8 field_0x1;
} PACKED stuct_080CAB14;
void sub_08021218(Entity*, u32, u32);
void sub_0802124C(Entity*);
void sub_08021218(DarkNutEntity*, u32, u32);
void sub_0802124C(DarkNutEntity*);
u32 sub_08021274(u32, u32);
void sub_08021390(Entity*);
void sub_080213B0(Entity*);
void sub_080213D0(Entity*, u32);
void sub_080213F0(Entity*);
void sub_08021400(Entity*);
void sub_08021414(Entity*);
void sub_08021424(Entity*);
u32 sub_080214FC(Entity*);
void sub_08021540(Entity*);
void sub_08021588(Entity*);
void sub_0802159C(Entity*);
void sub_08021600(Entity*);
void sub_08021644(Entity*);
u32 sub_08021664(Entity*, Entity*);
u32 sub_0802169C(Entity*, Entity*);
void sub_08021390(DarkNutEntity*);
void sub_080213B0(DarkNutEntity*);
void sub_080213D0(DarkNutEntity*, u32);
void sub_080213F0(DarkNutEntity*);
void sub_08021400(DarkNutEntity*);
void sub_08021414(DarkNutEntity*);
void sub_08021424(DarkNutEntity*);
u32 sub_080214FC(DarkNutEntity*);
void sub_08021540(DarkNutEntity*);
void sub_08021588(DarkNutEntity*);
void sub_0802159C(DarkNutEntity*);
void sub_08021600(DarkNutEntity*);
void sub_08021644(DarkNutEntity*);
u32 sub_08021664(DarkNutEntity*, Entity*);
u32 sub_0802169C(DarkNutEntity*, Entity*);
extern Entity* gUnk_020000B0;
extern void (*const DarkNut_Functions[])(Entity*);
extern void (*const gUnk_080CAAB0[])(Entity*);
extern void (*const DarkNut_Functions[])(DarkNutEntity*);
extern void (*const gUnk_080CAAB0[])(DarkNutEntity*);
extern const s8 gUnk_080CAB00[];
extern const s8 gUnk_080CAB04[];
@@ -49,150 +63,150 @@ extern const u8 gUnk_080CAB4A[];
extern const u8 gUnk_080CAB52[];
extern const u8 gUnk_080CAB68[];
extern void (*const gUnk_080CAB58[])(Entity*);
extern void (*const gUnk_080CAB58[])(DarkNutEntity*);
void DarkNut(Entity* this) {
EnemyFunctionHandler(this, DarkNut_Functions);
SetChildOffset(this, 0, 1, -22);
void DarkNut(DarkNutEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)DarkNut_Functions);
SetChildOffset(super, 0, 1, -22);
}
void DarkNut_OnTick(Entity* this) {
gUnk_080CAAB0[this->action](this);
void DarkNut_OnTick(DarkNutEntity* this) {
gUnk_080CAAB0[super->action](this);
}
void DarkNut_OnCollision(Entity* this) {
switch (this->contactFlags & 0x7f) {
void DarkNut_OnCollision(DarkNutEntity* this) {
switch (super->contactFlags & 0x7f) {
case 0x1c:
this->action = 11;
this->timer = gUnk_080CAB0C[this->type];
this->hitType = 81;
sub_08021218(this, 8, DirectionToAnimationState(this->knockbackDirection ^ 0x10));
super->action = 11;
super->timer = gUnk_080CAB0C[super->type];
super->hitType = 81;
sub_08021218(this, 8, DirectionToAnimationState(super->knockbackDirection ^ 0x10));
sub_08021588(this);
Create0x68FX(this, FX_STARS);
Create0x68FX(super, FX_STARS);
break;
case 0x16:
this->action = 11;
this->timer = gUnk_080CAB10[this->type];
this->hitType = 81;
sub_08021218(this, 8, DirectionToAnimationState(this->knockbackDirection ^ 0x10));
super->action = 11;
super->timer = gUnk_080CAB10[super->type];
super->hitType = 81;
sub_08021218(this, 8, DirectionToAnimationState(super->knockbackDirection ^ 0x10));
sub_08021588(this);
Create0x68FX(this, FX_STARS);
Create0x68FX(super, FX_STARS);
break;
case 0x4b:
if (this->action == 13 || this->action == 15 || this->action == 19 || this->action == 18)
if (super->action == 13 || super->action == 15 || super->action == 19 || super->action == 18)
break;
switch (this->field_0x78.HALF.HI) {
switch (this->unk_79) {
case 8 ... 12:
this->field_0x7a.HALF.LO = gUnk_080CAB04[this->type];
this->unk_7a = gUnk_080CAB04[super->type];
break;
case 4 ... 6:
this->field_0x7a.HALF.LO = gUnk_080CAB00[this->type];
this->unk_7a = gUnk_080CAB00[super->type];
break;
default:
this->field_0x7a.HALF.LO = 0;
this->unk_7a = 0;
break;
}
this->action = 10;
sub_08021218(this, 0xb, this->animationState);
super->action = 10;
sub_08021218(this, 0xb, super->animationState);
EnqueueSFX(SFX_15D);
sub_08021588(this);
break;
case 0x4c:
if (this->action == 15) {
if (super->action == 15) {
u8 bVar3 = 0xff;
if (this->child != NULL) {
bVar3 = this->child->contactFlags & 0x7f;
if (super->child != NULL) {
bVar3 = super->child->contactFlags & 0x7f;
}
if (bVar3 == 2) {
sub_080213D0(this, gUnk_080CAB08[this->type]);
sub_080213D0(this, gUnk_080CAB08[super->type]);
} else {
sub_080213D0(this, 0);
}
}
break;
default:
if (this->health != this->field_0x78.HALF.LO) {
if (super->health != this->unk_78) {
sub_08021588(this);
sub_08021390(this);
sub_0804AA1C(this);
sub_0804AA1C(super);
}
break;
}
this->field_0x78.HALF.LO = this->health;
EnemyFunctionHandlerAfterCollision(this, DarkNut_Functions);
this->unk_78 = super->health;
EnemyFunctionHandlerAfterCollision(super, DarkNut_Functions);
}
void DarkNut_OnGrabbed(Entity* this) {
void DarkNut_OnGrabbed(DarkNutEntity* this) {
}
void sub_08020D70(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->field_0x74.HALF.HI = 0;
this->field_0x78.HALF.LO = this->health;
this->animationState = -1;
void sub_08020D70(DarkNutEntity* this) {
sub_0804A720(super);
super->action = 1;
this->unk_75 = 0;
this->unk_78 = super->health;
super->animationState = -1;
sub_08021218(this, 0, 2);
}
void sub_08020D9C(Entity* this) {
if (sub_08049FDC(this, 1))
void sub_08020D9C(DarkNutEntity* this) {
if (sub_08049FDC(super, 1))
sub_080213F0(this);
}
void sub_08020DB4(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE)
void sub_08020DB4(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE)
sub_08021390(this);
}
void sub_08020DD4(Entity* this) {
void sub_08020DD4(DarkNutEntity* this) {
if (sub_080214FC(this)) {
sub_080213F0(this);
} else if (--this->field_0x76.HWORD == 0) {
this->action = 5;
sub_08021218(this, 5, this->animationState);
} else if (--this->unk_76 == 0) {
super->action = 5;
sub_08021218(this, 5, super->animationState);
} else {
if (--this->timer == 0)
if (--super->timer == 0)
sub_08021540(this);
ProcessMovement0(this);
UpdateAnimationSingleFrame(this);
ProcessMovement0(super);
UpdateAnimationSingleFrame(super);
}
}
void sub_08020E28(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE)
void sub_08020E28(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE)
sub_080213B0(this);
}
void sub_08020E48(Entity* this) {
void sub_08020E48(DarkNutEntity* this) {
if (sub_080214FC(this)) {
sub_080213F0(this);
} else {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE)
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE)
sub_080213B0(this);
}
}
void sub_08020E78(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE)
void sub_08020E78(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE)
sub_08021390(this);
}
void sub_08020E98(Entity* this) {
if (PlayerInRange(this, 1, 56)) {
void sub_08020E98(DarkNutEntity* this) {
if (PlayerInRange(super, 1, 56)) {
if (sub_0802169C(this, gUnk_020000B0)) {
this->action = 8;
sub_08021218(this, 7, this->animationState);
super->action = 8;
sub_08021218(this, 7, super->animationState);
} else {
this->direction = GetFacingDirection(gUnk_020000B0, this);
if (ProcessMovement0(this) == 0) {
this->action = 8;
sub_08021218(this, 7, this->animationState);
super->direction = GetFacingDirection(gUnk_020000B0, super);
if (ProcessMovement0(super) == 0) {
super->action = 8;
sub_08021218(this, 7, super->animationState);
} else {
this->direction = DirectionTurnAround(this->direction);
super->direction = DirectionTurnAround(super->direction);
sub_0802124C(this);
sub_08021644(this);
}
@@ -201,35 +215,35 @@ void sub_08020E98(Entity* this) {
if (gUnk_020000B0 == NULL) {
sub_08021414(this);
} else {
this->direction = GetFacingDirection(this, gUnk_020000B0);
ProcessMovement0(this);
super->direction = GetFacingDirection(super, gUnk_020000B0);
ProcessMovement0(super);
sub_0802124C(this);
sub_08021644(this);
}
}
}
void sub_08020F28(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE)
void sub_08020F28(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE)
sub_08021400(this);
}
void sub_08020F48(Entity* this) {
if (PlayerInRange(this, 1, 0x48)) {
void sub_08020F48(DarkNutEntity* this) {
if (PlayerInRange(super, 1, 0x48)) {
if (sub_08021664(this, gUnk_020000B0)) {
u32 uVar2 = sub_0804A044(this, gUnk_020000B0, 9);
u32 uVar2 = sub_0804A044(super, gUnk_020000B0, 9);
if (uVar2 == 0xff) {
sub_08021424(this);
} else {
Entity* pEVar3;
this->action = 14;
super->action = 14;
sub_08021218(this, 13, uVar2 >> 3);
pEVar3 = CreateProjectileWithParent(this, DARK_NUT_SWORD_SLASH, 1);
pEVar3 = CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 1);
if (pEVar3) {
pEVar3->parent = this;
this->child = pEVar3;
pEVar3->parent = super;
super->child = pEVar3;
}
}
} else {
@@ -240,155 +254,155 @@ void sub_08020F48(Entity* this) {
}
}
void sub_08020FAC(Entity* this) {
if (this->frame & ANIM_DONE) {
if (this->field_0x7a.HALF.LO) {
this->field_0x7a.HALF.LO--;
void sub_08020FAC(DarkNutEntity* this) {
if (super->frame & ANIM_DONE) {
if (this->unk_7a) {
this->unk_7a--;
} else {
this->iframes = -8;
super->iframes = -8;
sub_08021390(this);
}
} else {
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
}
}
void sub_08020FE4(Entity* this) {
UpdateAnimationSingleFrame(this);
if (--this->timer == 0) {
this->action = 12;
sub_08021218(this, 9, this->animationState);
sub_0804AA1C(this);
void sub_08020FE4(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
if (--super->timer == 0) {
super->action = 12;
sub_08021218(this, 9, super->animationState);
sub_0804AA1C(super);
}
}
void sub_08021010(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE) {
this->hitType = 0x56;
void sub_08021010(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE) {
super->hitType = 0x56;
sub_080213F0(this);
}
}
void sub_08021038(Entity* this) {
if (this->child == NULL && this->frame) {
Entity* pEVar2 = (Entity*)CreateProjectileWithParent(this, DARK_NUT_SWORD_SLASH, 0);
void sub_08021038(DarkNutEntity* this) {
if (super->child == NULL && super->frame) {
Entity* pEVar2 = (Entity*)CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 0);
if (pEVar2) {
pEVar2->parent = this;
this->child = pEVar2;
pEVar2->parent = super;
super->child = pEVar2;
}
EnqueueSFX(SFX_10E);
}
if (this->frame & ANIM_DONE) {
if (super->frame & ANIM_DONE) {
sub_08021588(this);
if (this->field_0x7c.BYTES.byte0) {
this->field_0x7c.BYTES.byte0--;
if (this->unk_7c) {
this->unk_7c--;
} else {
sub_08021390(this);
}
} else {
UpdateAnimationSingleFrame(this);
if (this->frame == 4)
this->hitType = 81;
UpdateAnimationSingleFrame(super);
if (super->frame == 4)
super->hitType = 81;
}
}
void sub_080210A8(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frame & 1) {
this->frame = 0;
void sub_080210A8(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
if (super->frame & 1) {
super->frame = 0;
sub_08021588(this);
EnqueueSFX(SFX_15D);
} else if (this->frame & ANIM_DONE) {
} else if (super->frame & ANIM_DONE) {
sub_08021390(this);
}
}
void sub_080210E4(Entity* this) {
UpdateAnimationSingleFrame(this);
if (this->frame & 1) {
Entity* ent;
void sub_080210E4(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
if (super->frame & 1) {
Entity* entity;
this->frame &= ~1;
ent = CreateProjectileWithParent(this, DARK_NUT_SWORD_SLASH, 2);
if (ent != NULL) {
ent->parent = this;
this->child = ent;
super->frame &= ~1;
entity = CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 2);
if (entity != NULL) {
entity->parent = super;
super->child = entity;
}
EnqueueSFX(SFX_10E);
}
sub_08021644(this);
if ((this->frame & 0x10) && (!ProcessMovement0(this) || (this->child && (this->child->contactFlags & 0x80)))) {
if ((super->frame & 0x10) && (!ProcessMovement0(super) || (super->child && (super->child->contactFlags & 0x80)))) {
sub_080213D0(this, 0);
} else {
if (--this->field_0x76.HWORD == 0)
if (--this->unk_76 == 0)
sub_080213D0(this, 0);
}
}
void sub_08021170(Entity* this) {
if (this->frame & ANIM_DONE) {
if (this->field_0x7a.HALF.HI) {
this->field_0x7a.HALF.HI--;
void sub_08021170(DarkNutEntity* this) {
if (super->frame & ANIM_DONE) {
if (this->unk_7b) {
this->unk_7b--;
} else {
sub_08021390(this);
}
} else {
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
}
}
void sub_080211A0(Entity* this) {
void sub_080211A0(DarkNutEntity* this) {
if (sub_080214FC(this)) {
sub_08021390(this);
} else {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE)
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE)
sub_080213B0(this);
}
}
void sub_080211D0(Entity* this)
void sub_080211D0(DarkNutEntity* this)
{
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
sub_0802159C(this);
if (this->frame & ANIM_DONE)
if (super->frame & ANIM_DONE)
sub_08021390(this);
}
void sub_080211F4(Entity* this) {
UpdateAnimationSingleFrame(this);
void sub_080211F4(DarkNutEntity* this) {
UpdateAnimationSingleFrame(super);
sub_08021600(this);
if (this->frame & ANIM_DONE)
if (super->frame & ANIM_DONE)
sub_08021390(this);
}
void sub_08021218(Entity* this, u32 param_2, u32 param_3) {
void sub_08021218(DarkNutEntity* this, u32 param_2, u32 param_3) {
const stuct_080CAB14* unk;
if (this->field_0x74.HALF.LO == param_2 && this->animationState == param_3)
if (this->unk_74 == param_2 && super->animationState == param_3)
return;
this->animationState = param_3;
this->field_0x74.HALF.LO = param_2;
super->animationState = param_3;
this->unk_74 = param_2;
unk = &gUnk_080CAB14[param_2];
this->spriteIndex = unk->field_0x1;
InitAnimationForceUpdate(this, unk->field_0x0 + param_3);
super->spriteIndex = unk->field_0x1;
InitAnimationForceUpdate(super, unk->field_0x0 + param_3);
}
void sub_0802124C(Entity* this) {
u32 iVar1 = sub_08021274(this->animationState, this->direction);
void sub_0802124C(DarkNutEntity* this) {
u32 iVar1 = sub_08021274(super->animationState, super->direction);
if (iVar1 != 0xff) {
sub_08021218(this, this->field_0x74.HALF.LO, iVar1);
sub_08021218(this, this->unk_74, iVar1);
} else {
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
}
}
@@ -404,103 +418,103 @@ u32 sub_08021274(u32 animationState, u32 dir) {
return dir;
}
void sub_080212B0(Entity* this) {
void sub_080212B0(DarkNutEntity* this) {
u8 tmp;
switch (this->field_0x74.HALF.HI) {
switch (this->unk_75) {
default:
this->field_0x74.HALF.HI = 1;
this->unk_75 = 1;
tmp = gUnk_080CAB3A[Random() & 7];
break;
case 1:
this->field_0x74.HALF.HI = 2;
this->unk_75 = 2;
tmp = gUnk_080CAB42[Random() & 7];
break;
case 2:
this->field_0x74.HALF.HI = 0;
this->unk_75 = 0;
tmp = gUnk_080CAB4A[Random() & 7];
break;
}
if (this->type < 2 && tmp == 2)
if (super->type < 2 && tmp == 2)
tmp = gUnk_080CAB52[Random() & 3];
this->child = NULL;
super->child = NULL;
gUnk_080CAB58[tmp](this);
}
void sub_08021328(Entity* this) {
this->action = 13;
this->field_0x7c.BYTES.byte0 = gUnk_080CAB68[this->type];
sub_08021218(this, 0xc, this->animationState);
void sub_08021328(DarkNutEntity* this) {
super->action = 13;
this->unk_7c = gUnk_080CAB68[super->type];
sub_08021218(this, 0xc, super->animationState);
}
void sub_0802134C(Entity* this) {
this->action = 15;
this->direction = DirectionFromAnimationState(this->animationState);
this->speed = 0x200;
this->field_0x76.HWORD = 0x78;
sub_08021218(this, 0xe, this->animationState);
void sub_0802134C(DarkNutEntity* this) {
super->action = 15;
super->direction = DirectionFromAnimationState(super->animationState);
super->speed = 0x200;
this->unk_76 = 0x78;
sub_08021218(this, 0xe, super->animationState);
}
void sub_08021370(Entity* this) {
this->action = 18;
sub_08021218(this, 0x10, this->animationState);
void sub_08021370(DarkNutEntity* this) {
super->action = 18;
sub_08021218(this, 0x10, super->animationState);
}
void sub_08021380(Entity* this) {
this->action = 19;
sub_08021218(this, 0x11, this->animationState);
void sub_08021380(DarkNutEntity* this) {
super->action = 19;
sub_08021218(this, 0x11, super->animationState);
}
void sub_08021390(Entity* this) {
this->action = 7;
this->speed = 0x200;
this->hitType = 0x56;
sub_08021218(this, 6, this->animationState);
void sub_08021390(DarkNutEntity* this) {
super->action = 7;
super->speed = 0x200;
super->hitType = 0x56;
sub_08021218(this, 6, super->animationState);
}
void sub_080213B0(Entity* this) {
this->action = 3;
this->timer = 1;
this->speed = 0xc0;
this->field_0x76.HWORD = 0xf0;
sub_08021218(this, 3, this->animationState);
void sub_080213B0(DarkNutEntity* this) {
super->action = 3;
super->timer = 1;
super->speed = 0xc0;
this->unk_76 = 0xf0;
sub_08021218(this, 3, super->animationState);
}
void sub_080213D0(Entity* this, u32 param_2) {
this->action = 16;
this->field_0x7a.HALF.HI = param_2;
sub_08021218(this, 0xf, this->animationState);
void sub_080213D0(DarkNutEntity* this, u32 param_2) {
super->action = 16;
this->unk_7b = param_2;
sub_08021218(this, 0xf, super->animationState);
sub_08021588(this);
}
void sub_080213F0(Entity* this) {
this->action = 6;
sub_08021218(this, 1, this->animationState);
void sub_080213F0(DarkNutEntity* this) {
super->action = 6;
sub_08021218(this, 1, super->animationState);
}
void sub_08021400(Entity* this) {
this->action = 9;
this->speed = 0x60;
sub_08021218(this, 10, this->animationState);
void sub_08021400(DarkNutEntity* this) {
super->action = 9;
super->speed = 0x60;
sub_08021218(this, 10, super->animationState);
}
void sub_08021414(Entity* this) {
this->action = 17;
sub_08021218(this, 5, this->animationState);
void sub_08021414(DarkNutEntity* this) {
super->action = 17;
sub_08021218(this, 5, super->animationState);
}
void sub_08021424(Entity* this) {
void sub_08021424(DarkNutEntity* this) {
s32 x, y;
u32 tmp;
u32 dir = GetFacingDirection(this, gUnk_020000B0);
tmp = sub_08021274(this->animationState, dir);
u32 dir = GetFacingDirection(super, gUnk_020000B0);
tmp = sub_08021274(super->animationState, dir);
if (tmp != 0xff) {
sub_08021218(this, this->field_0x74.HALF.LO, tmp);
sub_08021218(this, this->unk_74, tmp);
} else {
tmp = this->animationState;
tmp = super->animationState;
}
switch (tmp) {
@@ -522,122 +536,122 @@ void sub_08021424(Entity* this) {
break;
}
if (!(6 < (x - this->x.HALF.HI) + 3U) && !(4 < (y - this->y.HALF.HI) + 2U)) {
if (!(6 < (x - super->x.HALF.HI) + 3U) && !(4 < (y - super->y.HALF.HI) + 2U)) {
sub_080212B0(this);
} else {
this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, x, y);
if (!ProcessMovement0(this)) {
super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, x, y);
if (!ProcessMovement0(super)) {
sub_080212B0(this);
} else {
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
}
}
}
u32 sub_080214FC(Entity* this) {
u32 sub_080214FC(DarkNutEntity* this) {
u32 direction;
if (!sub_08049FDC(this, 1))
if (!sub_08049FDC(super, 1))
return 0;
direction = GetFacingDirection(this, gUnk_020000B0);
if (4 < (direction - (this->frame & 0x1f)) - 2)
direction = GetFacingDirection(super, gUnk_020000B0);
if (4 < (direction - (super->frame & 0x1f)) - 2)
return 0;
this->animationState = DirectionToAnimationState(direction);
super->animationState = DirectionToAnimationState(direction);
return 1;
}
void sub_08021540(Entity* this) {
void sub_08021540(DarkNutEntity* this) {
u32 tmp, tmp2;
u32 rand;
rand = Random();
if (!sub_08049FA0(this) && (rand & 1)) {
tmp2 = DirectionRoundUp(sub_08049EE4(this));
if (!sub_08049FA0(super) && (rand & 1)) {
tmp2 = DirectionRoundUp(sub_08049EE4(super));
} else {
tmp2 = DirectionRound(rand >> 0x10);
}
this->direction = tmp2;
super->direction = tmp2;
tmp = sub_08021274(this->animationState, tmp2);
tmp = sub_08021274(super->animationState, tmp2);
if (tmp != 0xff)
sub_08021218(this, 3, tmp);
this->timer = 30;
super->timer = 30;
}
void sub_08021588(Entity* this) {
if (this->child != NULL) {
this->child->parent = NULL;
this->child = NULL;
void sub_08021588(DarkNutEntity* this) {
if (super->child != NULL) {
super->child->parent = NULL;
super->child = NULL;
}
}
void sub_0802159C(Entity* this) {
if (this->frame == 1) {
Entity* ent;
void sub_0802159C(DarkNutEntity* this) {
if (super->frame == 1) {
Entity* entity;
this->frame = 0;
this->hitType = 0x51;
ent = CreateProjectileWithParent(this, DARK_NUT_SWORD_SLASH, 3);
if (ent != NULL) {
ent->parent = this;
this->child = ent;
super->frame = 0;
super->hitType = 0x51;
entity = CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 3);
if (entity != NULL) {
entity->parent = super;
super->child = entity;
}
EnqueueSFX(SFX_116);
} else if (this->frame == 2) {
this->frame = 0;
} else if (super->frame == 2) {
super->frame = 0;
sub_08021588(this);
} else if (this->frame & 0x20) {
this->frame &= ~0x20;
} else if (super->frame & 0x20) {
super->frame &= ~0x20;
EnqueueSFX(SFX_115);
}
}
void sub_08021600(Entity* this) {
if (this->frame == 1) {
Entity* ent;
void sub_08021600(DarkNutEntity* this) {
if (super->frame == 1) {
Entity* entity;
this->frame = 0;
this->hitType = 0x51;
ent = CreateProjectileWithParent(this, DARK_NUT_SWORD_SLASH, 4);
if (ent != NULL) {
ent->parent = this;
this->child = ent;
super->frame = 0;
super->hitType = 0x51;
entity = CreateProjectileWithParent(super, DARK_NUT_SWORD_SLASH, 4);
if (entity != NULL) {
entity->parent = super;
super->child = entity;
}
EnqueueSFX(SFX_10E);
} else if (this->frame == 2) {
this->frame = 0;
} else if (super->frame == 2) {
super->frame = 0;
sub_08021588(this);
}
}
void sub_08021644(Entity* this) {
if (this->frame & 0x20) {
this->frame &= ~0x20;
void sub_08021644(DarkNutEntity* this) {
if (super->frame & 0x20) {
super->frame &= ~0x20;
EnqueueSFX(SFX_PLY_LAND);
}
}
u32 sub_08021664(Entity* this, Entity* ent) {
switch (this->animationState) {
u32 sub_08021664(DarkNutEntity* this, Entity* entity) {
switch (super->animationState) {
case 0:
return sub_08049F1C(this, ent, 0x22);
return sub_08049F1C(super, entity, 0x22);
case 1:
return sub_08049F1C(this, ent, 0x1a);
return sub_08049F1C(super, entity, 0x1a);
case 2:
return sub_08049F1C(this, ent, 0x13);
return sub_08049F1C(super, entity, 0x13);
case 3:
return sub_08049F1C(this, ent, 0x1a);
return sub_08049F1C(super, entity, 0x1a);
}
return 0;
}
u32 sub_0802169C(Entity* this, Entity* ent) {
u32 sub_0802169C(DarkNutEntity* this, Entity* entity) {
u32 ret;
switch (this->animationState) {
switch (super->animationState) {
case 0:
ret = 0x2c;
break;
@@ -652,7 +666,7 @@ u32 sub_0802169C(Entity* this, Entity* ent) {
return 0;
}
if (sub_08049F1C(this, ent, ret)) {
if (sub_08049F1C(super, entity, ret)) {
return 0;
} else {
return 1;
@@ -660,15 +674,15 @@ u32 sub_0802169C(Entity* this, Entity* ent) {
}
// clang-format off
void (*const DarkNut_Functions[])(Entity*) = {
void (*const DarkNut_Functions[])(DarkNutEntity*) = {
DarkNut_OnTick,
DarkNut_OnCollision,
GenericKnockback,
GenericDeath,
GenericConfused,
(void (*)(DarkNutEntity*))GenericKnockback,
(void (*)(DarkNutEntity*))GenericDeath,
(void (*)(DarkNutEntity*))GenericConfused,
DarkNut_OnGrabbed,
};
void (*const gUnk_080CAAB0[])(Entity*) = {
void (*const gUnk_080CAAB0[])(DarkNutEntity*) = {
sub_08020D70,
sub_08020D9C,
sub_08020DB4,
@@ -749,7 +763,7 @@ const u8 gUnk_080CAB52[] = {
0, 3, 1, 0, 0, 0
};
void (*const gUnk_080CAB58[])(Entity*) = {
void (*const gUnk_080CAB58[])(DarkNutEntity*) = {
sub_08021328,
sub_0802134C,
sub_08021370,
+70 -62
View File
@@ -4,21 +4,29 @@
*
* @brief Door Mimic enemy
*/
#include "enemy.h"
#include "functions.h"
#include "sound.h"
#include "tiles.h"
void sub_080221C0(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[16];
/*0x78*/ u16 unk_78;
/*0x7a*/ u16 unk_7a;
/*0x7c*/ u16 unk_7c;
/*0x7e*/ u16 unk_7e;
} DoorMimicEntity;
void sub_080221C0(DoorMimicEntity*);
typedef struct {
s8 h;
s8 v;
} PACKED PosOffset;
extern void (*const DoorMimic_Functions[])(Entity*);
extern void (*const gUnk_080CB74C[])(Entity*);
extern void (*const DoorMimic_Functions[])(DoorMimicEntity*);
extern void (*const gUnk_080CB74C[])(DoorMimicEntity*);
extern const s8 gUnk_080CB764[];
extern const PosOffset gUnk_080CB76C[4][6];
@@ -27,111 +35,111 @@ extern const Hitbox* const* const gUnk_080CB8A4[];
extern s16 gUnk_080B4488[];
void DoorMimic(Entity* this) {
DoorMimic_Functions[GetNextFunction(this)](this);
this->hitbox = (Hitbox*)gUnk_080CB8A4[this->type2][this->frameIndex];
void DoorMimic(DoorMimicEntity* this) {
DoorMimic_Functions[GetNextFunction(super)](this);
super->hitbox = (Hitbox*)gUnk_080CB8A4[super->type2][super->frameIndex];
}
void DoorMimic_OnTick(Entity* this) {
gUnk_080CB74C[this->action](this);
void DoorMimic_OnTick(DoorMimicEntity* this) {
gUnk_080CB74C[super->action](this);
}
void DoorMimic_OnCollision(Entity* this) {
EnemyFunctionHandlerAfterCollision(this, DoorMimic_Functions);
void DoorMimic_OnCollision(DoorMimicEntity* this) {
EnemyFunctionHandlerAfterCollision(super, DoorMimic_Functions);
}
void DoorMimic_OnDeath(Entity* this) {
SetMetaTile((u16)this->field_0x7c.HALF.LO, (u16)this->field_0x7c.HALF.HI, this->collisionLayer);
CreateFx(this, FX_POT_SHATTER, 0);
SetRoomTrackerFlag(this);
void DoorMimic_OnDeath(DoorMimicEntity* this) {
SetMetaTile(this->unk_7c, this->unk_7e, super->collisionLayer);
CreateFx(super, FX_POT_SHATTER, 0);
SetRoomTrackerFlag(super);
DeleteThisEntity();
}
void sub_08022034(Entity* this) {
this->action = 1;
this->type2 = this->type & 3;
this->spritePriority.b0 = 5;
this->field_0x78.HWORD = gUnk_080CB764[this->type2 * 2 + 0] + this->x.HALF.HI;
this->field_0x7a.HWORD = gUnk_080CB764[this->type2 * 2 + 1] + this->y.HALF.HI;
InitializeAnimation(this, this->type2);
void sub_08022034(DoorMimicEntity* this) {
super->action = 1;
super->type2 = super->type & 3;
super->spritePriority.b0 = 5;
this->unk_78 = gUnk_080CB764[super->type2 * 2 + 0] + super->x.HALF.HI;
this->unk_7a = gUnk_080CB764[super->type2 * 2 + 1] + super->y.HALF.HI;
InitializeAnimation(super, super->type2);
sub_080221C0(this);
}
void sub_0802209C(Entity* this) {
if (this->timer == 0) {
if (CheckPlayerProximity(this->field_0x78.HWORD, this->field_0x7a.HWORD, 0x10, 0x10)) {
this->action = 2;
this->timer = 18;
InitializeAnimation(this, this->type2 + 4);
void sub_0802209C(DoorMimicEntity* this) {
if (super->timer == 0) {
if (CheckPlayerProximity(this->unk_78, this->unk_7a, 0x10, 0x10)) {
super->action = 2;
super->timer = 18;
InitializeAnimation(super, super->type2 + 4);
}
} else {
this->timer--;
super->timer--;
}
}
void sub_080220D8(Entity* this) {
if (--this->timer == 0)
this->action = 3;
void sub_080220D8(DoorMimicEntity* this) {
if (--super->timer == 0)
super->action = 3;
}
void sub_080220F0(Entity* this) {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
void sub_080220F0(DoorMimicEntity* this) {
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
const PosOffset* off;
u32 i;
this->action = 4;
this->timer = 120;
this->damage = 0;
off = gUnk_080CB76C[this->type2];
super->action = 4;
super->timer = 120;
super->damage = 0;
off = gUnk_080CB76C[super->type2];
for (i = 0; i < 6; i++, off++) {
Entity* fx = CreateFx(this, FX_DASH, 0);
Entity* fx = CreateFx(super, FX_DASH, 0);
if (fx) {
fx->x.HALF.HI += off->h;
fx->y.HALF.HI += off->v;
}
}
EnqueueSFX(SFX_PLACE_OBJ);
} else if (this->frame & 1) {
this->damage = 4;
} else if (super->frame & 1) {
super->damage = 4;
}
}
void sub_08022174(Entity* this) {
sub_0800445C(this);
if (--this->timer == 0) {
this->action = 5;
InitializeAnimation(this, this->type2 + 8);
void sub_08022174(DoorMimicEntity* this) {
sub_0800445C(super);
if (--super->timer == 0) {
super->action = 5;
InitializeAnimation(super, super->type2 + 8);
}
}
void sub_08022198(Entity* this) {
sub_0800445C(this);
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 1;
this->timer = 90;
void sub_08022198(DoorMimicEntity* this) {
sub_0800445C(super);
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 1;
super->timer = 90;
}
}
void sub_080221C0(Entity* this) {
u32 tilePos = COORD_TO_TILE(this) + gUnk_080B4488[this->type2];
this->field_0x7c.HALF.HI = tilePos;
this->field_0x7c.HALF.LO = GetMetaTileIndex(tilePos, this->collisionLayer);
SetMetaTile(gUnk_080CB79C[this->type2], tilePos, this->collisionLayer);
void sub_080221C0(DoorMimicEntity* this) {
u32 tilePos = COORD_TO_TILE(super) + gUnk_080B4488[super->type2];
this->unk_7e = tilePos;
this->unk_7c = GetMetaTileIndex(tilePos, super->collisionLayer);
SetMetaTile(gUnk_080CB79C[super->type2], tilePos, super->collisionLayer);
}
// clang-format off
void (*const DoorMimic_Functions[])(Entity*) = {
void (*const DoorMimic_Functions[])(DoorMimicEntity*) = {
DoorMimic_OnTick,
DoorMimic_OnCollision,
GenericKnockback,
(void (*)(DoorMimicEntity*))GenericKnockback,
DoorMimic_OnDeath,
GenericConfused,
(void (*)(DoorMimicEntity*))GenericConfused,
DoorMimic_OnTick,
};
void (*const gUnk_080CB74C[])(Entity*) = {
void (*const gUnk_080CB74C[])(DoorMimicEntity*) = {
sub_08022034,
sub_0802209C,
sub_080220D8,
+21 -15
View File
@@ -1,12 +1,17 @@
#define NENT_DEPRECATED
#include "entity.h"
#include "enemy.h"
#include "hitbox.h"
#include "player.h"
#include "physics.h"
#include "room.h"
/**
* @file dust.c
* @ingroup Enemies
*
* @brief Dust enemy
*/
#include "asm.h"
#include "enemy.h"
#include "entity.h"
#include "hitbox.h"
#include "object.h"
#include "physics.h"
#include "player.h"
#include "room.h"
typedef struct {
Entity base;
@@ -197,7 +202,7 @@ void sub_08044310(DustEntity* this) {
uVar7 = 0xff;
tmp = 0xff;
switch (gPlayerEntity.animationState / 2 & 3) {
switch (gPlayerEntity.base.animationState / 2 & 3) {
case 0:
for (i = 0; i < this->unk_74; i++) {
if ((((Hitbox3D*)&super->hitbox[i])[1].unknown[2] == 0) &&
@@ -271,15 +276,15 @@ void sub_08044498(DustEntity* this) {
u32 tmp;
u32 xdiff, ydiff;
uVar4 = COORD_TO_TILE(&gPlayerEntity);
uVar4 = COORD_TO_TILE(&gPlayerEntity.base);
tmp = (gPlayerState.playerInput.newInput & 0xf00);
if (tmp != this->unk_75 || uVar4 != this->unk_76) {
this->unk_75 = tmp;
this->unk_76 = uVar4;
pbVar2 = HEAP->items;
uVar4 = HEAP->unk_0;
xdiff = gPlayerEntity.x.HALF.HI - super->x.HALF.HI;
ydiff = gPlayerEntity.y.HALF.HI - super->y.HALF.HI;
xdiff = gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI;
ydiff = gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI;
for (i = 0; i < uVar4; i++) {
if (xdiff - pbVar2[i].unk_0 < 0x10 && ydiff - pbVar2[i].unk_1 < 0x10) {
@@ -287,7 +292,7 @@ void sub_08044498(DustEntity* this) {
if (pEVar1 == NULL) {
return;
}
CopyPosition(&gPlayerEntity, pEVar1);
CopyPosition(&gPlayerEntity.base, pEVar1);
return;
}
}
@@ -302,9 +307,10 @@ void sub_08044550(DustEntity* this) {
if (super->speed < 0x100) {
super->speed += 0x10;
}
ptr = &gUnk_08126EE4[gPlayerEntity.animationState & 0xe];
super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, gPlayerEntity.x.HALF.HI + ptr[0],
gPlayerEntity.y.HALF.HI + ptr[1]);
ptr = &gUnk_08126EE4[gPlayerEntity.base.animationState & 0xe];
super->direction =
CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, gPlayerEntity.base.x.HALF.HI + ptr[0],
gPlayerEntity.base.y.HALF.HI + ptr[1]);
LinearMoveUpdate(super);
} else {
sub_080445C0(this);
+2 -4
View File
@@ -2,12 +2,10 @@
* @file enemy4D.c
* @ingroup Enemies
*
* @brief enemy 4D
* @brief Enemy4D enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "entity.h"
#include "enemy.h"
#include "entity.h"
#include "functions.h"
typedef struct {
+4 -7
View File
@@ -4,12 +4,9 @@
*
* @brief Enemy50 enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "area.h"
#include "enemy.h"
#include "functions.h"
#include "area.h"
#include "player.h"
typedef struct {
@@ -163,7 +160,7 @@ void Enemy50_OnGrabbed(Enemy50Entity* this) {
void Enemy50_SubAction0(Enemy50Entity* this) {
super->subAction = 1;
super->gustJarTolerance = 0x3c;
InitializeAnimation(super, (gPlayerEntity.animationState >> 2) + 5);
InitializeAnimation(super, (gPlayerEntity.base.animationState >> 2) + 5);
}
void Enemy50_SubAction1(Enemy50Entity* this) {
@@ -305,7 +302,7 @@ void Enemy50_Action9(Enemy50Entity* this) {
if (sub_0807953C()) {
this->unk_78 += 8;
}
if (gPlayerEntity.health == 0) {
if (gPlayerEntity.base.health == 0) {
this->unk_78 = 0xe0;
}
this->unk_78++;
@@ -315,7 +312,7 @@ void Enemy50_Action9(Enemy50Entity* this) {
super->iframes = -0xc;
super->knockbackDuration = 0x14;
super->knockbackSpeed = 0x180;
super->knockbackDirection = gPlayerEntity.animationState << 2 ^ 0x10;
super->knockbackDirection = gPlayerEntity.base.animationState << 2 ^ 0x10;
sub_08041128(this);
sub_0803F6EC(this);
} else {
+16 -18
View File
@@ -4,11 +4,9 @@
*
* @brief Enemy64 enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
#include "fade.h"
#include "functions.h"
#include "tiles.h"
typedef struct {
@@ -351,7 +349,7 @@ void Enemy64_Action4(Enemy64Entity* this) {
void Enemy64_Action4_SubAction0(Enemy64Entity* this) {
SoundReq(SFX_BOSS_DIE);
if (PlayerCanBeMoved() && gPlayerEntity.z.HALF.HI == 0) {
if (PlayerCanBeMoved() && gPlayerEntity.base.z.HALF.HI == 0) {
SetPlayerControl(CONTROL_2);
super->subAction = 2;
super->timer = 30;
@@ -362,7 +360,7 @@ void Enemy64_Action4_SubAction0(Enemy64Entity* this) {
}
void Enemy64_Action4_SubAction1(Enemy64Entity* this) {
if (PlayerCanBeMoved() && gPlayerEntity.z.HALF.HI == 0) {
if (PlayerCanBeMoved() && gPlayerEntity.base.z.HALF.HI == 0) {
SetPlayerControl(CONTROL_2);
super->subAction = 2;
super->timer = 1;
@@ -419,7 +417,7 @@ void Enemy64_Action4_SubAction5(Enemy64Entity* this) {
entity = entity->child;
entity->flags &= ~0x80;
entity->spriteSettings.draw = 0;
entity = &gPlayerEntity;
entity = &gPlayerEntity.base;
entity->x.HALF.HI = gRoomControls.origin_x + 0xa8;
entity->y.HALF.HI = gRoomControls.origin_y + 0x80;
entity->animationState = 0;
@@ -462,9 +460,9 @@ void Enemy64_Action4_SubAction7(Enemy64Entity* this) {
void sub_08049944(Enemy64Entity* this) {
this->unk_7c = (this->unk_7c << 1 & 0x7f) | (this->unk_7c & 0x80);
if (EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x20)) {
if (EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, 0x20)) {
gPlayerState.field_0x14 = 1;
if (gPlayerEntity.z.HALF.HI == 0) {
if (gPlayerEntity.base.z.HALF.HI == 0) {
gPlayerState.flags |= PL_FLAGS2;
this->unk_7c |= 1;
}
@@ -481,22 +479,22 @@ void sub_08049998(Enemy64Entity* this, u32 param_2) {
tmpY = super->y.HALF.HI;
LinearMoveAngle(super, super->speed, super->direction);
if (((this->unk_7c & 1) != 0) && PlayerCanBeMoved()) {
gPlayerEntity.x.HALF.HI = (super->x.HALF.HI - tmpX) + gPlayerEntity.x.HALF.HI;
gPlayerEntity.y.HALF.HI = (super->y.HALF.HI - tmpY) + gPlayerEntity.y.HALF.HI;
gPlayerEntity.base.x.HALF.HI = (super->x.HALF.HI - tmpX) + gPlayerEntity.base.x.HALF.HI;
gPlayerEntity.base.y.HALF.HI = (super->y.HALF.HI - tmpY) + gPlayerEntity.base.y.HALF.HI;
}
}
void sub_080499F0(Enemy64Entity* this) {
u32 tmp;
if ((((super->action != 0) && (gPlayerEntity.z.HALF.HI == 0)) && (PlayerCanBeMoved())) &&
if ((((super->action != 0) && (gPlayerEntity.base.z.HALF.HI == 0)) && (PlayerCanBeMoved())) &&
((this->unk_7c & 1) == 0)) {
if (EntityWithinDistance(&gPlayerEntity, super->x.HALF.HI, super->y.HALF.HI, 0x24) &&
if (EntityWithinDistance(&gPlayerEntity.base, super->x.HALF.HI, super->y.HALF.HI, 0x24) &&
((this->unk_7c & 2) == 0)) {
tmp = CalculateDirectionFromOffsets((s32)gPlayerEntity.x.HALF.HI - super->x.HALF.HI,
(s32)gPlayerEntity.y.HALF.HI - super->y.HALF.HI);
gPlayerEntity.x.WORD = super->x.WORD + gSineTable[tmp] * 0x2400;
gPlayerEntity.y.WORD = super->y.WORD + gSineTable[tmp + 0x40] * -0x2400;
tmp = CalculateDirectionFromOffsets((s32)gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI,
(s32)gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI);
gPlayerEntity.base.x.WORD = super->x.WORD + gSineTable[tmp] * 0x2400;
gPlayerEntity.base.y.WORD = super->y.WORD + gSineTable[tmp + 0x40] * -0x2400;
}
this->unk_7c = 0;
}
@@ -535,7 +533,7 @@ void sub_08049B20(Enemy64Entity* this) {
tmpY = super->y.HALF.HI;
LinearMoveAngle(super, super->speed, super->direction);
if (((this->unk_7c & 1) != 0) && PlayerCanBeMoved()) {
gPlayerEntity.x.HALF.HI = (super->x.HALF.HI - tmpX) + gPlayerEntity.x.HALF.HI;
gPlayerEntity.y.HALF.HI = (super->y.HALF.HI - tmpY) + gPlayerEntity.y.HALF.HI;
gPlayerEntity.base.x.HALF.HI = (super->x.HALF.HI - tmpX) + gPlayerEntity.base.x.HALF.HI;
gPlayerEntity.base.y.HALF.HI = (super->y.HALF.HI - tmpY) + gPlayerEntity.base.y.HALF.HI;
}
}
+6
View File
@@ -1,3 +1,9 @@
/**
* @file enemy66.c
* @ingroup Enemies
*
* @brief Enemy66 enemy
*/
#include "entity.h"
void (*const gUnk_080D2ABC[])(Entity*);
+1 -2
View File
@@ -2,9 +2,8 @@
* @file enemyE.c
* @ingroup Enemies
*
* @brief enemy E
* @brief EnemyE enemy
*/
#include "enemy.h"
#include "functions.h"
+2 -4
View File
@@ -4,13 +4,11 @@
*
* @brief Eyegore enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "functions.h"
#include "fade.h"
#include "object.h"
#include "functions.h"
#include "hitbox.h"
#include "object.h"
#include "tiles.h"
typedef struct {
+115 -109
View File
@@ -4,148 +4,154 @@
*
* @brief Falling Boulder enemy
*/
#include "enemy.h"
#include "functions.h"
void sub_0802C4B0(Entity*);
void sub_0802C62C(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[18];
/*0x7a*/ u16 unk_7a;
/*0x7c*/ u16 unk_7c;
/*0x7e*/ u16 unk_7e;
/*0x80*/ u16 unk_80;
/*0x82*/ u16 unk_82;
/*0x84*/ u32 unk_84;
} FallingBoulderEntity;
extern void (*const FallingBoulder_Functions[])(Entity*);
extern void (*const gUnk_080CD558[])(Entity*);
void sub_0802C4B0(FallingBoulderEntity* this);
void sub_0802C62C(FallingBoulderEntity* this);
extern void (*const FallingBoulder_Functions[])(FallingBoulderEntity*);
extern void (*const gUnk_080CD558[])(FallingBoulderEntity*);
extern const u16 gUnk_080CD568[];
extern const u8 gUnk_080CD580[];
extern const s16 gUnk_080CD58C[];
void FallingBoulder(Entity* this) {
EnemyFunctionHandler(this, FallingBoulder_Functions);
void FallingBoulder(FallingBoulderEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)FallingBoulder_Functions);
}
void FallingBoulder_OnTick(Entity* this) {
gUnk_080CD558[this->action](this);
void FallingBoulder_OnTick(FallingBoulderEntity* this) {
gUnk_080CD558[super->action](this);
}
void FallingBoulder_OnCollision(Entity* this) {
void FallingBoulder_OnCollision(FallingBoulderEntity* this) {
/* ... */
}
void FallingBoulder_OnGrabbed(Entity* this) {
void FallingBoulder_OnGrabbed(FallingBoulderEntity* this) {
/* ... */
}
void sub_0802C258(Entity* this) {
sub_0804A720(this);
this->zVelocity = Q_16_16(2.0);
this->timer = 2;
this->field_0x7a.HWORD = Random() & 0x70;
switch (this->type) {
void sub_0802C258(FallingBoulderEntity* this) {
sub_0804A720(super);
super->zVelocity = Q_16_16(2.0);
super->timer = 2;
this->unk_7a = Random() & 0x70;
switch (super->type) {
case 1:
this->field_0x7a.HWORD |= 0x100;
this->unk_7a |= 0x100;
break;
case 2:
this->field_0x7a.HWORD |= 0x200;
this->unk_7a |= 0x200;
break;
}
this->field_0x80.HWORD = this->x.HALF.HI;
this->field_0x82.HWORD = this->y.HALF.HI;
this->z.HALF.HI = -0x10;
this->collisionLayer = 3;
this->spriteRendering.b3 = 1;
this->spritePriority.b0 = 2;
this->field_0x7c.HALF.LO = 0;
this->field_0x7c.HALF.HI = COORD_TO_TILE(this);
this->unk_80 = super->x.HALF.HI;
this->unk_82 = super->y.HALF.HI;
super->z.HALF.HI = -0x10;
super->collisionLayer = 3;
super->spriteRendering.b3 = 1;
super->spritePriority.b0 = 2;
this->unk_7c = 0;
this->unk_7e = COORD_TO_TILE(super);
sub_0802C62C(this);
sub_0802C4B0(this);
}
void sub_0802C318(Entity* this) {
if (--this->field_0x7a.HWORD == 0) {
this->action = 2;
void sub_0802C318(FallingBoulderEntity* this) {
if (--this->unk_7a == 0) {
super->action = 2;
}
}
void sub_0802C334(Entity* this) {
register Entity* ent asm("r2");
u32 diff;
u16 tmp;
if (this->field_0x7c.HALF_U.LO == 0) {
u32 tmp = gRoomControls.origin_y;
ent = &gPlayerEntity;
if (ent == NULL)
void sub_0802C334(FallingBoulderEntity* this) {
Entity* entity;
u32 roomOriginY, tmp;
s32 y, i;
if (this->unk_7c == 0) {
roomOriginY = gRoomControls.origin_y;
entity = &gPlayerEntity.base;
if (entity == NULL)
return;
if (ent->y.HALF.HI - tmp <= 0x38) {
tmp = entity->y.HALF.HI;
if (0x38 >= tmp - roomOriginY)
return;
}
this->field_0x7c.HALF_U.LO = 1;
this->spriteSettings.draw = 1;
this->unk_7c = 1;
super->spriteSettings.draw = 1;
}
GetNextFrame(this);
this->field_0x7c.HALF.HI = COORD_TO_TILE(this);
if (sub_080044EC(this, *(u32*)&this->cutsceneBeh) == 1) {
GetNextFrame(super);
this->unk_7e = COORD_TO_TILE(super);
if (sub_080044EC(super, this->unk_84) == 1) {
EnqueueSFX(0x14c);
COLLISION_ON(this);
this->field_0x7a.HWORD = 0xc;
COLLISION_ON(super);
this->unk_7a = 12;
sub_0802C4B0(this);
} else {
s32 y;
if (this->field_0x7a.HWORD) {
tmp = --this->field_0x7a.HWORD;
switch (tmp) {
if (this->unk_7a) {
switch (--this->unk_7a) {
case 0:
COLLISION_OFF(this);
COLLISION_OFF(super);
break;
case 8:
if (this->type2 != 0 && !sub_08049FA0(this)) {
diff = 0;
for (y = 1; y > -1; y--) {
ent = CreateFx(this, FX_ROCK2, 0);
if (ent) {
ent->x.HALF.HI = ent->x.HALF.HI + 12 - diff;
if (super->type2 != 0 && !sub_08049FA0(super)) {
for (i = 0; i < 2; i++) {
entity = CreateFx(super, FX_ROCK2, 0);
if (entity) {
entity->x.HALF.HI += 12 - i * 0x18;
}
diff += 0x18;
}
sub_0802C62C(this);
this->field_0x7a.HWORD = (Random() & 0xff) | 0x100;
this->unk_7a = (Random() & 0xff) | 0x100;
return;
}
break;
}
}
{
FORCE_REGISTER(RoomControls * tmp, r0) = &gRoomControls;
y = tmp->origin_y + tmp->height - this->y.HALF.HI;
}
roomOriginY = gRoomControls.origin_y;
tmp = gRoomControls.height;
y = roomOriginY + tmp - super->y.HALF.HI;
if (y >= 5) {
ProcessMovement1(this);
ProcessMovement1(super);
} else {
LinearMoveUpdate(this);
if (this->z.HALF.HI - y > 0x38) {
LinearMoveUpdate(super);
if (super->z.HALF.HI - y > 0x38) {
sub_0802C62C(this);
this->field_0x7a.HWORD = (Random() & 0x7f) | 0x80;
if (this->type == 3) {
this->action = 3;
this->unk_7a = (Random() & 0x7f) | 0x80;
if (super->type == 3) {
super->action = 3;
}
}
}
}
this->collisionLayer = 3;
this->spritePriority.b0 = 1;
UpdateSpriteForCollisionLayer(this);
super->collisionLayer = 3;
super->spritePriority.b0 = 1;
UpdateSpriteForCollisionLayer(super);
}
void nullsub_148(Entity* this) {
void nullsub_148(FallingBoulderEntity* this) {
/* ... */
}
void sub_0802C4B0(Entity* this) {
void sub_0802C4B0(FallingBoulderEntity* this) {
u32 offset;
u32 index;
u32 rand;
switch (GetMetaTileIndex(this->field_0x7c.HALF_U.HI, this->collisionLayer)) {
switch (GetMetaTileIndex(this->unk_7e, super->collisionLayer)) {
case 0x1ab ... 0x1af:
offset = 8;
break;
@@ -160,78 +166,78 @@ void sub_0802C4B0(Entity* this) {
rand = Random() & 7;
if (rand & 4) {
if (rand & 3) {
this->speed = gUnk_080CD568[offset | 2];
super->speed = gUnk_080CD568[offset | 2];
} else {
this->speed = gUnk_080CD568[offset | 0];
super->speed = gUnk_080CD568[offset | 0];
}
} else {
if (rand & 3) {
this->speed = gUnk_080CD568[offset | 1];
super->speed = gUnk_080CD568[offset | 1];
} else {
this->speed = gUnk_080CD568[offset | 3];
super->speed = gUnk_080CD568[offset | 3];
}
}
rand = Random() & 7;
if (rand & 4) {
if (this->timer != 0) {
this->timer = 0;
InitializeAnimation(this, 0);
if (super->timer != 0) {
super->timer = 0;
InitializeAnimation(super, 0);
}
if (rand & 3) {
this->direction = gUnk_080CD580[offset | 1];
super->direction = gUnk_080CD580[offset | 1];
} else {
this->direction = gUnk_080CD580[offset | 0];
super->direction = gUnk_080CD580[offset | 0];
}
} else {
if (this->timer != 1) {
this->timer = 1;
InitializeAnimation(this, 1);
if (super->timer != 1) {
super->timer = 1;
InitializeAnimation(super, 1);
}
if (rand & 3) {
this->direction = gUnk_080CD580[offset | 2];
super->direction = gUnk_080CD580[offset | 2];
} else {
this->direction = gUnk_080CD580[offset | 3];
super->direction = gUnk_080CD580[offset | 3];
}
}
rand = Random() & 7;
this->zVelocity = Q_16_16(2.0);
super->zVelocity = Q_16_16(2.0);
if (rand & 4) {
if (rand & 3) {
*(u32*)&this->cutsceneBeh = gUnk_080CD58C[offset | 1];
this->unk_84 = gUnk_080CD58C[offset | 1];
} else {
*(u32*)&this->cutsceneBeh = gUnk_080CD58C[offset | 3];
this->unk_84 = gUnk_080CD58C[offset | 3];
}
} else {
if (rand & 3) {
*(u32*)&this->cutsceneBeh = gUnk_080CD58C[offset | 2];
this->unk_84 = gUnk_080CD58C[offset | 2];
} else {
*(u32*)&this->cutsceneBeh = gUnk_080CD58C[offset | 0];
this->unk_84 = gUnk_080CD58C[offset | 0];
}
}
}
void sub_0802C62C(Entity* this) {
this->action = 1;
this->y.HALF.HI = this->field_0x82.HWORD;
this->x.HALF.HI = this->field_0x80.HWORD;
this->spriteSettings.draw = 0;
COLLISION_OFF(this);
this->field_0x7c.HALF.LO = 0;
void sub_0802C62C(FallingBoulderEntity* this) {
super->action = 1;
super->y.HALF.HI = this->unk_82;
super->x.HALF.HI = this->unk_80;
super->spriteSettings.draw = 0;
COLLISION_OFF(super);
this->unk_7c = 0;
}
// clang-format off
void (*const FallingBoulder_Functions[])(Entity*) = {
void (*const FallingBoulder_Functions[])(FallingBoulderEntity*) = {
FallingBoulder_OnTick,
FallingBoulder_OnCollision,
GenericKnockback,
GenericDeath,
GenericConfused,
(void (*)(FallingBoulderEntity*))GenericKnockback,
(void (*)(FallingBoulderEntity*))GenericDeath,
(void (*)(FallingBoulderEntity*))GenericConfused,
FallingBoulder_OnGrabbed,
};
void (*const gUnk_080CD558[])(Entity*) = {
void (*const gUnk_080CD558[])(FallingBoulderEntity*) = {
sub_0802C258,
sub_0802C318,
sub_0802C334,
+71 -61
View File
@@ -4,135 +4,145 @@
*
* @brief Fireball Guy enemy
*/
#include "enemy.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[28];
/*0x84*/ u8 unk_84;
} FireballGuyEntity;
typedef struct {
s8 h, v;
} PACKED PosOffset;
extern void sub_08045524(Entity*);
extern void sub_08045524(FireballGuyEntity*);
void sub_08045178(Entity*, Entity*, int, int);
void FireballGuy_OnTick(Entity*);
void FireballGuy_OnCollision(Entity*);
void FireballGuy_OnGrabbed(Entity*);
void FireballGuy_Init(Entity*);
void FireballGuy_Action1(Entity*);
void FireballGuy_Action2(Entity*);
void FireballGuy_OnTick(FireballGuyEntity*);
void FireballGuy_OnCollision(FireballGuyEntity*);
void FireballGuy_OnGrabbed(FireballGuyEntity*);
void FireballGuy_Init(FireballGuyEntity*);
void FireballGuy_Action1(FireballGuyEntity*);
void FireballGuy_Action2(FireballGuyEntity*);
static void (*const FireballGuy_Functions[])(Entity*) = {
FireballGuy_OnTick, FireballGuy_OnCollision, GenericKnockback, GenericDeath, GenericConfused, FireballGuy_OnGrabbed,
static void (*const FireballGuy_Functions[])(FireballGuyEntity*) = {
FireballGuy_OnTick,
FireballGuy_OnCollision,
(void (*)(FireballGuyEntity*))GenericKnockback,
(void (*)(FireballGuyEntity*))GenericDeath,
(void (*)(FireballGuyEntity*))GenericConfused,
FireballGuy_OnGrabbed,
};
void FireballGuy(Entity* this) {
EnemyFunctionHandler(this, FireballGuy_Functions);
void FireballGuy(FireballGuyEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)FireballGuy_Functions);
}
void FireballGuy_OnTick(Entity* this) {
static void (*const FireballGuy_Actions[])(Entity*) = {
void FireballGuy_OnTick(FireballGuyEntity* this) {
static void (*const FireballGuy_Actions[])(FireballGuyEntity*) = {
FireballGuy_Init,
FireballGuy_Action1,
FireballGuy_Action2,
};
FireballGuy_Actions[this->action](this);
FireballGuy_Actions[super->action](this);
}
void FireballGuy_OnCollision(Entity* this) {
if (this->health && this->cutsceneBeh.HALF.LO != this->health) {
this->action = 2;
void FireballGuy_OnCollision(FireballGuyEntity* this) {
if (super->health && this->unk_84 != super->health) {
super->action = 2;
} else {
EnemyFunctionHandlerAfterCollision(this, FireballGuy_Functions);
EnemyFunctionHandlerAfterCollision(super, FireballGuy_Functions);
}
}
void FireballGuy_OnGrabbed(Entity* this) {
void FireballGuy_OnGrabbed(FireballGuyEntity* this) {
}
void FireballGuy_Init(Entity* this) {
this->action = 1;
this->timer = 0;
this->spriteSettings.draw = 1;
this->speed = 0x80;
this->cutsceneBeh.HALF.LO = this->health;
this->collisionFlags |= 0x10;
sub_0804A720(this);
InitializeAnimation(this, 0);
void FireballGuy_Init(FireballGuyEntity* this) {
super->action = 1;
super->timer = 0;
super->spriteSettings.draw = 1;
super->speed = 0x80;
this->unk_84 = super->health;
super->collisionFlags |= 0x10;
sub_0804A720(super);
InitializeAnimation(super, 0);
sub_08045524(this);
}
void FireballGuy_Action1(Entity* this) {
ProcessMovement2(this);
GetNextFrame(this);
if (GravityUpdate(this, Q_8_8(24.0)) == 0)
void FireballGuy_Action1(FireballGuyEntity* this) {
ProcessMovement2(super);
GetNextFrame(super);
if (GravityUpdate(super, Q_8_8(24.0)) == 0)
sub_08045524(this);
}
/* Split FireballGuy into new ones */
void FireballGuy_Action2(Entity* this) {
void FireballGuy_Action2(FireballGuyEntity* this) {
// Entity count per form
static const u8 typeEntityCount[4] = { 2, 3, 4, 5 };
static const PosOffset gUnk_080D1810[4] = { { 6, 0 }, { -6, 0 }, { 0, 6 }, { 0, -6 } };
Entity* entities[4];
Entity* ent;
Entity* entity;
s32 count, i;
const PosOffset* off;
u32 tmp;
/* Can we create enough new entities? */
count = typeEntityCount[this->type];
if (MAX_ENTITIES + 1 - count <= gEntCount)
count = typeEntityCount[super->type];
if (MAX_ENTITIES - count <= gEntCount)
return;
/* Create 2-5 new MiniFireballGuy */
for (i = 0; i < count; i++)
entities[i] = CreateEnemy(MINI_FIREBALL_GUY, this->type);
entities[i] = CreateEnemy(MINI_FIREBALL_GUY, super->type);
off = gUnk_080D1810;
for (i = 0; i < count; i++) {
ent = entities[i];
ent->child = entities[(i + 1) % count];
ent->parent = entities[(i + count - 1) % count];
entity = entities[i];
entity->child = entities[(i + 1) % count];
entity->parent = entities[(i + count - 1) % count];
tmp = 0;
ent->type2 = 1;
ent->z.HALF.HI = tmp;
ent->iframes = -0x10;
entity->type2 = 1;
entity->z.HALF.HI = tmp;
entity->iframes = -0x10;
/* Set MiniFireballGuy offset relative to killed slime. */
sub_08045178(this, ent, off->h, off->v);
sub_08045178(super, entity, off->h, off->v);
off++;
}
ent = CreateFx(this, FX_DEATH, 0);
if (ent != NULL)
CopyPosition(this, ent);
entity = CreateFx(super, FX_DEATH, 0);
if (entity != NULL)
CopyPosition(super, entity);
DeleteEntity(this);
DeleteEntity(super);
}
u32 sub_0804A024(Entity*, u32, u32);
void sub_08045524(Entity* this) {
void sub_08045524(FireballGuyEntity* this) {
u32 tmp, tmp1, tmp2;
this->zVelocity = Q_16_16(1.75);
tmp = sub_0804A024(this, 1, 8);
super->zVelocity = Q_16_16(1.75);
tmp = sub_0804A024(super, 1, 8);
if (tmp != DIR_NONE && (Random() & 3) == 0) {
this->timer = Random() & 3;
this->direction = DirectionRound(tmp);
super->timer = Random() & 3;
super->direction = DirectionRound(tmp);
} else {
if (this->timer != 0) {
this->timer--;
if (super->timer != 0) {
super->timer--;
return;
}
this->timer = Random() & 3;
if (sub_08049FA0(this) == 0 && (Random() & 3)) {
tmp1 = sub_08049EE4(this);
super->timer = Random() & 3;
if (sub_08049FA0(super) == 0 && (Random() & 3)) {
tmp1 = sub_08049EE4(super);
tmp2 = Random() & 8;
tmp2 += 0xfc;
this->direction = DirectionRound(tmp1 + tmp2);
super->direction = DirectionRound(tmp1 + tmp2);
} else {
this->direction = DirectionRound(Random());
super->direction = DirectionRound(Random());
}
}
}
+2 -3
View File
@@ -4,10 +4,9 @@
*
* @brief Flying pot enemy
*/
#define NENT_DEPRECATED
#include "collision.h"
#include "functions.h"
#include "enemy.h"
#include "functions.h"
#include "player.h"
#include "room.h"
#include "tiles.h"
@@ -222,7 +221,7 @@ void FlyingPot_Action3(FlyingPotEntity* this) {
if (super->z.HALF.HI <= -6) {
super->action = FLYING_POT_ACTION_4;
super->timer = 10;
super->direction = GetFacingDirection(super, &gPlayerEntity);
super->direction = GetFacingDirection(super, &gPlayerEntity.base);
}
}
+19 -14
View File
@@ -1,7 +1,12 @@
#define NENT_DEPRECATED
/**
* @file flyingSkull.c
* @ingroup Enemies
*
* @brief Flying Skull enemy
*/
#include "collision.h"
#include "entity.h"
#include "enemy.h"
#include "entity.h"
#include "functions.h"
#include "hitbox.h"
#include "tiles.h"
@@ -133,16 +138,16 @@ void sub_08039DD8(FlyingSkullEntity* this) {
RegisterCarryEntity(super);
} else {
if ((gPlayerState.flags & PL_MINISH) == 0) {
Entity* ent = &gPlayerEntity;
if (EntityWithinDistance(super, ent->x.HALF.HI, ent->y.HALF.HI, 0x30)) {
Entity* player = &gPlayerEntity.base;
if (EntityWithinDistance(super, player->x.HALF.HI, player->y.HALF.HI, 0x30)) {
if (super->type == 1) {
super->action = 3;
super->timer = 30;
} else {
ent = CreateEnemy(STALFOS, super->type - 2);
if (ent != NULL) {
ent->type2 = 1;
CopyPosition(super, ent);
player = CreateEnemy(STALFOS, super->type - 2);
if (player != NULL) {
player->type2 = 1;
CopyPosition(super, player);
SetMetaTile(this->metaTileIndex, COORD_TO_TILE(super), super->collisionLayer);
DeleteEntity(super);
}
@@ -161,15 +166,15 @@ void sub_08039EE4(FlyingSkullEntity* this) {
COLLISION_OFF(super);
super->collisions = COL_NONE;
super->hitbox = (Hitbox*)&gUnk_080FD340;
gPlayerEntity.animationState;
this->unk_0x76 = gPlayerEntity.animationState;
gPlayerEntity.base.animationState;
this->unk_0x76 = gPlayerEntity.base.animationState;
SetMetaTile(this->metaTileIndex, COORD_TO_TILE(super), super->collisionLayer);
}
void sub_08039F4C(FlyingSkullEntity* this) {
if (gPlayerEntity.animationState != this->unk_0x76) {
super->frameIndex = AnimationStateIdle(gPlayerEntity.animationState - this->unk_0x76 + super->frameIndex);
this->unk_0x76 = gPlayerEntity.animationState;
if (gPlayerEntity.base.animationState != this->unk_0x76) {
super->frameIndex = AnimationStateIdle(gPlayerEntity.base.animationState - this->unk_0x76 + super->frameIndex);
this->unk_0x76 = gPlayerEntity.base.animationState;
}
}
@@ -206,7 +211,7 @@ void sub_0803A048(FlyingSkullEntity* this) {
if (super->z.HALF.HI <= -6) {
super->action = 5;
super->timer = 10;
super->direction = GetFacingDirection(super, &gPlayerEntity);
super->direction = GetFacingDirection(super, &gPlayerEntity.base);
}
}
+13 -16
View File
@@ -4,12 +4,9 @@
*
* @brief Ghini enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "area.h"
#include "enemy.h"
#include "functions.h"
#include "area.h"
#include "physics.h"
typedef struct {
@@ -124,7 +121,7 @@ void Ghini_OnGrabbed(GhiniEntity* this) {
void Ghini_SubAction0(GhiniEntity* this) {
super->subAction = 1;
super->gustJarTolerance = 0x3c;
InitializeAnimation(super, (gPlayerEntity.animationState >> 2) + 5);
InitializeAnimation(super, (gPlayerEntity.base.animationState >> 2) + 5);
}
void Ghini_SubAction1(GhiniEntity* this) {
@@ -262,7 +259,7 @@ void Ghini_Action9(GhiniEntity* this) {
if (sub_0807953C() != 0) {
this->unk_78 += 0xc;
}
if (gPlayerEntity.health == 0) {
if (gPlayerEntity.base.health == 0) {
this->unk_78 = 0xe0;
}
if (++this->unk_78 >= 0xe0) {
@@ -271,7 +268,7 @@ void Ghini_Action9(GhiniEntity* this) {
super->iframes = -0xc;
super->knockbackDuration = 0x14;
super->knockbackSpeed = 0x180;
super->knockbackDirection = gPlayerEntity.animationState << 2 ^ 0x10;
super->knockbackDirection = gPlayerEntity.base.animationState << 2 ^ 0x10;
sub_0803F51C(this);
sub_0803F6EC(this);
} else {
@@ -366,18 +363,18 @@ void sub_0803F694(GhiniEntity* this) {
void sub_0803F6C0(GhiniEntity* this) {
super->frame &= ~1;
gPlayerEntity.iframes = 0xc;
gPlayerEntity.base.iframes = 0xc;
ModHealth(-4);
SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6);
SoundReqClipped(&gPlayerEntity.base, SFX_PLY_VO6);
}
void sub_0803F6EC(GhiniEntity* this) {
if (gPlayerEntity.health != 0) {
gPlayerEntity.flags |= ENT_COLLIDE;
gPlayerEntity.zVelocity = Q_16_16(1.5);
gPlayerEntity.z.HALF.HI = -2;
gPlayerEntity.direction = gPlayerEntity.animationState << 2;
gPlayerEntity.iframes = -0x3c;
if (gPlayerEntity.base.health != 0) {
gPlayerEntity.base.flags |= ENT_COLLIDE;
gPlayerEntity.base.zVelocity = Q_16_16(1.5);
gPlayerEntity.base.z.HALF.HI = -2;
gPlayerEntity.base.direction = gPlayerEntity.base.animationState << 2;
gPlayerEntity.base.iframes = -0x3c;
gPlayerState.jump_status = 0x41;
}
gPlayerState.flags &= ~PL_CAPTURED;
@@ -387,7 +384,7 @@ void sub_0803F738(GhiniEntity* this) {
ResetActiveItems();
gPlayerState.mobility |= 0x80;
gPlayerState.field_0xa |= 0x80;
sub_0806FA90(&gPlayerEntity, super, 0, 1);
sub_0806FA90(&gPlayerEntity.base, super, 0, 1);
super->spriteOffsetY -= 2;
}
+21 -24
View File
@@ -4,12 +4,9 @@
*
* @brief Gibdo enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "enemy.h"
#include "object.h"
#include "functions.h"
#include "object.h"
typedef struct {
Entity base;
@@ -169,7 +166,7 @@ void sub_080376D0(GibdoEntity* this) {
ResetActiveItems();
gPlayerState.mobility |= 0x80;
gPlayerState.field_0xa |= 0x80;
CopyPositionAndSpriteOffset(&gPlayerEntity, super);
CopyPositionAndSpriteOffset(&gPlayerEntity.base, super);
UpdateAnimationSingleFrame(super);
if ((super->frame & 1) != 0) {
if (--this->field_0x7c == 0) {
@@ -355,19 +352,19 @@ void sub_08037A58(GibdoEntity* this) {
void sub_08037ACC(GibdoEntity* this) {
gPlayerState.flags &= ~PL_DISABLE_ITEMS;
COLLISION_ON(&gPlayerEntity);
gPlayerEntity.iframes = 30;
gPlayerEntity.knockbackDirection = DirectionFromAnimationState(super->animationState);
gPlayerEntity.knockbackDuration = 4;
gPlayerEntity.knockbackSpeed = 0x180;
COLLISION_ON(&gPlayerEntity.base);
gPlayerEntity.base.iframes = 30;
gPlayerEntity.base.knockbackDirection = DirectionFromAnimationState(super->animationState);
gPlayerEntity.base.knockbackDuration = 4;
gPlayerEntity.base.knockbackSpeed = 0x180;
}
// Damage player maybe?
void sub_08037B10(GibdoEntity* this) {
u32 health;
gPlayerEntity.iframes = 0xc;
gPlayerEntity.base.iframes = 0xc;
health = ModHealth(-8);
SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6);
SoundReqClipped(&gPlayerEntity.base, SFX_PLY_VO6);
if (health == 0) {
sub_08037A58(this);
this->field_0x76 = 240;
@@ -409,23 +406,23 @@ void Gibdo_CreateObjects(GibdoEntity* this) {
}
void Gibdo_MoveObjectsToStalfos(GibdoEntity* this, Entity* that) {
Entity* ent = this->field_0x80;
Entity* entity = this->field_0x80;
if (ent != NULL) {
ent->timer = 15;
ent->parent = that;
if (entity != NULL) {
entity->timer = 15;
entity->parent = that;
}
ent = this->field_0x84;
if (ent != NULL) {
ent->timer = 15;
ent->parent = that;
entity = this->field_0x84;
if (entity != NULL) {
entity->timer = 15;
entity->parent = that;
}
ent = super->child;
if (ent != NULL) {
ent->timer = 15;
ent->parent = that;
entity = super->child;
if (entity != NULL) {
entity->timer = 15;
entity->parent = that;
}
}
+44 -39
View File
@@ -1,10 +1,15 @@
#define NENT_DEPRECATED
#include "entity.h"
/**
* @file gleerok.c
* @ingroup Enemies
*
* @brief Gleerok enemy
*/
#include "enemy.h"
#include "player.h"
#include "screen.h"
#include "entity.h"
#include "functions.h"
#include "object.h"
#include "player.h"
#include "screen.h"
typedef struct {
union SplitHWord unk0;
@@ -19,7 +24,7 @@ typedef struct {
/*0x2e*/ u16 filler_2e;
/*0x30*/ u8 unk_30[6];
/*0x36*/ u8 filler_36[0x2];
/*0x38*/ Entity* ent;
/*0x38*/ Entity* entity1;
/*0x3c*/ Entity* entities[5];
/*0x50*/ Entity* ent2;
} Gleerok_HeapStruct;
@@ -145,7 +150,7 @@ void Gleerok(GleerokEntity* this) {
}
void Gleerok_OnDeath(GleerokEntity* this) {
sub_08078B48();
PausePlayer();
switch (super->type) {
case 2:
@@ -165,7 +170,7 @@ void Gleerok_OnDeath(GleerokEntity* this) {
this->unk_74--;
gScreen.controls.alphaBlend = this->unk_74 | (this->unk_75 << 8);
if (gScreen.controls.alphaBlend == 0x1000) {
sub_0807AABC(&gPlayerEntity);
sub_0807AABC(&gPlayerEntity.base);
DeleteThisEntity();
}
}
@@ -184,7 +189,7 @@ void Gleerok_OnDeath(GleerokEntity* this) {
case 0:
gPlayerState.field_0x14 = 1;
if (sub_0806FC80(super, &gPlayerEntity, super->frame & 0x3f)) {
if (sub_0806FC80(super, &gPlayerEntity.base, super->frame & 0x3f)) {
gPlayerState.spriteOffsetY = -6;
}
@@ -210,10 +215,10 @@ void sub_0802D170(GleerokEntity* this) {
this->unk_84->filler2[0].unk0.HALF.HI = 0x10;
if (sub_0802EB08(this->unk_84, 0x40, 2) == 0 && sub_0802EA88(this->unk_84) == 0) {
super->action = 2;
gPlayerEntity.x.HALF.HI = gRoomControls.origin_x + 0x98;
gPlayerEntity.y.HALF.HI = gRoomControls.origin_y + 0xd8;
gPlayerEntity.animationState = 0;
RestorePrevTileEntity(COORD_TO_TILE(&gPlayerEntity), 2);
gPlayerEntity.base.x.HALF.HI = gRoomControls.origin_x + 0x98;
gPlayerEntity.base.y.HALF.HI = gRoomControls.origin_y + 0xd8;
gPlayerEntity.base.animationState = 0;
RestorePrevTileEntity(COORD_TO_TILE(&gPlayerEntity.base), 2);
gRoomControls.camera_target = super;
SetFade(FADE_BLACK_WHITE | FADE_INSTANT, 8);
}
@@ -313,7 +318,7 @@ void sub_0802D3B8(GleerokEntity* this) {
if (CheckGlobalFlag(LV2_CLEAR)) {
gScreen.lcd.displayControl &= 0xfdff;
sub_0807AABC(&gPlayerEntity);
sub_0807AABC(&gPlayerEntity.base);
DeleteThisEntity();
}
@@ -420,7 +425,7 @@ void sub_0802D3B8(GleerokEntity* this) {
void sub_0802D650(GleerokEntity* this) {
#ifdef EU
sub_08078B48();
PausePlayer();
#endif
gUnk_080CD7E4[super->subAction](this);
@@ -431,7 +436,7 @@ void sub_0802D674(GleerokEntity* this) {
u32 val;
gPauseMenuOptions.disabled = 1;
if (gPlayerEntity.z.WORD != 0)
if (gPlayerEntity.base.z.WORD != 0)
return;
if (this->unk_7c.WORD == 0x96) {
SoundReq(SFX_BOSS_HIT);
@@ -445,13 +450,13 @@ void sub_0802D674(GleerokEntity* this) {
SoundReq(SFX_BOSS_HIT);
} else if (val <= 0x3c) {
if (val == 0x3c) {
CreateSpeechBubbleExclamationMark(&gPlayerEntity, 0xc, -0x18);
CreateSpeechBubbleExclamationMark(&gPlayerEntity.base, 0xc, -0x18);
}
gPlayerEntity.animationState = 0;
gPlayerEntity.base.animationState = 0;
} else if (val <= 0x59) {
gPlayerEntity.animationState = 2;
gPlayerEntity.base.animationState = 2;
} else if (val <= 0x77) {
gPlayerEntity.animationState = 6;
gPlayerEntity.base.animationState = 6;
}
}
@@ -485,7 +490,7 @@ void sub_0802D714(GleerokEntity* this) {
super->child = enemy;
if (enemy) {
enemy->parent = super;
heap->ent = super->child;
heap->entity1 = super->child;
((GleerokEntity*)(super->child))->unk_84 = heap;
}
@@ -515,7 +520,7 @@ void sub_0802D7B4(GleerokEntity* this) {
super->action = 1;
super->subAction = 0;
this->unk_84->ent2->timer = 24;
gRoomControls.camera_target = &gPlayerEntity;
gRoomControls.camera_target = &gPlayerEntity.base;
#ifndef EU
gPlayerState.controlMode = CONTROL_1;
#endif
@@ -572,7 +577,7 @@ void sub_0802D86C(GleerokEntity* this) {
if (((GleerokEntity*)(super->parent))->unk_80 == 0)
return;
if (!EntityInRectRadius(super, &gPlayerEntity, 8, 8))
if (!EntityInRectRadius(super, &gPlayerEntity.base, 8, 8))
return;
gPlayerState.field_0x14 = 1;
@@ -612,7 +617,7 @@ void sub_0802D86C(GleerokEntity* this) {
super->child = enemy;
if (enemy) {
enemy->parent = super->parent;
this->unk_84->ent = super->child;
this->unk_84->entity1 = super->child;
((GleerokEntity*)super->child)->unk_84 = this->unk_84;
}
@@ -633,7 +638,7 @@ void sub_0802D86C(GleerokEntity* this) {
if (enemy) {
enemy->parent = super->parent;
super->timer = this->unk_84->filler[0].unk0.HALF.HI;
this->unk_84->ent = super->child;
this->unk_84->entity1 = super->child;
((GleerokEntity*)super->child)->unk_84 = this->unk_84;
}
@@ -689,7 +694,7 @@ void sub_0802D86C(GleerokEntity* this) {
super->child = CreateEnemy(GLEEROK, 4);
if (super->child) {
super->child->parent = super->parent;
this->unk_84->ent = super->child;
this->unk_84->entity1 = super->child;
((GleerokEntity*)super->child)->unk_84 = this->unk_84;
CopyPosition(super, ((volatile Entity*)super)->child);
DeleteThisEntity();
@@ -705,7 +710,7 @@ void sub_0802D86C(GleerokEntity* this) {
void sub_0802DB84(GleerokEntity* this) {
u32 timer;
super->direction = GetFacingDirection(super, &gPlayerEntity);
super->direction = GetFacingDirection(super, &gPlayerEntity.base);
if (this->unk_84->filler[0].unk0.HALF.HI == super->direction) {
super->subAction = 1;
this->unk_78 = 0;
@@ -739,7 +744,7 @@ void sub_0802DB84(GleerokEntity* this) {
}
void sub_0802DC1C(GleerokEntity* this) {
u32 diff = GetFacingDirection(super, &gPlayerEntity);
u32 diff = GetFacingDirection(super, &gPlayerEntity.base);
diff = (this->unk_84->filler[0].unk0.HALF.HI - diff) & 0x1f;
if (diff > 0x10) {
@@ -783,7 +788,7 @@ void sub_0802DC1C(GleerokEntity* this) {
void sub_0802DCE0(GleerokEntity* this) {
if (this->unk_84->ent2->timer != 12) {
super->direction = GetFacingDirection(super, &gPlayerEntity);
super->direction = GetFacingDirection(super, &gPlayerEntity.base);
if (this->unk_84->filler[5].unk0.HALF.HI == super->direction) {
this->unk_84->ent2->timer = 12;
this->unk_82 = 4;
@@ -1004,7 +1009,7 @@ void sub_0802E0B8(GleerokEntity* this) {
val = super->frame & 0x3f;
if (val) {
if (sub_0806FC80(super, &gPlayerEntity, val)) {
if (sub_0806FC80(super, &gPlayerEntity.base, val)) {
gPlayerState.field_0x14 = 1;
gPlayerState.spriteOffsetY = -6;
}
@@ -1014,7 +1019,7 @@ void sub_0802E0B8(GleerokEntity* this) {
if (this->unk_79 > 1) {
super->health = 0;
super->action = 0;
sub_08078B48();
PausePlayer();
SoundReq(SFX_BOSS_DIE);
return;
} else {
@@ -1054,7 +1059,7 @@ void sub_0802E1D0(GleerokEntity* this) {
GetNextFrame(super);
}
if (super->frame & 0x3f) {
if (sub_0806FC80(super, &gPlayerEntity, super->frame & 0x3f)) {
if (sub_0806FC80(super, &gPlayerEntity.base, super->frame & 0x3f)) {
gPlayerState.field_0x14 = 1;
gPlayerState.spriteOffsetY = -6;
}
@@ -1097,7 +1102,7 @@ void sub_0802E300(GleerokEntity* this) {
u32 index;
Gleerok_HeapStruct2* ptr;
u8* ptr2;
Entity* ent;
Entity* entity;
Gleerok_HeapStruct* heap;
if ((this->unk_79 & 0x80) == 0) {
this->unk_7c.HALF.LO--;
@@ -1128,7 +1133,7 @@ void sub_0802E300(GleerokEntity* this) {
this->unk_79 &= ~0x80;
heap = this->unk_84;
dir = GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)) << 3;
dir = GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base)) << 3;
index = 0;
ptr2 = &this->unk_80;
tmp = 0;
@@ -1144,11 +1149,11 @@ void sub_0802E300(GleerokEntity* this) {
super->type2 = 0;
*ptr2 = 0;
InitializeAnimation(super, 0x4d);
ent = CreateEnemy(GLEEROK, 5);
super->child = ent;
entity = CreateEnemy(GLEEROK, 5);
super->child = entity;
if (super->child != NULL) {
super->child->parent = super;
heap->ent = super->child;
heap->entity1 = super->child;
((GleerokEntity*)super->child)->unk_84 = heap;
}
@@ -1368,7 +1373,7 @@ void sub_0802E7E4(Gleerok_HeapStruct* this) {
this->entities[i + 1]->spritePriority.b0 = bVar6;
}
}
this->ent->spritePriority.b0 = 0;
this->entity1->spritePriority.b0 = 0;
} else {
bVar6 = 5;
@@ -1388,7 +1393,7 @@ void sub_0802E7E4(Gleerok_HeapStruct* this) {
this->entities[i + 1]->spritePriority.b0 = bVar6;
}
}
this->ent->spritePriority.b0 = 6;
this->entity1->spritePriority.b0 = 6;
}
}
@@ -1398,7 +1403,7 @@ void sub_0802E9B0(GleerokEntity* this) {
s32 uVar4;
Gleerok_HeapStruct* heap;
iVar2 = sub_080041DC(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI) >> 4;
iVar2 = sub_080041DC(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI) >> 4;
if (iVar2 < 0x60) {
iVar2 = 10;
} else {
+10 -6
View File
@@ -1,9 +1,13 @@
#define NENT_DEPRECATED
#include "global.h"
#include "room.h"
/**
* @file gyorgChild.c
* @ingroup Enemies
*
* @brief Gyorg Child enemy
*/
#include "asm.h"
#include "functions.h"
#include "enemy/gyorg.h"
#include "functions.h"
#include "room.h"
void GyorgChild_OnTick(GyorgChildEntity*);
void GyorgChild_OnCollision(GyorgChildEntity*);
@@ -155,13 +159,13 @@ void GyorgChild_Action2(GyorgChildEntity* this) {
switch (super->animationState >> 1) {
case 0:
case 2:
super->x.HALF.HI = gPlayerEntity.x.HALF.HI + this->attackOffsetX;
super->x.HALF.HI = gPlayerEntity.base.x.HALF.HI + this->attackOffsetX;
super->y.HALF.HI = gRoomControls.scroll_y + this->attackOffsetY;
break;
case 1:
default:
super->x.HALF.HI = gRoomControls.scroll_x + this->attackOffsetX;
super->y.HALF.HI = gPlayerEntity.y.HALF.HI + this->attackOffsetY;
super->y.HALF.HI = gPlayerEntity.base.y.HALF.HI + this->attackOffsetY;
break;
}
if (super->type2 == 0) {
+35 -30
View File
@@ -1,4 +1,9 @@
#define NENT_DEPRECATED
/**
* @file gyorgFemale.c
* @ingroup Enemies
*
* @brief Gyorg Female enemy
*/
#include "asm.h"
#include "beanstalkSubtask.h"
#include "collision.h"
@@ -51,32 +56,32 @@ void GyorgFemale(Entity* this) {
}
void GyorgFemale_Setup(GyorgFemaleEntity* this) {
Entity* tmp;
Entity* entity;
if (gEntCount > 0x3d)
return;
tmp = CreateProjectile(GYORG_TAIL);
tmp->type = 0;
tmp->parent = super;
((GyorgHeap*)super->myHeap)->tail = (GenericEntity*)tmp;
tmp = CreateEnemy(GYORG_FEMALE_MOUTH, 0);
tmp->parent = super;
((GyorgHeap*)super->myHeap)->mouth = (GyorgFemaleMouthEntity*)tmp;
tmp = CreateEnemy(GYORG_FEMALE_EYE, 0);
tmp->parent = super;
tmp = CreateEnemy(GYORG_FEMALE_EYE, 1);
tmp->parent = super;
tmp = CreateEnemy(GYORG_FEMALE_EYE, 2);
tmp->parent = super;
tmp = CreateEnemy(GYORG_FEMALE_EYE, 3);
tmp->parent = super;
tmp = CreateEnemy(GYORG_FEMALE_EYE, 4);
tmp->parent = super;
tmp = CreateEnemy(GYORG_FEMALE_EYE, 5);
tmp->parent = super;
tmp = CreateEnemy(GYORG_FEMALE_EYE, 6);
tmp->parent = super;
tmp = CreateEnemy(GYORG_FEMALE_EYE, 7);
tmp->parent = super;
entity = CreateProjectile(GYORG_TAIL);
entity->type = 0;
entity->parent = super;
((GyorgHeap*)super->myHeap)->tail = (GenericEntity*)entity;
entity = CreateEnemy(GYORG_FEMALE_MOUTH, 0);
entity->parent = super;
((GyorgHeap*)super->myHeap)->mouth = (GyorgFemaleMouthEntity*)entity;
entity = CreateEnemy(GYORG_FEMALE_EYE, 0);
entity->parent = super;
entity = CreateEnemy(GYORG_FEMALE_EYE, 1);
entity->parent = super;
entity = CreateEnemy(GYORG_FEMALE_EYE, 2);
entity->parent = super;
entity = CreateEnemy(GYORG_FEMALE_EYE, 3);
entity->parent = super;
entity = CreateEnemy(GYORG_FEMALE_EYE, 4);
entity->parent = super;
entity = CreateEnemy(GYORG_FEMALE_EYE, 5);
entity->parent = super;
entity = CreateEnemy(GYORG_FEMALE_EYE, 6);
entity->parent = super;
entity = CreateEnemy(GYORG_FEMALE_EYE, 7);
entity->parent = super;
super->action = 1;
super->spriteOrientation.flipY = 2;
super->spriteRendering.b3 = 2;
@@ -88,8 +93,8 @@ void GyorgFemale_Setup(GyorgFemaleEntity* this) {
MemClear(&gMapDataTopSpecial, 0x8000);
sub_0804660C(this, 0);
sub_080464C0(this);
gPlayerEntity.collisionLayer = 2;
UpdateSpriteForCollisionLayer(&gPlayerEntity);
gPlayerEntity.base.collisionLayer = 2;
UpdateSpriteForCollisionLayer(&gPlayerEntity.base);
#ifndef EU
RegisterTransitionManager(this, sub_08046498, 0);
#else
@@ -267,8 +272,8 @@ void sub_08046518(void) {
void sub_080465C8(void) {
s32 x, y;
x = (gPlayerEntity.x.HALF.HI - gRoomControls.origin_x) >> 3;
y = (gPlayerEntity.y.HALF.HI - gRoomControls.origin_y) >> 3;
x = (gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x) >> 3;
y = (gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y) >> 3;
if (gMapDataBottomSpecial[(y << 7) + x]) {
gPlayerState.field_0x14 = 1;
}
@@ -373,7 +378,7 @@ void GyorgFemale_ProcessEyeHit(GyorgFemaleEntity* this) {
#ifndef EU
if (((GyorgHeap*)super->myHeap)->unk_3c != 0xFF) {
#endif
tmp = &gPlayerEntity;
tmp = &gPlayerEntity.base;
tmp->knockbackDirection = ((GyorgHeap*)super->myHeap)->unk_3c;
tmp->iframes = 0xF4;
tmp->knockbackDuration = 0xA;
+11 -7
View File
@@ -1,10 +1,14 @@
#define NENT_DEPRECATED
#include "global.h"
#include "entity.h"
/**
* @file gyorgFemaleEye.c
* @ingroup Enemies
*
* @brief Gyorg Female Eye enemy
*/
#include "enemy.h"
#include "player.h"
#include "functions.h"
#include "enemy/gyorg.h"
#include "entity.h"
#include "functions.h"
#include "player.h"
void GyorgFemaleEye_OnTick(GyorgFemaleEyeEntity*);
void GyorgFemaleEye_OnCollision(GyorgFemaleEyeEntity*);
@@ -79,9 +83,9 @@ void GyorgFemaleEye_OnCollision(GyorgFemaleEyeEntity* this) {
#endif
(*(((GyorgHeap**)&parent->base.myHeap)))->unk_18[super->type] = super->contactedEntity;
(*(((GyorgHeap**)&parent->base.myHeap)))->reflectFxPos.HALF.x =
(gPlayerEntity.x.HALF.HI + super->x.HALF.HI) / 2;
(gPlayerEntity.base.x.HALF.HI + super->x.HALF.HI) / 2;
(*(((GyorgHeap**)&parent->base.myHeap)))->reflectFxPos.HALF.y =
(gPlayerEntity.y.HALF.HI + super->y.HALF.HI) / 2;
(gPlayerEntity.base.y.HALF.HI + super->y.HALF.HI) / 2;
(*(((GyorgHeap**)&parent->base.myHeap)))->unk_3c = (super->knockbackDirection ^= 0x10);
#ifndef EU
break;
+9 -5
View File
@@ -1,8 +1,12 @@
#define NENT_DEPRECATED
#include "global.h"
/**
* @file gyorgFemaleMouth.c
* @ingroup Enemies
*
* @brief Gyorg Female Mouth enemy
*/
#include "enemy/gyorg.h"
#include "player.h"
#include "room.h"
#include "enemy/gyorg.h"
extern const Hitbox gUnk_080D28DC;
extern const Hitbox gUnk_080D28E4;
@@ -54,11 +58,11 @@ void GyorgFemaleMouth(Entity* this) {
GetNextFrame(this);
}
if (tmp & 2) {
if (this->y.HALF.HI < gPlayerEntity.y.HALF.HI) {
if (this->y.HALF.HI < gPlayerEntity.base.y.HALF.HI) {
tmp++;
}
} else {
if (this->x.HALF.HI < gPlayerEntity.x.HALF.HI) {
if (this->x.HALF.HI < gPlayerEntity.base.x.HALF.HI) {
tmp++;
}
}
+30 -32
View File
@@ -4,15 +4,12 @@
*
* @brief Gyorg Male enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "effects.h"
#include "enemy.h"
#include "player.h"
#include "enemy/gyorg.h"
#include "fileselect.h"
#include "functions.h"
#include "effects.h"
#include "enemy/gyorg.h"
#include "player.h"
// todo: wrong types
extern void sub_080A1D70(Entity*, u32);
@@ -114,8 +111,8 @@ void GyorgMale(GyorgMaleEntity* this) {
if (super->spriteSettings.draw == 1 && (super->y.HALF.HI - gRoomControls.scroll_y + 0x30) > 0x100u) {
super->spriteSettings.draw = 0;
}
this->unk_84 = gPlayerEntity.x.HALF.HI;
this->unk_86 = gPlayerEntity.y.HALF.HI;
this->unk_84 = gPlayerEntity.base.x.HALF.HI;
this->unk_86 = gPlayerEntity.base.y.HALF.HI;
}
void sub_08046898(GyorgMaleEntity* this) {
@@ -799,7 +796,7 @@ void sub_080477F0(GyorgMaleEntity* this) {
}
super->direction = CalculateDirectionFromOffsets(this->unk_80 - super->x.HALF.HI, this->unk_82 - super->y.HALF.HI);
sub_08047E48(this);
if (!EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x80)) {
if (!EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, 0x80)) {
super->action = 2;
super->subAction = 0;
super->spriteOrientation.flipY = 2;
@@ -864,7 +861,7 @@ void sub_08047978(GyorgMaleEntity* this) {
tmp->parent = super;
}
}
if (!EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x80)) {
if (!EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, 0x80)) {
super->action = 2;
super->subAction = 0;
super->spriteOrientation.flipY = 2;
@@ -1022,10 +1019,10 @@ void sub_08047D88(GyorgMaleEntity* this) {
return;
if (super->animIndex == 1)
return;
if (!EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x20))
if (!EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, 0x20))
return;
gPlayerState.field_0x14 = 1;
if (gPlayerEntity.z.HALF.HI != 0)
if (gPlayerEntity.base.z.HALF.HI != 0)
return;
this->unk_7c |= 1;
}
@@ -1039,8 +1036,8 @@ void sub_08047DF0(GyorgMaleEntity* this, u32 unk1) {
LinearMoveAngle(super, super->speed, super->direction);
if (this->unk_7c & 1) {
if (PlayerCanBeMoved()) {
gPlayerEntity.x.HALF.HI += super->x.HALF.HI - oldX;
gPlayerEntity.y.HALF.HI += super->y.HALF.HI - oldY;
gPlayerEntity.base.x.HALF.HI += super->x.HALF.HI - oldX;
gPlayerEntity.base.y.HALF.HI += super->y.HALF.HI - oldY;
}
}
}
@@ -1057,8 +1054,8 @@ void sub_08047E58(GyorgMaleEntity* this) {
LinearMoveAngle(super, super->speed, super->direction);
if (this->unk_7c & 1) {
if (PlayerCanBeMoved()) {
gPlayerEntity.x.HALF.HI += super->x.HALF.HI - oldX;
gPlayerEntity.y.HALF.HI += super->y.HALF.HI - oldY;
gPlayerEntity.base.x.HALF.HI += super->x.HALF.HI - oldX;
gPlayerEntity.base.y.HALF.HI += super->y.HALF.HI - oldY;
}
}
}
@@ -1072,12 +1069,13 @@ void sub_08047EA4(GyorgMaleEntity* this, u32 unk1) {
return;
if (this->unk_7c & 1) {
tmp2 = sub_08047F68(this) << 8;
dir = CalculateDirectionFromOffsets(gPlayerEntity.x.HALF.HI - super->x.HALF.HI,
gPlayerEntity.y.HALF.HI - super->y.HALF.HI);
dir = CalculateDirectionFromOffsets(gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI,
gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI);
tmp = dir - (tmp / 256);
tmp &= 0xFF;
gPlayerEntity.x.WORD += (gSineTable[tmp] - gSineTable[dir]) * tmp2;
gPlayerEntity.y.WORD -= (gSineTable[tmp + 0x40] - gSineTable[dir + 0x40]) * tmp2;
gPlayerEntity.base.x.WORD += (gSineTable[tmp] - gSineTable[dir]) * tmp2;
gPlayerEntity.base.y.WORD -= (gSineTable[tmp + 0x40] - gSineTable[dir + 0x40]) * tmp2;
}
this->unk_7a = this->unk_78;
}
@@ -1088,8 +1086,8 @@ const u16 gUnk_080D1C04[0x20] = { 0, 1, 4, 9, 16, 25, 36, 49, 64, 8
u32 sub_08047F68(GyorgMaleEntity* this) {
s32 diffX, diffY;
s32 distSquared, approx;
diffX = gPlayerEntity.x.HALF.HI - super->x.HALF.HI;
diffY = gPlayerEntity.y.HALF.HI - super->y.HALF.HI;
diffX = gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI;
diffY = gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI;
distSquared = (diffX * diffX) + (diffY * diffY);
if (distSquared == 0x400)
return 0x20;
@@ -1128,15 +1126,15 @@ void sub_08048004(GyorgMaleEntity* this) {
return;
if (super->animIndex == 0) {
COLLISION_OFF(super);
if (gPlayerEntity.z.HALF.HI != 0)
if (gPlayerEntity.base.z.HALF.HI != 0)
return;
if (!PlayerCanBeMoved())
return;
if (this->unk_7c & 1) {
u32 b = super->spriteRendering.b3;
if (b == 3) {
s32 posX = ((gPlayerEntity.x.HALF.HI - gRoomControls.origin_x) >> 3);
s32 posY = ((gPlayerEntity.y.HALF.HI - gRoomControls.origin_y) >> 3);
s32 posX = ((gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x) >> 3);
s32 posY = ((gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y) >> 3);
u16* tmp = (u16*)&gMapDataBottomSpecial;
if (tmp[(posY << 7) + posX]) {
if (!(this->unk_7c & 2)) {
@@ -1144,8 +1142,8 @@ void sub_08048004(GyorgMaleEntity* this) {
}
if ((this->unk_7c & 0x80))
return;
gPlayerEntity.x.HALF.HI = this->unk_84;
gPlayerEntity.y.HALF.HI = this->unk_86;
gPlayerEntity.base.x.HALF.HI = this->unk_84;
gPlayerEntity.base.y.HALF.HI = this->unk_86;
return;
}
}
@@ -1153,12 +1151,12 @@ void sub_08048004(GyorgMaleEntity* this) {
} else {
u32 b = super->spriteRendering.b3;
if (b != 3) {
if (EntityWithinDistance(&gPlayerEntity, super->x.HALF.HI, super->y.HALF.HI, 0x24)) {
if (EntityWithinDistance(&gPlayerEntity.base, super->x.HALF.HI, super->y.HALF.HI, 0x24)) {
if (!(this->unk_7c & 2)) {
u32 tmp = CalculateDirectionFromOffsets(gPlayerEntity.x.HALF.HI - super->x.HALF.HI,
gPlayerEntity.y.HALF.HI - super->y.HALF.HI);
gPlayerEntity.x.WORD = super->x.WORD + (gSineTable[tmp] * 9216);
gPlayerEntity.y.WORD = super->y.WORD - (gSineTable[tmp + 0x40] * 9216);
u32 tmp = CalculateDirectionFromOffsets(gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI,
gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI);
gPlayerEntity.base.x.WORD = super->x.WORD + (gSineTable[tmp] * 9216);
gPlayerEntity.base.y.WORD = super->y.WORD - (gSineTable[tmp + 0x40] * 9216);
}
}
}
+1 -4
View File
@@ -4,12 +4,9 @@
*
* @brief GyorgMaleEye enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "enemy.h"
#include "functions.h"
#include "fade.h"
#include "functions.h"
typedef struct {
/*0x00*/ Entity base;
+1 -2
View File
@@ -4,9 +4,8 @@
*
* @brief Hanging Seed enemy
*/
#include "entity.h"
#include "enemy.h"
#include "entity.h"
#include "functions.h"
extern void (*const HangingSeed_Functions[])(Entity*);
+210 -204
View File
@@ -4,317 +4,323 @@
*
* @brief Helmasaur enemy
*/
#include "collision.h"
#include "enemy.h"
#include "functions.h"
#include "object.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[16];
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
} HelmasaurEntity;
extern u32 sub_0804A024(Entity*, u32, u32);
void sub_0802C18C(Entity*);
void sub_0802C218(Entity*);
void sub_0802C1C0(Entity*);
u32 sub_0802C020(Entity*);
void sub_0802C058(Entity*, u32);
bool32 sub_0802C06C(Entity*);
void sub_0802C1CC(Entity*);
bool32 sub_0802C0E8(Entity*);
void sub_0802C18C(HelmasaurEntity*);
void sub_0802C218(HelmasaurEntity*);
void sub_0802C1C0(HelmasaurEntity*);
u32 sub_0802C020(HelmasaurEntity*);
void sub_0802C058(HelmasaurEntity*, u32);
bool32 sub_0802C06C(HelmasaurEntity*);
void sub_0802C1CC(HelmasaurEntity*);
bool32 sub_0802C0E8(HelmasaurEntity*);
extern void (*const Helmasaur_Functions[])(Entity*);
extern void (*const gUnk_080CD3FC[])(Entity*);
extern void (*const gUnk_080CD408[])(Entity*);
extern void (*const gUnk_080CD42C[])(Entity*);
extern void (*const gUnk_080CD438[])(Entity*);
extern void (*const gUnk_080CD450[])(Entity*);
extern void (*const Helmasaur_Functions[])(HelmasaurEntity*);
extern void (*const gUnk_080CD3FC[])(HelmasaurEntity*);
extern void (*const gUnk_080CD408[])(HelmasaurEntity*);
extern void (*const gUnk_080CD42C[])(HelmasaurEntity*);
extern void (*const gUnk_080CD438[])(HelmasaurEntity*);
extern void (*const gUnk_080CD450[])(HelmasaurEntity*);
extern const s8 gUnk_080CD45C[];
extern const s8 gUnk_080CD464[];
void Helmasaur(Entity* this) {
if (this->type == 0) {
EnemyFunctionHandler(this, Helmasaur_Functions);
SetChildOffset(this, 0, 1, -0x10);
void Helmasaur(HelmasaurEntity* this) {
if (super->type == 0) {
EnemyFunctionHandler(super, (EntityActionArray)Helmasaur_Functions);
SetChildOffset(super, 0, 1, -0x10);
} else {
gUnk_080CD3FC[this->action](this);
gUnk_080CD3FC[super->action](this);
}
}
void Helmasaur_OnTick(Entity* this) {
gUnk_080CD408[this->action](this);
void Helmasaur_OnTick(HelmasaurEntity* this) {
gUnk_080CD408[super->action](this);
}
void Helmasaur_OnCollision(Entity* this) {
if (this->hitType != 0x19) {
switch (this->contactFlags & 0x7f) {
void Helmasaur_OnCollision(HelmasaurEntity* this) {
if (super->hitType != 0x19) {
switch (super->contactFlags & 0x7f) {
case 0:
case 2:
case 3:
if (this->action == 4) {
this->knockbackDuration = 0;
if (super->action == 4) {
super->knockbackDuration = 0;
sub_0802C218(this);
}
break;
}
}
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, Helmasaur_Functions);
EnemyFunctionHandlerAfterCollision(super, Helmasaur_Functions);
}
void Helmasaur_OnGrabbed(Entity* this) {
if (this->hitType != 0x19) {
if (sub_0806F520(this)) {
gUnk_080CD42C[this->subAction](this);
void Helmasaur_OnGrabbed(HelmasaurEntity* this) {
if (super->hitType != 0x19) {
if (sub_0806F520(super)) {
gUnk_080CD42C[super->subAction](this);
}
} else if (2 < this->subAction || sub_0806F520(this)) {
gUnk_080CD438[this->subAction](this);
} else if (2 < super->subAction || sub_0806F520(super)) {
gUnk_080CD438[super->subAction](this);
}
}
void sub_0802BC74(Entity* this) {
void sub_0802BC74(HelmasaurEntity* this) {
sub_0802C1C0(this);
this->subAction = 1;
this->gustJarTolerance = 60;
this->animationState = AnimationStateFlip90(gPlayerEntity.animationState >> 1);
InitializeAnimation(this, this->animationState);
super->subAction = 1;
super->gustJarTolerance = 60;
super->animationState = AnimationStateFlip90(gPlayerEntity.base.animationState >> 1);
InitializeAnimation(super, super->animationState);
}
void sub_0802BCA0(Entity* this) {
sub_0806F4E8(this);
void sub_0802BCA0(HelmasaurEntity* this) {
sub_0806F4E8(super);
}
void sub_0802BCA8(Entity* this) {
if (this->hitType != 0x19) {
Entity* ent;
void sub_0802BCA8(HelmasaurEntity* this) {
if (super->hitType != 0x19) {
Entity* entity;
this->action = 7;
this->timer = 90;
this->zVelocity = Q_16_16(1.5);
this->hitType = 0x19;
this->gustJarState = this->gustJarState & 0xfb;
this->gustJarFlags = 0x12;
ent = CreateEnemy(HELMASAUR, 1);
if (ent != NULL) {
ent->animationState = this->animationState;
CopyPosition(this, ent);
super->action = 7;
super->timer = 90;
super->zVelocity = Q_16_16(1.5);
super->hitType = 0x19;
super->gustJarState = super->gustJarState & 0xfb;
super->gustJarFlags = 0x12;
entity = CreateEnemy(HELMASAUR, 1);
if (entity != NULL) {
entity->animationState = super->animationState;
CopyPosition(super, entity);
}
InitializeAnimation(this, this->animationState + 4);
InitializeAnimation(super, super->animationState + 4);
}
}
void sub_0802BCFC(Entity* this) {
this->subAction = 1;
this->gustJarTolerance = 60;
void sub_0802BCFC(HelmasaurEntity* this) {
super->subAction = 1;
super->gustJarTolerance = 60;
}
void sub_0802BD08(Entity* this) {
sub_0806F3E4(this);
void sub_0802BD08(HelmasaurEntity* this) {
sub_0806F3E4(super);
}
void sub_0802BD10(Entity* this) {
COLLISION_OFF(this);
UpdateAnimationVariableFrames(this, 2);
void sub_0802BD10(HelmasaurEntity* this) {
COLLISION_OFF(super);
UpdateAnimationVariableFrames(super, 2);
}
void nullsub_145(Entity* this) {
void nullsub_145(HelmasaurEntity* this) {
/* ... */
}
void sub_0802BD28(Entity* this) {
if (this->flags & ENT_COLLIDE) {
COLLISION_ON(this);
this->gustJarState &= ~0x4;
void sub_0802BD28(HelmasaurEntity* this) {
if (super->flags & ENT_COLLIDE) {
COLLISION_ON(super);
super->gustJarState &= ~0x4;
} else {
this->health = 0;
super->health = 0;
}
}
void sub_0802BD54(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->field_0x78.HALF.LO = Random();
this->gustJarTolerance = 60;
this->field_0x78.HALF.HI = 0xff;
this->direction = DirectionRound(Random());
this->animationState = this->direction >> 3;
InitializeAnimation(this, this->animationState);
void sub_0802BD54(HelmasaurEntity* this) {
sub_0804A720(super);
super->action = 1;
this->unk_78 = Random();
super->gustJarTolerance = 60;
this->unk_79 = 0xff;
super->direction = DirectionRound(Random());
super->animationState = super->direction >> 3;
InitializeAnimation(super, super->animationState);
}
void sub_0802BD8C(Entity* this) {
if (this->timer) {
this->timer--;
void sub_0802BD8C(HelmasaurEntity* this) {
if (super->timer) {
super->timer--;
} else {
u32 direction;
if (sub_08049FDC(this, 1)) {
direction = sub_0804A024(this, 1, 0x10);
if (direction != 0xff && direction != this->field_0x78.HALF.HI) {
if (sub_08049FDC(super, 1)) {
direction = sub_0804A024(super, 1, 0x10);
if (direction != 0xff && direction != this->unk_79) {
sub_0802C058(this, direction);
return;
}
}
direction = sub_0802C020(this);
if (direction != this->direction) {
if (direction != super->direction) {
sub_0802C058(this, direction);
}
}
}
void sub_0802BDE0(Entity* this) {
void sub_0802BDE0(HelmasaurEntity* this) {
if (sub_0802C06C(this)) {
this->action = 3;
this->timer = 60;
this->field_0x78.HALF.HI = 0xff;
super->action = 3;
super->timer = 60;
this->unk_79 = 0xff;
} else {
this->action = 1;
this->timer = (Random() & 0xf) + 15;
this->field_0x78.HALF.HI = this->direction;
super->action = 1;
super->timer = (Random() & 0xf) + 15;
this->unk_79 = super->direction;
}
}
void sub_0802BE18(Entity* this) {
UpdateAnimationVariableFrames(this, 2);
if (--this->timer == 0) {
this->action = 4;
this->timer = 30;
this->speed = 0x300;
void sub_0802BE18(HelmasaurEntity* this) {
UpdateAnimationVariableFrames(super, 2);
if (--super->timer == 0) {
super->action = 4;
super->timer = 30;
super->speed = 0x300;
} else {
sub_0802C18C(this);
}
}
void sub_0802BE48(Entity* this) {
if (!ProcessMovement2(this)) {
void sub_0802BE48(HelmasaurEntity* this) {
if (!ProcessMovement2(super)) {
sub_0802C218(this);
InitScreenShake(8, 0);
} else {
GetNextFrame(this);
GetNextFrame(super);
sub_0802C1CC(this);
if (sub_0802C0E8(this)) {
this->action = 5;
super->action = 5;
}
}
}
void sub_0802BE80(Entity* this) {
this->speed -= 0x20;
if (0xff < this->speed) {
void sub_0802BE80(HelmasaurEntity* this) {
super->speed -= 0x20;
if (0xff < super->speed) {
sub_0802C1CC(this);
}
if (this->speed > 0) {
ProcessMovement2(this);
if (super->speed > 0) {
ProcessMovement2(super);
sub_0802C18C(this);
} else {
sub_0802C1C0(this);
this->timer += 30;
super->timer += 30;
}
}
void sub_0802BEBC(Entity* this) {
this->direction ^= DirectionSouth;
ProcessMovement2(this);
this->direction ^= DirectionSouth;
if (!sub_080044EC(this, Q_16_16(0.125))) {
void sub_0802BEBC(HelmasaurEntity* this) {
super->direction ^= DirectionSouth;
ProcessMovement2(super);
super->direction ^= DirectionSouth;
if (!sub_080044EC(super, Q_16_16(0.125))) {
sub_0802C1C0(this);
}
}
void sub_0802BEEC(Entity* this) {
if (this->timer != 0) {
if ((--this->timer & 0x1F) == 0) {
this->animationState ^= 2;
this->direction = this->animationState << 3;
InitializeAnimation(this, this->animationState + 4);
void sub_0802BEEC(HelmasaurEntity* this) {
if (super->timer != 0) {
if ((--super->timer & 0x1F) == 0) {
super->animationState ^= 2;
super->direction = super->animationState << 3;
InitializeAnimation(super, super->animationState + 4);
}
} else if (!GravityUpdate(this, Q_8_8(28.0))) {
this->action = 8;
this->timer = 30;
this->speed = 0x120;
} else if (!GravityUpdate(super, Q_8_8(28.0))) {
super->action = 8;
super->timer = 30;
super->speed = 0x120;
}
}
void sub_0802BF3C(Entity* this) {
ProcessMovement0(this);
GetNextFrame(this);
if (--this->timer == 0) {
void sub_0802BF3C(HelmasaurEntity* this) {
ProcessMovement0(super);
GetNextFrame(super);
if (--super->timer == 0) {
u32 sprite;
this->timer = 30;
this->direction = sub_0802C020(this);
sprite = this->direction >> 3;
if (sprite != this->animationState) {
this->animationState = sprite;
InitializeAnimation(this, sprite + 4);
super->timer = 30;
super->direction = sub_0802C020(this);
sprite = super->direction >> 3;
if (sprite != super->animationState) {
super->animationState = sprite;
InitializeAnimation(super, sprite + 4);
}
}
}
void sub_0802BF78(Entity* this) {
this->action = 1;
this->flags2 = 4;
this->gustJarFlags = 1;
this->direction = this->animationState << 3;
InitializeAnimation(this, this->animationState + 8);
void sub_0802BF78(HelmasaurEntity* this) {
super->action = 1;
super->flags2 = 4;
super->gustJarFlags = 1;
super->direction = super->animationState << 3;
InitializeAnimation(super, super->animationState + 8);
}
void sub_0802BF98(Entity* this) {
if (sub_0806F520(this)) {
gUnk_080CD450[this->subAction](this);
void sub_0802BF98(HelmasaurEntity* this) {
if (sub_0806F520(super)) {
gUnk_080CD450[super->subAction](this);
} else {
this->action = 2;
this->timer = 30;
COLLISION_OFF(this);
super->action = 2;
super->timer = 30;
COLLISION_OFF(super);
}
}
void sub_0802BFD0(Entity* this) {
this->subAction = 2;
void sub_0802BFD0(HelmasaurEntity* this) {
super->subAction = 2;
}
void sub_0802BFD8(Entity* this) {
sub_0806F4E8(this);
void sub_0802BFD8(HelmasaurEntity* this) {
sub_0806F4E8(super);
}
void sub_0802BFE0(Entity* this) {
if (sub_0806F3E4(this)) {
DeleteEntity(this);
void sub_0802BFE0(HelmasaurEntity* this) {
if (sub_0806F3E4(super)) {
DeleteEntity(super);
}
}
void sub_0802BFF4(Entity* this) {
this->spriteSettings.draw ^= 1;
if (--this->timer == 0) {
DeleteEntity(this);
void sub_0802BFF4(HelmasaurEntity* this) {
super->spriteSettings.draw ^= 1;
if (--super->timer == 0) {
DeleteEntity(super);
}
}
u32 sub_0802C020(Entity* this) {
u32 sub_0802C020(HelmasaurEntity* this) {
u32 uVar1 = Random();
if (sub_08049FA0(this) || (uVar1 & 1))
if (sub_08049FA0(super) || (uVar1 & 1))
return DirectionRound(uVar1);
return (sub_08049EE4(this) + (uVar1 >> 0x10 & 1) * 4) & 0x18;
return (sub_08049EE4(super) + (uVar1 >> 0x10 & 1) * 4) & 0x18;
}
void sub_0802C058(Entity* this, u32 param_2) {
this->action = 2;
this->direction = param_2;
this->animationState = param_2 >> 3;
InitializeAnimation(this, this->animationState);
void sub_0802C058(HelmasaurEntity* this, u32 param_2) {
super->action = 2;
super->direction = param_2;
super->animationState = param_2 >> 3;
InitializeAnimation(super, super->animationState);
}
bool32 sub_0802C06C(Entity* this) {
u32 x = this->x.HALF.HI + this->hitbox->offset_x;
u32 y = this->y.HALF.HI + this->hitbox->offset_y;
u32 xdiff = gUnk_080CD45C[(this->direction >> 2) + 0];
u32 ydiff = gUnk_080CD45C[(this->direction >> 2) + 1];
bool32 sub_0802C06C(HelmasaurEntity* this) {
u32 x = super->x.HALF.HI + super->hitbox->offset_x;
u32 y = super->y.HALF.HI + super->hitbox->offset_y;
u32 xdiff = gUnk_080CD45C[(super->direction >> 2) + 0];
u32 ydiff = gUnk_080CD45C[(super->direction >> 2) + 1];
u8* layer = this->collisionLayer == 2 ? gMapTop.collisionData : gMapBottom.collisionData;
u8* layer = super->collisionLayer == 2 ? gMapTop.collisionData : gMapBottom.collisionData;
u32 i;
for (i = 0; i < 8; i++) {
@@ -329,15 +335,15 @@ bool32 sub_0802C06C(Entity* this) {
bool32 sub_0806FC24(u32, u32);
bool32 sub_0802C0E8(Entity* this) {
if (--this->timer == 0) {
bool32 sub_0802C0E8(HelmasaurEntity* this) {
if (--super->timer == 0) {
return TRUE;
} else {
const s8* ptr = &gUnk_080CD45C[this->direction >> 2];
s32 x = this->x.HALF.HI + this->hitbox->offset_x + ptr[0] * 6;
s32 y = this->y.HALF.HI + this->hitbox->offset_y + ptr[1] * 6;
const s8* ptr = &gUnk_080CD45C[super->direction >> 2];
s32 x = super->x.HALF.HI + super->hitbox->offset_x + ptr[0] * 6;
s32 y = super->y.HALF.HI + super->hitbox->offset_y + ptr[1] * 6;
u8* layer = this->collisionLayer == 2 ? gMapTop.collisionData : gMapBottom.collisionData;
u8* layer = super->collisionLayer == 2 ? gMapTop.collisionData : gMapBottom.collisionData;
u32 result = FALSE;
if (!sub_0806FC24(TILE(x, y), 9)) {
if (IsTileCollision(layer, x, y, 0)) {
@@ -350,50 +356,50 @@ bool32 sub_0802C0E8(Entity* this) {
}
}
void sub_0802C18C(Entity* this) {
this->field_0x78.HALF.LO--;
if ((this->field_0x78.HALF.LO & 7) == 0) {
Entity* ent = CreateObject(SPECIAL_FX, FX_DASH, 0x40);
if (ent != NULL) {
PositionRelative(this, ent, 0, Q_16_16(1.0));
void sub_0802C18C(HelmasaurEntity* this) {
this->unk_78--;
if ((this->unk_78 & 7) == 0) {
Entity* entity = CreateObject(SPECIAL_FX, FX_DASH, 0x40);
if (entity != NULL) {
PositionRelative(super, entity, 0, Q_16_16(1.0));
}
}
}
void sub_0802C1C0(Entity* this) {
this->action = 1;
this->timer = 30;
void sub_0802C1C0(HelmasaurEntity* this) {
super->action = 1;
super->timer = 30;
}
void sub_0802C1CC(Entity* this) {
const s8* ptr = &gUnk_080CD464[this->animationState << 2];
sub_08008796(this, 9, this->x.HALF.HI + ptr[0], this->y.HALF.HI + ptr[1]);
sub_08008796(this, 9, this->x.HALF.HI + ptr[2], this->y.HALF.HI + ptr[3]);
void sub_0802C1CC(HelmasaurEntity* this) {
const s8* ptr = &gUnk_080CD464[super->animationState << 2];
sub_08008796(super, 9, super->x.HALF.HI + ptr[0], super->y.HALF.HI + ptr[1]);
sub_08008796(super, 9, super->x.HALF.HI + ptr[2], super->y.HALF.HI + ptr[3]);
}
void sub_0802C218(Entity* this) {
this->action = 6;
this->speed = Q_8_8(0.875);
this->zVelocity = Q_16_16(1.5);
void sub_0802C218(HelmasaurEntity* this) {
super->action = 6;
super->speed = Q_8_8(0.875);
super->zVelocity = Q_16_16(1.5);
}
// clang-format off
void (*const Helmasaur_Functions[])(Entity*) = {
void (*const Helmasaur_Functions[])(HelmasaurEntity*) = {
Helmasaur_OnTick,
Helmasaur_OnCollision,
GenericKnockback,
GenericDeath,
GenericConfused,
(void (*)(HelmasaurEntity*))GenericKnockback,
(void (*)(HelmasaurEntity*))GenericDeath,
(void (*)(HelmasaurEntity*))GenericConfused,
Helmasaur_OnGrabbed,
};
void (*const gUnk_080CD3FC[])(Entity*) = {
void (*const gUnk_080CD3FC[])(HelmasaurEntity*) = {
sub_0802BF78,
sub_0802BF98,
sub_0802BFF4,
};
void (*const gUnk_080CD408[])(Entity*) = {
void (*const gUnk_080CD408[])(HelmasaurEntity*) = {
sub_0802BD54,
sub_0802BD8C,
sub_0802BDE0,
@@ -405,13 +411,13 @@ void (*const gUnk_080CD408[])(Entity*) = {
sub_0802BF3C,
};
void (*const gUnk_080CD42C[])(Entity*) = {
void (*const gUnk_080CD42C[])(HelmasaurEntity*) = {
sub_0802BC74,
sub_0802BCA0,
sub_0802BCA8,
};
void (*const gUnk_080CD438[])(Entity*) = {
void (*const gUnk_080CD438[])(HelmasaurEntity*) = {
sub_0802BCFC,
sub_0802BCA0,
sub_0802BD08,
@@ -420,7 +426,7 @@ void (*const gUnk_080CD438[])(Entity*) = {
sub_0802BD28,
};
void (*const gUnk_080CD450[])(Entity*) = {
void (*const gUnk_080CD450[])(HelmasaurEntity*) = {
sub_0802BFD0,
sub_0802BFD8,
sub_0802BFE0,
+144 -129
View File
@@ -4,206 +4,221 @@
*
* @brief keaton enemy
*/
#include "enemy.h"
#include "functions.h"
extern Entity* gUnk_020000B0;
void Keaton_OnTick(Entity*);
void Keaton_OnCollision(Entity*);
void Keaton_OnGrabbed(Entity*);
void Keaton_Init(Entity*);
void Keaton_Action1(Entity*);
void Keaton_Action2(Entity*);
void Keaton_Action3(Entity*);
void Keaton_Action4(Entity*);
void Keaton_Action5(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u16 unk_74;
/*0x76*/ u16 unk_76;
/*0x78*/ u16 unk_78;
/*0x7a*/ u8 unused2[1];
/*0x7b*/ u8 unk_7b;
} KeatonEntity;
static void (*const Keaton_Functions[])(Entity*) = {
Keaton_OnTick, Keaton_OnCollision, GenericKnockback, GenericDeath, GenericConfused, Keaton_OnGrabbed,
extern Entity* gUnk_020000B0;
void Keaton_OnTick(KeatonEntity*);
void Keaton_OnCollision(KeatonEntity*);
void Keaton_OnGrabbed(KeatonEntity*);
void Keaton_Init(KeatonEntity*);
void Keaton_Action1(KeatonEntity*);
void Keaton_Action2(KeatonEntity*);
void Keaton_Action3(KeatonEntity*);
void Keaton_Action4(KeatonEntity*);
void Keaton_Action5(KeatonEntity*);
static void (*const Keaton_Functions[])(KeatonEntity*) = {
Keaton_OnTick,
Keaton_OnCollision,
(void (*)(KeatonEntity*))GenericKnockback,
(void (*)(KeatonEntity*))GenericDeath,
(void (*)(KeatonEntity*))GenericConfused,
Keaton_OnGrabbed,
};
bool32 sub_080325E8(Entity* this);
void sub_08032650(Entity* this);
void sub_0803269C(Entity* this, u32 direction);
void sub_080326FC(Entity* this);
bool32 sub_0803271C(Entity* this);
void sub_08032740(Entity* this);
void sub_0803275C(Entity* this);
void sub_08032784(Entity* this);
void sub_08032794(Entity* this);
void sub_080327C8(Entity* this);
void sub_080327E0(Entity* this);
bool32 sub_080325E8(KeatonEntity* this);
void sub_08032650(KeatonEntity* this);
void sub_0803269C(KeatonEntity* this, u32 direction);
void sub_080326FC(KeatonEntity* this);
bool32 sub_0803271C(KeatonEntity* this);
void sub_08032740(KeatonEntity* this);
void sub_0803275C(KeatonEntity* this);
void sub_08032784(KeatonEntity* this);
void sub_08032794(KeatonEntity* this);
void sub_080327C8(KeatonEntity* this);
void sub_080327E0(KeatonEntity* this);
void Keaton(Entity* this) {
EnemyFunctionHandler(this, Keaton_Functions);
SetChildOffset(this, 0, 1, -18);
void Keaton(KeatonEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Keaton_Functions);
SetChildOffset(super, 0, 1, -18);
}
void Keaton_OnTick(Entity* this) {
static void (*const Keaton_Actions[])(Entity*) = {
void Keaton_OnTick(KeatonEntity* this) {
static void (*const Keaton_Actions[])(KeatonEntity*) = {
Keaton_Init, Keaton_Action1, Keaton_Action2, Keaton_Action3, Keaton_Action4, Keaton_Action5,
};
Keaton_Actions[this->action](this);
Keaton_Actions[super->action](this);
}
void Keaton_OnCollision(Entity* this) {
void Keaton_OnCollision(KeatonEntity* this) {
u32 var;
if (this->action != 3 && this->action != 4) {
this->action = 3;
this->timer = 12;
this->direction = DirectionTurnAround(DirectionRoundUp(this->knockbackDirection));
InitAnimationForceUpdate(this, this->direction >> 3);
} else if (this->contactFlags == 0xCC) {
if (this->confusedTime == 0) {
if (super->action != 3 && super->action != 4) {
super->action = 3;
super->timer = 12;
super->direction = DirectionTurnAround(DirectionRoundUp(super->knockbackDirection));
InitAnimationForceUpdate(super, super->direction >> 3);
} else if (super->contactFlags == 0xCC) {
if (super->confusedTime == 0) {
sub_0803275C(this);
}
}
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, Keaton_Functions);
EnemyFunctionHandlerAfterCollision(super, Keaton_Functions);
}
void Keaton_OnGrabbed(Entity* this) {
void Keaton_OnGrabbed(KeatonEntity* this) {
}
void Keaton_Init(Entity* this) {
sub_0804A720(this);
this->animationState = 0;
InitAnimationForceUpdate(this, 0);
void Keaton_Init(KeatonEntity* this) {
sub_0804A720(super);
super->animationState = 0;
InitAnimationForceUpdate(super, 0);
sub_080326FC(this);
sub_08032740(this);
}
void Keaton_Action1(Entity* this) {
void Keaton_Action1(KeatonEntity* this) {
if (!sub_080325E8(this) && !sub_0803271C(this)) {
this->timer--;
if (this->timer == 0) {
super->timer--;
if (super->timer == 0) {
sub_08032650(this);
}
if (!ProcessMovement0(this)) {
this->timer = 1;
if (!ProcessMovement0(super)) {
super->timer = 1;
}
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
}
}
void Keaton_Action2(Entity* this) {
void Keaton_Action2(KeatonEntity* this) {
if (!sub_080325E8(this)) {
UpdateAnimationSingleFrame(this);
if (this->frame & ANIM_DONE) {
UpdateAnimationSingleFrame(super);
if (super->frame & ANIM_DONE) {
sub_080326FC(this);
sub_08032740(this);
}
}
}
void Keaton_Action3(Entity* this) {
if (this->timer != 0) {
this->timer--;
if (this->timer == 0) {
this->subtimer = 30;
this->animationState = this->direction / 8;
InitAnimationForceUpdate(this, this->animationState + 4);
void Keaton_Action3(KeatonEntity* this) {
if (super->timer != 0) {
super->timer--;
if (super->timer == 0) {
super->subtimer = 30;
super->animationState = super->direction / 8;
InitAnimationForceUpdate(super, super->animationState + 4);
} else {
return;
}
}
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(this);
this->subtimer--;
if (this->subtimer == 0) {
this->action = 4;
this->speed = 0x1E0;
this->field_0x76.HWORD = 0x46;
this->field_0x78.HWORD = 0;
*(((u8*)&this->field_0x7a) + 1) = 0;
UpdateAnimationSingleFrame(super);
UpdateAnimationSingleFrame(super);
super->subtimer--;
if (super->subtimer == 0) {
super->action = 4;
super->speed = 0x1E0;
this->unk_76 = 0x46;
this->unk_78 = 0;
this->unk_7b = 0;
sub_080327C8(this);
} else {
if ((this->subtimer & 0x3) == 0) {
if ((super->subtimer & 0x3) == 0) {
sub_08032794(this);
}
}
}
void Keaton_Action4(Entity* this) {
if (this->child && (this->child->contactFlags & 0x80)) {
void Keaton_Action4(KeatonEntity* this) {
if (super->child && (super->child->contactFlags & 0x80)) {
sub_0803275C(this);
return;
}
if (--this->field_0x76.HWORD == 0 || !ProcessMovement2(this)) {
if (--this->unk_76 == 0 || !ProcessMovement2(super)) {
sub_0803275C(this);
return;
}
UpdateAnimationSingleFrame(this);
if ((this->field_0x76.HWORD & 0x7) == 0) {
UpdateAnimationSingleFrame(super);
if ((this->unk_76 & 0x7) == 0) {
sub_08032794(this);
}
}
void Keaton_Action5(Entity* this) {
this->timer--;
if ((this->timer == 0) && !sub_080325E8(this)) {
void Keaton_Action5(KeatonEntity* this) {
super->timer--;
if ((super->timer == 0) && !sub_080325E8(this)) {
sub_08032784(this);
}
}
u32 sub_080325E8(Entity* this) {
if ((sub_08049FA0(this) && sub_08049FDC(this, 1)) && (EntityInRectRadius(this, gUnk_020000B0, 0x68, 0x40) != 0)) {
if (((GetFacingDirection(this, gUnk_020000B0) - (DirectionRound(this->frame)) + 2) & 0x1F) < 5) {
this->action = 3;
this->timer = 12;
this->direction = DirectionRound(this->frame);
u32 sub_080325E8(KeatonEntity* this) {
if ((sub_08049FA0(super) && sub_08049FDC(super, 1)) &&
(EntityInRectRadius(super, gUnk_020000B0, 0x68, 0x40) != 0)) {
if (((GetFacingDirection(super, gUnk_020000B0) - (DirectionRound(super->frame)) + 2) & 0x1F) < 5) {
super->action = 3;
super->timer = 12;
super->direction = DirectionRound(super->frame);
return TRUE;
}
}
return FALSE;
}
void sub_08032650(Entity* this) {
void sub_08032650(KeatonEntity* this) {
static const u8 gUnk_080CE7E0[] = { 60, 60, 90, 90, 90, 90, 120, 120, 120, 120, 120, 120, 120, 120, 150, 150 };
u32 rand = Random();
this->timer = gUnk_080CE7E0[rand & 0xF];
if (!((sub_08049FA0(this) == 0) && ((rand >> 8 & 1) == 0))) {
this->direction = DirectionRound(rand >> 0x10);
super->timer = gUnk_080CE7E0[rand & 0xF];
if (!((sub_08049FA0(super) == 0) && ((rand >> 8 & 1) == 0))) {
super->direction = DirectionRound(rand >> 0x10);
} else {
this->direction = DirectionRoundUp(sub_08049EE4(this));
super->direction = DirectionRoundUp(sub_08049EE4(super));
}
sub_0803269C(this, this->direction);
sub_0803269C(this, super->direction);
}
void sub_0803269C(Entity* this, u32 direction) {
void sub_0803269C(KeatonEntity* this, u32 direction) {
u32 uVar1;
if (((direction - 3) & 7) < 3) {
uVar1 = DirectionToAnimationState(direction);
if (((this->animationState - uVar1) & 3) > 1) {
this->animationState = uVar1;
InitAnimationForceUpdate(this, (this->animIndex & 0xFC) + uVar1);
if (((super->animationState - uVar1) & 3) > 1) {
super->animationState = uVar1;
InitAnimationForceUpdate(super, (super->animIndex & 0xFC) + uVar1);
}
} else {
uVar1 = DirectionToAnimationState(direction);
if (uVar1 != this->animationState) {
this->animationState = uVar1;
InitAnimationForceUpdate(this, (this->animIndex & 0xFC) + uVar1);
if (uVar1 != super->animationState) {
super->animationState = uVar1;
InitAnimationForceUpdate(super, (super->animIndex & 0xFC) + uVar1);
}
}
}
void sub_080326FC(Entity* this) {
void sub_080326FC(KeatonEntity* this) {
static const u16 gUnk_080CE7F0[] = { 0xd2, 0xd2, 0xf0, 0xf0, 0x10e, 0x10e, 0x10e, 0x10e,
0x12c, 0x12c, 0x12c, 0x12c, 0x12c, 0x12c, 0x12c, 0x12c };
this->field_0x74.HWORD = gUnk_080CE7F0[Random() & 0xF];
this->unk_74 = gUnk_080CE7F0[Random() & 0xF];
}
bool32 sub_0803271C(Entity* this) {
this->field_0x74.HWORD--;
if (this->field_0x74.HWORD == 0) {
bool32 sub_0803271C(KeatonEntity* this) {
this->unk_74--;
if (this->unk_74 == 0) {
sub_08032784(this);
return TRUE;
} else {
@@ -211,52 +226,52 @@ bool32 sub_0803271C(Entity* this) {
}
}
void sub_08032740(Entity* this) {
this->action = 1;
this->speed = 0x80;
InitializeAnimation(this, this->animationState);
void sub_08032740(KeatonEntity* this) {
super->action = 1;
super->speed = 0x80;
InitializeAnimation(super, super->animationState);
sub_08032650(this);
}
void sub_0803275C(Entity* this) {
this->action = 5;
this->timer = 45;
this->speed = 0x80;
InitAnimationForceUpdate(this, this->animationState);
sub_0803269C(this, this->direction);
void sub_0803275C(KeatonEntity* this) {
super->action = 5;
super->timer = 45;
super->speed = 0x80;
InitAnimationForceUpdate(super, super->animationState);
sub_0803269C(this, super->direction);
sub_080327E0(this);
}
void sub_08032784(Entity* this) {
this->action = 2;
InitAnimationForceUpdate(this, this->animationState + 8);
void sub_08032784(KeatonEntity* this) {
super->action = 2;
InitAnimationForceUpdate(super, super->animationState + 8);
}
void sub_08032794(Entity* this) {
void sub_08032794(KeatonEntity* this) {
Entity* target;
const s8* temp;
static const s8 gUnk_080CE810[] = { 0, 2, -4, 0, 0, -11, 4, 0 };
target = CreateFx(this, FX_DASH, 0x40);
target = CreateFx(super, FX_DASH, 0x40);
if (target != NULL) {
temp = &gUnk_080CE810[this->animationState * 2];
PositionRelative(this, target, Q_16_16(temp[0]), Q_16_16(temp[1]));
temp = &gUnk_080CE810[super->animationState * 2];
PositionRelative(super, target, Q_16_16(temp[0]), Q_16_16(temp[1]));
}
}
void sub_080327C8(Entity* this) {
void sub_080327C8(KeatonEntity* this) {
Entity* child;
child = CreateProjectileWithParent(this, KEATON_DAGGER, 0);
child = CreateProjectileWithParent(super, KEATON_DAGGER, 0);
if (child != NULL) {
child->parent = this;
this->child = child;
child->parent = super;
super->child = child;
}
}
void sub_080327E0(Entity* this) {
if (this->child != NULL) {
this->child->parent = NULL;
this->child = NULL;
void sub_080327E0(KeatonEntity* this) {
if (super->child != NULL) {
super->child->parent = NULL;
super->child = NULL;
}
}
+2 -4
View File
@@ -4,8 +4,6 @@
*
* @brief Keese enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "physics.h"
#include "player.h"
@@ -141,7 +139,7 @@ void Keese_Sleep(KeeseEntity* this) {
if (super->timer != 0) {
super->timer--;
} else {
if (EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x70))
if (EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, 0x70))
Keese_StartFly(this);
}
}
@@ -167,7 +165,7 @@ void sub_08021F24(KeeseEntity* this) {
super->timer = gKeeseRestDurations[Random() & 0xF];
InitializeAnimation(super, KeeseAnimation_Rest);
} else if ((this->sleepTimer == 0) &&
!(EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x70))) {
!(EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, 0x70))) {
super->action = KEESE_ACTION_SLEEP;
super->timer = 30;
InitializeAnimation(super, KeeseAnimation_Rest);
+156 -145
View File
@@ -4,23 +4,30 @@
*
* @brief Lakitu enemy
*/
#include "global.h"
#include "enemy.h"
#include "physics.h"
#include "player.h"
extern void (*const LakituActionFuncs[])(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u16 unk_74;
/*0x76*/ u16 unk_76;
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
} LakituEntity;
extern void (*const LakituActionFuncs[])(LakituEntity*);
// Forward references to functions in lakitu.c
extern void sub_0803CAD0(Entity*);
extern void sub_0803CBAC(Entity*);
extern void sub_0803CA84(Entity*, u32);
extern bool32 sub_0803CA4C(Entity*);
extern bool32 sub_0803CB04(Entity*);
extern void Lakitu_SpawnLightning(Entity*);
extern void sub_0803CB34(Entity*);
extern void sub_0803CC08(Entity* this);
extern void sub_0803CAD0(LakituEntity* this);
extern void sub_0803CBAC(LakituEntity* this);
extern void sub_0803CA84(LakituEntity* this, u32);
extern bool32 sub_0803CA4C(LakituEntity* this);
extern bool32 sub_0803CB04(LakituEntity* this);
extern void Lakitu_SpawnLightning(LakituEntity* this);
extern void sub_0803CB34(LakituEntity* this);
extern void sub_0803CC08(LakituEntity* this);
enum {
INIT,
@@ -39,36 +46,36 @@ typedef struct {
} PACKED OffsetCoords;
// Variables
extern void (*const Lakitu_Functions[])(Entity*);
extern void (*const gUnk_080D0128[])(Entity*);
extern void (*const gUnk_080D0148[])(Entity*);
extern void (*const Lakitu_Functions[])(LakituEntity*);
extern void (*const gUnk_080D0128[])(LakituEntity*);
extern void (*const gUnk_080D0148[])(LakituEntity*);
extern const OffsetCoords gUnk_080D0154[];
void Lakitu(Entity* this) {
EnemyFunctionHandler(this, Lakitu_Functions);
void Lakitu(LakituEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Lakitu_Functions);
SetChildOffset(this, 0, 1, -16);
SetChildOffset(super, 0, 1, -16);
}
void Lakitu_OnTick(Entity* this) {
if (this->action != 0 && this->action != 7) {
void Lakitu_OnTick(LakituEntity* this) {
if (super->action != 0 && super->action != 7) {
sub_0803CAD0(this);
}
LakituActionFuncs[this->action](this);
LakituActionFuncs[super->action](this);
}
void Lakitu_OnCollision(Entity* this) {
if ((this->contactFlags & 0x7f) == 0x1d) {
this->zVelocity = Q_16_16(2.0);
void Lakitu_OnCollision(LakituEntity* this) {
if ((super->contactFlags & 0x7f) == 0x1d) {
super->zVelocity = Q_16_16(2.0);
sub_0803CBAC(this);
} else {
if (this->hitType == 0x43) {
Entity* fx = CreateFx(this, FX_DEATH, 0);
if (super->hitType == 0x43) {
Entity* fx = CreateFx(super, FX_DEATH, 0);
if (fx != NULL) {
u32 angle = (this->knockbackDirection ^ 0x10) << 3;
u32 angle = (super->knockbackDirection ^ 0x10) << 3;
s32 sine;
sine = gSineTable[angle];
@@ -88,163 +95,163 @@ void Lakitu_OnCollision(Entity* this) {
}
}
if (this->confusedTime) {
Create0x68FX(this, FX_STARS);
if (super->confusedTime) {
Create0x68FX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, Lakitu_Functions);
EnemyFunctionHandlerAfterCollision(super, Lakitu_Functions);
}
void Lakitu_OnGrabbed(Entity* this) {
if (sub_0806F520(this)) {
gUnk_080D0148[this->subAction](this);
void Lakitu_OnGrabbed(LakituEntity* this) {
if (sub_0806F520(super)) {
gUnk_080D0148[super->subAction](this);
}
}
void sub_0803C844(Entity* this) {
this->subAction = 1;
this->gustJarTolerance = 0x3c;
void sub_0803C844(LakituEntity* this) {
super->subAction = 1;
super->gustJarTolerance = 0x3c;
}
void sub_0803C850(Entity* this) {
Entity* cloud = this->child;
void sub_0803C850(LakituEntity* this) {
Entity* cloud = super->child;
if (cloud != NULL) {
cloud->spriteOffsetX = this->spriteOffsetX;
cloud->spriteOffsetX = super->spriteOffsetX;
}
sub_0806F4E8(this);
sub_0806F4E8(super);
}
void sub_0803C86C(Entity* this) {
void sub_0803C86C(LakituEntity* this) {
sub_0803CBAC(this);
this->child = NULL;
super->child = NULL;
}
void Lakitu_Initialize(Entity* this) {
Entity* cloud = CreateProjectileWithParent(this, 17, 0);
void Lakitu_Initialize(LakituEntity* this) {
Entity* cloud = CreateProjectileWithParent(super, 17, 0);
if (cloud == NULL) {
return;
}
cloud->parent = this;
this->child = cloud;
cloud->parent = super;
super->child = cloud;
sub_0804A720(this);
sub_0804A720(super);
this->action = HIDDEN;
super->action = HIDDEN;
this->z.HALF.HI = -2;
super->z.HALF.HI = -2;
this->spriteOffsetY = 0xff;
super->spriteOffsetY = 0xff;
this->field_0x74.HWORD = this->x.HALF.HI;
this->field_0x76.HWORD = this->y.HALF.HI;
this->unk_74 = super->x.HALF.HI;
this->unk_76 = super->y.HALF.HI;
}
void Lakitu_Hide(Entity* this) {
void Lakitu_Hide(LakituEntity* this) {
sub_0803CA84(this, 0);
if (sub_0803CA4C(this)) {
this->action = END_HIDE;
this->spriteSettings.draw = 1;
super->action = END_HIDE;
super->spriteSettings.draw = 1;
}
}
void Lakitu_EndHide(Entity* this) {
UpdateAnimationSingleFrame(this);
void Lakitu_EndHide(LakituEntity* this) {
UpdateAnimationSingleFrame(super);
if (this->frame & ANIM_DONE) {
this->action = IDLE;
this->timer = 60;
if (super->frame & ANIM_DONE) {
super->action = IDLE;
super->timer = 60;
this->hitType = 0x42;
super->hitType = 0x42;
InitAnimationForceUpdate(this, this->animationState + 4);
InitAnimationForceUpdate(super, super->animationState + 4);
}
}
void Lakitu_Idle(Entity* this) {
void Lakitu_Idle(LakituEntity* this) {
if (sub_0803CB04(this)) {
return;
}
if (!sub_0803CA4C(this)) {
this->action = BEGIN_HIDE;
super->action = BEGIN_HIDE;
this->hitType = 0x43;
InitAnimationForceUpdate(this, this->animationState + 0xc);
super->hitType = 0x43;
InitAnimationForceUpdate(super, super->animationState + 0xc);
} else {
sub_0803CA84(this, 4);
}
}
void Lakitu_BeginHide(Entity* this) {
UpdateAnimationSingleFrame(this);
void Lakitu_BeginHide(LakituEntity* this) {
UpdateAnimationSingleFrame(super);
if (this->frame & ANIM_DONE) {
this->action = HIDDEN;
this->spriteSettings.draw = 0;
if (super->frame & ANIM_DONE) {
super->action = HIDDEN;
super->spriteSettings.draw = 0;
InitAnimationForceUpdate(this, this->animationState);
InitAnimationForceUpdate(super, super->animationState);
}
}
void Lakitu_Lightning(Entity* this) {
UpdateAnimationSingleFrame(this);
void Lakitu_Lightning(LakituEntity* this) {
UpdateAnimationSingleFrame(super);
if (!(this->frame & ANIM_DONE)) {
if (!(super->frame & ANIM_DONE)) {
return;
}
Lakitu_SpawnLightning(this);
this->action = LIGHTNING_DELAY;
this->hitType = 0x42;
super->action = LIGHTNING_DELAY;
super->hitType = 0x42;
if ((Random() & 1) && !this->field_0x78.HALF.HI) {
this->timer = 15;
if ((Random() & 1) && !this->unk_79) {
super->timer = 15;
this->field_0x78.HALF.HI = TRUE;
this->unk_79 = TRUE;
} else {
this->timer = 30;
super->timer = 30;
this->field_0x78.HALF.HI = FALSE;
this->unk_79 = FALSE;
InitAnimationForceUpdate(this->child, this->animationState);
InitAnimationForceUpdate(super->child, super->animationState);
}
}
void Lakitu_LightningDelay(Entity* this) {
this->timer--;
void Lakitu_LightningDelay(LakituEntity* this) {
super->timer--;
if (this->timer != 0) {
if (super->timer != 0) {
return;
}
if (this->field_0x78.HALF.HI == 1) {
if (this->unk_79 == 1) {
sub_0803CB34(this);
} else {
this->action = IDLE;
this->timer = 180;
super->action = IDLE;
super->timer = 180;
InitAnimationForceUpdate(this, this->animationState + 4);
InitAnimationForceUpdate(super, super->animationState + 4);
}
}
void Lakitu_Cloudless(Entity* this) {
if (GravityUpdate(this, Q_8_8(24.0)) == 0 && this->animIndex <= 19) {
InitAnimationForceUpdate(this, this->animationState + 20);
void Lakitu_Cloudless(LakituEntity* this) {
if (GravityUpdate(super, Q_8_8(24.0)) == 0 && super->animIndex <= 19) {
InitAnimationForceUpdate(super, super->animationState + 20);
this->spritePriority.b1 = 0;
super->spritePriority.b1 = 0;
}
UpdateAnimationSingleFrame(this);
UpdateAnimationSingleFrame(super);
sub_0803CC08(this);
}
bool32 sub_0803CA4C(Entity* this) {
if (EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x28) == 0) {
if (EntityInRectRadius(this, &gPlayerEntity, 0x70, 0x50)) {
bool32 sub_0803CA4C(LakituEntity* this) {
if (EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, 0x28) == 0) {
if (EntityInRectRadius(super, &gPlayerEntity.base, 0x70, 0x50)) {
return TRUE;
}
}
@@ -252,158 +259,162 @@ bool32 sub_0803CA4C(Entity* this) {
return FALSE;
}
void sub_0803CA84(Entity* this, u32 unkParameter) {
u32 altAnimState = GetFacingDirection(this, &gPlayerEntity);
void sub_0803CA84(LakituEntity* this, u32 unkParameter) {
u32 altAnimState = GetFacingDirection(super, &gPlayerEntity.base);
if (((altAnimState - 3) & 7) > 2 || ((this->animationState - (altAnimState >> 3)) & 3) > 1) {
if (((altAnimState - 3) & 7) > 2 || ((super->animationState - (altAnimState >> 3)) & 3) > 1) {
altAnimState = DirectionRoundUp(altAnimState) >> 3;
if (altAnimState != this->animationState) {
this->animationState = altAnimState;
if (altAnimState != super->animationState) {
super->animationState = altAnimState;
InitAnimationForceUpdate(this, altAnimState + unkParameter);
InitAnimationForceUpdate(this->child, altAnimState);
InitAnimationForceUpdate(super, altAnimState + unkParameter);
InitAnimationForceUpdate(super->child, altAnimState);
}
}
}
void sub_0803CAD0(Entity* this) {
if (!EntityWithinDistance(this, this->field_0x74.HWORD, this->field_0x76.HWORD, 1)) {
this->direction =
CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, this->field_0x74.HWORD, this->field_0x76.HWORD);
void sub_0803CAD0(LakituEntity* this) {
if (!EntityWithinDistance(super, this->unk_74, this->unk_76, 1)) {
super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, this->unk_74, this->unk_76);
ProcessMovement2(this);
ProcessMovement2(super);
}
}
bool32 sub_0803CB04(Entity* this) {
bool32 sub_0803CB04(LakituEntity* this) {
bool32 ret;
u8 delay;
delay = --this->timer;
delay = --super->timer;
if (delay != 0) {
ret = FALSE;
} else {
sub_0803CB34(this);
this->field_0x78.HALF.HI = delay;
this->unk_79 = delay;
InitAnimationForceUpdate(this->child, this->animationState + 4);
InitAnimationForceUpdate(super->child, super->animationState + 4);
ret = TRUE;
}
return ret;
}
void sub_0803CB34(Entity* this) {
this->action = LIGHTNING_THROW;
this->hitType = 0xa6;
void sub_0803CB34(LakituEntity* this) {
super->action = LIGHTNING_THROW;
super->hitType = 0xa6;
this->field_0x78.HALF.LO = GetFacingDirection(this, &gPlayerEntity);
this->unk_78 = GetFacingDirection(super, &gPlayerEntity.base);
InitAnimationForceUpdate(this, this->animationState + 8);
InitAnimationForceUpdate(super, super->animationState + 8);
}
void Lakitu_SpawnLightning(Entity* this) {
void Lakitu_SpawnLightning(LakituEntity* this) {
Entity* lightning;
const OffsetCoords* offset;
lightning = CreateProjectileWithParent(this, LAKITU_LIGHTNING, 0);
lightning = CreateProjectileWithParent(super, LAKITU_LIGHTNING, 0);
if (lightning == NULL) {
return;
}
offset = &gUnk_080D0154[this->animationState];
offset = &gUnk_080D0154[super->animationState];
lightning->direction = this->field_0x78.HALF.LO;
lightning->direction = this->unk_78;
PositionRelative(this, lightning, Q_16_16(offset->x), Q_16_16(offset->y));
PositionRelative(super, lightning, Q_16_16(offset->x), Q_16_16(offset->y));
EnqueueSFX(SFX_193);
}
void sub_0803CBAC(Entity* this) {
void sub_0803CBAC(LakituEntity* this) {
Entity* cloud;
cloud = this->child;
cloud = super->child;
if (cloud != NULL) {
cloud->flags |= ENT_COLLIDE;
cloud->hitType = 0x43;
}
this->action = CLOUDLESS;
this->spriteSettings.draw = 1;
super->action = CLOUDLESS;
super->spriteSettings.draw = 1;
this->spritePriority.b1 = 1;
super->spritePriority.b1 = 1;
this->flags2 &= 0x7b;
super->flags2 &= 0x7b;
this->hitType = 0x42;
super->hitType = 0x42;
InitAnimationForceUpdate(this, this->animationState + 16);
InitAnimationForceUpdate(super, super->animationState + 16);
}
void sub_0803CC08(Entity* this) {
void sub_0803CC08(LakituEntity* this) {
Entity* cloud;
Entity* fx;
const s32 diff = Q_8_8(3.0 / 128.0);
cloud = this->child;
cloud = super->child;
if (cloud == NULL) {
return;
}
if ((u32)(cloud->z.HALF.HI - this->z.HALF.HI) > 2) {
if ((u32)(cloud->z.HALF.HI - super->z.HALF.HI) > 2) {
return;
}
if (this->zVelocity >= 0) {
if (super->zVelocity >= 0) {
return;
}
if (!EntityWithinDistance(this, cloud->x.HALF.HI, cloud->y.HALF.HI, 6)) {
if (!EntityWithinDistance(super, cloud->x.HALF.HI, cloud->y.HALF.HI, 6)) {
return;
}
fx = CreateFx(this, FX_DEATH, 0);
fx = CreateFx(super, FX_DEATH, 0);
if (fx != NULL) {
fx->x.HALF.HI += diff;
fx->y.HALF.HI += diff;
}
fx = CreateFx(this, FX_DEATH, 0);
fx = CreateFx(super, FX_DEATH, 0);
if (fx != NULL) {
fx->x.HALF.HI -= diff;
fx->y.HALF.HI += diff;
}
fx = CreateFx(this, FX_DEATH, 0);
fx = CreateFx(super, FX_DEATH, 0);
if (fx != NULL) {
fx->x.HALF.HI += diff;
fx->y.HALF.HI -= diff;
}
fx = CreateFx(this, FX_DEATH, 0);
fx = CreateFx(super, FX_DEATH, 0);
if (fx != NULL) {
fx->x.HALF.HI -= diff;
fx->y.HALF.HI -= diff;
}
this->child = NULL;
super->child = NULL;
DeleteEntity(cloud);
}
void (*const Lakitu_Functions[])(Entity*) = {
Lakitu_OnTick, Lakitu_OnCollision, GenericKnockback, GenericDeath, GenericConfused, Lakitu_OnGrabbed,
void (*const Lakitu_Functions[])(LakituEntity*) = {
Lakitu_OnTick,
Lakitu_OnCollision,
(void (*)(LakituEntity*))GenericKnockback,
(void (*)(LakituEntity*))GenericDeath,
(void (*)(LakituEntity*))GenericConfused,
Lakitu_OnGrabbed,
};
void (*const LakituActionFuncs[])(Entity*) = {
void (*const LakituActionFuncs[])(LakituEntity*) = {
Lakitu_Initialize, Lakitu_Hide, Lakitu_EndHide, Lakitu_Idle,
Lakitu_BeginHide, Lakitu_Lightning, Lakitu_LightningDelay, Lakitu_Cloudless,
};
void (*const gUnk_080D0148[])(Entity*) = {
void (*const gUnk_080D0148[])(LakituEntity*) = {
sub_0803C844,
sub_0803C850,
sub_0803C86C,
+80 -69
View File
@@ -4,164 +4,175 @@
*
* @brief Lakitu Cloud enemy
*/
#include "global.h"
#include "asm.h"
#include "entity.h"
#include "player.h"
#include "effects.h"
#include "enemy.h"
#include "physics.h"
#include "room.h"
#include "entity.h"
#include "object.h"
#include "physics.h"
#include "player.h"
#include "room.h"
extern void (*const LakituCloud_Functions[6])(Entity*);
extern void (*const gUnk_080D0430[3])(Entity*);
extern void (*const gUnk_080D043C[3])(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u16 unk_74;
/*0x76*/ u8 unused2[2];
/*0x78*/ u16 unk_78;
/*0x7a*/ u16 unk_7a;
} LakituCloudEntity;
void sub_0803CE14(Entity*);
void sub_0803CE3C(Entity*);
extern void (*const LakituCloud_Functions[6])(LakituCloudEntity*);
extern void (*const gUnk_080D0430[3])(LakituCloudEntity*);
extern void (*const gUnk_080D043C[3])(LakituCloudEntity*);
void LakituCloud(Entity* this) {
LakituCloud_Functions[GetNextFunction(this)](this);
void sub_0803CE14(LakituCloudEntity*);
void sub_0803CE3C(LakituCloudEntity*);
void LakituCloud(LakituCloudEntity* this) {
LakituCloud_Functions[GetNextFunction(super)](this);
}
void LakituCloud_OnTick(Entity* this) {
gUnk_080D0430[this->action](this);
void LakituCloud_OnTick(LakituCloudEntity* this) {
gUnk_080D0430[super->action](this);
}
void LakituCloud_OnKnockback(Entity* this) {
this->knockbackDuration = 0;
void LakituCloud_OnKnockback(LakituCloudEntity* this) {
super->knockbackDuration = 0;
LakituCloud_OnTick(this);
}
void LakituCloud_OnGrabbed(Entity* this) {
if (!sub_0806F520(this)) {
if (this->subAction == 2) {
void LakituCloud_OnGrabbed(LakituCloudEntity* this) {
if (!sub_0806F520(super)) {
if (super->subAction == 2) {
sub_0803CE3C(this);
}
} else {
gUnk_080D043C[this->subAction](this);
gUnk_080D043C[super->subAction](this);
}
}
void sub_0803CD2C(Entity* this) {
this->subAction = 1;
this->gustJarTolerance = 0x3c;
void sub_0803CD2C(LakituCloudEntity* this) {
super->subAction = 1;
super->gustJarTolerance = 0x3c;
}
void sub_0803CD38(Entity* this) {
sub_0806F4E8(this);
void sub_0803CD38(LakituCloudEntity* this) {
sub_0806F4E8(super);
}
void sub_0803CD40(Entity* this) {
if (!sub_0806F3E4(this)) {
void sub_0803CD40(LakituCloudEntity* this) {
if (!sub_0806F3E4(super)) {
return;
}
ModHealth(-2);
SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6);
SoundReqClipped(&gPlayerEntity.base, SFX_PLY_VO6);
sub_08079D84();
sub_0803CE3C(this);
}
void sub_0803CD6C(Entity* this) {
void sub_0803CD6C(LakituCloudEntity* this) {
Entity* lakitu;
this->action = 1;
this->z.HALF.HI = -2;
super->action = 1;
super->z.HALF.HI = -2;
// Set parent to lakitu
lakitu = GetCurrentRoomProperty(this->type);
this->child = lakitu;
this->parent = lakitu;
lakitu = GetCurrentRoomProperty(super->type);
super->child = lakitu;
super->parent = lakitu;
this->field_0x78.HWORD = this->x.HALF.HI;
this->field_0x7a.HWORD = this->y.HALF.HI;
this->unk_78 = super->x.HALF.HI;
this->unk_7a = super->y.HALF.HI;
InitAnimationForceUpdate(this, 4);
InitAnimationForceUpdate(super, 4);
sub_0803CE14(this);
}
void sub_0803CDA8(Entity* this) {
UpdateAnimationSingleFrame(this);
void sub_0803CDA8(LakituCloudEntity* this) {
UpdateAnimationSingleFrame(super);
if (!(this->direction & DIR_NOT_MOVING_CHECK)) {
LinearMoveUpdate(this);
if (!(super->direction & DIR_NOT_MOVING_CHECK)) {
LinearMoveUpdate(super);
}
if (--this->field_0x74.HWORD << 0x10 == 0) {
if (--this->unk_74 << 0x10 == 0) {
sub_0803CE14(this);
}
}
void sub_0803CDD8(Entity* this) {
void sub_0803CDD8(LakituCloudEntity* this) {
u8 one;
u8 draw;
draw = this->spriteSettings.draw;
draw = super->spriteSettings.draw;
one = 1;
this->spriteSettings.draw = draw ^ one;
super->spriteSettings.draw = draw ^ one;
this->timer--;
super->timer--;
if (this->timer == 0) {
this->action = 1;
if (super->timer == 0) {
super->action = 1;
COLLISION_ON(this);
COLLISION_ON(super);
this->spriteSettings.draw = one;
super->spriteSettings.draw = one;
}
}
void sub_0803CE14(Entity* this) {
void sub_0803CE14(LakituCloudEntity* this) {
u8 direction;
UpdateRailMovement(this, (u16**)&this->child, &this->field_0x74.HWORD);
UpdateRailMovement(super, (u16**)&super->child, &this->unk_74);
direction = this->direction;
direction = super->direction;
if (direction & DIR_NOT_MOVING_CHECK) {
return;
}
direction = direction / 8 + 4;
InitAnimationForceUpdate(this, direction);
InitAnimationForceUpdate(super, direction);
}
void sub_0803CE3C(Entity* this) {
CreateFx(this, FX_DEATH, 0);
void sub_0803CE3C(LakituCloudEntity* this) {
CreateFx(super, FX_DEATH, 0);
this->action = 2;
this->timer = 60;
super->action = 2;
super->timer = 60;
COLLISION_OFF(this);
COLLISION_OFF(super);
this->gustJarState &= 0xfb;
super->gustJarState &= 0xfb;
this->x.HALF.HI = this->field_0x78.HWORD;
this->y.HALF.HI = this->field_0x7a.HWORD;
super->x.HALF.HI = this->unk_78;
super->y.HALF.HI = this->unk_7a;
this->child = this->parent;
super->child = super->parent;
sub_0803CE14(this);
}
void (*const LakituCloud_Functions[])(Entity*) = {
LakituCloud_OnTick, LakituCloud_OnTick, LakituCloud_OnKnockback,
GenericDeath, GenericConfused, LakituCloud_OnGrabbed,
void (*const LakituCloud_Functions[])(LakituCloudEntity*) = {
LakituCloud_OnTick,
LakituCloud_OnTick,
LakituCloud_OnKnockback,
(void (*)(LakituCloudEntity*))GenericDeath,
(void (*)(LakituCloudEntity*))GenericConfused,
LakituCloud_OnGrabbed,
};
void (*const gUnk_080D0430[])(Entity*) = {
void (*const gUnk_080D0430[])(LakituCloudEntity*) = {
sub_0803CD6C,
sub_0803CDA8,
sub_0803CDD8,
};
void (*const gUnk_080D043C[])(Entity*) = {
void (*const gUnk_080D043C[])(LakituCloudEntity*) = {
sub_0803CD2C,
sub_0803CD38,
sub_0803CD40,
+84 -78
View File
@@ -9,13 +9,19 @@
#include "physics.h"
#include "tiles.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u16 unk_74;
} LeeverEntity;
extern Entity* gUnk_020000B0;
bool32 Leever_PlayerInRange(Entity*, s32);
void Leever_Move(Entity*);
void Leever_Move(LeeverEntity*);
extern void (*const Leever_Functions[])(Entity*);
extern void (*const gLeeverActions[])(Entity*);
extern void (*const Leever_Functions[])(LeeverEntity*);
extern void (*const gLeeverActions[])(LeeverEntity*);
extern const s8 gLeeverDrift[];
extern const u16 gUnk_080CA4CA[];
@@ -30,96 +36,96 @@ enum {
LeeverForm_Blue,
};
void Leever(Entity* this) {
EnemyFunctionHandler(this, Leever_Functions);
SetChildOffset(this, 0, 1, -0x10);
void Leever(LeeverEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Leever_Functions);
SetChildOffset(super, 0, 1, -0x10);
}
void Leever_OnTick(Entity* this) {
gLeeverActions[this->action](this);
void Leever_OnTick(LeeverEntity* this) {
gLeeverActions[super->action](this);
}
void Leever_OnCollision(Entity* this) {
if (this->contactFlags == 0x80) {
if (this->action == 3) {
this->field_0x74.HWORD = 1;
void Leever_OnCollision(LeeverEntity* this) {
if (super->contactFlags == 0x80) {
if (super->action == 3) {
this->unk_74 = 1;
}
} else {
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
}
}
EnemyFunctionHandlerAfterCollision(this, Leever_Functions);
EnemyFunctionHandlerAfterCollision(super, Leever_Functions);
}
void Leever_OnDeath(Entity* this) {
if (this->type == LeeverForm_Red) {
GenericDeath(this);
void Leever_OnDeath(LeeverEntity* this) {
if (super->type == LeeverForm_Red) {
GenericDeath(super);
} else {
CreateDeathFx(this, 0xf1, 0);
CreateDeathFx(super, 0xf1, 0);
}
}
void Leever_Initialize(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->timer = Random();
void Leever_Initialize(LeeverEntity* this) {
sub_0804A720(super);
super->action = 1;
super->timer = Random();
}
void Leever_Idle(Entity* this) {
if (--this->timer == 0) {
if (Leever_PlayerInRange(this, Random() & 0x1f)) {
this->action = 2;
this->spriteSettings.draw = TRUE;
this->direction =
(GetFacingDirection(this, gUnk_020000B0) + gLeeverDrift[Random() & 1]) & (0x3 | DirectionNorthWest);
InitializeAnimation(this, LeeverAnimation_DigUp);
UpdateSpriteForCollisionLayer(this);
void Leever_Idle(LeeverEntity* this) {
if (--super->timer == 0) {
if (Leever_PlayerInRange(super, Random() & 0x1f)) {
super->action = 2;
super->spriteSettings.draw = TRUE;
super->direction =
(GetFacingDirection(super, gUnk_020000B0) + gLeeverDrift[Random() & 1]) & (0x3 | DirectionNorthWest);
InitializeAnimation(super, LeeverAnimation_DigUp);
UpdateSpriteForCollisionLayer(super);
} else {
this->timer = DirectionRound(Random()) + 8;
super->timer = DirectionRound(Random()) + 8;
}
}
}
void Leever_DigUp(Entity* this) {
GetNextFrame(this);
void Leever_DigUp(LeeverEntity* this) {
GetNextFrame(super);
if (this->frame & ANIM_DONE) {
this->action = 3;
if (this->type == LeeverForm_Red) {
this->field_0x74.HWORD = 180;
if (super->frame & ANIM_DONE) {
super->action = 3;
if (super->type == LeeverForm_Red) {
this->unk_74 = 180;
} else {
this->field_0x74.HWORD = 110;
this->unk_74 = 110;
}
InitializeAnimation(this, LeeverAnimation_Attack);
} else if ((this->frame & 1) != 0) {
this->frame &= 0xfe;
COLLISION_ON(this);
InitializeAnimation(super, LeeverAnimation_Attack);
} else if ((super->frame & 1) != 0) {
super->frame &= 0xfe;
COLLISION_ON(super);
}
}
void Leever_Attack(Entity* this) {
void Leever_Attack(LeeverEntity* this) {
Leever_Move(this);
GetNextFrame(this);
GetNextFrame(super);
if (--this->field_0x74.HWORD == 0) {
this->action = 4;
COLLISION_OFF(this);
InitializeAnimation(this, LeeverAnimation_DigDown);
if (--this->unk_74 == 0) {
super->action = 4;
COLLISION_OFF(super);
InitializeAnimation(super, LeeverAnimation_DigDown);
}
}
void Leever_DigDown(Entity* this) {
void Leever_DigDown(LeeverEntity* this) {
Leever_Move(this);
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 1;
this->timer = 240;
this->spriteSettings.draw = FALSE;
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 1;
super->timer = 240;
super->spriteSettings.draw = FALSE;
}
}
bool32 sub_0801FDE4(Entity* ent, s32 x, s32 y) {
bool32 sub_0801FDE4(Entity* entity, s32 x, s32 y) {
u32 vvv;
const u16* puVar4;
@@ -129,9 +135,9 @@ bool32 sub_0801FDE4(Entity* ent, s32 x, s32 y) {
vvv = GetVvvAtWorldCoords(x, y, gUnk_020000B0->collisionLayer);
for (puVar4 = gUnk_080CA4CA; *puVar4 != (u16)-1;) {
if (*puVar4++ == vvv) {
ent->x.HALF.HI = (x & 0xfff0) + 8;
ent->y.HALF.HI = (y & 0xfff0) + 8;
ent->collisionLayer = gUnk_020000B0->collisionLayer;
entity->x.HALF.HI = (x & 0xfff0) + 8;
entity->y.HALF.HI = (y & 0xfff0) + 8;
entity->collisionLayer = gUnk_020000B0->collisionLayer;
return TRUE;
}
}
@@ -139,12 +145,12 @@ bool32 sub_0801FDE4(Entity* ent, s32 x, s32 y) {
}
}
bool32 Leever_PlayerInRange(Entity* ent, s32 arg2) {
bool32 Leever_PlayerInRange(Entity* entity, s32 arg2) {
s32 sin, cos;
s32 x, y;
u32 i;
if (sub_08049FDC(ent, 1) == 0) {
if (sub_08049FDC(entity, 1) == 0) {
return 0;
} else {
x = gUnk_020000B0->x.WORD;
@@ -154,7 +160,7 @@ bool32 Leever_PlayerInRange(Entity* ent, s32 arg2) {
for (i = 0; i < 8; i++) {
x += sin;
y += -cos;
if (sub_0801FDE4(ent, x >> 0x10, y >> 0x10) == 0) {
if (sub_0801FDE4(entity, x >> 0x10, y >> 0x10) == 0) {
return 0;
}
}
@@ -162,37 +168,37 @@ bool32 Leever_PlayerInRange(Entity* ent, s32 arg2) {
}
}
void Leever_Move(Entity* this) {
if (sub_08049FDC(this, 1) == 0) {
this->field_0x74.HWORD = 1;
void Leever_Move(LeeverEntity* this) {
if (sub_08049FDC(super, 1) == 0) {
this->unk_74 = 1;
}
this->speed = (this->frame & 0xf) * 0x20;
if (this->type == LeeverForm_Red) {
if ((this->subtimer++ & 0xf) == 0) {
sub_08004596(this, sub_0800132C(this, gUnk_020000B0));
super->speed = (super->frame & 0xf) * 0x20;
if (super->type == LeeverForm_Red) {
if ((super->subtimer++ & 0xf) == 0) {
sub_08004596(super, sub_0800132C(super, gUnk_020000B0));
}
} else {
this->speed += 0x40;
if ((this->subtimer++ & 0x7) == 0) {
sub_08004596(this, sub_0800132C(this, gUnk_020000B0));
super->speed += 0x40;
if ((super->subtimer++ & 0x7) == 0) {
sub_08004596(super, sub_0800132C(super, gUnk_020000B0));
}
}
ProcessMovement0(this);
ProcessMovement0(super);
}
// clang-format off
void (*const Leever_Functions[])(Entity*) = {
void (*const Leever_Functions[])(LeeverEntity*) = {
Leever_OnTick,
Leever_OnCollision,
GenericKnockback,
(void (*)(LeeverEntity*))GenericKnockback,
Leever_OnDeath,
GenericConfused,
(void (*)(LeeverEntity*))GenericConfused,
Leever_OnTick,
};
void (*const gLeeverActions[])(Entity*) = {
void (*const gLeeverActions[])(LeeverEntity*) = {
Leever_Initialize,
Leever_Idle,
Leever_DigUp,
+20 -22
View File
@@ -4,13 +4,11 @@
*
* @brief Like Like enemy
*/
#define NENT_DEPRECATED
#include "enemy.h"
#include "message.h"
#include "save.h"
#include "object.h"
#include "item.h"
#include "message.h"
#include "object.h"
#include "save.h"
typedef struct {
Entity base;
@@ -55,7 +53,7 @@ void LikeLike_OnCollision(LikeLikeEntity* this) {
super->timer = 95;
super->subtimer = tmp;
super->flags2 &= 0xfc;
this->prevSpritePriority = gPlayerEntity.spritePriority.b1;
this->prevSpritePriority = gPlayerEntity.base.spritePriority.b1;
}
}
}
@@ -73,7 +71,7 @@ void LikeLike_OnCollision(LikeLikeEntity* this) {
void LikeLike_OnDeath(LikeLikeEntity* this) {
if (super->timer == 2 && this->stolenItem != 0xff) {
SetDefaultPriority(super, PRIO_NO_BLOCK);
SetEntityPriority(super, PRIO_NO_BLOCK);
LikeLike_ReturnStolenItem(this->stolenItem);
}
GenericDeath(super);
@@ -200,12 +198,12 @@ void sub_0802805C(LikeLikeEntity* this) {
} else {
ResetActiveItems();
gPlayerState.mobility |= 0x80;
PositionRelative(super, &gPlayerEntity, 0, Q_16_16(1.0));
PositionRelative(super, &gPlayerEntity.base, 0, Q_16_16(1.0));
tmp = GetSpriteSubEntryOffsetDataPointer((u16)super->spriteIndex, super->frameIndex);
gPlayerEntity.spriteOffsetX = tmp[0];
gPlayerEntity.spriteOffsetY = tmp[1];
gPlayerEntity.spritePriority.b1 = 0;
gPlayerEntity.base.spriteOffsetX = tmp[0];
gPlayerEntity.base.spriteOffsetY = tmp[1];
gPlayerEntity.base.spritePriority.b1 = 0;
if (--super->timer == 0) {
sub_080281A0(this);
@@ -227,14 +225,14 @@ void LikeLike_ReleasePlayer(LikeLikeEntity* this) {
gPlayerState.jump_status = 0x41;
gPlayerState.field_0xa = 0;
gPlayerState.flags &= ~PL_CAPTURED;
gPlayerEntity.flags |= ENT_COLLIDE;
gPlayerEntity.zVelocity = Q_16_16(1.5);
gPlayerEntity.iframes = -60;
gPlayerEntity.base.flags |= ENT_COLLIDE;
gPlayerEntity.base.zVelocity = Q_16_16(1.5);
gPlayerEntity.base.iframes = -60;
tmp = 0;
gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState);
gPlayerEntity.spritePriority.b1 = this->prevSpritePriority;
gPlayerEntity.z.HALF.HI = gPlayerEntity.spriteOffsetY;
gPlayerEntity.spriteOffsetY = tmp;
gPlayerEntity.base.direction = Direction8FromAnimationState(gPlayerEntity.base.animationState);
gPlayerEntity.base.spritePriority.b1 = this->prevSpritePriority;
gPlayerEntity.base.z.HALF.HI = gPlayerEntity.base.spriteOffsetY;
gPlayerEntity.base.spriteOffsetY = tmp;
super->action = 4;
super->timer = 80;
super->subtimer = tmp;
@@ -260,12 +258,12 @@ void sub_080281A0(LikeLikeEntity* this) {
bool32 LikeLike_StealItem(u32 item) {
bool32 ret = FALSE;
if (GetInventoryValue(item) == 1) {
if (ItemIsShield(gSave.stats.itemButtons[SLOT_A])) {
gSave.stats.itemButtons[SLOT_A] = ITEM_NONE;
if (ItemIsShield(gSave.stats.equipped[SLOT_A])) {
gSave.stats.equipped[SLOT_A] = ITEM_NONE;
}
if (ItemIsShield(gSave.stats.itemButtons[SLOT_B])) {
gSave.stats.itemButtons[SLOT_B] = ITEM_NONE;
if (ItemIsShield(gSave.stats.equipped[SLOT_B])) {
gSave.stats.equipped[SLOT_B] = ITEM_NONE;
}
SetInventoryValue(item, 0);
+264 -243
View File
@@ -4,49 +4,70 @@
*
* @brief Madderpillar enemy
*/
#include "enemy.h"
#include "functions.h"
#include "hitbox.h"
void sub_08029E0C(Entity*);
void sub_08029EEC(Entity*);
void sub_0802A098(Entity*);
void sub_0802A16C(Entity*);
void sub_0802A058(Entity*);
bool32 sub_0802A14C(Entity*);
void sub_0802A18C(Entity*);
bool32 sub_08029FE4(Entity*);
void sub_08029FB4(Entity*, u32, u32);
void sub_0802A0F8(Entity*);
void sub_08029F0C(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u8 unk_74;
/*0x75*/ u8 unk_75;
/*0x76*/ u8 unused2[1];
/*0x77*/ u8 unk_77;
/*0x78*/ union SplitHWord unk_78;
/*0x7a*/ union SplitHWord unk_7a;
/*0x7c*/ u8 unk_7c;
/*0x7d*/ u8 unk_7d;
/*0x7e*/ u8 unk_7e;
/*0x7f*/ u8 unk_7f;
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
/*0x83*/ u8 unk_83;
/*0x84*/ u8 unk_84;
/*0x85*/ u8 unk_85;
/*0x86*/ u8 unk_86;
} MadderpillarEntity;
void sub_08029E0C(MadderpillarEntity* this);
void sub_08029EEC(MadderpillarEntity* this);
void sub_0802A098(MadderpillarEntity* this);
void sub_0802A16C(MadderpillarEntity* this);
void sub_0802A058(MadderpillarEntity* this);
bool32 sub_0802A14C(MadderpillarEntity* this);
void sub_0802A18C(MadderpillarEntity* this);
bool32 sub_08029FE4(MadderpillarEntity* this);
void sub_08029FB4(MadderpillarEntity* this, u32, u32);
void sub_0802A0F8(MadderpillarEntity* this);
void sub_08029F0C(MadderpillarEntity* this);
extern s16 gUnk_080B4488[];
extern void (*const gUnk_080CCD44[])(Entity*);
extern void (*const Madderpillar_Functions[])(Entity*);
extern void (*const gUnk_080CCD78[])(Entity*);
extern void (*const gUnk_080CCD88[])(Entity*);
extern void (*const gUnk_080CCD44[])(MadderpillarEntity*);
extern void (*const Madderpillar_Functions[])(MadderpillarEntity*);
extern void (*const gUnk_080CCD78[])(MadderpillarEntity*);
extern void (*const gUnk_080CCD88[])(MadderpillarEntity*);
extern const u8 gUnk_080CCDA0[];
extern void (*const gUnk_080CCDA8[])(Entity*);
extern void (*const gUnk_080CCDA8[])(MadderpillarEntity*);
extern const u8 gUnk_080CCDC8[];
extern const u16 gUnk_080CCDD4[];
void Madderpillar(Entity* this) {
gUnk_080CCD44[this->type](this);
void Madderpillar(MadderpillarEntity* this) {
gUnk_080CCD44[super->type](this);
}
void sub_08029870(Entity* this) {
Madderpillar_Functions[GetNextFunction(this)](this);
void sub_08029870(MadderpillarEntity* this) {
Madderpillar_Functions[GetNextFunction(super)](this);
}
void Madderpillar_OnTick(Entity* this) {
gUnk_080CCD78[this->action](this);
void Madderpillar_OnTick(MadderpillarEntity* this) {
gUnk_080CCD78[super->action](this);
}
void Madderpillar_OnCollision(Entity* this) {
if (this->action == 1) {
switch (this->contactFlags & 0x7f) {
void Madderpillar_OnCollision(MadderpillarEntity* this) {
if (super->action == 1) {
switch (super->contactFlags & 0x7f) {
case 0:
case 1:
case 2:
@@ -57,273 +78,273 @@ void Madderpillar_OnCollision(Entity* this) {
case 0x1e:
break;
default:
this->action = 2;
this->timer = 0;
this->hitType = 0x6b;
this->field_0x76.HALF.HI = 0;
ChangeObjPalette(this, 0x7f);
super->action = 2;
super->timer = 0;
super->hitType = 0x6b;
this->unk_77 = 0;
ChangeObjPalette(super, 0x7f);
EnqueueSFX(SFX_HIT);
this->child->action = 2;
super->child->action = 2;
break;
}
}
EnemyFunctionHandlerAfterCollision(this, Madderpillar_Functions);
EnemyFunctionHandlerAfterCollision(super, Madderpillar_Functions);
}
void Madderpillar_OnDeath(Entity* this) {
if (this->subtimer) {
this->subtimer--;
void Madderpillar_OnDeath(MadderpillarEntity* this) {
if (super->subtimer) {
super->subtimer--;
} else {
GenericDeath(this);
GenericDeath(super);
}
}
void Madderpillar_OnGrabbed(Entity* this) {
void Madderpillar_OnGrabbed(MadderpillarEntity* this) {
/* ... */
}
void sub_0802999C(Entity* this) {
void sub_0802999C(MadderpillarEntity* this) {
if (gEntCount < 0x44) {
Entity *ent1, *ent2, *ent3, *ent4, *ent5, *ent6;
ent1 = CreateEnemy(MADDERPILLAR, 1);
ent1->parent = this;
PositionRelative(this, ent1, 0, 5);
this->child = ent1;
ent1->parent = super;
PositionRelative(super, ent1, 0, 5);
super->child = ent1;
ent2 = CreateEnemy(MADDERPILLAR, 2);
ent2->parent = this;
PositionRelative(this, ent2, 0, 4);
ent2->parent = super;
PositionRelative(super, ent2, 0, 4);
ent1->child = ent2;
ent3 = CreateEnemy(MADDERPILLAR, 3);
ent3->parent = this;
PositionRelative(this, ent3, 0, 3);
ent3->parent = super;
PositionRelative(super, ent3, 0, 3);
ent2->child = ent3;
ent4 = CreateEnemy(MADDERPILLAR, 4);
ent4->parent = this;
PositionRelative(this, ent4, 0, 2);
ent4->parent = super;
PositionRelative(super, ent4, 0, 2);
ent3->child = ent4;
ent5 = CreateEnemy(MADDERPILLAR, 5);
ent5->parent = this;
PositionRelative(this, ent5, 0, 1);
ent5->parent = super;
PositionRelative(super, ent5, 0, 1);
ent4->child = ent5;
ent6 = CreateEnemy(MADDERPILLAR, 6);
ent6->child = this;
ent6->parent = this;
PositionRelative(this, ent6, 0, 0);
ent6->child = super;
ent6->parent = super;
PositionRelative(super, ent6, 0, 0);
ent5->child = ent6;
this->action = 1;
COLLISION_ON(this);
this->direction = DirectionRound(Random());
this->speed = 0xa0;
this->animationState = 0xff;
this->y.WORD += 6;
this->parent = this;
this->field_0x74.HALF.LO = 0xff;
this->field_0x74.HALF.HI = 0;
this->field_0x76.HALF.HI = 1;
super->action = 1;
COLLISION_ON(super);
super->direction = DirectionRound(Random());
super->speed = 0xa0;
super->animationState = 0xff;
super->y.WORD += 6;
super->parent = super;
this->unk_74 = 0xff;
this->unk_75 = 0;
this->unk_77 = 1;
sub_08029E0C(this);
sub_08029EEC(this);
}
}
void sub_08029A94(Entity* this) {
UpdateAnimationSingleFrame(this);
void sub_08029A94(MadderpillarEntity* this) {
UpdateAnimationSingleFrame(super);
sub_0802A098(this);
}
void sub_08029AA4(Entity* this) {
if (this->field_0x76.HALF.HI != 0) {
this->action = 3;
this->speed = 0x108;
this->hitType = 0x6a;
this->field_0x7a.HWORD = 0x168;
this->field_0x74.HALF.HI = 4;
void sub_08029AA4(MadderpillarEntity* this) {
if (this->unk_77 != 0) {
super->action = 3;
super->speed = 0x108;
super->hitType = 0x6a;
this->unk_7a.HWORD = 0x168;
this->unk_75 = 4;
sub_08029EEC(this);
EnqueueSFX(SFX_19D);
}
}
void sub_08029AE0(Entity* this) {
UpdateAnimationSingleFrame(this);
void sub_08029AE0(MadderpillarEntity* this) {
UpdateAnimationSingleFrame(super);
sub_0802A16C(this);
sub_0802A098(this);
if (--this->field_0x7a.HWORD == 0) {
this->action = 1;
this->speed = 0xa0;
this->field_0x74.HALF.HI = 0;
if (--this->unk_7a.HWORD == 0) {
super->action = 1;
super->speed = 0xa0;
this->unk_75 = 0;
sub_08029EEC(this);
ChangeObjPalette(this, 0x77);
ChangeObjPalette(super, 0x77);
EnqueueSFX(SFX_182);
}
}
void sub_08029B2C(Entity* this) {
void sub_08029B2C(MadderpillarEntity* this) {
if (sub_0802A14C(this)) {
if (this->field_0x86.HALF.LO) {
if (--this->timer == 0) {
CreateFx(this, FX_GIANT_EXPLOSION3, 0);
DeleteEntity(this);
if (this->unk_86) {
if (--super->timer == 0) {
CreateFx(super, FX_GIANT_EXPLOSION3, 0);
DeleteEntity(super);
}
} else {
COLLISION_OFF(this);
this->timer = -(this->type * 15 - 90);
this->field_0x86.HALF.LO = 1;
COLLISION_OFF(super);
super->timer = -(super->type * 15 - 90);
this->unk_86 = 1;
}
} else {
gUnk_080CCD88[this->action](this);
gUnk_080CCD88[super->action](this);
}
}
void sub_08029B90(Entity* this) {
this->action = 1;
this->spriteSettings.draw = 1;
void sub_08029B90(MadderpillarEntity* this) {
super->action = 1;
super->spriteSettings.draw = 1;
sub_0802A058(this);
if (this->type < 2) {
InitializeAnimation(this, 0);
if (super->type < 2) {
InitializeAnimation(super, 0);
} else {
InitializeAnimation(this, 4);
InitializeAnimation(super, 4);
}
}
void sub_08029BC4(Entity* this) {
void sub_08029BC4(MadderpillarEntity* this) {
u32 uVar1;
u32 uVar2;
sub_0802A18C(this);
uVar1 = this->x.HALF.HI;
uVar2 = this->y.HALF.HI;
uVar1 = super->x.HALF.HI;
uVar2 = super->y.HALF.HI;
if (sub_08029FE4(this)) {
u32 index;
if (this->type < 2) {
if (super->type < 2) {
index = 0;
} else {
index = 4;
}
InitializeAnimation(this, this->animationState + index);
InitializeAnimation(super, super->animationState + index);
}
sub_08029FB4(this, this->x.HALF.HI - uVar1, this->y.HALF.HI - uVar2);
sub_08029FB4(this, super->x.HALF.HI - uVar1, super->y.HALF.HI - uVar2);
}
void sub_08029C08(Entity* this) {
this->action = 3;
this->timer = gUnk_080CCDA0[this->type];
this->hitType = 0x6b;
this->child->action = 2;
void sub_08029C08(MadderpillarEntity* this) {
super->action = 3;
super->timer = gUnk_080CCDA0[super->type];
super->hitType = 0x6b;
super->child->action = 2;
}
void sub_08029C2C(Entity* this) {
if (--this->timer == 0) {
this->action = 4;
ChangeObjPalette(this, 0x7f);
void sub_08029C2C(MadderpillarEntity* this) {
if (--super->timer == 0) {
super->action = 4;
ChangeObjPalette(super, 0x7f);
EnqueueSFX(SFX_MENU_CANCEL);
}
}
void sub_08029C50(Entity* this) {
if (this->parent->field_0x76.HALF.HI != 0) {
this->action = 5;
this->hitType = 0x6a;
void sub_08029C50(MadderpillarEntity* this) {
if (((MadderpillarEntity*)super->parent)->unk_77 != 0) {
super->action = 5;
super->hitType = 0x6a;
}
}
void sub_08029C6C(Entity* this) {
void sub_08029C6C(MadderpillarEntity* this) {
sub_0802A18C(this);
sub_08029BC4(this);
if (this->parent->action != 3) {
this->action = 1;
ChangeObjPalette(this, 0x77);
if (super->parent->action != 3) {
super->action = 1;
ChangeObjPalette(super, 0x77);
} else {
sub_0802A16C(this);
}
}
void sub_08029C98(Entity* this) {
void sub_08029C98(MadderpillarEntity* this) {
if (sub_0802A14C(this)) {
CreateFx(this, FX_GIANT_EXPLOSION3, 0);
DeleteEntity(this);
CreateFx(super, FX_GIANT_EXPLOSION3, 0);
DeleteEntity(super);
} else {
gUnk_080CCDA8[this->action](this);
gUnk_080CCDA8[super->action](this);
}
}
void sub_08029CCC(Entity* this) {
this->action = 1;
this->spriteSettings.draw = 1;
void sub_08029CCC(MadderpillarEntity* this) {
super->action = 1;
super->spriteSettings.draw = 1;
sub_0802A058(this);
InitializeAnimation(this, 8);
InitializeAnimation(super, 8);
}
void sub_08029CF0(Entity* this) {
void sub_08029CF0(MadderpillarEntity* this) {
if (sub_08029FE4(this)) {
InitializeAnimation(this, this->animationState + 8);
InitializeAnimation(super, super->animationState + 8);
}
}
void sub_08029D08(Entity* this) {
this->action = 3;
this->timer = 71;
void sub_08029D08(MadderpillarEntity* this) {
super->action = 3;
super->timer = 71;
}
void sub_08029D14(Entity* this) {
if (this->timer != 0) {
if (--this->timer == 0) {
InitializeAnimation(this, this->animationState + 0xc);
ChangeObjPalette(this, 0x7f);
void sub_08029D14(MadderpillarEntity* this) {
if (super->timer != 0) {
if (--super->timer == 0) {
InitializeAnimation(super, super->animationState + 0xc);
ChangeObjPalette(super, 0x7f);
EnqueueSFX(SFX_MENU_CANCEL);
}
} else {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 4;
this->timer = 120;
this->hitType = 0x6c;
this->hitbox = (Hitbox*)&gUnk_080FD298;
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 4;
super->timer = 120;
super->hitType = 0x6c;
super->hitbox = (Hitbox*)&gUnk_080FD298;
EnqueueSFX(SFX_6B);
}
}
}
void sub_08029D78(Entity* this) {
void sub_08029D78(MadderpillarEntity* this) {
sub_0802A0F8(this);
if (--this->timer == 0) {
this->action = 5;
this->hitType = 0x6a;
this->hitbox = (Hitbox*)&gUnk_080FD2A0;
InitializeAnimation(this, this->animationState + 0x10);
if (--super->timer == 0) {
super->action = 5;
super->hitType = 0x6a;
super->hitbox = (Hitbox*)&gUnk_080FD2A0;
InitializeAnimation(super, super->animationState + 0x10);
}
}
void sub_08029DAC(Entity* this) {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 6;
this->parent->field_0x76.HALF.HI = 1;
InitializeAnimation(this, this->animationState + 8);
void sub_08029DAC(MadderpillarEntity* this) {
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 6;
((MadderpillarEntity*)super->parent)->unk_77 = 1;
InitializeAnimation(super, super->animationState + 8);
}
}
void sub_08029DDC(Entity* this) {
this->action = 7;
void sub_08029DDC(MadderpillarEntity* this) {
super->action = 7;
}
void sub_08029DE4(Entity* this) {
void sub_08029DE4(MadderpillarEntity* this) {
sub_08029CF0(this);
if (this->parent->action != 3) {
this->action = 1;
ChangeObjPalette(this, 0x77);
if (super->parent->action != 3) {
super->action = 1;
ChangeObjPalette(super, 0x77);
} else {
sub_0802A16C(this);
}
}
void sub_08029E0C(Entity* this) {
void sub_08029E0C(MadderpillarEntity* this) {
u32 tile;
s32 uVar4;
s32 iVar3;
@@ -333,16 +354,16 @@ void sub_08029E0C(Entity* this) {
u32 local_24;
u32 dir;
uVar2 = (this->direction >> 3) * 3;
uVar2 = (super->direction >> 3) * 3;
ptr = &gUnk_080CCDC8[uVar2];
uVar4 = (Random() & 1) * 2 - 1;
iVar3 = ((s32)Random() & 0xf) % 3;
tile = COORD_TO_TILE(this);
tile = COORD_TO_TILE(super);
for (i = 0; i < 3; i++) {
dir = ptr[iVar3];
if (GetCollisionDataAtMetaTilePos(gUnk_080B4488[dir >> 3] + tile, this->collisionLayer) == 0) {
if (GetCollisionDataAtMetaTilePos(gUnk_080B4488[dir >> 3] + tile, super->collisionLayer) == 0) {
local_24 = dir;
if (this->direction - this->field_0x74.HALF.LO != dir - this->direction)
if (super->direction - this->unk_74 != dir - super->direction)
break;
}
iVar3 = (iVar3 + uVar4 + 3) % 3;
@@ -352,61 +373,61 @@ void sub_08029E0C(Entity* this) {
dir = local_24;
}
if (this->field_0x74.HALF.LO != this->direction) {
this->field_0x74.HALF.LO = this->direction;
if (this->unk_74 != super->direction) {
this->unk_74 = super->direction;
}
this->direction = dir;
super->direction = dir;
sub_08029F0C(this);
}
void sub_08029EEC(Entity* this) {
u32 uVar1 = (this->direction >> 3) + this->field_0x74.HALF.HI;
if (uVar1 != this->animationState) {
this->animationState = uVar1;
InitAnimationForceUpdate(this, uVar1);
void sub_08029EEC(MadderpillarEntity* this) {
u32 uVar1 = (super->direction >> 3) + this->unk_75;
if (uVar1 != super->animationState) {
super->animationState = uVar1;
InitAnimationForceUpdate(super, uVar1);
}
}
void sub_08029F0C(Entity* this) {
switch (this->direction >> 3) {
void sub_08029F0C(MadderpillarEntity* this) {
switch (super->direction >> 3) {
case 0: // UP
this->field_0x78.HWORD = this->y.HALF.HI - 0x10;
this->unk_78.HWORD = super->y.HALF.HI - 0x10;
break;
case 1: // RIGHT
this->field_0x78.HWORD = this->x.HALF.HI + 0x10;
this->unk_78.HWORD = super->x.HALF.HI + 0x10;
break;
case 2: // DOWN
this->field_0x78.HWORD = this->y.HALF.HI + 0x10;
this->unk_78.HWORD = super->y.HALF.HI + 0x10;
break;
case 3: // LEFT
this->field_0x78.HWORD = this->x.HALF.HI - 0x10;
this->unk_78.HWORD = super->x.HALF.HI - 0x10;
break;
}
}
bool32 sub_08029F48(Entity* this) {
switch (this->direction >> 3) {
bool32 sub_08029F48(MadderpillarEntity* this) {
switch (super->direction >> 3) {
case 0: // UP
if (this->y.HALF.HI <= this->field_0x78.HWORD) {
this->y.HALF.HI = this->field_0x78.HWORD;
if (super->y.HALF.HI <= this->unk_78.HWORD) {
super->y.HALF.HI = this->unk_78.HWORD;
return TRUE;
}
break;
case 1: // RIGHT
if (this->x.HALF.HI >= this->field_0x78.HWORD) {
this->x.HALF.HI = this->field_0x78.HWORD;
if (super->x.HALF.HI >= this->unk_78.HWORD) {
super->x.HALF.HI = this->unk_78.HWORD;
return TRUE;
}
break;
case 2: // DOWN
if (this->y.HALF.HI >= this->field_0x78.HWORD) {
this->y.HALF.HI = this->field_0x78.HWORD;
if (super->y.HALF.HI >= this->unk_78.HWORD) {
super->y.HALF.HI = this->unk_78.HWORD;
return TRUE;
}
break;
case 3: // LEFT
if (this->x.HALF.HI <= this->field_0x78.HWORD) {
this->x.HALF.HI = this->field_0x78.HWORD;
if (super->x.HALF.HI <= this->unk_78.HWORD) {
super->x.HALF.HI = this->unk_78.HWORD;
return TRUE;
}
break;
@@ -415,23 +436,23 @@ bool32 sub_08029F48(Entity* this) {
return FALSE;
}
void sub_08029FB4(Entity* this, u32 x, u32 y) {
u8* dst = (u8*)&this->child->field_0x78;
s32 unk = this->parent->field_0x7c.BYTES.byte2;
void sub_08029FB4(MadderpillarEntity* this, u32 x, u32 y) {
u8* dst = (u8*)&((MadderpillarEntity*)super->child)->unk_78;
s32 unk = ((MadderpillarEntity*)super->parent)->unk_7e;
u8 idx = unk % 0xe;
dst[idx] = ((x + 8) & 0xf) | (((y + 8) & 0xf) << 4);
}
/* The optimizer is strong within you. */
bool32 sub_08029FE4(Entity* this) {
bool32 sub_08029FE4(MadderpillarEntity* this) {
u8 state;
u8* dst = (u8*)&this->field_0x78;
s32 unk = this->parent->field_0x7c.BYTES.byte2 + 1;
u8* dst = (u8*)&this->unk_78;
s32 unk = ((MadderpillarEntity*)super->parent)->unk_7e + 1;
s8 iVar6 = (dst[unk % 0xe] & 0xf) - 8;
s8 iVar5 = (dst[unk % 0xe] >> 4) - 8;
this->x.HALF.HI += iVar6;
this->y.HALF.HI += iVar5;
GetNextFrame(this);
super->x.HALF.HI += iVar6;
super->y.HALF.HI += iVar5;
GetNextFrame(super);
state = 0xff;
if (iVar6 != 0) {
@@ -450,72 +471,72 @@ bool32 sub_08029FE4(Entity* this) {
}
}
if (state != 0xff && state != this->animationState) {
this->animationState = state;
if (state != 0xff && state != super->animationState) {
super->animationState = state;
return TRUE;
} else {
return FALSE;
}
}
void sub_0802A058(Entity* this) {
this->field_0x78.HALF.LO = 0x88;
this->field_0x78.HALF.HI = 0x88;
this->field_0x7a.HALF.LO = 0x88;
this->field_0x7a.HALF.HI = 0x88;
this->field_0x7c.BYTES.byte0 = 0x88;
this->field_0x7c.BYTES.byte1 = 0x88;
this->field_0x7c.BYTES.byte2 = 0x88;
this->field_0x7c.BYTES.byte3 = 0x88;
this->field_0x80.HALF.LO = 0x88;
this->field_0x80.HALF.HI = 0x88;
this->field_0x82.HALF.LO = 0x88;
this->field_0x82.HALF.HI = 0x88;
this->cutsceneBeh.HALF.LO = 0x88;
this->cutsceneBeh.HALF.HI = 0x88;
void sub_0802A058(MadderpillarEntity* this) {
this->unk_78.HALF.LO = 0x88;
this->unk_78.HALF.HI = 0x88;
this->unk_7a.HALF.LO = 0x88;
this->unk_7a.HALF.HI = 0x88;
this->unk_7c = 0x88;
this->unk_7d = 0x88;
this->unk_7e = 0x88;
this->unk_7f = 0x88;
this->unk_80 = 0x88;
this->unk_81 = 0x88;
this->unk_82 = 0x88;
this->unk_83 = 0x88;
this->unk_84 = 0x88;
this->unk_85 = 0x88;
}
void sub_0802A098(Entity* this) {
void sub_0802A098(MadderpillarEntity* this) {
u32 uVar1;
u32 uVar2;
s32 unk = (++this->field_0x7c.BYTES.byte2, this->field_0x7c.BYTES.byte2);
s32 unk = (++this->unk_7e, this->unk_7e);
u8 idx = unk % 0xe;
if (idx == 0) {
this->field_0x7c.BYTES.byte2 = 0;
this->unk_7e = 0;
}
uVar1 = this->x.HALF.HI;
uVar2 = this->y.HALF.HI;
ProcessMovement0(this);
uVar1 = super->x.HALF.HI;
uVar2 = super->y.HALF.HI;
ProcessMovement0(super);
if (sub_08029F48(this)) {
sub_08029E0C(this);
sub_08029EEC(this);
EnqueueSFX(SFX_PLACE_OBJ);
}
sub_08029FB4(this, this->x.HALF.HI - uVar1, this->y.HALF.HI - uVar2);
sub_08029FB4(this, super->x.HALF.HI - uVar1, super->y.HALF.HI - uVar2);
}
void sub_0802A0F8(Entity* this) {
if (this->health != 0) {
if ((this->contactFlags & 0x80) && this->iframes != 0) {
Entity* ent = this;
void sub_0802A0F8(MadderpillarEntity* this) {
if (super->health != 0) {
if ((super->contactFlags & 0x80) && super->iframes != 0) {
Entity* entity = super;
u32 i;
for (i = 0; i < 6; i++) {
ent = ent->child;
ent->iframes = this->iframes;
entity = entity->child;
entity->iframes = super->iframes;
}
}
} else {
this->parent->flags &= ~ENT_COLLIDE;
this->parent->health = 0;
this->parent->subtimer = 105;
super->parent->flags &= ~ENT_COLLIDE;
super->parent->health = 0;
super->parent->subtimer = 105;
}
}
bool32 sub_0802A14C(Entity* this) {
bool32 sub_0802A14C(MadderpillarEntity* this) {
u32 ret = FALSE;
if (this->parent->health == 0 || this->field_0x86.HALF.LO) {
if (super->parent->health == 0 || this->unk_86) {
ret = TRUE;
} else {
ret = FALSE;
@@ -523,13 +544,13 @@ bool32 sub_0802A14C(Entity* this) {
return ret;
}
void sub_0802A16C(Entity* this) {
ChangeObjPalette(this, gUnk_080CCDD4[this->parent->field_0x7a.HWORD >> 2 & 3]);
void sub_0802A16C(MadderpillarEntity* this) {
ChangeObjPalette(super, gUnk_080CCDD4[((MadderpillarEntity*)super->parent)->unk_7a.HWORD >> 2 & 3]);
}
void sub_0802A18C(Entity* this) {
if (this->contactFlags & 0x80) {
switch (this->contactFlags & 0x7f) {
void sub_0802A18C(MadderpillarEntity* this) {
if (super->contactFlags & 0x80) {
switch (super->contactFlags & 0x7f) {
case 0:
case 1:
case 2:
@@ -547,7 +568,7 @@ void sub_0802A18C(Entity* this) {
}
// clang-format off
void (*const gUnk_080CCD44[])(Entity*) = {
void (*const gUnk_080CCD44[])(MadderpillarEntity*) = {
sub_08029870,
sub_08029B2C,
sub_08029B2C,
@@ -557,23 +578,23 @@ void (*const gUnk_080CCD44[])(Entity*) = {
sub_08029C98,
};
void (*const Madderpillar_Functions[])(Entity*) = {
void (*const Madderpillar_Functions[])(MadderpillarEntity*) = {
Madderpillar_OnTick,
Madderpillar_OnCollision,
Madderpillar_OnTick,
Madderpillar_OnDeath,
GenericConfused,
(void (*)(MadderpillarEntity*))GenericConfused,
Madderpillar_OnGrabbed,
};
void (*const gUnk_080CCD78[])(Entity*) = {
void (*const gUnk_080CCD78[])(MadderpillarEntity*) = {
sub_0802999C,
sub_08029A94,
sub_08029AA4,
sub_08029AE0,
};
void (*const gUnk_080CCD88[])(Entity*) = {
void (*const gUnk_080CCD88[])(MadderpillarEntity*) = {
sub_08029B90,
sub_08029BC4,
sub_08029C08,
@@ -592,7 +613,7 @@ const u8 gUnk_080CCDA0[] = {
0x00,
};
void (*const gUnk_080CCDA8[])(Entity*) = {
void (*const gUnk_080CCDA8[])(MadderpillarEntity*) = {
sub_08029CCC,
sub_08029CF0,
sub_08029D08,
+786 -745
View File
File diff suppressed because it is too large Load Diff
-1
View File
@@ -4,7 +4,6 @@
*
* @brief Mazaal Hand enemy
*/
#include "entity.h"
#include "hitbox.h"
+406 -388
View File
File diff suppressed because it is too large Load Diff
+114 -101
View File
@@ -4,7 +4,6 @@
*
* @brief Mazaal Macro enemy
*/
#include "enemy.h"
#include "functions.h"
#include "screenTransitions.h"
@@ -12,39 +11,53 @@
#include "structures.h"
#include "tiles.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[5];
/*0x6d*/ u8 unk_6d;
/*0x6e*/ u8 unused2[10];
/*0x78*/ u16 unk_78;
/*0x7a*/ u8 unused3[10];
/*0x84*/ ScriptExecutionContext* context;
} MazaalMacroEntity;
extern void sub_0807B600(u32);
extern const u16 script_MazaalMacroDefeated[];
void sub_08034E18(Entity*);
void sub_08034FA0(Entity*);
u32 sub_08035084(Entity*);
void sub_08034F70(Entity*);
void sub_08035120(Entity*);
void sub_08035050(Entity*);
void sub_08034E18(MazaalMacroEntity* this);
void sub_08034FA0(MazaalMacroEntity* this);
u32 sub_08035084(MazaalMacroEntity* this);
void sub_08034F70(MazaalMacroEntity* this);
void sub_08035120(MazaalMacroEntity* this);
void sub_08035050(MazaalMacroEntity* this);
void MazaalMacro_OnTick(Entity* this);
void MazaalMacro_OnCollision(Entity* this);
void MazaalMacro_OnDeath(Entity* this);
void sub_08034CC4(Entity* this);
void sub_08034D4C(Entity* this);
void sub_08034DC8(Entity* this);
void sub_08034E30(Entity* this);
void sub_08034E68(Entity* this);
void sub_08034EC0(Entity* this);
void sub_08034ED8(Entity* this);
void sub_08034EE4(Entity* this);
void sub_08034F58(Entity* this);
void MazaalMacro_OnTick(MazaalMacroEntity* this);
void MazaalMacro_OnCollision(MazaalMacroEntity* this);
void MazaalMacro_OnDeath(MazaalMacroEntity* this);
void sub_08034CC4(MazaalMacroEntity* this);
void sub_08034D4C(MazaalMacroEntity* this);
void sub_08034DC8(MazaalMacroEntity* this);
void sub_08034E30(MazaalMacroEntity* this);
void sub_08034E68(MazaalMacroEntity* this);
void sub_08034EC0(MazaalMacroEntity* this);
void sub_08034ED8(MazaalMacroEntity* this);
void sub_08034EE4(MazaalMacroEntity* this);
void sub_08034F58(MazaalMacroEntity* this);
void (*const MazaalMacro_Functions[])(Entity*) = {
MazaalMacro_OnTick, MazaalMacro_OnCollision, GenericKnockback, MazaalMacro_OnDeath, GenericConfused,
void (*const MazaalMacro_Functions[])(MazaalMacroEntity*) = {
MazaalMacro_OnTick,
MazaalMacro_OnCollision,
(void (*)(MazaalMacroEntity*))GenericKnockback,
MazaalMacro_OnDeath,
(void (*)(MazaalMacroEntity*))GenericConfused,
};
void (*const gUnk_080CEEA4[])(Entity*) = {
void (*const gUnk_080CEEA4[])(MazaalMacroEntity*) = {
sub_08034CC4,
sub_08034D4C,
sub_08034DC8,
};
void (*const gUnk_080CEEB0[])(Entity*) = {
void (*const gUnk_080CEEB0[])(MazaalMacroEntity*) = {
sub_08034E30, sub_08034E68, sub_08034EC0, sub_08034ED8, sub_08034EE4, sub_08034F58,
};
@@ -53,101 +66,101 @@ const u8 gUnk_080CEECC[] = { 0x58, 0x68, 0x88, 0x68, 0xb8, 0x68, 0x58, 0xa8, 0x8
const s16 gUnk_080CEED8[] = { -0x82, -0x81, -0x80, -0x7f, -0x7e, -0x42, -0x41, -0x40, -0x3f, -0x3e, -2, -1,
1, 2, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x7e, 0x7f, 0x80, 0x81, 0x82 };
void MazaalMacro(Entity* this) {
MazaalMacro_Functions[GetNextFunction(this)](this);
void MazaalMacro(MazaalMacroEntity* this) {
MazaalMacro_Functions[GetNextFunction(super)](this);
}
void MazaalMacro_OnTick(Entity* this) {
if (this->type != 2) {
gUnk_080CEEA4[this->action](this);
void MazaalMacro_OnTick(MazaalMacroEntity* this) {
if (super->type != 2) {
gUnk_080CEEA4[super->action](this);
} else {
sub_08034E18(this);
}
}
void MazaalMacro_OnCollision(Entity* this) {
void MazaalMacro_OnCollision(MazaalMacroEntity* this) {
sub_08034FA0(this);
EnemyFunctionHandlerAfterCollision(this, MazaalMacro_Functions);
EnemyFunctionHandlerAfterCollision(super, MazaalMacro_Functions);
}
void MazaalMacro_OnDeath(Entity* this) {
GenericDeath(this);
void MazaalMacro_OnDeath(MazaalMacroEntity* this) {
GenericDeath(super);
}
void sub_08034CC4(Entity* this) {
void sub_08034CC4(MazaalMacroEntity* this) {
Entity* entity;
if (sub_08035084(this) != 0) {
this->action = this->type + 1;
this->subtimer = 0;
this->field_0x6c.HALF.HI |= 1;
this->field_0x78.HWORD = 0x4b0;
super->action = super->type + 1;
super->subtimer = 0;
this->unk_6d |= 1;
this->unk_78 = 0x4b0;
sub_08034F70(this);
InitializeAnimation(this, this->type);
SetMetaTile(SPECIAL_META_TILE_34, COORD_TO_TILE(this), this->collisionLayer);
InitializeAnimation(super, super->type);
SetMetaTile(SPECIAL_META_TILE_34, COORD_TO_TILE(super), super->collisionLayer);
entity = CreateEnemy(MAZAAL_MACRO, 2);
if (entity != NULL) {
this->child = entity;
entity->parent = this;
CopyPosition(this, entity);
super->child = entity;
entity->parent = super;
CopyPosition(super, entity);
}
}
}
void sub_08034D4C(Entity* this) {
void sub_08034D4C(MazaalMacroEntity* this) {
Entity* entity;
GetNextFrame(this);
if (--this->field_0x78.HWORD == 0) {
if ((this->subtimer < 8) && (entity = CreateEnemy(VAATI_PROJECTILE, 0), entity != (Entity*)0x0)) {
GetNextFrame(super);
if (--this->unk_78 == 0) {
if ((super->subtimer < 8) && (entity = CreateEnemy(VAATI_PROJECTILE, 0), entity != (Entity*)0x0)) {
entity->direction = (s32)Random() % 5 + 0xc;
entity->x.HALF.HI = (gRoomControls.width / 2) + gRoomControls.origin_x;
entity->y.HALF.HI = gRoomControls.origin_y + 8;
entity->collisionLayer = 3;
entity->parent = this;
entity->parent = super;
UpdateSpriteForCollisionLayer(entity);
this->field_0x78.HWORD = 600;
this->subtimer = this->subtimer + 1;
this->unk_78 = 600;
super->subtimer = super->subtimer + 1;
} else {
this->field_0x78.HWORD = 0x78;
this->unk_78 = 0x78;
}
}
}
void sub_08034DC8(Entity* this) {
void sub_08034DC8(MazaalMacroEntity* this) {
if (gRoomTransition.field_0x39 == 0) {
CreateFx(this, FX_GIANT_EXPLOSION4, 0);
RestorePrevTileEntity(COORD_TO_TILE(this), this->collisionLayer);
CreateFx(super, FX_GIANT_EXPLOSION4, 0);
RestorePrevTileEntity(COORD_TO_TILE(super), super->collisionLayer);
DeleteThisEntity();
}
}
void sub_08034E18(Entity* this) {
gUnk_080CEEB0[this->action](this);
void sub_08034E18(MazaalMacroEntity* this) {
gUnk_080CEEB0[super->action](this);
}
void sub_08034E30(Entity* this) {
this->action = this->parent->type + 1;
this->collisionLayer = 2;
this->spritePriority.b0 = 7;
this->spritePriority.b1 = 0;
UpdateSpriteForCollisionLayer(this);
InitializeAnimation(this, 2);
void sub_08034E30(MazaalMacroEntity* this) {
super->action = super->parent->type + 1;
super->collisionLayer = 2;
super->spritePriority.b0 = 7;
super->spritePriority.b1 = 0;
UpdateSpriteForCollisionLayer(super);
InitializeAnimation(super, 2);
}
void sub_08034E68(Entity* this) {
void sub_08034E68(MazaalMacroEntity* this) {
ScriptExecutionContext* scriptExecutionContext;
if (this->parent->next == NULL) {
if (this->spriteSettings.draw != 0) {
this->spriteSettings.draw = 0;
if (super->parent->next == NULL) {
if (super->spriteSettings.draw != 0) {
super->spriteSettings.draw = 0;
sub_08035120(this);
}
if (gRoomTransition.field_0x39 == 0) {
if (PlayerCanBeMoved()) {
this->action = 3;
scriptExecutionContext = StartCutscene(this, (u16*)script_MazaalMacroDefeated);
*(ScriptExecutionContext**)&this->cutsceneBeh = scriptExecutionContext;
super->action = 3;
scriptExecutionContext = StartCutscene(super, (u16*)script_MazaalMacroDefeated);
this->context = scriptExecutionContext;
}
} else {
DeleteThisEntity();
@@ -155,24 +168,24 @@ void sub_08034E68(Entity* this) {
}
}
void sub_08034EC0(Entity* this) {
if (this->parent->next == NULL) {
void sub_08034EC0(MazaalMacroEntity* this) {
if (super->parent->next == NULL) {
sub_08035120(this);
DeleteThisEntity();
}
}
void sub_08034ED8(Entity* this) {
ExecuteScriptForEntity(this, NULL);
void sub_08034ED8(MazaalMacroEntity* this) {
ExecuteScriptForEntity(super, NULL);
}
void sub_08034EE4(Entity* this) {
void sub_08034EE4(MazaalMacroEntity* this) {
u32 randomValue;
Entity* entity;
if ((++this->timer & 0xf) == 0) {
if ((++super->timer & 0xf) == 0) {
randomValue = Random();
entity = CreateFx(this, gUnk_080CEEC8[randomValue & 3], 0);
entity = CreateFx(super, gUnk_080CEEC8[randomValue & 3], 0);
if (entity != NULL) {
entity->x.HALF.HI = (((randomValue >> 2) & 0x77) << 1) + 1 + gRoomControls.scroll_x;
entity->y.HALF.HI = ((randomValue >> 9) & 0x7e) + 1 + gRoomControls.scroll_y;
@@ -180,59 +193,59 @@ void sub_08034EE4(Entity* this) {
UpdateSpriteForCollisionLayer(entity);
}
}
ExecuteScriptForEntity(this, NULL);
ExecuteScriptForEntity(super, NULL);
}
void sub_08034F58(Entity* this) {
void sub_08034F58(MazaalMacroEntity* this) {
DoExitTransition(&gUnk_0813ABA8);
DeleteEntity(this);
DeleteEntity(super);
}
void sub_08034F70(Entity* this) {
this->health = gRoomTransition.field_0x39;
void sub_08034F70(MazaalMacroEntity* this) {
super->health = gRoomTransition.field_0x39;
if (gRoomTransition.field_0x39 >= 0x3d) {
this->type2 = 0;
super->type2 = 0;
} else if (gRoomTransition.field_0x39 >= 0x1f) {
this->type2 = 1;
super->type2 = 1;
} else {
this->type2 = 2;
super->type2 = 2;
}
}
void sub_08034FA0(Entity* this) {
if (0 < this->iframes) {
this->child->iframes = this->iframes;
void sub_08034FA0(MazaalMacroEntity* this) {
if (0 < super->iframes) {
super->child->iframes = super->iframes;
InitScreenShake(12, 1);
}
switch (this->type2) {
switch (super->type2) {
case 0:
if (this->health < 0x3c) {
if (super->health < 0x3c) {
gRoomTransition.field_0x39 = 0x3c;
sub_08035050(this);
return;
}
break;
case 1:
if (this->health < 0x1e) {
if (super->health < 0x1e) {
gRoomTransition.field_0x39 = 0x1e;
sub_08035050(this);
return;
}
break;
default:
if (this->health == 0) {
RestorePrevTileEntity(COORD_TO_TILE(this), this->collisionLayer);
if (super->health == 0) {
RestorePrevTileEntity(COORD_TO_TILE(super), super->collisionLayer);
}
break;
}
gRoomTransition.field_0x39 = this->health;
gRoomTransition.field_0x39 = super->health;
}
void sub_08035050(Entity* this) {
void sub_08035050(MazaalMacroEntity* this) {
Entity* entity;
COLLISION_OFF(this);
this->health = 0;
COLLISION_OFF(super);
super->health = 0;
entity = CreateEnemy(VAATI_PROJECTILE, 0);
if (entity != NULL) {
entity->type2 = 1;
@@ -242,13 +255,13 @@ void sub_08035050(Entity* this) {
}
}
u32 sub_08035084(Entity* this) {
u32 sub_08035084(MazaalMacroEntity* this) {
u32 vulnPillar;
Entity* entity;
u32 i;
const u8* coords;
if (this->type == 0) {
if (super->type == 0) {
if (0x42 < gEntCount) {
return 0;
}
@@ -258,7 +271,7 @@ u32 sub_08035084(Entity* this) {
gRoomTransition.field_0x38 = (gRoomTransition.field_0x38 & 0xf) | (vulnPillar << 4);
for (i = 0, coords = gUnk_080CEECC; i < 6; i++, coords += 2) {
if (i == vulnPillar) {
entity = this;
entity = super;
} else {
entity = CreateEnemy(MAZAAL_MACRO, 1);
}
@@ -271,11 +284,11 @@ u32 sub_08035084(Entity* this) {
return 1;
}
void sub_08035120(Entity* this) {
void sub_08035120(MazaalMacroEntity* this) {
s32 tile;
u32 i;
tile = COORD_TO_TILE(this);
tile = COORD_TO_TILE(super);
for (i = 0; i < 0x18; i++) {
sub_0807B600(tile + gUnk_080CEED8[i]);
}
+53 -44
View File
@@ -4,79 +4,88 @@
*
* @brief Mini Fireball Guy enemy
*/
#include "enemy.h"
#include "functions.h"
extern void sub_08045678(Entity*);
void MiniFireballGuy_OnTick(Entity*);
void MiniFireballGuy_OnCollision(Entity*);
void MiniFireballGuy_OnDeath(Entity*);
void MiniFireballGuy_OnGrabbed(Entity*);
void sub_08045618(Entity*);
void sub_08045654(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[4];
/*0x6c*/ u8 unk_6c;
} MiniFireballGuyEntity;
static void (*const MiniFireballGuy_Functions[])(Entity*) = {
MiniFireballGuy_OnTick, MiniFireballGuy_OnCollision, GenericKnockback, MiniFireballGuy_OnDeath,
GenericConfused, MiniFireballGuy_OnGrabbed,
extern void sub_08045678(MiniFireballGuyEntity* this);
void MiniFireballGuy_OnTick(MiniFireballGuyEntity* this);
void MiniFireballGuy_OnCollision(MiniFireballGuyEntity* this);
void MiniFireballGuy_OnDeath(MiniFireballGuyEntity* this);
void MiniFireballGuy_OnGrabbed(MiniFireballGuyEntity* this);
void sub_08045618(MiniFireballGuyEntity* this);
void sub_08045654(MiniFireballGuyEntity* this);
static void (*const MiniFireballGuy_Functions[])(MiniFireballGuyEntity*) = {
MiniFireballGuy_OnTick,
MiniFireballGuy_OnCollision,
(void (*)(MiniFireballGuyEntity*))GenericKnockback,
MiniFireballGuy_OnDeath,
(void (*)(MiniFireballGuyEntity*))GenericConfused,
MiniFireballGuy_OnGrabbed,
};
void MiniFireballGuy(Entity* this) {
EnemyFunctionHandler(this, MiniFireballGuy_Functions);
void MiniFireballGuy(MiniFireballGuyEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)MiniFireballGuy_Functions);
}
void MiniFireballGuy_OnTick(Entity* this) {
static void (*const actionFuncs[])(Entity*) = {
void MiniFireballGuy_OnTick(MiniFireballGuyEntity* this) {
static void (*const actionFuncs[])(MiniFireballGuyEntity*) = {
sub_08045618,
sub_08045654,
};
actionFuncs[this->action](this);
actionFuncs[super->action](this);
}
void MiniFireballGuy_OnCollision(Entity* this) {
EnemyFunctionHandlerAfterCollision(this, MiniFireballGuy_Functions);
void MiniFireballGuy_OnCollision(MiniFireballGuyEntity* this) {
EnemyFunctionHandlerAfterCollision(super, MiniFireballGuy_Functions);
}
void MiniFireballGuy_OnDeath(Entity* this) {
if ((this != this->parent) && (this->parent != NULL)) {
this->field_0x6c.HALF.LO &= ~0x80;
this->parent->child = this->child;
this->child->parent = this->parent;
void MiniFireballGuy_OnDeath(MiniFireballGuyEntity* this) {
if ((super != super->parent) && (super->parent != NULL)) {
this->unk_6c &= ~0x80;
super->parent->child = super->child;
super->child->parent = super->parent;
}
GenericDeath(this);
GenericDeath(super);
}
void MiniFireballGuy_OnGrabbed(Entity* this) {
void MiniFireballGuy_OnGrabbed(MiniFireballGuyEntity* this) {
}
void sub_08045618(Entity* this) {
this->action = 1;
this->spriteSettings.draw = 1;
this->speed = 0x80;
this->collisionFlags = this->collisionFlags | 0x10;
sub_0804A720(this);
InitializeAnimation(this, 1);
void sub_08045618(MiniFireballGuyEntity* this) {
super->action = 1;
super->spriteSettings.draw = 1;
super->speed = 0x80;
super->collisionFlags = super->collisionFlags | 0x10;
sub_0804A720(super);
InitializeAnimation(super, 1);
sub_08045678(this);
}
void sub_08045654(Entity* this) {
ProcessMovement2(this);
GetNextFrame(this);
if (GravityUpdate(this, Q_8_8(24.0)) == 0) {
void sub_08045654(MiniFireballGuyEntity* this) {
ProcessMovement2(super);
GetNextFrame(super);
if (GravityUpdate(super, Q_8_8(24.0)) == 0) {
sub_08045678(this);
}
}
void sub_08045678(Entity* this) {
this->zVelocity = Q_16_16(1.75);
if (this->timer != 0) {
this->timer--;
void sub_08045678(MiniFireballGuyEntity* this) {
super->zVelocity = Q_16_16(1.75);
if (super->timer != 0) {
super->timer--;
} else {
this->timer = Random() & 3;
if ((sub_08049FA0(this) == 0) && (Random() & 3)) {
this->direction = DirectionRound(sub_08049EE4(this) - 4 + (Random() & 8));
super->timer = Random() & 3;
if ((sub_08049FA0(super) == 0) && (Random() & 3)) {
super->direction = DirectionRound(sub_08049EE4(super) - 4 + (Random() & 8));
} else {
this->direction = DirectionRound(Random());
super->direction = DirectionRound(Random());
}
}
}
+70 -61
View File
@@ -4,107 +4,116 @@
*
* @brief Mini Slime enemy
*/
#include "enemy.h"
#include "physics.h"
void sub_08045374(Entity*);
void MiniSlime_OnTick(Entity*);
void MiniSlime_OnCollision(Entity*);
void MiniSlime_OnDeath(Entity*);
void MiniSlime_OnGrabbed(Entity*);
void sub_080452A4(Entity*);
void sub_080452E4(Entity*);
void sub_080452FC(Entity*);
void sub_08045374(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[4];
/*0x6c*/ u8 unk_6c;
/*0x6d*/ u8 unk_6d;
} MiniSlimeEntity;
void sub_08045374(MiniSlimeEntity* this);
void MiniSlime_OnTick(MiniSlimeEntity* this);
void MiniSlime_OnCollision(MiniSlimeEntity* this);
void MiniSlime_OnDeath(MiniSlimeEntity* this);
void MiniSlime_OnGrabbed(MiniSlimeEntity* this);
void sub_080452A4(MiniSlimeEntity* this);
void sub_080452E4(MiniSlimeEntity* this);
void sub_080452FC(MiniSlimeEntity* this);
extern void sub_080452E4(Entity*);
extern void ReplaceMonitoredEntity(Entity*, Entity*);
static void (*const MiniSlime_Functions[])(Entity*) = {
MiniSlime_OnTick, MiniSlime_OnCollision, GenericKnockback, MiniSlime_OnDeath, GenericConfused, MiniSlime_OnGrabbed,
static void (*const MiniSlime_Functions[])(MiniSlimeEntity*) = {
MiniSlime_OnTick,
MiniSlime_OnCollision,
(void (*)(MiniSlimeEntity*))GenericKnockback,
MiniSlime_OnDeath,
(void (*)(MiniSlimeEntity*))GenericConfused,
MiniSlime_OnGrabbed,
};
void MiniSlime(Entity* this) {
EnemyFunctionHandler(this, MiniSlime_Functions);
SetChildOffset(this, 0, 1, -8);
void MiniSlime(MiniSlimeEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)MiniSlime_Functions);
SetChildOffset(super, 0, 1, -8);
}
void MiniSlime_OnTick(Entity* this) {
static void (*const actionFuncs[])(Entity*) = {
void MiniSlime_OnTick(MiniSlimeEntity* this) {
static void (*const actionFuncs[])(MiniSlimeEntity*) = {
sub_080452A4,
sub_080452E4,
sub_080452FC,
sub_08045374,
};
actionFuncs[this->action](this);
actionFuncs[super->action](this);
}
void MiniSlime_OnCollision(Entity* this) {
if (this->confusedTime)
Create0x68FX(this, FX_STARS);
void MiniSlime_OnCollision(MiniSlimeEntity* this) {
if (super->confusedTime)
Create0x68FX(super, FX_STARS);
EnemyFunctionHandlerAfterCollision(this, MiniSlime_Functions);
EnemyFunctionHandlerAfterCollision(super, MiniSlime_Functions);
}
void MiniSlime_OnDeath(Entity* this) {
Entity* parent = this->parent;
if ((this != parent) && (parent != NULL)) {
this->field_0x6c.HALF.LO &= ~0x80;
this->parent->child = this->child;
this->child->parent = this->parent;
if (this->field_0x6c.HALF.HI & 0x40)
ReplaceMonitoredEntity(this, parent);
void MiniSlime_OnDeath(MiniSlimeEntity* this) {
Entity* parent = super->parent;
if ((super != parent) && (parent != NULL)) {
this->unk_6c &= ~0x80;
super->parent->child = super->child;
super->child->parent = super->parent;
if (this->unk_6d & 0x40)
ReplaceMonitoredEntity(super, parent);
}
GenericDeath(this);
GenericDeath(super);
}
void MiniSlime_OnGrabbed(Entity* this) {
void MiniSlime_OnGrabbed(MiniSlimeEntity* this) {
}
void sub_080452A4(Entity* this) {
this->action = 1;
this->spriteSettings.draw = 1;
this->speed = 0x100;
sub_0804A720(this);
InitializeAnimation(this, 6);
if (this->type2) {
this->action = 2;
this->timer = 1;
void sub_080452A4(MiniSlimeEntity* this) {
super->action = 1;
super->spriteSettings.draw = 1;
super->speed = 0x100;
sub_0804A720(super);
InitializeAnimation(super, 6);
if (super->type2) {
super->action = 2;
super->timer = 1;
} else {
sub_080452E4(this);
}
}
void sub_080452E4(Entity* this) {
this->action = 2;
this->timer = (Random() & 0x1f) + 1;
void sub_080452E4(MiniSlimeEntity* this) {
super->action = 2;
super->timer = (Random() & 0x1f) + 1;
}
void sub_080452FC(Entity* this) {
void sub_080452FC(MiniSlimeEntity* this) {
u32 cVar2, bVar3;
GetNextFrame(this);
if (--this->timer == 0) {
this->action = 3;
this->timer = 1;
if (0 < this->speed)
this->timer = FixedDiv(0x1000, this->speed) >> 8;
GetNextFrame(super);
if (--super->timer == 0) {
super->action = 3;
super->timer = 1;
if (0 < super->speed)
super->timer = FixedDiv(0x1000, super->speed) >> 8;
if (sub_08049FA0(this) == 0 && (Random() & 3)) {
cVar2 = sub_08049EE4(this);
if (sub_08049FA0(super) == 0 && (Random() & 3)) {
cVar2 = sub_08049EE4(super);
bVar3 = Random() & 8;
bVar3 += 0xfc;
this->direction = DirectionRound(cVar2 + bVar3);
super->direction = DirectionRound(cVar2 + bVar3);
} else {
this->direction = DirectionRound(Random());
super->direction = DirectionRound(Random());
sub_08045374(this);
}
}
}
void sub_08045374(Entity* this) {
ProcessMovement0(this);
GetNextFrame(this);
if (--this->timer == 0)
this->action = 1;
void sub_08045374(MiniSlimeEntity* this) {
ProcessMovement0(super);
GetNextFrame(super);
if (--super->timer == 0)
super->action = 1;
}
+156 -126
View File
@@ -4,240 +4,270 @@
*
* @brief Moldorm enemy
*/
#include "enemy.h"
#include "collision.h"
#include "enemy.h"
#include "functions.h"
void sub_08022EAC(Entity*);
void sub_08022F14(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ u16 unk_74;
/*0x76*/ u16 unk_76;
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
/*0x7a*/ u8 unk_7a;
/*0x7b*/ u8 unk_7b;
union {
/*0x7c*/ Entity* entity;
struct {
/*0x7c*/ u8 unk_7c;
/*0x7d*/ u8 unk_7d;
/*0x7e*/ u8 unk_7e;
/*0x7f*/ u8 unk_7f;
} split;
} unk_7c;
union {
/*0x80*/ Entity* entity;
struct {
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
/*0x83*/ u8 unk_83;
} split;
} unk_80;
/*0x84*/ u32 unk_84;
} MoldormEntity;
extern void (*const gUnk_080CBB90[])(Entity*);
extern void (*const Moldorm_Functions[])(Entity*);
extern void (*const gUnk_080CBBB4[])(Entity*);
extern void (*const gUnk_080CBBBC[])(Entity*);
void sub_08022EAC(MoldormEntity*);
void sub_08022F14(MoldormEntity*);
extern void (*const gUnk_080CBB90[])(MoldormEntity*);
extern void (*const Moldorm_Functions[])(MoldormEntity*);
extern void (*const gUnk_080CBBB4[])(MoldormEntity*);
extern void (*const gUnk_080CBBBC[])(MoldormEntity*);
extern const s8 gUnk_080CBBC4[];
void Moldorm(Entity* this) {
gUnk_080CBB90[this->type](this);
void Moldorm(MoldormEntity* this) {
gUnk_080CBB90[super->type](this);
}
void sub_08022BA0(Entity* this) {
this->field_0x78.HALF.HI++;
this->field_0x74.HWORD = this->x.HALF.HI;
this->field_0x76.HWORD = this->y.HALF.HI;
EnemyFunctionHandler(this, Moldorm_Functions);
void sub_08022BA0(MoldormEntity* this) {
this->unk_79++;
this->unk_74 = super->x.HALF.HI;
this->unk_76 = super->y.HALF.HI;
EnemyFunctionHandler(super, (EntityActionArray)Moldorm_Functions);
sub_08022EAC(this);
}
void Moldorm_OnTick(Entity* this) {
gUnk_080CBBB4[this->action](this);
void Moldorm_OnTick(MoldormEntity* this) {
gUnk_080CBBB4[super->action](this);
}
void Moldorm_OnCollision(Entity* this) {
if (this->field_0x7a.HALF.LO != this->health)
this->field_0x7a.HALF.HI = 30;
void Moldorm_OnCollision(MoldormEntity* this) {
if (this->unk_7a != super->health)
this->unk_7b = 30;
this->field_0x7a.HALF.LO = this->health;
this->timer = 1;
this->direction = this->knockbackDirection;
this->unk_7a = super->health;
super->timer = 1;
super->direction = super->knockbackDirection;
this->animationState = ((this->direction + 2) & 0x1c) >> 2;
this->frameIndex = this->animationState;
super->animationState = ((super->direction + 2) & 0x1c) >> 2;
super->frameIndex = super->animationState;
this->child->iframes = this->iframes;
(*(Entity**)&this->field_0x7c)->iframes = this->iframes;
(*(Entity**)&this->field_0x80)->iframes = this->iframes;
EnemyFunctionHandlerAfterCollision(this, Moldorm_Functions);
super->child->iframes = super->iframes;
this->unk_7c.entity->iframes = super->iframes;
this->unk_80.entity->iframes = super->iframes;
EnemyFunctionHandlerAfterCollision(super, Moldorm_Functions);
}
void sub_08022C58(Entity* this) {
void sub_08022C58(MoldormEntity* this) {
Entity *tail0, *tail1, *tail2;
COLLISION_OFF(this);
COLLISION_OFF(super);
if (gEntCount >= 0x45)
return;
tail0 = CreateEnemy(MOLDORM, 1);
this->child = tail0;
super->child = tail0;
tail0->spritePriority.b0 = 5;
tail0->parent = this;
CopyPosition(this, tail0);
tail0->parent = super;
CopyPosition(super, tail0);
tail1 = CreateEnemy(MOLDORM, 2);
tail0->child = tail1;
tail1->spritePriority.b0 = 5;
tail1->parent = this;
CopyPosition(this, tail1);
tail1->parent = super;
CopyPosition(super, tail1);
tail2 = CreateEnemy(MOLDORM, 3);
tail1->child = tail2;
tail2->spritePriority.b0 = 5;
tail2->parent = this;
CopyPosition(this, tail2);
tail2->parent = super;
CopyPosition(super, tail2);
sub_0804A720(this);
this->action = 1;
this->timer = 1;
this->subtimer = 1;
COLLISION_ON(this);
this->parent = this;
this->child = tail0;
*(Entity**)&this->field_0x7c = tail1;
*(Entity**)&this->field_0x80 = tail2;
sub_0804A720(super);
super->action = 1;
super->timer = 1;
super->subtimer = 1;
COLLISION_ON(super);
super->parent = super;
super->child = tail0;
this->unk_7c.entity = tail1;
this->unk_80.entity = tail2;
this->direction = Random() & 0x1f;
this->animationState = ((this->direction + 2) & 0x1c) >> 2;
this->frameIndex = this->animationState;
this->field_0x7a.HALF.LO = this->health;
super->direction = Random() & 0x1f;
super->animationState = ((super->direction + 2) & 0x1c) >> 2;
super->frameIndex = super->animationState;
this->unk_7a = super->health;
}
void sub_08022D40(Entity* this) {
if (this->field_0x7a.HALF.HI) {
if (this->field_0x7a.HALF.HI-- & 1) {
this->animationState = (this->animationState + 1) & 7;
this->frameIndex = this->animationState;
void sub_08022D40(MoldormEntity* this) {
if (this->unk_7b) {
if (this->unk_7b-- & 1) {
super->animationState = (super->animationState + 1) & 7;
super->frameIndex = super->animationState;
}
} else {
sub_08022F14(this);
ProcessMovement0(this);
ProcessMovement0(super);
if (this->collisions != COL_NONE) {
sub_0800417E(this, this->collisions);
this->animationState = ((this->direction + 2) & 0x1c) >> 2;
this->frameIndex = this->animationState;
if (super->collisions != COL_NONE) {
sub_0800417E(super, super->collisions);
super->animationState = ((super->direction + 2) & 0x1c) >> 2;
super->frameIndex = super->animationState;
}
}
}
void sub_08022D90(Entity* this) {
if (this->parent->next != NULL) {
void sub_08022D90(MoldormEntity* this) {
if (super->parent->next != NULL) {
Entity* parent;
gUnk_080CBBBC[this->action](this);
parent = this->parent;
this->spriteOrientation.flipY = parent->spriteOrientation.flipY;
this->spriteRendering.b3 = parent->spriteRendering.b3;
this->collisionLayer = parent->collisionLayer;
gUnk_080CBBBC[super->action](this);
parent = super->parent;
super->spriteOrientation.flipY = parent->spriteOrientation.flipY;
super->spriteRendering.b3 = parent->spriteRendering.b3;
super->collisionLayer = parent->collisionLayer;
} else {
DeleteEntity(this);
DeleteEntity(super);
}
}
void sub_08022DE8(Entity* this) {
this->action = 1;
this->field_0x7c.BYTES.byte0 = 0x88;
this->field_0x7c.BYTES.byte1 = 0x88;
this->field_0x7c.BYTES.byte2 = 0x88;
this->field_0x7c.BYTES.byte3 = 0x88;
this->field_0x80.HALF.LO = 0x88;
this->field_0x80.HALF.HI = 0x88;
this->field_0x82.HALF.LO = 0x88;
this->field_0x82.HALF.HI = 0x88;
this->animationState = this->parent->animationState;
*(u32*)&this->cutsceneBeh = this->animationState * 0x11111111;
void sub_08022DE8(MoldormEntity* this) {
super->action = 1;
this->unk_7c.split.unk_7c = 0x88;
this->unk_7c.split.unk_7d = 0x88;
this->unk_7c.split.unk_7e = 0x88;
this->unk_7c.split.unk_7f = 0x88;
this->unk_80.split.unk_80 = 0x88;
this->unk_80.split.unk_81 = 0x88;
this->unk_80.split.unk_82 = 0x88;
this->unk_80.split.unk_83 = 0x88;
super->animationState = super->parent->animationState;
this->unk_84 = super->animationState * 0x11111111;
if (this->type != 3) {
this->frameIndex = this->type + 7;
if (super->type != 3) {
super->frameIndex = super->type + 7;
} else {
this->frameIndex = this->animationState + 10;
super->frameIndex = super->animationState + 10;
}
}
void sub_08022E40(Entity* this) {
void sub_08022E40(MoldormEntity* this) {
u32 bVar1;
u32 animationState;
u32 tmp;
u32 tmp2;
u8* ptr;
this->field_0x74.HWORD = this->x.HALF.HI;
this->field_0x76.HWORD = this->y.HALF.HI;
tmp2 = (this->parent->field_0x78.HALF.HI + 1) & 7;
ptr = (u8*)&this->field_0x7c + tmp2;
this->unk_74 = super->x.HALF.HI;
this->unk_76 = super->y.HALF.HI;
tmp2 = (((MoldormEntity*)super->parent)->unk_79 + 1) & 7;
ptr = (u8*)&this->unk_7c.split.unk_7c + tmp2;
bVar1 = *ptr;
tmp = (bVar1 & 0xf) - 8;
bVar1 >>= 4;
this->x.HALF.HI = ((short)((tmp * 0x100)) >> 8) + this->x.HALF.HI;
super->x.HALF.HI = ((short)((tmp * 0x100)) >> 8) + super->x.HALF.HI;
bVar1 -= 8;
this->y.HALF.HI = bVar1 + this->y.HALF.HI;
animationState = (u8)(*(u32*)&this->cutsceneBeh >> (((this->parent->field_0x78.HALF.HI + 1) & 7) << 2)) & 7;
this->animationState = animationState;
if (this->type == 3) {
this->frameIndex = animationState + 10;
super->y.HALF.HI = bVar1 + super->y.HALF.HI;
animationState = (u8)(this->unk_84 >> (((((MoldormEntity*)super->parent)->unk_79 + 1) & 7) << 2)) & 7;
super->animationState = animationState;
if (super->type == 3) {
super->frameIndex = animationState + 10;
} else {
sub_08022EAC(this);
}
}
void sub_08022EAC(Entity* this) {
void sub_08022EAC(MoldormEntity* this) {
int iVar1;
u32 tmp;
u32 tmp2;
if (this->child != NULL) {
tmp2 = ((this->parent->field_0x78.HALF.HI) & 7);
((u8*)&this->child->field_0x7c)[tmp2] = ((this->x.HALF_U.HI - this->field_0x74.HALF.LO + 8) & 0xf) +
((u32)((this->y.HALF_U.HI - this->field_0x76.HALF.LO + 8) & 0xf) << 4);
iVar1 = ((this->parent->field_0x78.HALF.HI) & 7) << 2;
tmp = (this->animationState & 7) << iVar1;
tmp |= ~(0xf << iVar1) & (*(u32*)&this->child->cutsceneBeh);
*(u32*)&this->child->cutsceneBeh = tmp;
if (super->child != NULL) {
tmp2 = ((((MoldormEntity*)super->parent)->unk_79) & 7);
((u8*)&((MoldormEntity*)super->child)->unk_7c.split.unk_7c)[tmp2] =
((super->x.HALF_U.HI - this->unk_74 + 8) & 0xf) +
((u32)((super->y.HALF_U.HI - this->unk_76 + 8) & 0xf) << 4);
iVar1 = ((((MoldormEntity*)super->parent)->unk_79) & 7) << 2;
tmp = (super->animationState & 7) << iVar1;
tmp |= ~(0xf << iVar1) & (((MoldormEntity*)super->child)->unk_84);
((MoldormEntity*)super->child)->unk_84 = tmp;
}
}
void sub_08022F14(Entity* this) {
if (sub_08049FA0(this) == 0) {
u32 bVar6 = (sub_08049EE4(this) - this->direction) & 0x1f;
void sub_08022F14(MoldormEntity* this) {
if (sub_08049FA0(super) == 0) {
u32 bVar6 = (sub_08049EE4(super) - super->direction) & 0x1f;
if (8 < ((bVar6 + 4) & 0x1f)) {
this->subtimer = 8;
super->subtimer = 8;
if (bVar6 < 0x10) {
this->field_0x78.HALF.LO = 1;
this->unk_78 = 1;
} else {
this->field_0x78.HALF.LO = -1;
this->unk_78 = -1;
}
}
}
if (--this->timer == 0) {
this->timer = 4;
if (--super->timer == 0) {
super->timer = 4;
if (--this->subtimer == 0) {
this->subtimer = 8;
this->field_0x78.HALF.LO = gUnk_080CBBC4[Random() & 1];
if (--super->subtimer == 0) {
super->subtimer = 8;
this->unk_78 = gUnk_080CBBC4[Random() & 1];
}
this->direction += this->field_0x78.HALF.LO;
this->direction &= DirectionNorthWest | 0x3;
super->direction += this->unk_78;
super->direction &= DirectionNorthWest | 0x3;
this->animationState = ((this->direction + 2) & 0x1c) >> 2;
this->frameIndex = this->animationState;
super->animationState = ((super->direction + 2) & 0x1c) >> 2;
super->frameIndex = super->animationState;
}
}
// clang-format off
void (*const gUnk_080CBB90[])(Entity*) = {
void (*const gUnk_080CBB90[])(MoldormEntity*) = {
sub_08022BA0,
sub_08022D90,
sub_08022D90,
sub_08022D90,
};
void (*const Moldorm_Functions[])(Entity*) = {
void (*const Moldorm_Functions[])(MoldormEntity*) = {
Moldorm_OnTick,
Moldorm_OnCollision,
GenericKnockback,
GenericDeath,
GenericConfused,
(void (*)(MoldormEntity*))GenericKnockback,
(void (*)(MoldormEntity*))GenericDeath,
(void (*)(MoldormEntity*))GenericConfused,
};
void (*const gUnk_080CBBB4[])(Entity*) = {
void (*const gUnk_080CBBB4[])(MoldormEntity*) = {
sub_08022C58,
sub_08022D40,
};
void (*const gUnk_080CBBBC[])(Entity*) = {
void (*const gUnk_080CBBBC[])(MoldormEntity*) = {
sub_08022DE8,
sub_08022E40,
};
+335 -310
View File
@@ -4,161 +4,189 @@
*
* @brief Moldworm enemy
*/
#include "collision.h"
#include "enemy.h"
#include "functions.h"
#include "tiles.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[12];
/*0x74*/ Entity* unk_74;
union {
/*0x78*/ u16 HWORD;
struct {
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
} PACKED split;
} PACKED unk_78;
/*0x7a*/ u8 unk_7a;
/*0x7b*/ u8 unk_7b;
/*0x7c*/ u8 unk_7c;
/*0x7d*/ u8 unk_7d;
/*0x7e*/ u8 unk_7e;
/*0x7f*/ u8 unk_7f;
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
/*0x83*/ u8 unk_83;
/*0x84*/ u8 unk_84;
/*0x85*/ u8 unk_85;
/*0x86*/ u8 unk_86;
/*0x87*/ u8 unk_87;
} MoldwormEntity;
extern void SoundReqClipped(Entity*, u32);
extern bool32 sub_08023A38(u32 metaTileType);
extern void sub_08023990(Entity*, u32, u32);
extern void sub_08023A88(Entity*, u32);
void sub_080235BC(Entity*);
void sub_08023644(Entity*);
void sub_08023730(Entity*);
void sub_080237D8(Entity*);
void sub_0802390C(Entity*);
void sub_080239F0(Entity*);
bool32 sub_08023B38(Entity*);
void sub_08023990(MoldwormEntity*, u32, u32);
void sub_08023A88(MoldwormEntity*, u32);
void sub_080235BC(MoldwormEntity*);
void sub_08023644(MoldwormEntity*);
void sub_08023730(MoldwormEntity*);
void sub_080237D8(MoldwormEntity*);
void sub_0802390C(MoldwormEntity*);
void sub_080239F0(MoldwormEntity*);
bool32 sub_08023B38(MoldwormEntity*);
void sub_08023A68(MoldwormEntity*);
void sub_08023AB0(MoldwormEntity*);
extern void (*const Moldworm_Functions[])(Entity*);
extern void (*const gUnk_080CBC50[])(Entity*);
extern void (*const Moldworm_Functions[])(MoldwormEntity*);
extern void (*const gUnk_080CBC50[])(MoldwormEntity*);
extern const s8 gUnk_080CBC70[];
extern const s8 gUnk_080CBC90[];
extern void (*const gUnk_080CBC98[])(Entity*);
extern void (*const gUnk_080CBCA8[])(Entity*);
extern void (*const gUnk_080CBC98[])(MoldwormEntity*);
extern void (*const gUnk_080CBCA8[])(MoldwormEntity*);
extern const s8 gUnk_080CBCB8[];
void Moldworm(Entity* this) {
u16 prevX = this->x.HALF.HI;
u16 prevY = this->y.HALF.HI;
void Moldworm(MoldwormEntity* this) {
u16 prevX = super->x.HALF.HI;
u16 prevY = super->y.HALF.HI;
if (this->type == 0) {
if (this->action != 0) {
if (super->type == 0) {
if (super->action != 0) {
sub_0802390C(this);
}
this->field_0x7c.BYTES.byte1 = this->field_0x7c.BYTES.byte0;
EnemyFunctionHandler(this, Moldworm_Functions);
this->unk_7d = this->unk_7c;
EnemyFunctionHandler(super, (EntityActionArray)Moldworm_Functions);
} else {
if (this->parent->next != NULL) {
if (this->type != 8) {
if (super->parent->next != NULL) {
if (super->type != 8) {
sub_080235BC(this);
} else {
sub_08023730(this);
}
} else {
DeleteEntity(this);
DeleteEntity(super);
return;
}
}
if (this->parent->field_0x7c.BYTES.byte0 != this->parent->field_0x7c.BYTES.byte1 && this->child) {
u32 temp = (this->parent->field_0x7c.BYTES.byte0 - 1) & 0xf;
u8* ptr = (u8*)&this->child->field_0x78 + temp;
*ptr = (((this->x.HALF.HI - prevX + 8) & 0xf) << 4) | ((this->y.HALF.HI - prevY + 8U) & 0xf);
if (((MoldwormEntity*)super->parent)->unk_7c != ((MoldwormEntity*)super->parent)->unk_7d && super->child) {
u32 temp = (((MoldwormEntity*)super->parent)->unk_7c - 1) & 0xf;
u8* ptr = (u8*)&((MoldwormEntity*)super->child)->unk_78.split.unk_78 + temp;
*ptr = (((super->x.HALF.HI - prevX + 8) & 0xf) << 4) | ((super->y.HALF.HI - prevY + 8U) & 0xf);
}
}
void Moldworm_OnTick(Entity* this) {
gUnk_080CBC50[this->action](this);
void Moldworm_OnTick(MoldwormEntity* this) {
gUnk_080CBC50[super->action](this);
}
void Moldworm_OnCollision(Entity* this) {
if (this->subAction == 0xff) {
this->action = 7;
this->timer = 1;
this->subAction = 0;
this->hitType = 0x85;
this->iframes = -8;
this->field_0x7c.BYTES.byte3 = 0;
this->field_0x7a.HALF.HI = 0;
if (this->contactFlags == 0x80 || this->contactFlags == 0x9e) {
this->type2 = 0;
this->field_0x80.HALF.LO = 0x14;
void Moldworm_OnCollision(MoldwormEntity* this) {
if (super->subAction == 0xff) {
super->action = 7;
super->timer = 1;
super->subAction = 0;
super->hitType = 0x85;
super->iframes = -8;
this->unk_7f = 0;
this->unk_7b = 0;
if (super->contactFlags == 0x80 || super->contactFlags == 0x9e) {
super->type2 = 0;
this->unk_80 = 0x14;
} else {
this->type2 = 1;
this->field_0x80.HALF.LO = 8;
super->type2 = 1;
this->unk_80 = 8;
}
}
if (this->health == 0 && this->field_0x7c.BYTES.byte3 == 0 && this->action == 7) {
CopyPosition(this, &gPlayerEntity);
gPlayerEntity.flags |= ENT_COLLIDE;
gPlayerEntity.spriteSettings.draw = 1;
gPlayerEntity.zVelocity = Q_16_16(1.5);
gPlayerEntity.direction = 0xff;
gPlayerEntity.iframes = -0x14;
if (super->health == 0 && this->unk_7f == 0 && super->action == 7) {
CopyPosition(super, &gPlayerEntity.base);
gPlayerEntity.base.flags |= ENT_COLLIDE;
gPlayerEntity.base.spriteSettings.draw = 1;
gPlayerEntity.base.zVelocity = Q_16_16(1.5);
gPlayerEntity.base.direction = 0xff;
gPlayerEntity.base.iframes = -0x14;
gPlayerState.jump_status = 0x41;
gPlayerState.flags &= ~PL_MOLDWORM_CAPTURED;
}
EnemyFunctionHandlerAfterCollision(this, Moldworm_Functions);
EnemyFunctionHandlerAfterCollision(super, Moldworm_Functions);
}
void Moldworm_OnKnockback(Entity* this) {
this->field_0x7c.BYTES.byte0++;
GenericKnockback(this);
void Moldworm_OnKnockback(MoldwormEntity* this) {
this->unk_7c++;
GenericKnockback(super);
}
void Moldworm_OnGrabbed(Entity* this) {
void Moldworm_OnGrabbed(MoldwormEntity* this) {
}
void sub_080231BC(Entity* this) {
void sub_080231BC(MoldwormEntity* this) {
if (gEntCount < 0x40) {
Entity* ent;
ent = this->child = CreateEnemy(MOLDWORM, 1);
ent->parent = this;
ent = super->child = CreateEnemy(MOLDWORM, 1);
ent->parent = super;
ent = ent->child = CreateEnemy(MOLDWORM, 2);
ent->parent = this;
ent->parent = super;
ent = ent->child = CreateEnemy(MOLDWORM, 3);
ent->parent = this;
ent->parent = super;
ent = ent->child = CreateEnemy(MOLDWORM, 4);
ent->parent = this;
ent->parent = super;
ent = ent->child = CreateEnemy(MOLDWORM, 5);
ent->parent = this;
ent->parent = super;
ent = ent->child = CreateEnemy(MOLDWORM, 6);
ent->parent = this;
ent->parent = super;
ent = ent->child = CreateEnemy(MOLDWORM, 7);
ent->parent = this;
ent->parent = super;
ent->child = CreateEnemy(MOLDWORM, 8);
*(Entity**)&ent->child->field_0x74 = ent;
((MoldwormEntity*)ent->child)->unk_74 = ent;
ent = ent->child;
ent->parent = this;
ent->parent = super;
ent->child = NULL;
sub_0804A720(this);
this->action = 6;
this->timer = 30;
this->parent = this;
this->field_0x78.HWORD = 0x1e;
this->palette.b.b0 = 5;
this->direction = Random() & 0x1f;
this->animationState = Direction8ToAnimationState(Direction8RoundUp(this->direction));
InitializeAnimation(this, this->animationState);
sub_0804A720(super);
super->action = 6;
super->timer = 30;
super->parent = super;
this->unk_78.HWORD = 0x1e;
super->palette.b.b0 = 5;
super->direction = Random() & 0x1f;
super->animationState = Direction8ToAnimationState(Direction8RoundUp(super->direction));
InitializeAnimation(super, super->animationState);
}
}
void nullsub_136(Entity* this) {
void nullsub_136(MoldwormEntity* this) {
}
void sub_08023288(Entity* this) {
if (sub_08049FDC(this, 1) && (this->timer++ & 0xf) == 0) {
void sub_08023288(MoldwormEntity* this) {
if (sub_08049FDC(super, 1) && (super->timer++ & 0xf) == 0) {
u32 idx = Random() & 0x1e;
u32 i;
for (i = 0; i < 0x10; i++) {
u32 x = gPlayerEntity.x.HALF.HI + gUnk_080CBC70[idx + 0];
u32 y = gPlayerEntity.y.HALF.HI + gUnk_080CBC70[idx + 1];
if (sub_08023A38(GetMetaTileTypeByPos(x, y, gPlayerEntity.collisionLayer))) {
u32 x = gPlayerEntity.base.x.HALF.HI + gUnk_080CBC70[idx + 0];
u32 y = gPlayerEntity.base.y.HALF.HI + gUnk_080CBC70[idx + 1];
if (sub_08023A38(GetMetaTileTypeByPos(x, y, gPlayerEntity.base.collisionLayer))) {
sub_08023990(this, x, y);
return;
}
@@ -168,262 +196,259 @@ void sub_08023288(Entity* this) {
}
}
void sub_08023330(Entity* this) {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 4;
this->timer = 25;
COLLISION_ON(this);
this->field_0x78.HWORD = 600;
this->direction = Random() & 0x1c;
this->animationState = this->direction >> 2;
this->field_0x7a.HALF.HI = 0;
this->field_0x7c.BYTES.byte3 = 0;
sub_08023A88(this, this->animationState);
CopyPosition(this, this->child);
CreateFx(this, FX_ROCK, 0);
void sub_08023330(MoldwormEntity* this) {
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 4;
super->timer = 25;
COLLISION_ON(super);
this->unk_78.HWORD = 600;
super->direction = Random() & 0x1c;
super->animationState = super->direction >> 2;
this->unk_7b = 0;
this->unk_7f = 0;
sub_08023A88(this, super->animationState);
CopyPosition(super, super->child);
CreateFx(super, FX_ROCK, 0);
}
}
void sub_08023A68(Entity*);
void sub_08023AB0(Entity*);
void sub_08023398(MoldwormEntity* this) {
this->unk_7c++;
void sub_08023398(Entity* this) {
this->field_0x7c.BYTES.byte0++;
if (this->field_0x7c.BYTES.byte3 && !sub_08049FDC(this, 1)) {
this->field_0x78.HWORD = 1;
if (this->unk_7f && !sub_08049FDC(super, 1)) {
this->unk_78.HWORD = 1;
}
if (--this->field_0x78.HWORD == 0) {
if (sub_08023A38(GetMetaTileTypeByEntity(this))) {
this->action = 5;
this->field_0x7c.BYTES.byte3 = 0;
COLLISION_OFF(this);
this->hitType = 0x85;
this->child->timer = 1;
if (--this->unk_78.HWORD == 0) {
if (sub_08023A38(GetMetaTileTypeByEntity(super))) {
super->action = 5;
this->unk_7f = 0;
COLLISION_OFF(super);
super->hitType = 0x85;
super->child->timer = 1;
sub_08023A68(this);
CreateFx(this, FX_ROCK, 0);
CreateFx(super, FX_ROCK, 0);
return;
}
this->field_0x78.HWORD = 0x28;
this->unk_78.HWORD = 0x28;
}
if (this->field_0x7c.BYTES.byte3) {
if (this->unk_7f) {
sub_08023AB0(this);
}
if (--this->timer < 3) {
if (this->timer == 0)
this->timer = 25;
if (--super->timer < 3) {
if (super->timer == 0)
super->timer = 25;
} else {
int prevX = this->x.WORD;
int prevY = this->y.WORD;
ProcessMovement0(this);
if (this->x.WORD == prevX && this->y.WORD == prevY) {
this->field_0x7c.BYTES.byte0--;
int prevX = super->x.WORD;
int prevY = super->y.WORD;
ProcessMovement0(super);
if (super->x.WORD == prevX && super->y.WORD == prevY) {
this->unk_7c--;
}
if ((gRoomTransition.frameCount & 7) == 0) {
u32 uVar4;
sub_08004596(this, sub_08049F84(this, 1));
uVar4 = Direction8ToAnimationState(Direction8RoundUp(this->direction));
if (uVar4 != this->animationState) {
this->animationState = uVar4;
InitializeAnimation(this, uVar4 + this->field_0x7a.HALF.HI);
sub_08004596(super, sub_08049F84(super, 1));
uVar4 = Direction8ToAnimationState(Direction8RoundUp(super->direction));
if (uVar4 != super->animationState) {
super->animationState = uVar4;
InitializeAnimation(super, uVar4 + this->unk_7b);
}
}
}
}
void sub_080234A4(Entity* this) {
this->field_0x7c.BYTES.byte0++;
GetNextFrame(this);
if (this->field_0x7c.BYTES.byte3) {
this->action = 6;
this->spriteSettings.draw = 0;
this->field_0x78.HWORD = 300;
void sub_080234A4(MoldwormEntity* this) {
this->unk_7c++;
GetNextFrame(super);
if (this->unk_7f) {
super->action = 6;
super->spriteSettings.draw = 0;
this->unk_78.HWORD = 300;
}
}
void sub_080234D8(Entity* this) {
if (--this->field_0x78.HWORD == 0) {
this->action = 2;
this->palette.b.b0 = 5;
this->direction = Random() & 0x1f;
this->animationState = Direction8ToAnimationState(Direction8RoundUp(this->direction));
sub_08023A88(this, this->animationState);
void sub_080234D8(MoldwormEntity* this) {
if (--this->unk_78.HWORD == 0) {
super->action = 2;
super->palette.b.b0 = 5;
super->direction = Random() & 0x1f;
super->animationState = Direction8ToAnimationState(Direction8RoundUp(super->direction));
sub_08023A88(this, super->animationState);
}
}
void sub_0802351C(Entity* this) {
if ((this->timer != 0) && ((this->type2 == 1) || (gPlayerEntity.frameIndex == 0xff))) {
this->timer = 0;
this->child->action = 3;
this->child->subtimer = this->field_0x80.HALF.LO;
InitializeAnimation(this->child, this->child->animationState + 1);
InitializeAnimation(this, this->animationState);
void sub_0802351C(MoldwormEntity* this) {
if ((super->timer != 0) && ((super->type2 == 1) || (gPlayerEntity.base.frameIndex == 0xff))) {
super->timer = 0;
super->child->action = 3;
super->child->subtimer = this->unk_80;
InitializeAnimation(super->child, super->child->animationState + 1);
InitializeAnimation(super, super->animationState);
}
if (this->field_0x7c.BYTES.byte3 == 0) {
if (this->type2 == 0) {
gPlayerEntity.animationState = this->animationState & 7;
if (this->unk_7f == 0) {
if (super->type2 == 0) {
gPlayerEntity.base.animationState = super->animationState & 7;
gPlayerState.flags |= PL_MOLDWORM_CAPTURED;
PositionRelative(this, &gPlayerEntity, 0, Q_16_16(gUnk_080CBC90[this->animationState & 7]));
gPlayerEntity.spriteOffsetY = -gUnk_080CBC90[this->animationState & 7];
PositionRelative(super, &gPlayerEntity.base, 0, Q_16_16(gUnk_080CBC90[super->animationState & 7]));
gPlayerEntity.base.spriteOffsetY = -gUnk_080CBC90[super->animationState & 7];
}
} else {
this->action = 4;
super->action = 4;
}
}
void sub_080235BC(Entity* this) {
gUnk_080CBC98[this->action](this);
void sub_080235BC(MoldwormEntity* this) {
gUnk_080CBC98[super->action](this);
}
void sub_080235D4(Entity* this) {
void sub_080235D4(MoldwormEntity* this) {
Entity* parent;
this->action = 1;
parent = this->parent;
this->x.HALF.HI = parent->x.HALF.HI;
this->y.HALF.HI = parent->y.HALF.HI;
super->action = 1;
parent = super->parent;
super->x.HALF.HI = parent->x.HALF.HI;
super->y.HALF.HI = parent->y.HALF.HI;
sub_080239F0(this);
if (this->type == 1) {
this->animationState = 0x10;
if (super->type == 1) {
super->animationState = 0x10;
} else {
this->animationState = 0x12;
super->animationState = 0x12;
}
InitializeAnimation(this, this->animationState);
InitializeAnimation(super, super->animationState);
}
void sub_08023604(Entity* this) {
if (((u8*)&this->field_0x78)[this->parent->field_0x7c.BYTES.byte0 & 0xf] != 0x88) {
this->action = 2;
this->timer = 0;
COLLISION_ON(this);
this->spriteSettings.draw = 1;
void sub_08023604(MoldwormEntity* this) {
if (((u8*)&this->unk_78.split.unk_78)[((MoldwormEntity*)super->parent)->unk_7c & 0xf] != 0x88) {
super->action = 2;
super->timer = 0;
COLLISION_ON(super);
super->spriteSettings.draw = 1;
sub_08023644(this);
}
}
void sub_08023644(Entity* this) {
Entity* parent = this->parent;
void sub_08023644(MoldwormEntity* this) {
Entity* parent = super->parent;
if (parent->animIndex == 0x17 && this->timer != 0 && this->x.HALF.HI == parent->x.HALF.HI &&
this->y.HALF.HI == parent->y.HALF.HI) {
this->action = 1;
COLLISION_OFF(this);
this->spriteSettings.draw = 0;
this->child->timer = 1;
if (parent->animIndex == 0x17 && super->timer != 0 && super->x.HALF.HI == parent->x.HALF.HI &&
super->y.HALF.HI == parent->y.HALF.HI) {
super->action = 1;
COLLISION_OFF(super);
super->spriteSettings.draw = 0;
super->child->timer = 1;
sub_080239F0(this);
}
if (parent->field_0x7c.BYTES.byte0 != parent->field_0x7c.BYTES.byte1) {
u8* tmp = &((u8*)&this->field_0x78)[parent->field_0x7c.BYTES.byte0 & 0xf];
this->x.HALF.HI += (*tmp >> 4) - 8;
this->y.HALF.HI += (*tmp & 0xf) - 8;
this->spriteOrientation.flipY = parent->spriteOrientation.flipY;
this->spriteRendering.b3 = parent->spriteRendering.b3;
this->collisionLayer = parent->collisionLayer;
if (((MoldwormEntity*)parent)->unk_7c != ((MoldwormEntity*)parent)->unk_7d) {
u8* tmp = &((u8*)&this->unk_78.split.unk_78)[((MoldwormEntity*)parent)->unk_7c & 0xf];
super->x.HALF.HI += (*tmp >> 4) - 8;
super->y.HALF.HI += (*tmp & 0xf) - 8;
super->spriteOrientation.flipY = parent->spriteOrientation.flipY;
super->spriteRendering.b3 = parent->spriteRendering.b3;
super->collisionLayer = parent->collisionLayer;
}
}
void sub_080236F8(Entity* parent) {
if (--parent->subtimer == 0) {
parent->action = 2;
parent->child->action = 3;
parent->child->subtimer = parent->parent->field_0x80.HALF.LO;
InitializeAnimation(parent->child, parent->child->animationState + 1);
InitializeAnimation(parent, parent->animationState);
void sub_080236F8(MoldwormEntity* this) {
if (--super->subtimer == 0) {
super->action = 2;
super->child->action = 3;
super->child->subtimer = ((MoldwormEntity*)super->parent)->unk_80;
InitializeAnimation(super->child, super->child->animationState + 1);
InitializeAnimation(super, super->animationState);
}
}
void sub_08023730(Entity* this) {
gUnk_080CBCA8[this->action](this);
void sub_08023730(MoldwormEntity* this) {
gUnk_080CBCA8[super->action](this);
}
void sub_08023748(Entity* this) {
void sub_08023748(MoldwormEntity* this) {
Entity* parent;
this->action = 1;
this->animationState = 20;
parent = this->parent;
this->x.HALF.HI = parent->x.HALF.HI;
this->y.HALF.HI = parent->y.HALF.HI;
super->action = 1;
super->animationState = 20;
parent = super->parent;
super->x.HALF.HI = parent->x.HALF.HI;
super->y.HALF.HI = parent->y.HALF.HI;
sub_080239F0(this);
sub_08023A68(this);
}
void sub_0802376C(Entity* this) {
Entity* parent = this->parent;
void sub_0802376C(MoldwormEntity* this) {
Entity* parent = super->parent;
if (parent->spriteSettings.draw == 1 && parent->animIndex < 0x10) {
this->spriteSettings.draw = 1;
GetNextFrame(this);
super->spriteSettings.draw = 1;
GetNextFrame(super);
}
if (((u8*)&this->field_0x78)[parent->field_0x7c.BYTES.byte0 & 0xf] != 0x88) {
this->action = 2;
this->timer = 0;
COLLISION_ON(this);
this->parent->field_0x7c.BYTES.byte3 = 1;
if (((u8*)&this->unk_78.split.unk_78)[((MoldwormEntity*)parent)->unk_7c & 0xf] != 0x88) {
super->action = 2;
super->timer = 0;
COLLISION_ON(super);
((MoldwormEntity*)super->parent)->unk_7f = 1;
sub_08023A88(this, 20);
sub_080237D8(this);
}
}
void sub_080237D8(Entity* this) {
Entity* parent = this->parent;
void sub_080237D8(MoldwormEntity* this) {
Entity* parent = super->parent;
if ((parent->animIndex == 0x17) && (this->timer != 0) && (this->x.HALF.HI == parent->x.HALF.HI) &&
(this->y.HALF.HI == parent->y.HALF.HI)) {
this->action = 1;
COLLISION_OFF(this);
this->spriteSettings.draw = 0;
parent->field_0x7c.BYTES.byte3 = 1;
if ((parent->animIndex == 0x17) && (super->timer != 0) && (super->x.HALF.HI == parent->x.HALF.HI) &&
(super->y.HALF.HI == parent->y.HALF.HI)) {
super->action = 1;
COLLISION_OFF(super);
super->spriteSettings.draw = 0;
((MoldwormEntity*)parent)->unk_7f = 1;
sub_080239F0(this);
sub_08023A68(this);
}
if (parent->field_0x7c.BYTES.byte0 != parent->field_0x7c.BYTES.byte1) {
u8* tmp = &((u8*)&this->field_0x78)[parent->field_0x7c.BYTES.byte0 & 0xf];
this->x.HALF.HI += (*tmp >> 4) - 8;
this->y.HALF.HI += (*tmp & 0xf) - 8;
if (((MoldwormEntity*)parent)->unk_7c != ((MoldwormEntity*)parent)->unk_7d) {
u8* tmp = &((u8*)&this->unk_78.split.unk_78)[((MoldwormEntity*)parent)->unk_7c & 0xf];
super->x.HALF.HI += (*tmp >> 4) - 8;
super->y.HALF.HI += (*tmp & 0xf) - 8;
this->spriteOrientation.flipY = parent->spriteOrientation.flipY;
this->spriteRendering.b3 = parent->spriteRendering.b3;
this->collisionLayer = parent->collisionLayer;
super->spriteOrientation.flipY = parent->spriteOrientation.flipY;
super->spriteRendering.b3 = parent->spriteRendering.b3;
super->collisionLayer = parent->collisionLayer;
}
}
void sub_08023894(Entity* this) {
if (--this->subtimer == 0) {
this->action = 2;
this->parent->field_0x7c.BYTES.byte3 = 1;
InitializeAnimation(this, this->animationState);
if (this->parent->type2 == 0) {
void sub_08023894(MoldwormEntity* this) {
if (--super->subtimer == 0) {
super->action = 2;
((MoldwormEntity*)super->parent)->unk_7f = 1;
InitializeAnimation(super, super->animationState);
if (super->parent->type2 == 0) {
gPlayerState.flags |= PL_MOLDWORM_RELEASED;
gPlayerEntity.x.HALF.HI = this->x.HALF.HI;
gPlayerEntity.y.HALF.HI = this->y.HALF.HI;
gPlayerEntity.direction = DirectionRoundUp(GetFacingDirection(*(Entity**)&this->field_0x74, this));
gPlayerEntity.animationState = gPlayerEntity.direction >> 2;
gPlayerEntity.iframes = 12;
gPlayerEntity.base.x.HALF.HI = super->x.HALF.HI;
gPlayerEntity.base.y.HALF.HI = super->y.HALF.HI;
gPlayerEntity.base.direction = DirectionRoundUp(GetFacingDirection(this->unk_74, super));
gPlayerEntity.base.animationState = gPlayerEntity.base.direction >> 2;
gPlayerEntity.base.iframes = 12;
ModHealth(-0x10);
SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6);
SoundReqClipped(&gPlayerEntity.base, SFX_PLY_VO6);
}
}
}
void sub_0802390C(Entity* this) {
if (this->contactFlags & 0x80) {
Entity* ent = this->child;
void sub_0802390C(MoldwormEntity* this) {
if (super->contactFlags & 0x80) {
Entity* ent = super->child;
do {
ent->iframes = this->iframes;
ent->iframes = super->iframes;
} while (ent = ent->child, ent != NULL);
} else {
Entity* ent = this->child;
Entity* ent = super->child;
do {
if (ent->contactFlags & 0x80) {
u8 bVar2 = 0xff - ent->health;
@@ -431,13 +456,13 @@ void sub_0802390C(Entity* this) {
u32 tmp;
ent->health = 0xff;
tmp = (u8)ent->iframes;
if (this->health >= bVar2) {
this->health -= bVar2;
if (super->health >= bVar2) {
super->health -= bVar2;
} else {
this->health = 0;
super->health = 0;
}
ent = this;
ent = super;
do {
ent->iframes = tmp;
} while (ent = ent->child, ent != NULL);
@@ -448,44 +473,44 @@ void sub_0802390C(Entity* this) {
}
}
void sub_08023990(Entity* this, u32 param_2, u32 param_3) {
void sub_08023990(MoldwormEntity* this, u32 param_2, u32 param_3) {
Entity* ent;
this->action = 3;
this->spriteSettings.draw = 1;
this->palette.b.b0 = 0x5;
this->palette.b.b4 = 0x5;
this->spritePriority.b0 = 7;
this->x.HALF.HI = param_2;
this->y.HALF.HI = param_3;
this->collisionLayer = gPlayerEntity.collisionLayer;
UpdateSpriteForCollisionLayer(this);
InitializeAnimation(this, 0x16);
super->action = 3;
super->spriteSettings.draw = 1;
super->palette.b.b0 = 0x5;
super->palette.b.b4 = 0x5;
super->spritePriority.b0 = 7;
super->x.HALF.HI = param_2;
super->y.HALF.HI = param_3;
super->collisionLayer = gPlayerEntity.base.collisionLayer;
UpdateSpriteForCollisionLayer(super);
InitializeAnimation(super, 0x16);
ent = this->child;
ent = super->child;
do {
sub_080239F0(ent);
CopyPosition(this, ent);
sub_080239F0((MoldwormEntity*)ent);
CopyPosition(super, ent);
} while (ent = ent->child, ent != NULL);
}
void sub_080239F0(Entity* this) {
*(u8*)&this->field_0x78 = 0x88;
*(u8*)((int)&this->field_0x78 + 1) = 0x88;
*(u8*)&this->field_0x7a = 0x88;
*(u8*)((int)&this->field_0x7a + 1) = 0x88;
*(u8*)&this->field_0x7c = 0x88;
*(u8*)((int)&this->field_0x7c + 1) = 0x88;
*(u8*)((int)&this->field_0x7c + 2) = 0x88;
*(u8*)((int)&this->field_0x7c + 3) = 0x88;
*(u8*)&this->field_0x80 = 0x88;
*(u8*)((int)&this->field_0x80 + 1) = 0x88;
*(u8*)&this->field_0x82 = 0x88;
*(u8*)((int)&this->field_0x82 + 1) = 0x88;
*(u8*)&this->cutsceneBeh = 0x88;
*(u8*)((int)&this->cutsceneBeh + 1) = 0x88;
*(u8*)&this->field_0x86 = 0x88;
*(u8*)((int)&this->field_0x86 + 1) = 0x88;
void sub_080239F0(MoldwormEntity* this) {
this->unk_78.split.unk_78 = 0x88;
this->unk_78.split.unk_79 = 0x88;
this->unk_7a = 0x88;
this->unk_7b = 0x88;
this->unk_7c = 0x88;
this->unk_7d = 0x88;
this->unk_7e = 0x88;
this->unk_7f = 0x88;
this->unk_80 = 0x88;
this->unk_81 = 0x88;
this->unk_82 = 0x88;
this->unk_83 = 0x88;
this->unk_84 = 0x88;
this->unk_85 = 0x88;
this->unk_86 = 0x88;
this->unk_87 = 0x88;
}
bool32 sub_08023A38(u32 metaTileType) {
@@ -501,39 +526,39 @@ bool32 sub_08023A38(u32 metaTileType) {
}
}
void sub_08023A68(Entity* this) {
ChangeObjPalette(this, 5);
this->spritePriority.b0 = 7;
InitializeAnimation(this, 0x17);
void sub_08023A68(MoldwormEntity* this) {
ChangeObjPalette(super, 5);
super->spritePriority.b0 = 7;
InitializeAnimation(super, 0x17);
}
void sub_08023A88(Entity* this, u32 unk) {
ChangeObjPalette(this, 0x22);
this->spritePriority.b0 = 4;
InitializeAnimation(this, unk);
void sub_08023A88(MoldwormEntity* this, u32 unk) {
ChangeObjPalette(super, 0x22);
super->spritePriority.b0 = 4;
InitializeAnimation(super, unk);
}
void sub_08023AB0(Entity* this) {
if (this->field_0x7a.HALF.HI == 8) {
if (this->field_0x7c.BYTES.byte2) {
this->field_0x7c.BYTES.byte2--;
} else if (!sub_08023B38(this) || (this->field_0x78.HWORD <= 0x1D)) {
this->hitType = 0x85;
this->field_0x7a.HALF.HI = 0;
this->field_0x7c.BYTES.byte2 = 30;
InitializeAnimation(this, this->animationState);
void sub_08023AB0(MoldwormEntity* this) {
if (this->unk_7b == 8) {
if (this->unk_7e) {
this->unk_7e--;
} else if (!sub_08023B38(this) || (this->unk_78.HWORD <= 0x1d)) {
super->hitType = 0x85;
this->unk_7b = 0;
this->unk_7e = 30;
InitializeAnimation(super, super->animationState);
}
} else if (this->field_0x7c.BYTES.byte2) {
this->field_0x7c.BYTES.byte2--;
} else if (this->field_0x78.HWORD >= 90 && sub_08023B38(this)) {
this->hitType = 0x87;
this->field_0x7a.HALF.HI = 8;
this->field_0x7c.BYTES.byte2 = 10;
InitializeAnimation(this, this->animationState + 8);
} else if (this->unk_7e) {
this->unk_7e--;
} else if (this->unk_78.HWORD >= 90 && sub_08023B38(this)) {
super->hitType = 0x87;
this->unk_7b = 8;
this->unk_7e = 10;
InitializeAnimation(super, super->animationState + 8);
}
}
bool32 sub_08023B38(Entity* this) {
bool32 sub_08023B38(MoldwormEntity* this) {
Entity* entity;
bool32 result;
s32 iVar2;
@@ -545,8 +570,8 @@ bool32 sub_08023B38(Entity* this) {
if (entity == NULL) {
return FALSE;
} else {
tmp1 = (this->x.HALF.HI + (gUnk_080CBCB8[this->animationState * 2 + 0]));
tmp2 = (this->y.HALF.HI + (gUnk_080CBCB8[this->animationState * 2 + 1]));
tmp1 = (super->x.HALF.HI + (gUnk_080CBCB8[super->animationState * 2 + 0]));
tmp2 = (super->y.HALF.HI + (gUnk_080CBCB8[super->animationState * 2 + 1]));
result = FALSE;
if ((entity->x.HALF.HI - tmp1 + 0x14U < 0x29) && (entity->y.HALF.HI - tmp2 + 0x14U < 0x29)) {
result = TRUE;
@@ -556,16 +581,16 @@ bool32 sub_08023B38(Entity* this) {
}
// clang-format off
void (*const Moldworm_Functions[])(Entity*) = {
void (*const Moldworm_Functions[])(MoldwormEntity*) = {
Moldworm_OnTick,
Moldworm_OnCollision,
Moldworm_OnKnockback,
GenericDeath,
GenericConfused,
(void (*)(MoldwormEntity*))GenericDeath,
(void (*)(MoldwormEntity*))GenericConfused,
Moldworm_OnGrabbed,
};
void (*const gUnk_080CBC50[])(Entity*) = {
void (*const gUnk_080CBC50[])(MoldwormEntity*) = {
sub_080231BC,
nullsub_136,
sub_08023288,
@@ -588,17 +613,17 @@ const s8 gUnk_080CBC70[] = {
};
const s8 gUnk_080CBC90[] = {
0xff, 0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0xff,
0xff, 0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0xff,
};
void (*const gUnk_080CBC98[])(Entity*) = {
void (*const gUnk_080CBC98[])(MoldwormEntity*) = {
sub_080235D4,
sub_08023604,
sub_08023644,
sub_080236F8,
};
void (*const gUnk_080CBCA8[])(Entity*) = {
void (*const gUnk_080CBCA8[])(MoldwormEntity*) = {
sub_08023748,
sub_0802376C,
sub_080237D8,
-3
View File
@@ -4,9 +4,6 @@
*
* @brief Mulldozer enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "collision.h"
#include "enemy.h"
+9 -10
View File
@@ -4,7 +4,6 @@
*
* @brief Octorok enemy
*/
#include "enemy.h"
#include "physics.h"
@@ -128,14 +127,14 @@ void Octorok_Move(Entity* this) {
void Octorok_ShootNut(Entity* this) {
GetNextFrame(this);
if (this->frame & 1) {
Entity* ent = CreateProjectileWithParent(this, ROCK_PROJECTILE, 0);
if (ent != NULL) {
Entity* entity = CreateProjectileWithParent(this, ROCK_PROJECTILE, 0);
if (entity != NULL) {
const s8* off;
ent->direction = this->direction;
entity->direction = this->direction;
off = &gOctorokNutOffset[this->direction / 4];
ent->x.HALF.HI += off[0];
ent->y.HALF.HI += off[1];
ent->z.HALF.HI = -3;
entity->x.HALF.HI += off[0];
entity->y.HALF.HI += off[1];
entity->z.HALF.HI = -3;
this->frame &= 0xfe;
EnqueueSFX(SFX_18D);
}
@@ -182,12 +181,12 @@ void Octorok_Turn(Entity* this) {
}
bool32 Octorok_FacesPlayer(Entity* this) {
Entity* ent = sub_08049DF4(1);
Entity* entity = sub_08049DF4(1);
if (ent == NULL)
if (entity == NULL)
return FALSE;
if (DirectionRoundUp(GetFacingDirection(this, ent)) != this->direction)
if (DirectionRoundUp(GetFacingDirection(this, entity)) != this->direction)
return FALSE;
return TRUE;
+39 -39
View File
@@ -4,7 +4,6 @@
*
* @brief Octorok boss enemy
*/
#define NENT_DEPRECATED
#include "enemy/octorokBoss.h"
#include "collision.h"
#include "functions.h"
@@ -113,17 +112,17 @@ void OctorokBoss_Hit(OctorokBossEntity* this) {
if (super->subAction != 3) {
gRoomControls.camera_target = &this->heap->tailObjects[0]->base;
this->heap->field_0x7 = 0x5a;
sub_08078B48();
PausePlayer();
}
} else {
if (this->heap->field_0x7 != 0) {
this->heap->field_0x7--;
sub_08078B48();
PausePlayer();
}
}
OctorokBoss_Hit_SubActions[super->subAction](this);
if (super->subAction > 3) {
sub_08078B48();
PausePlayer();
}
sub_0800445C(super);
SetAffineInfo(super, this->unk_76, this->unk_74, this->angle.HWORD);
@@ -136,7 +135,7 @@ void OctorokBoss_Hit_SubAction0(OctorokBossEntity* this) {
if (this->bossPhase == 4) {
super->subAction = 4;
gPauseMenuOptions.disabled = 1;
sub_08078B48();
PausePlayer();
SoundReq(SFX_BOSS_DIE);
} else {
if (IS_FROZEN(this) == FALSE) {
@@ -230,7 +229,7 @@ void OctorokBoss_Hit_SubAction2(OctorokBossEntity* this) {
} else {
super->subAction = 3;
this->timer = 150;
gRoomControls.camera_target = &gPlayerEntity;
gRoomControls.camera_target = &gPlayerEntity.base;
}
}
@@ -391,9 +390,9 @@ void OctorokBoss_Init(OctorokBossEntity* this) {
super->action = INTRO;
super->subAction = 0;
this->timer = 0x3c;
gPlayerEntity.spriteSettings.draw = 0;
gPlayerEntity.x.HALF.HI = super->x.HALF.HI;
gPlayerEntity.y.HALF.HI = super->y.HALF.HI - 0xa0;
gPlayerEntity.base.spriteSettings.draw = 0;
gPlayerEntity.base.x.HALF.HI = super->x.HALF.HI;
gPlayerEntity.base.y.HALF.HI = super->y.HALF.HI - 0xa0;
gRoomControls.camera_target = super;
break;
case LEG_BR:
@@ -443,7 +442,7 @@ void OctorokBoss_Intro(OctorokBossEntity* this) {
OctorokBoss_Intro_SubAction0, OctorokBoss_Intro_SubAction1, OctorokBoss_Intro_SubAction2,
OctorokBoss_Intro_SubAction3, OctorokBoss_Intro_SubAction4, OctorokBoss_Intro_SubAction5,
};
sub_08078B48();
PausePlayer();
gPauseMenuOptions.disabled = 1;
sub_08036F60(this);
OctorokBoss_Intro_SubActions[super->subAction](this);
@@ -478,8 +477,8 @@ void OctorokBoss_Intro_SubAction2(OctorokBossEntity* this) {
if (this->timer-- == 0) {
super->subAction = 3;
this->timer = 60;
gPlayerEntity.spriteSettings.draw |= 1;
gRoomControls.camera_target = &gPlayerEntity;
gPlayerEntity.base.spriteSettings.draw |= 1;
gRoomControls.camera_target = &gPlayerEntity.base;
gRoomControls.scrollSpeed = 1;
}
}
@@ -488,8 +487,8 @@ void OctorokBoss_Intro_SubAction3(OctorokBossEntity* this) {
// Move the camera to the player
if (this->timer-- == 0) {
// Move the player inside the arena
gPlayerEntity.direction = 0x10;
gPlayerEntity.animationState = 4;
gPlayerEntity.base.direction = 0x10;
gPlayerEntity.base.animationState = 4;
sub_08078AC0(0x1e, 0, 0);
this->timer = 60;
super->subAction = 4;
@@ -501,22 +500,22 @@ void OctorokBoss_Intro_SubAction4(OctorokBossEntity* this) {
super->subAction = 5;
this->timer = 45;
// Make the player look towards the exit
gPlayerEntity.animationState = 0;
gPlayerEntity.base.animationState = 0;
} else {
// Spawn exclamation bubble at a certain time
if (this->timer == 0x1e) {
CreateSpeechBubbleExclamationMark(&gPlayerEntity, 0xc, -0x18);
CreateSpeechBubbleExclamationMark(&gPlayerEntity.base, 0xc, -0x18);
}
}
}
void OctorokBoss_Intro_SubAction5(OctorokBossEntity* this) {
if (gPlayerEntity.animationState == 4) {
if (gPlayerEntity.base.animationState == 4) {
if (this->timer++ > 0x1e) {
// Play boss theme, enable control and switch to main action
super->action = ACTION1;
super->subAction = 0;
gRoomControls.scrollSpeed = gPlayerEntity.animationState;
gRoomControls.scrollSpeed = gPlayerEntity.base.animationState;
OctorokBoss_SetAttackTimer(this);
gPauseMenuOptions.disabled = 0;
SoundReq(BGM_BOSS_THEME);
@@ -524,7 +523,7 @@ void OctorokBoss_Intro_SubAction5(OctorokBossEntity* this) {
} else {
if (this->timer-- == 0) {
// Player looks back towards Octorok
gPlayerEntity.animationState = 4;
gPlayerEntity.base.animationState = 4;
}
}
}
@@ -692,7 +691,7 @@ void OctorokBoss_Action1_AimTowardsPlayer(OctorokBossEntity* this) {
s32 tmp2;
tmp1 =
(u8)(CalculateDirectionFromOffsets(gPlayerEntity.x.WORD - super->x.WORD, gPlayerEntity.y.WORD - super->y.WORD) -
(u8)(CalculateDirectionFromOffsets(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD) -
(((u8)(-this->angle.HALF.HI) ^ 0x80)));
if (IS_FROZEN(this) == FALSE) {
tmp2 = 8;
@@ -795,13 +794,13 @@ void OctorokBoss_Action1_Attack(OctorokBossEntity* this) {
sub_08036FE4(this);
if (this->unk_80 != 0) {
gPlayerEntity.spriteSettings.draw = 0;
gPlayerEntity.flags &= ~ENT_COLLIDE;
gPlayerEntity.collisionLayer = 2;
sub_08078B48();
gPlayerEntity.base.spriteSettings.draw = 0;
gPlayerEntity.base.flags &= ~ENT_COLLIDE;
gPlayerEntity.base.collisionLayer = 2;
PausePlayer();
PutAwayItems();
gPlayerEntity.parent = super;
sub_08036914(&gPlayerEntity, (u8) - (this->angle.HALF.HI + 0x80), 0x3800);
gPlayerEntity.base.parent = super;
sub_08036914(&gPlayerEntity.base, (u8) - (this->angle.HALF.HI + 0x80), 0x3800);
}
}
@@ -901,17 +900,18 @@ void OctorokBoss_ExecuteAttackVacuum(OctorokBossEntity* this) {
if (this->unk_80 == 0) {
super->direction =
CalculateDirectionFromOffsets(gPlayerEntity.x.WORD - super->x.WORD, gPlayerEntity.y.WORD - super->y.WORD);
CalculateDirectionFromOffsets(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD);
tmp = ((u8) - (this->angle.HALF.HI + 0x80)) - super->direction;
if (tmp < 0) {
tmp = -tmp;
}
if (tmp < 0x10) {
if (sub_0806FC80(super, &gPlayerEntity, 0xf0) != 0) {
if (sub_0806FC80(super, &gPlayerEntity.base, 0xf0) != 0) {
if ((gPlayerState.flags & PL_FROZEN) == 0) {
if ((gPlayerEntity.flags & PL_MINISH) != 0) {
LinearMoveAngle(&gPlayerEntity, 0x280, -this->angle.HALF.HI);
if (sub_0806FC80(super, &gPlayerEntity, 0x48) != 0) {
if ((gPlayerEntity.base.flags & PL_MINISH) != 0) {
LinearMoveAngle(&gPlayerEntity.base, 0x280, -this->angle.HALF.HI);
if (sub_0806FC80(super, &gPlayerEntity.base, 0x48) != 0) {
this->unk_80 = 1;
this->timer = 2;
this->heap->targetAngle = CalculateDirectionFromOffsets(
@@ -942,9 +942,9 @@ void OctorokBoss_ExecuteAttackVacuum(OctorokBossEntity* this) {
this->unk_80 = 0;
this->angularSpeed.HWORD = 0x100;
this->heap->mouthObject->timer++;
gPlayerEntity.spriteSettings.draw = 1;
gPlayerEntity.flags &= ~ENT_COLLIDE;
gPlayerEntity.collisionLayer = 1;
gPlayerEntity.base.spriteSettings.draw = 1;
gPlayerEntity.base.flags &= ~ENT_COLLIDE;
gPlayerEntity.base.collisionLayer = 1;
sub_080792BC(0x400, (u32)(-(this->angle.HALF.HI + 0x80) * 0x1000000) >> 0x1b, 0x30);
OctorokBoss_SetAttackTimer(this);
SoundReq(SFX_EF);
@@ -959,8 +959,8 @@ void OctorokBoss_ExecuteAttackVacuum(OctorokBossEntity* this) {
} else {
this->timer--;
if ((gPlayerState.flags == PL_FROZEN) && (this->timer == 0x3c)) {
tmp = CalculateDirectionFromOffsets(gPlayerEntity.x.WORD - super->x.WORD,
gPlayerEntity.y.WORD - super->y.WORD);
tmp = CalculateDirectionFromOffsets(gPlayerEntity.base.x.WORD - super->x.WORD,
gPlayerEntity.base.y.WORD - super->y.WORD);
if ((u8)((tmp - ((u8) - this->angle.HALF.HI ^ 0x80))) > 0x80) {
this->heap->targetAngle = this->angle.HALF.HI + 0x30;
} else {
@@ -1088,9 +1088,9 @@ void OctorokBoss_Burning_SubAction2(OctorokBossEntity* this) {
void sub_080368D8(OctorokBossEntity* this) {
if (this->unk_80 != 0) {
gPlayerEntity.spriteSettings.draw = 1;
gPlayerEntity.flags |= ENT_COLLIDE;
gPlayerEntity.collisionLayer = 1;
gPlayerEntity.base.spriteSettings.draw = 1;
gPlayerEntity.base.flags |= ENT_COLLIDE;
gPlayerEntity.base.collisionLayer = 1;
}
this->unk_76 = 0xa0;
this->unk_74 = 0xa0;
+10 -4
View File
@@ -1,6 +1,12 @@
/**
* @file octorokGolden.c
* @ingroup Enemies
*
* @brief Golden Octorock enemy
*/
#include "collision.h"
#include "map.h"
#include "enemy.h"
#include "map.h"
#include "player.h"
#include "item.h"
@@ -96,7 +102,7 @@ static void sub_08037D54(Entity* this) {
this->animationState |= 0xff;
sub_08037E14(this);
} else {
u32 dir = GetFacingDirection(this, &gPlayerEntity);
u32 dir = GetFacingDirection(this, &gPlayerEntity.base);
this->direction = (dir + 4) & 0x18;
this->animationState = this->direction >> 3;
InitializeAnimation(this, this->animationState + 4);
@@ -110,7 +116,7 @@ void sub_08037E14(Entity* this) {
const s8* ptr;
s32 x, y;
this->timer = 8;
dir = (GetFacingDirection(this, &gPlayerEntity) + 4) & 0x18;
dir = (GetFacingDirection(this, &gPlayerEntity.base) + 4) & 0x18;
layer = (u8*)GetLayerByIndex(this->collisionLayer)->collisionData;
ptr = gUnk_080CF498 + (dir >> 2);
x = this->x.HALF.HI + *ptr;
@@ -129,7 +135,7 @@ void sub_08037E14(Entity* this) {
}
bool32 sub_08037E90(Entity* this) {
u32 dir = sub_0804A044(this, &gPlayerEntity, 8);
u32 dir = sub_0804A044(this, &gPlayerEntity.base, 8);
if (dir != 0xff) {
this->action = 2;
this->timer = 3;
+237 -229
View File
@@ -4,21 +4,29 @@
*
* @brief Peahat enemy
*/
#include "enemy.h"
#include "room.h"
#include "physics.h"
#include "room.h"
extern void (*const Peahat_Functions[])(Entity*);
extern void (*const gPeahatPropellerFunctions[])(Entity*);
extern void (*const gPeahatActions[])(Entity*);
extern void (*const gUnk_080CA5BC[])(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[24];
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
/*0x83*/ u8 unk_83;
} PeahatEntity;
extern void (*const Peahat_Functions[])(PeahatEntity*);
extern void (*const gPeahatPropellerFunctions[])(PeahatEntity*);
extern void (*const gPeahatActions[])(PeahatEntity*);
extern void (*const gUnk_080CA5BC[])(PeahatEntity*);
extern const s8 gPeahatFlightHeights[];
extern const s8 gUnk_080CA5D4[];
void sub_080205F8(Entity*);
void sub_08020604(Entity*);
void sub_080205F8(PeahatEntity* this);
void sub_08020604(PeahatEntity* this);
extern Entity* gUnk_020000B0;
@@ -36,357 +44,357 @@ enum {
PeahatAnimation_RepairPropeller,
};
void Peahat(Entity* this) {
if (this->type == PeahatForm_Torso) {
EnemyFunctionHandler(this, Peahat_Functions);
SetChildOffset(this, 0, 1, -0x10);
void Peahat(PeahatEntity* this) {
if (super->type == PeahatForm_Torso) {
EnemyFunctionHandler(super, (EntityActionArray)Peahat_Functions);
SetChildOffset(super, 0, 1, -0x10);
} else {
gPeahatPropellerFunctions[this->action](this);
gPeahatPropellerFunctions[super->action](this);
}
}
void Peahat_OnTick(Entity* this) {
gPeahatActions[this->action](this);
if (this->field_0x80.HALF.HI)
this->z.HALF.HI = gPeahatFlightHeights[(this->subtimer++ & 0x30) >> 4];
void Peahat_OnTick(PeahatEntity* this) {
gPeahatActions[super->action](this);
if (this->unk_81)
super->z.HALF.HI = gPeahatFlightHeights[(super->subtimer++ & 0x30) >> 4];
}
void Peahat_OnCollision(Entity* this) {
if (this->field_0x82.HALF.LO) {
if (this->contactFlags == 0x94) {
Entity* ent = CreateEnemy(PEAHAT, PeahatForm_Propeller);
if (ent != NULL) {
CopyPosition(this, ent);
ent->z.HALF.HI -= 8;
void Peahat_OnCollision(PeahatEntity* this) {
if (this->unk_82) {
if (super->contactFlags == 0x94) {
Entity* entity = CreateEnemy(PEAHAT, PeahatForm_Propeller);
if (entity != NULL) {
CopyPosition(super, entity);
entity->z.HALF.HI -= 8;
}
this->field_0x82.HALF.LO = 0;
this->animationState = PeahatAnimation_SlicedPropeller;
this->action = 5;
this->speed = 0x80;
this->iframes = -30;
this->field_0x80.HALF.HI = 0;
InitializeAnimation(this, this->animationState);
} else if (this->contactFlags == 0x9b) {
this->animationState = PeahatAnimation_BrokenPropeller;
this->action = 5;
this->speed = 0x80;
this->iframes = -30;
this->field_0x80.HALF.HI = 0;
InitializeAnimation(this, this->animationState);
} else if (this->contactFlags == 0x80) {
if (this->animationState == PeahatAnimation_Flying) {
this->action = 1;
this->timer = 30;
this->speed = 0x80;
this->direction = -1;
this->field_0x82.HALF.HI = 0x78;
GetNextFrame(this);
this->unk_82 = 0;
super->animationState = PeahatAnimation_SlicedPropeller;
super->action = 5;
super->speed = 0x80;
super->iframes = -30;
this->unk_81 = 0;
InitializeAnimation(super, super->animationState);
} else if (super->contactFlags == 0x9b) {
super->animationState = PeahatAnimation_BrokenPropeller;
super->action = 5;
super->speed = 0x80;
super->iframes = -30;
this->unk_81 = 0;
InitializeAnimation(super, super->animationState);
} else if (super->contactFlags == 0x80) {
if (super->animationState == PeahatAnimation_Flying) {
super->action = 1;
super->timer = 30;
super->speed = 0x80;
super->direction = -1;
this->unk_83 = 0x78;
GetNextFrame(super);
}
}
}
if (this->confusedTime)
Create0x68FX(this, FX_STARS);
if (super->confusedTime)
Create0x68FX(super, FX_STARS);
EnemyFunctionHandlerAfterCollision(this, Peahat_Functions);
EnemyFunctionHandlerAfterCollision(super, Peahat_Functions);
}
void Peahat_OnGrabbed(Entity* this) {
if (2 >= this->subAction && !sub_0806F520(this))
void Peahat_OnGrabbed(PeahatEntity* this) {
if (2 >= super->subAction && !sub_0806F520(super))
return;
gUnk_080CA5BC[this->subAction](this);
gUnk_080CA5BC[super->subAction](this);
}
void sub_080200B4(Entity* this) {
this->subAction = 1;
this->gustJarTolerance = 60;
if (this->animationState == PeahatAnimation_Flying) {
this->animationState = PeahatAnimation_BrokenPropeller;
this->action = 5;
this->hitType = 0x71;
this->field_0x80.HALF.HI = 0;
InitializeAnimation(this, this->animationState);
void sub_080200B4(PeahatEntity* this) {
super->subAction = 1;
super->gustJarTolerance = 60;
if (super->animationState == PeahatAnimation_Flying) {
super->animationState = PeahatAnimation_BrokenPropeller;
super->action = 5;
super->hitType = 0x71;
this->unk_81 = 0;
InitializeAnimation(super, super->animationState);
}
}
void sub_080200E4(Entity* this) {
sub_0806F4E8(this);
void sub_080200E4(PeahatEntity* this) {
sub_0806F4E8(super);
}
void sub_080200EC(Entity* this) {
sub_0806F3E4(this);
void sub_080200EC(PeahatEntity* this) {
sub_0806F3E4(super);
}
void sub_080200F4(Entity* this) {
COLLISION_OFF(this);
void sub_080200F4(PeahatEntity* this) {
COLLISION_OFF(super);
}
void nullsub_5(Entity* this) {
void nullsub_5(PeahatEntity* this) {
}
void sub_08020104(Entity* this) {
if (this->flags & ENT_COLLIDE) {
COLLISION_ON(this);
this->gustJarState &= 0xfb;
void sub_08020104(PeahatEntity* this) {
if (super->flags & ENT_COLLIDE) {
COLLISION_ON(super);
super->gustJarState &= 0xfb;
} else {
this->health = 0;
super->health = 0;
}
}
void Peahat_Initialize(Entity* this) {
sub_0804A720(this);
this->action = 1;
this->timer = 16;
this->subtimer = Random();
this->direction = Random() & 0x1f;
this->gustJarFlags = 18;
this->field_0x80.HALF.LO = (Random() & 1) ? 2 : -2;
this->field_0x80.HALF.HI = 1;
this->field_0x82.HALF.LO = 1;
this->animationState = PeahatAnimation_Flying;
InitializeAnimation(this, this->animationState);
void Peahat_Initialize(PeahatEntity* this) {
sub_0804A720(super);
super->action = 1;
super->timer = 16;
super->subtimer = Random();
super->direction = Random() & 0x1f;
super->gustJarFlags = 18;
this->unk_80 = (Random() & 1) ? 2 : -2;
this->unk_81 = 1;
this->unk_82 = 1;
super->animationState = PeahatAnimation_Flying;
InitializeAnimation(super, super->animationState);
}
void Peahat_Fly(Entity* this) {
if (this->field_0x82.HALF.HI)
this->field_0x82.HALF.HI--;
void Peahat_Fly(PeahatEntity* this) {
if (this->unk_83)
this->unk_83--;
if (sub_08049FDC(this, 1)) {
if (this->field_0x82.HALF.HI == 0 && (this->subtimer & 0xf) == 0 && sub_08049F1C(this, gUnk_020000B0, 0x30)) {
this->action = 2;
this->subAction = Random() & 3;
this->timer = 60;
this->speed = 160;
if (sub_08049FDC(super, 1)) {
if (this->unk_83 == 0 && (super->subtimer & 0xf) == 0 && sub_08049F1C(super, gUnk_020000B0, 0x30)) {
super->action = 2;
super->subAction = Random() & 3;
super->timer = 60;
super->speed = 160;
}
}
if (--this->timer == 0) {
this->timer = 16;
if (--super->timer == 0) {
super->timer = 16;
sub_08020604(this);
if ((Random() & 3) == 0) {
this->field_0x80.HALF.LO = (Random() & 1) ? 2 : -2;
this->unk_80 = (Random() & 1) ? 2 : -2;
}
}
ProcessMovement2(this);
GetNextFrame(this);
ProcessMovement2(super);
GetNextFrame(super);
}
void Peahat_ChargeStart(Entity* this) {
if (sub_08049FDC(this, 1)) {
if (--this->timer) {
UpdateAnimationVariableFrames(this, 4 - ((this->timer >> 4) & 0x3));
void Peahat_ChargeStart(PeahatEntity* this) {
if (sub_08049FDC(super, 1)) {
if (--super->timer) {
UpdateAnimationVariableFrames(super, 4 - ((super->timer >> 4) & 0x3));
return;
} else {
this->action = 3;
this->timer = 120;
this->speed = 192;
this->direction =
(GetFacingDirection(this, gUnk_020000B0) + gUnk_080CA5D4[Random() & 1]) & (0x3 | DirectionNorthWest);
super->action = 3;
super->timer = 120;
super->speed = 192;
super->direction =
(GetFacingDirection(super, gUnk_020000B0) + gUnk_080CA5D4[Random() & 1]) & (0x3 | DirectionNorthWest);
}
} else {
sub_080205F8(this);
}
UpdateAnimationVariableFrames(this, 4);
UpdateAnimationVariableFrames(super, 4);
}
void Peahat_ChargeTarget(Entity* this) {
if (sub_08049FDC(this, 1)) {
if (--this->timer == 0) {
void Peahat_ChargeTarget(PeahatEntity* this) {
if (sub_08049FDC(super, 1)) {
if (--super->timer == 0) {
sub_080205F8(this);
}
if (this->timer > 60) {
if (this->timer & 1)
this->speed += 4;
if (super->timer > 60) {
if (super->timer & 1)
super->speed += 4;
if ((gRoomTransition.frameCount & 3) == 0)
sub_08004596(this, GetFacingDirection(this, gUnk_020000B0));
sub_08004596(super, GetFacingDirection(super, gUnk_020000B0));
}
ProcessMovement2(this);
ProcessMovement2(super);
} else {
sub_080205F8(this);
}
UpdateAnimationVariableFrames(this, 4);
UpdateAnimationVariableFrames(super, 4);
}
void Peahat_ChargeEnd(Entity* this) {
if (--this->timer == 0) {
this->action = 1;
this->timer = 1;
this->speed = 128;
this->field_0x82.HALF.HI = 120;
GetNextFrame(this);
void Peahat_ChargeEnd(PeahatEntity* this) {
if (--super->timer == 0) {
super->action = 1;
super->timer = 1;
super->speed = 128;
this->unk_83 = 120;
GetNextFrame(super);
} else {
if (this->timer & 1)
this->speed -= 8;
if (super->timer & 1)
super->speed -= 8;
ProcessMovement2(this);
UpdateAnimationVariableFrames(this, 4);
ProcessMovement2(super);
UpdateAnimationVariableFrames(super, 4);
}
}
#define DIR_NONE 0xff
void Peahat_Stunned(Entity* this) {
switch (this->animationState) {
void Peahat_Stunned(PeahatEntity* this) {
switch (super->animationState) {
default:
if (sub_080044EC(this, 0x1800) == 0) {
this->action = 6;
this->timer = 240;
this->subtimer = 10;
this->hitType = 0x71;
if (sub_080044EC(super, 0x1800) == 0) {
super->action = 6;
super->timer = 240;
super->subtimer = 10;
super->hitType = 0x71;
}
if (this->direction == DIR_NONE)
this->direction = this->knockbackDirection;
if (super->direction == DIR_NONE)
super->direction = super->knockbackDirection;
ProcessMovement0(this);
GetNextFrame(this);
ProcessMovement0(super);
GetNextFrame(super);
break;
case PeahatAnimation_SlicedPropeller:
GravityUpdate(this, Q_8_8(28.0));
if (this->z.HALF.HI == 0) {
this->action = 7;
this->timer = 150;
this->subtimer = 10;
this->hitType = 0x71;
GravityUpdate(super, Q_8_8(28.0));
if (super->z.HALF.HI == 0) {
super->action = 7;
super->timer = 150;
super->subtimer = 10;
super->hitType = 0x71;
}
break;
};
}
void Peahat_RepairPropeller(Entity* this) {
if ((this->subtimer != 0) && (--this->subtimer == 0)) {
Create0x68FX(this, FX_STARS);
void Peahat_RepairPropeller(PeahatEntity* this) {
if ((super->subtimer != 0) && (--super->subtimer == 0)) {
Create0x68FX(super, FX_STARS);
}
if (sub_0800442E(this) || (--this->timer == 0)) {
this->action = 9;
this->zVelocity = Q_16_16(1.5);
this->direction = Random() & 0x1f;
sub_0804AA1C(this);
this->animationState = PeahatAnimation_RepairPropeller;
InitializeAnimation(this, this->animationState);
if (sub_0800442E(super) || (--super->timer == 0)) {
super->action = 9;
super->zVelocity = Q_16_16(1.5);
super->direction = Random() & 0x1f;
sub_0804AA1C(super);
super->animationState = PeahatAnimation_RepairPropeller;
InitializeAnimation(super, super->animationState);
}
}
void Peahat_Recover(Entity* this) {
if ((this->subtimer != 0) && (--this->subtimer == 0)) {
Create0x68FX(this, FX_STARS);
void Peahat_Recover(PeahatEntity* this) {
if ((super->subtimer != 0) && (--super->subtimer == 0)) {
Create0x68FX(super, FX_STARS);
}
if (sub_0800442E(this) || (--this->timer == 0)) {
this->action = 8;
this->timer = 240;
this->direction = Random() & 0x1f;
sub_0804AA1C(this);
if (sub_0800442E(super) || (--super->timer == 0)) {
super->action = 8;
super->timer = 240;
super->direction = Random() & 0x1f;
sub_0804AA1C(super);
}
}
void Peahat_Hop(Entity* this) {
GetNextFrame(this);
if (--this->timer == 0) {
if (this->frame & ANIM_DONE) {
this->action = 9;
this->zVelocity = Q_16_16(1.5);
this->animationState = PeahatAnimation_NewPropeller;
InitializeAnimation(this, this->animationState);
void Peahat_Hop(PeahatEntity* this) {
GetNextFrame(super);
if (--super->timer == 0) {
if (super->frame & ANIM_DONE) {
super->action = 9;
super->zVelocity = Q_16_16(1.5);
super->animationState = PeahatAnimation_NewPropeller;
InitializeAnimation(super, super->animationState);
} else {
this->timer = 1;
super->timer = 1;
}
}
if (this->frame & 2) {
this->frame &= ~2;
this->direction = Random() & 0x1f;
if (super->frame & 2) {
super->frame &= ~2;
super->direction = Random() & 0x1f;
}
if (this->frame & 1) {
sub_0800442E(this);
if (super->frame & 1) {
sub_0800442E(super);
} else {
ProcessMovement0(this);
ProcessMovement0(super);
}
}
void Peahat_Takeoff(Entity* this) {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 1;
this->hitType = 0x70;
this->field_0x82.HALF.LO = 1;
this->field_0x80.HALF.HI = 1;
this->animationState = PeahatAnimation_Flying;
InitializeAnimation(this, this->animationState);
} else if (this->frame & 1) {
sub_0800442E(this);
void Peahat_Takeoff(PeahatEntity* this) {
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 1;
super->hitType = 0x70;
this->unk_82 = 1;
this->unk_81 = 1;
super->animationState = PeahatAnimation_Flying;
InitializeAnimation(super, super->animationState);
} else if (super->frame & 1) {
sub_0800442E(super);
} else {
GravityUpdate(this, Q_8_8(28.0));
ProcessMovement0(this);
GravityUpdate(super, Q_8_8(28.0));
ProcessMovement0(super);
}
}
void PeahatPropeller_Initialize(Entity* this) {
this->action = 1;
this->timer = 240;
this->subtimer = 40;
this->spriteSettings.draw = 1;
this->spriteRendering.b3 = 1;
this->spriteOrientation.flipY = 1;
this->spriteSettings.shadow = 0;
this->speed = 0x20;
this->direction = (Random() & 0x10) + 8;
InitializeAnimation(this, PeahatAnimation_Propeller);
void PeahatPropeller_Initialize(PeahatEntity* this) {
super->action = 1;
super->timer = 240;
super->subtimer = 40;
super->spriteSettings.draw = 1;
super->spriteRendering.b3 = 1;
super->spriteOrientation.flipY = 1;
super->spriteSettings.shadow = 0;
super->speed = 0x20;
super->direction = (Random() & 0x10) + 8;
InitializeAnimation(super, PeahatAnimation_Propeller);
}
void PeahatPropeller_Fly(Entity* this) {
GetNextFrame(this);
if (--this->timer == 0) {
DeleteEntity(this);
void PeahatPropeller_Fly(PeahatEntity* this) {
GetNextFrame(super);
if (--super->timer == 0) {
DeleteEntity(super);
} else {
if (this->timer < 60)
this->spriteSettings.draw ^= 1;
if (super->timer < 60)
super->spriteSettings.draw ^= 1;
this->z.WORD -= Q_16_16(0.75);
LinearMoveUpdate(this);
if (--this->subtimer == 0) {
this->subtimer = 40;
this->direction = (Random() & 0x10) + 8;
super->z.WORD -= Q_16_16(0.75);
LinearMoveUpdate(super);
if (--super->subtimer == 0) {
super->subtimer = 40;
super->direction = (Random() & 0x10) + 8;
}
}
}
void sub_080205F8(Entity* this) {
this->action = 4;
this->timer = 60;
void sub_080205F8(PeahatEntity* this) {
super->action = 4;
super->timer = 60;
}
void sub_08020604(Entity* this) {
if (!sub_08049FA0(this) && (Random() & 3)) {
this->direction = sub_08049EE4(this);
void sub_08020604(PeahatEntity* this) {
if (!sub_08049FA0(super) && (Random() & 3)) {
super->direction = sub_08049EE4(super);
} else {
this->direction += this->field_0x80.HALF.LO;
this->direction &= (0x3 | DirectionNorthWest);
super->direction += this->unk_80;
super->direction &= (0x3 | DirectionNorthWest);
}
}
// clang-format off
void (*const Peahat_Functions[])(Entity*) = {
void (*const Peahat_Functions[])(PeahatEntity*) = {
Peahat_OnTick,
Peahat_OnCollision,
GenericKnockback,
GenericDeath,
GenericConfused,
(void (*)(PeahatEntity*))GenericKnockback,
(void (*)(PeahatEntity*))GenericDeath,
(void (*)(PeahatEntity*))GenericConfused,
Peahat_OnGrabbed,
};
void (*const gPeahatPropellerFunctions[])(Entity*) = {
void (*const gPeahatPropellerFunctions[])(PeahatEntity*) = {
PeahatPropeller_Initialize,
PeahatPropeller_Fly,
};
void (*const gPeahatActions[])(Entity*) = {
void (*const gPeahatActions[])(PeahatEntity*) = {
Peahat_Initialize,
Peahat_Fly,
Peahat_ChargeStart,
@@ -403,7 +411,7 @@ const s8 gPeahatFlightHeights[] = {
-5, -6, -7, -6,
};
void (*const gUnk_080CA5BC[])(Entity*) = {
void (*const gUnk_080CA5BC[])(PeahatEntity*) = {
sub_080200B4,
sub_080200E4,
sub_080200EC,
+426 -410
View File
File diff suppressed because it is too large Load Diff
+294 -280
View File
@@ -4,32 +4,47 @@
*
* @brief Puffstool enemy
*/
#include "collision.h"
#include "enemy.h"
#include "object.h"
#include "tiles.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[16];
/*0x78*/ u16 unk_78;
/*0x7a*/ u8 unk_7a;
/*0x7b*/ u8 unk_7b;
/*0x7c*/ u16 unk_7c;
/*0x7e*/ u16 unk_7e;
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
/*0x83*/ u8 unused2[1];
/*0x84*/ u16 unk_84;
/*0x86*/ u16 unk_86;
} PuffstoolEntity;
extern u8 gMapMetaTileTypeToCollisionData[];
bool32 sub_080258C4(Entity*);
void sub_08025B18(Entity*);
void sub_08025C2C(Entity*);
void sub_08025BD4(Entity*);
void sub_080256B4(Entity*);
bool32 sub_08025C44(Entity*);
u32 sub_08025C60(Entity*);
bool32 sub_0802571C(Entity*);
void sub_08025A54(Entity*);
void sub_08025AE8(Entity*);
bool32 sub_0802594C(Entity*, u32);
bool32 sub_080257EC(Entity*, u32, u32);
bool32 sub_080258C4(PuffstoolEntity*);
void sub_08025B18(PuffstoolEntity*);
void sub_08025C2C(PuffstoolEntity*);
void sub_08025BD4(PuffstoolEntity*);
void sub_080256B4(PuffstoolEntity*);
bool32 sub_08025C44(PuffstoolEntity*);
u32 sub_08025C60(PuffstoolEntity*);
bool32 sub_0802571C(PuffstoolEntity*);
void sub_08025A54(PuffstoolEntity*);
void sub_08025AE8(PuffstoolEntity*);
bool32 sub_0802594C(PuffstoolEntity*, u32);
bool32 sub_080257EC(PuffstoolEntity*, u32, u32);
bool32 sub_08025AB8(u32, u32);
extern void (*const Puffstool_Functions[])(Entity*);
extern void (*const gUnk_080CBFB4[])(Entity*);
extern void (*const Puffstool_Functions[])(PuffstoolEntity*);
extern void (*const gUnk_080CBFB4[])(PuffstoolEntity*);
extern const u8 gUnk_080CBFE8[];
extern void (*const gUnk_080CBFEC[])(Entity*);
extern void (*const gUnk_080CBFEC[])(PuffstoolEntity*);
extern const u8 gUnk_080CBFF8[];
extern const u16 gUnk_080CC000[];
extern const s8 gUnk_080CC020[];
@@ -40,277 +55,276 @@ extern const s8 gUnk_080CC0A8[];
extern const s8 gUnk_080CC0BA[];
extern const s8 gUnk_080CC0C2[];
void Puffstool(Entity* this) {
EnemyFunctionHandler(this, Puffstool_Functions);
SetChildOffset(this, 0, 1, -0x10);
void Puffstool(PuffstoolEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Puffstool_Functions);
SetChildOffset(super, 0, 1, -0x10);
}
void Puffstool_OnTick(Entity* this) {
gUnk_080CBFB4[this->action](this);
void Puffstool_OnTick(PuffstoolEntity* this) {
gUnk_080CBFB4[super->action](this);
}
void Puffstool_OnCollide(Entity* this) {
void Puffstool_OnCollide(PuffstoolEntity* this) {
u8 tmp;
switch (this->contactFlags & 0x7f) {
switch (super->contactFlags & 0x7f) {
case 0 ... 3:
/* ... */
break;
case 0x1b:
sub_0804AA1C(this);
sub_0804AA1C(super);
tmp = gUnk_080CBFE8[(*(Entity**)&this->contactedEntity)->type];
if (tmp < this->field_0x82.HALF.LO) {
this->field_0x82.HALF.LO -= gUnk_080CBFE8[(*(Entity**)&this->contactedEntity)->type];
tmp = gUnk_080CBFE8[(*(Entity**)&super->contactedEntity)->type];
if (tmp < this->unk_82) {
this->unk_82 -= gUnk_080CBFE8[(*(Entity**)&super->contactedEntity)->type];
} else {
this->cutsceneBeh.HWORD = 0x294;
this->hitType = 0x83;
this->field_0x82.HALF.LO = 0;
ChangeObjPalette(this, 0x7c);
this->unk_84 = 0x294;
super->hitType = 0x83;
this->unk_82 = 0;
ChangeObjPalette(super, 0x7c);
}
this->action = 7;
this->timer = 60;
if (0 < this->zVelocity) {
this->zVelocity = 0;
super->action = 7;
super->timer = 60;
if (0 < super->zVelocity) {
super->zVelocity = 0;
}
this->iframes = -0xc;
this->knockbackDuration = 0;
if (this->field_0x80.HALF.LO == 0) {
this->animationState = (*(Entity**)&this->contactedEntity)->direction >> 3;
InitializeAnimation(this, this->animationState + 4);
this->frameDuration = 6;
this->field_0x80.HALF.LO = 1;
super->iframes = -0xc;
super->knockbackDuration = 0;
if (this->unk_80 == 0) {
super->animationState = (*(Entity**)&super->contactedEntity)->direction >> 3;
InitializeAnimation(super, super->animationState + 4);
super->frameDuration = 6;
this->unk_80 = 1;
}
break;
default:
if (this->hitType == 0x82 && this->iframes < 0) {
Entity* ent = CreateObject(DIRT_PARTICLE, 2, 0);
if (ent != NULL) {
ent->spritePriority.b0 = 3;
CopyPosition(this, ent);
if (super->hitType == 0x82 && super->iframes < 0) {
Entity* entity = CreateObject(DIRT_PARTICLE, 2, 0);
if (entity != NULL) {
entity->spritePriority.b0 = 3;
CopyPosition(super, entity);
}
EnqueueSFX(SFX_186);
}
break;
}
EnemyFunctionHandlerAfterCollision(this, Puffstool_Functions);
EnemyFunctionHandlerAfterCollision(super, Puffstool_Functions);
}
void Puffstool_OnDeath(Entity* this) {
if ((this->gustJarState & 2) && this->timer == 1 && this->field_0x82.HALF.LO) {
void Puffstool_OnDeath(PuffstoolEntity* this) {
if ((super->gustJarState & 2) && super->timer == 1 && this->unk_82) {
sub_08025B18(this);
}
GenericDeath(this);
GenericDeath(super);
}
void Puffstool_OnGrabbed(Entity* this) {
GravityUpdate(this, Q_8_8(32.0));
if (sub_0806F520(this)) {
gUnk_080CBFEC[this->subAction](this);
void Puffstool_OnGrabbed(PuffstoolEntity* this) {
GravityUpdate(super, Q_8_8(32.0));
if (sub_0806F520(super)) {
gUnk_080CBFEC[super->subAction](this);
} else {
sub_08025C2C(this);
}
}
void sub_08025180(Entity* this) {
this->subAction = 1;
this->timer = Random();
this->animationState = (((*(Entity**)&this->contactedEntity)->direction ^ 0x10) >> 3);
InitializeAnimation(this, this->animationState + 4);
sub_0804AA1C(this);
void sub_08025180(PuffstoolEntity* this) {
super->subAction = 1;
super->timer = Random();
super->animationState = (((*(Entity**)&super->contactedEntity)->direction ^ 0x10) >> 3);
InitializeAnimation(super, super->animationState + 4);
sub_0804AA1C(super);
}
void sub_080251AC(Entity* this) {
if (this->field_0x82.HALF.LO >= 4) {
this->field_0x82.HALF.LO -= 3;
if ((--this->timer & 3) == 0) {
void sub_080251AC(PuffstoolEntity* this) {
if (this->unk_82 >= 4) {
this->unk_82 -= 3;
if ((--super->timer & 3) == 0) {
sub_08025BD4(this);
}
} else {
this->cutsceneBeh.HWORD = 0x294;
this->hitType = 0x83;
this->field_0x82.HALF.LO = 0;
ChangeObjPalette(this, 0x7c);
this->unk_84 = 0x294;
super->hitType = 0x83;
this->unk_82 = 0;
ChangeObjPalette(super, 0x7c);
}
GetNextFrame(this);
GetNextFrame(super);
}
void sub_080251FC(Entity* this) {
sub_0804A720(this);
this->field_0x82.HALF.LO = 240;
this->direction = Random() & 0x1c;
this->field_0x80.HALF.LO = 0;
void sub_080251FC(PuffstoolEntity* this) {
sub_0804A720(super);
this->unk_82 = 240;
super->direction = Random() & 0x1c;
this->unk_80 = 0;
sub_080256B4(this);
InitializeAnimation(this, 0);
InitializeAnimation(super, 0);
}
void sub_08025230(Entity* this) {
if (this->field_0x80.HALF.HI)
this->field_0x80.HALF.HI--;
void sub_08025230(PuffstoolEntity* this) {
if (this->unk_81)
this->unk_81--;
sub_08025C44(this);
GetNextFrame(this);
if (--this->timer == 0) {
this->timer = (Random() & 3) + 4;
this->direction = sub_08025C60(this);
GetNextFrame(super);
if (--super->timer == 0) {
super->timer = (Random() & 3) + 4;
super->direction = sub_08025C60(this);
}
if (this->collisions != COL_NONE) {
if (--this->subtimer == 0) {
sub_0800417E(this, this->collisions);
if (super->collisions != COL_NONE) {
if (--super->subtimer == 0) {
sub_0800417E(super, super->collisions);
}
} else {
this->subtimer = 30;
super->subtimer = 30;
}
if (this->field_0x78.HWORD == 0) {
if (this->unk_78 == 0) {
if (sub_0802571C(this)) {
this->action = 2;
this->timer = 240;
this->field_0x86.HWORD = COORD_TO_TILE(this);
super->action = 2;
super->timer = 240;
this->unk_86 = COORD_TO_TILE(super);
}
} else {
this->field_0x78.HWORD--;
this->unk_78--;
}
}
void sub_080252E0(Entity* this) {
void sub_080252E0(PuffstoolEntity* this) {
u32 tile;
this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, (u16)this->field_0x7c.HALF.LO,
(u16)this->field_0x7c.HALF.HI);
super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, this->unk_7c, this->unk_7e);
sub_08025C44(this);
GetNextFrame(this);
GetNextFrame(super);
tile = COORD_TO_TILE(this);
if (tile == this->field_0x86.HWORD) {
if (--this->timer == 0) {
tile = COORD_TO_TILE(super);
if (tile == this->unk_86) {
if (--super->timer == 0) {
sub_080256B4(this);
}
} else {
this->field_0x86.HWORD = tile;
this->timer = 240;
this->unk_86 = tile;
super->timer = 240;
}
if (this->x.HALF.HI == (u16)this->field_0x7c.HALF.LO && this->y.HALF.HI == (u16)this->field_0x7c.HALF.HI) {
this->action = 3;
this->timer = 30;
this->subtimer = 0;
this->zVelocity = Q_16_16(1.5);
InitializeAnimation(this, 1);
if (super->x.HALF.HI == this->unk_7c && super->y.HALF.HI == this->unk_7e) {
super->action = 3;
super->timer = 30;
super->subtimer = 0;
super->zVelocity = Q_16_16(1.5);
InitializeAnimation(super, 1);
}
}
void sub_0802538C(Entity* this) {
if (this->timer) {
this->timer--;
void sub_0802538C(PuffstoolEntity* this) {
if (super->timer) {
super->timer--;
} else {
if (this->frame == 0) {
GetNextFrame(this);
if (super->frame == 0) {
GetNextFrame(super);
} else {
GravityUpdate(this, Q_8_8(32.0));
if (this->zVelocity < Q_16_16(0.125)) {
this->action = 4;
InitializeAnimation(this, 2);
GravityUpdate(super, Q_8_8(32.0));
if (super->zVelocity < Q_16_16(0.125)) {
super->action = 4;
InitializeAnimation(super, 2);
}
}
}
}
void sub_080253D4(Entity* this) {
GetNextFrame(this);
if (!GravityUpdate(this, Q_8_8(32.0))) {
if (this->subtimer == 0) {
this->action = 5;
InitializeAnimation(this, 3);
void sub_080253D4(PuffstoolEntity* this) {
GetNextFrame(super);
if (!GravityUpdate(super, Q_8_8(32.0))) {
if (super->subtimer == 0) {
super->action = 5;
InitializeAnimation(super, 3);
} else {
this->action = 6;
this->timer = 30;
InitializeAnimation(this, 3);
super->action = 6;
super->timer = 30;
InitializeAnimation(super, 3);
sub_08025A54(this);
sub_08025AE8(this);
}
}
}
void sub_0802541C(Entity* this) {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
this->action = 3;
this->subtimer = 1;
this->zVelocity = Q_16_16(2.0);
InitializeAnimation(this, 1);
void sub_0802541C(PuffstoolEntity* this) {
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
super->action = 3;
super->subtimer = 1;
super->zVelocity = Q_16_16(2.0);
InitializeAnimation(super, 1);
}
}
void sub_0802544C(Entity* this) {
if (this->frame == 0) {
GetNextFrame(this);
void sub_0802544C(PuffstoolEntity* this) {
if (super->frame == 0) {
GetNextFrame(super);
} else {
if (--this->timer == 0) {
if (--super->timer == 0) {
sub_080256B4(this);
InitializeAnimation(this, 0);
InitializeAnimation(super, 0);
}
}
}
void sub_0802547C(Entity* this) {
GravityUpdate(this, Q_8_8(32.0));
GetNextFrame(this);
if ((this->timer & 7) == 0) {
void sub_0802547C(PuffstoolEntity* this) {
GravityUpdate(super, Q_8_8(32.0));
GetNextFrame(super);
if ((super->timer & 7) == 0) {
sub_08025BD4(this);
}
if (--this->timer == 0) {
if (--super->timer == 0) {
sub_08025C2C(this);
}
}
void sub_080254B4(Entity* this) {
GravityUpdate(this, Q_8_8(32.0));
if (this->frame & ANIM_DONE) {
if (this->z.HALF.HI == 0) {
if (this->cutsceneBeh.HWORD == 0) {
this->hitType = 0x82;
this->field_0x82.HALF.LO = -0x10;
void sub_080254B4(PuffstoolEntity* this) {
GravityUpdate(super, Q_8_8(32.0));
if (super->frame & ANIM_DONE) {
if (super->z.HALF.HI == 0) {
if (this->unk_84 == 0) {
super->hitType = 0x82;
this->unk_82 = -0x10;
sub_080256B4(this);
} else {
this->action = 0xc;
Create0x68FX(this, FX_STARS);
super->action = 0xc;
Create0x68FX(super, FX_STARS);
}
InitializeAnimation(this, 0);
InitializeAnimation(super, 0);
}
} else {
GetNextFrame(this);
GetNextFrame(super);
}
}
void sub_08025514(Entity* this) {
GetNextFrame(this);
if (sub_0802594C(this, this->timer++)) {
this->action = 2;
this->timer = 240;
this->field_0x80.HALF.HI = 120;
} else if (3 < this->timer) {
this->action = 10;
this->timer = 32;
void sub_08025514(PuffstoolEntity* this) {
GetNextFrame(super);
if (sub_0802594C(this, super->timer++)) {
super->action = 2;
super->timer = 240;
this->unk_81 = 120;
} else if (3 < super->timer) {
super->action = 10;
super->timer = 32;
}
}
void sub_08025554(Entity* this) {
Entity* ent = sub_08049DF4(1);
if (ent == NULL) {
void sub_08025554(PuffstoolEntity* this) {
Entity* entity = sub_08049DF4(1);
if (entity == NULL) {
sub_080256B4(this);
} else {
if ((this->timer & 3) == 0) {
this->direction = GetFacingDirection(ent, this);
if ((super->timer & 3) == 0) {
super->direction = GetFacingDirection(entity, super);
}
sub_08025C44(this);
GetNextFrame(this);
if (this->timer != 0) {
this->timer--;
GetNextFrame(super);
if (super->timer != 0) {
super->timer--;
} else {
if (!sub_080258C4(this)) {
sub_080256B4(this);
@@ -319,19 +333,19 @@ void sub_08025554(Entity* this) {
}
}
void sub_080255AC(Entity* this) {
Entity* ent = sub_08049DF4(1);
if (ent == NULL) {
void sub_080255AC(PuffstoolEntity* this) {
Entity* entity = sub_08049DF4(1);
if (entity == NULL) {
sub_080256B4(this);
} else {
if (this->field_0x80.HALF.HI != 0) {
this->field_0x80.HALF.HI--;
if (this->unk_81 != 0) {
this->unk_81--;
}
if (--this->timer == 0) {
if (--super->timer == 0) {
s32 tmp;
this->timer = (Random() & 3) + 4;
super->timer = (Random() & 3) + 4;
tmp = Random() & 0xf;
if (tmp < 8) {
@@ -339,57 +353,57 @@ void sub_080255AC(Entity* this) {
}
tmp -= 7;
this->direction = (GetFacingDirection(ent, this) + tmp) & (0x3 | DirectionNorthWest);
super->direction = (GetFacingDirection(entity, super) + tmp) & (0x3 | DirectionNorthWest);
}
if (this->field_0x78.HWORD == 0) {
if (this->unk_78 == 0) {
if (sub_080258C4(this) == 0) {
sub_080256B4(this);
}
} else {
this->field_0x78.HWORD--;
this->unk_78--;
}
sub_08025C44(this);
GetNextFrame(this);
GetNextFrame(super);
}
}
void sub_0802563C(Entity* this) {
GetNextFrame(this);
void sub_0802563C(PuffstoolEntity* this) {
GetNextFrame(super);
if (--this->cutsceneBeh.HWORD == 0) {
ChangeObjPalette(this, 0x28);
this->hitType = 0x82;
this->field_0x82.HALF.LO = 240;
if (--this->unk_84 == 0) {
ChangeObjPalette(super, 0x28);
super->hitType = 0x82;
this->unk_82 = 240;
sub_080256B4(this);
sub_0804AA1C(this);
} else if (this->cutsceneBeh.HWORD < 120) {
u32 tmp3 = gUnk_080CBFF8[this->cutsceneBeh.HWORD >> 4];
if ((this->cutsceneBeh.HWORD & tmp3) == 0) {
if (this->cutsceneBeh.HWORD & (tmp3 + 1)) {
ChangeObjPalette(this, 124);
sub_0804AA1C(super);
} else if (this->unk_84 < 120) {
u32 tmp3 = gUnk_080CBFF8[this->unk_84 >> 4];
if ((this->unk_84 & tmp3) == 0) {
if (this->unk_84 & (tmp3 + 1)) {
ChangeObjPalette(super, 124);
} else {
ChangeObjPalette(this, 40);
ChangeObjPalette(super, 40);
}
}
}
}
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) & DirectionNorthWest;
this->field_0x78.HWORD = gUnk_080CC000[Random() & 0xf];
this->field_0x7a.HALF.LO = ((s32)Random() % 0x18) << 1;
this->field_0x7a.HALF.HI = 0;
void sub_080256B4(PuffstoolEntity* this) {
super->action = 1;
super->timer = (Random() & 3) + 4;
super->subtimer = 30;
super->direction = (super->direction + 7 + ((s32)Random() % 7) * 4) & DirectionNorthWest;
this->unk_78 = gUnk_080CC000[Random() & 0xf];
this->unk_7a = ((s32)Random() % 0x18) << 1;
this->unk_7b = 0;
}
bool32 sub_0802571C(Entity* this) {
bool32 sub_0802571C(PuffstoolEntity* this) {
RoomControls* ctrl = &gRoomControls;
u16 xDiff = (this->x.HALF.HI - ctrl->origin_x + 8) & -0x10;
u16 yDiff = (this->y.HALF.HI - ctrl->origin_y + 8) & -0x10;
u16 unk = this->field_0x7a.HALF.LO;
u16 xDiff = (super->x.HALF.HI - ctrl->origin_x + 8) & -0x10;
u16 yDiff = (super->y.HALF.HI - ctrl->origin_y + 8) & -0x10;
u16 unk = this->unk_7a;
u16 i;
for (i = 0; i < 4; i++) {
@@ -397,8 +411,8 @@ bool32 sub_0802571C(Entity* this) {
u16 sVar4 = yDiff + gUnk_080CC020[unk + 1];
if (sub_080257EC(this, sVar3, sVar4)) {
this->field_0x7c.HALF.LO = sVar3 + ctrl->origin_x;
this->field_0x7c.HALF.HI = sVar4 + ctrl->origin_y;
this->unk_7c = sVar3 + ctrl->origin_x;
this->unk_7e = sVar4 + ctrl->origin_y;
return TRUE;
}
@@ -408,31 +422,31 @@ bool32 sub_0802571C(Entity* this) {
}
}
this->field_0x7a.HALF.LO = unk;
this->field_0x7a.HALF.HI++;
this->unk_7a = unk;
this->unk_7b++;
return FALSE;
}
bool32 sub_080257EC(Entity* this, u32 x, u32 y) {
u16 metaTileType = sub_080B1A48(x - 0x00, y - 0x00, this->collisionLayer);
bool32 sub_080257EC(PuffstoolEntity* this, u32 x, u32 y) {
u16 metaTileType = sub_080B1A48(x - 0x00, y - 0x00, super->collisionLayer);
if (metaTileType != 0x312 && gMapMetaTileTypeToVvv[metaTileType] != VVV_22 &&
gMapMetaTileTypeToCollisionData[metaTileType] == 0) {
return TRUE;
}
metaTileType = sub_080B1A48(x - 0x10, y - 0x00, this->collisionLayer);
metaTileType = sub_080B1A48(x - 0x10, y - 0x00, super->collisionLayer);
if (metaTileType != 0x312 && gMapMetaTileTypeToVvv[metaTileType] != VVV_22 &&
gMapMetaTileTypeToCollisionData[metaTileType] == 0) {
return TRUE;
}
metaTileType = sub_080B1A48(x - 0x00, y - 0x10, this->collisionLayer);
metaTileType = sub_080B1A48(x - 0x00, y - 0x10, super->collisionLayer);
if (metaTileType != 0x312 && gMapMetaTileTypeToVvv[metaTileType] != VVV_22 &&
gMapMetaTileTypeToCollisionData[metaTileType] == 0) {
return TRUE;
}
metaTileType = sub_080B1A48(x - 0x10, y - 0x10, this->collisionLayer);
metaTileType = sub_080B1A48(x - 0x10, y - 0x10, super->collisionLayer);
if (metaTileType != 0x312 && gMapMetaTileTypeToVvv[metaTileType] != VVV_22 &&
gMapMetaTileTypeToCollisionData[metaTileType] == 0) {
return TRUE;
@@ -441,26 +455,26 @@ bool32 sub_080257EC(Entity* this, u32 x, u32 y) {
return FALSE;
}
bool32 sub_080258C4(Entity* this) {
Entity* ent = sub_08049DF4(1);
if (ent == NULL) {
bool32 sub_080258C4(PuffstoolEntity* this) {
Entity* entity = sub_08049DF4(1);
if (entity == NULL) {
return FALSE;
} else {
s32 iVar4;
s32 iVar1;
iVar4 = ent->x.HALF.HI - this->x.HALF.HI;
iVar4 = entity->x.HALF.HI - super->x.HALF.HI;
iVar4 = iVar4 * iVar4;
iVar1 = ent->y.HALF.HI - this->y.HALF.HI;
iVar1 = entity->y.HALF.HI - super->y.HALF.HI;
iVar1 = iVar1 * iVar1;
iVar4 = iVar4 + iVar1;
if (this->cutsceneBeh.HWORD == 0 && this->field_0x80.HALF.HI == 0 && 0x400 >= iVar4) {
this->action = 9;
this->timer = 0;
if (this->unk_84 == 0 && this->unk_81 == 0 && 0x400 >= iVar4) {
super->action = 9;
super->timer = 0;
return TRUE;
} else if (0x900 >= iVar4) {
this->action = 11;
this->timer = 1;
this->field_0x78.HWORD = gUnk_080CC050[Random() & 0xf];
super->action = 11;
super->timer = 1;
this->unk_78 = gUnk_080CC050[Random() & 0xf];
return TRUE;
} else {
return FALSE;
@@ -469,15 +483,15 @@ bool32 sub_080258C4(Entity* this) {
}
// regalloc
bool32 sub_0802594C(Entity* this, u32 param_2) {
bool32 sub_0802594C(PuffstoolEntity* this, u32 param_2) {
s16 xDiff;
s16 yDiff;
s16 iVar9;
u32 layer;
const s8* unk = gUnk_080CC090[param_2];
layer = this->collisionLayer;
xDiff = (this->x.HALF.HI - gRoomControls.origin_x + 8) & -0x10;
yDiff = (this->y.HALF.HI - gRoomControls.origin_y + 8) & -0x10;
layer = super->collisionLayer;
xDiff = (super->x.HALF.HI - gRoomControls.origin_x + 8) & -0x10;
yDiff = (super->y.HALF.HI - gRoomControls.origin_y + 8) & -0x10;
do {
u8 bVar7;
u8 bVar4;
@@ -491,8 +505,8 @@ bool32 sub_0802594C(Entity* this, u32 param_2) {
bVar6 = GetCollisionDataAtWorldCoords(iVar9 - 0x00, iVar11 - 0x10, layer);
bVar7 = GetCollisionDataAtWorldCoords(iVar9 - 0x10, iVar11 - 0x10, layer);
if ((bVar4 | bVar5 | bVar6 | bVar7) == 0) {
this->field_0x7c.HALF.LO = gRoomControls.origin_x + iVar9;
this->field_0x7c.HALF.HI = gRoomControls.origin_y + iVar11;
this->unk_7c = gRoomControls.origin_x + iVar9;
this->unk_7e = gRoomControls.origin_y + iVar11;
return TRUE;
}
unk += 2;
@@ -501,10 +515,10 @@ bool32 sub_0802594C(Entity* this, u32 param_2) {
return 0;
}
void sub_08025A54(Entity* this) {
u32 layer = this->collisionLayer;
s16 x = this->x.HALF.HI - gRoomControls.origin_x;
s16 y = this->y.HALF.HI - gRoomControls.origin_y;
void sub_08025A54(PuffstoolEntity* this) {
u32 layer = super->collisionLayer;
s16 x = super->x.HALF.HI - gRoomControls.origin_x;
s16 y = super->y.HALF.HI - gRoomControls.origin_y;
const s8* offset = gUnk_080CC0A0;
u32 i = 0;
@@ -526,26 +540,26 @@ bool32 sub_08025AB8(u32 metaTilePos, u32 layer) {
return FALSE;
}
void sub_08025AE8(Entity* this) {
Entity* ent;
void sub_08025AE8(PuffstoolEntity* this) {
Entity* entity;
ent = CreateFx(this, FX_BROWN_SMOKE, 0);
if (ent != NULL) {
ent->y.WORD--;
entity = CreateFx(super, FX_BROWN_SMOKE, 0);
if (entity != NULL) {
entity->y.WORD--;
}
ent = CreateFx(this, FX_BROWN_SMOKE_LARGE, 0);
if (ent != NULL) {
ent->y.WORD++;
entity = CreateFx(super, FX_BROWN_SMOKE_LARGE, 0);
if (entity != NULL) {
entity->y.WORD++;
}
}
void sub_08025B18(Entity* this) {
Entity* ent;
void sub_08025B18(PuffstoolEntity* this) {
Entity* entity;
s32 x = this->x.HALF.HI - gRoomControls.origin_x;
s32 y = this->y.HALF.HI - gRoomControls.origin_y;
u32 layer = this->collisionLayer;
s32 x = super->x.HALF.HI - gRoomControls.origin_x;
s32 y = super->y.HALF.HI - gRoomControls.origin_y;
u32 layer = super->collisionLayer;
const s8* offset = gUnk_080CC0A8;
u32 i = 0;
@@ -553,62 +567,62 @@ void sub_08025B18(Entity* this) {
for (; i < 9; i++, offset += 2) {
sub_08025AB8((((x + offset[0]) >> 4) & 0x3fU) | ((((y + offset[1]) >> 4) & 0x3fU) << 6), layer);
ent = CreateObject(DIRT_PARTICLE, 2, 0);
if (ent != NULL) {
PositionRelative(this, ent, Q_16_16(offset[0]), Q_16_16(offset[1]));
ent->x.HALF.HI &= -0x10;
ent->x.HALF.HI += 8;
ent->y.HALF.HI &= -0x10;
ent->y.HALF.HI += 8;
ent->z.HALF.HI = -1;
entity = CreateObject(DIRT_PARTICLE, 2, 0);
if (entity != NULL) {
PositionRelative(super, entity, Q_16_16(offset[0]), Q_16_16(offset[1]));
entity->x.HALF.HI &= -0x10;
entity->x.HALF.HI += 8;
entity->y.HALF.HI &= -0x10;
entity->y.HALF.HI += 8;
entity->z.HALF.HI = -1;
}
}
}
void sub_08025BD4(Entity* this) {
if (this->field_0x82.HALF.LO && (this->frame & 1) == 0) {
Entity* ent = CreateObject(DIRT_PARTICLE, 0, 0);
if (ent != NULL) {
PositionRelative(this, ent, Q_16_16(gUnk_080CC0BA[this->animationState * 2 + 0]),
Q_16_16(gUnk_080CC0BA[this->animationState * 2 + 1]));
ent->z.HALF.HI = -10;
void sub_08025BD4(PuffstoolEntity* this) {
if (this->unk_82 && (super->frame & 1) == 0) {
Entity* entity = CreateObject(DIRT_PARTICLE, 0, 0);
if (entity != NULL) {
PositionRelative(super, entity, Q_16_16(gUnk_080CC0BA[super->animationState * 2 + 0]),
Q_16_16(gUnk_080CC0BA[super->animationState * 2 + 1]));
entity->z.HALF.HI = -10;
}
}
}
void sub_08025C2C(Entity* this) {
this->action = 8;
this->field_0x80.HALF.LO = 0;
InitializeAnimation(this, 8);
void sub_08025C2C(PuffstoolEntity* this) {
super->action = 8;
this->unk_80 = 0;
InitializeAnimation(super, 8);
}
bool32 sub_08025C44(Entity* this) {
if ((this->frame & 1) == 0) {
return ProcessMovement0(this);
bool32 sub_08025C44(PuffstoolEntity* this) {
if ((super->frame & 1) == 0) {
return ProcessMovement0(super);
} else {
return FALSE;
}
}
u32 sub_08025C60(Entity* this) {
if (!sub_08049FA0(this) && (Random() & 1)) {
return sub_08049EE4(this);
u32 sub_08025C60(PuffstoolEntity* this) {
if (!sub_08049FA0(super) && (Random() & 1)) {
return sub_08049EE4(super);
}
return (gUnk_080CC0C2[Random() & 7] + this->direction) & 0x1f;
return (gUnk_080CC0C2[Random() & 7] + super->direction) & 0x1f;
}
// clang-format off
void (*const Puffstool_Functions[])(Entity*) = {
void (*const Puffstool_Functions[])(PuffstoolEntity*) = {
Puffstool_OnTick,
Puffstool_OnCollide,
GenericKnockback,
(void (*)(PuffstoolEntity*))GenericKnockback,
Puffstool_OnDeath,
GenericConfused,
(void (*)(PuffstoolEntity*))GenericConfused,
Puffstool_OnGrabbed,
};
void (*const gUnk_080CBFB4[])(Entity*) = {
void (*const gUnk_080CBFB4[])(PuffstoolEntity*) = {
sub_080251FC,
sub_08025230,
sub_080252E0,
@@ -628,7 +642,7 @@ const u8 gUnk_080CBFE8[] = {
40, 120, 240, 0x0
};
void (*const gUnk_080CBFEC[])(Entity*) = {
void (*const gUnk_080CBFEC[])(PuffstoolEntity*) = {
sub_08025180,
sub_080251AC,
sub_080251AC,
+14 -15
View File
@@ -4,7 +4,6 @@
*
* @brief Rock Chuchu enemy
*/
#include "enemy.h"
#include "player.h"
@@ -20,7 +19,7 @@ void RockChuchu_OnTick(Entity* this) {
}
void RockChuchu_OnCollision(Entity* this) {
Entity* ent;
Entity* entity;
if (this->health) {
switch (this->contactFlags & 0x7f) {
@@ -44,18 +43,18 @@ void RockChuchu_OnCollision(Entity* this) {
case 0x16:
case 0x1c:
CreateFx(this, FX_ROCK, 0);
ent = CreateEnemy(CHUCHU, 1);
if (ent != NULL) {
ent->type2 = 1;
entity = CreateEnemy(CHUCHU, 1);
if (entity != NULL) {
entity->type2 = 1;
#ifndef EU
ent->iframes = -8;
entity->iframes = -8;
#endif
sub_0804A4E4(this, ent);
sub_0804A4E4(this, entity);
this->action = 2;
COLLISION_OFF(this);
this->spriteSettings.draw = 0;
this->direction = this->knockbackDirection;
this->child = ent;
this->child = entity;
}
}
} else {
@@ -97,15 +96,15 @@ void sub_08022390(Entity* this) {
}
void sub_080223E4(Entity* this) {
Entity* ent;
Entity* entity;
ent = this->child;
if (ent != NULL) {
ent->contactFlags = 0x94;
ent->iframes = 0x10;
entity = this->child;
if (entity != NULL) {
entity->contactFlags = 0x94;
entity->iframes = 0x10;
#ifndef EU
ent->knockbackDuration = 0xc;
ent->knockbackDirection = this->direction;
entity->knockbackDuration = 0xc;
entity->knockbackDirection = this->direction;
#endif
}
+169 -163
View File
@@ -4,7 +4,6 @@
*
* @brief Rollobite enemy
*/
#include "collision.h"
#include "enemy.h"
#include "physics.h"
@@ -12,274 +11,281 @@
#include "room.h"
#include "tiles.h"
extern void (*const Rollobite_Functions[])(Entity*);
extern void (*const gRollobiteActions[])(Entity*);
extern void (*const gUnk_080CA6A4[])(Entity*);
extern void (*const gUnk_080CA6BC[])(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[28];
/*0x84*/ u8 unk_84;
/*0x85*/ u8 unk_85;
} RollobiteEntity;
extern void (*const Rollobite_Functions[])(RollobiteEntity*);
extern void (*const gRollobiteActions[])(RollobiteEntity*);
extern void (*const gUnk_080CA6A4[])(RollobiteEntity*);
extern void (*const gUnk_080CA6BC[])(RollobiteEntity*);
extern const u8 gUnk_080CA6CC[];
extern const s8 gUnk_080CA6D4[];
void sub_08020A30(Entity*);
void sub_08020A7C(Entity*);
bool32 Rollobite_TryToHoleUp(Entity*);
bool32 Rollobite_IsRolledUp(Entity*);
void sub_08020A30(RollobiteEntity* this);
void sub_08020A7C(RollobiteEntity* this);
bool32 Rollobite_TryToHoleUp(RollobiteEntity* this);
bool32 Rollobite_IsRolledUp(RollobiteEntity* this);
extern void RegisterCarryEntity(Entity*);
void Rollobite(Entity* this) {
EnemyFunctionHandler(this, Rollobite_Functions);
void Rollobite(RollobiteEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Rollobite_Functions);
}
void Rollobite_OnTick(Entity* this) {
void Rollobite_OnTick(RollobiteEntity* this) {
Rollobite_TryToHoleUp(this);
gRollobiteActions[this->action](this);
gRollobiteActions[super->action](this);
}
void Rollobite_OnCollision(Entity* this) {
if (this->hitType == 34 && this->health != 0xff) {
this->action = 4;
this->zVelocity = Q_16_16(2.0);
this->direction = DIR_NONE;
this->health = 0xff;
this->hitType = 35;
InitializeAnimation(this, this->animationState + 8);
void Rollobite_OnCollision(RollobiteEntity* this) {
if (super->hitType == 34 && super->health != 0xff) {
super->action = 4;
super->zVelocity = Q_16_16(2.0);
super->direction = DIR_NONE;
super->health = 0xff;
super->hitType = 35;
InitializeAnimation(super, super->animationState + 8);
}
if (this->contactFlags != 0x80) {
if (this->action == 4 || this->action == 5) {
this->action = 4;
this->timer = 180;
this->direction = DIR_NONE;
InitializeAnimation(this, this->animationState + 0x10);
if (super->contactFlags != 0x80) {
if (super->action == 4 || super->action == 5) {
super->action = 4;
super->timer = 180;
super->direction = DIR_NONE;
InitializeAnimation(super, super->animationState + 0x10);
}
}
if (this->contactFlags == 0x93)
if (super->contactFlags == 0x93)
Rollobite_OnTick(this);
}
void Rollobite_OnKnockback(Entity* this) {
void Rollobite_OnKnockback(RollobiteEntity* this) {
if (Rollobite_TryToHoleUp(this)) {
this->knockbackDuration = 0;
super->knockbackDuration = 0;
} else if (Rollobite_IsRolledUp(this)) {
this->knockbackDuration--;
CalculateEntityTileCollisions(this, this->knockbackDirection, 10);
ProcessMovementInternal(this, this->knockbackSpeed, this->knockbackDirection, 10);
super->knockbackDuration--;
CalculateEntityTileCollisions(super, super->knockbackDirection, 10);
ProcessMovementInternal(super, super->knockbackSpeed, super->knockbackDirection, 10);
} else {
GenericKnockback(this);
GenericKnockback(super);
}
}
void Rollobite_OnGrabbed(Entity* this) {
if (this->subAction < 3 && !sub_0806F520(this)) {
this->action = 4;
COLLISION_ON(this);
this->direction = DIR_NONE;
InitializeAnimation(this, this->animationState + 0x10);
void Rollobite_OnGrabbed(RollobiteEntity* this) {
if (super->subAction < 3 && !sub_0806F520(super)) {
super->action = 4;
COLLISION_ON(super);
super->direction = DIR_NONE;
InitializeAnimation(super, super->animationState + 0x10);
} else {
gUnk_080CA6A4[this->subAction](this);
gUnk_080CA6A4[super->subAction](this);
}
}
void sub_0802077C(Entity* this) {
this->subAction = 1;
this->gustJarTolerance = 60;
void sub_0802077C(RollobiteEntity* this) {
super->subAction = 1;
super->gustJarTolerance = 60;
}
void sub_08020788(Entity* this) {
sub_0806F4E8(this);
void sub_08020788(RollobiteEntity* this) {
sub_0806F4E8(super);
}
void sub_08020790(Entity* this) {
sub_0806F3E4(this);
void sub_08020790(RollobiteEntity* this) {
sub_0806F3E4(super);
}
void sub_08020798(Entity* this) {
COLLISION_OFF(this);
void sub_08020798(RollobiteEntity* this) {
COLLISION_OFF(super);
}
void nullsub_6(Entity* this) {
void nullsub_6(RollobiteEntity* this) {
/* ... */
}
void sub_080207A8(Entity* this) {
this->action = 4;
COLLISION_ON(this);
this->spritePriority.b0 = 4;
this->gustJarState &= 0xfb;
this->direction ^= DirectionSouth;
this->zVelocity = Q_16_16(1.5);
this->speed = 0x80;
InitializeAnimation(this, this->animationState + 0x10);
void sub_080207A8(RollobiteEntity* this) {
super->action = 4;
COLLISION_ON(super);
super->spritePriority.b0 = 4;
super->gustJarState &= 0xfb;
super->direction ^= DirectionSouth;
super->zVelocity = Q_16_16(1.5);
super->speed = 0x80;
InitializeAnimation(super, super->animationState + 0x10);
}
void Rollobite_Initialize(Entity* this) {
sub_0804A720(this);
this->carryFlags = 0x30;
this->gustJarFlags = 18;
this->cutsceneBeh.HALF.LO = 0;
this->direction = DirectionRound(Random());
void Rollobite_Initialize(RollobiteEntity* this) {
sub_0804A720(super);
super->carryFlags = 0x30;
super->gustJarFlags = 18;
this->unk_84 = 0;
super->direction = DirectionRound(Random());
sub_08020A30(this);
}
void Rollobite_Walk(Entity* this) {
GetNextFrame(this);
if (this->frame & 0x1) {
this->frame &= ~0x1;
if (!ProcessMovement0(this))
this->timer = 1;
void Rollobite_Walk(RollobiteEntity* this) {
GetNextFrame(super);
if (super->frame & 0x1) {
super->frame &= ~0x1;
if (!ProcessMovement0(super))
super->timer = 1;
}
if (this->frame & 0x10) {
this->frame &= ~0x10;
if (--this->timer == 0) {
this->action = 3;
this->timer = 60;
if (super->frame & 0x10) {
super->frame &= ~0x10;
if (--super->timer == 0) {
super->action = 3;
super->timer = 60;
}
}
}
void sub_08020874(Entity* this) {
gUnk_080CA6BC[this->subAction](this);
void sub_08020874(RollobiteEntity* this) {
gUnk_080CA6BC[super->subAction](this);
}
void sub_0802088C(Entity* this) {
this->subAction = 1;
COLLISION_OFF(this);
this->cutsceneBeh.HALF.HI = gPlayerEntity.animationState;
this->spritePriority.b1 = 0;
void sub_0802088C(RollobiteEntity* this) {
super->subAction = 1;
COLLISION_OFF(super);
this->unk_85 = gPlayerEntity.base.animationState;
super->spritePriority.b1 = 0;
}
void sub_080208B4(Entity* this) {
s8 uVar1 = (this->cutsceneBeh.HALF.HI - gPlayerEntity.animationState) / 2;
void sub_080208B4(RollobiteEntity* this) {
s8 uVar1 = (this->unk_85 - gPlayerEntity.base.animationState) / 2;
if (uVar1) {
this->animationState = (this->animationState + uVar1) & 3;
InitializeAnimation(this, this->animationState + 0x10);
super->animationState = (super->animationState + uVar1) & 3;
InitializeAnimation(super, super->animationState + 0x10);
}
this->cutsceneBeh.HALF.HI = gPlayerEntity.animationState;
this->unk_85 = gPlayerEntity.base.animationState;
}
void sub_080208F0(Entity* this) {
this->spritePriority.b1 = 3;
void sub_080208F0(RollobiteEntity* this) {
super->spritePriority.b1 = 3;
}
void sub_08020904(Entity* this) {
this->action = 4;
COLLISION_ON(this);
this->direction = -1;
InitializeAnimation(this, this->animationState + 0x10);
void sub_08020904(RollobiteEntity* this) {
super->action = 4;
COLLISION_ON(super);
super->direction = -1;
InitializeAnimation(super, super->animationState + 0x10);
}
void Rollobite_Turn(Entity* this) {
if (--this->timer == 0)
void Rollobite_Turn(RollobiteEntity* this) {
if (--super->timer == 0)
sub_08020A30(this);
}
void Rollobite_RolledUp(Entity* this) {
void Rollobite_RolledUp(RollobiteEntity* this) {
u32 unk;
if ((this->frame & ANIM_DONE) == 0)
GetNextFrame(this);
if ((super->frame & ANIM_DONE) == 0)
GetNextFrame(super);
unk = sub_080044EC(this, 0x2800);
unk = sub_080044EC(super, 0x2800);
if (unk == 0) {
if (--this->timer == 0) {
this->action = 5;
InitializeAnimation(this, this->animationState + 12);
if (--super->timer == 0) {
super->action = 5;
InitializeAnimation(super, super->animationState + 12);
}
RegisterCarryEntity(this);
RegisterCarryEntity(super);
} else {
if (unk == 1)
EnqueueSFX(SFX_PLACE_OBJ);
if (!(this->direction & DIR_NOT_MOVING_CHECK))
ProcessMovement2(this);
if (!(super->direction & DIR_NOT_MOVING_CHECK))
ProcessMovement2(super);
}
}
void Rollobite_Unroll(Entity* this) {
GetNextFrame(this);
if (this->frame & ANIM_DONE) {
COLLISION_ON(this);
this->speed = 0x100;
this->hitType = 34;
void Rollobite_Unroll(RollobiteEntity* this) {
GetNextFrame(super);
if (super->frame & ANIM_DONE) {
COLLISION_ON(super);
super->speed = 0x100;
super->hitType = 34;
sub_08020A30(this);
this->direction = DirectionFromAnimationState(this->animationState);
InitializeAnimation(this, this->animationState);
super->direction = DirectionFromAnimationState(super->animationState);
InitializeAnimation(super, super->animationState);
} else {
if ((this->frame & 1) == 0)
RegisterCarryEntity(this);
if ((super->frame & 1) == 0)
RegisterCarryEntity(super);
}
}
void Rollobite_LinedUp(Entity* this) {
if (GravityUpdate(this, Q_8_8(28.0)) == 0) {
this->action = 7;
this->spritePriority.b0 = 7;
void Rollobite_LinedUp(RollobiteEntity* this) {
if (GravityUpdate(super, Q_8_8(28.0)) == 0) {
super->action = 7;
super->spritePriority.b0 = 7;
}
if (this->frame == 0)
GetNextFrame(this);
if (super->frame == 0)
GetNextFrame(super);
}
void Rollobite_Holed(Entity* this) {
GetNextFrame(this);
void Rollobite_Holed(RollobiteEntity* this) {
GetNextFrame(super);
}
void sub_08020A30(Entity* this) {
if (this->cutsceneBeh.HALF.LO < 2) {
this->timer = gUnk_080CA6CC[Random() & 7];
if (this->timer == 0) {
this->action = 3;
this->timer = 60;
this->cutsceneBeh.HALF.LO++;
void sub_08020A30(RollobiteEntity* this) {
if (this->unk_84 < 2) {
super->timer = gUnk_080CA6CC[Random() & 7];
if (super->timer == 0) {
super->action = 3;
super->timer = 60;
this->unk_84++;
return;
}
}
this->action = 1;
this->cutsceneBeh.HALF.LO = 0;
super->action = 1;
this->unk_84 = 0;
sub_08020A7C(this);
}
void sub_08020A7C(Entity* this) {
void sub_08020A7C(RollobiteEntity* this) {
s32 tmp = Random();
u32 state = DirectionRound(this->direction + gUnk_080CA6D4[tmp % 3]);
u32 state = DirectionRound(super->direction + gUnk_080CA6D4[tmp % 3]);
if (sub_08049FA0(this) == 0) {
u32 tmp = DirectionRoundUp(sub_08049EE4(this));
if (sub_08049FA0(super) == 0) {
u32 tmp = DirectionRoundUp(sub_08049EE4(super));
if ((state ^ DirectionSouth) == tmp)
state ^= DirectionSouth;
}
this->direction = state;
this->animationState = (u8)(state >> 3);
InitializeAnimation(this, this->animationState);
super->direction = state;
super->animationState = (u8)(state >> 3);
InitializeAnimation(super, super->animationState);
}
bool32 Rollobite_TryToHoleUp(Entity* this) {
if (Rollobite_IsRolledUp(this) && this->z.HALF.HI == 0) {
u32 tilePos = COORD_TO_TILE(this);
u32 tileType = GetMetaTileType(tilePos, this->collisionLayer);
bool32 Rollobite_TryToHoleUp(RollobiteEntity* this) {
if (Rollobite_IsRolledUp(this) && super->z.HALF.HI == 0) {
u32 tilePos = COORD_TO_TILE(super);
u32 tileType = GetMetaTileType(tilePos, super->collisionLayer);
if ((tileType * 0x10000 - 0x710000U) >> 0x10 < 2) {
this->action = 6;
COLLISION_OFF(this);
this->x.HALF.HI &= 0xfff0;
this->x.HALF.HI += 8;
this->y.HALF.HI &= 0xfff0;
this->y.HALF.HI += 13;
this->zVelocity = Q_16_16(2.0);
InitializeAnimation(this, this->animationState + 0x14);
SetMetaTile(SPECIAL_META_TILE_52, tilePos, this->collisionLayer);
super->action = 6;
COLLISION_OFF(super);
super->x.HALF.HI &= 0xfff0;
super->x.HALF.HI += 8;
super->y.HALF.HI &= 0xfff0;
super->y.HALF.HI += 13;
super->zVelocity = Q_16_16(2.0);
InitializeAnimation(super, super->animationState + 0x14);
SetMetaTile(SPECIAL_META_TILE_52, tilePos, super->collisionLayer);
return TRUE;
}
}
return FALSE;
}
bool32 Rollobite_IsRolledUp(Entity* this) {
u32 tmp = this->animIndex;
bool32 Rollobite_IsRolledUp(RollobiteEntity* this) {
u32 tmp = super->animIndex;
if (16 <= tmp && tmp <= 19) {
return TRUE;
} else {
@@ -288,16 +294,16 @@ bool32 Rollobite_IsRolledUp(Entity* this) {
}
// clang-format off
void (*const Rollobite_Functions[])(Entity*) = {
void (*const Rollobite_Functions[])(RollobiteEntity*) = {
Rollobite_OnTick,
Rollobite_OnCollision,
Rollobite_OnKnockback,
GenericDeath,
GenericConfused,
(void (*)(RollobiteEntity*))GenericDeath,
(void (*)(RollobiteEntity*))GenericConfused,
Rollobite_OnGrabbed,
};
void (*const gRollobiteActions[])(Entity*) = {
void (*const gRollobiteActions[])(RollobiteEntity*) = {
Rollobite_Initialize,
Rollobite_Walk,
sub_08020874,
@@ -308,7 +314,7 @@ void (*const gRollobiteActions[])(Entity*) = {
Rollobite_Holed,
};
void (*const gUnk_080CA6A4[])(Entity*) = {
void (*const gUnk_080CA6A4[])(RollobiteEntity*) = {
sub_0802077C,
sub_08020788,
sub_08020790,
@@ -317,7 +323,7 @@ void (*const gUnk_080CA6A4[])(Entity*) = {
sub_080207A8,
};
void (*const gUnk_080CA6BC[])(Entity*) = {
void (*const gUnk_080CA6BC[])(RollobiteEntity*) = {
sub_0802088C,
sub_080208B4,
sub_080208F0,
+121 -109
View File
@@ -4,204 +4,216 @@
*
* @brief Rope enemy
*/
#include "enemy.h"
#include "physics.h"
#include "tiles.h"
void Rope_OnTick(Entity*);
void Rope_OnCollision(Entity*);
void Rope_OnGrabbed(Entity*);
void sub_08031434(Entity*);
void sub_08031480(Entity*);
void sub_080314FC(Entity*);
void sub_080315BC(Entity*);
void sub_0803140C(Entity*);
void sub_08031418(Entity*);
void sub_08031420(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[16];
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unused2[1];
/*0x7a*/ u16 unk_7a;
} RopeEntity;
static void (*const Rope_Functions[6])(Entity*) = {
Rope_OnTick, Rope_OnCollision, GenericKnockback, GenericDeath, GenericConfused, Rope_OnGrabbed,
void Rope_OnTick(RopeEntity* this);
void Rope_OnCollision(RopeEntity* this);
void Rope_OnGrabbed(RopeEntity* this);
void sub_08031434(RopeEntity* this);
void sub_08031480(RopeEntity* this);
void sub_080314FC(RopeEntity* this);
void sub_080315BC(RopeEntity* this);
void sub_0803140C(RopeEntity* this);
void sub_08031418(RopeEntity* this);
void sub_08031420(RopeEntity* this);
static void (*const Rope_Functions[6])(RopeEntity*) = {
Rope_OnTick,
Rope_OnCollision,
(void (*)(RopeEntity*))GenericKnockback,
(void (*)(RopeEntity*))GenericDeath,
(void (*)(RopeEntity*))GenericConfused,
Rope_OnGrabbed,
};
extern Entity* gUnk_020000B0;
void sub_08031600(Entity*);
u32 sub_0803163C(Entity*);
void sub_08031600(RopeEntity* this);
u32 sub_0803163C(RopeEntity* this);
void Rope(Entity* this) {
EnemyFunctionHandler(this, Rope_Functions);
SetChildOffset(this, 0, 1, -16);
void Rope(RopeEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)Rope_Functions);
SetChildOffset(super, 0, 1, -16);
}
void Rope_OnTick(Entity* this) {
static void (*const actionFuncs[4])(Entity*) = {
void Rope_OnTick(RopeEntity* this) {
static void (*const actionFuncs[4])(RopeEntity*) = {
sub_08031434,
sub_08031480,
sub_080314FC,
sub_080315BC,
};
actionFuncs[this->action](this);
actionFuncs[super->action](this);
}
void Rope_OnCollision(Entity* this) {
if (this->action == 3) {
this->subtimer = 30;
this->field_0x78.HALF.LO = 0x3c;
void Rope_OnCollision(RopeEntity* this) {
if (super->action == 3) {
super->subtimer = 30;
this->unk_78 = 0x3c;
sub_08031600(this);
}
if (this->confusedTime) {
Create0x68FX(this, FX_STARS);
if (super->confusedTime) {
Create0x68FX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, Rope_Functions);
EnemyFunctionHandlerAfterCollision(super, Rope_Functions);
}
void Rope_OnGrabbed(Entity* this) {
static void (*const subActionFuncs[3])(Entity*) = {
void Rope_OnGrabbed(RopeEntity* this) {
static void (*const subActionFuncs[3])(RopeEntity*) = {
sub_0803140C,
sub_08031418,
sub_08031420,
};
if (sub_0806F520(this)) {
subActionFuncs[this->subAction](this);
if (sub_0806F520(super)) {
subActionFuncs[super->subAction](this);
}
}
void sub_0803140C(Entity* this) {
this->subAction = 1;
this->gustJarTolerance = 0x3c;
void sub_0803140C(RopeEntity* this) {
super->subAction = 1;
super->gustJarTolerance = 0x3c;
}
void sub_08031418(Entity* this) {
sub_0806F4E8(this);
void sub_08031418(RopeEntity* this) {
sub_0806F4E8(super);
}
void sub_08031420(Entity* this) {
if (sub_0806F3E4(this)) {
GenericDeath(this);
void sub_08031420(RopeEntity* this) {
if (sub_0806F3E4(super)) {
GenericDeath(super);
}
}
void sub_08031434(Entity* this) {
void sub_08031434(RopeEntity* this) {
sub_0804A720(this);
this->animationState = 0xff;
this->gustJarFlags = 1;
this->field_0x7a.HWORD = this->speed;
if (!(this->type)) {
sub_0804A720(super);
super->animationState = 0xff;
super->gustJarFlags = 1;
this->unk_7a = super->speed;
if (!(super->type)) {
sub_08031600(this);
} else {
this->action = 1;
this->subAction = 0;
this->spriteSettings.draw = (this->spriteSettings.draw & 0xfc);
this->z.HALF.HI = -0x80;
this->frameIndex = 0xff;
super->action = 1;
super->subAction = 0;
super->spriteSettings.draw = (super->spriteSettings.draw & 0xfc);
super->z.HALF.HI = -0x80;
super->frameIndex = 0xff;
}
}
void sub_08031480(Entity* this) {
if (this->subAction == 0) {
if (this->timer != 0) {
this->timer--;
void sub_08031480(RopeEntity* this) {
if (super->subAction == 0) {
if (super->timer != 0) {
super->timer--;
} else {
sub_08031600(this);
this->action = 1;
this->subAction = 1;
this->spriteSettings.draw = 3;
this->spriteRendering.b3 = 1;
this->spriteOrientation.flipY = 1;
super->action = 1;
super->subAction = 1;
super->spriteSettings.draw = 3;
super->spriteRendering.b3 = 1;
super->spriteOrientation.flipY = 1;
SoundReq(SFX_12D);
}
} else {
if (GravityUpdate(this, Q_8_8(24.0)) == 0) {
this->action = 2;
this->subtimer = 15;
this->spriteSettings.draw = 1;
UpdateSpriteForCollisionLayer(this);
if (GravityUpdate(super, Q_8_8(24.0)) == 0) {
super->action = 2;
super->subtimer = 15;
super->spriteSettings.draw = 1;
UpdateSpriteForCollisionLayer(super);
EnqueueSFX(SFX_WATER_SPLASH);
}
}
}
void sub_080314FC(Entity* this) {
void sub_080314FC(RopeEntity* this) {
u32 u;
GetNextFrame(this);
if (this->subtimer) {
this->subtimer--;
GetNextFrame(super);
if (super->subtimer) {
super->subtimer--;
} else {
if (this->field_0x78.HALF.LO) {
this->field_0x78.HALF.LO--;
if (this->unk_78) {
this->unk_78--;
}
if (sub_08049FA0(this)) {
if (!(this->field_0x78.HALF.LO)) {
if (sub_08049FDC(this, 1)) {
u = sub_0804A044(this, gUnk_020000B0, 0xc);
if (sub_08049FA0(super)) {
if (!(this->unk_78)) {
if (sub_08049FDC(super, 1)) {
u = sub_0804A044(super, gUnk_020000B0, 0xc);
if (u != 0xff) {
this->action = 3;
this->timer = 30;
this->field_0x7a.HWORD = this->speed = 0x1a0;
this->direction = u;
this->animationState = this->direction >> 3;
InitializeAnimation(this, this->animationState + 4);
super->action = 3;
super->timer = 30;
this->unk_7a = super->speed = 0x1a0;
super->direction = u;
super->animationState = super->direction >> 3;
InitializeAnimation(super, super->animationState + 4);
return;
}
}
}
} else {
if ((Random() & 1)) {
this->direction = DirectionRoundUp(sub_08049EE4(this));
u = this->direction >> 3;
if (u != this->animationState) {
this->animationState = u;
InitializeAnimation(this, u);
super->direction = DirectionRoundUp(sub_08049EE4(super));
u = super->direction >> 3;
if (u != super->animationState) {
super->animationState = u;
InitializeAnimation(super, u);
}
}
}
if (--this->timer == 0) {
if (--super->timer == 0) {
sub_08031600(this);
}
sub_0803163C(this);
}
}
void sub_080315BC(Entity* this) {
if (this->timer != 0) {
this->timer--;
UpdateAnimationVariableFrames(this, 2);
void sub_080315BC(RopeEntity* this) {
if (super->timer != 0) {
super->timer--;
UpdateAnimationVariableFrames(super, 2);
} else {
if (sub_08049FA0(this)) {
GetNextFrame(this);
if (sub_08049FA0(super)) {
GetNextFrame(super);
if (sub_0803163C(this)) {
return;
}
}
this->field_0x78.HALF.LO = 0x1e;
this->unk_78 = 0x1e;
sub_08031600(this);
}
}
void sub_08031600(Entity* this) {
void sub_08031600(RopeEntity* this) {
u32 r;
this->action = 2;
this->timer = (Random() & 0x30) + 60;
this->speed = 0x80;
this->field_0x7a.HWORD = 0x80;
super->action = 2;
super->timer = (Random() & 0x30) + 60;
super->speed = 0x80;
this->unk_7a = 0x80;
r = Random() & 0x18;
this->direction = r;
super->direction = r;
r = r / 8;
if (r != this->animationState) {
this->animationState = r;
InitializeAnimation(this, r);
if (r != super->animationState) {
super->animationState = r;
InitializeAnimation(super, r);
}
}
u32 sub_0803163C(Entity* this) {
u32 sub_0803163C(RopeEntity* this) {
u32 h;
if (GetVvvAtEntity(this) == VVV_19) {
h = this->field_0x7a.HWORD / 2;
if (GetVvvAtEntity(super) == VVV_19) {
h = this->unk_7a / 2;
} else {
h = this->field_0x7a.HWORD;
h = this->unk_7a;
}
this->speed = h;
return ProcessMovement0(this);
super->speed = h;
return ProcessMovement0(super);
}
+94 -83
View File
@@ -4,166 +4,177 @@
*
* @brief Golden Rope enemy
*/
#include "global.h"
#include "entity.h"
#include "enemy.h"
#include "entity.h"
#include "physics.h"
#include "player.h"
#include "item.h"
void RopeGolden_OnTick(Entity*);
void RopeGolden_OnCollision(Entity*);
void RopeGolden_OnDeath(Entity*);
void sub_08038258(Entity*);
void sub_0803827C(Entity*);
void sub_080382EC(Entity*);
void sub_08038304(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[16];
/*0x78*/ u8 unk_78;
/*0x79*/ u8 unk_79;
/*0x7a*/ u8 unk_7a;
} RopeGoldenEntity;
static void (*const RopeGolden_Functions[6])(Entity*) = {
RopeGolden_OnTick, RopeGolden_OnCollision, GenericKnockback, RopeGolden_OnDeath, GenericConfused, RopeGolden_OnTick,
void RopeGolden_OnTick(RopeGoldenEntity* this);
void RopeGolden_OnCollision(RopeGoldenEntity* this);
void RopeGolden_OnDeath(RopeGoldenEntity* this);
void sub_08038258(RopeGoldenEntity* this);
void sub_0803827C(RopeGoldenEntity* this);
void sub_080382EC(RopeGoldenEntity* this);
void sub_08038304(RopeGoldenEntity* this);
static void (*const RopeGolden_Functions[6])(RopeGoldenEntity*) = {
RopeGolden_OnTick,
RopeGolden_OnCollision,
(void (*)(RopeGoldenEntity*))GenericKnockback,
RopeGolden_OnDeath,
(void (*)(RopeGoldenEntity*))GenericConfused,
RopeGolden_OnTick,
};
void sub_080383AC(Entity*);
void sub_080383E4(Entity*);
void sub_080383AC(RopeGoldenEntity* this);
void sub_080383E4(RopeGoldenEntity* this);
void RopeGolden(Entity* this) {
void RopeGolden(RopeGoldenEntity* this) {
u32 x;
x = sub_080012DC(this);
x = sub_080012DC(super);
if (x != 0) {
gUnk_080012C8[x](this);
gUnk_080012C8[x](super);
} else {
RopeGolden_Functions[GetNextFunction(this)](this);
SetChildOffset(this, 0, 1, -0x10);
RopeGolden_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
}
}
void RopeGolden_OnTick(Entity* this) {
static void (*const actionFuncs[4])(Entity*) = {
void RopeGolden_OnTick(RopeGoldenEntity* this) {
static void (*const actionFuncs[4])(RopeGoldenEntity*) = {
sub_08038258,
sub_0803827C,
sub_080382EC,
sub_08038304,
};
actionFuncs[this->action](this);
actionFuncs[super->action](this);
}
void RopeGolden_OnCollision(Entity* this) {
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
void RopeGolden_OnCollision(RopeGoldenEntity* this) {
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(this, RopeGolden_Functions);
EnemyFunctionHandlerAfterCollision(super, RopeGolden_Functions);
}
void RopeGolden_OnDeath(Entity* this) {
if ((this->gustJarState & 2) == 0) {
SetGlobalFlag(this->type2);
void RopeGolden_OnDeath(RopeGoldenEntity* this) {
if ((super->gustJarState & 2) == 0) {
SetGlobalFlag(super->type2);
}
CreateDeathFx(this, 0xff, ITEM_RUPEE100);
CreateDeathFx(super, 0xff, ITEM_RUPEE100);
}
void sub_08038258(Entity* this) {
if (CheckGlobalFlag(this->type2) != 0) {
void sub_08038258(RopeGoldenEntity* this) {
if (CheckGlobalFlag(super->type2) != 0) {
DeleteThisEntity();
}
sub_0804A720(this);
this->animationState = 0xff;
sub_0804A720(super);
super->animationState = 0xff;
sub_080383AC(this);
}
void sub_0803827C(Entity* this) {
if (this->subtimer != 0) {
this->subtimer--;
void sub_0803827C(RopeGoldenEntity* this) {
if (super->subtimer != 0) {
super->subtimer--;
} else {
if ((sub_0804A044(this, &gPlayerEntity, 0x8) != 0xff) ||
(EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x24) != 0)) {
if ((sub_0804A044(super, &gPlayerEntity.base, 0x8) != 0xff) ||
(EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, 0x24) != 0)) {
sub_080383E4(this);
return;
}
}
UpdateAnimationVariableFrames(this, 0x2);
if (!ProcessMovement0(this)) {
UpdateAnimationVariableFrames(super, 0x2);
if (!ProcessMovement0(super)) {
sub_080383AC(this);
} else {
if (--this->timer == 0) {
if (--super->timer == 0) {
sub_080383AC(this);
}
}
}
void sub_080382EC(Entity* this) {
if (--this->timer == 0) {
this->action = 3;
void sub_080382EC(RopeGoldenEntity* this) {
if (--super->timer == 0) {
super->action = 3;
}
}
void sub_08038304(Entity* this) {
void sub_08038304(RopeGoldenEntity* this) {
u32 cVar2;
s32 tmp;
u32 tmp3;
u32 h;
UpdateAnimationVariableFrames(this, 2);
if (!ProcessMovement0(this)) {
if (this->field_0x78.HALF.LO == this->direction) {
UpdateAnimationVariableFrames(super, 2);
if (!ProcessMovement0(super)) {
if (this->unk_78 == super->direction) {
#ifdef EU
this->subtimer = 30;
super->subtimer = 30;
#else
this->subtimer = 90;
super->subtimer = 90;
#endif
sub_080383AC(this);
} else {
this->direction = this->field_0x78.HALF.LO;
super->direction = this->unk_78;
}
} else {
tmp = 10;
if ((u8)((++this->timer) % tmp) == 0) {
this->timer = 0;
if (this->field_0x78.HALF.LO == this->direction) {
if ((u8)((++super->timer) % tmp) == 0) {
super->timer = 0;
if (this->unk_78 == super->direction) {
cVar2 = ((Random() & 2) - 1) << 27;
cVar2 = cVar2 >> 24;
h = this->field_0x78.HALF.HI;
h = this->unk_79;
tmp3 = (u8)cVar2 << 24;
if (tmp3 >> 24 == h) {
if (h == this->field_0x7a.HALF.LO) {
if (h == this->unk_7a) {
cVar2 = -tmp3 >> 24;
}
}
this->field_0x7a.HALF.LO = this->field_0x78.HALF.HI;
this->field_0x78.HALF.HI = cVar2;
this->direction = (this->direction + cVar2) & DirectionWest;
this->unk_7a = this->unk_79;
this->unk_79 = cVar2;
super->direction = (super->direction + cVar2) & DirectionWest;
} else {
this->direction = this->field_0x78.HALF.LO;
super->direction = this->unk_78;
}
this->animationState = this->direction >> 3;
InitializeAnimation(this, this->animationState + 4);
super->animationState = super->direction >> 3;
InitializeAnimation(super, super->animationState + 4);
}
}
}
void sub_080383AC(Entity* this) {
void sub_080383AC(RopeGoldenEntity* this) {
u32 v;
this->action = 1;
this->timer = 8;
this->speed = 0x100;
this->direction = DirectionRoundUp(GetFacingDirection(this, &gPlayerEntity));
v = this->direction >> 3;
if (v != this->animationState) {
this->animationState = v;
InitializeAnimation(this, v);
super->action = 1;
super->timer = 8;
super->speed = 0x100;
super->direction = DirectionRoundUp(GetFacingDirection(super, &gPlayerEntity.base));
v = super->direction >> 3;
if (v != super->animationState) {
super->animationState = v;
InitializeAnimation(super, v);
}
}
void sub_080383E4(Entity* this) {
void sub_080383E4(RopeGoldenEntity* this) {
u32 v;
this->action = 2;
this->timer = 8;
this->speed = 0x280;
v = DirectionRoundUp(GetFacingDirection(this, &gPlayerEntity));
this->direction = v;
this->field_0x78.HALF.LO = v;
this->animationState = this->direction >> 3;
this->field_0x78.HALF.HI = 0xff;
this->field_0x7a.HALF.LO = -1;
InitializeAnimation(this, this->animationState + 4);
super->action = 2;
super->timer = 8;
super->speed = 0x280;
v = DirectionRoundUp(GetFacingDirection(super, &gPlayerEntity.base));
super->direction = v;
this->unk_78 = v;
super->animationState = super->direction >> 3;
this->unk_79 = 0xff;
this->unk_7a = -1;
InitializeAnimation(super, super->animationState + 4);
}
+176 -168
View File
@@ -4,303 +4,311 @@
*
* @brief Rupee Like enemy
*/
#include "global.h"
#include "entity.h"
#include "enemy.h"
#include "object.h"
#include "save.h"
#include "entity.h"
#include "hitbox.h"
#include "object.h"
#include "room.h"
#include "save.h"
extern void sub_080293DC(Entity*);
extern void sub_080296D8(Entity*);
extern void sub_08029770(Entity*);
extern void sub_080297F0(Entity*);
extern void sub_080296C8(Entity*);
extern void sub_0802969C(Entity*);
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[24];
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
/*0x83*/ u8 unk_83;
/*0x84*/ u8 unk_84;
} RupeeLikeEntity;
extern void (*const RupeeLike_Functions[])(Entity*);
extern void (*const gUnk_080CCC18[])(Entity*);
extern void (*const gUnk_080CCC3C[])(Entity*);
extern void sub_080293DC(RupeeLikeEntity* this);
extern void sub_080296D8(RupeeLikeEntity* this);
extern void sub_08029770(RupeeLikeEntity* this);
extern void sub_080297F0(RupeeLikeEntity* this);
extern void sub_080296C8(RupeeLikeEntity* this);
extern void sub_0802969C(RupeeLikeEntity* this);
extern void (*const RupeeLike_Functions[])(RupeeLikeEntity*);
extern void (*const gUnk_080CCC18[])(RupeeLikeEntity*);
extern void (*const gUnk_080CCC3C[])(RupeeLikeEntity*);
extern const u8 gUnk_080CCC34[];
extern const s8 gUnk_080CCC44[];
extern const u8 gUnk_080CCC47[];
void RupeeLike(Entity* this) {
void RupeeLike(RupeeLikeEntity* this) {
u32 uVar1;
if (this->type2 == 0) {
uVar1 = (u8)sub_080043E8(this);
if (super->type2 == 0) {
uVar1 = (u8)sub_080043E8(super);
if (uVar1 != 0) {
if (this->action == 4) {
if (super->action == 4) {
sub_080296D8(this);
}
sub_08001290(this, uVar1);
sub_08001290(super, uVar1);
} else {
RupeeLike_Functions[GetNextFunction(this)](this);
SetChildOffset(this, 0, 1, -0x10);
RupeeLike_Functions[GetNextFunction(super)](this);
SetChildOffset(super, 0, 1, -0x10);
}
} else {
sub_080293DC(this);
}
}
void RupeeLike_OnTick(Entity* this) {
gUnk_080CCC18[this->action](this);
void RupeeLike_OnTick(RupeeLikeEntity* this) {
gUnk_080CCC18[super->action](this);
}
void RupeeLike_OnCollision(Entity* this) {
if (this->hitType == 0x8e) {
void RupeeLike_OnCollision(RupeeLikeEntity* this) {
if (super->hitType == 0x8e) {
sub_08029770(this);
} else {
if (this->action == 4) {
if (super->action == 4) {
sub_080296D8(this);
}
if (*(u8*)(*(u32*)&this->contactedEntity + 8) == 1) {
if (this->action == 2) {
InitializeAnimation(this, 0);
InitializeAnimation(this->child, 4);
if (*(u8*)(*(u32*)&super->contactedEntity + 8) == 1) {
if (super->action == 2) {
InitializeAnimation(super, 0);
InitializeAnimation(super->child, 4);
}
this->action = 4;
this->timer = 60;
this->subtimer = 0;
this->field_0x82.HALF.HI = 0x41;
this->flags2 &= 0xfc;
this->field_0x80.HALF.LO = gPlayerEntity.spritePriority.b1;
super->action = 4;
super->timer = 60;
super->subtimer = 0;
this->unk_83 = 0x41;
super->flags2 &= 0xfc;
this->unk_80 = gPlayerEntity.base.spritePriority.b1;
EnqueueSFX(SFX_PLACE_OBJ);
} else {
if (this->confusedTime != 0) {
Create0x68FX(this, FX_STARS);
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
}
}
}
EnemyFunctionHandlerAfterCollision(this, RupeeLike_Functions);
EnemyFunctionHandlerAfterCollision(super, RupeeLike_Functions);
}
void RupeeLike_OnDeath(Entity* this) {
CreateDeathFx(this, 0xff, gUnk_080CCC34[this->cutsceneBeh.HALF.LO * 3 + this->type]);
void RupeeLike_OnDeath(RupeeLikeEntity* this) {
CreateDeathFx(super, 0xff, gUnk_080CCC34[this->unk_84 * 3 + super->type]);
}
void RupeeLike_OnGrabbed(Entity* this) {
void RupeeLike_OnGrabbed(RupeeLikeEntity* this) {
}
void sub_080293DC(Entity* this) {
CopyPositionAndSpriteOffset(this->parent, this);
this->y.HALF.HI++;
this->z.HALF.HI--;
gUnk_080CCC3C[this->action](this);
void sub_080293DC(RupeeLikeEntity* this) {
CopyPositionAndSpriteOffset(super->parent, super);
super->y.HALF.HI++;
super->z.HALF.HI--;
gUnk_080CCC3C[super->action](this);
}
void sub_0802940C(Entity* this) {
Entity* ent;
void sub_0802940C(RupeeLikeEntity* this) {
Entity* entity;
ent = CreateEnemy(RUPEE_LIKE, this->type);
if (ent != NULL) {
sub_0804A720(this);
ent->parent = this;
ent->type2 = 1;
this->child = ent;
this->field_0x80.HALF.HI = 0;
this->cutsceneBeh.HALF.LO = 0;
this->field_0x82.HALF.LO = this->palette.b.b0;
entity = CreateEnemy(RUPEE_LIKE, super->type);
if (entity != NULL) {
sub_0804A720(super);
entity->parent = super;
entity->type2 = 1;
super->child = entity;
this->unk_81 = 0;
this->unk_84 = 0;
this->unk_82 = super->palette.b.b0;
sub_080297F0(this);
}
}
void sub_0802944C(Entity* this) {
void sub_0802944C(RupeeLikeEntity* this) {
sub_080296C8(this);
if ((this->field_0x80.HALF.HI != 0) && sub_08049FDC(this, 1)) {
if ((this->unk_81 != 0) && sub_08049FDC(super, 1)) {
sub_08029770(this);
}
}
void sub_08029474(Entity* this) {
void sub_08029474(RupeeLikeEntity* this) {
u32 bVar1;
sub_080296C8(this);
if (this->frame & ANIM_DONE) {
this->action = 3;
this->timer = 8;
bVar1 = GetFacingDirection(this, &gPlayerEntity);
this->direction = bVar1;
this->animationState = (bVar1 << 0x18) >> 0x1c;
InitializeAnimation(this, this->animationState);
InitializeAnimation(this->child, this->animationState + 4);
if (super->frame & ANIM_DONE) {
super->action = 3;
super->timer = 8;
bVar1 = GetFacingDirection(super, &gPlayerEntity.base);
super->direction = bVar1;
super->animationState = (bVar1 << 0x18) >> 0x1c;
InitializeAnimation(super, super->animationState);
InitializeAnimation(super->child, super->animationState + 4);
} else {
if (this->frame == 1) {
this->frame = 0;
COLLISION_ON(this);
if (super->frame == 1) {
super->frame = 0;
COLLISION_ON(super);
}
}
}
void sub_080294D4(Entity* this) {
if (sub_08049FDC(this, 1) != 0) {
if (--this->timer == 0) {
this->timer = 8;
sub_08004596(this, GetFacingDirection(this, &gPlayerEntity));
void sub_080294D4(RupeeLikeEntity* this) {
if (sub_08049FDC(super, 1) != 0) {
if (--super->timer == 0) {
super->timer = 8;
sub_08004596(super, GetFacingDirection(super, &gPlayerEntity.base));
sub_0802969C(this);
}
ProcessMovement0(this);
ProcessMovement0(super);
sub_080296C8(this);
} else {
this->action = 6;
COLLISION_OFF(this);
InitializeAnimation(this, 3);
InitializeAnimation(this->child, 7);
super->action = 6;
COLLISION_OFF(super);
InitializeAnimation(super, 3);
InitializeAnimation(super->child, 7);
}
}
void sub_0802953C(Entity* this) {
void sub_0802953C(RupeeLikeEntity* this) {
u8* pbVar3;
sub_080296C8(this);
sub_080296C8(this);
if (sub_0807953C() != 0) {
this->subtimer++;
super->subtimer++;
}
if (this->timer != 0) {
this->timer--;
if (super->timer != 0) {
super->timer--;
}
if (((this->subtimer > 0x2d) || (gSave.stats.rupees == 0)) && (this->timer == 0)) {
if (((super->subtimer > 0x2d) || (gSave.stats.rupees == 0)) && (super->timer == 0)) {
sub_080296D8(this);
} else {
ResetActiveItems();
gPlayerState.mobility |= 0x80;
PositionRelative(this, &gPlayerEntity, 0, Q_16_16(1.0));
pbVar3 = GetSpriteSubEntryOffsetDataPointer((u16)this->spriteIndex, this->frameIndex);
gPlayerEntity.spriteOffsetX = pbVar3[0];
gPlayerEntity.spriteOffsetY = pbVar3[1] - 1;
gPlayerEntity.spritePriority.b1 = 0;
if (--this->field_0x82.HALF.HI == 0) {
this->field_0x82.HALF.HI = 0x41;
PositionRelative(super, &gPlayerEntity.base, 0, Q_16_16(1.0));
pbVar3 = GetSpriteSubEntryOffsetDataPointer((u16)super->spriteIndex, super->frameIndex);
gPlayerEntity.base.spriteOffsetX = pbVar3[0];
gPlayerEntity.base.spriteOffsetY = pbVar3[1] - 1;
gPlayerEntity.base.spritePriority.b1 = 0;
if (--this->unk_83 == 0) {
this->unk_83 = 0x41;
if (gSave.stats.rupees != 0) {
ModRupees(gUnk_080CCC44[this->type]);
this->cutsceneBeh.HALF.LO = 1;
ModRupees(gUnk_080CCC44[super->type]);
this->unk_84 = 1;
}
}
}
}
void sub_08029610(Entity* this) {
if (--this->subtimer == 0) {
this->action = 3;
this->timer = 1;
void sub_08029610(RupeeLikeEntity* this) {
if (--super->subtimer == 0) {
super->action = 3;
super->timer = 1;
}
sub_080296C8(this);
}
void sub_08029630(Entity* this) {
void sub_08029630(RupeeLikeEntity* this) {
sub_080296C8(this);
if (this->frame & ANIM_DONE) {
this->field_0x80.HALF.HI = 1;
this->child->spriteSettings.draw = FALSE;
if (super->frame & ANIM_DONE) {
this->unk_81 = 1;
super->child->spriteSettings.draw = FALSE;
sub_080297F0(this);
}
}
void sub_08029660(Entity* this) {
void sub_08029660(RupeeLikeEntity* this) {
u32 temp;
this->action = 1;
this->spriteIndex = 0xd1;
temp = gUnk_080CCC47[this->type];
this->palette.b.b0 = temp;
super->action = 1;
super->spriteIndex = 0xd1;
temp = gUnk_080CCC47[super->type];
super->palette.b.b0 = temp;
}
void sub_08029688(Entity* this) {
if (this->parent->next == NULL) {
DeleteEntity(this);
void sub_08029688(RupeeLikeEntity* this) {
if (super->parent->next == NULL) {
DeleteEntity(super);
}
}
void sub_0802969C(Entity* this) {
void sub_0802969C(RupeeLikeEntity* this) {
u32 bVar1;
if (this->direction & (0x3 | DIR_DIAGONAL | DirectionEast)) {
if (super->direction & (0x3 | DIR_DIAGONAL | DirectionEast)) {
bVar1 = this->direction >> 4;
if (bVar1 != this->animationState) {
this->animationState = bVar1;
InitializeAnimation(this, bVar1);
InitializeAnimation(this->child, bVar1 + 4);
bVar1 = super->direction >> 4;
if (bVar1 != super->animationState) {
super->animationState = bVar1;
InitializeAnimation(super, bVar1);
InitializeAnimation(super->child, bVar1 + 4);
}
}
}
void sub_080296C8(Entity* this) {
GetNextFrame(this);
GetNextFrame(this->child);
void sub_080296C8(RupeeLikeEntity* this) {
GetNextFrame(super);
GetNextFrame(super->child);
}
void sub_080296D8(Entity* this) {
void sub_080296D8(RupeeLikeEntity* this) {
gPlayerState.jump_status = 0x41;
gPlayerState.flags &= ~PL_CAPTURED;
gPlayerEntity.flags |= ENT_COLLIDE;
gPlayerEntity.zVelocity = Q_16_16(1.5);
gPlayerEntity.iframes = 0xa6;
gPlayerEntity.z.HALF.HI = -2;
gPlayerEntity.direction = gPlayerEntity.animationState << 2;
gPlayerEntity.spritePriority.b1 = this->field_0x80.HALF.LO;
gPlayerEntity.spriteOffsetY = 0;
gPlayerEntity.speed = 0x140;
this->action = 5;
this->subtimer = 60;
this->flags2 |= 3;
if ((s8)this->iframes == 0) {
this->iframes = 0xf4;
gPlayerEntity.base.flags |= ENT_COLLIDE;
gPlayerEntity.base.zVelocity = Q_16_16(1.5);
gPlayerEntity.base.iframes = 0xa6;
gPlayerEntity.base.z.HALF.HI = -2;
gPlayerEntity.base.direction = gPlayerEntity.base.animationState << 2;
gPlayerEntity.base.spritePriority.b1 = this->unk_80;
gPlayerEntity.base.spriteOffsetY = 0;
gPlayerEntity.base.speed = 0x140;
super->action = 5;
super->subtimer = 60;
super->flags2 |= 3;
if ((s8)super->iframes == 0) {
super->iframes = 0xf4;
}
}
void sub_08029770(Entity* this) {
void sub_08029770(RupeeLikeEntity* this) {
u32 temp;
if (LoadFixedGFX(this, 0x73) != 0) {
this->action = 2;
COLLISION_OFF(this);
this->spriteIndex = 0xd1;
this->spritePriority.b1 = 3;
temp = this->field_0x82.HALF.LO;
this->palette.b.b0 = temp;
this->hitType = 0x8d;
this->hitbox = (Hitbox*)&gUnk_080FD260;
InitializeAnimation(this, 2);
this->child->spriteSettings.draw = TRUE;
InitializeAnimation(this->child, 6);
CreateDust(this);
if (LoadFixedGFX(super, 0x73) != 0) {
super->action = 2;
COLLISION_OFF(super);
super->spriteIndex = 0xd1;
super->spritePriority.b1 = 3;
temp = this->unk_82;
super->palette.b.b0 = temp;
super->hitType = 0x8d;
super->hitbox = (Hitbox*)&gUnk_080FD260;
InitializeAnimation(super, 2);
super->child->spriteSettings.draw = TRUE;
InitializeAnimation(super->child, 6);
CreateDust(super);
}
}
void sub_080297F0(Entity* this) {
void sub_080297F0(RupeeLikeEntity* this) {
u32 temp;
this->action = 1;
this->timer = 120;
COLLISION_ON(this);
this->spriteSettings.draw = TRUE;
this->hitType = 0x8e;
UnloadGFXSlots(this);
super->action = 1;
super->timer = 120;
COLLISION_ON(super);
super->spriteSettings.draw = TRUE;
super->hitType = 0x8e;
UnloadGFXSlots(super);
#ifdef EU
this->spriteIndex = 0x142;
super->spriteIndex = 0x142;
#else
this->spriteIndex = 0x143;
super->spriteIndex = 0x143;
#endif
temp = gUnk_080CCC47[this->type];
this->palette.b.b0 = temp;
this->spriteVramOffset = 9;
InitializeAnimation(this, 0x54);
temp = gUnk_080CCC47[super->type];
super->palette.b.b0 = temp;
super->spriteVramOffset = 9;
InitializeAnimation(super, 0x54);
}
// clang-format off
void (*const RupeeLike_Functions[])(Entity*) = {
void (*const RupeeLike_Functions[])(RupeeLikeEntity*) = {
RupeeLike_OnTick,
RupeeLike_OnCollision,
GenericKnockback,
(void (*)(RupeeLikeEntity*))GenericKnockback,
RupeeLike_OnDeath,
GenericConfused,
(void (*)(RupeeLikeEntity*))GenericConfused,
RupeeLike_OnGrabbed,
};
void (*const gUnk_080CCC18[])(Entity*) = {
void (*const gUnk_080CCC18[])(RupeeLikeEntity*) = {
sub_0802940C,
sub_0802944C,
sub_08029474,
@@ -316,7 +324,7 @@ const u8 gUnk_080CCC34[] = {
0x56, 0x57,
};
void (*const gUnk_080CCC3C[])(Entity*) = {
void (*const gUnk_080CCC3C[])(RupeeLikeEntity*) = {
sub_08029660,
sub_08029688,
};

Some files were not shown because too many files have changed in this diff Show More