From a818f1b7041898d7eee28b5c1c455ba3225e063f Mon Sep 17 00:00:00 2001 From: octorock <79596758+octorock@users.noreply.github.com> Date: Sat, 30 Dec 2023 22:08:56 +0100 Subject: [PATCH] Use new entity struct for player --- include/entity.h | 7 +- include/new_player.h | 26 - include/object/deathFx.h | 3 - include/object/linkAnimation.h | 3 - include/object/pushableFurniture.h | 25 + include/player.h | 21 +- include/playerItem/playerItemBottle.h | 13 + src/beanstalkSubtask.c | 222 +- src/code_08049DF4.c | 16 +- src/collision.c | 75 +- src/enemy/armos.c | 8 +- src/enemy/beetle.c | 12 +- src/enemy/bobomb.c | 8 +- src/enemy/bombPeahat.c | 2 +- src/enemy/businessScrub.c | 2 +- src/enemy/chuchuBoss.c | 34 +- src/enemy/cuccoAggr.c | 6 +- src/enemy/cuccoChickAggr.c | 4 +- src/enemy/dust.c | 17 +- src/enemy/enemy50.c | 6 +- src/enemy/enemy64.c | 30 +- src/enemy/fallingBoulder.c | 2 +- src/enemy/flyingPot.c | 2 +- src/enemy/flyingSkull.c | 14 +- src/enemy/ghini.c | 24 +- src/enemy/gibdo.c | 16 +- src/enemy/gleerok.c | 42 +- src/enemy/gyorgChild.c | 4 +- src/enemy/gyorgFemale.c | 10 +- src/enemy/gyorgFemaleEye.c | 4 +- src/enemy/gyorgFemaleMouth.c | 4 +- src/enemy/gyorgMale.c | 51 +- src/enemy/helmasaur.c | 2 +- src/enemy/keese.c | 4 +- src/enemy/lakitu.c | 8 +- src/enemy/lakituCloud.c | 2 +- src/enemy/likeLike.c | 24 +- src/enemy/mazaalBracelet.c | 48 +- src/enemy/mazaalHead.c | 8 +- src/enemy/moldworm.c | 40 +- src/enemy/octorokBoss.c | 63 +- src/enemy/octorokGolden.c | 6 +- src/enemy/pesto.c | 30 +- src/enemy/rollobite.c | 6 +- src/enemy/ropeGolden.c | 8 +- src/enemy/rupeeLike.c | 30 +- src/enemy/spinyBeetle.c | 8 +- src/enemy/stalfos.c | 4 +- src/enemy/sub_080451CC.c | 11 +- src/enemy/treeItem.c | 8 +- src/enemy/vaatiArm.c | 6 +- src/enemy/vaatiEyesMacro.c | 4 +- src/enemy/vaatiProjectile.c | 22 +- src/enemy/vaatiRebornEnemy.c | 14 +- src/enemy/vaatiTransfigured.c | 2 +- src/enemy/vaatiWrath.c | 26 +- src/enemy/wallMaster.c | 18 +- src/enemy/wallMaster2.c | 8 +- src/enemy/waterDrop.c | 4 +- src/enemy/wizzrobeFire.c | 2 +- src/enemy/wizzrobeIce.c | 2 +- src/enemy/wizzrobeWind.c | 2 +- src/entity.c | 65 +- src/game.c | 4 +- src/gameUtils.c | 41 +- src/interrupts.c | 25 +- src/item/itemBomb.c | 4 +- src/item/itemBoomerang.c | 2 +- src/item/itemBow.c | 2 +- src/item/itemGustJar.c | 28 +- src/item/itemJarEmpty.c | 12 +- src/item/itemLantern.c | 31 +- src/item/itemMoleMitts.c | 56 +- src/item/itemOcarina.c | 15 +- src/item/itemPacciCane.c | 2 +- src/item/itemPegasusBoots.c | 29 +- src/item/itemRocsCape.c | 23 +- src/item/itemShield.c | 2 +- src/item/itemSword.c | 32 +- src/item/itemTryPickupObject.c | 33 +- src/itemUtils.c | 2 +- src/manager/cloudStaircaseTransitionManager.c | 2 +- src/manager/diggingCaveEntranceManager.c | 16 +- src/manager/ezloHintManager.c | 4 +- src/manager/fightManager.c | 3 +- src/manager/holeManager.c | 6 +- src/manager/hyruleTownBellManager.c | 6 +- src/manager/lightManager.c | 8 +- src/manager/lightRayManager.c | 4 +- src/manager/miscManager.c | 12 +- src/manager/moveableObjectManager.c | 3 +- src/manager/pushableFurnitureManager.c | 27 +- src/manager/rollingBarrelManager.c | 26 +- src/manager/specialWarpManager.c | 4 +- src/manager/templeOfDropletsManager.c | 6 +- src/manager/tilePuzzleManager.c | 4 +- src/manager/vaati3StartManager.c | 14 +- src/manager/waterfallBottomManager.c | 8 +- src/manager/weatherChangeManager.c | 4 +- src/npc/anju.c | 4 +- src/npc/beedle.c | 6 +- src/npc/bigGoron.c | 10 +- src/npc/bladeBrothers.c | 2 +- src/npc/brocco.c | 4 +- src/npc/carpenter.c | 5 +- src/npc/castleMaid.c | 3 +- src/npc/cat.c | 10 +- src/npc/dampe.c | 4 +- src/npc/din.c | 4 +- src/npc/dog.c | 4 +- src/npc/epona.c | 3 +- src/npc/ezlo.c | 18 +- src/npc/farore.c | 4 +- src/npc/festari.c | 2 +- src/npc/gentari.c | 4 +- src/npc/ghostBrothers.c | 4 +- src/npc/gina.c | 4 +- src/npc/gregal.c | 4 +- src/npc/guard.c | 8 +- src/npc/guardWithSpear.c | 20 +- src/npc/hurdyGurdyMan.c | 3 +- src/npc/kid.c | 32 +- src/npc/kingDaltus.c | 3 +- src/npc/malon.c | 2 +- src/npc/mama.c | 3 +- src/npc/mayorHagen.c | 4 +- src/npc/ministerPotho.c | 4 +- src/npc/mountainMinish.c | 5 +- src/npc/mutoh.c | 4 +- src/npc/nayru.c | 4 +- src/npc/npc23.c | 26 +- src/npc/npc5.c | 34 +- src/npc/percy.c | 4 +- src/npc/pina.c | 4 +- src/npc/postman.c | 18 +- src/npc/sittingPerson.c | 2 +- src/npc/smith.c | 2 +- src/npc/stockwell.c | 2 +- src/npc/sturgeon.c | 4 +- src/npc/talon.c | 2 +- src/npc/teachers.c | 4 +- src/npc/tingleSiblings.c | 2 +- src/npc/townMinish.c | 8 +- src/npc/townsperson.c | 6 +- src/npc/zelda.c | 2 +- src/npc/zeldaFollower.c | 46 +- src/npcUtils.c | 10 +- src/object/ambientClouds.c | 28 +- src/object/bakerOven.c | 14 +- src/object/barrelSpiderweb.c | 6 +- src/object/beanstalk.c | 6 +- src/object/bigPushableLever.c | 6 +- src/object/bigVortex.c | 10 +- src/object/bird.c | 36 +- src/object/board.c | 6 +- src/object/book.c | 8 +- src/object/bossDoor.c | 2 +- src/object/bush.c | 2 +- src/object/button.c | 6 +- src/object/cameraTarget.c | 2 +- src/object/chestSpawner.c | 6 +- src/object/cloud.c | 2 +- src/object/crenelBeanSprout.c | 12 +- src/object/cutsceneMiscObject.c | 20 +- src/object/dirtParticle.c | 2 +- src/object/doubleBookshelf.c | 2 +- src/object/evilSpirit.c | 9 +- src/object/ezloCap.c | 18 +- src/object/ezloCapFlying.c | 33 +- src/object/fairy.c | 8 +- src/object/fan.c | 6 +- src/object/figurineDevice.c | 8 +- src/object/floatingPlatform.c | 4 +- src/object/fourElements.c | 2 +- src/object/frozenOctorok.c | 2 +- src/object/furniture.c | 11 +- src/object/giantTwig.c | 2 +- src/object/gleerokParticle.c | 2 +- src/object/graveyardKey.c | 11 +- src/object/greatFairy.c | 8 +- src/object/gustJarParticle.c | 8 +- src/object/gyorgBossObject.c | 8 +- src/object/houseDoorExterior.c | 2 +- src/object/houseDoorInterior.c | 3 +- src/object/itemForSale.c | 11 +- src/object/itemOnGround.c | 10 +- src/object/keyStealingTakkuri.c | 15 +- src/object/ladderHoleInBookshelf.c | 10 +- src/object/ladderUp.c | 2 +- src/object/lavaPlatform.c | 4 +- src/object/lightRay.c | 28 +- src/object/lilypadLarge.c | 64 +- src/object/lilypadSmall.c | 4 +- src/object/linkAnimation.c | 20 +- src/object/linkEmptyingBottle.c | 12 +- src/object/linkFire.c | 20 +- src/object/lockedDoor.c | 8 +- src/object/macroBook.c | 4 +- src/object/mask.c | 10 +- src/object/mazaalBossObject.c | 3 +- src/object/minecart.c | 68 +- src/object/minecartDoor.c | 16 +- src/object/minishEmoticon.c | 2 +- src/object/minishSizedEntrance.c | 5 +- src/object/moleMittsParticle.c | 4 +- src/object/object1F.c | 2 +- src/object/object37.c | 2 +- src/object/object70.c | 34 +- src/object/objectA8.c | 8 +- src/object/objectBlockingStairs.c | 14 +- src/object/objectOnPillar.c | 10 +- src/object/objectOnSpinyBeetle.c | 2 +- src/object/octorokBossObject.c | 2 +- src/object/paper.c | 3 +- src/object/playerClone.c | 42 +- src/object/pot.c | 4 +- src/object/pressurePlate.c | 2 +- src/object/pullableLever.c | 16 +- src/object/pullableMushroom.c | 33 +- src/object/pushableFurniture.c | 29 +- src/object/pushableGrave.c | 2 +- src/object/pushableLever.c | 6 +- src/object/pushableStatue.c | 22 +- src/object/shrinkingHieroglyphs.c | 4 +- src/object/specialFx.c | 4 +- src/object/steam.c | 2 +- src/object/swordParticle.c | 16 +- src/object/thunderbolt.c | 2 +- src/object/trapdoor.c | 4 +- src/object/treeHidingPortal.c | 8 +- src/object/vaati1Portal.c | 4 +- src/object/vaati3PlayerObject.c | 2 +- src/object/warpPoint.c | 41 +- src/object/well.c | 4 +- src/object/whirlwind.c | 23 +- src/object/windTribeTeleporter.c | 26 +- src/objectUtils.c | 20 +- src/physics.c | 37 +- src/player.c | 2828 +++++++++-------- src/playerItem.c | 15 +- src/playerItem/playerItemBoomerang.c | 22 +- src/playerItem/playerItemBottle.c | 34 +- src/playerItem/playerItemBow.c | 20 +- src/playerItem/playerItemCellOverwriteSet.c | 2 +- src/playerItem/playerItemDashSword.c | 10 +- src/playerItem/playerItemFireRodProjectile.c | 4 +- src/playerItem/playerItemGust.c | 8 +- src/playerItem/playerItemGustBig.c | 21 +- src/playerItem/playerItemGustJar.c | 14 +- src/playerItem/playerItemHeldObject.c | 15 +- src/playerItem/playerItemLantern.c | 22 +- src/playerItem/playerItemPacciCane.c | 14 +- .../playerItemPacciCaneProjectile.c | 8 +- src/playerItem/playerItemShield.c | 38 +- src/playerItem/playerItemSpiralBeam.c | 6 +- src/playerItem/playerItemSword.c | 34 +- src/playerItem/playerItemSwordBeam.c | 6 +- src/playerItemUtils.c | 2 +- src/playerUtils.c | 441 +-- src/projectile/darkNutSwordSlash.c | 2 +- src/projectile/dirtBallProjectile.c | 2 +- src/projectile/gleerokProjectile.c | 4 +- src/projectile/gyorgMaleEnergyProjectile.c | 2 +- src/projectile/keatonDagger.c | 2 +- src/projectile/lakituCloudProjectile.c | 2 +- src/projectile/octorokBossProjectile.c | 2 +- src/projectile/projectile5.c | 2 +- src/projectile/spiderWeb.c | 11 +- src/projectile/v1DarkMagicProjectile.c | 20 +- src/projectile/v2Projectile.c | 2 +- src/projectile/v3ElectricProjectile.c | 6 +- src/projectile/v3HandProjectile.c | 2 +- src/room.c | 7 +- src/roomInit.c | 34 +- src/script.c | 116 +- src/scroll.c | 29 +- src/subtask/subtaskFastTravel.c | 2 +- src/vram.c | 7 +- src/worldEvent/worldEvent15.c | 3 +- 279 files changed, 3482 insertions(+), 3475 deletions(-) delete mode 100644 include/new_player.h create mode 100644 include/object/pushableFurniture.h create mode 100644 include/playerItem/playerItemBottle.h diff --git a/include/entity.h b/include/entity.h index 42d77030..315e94db 100644 --- a/include/entity.h +++ b/include/entity.h @@ -220,9 +220,6 @@ typedef struct Entity_ { /*0x62*/ u8 spriteOffsetX; /*0x63*/ s8 spriteOffsetY; /*0x64*/ void* myHeap; /**< Heap data allocated with #zMalloc. */ -#ifdef ENT_DEPRECATED - GENERIC_ENTITY_FIELDS -#endif } Entity; typedef struct { @@ -248,8 +245,8 @@ typedef struct LinkedList { * to allow the iteration of all Entity's. */ extern LinkedList gEntityLists[9]; -extern Entity gAuxPlayerEntities[MAX_AUX_PLAYER_ENTITIES]; -extern Entity gEntities[MAX_ENTITIES]; +extern GenericEntity gAuxPlayerEntities[MAX_AUX_PLAYER_ENTITIES]; +extern GenericEntity gEntities[MAX_ENTITIES]; typedef void(EntityAction)(Entity*); typedef void (*EntityActionPtr)(Entity*); diff --git a/include/new_player.h b/include/new_player.h deleted file mode 100644 index bae1ed2f..00000000 --- a/include/new_player.h +++ /dev/null @@ -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 diff --git a/include/object/deathFx.h b/include/object/deathFx.h index f8317f8c..4f14ea86 100644 --- a/include/object/deathFx.h +++ b/include/object/deathFx.h @@ -1,9 +1,6 @@ #ifndef DEATHFX_H #define DEATHFX_H -#ifdef ENT_DEPRECATED -#error "deathFx.h requires new entities" -#endif #include "entity.h" typedef struct { diff --git a/include/object/linkAnimation.h b/include/object/linkAnimation.h index 00e0ba94..781df520 100644 --- a/include/object/linkAnimation.h +++ b/include/object/linkAnimation.h @@ -1,9 +1,6 @@ #ifndef LINKANIMATION_H #define LINKANIMATION_H -#ifdef ENT_DEPRECATED -#error "linkAnimtion.h requires new entities" -#endif #include "entity.h" typedef struct { diff --git a/include/object/pushableFurniture.h b/include/object/pushableFurniture.h new file mode 100644 index 00000000..db693183 --- /dev/null +++ b/include/object/pushableFurniture.h @@ -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 diff --git a/include/player.h b/include/player.h index 38e186e5..d22b8968 100644 --- a/include/player.h +++ b/include/player.h @@ -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, @@ -585,9 +602,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); diff --git a/include/playerItem/playerItemBottle.h b/include/playerItem/playerItemBottle.h new file mode 100644 index 00000000..9055ee2f --- /dev/null +++ b/include/playerItem/playerItemBottle.h @@ -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 diff --git a/src/beanstalkSubtask.c b/src/beanstalkSubtask.c index 6568047b..869294c5 100644 --- a/src/beanstalkSubtask.c +++ b/src/beanstalkSubtask.c @@ -1,4 +1,3 @@ -#define ENT_DEPRECATED #include "beanstalkSubtask.h" #include "backgroundAnimations.h" @@ -174,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; @@ -194,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 (sub_080B1B44(COORD_TO_TILE_OFFSET(&gPlayerEntity, -ptr1[0], -ptr1[1]), gPlayerEntity.collisionLayer) == - 0xff) { + if (sub_080B1B44(COORD_TO_TILE_OFFSET(&gPlayerEntity.base, -ptr1[0], -ptr1[1]), + gPlayerEntity.base.collisionLayer) == 0xff) { 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; } } } - layer = GetLayerByIndex(gPlayerEntity.collisionLayer); - ptr1 = &gUnk_080B4468[gPlayerEntity.animationState & 6]; - position = COORD_TO_TILE_OFFSET(&gPlayerEntity, -ptr1[0], -ptr1[1]); - tileType = GetTileType(position, gPlayerEntity.collisionLayer); + layer = GetLayerByIndex(gPlayerEntity.base.collisionLayer); + ptr1 = &gUnk_080B4468[gPlayerEntity.base.animationState & 6]; + position = COORD_TO_TILE_OFFSET(&gPlayerEntity.base, -ptr1[0], -ptr1[1]); + tileType = GetTileType(position, gPlayerEntity.base.collisionLayer); if (tileType < 0x4000) { direction = sub_080B1B54(tileType); } else { direction = tileType; } - animationState1 = gPlayerEntity.animationState; + animationState1 = gPlayerEntity.base.animationState; animationState2 = animationState1 & 0xff; switch (direction) { @@ -235,7 +234,7 @@ u32 UpdatePlayerCollision(void) { if (sub_0801A458(layer, position, 2) == 0) { return 0; } - layer->mapData[position] = 0x4001 + (gPlayerEntity.animationState >> 1); + layer->mapData[position] = 0x4001 + (gPlayerEntity.base.animationState >> 1); if ((gPlayerState.flags & PL_MINISH) != 0) { gPlayerState.pushedObject = 0xc0; } else { @@ -243,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 0x28: 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 (sub_080B1B44(position, gPlayerEntity.collisionLayer) != 0xf) { + if (sub_080B1B44(position, gPlayerEntity.base.collisionLayer) != 0xf) { 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 +285,18 @@ u32 UpdatePlayerCollision(void) { if (sub_0801A2B0(layer, position, 0xb) == 0) { return 0; } - layer->mapData[position] = 0x401c + (gPlayerEntity.animationState >> 1); + layer->mapData[position] = 0x401c + (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.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 0x70: 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,7 +309,7 @@ u32 UpdatePlayerCollision(void) { if (gPlayerState.flags & PL_MINISH) { return 0; } - if (gPlayerEntity.animationState != IdleNorth) { + if (gPlayerEntity.base.animationState != IdleNorth) { return 0; } gUnk_0200AF00.rActionInteractTile = R_ACTION_READ; @@ -318,7 +317,7 @@ u32 UpdatePlayerCollision(void) { return 0; } gPlayerState.mobility = 1; - sub_080A7CFC(position, gPlayerEntity.collisionLayer); + sub_080A7CFC(position, gPlayerEntity.base.collisionLayer); return 1; case 0x1a: if ((animationState1 & 0xff) != 0) { @@ -332,7 +331,7 @@ u32 UpdatePlayerCollision(void) { return 0; } gPlayerState.mobility = 1; - OpenSmallChest(position, gPlayerEntity.collisionLayer); + OpenSmallChest(position, gPlayerEntity.base.collisionLayer); return 2; case 0x71: if (HasDungeonSmallKey() == 0) { @@ -343,7 +342,7 @@ u32 UpdatePlayerCollision(void) { return 0; } gPlayerState.mobility = 1; - sub_0804B388(position, gPlayerEntity.collisionLayer); + sub_0804B388(position, gPlayerEntity.base.collisionLayer); return 2; case 0x3d: case 0x4040 ... 0x4048: @@ -358,61 +357,61 @@ 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 0x400b: if (sub_0801A2B0(layer, position, 8) == 0) { return 0; } - if ((gPlayerEntity.collisionLayer == 3) && (gMapTop.mapData[position] == 0x400b)) { - gMapTop.mapData[position] = 0x400c + (gPlayerEntity.animationState >> 1); + if ((gPlayerEntity.base.collisionLayer == 3) && (gMapTop.mapData[position] == 0x400b)) { + gMapTop.mapData[position] = 0x400c + (gPlayerEntity.base.animationState >> 1); } else { - layer->mapData[position] = 0x400c + (gPlayerEntity.animationState >> 1); + layer->mapData[position] = 0x400c + (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 0x405a: if (sub_0801A2B0(layer, position, 2) == 0) { return 0; } - layer->mapData[position] = 0x405b + (gPlayerEntity.animationState >> 1); + layer->mapData[position] = 0x405b + (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 0x4036: if (sub_0801A2B0(layer, position, 0xb) == 0) { return 0; } - layer->mapData[position] = 0x4037 + (gPlayerEntity.animationState >> 1); + layer->mapData[position] = 0x4037 + (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 0x403e: if ((animationState1 & 0xff) != 0) { @@ -421,25 +420,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; } layer->mapData[position] = 0x403f; 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 0x72: 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; } @@ -449,7 +448,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++; } @@ -462,20 +461,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 0x402b ... 0x402d: if (sub_0801A370(layer, position) != 0) { - layer->mapData[position] = 0x4030 + ((gPlayerEntity.animationState & 4) >> 2); + layer->mapData[position] = 0x4030 + ((gPlayerEntity.base.animationState & 4) >> 2); if ((gPlayerState.flags & PL_MINISH) != 0) { gPlayerState.pushedObject = 0xa0; } else { @@ -483,9 +482,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; @@ -494,7 +493,7 @@ u32 UpdatePlayerCollision(void) { if (sub_0801A458(layer, position, 8) == 0) { return 0; } - layer->mapData[position] = 0x404b + (gPlayerEntity.animationState >> 1); + layer->mapData[position] = 0x404b + (gPlayerEntity.base.animationState >> 1); if ((gPlayerState.flags & PL_MINISH) != 0) { gPlayerState.pushedObject = 0xc0; } else { @@ -502,21 +501,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 0x4052: if (gPlayerState.field_0x35 != 0) { return 0; } - SetTile(0x4054, position, gPlayerEntity.collisionLayer); + SetTile(0x4054, position, gPlayerEntity.base.collisionLayer); return 4; case 0x4053: if (gPlayerState.field_0x35 != 6) { return 0; } - SetTile(0x4054, position, gPlayerEntity.collisionLayer); + SetTile(0x4054, position, gPlayerEntity.base.collisionLayer); return 4; case 0x4055: position--; @@ -525,12 +524,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) { - SetTile(0x4059, position, gPlayerEntity.collisionLayer); + SetTile(0x4059, position, gPlayerEntity.base.collisionLayer); return 4; } } @@ -542,12 +541,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) { - SetTile(0x4059, position, gPlayerEntity.collisionLayer); + SetTile(0x4059, position, gPlayerEntity.base.collisionLayer); return 4; } } @@ -561,30 +560,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; } - SetTile(0x4074, position, gPlayerEntity.collisionLayer); + SetTile(0x4074, 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 0x407d: - 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; } - SetTile(0x4074, position, gPlayerEntity.collisionLayer); - sub_080001D0(0xd, position, gPlayerEntity.collisionLayer); + SetTile(0x4074, position, gPlayerEntity.base.collisionLayer); + sub_080001D0(0xd, position, gPlayerEntity.base.collisionLayer); return 1; default: return 0; @@ -597,11 +596,11 @@ bool32 sub_0801A2B0(LayerStruct* layer, 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 = sub_080B1B54(GetTileType(position, gPlayerEntity.collisionLayer)); + temp4 = sub_080B1B54(GetTileType(position, gPlayerEntity.base.collisionLayer)); switch (temp4) { case 0x52: break; @@ -633,16 +632,16 @@ bool32 sub_0801A370(LayerStruct* layer, 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 = GetTileType(pos, gPlayerEntity.collisionLayer); + tileType = GetTileType(pos, gPlayerEntity.base.collisionLayer); switch (tileType) { case 0x402b: pos += offset; @@ -653,7 +652,7 @@ bool32 sub_0801A370(LayerStruct* layer, u32 position) { if (topLayer->collisionData[pos - 0x80] == 0x46) { return FALSE; } - switch ((u16)sub_080B1B54(GetTileType(pos, gPlayerEntity.collisionLayer))) { + switch ((u16)sub_080B1B54(GetTileType(pos, gPlayerEntity.base.collisionLayer))) { case 0x52: return FALSE; case 0x26: @@ -686,10 +685,10 @@ bool32 sub_0801A370(LayerStruct* layer, u32 position) { bool32 sub_0801A458(LayerStruct* layer, 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 = GetTileType(pos, gPlayerEntity.collisionLayer); + tileType = GetTileType(pos, gPlayerEntity.base.collisionLayer); switch (sub_080B1B54(tileType)) { case 0x52: case 0x26: @@ -719,18 +718,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; } } @@ -931,9 +930,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 = GetTileType(COORD_TO_TILE_OFFSET(&gPlayerEntity, -ptr[0], -ptr[1]), gPlayerEntity.collisionLayer); + GetLayerByIndex(gPlayerEntity.base.collisionLayer); + ptr = &gUnk_080B44A8[gPlayerEntity.base.animationState & 6]; + tileType = + GetTileType(COORD_TO_TILE_OFFSET(&gPlayerEntity.base, -ptr[0], -ptr[1]), gPlayerEntity.base.collisionLayer); if (tileType < 0x4000) { sub_080B1B54(tileType); } @@ -971,7 +971,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; diff --git a/src/code_08049DF4.c b/src/code_08049DF4.c index 723626eb..e9794e59 100644 --- a/src/code_08049DF4.c +++ b/src/code_08049DF4.c @@ -24,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; } @@ -35,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; } @@ -45,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; } diff --git a/src/collision.c b/src/collision.c index c3630276..ea0d5db9 100644 --- a/src/collision.c +++ b/src/collision.c @@ -1,4 +1,3 @@ -#define ENT_DEPRECATED #include "asm.h" #include "collision.h" #include "common.h" @@ -75,10 +74,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 +88,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 +211,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 +247,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 +276,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 +463,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 +483,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 +497,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 +525,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 +550,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 +579,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 +646,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 +658,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 +669,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 +693,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 +715,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 +779,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; } diff --git a/src/enemy/armos.c b/src/enemy/armos.c index d03a3089..b0a28dbb 100644 --- a/src/enemy/armos.c +++ b/src/enemy/armos.c @@ -60,8 +60,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; } } @@ -92,7 +92,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)) { @@ -429,7 +429,7 @@ bool32 sub_0803086C(ArmosEntity* this) { if (GetTileType(pos, super->collisionLayer) == 0x4049) { 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; diff --git a/src/enemy/beetle.c b/src/enemy/beetle.c index b1dbd739..6b83d6dc 100644 --- a/src/enemy/beetle.c +++ b/src/enemy/beetle.c @@ -44,7 +44,7 @@ void Beetle_OnCollision(BeetleEntity* this) { super->subtimer = 0; COLLISION_OFF(super); super->spritePriority.b0 = 3; - CopyPositionAndSpriteOffset(&gPlayerEntity, super); + CopyPositionAndSpriteOffset(&gPlayerEntity.base, super); super->z.HALF.HI = -1; this->unk_87 = 1; InitializeAnimation(super, 6); @@ -159,7 +159,7 @@ void sub_08021984(BeetleEntity* this) { void sub_08021A10(BeetleEntity* this) { GetNextFrame(super); - if (EntityInRectRadius(super, &gPlayerEntity, 120, 80) && sub_08021D00(this) == 0) { + if (EntityInRectRadius(super, &gPlayerEntity.base, 120, 80) && sub_08021D00(this) == 0) { if (--super->timer == 0) { super->action = 3; super->timer = (Random() & 0x3f) + 30; @@ -250,17 +250,17 @@ void sub_08021B64(BeetleEntity* this) { super->action = 6; super->zVelocity = Q_16_16(1.0); this->unk_87 = 0; - if (gPlayerEntity.direction != 0xff) { - super->direction = DirectionSouth ^ gPlayerEntity.direction; + if (gPlayerEntity.base.direction != 0xff) { + super->direction = DirectionSouth ^ gPlayerEntity.base.direction; } else { - super->direction = (gPlayerEntity.animationState << 2) ^ DirectionSouth; + super->direction = (gPlayerEntity.base.animationState << 2) ^ DirectionSouth; } InitializeAnimation(super, 5); } else { gPlayerState.mobility |= 0x80; gPlayerState.speed_modifier -= 0x50; gPlayerState.attachedBeetleCount++; - CopyPositionAndSpriteOffset(&gPlayerEntity, super); + CopyPositionAndSpriteOffset(&gPlayerEntity.base, super); super->x.HALF.HI += gUnk_080CB5E4[(super->subtimer++ & 0xe) >> 1]; super->z.HALF.HI--; GetNextFrame(super); diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c index b232c780..5c15c015 100644 --- a/src/enemy/bobomb.c +++ b/src/enemy/bobomb.c @@ -44,7 +44,7 @@ void Bobomb_OnCollision(BobombEntity* this) { case 1: if (this->unk_82) { super->knockbackDuration = 0; - gPlayerEntity.knockbackDuration = 4; + gPlayerEntity.base.knockbackDuration = 4; } return; case 0xe: @@ -114,7 +114,7 @@ void sub_0802C83C(BobombEntity* this) { if (this->unk_82) { if (--super->timer == 0) { super->action = 3; - switch (gPlayerEntity.animationState & 6) { + switch (gPlayerEntity.base.animationState & 6) { case 2: super->x.HALF.HI -= 6; break; @@ -218,7 +218,7 @@ void sub_0802CA10(BobombEntity* this) { } } else { this->unk_83 = 2; - super->direction = (((gPlayerEntity.animationState) << 2) | IdleSouth) & (DIR_DIAGONAL | DirectionWest); + super->direction = (((gPlayerEntity.base.animationState) << 2) | IdleSouth) & (DIR_DIAGONAL | DirectionWest); sub_0802CC18(this); GetNextFrame(super); } @@ -242,7 +242,7 @@ void sub_0802CA94(BobombEntity* this) { super->speed = 0; this->unk_83 = 0; this->unk_81 = 0; - super->direction = ((gPlayerEntity.animationState << 2) | IdleSouth) & (DirectionWest | DIR_DIAGONAL); + super->direction = ((gPlayerEntity.base.animationState << 2) | IdleSouth) & (DirectionWest | DIR_DIAGONAL); InitializeAnimation(super, (super->direction >> 4) | IdleWest); } diff --git a/src/enemy/bombPeahat.c b/src/enemy/bombPeahat.c index 02871212..d0fd3a22 100644 --- a/src/enemy/bombPeahat.c +++ b/src/enemy/bombPeahat.c @@ -213,7 +213,7 @@ void sub_0802AAC0(BombPeahatEntity* this) { #ifdef EU } else if (entity->timer == 0) { if (sub_080B1B44(COORD_TO_TILE(super), 1) == 0) { - if (EntityInRectRadius(super, &gPlayerEntity, 0x10, 0x10) && entity->subtimer <= 0x50) { + if (EntityInRectRadius(super, &gPlayerEntity.base, 0x10, 0x10) && entity->subtimer <= 0x50) { this->unk_81 = 0; } } else if (entity->subtimer <= 0x13) { diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index 3a9ac5f5..dde81993 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -311,7 +311,7 @@ void BusinessScrub_Action5(BusinessScrubEntity* this) { } void BusinessScrub_Action6(BusinessScrubEntity* this) { - if (gPlayerEntity.action == PLAYER_ITEMGET) { + if (gPlayerEntity.base.action == PLAYER_ITEMGET) { if (this->unk_81 == 0) { SetPlayerControl(1); this->unk_81 = 1; diff --git a/src/enemy/chuchuBoss.c b/src/enemy/chuchuBoss.c index 73850077..00488c3c 100644 --- a/src/enemy/chuchuBoss.c +++ b/src/enemy/chuchuBoss.c @@ -464,7 +464,7 @@ void sub_08026090(ChuchuBossEntity* this) { } else { PausePlayer(); if (super->timer-- == 0) { - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; DeleteThisEntity(); } } @@ -540,7 +540,7 @@ 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) { + if (gPlayerEntity.base.action != PLAYER_ROOMTRANSITION && gPlayerEntity.base.action != PLAYER_ROOM_EXIT) { PausePlayer(); } } @@ -558,7 +558,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; SetTile(0x4022, 0x2c8, 1); @@ -566,7 +566,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); @@ -576,20 +576,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; } } } @@ -655,7 +655,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); } @@ -681,7 +681,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; @@ -731,7 +731,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; @@ -793,7 +793,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; @@ -1201,9 +1201,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; @@ -1243,7 +1243,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; @@ -1785,8 +1785,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; diff --git a/src/enemy/cuccoAggr.c b/src/enemy/cuccoAggr.c index 9a07ea9e..03a158ea 100644 --- a/src/enemy/cuccoAggr.c +++ b/src/enemy/cuccoAggr.c @@ -173,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); @@ -193,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); @@ -278,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); diff --git a/src/enemy/cuccoChickAggr.c b/src/enemy/cuccoChickAggr.c index da26009c..03eb697f 100644 --- a/src/enemy/cuccoChickAggr.c +++ b/src/enemy/cuccoChickAggr.c @@ -137,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; diff --git a/src/enemy/dust.c b/src/enemy/dust.c index 68d3336d..e6d3ca7a 100644 --- a/src/enemy/dust.c +++ b/src/enemy/dust.c @@ -202,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) && @@ -276,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) { @@ -292,7 +292,7 @@ void sub_08044498(DustEntity* this) { if (pEVar1 == NULL) { return; } - CopyPosition(&gPlayerEntity, pEVar1); + CopyPosition(&gPlayerEntity.base, pEVar1); return; } } @@ -307,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); diff --git a/src/enemy/enemy50.c b/src/enemy/enemy50.c index 0a33c592..bb18b5bd 100644 --- a/src/enemy/enemy50.c +++ b/src/enemy/enemy50.c @@ -160,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) { @@ -302,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++; @@ -312,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 { diff --git a/src/enemy/enemy64.c b/src/enemy/enemy64.c index b226528f..62bd707b 100644 --- a/src/enemy/enemy64.c +++ b/src/enemy/enemy64.c @@ -348,7 +348,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; @@ -359,7 +359,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; @@ -416,7 +416,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; @@ -459,9 +459,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; } @@ -478,22 +478,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 = sub_080045DA((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 = sub_080045DA((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; } @@ -532,7 +532,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; } } diff --git a/src/enemy/fallingBoulder.c b/src/enemy/fallingBoulder.c index 81169608..aee943f0 100644 --- a/src/enemy/fallingBoulder.c +++ b/src/enemy/fallingBoulder.c @@ -80,7 +80,7 @@ void sub_0802C334(FallingBoulderEntity* this) { u16 tmp; if (this->unk_7c == 0) { u32 tmp = gRoomControls.origin_y; - entity = &gPlayerEntity; + entity = &gPlayerEntity.base; if (entity == NULL) return; if (entity->y.HALF.HI - tmp <= 0x38) { diff --git a/src/enemy/flyingPot.c b/src/enemy/flyingPot.c index 10e6136d..8c4159d4 100644 --- a/src/enemy/flyingPot.c +++ b/src/enemy/flyingPot.c @@ -220,7 +220,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); } } diff --git a/src/enemy/flyingSkull.c b/src/enemy/flyingSkull.c index 525d40d9..17c46040 100644 --- a/src/enemy/flyingSkull.c +++ b/src/enemy/flyingSkull.c @@ -137,7 +137,7 @@ void sub_08039DD8(FlyingSkullEntity* this) { RegisterCarryEntity(super); } else { if ((gPlayerState.flags & PL_MINISH) == 0) { - Entity* player = &gPlayerEntity; + Entity* player = &gPlayerEntity.base; if (EntityWithinDistance(super, player->x.HALF.HI, player->y.HALF.HI, 0x30)) { if (super->type == 1) { super->action = 3; @@ -165,15 +165,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; SetTile(this->unk_0x74, 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; } } @@ -210,7 +210,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); } } diff --git a/src/enemy/ghini.c b/src/enemy/ghini.c index 683828de..5b408126 100644 --- a/src/enemy/ghini.c +++ b/src/enemy/ghini.c @@ -121,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) { @@ -259,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) { @@ -268,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 { @@ -363,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; @@ -384,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; } diff --git a/src/enemy/gibdo.c b/src/enemy/gibdo.c index 1471e807..0732a282 100644 --- a/src/enemy/gibdo.c +++ b/src/enemy/gibdo.c @@ -166,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) { @@ -352,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; diff --git a/src/enemy/gleerok.c b/src/enemy/gleerok.c index ef144203..19399037 100644 --- a/src/enemy/gleerok.c +++ b/src/enemy/gleerok.c @@ -170,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(); } } @@ -189,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; } @@ -215,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); } @@ -318,7 +318,7 @@ void sub_0802D3B8(GleerokEntity* this) { if (CheckGlobalFlag(LV2_CLEAR)) { gScreen.lcd.displayControl &= 0xfdff; - sub_0807AABC(&gPlayerEntity); + sub_0807AABC(&gPlayerEntity.base); DeleteThisEntity(); } @@ -436,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); @@ -450,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; } } @@ -520,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 @@ -577,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; @@ -710,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; @@ -744,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) { @@ -788,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; @@ -1009,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; } @@ -1059,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; } @@ -1133,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; @@ -1403,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 { diff --git a/src/enemy/gyorgChild.c b/src/enemy/gyorgChild.c index c72b4619..ea6a5db6 100644 --- a/src/enemy/gyorgChild.c +++ b/src/enemy/gyorgChild.c @@ -159,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) { diff --git a/src/enemy/gyorgFemale.c b/src/enemy/gyorgFemale.c index 4270139c..fbc0a222 100644 --- a/src/enemy/gyorgFemale.c +++ b/src/enemy/gyorgFemale.c @@ -93,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 @@ -272,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; } @@ -435,7 +435,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; diff --git a/src/enemy/gyorgFemaleEye.c b/src/enemy/gyorgFemaleEye.c index 234d88ed..b9ff2671 100644 --- a/src/enemy/gyorgFemaleEye.c +++ b/src/enemy/gyorgFemaleEye.c @@ -83,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; diff --git a/src/enemy/gyorgFemaleMouth.c b/src/enemy/gyorgFemaleMouth.c index 0500b001..e696f7c8 100644 --- a/src/enemy/gyorgFemaleMouth.c +++ b/src/enemy/gyorgFemaleMouth.c @@ -58,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++; } } diff --git a/src/enemy/gyorgMale.c b/src/enemy/gyorgMale.c index 1521b85c..40c43de4 100644 --- a/src/enemy/gyorgMale.c +++ b/src/enemy/gyorgMale.c @@ -111,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) { @@ -793,7 +793,7 @@ void sub_080477F0(GyorgMaleEntity* this) { } super->direction = sub_080045DA(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; @@ -858,7 +858,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; @@ -1016,10 +1016,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; } @@ -1033,8 +1033,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; } } } @@ -1051,8 +1051,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; } } } @@ -1066,11 +1066,12 @@ void sub_08047EA4(GyorgMaleEntity* this, u32 unk1) { return; if (this->unk_7c & 1) { tmp2 = sub_08047F68(this) << 8; - dir = sub_080045DA(gPlayerEntity.x.HALF.HI - super->x.HALF.HI, gPlayerEntity.y.HALF.HI - super->y.HALF.HI); + dir = sub_080045DA(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; } @@ -1081,8 +1082,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; @@ -1121,15 +1122,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)) { @@ -1137,8 +1138,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; } } @@ -1146,12 +1147,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 = sub_080045DA(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 = sub_080045DA(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); } } } diff --git a/src/enemy/helmasaur.c b/src/enemy/helmasaur.c index 6ac69120..9f970a08 100644 --- a/src/enemy/helmasaur.c +++ b/src/enemy/helmasaur.c @@ -83,7 +83,7 @@ void sub_0802BC74(HelmasaurEntity* this) { sub_0802C1C0(this); super->subAction = 1; super->gustJarTolerance = 60; - super->animationState = AnimationStateFlip90(gPlayerEntity.animationState >> 1); + super->animationState = AnimationStateFlip90(gPlayerEntity.base.animationState >> 1); InitializeAnimation(super, super->animationState); } diff --git a/src/enemy/keese.c b/src/enemy/keese.c index 96f3bd08..922ad17d 100644 --- a/src/enemy/keese.c +++ b/src/enemy/keese.c @@ -139,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); } } @@ -165,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); diff --git a/src/enemy/lakitu.c b/src/enemy/lakitu.c index 5798f410..107afd16 100644 --- a/src/enemy/lakitu.c +++ b/src/enemy/lakitu.c @@ -250,8 +250,8 @@ void Lakitu_Cloudless(LakituEntity* this) { } bool32 sub_0803CA4C(LakituEntity* this) { - if (EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x28) == 0) { - if (EntityInRectRadius(super, &gPlayerEntity, 0x70, 0x50)) { + if (EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, 0x28) == 0) { + if (EntityInRectRadius(super, &gPlayerEntity.base, 0x70, 0x50)) { return TRUE; } } @@ -260,7 +260,7 @@ bool32 sub_0803CA4C(LakituEntity* this) { } void sub_0803CA84(LakituEntity* this, u32 unkParameter) { - u32 altAnimState = GetFacingDirection(super, &gPlayerEntity); + u32 altAnimState = GetFacingDirection(super, &gPlayerEntity.base); if (((altAnimState - 3) & 7) > 2 || ((super->animationState - (altAnimState >> 3)) & 3) > 1) { altAnimState = DirectionRoundUp(altAnimState) >> 3; @@ -304,7 +304,7 @@ void sub_0803CB34(LakituEntity* this) { super->action = LIGHTNING_THROW; super->hitType = 0xa6; - this->unk_78 = GetFacingDirection(super, &gPlayerEntity); + this->unk_78 = GetFacingDirection(super, &gPlayerEntity.base); InitAnimationForceUpdate(super, super->animationState + 8); } diff --git a/src/enemy/lakituCloud.c b/src/enemy/lakituCloud.c index 3d0c000d..ac2549fc 100644 --- a/src/enemy/lakituCloud.c +++ b/src/enemy/lakituCloud.c @@ -68,7 +68,7 @@ void sub_0803CD40(LakituCloudEntity* this) { ModHealth(-2); - SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6); + SoundReqClipped(&gPlayerEntity.base, SFX_PLY_VO6); sub_08079D84(); sub_0803CE3C(this); diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c index 52f37306..fef316b6 100644 --- a/src/enemy/likeLike.c +++ b/src/enemy/likeLike.c @@ -53,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; } } } @@ -198,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); @@ -225,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; diff --git a/src/enemy/mazaalBracelet.c b/src/enemy/mazaalBracelet.c index a896d130..c2afcae9 100644 --- a/src/enemy/mazaalBracelet.c +++ b/src/enemy/mazaalBracelet.c @@ -424,7 +424,7 @@ void sub_0803A660(MazaalBraceletEntity* this) { } else { super->action = 7; super->timer = 0; - uVar2 = GetFacingDirection(super, &gPlayerEntity); + uVar2 = GetFacingDirection(super, &gPlayerEntity.base); super->direction = (u8)uVar2; super->speed = 0x280; return; @@ -615,11 +615,11 @@ void sub_0803AA00(MazaalBraceletEntity* this) { sub_08004596(super, direction); } LinearMoveUpdate(super); - if ((super->direction == direction) || (super->y.HALF.HI >= gPlayerEntity.y.HALF.HI)) { + if ((super->direction == direction) || (super->y.HALF.HI >= gPlayerEntity.base.y.HALF.HI)) { super->action = 0x13; super->spriteSettings.draw = 0; super->direction = direction; - this->unk_80.HWORD = gPlayerEntity.x.HALF.HI; + this->unk_80.HWORD = gPlayerEntity.base.x.HALF.HI; InitAnimationForceUpdate(super->child, 4); } } @@ -1184,7 +1184,7 @@ void sub_0803B5C0(MazaalBraceletEntity* this) { u32 direction; u32 temp; - direction = GetFacingDirection(super, &gPlayerEntity); + direction = GetFacingDirection(super, &gPlayerEntity.base); if (direction < 10) { direction = 10; } @@ -1202,8 +1202,8 @@ void sub_0803B5C0(MazaalBraceletEntity* this) { } u32 sub_0803B610(MazaalBraceletEntity* this) { - return EntityWithinDistance(super, gPlayerEntity.x.HALF.HI + gUnk_080CFD19[super->type], - gPlayerEntity.y.HALF.HI - 0xc, 8); + return EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI + gUnk_080CFD19[super->type], + gPlayerEntity.base.y.HALF.HI - 0xc, 8); } // sub_0803B698 was the tail of super function @@ -1211,9 +1211,9 @@ void sub_0803B63C(MazaalBraceletEntity* this) { int y; int x; - x = gPlayerEntity.x.HALF.HI; + x = gPlayerEntity.base.x.HALF.HI; x += gUnk_080CFD19[super->type]; - y = gPlayerEntity.y.HALF.HI - 0xc; + y = gPlayerEntity.base.y.HALF.HI - 0xc; if (super->timer++ > 180) { super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, x, y); } else { @@ -1270,29 +1270,29 @@ void sub_0803B798(void) { ~(PL_CAPTURED | PL_FLAGS10000 | PL_GYORG_FIGHT | PL_ROLLING | PL_MOLDWORM_CAPTURED | PL_IN_HOLE | PL_MOLDWORM_RELEASED | PL_CLONING | PL_USE_LANTERN | PL_PARACHUTE | PL_CONVEYOR_PUSHED | PL_ENTER_MINECART | PL_SWORD_THRUST | PL_USE_OCARINA | PL_CLIMBING | PL_FLAGS40000000 | PL_FLAGS80000000); - gPlayerEntity.flags |= ENT_COLLIDE; - gPlayerEntity.zVelocity = Q_16_16(1.5); - gPlayerEntity.z.HALF.HI = -10; - gPlayerEntity.direction = 0x10; - gPlayerEntity.animationState = 4; - gPlayerEntity.spritePriority.b1 = 1; - gPlayerEntity.spriteOffsetY = 0; - gPlayerEntity.speed = 0x140; - gPlayerEntity.iframes = -0x1e; + gPlayerEntity.base.flags |= ENT_COLLIDE; + gPlayerEntity.base.zVelocity = Q_16_16(1.5); + gPlayerEntity.base.z.HALF.HI = -10; + gPlayerEntity.base.direction = 0x10; + gPlayerEntity.base.animationState = 4; + gPlayerEntity.base.spritePriority.b1 = 1; + gPlayerEntity.base.spriteOffsetY = 0; + gPlayerEntity.base.speed = 0x140; + gPlayerEntity.base.iframes = -0x1e; } void sub_0803B804(MazaalBraceletEntity* this) { - gPlayerEntity.iframes = 30; + gPlayerEntity.base.iframes = 30; ModHealth(-4); - SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6); + SoundReqClipped(&gPlayerEntity.base, SFX_PLY_VO6); } void sub_0803B824(MazaalBraceletEntity* this) { ResetActiveItems(); gPlayerState.mobility |= 0x80; - sub_0806FA90(super, &gPlayerEntity, gUnk_080CFD1D[super->type], 1); - gPlayerEntity.spriteOffsetY = -6; - gPlayerEntity.spritePriority.b1 = 0; + sub_0806FA90(super, &gPlayerEntity.base, gUnk_080CFD1D[super->type], 1); + gPlayerEntity.base.spriteOffsetY = -6; + gPlayerEntity.base.spritePriority.b1 = 0; } u32 sub_0803B870(MazaalBraceletEntity* this) { @@ -1303,8 +1303,8 @@ u32 sub_0803B870(MazaalBraceletEntity* this) { super->action = 0x18; super->timer = 68; super->spriteSettings.draw = 0; - gPlayerEntity.flags &= ~ENT_COLLIDE; - gPlayerEntity.iframes = -0x10; + gPlayerEntity.base.flags &= ~ENT_COLLIDE; + gPlayerEntity.base.iframes = -0x10; sub_0803B824(this); entity->hitType = 0x13; InitAnimationForceUpdate(entity, 7); diff --git a/src/enemy/mazaalHead.c b/src/enemy/mazaalHead.c index 03c5c4de..049b32d1 100644 --- a/src/enemy/mazaalHead.c +++ b/src/enemy/mazaalHead.c @@ -246,7 +246,7 @@ void sub_08033FFC(MazaalHeadEntity* this) { break; default: if (((this->unk_74)->base.flags & ENT_COLLIDE) != 0) { - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; sub_08034420(this); gPlayerState.controlMode = CONTROL_1; ResetPlayerAnimationAndAction(); @@ -567,12 +567,12 @@ void sub_0803473C(MazaalHeadEntity* this) { if (0x28 < (this->unk_74)->base.action) { return; } - playerX = gPlayerEntity.x.HALF.HI - 0x60; + playerX = gPlayerEntity.base.x.HALF.HI - 0x60; } else { if (0x28 < (this->unk_78)->base.action) { return; } - playerX = gPlayerEntity.x.HALF.HI + 0x60; + playerX = gPlayerEntity.base.x.HALF.HI + 0x60; } roomX = gRoomControls.origin_x; if (playerX - 4 > super->x.HALF.HI) { @@ -593,7 +593,7 @@ void sub_0803473C(MazaalHeadEntity* this) { } void sub_080347B4(MazaalHeadEntity* this) { - u32 playerX = gPlayerEntity.x.HALF.HI; + u32 playerX = gPlayerEntity.base.x.HALF.HI; u32 roomX = gRoomControls.origin_x; if (playerX - 4 > super->x.HALF.HI) { if (roomX + 0xe0 < super->x.HALF.HI) { diff --git a/src/enemy/moldworm.c b/src/enemy/moldworm.c index a6469c11..acb85509 100644 --- a/src/enemy/moldworm.c +++ b/src/enemy/moldworm.c @@ -111,12 +111,12 @@ void Moldworm_OnCollision(MoldwormEntity* this) { } if (super->health == 0 && this->unk_7f == 0 && super->action == 7) { - CopyPosition(super, &gPlayerEntity); - gPlayerEntity.flags |= ENT_COLLIDE; - gPlayerEntity.spriteSettings.draw = 1; - gPlayerEntity.zVelocity = Q_16_16(1.5); - gPlayerEntity.direction = 0xff; - gPlayerEntity.iframes = -0x14; + 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; } @@ -183,9 +183,9 @@ void sub_08023288(MoldwormEntity* this) { 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(GetTileTypeByPos(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(GetTileTypeByPos(x, y, gPlayerEntity.base.collisionLayer))) { sub_08023990(this, x, y); return; } @@ -282,7 +282,7 @@ void sub_080234D8(MoldwormEntity* this) { } void sub_0802351C(MoldwormEntity* this) { - if ((super->timer != 0) && ((super->type2 == 1) || (gPlayerEntity.frameIndex == 0xff))) { + if ((super->timer != 0) && ((super->type2 == 1) || (gPlayerEntity.base.frameIndex == 0xff))) { super->timer = 0; super->child->action = 3; super->child->subtimer = this->unk_80; @@ -292,10 +292,10 @@ void sub_0802351C(MoldwormEntity* this) { if (this->unk_7f == 0) { if (super->type2 == 0) { - gPlayerEntity.animationState = super->animationState & 7; + gPlayerEntity.base.animationState = super->animationState & 7; gPlayerState.flags |= PL_MOLDWORM_CAPTURED; - PositionRelative(super, &gPlayerEntity, 0, Q_16_16(gUnk_080CBC90[super->animationState & 7])); - gPlayerEntity.spriteOffsetY = -gUnk_080CBC90[super->animationState & 7]; + PositionRelative(super, &gPlayerEntity.base, 0, Q_16_16(gUnk_080CBC90[super->animationState & 7])); + gPlayerEntity.base.spriteOffsetY = -gUnk_080CBC90[super->animationState & 7]; } } else { super->action = 4; @@ -429,13 +429,13 @@ void sub_08023894(MoldwormEntity* this) { InitializeAnimation(super, super->animationState); if (super->parent->type2 == 0) { gPlayerState.flags |= PL_MOLDWORM_RELEASED; - gPlayerEntity.x.HALF.HI = super->x.HALF.HI; - gPlayerEntity.y.HALF.HI = super->y.HALF.HI; - gPlayerEntity.direction = DirectionRoundUp(GetFacingDirection(this->unk_74, super)); - 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); } } } @@ -482,7 +482,7 @@ void sub_08023990(MoldwormEntity* this, u32 param_2, u32 param_3) { super->spritePriority.b0 = 7; super->x.HALF.HI = param_2; super->y.HALF.HI = param_3; - super->collisionLayer = gPlayerEntity.collisionLayer; + super->collisionLayer = gPlayerEntity.base.collisionLayer; UpdateSpriteForCollisionLayer(super); InitializeAnimation(super, 0x16); diff --git a/src/enemy/octorokBoss.c b/src/enemy/octorokBoss.c index 00f5d79f..4b3531f8 100644 --- a/src/enemy/octorokBoss.c +++ b/src/enemy/octorokBoss.c @@ -228,7 +228,7 @@ void OctorokBoss_Hit_SubAction2(OctorokBossEntity* this) { } else { super->subAction = 3; this->timer = 150; - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; } } @@ -389,9 +389,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: @@ -476,8 +476,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; } } @@ -486,8 +486,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; @@ -499,22 +499,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); @@ -522,7 +522,7 @@ void OctorokBoss_Intro_SubAction5(OctorokBossEntity* this) { } else { if (this->timer-- == 0) { // Player looks back towards Octorok - gPlayerEntity.animationState = 4; + gPlayerEntity.base.animationState = 4; } } } @@ -689,7 +689,7 @@ void OctorokBoss_Action1_AimTowardsPlayer(OctorokBossEntity* this) { s32 tmp1; s32 tmp2; - tmp1 = (u8)(sub_080045DA(gPlayerEntity.x.WORD - super->x.WORD, gPlayerEntity.y.WORD - super->y.WORD) - + tmp1 = (u8)(sub_080045DA(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; @@ -792,13 +792,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; + 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); } } @@ -897,17 +897,18 @@ void OctorokBoss_ExecuteAttackVacuum(OctorokBossEntity* this) { s32 tmp; if (this->unk_80 == 0) { - super->direction = sub_080045DA(gPlayerEntity.x.WORD - super->x.WORD, gPlayerEntity.y.WORD - super->y.WORD); + super->direction = + sub_080045DA(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 = @@ -938,9 +939,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); @@ -955,7 +956,7 @@ void OctorokBoss_ExecuteAttackVacuum(OctorokBossEntity* this) { } else { this->timer--; if ((gPlayerState.flags == PL_FROZEN) && (this->timer == 0x3c)) { - tmp = sub_080045DA(gPlayerEntity.x.WORD - super->x.WORD, gPlayerEntity.y.WORD - super->y.WORD); + tmp = sub_080045DA(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 { @@ -1083,9 +1084,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; diff --git a/src/enemy/octorokGolden.c b/src/enemy/octorokGolden.c index a3295b7c..80342aa7 100644 --- a/src/enemy/octorokGolden.c +++ b/src/enemy/octorokGolden.c @@ -102,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); @@ -116,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; @@ -135,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; diff --git a/src/enemy/pesto.c b/src/enemy/pesto.c index 612df286..037bd7db 100644 --- a/src/enemy/pesto.c +++ b/src/enemy/pesto.c @@ -126,7 +126,7 @@ void sub_08024060(PestoEntity* this) { if (super->hitType != 0x6e) { COLLISION_OFF(super); super->hitType = 0x6e; - super->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; + super->spriteRendering.b3 = gPlayerEntity.base.spriteRendering.b3; } GetNextFrame(super); @@ -199,7 +199,7 @@ void sub_080241C0(PestoEntity* this) { switch (this->unk_80) { case 0: if (PlayerInRange(super, 3, (gPlayerState.hurtBlinkSpeed != 0) ? 0xa0 : 0x40) && sub_08049FDC(super, 3) && - gPlayerEntity.action != PLAYER_USEENTRANCE) { + gPlayerEntity.base.action != PLAYER_USEENTRANCE) { this->unk_80++; super->speed = 0; sub_08024A14(this, 3, 10); @@ -408,8 +408,8 @@ void sub_080244E8(PestoEntity* this) { this->unk_84 = 0; super->flags2 &= 0xfc; sub_080249DC(this); - this->unk_85 = gPlayerEntity.spritePriority.b1; - gPlayerEntity.flags &= ~ENT_COLLIDE; + this->unk_85 = gPlayerEntity.base.spritePriority.b1; + gPlayerEntity.base.flags &= ~ENT_COLLIDE; gPlayerState.flags |= PL_DISABLE_ITEMS; gPlayerState.field_0xa |= 0x80; if (gPlayerState.swim_state != 0) { @@ -526,7 +526,7 @@ void sub_080244E8(PestoEntity* this) { } break; case 7: - if (gPlayerEntity.z.HALF.HI == 0) { + if (gPlayerEntity.base.z.HALF.HI == 0) { this->unk_80 = 0; super->speed = 0x80; sub_08024B38(this); @@ -843,7 +843,7 @@ void sub_08024E4C(PestoEntity* this) { super->subtimer = 8; sub_08024A14(this, 0, 8); } else { - Entity* player = &gPlayerEntity; + Entity* player = &gPlayerEntity.base; ResetActiveItems(); gPlayerState.flags |= PL_DISABLE_ITEMS; gPlayerState.field_0xa |= 0x80; @@ -868,15 +868,15 @@ void sub_08024E4C(PestoEntity* this) { void sub_08024F50(PestoEntity* this) { gPlayerState.field_0xa = 0; gPlayerState.flags &= ~PL_DISABLE_ITEMS; - CopyPosition(super, &gPlayerEntity); - gPlayerEntity.action = PLAYER_NORMAL; - COLLISION_ON(&gPlayerEntity); - gPlayerEntity.iframes = -0x3c; - gPlayerEntity.direction = gPlayerEntity.animationState << 2; - gPlayerEntity.speed = 0; - gPlayerEntity.spritePriority.b1 = this->unk_85; - gPlayerEntity.z.HALF.HI = gPlayerEntity.spriteOffsetY; - gPlayerEntity.spriteOffsetY = 0; + CopyPosition(super, &gPlayerEntity.base); + gPlayerEntity.base.action = PLAYER_NORMAL; + COLLISION_ON(&gPlayerEntity.base); + gPlayerEntity.base.iframes = -0x3c; + gPlayerEntity.base.direction = gPlayerEntity.base.animationState << 2; + gPlayerEntity.base.speed = 0; + gPlayerEntity.base.spritePriority.b1 = this->unk_85; + gPlayerEntity.base.z.HALF.HI = gPlayerEntity.base.spriteOffsetY; + gPlayerEntity.base.spriteOffsetY = 0; super->flags2 |= 3; this->unk_83 = 0xc0; this->unk_80 += 2; diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c index db273ef7..62f6e2d6 100644 --- a/src/enemy/rollobite.c +++ b/src/enemy/rollobite.c @@ -152,17 +152,17 @@ void sub_08020874(RollobiteEntity* this) { void sub_0802088C(RollobiteEntity* this) { super->subAction = 1; COLLISION_OFF(super); - this->unk_85 = gPlayerEntity.animationState; + this->unk_85 = gPlayerEntity.base.animationState; super->spritePriority.b1 = 0; } void sub_080208B4(RollobiteEntity* this) { - s8 uVar1 = (this->unk_85 - gPlayerEntity.animationState) / 2; + s8 uVar1 = (this->unk_85 - gPlayerEntity.base.animationState) / 2; if (uVar1) { super->animationState = (super->animationState + uVar1) & 3; InitializeAnimation(super, super->animationState + 0x10); } - this->unk_85 = gPlayerEntity.animationState; + this->unk_85 = gPlayerEntity.base.animationState; } void sub_080208F0(RollobiteEntity* this) { diff --git a/src/enemy/ropeGolden.c b/src/enemy/ropeGolden.c index 77a76670..fd83dc53 100644 --- a/src/enemy/ropeGolden.c +++ b/src/enemy/ropeGolden.c @@ -86,8 +86,8 @@ void sub_0803827C(RopeGoldenEntity* this) { if (super->subtimer != 0) { super->subtimer--; } else { - if ((sub_0804A044(super, &gPlayerEntity, 0x8) != 0xff) || - (EntityWithinDistance(super, 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; } @@ -157,7 +157,7 @@ void sub_080383AC(RopeGoldenEntity* this) { super->action = 1; super->timer = 8; super->speed = 0x100; - super->direction = DirectionRoundUp(GetFacingDirection(super, &gPlayerEntity)); + super->direction = DirectionRoundUp(GetFacingDirection(super, &gPlayerEntity.base)); v = super->direction >> 3; if (v != super->animationState) { super->animationState = v; @@ -170,7 +170,7 @@ void sub_080383E4(RopeGoldenEntity* this) { super->action = 2; super->timer = 8; super->speed = 0x280; - v = DirectionRoundUp(GetFacingDirection(super, &gPlayerEntity)); + v = DirectionRoundUp(GetFacingDirection(super, &gPlayerEntity.base)); super->direction = v; this->unk_78 = v; super->animationState = super->direction >> 3; diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c index bea1fe2e..b749e900 100644 --- a/src/enemy/rupeeLike.c +++ b/src/enemy/rupeeLike.c @@ -76,7 +76,7 @@ void RupeeLike_OnCollision(RupeeLikeEntity* this) { super->subtimer = 0; this->unk_83 = 0x41; super->flags2 &= 0xfc; - this->unk_80 = gPlayerEntity.spritePriority.b1; + this->unk_80 = gPlayerEntity.base.spritePriority.b1; EnqueueSFX(SFX_PLACE_OBJ); } else { if (super->confusedTime != 0) { @@ -131,7 +131,7 @@ void sub_08029474(RupeeLikeEntity* this) { if (super->frame & ANIM_DONE) { super->action = 3; super->timer = 8; - bVar1 = GetFacingDirection(super, &gPlayerEntity); + bVar1 = GetFacingDirection(super, &gPlayerEntity.base); super->direction = bVar1; super->animationState = (bVar1 << 0x18) >> 0x1c; InitializeAnimation(super, super->animationState); @@ -148,7 +148,7 @@ void sub_080294D4(RupeeLikeEntity* this) { if (sub_08049FDC(super, 1) != 0) { if (--super->timer == 0) { super->timer = 8; - sub_08004596(super, GetFacingDirection(super, &gPlayerEntity)); + sub_08004596(super, GetFacingDirection(super, &gPlayerEntity.base)); sub_0802969C(this); } ProcessMovement0(super); @@ -177,11 +177,11 @@ void sub_0802953C(RupeeLikeEntity* 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)); pbVar3 = GetSpriteSubEntryOffsetDataPointer((u16)super->spriteIndex, super->frameIndex); - gPlayerEntity.spriteOffsetX = pbVar3[0]; - gPlayerEntity.spriteOffsetY = pbVar3[1] - 1; - gPlayerEntity.spritePriority.b1 = 0; + 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) { @@ -245,14 +245,14 @@ void sub_080296C8(RupeeLikeEntity* 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->unk_80; - gPlayerEntity.spriteOffsetY = 0; - gPlayerEntity.speed = 0x140; + 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; diff --git a/src/enemy/spinyBeetle.c b/src/enemy/spinyBeetle.c index 8f5dd46f..67cb1ebd 100644 --- a/src/enemy/spinyBeetle.c +++ b/src/enemy/spinyBeetle.c @@ -134,19 +134,19 @@ void sub_08033958(SpinyBeetleEntity* this) { case 0: if (this->unk_78 == 0) return; - if (super->y.HALF.HI - gPlayerEntity.y.HALF.HI > 0x30) + if (super->y.HALF.HI - gPlayerEntity.base.y.HALF.HI > 0x30) return; break; case 0x10: - if (gPlayerEntity.y.HALF.HI - super->y.HALF.HI > 0x30) + if (gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI > 0x30) return; break; case 8: - if (gPlayerEntity.x.HALF.HI - super->x.HALF.HI > 0x30) + if (gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI > 0x30) return; break; case 0x18: - if (super->x.HALF.HI - gPlayerEntity.x.HALF.HI > 0x30) + if (super->x.HALF.HI - gPlayerEntity.base.x.HALF.HI > 0x30) return; break; } diff --git a/src/enemy/stalfos.c b/src/enemy/stalfos.c index 1cbdc67a..98e75b9c 100644 --- a/src/enemy/stalfos.c +++ b/src/enemy/stalfos.c @@ -170,7 +170,7 @@ void Stalfos_Init(StalfosEntity* this) { } else { super->action = 4; super->direction = 0xff; - super->animationState = (((GetFacingDirection(super, &gPlayerEntity) + 4) & 0x18) >> 3); + super->animationState = (((GetFacingDirection(super, &gPlayerEntity.base) + 4) & 0x18) >> 3); sub_0803981C(this); } } @@ -347,7 +347,7 @@ u32 sub_080398C0(StalfosEntity* this) { u32 rand = Random(); if ((super->type == 0) && sub_08049FDC(super, 1) && (EntityWithinDistance(super, gUnk_020000B0->x.HALF.HI, gUnk_020000B0->y.HALF.HI, 0x58) != 0)) { - return GetFacingDirection(super, &gPlayerEntity); + return GetFacingDirection(super, &gPlayerEntity.base); } else { if ((sub_08049FA0(super) == 0) && ((rand & 7) != 0)) { return sub_08049EE4(super); diff --git a/src/enemy/sub_080451CC.c b/src/enemy/sub_080451CC.c index 05425c9c..85379354 100644 --- a/src/enemy/sub_080451CC.c +++ b/src/enemy/sub_080451CC.c @@ -1,13 +1,12 @@ -#define ENT_DEPRECATED #include "entity.h" -void sub_080451CC(Entity* this, Entity* other) { +void sub_080451CC(GenericEntity* this, GenericEntity* other) { u8* pThis; u8* pOther; - other->flags = this->flags & ~ENT_DID_INIT; - other->x.WORD = this->x.WORD; - other->y.WORD = this->y.WORD; - other->z.WORD = this->z.WORD; + other->base.flags = this->base.flags & ~ENT_DID_INIT; + other->base.x.WORD = this->base.x.WORD; + other->base.y.WORD = this->base.y.WORD; + other->base.z.WORD = this->base.z.WORD; pThis = (u8*)&this->field_0x68; pOther = (u8*)&other->field_0x68; diff --git a/src/enemy/treeItem.c b/src/enemy/treeItem.c index b953432d..7ce1dc35 100644 --- a/src/enemy/treeItem.c +++ b/src/enemy/treeItem.c @@ -83,11 +83,11 @@ static bool32 ShouldSpawnTreeItem(TreeItemEntity* this) { s32 expectedStateX, expectedStateY; s32 playerState; - if (gPlayerEntity.action != PLAYER_BOUNCE) { + if (gPlayerEntity.base.action != PLAYER_BOUNCE) { return FALSE; } - diff = gPlayerEntity.x.HALF.HI - super->x.HALF.HI; + diff = gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI; expectedStateX = 6; if (diff & 0x8000) { expectedStateX = 2; @@ -98,7 +98,7 @@ static bool32 ShouldSpawnTreeItem(TreeItemEntity* this) { return FALSE; } - diff = gPlayerEntity.y.HALF.HI - super->y.HALF.HI; + diff = gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI; expectedStateY = 0; if (diff & 0x8000) { expectedStateY = 4; @@ -109,7 +109,7 @@ static bool32 ShouldSpawnTreeItem(TreeItemEntity* this) { return FALSE; } - playerState = gPlayerEntity.animationState; + playerState = gPlayerEntity.base.animationState; if ((playerState == 0 && expectedStateY == 0) || (playerState == 4 && expectedStateY == 4) || (playerState == 6 && expectedStateX == 6) || (playerState == 2 && expectedStateX == 2)) { return TRUE; diff --git a/src/enemy/vaatiArm.c b/src/enemy/vaatiArm.c index 2558f5f0..476730df 100644 --- a/src/enemy/vaatiArm.c +++ b/src/enemy/vaatiArm.c @@ -555,8 +555,8 @@ static void sub_08042C34(VaatiArmEntity* this) { super->subAction = 1; random = Random() & 6; temp = &gUnk_080D12F8[random]; - x = gPlayerEntity.x.HALF.HI + *temp; - y = gPlayerEntity.y.HALF.HI + *(temp + 1); + x = gPlayerEntity.base.x.HALF.HI + *temp; + y = gPlayerEntity.base.y.HALF.HI + *(temp + 1); if ((gRoomControls.origin_x + 0x20) > x) { x = gRoomControls.origin_x + 0x20; } @@ -693,7 +693,7 @@ static void sub_08042EF4(VaatiArmEntity* this) { UpdateAnimationSingleFrame(super); if (!sub_08043C98(this)) { if (--super->timer == 0) { - if (EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x50)) { + if (EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, 0x50)) { super->subAction = 6; super->timer = 40; } else { diff --git a/src/enemy/vaatiEyesMacro.c b/src/enemy/vaatiEyesMacro.c index 3c0d04e5..714e7ec9 100644 --- a/src/enemy/vaatiEyesMacro.c +++ b/src/enemy/vaatiEyesMacro.c @@ -183,7 +183,7 @@ void VaatiEyesMacroFunction0Type2(VaatiEyesMacroEntity* this) { super->animationState = 0xff; } CopyPositionAndSpriteOffset(super->parent, super); - uVar2 = (GetFacingDirection(super, &gPlayerEntity) + 1) & 0x1e; + uVar2 = (GetFacingDirection(super, &gPlayerEntity.base) + 1) & 0x1e; temp = (xy*)&gUnk_080CDE70[uVar2]; if (temp->x != super->frameIndex) { if (temp->y != super->frameIndex) { @@ -237,7 +237,7 @@ void sub_0802EFB8(VaatiEyesMacroEntity* this) { if ((rand >> 0x10 & 3) != 0) { uVar1 = rand & 0x18; } else { - uVar3 = GetFacingDirection(&gPlayerEntity, super); + uVar3 = GetFacingDirection(&gPlayerEntity.base, super); uVar1 = (uVar3 + 4) & 0x18; } iVar4 = sub_080B1B44(TILE(super->x.HALF.HI, super->y.HALF.HI) + gUnk_080B4488[((uVar1) >> 3)], 1); diff --git a/src/enemy/vaatiProjectile.c b/src/enemy/vaatiProjectile.c index 666d5fa5..a202f9a3 100644 --- a/src/enemy/vaatiProjectile.c +++ b/src/enemy/vaatiProjectile.c @@ -73,9 +73,9 @@ void VaatiProjectile_OnCollision(VaatiProjectileEntity* this) { super->action = 5; COLLISION_OFF(super); super->spritePriority.b1 = 0; - gPlayerEntity.flags &= ~ENT_COLLIDE; - gPlayerEntity.spriteOrientation.flipY = super->spriteOrientation.flipY; - gPlayerEntity.spriteRendering.b3 = super->spriteRendering.b3; + gPlayerEntity.base.flags &= ~ENT_COLLIDE; + gPlayerEntity.base.spriteOrientation.flipY = super->spriteOrientation.flipY; + gPlayerEntity.base.spriteRendering.b3 = super->spriteRendering.b3; sub_0803E444(this); #ifndef EU SetPlayerControl(2); @@ -85,8 +85,8 @@ void VaatiProjectile_OnCollision(VaatiProjectileEntity* this) { } } else { gPlayerState.flags &= ~PL_DISABLE_ITEMS; - entity = &gPlayerEntity; - entity->flags = gPlayerEntity.flags | ENT_COLLIDE; + entity = &gPlayerEntity.base; + entity->flags = gPlayerEntity.base.flags | ENT_COLLIDE; } #endif } @@ -174,7 +174,7 @@ void VaatiProjectileFunction0Action3(VaatiProjectileEntity* this) { void VaatiProjectileFunction0Action4(VaatiProjectileEntity* this) { if (--super->timer == 0) { super->action = 1; - super->direction = GetFacingDirection(super, &gPlayerEntity); + super->direction = GetFacingDirection(super, &gPlayerEntity.base); } GetNextFrame(super); } @@ -221,8 +221,8 @@ void VaatiProjectileFunction0Action8(VaatiProjectileEntity* this) { } void VaatiProjectileFunction0Action9(VaatiProjectileEntity* this) { - super->x.HALF.HI = gPlayerEntity.x.HALF.HI; - super->y.HALF.HI = gPlayerEntity.y.HALF.HI; + super->x.HALF.HI = gPlayerEntity.base.x.HALF.HI; + super->y.HALF.HI = gPlayerEntity.base.y.HALF.HI; if (super->z.HALF.HI < -8) { if (super->animIndex != 2) { super->timer = 0; @@ -239,7 +239,7 @@ void sub_0803E444(VaatiProjectileEntity* this) { gPlayerState.mobility |= 0x80; gPlayerState.field_0xa |= 0x80; sub_0806FA90(super, super->contactedEntity, 0, -2); - gPlayerEntity.spriteOffsetY += 0xe; + gPlayerEntity.base.spriteOffsetY += 0xe; } void sub_0803E480(VaatiProjectileEntity* this) { @@ -284,7 +284,7 @@ void sub_0803E4D8(VaatiProjectileEntity* this) { u32 tile; tile = TILE(super->x.HALF.HI, super->y.HALF.HI + 8); - if (sub_080B1B44(tile, gPlayerEntity.collisionLayer) != 0xff) { - SetTile(0x4074, tile, gPlayerEntity.collisionLayer); + if (sub_080B1B44(tile, gPlayerEntity.base.collisionLayer) != 0xff) { + SetTile(0x4074, tile, gPlayerEntity.base.collisionLayer); } } diff --git a/src/enemy/vaatiRebornEnemy.c b/src/enemy/vaatiRebornEnemy.c index 64ec55b0..7ff9174e 100644 --- a/src/enemy/vaatiRebornEnemy.c +++ b/src/enemy/vaatiRebornEnemy.c @@ -281,8 +281,8 @@ void VaatiRebornEnemyType0Action2(VaatiRebornEnemyEntity* this) { if ((super->frame & ANIM_DONE) != 0) { super->spriteSettings.draw = 1; if (4 < this->unk_81) { - super->x.HALF.HI = gPlayerEntity.x.HALF.HI; - super->y.HALF.HI = gPlayerEntity.y.HALF.HI - 0x18; + super->x.HALF.HI = gPlayerEntity.base.x.HALF.HI; + super->y.HALF.HI = gPlayerEntity.base.y.HALF.HI - 0x18; } if (--this->unk_77 == 0) { super->action = 1; @@ -364,7 +364,7 @@ void VaatiRebornEnemyType0Action4(VaatiRebornEnemyEntity* this) { if ((super->frame & 0x10) != 0) { super->frame &= 0xef; if (this->unk_84 == 0xff) { - index = Direction8RoundUp(GetFacingDirection(super, &gPlayerEntity)); + index = Direction8RoundUp(GetFacingDirection(super, &gPlayerEntity.base)); this->unk_84 = gUnk_080D04C0[index >> 2]; super->subtimer = 0; } @@ -410,7 +410,7 @@ void VaatiRebornEnemyType0Action5(VaatiRebornEnemyEntity* this) { if (!((this->unk_86 < 2) || (3 < this->unk_87)) && (Random() & 0x10) != 0) { this->unk_87++; super->subtimer = (Random() & 0x3f) + 64; - uVar3 = GetFacingDirection(super, &gPlayerEntity); + uVar3 = GetFacingDirection(super, &gPlayerEntity.base); super->direction = (uVar3 & 0x10) | DirectionEast; } else { this->unk_74++; @@ -903,15 +903,15 @@ u32 sub_0803E028(VaatiRebornEnemyEntity* this) { return ret; } tmp = gRoomControls.origin_x + 0x58; - if (tmp > gPlayerEntity.x.HALF.HI) { + if (tmp > gPlayerEntity.base.x.HALF.HI) { return ret; } tmp = gRoomControls.origin_y + 0x58; - if (tmp > gPlayerEntity.x.HALF.HI) { + if (tmp > gPlayerEntity.base.x.HALF.HI) { return ret; } tmp = gRoomControls.origin_y + 0xf8; - if (tmp >= gPlayerEntity.x.HALF.HI) { + if (tmp >= gPlayerEntity.base.x.HALF.HI) { this->unk_81 += 5; ret = 1; } diff --git a/src/enemy/vaatiTransfigured.c b/src/enemy/vaatiTransfigured.c index e84b14f8..265b5a98 100644 --- a/src/enemy/vaatiTransfigured.c +++ b/src/enemy/vaatiTransfigured.c @@ -676,7 +676,7 @@ void VaatiTransfiguredType2Action1(VaatiTransfiguredEntity* this) { CopyPosition(super->parent, super); switch (super->type2) { case 2: - uVar3 = GetFacingDirection(super, &gPlayerEntity); + uVar3 = GetFacingDirection(super, &gPlayerEntity.base); t = &gUnk_080D0B18[uVar3]; super->x.HALF.HI += t->x; super->y.HALF.HI += t->y; diff --git a/src/enemy/vaatiWrath.c b/src/enemy/vaatiWrath.c index 8ad668b8..b8bd9b20 100644 --- a/src/enemy/vaatiWrath.c +++ b/src/enemy/vaatiWrath.c @@ -5,9 +5,9 @@ * @brief Vaati Wrath enemy */ #include "enemy/vaatiWrath.h" + #include "functions.h" #include "message.h" -#include "new_player.h" #include "object.h" #include "save.h" #include "screen.h" @@ -217,7 +217,7 @@ void VaatiWrathType0Action1(VaatiWrathEntity* this) { super->subAction = 6; super->timer = 30; gRoomTransition.field_0x38 |= 1; - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; gPlayerState.controlMode = CONTROL_1; break; default: @@ -421,7 +421,7 @@ void VaatiWrathType0Action9(VaatiWrathEntity* this) { sub_08042214(this); } else { if (--super->timer == 0) { - if ((gPlayerEntity.x.HALF.HI - super->x.HALF.HI) + 0x40u < 0x81) { + if ((gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI) + 0x40u < 0x81) { super->action = 10; this->unk_7b = 0; ((VaatiWrathHeapStruct*)super->myHeap)->eyes[0]->timer = 1; @@ -588,7 +588,7 @@ void sub_08041BE8(VaatiWrathEntity* this) { DeleteEntity(entity); ((VaatiWrathHeapStruct*)super->myHeap)->object5b = NULL; - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; #endif entity = ((VaatiWrathHeapStruct*)super->myHeap)->eyes[0]; entity->myHeap = NULL; @@ -834,13 +834,13 @@ u32 sub_0804207C(VaatiWrathEntity* this) { if (((arm != NULL) && (arm->action >= 5)) && EntityWithinDistance(arm, x, y, 0x30)) { return CalculateDirectionTo(arm->x.HALF.HI, arm->y.HALF.HI, x, y); } else { - if (gPlayerEntity.y.HALF.HI < 0x40) { + if (gPlayerEntity.base.y.HALF.HI < 0x40) { tmp = gRoomControls.origin_y + 0x18; } else { - tmp = gPlayerEntity.y.HALF.HI - 0x28; + tmp = gPlayerEntity.base.y.HALF.HI - 0x28; } - return CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, gPlayerEntity.x.HALF.HI, tmp); + return CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, gPlayerEntity.base.x.HALF.HI, tmp); } } } @@ -860,12 +860,12 @@ void sub_0804212C(VaatiWrathEntity* this) { } arm = NULL; y = super->y.HALF.HI - 0x44; - if (gPlayerEntity.y.HALF.HI - y < 0x61u) { + if (gPlayerEntity.base.y.HALF.HI - y < 0x61u) { x = super->x.HALF.HI - 0x38; - if (gPlayerEntity.x.HALF.HI - x < 0x39u) { + if (gPlayerEntity.base.x.HALF.HI - x < 0x39u) { arm = ((VaatiWrathHeapStruct*)super->myHeap)->arms[1]; } else { - if ((gPlayerEntity.x.HALF.HI - super->x.HALF.HI) < 0x39u) { + if ((gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI) < 0x39u) { arm = ((VaatiWrathHeapStruct*)super->myHeap)->arms[0]; } } @@ -1005,8 +1005,8 @@ void VaatiWrathType0PreAction(VaatiWrathEntity* this) { case PL_STATE_IDLE: case PL_STATE_WALK: if (gPlayerState.item == NULL) { - if (gNewPlayerEntity.unk_7a == 0) { - if ((gPlayerEntity.z.HALF.HI & 0x8000U) == 0 || (gPlayerState.field_0xa != 0)) { + if (gPlayerEntity.unk_7a == 0) { + if ((gPlayerEntity.base.z.HALF.HI & 0x8000U) == 0 || (gPlayerState.field_0xa != 0)) { CreateEzloHint(TEXT_INDEX(TEXT_EZLO, 0x70), 0); gRoomTransition.field_0x38 |= 2; } @@ -1054,7 +1054,7 @@ void VaatiWrathType2(VaatiWrathEntity* this) { sub_0806FA90(((VaatiWrathHeapStruct*)super->myHeap)->type0, super, 0, -1); super->spriteOffsetY++; if (super->animIndex == 0x12) { - uVar1 = GetFacingDirection(super, &gPlayerEntity); + uVar1 = GetFacingDirection(super, &gPlayerEntity.base); super->x.HALF.HI = gUnk_080D0EB0[uVar1] + super->x.HALF.HI; } } diff --git a/src/enemy/wallMaster.c b/src/enemy/wallMaster.c index 1c72f15d..8f37a64f 100644 --- a/src/enemy/wallMaster.c +++ b/src/enemy/wallMaster.c @@ -42,9 +42,9 @@ void WallMaster_OnCollision(WallMasterEntity* this) { if (super->hitType != 0x75 && ((super->contactFlags & 0x7f) == 0 || (super->contactFlags & 0x7f) == 0x1e)) { super->action = 5; COLLISION_OFF(super); - this->unk_7e = gPlayerEntity.x.HALF.HI; - this->unk_80 = gPlayerEntity.y.HALF.HI; - this->unk_82 = gPlayerEntity.z.HALF.HI; + this->unk_7e = gPlayerEntity.base.x.HALF.HI; + this->unk_80 = gPlayerEntity.base.y.HALF.HI; + this->unk_82 = gPlayerEntity.base.z.HALF.HI; if (super->action != 3) { InitializeAnimation(super, 1); } @@ -150,12 +150,12 @@ void sub_0802A69C(WallMasterEntity* this) { sub_0802A7D0(this); gPlayerState.field_0xa |= 0x80; gPlayerState.mobility |= 0x80; - gPlayerEntity.x.HALF.HI = this->unk_7e; - gPlayerEntity.y.HALF.HI = this->unk_80; - gPlayerEntity.z.HALF.HI = this->unk_82; + gPlayerEntity.base.x.HALF.HI = this->unk_7e; + gPlayerEntity.base.y.HALF.HI = this->unk_80; + gPlayerEntity.base.z.HALF.HI = this->unk_82; - if (gPlayerEntity.z.HALF.HI != super->z.HALF.HI) { - if (gPlayerEntity.z.HALF.HI < super->z.HALF.HI) { + if (gPlayerEntity.base.z.HALF.HI != super->z.HALF.HI) { + if (gPlayerEntity.base.z.HALF.HI < super->z.HALF.HI) { super->z.HALF.HI--; } else { super->z.HALF.HI++; @@ -171,7 +171,7 @@ void sub_0802A69C(WallMasterEntity* this) { } else if (super->frame & 0x1) { super->frame = flags; super->spriteOffsetY = 3; - gPlayerEntity.spriteSettings.draw = 0; + gPlayerEntity.base.spriteSettings.draw = 0; } } diff --git a/src/enemy/wallMaster2.c b/src/enemy/wallMaster2.c index 34d7cb6a..e5a20d2c 100644 --- a/src/enemy/wallMaster2.c +++ b/src/enemy/wallMaster2.c @@ -49,7 +49,7 @@ void WallMaster2_OnCollision(WallMaster2Entity* this) { super->action = 3; COLLISION_OFF(super); InitializeAnimation(super, 1); - gPlayerEntity.flags &= ~ENT_COLLIDE; + gPlayerEntity.base.flags &= ~ENT_COLLIDE; break; } if (super->confusedTime != 0) { @@ -133,8 +133,8 @@ void sub_0802CE68(WallMaster2Entity* this) { gPlayerState.field_0xa |= 0x80; gPlayerState.mobility |= 0x80; gPlayerState.flags |= PL_DISABLE_ITEMS; - if (!EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 4)) { - super->direction = GetFacingDirection(super, &gPlayerEntity); + if (!EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, 4)) { + super->direction = GetFacingDirection(super, &gPlayerEntity.base); LinearMoveUpdate(super); } sub_0802CFD8(this); @@ -145,7 +145,7 @@ void sub_0802CE68(WallMaster2Entity* this) { super->timer = 30; } else if (super->frame & 1) { super->frame = frames; - gPlayerEntity.spriteSettings.draw = 0; + gPlayerEntity.base.spriteSettings.draw = 0; } } diff --git a/src/enemy/waterDrop.c b/src/enemy/waterDrop.c index 6214d93e..fb2d13e2 100644 --- a/src/enemy/waterDrop.c +++ b/src/enemy/waterDrop.c @@ -76,8 +76,8 @@ void sub_0802A334(Entity* this) { } void sub_0802A39C(Entity* this) { - u32 x = (gPlayerEntity.x.HALF.HI - gRoomControls.scroll_x + gScreen.bg1.xOffset) >> 3; - u32 y = (gPlayerEntity.y.HALF.HI - gRoomControls.scroll_y + gScreen.bg1.yOffset - 10) >> 3; + u32 x = (gPlayerEntity.base.x.HALF.HI - gRoomControls.scroll_x + gScreen.bg1.xOffset) >> 3; + u32 y = (gPlayerEntity.base.y.HALF.HI - gRoomControls.scroll_y + gScreen.bg1.yOffset - 10) >> 3; if (gBG3Buffer[(x & 0x1fU) + (y & 0x1fU) * 0x20 + 0x400]) { COLLISION_OFF(this); } else { diff --git a/src/enemy/wizzrobeFire.c b/src/enemy/wizzrobeFire.c index f81af162..356a8b1b 100644 --- a/src/enemy/wizzrobeFire.c +++ b/src/enemy/wizzrobeFire.c @@ -95,7 +95,7 @@ void WizzrobeFire_Action2(WizzrobeEntity* this) { super->child->spriteSettings.draw = 0; break; case 6: - if (EntityInRectRadius(super, &gPlayerEntity, 0xa0, 0xa0) && CheckOnScreen(super)) { + if (EntityInRectRadius(super, &gPlayerEntity.base, 0xa0, 0xa0) && CheckOnScreen(super)) { Entity* projectile = CreateProjectileWithParent(super, FIRE_PROJECTILE, 1); if (projectile != NULL) { projectile->direction = super->direction & 0x18; diff --git a/src/enemy/wizzrobeIce.c b/src/enemy/wizzrobeIce.c index 0d07a305..4df8891c 100644 --- a/src/enemy/wizzrobeIce.c +++ b/src/enemy/wizzrobeIce.c @@ -102,7 +102,7 @@ void WizzrobeIce_Action2(WizzrobeEntity* this) { super->child->spriteSettings.draw = 0; break; case 0xa: - if (EntityInRectRadius(super, &gPlayerEntity, 0xa0, 0xa0) && CheckOnScreen(super)) { + if (EntityInRectRadius(super, &gPlayerEntity.base, 0xa0, 0xa0) && CheckOnScreen(super)) { Entity* projectile = CreateProjectileWithParent(super, ICE_PROJECTILE, 1); if (projectile != NULL) { projectile->direction = super->direction & 0x18; diff --git a/src/enemy/wizzrobeWind.c b/src/enemy/wizzrobeWind.c index 57381154..ac1c3396 100644 --- a/src/enemy/wizzrobeWind.c +++ b/src/enemy/wizzrobeWind.c @@ -118,7 +118,7 @@ void WizzrobeWind_Action2(WizzrobeEntity* this) { super->parent->spriteSettings.draw = 0; break; case 8: - if (EntityInRectRadius(super, &gPlayerEntity, 0xa0, 0xa0) && CheckOnScreen(super)) { + if (EntityInRectRadius(super, &gPlayerEntity.base, 0xa0, 0xa0) && CheckOnScreen(super)) { Entity* projectile = CreateProjectileWithParent(super, WIND_PROJECTILE, 1); if (projectile != NULL) { projectile->direction = super->direction & 0x18; diff --git a/src/entity.c b/src/entity.c index fd4cb707..34be309d 100644 --- a/src/entity.c +++ b/src/entity.c @@ -1,4 +1,3 @@ -#define ENT_DEPRECATED #include "area.h" #include "common.h" #include "functions.h" @@ -187,12 +186,12 @@ static void UpdatePriorityTimer(void) { void SetPlayerEventPriority(void) { gPriorityHandler.event_priority = PRIO_PLAYER_EVENT; - gPlayerEntity.updatePriority = PRIO_PLAYER_EVENT; + gPlayerEntity.base.updatePriority = PRIO_PLAYER_EVENT; } void ResetPlayerEventPriority(void) { gPriorityHandler.event_priority = PRIO_MIN; - gPlayerEntity.updatePriority = PRIO_PLAYER; + gPlayerEntity.base.updatePriority = PRIO_PLAYER; } void RevokePriority(Entity* e) { @@ -237,7 +236,7 @@ void UpdateManagers(void) { void EraseAllEntities(void) { DeleteAllEntities(); MemClear(&gPriorityHandler, sizeof(PriorityHandler)); - MemClear(&gPlayerEntity, 10880); + MemClear(&gPlayerEntity.base, 10880); MemClear(&gUnk_02033290, 2048); sub_0805E98C(); gEntCount = 0; @@ -249,9 +248,9 @@ void EraseAllEntities(void) { Entity* GetEmptyEntity() { u8 flags_ip; - Entity* end; - Entity* rv; - Entity* currentEnt; + GenericEntity* end; + GenericEntity* rv; + GenericEntity* currentEnt; LinkedList* nextList; LinkedList* listPtr; @@ -262,21 +261,21 @@ Entity* GetEmptyEntity() { end = currentEnt + ARRAY_COUNT(gEntities); do { - if (currentEnt->prev == 0) { - return currentEnt; + if (currentEnt->base.prev == 0) { + return ¤tEnt->base; } } while (++currentEnt < end); } - currentEnt = &gPlayerEntity; + currentEnt = (GenericEntity*)&gPlayerEntity.base; do { - if ((s32)currentEnt->prev < 0 && (currentEnt->flags & (ENT_UNUSED1 | ENT_UNUSED2)) && - currentEnt != gUpdateContext.current_entity) { - ClearDeletedEntity(currentEnt); - return currentEnt; + if ((s32)currentEnt->base.prev < 0 && (currentEnt->base.flags & (ENT_UNUSED1 | ENT_UNUSED2)) && + (Entity*)currentEnt != gUpdateContext.current_entity) { + ClearDeletedEntity(¤tEnt->base); + return ¤tEnt->base; } - } while (++currentEnt < (Entity*)&gCarriedEntity); + } while (++currentEnt < (GenericEntity*)&gCarriedEntity); flags_ip = 0; rv = NULL; @@ -284,37 +283,35 @@ Entity* GetEmptyEntity() { endListPtr = listPtr + ARRAY_COUNT(gEntityLists); do { - currentEnt = listPtr->first; + currentEnt = (GenericEntity*)listPtr->first; nextList = listPtr + 1; while ((u32)currentEnt != (u32)listPtr) { - if (currentEnt->kind != MANAGER && - flags_ip < (currentEnt->flags & (ENT_UNUSED1 | ENT_UNUSED2 | ENT_DELETED)) && - gUpdateContext.current_entity != currentEnt) { - flags_ip = currentEnt->flags & (ENT_UNUSED1 | ENT_UNUSED2 | ENT_DELETED); + if (currentEnt->base.kind != MANAGER && + flags_ip < (currentEnt->base.flags & (ENT_UNUSED1 | ENT_UNUSED2 | ENT_DELETED)) && + gUpdateContext.current_entity != ¤tEnt->base) { + flags_ip = currentEnt->base.flags & (ENT_UNUSED1 | ENT_UNUSED2 | ENT_DELETED); rv = currentEnt; } - currentEnt = currentEnt->next; + currentEnt = (GenericEntity*)currentEnt->base.next; } listPtr = nextList; } while (listPtr < endListPtr); if (rv) { - DeleteEntity(rv); - ClearDeletedEntity(rv); + DeleteEntity(&rv->base); + ClearDeletedEntity(&rv->base); } - return rv; + return &rv->base; } -extern Entity gAuxPlayerEntities[7]; - Entity* CreateAuxPlayerEntity(void) { - Entity* ent = gAuxPlayerEntities; + GenericEntity* ent = gAuxPlayerEntities; do { - if (ent->prev == NULL) { - return ent; + if (ent->base.prev == NULL) { + return &ent->base; } } while (++ent < &gAuxPlayerEntities[7]); @@ -382,17 +379,17 @@ void DeleteEntity(Entity* ent) { } void ClearAllDeletedEntities(void) { - Entity* ent = &gPlayerEntity; + GenericEntity* ent = (GenericEntity*)&gPlayerEntity.base; do { //! @bug if prev pointed to a VALID location higher than a signed int, would still be deleted - if ((int)ent->prev < 0) { - ClearDeletedEntity(ent); + if ((int)ent->base.prev < 0) { + ClearDeletedEntity(&ent->base); } - } while (ent++, ent < (&gPlayerEntity + 80)); + } while (ent++, ent < (((GenericEntity*)&gPlayerEntity.base) + 80)); } void ClearDeletedEntity(Entity* ent) { - DmaClear32(3, ent, sizeof(Entity)); + DmaClear32(3, ent, sizeof(GenericEntity)); gEntCount--; } diff --git a/src/game.c b/src/game.c index 84b99bc8..9f193935 100644 --- a/src/game.c +++ b/src/game.c @@ -388,12 +388,12 @@ static void UpdateWindcrests(void) { u32 hi_x, hi_y; s32 x, y; - x = gPlayerEntity.x.HALF.HI; + x = gPlayerEntity.base.x.HALF.HI; if (x < 0) x += 0xf; hi_x = x >> 4; - y = gPlayerEntity.y.HALF.HI; + y = gPlayerEntity.base.y.HALF.HI; if (y < 0) y += 0xf; hi_y = y >> 4; diff --git a/src/gameUtils.c b/src/gameUtils.c index ef1db81a..56a8aed7 100644 --- a/src/gameUtils.c +++ b/src/gameUtils.c @@ -3,7 +3,6 @@ * * @brief Game Utils */ -#define ENT_DEPRECATED #include "backgroundAnimations.h" #include "enemy.h" #include "entity.h" @@ -113,9 +112,9 @@ void InitializePlayer(void) { MemClear(&gActiveItems, sizeof(gActiveItems)); MemClear(&gPlayerState, sizeof(gPlayerState)); MemFill32(0xffffffff, &gPlayerState.path_memory, sizeof(gPlayerState.path_memory)); - MemClear(&gPlayerEntity, sizeof(gPlayerEntity)); + MemClear(&gPlayerEntity.base, sizeof(gPlayerEntity)); - pl = &gPlayerEntity; + pl = &gPlayerEntity.base; gRoomControls.camera_target = pl; gPlayerState.queued_action = sPlayerSpawnStates[gRoomTransition.player_status.spawn_type]; @@ -211,7 +210,7 @@ s32 ModHealth(s32 delta) { newHealth = stats->maxHealth; } stats->health = newHealth; - gPlayerEntity.health = newHealth; + gPlayerEntity.base.health = newHealth; return newHealth; } @@ -387,8 +386,8 @@ u32 StairsAreValid(void) { void InitParachuteRoom(void) { gRoomTransition.transitioningOut = 1; - gRoomTransition.player_status.start_pos_x = (gPlayerEntity.x.HALF.HI - gRoomControls.origin_x) & 0x3F8; - gRoomTransition.player_status.start_pos_y = (gPlayerEntity.y.HALF.HI - gRoomControls.origin_y) & 0x3F8; + gRoomTransition.player_status.start_pos_x = (gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x) & 0x3F8; + gRoomTransition.player_status.start_pos_y = (gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y) & 0x3F8; gRoomTransition.player_status.start_anim = 4; gRoomTransition.player_status.spawn_type = PL_SPAWN_PARACHUTE_FORWARD; gRoomTransition.player_status.area_next = gRoomControls.area; @@ -434,10 +433,10 @@ bool32 CanDispEzloMessage(void) { return FALSE; if ((gPlayerState.flags & (PL_NO_CAP | PL_CAPTURED | PL_DISABLE_ITEMS)) || (gPlayerState.framestate_last > tmp) || - gPlayerState.item || gPlayerEntity.field_0x7a.HWORD) + gPlayerState.item || gPlayerEntity.unk_7a) return FALSE; - if ((gPlayerEntity.z.HALF.HI & 0x8000) && !gPlayerState.field_0xa) + if ((gPlayerEntity.base.z.HALF.HI & 0x8000) && !gPlayerState.field_0xa) return FALSE; GenerateAreaHint(); @@ -450,7 +449,7 @@ void DisplayEzloMessage(void) { u32 height; u32 idx; if (gRoomTransition.hint_height == 0) { - height = gPlayerEntity.y.HALF.HI - gRoomControls.scroll_y > 96 ? 1 : 13; + height = gPlayerEntity.base.y.HALF.HI - gRoomControls.scroll_y > 96 ? 1 : 13; } else { height = gRoomTransition.hint_height; } @@ -489,11 +488,11 @@ void DecreasePortalTimer(void) { void UpdatePlayerMapCoords(void) { if (!AreaHasNoEnemies()) { if (AreaIsOverworld()) { - gRoomTransition.player_status.overworld_map_x = gPlayerEntity.x.HALF_U.HI; - gRoomTransition.player_status.overworld_map_y = gPlayerEntity.y.HALF_U.HI; + gRoomTransition.player_status.overworld_map_x = gPlayerEntity.base.x.HALF_U.HI; + gRoomTransition.player_status.overworld_map_y = gPlayerEntity.base.y.HALF_U.HI; } else if (AreaIsDungeon()) { - gRoomTransition.player_status.dungeon_map_x = gPlayerEntity.x.HALF.HI; - gRoomTransition.player_status.dungeon_map_y = gPlayerEntity.y.HALF.HI; + gRoomTransition.player_status.dungeon_map_x = gPlayerEntity.base.x.HALF.HI; + gRoomTransition.player_status.dungeon_map_y = gPlayerEntity.base.y.HALF.HI; } } } @@ -739,25 +738,25 @@ void CheckAreaDiscovery(void) { } void UpdatePlayerRoomStatus(void) { - gPlayerState.startPosX = gPlayerEntity.x.HALF.HI; - gPlayerState.startPosY = gPlayerEntity.y.HALF.HI; + gPlayerState.startPosX = gPlayerEntity.base.x.HALF.HI; + gPlayerState.startPosY = gPlayerEntity.base.y.HALF.HI; if (sub_08053144()) { MemCopy(&gRoomTransition.player_status, &gSave.saved_status, sizeof gRoomTransition.player_status); if (AreaIsDungeon()) { gRoomTransition.player_status.dungeon_area = gRoomControls.area; gRoomTransition.player_status.dungeon_room = gRoomControls.room; - gRoomTransition.player_status.dungeon_x = gPlayerEntity.x.HALF.HI; - gRoomTransition.player_status.dungeon_y = gPlayerEntity.y.HALF.HI; + gRoomTransition.player_status.dungeon_x = gPlayerEntity.base.x.HALF.HI; + gRoomTransition.player_status.dungeon_y = gPlayerEntity.base.y.HALF.HI; } } } void sub_08053250(void) { gRoomTransition.player_status.spawn_type = PL_SPAWN_DEFAULT; - gRoomTransition.player_status.start_pos_x = gPlayerEntity.x.HALF.HI - gRoomControls.origin_x; - gRoomTransition.player_status.start_pos_y = gPlayerEntity.y.HALF.HI - gRoomControls.origin_y; - gRoomTransition.player_status.start_anim = gPlayerEntity.animationState; - gRoomTransition.player_status.layer = gPlayerEntity.collisionLayer; + gRoomTransition.player_status.start_pos_x = gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x; + gRoomTransition.player_status.start_pos_y = gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y; + gRoomTransition.player_status.start_anim = gPlayerEntity.base.animationState; + gRoomTransition.player_status.layer = gPlayerEntity.base.collisionLayer; gRoomTransition.player_status.area_next = gRoomControls.area; gRoomTransition.player_status.room_next = gRoomControls.room; MemCopy(&gRoomTransition.player_status, &gSave.saved_status, sizeof gRoomTransition.player_status); diff --git a/src/interrupts.c b/src/interrupts.c index 3ef7235d..5469b5b1 100644 --- a/src/interrupts.c +++ b/src/interrupts.c @@ -1,4 +1,3 @@ -#define ENT_DEPRECATED #include "functions.h" #include "gba/m4a.h" #include "global.h" @@ -237,7 +236,7 @@ static void HandlePlayerLife(Entity* this) { gUnk_0200AF00.rActionInteractTile = R_ACTION_NONE; gUnk_0200AF00.rActionGrabbing = R_ACTION_NONE; - if ((gPlayerEntity.contactFlags & 0x80) && (gPlayerEntity.iframes > 0)) + if ((gPlayerEntity.base.contactFlags & 0x80) && (gPlayerEntity.base.iframes > 0)) SoundReq(SFX_86); gPlayerState.flags &= ~(PL_FALLING | PL_CONVEYOR_PUSHED); @@ -320,15 +319,15 @@ static void sub_080171F0(void) { ResetActiveItems(); if (gPlayerState.field_0x14 != 0) gPlayerState.field_0x14--; - if (gPlayerEntity.field_0x7a.HWORD != 0) - gPlayerEntity.field_0x7a.HWORD--; + if (gPlayerEntity.unk_7a != 0) + gPlayerEntity.unk_7a--; - gPlayerEntity.contactFlags &= ~0x80; - if (gPlayerEntity.action != PLAYER_DROWN) + gPlayerEntity.base.contactFlags &= ~0x80; + if (gPlayerEntity.base.action != PLAYER_DROWN) COPY_FLAG_FROM_TO(gPlayerState.flags, 0x2, 0x10000); gPlayerState.flags &= ~PL_FLAGS2; - sub_080028E0(&gPlayerEntity); + sub_080028E0(&gPlayerEntity.base); if (gPlayerState.flags & PL_CLONING) gUnk_0200AF00.rActionPlayerState = R_ACTION_CANCEL; @@ -341,23 +340,23 @@ static void sub_080171F0(void) { gPlayerState.speed_modifier = 0; gPlayerState.attachedBeetleCount = 0; MemClear(&gCarriedEntity, sizeof(gCarriedEntity)); - gPlayerEntity.spriteOffsetY = gPlayerState.spriteOffsetY; + gPlayerEntity.base.spriteOffsetY = gPlayerState.spriteOffsetY; gPlayerState.spriteOffsetY = 0; sub_0807B0C8(); if (gPlayerState.flags & PL_CLONING) gPlayerClones[0]->spriteOffsetY = gPlayerClones[1]->spriteOffsetY = gPlayerClones[2]->spriteOffsetY = 0; - if (gPlayerEntity.action == PLAYER_CLIMB) + if (gPlayerEntity.base.action == PLAYER_CLIMB) gPlayerState.flags |= PL_CLIMBING; else gPlayerState.flags &= ~PL_CLIMBING; - sub_0807A8D8(&gPlayerEntity); + sub_0807A8D8(&gPlayerEntity.base); if (gPlayerState.jump_status & 0xc0) - gPlayerEntity.iframes = 0xfe; + gPlayerEntity.base.iframes = 0xfe; - if (gPlayerEntity.action != PLAYER_ROOMTRANSITION) { - sub_08077FEC(gPlayerEntity.action); + if (gPlayerEntity.base.action != PLAYER_ROOMTRANSITION) { + sub_08077FEC(gPlayerEntity.base.action); } } diff --git a/src/item/itemBomb.c b/src/item/itemBomb.c index 74264e17..90c66539 100644 --- a/src/item/itemBomb.c +++ b/src/item/itemBomb.c @@ -38,8 +38,8 @@ void sub_08075FF8(ItemBehavior* this, u32 index) { if (maxBombs > bombCount) { entity = CreatePlayerItemWithParent(this, PLAYER_ITEM_BOMB); if (entity != NULL) { - pos = &gUnk_0811BDAC[gPlayerEntity.animationState & 6]; - PositionRelative(&gPlayerEntity, entity, Q_16_16(pos[0]), Q_16_16(pos[1])); + pos = &gUnk_0811BDAC[gPlayerEntity.base.animationState & 6]; + PositionRelative(&gPlayerEntity.base, entity, Q_16_16(pos[0]), Q_16_16(pos[1])); ModBombs(-1); SoundReq(SFX_PLACE_OBJ); } diff --git a/src/item/itemBoomerang.c b/src/item/itemBoomerang.c index 64c78d87..a9c6aaab 100644 --- a/src/item/itemBoomerang.c +++ b/src/item/itemBoomerang.c @@ -15,7 +15,7 @@ void ItemBoomerang(ItemBehavior* this, u32 index) { void sub_08075D2C(ItemBehavior* this, u32 index) { if (((gPlayerState.attack_status & 8) == 0) && (FindPlayerItemForItem(this, this->behaviorId) == NULL)) { this->priority |= 0xf; - sub_0806F948(&gPlayerEntity); + sub_0806F948(&gPlayerEntity.base); CreatePlayerItemIfNotExists(this, ITEM_BOOMERANG); sub_08077D38(this, index); gPlayerState.attack_status |= 8; diff --git a/src/item/itemBow.c b/src/item/itemBow.c index ca2cc809..9b57e9c1 100644 --- a/src/item/itemBow.c +++ b/src/item/itemBow.c @@ -19,7 +19,7 @@ void ItemBow(ItemBehavior* this, u32 index) { void sub_08075DF4(ItemBehavior* this, u32 index) { if ((gPlayerState.attack_status & 8) == 0) { this->priority |= 0x80; - sub_0806F948(&gPlayerEntity); + sub_0806F948(&gPlayerEntity.base); sub_08077BB8(this); sub_08077D38(this, index); gPlayerState.bow_state = 1; diff --git a/src/item/itemGustJar.c b/src/item/itemGustJar.c index 54dae3b2..a1c8b4f0 100644 --- a/src/item/itemGustJar.c +++ b/src/item/itemGustJar.c @@ -1,7 +1,6 @@ #include "entity.h" #include "functions.h" #include "item.h" -#include "new_player.h" #include "playeritem.h" void (*const ItemGustJar_StateFunctions[])(ItemBehavior* this, u32); @@ -12,15 +11,15 @@ void ItemGustJar(ItemBehavior* this, u32 index) { } void sub_08076DF4(ItemBehavior* this, u32 index) { - if (GetCollisionTileInFront(&gPlayerEntity) != 0x29 && gPlayerState.floor_type != SURFACE_DOOR && + if (GetCollisionTileInFront(&gPlayerEntity.base) != 0x29 && gPlayerState.floor_type != SURFACE_DOOR && gPlayerState.floor_type != SURFACE_DOOR_13 && gPlayerState.jump_status == 0) { sub_08077D38(this, index); this->timer = 0; - this->playerAnimationState = gPlayerEntity.animationState; + this->playerAnimationState = gPlayerEntity.base.animationState; this->priority |= 0x80; this->priority++; gPlayerState.gustJarSpeed = 1; - gNewPlayerEntity.unk_74 = NULL; + gPlayerEntity.unk_74 = NULL; gPlayerState.field_0x1c = 1; sub_08077BB8(this); } else { @@ -40,7 +39,7 @@ void sub_08076E60(ItemBehavior* this, u32 index) { gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> index); playerItem = CreatePlayerItem(PLAYER_ITEM_GUST, 0, 0, 0); if (playerItem != NULL) { - playerItem->parent = &gPlayerEntity; + playerItem->parent = &gPlayerEntity.base; } } else { UpdateItemAnim(this); @@ -63,7 +62,7 @@ void sub_08076EC8(ItemBehavior* this, u32 index) { gPlayerState.gustJarSpeed = 1; } - if (gPlayerEntity.subAction == 0x1b) { + if (gPlayerEntity.base.subAction == 0x1b) { animIndex = ANIM_GUSTJAR_524; } else { if (gPlayerState.direction & DIR_NOT_MOVING_CHECK) { @@ -95,7 +94,7 @@ void sub_08076F64(ItemBehavior* this, u32 index) { this->subtimer = 0; this->timer = 0; gPlayerState.gustJarSpeed = 1; - player = &gNewPlayerEntity; + player = &gPlayerEntity; player->unk_74 = NULL; gPlayerState.field_0x1c = 1; gPlayerState.field_0xa &= ~(8 >> index); @@ -119,9 +118,9 @@ void sub_08076F64(ItemBehavior* this, u32 index) { UpdateItemAnim(this); if ((gPlayerState.flags & PL_FLAGS2)) return; - gPlayerEntity.direction = - DirectionTurnAround(Direction8FromAnimationState(gPlayerEntity.animationState)); - gPlayerEntity.speed = 0x80; + gPlayerEntity.base.direction = + DirectionTurnAround(Direction8FromAnimationState(gPlayerEntity.base.animationState)); + gPlayerEntity.base.speed = 0x80; UpdatePlayerMovement(); return; @@ -137,7 +136,7 @@ void sub_08076F64(ItemBehavior* this, u32 index) { UpdateItemAnim(this); if (this->playerFrame & 1) { gPlayerState.field_0x1c = 5; - gNewPlayerEntity.unk_70 = NULL; + gPlayerEntity.unk_70 = NULL; if (gPlayerState.gustJarSpeed) { CreatePlayerItem(PLAYER_ITEM_GUST_BIG, 0, 0, 0); } @@ -145,8 +144,9 @@ void sub_08076F64(ItemBehavior* this, u32 index) { if (gPlayerState.flags & PL_FLAGS2) return; - gPlayerEntity.direction = DirectionTurnAround(Direction8FromAnimationState(gPlayerEntity.animationState)); - gPlayerEntity.speed = 0x80; + gPlayerEntity.base.direction = + DirectionTurnAround(Direction8FromAnimationState(gPlayerEntity.base.animationState)); + gPlayerEntity.base.speed = 0x80; UpdatePlayerMovement(); return; case 6: @@ -169,7 +169,7 @@ void sub_08076F64(ItemBehavior* this, u32 index) { break; } gPlayerState.field_0x1c = 0; - gNewPlayerEntity.unk_70 = NULL; + gPlayerEntity.unk_70 = NULL; DeleteItemBehavior(this, index); } diff --git a/src/item/itemJarEmpty.c b/src/item/itemJarEmpty.c index 6296dc67..90ec65ed 100644 --- a/src/item/itemJarEmpty.c +++ b/src/item/itemJarEmpty.c @@ -20,7 +20,7 @@ void ItemJarEmpty(ItemBehavior* this, u32 index) { void sub_08077534(ItemBehavior* this, u32 index) { u32 tmp; sub_08077D38(this, index); - sub_0806F948(&gPlayerEntity); + sub_0806F948(&gPlayerEntity.base); sub_08077BB8(this); this->priority |= 0xf; tmp = this->behaviorId; @@ -41,8 +41,8 @@ void sub_08077534(ItemBehavior* this, u32 index) { case ITEM_BOTTLE_PICOLYTE_BLUE: case ITEM_BOTTLE_PICOLYTE_WHITE: this->stateID = 3; - gPlayerEntity.animationState = 4; - gPlayerEntity.spriteSettings.flipX = 0; + gPlayerEntity.base.animationState = 4; + gPlayerEntity.base.spriteSettings.flipX = 0; SetItemAnim(this, ANIM_BOTTLE_DRINK); break; case BOTTLE_CHARM_NAYRU: @@ -53,7 +53,7 @@ void sub_08077534(ItemBehavior* this, u32 index) { SetItemAnim(this, ANIM_BOTTLE_POUR); break; } - gPlayerEntity.flags &= ~ENT_COLLIDE; + gPlayerEntity.base.flags &= ~ENT_COLLIDE; } void sub_08077618(ItemBehavior* this, u32 index) { @@ -68,7 +68,7 @@ void sub_08077618(ItemBehavior* this, u32 index) { void sub_08077640(ItemBehavior* this, u32 index) { UpdateItemAnim(this); if ((this->playerFrame & 0x80) != 0) { - gPlayerEntity.flags |= ENT_COLLIDE; + gPlayerEntity.base.flags |= ENT_COLLIDE; DeleteItemBehavior(this, index); } } @@ -76,7 +76,7 @@ void sub_08077640(ItemBehavior* this, u32 index) { void sub_0807766C(ItemBehavior* this, u32 index) { UpdateItemAnim(this); if ((this->playerFrame & 0x80) != 0) { - gPlayerEntity.flags |= ENT_COLLIDE; + gPlayerEntity.base.flags |= ENT_COLLIDE; DeleteItemBehavior(this, index); } } diff --git a/src/item/itemLantern.c b/src/item/itemLantern.c index f7806bd0..af488bd1 100644 --- a/src/item/itemLantern.c +++ b/src/item/itemLantern.c @@ -1,7 +1,6 @@ #include "functions.h" #include "game.h" #include "item.h" -#include "new_player.h" #include "object.h" #include "sound.h" @@ -38,13 +37,13 @@ void sub_08075A0C(ItemBehavior* this, u32 index) { this->priority |= 0x80; sub_08077D38(this, index); CreatePlayerItemForItemIfNotExists(this); - sub_0806F948(&gPlayerEntity); + sub_0806F948(&gPlayerEntity.base); this->behaviorId = 0x10; ForceEquipItem(ITEM_LANTERN_ON, equipSlot); - tmp = &gUnk_08126EEC[gPlayerEntity.animationState & 6]; - object = CreateObjectWithParent(&gPlayerEntity, LAMP_PARTICLE, 1, 0); + tmp = &gUnk_08126EEC[gPlayerEntity.base.animationState & 6]; + object = CreateObjectWithParent(&gPlayerEntity.base, LAMP_PARTICLE, 1, 0); if (object != NULL) { - object->spriteVramOffset = gPlayerEntity.spriteVramOffset; + object->spriteVramOffset = gPlayerEntity.base.spriteVramOffset; object->x.HALF.HI = tmp[0] + object->x.HALF.HI; object->y.HALF.HI = tmp[1] + object->y.HALF.HI; } @@ -89,19 +88,19 @@ void sub_08075B54(ItemBehavior* this, u32 index) { DeleteItemBehavior(this, index); SoundReq(SFX_ITEM_LANTERN_OFF); } else { - if (((gPlayerState.queued_action != PLAYER_ROLL) && (gPlayerEntity.frameIndex < 0x37)) && - ((u16)gPlayerEntity.spriteIndex == 6)) { - tmp = &gUnk_08126EEC[gPlayerEntity.animationState & 6]; + if (((gPlayerState.queued_action != PLAYER_ROLL) && (gPlayerEntity.base.frameIndex < 0x37)) && + ((u16)gPlayerEntity.base.spriteIndex == 6)) { + tmp = &gUnk_08126EEC[gPlayerEntity.base.animationState & 6]; if ((gPlayerState.jump_status == 0) && - (sub_080B1BA4(TILE(gPlayerEntity.x.HALF.HI + tmp[0], gPlayerEntity.y.HALF.HI + tmp[1]), - gPlayerEntity.collisionLayer, 0x40) != 0)) { + (sub_080B1BA4(TILE(gPlayerEntity.base.x.HALF.HI + tmp[0], gPlayerEntity.base.y.HALF.HI + tmp[1]), + gPlayerEntity.base.collisionLayer, 0x40) != 0)) { this->animPriority = 0xf; this->stateID++; - gNewPlayerEntity.unk_7a = 2; - object = CreateObjectWithParent(&gPlayerEntity, LAMP_PARTICLE, 1, 0); + gPlayerEntity.unk_7a = 2; + object = CreateObjectWithParent(&gPlayerEntity.base, LAMP_PARTICLE, 1, 0); if (object != NULL) { - object->spriteVramOffset = gPlayerEntity.spriteVramOffset; + object->spriteVramOffset = gPlayerEntity.base.spriteVramOffset; object->x.HALF.HI = tmp[0] + object->x.HALF.HI; object->y.HALF.HI = tmp[1] + object->y.HALF.HI; } @@ -120,8 +119,8 @@ void sub_08075C9C(ItemBehavior* this, u32 index) { UpdateItemAnim(this); if ((this->playerFrame & 0x10) != 0) { - tmp = &gUnk_08126EEC[gPlayerEntity.animationState & 6]; - sub_0807AB44(&gPlayerEntity, tmp[0], tmp[1]); + tmp = &gUnk_08126EEC[gPlayerEntity.base.animationState & 6]; + sub_0807AB44(&gPlayerEntity.base, tmp[0], tmp[1]); } if ((this->playerFrame & 0x80) != 0) { this->animPriority = 0; @@ -129,6 +128,6 @@ void sub_08075C9C(ItemBehavior* this, u32 index) { gPlayerState.field_0xa = (~(8 >> index)) & gPlayerState.field_0xa; gPlayerState.keepFacing = (~(8 >> index)) & gPlayerState.keepFacing; } else { - gNewPlayerEntity.unk_7a++; + gPlayerEntity.unk_7a++; } } diff --git a/src/item/itemMoleMitts.c b/src/item/itemMoleMitts.c index aa063eff..7dfc8d27 100644 --- a/src/item/itemMoleMitts.c +++ b/src/item/itemMoleMitts.c @@ -37,10 +37,10 @@ void sub_08077130(ItemBehavior* this, u32 index) { SetItemAnim(this, ANIM_MOLEMITTS_DIG); this->stateID = 2; if (iVar1 == 0x56) { - if ((gPlayerEntity.animationState & 2) != 0) { - gPlayerEntity.y.HALF.HI = (gPlayerEntity.y.HALF.HI & 0xfff0) | 6; + if ((gPlayerEntity.base.animationState & 2) != 0) { + gPlayerEntity.base.y.HALF.HI = (gPlayerEntity.base.y.HALF.HI & 0xfff0) | 6; } else { - gPlayerEntity.x.HALF.HI = (gPlayerEntity.x.HALF.HI & 0xfff0) | 8; + gPlayerEntity.base.x.HALF.HI = (gPlayerEntity.base.x.HALF.HI & 0xfff0) | 8; } } } @@ -67,22 +67,22 @@ void sub_080771C8(ItemBehavior* this, u32 index) { gPlayerState.moleMittsState = 0; } else { if (((this->playerFrame & 0x20) != 0) && (this->subtimer == 0xff)) { - CreateObjectWithParent(&gPlayerEntity, MOLE_MITTS_PARTICLE, this->playerFrame, 1); + CreateObjectWithParent(&gPlayerEntity.base, MOLE_MITTS_PARTICLE, this->playerFrame, 1); } if ((this->playerFrame & 0x10) != 0) { - if (sub_0800875A(&gPlayerEntity, 0xd, this) == 0) { + if (sub_0800875A(&gPlayerEntity.base, 0xd, this) == 0) { SetItemAnim(this, ANIM_MOLEMITTS_MISS); this->stateID = 3; SoundReq(SFX_ITEM_GLOVES_AIR); } else { if (this->subtimer != 0xff) { - object = CreateObjectWithParent(&gPlayerEntity, OBJECT_1F, 0, this->field_0x2[1]); + object = CreateObjectWithParent(&gPlayerEntity.base, OBJECT_1F, 0, this->field_0x2[1]); if (object != NULL) { object->timer = this->timer; object->subtimer = this->subtimer; - object->animationState = gPlayerEntity.animationState & 6; - gPlayerEntity.frame = 0; - gPlayerEntity.frameDuration = gUnk_0811BE14[this->subtimer]; + object->animationState = gPlayerEntity.base.animationState & 6; + gPlayerEntity.base.frame = 0; + gPlayerEntity.base.frameDuration = gUnk_0811BE14[this->subtimer]; } } else { if ((this->field_0x2[1] == 0x0f) && (this->timer == 0x17)) { @@ -110,22 +110,22 @@ void sub_080772A8(ItemBehavior* this, u32 index) { if (GetInventoryValue(ITEM_DIG_BUTTERFLY) == 1) { if ((this->playerFrame & 7) != 3) { sub_08077E3C(this, 2); - gPlayerEntity.speed = gUnk_0811BE16[this->playerFrame & 7] << 1; + gPlayerEntity.base.speed = gUnk_0811BE16[this->playerFrame & 7] << 1; } else { UpdateItemAnim(this); - gPlayerEntity.speed = gUnk_0811BE16[this->playerFrame & 7]; + gPlayerEntity.base.speed = gUnk_0811BE16[this->playerFrame & 7]; } } else { UpdateItemAnim(this); - gPlayerEntity.speed = gUnk_0811BE16[this->playerFrame & 7]; + gPlayerEntity.base.speed = gUnk_0811BE16[this->playerFrame & 7]; } - gPlayerEntity.direction = gPlayerEntity.animationState << 2; - if (gPlayerEntity.speed != 0) { + gPlayerEntity.base.direction = gPlayerEntity.base.animationState << 2; + if (gPlayerEntity.base.speed != 0) { UpdatePlayerMovement(); } if ((this->playerFrame & 0x10) != 0) { if (this->timer != 0) { - gPlayerEntity.frameDuration = 1; + gPlayerEntity.base.frameDuration = 1; if (sub_080774A0()) { this->timer = 0; return; @@ -135,21 +135,21 @@ void sub_080772A8(ItemBehavior* this, u32 index) { gPlayerState.moleMittsState = 0; } else { if ((this->playerFrame & 0x60) != 0) { - gPlayerEntity.frameDuration = 1; - if (sub_0807B5B0(&gPlayerEntity)) { + gPlayerEntity.base.frameDuration = 1; + if (sub_0807B5B0(&gPlayerEntity.base)) { SoundReq(SFX_108); - CreateObjectWithParent(&gPlayerEntity, MOLE_MITTS_PARTICLE, this->playerFrame, 0); + CreateObjectWithParent(&gPlayerEntity.base, MOLE_MITTS_PARTICLE, this->playerFrame, 0); } else { SetItemAnim(this, ANIM_MOLEMITTS_CLANG); - effect = CreateFx(&gPlayerEntity, FX_STARS_STRIKE, 0); + effect = CreateFx(&gPlayerEntity.base, FX_STARS_STRIKE, 0); if (effect != NULL) { effect->animationState = this->playerAnimationState; - effect->spritePriority.b0 = gPlayerEntity.spritePriority.b0 - 1; + effect->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0 - 1; } - effect = CreateFx(&gPlayerEntity, FX_STARS_STRIKE, 0); + effect = CreateFx(&gPlayerEntity.base, FX_STARS_STRIKE, 0); if (effect != NULL) { effect->animationState = this->playerAnimationState; - effect->spritePriority.b0 = gPlayerEntity.spritePriority.b0 - 1; + effect->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0 - 1; effect->subtimer = 1; } this->stateID = 3; @@ -161,8 +161,8 @@ void sub_080772A8(ItemBehavior* this, u32 index) { } void sub_08077448(ItemBehavior* this, u32 index) { - gPlayerEntity.direction = gPlayerEntity.animationState << 2 ^ 0x10; - gPlayerEntity.speed = 0x100; + gPlayerEntity.base.direction = gPlayerEntity.base.animationState << 2 ^ 0x10; + gPlayerEntity.base.speed = 0x100; if (((this->playerFrame & 1) != 0) && (this->field_0x5 != 0)) { UpdatePlayerMovement(); } @@ -178,16 +178,16 @@ s32 sub_080774A0(void) { u32 iVar2; u32 uVar3; - uVar3 = COORD_TO_TILE_OFFSET((&gPlayerEntity), -gUnk_0811BE1E[gPlayerEntity.animationState & 6], - -gUnk_0811BE1E[(gPlayerEntity.animationState & 6) + 1]); + uVar3 = COORD_TO_TILE_OFFSET((&gPlayerEntity.base), -gUnk_0811BE1E[gPlayerEntity.base.animationState & 6], + -gUnk_0811BE1E[(gPlayerEntity.base.animationState & 6) + 1]); - iVar2 = sub_080B1B44(uVar3, gPlayerEntity.collisionLayer); + iVar2 = sub_080B1B44(uVar3, gPlayerEntity.base.collisionLayer); if (iVar2 > 0x16) return 0; if (iVar2 < 0xf) return 0; - if (sub_080B1AE0(uVar3, gPlayerEntity.collisionLayer) != 0x56) { + if (sub_080B1AE0(uVar3, gPlayerEntity.base.collisionLayer) != 0x56) { return 1; } else { return 0x56; diff --git a/src/item/itemOcarina.c b/src/item/itemOcarina.c index 4b88138c..e5cea164 100644 --- a/src/item/itemOcarina.c +++ b/src/item/itemOcarina.c @@ -1,6 +1,5 @@ #include "functions.h" #include "item.h" -#include "new_player.h" #include "sound.h" extern void ResetPlayerVelocity(void); @@ -14,7 +13,7 @@ void ItemOcarina(ItemBehavior* this, u32 index) { OcarinaUpdate, }; gOcarinaStates[this->stateID](this, index); - gNewPlayerEntity.unk_7a++; + gPlayerEntity.unk_7a++; } void OcarinaUse(ItemBehavior* this, u32 index) { @@ -22,10 +21,10 @@ void OcarinaUse(ItemBehavior* this, u32 index) { DeleteItemBehavior(this, index); } else { this->priority |= 0xf; - gPlayerEntity.animationState = 0x04; - gPlayerEntity.spriteSettings.flipX = 0; - gPlayerEntity.flags &= ~ENT_COLLIDE; - gNewPlayerEntity.unk_7a = 2; + gPlayerEntity.base.animationState = 0x04; + gPlayerEntity.base.spriteSettings.flipX = 0; + gPlayerEntity.base.flags &= ~ENT_COLLIDE; + gPlayerEntity.unk_7a = 2; gPlayerState.flags |= PL_USE_OCARINA; gPlayerState.field_0x27[0] = -1; gPauseMenuOptions.disabled = 1; @@ -41,11 +40,11 @@ void OcarinaUse(ItemBehavior* this, u32 index) { void OcarinaUpdate(ItemBehavior* this, u32 index) { UpdateItemAnim(this); if ((this->playerFrame & 0x80) != 0) { - gPlayerEntity.flags |= ENT_COLLIDE; + gPlayerEntity.base.flags |= ENT_COLLIDE; gPlayerState.flags &= ~PL_USE_OCARINA; gPlayerState.field_0x27[0] = 0; gPauseMenuOptions.disabled = 0; - CreateBird(&gPlayerEntity); + CreateBird(&gPlayerEntity.base); ResetPlayerEventPriority(); DeleteItemBehavior(this, index); } diff --git a/src/item/itemPacciCane.c b/src/item/itemPacciCane.c index 879f2051..56d2592c 100644 --- a/src/item/itemPacciCane.c +++ b/src/item/itemPacciCane.c @@ -18,7 +18,7 @@ void ItemPacciCane(ItemBehavior* this, u32 index) { void sub_08076C98(ItemBehavior* this, u32 index) { this->priority |= 0xf; sub_08077D38(this, index); - sub_0806F948(&gPlayerEntity); + sub_0806F948(&gPlayerEntity.base); sub_08077BB8(this); } diff --git a/src/item/itemPegasusBoots.c b/src/item/itemPegasusBoots.c index 21fa559a..0b4af5ea 100644 --- a/src/item/itemPegasusBoots.c +++ b/src/item/itemPegasusBoots.c @@ -1,4 +1,3 @@ -#define ENT_DEPRECATED #include "asm.h" #include "effects.h" #include "functions.h" @@ -25,7 +24,7 @@ void ItemPegasusBoots(ItemBehavior* this, u32 index) { Entity* fx; u32 uVar4; - if (gPlayerEntity.field_0x7a.HWORD != 0) { + if (gPlayerEntity.unk_7a != 0) { gPlayerState.dash_state = 0; gPlayerState.itemAnimPriority = 0; DeleteItemBehavior(this, index); @@ -36,11 +35,11 @@ void ItemPegasusBoots(ItemBehavior* this, u32 index) { } if (((gPlayerState.flags & PL_MINISH) == 0) && ((this->timer & 7) == 0)) { if (gPlayerState.floor_type == SURFACE_SWAMP) { - if (gPlayerEntity.spriteOffsetY == 0) { - CreateFx(&gPlayerEntity, FX_GREEN_SPLASH, 0); + if (gPlayerEntity.base.spriteOffsetY == 0) { + CreateFx(&gPlayerEntity.base, FX_GREEN_SPLASH, 0); } } else { - fx = CreateFx(&gPlayerEntity, FX_DASH, 0x40); + fx = CreateFx(&gPlayerEntity.base, FX_DASH, 0x40); if ((fx != NULL) && (fx->y.HALF.HI = fx->y.HALF.HI + 2, this->stateID != 2)) { uVar4 = Random() & 3; if ((Random() & 1) != 0) { @@ -86,7 +85,7 @@ void sub_080768F8(ItemBehavior* this, u32 index) { void sub_08076964(ItemBehavior* this, u32 index) { Entity* entity; u32 uVar3; - if (IsItemActive(this) && gPlayerEntity.z.WORD == 0 && gPlayerState.dash_state) { + if (IsItemActive(this) && gPlayerEntity.base.z.WORD == 0 && gPlayerState.dash_state) { UpdateItemAnim(this); if ((gPlayerState.flags & PL_MINISH) == 0) { @@ -113,7 +112,7 @@ void sub_08076964(ItemBehavior* this, u32 index) { } else { uVar3 = gSave.stats.equipped[SLOT_B]; } - entity->field_0x68.HALF.LO = uVar3; + ((GenericEntity*)entity)->field_0x68.HALF.LO = uVar3; return; } } else if (!(gPlayerState.flags & PL_MINISH)) { @@ -138,16 +137,16 @@ void sub_08076A88(ItemBehavior* this, u32 index) { if ((IsItemActive(this) != 0) && (gPlayerState.dash_state != 0)) { if (!(gPlayerState.flags & PL_MINISH)) { - gPlayerEntity.speed = 0x300; + gPlayerEntity.base.speed = 0x300; } else { - gPlayerEntity.speed = 0x280; + gPlayerEntity.base.speed = 0x280; } - uVar2 = gUnk_0800275C[(gPlayerEntity.animationState & 0xe) * 4]; - if (uVar2 == (gPlayerEntity.collisions & uVar2)) { + uVar2 = gUnk_0800275C[(gPlayerEntity.base.animationState & 0xe) * 4]; + if (uVar2 == (gPlayerEntity.base.collisions & uVar2)) { if (this->subtimer != 0) { - gPlayerEntity.action = PLAYER_BOUNCE; - gPlayerEntity.subAction = 0; - COLLISION_OFF(&gPlayerEntity); + gPlayerEntity.base.action = PLAYER_BOUNCE; + gPlayerEntity.base.subAction = 0; + COLLISION_OFF(&gPlayerEntity.base); gPlayerState.field_0x38 = 0; gPlayerState.direction = DIR_NONE; return; @@ -156,7 +155,7 @@ void sub_08076A88(ItemBehavior* this, u32 index) { return; } ptr = gUnk_0811BE38; - if ((*(u16*)&ptr[(gPlayerEntity.animationState & 0xfe)] & gPlayerState.playerInput.heldInput) == 0) { + if ((*(u16*)&ptr[(gPlayerEntity.base.animationState & 0xfe)] & gPlayerState.playerInput.heldInput) == 0) { this->direction = (this->playerAnimationState & 0xe) * 4; if ((gPlayerState.direction != DIR_NONE) && (gPlayerState.direction != this->direction)) { if (((gPlayerState.direction - this->direction) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | diff --git a/src/item/itemRocsCape.c b/src/item/itemRocsCape.c index d284ba28..ed7f6526 100644 --- a/src/item/itemRocsCape.c +++ b/src/item/itemRocsCape.c @@ -1,6 +1,5 @@ #include "functions.h" #include "item.h" -#include "new_player.h" #include "sound.h" void sub_08076758(ItemBehavior*, u32); @@ -15,16 +14,16 @@ void ItemRocsCape(ItemBehavior* this, u32 index) { if (gPlayerState.grab_status) { if (((gPlayerState.attack_status | gPlayerState.heldObject) == 0) && (((gPlayerState.floor_type != SURFACE_DOOR && (gPlayerState.floor_type != SURFACE_PIT)) || - ((gPlayerEntity.z.WORD != 0 || (gPlayerState.field_0x14 != 0)))))) { + ((gPlayerEntity.base.z.WORD != 0 || (gPlayerState.field_0x14 != 0)))))) { if ((gPlayerState.jump_status == 0) || ((gPlayerState.jump_status & 7) == 3)) { - if (-1 < gPlayerEntity.z.WORD) { + if (-1 < gPlayerEntity.base.z.WORD) { gPlayerState.grab_status = 0; this->stateID++; gPlayerState.keepFacing = 0; gPlayerState.jump_status = 1; gPlayerState.itemAnimPriority = -1; gPlayerState.item = NULL; - gPlayerEntity.zVelocity = Q_16_16(2.0); + gPlayerEntity.base.zVelocity = Q_16_16(2.0); sub_08077F84(); SoundReq(SFX_PLY_VO4); return; @@ -39,13 +38,13 @@ void ItemRocsCape(ItemBehavior* this, u32 index) { gPlayerState.heldObject | gPlayerState.field_0x1c | gPlayerState.moleMittsState) == 0) && ((((gPlayerState.floor_type != SURFACE_DOOR && gPlayerState.floor_type != SURFACE_DOOR_13 && gPlayerState.floor_type != SURFACE_PIT) || - (gPlayerEntity.z.WORD != 0)) || + (gPlayerEntity.base.z.WORD != 0)) || (gPlayerState.field_0x14 != 0)))) { if ((gPlayerState.jump_status != 0) && ((gPlayerState.jump_status & 7) != 3)) { sub_08076758(this, index); return; - } else if (gPlayerEntity.z.WORD >= 0) { - gPlayerEntity.zVelocity = Q_16_16(2.0); + } else if (gPlayerEntity.base.z.WORD >= 0) { + gPlayerEntity.base.zVelocity = Q_16_16(2.0); gPlayerState.jump_status = 1; gPlayerState.item = NULL; this->stateID++; @@ -65,20 +64,20 @@ void sub_08076758(ItemBehavior* this, u32 index) { ((gPlayerState.jump_status & 7) != 3)) { if (IsItemActive(this)) { if (this->stateID < 2) { - if ((gPlayerEntity.zVelocity <= 0) && ((gPlayerState.jump_status & 0x10) == 0)) { + if ((gPlayerEntity.base.zVelocity <= 0) && ((gPlayerState.jump_status & 0x10) == 0)) { this->stateID = 2; - gNewPlayerEntity.unk_7a = 2; - gPlayerEntity.zVelocity = Q_16_16(2.0); + gPlayerEntity.unk_7a = 2; + gPlayerEntity.base.zVelocity = Q_16_16(2.0); gPlayerState.jump_status |= 0x10; gPlayerState.animation = ANIM_ROCS_CAPE; SoundReq(SFX_172); } } else { - gNewPlayerEntity.unk_7a++; + gPlayerEntity.unk_7a++; } } else { if (this->stateID > 1) { - gNewPlayerEntity.unk_7a++; + gPlayerEntity.unk_7a++; gPlayerState.jump_status &= 0xef; } } diff --git a/src/item/itemShield.c b/src/item/itemShield.c index f9320d79..2fa8f07c 100644 --- a/src/item/itemShield.c +++ b/src/item/itemShield.c @@ -20,7 +20,7 @@ void ItemShield(ItemBehavior* this, u32 index) { void sub_08076D04(ItemBehavior* this, u32 index) { gPlayerState.shield_status = 0x81; this->priority = 2; - sub_0806F948(&gPlayerEntity); + sub_0806F948(&gPlayerEntity.base); sub_08077D38(this, index); sub_08077BB8(this); } diff --git a/src/item/itemSword.c b/src/item/itemSword.c index f27e0f2b..95110349 100644 --- a/src/item/itemSword.c +++ b/src/item/itemSword.c @@ -38,8 +38,8 @@ void sub_08075338(ItemBehavior* this, u32 index) { if (gPlayerState.jump_status) { if ((gPlayerState.jump_status & 7) != 3) { - if ((gPlayerState.jump_status & 0x78) == 0 && (u32)gPlayerEntity.zVelocity < Q_16_16(1.5) && - (gPlayerState.skills & SKILL_DOWN_THRUST) && gPlayerEntity.z.WORD != 0) { + if ((gPlayerState.jump_status & 0x78) == 0 && (u32)gPlayerEntity.base.zVelocity < Q_16_16(1.5) && + (gPlayerState.skills & SKILL_DOWN_THRUST) && gPlayerEntity.base.z.WORD != 0) { gPlayerState.jump_status |= 0x20; gPlayerState.lastSwordMove = SWORD_MOVE_DOWN_THRUST; gPlayerState.attack_status |= (8 >> index) | ((8 >> index) << 4); @@ -52,7 +52,7 @@ void sub_08075338(ItemBehavior* this, u32 index) { #ifndef EU sub_080759B8(this, index); return; - } else if (gPlayerEntity.z.WORD) { + } else if (gPlayerEntity.base.z.WORD) { #endif sub_080759B8(this, index); return; @@ -87,7 +87,7 @@ void sub_08075338(ItemBehavior* this, u32 index) { if ((gPlayerState.sword_state & 0x80) == 0) { gPlayerState.sword_state = 0; - sub_0806F948(&gPlayerEntity); + sub_0806F948(&gPlayerEntity.base); } if (gPlayerState.item) { @@ -112,7 +112,7 @@ void sub_080754B8(ItemBehavior* this, u32 index) { this->priority &= ~0x80; } - if (gPlayerEntity.frameSpriteSettings & 1) { + if (gPlayerEntity.base.frameSpriteSettings & 1) { swordBeam = GetSwordBeam(); if (swordBeam && FindEntityByID(PLAYER_ITEM, PLAYER_ITEM_SWORD_BEAM1, 2) == 0) { CreatePlayerItemWithParent(this, PLAYER_ITEM_SWORD_BEAM1); @@ -198,7 +198,7 @@ void sub_08075694(ItemBehavior* this, u32 index) { gPlayerState.field_0xa = (8 >> index) | gPlayerState.field_0xa; this->stateID = 4; this->animPriority = 6; - gPlayerEntity.hurtType = 0x1e; + gPlayerEntity.base.hurtType = 0x1e; gPlayerState.sword_state |= 0x40; gPlayerState.sword_state &= 0xdf; if ((gPlayerState.chargeState.action == 4) && ((gPlayerState.flags & PL_CLONING) == 0)) { @@ -223,8 +223,8 @@ void sub_08075738(ItemBehavior* this, u32 index) { if (!(gPlayerState.direction & DIR_NOT_MOVING_CHECK)) { this->direction = gPlayerState.direction; } - gPlayerEntity.direction = this->direction; - gPlayerEntity.speed = 0x180; + gPlayerEntity.base.direction = this->direction; + gPlayerEntity.base.speed = 0x180; if ((this->playerFrame & 0x80) != 0) { bVar6 = 10; if ((gPlayerState.skills & SKILL_LONG_SPIN) != 0) { @@ -236,19 +236,19 @@ void sub_08075738(ItemBehavior* this, u32 index) { } } } else { - if (((((gPlayerEntity.frameSpriteSettings & 1) != 0) && ((gPlayerState.sword_state & 0x80) == 0)) && + if (((((gPlayerEntity.base.frameSpriteSettings & 1) != 0) && ((gPlayerState.sword_state & 0x80) == 0)) && ((gPlayerState.skills & SKILL_FOURSWORD) != 0))) { Entity* bombEnt = CreatePlayerItemWithParent(this, PLAYER_ITEM_SPIRAL_BEAM); if (bombEnt) { - bombEnt->animationState = (gPlayerEntity.animationState & 6) | 0x80; + bombEnt->animationState = (gPlayerEntity.base.animationState & 6) | 0x80; } } - if ((((gPlayerEntity.frameSpriteSettings & 2) != 0) && ((gPlayerState.sword_state & 0x80) == 0)) && + if ((((gPlayerEntity.base.frameSpriteSettings & 2) != 0) && ((gPlayerState.sword_state & 0x80) == 0)) && (((gPlayerState.skills & SKILL_GREAT_SPIN) != 0 && (--this->timer != 0)))) { gPlayerState.sword_state |= 0x10; gPlayerState.lastSwordMove = SWORD_MOVE_GREAT_SPIN; - this->direction = gPlayerEntity.animationState << 2; + this->direction = gPlayerEntity.base.animationState << 2; this->timer = 1; this->subtimer = 1; gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> index); @@ -300,11 +300,11 @@ void sub_08075900(ItemBehavior* this, u32 index) { if (--this->timer == 0) { SetItemAnim(this, ANIM_ROLLATTACK_END); } - gPlayerEntity.direction = (gPlayerEntity.animationState >> 1) << 3; - gPlayerEntity.speed = 0x300; + gPlayerEntity.base.direction = (gPlayerEntity.base.animationState >> 1) << 3; + gPlayerEntity.base.speed = 0x300; UpdatePlayerMovement(); if ((gRoomTransition.frameCount & 3) == 0) { - CreateFx(&gPlayerEntity, FX_DASH, 0x40); + CreateFx(&gPlayerEntity.base, FX_DASH, 0x40); } } else { if ((this->playerFrame & 0x80) != 0) { @@ -318,7 +318,7 @@ void sub_08075900(ItemBehavior* this, u32 index) { void sub_080759B8(ItemBehavior* this, u32 index) { if ((gPlayerState.flags & PL_MINISH) == 0) { - gPlayerEntity.hurtType = 0; + gPlayerEntity.base.hurtType = 0; } gPlayerState.flags &= ~PL_SWORD_THRUST; gPlayerState.sword_state = 0; diff --git a/src/item/itemTryPickupObject.c b/src/item/itemTryPickupObject.c index b3aa25a1..e721bb51 100644 --- a/src/item/itemTryPickupObject.c +++ b/src/item/itemTryPickupObject.c @@ -1,6 +1,5 @@ #include "functions.h" #include "item.h" -#include "new_player.h" #include "playeritem.h" #include "sound.h" @@ -39,9 +38,9 @@ void sub_08076088(ItemBehavior* this, Entity* param_2, u32 param_3) { gPlayerState.framestate = 4; this->stateID = 2; this->animPriority = 0xf; - if ((gNewPlayerEntity.unk_79 & 0x80)) { - gNewPlayerEntity.unk_79 = 0; - COLLISION_ON(&gPlayerEntity); + if ((gPlayerEntity.unk_79 & 0x80)) { + gPlayerEntity.unk_79 = 0; + COLLISION_ON(&gPlayerEntity.base); gPlayerState.heldObject = 4; gPlayerState.keepFacing = ~(8 >> param_3) & gPlayerState.keepFacing; gPlayerState.field_0xa = ~(8 >> param_3) & gPlayerState.field_0xa; @@ -56,7 +55,7 @@ void sub_08076088(ItemBehavior* this, Entity* param_2, u32 param_3) { if (param_2 == NULL) { PlayerCancelHoldItem(this, param_3); } else { - PlayerEntity* playerEnt = &gNewPlayerEntity; + PlayerEntity* playerEnt = &gPlayerEntity; playerEnt->unk_74 = param_2; playerEnt->base.subtimer = 0; param_2->child = this->field_0x18; @@ -87,7 +86,7 @@ void ItemPickupCheck(ItemBehavior* this, u32 index) { if (gPlayerState.attack_status == 0 && (gPlayerState.jump_status == 0 || (gPlayerState.flags & (PL_BUSY | PL_FALLING | PL_IN_MINECART)) != 0) && - (gPlayerState.grab_status = gPlayerEntity.animationState | 0x80, gPlayerEntity.iframes <= 8)) { + (gPlayerState.grab_status = gPlayerEntity.base.animationState | 0x80, gPlayerEntity.base.iframes <= 8)) { switch (sub_080789A8()) { case 2: @@ -143,7 +142,7 @@ void sub_080762D8(ItemBehavior* this, u32 index) { return; } - if (gPlayerEntity.iframes < 9 && gPlayerEntity.knockbackDuration == 0) { + if (gPlayerEntity.base.iframes < 9 && gPlayerEntity.base.knockbackDuration == 0) { if (this->field_0x18 != NULL) { if (this->field_0x18->action == 2 && this->field_0x18->subAction == 5) { if (!(gPlayerState.playerInput.heldInput & INPUT_ACTION)) { // Pressing R @@ -169,10 +168,10 @@ void sub_080762D8(ItemBehavior* this, u32 index) { if (!gPlayerState.jump_status) { - if (gPlayerState.heldObject == 1 && sub_0800875A(&gPlayerEntity, 6, this) != 0) { + if (gPlayerState.heldObject == 1 && sub_0800875A(&gPlayerEntity.base, 6, this) != 0) { sub_08076088(this, NULL, index); return; - } else if (gUnk_0811BE38[gPlayerEntity.animationState >> 1] & gPlayerState.playerInput.heldInput) { + } else if (gUnk_0811BE38[gPlayerEntity.base.animationState >> 1] & gPlayerState.playerInput.heldInput) { UpdateItemAnim(this); if (!(gPlayerState.flags & PL_NO_CAP)) { @@ -194,9 +193,9 @@ void sub_080762D8(ItemBehavior* this, u32 index) { sub_08076088(this, this->field_0x18, index); } else { - if (gPlayerState.playerInput.heldInput & gUnk_0811BE40[gPlayerEntity.animationState >> 1]) { - if (gPlayerEntity.subtimer < 6) { - gPlayerEntity.subtimer++; + if (gPlayerState.playerInput.heldInput & gUnk_0811BE40[gPlayerEntity.base.animationState >> 1]) { + if (gPlayerEntity.base.subtimer < 6) { + gPlayerEntity.base.subtimer++; return; } @@ -217,7 +216,7 @@ void sub_080762D8(ItemBehavior* this, u32 index) { SetItemAnim(this, animIndex); } } else { - gPlayerEntity.subtimer = 0; + gPlayerEntity.base.subtimer = 0; if (!(gPlayerState.flags & PL_NO_CAP)) { SetItemAnim(this, ANIM_PULL); @@ -242,7 +241,7 @@ void sub_08076488(ItemBehavior* this, u32 index) { } UpdateItemAnim(this); if ((this->playerFrame & 0x80) != 0) { - gPlayerEntity.flags |= ENT_COLLIDE; + gPlayerEntity.base.flags |= ENT_COLLIDE; gPlayerState.heldObject = 4; bVar1 = ~(8 >> index); gPlayerState.keepFacing = bVar1 & gPlayerState.keepFacing; @@ -261,14 +260,14 @@ void sub_08076518(ItemBehavior* this, u32 index) { if (PlayerTryDropObject(this, index)) { gPlayerState.framestate = PL_STATE_HOLD; if ((gPlayerState.jump_status & 0x80) == 0 && gPlayerState.field_0x1f[0] == 0) { - if (gPlayerEntity.knockbackDuration != 0) { + if (gPlayerEntity.base.knockbackDuration != 0) { PlayerCancelHoldItem(this, index); } else { if ((gPlayerState.playerInput.newInput & (INPUT_LIFT_THROW | INPUT_CANCEL | INPUT_INTERACT)) != 0) { - sub_0806F948(&gPlayerEntity); + sub_0806F948(&gPlayerEntity.base); gPlayerState.heldObject = 5; this->field_0x18->subAction = 2; - this->field_0x18->direction = (gPlayerEntity.animationState & 0xe) << 2; + this->field_0x18->direction = (gPlayerEntity.base.animationState & 0xe) << 2; this->field_0x18 = NULL; this->stateID++; this->animPriority = 0x0f; diff --git a/src/itemUtils.c b/src/itemUtils.c index 832c68ce..a774778f 100644 --- a/src/itemUtils.c +++ b/src/itemUtils.c @@ -566,7 +566,7 @@ u32 CreateItemDrop(Entity* arg0, u32 itemId, u32 itemParameter) { if (itemId != ITEM_ENEMY_BEETLE) { itemEntity = CreateObject(GROUND_ITEM, itemId, adjustedParam); if (itemEntity != NULL) { - if (arg0 == &gPlayerEntity) { + if (arg0 == &gPlayerEntity.base) { itemEntity->timer = 1; } else { itemEntity->timer = 0; diff --git a/src/manager/cloudStaircaseTransitionManager.c b/src/manager/cloudStaircaseTransitionManager.c index 73dc764d..d8a47d63 100644 --- a/src/manager/cloudStaircaseTransitionManager.c +++ b/src/manager/cloudStaircaseTransitionManager.c @@ -15,7 +15,7 @@ void CloudStaircaseTransitionManager_Main(CloudStaircaseTransitionManager* this) this->y = 0; } if (((CheckPlayerInRegion(this->x, this->y, 0x14, 0x40) != 0) && - (((gPlayerEntity.y.HALF.HI - gRoomControls.origin_y) + gPlayerEntity.z.HALF.HI) < 0)) && + (((gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y) + gPlayerEntity.base.z.HALF.HI) < 0)) && (gRoomControls.scroll_y == gRoomControls.origin_y)) { MemClear(&gRoomTransition.player_status, sizeof(PlayerRoomStatus)); gRoomTransition.transitioningOut = 1; diff --git a/src/manager/diggingCaveEntranceManager.c b/src/manager/diggingCaveEntranceManager.c index d020dd5f..7491eea4 100644 --- a/src/manager/diggingCaveEntranceManager.c +++ b/src/manager/diggingCaveEntranceManager.c @@ -77,8 +77,8 @@ bool32 DiggingCaveEntranceManager_CheckEnterEntrance(DiggingCaveEntranceManager* u16 offsetX, offsetY, offsetX2, offsetY2; u32 tmp, tmp2; if (gDiggingCaveEntranceTransition.isDiggingCave) { - offsetX = gPlayerEntity.x.HALF.HI - gRoomControls.origin_x; - offsetY = gPlayerEntity.y.HALF.HI - gRoomControls.origin_y; + offsetX = gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x; + offsetY = gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y; offsetX2 = (entr->sourceTilePosition & TILE_POS_X_COMPONENT) * 16 + 8; offsetY2 = ((entr->sourceTilePosition & TILE_POS_Y_COMPONENT) >> 6) * 16 + 0x18; tmp = offsetX - offsetX2; @@ -89,10 +89,10 @@ bool32 DiggingCaveEntranceManager_CheckEnterEntrance(DiggingCaveEntranceManager* DiggingCaveEntranceManager_EnterEntrance(this, entr); return TRUE; } else { - if (COORD_TO_TILE(&gPlayerEntity) != entr->sourceTilePosition) + if (COORD_TO_TILE(&gPlayerEntity.base) != entr->sourceTilePosition) return FALSE; offsetY2 = gRoomControls.origin_y + ((entr->sourceTilePosition >> 6) << 4) + 6; - if (gPlayerEntity.y.HALF.HI >= offsetY2) + if (gPlayerEntity.base.y.HALF.HI >= offsetY2) return FALSE; DiggingCaveEntranceManager_EnterEntrance(this, entr); return TRUE; @@ -109,10 +109,10 @@ void DiggingCaveEntranceManager_EnterEntrance(DiggingCaveEntranceManager* this, gRoomControls.area = entr->targetArea; gRoomControls.room = entr->targetRoom; gDiggingCaveEntranceTransition.entrance = entr; - gDiggingCaveEntranceTransition.offsetX = - gPlayerEntity.x.HALF.HI - gRoomControls.origin_x - ((entr->sourceTilePosition & TILE_POS_X_COMPONENT) * 16); - gDiggingCaveEntranceTransition.offsetY = - gPlayerEntity.y.HALF.HI - gRoomControls.origin_y - ((entr->sourceTilePosition & TILE_POS_Y_COMPONENT) >> 2); + gDiggingCaveEntranceTransition.offsetX = gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x - + ((entr->sourceTilePosition & TILE_POS_X_COMPONENT) * 16); + gDiggingCaveEntranceTransition.offsetY = gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y - + ((entr->sourceTilePosition & TILE_POS_Y_COMPONENT) >> 2); #ifndef EU isDiggingCave = gDiggingCaveEntranceTransition.isDiggingCave; diff --git a/src/manager/ezloHintManager.c b/src/manager/ezloHintManager.c index 4f6a2723..eb2a666a 100644 --- a/src/manager/ezloHintManager.c +++ b/src/manager/ezloHintManager.c @@ -121,7 +121,7 @@ static void EzloHintManager_Action3(EzloHintManager* this) { if (gPlayerState.flags & (PL_BUSY | PL_DROWNING | PL_USE_PORTAL | PL_FALLING | PL_IN_MINECART | PL_CAPTURED)) return; - if (gPlayerEntity.z.HALF.HI != 0) + if (gPlayerEntity.base.z.HALF.HI != 0) return; gPlayerState.jump_status = 0; CreateEzloHint(this->msg_idx, this->msg_height); @@ -136,7 +136,7 @@ static void EzloHintManager_Action3(EzloHintManager* this) { return; case 3: /* wait for player to finish talking */ - if (gPlayerEntity.action == PLAYER_NORMAL || gPlayerEntity.action == PLAYER_MINISH) { + if (gPlayerEntity.base.action == PLAYER_NORMAL || gPlayerEntity.base.action == PLAYER_MINISH) { gPlayerState.controlMode = CONTROL_1; ResetPlayerEventPriority(); SetFlag(this->flag1); diff --git a/src/manager/fightManager.c b/src/manager/fightManager.c index dfef3d50..9d743f07 100644 --- a/src/manager/fightManager.c +++ b/src/manager/fightManager.c @@ -9,7 +9,6 @@ * (There is also a part about changing the music and setting it back when the fight is done, which is song 0x33 (a * fight theme) by default but can be overridden through room data) */ -#define ENT_DEPRECATED #include "manager/fightManager.h" #include "area.h" #include "common.h" @@ -113,7 +112,7 @@ void FightManager_LoadFight(FightManager* this) { while (prop->kind != 0xFF) { ent = LoadRoomEntity(prop++); if ((ent != NULL) && (ent->kind == ENEMY)) { - ent->field_0x6c.HALF.HI |= 0x40; + ((GenericEntity*)ent)->field_0x6c.HALF.HI |= 0x40; FightManagerHelper_Monitor(monitor, ent, counter++); } if (counter >= 7) { diff --git a/src/manager/holeManager.c b/src/manager/holeManager.c index 341e9485..a4d0d2d8 100644 --- a/src/manager/holeManager.c +++ b/src/manager/holeManager.c @@ -155,8 +155,10 @@ void sub_0805B210(HoleManager* this) { gRoomTransition.player_status.start_pos_y = tmp->unk_06; break; case 1: - gRoomTransition.player_status.start_pos_x = gPlayerEntity.x.HALF.HI - gRoomControls.origin_x + tmp->unk_04; - gRoomTransition.player_status.start_pos_y = gPlayerEntity.y.HALF.HI - gRoomControls.origin_y + tmp->unk_06; + gRoomTransition.player_status.start_pos_x = + gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x + tmp->unk_04; + gRoomTransition.player_status.start_pos_y = + gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y + tmp->unk_06; break; case 2: gRoomTransition.player_status.start_pos_x = tmp->unk_04; diff --git a/src/manager/hyruleTownBellManager.c b/src/manager/hyruleTownBellManager.c index c22442dc..4dc2ebed 100644 --- a/src/manager/hyruleTownBellManager.c +++ b/src/manager/hyruleTownBellManager.c @@ -13,11 +13,11 @@ void HyruleTownBellManager_Main(HyruleTownBellManager* this) { RoomControls* roomControls = &gRoomControls; u32 a = roomControls->origin_x + 0x1f8; - u32 x = (a - gPlayerEntity.x.HALF.HI) + 0x10; + u32 x = (a - gPlayerEntity.base.x.HALF.HI) + 0x10; u32 b = roomControls->origin_y + 0x140; - u32 y = (b - gPlayerEntity.y.HALF.HI) + 0x10; + u32 y = (b - gPlayerEntity.base.y.HALF.HI) + 0x10; if (super->action == 0) { - if (x < 0x20 && y < 0x20 && gPlayerEntity.z.HALF.HI < -0x18 && gPlayerState.framestate == PL_STATE_CAPE) { + if (x < 0x20 && y < 0x20 && gPlayerEntity.base.z.HALF.HI < -0x18 && gPlayerState.framestate == PL_STATE_CAPE) { super->action++; super->timer = 90; SoundReq(SFX_10A); diff --git a/src/manager/lightManager.c b/src/manager/lightManager.c index c34c4755..7a0cca5f 100644 --- a/src/manager/lightManager.c +++ b/src/manager/lightManager.c @@ -49,8 +49,8 @@ void LightManager_Main(LightManager* this) { if (gArea.lightType == 2) { gScreen.lcd.displayControl &= ~DISPCNT_WIN0_ON; } else { - if (CheckRectOnScreen(gPlayerEntity.x.HALF.HI - gRoomControls.origin_x, - gPlayerEntity.y.HALF.HI - gRoomControls.origin_y, 0, 0)) { + if (CheckRectOnScreen(gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x, + gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y, 0, 0)) { gScreen.lcd.displayControl |= DISPCNT_WIN0_ON; } else { gScreen.lcd.displayControl &= ~DISPCNT_WIN0_ON; @@ -79,8 +79,8 @@ void LightManager_Main(LightManager* this) { } super->timer = uVar3; - sub_0801E160(gPlayerEntity.x.HALF.HI - gRoomControls.scroll_x, - gPlayerEntity.y.HALF.HI - gRoomControls.scroll_y - 9 + gPlayerEntity.z.HALF.HI, + sub_0801E160(gPlayerEntity.base.x.HALF.HI - gRoomControls.scroll_x, + gPlayerEntity.base.y.HALF.HI - gRoomControls.scroll_y - 9 + gPlayerEntity.base.z.HALF.HI, uVar3 + this->unk20); } } diff --git a/src/manager/lightRayManager.c b/src/manager/lightRayManager.c index 48c48a6f..8a6a75b9 100644 --- a/src/manager/lightRayManager.c +++ b/src/manager/lightRayManager.c @@ -88,8 +88,8 @@ void LightRayManager_Action1(LightRayManager* this) { if (prop->unk0 == 0xff) return; - x = gPlayerEntity.x.HALF.HI / 16; - y = gPlayerEntity.y.HALF.HI / 16; + x = gPlayerEntity.base.x.HALF.HI / 16; + y = gPlayerEntity.base.y.HALF.HI / 16; for (; prop->unk0 != 0xff; prop++) { if (prop->unk0 != this->unk_21) { diff --git a/src/manager/miscManager.c b/src/manager/miscManager.c index 2fe982bb..c250e517 100644 --- a/src/manager/miscManager.c +++ b/src/manager/miscManager.c @@ -164,7 +164,7 @@ void MiscManager_Type1(MiscManager* this) { PutAwayItems(); } if (super->timer == 60) { - gPlayerEntity.animationState = super->subtimer; + gPlayerEntity.base.animationState = super->subtimer; } if (!--super->timer) { super->action = 3; @@ -298,7 +298,7 @@ void sub_08059278(void) { void MiscManager_Type8(MiscManager* this) { super->action = 1; - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; } void MiscManager_Type9(MiscManager* this) { @@ -363,9 +363,9 @@ void MiscManager_TypeB(MiscManager* this) { } bool32 sub_080593CC(MiscManager* this) { - if (!(gPlayerState.flags & PL_MINISH) && gPlayerState.swim_state != 0 && gPlayerEntity.animationState == 0 && + if (!(gPlayerState.flags & PL_MINISH) && gPlayerState.swim_state != 0 && gPlayerEntity.base.animationState == 0 && (gPlayerState.playerInput.heldInput & INPUT_ANY_DIRECTION) == INPUT_UP) { - return EntityWithinDistance(&gPlayerEntity, this->unk_38, this->unk_3a + 0xC, 6); + return EntityWithinDistance(&gPlayerEntity.base, this->unk_38, this->unk_3a + 0xC, 6); } return FALSE; } @@ -395,7 +395,7 @@ void MiscManager_TypeD(MiscManager* this) { if (gRoomVars.field_0x0) { StartPlayerScript(gUnk_08108380[gRoomControls.scroll_direction]); } else { - StartPlayerScript(gUnk_08108380[gPlayerEntity.animationState >> 1]); + StartPlayerScript(gUnk_08108380[gPlayerEntity.base.animationState >> 1]); } } DeleteThisEntity(); @@ -431,7 +431,7 @@ void MiscManager_TypeE(MiscManager* this) { #if defined(USA) || defined(DEMO_USA) || defined(DEMO_JP) void MiscManager_TypeF(MiscManager* this) { SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT); - if (gPlayerEntity.action == PLAYER_TALKEZLO) { + if (gPlayerEntity.base.action == PLAYER_TALKEZLO) { DeleteThisEntity(); } gInput.heldKeys |= SELECT_BUTTON; diff --git a/src/manager/moveableObjectManager.c b/src/manager/moveableObjectManager.c index bc9a05c2..21756299 100644 --- a/src/manager/moveableObjectManager.c +++ b/src/manager/moveableObjectManager.c @@ -6,7 +6,6 @@ * * E.g. for pushable rock. */ -#define ENT_DEPRECATED #include "manager/moveableObjectManager.h" #include "flags.h" #include "room.h" @@ -15,7 +14,7 @@ void MoveableObjectManager_Main(MoveableObjectManager* this) { Entity* object = CreateObject(super->timer, super->type, super->type2); if (!object) return; - object->field_0x86.HWORD = this->flags; + ((GenericEntity*)object)->field_0x86.HWORD = this->flags; if (CheckFlags(this->flags)) { object->x.HALF.HI = this->unk_36 | (this->unk_37 & 0xF) << 8; // r1 object->y.HALF.HI = this->unk_3c & 0xFFF; diff --git a/src/manager/pushableFurnitureManager.c b/src/manager/pushableFurnitureManager.c index 687203a0..f701bc42 100644 --- a/src/manager/pushableFurnitureManager.c +++ b/src/manager/pushableFurnitureManager.c @@ -4,10 +4,11 @@ * * @brief Creates pushable furniture based on a room property list. */ -#define ENT_DEPRECATED #include "manager/pushableFurnitureManager.h" + #include "flags.h" #include "object.h" +#include "object/pushableFurniture.h" #include "room.h" void PushableFurnitureManager_Init(PushableFurnitureManager*); @@ -36,16 +37,16 @@ void PushableFurnitureManager_Init(PushableFurnitureManager* this) { this->unk_28 = 0; this->unk_29 = 0; while (tmp->unk_00 != 0xFF && super->timer < 0x20) { - Entity* obj; - obj = CreateObject(PUSHABLE_FURNITURE, tmp->unk_01, tmp->unk_02); - if (obj) { - obj->timer = tmp->unk_03; - obj->x.HALF.HI = gRoomControls.origin_x + tmp->unk_04; - obj->y.HALF.HI = gRoomControls.origin_y + tmp->unk_06; - obj->parent = (Entity*)this; - obj->collisionLayer = 1; - obj->field_0x82.HALF.HI = super->timer; - obj->field_0x82.HALF.LO = tmp->unk_00; + PushableFurnitureEntity* furniture = + (PushableFurnitureEntity*)CreateObject(PUSHABLE_FURNITURE, tmp->unk_01, tmp->unk_02); + if (furniture) { + furniture->base.timer = tmp->unk_03; + furniture->base.x.HALF.HI = gRoomControls.origin_x + tmp->unk_04; + furniture->base.y.HALF.HI = gRoomControls.origin_y + tmp->unk_06; + furniture->base.parent = (Entity*)this; + furniture->base.collisionLayer = 1; + furniture->unk_83 = super->timer; + furniture->unk_82 = tmp->unk_00; this->unk_29 |= 1 << super->timer; } tmp++; @@ -76,13 +77,13 @@ void PushableFurnitureManager_Action2(PushableFurnitureManager* this) { void sub_0805C7CC(PushableFurnitureManager* this) { if (gPlayerState.flags & PL_MINISH) { - if (gPlayerEntity.y.HALF.HI < this->unk_2a + 0x10) { + if (gPlayerEntity.base.y.HALF.HI < this->unk_2a + 0x10) { super->subAction = 1; } else { super->subAction = 0; } } else { - if (gPlayerEntity.y.HALF.HI < this->unk_2a + 0x28) { + if (gPlayerEntity.base.y.HALF.HI < this->unk_2a + 0x28) { super->subAction = 3; } else { super->subAction = 2; diff --git a/src/manager/rollingBarrelManager.c b/src/manager/rollingBarrelManager.c index 20c8b3f1..e309f017 100644 --- a/src/manager/rollingBarrelManager.c +++ b/src/manager/rollingBarrelManager.c @@ -93,7 +93,7 @@ void sub_080588F8(RollingBarrelManager* this) { } } if (super->timer) { - s32 tmp = gPlayerEntity.y.HALF.HI - gRoomControls.origin_y; + s32 tmp = gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y; u32 tmp2; tmp2 = (((unsigned)(tmp - 0x50 < 0 ? 0x50 - tmp : tmp - 0x50) >> 3) * 0x3000) + 0x4000; if (super->subtimer == 0) { @@ -134,14 +134,14 @@ void sub_08058A04(RollingBarrelManager* this) { { 0x9C, 0x78, 0x1A, 0x16 }, { 0x9A, 0x70, 0x1A, 0x18 }, { 0x98, 0x64, 0x1E, 0x1E }, { 0x98, 0x6A, 0x1C, 0x10 } }; - s32 tmp = gPlayerEntity.x.HALF.HI - gRoomControls.origin_x; - s32 tmp2 = gPlayerEntity.y.HALF.HI - gRoomControls.origin_y; + s32 tmp = gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x; + s32 tmp2 = gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y; if ((this->unk_20 - 0x118 < 0xDu) && CheckGlobalFlag(LV1TARU_OPEN) && (tmp - 0x6d < 0x17u) && - (tmp2 - 0x45 < 0x17u) && (gPlayerEntity.z.HALF.HI == 0)) { + (tmp2 - 0x45 < 0x17u) && (gPlayerEntity.base.z.HALF.HI == 0)) { gPlayerState.queued_action = PLAYER_FALL; gPlayerState.field_0x38 = 0; - gPlayerEntity.x.HALF.HI = gRoomControls.origin_x + 0x78; - gPlayerEntity.y.HALF.HI = gRoomControls.origin_y + 0x50; + gPlayerEntity.base.x.HALF.HI = gRoomControls.origin_x + 0x78; + gPlayerEntity.base.y.HALF.HI = gRoomControls.origin_y + 0x50; return; } if (tmp < 0x78) { @@ -176,8 +176,8 @@ u32 sub_08058B08(RollingBarrelManager* this, u32 unk1, u32 unk2, const struct_08 tmp -= unk1; tmp >>= 3; unk3 += tmp; - tmp2 = (gPlayerEntity.x.HALF.HI - gRoomControls.origin_x - unk3->unk_0); - tmp3 = (gPlayerEntity.y.HALF.HI - gRoomControls.origin_y - unk3->unk_2); + tmp2 = (gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x - unk3->unk_0); + tmp3 = (gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y - unk3->unk_2); return ((tmp2 < unk3->unk_4) && (tmp3 < unk3->unk_6)); } } @@ -230,8 +230,8 @@ void sub_08058BC8(RollingBarrelManager* this) { void sub_08058CB0(RollingBarrelManager* this) { static const u16 gUnk_08108300[4] = { 0xA4, 0x4C, 0xF4, 0x9C }; - u32 tmp = gPlayerEntity.x.HALF.HI - gRoomControls.origin_x; - u32 tmp2 = gPlayerEntity.y.HALF.HI - gRoomControls.origin_y; + u32 tmp = gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x; + u32 tmp2 = gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y; u32 tmp3; if (tmp < 0x78) { tmp3 = 1; @@ -248,12 +248,12 @@ void sub_08058CB0(RollingBarrelManager* this) { } void sub_08058CFC(void) { - u32 tmp = gPlayerEntity.y.HALF.HI - gRoomControls.scroll_y; + u32 tmp = gPlayerEntity.base.y.HALF.HI - gRoomControls.scroll_y; if (tmp < 0x4C) { - sub_080044AE(&gPlayerEntity, 0xC0, 0x10); + sub_080044AE(&gPlayerEntity.base, 0xC0, 0x10); } if (tmp > 0x54) { - sub_080044AE(&gPlayerEntity, 0xC0, 0); + sub_080044AE(&gPlayerEntity.base, 0xC0, 0); } } diff --git a/src/manager/specialWarpManager.c b/src/manager/specialWarpManager.c index f387761e..f62ac451 100644 --- a/src/manager/specialWarpManager.c +++ b/src/manager/specialWarpManager.c @@ -22,10 +22,10 @@ void SpecialWarpManager_Main(SpecialWarpManager* this) { if (super->timer == 0 || gPlayerState.floor_type == SURFACE_LADDER) { for (data = this->warpList; data->posX != 0xffff; data++) { collisionLayer = (data->unk_07.all & 0x3); - if ((collisionLayer & gPlayerEntity.collisionLayer) != 0) { + if ((collisionLayer & gPlayerEntity.base.collisionLayer) != 0) { if ((gPlayerState.flags & PL_MINISH) != 0 || data->unk_07.b.unk2 != 0) { if (CheckPlayerInRegion(data->posX, data->posY, data->width, data->height) && - gPlayerEntity.z.HALF.HI == 0) { + gPlayerEntity.base.z.HALF.HI == 0) { DoExitTransition(GetCurrentRoomProperty(data->roomProperty)); } } diff --git a/src/manager/templeOfDropletsManager.c b/src/manager/templeOfDropletsManager.c index 62ea646a..14fc1d75 100644 --- a/src/manager/templeOfDropletsManager.c +++ b/src/manager/templeOfDropletsManager.c @@ -334,14 +334,14 @@ void TempleOfDropletsManager_Type6_Action1(TempleOfDropletsManager* this) { } void TempleOfDropletsManager_Type6_Action2(TempleOfDropletsManager* this) { - if ((gPlayerEntity.health != 0) && (gPlayerEntity.z.HALF.HI == 0) && (!gPlayerState.item)) { + if ((gPlayerEntity.base.health != 0) && (gPlayerEntity.base.z.HALF.HI == 0) && (!gPlayerState.item)) { switch (gPlayerState.framestate_last) { case PL_STATE_IDLE: case PL_STATE_WALK: if (sub_0805A73C(this)) { super->action++; - sub_08004168(&gPlayerEntity); - gPlayerEntity.animationState = 4; + sub_08004168(&gPlayerEntity.base); + gPlayerEntity.base.animationState = 4; RequestPriorityDuration((Entity*)this, 600); SetPlayerControl(0xFF); gPauseMenuOptions.disabled = 1; diff --git a/src/manager/tilePuzzleManager.c b/src/manager/tilePuzzleManager.c index a229878f..d85b92bd 100644 --- a/src/manager/tilePuzzleManager.c +++ b/src/manager/tilePuzzleManager.c @@ -24,10 +24,10 @@ void TilePuzzleManager_Main(TilePuzzleManager* this) { super->action = IN_PROGRESS; super->subtimer = super->timer; this->own_tile = (((this->x >> 4) & 0x3fU) | ((this->y >> 4) & 0x3fU) << 6); - this->player_previous_tile = this->player_current_tile = COORD_TO_TILE((&gPlayerEntity)); + this->player_previous_tile = this->player_current_tile = COORD_TO_TILE((&gPlayerEntity.base)); break; case 1: - this->player_current_tile = COORD_TO_TILE((&gPlayerEntity)); + this->player_current_tile = COORD_TO_TILE((&gPlayerEntity.base)); if (this->player_current_tile != this->player_previous_tile) { this->player_previous_tile = this->player_current_tile; switch (GetTileType(this->player_current_tile, super->type2)) { diff --git a/src/manager/vaati3StartManager.c b/src/manager/vaati3StartManager.c index c30c1e4b..1fa0c618 100644 --- a/src/manager/vaati3StartManager.c +++ b/src/manager/vaati3StartManager.c @@ -63,8 +63,8 @@ void Vaati3StartManager_Type0_Action1(Vaati3StartManager* this) { s32 distY; Entity* object; - distX = gPlayerEntity.x.HALF.HI - (gRoomControls.origin_x + 0x88); - distY = gPlayerEntity.y.HALF.HI - (gRoomControls.origin_y + 0x40); + distX = gPlayerEntity.base.x.HALF.HI - (gRoomControls.origin_x + 0x88); + distY = gPlayerEntity.base.y.HALF.HI - (gRoomControls.origin_y + 0x40); if (distX * distX + distY * distY < 0x901) { super->action = 2; super->subAction = 0; @@ -76,7 +76,7 @@ void Vaati3StartManager_Type0_Action1(Vaati3StartManager* this) { object->x.HALF.HI = gRoomControls.origin_x + 0x88; object->y.HALF.HI = gRoomControls.origin_y + 0x48; } - object = CreateSpeechBubbleExclamationMark(&gPlayerEntity, 8, 0xfffffff0); + object = CreateSpeechBubbleExclamationMark(&gPlayerEntity.base, 8, 0xfffffff0); if (object != NULL) { object->spritePriority.b0 = 3; } @@ -85,10 +85,10 @@ void Vaati3StartManager_Type0_Action1(Vaati3StartManager* this) { } void Vaati3StartManager_Type0_Action2(Vaati3StartManager* this) { - gPlayerEntity.animationState = 0; - if (gPlayerEntity.z.HALF.HI != 0) { - if (gPlayerEntity.y.HALF.HI < (gRoomControls.origin_y + 0x48)) { - gPlayerEntity.y.HALF.HI = gRoomControls.origin_y + 0x48; + gPlayerEntity.base.animationState = 0; + if (gPlayerEntity.base.z.HALF.HI != 0) { + if (gPlayerEntity.base.y.HALF.HI < (gRoomControls.origin_y + 0x48)) { + gPlayerEntity.base.y.HALF.HI = gRoomControls.origin_y + 0x48; } } else { if (--super->timer == 0) { diff --git a/src/manager/waterfallBottomManager.c b/src/manager/waterfallBottomManager.c index d449a3ae..a8e3f4c4 100644 --- a/src/manager/waterfallBottomManager.c +++ b/src/manager/waterfallBottomManager.c @@ -11,10 +11,10 @@ void WaterfallBottomManager_Main(WaterfallBottomManager* this) { SetTile(0x4014, 0x5c3, 1); - if ((gRoomControls.origin_y + 200 < gPlayerEntity.y.HALF.HI) && - ((u32)(gPlayerEntity.x.HALF.HI - gRoomControls.origin_x) - 0x30 < 0x11)) { - gPlayerEntity.collisionLayer = 3; - UpdateSpriteForCollisionLayer(&gPlayerEntity); + if ((gRoomControls.origin_y + 200 < gPlayerEntity.base.y.HALF.HI) && + ((u32)(gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x) - 0x30 < 0x11)) { + gPlayerEntity.base.collisionLayer = 3; + UpdateSpriteForCollisionLayer(&gPlayerEntity.base); } DeleteManager(super); } diff --git a/src/manager/weatherChangeManager.c b/src/manager/weatherChangeManager.c index f1988de4..83fa2d16 100644 --- a/src/manager/weatherChangeManager.c +++ b/src/manager/weatherChangeManager.c @@ -153,11 +153,11 @@ void sub_080596E0(WeatherChangeManager* this) { } u32 sub_08059844(void) { - return gPlayerEntity.x.HALF.HI - gRoomControls.origin_x > gRoomControls.width >> 1; + return gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x > gRoomControls.width >> 1; } u32 sub_0805986C(void) { - return gPlayerEntity.x.HALF.HI - gRoomControls.origin_x > 0x200; + return gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x > 0x200; } void sub_08059894(const u16* unk1, const u16* unk2, u32 unk3) { diff --git a/src/npc/anju.c b/src/npc/anju.c index 199629d4..2e1b02bd 100644 --- a/src/npc/anju.c +++ b/src/npc/anju.c @@ -25,8 +25,8 @@ void Anju(AnjuEntity* this) { if (super->interactType == INTERACTION_FUSE) { super->action = 2; super->interactType = INTERACTION_NONE; - InitializeAnimation(super, (super->animIndex & -4) + GetAnimationStateForDirection4( - GetFacingDirection(super, &gPlayerEntity))); + InitializeAnimation(super, (super->animIndex & -4) + GetAnimationStateForDirection4(GetFacingDirection( + super, &gPlayerEntity.base))); InitializeNPCFusion(super); } else { ExecuteScriptAndHandleAnimation(super, NULL); diff --git a/src/npc/beedle.c b/src/npc/beedle.c index a77d7390..0729e1cc 100644 --- a/src/npc/beedle.c +++ b/src/npc/beedle.c @@ -195,8 +195,8 @@ void sub_0806346C(Entity* this) { s32 iVar2; s32 iVar3; - iVar3 = (gPlayerEntity.x.HALF.HI - this->x.HALF.HI); - iVar2 = (gPlayerEntity.y.HALF.HI - this->y.HALF.HI); + iVar3 = (gPlayerEntity.base.x.HALF.HI - this->x.HALF.HI); + iVar2 = (gPlayerEntity.base.y.HALF.HI - this->y.HALF.HI); iVar3 += 0x30; iVar2 += 0x18; @@ -216,7 +216,7 @@ void sub_0806346C(Entity* this) { iVar3 >>= 4; iVar2 >>= 4; - bVar1 = gUnk_0810C8F0[iVar2][iVar3][gPlayerEntity.animationState >> 1]; + bVar1 = gUnk_0810C8F0[iVar2][iVar3][gPlayerEntity.base.animationState >> 1]; if (bVar1 != this->type2) { const InteractCollisionData* data = &gBeedleCollisionData[bVar1]; SetInteractableObjectCollision(this, 1, data->interactDirections, data); diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index aded3196..87b4884b 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -92,10 +92,10 @@ void sub_0806CF30(BigGoronEntity* this) { case 0: case 1: if (gRoomTransition.frameCount % 4 == 0) { - if (gPlayerEntity.x.HALF.HI < super->x.HALF.HI && this->originalX - 32 < super->x.HALF.HI) { + if (gPlayerEntity.base.x.HALF.HI < super->x.HALF.HI && this->originalX - 32 < super->x.HALF.HI) { super->x.HALF.HI--; } - if (gPlayerEntity.x.HALF.HI > super->x.HALF.HI && this->originalX + 32 > super->x.HALF.HI) { + if (gPlayerEntity.base.x.HALF.HI > super->x.HALF.HI && this->originalX + 32 > super->x.HALF.HI) { super->x.HALF.HI++; } } @@ -542,8 +542,8 @@ void sub_0806D788(void) { void sub_0806D7C4(Entity* this, ScriptExecutionContext* context) { Entity* entity; - this->x.HALF.HI = gPlayerEntity.x.HALF.HI; - this->y.HALF.HI = gPlayerEntity.y.HALF.HI - 0x18; + this->x.HALF.HI = gPlayerEntity.base.x.HALF.HI; + this->y.HALF.HI = gPlayerEntity.base.y.HALF.HI - 0x18; entity = FindEntity(NPC, BIG_GORON, 7, 2, 0); if (entity != NULL) { sub_0807DEDC(this, context, entity->x.HALF.HI, entity->y.HALF.HI); @@ -557,7 +557,7 @@ void sub_0806D804(Entity* this, ScriptExecutionContext* context) { this->y.HALF.HI = entity->y.HALF.HI - 0x10; this->spritePriority.b1 = 0; } - sub_0807DEDC(this, context, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI - 0x10); + sub_0807DEDC(this, context, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI - 0x10); } void sub_0806D858(Entity* this) { diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c index 002c5d0a..6926a87a 100644 --- a/src/npc/bladeBrothers.c +++ b/src/npc/bladeBrothers.c @@ -313,7 +313,7 @@ void sub_08068b2c(BladeBrothersEntity* this) { if (super->interactType == INTERACTION_FUSE) { super->action = 2; super->interactType = INTERACTION_NONE; - animationState = GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)); + animationState = GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base)); InitAnimationForceUpdate(super, animationState); InitializeNPCFusion(super); } else { diff --git a/src/npc/brocco.c b/src/npc/brocco.c index d4bfa44d..b4ab49e7 100644 --- a/src/npc/brocco.c +++ b/src/npc/brocco.c @@ -91,8 +91,8 @@ void sub_0806362C(BroccoEntity* this) { super->action = 2; super->interactType = INTERACTION_NONE; this->animIndex = super->animIndex; - InitAnimationForceUpdate(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)) + 4); + InitAnimationForceUpdate( + super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base)) + 4); InitializeNPCFusion(super); } else { ExecuteScriptForEntity(super, NULL); diff --git a/src/npc/carpenter.c b/src/npc/carpenter.c index 28123e37..690f6c67 100644 --- a/src/npc/carpenter.c +++ b/src/npc/carpenter.c @@ -42,8 +42,9 @@ void Carpenter(CarpenterEntity* this) { super->action = 2; super->interactType = INTERACTION_NONE; this->animIndex = super->animIndex; - InitializeAnimation(super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)) + - 4 + (super->type * 8)); + InitializeAnimation(super, + GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base)) + 4 + + (super->type * 8)); InitializeNPCFusion(super); } else { ExecuteScriptForEntity(super, 0); diff --git a/src/npc/castleMaid.c b/src/npc/castleMaid.c index 448f0a30..2a47701a 100644 --- a/src/npc/castleMaid.c +++ b/src/npc/castleMaid.c @@ -91,7 +91,8 @@ void sub_08064570(CastleMaidEntity* this) { if (super->interactType != INTERACTION_NONE) { super->action++; super->interactType = INTERACTION_NONE; - InitializeAnimation(super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitializeAnimation(super, + GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); if (this->dialogFunc != NULL) { this->dialogFunc(); } diff --git a/src/npc/cat.c b/src/npc/cat.c index 9096a5a4..a3228998 100644 --- a/src/npc/cat.c +++ b/src/npc/cat.c @@ -142,7 +142,7 @@ void sub_080677EC(CatEntity* this) { super->hitType = -0x58; super->flags2 = 1; this->unk_69 = 0xff; - if (super->x.HALF.HI < gPlayerEntity.x.HALF.HI) { + if (super->x.HALF.HI < gPlayerEntity.base.x.HALF.HI) { super->spriteSettings.flipX = 1; } else { super->spriteSettings.flipX = 0; @@ -321,7 +321,7 @@ void sub_08067B80(CatEntity* this, u32 animIndex) { this->unk_74 = (Random() & 0x7f) + 0x1e; InitAnimationForceUpdate(super, animIndex); sub_08067DDC(super); - if (super->x.HALF.HI < gPlayerEntity.x.HALF.HI) { + if (super->x.HALF.HI < gPlayerEntity.base.x.HALF.HI) { super->spriteSettings.flipX = 1; } else { super->spriteSettings.flipX = 0; @@ -330,11 +330,11 @@ void sub_08067B80(CatEntity* this, u32 animIndex) { void sub_08067BD4(Entity* this) { if (this->spriteSettings.flipX > 0) { - if (this->x.HALF.HI - 4 > gPlayerEntity.x.HALF.HI) { + if (this->x.HALF.HI - 4 > gPlayerEntity.base.x.HALF.HI) { this->spriteSettings.flipX = 0; } } else { - if (this->x.HALF.HI + 4 < gPlayerEntity.x.HALF.HI) { + if (this->x.HALF.HI + 4 < gPlayerEntity.base.x.HALF.HI) { this->spriteSettings.flipX = 1; } } @@ -376,7 +376,7 @@ void sub_08067C44(CatEntity* this) { return; } - iVar4 = sub_0806FCA0(super, &gPlayerEntity); + iVar4 = sub_0806FCA0(super, &gPlayerEntity.base); switch (super->animIndex) { case 0: default: diff --git a/src/npc/dampe.c b/src/npc/dampe.c index 8652612e..31866c7e 100644 --- a/src/npc/dampe.c +++ b/src/npc/dampe.c @@ -29,8 +29,8 @@ void Dampe(Entity* this) { if (this->interactType == INTERACTION_FUSE) { this->action = 2; this->interactType = INTERACTION_NONE; - InitAnimationForceUpdate(this, - GetAnimationStateForDirection4(GetFacingDirection(this, &gPlayerEntity)) + 4); + InitAnimationForceUpdate( + this, GetAnimationStateForDirection4(GetFacingDirection(this, &gPlayerEntity.base)) + 4); InitializeNPCFusion(this); } else { ExecuteScriptAndHandleAnimation(this, NULL); diff --git a/src/npc/din.c b/src/npc/din.c index b125cc95..604c03bb 100644 --- a/src/npc/din.c +++ b/src/npc/din.c @@ -26,8 +26,8 @@ void Din(DinEntity* this) { super->interactType = INTERACTION_NONE; InitializeNPCFusion(super); this->animIndex = super->animIndex; - InitAnimationForceUpdate(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitAnimationForceUpdate( + super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); } else { ExecuteScriptAndHandleAnimation(super, NULL); } diff --git a/src/npc/dog.c b/src/npc/dog.c index f5512406..3ca53e97 100644 --- a/src/npc/dog.c +++ b/src/npc/dog.c @@ -265,7 +265,7 @@ void sub_08069CB8(DogEntity* this) { u32 direction; u32 animState; - direction = GetFacingDirection(super, &gPlayerEntity); + direction = GetFacingDirection(super, &gPlayerEntity.base); animState = gUnk_08111DB0[direction + super->animationState * 0x20]; super->animationState = animState >> 6; this->unk_6b = animState & 0x3f; @@ -429,7 +429,7 @@ bool32 sub_08069F90(DogEntity* this) { if ((super->type == 2) && (CheckLocalFlag(MACHI_02_DOG) == 0)) { return TRUE; } else { - return EntityInRectRadius(super, &gPlayerEntity, 0x14, 0x14); + return EntityInRectRadius(super, &gPlayerEntity.base, 0x14, 0x14); } } diff --git a/src/npc/epona.c b/src/npc/epona.c index 1421262b..bec976fd 100644 --- a/src/npc/epona.c +++ b/src/npc/epona.c @@ -103,7 +103,8 @@ void sub_08065AA4(EponaEntity* this) { SetEntityPriority(super, PRIO_MESSAGE); sub_08065A50(this); } - InitAnimationForceUpdate(super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitAnimationForceUpdate(super, + GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); } else { sub_08065A50(this); ResetPlayerAnimationAndAction(); diff --git a/src/npc/ezlo.c b/src/npc/ezlo.c index 15d4a715..b80078cb 100644 --- a/src/npc/ezlo.c +++ b/src/npc/ezlo.c @@ -32,8 +32,8 @@ void sub_0806D8A0(Entity* this, ScriptExecutionContext* context) { if (this->spriteSettings.flipX) { xOffset = -xOffset; } - xOffset += gPlayerEntity.x.HALF.HI; - yOffset = gPlayerEntity.y.HALF.HI + 2; + xOffset += gPlayerEntity.base.x.HALF.HI; + yOffset = gPlayerEntity.base.y.HALF.HI + 2; context->x.HALF.HI = xOffset; context->y.HALF.HI = yOffset; @@ -43,15 +43,15 @@ void sub_0806D8A0(Entity* this, ScriptExecutionContext* context) { } void sub_0806D908(Entity* this) { - this->direction = - CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI); + this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, gPlayerEntity.base.x.HALF.HI, + gPlayerEntity.base.y.HALF.HI); this->animationState = (this->animationState & 0x80) | gUnk_08114144[this->direction >> 0x1]; } // called when talk to ezlo, also when ezlo moves after you void sub_0806D944(Entity* this) { this->spriteSettings.flipX = 0; - if (this->x.WORD <= gPlayerEntity.x.WORD) { + if (this->x.WORD <= gPlayerEntity.base.x.WORD) { this->spriteSettings.flipX = 1; } } @@ -66,12 +66,12 @@ void sub_0806D96C(Entity* this) { } void sub_0806D9A4(Entity* this) { - if (this->x.WORD <= gPlayerEntity.x.WORD) { - gPlayerEntity.spriteSettings.flipX = 0; + if (this->x.WORD <= gPlayerEntity.base.x.WORD) { + gPlayerEntity.base.spriteSettings.flipX = 0; } else { - gPlayerEntity.spriteSettings.flipX = 1; + gPlayerEntity.base.spriteSettings.flipX = 1; } - gPlayerEntity.animationState = 4; + gPlayerEntity.base.animationState = 4; } // animation states diff --git a/src/npc/farore.c b/src/npc/farore.c index 5a553f07..ae08c094 100644 --- a/src/npc/farore.c +++ b/src/npc/farore.c @@ -26,8 +26,8 @@ void Farore(FaroreEntity* this) { super->interactType = INTERACTION_NONE; InitializeNPCFusion(super); this->animIndex = super->animIndex; - InitAnimationForceUpdate(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitAnimationForceUpdate( + super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); } else { ExecuteScriptAndHandleAnimation(super, NULL); } diff --git a/src/npc/festari.c b/src/npc/festari.c index fb4d15f9..8a13f80a 100644 --- a/src/npc/festari.c +++ b/src/npc/festari.c @@ -46,7 +46,7 @@ void sub_0805FE48(FestariEntity* this) { if (super->interactType == INTERACTION_FUSE) { super->action = 2; super->interactType = INTERACTION_NONE; - InitAnimationForceUpdate(super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitAnimationForceUpdate(super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); InitializeNPCFusion(super); } else { ExecuteScript(super, this->context); diff --git a/src/npc/gentari.c b/src/npc/gentari.c index c7ed252b..968f71fc 100644 --- a/src/npc/gentari.c +++ b/src/npc/gentari.c @@ -26,8 +26,8 @@ void Gentari(GentariEntity* this) { if (super->interactType == INTERACTION_FUSE) { super->action = 2; super->interactType = INTERACTION_NONE; - InitAnimationForceUpdate(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitAnimationForceUpdate( + super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); InitializeNPCFusion(super); } else { ExecuteScriptAndHandleAnimation(super, NULL); diff --git a/src/npc/ghostBrothers.c b/src/npc/ghostBrothers.c index 7bf07ad6..9282b35f 100644 --- a/src/npc/ghostBrothers.c +++ b/src/npc/ghostBrothers.c @@ -80,8 +80,8 @@ void sub_08065C0C(GhostBrothersEntity* this) { if (super->interactType == INTERACTION_FUSE) { super->action = 2; super->interactType = INTERACTION_NONE; - InitAnimationForceUpdate(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitAnimationForceUpdate( + super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); InitializeNPCFusion(super); } else { ExecuteScriptAndHandleAnimation(super, NULL); diff --git a/src/npc/gina.c b/src/npc/gina.c index 46b13bcd..0124c37e 100644 --- a/src/npc/gina.c +++ b/src/npc/gina.c @@ -27,8 +27,8 @@ void Gina(GinaEntity* this) { if (super->interactType == INTERACTION_FUSE) { super->action = 2; super->interactType = INTERACTION_NONE; - InitAnimationForceUpdate(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitAnimationForceUpdate( + super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); InitializeNPCFusion(super); } else { ExecuteScriptAndHandleAnimation(super, NULL); diff --git a/src/npc/gregal.c b/src/npc/gregal.c index 4a2e3fb5..f081280a 100644 --- a/src/npc/gregal.c +++ b/src/npc/gregal.c @@ -102,8 +102,8 @@ void sub_0806CC08(GregalEntity* this) { super->action = 2; super->interactType = INTERACTION_NONE; this->animIndex = super->animIndex; - InitAnimationForceUpdate(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)) + 8); + InitAnimationForceUpdate( + super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base)) + 8); InitializeNPCFusion(super); } else { ExecuteScriptForEntity(super, NULL); diff --git a/src/npc/guard.c b/src/npc/guard.c index 7a18d62d..760bb6b0 100644 --- a/src/npc/guard.c +++ b/src/npc/guard.c @@ -319,7 +319,7 @@ void sub_08063DC8(Entity* this) { if (this->type == 0xff) { this->action = 2; this->timer = 30; - this->animationState = GetAnimationStateForDirection4(GetFacingDirection(this, &gPlayerEntity)); + this->animationState = GetAnimationStateForDirection4(GetFacingDirection(this, &gPlayerEntity.base)); InitAnimationForceUpdate(this, this->animationState + 4); } else { sub_0806EE20(this); @@ -332,7 +332,7 @@ void sub_08063DC8(Entity* this) { if (this->interactType != INTERACTION_NONE) { this->action = 3; this->interactType = INTERACTION_NONE; - InitializeAnimation(this, GetAnimationStateForDirection4(GetFacingDirection(this, &gPlayerEntity))); + InitializeAnimation(this, GetAnimationStateForDirection4(GetFacingDirection(this, &gPlayerEntity.base))); sub_08064428(this); } } @@ -389,8 +389,8 @@ void sub_08063F20(GuardEntity* this) { if (super->interactType != INTERACTION_NONE) { super->action++; super->interactType = INTERACTION_NONE; - InitializeAnimation(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)) + this->unk_70); + InitializeAnimation(super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base)) + + this->unk_70); sub_08064428(super); } } diff --git a/src/npc/guardWithSpear.c b/src/npc/guardWithSpear.c index 8d9bf404..e4821138 100644 --- a/src/npc/guardWithSpear.c +++ b/src/npc/guardWithSpear.c @@ -111,7 +111,7 @@ void sub_08064198(GuardWithSpearEntity* this) { this->unk_71--; } - yDiff = gPlayerEntity.y.HALF.HI - super->y.HALF.HI; + yDiff = gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI; if (2 < yDiff) { yDiff = 2; } @@ -131,7 +131,7 @@ void sub_08064198(GuardWithSpearEntity* this) { sVar1 = super->y.HALF.HI; ProcessMovement0(super); if (sVar1 != super->y.HALF.HI) { - if (0x140 < gPlayerEntity.speed && gRoomTransition.frameCount % 6 == 0) { + if (0x140 < gPlayerEntity.base.speed && gRoomTransition.frameCount % 6 == 0) { CreateDustSmall(super); } this->unk_71 = 10; @@ -144,7 +144,7 @@ void sub_08064198(GuardWithSpearEntity* this) { } if (this->unk_71 == 0) { animationState = super->animationState = - GetAnimationStateForDirection8(GetFacingDirection(super, &gPlayerEntity)); + GetAnimationStateForDirection8(GetFacingDirection(super, &gPlayerEntity.base)); animIndex = (animationState >> 1) + this->unk_70; if (animIndex != super->animIndex) { InitializeAnimation(super, animIndex); @@ -152,8 +152,8 @@ void sub_08064198(GuardWithSpearEntity* this) { } sub_0806ED78(super); sVar1 = super->z.HALF.HI; - super->z.HALF.HI = gPlayerEntity.z.HALF.HI; - if (sVar1 < 0 && gPlayerEntity.z.HALF.HI == 0) { + super->z.HALF.HI = gPlayerEntity.base.z.HALF.HI; + if (sVar1 < 0 && gPlayerEntity.base.z.HALF.HI == 0) { CreateDustSmall(super); } } @@ -168,7 +168,7 @@ void sub_080642B8(GuardWithSpearEntity* this) { this->unk_71--; } - yDiff = gPlayerEntity.x.HALF.HI - super->x.HALF.HI; + yDiff = gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI; if (2 < yDiff) { yDiff = 2; } @@ -188,7 +188,7 @@ void sub_080642B8(GuardWithSpearEntity* this) { sVar1 = super->x.HALF.HI; ProcessMovement0(super); if (sVar1 != super->x.HALF.HI) { - if (0x140 < gPlayerEntity.speed && gRoomTransition.frameCount % 6 == 0) { + if (0x140 < gPlayerEntity.base.speed && gRoomTransition.frameCount % 6 == 0) { CreateDustSmall(super); } this->unk_71 = 10; @@ -201,7 +201,7 @@ void sub_080642B8(GuardWithSpearEntity* this) { } if (this->unk_71 == 0) { animationState = super->animationState = - GetAnimationStateForDirection8(GetFacingDirection(super, &gPlayerEntity)); + GetAnimationStateForDirection8(GetFacingDirection(super, &gPlayerEntity.base)); animIndex = (animationState >> 1) + this->unk_70; if (animIndex != super->animIndex) { InitializeAnimation(super, animIndex); @@ -209,8 +209,8 @@ void sub_080642B8(GuardWithSpearEntity* this) { } sub_0806ED78(super); sVar1 = super->z.HALF.HI; - super->z.HALF.HI = gPlayerEntity.z.HALF.HI; - if (sVar1 < 0 && gPlayerEntity.z.HALF.HI == 0) { + super->z.HALF.HI = gPlayerEntity.base.z.HALF.HI; + if (sVar1 < 0 && gPlayerEntity.base.z.HALF.HI == 0) { CreateDustSmall(super); } } diff --git a/src/npc/hurdyGurdyMan.c b/src/npc/hurdyGurdyMan.c index 90580f2d..eb271392 100644 --- a/src/npc/hurdyGurdyMan.c +++ b/src/npc/hurdyGurdyMan.c @@ -37,7 +37,8 @@ void HurdyGurdyMan(HurdyGurdyManEntity* this) { super->action = 2; super->interactType = INTERACTION_NONE; this->unk_69 = super->animIndex; - InitializeAnimation(super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitializeAnimation(super, + GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); index = GetFuserId(super); pointerToArray = gUnk_08001A7C[index]; if (this->fusionOffer == 0x32) { diff --git a/src/npc/kid.c b/src/npc/kid.c index 281bbc93..aa4bcbea 100644 --- a/src/npc/kid.c +++ b/src/npc/kid.c @@ -313,7 +313,7 @@ void sub_080621AC(KidEntity* this) { if (super->animIndex < 8) { InitializeAnimation(super, (super->animIndex & 0xfffffffc) + - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); } break; case 2: @@ -353,17 +353,17 @@ void sub_080622F4(KidEntity* this) { KidHeapItem item; // Prepended heap item is initialized from player's current state. - item.FIELDS.x = gPlayerEntity.x.HALF_U.HI; - item.FIELDS.y = gPlayerEntity.y.HALF_U.HI; - item.FIELDS.z = gPlayerEntity.z.HALF_U.HI; + item.FIELDS.x = gPlayerEntity.base.x.HALF_U.HI; + item.FIELDS.y = gPlayerEntity.base.y.HALF_U.HI; + item.FIELDS.z = gPlayerEntity.base.z.HALF_U.HI; item.FIELDS.framestate = gPlayerState.framestate; - item.FIELDS.animationState = gPlayerEntity.animationState; - item.FIELDS.collisionLayer = gPlayerEntity.collisionLayer; + item.FIELDS.animationState = gPlayerEntity.base.animationState; + item.FIELDS.collisionLayer = gPlayerEntity.base.collisionLayer; heapPtr = super->myHeap; if (heapPtr->FIELDS.framestate == 0x16 && item.FIELDS.framestate != 0x16) { - dx = super->x.HALF.HI - gPlayerEntity.x.HALF.HI; - dy = super->y.HALF.HI - gPlayerEntity.y.HALF.HI; + dx = super->x.HALF.HI - gPlayerEntity.base.x.HALF.HI; + dy = super->y.HALF.HI - gPlayerEntity.base.y.HALF.HI; if (dx < 0) dx = -dx; @@ -395,7 +395,7 @@ void sub_080622F4(KidEntity* this) { KID_HEAP_SHIFT_RIGHT; animIndex = 0x4; } else { - dist = sub_080041E8(gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, (u16)heapPtr->FIELDS.x, + dist = sub_080041E8(gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, (u16)heapPtr->FIELDS.x, (u16)heapPtr->FIELDS.y); dist = ((u32)dist) >> 0x4; if (dist > 0x18) { @@ -465,20 +465,20 @@ void sub_0806252C(Entity* this) { s32 r10; FORCE_REGISTER(s32 x, r12); - r1 = gPlayerEntity.x.HALF_U.HI; + r1 = gPlayerEntity.base.x.HALF_U.HI; r3 = 0xffff0000; r0 = r3; r0 &= r5; r0 |= r1; - r1 = gPlayerEntity.y.HALF_U.HI; + r1 = gPlayerEntity.base.y.HALF_U.HI; r1 <<= 0x10; r2 = 0x0000ffff; r0 &= r2; r0 |= r1; r5 = r0; - r0 = gPlayerEntity.z.HALF_U.HI; + r0 = gPlayerEntity.base.z.HALF_U.HI; r3 &= r6; r3 |= r0; @@ -488,7 +488,7 @@ void sub_0806252C(Entity* this) { r2 &= r3; r2 |= r0; - r1 = gPlayerEntity.animationState; + r1 = gPlayerEntity.base.animationState; r0 = 0x3f; r1 &= r0; r1 <<= 0x18; @@ -496,15 +496,15 @@ void sub_0806252C(Entity* this) { r0 &= r2; r0 |= r1; - r1 = gPlayerEntity.collisionLayer; + r1 = gPlayerEntity.base.collisionLayer; r1 <<= 0x1e; r2 = 0x3fffffff; r0 &= r2; r0 |= r1; r6 = r0; - r10 = r0 = gPlayerEntity.x.HALF.HI - this->x.HALF.HI; - r8 = r0 = gPlayerEntity.y.HALF.HI - this->y.HALF.HI; + r10 = r0 = gPlayerEntity.base.x.HALF.HI - this->x.HALF.HI; + r8 = r0 = gPlayerEntity.base.y.HALF.HI - this->y.HALF.HI; r10 = FixedDiv(r10, KID_HEAP_COUNT); r8 = FixedDiv(r8, KID_HEAP_COUNT); diff --git a/src/npc/kingDaltus.c b/src/npc/kingDaltus.c index cc901f18..1840e24e 100644 --- a/src/npc/kingDaltus.c +++ b/src/npc/kingDaltus.c @@ -37,7 +37,8 @@ void KingDaltus(KingDaltusEntity* this) { if (super->interactType == INTERACTION_FUSE) { super->interactType = INTERACTION_NONE; super->action = 2; - InitAnimationForceUpdate(super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitAnimationForceUpdate(super, + GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); InitializeNPCFusion(super); } scriptedActionFuncs[super->action](this); diff --git a/src/npc/malon.c b/src/npc/malon.c index 65e1ab77..9584078f 100644 --- a/src/npc/malon.c +++ b/src/npc/malon.c @@ -62,7 +62,7 @@ void sub_080658BC(MalonEntity* this) { if (super->interactType == INTERACTION_FUSE) { super->action = 2; super->interactType = INTERACTION_NONE; - InitAnimationForceUpdate(super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitAnimationForceUpdate(super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); InitializeNPCFusion(super); } else { ExecuteScriptAndHandleAnimation(super, NULL); diff --git a/src/npc/mama.c b/src/npc/mama.c index cdcb3cb3..fa20f7a2 100644 --- a/src/npc/mama.c +++ b/src/npc/mama.c @@ -39,7 +39,8 @@ void Mama(MamaEntity* this) { super->action = 2; super->interactType = INTERACTION_NONE; this->animIndex = super->animIndex; - InitializeAnimation(super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitializeAnimation(super, + GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); InitializeNPCFusion(super); } else { ExecuteScriptForEntity(super, NULL); diff --git a/src/npc/mayorHagen.c b/src/npc/mayorHagen.c index 25887beb..9f4aeb4c 100644 --- a/src/npc/mayorHagen.c +++ b/src/npc/mayorHagen.c @@ -32,8 +32,8 @@ void MayorHagen(MayorHagenEntity* this) { super->action = v; super->interactType = INTERACTION_NONE; this->animIndex = super->animIndex; - InitAnimationForceUpdate(super, - 4 + GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitAnimationForceUpdate( + super, 4 + GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); InitializeNPCFusion(super); break; } diff --git a/src/npc/ministerPotho.c b/src/npc/ministerPotho.c index 3004e7ce..1532a424 100644 --- a/src/npc/ministerPotho.c +++ b/src/npc/ministerPotho.c @@ -78,8 +78,8 @@ void sub_08066864(MinisterPothoEntity* this) { if (super->interactType == INTERACTION_FUSE) { super->action = 2; super->interactType = INTERACTION_NONE; - InitAnimationForceUpdate(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitAnimationForceUpdate( + super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); InitializeNPCFusion(super); } else { ExecuteScriptAndHandleAnimation(super, NULL); diff --git a/src/npc/mountainMinish.c b/src/npc/mountainMinish.c index 24e3be4d..4bbf89b9 100644 --- a/src/npc/mountainMinish.c +++ b/src/npc/mountainMinish.c @@ -134,7 +134,8 @@ void sub_08067EF0(MountainMinishEntity* this) { super->action = 3; super->interactType = INTERACTION_NONE; this->animIndex = super->animIndex; - InitializeAnimation(super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitializeAnimation(super, + GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); InitializeNPCFusion(super); } else { ExecuteScriptForEntity(super, 0); @@ -143,7 +144,7 @@ void sub_08067EF0(MountainMinishEntity* this) { super->action = 2; super->interactType = INTERACTION_NONE; InitializeAnimation(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); sub_08068190(super); } } diff --git a/src/npc/mutoh.c b/src/npc/mutoh.c index 0390ac03..5e09a1d0 100644 --- a/src/npc/mutoh.c +++ b/src/npc/mutoh.c @@ -43,8 +43,8 @@ void Mutoh(MutohEntity* this) { if (super->interactType == INTERACTION_FUSE) { super->action = 2; super->interactType = INTERACTION_NONE; - InitAnimationForceUpdate(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)) + 4); + InitAnimationForceUpdate( + super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base)) + 4); InitializeNPCFusion(super); } else { ExecuteScriptAndHandleAnimation(super, NULL); diff --git a/src/npc/nayru.c b/src/npc/nayru.c index cdf79cc5..5130dbf5 100644 --- a/src/npc/nayru.c +++ b/src/npc/nayru.c @@ -26,8 +26,8 @@ void Nayru(NayruEntity* this) { super->interactType = INTERACTION_NONE; InitializeNPCFusion(super); this->animIndex = super->animIndex; - InitAnimationForceUpdate(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitAnimationForceUpdate( + super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); } else { ExecuteScriptAndHandleAnimation(super, NULL); } diff --git a/src/npc/npc23.c b/src/npc/npc23.c index 4c43992a..acda02d4 100644 --- a/src/npc/npc23.c +++ b/src/npc/npc23.c @@ -51,7 +51,7 @@ void sub_080662F8(NPC23Entity* this) { this->unk_80 = super->y.HALF.HI; this->unk_86 = 0; this->unk_82 = super->timer; - super->parent = &gPlayerEntity; + super->parent = &gPlayerEntity.base; this->unk_84 = 0; sub_08066490(this, super->parent); AddInteractableWhenBigObject(super); @@ -86,7 +86,7 @@ void nullsub_110(NPC23Entity* this) { void sub_080663D4(NPC23Entity* this) { if (super->x.HALF.HI == this->unk_7e - 8) { - if (gPlayerEntity.action != PLAYER_ROOM_EXIT) { + if (gPlayerEntity.base.action != PLAYER_ROOM_EXIT) { super->action = 4; super->direction = 0; super->speed = 0; @@ -109,14 +109,14 @@ void sub_0806643C(NPC23Entity* this) { super->action = 5; gRoomControls.camera_target = NULL; sub_08078AC0(0x40, 0, 0); - gPlayerEntity.animationState = 0; - gPlayerEntity.direction = 0; + gPlayerEntity.base.animationState = 0; + gPlayerEntity.base.direction = 0; } GetNextFrame(super); } void sub_08066474(NPC23Entity* this) { - if (gPlayerEntity.action != PLAYER_ROOM_EXIT) { + if (gPlayerEntity.base.action != PLAYER_ROOM_EXIT) { gPauseMenuOptions.disabled = 0; } } @@ -159,9 +159,9 @@ void sub_08066490(NPC23Entity* this, Entity* entity) { bool32 sub_0806650C(NPC23Entity* this) { u32 dir = 0; - s32 px = gPlayerEntity.x.HALF_U.HI; + s32 px = gPlayerEntity.base.x.HALF_U.HI; s32 px2 = px; - s32 py = gPlayerEntity.y.HALF_U.HI; + s32 py = gPlayerEntity.base.y.HALF_U.HI; if (py < this->unk_80 + 16) { dir = 4; @@ -173,17 +173,17 @@ bool32 sub_0806650C(NPC23Entity* this) { dir = 6; } if (dir == 0) { - gPlayerEntity.speed = 0; + gPlayerEntity.base.speed = 0; } } - if (gPlayerEntity.action != PLAYER_ROOM_EXIT) { + if (gPlayerEntity.base.action != PLAYER_ROOM_EXIT) { if (dir == 0) { return 0; } sub_08078AC0(8, 0, 0); - gPlayerEntity.animationState = dir; - gPlayerEntity.direction = Direction8FromAnimationState(dir); + gPlayerEntity.base.animationState = dir; + gPlayerEntity.base.direction = Direction8FromAnimationState(dir); } return 1; } @@ -197,11 +197,11 @@ void sub_08066570(Entity* this) { return; } - if (this->action == 3 || !sub_0806FC80(this, &gPlayerEntity, 0x50)) { + if (this->action == 3 || !sub_0806FC80(this, &gPlayerEntity.base, 0x50)) { return; } - direction = GetFacingDirection(this, &gPlayerEntity); + direction = GetFacingDirection(this, &gPlayerEntity.base); cond = TRUE; dir2 = (direction & DirectionWest); diff --git a/src/npc/npc5.c b/src/npc/npc5.c index da120bee..d4a78753 100644 --- a/src/npc/npc5.c +++ b/src/npc/npc5.c @@ -96,7 +96,7 @@ void CreateZeldaFollower(void) { if (CheckGlobalFlag(ZELDA_CHASE) != 0) { npc = CreateNPC(ZELDA_FOLLOWER, 0, 0); if (npc != NULL) { - CopyPosition(&gPlayerEntity, npc); + CopyPosition(&gPlayerEntity.base, npc); npc->flags |= ENT_PERSIST; npc->animationState = GetAnimationState(npc); } @@ -124,8 +124,8 @@ void sub_08060A00(NPC5Entity* this) { if (super->action != 0) { if (((((UnkHeap*)super->myHeap)->unk_0) & 4) == 0) { ((UnkHeap*)super->myHeap)->unk_0 |= 4; - ((UnkHeap*)super->myHeap)->unk_5 = (gPlayerEntity.x.HALF.HI & 0xfff0) + 8; - ((UnkHeap*)super->myHeap)->unk_6 = (gPlayerEntity.y.HALF.HI & 0xfff0) + 8; + ((UnkHeap*)super->myHeap)->unk_5 = (gPlayerEntity.base.x.HALF.HI & 0xfff0) + 8; + ((UnkHeap*)super->myHeap)->unk_6 = (gPlayerEntity.base.y.HALF.HI & 0xfff0) + 8; } } } @@ -135,12 +135,12 @@ void sub_08060A00(NPC5Entity* this) { } if (super->action != 0) { - ((UnkHeap*)super->myHeap)->unk_1 = gPlayerEntity.x.HALF.HI; - ((UnkHeap*)super->myHeap)->unk_2 = gPlayerEntity.y.HALF.HI; + ((UnkHeap*)super->myHeap)->unk_1 = gPlayerEntity.base.x.HALF.HI; + ((UnkHeap*)super->myHeap)->unk_2 = gPlayerEntity.base.y.HALF.HI; } if (this->unk_74 != gRoomControls.room) { this->unk_74 = gRoomControls.room; - CopyPosition(&gPlayerEntity, super); + CopyPosition(&gPlayerEntity.base, super); super->action = 1; super->spriteSettings.draw = 1; super->speed = 0x120; @@ -182,7 +182,7 @@ void sub_08060AE0(NPC5Entity* this) { void sub_08060B5C(NPC5Entity* this) { if (sub_08061230(this) == 0) { if ((sub_08060F80(super) == 0) && - (((GetFacingDirection(super, &gPlayerEntity) + (super->animationState * -4) + 4) & 0x1f)) < 9) { + (((GetFacingDirection(super, &gPlayerEntity.base) + (super->animationState * -4) + 4) & 0x1f)) < 9) { super->action = 2; super->subtimer = 0; return; @@ -227,8 +227,8 @@ void sub_08060BA0(NPC5Entity* this) { } } else { - if (sub_08060FD0(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI) != 0) { - sub_08061090(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI); + if (sub_08060FD0(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI) != 0) { + sub_08061090(this, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI); sub_08061170(this); ((UnkHeap*)super->myHeap)->unk_0 &= 0xf5; } else { @@ -257,7 +257,7 @@ void sub_08060BA0(NPC5Entity* this) { } } else { ((UnkHeap*)super->myHeap)->unk_0 &= 0xfd; - sub_08061464(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI); + sub_08061464(this, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI); } } } @@ -315,7 +315,7 @@ void sub_08060E34(NPC5Entity* this) { UpdateAnimationSingleFrame(super); if ((super->frame & ANIM_DONE) != 0) { super->action = 2; - super->animationState = DirectionToAnimationState(GetFacingDirection(super, &gPlayerEntity)) * 2; + super->animationState = DirectionToAnimationState(GetFacingDirection(super, &gPlayerEntity.base)) * 2; sub_08060E70(this, 8); } } @@ -343,7 +343,7 @@ void sub_08060EDC(NPC5Entity* this) { if (((u32)super->animIndex - 0x20 < 0x10) && ((super->frame & ANIM_DONE) == 0)) { UpdateAnimationSingleFrame(super); } else { - tmp = GetFacingDirection(super, &gPlayerEntity) + super->animationState * -4; + tmp = GetFacingDirection(super, &gPlayerEntity.base) + super->animationState * -4; if (((tmp + 3) & 0x1f) >= 7) { if ((tmp & 0x1f) < 0x10) { InitAnimationForceUpdate(super, super->animationState + 0x20); @@ -364,12 +364,12 @@ void sub_08060EDC(NPC5Entity* this) { } } u32 sub_08060F80(Entity* this) { - if (sub_08060FD0(this, (s32)gPlayerEntity.x.HALF.HI, (s32)gPlayerEntity.y.HALF.HI) == 0) { + if (sub_08060FD0(this, (s32)gPlayerEntity.base.x.HALF.HI, (s32)gPlayerEntity.base.y.HALF.HI) == 0) { return 0; } ((UnkHeap*)this->myHeap)->unk_0 &= 0xfb; - if (PointInsideRadius(gPlayerEntity.x.HALF.HI - this->x.HALF.HI, gPlayerEntity.y.HALF.HI - this->y.HALF.HI, - ((UnkHeap*)this->myHeap)->unk_0b) != 0) { + if (PointInsideRadius(gPlayerEntity.base.x.HALF.HI - this->x.HALF.HI, + gPlayerEntity.base.y.HALF.HI - this->y.HALF.HI, ((UnkHeap*)this->myHeap)->unk_0b) != 0) { return 1; } return 0; @@ -416,8 +416,8 @@ void sub_08061090(NPC5Entity* this, u32 a, u32 b) { s32 sqrDist; u32 tmp; - xDist = gPlayerEntity.x.HALF.HI - super->x.HALF.HI; - yDist = gPlayerEntity.y.HALF.HI - super->y.HALF.HI; + xDist = gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI; + yDist = gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI; sqrDist = (xDist * xDist) + (yDist * yDist); if (sqrDist < 0x900) { super->speed = 0x120; diff --git a/src/npc/percy.c b/src/npc/percy.c index c6dd0b36..a3a04a44 100644 --- a/src/npc/percy.c +++ b/src/npc/percy.c @@ -84,7 +84,7 @@ void sub_0806B41C(PercyEntity* this) { super->action = 2; super->interactType = INTERACTION_NONE; InitializeAnimation(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)) + 4); + GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base)) + 4); idx = GetFuserId(super); tmp = gUnk_08001A7C[idx]; if (this->fusionOffer == 33) @@ -165,7 +165,7 @@ void sub_0806B540(Entity* this) { } break; case 3: - if ((gPlayerEntity.action != PLAYER_ITEMGET)) { + if ((gPlayerEntity.base.action != PLAYER_ITEMGET)) { context->wait = 0x2d; return; } diff --git a/src/npc/pina.c b/src/npc/pina.c index f4cdc048..26692def 100644 --- a/src/npc/pina.c +++ b/src/npc/pina.c @@ -93,8 +93,8 @@ void sub_08063B68(PinaEntity* this) { super->action = 2; super->interactType = INTERACTION_NONE; this->animIndex = super->animIndex; - InitAnimationForceUpdate(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)) + 4); + InitAnimationForceUpdate( + super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base)) + 4); InitializeNPCFusion(super); } else { ExecuteScriptForEntity(super, NULL); diff --git a/src/npc/postman.c b/src/npc/postman.c index 3e2f5745..3d434f77 100644 --- a/src/npc/postman.c +++ b/src/npc/postman.c @@ -256,15 +256,15 @@ void sub_08060528(PostmanEntity* this) { super->action = 3; super->interactType = INTERACTION_NONE; InitializeNPCFusion(super); - InitAnimationForceUpdate(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitAnimationForceUpdate( + super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); } else { if (super->interactType != INTERACTION_NONE) { super->action = 2; super->interactType = INTERACTION_NONE; sub_080606D8(super); - InitAnimationForceUpdate(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitAnimationForceUpdate( + super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); } else { ExecuteScriptAndHandleAnimation(super, NULL); } @@ -302,7 +302,7 @@ void sub_08060528(PostmanEntity* this) { Postman_MakeInteractable(this); } if (super->z.WORD >= 0 && - ((gPlayerEntity.collisionLayer == 0 || (super->collisionLayer == gPlayerEntity.collisionLayer)))) { + ((gPlayerEntity.base.collisionLayer == 0 || (super->collisionLayer == gPlayerEntity.base.collisionLayer)))) { sub_0806ED78(super); } sub_0800451C(super); @@ -406,13 +406,13 @@ void sub_0806076C(PostmanEntity* this, ScriptExecutionContext* context) { void sub_080608E4(PostmanEntity* this, ScriptExecutionContext* context) { context->condition = 0; if (super->z.WORD >= 0) { - if ((super->collisionLayer != 1 || gPlayerEntity.collisionLayer != 2) && - (super->collisionLayer != 2 || gPlayerEntity.collisionLayer != 1)) { + if ((super->collisionLayer != 1 || gPlayerEntity.base.collisionLayer != 2) && + (super->collisionLayer != 2 || gPlayerEntity.base.collisionLayer != 1)) { const Rect* ptr = &gUnk_0810AA70[context->intVariable][super->animationState >> 1]; u32 x = super->x.HALF.HI + ptr->x; u32 y = super->y.HALF.HI + ptr->y; - x = gPlayerEntity.x.HALF.HI - x; - y = gPlayerEntity.y.HALF.HI - y; + x = gPlayerEntity.base.x.HALF.HI - x; + y = gPlayerEntity.base.y.HALF.HI - y; x += ptr->width; y += ptr->height; if (ptr->width * 2 > x && ptr->height * 2 > y) { diff --git a/src/npc/sittingPerson.c b/src/npc/sittingPerson.c index 649239e0..c3da1060 100644 --- a/src/npc/sittingPerson.c +++ b/src/npc/sittingPerson.c @@ -151,7 +151,7 @@ void sub_080637B8(SittingPersonEntity* this) { super->action = 2; super->interactType = INTERACTION_NONE; this->animIndex = super->animIndex; - tmp = GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)); + tmp = GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base)); tmp += super->spriteSettings.flipX ? 4 : 0; InitializeAnimation(super, tmp); InitializeNPCFusion(super); diff --git a/src/npc/smith.c b/src/npc/smith.c index 940bd75a..2210dede 100644 --- a/src/npc/smith.c +++ b/src/npc/smith.c @@ -48,7 +48,7 @@ void Smith(SmithEntity* this) { super->action = 4; super->interactType = INTERACTION_NONE; index = (super->animIndex == 0xc) ? 8 : 0; - index += GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)); + index += GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base)); InitAnimationForceUpdate(super, index); InitializeNPCFusion(super); } diff --git a/src/npc/stockwell.c b/src/npc/stockwell.c index dc930fd9..d1971904 100644 --- a/src/npc/stockwell.c +++ b/src/npc/stockwell.c @@ -175,7 +175,7 @@ void sub_080652E4(Entity* this) { if (this->timer != 0) { this->timer--; } else { - if (gPlayerEntity.action != PLAYER_ITEMGET) { + if (gPlayerEntity.base.action != PLAYER_ITEMGET) { this->subAction++; MessageNoOverlap(TEXT_INDEX(TEXT_STOCKWELL, 0x19), this); } diff --git a/src/npc/sturgeon.c b/src/npc/sturgeon.c index 9bc3bd84..b48d2ec6 100644 --- a/src/npc/sturgeon.c +++ b/src/npc/sturgeon.c @@ -64,8 +64,8 @@ void Sturgeon(SturgeonEntity* this) { if (super->interactType == INTERACTION_FUSE) { super->action = super->action | 0xff; super->interactType = INTERACTION_NONE; - InitAnimationForceUpdate(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitAnimationForceUpdate( + super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); InitializeNPCFusion(super); } else { ExecuteScriptAndHandleAnimation(super, NULL); diff --git a/src/npc/talon.c b/src/npc/talon.c index 9e2cdfc9..ddcd1977 100644 --- a/src/npc/talon.c +++ b/src/npc/talon.c @@ -152,7 +152,7 @@ void sub_080656D4(TalonEntity* this) { void sub_0806574C(TalonEntity* this) { u32 j; - j = (super->animIndex & ~3) + GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)); + j = (super->animIndex & ~3) + GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base)); if (super->animIndex != j) { InitAnimationForceUpdate(super, j); } diff --git a/src/npc/teachers.c b/src/npc/teachers.c index 609c7bc4..89953855 100644 --- a/src/npc/teachers.c +++ b/src/npc/teachers.c @@ -38,8 +38,8 @@ void Teachers(TeachersEntity* this) { super->action = 2; super->interactType = INTERACTION_NONE; this->animIndex = super->animIndex; - InitializeAnimation(super, (super->animIndex & -4) + GetAnimationStateForDirection4( - GetFacingDirection(super, &gPlayerEntity))); + InitializeAnimation(super, (super->animIndex & -4) + GetAnimationStateForDirection4(GetFacingDirection( + super, &gPlayerEntity.base))); InitializeNPCFusion(super); } else { ExecuteScriptAndHandleAnimation(super, NULL); diff --git a/src/npc/tingleSiblings.c b/src/npc/tingleSiblings.c index 3d4b26e8..75abc4db 100644 --- a/src/npc/tingleSiblings.c +++ b/src/npc/tingleSiblings.c @@ -70,7 +70,7 @@ void sub_08064DE4(Entity* this) { this->action = 2; this->interactType = INTERACTION_NONE; InitAnimationForceUpdate(this, - GetAnimationStateForDirection4(GetFacingDirection(this, &gPlayerEntity))); + GetAnimationStateForDirection4(GetFacingDirection(this, &gPlayerEntity.base))); InitializeNPCFusion(this); } else { ExecuteScriptAndHandleAnimation(this, NULL); diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c index f29f6e4e..273da662 100644 --- a/src/npc/townMinish.c +++ b/src/npc/townMinish.c @@ -184,7 +184,7 @@ void sub_0806ABFC(TownMinishEntity* this) { void sub_0806AC3C(TownMinishEntity* this) { if (super->animIndex <= 3) { s32 unk; - Entity* link = &gPlayerEntity; + Entity* link = &gPlayerEntity.base; if (EntityInRectRadius(super, link, 0x18, 0x18)) { unk = GetFacingDirection(super, link) & 0x1e; } else { @@ -238,12 +238,12 @@ void sub_0806ACC4(TownMinishEntity* this) { if (super->type2 == 10 && super->interactType) { super->action = 2; super->interactType = INTERACTION_NONE; - InitializeAnimation(super, - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity)) + 8); + InitializeAnimation( + super, GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base)) + 8); sub_0806AFE8(super, this->context); } if (super->type == 1) { - u8 idx = gPlayerEntity.animationState >> 1; + u8 idx = gPlayerEntity.base.animationState >> 1; SetInteractableObjectCollision(super, 1, gUnk_081126E4[idx], &gUnk_081126D4[idx]); } } diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c index 967a6645..8f8b34f1 100644 --- a/src/npc/townsperson.c +++ b/src/npc/townsperson.c @@ -131,7 +131,7 @@ void sub_08061D64(TownspersonEntity* this) { InitializeNPCFusion(super); this->unk_69 = super->animIndex; InitializeAnimation(super, (super->animIndex & -4) + - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity.base))); } else { ExecuteScriptForEntity(super, NULL); HandleEntity0x82Actions(super); @@ -144,8 +144,8 @@ void sub_08061D64(TownspersonEntity* this) { super->interactType = INTERACTION_NONE; sub_08062048(super); this->unk_69 = super->animIndex; - InitializeAnimation(super, (super->animIndex & -4) + - GetAnimationStateForDirection4(GetFacingDirection(super, &gPlayerEntity))); + InitializeAnimation(super, (super->animIndex & -4) + GetAnimationStateForDirection4( + GetFacingDirection(super, &gPlayerEntity.base))); } } } diff --git a/src/npc/zelda.c b/src/npc/zelda.c index c1f80998..d8e77ffd 100644 --- a/src/npc/zelda.c +++ b/src/npc/zelda.c @@ -79,7 +79,7 @@ void sub_08066D94(Entity* this) { SetGlobalFlag(ZELDA_CHASE); npc = (ZeldaFollowerEntity*)CreateNPC(ZELDA_FOLLOWER, 0, 0); if (npc != NULL) { - npc->base.animationState = gPlayerEntity.animationState; + npc->base.animationState = gPlayerEntity.base.animationState; npc->base.flags |= ENT_PERSIST; npc->base.animationState = GetAnimationState(this); room = gRoomControls.room; diff --git a/src/npc/zeldaFollower.c b/src/npc/zeldaFollower.c index 45315961..1fe5f067 100644 --- a/src/npc/zeldaFollower.c +++ b/src/npc/zeldaFollower.c @@ -71,19 +71,19 @@ void sub_08068318(ZeldaFollowerEntity* this) { ZeldaFollowerItem* heapPtr; ZeldaFollowerItem item; - item.FIELDS.x = gPlayerEntity.x.HALF_U.HI; - item.FIELDS.y = gPlayerEntity.y.HALF_U.HI; - item.FIELDS.z = gPlayerEntity.z.HALF_U.HI; + item.FIELDS.x = gPlayerEntity.base.x.HALF_U.HI; + item.FIELDS.y = gPlayerEntity.base.y.HALF_U.HI; + item.FIELDS.z = gPlayerEntity.base.z.HALF_U.HI; item.FIELDS.framestate = gPlayerState.framestate; - item.FIELDS.animationState = gPlayerEntity.animationState; - item.FIELDS.collisionLayer = gPlayerEntity.collisionLayer; + item.FIELDS.animationState = gPlayerEntity.base.animationState; + item.FIELDS.collisionLayer = gPlayerEntity.base.collisionLayer; heapPtr = super->myHeap; if ((heapPtr->FIELDS.framestate == 0xa && item.FIELDS.framestate != 0xa) || (heapPtr->FIELDS.framestate == 0x16 && item.FIELDS.framestate != 0x16)) { - super->x.HALF.HI = gPlayerEntity.x.HALF.HI; - super->y.HALF.HI = gPlayerEntity.y.HALF.HI; + super->x.HALF.HI = gPlayerEntity.base.x.HALF.HI; + super->y.HALF.HI = gPlayerEntity.base.y.HALF.HI; super->spriteSettings.draw = 1; sub_08068578(super); } @@ -106,7 +106,7 @@ void sub_08068318(ZeldaFollowerEntity* this) { ZELDA_FOLLOWER_HEAP_SHIFT_RIGHT(super, heapPtr); animIndex = 0x4; } else { - dist = sub_080041E8(gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, (u16)heapPtr->FIELDS.x, + dist = sub_080041E8(gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, (u16)heapPtr->FIELDS.x, (u16)heapPtr->FIELDS.y); dist = ((u32)dist) >> 0x4; if (dist > 0x18) { @@ -187,17 +187,17 @@ void sub_08068578(Entity* this) { // first u32 (r5) #ifdef REWRITE_CODE - r0 = gPlayerEntity.x.HALF_U.HI | (r5 & 0xffff0000); - r5 = (gPlayerEntity.y.HALF_U.HI << 0x10) | (r0 & 0x0000ffff); + r0 = gPlayerEntity.base.x.HALF_U.HI | (r5 & 0xffff0000); + r5 = (gPlayerEntity.base.y.HALF_U.HI << 0x10) | (r0 & 0x0000ffff); #else - r1 = gPlayerEntity.x.HALF_U.HI; + r1 = gPlayerEntity.base.x.HALF_U.HI; r3 = 0xffff0000; r0 = r3; r0 &= r5; r0 |= r1; - r1 = gPlayerEntity.y.HALF_U.HI; + r1 = gPlayerEntity.base.y.HALF_U.HI; r1 <<= 0x10; r2 = 0xffff; r0 &= r2; @@ -207,12 +207,12 @@ void sub_08068578(Entity* this) { // second u32 (r6) #ifdef REWRITE_CODE - r3 = gPlayerEntity.z.HALF_U.HI | (r6 & 0xffff0000); + r3 = gPlayerEntity.base.z.HALF_U.HI | (r6 & 0xffff0000); r2 = (gPlayerState.framestate << 0x10) | (r3 & 0xff00ffff); - r0 = ((gPlayerEntity.animationState & 0x3f) << 0x18) | (r2 & 0xc0ffffff); - r6 = (gPlayerEntity.collisionLayer << 0x1e) | (r0 & 0x3fffffff); + r0 = ((gPlayerEntity.base.animationState & 0x3f) << 0x18) | (r2 & 0xc0ffffff); + r6 = (gPlayerEntity.base.collisionLayer << 0x1e) | (r0 & 0x3fffffff); #else - r0 = gPlayerEntity.z.HALF_U.HI; + r0 = gPlayerEntity.base.z.HALF_U.HI; r3 &= r6; r3 |= r0; @@ -222,7 +222,7 @@ void sub_08068578(Entity* this) { r2 &= r3; r2 |= r0; - r1 = gPlayerEntity.animationState; + r1 = gPlayerEntity.base.animationState; r0 = 0x3f; r1 &= r0; r1 <<= 0x18; @@ -230,8 +230,8 @@ void sub_08068578(Entity* this) { r0 &= r2; r0 |= r1; - // gPlayerEntity is now at r1 - r1 = gPlayerEntity.collisionLayer; + // gPlayerEntity.base.is now at r1 + r1 = gPlayerEntity.base.collisionLayer; r1 <<= 0x1e; r2 = 0x3fffffff; r0 &= r2; @@ -240,18 +240,18 @@ void sub_08068578(Entity* this) { #endif #ifdef REWRITE_CODE - r10 = gPlayerEntity.x.HALF.HI - this->x.HALF.HI; + r10 = gPlayerEntity.base.x.HALF.HI - this->x.HALF.HI; #else - r1 = gPlayerEntity.x.HALF.HI; + r1 = gPlayerEntity.base.x.HALF.HI; r0 = this->x.HALF.HI; r0 = r1 - r0; r10 = r0; #endif #ifdef REWRITE_CODE - r8 = gPlayerEntity.y.HALF.HI - this->y.HALF.HI; + r8 = gPlayerEntity.base.y.HALF.HI - this->y.HALF.HI; #else - r1 = gPlayerEntity.y.HALF.HI; + r1 = gPlayerEntity.base.y.HALF.HI; r0 = this->y.HALF.HI; r0 = r1 - r0; r8 = r0; diff --git a/src/npcUtils.c b/src/npcUtils.c index b0c111fe..3d0323c3 100644 --- a/src/npcUtils.c +++ b/src/npcUtils.c @@ -121,20 +121,20 @@ u32 sub_0806ED78(Entity* ent) { s32 GetAnimationStateInRectRadius(Entity* ent, u32 x, u32 y) { s32 anim = -1; - if (EntityInRectRadius(ent, &gPlayerEntity, x, y)) + if (EntityInRectRadius(ent, &gPlayerEntity.base, x, y)) anim = GetAnimationState(ent); return anim; } u32 GetAnimationState(Entity* ent) { - u32 direction = GetFacingDirection(ent, &gPlayerEntity); + u32 direction = GetFacingDirection(ent, &gPlayerEntity.base); return GetAnimationStateForDirection4(direction); } s32 GetFacingDirectionInRectRadius(Entity* ent, u32 x, u32 y) { s32 dir = -1; - if (EntityInRectRadius(ent, &gPlayerEntity, x, y)) - dir = GetFacingDirection(ent, &gPlayerEntity); + if (EntityInRectRadius(ent, &gPlayerEntity.base, x, y)) + dir = GetFacingDirection(ent, &gPlayerEntity.base); return dir; } @@ -160,7 +160,7 @@ u32 sub_0806EE20(Entity* ent) { return gUnk_08114EFC[ent->carryFlags](ent); } else { ent->knockbackSpeed = 8; - v3 = GetFacingDirection(ent, &gPlayerEntity); + v3 = GetFacingDirection(ent, &gPlayerEntity.base); ent->knockbackDirection = GetAnimationStateForDirection4(v3); } return 0; diff --git a/src/object/ambientClouds.c b/src/object/ambientClouds.c index d7470d7d..7e885373 100644 --- a/src/object/ambientClouds.c +++ b/src/object/ambientClouds.c @@ -82,12 +82,12 @@ void AmbientClouds_Action1(Entity* this) { this->spriteOrientation.flipY = 1; this->spriteRendering.b3 = 0; if ((this->type2 == 1) || (this->child->action == 2)) { - if (gPlayerEntity.z.HALF.HI < -0x24) + if (gPlayerEntity.base.z.HALF.HI < -0x24) this->timer = 1; else this->timer = 0; this->y.HALF.HI += (this->type2 - 1) * -0x24; - if (EntityInRectRadius(this, &gPlayerEntity, 15, 15) && (this->timer != 0)) { + if (EntityInRectRadius(this, &gPlayerEntity.base, 15, 15) && (this->timer != 0)) { this->action = 2; this->spriteOrientation.flipY = 2; this->spriteRendering.b3 = 3; @@ -95,23 +95,23 @@ void AmbientClouds_Action1(Entity* this) { this->child->action = 1; } gPlayerState.field_0x14 = 1; - gPlayerEntity.y.HALF.HI -= 0x24; - gPlayerEntity.z.HALF.HI += 0x24; - sub_0807AA80(&gPlayerEntity); + gPlayerEntity.base.y.HALF.HI -= 0x24; + gPlayerEntity.base.z.HALF.HI += 0x24; + sub_0807AA80(&gPlayerEntity.base); if (this->subtimer == 0) { - Entity* fx = CreateFx(&gPlayerEntity, FX_DEATH, 0); + Entity* fx = CreateFx(&gPlayerEntity.base, FX_DEATH, 0); if (fx != NULL) { fx->x.HALF.HI += 8; } - fx = CreateFx(&gPlayerEntity, FX_DEATH, 0); + fx = CreateFx(&gPlayerEntity.base, FX_DEATH, 0); if (fx != NULL) { fx->x.HALF.HI -= 8; } - fx = CreateFx(&gPlayerEntity, FX_DEATH, 0); + fx = CreateFx(&gPlayerEntity.base, FX_DEATH, 0); if (fx != NULL) { fx->y.HALF.HI += 8; } - fx = CreateFx(&gPlayerEntity, FX_DEATH, 0); + fx = CreateFx(&gPlayerEntity.base, FX_DEATH, 0); if (fx != NULL) { fx->y.HALF.HI -= 8; } @@ -125,20 +125,20 @@ void AmbientClouds_Action1(Entity* this) { void AmbientClouds_Action2(Entity* this) { this->y.HALF.HI += this->type2 * -0x24; - if (EntityInRectRadius(this, &gPlayerEntity, 15, 15)) { + if (EntityInRectRadius(this, &gPlayerEntity.base, 15, 15)) { gPlayerState.field_0x14 = 1; gPlayerState.flags |= PL_FLAGS2; } else { this->action = 1; - gPlayerEntity.z.HALF_U.HI += this->z.HALF_U.HI; - gPlayerEntity.y.HALF_U.HI -= this->z.HALF_U.HI; - gPlayerEntity.collisionLayer = 1; + gPlayerEntity.base.z.HALF_U.HI += this->z.HALF_U.HI; + gPlayerEntity.base.y.HALF_U.HI -= this->z.HALF_U.HI; + gPlayerEntity.base.collisionLayer = 1; } this->y.HALF.HI += this->type2 * 0x24; } void AmbientClouds_Action3(Entity* this) { - if (EntityInRectRadius(this, &gPlayerEntity, 15, 15)) { + if (EntityInRectRadius(this, &gPlayerEntity.base, 15, 15)) { gPlayerState.field_0x14 = 1; } } diff --git a/src/object/bakerOven.c b/src/object/bakerOven.c index 65683a8c..22b5fbbb 100644 --- a/src/object/bakerOven.c +++ b/src/object/bakerOven.c @@ -75,15 +75,15 @@ void BakerOven_Action1(BakerOvenEntity* this) { } /* Damage minish link if he touches a steam cloud */ - if (super->subtimer == 0 && gPlayerEntity.iframes == 0 && super->frameIndex && - sub_0806FC80(super, &gPlayerEntity, 4)) { + if (super->subtimer == 0 && gPlayerEntity.base.iframes == 0 && super->frameIndex && + sub_0806FC80(super, &gPlayerEntity.base, 4)) { super->subtimer++; ModHealth(-2); - SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6); - gPlayerEntity.iframes = 16; - gPlayerEntity.knockbackDirection = 16; - gPlayerEntity.knockbackDuration = 12; - gPlayerEntity.knockbackSpeed = 16; + SoundReqClipped(&gPlayerEntity.base, SFX_PLY_VO6); + gPlayerEntity.base.iframes = 16; + gPlayerEntity.base.knockbackDirection = 16; + gPlayerEntity.base.knockbackDuration = 12; + gPlayerEntity.base.knockbackSpeed = 16; } } } diff --git a/src/object/barrelSpiderweb.c b/src/object/barrelSpiderweb.c index 4e5ca85d..386f2c74 100644 --- a/src/object/barrelSpiderweb.c +++ b/src/object/barrelSpiderweb.c @@ -43,7 +43,7 @@ void BarrelSpiderweb_Init(Entity* this) { this->flags2 = 4; this->hitbox = (Hitbox*)&gHitbox_0; this->frameIndex = 2; - this->collisionLayer = gPlayerEntity.collisionLayer; + this->collisionLayer = gPlayerEntity.base.collisionLayer; sub_0808BDB0(this); this->y.HALF.HI = 0x170 - (this->parent)->zVelocity; sub_0808BBE0(this); @@ -115,9 +115,9 @@ void BarrelSpiderweb_Action2(Entity* this) { SetAffineInfo(this, 0x200 - this->subtimer, 0x200 - this->subtimer, 0); } if (this->contactFlags == 0x93) { - this->direction = GetFacingDirection(this, &gPlayerEntity); + this->direction = GetFacingDirection(this, &gPlayerEntity.base); LinearMoveUpdate(this); - if (EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI - 6, 0x1c)) { + if (EntityWithinDistance(this, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI - 6, 0x1c)) { sub_0808BD00(this); } } else { diff --git a/src/object/beanstalk.c b/src/object/beanstalk.c index f1749ccd..fb6abf4e 100644 --- a/src/object/beanstalk.c +++ b/src/object/beanstalk.c @@ -275,7 +275,7 @@ void Beanstalk_Action1Type7(BeanstalkEntity* this) { case 3: case 4: if (gPlayerState.floor_type == SURFACE_LADDER) { - if (EntityInRectRadius(super, &gPlayerEntity, 0, 8)) { + if (EntityInRectRadius(super, &gPlayerEntity.base, 0, 8)) { if ((super->animIndex == (super->type2 - 1) * 3 + 1) && (super->timer == 0)) { super->timer = 1; InitializeAnimation(super, super->animIndex + 1); @@ -334,8 +334,8 @@ void Beanstalk_Action1Type9(BeanstalkEntity* this) { super->y.HALF.HI += 0x28; this->unk_72 = sub_080B1A0C(super, 0, -0x18); } - super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; - super->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; + super->spriteOrientation.flipY = gPlayerEntity.base.spriteOrientation.flipY; + super->spriteRendering.b3 = gPlayerEntity.base.spriteRendering.b3; if (gPlayerState.floor_type == SURFACE_LADDER) { super->spritePriority.b0 = 0; if (sub_080B1A0C(super, 0, -0x18) != 0x4014) { diff --git a/src/object/bigPushableLever.c b/src/object/bigPushableLever.c index 41b7a21c..e4110703 100644 --- a/src/object/bigPushableLever.c +++ b/src/object/bigPushableLever.c @@ -58,9 +58,9 @@ void BigPushableLever_Idle(BigPushableLeverEntity* this) { gPlayerState.pushedObject = 0x98; gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.flags |= PL_BUSY; - gPlayerEntity.x.HALF.LO = 0; - gPlayerEntity.y.HALF.LO = 0; - gPlayerEntity.direction = gPlayerEntity.animationState << 2; + gPlayerEntity.base.x.HALF.LO = 0; + gPlayerEntity.base.y.HALF.LO = 0; + gPlayerEntity.base.direction = gPlayerEntity.base.animationState << 2; } } } diff --git a/src/object/bigVortex.c b/src/object/bigVortex.c index 9a5b3c51..91b510b9 100644 --- a/src/object/bigVortex.c +++ b/src/object/bigVortex.c @@ -75,12 +75,12 @@ void BigVortex_Action2(BigVortexEntity* this) { void BigVortex_Action3(BigVortexEntity* this) { - if (sub_0800419C(super, &gPlayerEntity, 8, 8) != 0) { - CopyPosition(super, &gPlayerEntity); + if (sub_0800419C(super, &gPlayerEntity.base, 8, 8) != 0) { + CopyPosition(super, &gPlayerEntity.base); sub_08004542(super); - sub_08004542(&gPlayerEntity); - gPlayerEntity.collisionLayer = 1; - SortEntityAbove(super, &gPlayerEntity); + sub_08004542(&gPlayerEntity.base); + gPlayerEntity.base.collisionLayer = 1; + SortEntityAbove(super, &gPlayerEntity.base); gPlayerState.queued_action = PLAYER_PARACHUTE; gPlayerState.field_0x38 = 1; gPlayerState.field_0x39 = super->type2; diff --git a/src/object/bird.c b/src/object/bird.c index a4fa24dc..bbd382ff 100644 --- a/src/object/bird.c +++ b/src/object/bird.c @@ -211,26 +211,26 @@ void Bird_Type8(BirdEntity* this) { super->spriteRendering.b3 = 0; super->spriteOrientation.flipY = 1; super->x.HALF.HI = gRoomControls.scroll_x; - super->y.HALF.HI = gPlayerEntity.y.HALF.HI; + super->y.HALF.HI = gPlayerEntity.base.y.HALF.HI; super->child = NULL; SetEntityPriority(super, 6); InitAnimationForceUpdate(super, 0); SoundReq(0x123); break; case 1: - super->collisionLayer = gPlayerEntity.collisionLayer; + super->collisionLayer = gPlayerEntity.base.collisionLayer; super->speed += 8; if (super->speed > 0x300) { super->speed = 0x300; } - if ((gPlayerEntity.flags & ENT_COLLIDE) && (gMessage.state & MESSAGE_ACTIVE) == 0 && - gPlayerEntity.action != PLAYER_SLEEP && gPlayerEntity.action != PLAYER_BOUNCE && - gPlayerEntity.action != PLAYER_MINISH && gPlayerState.framestate != PL_STATE_CLIMB && + if ((gPlayerEntity.base.flags & ENT_COLLIDE) && (gMessage.state & MESSAGE_ACTIVE) == 0 && + gPlayerEntity.base.action != PLAYER_SLEEP && gPlayerEntity.base.action != PLAYER_BOUNCE && + gPlayerEntity.base.action != PLAYER_MINISH && gPlayerState.framestate != PL_STATE_CLIMB && gPlayerState.framestate != PL_STATE_JUMP && gPlayerState.framestate != PL_STATE_PARACHUTE && - PlayerCanBeMoved() && (EntityInRectRadius(super, &gPlayerEntity, 0xe, 0xe))) { - s32 z = gPlayerEntity.z.HALF.HI - super->z.HALF.HI - 8; - if ((u16)z < 0x20 && gPlayerEntity.health != 0) { + PlayerCanBeMoved() && (EntityInRectRadius(super, &gPlayerEntity.base, 0xe, 0xe))) { + s32 z = gPlayerEntity.base.z.HALF.HI - super->z.HALF.HI - 8; + if ((u16)z < 0x20 && gPlayerEntity.base.health != 0) { pEVar5 = CreateObject(BIRD, 10, 0); if (pEVar5 != NULL) { super->child = pEVar5; @@ -244,8 +244,8 @@ void Bird_Type8(BirdEntity* this) { PutAwayItems(); gPlayerState.swim_state = 0; gPlayerState.jump_status = 0; - gPlayerEntity.flags &= ~0x80; - gPlayerEntity.spriteSettings.draw = 0; + gPlayerEntity.base.flags &= ~0x80; + gPlayerEntity.base.spriteSettings.draw = 0; gPriorityHandler.event_priority = 6; gPauseMenuOptions.disabled = 1; } @@ -254,7 +254,7 @@ void Bird_Type8(BirdEntity* this) { break; default: PausePlayer(); - gPlayerEntity.spriteSettings.draw = 0; + gPlayerEntity.base.spriteSettings.draw = 0; break; } LinearMoveUpdate(super); @@ -262,7 +262,7 @@ void Bird_Type8(BirdEntity* this) { UpdateAnimationSingleFrame(super); pEVar5 = super->child; if (pEVar5 != NULL) { - if (gPlayerEntity.x.HALF.HI < super->x.HALF.HI - 8) { + if (gPlayerEntity.base.x.HALF.HI < super->x.HALF.HI - 8) { super->timer = 0; } @@ -274,7 +274,7 @@ void Bird_Type8(BirdEntity* this) { pEVar5->spriteOrientation.flipY = super->spriteOrientation.flipY; } else { super->timer--; - CopyPosition(&gPlayerEntity, pEVar5); + CopyPosition(&gPlayerEntity.base, pEVar5); } } @@ -308,13 +308,13 @@ void Bird_Type9(BirdEntity* this) { super->spriteOrientation.flipY = 1; SetEntityPriority(super, 6); super->x.HALF.HI = gRoomControls.scroll_x; - super->y.HALF.HI = gPlayerEntity.y.HALF.HI; + super->y.HALF.HI = gPlayerEntity.base.y.HALF.HI; SoundReq(SFX_123); super->spritePriority.b1 = 2; InitAnimationForceUpdate(super, 0); PausePlayer(); } else if (super->action == 1) { - gPlayerEntity.spriteSettings.draw = 0; + gPlayerEntity.base.spriteSettings.draw = 0; child = super->child; if (child != NULL) { PositionRelative(super, child, Q_16_16(-8), 0); @@ -330,8 +330,8 @@ void Bird_Type9(BirdEntity* this) { if (child != NULL) { child->action++; } - gRoomControls.camera_target = &gPlayerEntity; - gPlayerEntity.spriteSettings.draw = 1; + gRoomControls.camera_target = &gPlayerEntity.base; + gPlayerEntity.base.spriteSettings.draw = 1; ResetPlayerAnimationAndAction(); ResetPlayerEventPriority(); gPauseMenuOptions.disabled = 0; @@ -354,7 +354,7 @@ void Bird_Type9(BirdEntity* this) { } void Bird_Type10(BirdEntity* this) { - super->palette.b.b0 = gPlayerEntity.palette.b.b0; + super->palette.b.b0 = gPlayerEntity.base.palette.b.b0; switch (super->action) { case 0: super->action = 1; diff --git a/src/object/board.c b/src/object/board.c index d7bf16d0..dbdcabea 100644 --- a/src/object/board.c +++ b/src/object/board.c @@ -63,10 +63,10 @@ void Board_Action1(BoardEntity* this) { } void sub_08098BE8(BoardEntity* this) { - if ((gPlayerState.flags & PL_MINISH) && sub_08098C30(this, &gPlayerEntity) && PlayerCanBeMoved() && - gPlayerEntity.z.HALF.HI == 0) { + if ((gPlayerState.flags & PL_MINISH) && sub_08098C30(this, &gPlayerEntity.base) && PlayerCanBeMoved() && + gPlayerEntity.base.z.HALF.HI == 0) { gPlayerState.field_0x14 = 1; - sub_0807AAF8(&gPlayerEntity, this->tile); + sub_0807AAF8(&gPlayerEntity.base, this->tile); } } diff --git a/src/object/book.c b/src/object/book.c index 50bf896e..6a516500 100644 --- a/src/object/book.c +++ b/src/object/book.c @@ -110,9 +110,9 @@ void Book_Action1(BookEntity* this) { gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.flags |= PL_BUSY; - gPlayerEntity.x.HALF.LO = 0; - gPlayerEntity.y.HALF.LO = 0; - gPlayerEntity.direction = gPlayerEntity.animationState << 2; + gPlayerEntity.base.x.HALF.LO = 0; + gPlayerEntity.base.y.HALF.LO = 0; + gPlayerEntity.base.direction = gPlayerEntity.base.animationState << 2; EnqueueSFX(SFX_10F); } else { super->timer = 22; @@ -219,7 +219,7 @@ void Book_Action5(BookEntity* this) { } u32 sub_0809B688(Entity* this) { - u32 ret = EntityInRectRadius(this, &gPlayerEntity, 6, 12); + u32 ret = EntityInRectRadius(this, &gPlayerEntity.base, 6, 12); if (ret == 1 && gPlayerState.direction != DirectionSouth) { ret = 0; diff --git a/src/object/bossDoor.c b/src/object/bossDoor.c index 8eb3497e..8502dd14 100644 --- a/src/object/bossDoor.c +++ b/src/object/bossDoor.c @@ -105,7 +105,7 @@ void BossDoor_Action3(BossDoorEntity* this) { if (--super->timer == 0) { if (super->type < 4) { sub_08078AC0(0x40, 0, 1); - gPlayerEntity.direction = super->type << 3; + gPlayerEntity.base.direction = super->type << 3; } DeleteThisEntity(); } diff --git a/src/object/bush.c b/src/object/bush.c index 4cad7205..6e7a08af 100644 --- a/src/object/bush.c +++ b/src/object/bush.c @@ -60,7 +60,7 @@ void Bush_Init(BushEntity* this) { super->gustJarTolerance = gUnk_08120588[super->type].unk_1; super->gustJarFlags = gUnk_08120588[super->type].unk_2; super->speed = 0x80; - super->collisionLayer = gPlayerEntity.collisionLayer; + super->collisionLayer = gPlayerEntity.base.collisionLayer; super->health = 1; super->collisionFlags = 7; super->hitType = 0x6e; diff --git a/src/object/button.c b/src/object/button.c index 2a025542..ad621bc7 100644 --- a/src/object/button.c +++ b/src/object/button.c @@ -171,7 +171,7 @@ Entity* sub_08081D74(ButtonEntity* this) { ent = 0; if (sub_08081E0C(super)) { if ((gPlayerState.flags & PL_CAPTURED) == 0 && (gPlayerState.flags & PL_MINISH) == 0) { - ent = &gPlayerEntity; + ent = &gPlayerEntity.base; } } else { if (gPlayerState.flags & PL_CLONING) { @@ -189,7 +189,7 @@ Entity* sub_08081D74(ButtonEntity* this) { } u32 sub_08081E0C(Entity* this) { - Entity* tmp = &gPlayerEntity; + Entity* tmp = &gPlayerEntity.base; if (tmp->z.HALF.HI != 0 || !PlayerCanBeMoved()) { return 0; } else { @@ -289,7 +289,7 @@ bool32 sub_08081F7C(ButtonEntity* this, u32 r7) { void sub_08081FF8(Entity* this) { u32 direction; u32 i; - if (this->child != &gPlayerEntity) + if (this->child != &gPlayerEntity.base) return; direction = GetFacingDirection(this->child, this); sub_080044AE(this->child, 0x200, direction); diff --git a/src/object/cameraTarget.c b/src/object/cameraTarget.c index 0eaa13ea..f327c414 100644 --- a/src/object/cameraTarget.c +++ b/src/object/cameraTarget.c @@ -150,7 +150,7 @@ void sub_08083A40(Entity* this) { this->spriteSettings.draw = 1; this->action = 2; - if (this->child->x.HALF.HI > gPlayerEntity.x.HALF.HI) { + if (this->child->x.HALF.HI > gPlayerEntity.base.x.HALF.HI) { bVar1 = 0; this->spriteOffsetX = 8; } else { diff --git a/src/object/chestSpawner.c b/src/object/chestSpawner.c index 3b964436..f40a7b1a 100644 --- a/src/object/chestSpawner.c +++ b/src/object/chestSpawner.c @@ -113,14 +113,14 @@ void ChestSpawner_Type2Action2(ChestSpawnerEntity* this) { SetPriorityTimer(30); switch (super->subAction) { case 0: - if (EntityInRectRadius(super, &gPlayerEntity, 0x10, 8)) { + if (EntityInRectRadius(super, &gPlayerEntity.base, 0x10, 8)) { sub_08078AC0(0x10, 0, 0); - gPlayerEntity.direction = 0x10; + gPlayerEntity.base.direction = 0x10; } super->subAction = 1; break; case 1: - if ((super->type == 5) || (gPlayerEntity.action == PLAYER_NORMAL)) { + if ((super->type == 5) || (gPlayerEntity.base.action == PLAYER_NORMAL)) { super->subAction = 2; super->timer = 8; super->subtimer = 0; diff --git a/src/object/cloud.c b/src/object/cloud.c index d1ec3e74..58d34f12 100644 --- a/src/object/cloud.c +++ b/src/object/cloud.c @@ -134,7 +134,7 @@ void sub_0809F69C(CloudEntity* this) { if (--super->timer == 0) { super->timer = 30; super->action = 4; - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; SoundReq(SFX_SECRET_BIG); } } diff --git a/src/object/crenelBeanSprout.c b/src/object/crenelBeanSprout.c index 3b2efb83..384722b2 100644 --- a/src/object/crenelBeanSprout.c +++ b/src/object/crenelBeanSprout.c @@ -53,7 +53,7 @@ void CrenelBeanSprout_Init(CrenelBeanSproutEntity* this) { case 0: if (CheckGlobalFlag(WATERBEAN_OUT)) { if (CheckGlobalFlag(WATERBEAN_PUT) == 0) { - PositionRelative(&gPlayerEntity, super, 0, 0x10000); + PositionRelative(&gPlayerEntity.base, super, 0, 0x10000); SetTile(0x4022, 0xdc, super->collisionLayer); } else { if (CheckLocalFlag(super->type2) == 0) { @@ -79,9 +79,9 @@ void CrenelBeanSprout_Init(CrenelBeanSproutEntity* this) { case 3: if (CheckGlobalFlag(WATERBEAN_OUT)) { if (CheckGlobalFlag(WATERBEAN_PUT) == 0) { - super->spritePriority.b0 = gPlayerEntity.spritePriority.b0 - 1; - *(((u8*)&gPlayerEntity) + 0x79) = tmp; - PositionRelative(&gPlayerEntity, super, 0, -0x180000); + super->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0 - 1; + *(((u8*)&gPlayerEntity.base) + 0x79) = tmp; + PositionRelative(&gPlayerEntity.base, super, 0, -0x180000); } else { DeleteThisEntity(); } @@ -165,7 +165,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) { } else { GetNextFrame(super); } - tmp = gPlayerEntity.animationState & 6; + tmp = gPlayerEntity.base.animationState & 6; this->unk_70 = ((super->x.HALF.HI + (s8)gUnk_08123184[tmp]) & -0x10) | 8; this->unk_72 = ((super->y.HALF.HI + (s8)gUnk_08123184[(tmp) + 1]) & -0x10) | 8; if (sub_080B1AB4(this->unk_70, this->unk_72, super->collisionLayer) == 0x19) { @@ -173,7 +173,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) { } else { gUnk_0200AF00.rActionPlayerState = R_ACTION_NONE; } - PositionRelative(&gPlayerEntity, super, 0, 0x10000); + PositionRelative(&gPlayerEntity.base, super, 0, 0x10000); if (GetTileUnderEntity(super) == 0x19) { RestorePrevTileEntity(0xdc, super->collisionLayer); sub_08096A78(this); diff --git a/src/object/cutsceneMiscObject.c b/src/object/cutsceneMiscObject.c index c1d5cc1e..68f86a77 100644 --- a/src/object/cutsceneMiscObject.c +++ b/src/object/cutsceneMiscObject.c @@ -184,7 +184,7 @@ void sub_08094B80(CutsceneMiscObjectEntity* this) { void sub_08094B94(CutsceneMiscObjectEntity* this) { Entity* e = CreateObject(CUTSCENE_MISC_OBJECT, 0x22, 0); if (e != NULL) { - CopyPosition(&gPlayerEntity, e); + CopyPosition(&gPlayerEntity.base, e); e->z.HALF.HI = -48; ((CutsceneMiscObjectEntity*)e)->ctx = StartCutscene(e, &script_CutsceneMiscObjectTheLittleHat); CreateDust(e); @@ -196,7 +196,7 @@ void sub_08094B94(CutsceneMiscObjectEntity* this) { void sub_08094BE0(Entity* this) { Entity* e = FindEntity(OBJECT, CUTSCENE_MISC_OBJECT, 6, 0x22, 0); if (e != NULL) { - CopyPosition(&gPlayerEntity, e); + CopyPosition(&gPlayerEntity.base, e); e->z.HALF.HI = -12; e->y.HALF.HI++; e->collisionLayer = 2; @@ -412,7 +412,7 @@ void CutsceneMiscObject_Type6(CutsceneMiscObjectEntity* this) { } break; case 3: - if (gPlayerEntity.action != PLAYER_EMPTYBOTTLE) { + if (gPlayerEntity.base.action != PLAYER_EMPTYBOTTLE) { super->action = 4; #ifndef EU if (!CheckGlobalFlag(BIN_DOGFOOD)) { @@ -1051,7 +1051,7 @@ void sub_08095D30(CutsceneMiscObjectEntity* this, u32 a2) { void sub_08095D54(CutsceneMiscObjectEntity* this, ScriptExecutionContext* ctx) { Entity* e = CreateObject(CUTSCENE_MISC_OBJECT, 0x1C, 0); if (e != NULL) { - CopyPosition(&gPlayerEntity, e); + CopyPosition(&gPlayerEntity.base, e); e->collisionLayer = 2; ((CutsceneMiscObjectEntity*)e)->ctx = StartCutscene(e, (u16*)ctx->intVariable); } @@ -1152,7 +1152,7 @@ void CutsceneMiscObject_Type31(CutsceneMiscObjectEntity* this) { break; } ChangeObjPalette(super, pal); - if ((gPlayerEntity.frame & 1) == 0) { + if ((gPlayerEntity.base.frame & 1) == 0) { local->anim = 0x8BF; super->timer = 52; super->subtimer = -75; @@ -1161,16 +1161,16 @@ void CutsceneMiscObject_Type31(CutsceneMiscObjectEntity* this) { super->timer = 85; super->subtimer = -42; } - CopyPosition(&gPlayerEntity, super); + CopyPosition(&gPlayerEntity.base, super); super->spritePriority.b0 = 3; } - if (gPlayerEntity.frame & 0x10) { - gPlayerEntity.frame &= ~0x10; + if (gPlayerEntity.base.frame & 0x10) { + gPlayerEntity.base.frame &= ~0x10; SoundReq(468); } - if ((u16)gPlayerEntity.spriteIndex != local->anim >> 8 || gPlayerEntity.animIndex != (u8)local->anim) + if ((u16)gPlayerEntity.base.spriteIndex != local->anim >> 8 || gPlayerEntity.base.animIndex != (u8)local->anim) DeleteThisEntity(); - tmp = gPlayerEntity.frameIndex - super->timer + super->subtimer; + tmp = gPlayerEntity.base.frameIndex - super->timer + super->subtimer; if (tmp != super->frameIndex) { super->frameIndex = tmp; sub_080042D0(super, super->frameIndex, (u16)super->spriteIndex); diff --git a/src/object/dirtParticle.c b/src/object/dirtParticle.c index f6bdf51c..827456c2 100644 --- a/src/object/dirtParticle.c +++ b/src/object/dirtParticle.c @@ -90,7 +90,7 @@ void DirtParticle_Init(DirtParticleEntity* this) { } super->x.HALF.HI += tmp; super->y.HALF.HI += tmp; - super->collisionLayer = gPlayerEntity.collisionLayer; + super->collisionLayer = gPlayerEntity.base.collisionLayer; InitializeAnimation(super, 10); return; case 1: diff --git a/src/object/doubleBookshelf.c b/src/object/doubleBookshelf.c index d96a80cb..cbc27c93 100644 --- a/src/object/doubleBookshelf.c +++ b/src/object/doubleBookshelf.c @@ -145,7 +145,7 @@ void sub_0809B234(DoubleBookshelfEntity* this) { } void sub_0809B274(DoubleBookshelfEntity* this) { - Entity* player = &gPlayerEntity; + Entity* player = &gPlayerEntity.base; switch (this->unk_84) { case 0: if (player->y.HALF.HI + 0x14 >= super->y.HALF.HI) { diff --git a/src/object/evilSpirit.c b/src/object/evilSpirit.c index cb42b88b..a09392a4 100644 --- a/src/object/evilSpirit.c +++ b/src/object/evilSpirit.c @@ -86,7 +86,8 @@ void EvilSpirit_Action1(EvilSpiritEntity* this) { sub_080045DA(super->parent->x.WORD - super->x.WORD, super->parent->y.WORD - super->y.WORD) ^ 0x80; } else { super->speed = 0x600; - dir = sub_080045DA(gPlayerEntity.x.WORD - super->x.WORD, gPlayerEntity.y.WORD - super->y.WORD) ^ 0x80; + dir = sub_080045DA(gPlayerEntity.base.x.WORD - super->x.WORD, gPlayerEntity.base.y.WORD - super->y.WORD) ^ + 0x80; if (dir != super->direction) { if ((u8)(dir - super->direction) > 0x80) { super->direction += 3; @@ -94,7 +95,7 @@ void EvilSpirit_Action1(EvilSpiritEntity* this) { super->direction -= 3; } } - if ((gPlayerEntity.animationState & 2) == 0) { + if ((gPlayerEntity.base.animationState & 2) == 0) { this->unk76 = this->unk7c + 0x40; } else { this->unk76 = this->unk7c - 0x20; @@ -112,7 +113,7 @@ void EvilSpirit_Action1(EvilSpiritEntity* this) { super->direction++; super->gustJarTolerance--; this->unk7f = 1; - if ((gPlayerEntity.animationState & 2) == 0) { + if ((gPlayerEntity.base.animationState & 2) == 0) { this->unk76 = this->unk7c + 0x10; } else { this->unk76 = this->unk7c - 0x20; @@ -183,7 +184,7 @@ void EvilSpirit_Action3(EvilSpiritEntity* this) { super->gustJarTolerance--; this->unk7f = 1; - if ((gPlayerEntity.animationState & 2) == 0) { + if ((gPlayerEntity.base.animationState & 2) == 0) { this->unk76 = this->unk7c + 0x10; } else { this->unk76 = this->unk7c - 0x20; diff --git a/src/object/ezloCap.c b/src/object/ezloCap.c index 8cb07487..de1beb00 100644 --- a/src/object/ezloCap.c +++ b/src/object/ezloCap.c @@ -55,12 +55,12 @@ void EzloCap(EzloCapEntity* this) { void EzloCap_Type0Init(EzloCapEntity* this) { super->updatePriority = 6; - super->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; - super->spritePriority.b0 = gPlayerEntity.spritePriority.b0 - 1; - super->palette.b.b0 = gPlayerEntity.palette.b.b0; - super->collisionLayer = gPlayerEntity.collisionLayer; + super->spriteRendering.b3 = gPlayerEntity.base.spriteRendering.b3; + super->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0 - 1; + super->palette.b.b0 = gPlayerEntity.base.palette.b.b0; + super->collisionLayer = gPlayerEntity.base.collisionLayer; super->action = 1; - if (gPlayerEntity.animationState == 2) { + if (gPlayerEntity.base.animationState == 2) { super->spriteSettings.flipX = 1; } LoadSwapGFX(super, 1, 3); @@ -78,7 +78,7 @@ void EzloCap_Type0Init(EzloCapEntity* this) { void EzloCap_Type0Action1(EzloCapEntity* this) { static const u8 gUnk_0811F16C[] = { 4, 0, 2, 6, 10, 8, 9, 5, 1, 0, 0, 0 }; - u32 tmp = gPlayerEntity.palette.b.b0; + u32 tmp = gPlayerEntity.base.palette.b.b0; super->palette.b.b0 = tmp; if ((gMessage.state & MESSAGE_ACTIVE) == 0) { DeleteEntity(super); @@ -160,8 +160,8 @@ void EzloCap_Type1Action1(EzloCapEntity* this) { void EzloCap_ScriptedInit(EzloCapEntity* this) { super->updatePriority = 2; - super->palette.b.b0 = gPlayerEntity.palette.b.b0; - super->collisionLayer = gPlayerEntity.collisionLayer; + super->palette.b.b0 = gPlayerEntity.base.palette.b.b0; + super->collisionLayer = gPlayerEntity.base.collisionLayer; super->spritePriority.b1 = 3; super->spriteSettings.shadow = 1; super->action = 1; @@ -170,7 +170,7 @@ void EzloCap_ScriptedInit(EzloCapEntity* this) { this->unk_82 = 0; ExecuteScript(super, this->unk_84); sub_08082D20(this, this->unk_84); - if (gPlayerEntity.animationState == 2) { + if (gPlayerEntity.base.animationState == 2) { super->spriteSettings.flipX = 1; } sub_08082C5C(this); diff --git a/src/object/ezloCapFlying.c b/src/object/ezloCapFlying.c index 21a7faff..91c197a0 100644 --- a/src/object/ezloCapFlying.c +++ b/src/object/ezloCapFlying.c @@ -5,7 +5,6 @@ * @brief Ezlo Cap Flying object */ #include "functions.h" -#include "new_player.h" #include "object.h" typedef struct { @@ -31,7 +30,7 @@ void EzloCapFlying(EzloCapFlyingEntity* this) { }; if ((gPlayerState.flags & PL_PARACHUTE) == 0) { if (super->type == 0) { - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; } DeleteThisEntity(); } @@ -41,7 +40,7 @@ void EzloCapFlying(EzloCapFlyingEntity* this) { void EzloCapFlying_Init(EzloCapFlyingEntity* this) { super->action = 1; super->lastFrameIndex = 0xff; - super->palette.b.b0 = gPlayerEntity.palette.b.b0; + super->palette.b.b0 = gPlayerEntity.base.palette.b.b0; if (super->type == 0) { gRoomControls.camera_target = super; super->spriteRendering.b0 = 3; @@ -65,7 +64,7 @@ void EzloCapFlying_Action1Type0(EzloCapFlyingEntity* this) { if ((s16)this->unk_6e < 0) { this->unk_6e = -this->unk_6e; } - switch (gPlayerEntity.subAction) { + switch (gPlayerEntity.base.subAction) { case 1: this->unk_72 -= 4; break; @@ -103,10 +102,10 @@ void EzloCapFlying_Action1Type0(EzloCapFlyingEntity* this) { sub_080936C8(this); break; } - tmp = gPlayerEntity.animationState & 2; + tmp = gPlayerEntity.base.animationState & 2; if (tmp != 0) { super->frameIndex = 1; - if (gPlayerEntity.animationState == 2) { + if (gPlayerEntity.base.animationState == 2) { this->unk_6e = -this->unk_6e; } } else { @@ -116,32 +115,32 @@ void EzloCapFlying_Action1Type0(EzloCapFlyingEntity* this) { super->lastFrameIndex = super->frameIndex; sub_080042D0(super, super->frameIndex, super->spriteIndex); } - CopyPosition(&gPlayerEntity, super); + CopyPosition(&gPlayerEntity.base, super); - super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; - super->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; + super->spriteOrientation.flipY = gPlayerEntity.base.spriteOrientation.flipY; + super->spriteRendering.b3 = gPlayerEntity.base.spriteRendering.b3; sub_0806FCF4(super, this->unk_72, 10, 2); SetAffineInfo(super, this->unk_6e, this->unk_72, 0); - sub_0806FEBC(&gPlayerEntity, 1, super); + sub_0806FEBC(&gPlayerEntity.base, 1, super); } void EzloCapFlying_Action1Type1(EzloCapFlyingEntity* this) { - super->frameIndex = ((gPlayerEntity.direction + (gPlayerEntity.direction >> 1)) >> 2) + 2; + super->frameIndex = ((gPlayerEntity.base.direction + (gPlayerEntity.base.direction >> 1)) >> 2) + 2; if (super->frameIndex != super->lastFrameIndex) { super->lastFrameIndex = super->frameIndex; sub_080042D0(super, super->frameIndex, super->spriteIndex); } - CopyPosition(&gPlayerEntity, super); - super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; - super->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; + CopyPosition(&gPlayerEntity.base, super); + super->spriteOrientation.flipY = gPlayerEntity.base.spriteOrientation.flipY; + super->spriteRendering.b3 = gPlayerEntity.base.spriteRendering.b3; sub_0806FCF4(super, ((EzloCapFlyingEntity*)super->parent)->unk_72, 0x18, 0); super->spriteOffsetY = -super->spriteOffsetY; - sub_0806FEBC(&gPlayerEntity, 0, super); + sub_0806FEBC(&gPlayerEntity.base, 0, super); } void sub_080936C8(EzloCapFlyingEntity* this) { - s32 tmp = gNewPlayerEntity.unk_7c; - this->unk_76 = 0x138 - (gNewPlayerEntity.unk_7c >> 2); + s32 tmp = gPlayerEntity.unk_7c.WORD_U; + this->unk_76 = 0x138 - (gPlayerEntity.unk_7c.WORD_U >> 2); this->unk_74 = 8 - (tmp / 0x3c); if (super->timer == 0) { if (this->unk_76 < this->unk_6e) { diff --git a/src/object/fairy.c b/src/object/fairy.c index 1389f1fa..871da3dd 100644 --- a/src/object/fairy.c +++ b/src/object/fairy.c @@ -181,7 +181,7 @@ void Fairy_Action3(FairyEntity* this) { } else { CopyPosition(super->child, super); super->z.HALF.HI--; - if (IsColliding(super, &gPlayerEntity)) { + if (IsColliding(super, &gPlayerEntity.base)) { sub_0808DB2C(this); } } @@ -245,8 +245,8 @@ void sub_0808DAD0(FairyEntity* this) { super->spriteSettings.draw = 1; super->spritePriority.b1 = 2; super->spriteOffsetY = -5; - super->child = &gPlayerEntity; - CopyPosition(&gPlayerEntity, super); + super->child = &gPlayerEntity.base; + CopyPosition(&gPlayerEntity.base, super); } void sub_0808DB2C(FairyEntity* this) { @@ -254,5 +254,5 @@ void sub_0808DB2C(FairyEntity* this) { super->subAction = 0; super->flags |= ENT_COLLIDE; super->flags2 = 1; - CopyPosition(&gPlayerEntity, super); + CopyPosition(&gPlayerEntity.base, super); } diff --git a/src/object/fan.c b/src/object/fan.c index bf9e5d27..f786981a 100644 --- a/src/object/fan.c +++ b/src/object/fan.c @@ -114,7 +114,7 @@ void sub_0809EE44(FanEntity* this) { uVar4 = (super->frame & 7); super->speed = this->unk7e << uVar4; if (uVar4 != 0) { - pEVar1 = &gPlayerEntity; + pEVar1 = &gPlayerEntity.base; if (sub_0809EF78(this, pEVar1)) { if (PlayerCanBeMoved()) { sub_08079E58(super->speed, super->direction); @@ -135,8 +135,8 @@ void sub_0809EE44(FanEntity* this) { bVar3 = 1; break; case 0x3: - if (pEVar1->x.HALF.HI != gPlayerEntity.x.HALF.HI || - pEVar1->y.HALF.HI != gPlayerEntity.y.HALF.HI) + if (pEVar1->x.HALF.HI != gPlayerEntity.base.x.HALF.HI || + pEVar1->y.HALF.HI != gPlayerEntity.base.y.HALF.HI) bVar3 = 1; break; break; diff --git a/src/object/figurineDevice.c b/src/object/figurineDevice.c index b3aadfaf..8572dc38 100644 --- a/src/object/figurineDevice.c +++ b/src/object/figurineDevice.c @@ -717,7 +717,7 @@ void FigurineDevice_NoFigurinesLeftMessage(void) { gMessage.rupees = 5; } #ifndef EU - gPlayerEntity.animationState = 6; + gPlayerEntity.base.animationState = 6; #endif } @@ -794,9 +794,9 @@ void sub_0808861C(FigurineDeviceEntity* this, ScriptExecutionContext* context) { // If I understand this correctly then it checks if the player is at the lever context->condition = CheckPlayerInRegion(168, 84, 12, 8); #ifdef JP - if ((gPlayerEntity.animationState != 0)) { + if ((gPlayerEntity.base.animationState != 0)) { #else - if ((gPlayerEntity.animationState != 0) || (gPlayerEntity.z.HALF.HI != 0)) { + if ((gPlayerEntity.base.animationState != 0) || (gPlayerEntity.base.z.HALF.HI != 0)) { #endif context->condition = 0; } @@ -806,7 +806,7 @@ void sub_0808861C(FigurineDeviceEntity* this, ScriptExecutionContext* context) { #if !defined(JP) void sub_08088658(FigurineDeviceEntity* this, ScriptExecutionContext* context) { context->condition = CheckPlayerInRegion(120, 120, 16, 8); // And this is if the player is at the door - if (gPlayerEntity.z.HALF.HI != 0) { + if (gPlayerEntity.base.z.HALF.HI != 0) { context->condition = 0; } gActiveScriptInfo.flags |= 1; diff --git a/src/object/floatingPlatform.c b/src/object/floatingPlatform.c index 5da525f0..3a260350 100644 --- a/src/object/floatingPlatform.c +++ b/src/object/floatingPlatform.c @@ -63,9 +63,9 @@ bool32 sub_08086168(FloatingPlatformEntity* this) { const u8* ptr; ptr = gUnk_08120658 + super->type * 2; - if (((EntityInRectRadius(super, &gPlayerEntity, ptr[0], ptr[1])) && PlayerCanBeMoved())) { + if (((EntityInRectRadius(super, &gPlayerEntity.base, ptr[0], ptr[1])) && PlayerCanBeMoved())) { gPlayerState.field_0x14 = 1; - if (gPlayerEntity.z.HALF.HI == 0) { + if (gPlayerEntity.base.z.HALF.HI == 0) { return TRUE; } else { return FALSE; diff --git a/src/object/fourElements.c b/src/object/fourElements.c index 0968a61c..b8d9ea50 100644 --- a/src/object/fourElements.c +++ b/src/object/fourElements.c @@ -107,7 +107,7 @@ void FourElements_Action3(FourElementsEntity* this) { if (super->timer != 0) { sub_080A0424(this); if (--super->timer == 0) { - SetEntityPriority(&gPlayerEntity, 0); + SetEntityPriority(&gPlayerEntity.base, 0); } } else { RequestPriorityDuration(NULL, 60); diff --git a/src/object/frozenOctorok.c b/src/object/frozenOctorok.c index 800f77fc..be88eb5f 100644 --- a/src/object/frozenOctorok.c +++ b/src/object/frozenOctorok.c @@ -386,7 +386,7 @@ void FrozenOctorok_Action1SubAction6(FrozenOctorokEntity* this) { LinearMoveUpdate(super); if ((gRoomControls.origin_y + 0x1c8) < super->y.HALF.HI) { gRoomControls.scrollSpeed = 4; - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; SetLocalFlag(0x9b); DeleteEntity(super->parent); DeleteEntity(&this->heap->mouthObject->base); diff --git a/src/object/furniture.c b/src/object/furniture.c index 7a816166..31d06f14 100644 --- a/src/object/furniture.c +++ b/src/object/furniture.c @@ -309,7 +309,8 @@ static void FurnitureInit(FurnitureEntity* this) { static void FurnitureUpdate(FurnitureEntity* this) { switch (this->flags & 0x7FFF) { case 0x1: - if (gPlayerEntity.y.HALF.HI < super->y.HALF.HI || gPlayerEntity.y.HALF.HI > super->y.HALF.HI + 24) { + if (gPlayerEntity.base.y.HALF.HI < super->y.HALF.HI || + gPlayerEntity.base.y.HALF.HI > super->y.HALF.HI + 24) { super->spriteRendering.b3 = 2; } else { super->spriteRendering.b3 = 3; @@ -337,16 +338,16 @@ static void FurnitureUpdate(FurnitureEntity* this) { } break; case 0x80: - if (gPlayerEntity.y.HALF.HI < super->y.HALF.HI + 8) { + if (gPlayerEntity.base.y.HALF.HI < super->y.HALF.HI + 8) { if (gPlayerState.floor_type != SURFACE_LADDER && GetTileTypeByEntity(super) == 0x4017) { SetTile(0x4026, this->tile, super->collisionLayer); SetTile(0x403D, this->tile - 64, super->collisionLayer); SetTile(0x403D, this->tile - 128, super->collisionLayer); } } else { - if (gPlayerEntity.collisionLayer & 2) { - gPlayerEntity.collisionLayer = 1; - UpdateSpriteForCollisionLayer(&gPlayerEntity); + if (gPlayerEntity.base.collisionLayer & 2) { + gPlayerEntity.base.collisionLayer = 1; + UpdateSpriteForCollisionLayer(&gPlayerEntity.base); } if (GetTileTypeByEntity(super) != 0x4017) { SetTile(0x4017, this->tile, super->collisionLayer); diff --git a/src/object/giantTwig.c b/src/object/giantTwig.c index bc936e18..62deab7a 100644 --- a/src/object/giantTwig.c +++ b/src/object/giantTwig.c @@ -102,7 +102,7 @@ void GiantTwig_Type0Init(GiantTwigEntity* this) { void GiantTwig_Type0Idle(GiantTwigEntity* this) { if (super->type == 0) { - if (gPlayerEntity.y.HALF.HI < super->y.HALF.HI + 0x20) { + if (gPlayerEntity.base.y.HALF.HI < super->y.HALF.HI + 0x20) { super->spriteRendering.b3 = 1; } else { super->spriteRendering.b3 = 2; diff --git a/src/object/gleerokParticle.c b/src/object/gleerokParticle.c index 03ed1d2f..23bd5d17 100644 --- a/src/object/gleerokParticle.c +++ b/src/object/gleerokParticle.c @@ -77,7 +77,7 @@ void GleerokParticle_Init(GleerokParticleEntity* this) { gRoomControls.camera_target = super; } else { if (--this->unk78 == -1) { - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; DeleteThisEntity(); } } diff --git a/src/object/graveyardKey.c b/src/object/graveyardKey.c index 84f618df..699bb95a 100644 --- a/src/object/graveyardKey.c +++ b/src/object/graveyardKey.c @@ -92,7 +92,7 @@ void GraveyardKey_Init(Entity* this, const struct_gUnk_08123FB0* param_2) { if ((this->direction & DIR_NOT_MOVING_CHECK)) { dir = this->direction; if (dir == (DIR_NOT_MOVING_CHECK | 0x1)) { - this->direction = (((gPlayerEntity.animationState * 4 + (Random() & 3)) - 2) & 0x1f) ^ DirectionSouth; + this->direction = (((gPlayerEntity.base.animationState * 4 + (Random() & 3)) - 2) & 0x1f) ^ DirectionSouth; } } UpdateSpriteForCollisionLayer(this); @@ -130,7 +130,7 @@ void GraveyardKey_Action2(Entity* this, const struct_gUnk_08123FB0* param_2) { this->zVelocity = param_2->unk14 << 3; } else { this->action++; - this->collisionLayer = gPlayerEntity.collisionLayer; + this->collisionLayer = gPlayerEntity.base.collisionLayer; UpdateSpriteForCollisionLayer(this); if (param_2->funcEnt != NULL) { param_2->funcEnt(this); @@ -177,13 +177,14 @@ void sub_0809D91C(Entity* this) { bool32 sub_0809D93C(Entity* this, const struct_gUnk_08123FB0* param_2) { u32 uVar1; - if (gPlayerEntity.action == PLAYER_BOUNCE && ((param_2->unk0c >> gPlayerEntity.animationState & 1) != 0)) { - uVar1 = (gPlayerEntity.x.HALF.HI - this->x.HALF.HI) + param_2->unk08 + param_2->unk0a; + if (gPlayerEntity.base.action == PLAYER_BOUNCE && + ((param_2->unk0c >> gPlayerEntity.base.animationState & 1) != 0)) { + uVar1 = (gPlayerEntity.base.x.HALF.HI - this->x.HALF.HI) + param_2->unk08 + param_2->unk0a; if (param_2->unk0a * 2 <= (u16)uVar1) { return 0; } - uVar1 = (gPlayerEntity.y.HALF.HI - (this->y.HALF.HI + param_2->y)) + param_2->unk09 + param_2->unk0b; + uVar1 = (gPlayerEntity.base.y.HALF.HI - (this->y.HALF.HI + param_2->y)) + param_2->unk09 + param_2->unk0b; if (param_2->unk0b * 2 > (u16)uVar1) { return 1; } diff --git a/src/object/greatFairy.c b/src/object/greatFairy.c index 376f931e..3099571c 100644 --- a/src/object/greatFairy.c +++ b/src/object/greatFairy.c @@ -65,12 +65,12 @@ void GreatFairy(GreatFairyEntity* this) { void GreatFairy_CallBehavior(GreatFairyEntity* this) { GreatFairy_Behaviors[super->action](this); - if ((gPlayerEntity.y.HALF.HI - gRoomControls.origin_y) < 168) { + if ((gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y) < 168) { gRoomControls.camera_target = super; gRoomControls.scrollSpeed = 2; } else { - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; gRoomControls.scrollSpeed = 2; } } @@ -541,8 +541,8 @@ void sub_08087424(GreatFairyEntity* this, ScriptExecutionContext* context) { ResetPlayerAnimationAndAction(); ent = CreateObject(THUNDERBOLT, 0, 0); if (ent != NULL) { - ent->parent = &gPlayerEntity; - CopyPosition(&gPlayerEntity, ent); + ent->parent = &gPlayerEntity.base; + CopyPosition(&gPlayerEntity.base, ent); SetEntityPriority(ent, PRIO_MESSAGE); } diff --git a/src/object/gustJarParticle.c b/src/object/gustJarParticle.c index b55e2d16..afbc0aa1 100644 --- a/src/object/gustJarParticle.c +++ b/src/object/gustJarParticle.c @@ -25,10 +25,10 @@ void GustJarParticle(Entity* this) { void GustJarParticle_Init(Entity* this) { this->action = 1; this->speed = 0x80; - this->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; - this->spritePriority.b0 = gPlayerEntity.spritePriority.b0; - this->collisionLayer = gPlayerEntity.collisionLayer; - this->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; + this->spriteRendering.b3 = gPlayerEntity.base.spriteRendering.b3; + this->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0; + this->collisionLayer = gPlayerEntity.base.collisionLayer; + this->spriteOrientation.flipY = gPlayerEntity.base.spriteOrientation.flipY; this->type = Random() & 1; InitializeAnimation(this, 0x11); } diff --git a/src/object/gyorgBossObject.c b/src/object/gyorgBossObject.c index 0197a246..2de64ed0 100644 --- a/src/object/gyorgBossObject.c +++ b/src/object/gyorgBossObject.c @@ -228,7 +228,7 @@ void GyorgBossObject_FemalePhase4(GyorgBossObjectEntity* this) { } this->unk_6c = 0; gRoomTransition.field_0x39 = 0; - if (PlayerCanBeMoved() && gPlayerEntity.z.HALF.HI == 0) { + if (PlayerCanBeMoved() && gPlayerEntity.base.z.HALF.HI == 0) { super->action = 9; super->timer = 0; super->subtimer = 240; @@ -236,7 +236,7 @@ void GyorgBossObject_FemalePhase4(GyorgBossObjectEntity* this) { super->direction = 0; super->speed = 0x60; gPlayerState.flags &= ~PL_GYORG_FIGHT; - CopyPosition(&gPlayerEntity, super); + CopyPosition(&gPlayerEntity.base, super); gRoomControls.camera_target = super; SetPlayerControl(2); } @@ -463,7 +463,7 @@ void sub_080A1FF0(GyorgBossObjectEntity* this) { } } if (this->unk_7b) { - if (EntityWithinDistance(&gPlayerEntity, gRoomControls.origin_x + 0x200, gRoomControls.origin_y + 0x210, + if (EntityWithinDistance(&gPlayerEntity.base, gRoomControls.origin_x + 0x200, gRoomControls.origin_y + 0x210, 0x100)) { if (super->timer == 0) { super->timer = 120; @@ -482,7 +482,7 @@ u32 sub_080A20B8(GyorgBossObjectEntity* this, GyorgMaleEntity* other) { if (other == NULL) { return 1; } - if (PlayerCanBeMoved() && gPlayerEntity.z.HALF.HI == 0) { + if (PlayerCanBeMoved() && gPlayerEntity.base.z.HALF.HI == 0) { return other->unk_7c == 0 && gPlayerState.field_0x14 != 0; } return 0; diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c index 676ad461..79ecf0d8 100644 --- a/src/object/houseDoorExterior.c +++ b/src/object/houseDoorExterior.c @@ -182,7 +182,7 @@ void sub_0808692C(HouseDoorExteriorEntity* this) { static u8 sub_08086954(HouseDoorExteriorEntity* this) { if (sub_0800445C(super)) { - if (GetAnimationStateInRectRadius(super, 6, 20) >= 0 && gPlayerEntity.animationState == 0 && + if (GetAnimationStateInRectRadius(super, 6, 20) >= 0 && gPlayerEntity.base.animationState == 0 && (u16)gPlayerState.playerInput.heldInput == INPUT_UP && gPlayerState.jump_status == 0) { super->timer--; } diff --git a/src/object/houseDoorInterior.c b/src/object/houseDoorInterior.c index 75b2dd27..f2a51b32 100644 --- a/src/object/houseDoorInterior.c +++ b/src/object/houseDoorInterior.c @@ -91,7 +91,8 @@ void HouseDoorInterior_Action1(HouseDoorInteriorEntity* this) { if (sub_0800445C(super) && this->unk7d == 0) { ptr = gUnk_081227CC + super->type2; if (GetAnimationStateInRectRadius(super, ptr->x, ptr->y) >= 0 && - ptr->animationState == gPlayerEntity.animationState && gPlayerState.playerInput.heldInput & ptr->unk2) { + ptr->animationState == gPlayerEntity.base.animationState && + gPlayerState.playerInput.heldInput & ptr->unk2) { --super->timer; } } else { diff --git a/src/object/itemForSale.c b/src/object/itemForSale.c index fc67ff26..0b99381d 100644 --- a/src/object/itemForSale.c +++ b/src/object/itemForSale.c @@ -10,7 +10,6 @@ #include "hitbox.h" #include "kinstone.h" #include "message.h" -#include "new_player.h" typedef struct { u8 before[0x20]; @@ -92,7 +91,7 @@ void ItemForSale_Action1(ItemForSaleEntity* this) { PausePlayer(); ResetActiveItems(); gPlayerState.heldObject = 4; - gNewPlayerEntity.unk_74 = super; + gPlayerEntity.unk_74 = super; gUnk_0200AF00.rActionPlayerState = R_ACTION_DROP; MessageClose(); } @@ -104,8 +103,8 @@ void ItemForSale_Action2(ItemForSaleEntity* this) { void* ptr; gUnk_0200AF00.rActionPlayerState = R_ACTION_DROP; - super->spriteSettings.draw = gPlayerEntity.spriteSettings.draw; - if ((gPlayerState.heldObject == 0) || (super != gNewPlayerEntity.unk_74)) { + super->spriteSettings.draw = gPlayerEntity.base.spriteSettings.draw; + if ((gPlayerState.heldObject == 0) || (super != gPlayerEntity.unk_74)) { sub_080819B4(this); } else { ptr = sub_080784E4(); @@ -130,7 +129,7 @@ void sub_080819B4(ItemForSaleEntity* this) { DeleteThisEntity(); } gPlayerState.heldObject = 0; - gNewPlayerEntity.unk_74 = 0; + gPlayerEntity.unk_74 = 0; ptr = &gUnk_0200AF00; gRoomVars.shopItemType = 0; ptr->rActionInteractObject = R_ACTION_NONE; @@ -141,7 +140,7 @@ void sub_080819B4(ItemForSaleEntity* this) { super->z.WORD = 0; super->action = 1; super->subAction = 0; - super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; + super->spriteOrientation.flipY = gPlayerEntity.base.spriteOrientation.flipY; super->collisionLayer = 1; super->spritePriority.b0 = 4; UpdateSpriteForCollisionLayer(super); diff --git a/src/object/itemOnGround.c b/src/object/itemOnGround.c index f3f6a62f..edb631a2 100644 --- a/src/object/itemOnGround.c +++ b/src/object/itemOnGround.c @@ -187,7 +187,7 @@ void sub_080810FC(ItemOnGroundEntity* this) { super->subAction = 0; COLLISION_ON(super); super->flags2 = 0x11; - CopyPosition(&gPlayerEntity, super); + CopyPosition(&gPlayerEntity.base, super); } } @@ -295,10 +295,10 @@ void sub_080812A8(ItemOnGroundEntity* this) { void sub_080812E8(ItemOnGroundEntity* this) { PlayerState* playerState = &gPlayerState; #ifdef EU - if ((playerState->swim_state & 0x80) && IsColliding(super, &gPlayerEntity)) { + if ((playerState->swim_state & 0x80) && IsColliding(super, &gPlayerEntity.base)) { #else if ((playerState->swim_state & 0x80) && (playerState->flags & PL_MINISH) == 0 && - IsColliding(super, &gPlayerEntity)) { + IsColliding(super, &gPlayerEntity.base)) { #endif sub_080810FC(this); } @@ -314,7 +314,7 @@ void ItemOnGround_Action3(ItemOnGroundEntity* this) { } else { CopyPosition(other, super); super->z.HALF.HI--; - other = &gPlayerEntity; + other = &gPlayerEntity.base; if (IsColliding(super, other)) { sub_080810FC(this); } @@ -481,7 +481,7 @@ void sub_08081598(ItemOnGroundEntity* this) { super->spriteSettings.draw = 1; super->spritePriority.b1 = 2; super->spritePriority.b0 = 3; - super->child = &gPlayerEntity; + super->child = &gPlayerEntity.base; CopyPosition(super->child, super); super->z.HALF.HI -= 4; if (super->type != 0x5F && sub_08081420(this)) { diff --git a/src/object/keyStealingTakkuri.c b/src/object/keyStealingTakkuri.c index de25fd6a..c5a8bdf3 100644 --- a/src/object/keyStealingTakkuri.c +++ b/src/object/keyStealingTakkuri.c @@ -169,7 +169,7 @@ void KeyStealingTakkuri_Type5_Action1(KeyStealingTakkuriEntity* this) { super->zVelocity = Q_16_16(1.0); } else { super->action++; - super->collisionLayer = gPlayerEntity.collisionLayer; + super->collisionLayer = gPlayerEntity.base.collisionLayer; UpdateSpriteForCollisionLayer(super); } SoundReq(SFX_RUPEE_BOUNCE); @@ -392,7 +392,7 @@ void sub_0809E0A0(KeyStealingTakkuriEntity* this) { obj->parent = super; super->child = obj; super->subtimer = 0; - CopyPosition(&gPlayerEntity, obj); + CopyPosition(&gPlayerEntity.base, obj); obj->z.HALF.HI = -8; } } @@ -414,7 +414,7 @@ void sub_0809E0D4(KeyStealingTakkuriEntity* this, ScriptExecutionContext* contex return; } } else { - entity = &gPlayerEntity; + entity = &gPlayerEntity.base; } context->unk_18++; sub_0807DEDC(super, context, entity->x.HALF.HI, entity->y.HALF.HI); @@ -475,7 +475,8 @@ void sub_0809E1F0(KeyStealingTakkuriEntity* this) { } void sub_0809E210(KeyStealingTakkuriEntity* this) { - gPlayerEntity.animationState = GetAnimationStateForDirection8(GetFacingDirection(&gPlayerEntity, super)) & 0xfe; + gPlayerEntity.base.animationState = + GetAnimationStateForDirection8(GetFacingDirection(&gPlayerEntity.base, super)) & 0xfe; gPlayerState.animation = ANIM_DEFAULT; } @@ -504,8 +505,8 @@ u32 sub_0809E2C4(KeyStealingTakkuriEntity* this, u32 param_2) { s32 roomY; ptr = &gUnk_08124178[param_2 * 2]; - roomX = gPlayerEntity.x.HALF.HI - (gRoomControls.origin_x + ptr[0]); - roomY = gPlayerEntity.y.HALF.HI - (gRoomControls.origin_y + ptr[1]); + roomX = gPlayerEntity.base.x.HALF.HI - (gRoomControls.origin_x + ptr[0]); + roomY = gPlayerEntity.base.y.HALF.HI - (gRoomControls.origin_y + ptr[1]); tmp = gUnk_08124158; counter = 0; while (counter < 4) { @@ -515,7 +516,7 @@ u32 sub_0809E2C4(KeyStealingTakkuriEntity* this, u32 param_2) { uVar1 = roomY - tmp->unk_2 + tmp->unk_5; uVar2 = tmp->unk_5 * 2; if (uVar2 > (u16)uVar1) { - if (tmp->unk_6 == gPlayerEntity.animationState && gPlayerEntity.action == PLAYER_BOUNCE) { + if (tmp->unk_6 == gPlayerEntity.base.animationState && gPlayerEntity.base.action == PLAYER_BOUNCE) { return 1; } return 2; diff --git a/src/object/ladderHoleInBookshelf.c b/src/object/ladderHoleInBookshelf.c index dd55d741..0082e9d3 100644 --- a/src/object/ladderHoleInBookshelf.c +++ b/src/object/ladderHoleInBookshelf.c @@ -29,7 +29,7 @@ void LadderHoleInBookshelf_Init(Entity* this) { void LadderHoleInBookshelf_Action1(Entity* this) { if (sub_08094064(this)) { if (this->collisionLayer == 2) { - switch (gPlayerEntity.action) { + switch (gPlayerEntity.base.action) { case PLAYER_CLIMB: case PLAYER_USEENTRANCE: return; @@ -38,7 +38,7 @@ void LadderHoleInBookshelf_Action1(Entity* this) { UpdateSpriteForCollisionLayer(this); this->spritePriority.b0 = 5; } else { - switch (gPlayerEntity.action) { + switch (gPlayerEntity.base.action) { case PLAYER_CLIMB: case PLAYER_USEENTRANCE: this->collisionLayer = 2; @@ -46,10 +46,10 @@ void LadderHoleInBookshelf_Action1(Entity* this) { this->spritePriority.b0 = 1; break; default: - if ((gPlayerEntity.collisionLayer & 2) == 0) { + if ((gPlayerEntity.base.collisionLayer & 2) == 0) { break; } - gPlayerEntity.collisionLayer = 1; + gPlayerEntity.base.collisionLayer = 1; break; } } @@ -58,7 +58,7 @@ void LadderHoleInBookshelf_Action1(Entity* this) { bool32 sub_08094064(Entity* this) { bool32 rv = 1; - if (gPlayerEntity.x.HALF.HI - this->x.HALF.HI + 0x1cU >= 0x39) { + if (gPlayerEntity.base.x.HALF.HI - this->x.HALF.HI + 0x1cU >= 0x39) { rv = 0; } diff --git a/src/object/ladderUp.c b/src/object/ladderUp.c index 8743fadc..cfdadfb9 100644 --- a/src/object/ladderUp.c +++ b/src/object/ladderUp.c @@ -64,7 +64,7 @@ void LadderUp(Entity* this) { #endif default: if (this->type2 == 0) { - if (gPlayerEntity.y.HALF.HI < this->y.HALF.HI) { + if (gPlayerEntity.base.y.HALF.HI < this->y.HALF.HI) { if (gPlayerState.floor_type != SURFACE_LADDER && (GetTileTypeByEntity(this) == 0x4017)) { SetTile(0x4023, COORD_TO_TILE(this), this->collisionLayer); RestorePrevTileEntity(COORD_TO_TILE_OFFSET(this, 0, 0x10), this->collisionLayer); diff --git a/src/object/lavaPlatform.c b/src/object/lavaPlatform.c index a98cd00b..5db1f0b9 100644 --- a/src/object/lavaPlatform.c +++ b/src/object/lavaPlatform.c @@ -278,10 +278,10 @@ void sub_0809264C(LavaPlatformEntity* this) { } bool32 LavaPlatform_IsPlayerOnPlatform(LavaPlatformEntity* this) { - if ((gPlayerState.flags & PL_MINISH) == 0 && EntityInRectRadius(super, &gPlayerEntity, 0x10, 0x10) && + if ((gPlayerState.flags & PL_MINISH) == 0 && EntityInRectRadius(super, &gPlayerEntity.base, 0x10, 0x10) && PlayerCanBeMoved()) { gPlayerState.field_0x14 = 1; - if (gPlayerEntity.z.HALF.HI == 0) { + if (gPlayerEntity.base.z.HALF.HI == 0) { super->subtimer = 1; return TRUE; } diff --git a/src/object/lightRay.c b/src/object/lightRay.c index 9d0b6548..a48ffa53 100644 --- a/src/object/lightRay.c +++ b/src/object/lightRay.c @@ -41,12 +41,12 @@ void LightRay_Type0(LightRayEntity* this) { super->subtimer = 0; gRoomControls.camera_target = super; gRoomControls.scrollSpeed = 1; - if (super->x.HALF.HI > gPlayerEntity.x.HALF.HI) { + if (super->x.HALF.HI > gPlayerEntity.base.x.HALF.HI) { tmp = 2; } else { tmp = 6; } - gPlayerEntity.animationState = tmp; + gPlayerEntity.base.animationState = tmp; gScreen.lcd.displayControl = (gScreen.lcd.displayControl & 0xbfff) | 0x2800; gScreen.controls.window0HorizontalDimensions = 0; gScreen.controls.window0VerticalDimensions = 0xa0; @@ -66,7 +66,7 @@ void LightRay_Type0(LightRayEntity* this) { super->action = 2; super->timer = 60; gScreen.lcd.displayControl &= 0xdfff; - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; SoundReq(SFX_134); } } @@ -115,12 +115,12 @@ void LightRay_Type1(LightRayEntity* this) { super->subtimer = 32; gRoomControls.camera_target = super; gRoomControls.scrollSpeed = 1; - if (super->x.HALF.HI > gPlayerEntity.x.HALF.HI) { + if (super->x.HALF.HI > gPlayerEntity.base.x.HALF.HI) { tmp = 2; } else { tmp = 6; } - gPlayerEntity.animationState = tmp; + gPlayerEntity.base.animationState = tmp; gScreen.lcd.displayControl = (gScreen.lcd.displayControl & 0xbfff) | 0x2000; gScreen.controls.window0HorizontalDimensions = DISPLAY_WIDTH; gScreen.controls.window0VerticalDimensions = DISPLAY_HEIGHT; @@ -139,7 +139,7 @@ void LightRay_Type1(LightRayEntity* this) { } else { super->action = 2; super->timer = 60; - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; SoundReq(SFX_134); } } @@ -166,12 +166,12 @@ void LightRay_Type2(LightRayEntity* this) { super->subtimer = 0; gRoomControls.camera_target = super; gRoomControls.scrollSpeed = 1; - if (super->x.HALF.HI > gPlayerEntity.x.HALF.HI) { + if (super->x.HALF.HI > gPlayerEntity.base.x.HALF.HI) { tmp = 2; } else { tmp = 6; } - gPlayerEntity.animationState = tmp; + gPlayerEntity.base.animationState = tmp; gScreen.controls.window0HorizontalDimensions = 0x60; gScreen.controls.window0VerticalDimensions = 0xa0; break; @@ -211,7 +211,7 @@ void LightRay_Type2(LightRayEntity* this) { case 3: if (--super->timer == 0) { super->action = 4; - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; gRoomControls.scrollSpeed = 2; } break; @@ -236,12 +236,12 @@ void LightRay_Type3(LightRayEntity* this) { super->subtimer = 0; gRoomControls.camera_target = super; gRoomControls.scrollSpeed = 1; - if (super->x.HALF.HI > gPlayerEntity.x.HALF.HI) { + if (super->x.HALF.HI > gPlayerEntity.base.x.HALF.HI) { tmp = 2; } else { tmp = 6; } - gPlayerEntity.animationState = tmp; + gPlayerEntity.base.animationState = tmp; gScreen.controls.window0HorizontalDimensions = 0x80f0; gScreen.controls.window0VerticalDimensions = 0xa0; super->subAction = 0x80; @@ -292,12 +292,12 @@ void LightRay_Type4(LightRayEntity* this) { super->subtimer = 128; gRoomControls.camera_target = super; gRoomControls.scrollSpeed = 1; - if (super->x.HALF.HI > gPlayerEntity.x.HALF.HI) { + if (super->x.HALF.HI > gPlayerEntity.base.x.HALF.HI) { tmp = 2; } else { tmp = 6; } - gPlayerEntity.animationState = tmp; + gPlayerEntity.base.animationState = tmp; break; case 1: if (super->timer != 0) { @@ -310,7 +310,7 @@ void LightRay_Type4(LightRayEntity* this) { } else { super->action = 2; super->timer = 60; - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; SoundReq(SFX_134); } } diff --git a/src/object/lilypadLarge.c b/src/object/lilypadLarge.c index 3f47f21c..7a09ee3a 100644 --- a/src/object/lilypadLarge.c +++ b/src/object/lilypadLarge.c @@ -100,19 +100,19 @@ void LilypadLarge_Action1(LilypadLargeEntity* this) { u32 uVar4; super->flags |= 0x20; - if (sub_0806FC80(super, &gPlayerEntity, 0x18) != 0) { + if (sub_0806FC80(super, &gPlayerEntity.base, 0x18) != 0) { gPlayerState.flags |= PL_FLAGS2; - if (gPlayerEntity.z.WORD == 0) { + if (gPlayerEntity.base.z.WORD == 0) { if (gPlayerState.swim_state != 0) { - gPlayerEntity.collisionFlags &= 0xfb; + gPlayerEntity.base.collisionFlags &= 0xfb; gPlayerState.swim_state = 0; } gPlayerState.lilypad = super; if (super->collisionLayer == 1) { - ResetCollisionLayer(&gPlayerEntity); + ResetCollisionLayer(&gPlayerEntity.base); } else { - sub_08004542(&gPlayerEntity); + sub_08004542(&gPlayerEntity.base); } if (super->subtimer == 0) { super->subtimer = 4; @@ -127,7 +127,7 @@ void LilypadLarge_Action1(LilypadLargeEntity* this) { } if (gPlayerState.field_0x1c == 3) { tmp = gUnk_08120620[gPlayerState.gustJarSpeed - 1]; - switch (gPlayerEntity.animationState & 6) { + switch (gPlayerEntity.base.animationState & 6) { case 4: this->unk_70 -= tmp; break; @@ -150,8 +150,8 @@ void LilypadLarge_Action1(LilypadLargeEntity* this) { SoundReq(SFX_WATER_WALK); } if ((super->contactFlags & 0x7f) == 0x13) { - sVar10 = gPlayerEntity.x.HALF.HI + gUnk_08126EE4[gPlayerEntity.animationState & 0xe]; - uVar4 = gPlayerEntity.y.HALF.HI + gUnk_08126EE4[gPlayerEntity.animationState | 1]; + sVar10 = gPlayerEntity.base.x.HALF.HI + gUnk_08126EE4[gPlayerEntity.base.animationState & 0xe]; + uVar4 = gPlayerEntity.base.y.HALF.HI + gUnk_08126EE4[gPlayerEntity.base.animationState | 1]; super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, sVar10, uVar4); switch (gPlayerState.gustJarSpeed) { @@ -377,26 +377,26 @@ void sub_08085B40(LilypadLargeEntity* this) { this->unk_78.WORD += 0x100000; SetAffineInfo(super, this->unk_78.HALF_U.HI, this->unk_78.HALF_U.HI, this->unk_7c.HALF_U.HI); } - gPlayerEntity.y.HALF.HI = (super->y.HALF.HI + super->z.HALF.HI) - this->unk_74; + gPlayerEntity.base.y.HALF.HI = (super->y.HALF.HI + super->z.HALF.HI) - this->unk_74; if (gArea.locationIndex == 0x1b) { - gPlayerEntity.z.HALF.HI = super->y.HALF.HI - this->unk_74 - 0xd0 - gPlayerEntity.y.HALF.HI; + gPlayerEntity.base.z.HALF.HI = super->y.HALF.HI - this->unk_74 - 0xd0 - gPlayerEntity.base.y.HALF.HI; } else { - gPlayerEntity.z.HALF.HI = super->y.HALF.HI - this->unk_74 - 0x40 - gPlayerEntity.y.HALF.HI; + gPlayerEntity.base.z.HALF.HI = super->y.HALF.HI - this->unk_74 - 0x40 - gPlayerEntity.base.y.HALF.HI; } } } else { ResetCollisionLayer(super); if (GetTileUnderEntity(super) == 0xd) { - ResetCollisionLayer(&gPlayerEntity); + ResetCollisionLayer(&gPlayerEntity.base); LilypadLarge_Action4(this); - super->direction = GetFacingDirection(&gPlayerEntity, super); - LinearMoveDirection(&gPlayerEntity, 0x100, super->direction); + super->direction = GetFacingDirection(&gPlayerEntity.base, super); + LinearMoveDirection(&gPlayerEntity.base, 0x100, super->direction); } } if (this->unk_82 == 0) { - if (GravityUpdate(&gPlayerEntity, Q_8_8(32.0)) == 0) { - ResetCollisionLayer(&gPlayerEntity); + if (GravityUpdate(&gPlayerEntity.base, Q_8_8(32.0)) == 0) { + ResetCollisionLayer(&gPlayerEntity.base); sub_08085F1C(this); super->action = 1; super->subtimer = 4; @@ -418,23 +418,23 @@ void sub_08085B40(LilypadLargeEntity* this) { } void LilypadLarge_Action3(LilypadLargeEntity* this) { - if (sub_0806FC80(super, &gPlayerEntity, 0x18) != 0) { + if (sub_0806FC80(super, &gPlayerEntity.base, 0x18) != 0) { LinearMoveUpdate(super); - gPlayerEntity.speed = super->speed; - gPlayerEntity.direction = super->direction; - LinearMoveUpdate(&gPlayerEntity); + gPlayerEntity.base.speed = super->speed; + gPlayerEntity.base.direction = super->direction; + LinearMoveUpdate(&gPlayerEntity.base); gPlayerState.flags |= PL_FLAGS2; if (super->collisionLayer == 1) { - ResetCollisionLayer(&gPlayerEntity); + ResetCollisionLayer(&gPlayerEntity.base); } else { - sub_08004542(&gPlayerEntity); + sub_08004542(&gPlayerEntity.base); } } if (gRoomControls.reload_flags == 0) { super->flags &= ~ENT_PERSIST; super->action = 1; super->updatePriority = super->updatePriorityPrev; - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; } } @@ -498,7 +498,7 @@ void sub_08085D60(LilypadLargeEntity* this) { if (sub_080806BC((super->x.HALF.HI - gRoomControls.origin_x) + tmpX, (super->y.HALF.HI - gRoomControls.origin_y) + tmpY, r4, 5) == 0) { - if (sub_0807BD14(&gPlayerEntity, r4 >> 3) != 0) { + if (sub_0807BD14(&gPlayerEntity.base, r4 >> 3) != 0) { super->direction = r4; sub_08085E74(this); return; @@ -514,7 +514,7 @@ void sub_08085D60(LilypadLargeEntity* this) { tmpX2 = gUnk_08120638[tmp]; tmpY2 = gUnk_08120638[tmp + 1]; if (sub_080B1AF0(super, tmpX2, tmpY2) == 0xff) { - if (sub_0807BD14(&gPlayerEntity, r6 >> 3) != 0) { + if (sub_0807BD14(&gPlayerEntity.base, r6 >> 3) != 0) { super->direction = (u8)r6; sub_08085E74(this); } @@ -547,9 +547,9 @@ void sub_08085E74(LilypadLargeEntity* this) { this->unk_6c = 0; super->x.HALF.LO = 0; super->y.HALF.LO = 0; - gPlayerEntity.x.HALF.LO = 0; - gPlayerEntity.y.HALF.LO = 0; - gPlayerEntity.direction = super->direction; + gPlayerEntity.base.x.HALF.LO = 0; + gPlayerEntity.base.y.HALF.LO = 0; + gPlayerEntity.base.direction = super->direction; gPlayerState.animation = ANIM_DEFAULT; gRoomControls.camera_target = super; if (gPlayerState.item != NULL) { @@ -559,13 +559,13 @@ void sub_08085E74(LilypadLargeEntity* this) { } void sub_08085EFC(LilypadLargeEntity* this) { - this->unk_76 = super->x.HALF.HI - gPlayerEntity.x.HALF.HI; - this->unk_74 = super->y.HALF.HI - gPlayerEntity.y.HALF.HI; + this->unk_76 = super->x.HALF.HI - gPlayerEntity.base.x.HALF.HI; + this->unk_74 = super->y.HALF.HI - gPlayerEntity.base.y.HALF.HI; } void sub_08085F1C(LilypadLargeEntity* this) { - gPlayerEntity.x.HALF.HI = super->x.HALF.HI - this->unk_76; - gPlayerEntity.y.HALF.HI = super->y.HALF.HI - this->unk_74; + gPlayerEntity.base.x.HALF.HI = super->x.HALF.HI - this->unk_76; + gPlayerEntity.base.y.HALF.HI = super->y.HALF.HI - this->unk_74; sub_0807A5B8(super->direction); } diff --git a/src/object/lilypadSmall.c b/src/object/lilypadSmall.c index 78e91a99..2d92e4f0 100644 --- a/src/object/lilypadSmall.c +++ b/src/object/lilypadSmall.c @@ -42,13 +42,13 @@ void LilypadSmall(LilypadSmallEntity* this) { static bool32 CheckMovePlayer(LilypadSmallEntity* this) { if (!(gPlayerState.flags & PL_MINISH)) { return FALSE; - } else if (EntityInRectRadius(super, &gPlayerEntity, 8, 8) == 0) { + } else if (EntityInRectRadius(super, &gPlayerEntity.base, 8, 8) == 0) { return FALSE; } else if (!PlayerCanBeMoved()) { return FALSE; } else { gPlayerState.field_0x14 = 1; - if (gPlayerEntity.z.HALF.HI != 0) { + if (gPlayerEntity.base.z.HALF.HI != 0) { return FALSE; } else { return TRUE; diff --git a/src/object/linkAnimation.c b/src/object/linkAnimation.c index 123d6e77..71e1a494 100644 --- a/src/object/linkAnimation.c +++ b/src/object/linkAnimation.c @@ -52,19 +52,19 @@ void LinkAnimation_ItemGet(LinkAnimationEntity* this) { u8* ptr; // hide player entity - gPlayerEntity.flags &= ~ENT_COLLIDE; - gPlayerEntity.spriteSettings.draw = 0; + gPlayerEntity.base.flags &= ~ENT_COLLIDE; + gPlayerEntity.base.spriteSettings.draw = 0; - super->palette.b.b0 = gPlayerEntity.palette.b.b0; + super->palette.b.b0 = gPlayerEntity.base.palette.b.b0; switch (super->subAction) { case ITEMGET_INIT: one = 1; super->subAction = one; super->spriteSettings.draw = one; - super->collisionLayer = gPlayerEntity.collisionLayer; - super->spritePriority.b0 = gPlayerEntity.spritePriority.b0; - super->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; - super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; + super->collisionLayer = gPlayerEntity.base.collisionLayer; + super->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0; + super->spriteRendering.b3 = gPlayerEntity.base.spriteRendering.b3; + super->spriteOrientation.flipY = gPlayerEntity.base.spriteOrientation.flipY; super->spriteSettings.flipX = 0; super->animationState = 4; SetEntityPriority(super, PRIO_PLAYER_EVENT); @@ -98,9 +98,9 @@ void LinkAnimation_ItemGet(LinkAnimationEntity* this) { if (super->frame & ANIM_DONE) { super->action = PLAYER_NORMAL; // restore player state - gPlayerEntity.flags = this->storeFlags; - gPlayerEntity.spriteSettings.draw = this->storeDrawFlags; - gPlayerEntity.iframes = this->storeIFrames; + gPlayerEntity.base.flags = this->storeFlags; + gPlayerEntity.base.spriteSettings.draw = this->storeDrawFlags; + gPlayerEntity.base.iframes = this->storeIFrames; gPlayerState.field_0x7 = this->storeField7; gPlayerState.keepFacing = this->storeKeepFacing; gPlayerState.field_0xa = this->storeFieldA; diff --git a/src/object/linkEmptyingBottle.c b/src/object/linkEmptyingBottle.c index 8f029f69..e3b77637 100644 --- a/src/object/linkEmptyingBottle.c +++ b/src/object/linkEmptyingBottle.c @@ -39,8 +39,9 @@ void LinkEmptyingBottle_Init(LinkEmptyingBottleEntity* this) { effect = CreateFx(super, FX_WATER_SPLASH, 0); super->child = effect; if (effect != NULL) { - PositionRelative(&gPlayerEntity, effect, gUnk_08122A18[gPlayerEntity.animationState & 6] << 0x10, - gUnk_08122A18[gPlayerEntity.animationState | 1] << 0x10); + PositionRelative(&gPlayerEntity.base, effect, + gUnk_08122A18[gPlayerEntity.base.animationState & 6] << 0x10, + gUnk_08122A18[gPlayerEntity.base.animationState | 1] << 0x10); } CopyPosition(super->child, super); sub_08094980(this, 0x4032, 0x4033); @@ -50,8 +51,9 @@ void LinkEmptyingBottle_Init(LinkEmptyingBottleEntity* this) { effect = CreateFx(super, FX_GREEN_SPLASH2, 0); super->child = effect; if (effect != NULL) { - PositionRelative(&gPlayerEntity, effect, gUnk_08122A18[gPlayerEntity.animationState & 6] << 0x10, - gUnk_08122A18[gPlayerEntity.animationState | 1] << 0x10); + PositionRelative(&gPlayerEntity.base, effect, + gUnk_08122A18[gPlayerEntity.base.animationState & 6] << 0x10, + gUnk_08122A18[gPlayerEntity.base.animationState | 1] << 0x10); } if (super->type2 == 0) { CopyPosition(super->child, super); @@ -64,7 +66,7 @@ void LinkEmptyingBottle_Init(LinkEmptyingBottleEntity* this) { } break; case 2: - child = CreateGroundItem(&gPlayerEntity, ITEM_FAIRY, 0); + child = CreateGroundItem(&gPlayerEntity.base, ITEM_FAIRY, 0); super->child = child; if (child != NULL) { child->timer = 1; diff --git a/src/object/linkFire.c b/src/object/linkFire.c index 8d7223f7..1a12c93f 100644 --- a/src/object/linkFire.c +++ b/src/object/linkFire.c @@ -59,22 +59,22 @@ void sub_0808DDE8(LinkFireEntity* this) { gPlayerState.flags &= ~PL_BURNING; DeleteThisEntity(); } - player = &gPlayerEntity; - super->x.HALF.HI = (s8)gUnk_081217B8[gPlayerEntity.animationState >> 1] + player->x.HALF.HI; - super->y.HALF.HI = gPlayerEntity.y.HALF.HI + -6; - super->z = gPlayerEntity.z; - super->collisionLayer = gPlayerEntity.collisionLayer; - super->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; - super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; + player = &gPlayerEntity.base; + super->x.HALF.HI = (s8)gUnk_081217B8[gPlayerEntity.base.animationState >> 1] + player->x.HALF.HI; + super->y.HALF.HI = gPlayerEntity.base.y.HALF.HI + -6; + super->z = gPlayerEntity.base.z; + super->collisionLayer = gPlayerEntity.base.collisionLayer; + super->spriteRendering.b3 = gPlayerEntity.base.spriteRendering.b3; + super->spriteOrientation.flipY = gPlayerEntity.base.spriteOrientation.flipY; if ((gPlayerState.flags & PL_BURNING) != 0) { GetNextFrame(super); } else { DeleteThisEntity(); } - if (gPlayerEntity.animationState >> 1 == 2) { - sub_0806FEBC(&gPlayerEntity, 3, super); + if (gPlayerEntity.base.animationState >> 1 == 2) { + sub_0806FEBC(&gPlayerEntity.base, 3, super); super->y.HALF.HI -= 5; } else { - sub_0806FEBC(&gPlayerEntity, 0, super); + sub_0806FEBC(&gPlayerEntity.base, 0, super); } } diff --git a/src/object/lockedDoor.c b/src/object/lockedDoor.c index 6395744c..d7f089a2 100644 --- a/src/object/lockedDoor.c +++ b/src/object/lockedDoor.c @@ -283,19 +283,19 @@ u32 sub_08083734(Entity* this, u32 unk0) { // struct? switch (unk0) { case 0: - if (((LockedDoorEntity*)this)->unk_72 + 0xd - gPlayerEntity.y.HALF.HI < 0) + if (((LockedDoorEntity*)this)->unk_72 + 0xd - gPlayerEntity.base.y.HALF.HI < 0) return 1; break; case 1: - if (gPlayerEntity.x.HALF.HI - (((LockedDoorEntity*)this)->unk_70 - 0xb) < 0) + if (gPlayerEntity.base.x.HALF.HI - (((LockedDoorEntity*)this)->unk_70 - 0xb) < 0) return 1; break; case 2: - if (gPlayerEntity.y.HALF.HI - (((LockedDoorEntity*)this)->unk_72 - 0x8) < 0) + if (gPlayerEntity.base.y.HALF.HI - (((LockedDoorEntity*)this)->unk_72 - 0x8) < 0) return 1; break; case 3: - if (((LockedDoorEntity*)this)->unk_70 + 0xa - gPlayerEntity.x.HALF.HI < 0) + if (((LockedDoorEntity*)this)->unk_70 + 0xa - gPlayerEntity.base.x.HALF.HI < 0) return 1; break; } diff --git a/src/object/macroBook.c b/src/object/macroBook.c index 5e289acb..c0cb253e 100644 --- a/src/object/macroBook.c +++ b/src/object/macroBook.c @@ -125,7 +125,7 @@ void MacroBook_Action3(MacroBookEntity* this) { SetAffineInfo(super, this->unk80, this->unk80, 0); } else { sub_0809AA9C(this, super->child, 0); - sub_0809AA9C(this, &gPlayerEntity, 1); + sub_0809AA9C(this, &gPlayerEntity.base, 1); if (gPlayerClones[0] != NULL) { sub_0809AA9C(this, gPlayerClones[0], 1); } @@ -182,7 +182,7 @@ void sub_0809AA00(MacroBookEntity* this) { } else { sub_0809AA9C(this, super->child, 0); } - ent = &gPlayerEntity; + ent = &gPlayerEntity.base; this->playerWithinRect = EntityInRectRadius(super, ent, 0x20, 0x22); if (this->playerWithinRect != 0) { sub_0809AA9C(this, ent, 1); diff --git a/src/object/mask.c b/src/object/mask.c index dc289996..5fd949ef 100644 --- a/src/object/mask.c +++ b/src/object/mask.c @@ -80,21 +80,21 @@ void Mask_Init(MaskEntity* this) { // Probably related to knocking it down void Mask_Action1(MaskEntity* this) { // Check for the first frame of bonking animation - if (gPlayerEntity.action != PLAYER_BOUNCE) { + if (gPlayerEntity.base.action != PLAYER_BOUNCE) { return; } - if (gPlayerEntity.animationState != 0) { + if (gPlayerEntity.base.animationState != 0) { return; } // Check if link is close enough to the mask - if (super->y.HALF.HI + 40 < gPlayerEntity.y.HALF.HI) { + if (super->y.HALF.HI + 40 < gPlayerEntity.base.y.HALF.HI) { return; } - if (super->x.HALF.HI - gPlayerEntity.x.HALF.HI >= super->subtimer || - super->x.HALF.HI - gPlayerEntity.x.HALF.HI <= -super->subtimer) { + if (super->x.HALF.HI - gPlayerEntity.base.x.HALF.HI >= super->subtimer || + super->x.HALF.HI - gPlayerEntity.base.x.HALF.HI <= -super->subtimer) { return; } diff --git a/src/object/mazaalBossObject.c b/src/object/mazaalBossObject.c index 4e05b012..9fc03361 100644 --- a/src/object/mazaalBossObject.c +++ b/src/object/mazaalBossObject.c @@ -8,7 +8,6 @@ #include "entity.h" #include "functions.h" #include "item.h" -#include "new_player.h" #include "object.h" #include "player.h" #include "room.h" @@ -186,7 +185,7 @@ void MazaalBossObject_Action8(MazaalBossObjectEntity* this) { break; case 2: if (--super->timer == 0) { - gRoomControls.camera_target = &gNewPlayerEntity.base; + gRoomControls.camera_target = &gPlayerEntity.base; gPlayerState.controlMode = CONTROL_1; DeleteThisEntity(); } diff --git a/src/object/minecart.c b/src/object/minecart.c index 6f0e0b18..67d52465 100644 --- a/src/object/minecart.c +++ b/src/object/minecart.c @@ -84,9 +84,9 @@ void Minecart_Action1(MinecartEntity* this) { super->action++; gPlayerState.jump_status = 0x81; gPlayerState.flags |= PL_ENTER_MINECART; - gPlayerEntity.zVelocity = Q_16_16(2.0); - gPlayerEntity.speed = 0x100; - gPlayerEntity.flags &= ~PL_MINISH; + gPlayerEntity.base.zVelocity = Q_16_16(2.0); + gPlayerEntity.base.speed = 0x100; + gPlayerEntity.base.flags &= ~PL_MINISH; ResetActiveItems(); DeleteClones(); SoundReq(SFX_PLY_JUMP); @@ -98,21 +98,21 @@ void Minecart_Action1(MinecartEntity* this) { } void Minecart_Action2(MinecartEntity* this) { - if (EntityInRectRadius(super, &gPlayerEntity, 2, 2) != 0) { - gPlayerEntity.x.HALF.HI = super->x.HALF.HI; - gPlayerEntity.y.HALF.HI = super->y.HALF.HI; - if (gPlayerEntity.z.HALF.HI > -0x10) { - if (gPlayerEntity.zVelocity >= 0) { + if (EntityInRectRadius(super, &gPlayerEntity.base, 2, 2) != 0) { + gPlayerEntity.base.x.HALF.HI = super->x.HALF.HI; + gPlayerEntity.base.y.HALF.HI = super->y.HALF.HI; + if (gPlayerEntity.base.z.HALF.HI > -0x10) { + if (gPlayerEntity.base.zVelocity >= 0) { return; } - gPlayerEntity.animationState = super->animationState << 1; + gPlayerEntity.base.animationState = super->animationState << 1; gPlayerState.flags = (gPlayerState.flags ^ PL_ENTER_MINECART) | PL_IN_MINECART; super->action++; super->subtimer = 1; super->flags |= ENT_PERSIST; super->hitType = 0x97; - super->collisionFlags = (gPlayerEntity.collisionFlags + 1) | 0x20; - super->flags2 = gPlayerEntity.flags2; + super->collisionFlags = (gPlayerEntity.base.collisionFlags + 1) | 0x20; + super->flags2 = gPlayerEntity.base.flags2; super->hurtType = 0x18; super->damage = 8; sub_0801766C(super); @@ -120,10 +120,10 @@ void Minecart_Action2(MinecartEntity* this) { SoundReq(SFX_137); } } else { - gPlayerEntity.direction = GetFacingDirection(&gPlayerEntity, super); + gPlayerEntity.base.direction = GetFacingDirection(&gPlayerEntity.base, super); } - if (gPlayerEntity.zVelocity < 0) { - gPlayerEntity.spritePriority.b0 = super->spritePriority.b0 - 1; + if (gPlayerEntity.base.zVelocity < 0) { + gPlayerEntity.base.spritePriority.b0 = super->spritePriority.b0 - 1; } } @@ -139,20 +139,20 @@ void Minecart_Action3(MinecartEntity* this) { return; } - if ((gPlayerEntity.frame & 0xf) == 0) { + if ((gPlayerEntity.base.frame & 0xf) == 0) { COLLISION_OFF(super); - CopyPosition(super, &gPlayerEntity); - if ((gPlayerEntity.frame & 0xf0) == 0x10) { + CopyPosition(super, &gPlayerEntity.base); + if ((gPlayerEntity.base.frame & 0xf0) == 0x10) { super->spriteOffsetY = 1; } else { super->spriteOffsetY = 0; } } else { COLLISION_ON(super); - gPlayerEntity.speed = 0; + gPlayerEntity.base.speed = 0; LinearMoveUpdate(super); - CopyPosition(super, &gPlayerEntity); - gPlayerEntity.spritePriority.b0 = super->spritePriority.b0 - 1; + CopyPosition(super, &gPlayerEntity.base); + gPlayerEntity.base.spritePriority.b0 = super->spritePriority.b0 - 1; if (!sub_08091DDC(this)) { if ((gRoomTransition.frameCount & 0xf) == 0) { SoundReq(SFX_138); @@ -181,11 +181,11 @@ void Minecart_Action3(MinecartEntity* this) { sub_08017744(super); gPlayerState.jump_status = 0x41; gPlayerState.flags = (gPlayerState.flags ^ PL_IN_MINECART) | PL_ENTER_MINECART; - gPlayerEntity.zVelocity = Q_16_16(2.0); - gPlayerEntity.speed = 0x200; - gPlayerEntity.animationState = super->animationState << 1; - gPlayerEntity.direction = super->direction; - gPlayerEntity.flags |= PL_MINISH; + gPlayerEntity.base.zVelocity = Q_16_16(2.0); + gPlayerEntity.base.speed = 0x200; + gPlayerEntity.base.animationState = super->animationState << 1; + gPlayerEntity.base.direction = super->direction; + gPlayerEntity.base.flags |= PL_MINISH; sub_08004168(super); InitAnimationForceUpdate(super, super->animationState + 0xc); SoundReq(SFX_PLY_VO4); @@ -201,14 +201,14 @@ void Minecart_Action3(MinecartEntity* this) { case 0x6f: if (uVar3 == GetTileUnderEntity(super)) { Minecart_Action4(this); - gPlayerEntity.animationState = super->animationState << 1; + gPlayerEntity.base.animationState = super->animationState << 1; return; } break; } } - gPlayerEntity.animationState = super->animationState << 1; + gPlayerEntity.base.animationState = super->animationState << 1; if (super->animIndex == super->animationState) { UpdateAnimationSingleFrame(super); } else { @@ -220,7 +220,7 @@ void Minecart_Action3(MinecartEntity* this) { void Minecart_Action4(MinecartEntity* this) { sub_08004168(super); - CopyPosition(super, &gPlayerEntity); + CopyPosition(super, &gPlayerEntity.base); switch (GetTileUnderEntity(super)) { case 0x67: if (super->direction == DirectionWest) { @@ -264,16 +264,16 @@ void Minecart_Action4(MinecartEntity* this) { } super->action = 3; - gPlayerEntity.animationState = super->animationState << 1; + gPlayerEntity.base.animationState = super->animationState << 1; } void Minecart_Action5(MinecartEntity* this) { LinearMoveUpdate(super); - CopyPosition(super, &gPlayerEntity); + CopyPosition(super, &gPlayerEntity.base); if (gRoomControls.reload_flags == 0) { super->action = 3; super->speed = 0x700; - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; } } @@ -293,7 +293,7 @@ void Minecart_Action6(MinecartEntity* this) { SetTile(0x4022, COORD_TO_TILE(super), super->collisionLayer); } else { UpdateAnimationSingleFrame(super); - gPlayerEntity.spritePriority.b0 = super->spritePriority.b0 - 1; + gPlayerEntity.base.spritePriority.b0 = super->spritePriority.b0 - 1; } } @@ -313,7 +313,7 @@ bool32 sub_08091DDC(MinecartEntity* this) { static const s8 gUnk_081223D0[] = { 0, -8, 8, 0, 0, 8, -8, 0 }; if ((sub_080B1AF0(super, gUnk_081223D0[super->animationState * 2], gUnk_081223D0[super->animationState * 2 + 1]) == 0xff) && - (sub_0807BD14(&gPlayerEntity, super->animationState))) { + (sub_0807BD14(&gPlayerEntity.base, super->animationState))) { super->updatePriority = 6; super->action = 5; switch (super->direction) { @@ -324,7 +324,7 @@ bool32 sub_08091DDC(MinecartEntity* this) { super->speed = 0xa0; break; } - gPlayerEntity.direction = super->direction; + gPlayerEntity.base.direction = super->direction; gRoomControls.camera_target = super; return 1; } else { diff --git a/src/object/minecartDoor.c b/src/object/minecartDoor.c index 0ce907e3..6c70abd8 100644 --- a/src/object/minecartDoor.c +++ b/src/object/minecartDoor.c @@ -98,7 +98,7 @@ void MinecartDoor_Action3(MinecartDoorEntity* this) { return; } if ((gPlayerState.flags & PL_IN_MINECART) != 0) { - if (super->type * 2 - (u32)gPlayerEntity.animationState == 0) { + if (super->type * 2 - (u32)gPlayerEntity.base.animationState == 0) { if (sub_08083734(super, super->type) == 0) { return; } @@ -131,15 +131,15 @@ bool32 sub_08096CEC(MinecartDoorEntity* this) { return TRUE; } else { if ((gPlayerState.flags & PL_IN_MINECART) != 0) { - Entity* player = &gPlayerEntity; + Entity* player = &gPlayerEntity.base; if ((((super->type << 1) ^ player->animationState) & 2) == 0) { if ((super->type & 1) != 0) { - if (sub_08096D68(gPlayerEntity.y.HALF.HI, super->y.HALF.HI, gPlayerEntity.x.HALF.HI, + if (sub_08096D68(gPlayerEntity.base.y.HALF.HI, super->y.HALF.HI, gPlayerEntity.base.x.HALF.HI, super->x.HALF.HI)) { return TRUE; } } else { - if (sub_08096D68(gPlayerEntity.x.HALF.HI, super->x.HALF.HI, gPlayerEntity.y.HALF.HI, + if (sub_08096D68(gPlayerEntity.base.x.HALF.HI, super->x.HALF.HI, gPlayerEntity.base.y.HALF.HI, super->y.HALF.HI)) { return TRUE; } @@ -161,22 +161,22 @@ bool32 sub_08096D68(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { bool32 sub_08096D84(MinecartDoorEntity* this) { switch (super->type) { case 0: - if (((super->y.HALF.HI + 10) - (gPlayerEntity.y.HALF.HI)) < 0x65U) { + if (((super->y.HALF.HI + 10) - (gPlayerEntity.base.y.HALF.HI)) < 0x65U) { return TRUE; } break; case 1: - if (((gPlayerEntity.x.HALF.HI) - (super->x.HALF.HI - 10)) < 0x65U) { + if (((gPlayerEntity.base.x.HALF.HI) - (super->x.HALF.HI - 10)) < 0x65U) { return TRUE; } break; case 2: - if (((gPlayerEntity.y.HALF.HI) - (super->y.HALF.HI - 10)) < 0x65U) { + if (((gPlayerEntity.base.y.HALF.HI) - (super->y.HALF.HI - 10)) < 0x65U) { return TRUE; } break; case 3: - if (((super->x.HALF.HI + 10) - (gPlayerEntity.x.HALF.HI)) < 0x65U) { + if (((super->x.HALF.HI + 10) - (gPlayerEntity.base.x.HALF.HI)) < 0x65U) { return TRUE; } break; diff --git a/src/object/minishEmoticon.c b/src/object/minishEmoticon.c index 0904b1cb..147ca51d 100644 --- a/src/object/minishEmoticon.c +++ b/src/object/minishEmoticon.c @@ -37,7 +37,7 @@ void MinishEmoticon_Action1(Entity* this) { if ((gPlayerState.flags & PL_MINISH) == 0) { DeleteThisEntity(); } - playerEnt = &gPlayerEntity; + playerEnt = &gPlayerEntity.base; sub_08079BD8(this); this->spriteOrientation.flipY = 1; this->palette.b.b0 = playerEnt->palette.b.b0; diff --git a/src/object/minishSizedEntrance.c b/src/object/minishSizedEntrance.c index c12192c2..cbe61fc8 100644 --- a/src/object/minishSizedEntrance.c +++ b/src/object/minishSizedEntrance.c @@ -45,8 +45,9 @@ void MinishSizedEntrance_Action1(Entity* this) { DeleteThisEntity(); } } - if ((gPlayerState.flags & PL_MINISH) && EntityInRectRadius(this, &gPlayerEntity, 4, 4) && - (gPlayerEntity.z.HALF.HI == 0) && (((u16)gPlayerState.playerInput.heldInput) & gUnk_0812225C[this->type2])) { + if ((gPlayerState.flags & PL_MINISH) && EntityInRectRadius(this, &gPlayerEntity.base, 4, 4) && + (gPlayerEntity.base.z.HALF.HI == 0) && + (((u16)gPlayerState.playerInput.heldInput) & gUnk_0812225C[this->type2])) { DoExitTransition(GetCurrentRoomProperty(this->timer)); } } diff --git a/src/object/moleMittsParticle.c b/src/object/moleMittsParticle.c index 29e2a971..125a679d 100644 --- a/src/object/moleMittsParticle.c +++ b/src/object/moleMittsParticle.c @@ -26,7 +26,7 @@ void MoleMittsParticle_Init(Entity* this) { u32 palette; this->action = 1; - this->animationState = gPlayerEntity.animationState >> 1; + this->animationState = gPlayerEntity.base.animationState >> 1; this->spriteRendering.b3 = 2; this->spritePriority.b0 = 3; this->spriteOrientation.flipY--; @@ -72,7 +72,7 @@ void MoleMittsParticle_Action1(Entity* this) { DeleteThisEntity(); } if (this->type2 != 0) { - this->spritePriority.b0 = gPlayerEntity.spritePriority.b0 + 1 - this->frame; + this->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0 + 1 - this->frame; } } diff --git a/src/object/object1F.c b/src/object/object1F.c index 292ee2cd..1843e02e 100644 --- a/src/object/object1F.c +++ b/src/object/object1F.c @@ -58,7 +58,7 @@ void Object1F_Init(Object1FEntity* this) { temp = gUnk_08120A18[super->subtimer].unk1; super->palette.b.b0 = temp; this->unk6c = gUnk_08120A18[super->subtimer].unk2; - super->collisionLayer = gPlayerEntity.collisionLayer; + super->collisionLayer = gPlayerEntity.base.collisionLayer; super->speed = 0x100; InitializeAnimation(super, gUnk_08120A18[super->subtimer].animationState); } diff --git a/src/object/object37.c b/src/object/object37.c index 1ec12de2..35f32e93 100644 --- a/src/object/object37.c +++ b/src/object/object37.c @@ -46,7 +46,7 @@ void Object37_Action1(Object37Entity* this) { if ((gSave.kinstones.fusionUnmarked[0] != 0) && (this->unk70 != *this->unk78)) { item = CreateGroundItem(super, ITEM_RUPEE100, 0); if (item != 0) { - item->direction = gPlayerEntity.animationState << 2; + item->direction = gPlayerEntity.base.animationState << 2; item->speed = 0x80; item->zVelocity = Q_16_16(2.0); } diff --git a/src/object/object70.c b/src/object/object70.c index 082289c8..f9017446 100644 --- a/src/object/object70.c +++ b/src/object/object70.c @@ -24,9 +24,9 @@ void Object70_Init(Entity* this) { this->frameIndex = this->type + 0xb; if (this->type != 0) { sub_08004168(this); - gPlayerEntity.spriteOrientation.flipY = 3; - if ((gPlayerEntity.spritePriority.b0) != 7) { - this->spritePriority.b0 = gPlayerEntity.spritePriority.b0 + 1; + gPlayerEntity.base.spriteOrientation.flipY = 3; + if ((gPlayerEntity.base.spritePriority.b0) != 7) { + this->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0 + 1; } else { this->spritePriority.b0 = 7; } @@ -36,23 +36,23 @@ void Object70_Init(Entity* this) { void Object70_Action1(Entity* this) { if (this->type == 0) { - if (gPlayerEntity.z.WORD != 0 || (gPlayerState.dash_state & 0x40) != 0 || + if (gPlayerEntity.base.z.WORD != 0 || (gPlayerState.dash_state & 0x40) != 0 || gPlayerState.floor_type != SURFACE_SWAMP || - (gPlayerEntity.action != PLAYER_NORMAL && gPlayerEntity.action != PLAYER_ROLL && - gPlayerEntity.action != PLAYER_JUMP)) { - if (gPlayerEntity.z.WORD == 0) { - CreateFx(&gPlayerEntity, FX_GREEN_SPLASH, 0); + (gPlayerEntity.base.action != PLAYER_NORMAL && gPlayerEntity.base.action != PLAYER_ROLL && + gPlayerEntity.base.action != PLAYER_JUMP)) { + if (gPlayerEntity.base.z.WORD == 0) { + CreateFx(&gPlayerEntity.base, FX_GREEN_SPLASH, 0); } - gPlayerEntity.spriteOrientation.flipY = 2; + gPlayerEntity.base.spriteOrientation.flipY = 2; DeleteThisEntity(); } - this->x = gPlayerEntity.x; - this->y = gPlayerEntity.y; + this->x = gPlayerEntity.base.x; + this->y = gPlayerEntity.base.y; if (gPlayerState.jump_status == 0) { - gPlayerEntity.spriteOrientation.flipY = 3; - if (gPlayerEntity.spritePriority.b0 != 7) { - this->spritePriority.b0 = gPlayerEntity.spritePriority.b0 + 1; + gPlayerEntity.base.spriteOrientation.flipY = 3; + if (gPlayerEntity.base.spritePriority.b0 != 7) { + this->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0 + 1; } else { this->spritePriority.b0 = 7; } @@ -60,11 +60,11 @@ void Object70_Action1(Entity* this) { return; } - if (gPlayerEntity.action != PLAYER_USEENTRANCE) { + if (gPlayerEntity.base.action != PLAYER_USEENTRANCE) { if (this->collisionLayer == 1) { - gPlayerEntity.spriteOrientation.flipY = 2; + gPlayerEntity.base.spriteOrientation.flipY = 2; } else { - gPlayerEntity.spriteOrientation.flipY = 1; + gPlayerEntity.base.spriteOrientation.flipY = 1; } DeleteThisEntity(); } diff --git a/src/object/objectA8.c b/src/object/objectA8.c index f44abf38..4de9ccae 100644 --- a/src/object/objectA8.c +++ b/src/object/objectA8.c @@ -54,7 +54,7 @@ void ObjectA8(ObjectA8Entity* this) { case 0x1e: case 0x1f: super->action = 5; - super->child = &gPlayerEntity; + super->child = &gPlayerEntity.base; CreateItemEntity(super->type, 0, 0); DeleteThisEntity(); } @@ -130,7 +130,7 @@ void ObjectA8_Action2Subaction2(ObjectA8Entity* this) { if (sub_0806F3E4(super)) { super->flags &= ~ENT_COLLIDE; super->action = 5; - super->child = &gPlayerEntity; + super->child = &gPlayerEntity.base; GiveItem(super->type, 0); } } @@ -174,7 +174,7 @@ void ObjectA8_Action4(ObjectA8Entity* this) { } else { CopyPosition(super->child, super); super->z.HALF.HI--; - if (IsColliding(super, &gPlayerEntity)) { + if (IsColliding(super, &gPlayerEntity.base)) { sub_0809FECC(this); GiveItem(super->type, 0); } @@ -238,7 +238,7 @@ bool32 sub_0809FE9C(ObjectA8Entity* this) { } void sub_0809FECC(ObjectA8Entity* this) { - super->child = &gPlayerEntity; + super->child = &gPlayerEntity.base; super->action = 5; super->subAction = 0; } diff --git a/src/object/objectBlockingStairs.c b/src/object/objectBlockingStairs.c index ecb5ceaf..b35f6777 100644 --- a/src/object/objectBlockingStairs.c +++ b/src/object/objectBlockingStairs.c @@ -86,7 +86,7 @@ void ObjectBlockingStairs_Action1(ObjectBlockingStairsEntity* this) { int xDist; Entity* ent; - xDist = (int)gPlayerEntity.x.HALF.HI - super->x.HALF.HI; + xDist = (int)gPlayerEntity.base.x.HALF.HI - super->x.HALF.HI; if (this->objFlags) { if (!CheckFlags(this->objFlags)) { @@ -116,7 +116,7 @@ void ObjectBlockingStairs_Action1(ObjectBlockingStairsEntity* this) { case 0x4030: case 0x4031: super->action = 3; - super->direction = Direction8FromAnimationState(gPlayerEntity.animationState); + super->direction = Direction8FromAnimationState(gPlayerEntity.base.animationState); super->speed = 0x80; super->timer = 64; RequestPriorityDuration(super, 80); @@ -125,7 +125,7 @@ void ObjectBlockingStairs_Action1(ObjectBlockingStairsEntity* this) { return; } - if ((gPlayerEntity.animationState & 2) == 0) { + if ((gPlayerEntity.base.animationState & 2) == 0) { return; } RegisterCarryEntity(super); @@ -159,13 +159,13 @@ void ObjectBlockingStairs_Action2(ObjectBlockingStairsEntity* this) { sub_08093280(this); } else { if (gPlayerState.heldObject == 0x12) { - if ((gPlayerEntity.frame & 2) != 0 && ++super->subtimer > 8) { + if ((gPlayerEntity.base.frame & 2) != 0 && ++super->subtimer > 8) { gPlayerState.queued_action = PLAYER_PULL; gPlayerState.field_0x38 = 0x40; gPlayerState.flags |= PL_BUSY; - gPlayerEntity.x.HALF.LO = 0; - gPlayerEntity.y.HALF.LO = 0; - super->direction = (gPlayerEntity.animationState ^ 4) << 2; + gPlayerEntity.base.x.HALF.LO = 0; + gPlayerEntity.base.y.HALF.LO = 0; + super->direction = (gPlayerEntity.base.animationState ^ 4) << 2; super->timer = 64; EnqueueSFX(SFX_10F); sub_08093248(this); diff --git a/src/object/objectOnPillar.c b/src/object/objectOnPillar.c index a4aa5860..7815dd74 100644 --- a/src/object/objectOnPillar.c +++ b/src/object/objectOnPillar.c @@ -121,17 +121,17 @@ void ObjectOnPillar_SubAction0(ObjectOnPillarEntity* this) { const s8* ptr; if (this->unk_72 == 0) { this->unk_72 = 1; - ptr = &gUnk_08123274[gPlayerEntity.animationState]; - PositionRelative(super, &gPlayerEntity, ptr[0] << 0x10, ptr[1] << 0x10); + ptr = &gUnk_08123274[gPlayerEntity.base.animationState]; + PositionRelative(super, &gPlayerEntity.base, ptr[0] << 0x10, ptr[1] << 0x10); } sub_08097008(this); if (sub_080896B0()) { gPlayerState.queued_action = PLAYER_PULL; gPlayerState.field_0x38 = 0x20; gPlayerState.flags |= PL_BUSY; - gPlayerEntity.x.HALF.LO = 0; - gPlayerEntity.y.HALF.LO = 0; - super->direction = ((gPlayerEntity.animationState ^ 4) << 2); + gPlayerEntity.base.x.HALF.LO = 0; + gPlayerEntity.base.y.HALF.LO = 0; + super->direction = ((gPlayerEntity.base.animationState ^ 4) << 2); sub_08097098(this); } } diff --git a/src/object/objectOnSpinyBeetle.c b/src/object/objectOnSpinyBeetle.c index 064e987c..17597f8f 100644 --- a/src/object/objectOnSpinyBeetle.c +++ b/src/object/objectOnSpinyBeetle.c @@ -138,7 +138,7 @@ void ObjectOnSpinyBeetle_Action2Subaction0(ObjectOnSpinyBeetleEntity* this) { super->flags |= ENT_COLLIDE; super->collisionFlags = 7; super->hitType = 1; - super->flags2 = gPlayerEntity.flags2; + super->flags2 = gPlayerEntity.base.flags2; super->spriteOffsetY = 0; (super->parent)->child = NULL; super->subAction++; diff --git a/src/object/octorokBossObject.c b/src/object/octorokBossObject.c index 51143b43..ddab7bce 100644 --- a/src/object/octorokBossObject.c +++ b/src/object/octorokBossObject.c @@ -317,7 +317,7 @@ void OctorokBossObject_Action1(OctorokBossObjectEntity* this) { case 9: PausePlayer(); if ((this->unk_78.WORD_U)-- == 0) { - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; DeleteThisEntity(); } break; diff --git a/src/object/paper.c b/src/object/paper.c index f45f0c6d..62e49ff7 100644 --- a/src/object/paper.c +++ b/src/object/paper.c @@ -66,7 +66,8 @@ void Paper_Type2(Entity* this) { void Paper_Action1(Entity* this) { if (this->type == 0) { - if ((gPlayerEntity.y.HALF.HI < this->y.HALF.HI) || (gPlayerEntity.y.HALF.HI) > this->y.HALF.HI + 0x18) { + if ((gPlayerEntity.base.y.HALF.HI < this->y.HALF.HI) || + (gPlayerEntity.base.y.HALF.HI) > this->y.HALF.HI + 0x18) { this->spriteRendering.b3 = 1; } else { this->spriteRendering.b3 = 2; diff --git a/src/object/playerClone.c b/src/object/playerClone.c index b4281f78..36c4dd8b 100644 --- a/src/object/playerClone.c +++ b/src/object/playerClone.c @@ -72,8 +72,8 @@ void PlayerClone_Action1(PlayerCloneEntity* this) { super->updatePriority = 6; super->hitbox = (Hitbox*)&PlayerCloneHitbox; super->subtimer = (super->type + 1) * 15; - this->unk78 = super->x.HALF.HI - gPlayerEntity.x.HALF.HI; - this->unk7a = super->y.HALF.HI - gPlayerEntity.y.HALF.HI; + this->unk78 = super->x.HALF.HI - gPlayerEntity.base.x.HALF.HI; + this->unk7a = super->y.HALF.HI - gPlayerEntity.base.y.HALF.HI; if ((this->unk78 != 0) && (this->unk7a != 0)) { ((PlayerCloneEntity*)gPlayerClones[super->type])->unk70 = 1; } @@ -106,13 +106,13 @@ void PlayerClone_Action2(PlayerCloneEntity* this) { if (gPlayerState.chargeState.action == 5 && gPlayerClones[super->type] != NULL && gPlayerState.framestate != PL_STATE_TALKEZLO && super->health != 0) { - if (gPlayerEntity.iframes >= 1) { + if (gPlayerEntity.base.iframes >= 1) { gPlayerState.chargeState.action = 1; } else { GetTileUnderEntity(super); sub_08084B1C(this); - super->x.HALF.HI = gPlayerEntity.x.HALF.HI + this->unk78; - super->y.HALF.HI = gPlayerEntity.y.HALF.HI + this->unk7a; + super->x.HALF.HI = gPlayerEntity.base.x.HALF.HI + this->unk78; + super->y.HALF.HI = gPlayerEntity.base.y.HALF.HI + this->unk7a; sub_08084CAC(this); sub_080085B0(super); if ((super->collisions & (COL_NORTH_FULL | COL_SOUTH_FULL | COL_EAST_FULL | COL_WEST_FULL)) != @@ -151,22 +151,22 @@ void PlayerClone_Action2(PlayerCloneEntity* this) { } void sub_08084B1C(PlayerCloneEntity* this) { - super->flags = gPlayerEntity.flags; - super->spriteVramOffset = gPlayerEntity.spriteVramOffset; - super->frameIndex = gPlayerEntity.frameIndex; - super->frameSpriteSettings = gPlayerEntity.frameSpriteSettings; - super->spriteIndex = gPlayerEntity.spriteIndex; - super->direction = gPlayerEntity.direction; - super->animationState = gPlayerEntity.animationState; - super->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX; - super->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; - super->spritePriority.b0 = gPlayerEntity.spritePriority.b0; - super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; - super->collisionLayer = gPlayerEntity.collisionLayer; - super->flags2 = gPlayerEntity.flags2; - super->hitType = gPlayerEntity.hitType; - super->collisionFlags = gPlayerEntity.collisionFlags; - super->hurtType = gPlayerEntity.hurtType; + super->flags = gPlayerEntity.base.flags; + super->spriteVramOffset = gPlayerEntity.base.spriteVramOffset; + super->frameIndex = gPlayerEntity.base.frameIndex; + super->frameSpriteSettings = gPlayerEntity.base.frameSpriteSettings; + super->spriteIndex = gPlayerEntity.base.spriteIndex; + super->direction = gPlayerEntity.base.direction; + super->animationState = gPlayerEntity.base.animationState; + super->spriteSettings.flipX = gPlayerEntity.base.spriteSettings.flipX; + super->spriteRendering.b3 = gPlayerEntity.base.spriteRendering.b3; + super->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0; + super->spriteOrientation.flipY = gPlayerEntity.base.spriteOrientation.flipY; + super->collisionLayer = gPlayerEntity.base.collisionLayer; + super->flags2 = gPlayerEntity.base.flags2; + super->hitType = gPlayerEntity.base.hitType; + super->collisionFlags = gPlayerEntity.base.collisionFlags; + super->hurtType = gPlayerEntity.base.hurtType; CopyPosition(super, super->child); if (gPlayerState.attack_status != 0) { super->child->damage = gPlayerState.item->damage; diff --git a/src/object/pot.c b/src/object/pot.c index 4f8cd84e..388b35cc 100644 --- a/src/object/pot.c +++ b/src/object/pot.c @@ -156,7 +156,7 @@ void sub_08082510(PotEntity* this) { super->hitbox = (Hitbox*)&gUnk_080FD340; super->collisionFlags = 7; super->hitType = 1; - super->flags2 = gPlayerEntity.flags2; + super->flags2 = gPlayerEntity.base.flags2; super->spriteOffsetY = 0; SetTile((u16)this->unk_70, COORD_TO_TILE(super), super->collisionLayer); super->subAction++; @@ -181,7 +181,7 @@ void sub_0808259C(PotEntity* this) { CreateFx(super, FX_LAVA_SPLASH, 0); break; default: - sub_08082850(this, &gPlayerEntity); + sub_08082850(this, &gPlayerEntity.base); return; } diff --git a/src/object/pressurePlate.c b/src/object/pressurePlate.c index 407ba680..be8a7ff6 100644 --- a/src/object/pressurePlate.c +++ b/src/object/pressurePlate.c @@ -120,7 +120,7 @@ static u32 get_standing_count(PressurePlateEntity* this) { num = 0; if (IsCollidingPlayer(super) != 0) { - gPlayerEntity.spriteOffsetY = sSpriteOffsets[this->dir]; + gPlayerEntity.base.spriteOffsetY = sSpriteOffsets[this->dir]; num = 1; } if ((gPlayerState.flags & PL_CLONING) != 0) { diff --git a/src/object/pullableLever.c b/src/object/pullableLever.c index 0aaaa1ac..991f7c2e 100644 --- a/src/object/pullableLever.c +++ b/src/object/pullableLever.c @@ -105,7 +105,7 @@ void PullableLever_HandleAction2(PullableLeverEntity* this) { void PullableLever_HandleSubAction0(PullableLeverEntity* this) { u16 y; u16 x; - Entity* player = &gPlayerEntity; + Entity* player = &gPlayerEntity.base; if (this->unk_75 == 0) { if (-player->animationState + super->type2 * 2 == 0) { @@ -122,7 +122,7 @@ void PullableLever_HandleSubAction0(PullableLeverEntity* this) { if (player->animationState >> 1 == super->type2) { if (gPlayerState.framestate == PL_STATE_PULL) { if (gPlayerState.heldObject & 2) { - if (gPlayerEntity.frame & 2) { + if (gPlayerEntity.base.frame & 2) { sub_0809153C(this); if (this->unk_75 == 1) { this->unk_75 = 2; @@ -191,15 +191,15 @@ void sub_0809153C(PullableLeverEntity* this) { s16 diff; s32 radius; - Entity* player = &gPlayerEntity; + Entity* player = &gPlayerEntity.base; dir = gUnk_081222C0[super->type2]; if (this->necessaryPullLength <= this->pullLength) { return; } prevX = player->x.HALF.HI; prevY = player->y.HALF.HI; - sub_080044AE(&gPlayerEntity, super->speed, dir); - if ((prevX == gPlayerEntity.x.HALF.HI) && (prevY == gPlayerEntity.y.HALF.HI)) { + sub_080044AE(&gPlayerEntity.base, super->speed, dir); + if ((prevX == gPlayerEntity.base.x.HALF.HI) && (prevY == gPlayerEntity.base.y.HALF.HI)) { return; } @@ -208,13 +208,13 @@ void sub_0809153C(PullableLeverEntity* this) { diff = player->y.HALF.HI - prevY; break; case 1: - diff = prevX - gPlayerEntity.x.HALF.HI; + diff = prevX - gPlayerEntity.base.x.HALF.HI; break; case 2: - diff = prevY - gPlayerEntity.y.HALF.HI; + diff = prevY - gPlayerEntity.base.y.HALF.HI; break; case 3: - diff = gPlayerEntity.x.HALF.HI - prevX; + diff = gPlayerEntity.base.x.HALF.HI - prevX; break; } radius = (diff << 0x18); diff --git a/src/object/pullableMushroom.c b/src/object/pullableMushroom.c index 8c786450..63fcdfbb 100644 --- a/src/object/pullableMushroom.c +++ b/src/object/pullableMushroom.c @@ -269,7 +269,7 @@ void sub_0808AEB0(PullableMushroomEntity* this) { if ((gPlayerState.playerInput.heldInput & gUnk_081211E4[super->animationState]) != 0) { GetNextFrame(super); if (uVar1 < 0x40) { - sub_080044AE(&gPlayerEntity, 0x40, super->direction); + sub_080044AE(&gPlayerEntity.base, 0x40, super->direction); if (this->unk_7c-- == 0) { this->unk_7c = 4; SoundReq(SFX_12F); @@ -278,29 +278,30 @@ void sub_0808AEB0(PullableMushroomEntity* this) { super->subtimer = 1; } else { - if (((super->subtimer != 0) && (gPlayerEntity.action == PLAYER_NORMAL)) && (gPlayerState.swim_state == 0)) { + if (((super->subtimer != 0) && (gPlayerEntity.base.action == PLAYER_NORMAL)) && + (gPlayerState.swim_state == 0)) { gPlayerState.queued_action = PLAYER_08072C9C; gPlayerState.field_0x38 = uVar1; gPlayerState.field_0x39 = super->direction ^ 0x10; - gPlayerState.field_0x3a = sub_0808B1F0(this, &gPlayerEntity); + gPlayerState.field_0x3a = sub_0808B1F0(this, &gPlayerEntity.base); super->subAction++; } } } else { super->timer = 1; this->unk_7c = 1; - super->animationState = AnimationStateFlip90(gPlayerEntity.animationState >> 1); + super->animationState = AnimationStateFlip90(gPlayerEntity.base.animationState >> 1); super->direction = (super->animationState << 3); super->flags &= ~0x80; - super->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX; + super->spriteSettings.flipX = gPlayerEntity.base.spriteSettings.flipX; InitializeAnimation(super, super->animationState + 5); if (sub_0808B21C(this, 0)) { sub_0808B168((PullableMushroomEntity*)super->child, 0); } if ((super->animationState & 1) != 0) { - gPlayerEntity.y.HALF.HI = super->y.HALF.HI; + gPlayerEntity.base.y.HALF.HI = super->y.HALF.HI; } else { - gPlayerEntity.x.HALF.HI = super->x.HALF.HI; + gPlayerEntity.base.x.HALF.HI = super->x.HALF.HI; } } } @@ -332,9 +333,9 @@ void PullableMushroom_Action3(PullableMushroomEntity* this) { void sub_0808B05C(PullableMushroomEntity* this) { if (super->type == 0) { - super->animationState = AnimationStateFlip90(gPlayerEntity.animationState >> 1); + super->animationState = AnimationStateFlip90(gPlayerEntity.base.animationState >> 1); super->direction = super->animationState << 3; - super->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX; + super->spriteSettings.flipX = gPlayerEntity.base.spriteSettings.flipX; super->flags &= ~0x80; InitializeAnimation(super, super->animationState + 5); if (sub_0808B21C(this, 1)) { @@ -355,16 +356,16 @@ void sub_0808B0BC(PullableMushroomEntity* this) { GetNextFrame(super); break; case 1: - ptr = &gUnk_08126EE4[gPlayerEntity.animationState & 0xe]; - ent.base.x.HALF.HI = ptr[0] + gPlayerEntity.x.HALF.HI; - ent.base.y.HALF.HI = ptr[1] + gPlayerEntity.y.HALF.HI; + ptr = &gUnk_08126EE4[gPlayerEntity.base.animationState & 0xe]; + ent.base.x.HALF.HI = ptr[0] + gPlayerEntity.base.x.HALF.HI; + ent.base.y.HALF.HI = ptr[1] + gPlayerEntity.base.y.HALF.HI; if (sub_0800419C(&ent.base, super, 7, 7)) { - if ((gPlayerEntity.action != PLAYER_NORMAL) || (gPlayerState.swim_state != 0)) + if ((gPlayerEntity.base.action != PLAYER_NORMAL) || (gPlayerState.swim_state != 0)) return; gPlayerState.queued_action = PLAYER_08072C9C; gPlayerState.field_0x38 = uVar2; gPlayerState.field_0x39 = super->direction ^ 0x10; - gPlayerState.field_0x3a = sub_0808B1F0((PullableMushroomEntity*)super->parent, &gPlayerEntity); + gPlayerState.field_0x3a = sub_0808B1F0((PullableMushroomEntity*)super->parent, &gPlayerEntity.base); } else { super->speed = 0x40; if (uVar2 < 0x40) { @@ -397,13 +398,13 @@ void sub_0808B168(PullableMushroomEntity* this, u32 param_2) { pEVar6 = pEVar5; } else { if ((super->animationState & 1) != 0) { - pEVar6 = &gPlayerEntity; + pEVar6 = &gPlayerEntity.base; pEVar5 = super->parent; pcVar5 = (gUnk_081211FC + super->animationState * 2); pcVar3 = (gUnk_081211F4 + 1 + AnimationStateFlip90(super->animationState) * 2); } else { pEVar6 = super->parent; - pEVar5 = &gPlayerEntity; + pEVar5 = &gPlayerEntity.base; pcVar5 = (gUnk_081211F4 + AnimationStateFlip90(super->animationState) * 2); pcVar3 = (gUnk_081211FC + 1 + super->animationState * 2); } diff --git a/src/object/pushableFurniture.c b/src/object/pushableFurniture.c index da7d04d5..327dfbe6 100644 --- a/src/object/pushableFurniture.c +++ b/src/object/pushableFurniture.c @@ -4,27 +4,9 @@ * * @brief Pushable Furniture object */ -#include "functions.h" -#include "object.h" +#include "object/pushableFurniture.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; +#include "functions.h" extern const s16 gUnk_080B4488[]; @@ -339,9 +321,10 @@ void sub_0808FDE8(PushableFurnitureEntity* this) { bool32 sub_0808FECC(PushableFurnitureEntity* this) { bool32 result = TRUE; - if (!((gPlayerState.flags & PL_MINISH) == 0 && (gPlayerEntity.action == PLAYER_BOUNCE) && - (gPlayerEntity.animationState == 0) && (gPlayerEntity.y.HALF.HI - super->y.HALF.HI < 0x14) && - (super->x.HALF.HI + 0xc > gPlayerEntity.x.HALF.HI) && (super->x.HALF.HI - 12 < gPlayerEntity.x.HALF.HI))) { + if (!((gPlayerState.flags & PL_MINISH) == 0 && (gPlayerEntity.base.action == PLAYER_BOUNCE) && + (gPlayerEntity.base.animationState == 0) && (gPlayerEntity.base.y.HALF.HI - super->y.HALF.HI < 0x14) && + (super->x.HALF.HI + 0xc > gPlayerEntity.base.x.HALF.HI) && + (super->x.HALF.HI - 12 < gPlayerEntity.base.x.HALF.HI))) { result = FALSE; } return result; diff --git a/src/object/pushableGrave.c b/src/object/pushableGrave.c index 7c7a3cbe..eb343f09 100644 --- a/src/object/pushableGrave.c +++ b/src/object/pushableGrave.c @@ -118,7 +118,7 @@ void PushableGrave_Action3(PushableGraveEntity* this) { EnqueueSFX(SFX_SECRET); sub_080977F4(this); if (super->type == 0) { - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; gRoomControls.scrollSpeed = 4; } } diff --git a/src/object/pushableLever.c b/src/object/pushableLever.c index 2a16033b..bfdc1a46 100644 --- a/src/object/pushableLever.c +++ b/src/object/pushableLever.c @@ -57,9 +57,9 @@ void PushableLever_Idle(PushableLeverEntity* this) { gPlayerState.pushedObject = 0x90; gPlayerState.queued_action = PLAYER_PUSH; gPlayerState.flags |= PL_BUSY; - gPlayerEntity.x.HALF.LO = 0; - gPlayerEntity.y.HALF.LO = 0; - gPlayerEntity.direction = gPlayerEntity.animationState << 2; + gPlayerEntity.base.x.HALF.LO = 0; + gPlayerEntity.base.y.HALF.LO = 0; + gPlayerEntity.base.direction = gPlayerEntity.base.animationState << 2; } } } diff --git a/src/object/pushableStatue.c b/src/object/pushableStatue.c index f9910b31..386cb3e0 100644 --- a/src/object/pushableStatue.c +++ b/src/object/pushableStatue.c @@ -104,9 +104,9 @@ void PushableStatue_SubAction0(PushableStatueEntity* this) { if (this->unk_83 == 0) { this->unk_83 = 1; - index = gPlayerEntity.animationState; + index = gPlayerEntity.base.animationState; ptr = &gUnk_08120CB4[index]; - PositionRelative(super, &gPlayerEntity, *(ptr) << 0x10, *(ptr + 1) << 0x10); + PositionRelative(super, &gPlayerEntity.base, *(ptr) << 0x10, *(ptr + 1) << 0x10); } tileType = GetTileType(this->unk_84, super->collisionLayer); if (tileType != 0x400b) { @@ -131,9 +131,9 @@ void PushableStatue_SubAction0(PushableStatueEntity* this) { gPlayerState.queued_action = PLAYER_PULL; gPlayerState.field_0x38 = 0x20; gPlayerState.flags |= PL_BUSY; - gPlayerEntity.x.HALF.LO = 0; - gPlayerEntity.y.HALF.LO = 0; - super->direction = (gPlayerEntity.animationState ^ 4) << 2; + gPlayerEntity.base.x.HALF.LO = 0; + gPlayerEntity.base.y.HALF.LO = 0; + super->direction = (gPlayerEntity.base.animationState ^ 4) << 2; sub_08089538(this); } } @@ -258,13 +258,13 @@ bool32 sub_080896B0(void) { u32 tmp2; u32 val; - if (((gPlayerState.heldObject & 0x1f) == 0x12) && ((gPlayerEntity.frame & 1) != 0)) { - ptr = &gUnk_080B4468[gPlayerEntity.animationState & 6]; - uVar1 = gUnk_080B4488[gPlayerEntity.animationState >> 1]; - uVar4 = COORD_TO_TILE_OFFSET(&gPlayerEntity, -ptr[0], -ptr[1]) - uVar1; - val = sub_080B1AE0(uVar4, gPlayerEntity.collisionLayer); + if (((gPlayerState.heldObject & 0x1f) == 0x12) && ((gPlayerEntity.base.frame & 1) != 0)) { + ptr = &gUnk_080B4468[gPlayerEntity.base.animationState & 6]; + uVar1 = gUnk_080B4488[gPlayerEntity.base.animationState >> 1]; + uVar4 = COORD_TO_TILE_OFFSET(&gPlayerEntity.base, -ptr[0], -ptr[1]) - uVar1; + val = sub_080B1AE0(uVar4, gPlayerEntity.base.collisionLayer); if ((val - 0x26 > 1) && (val != 0x29)) { - layer = GetLayerByIndex(gPlayerEntity.collisionLayer); + layer = GetLayerByIndex(gPlayerEntity.base.collisionLayer); iVar2 = (uVar4 * 0x10000) >> 0x10; tmp1 = layer->collisionData[iVar2]; tmp2 = layer->collisionData[(iVar2 - uVar1)]; diff --git a/src/object/shrinkingHieroglyphs.c b/src/object/shrinkingHieroglyphs.c index 1fcaa801..c490b834 100644 --- a/src/object/shrinkingHieroglyphs.c +++ b/src/object/shrinkingHieroglyphs.c @@ -69,7 +69,7 @@ void ShrinkingHieroglyphs_Action1(ShrinkingHieroglyphsEntity* this) { if (super->type == 0) { UpdateAnimationSingleFrame(super); if (super->type2 != 0) { - gPlayerEntity.subtimer = 0; + gPlayerEntity.base.subtimer = 0; super->action++; InitAnimationForceUpdate(super, 1); SoundReq(SFX_178); @@ -109,7 +109,7 @@ void ShrinkingHieroglyphs_Action2(ShrinkingHieroglyphsEntity* this) { } void sub_08098130(ShrinkingHieroglyphsEntity* this) { - CopyPosition(&gPlayerEntity, super); + CopyPosition(&gPlayerEntity.base, super); super->direction = this->objDir.HALF.HI; super->speed = this->unk7a; LinearMoveUpdate(super); diff --git a/src/object/specialFx.c b/src/object/specialFx.c index 5de442a3..bfe1a5e5 100644 --- a/src/object/specialFx.c +++ b/src/object/specialFx.c @@ -307,8 +307,8 @@ void sub_080847E0(SpecialFxObject* this) { if (gRoomControls.reload_flags == 1) { DeleteThisEntity(); } - PositionRelative(&gPlayerEntity, super, 0, -0x30000); + PositionRelative(&gPlayerEntity.base, super, 0, -0x30000); super->z.HALF.HI = -3; - SortEntityAbove(&gPlayerEntity, super); + SortEntityAbove(&gPlayerEntity.base, super); sub_080845DC(this); } diff --git a/src/object/steam.c b/src/object/steam.c index 451afadb..7cef37d1 100644 --- a/src/object/steam.c +++ b/src/object/steam.c @@ -43,7 +43,7 @@ void Steam(Entity* _this) { type = super->type; ptr = &this->unk_0x68; if (type != 0) { - if (gPlayerEntity.x.HALF.HI - gRoomControls.origin_x > (0xf8 << 1)) { + if (gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x > (0xf8 << 1)) { if (*ptr < 0x40) { (*ptr)++; } diff --git a/src/object/swordParticle.c b/src/object/swordParticle.c index 9721e52f..f86879a0 100644 --- a/src/object/swordParticle.c +++ b/src/object/swordParticle.c @@ -33,8 +33,8 @@ void SwordParticle_Init(SwordParticleEntity* this) { super->action = 1; super->flags |= ENT_PERSIST; super->spritePriority.b0 = 0; - super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; - super->animationState = gPlayerEntity.animationState >> 1; + super->spriteOrientation.flipY = gPlayerEntity.base.spriteOrientation.flipY; + super->animationState = gPlayerEntity.base.animationState >> 1; super->direction = (((super->animationState + 1) & 3) << 3); super->subtimer = 6; super->speed = 0x140; @@ -121,12 +121,12 @@ void SwordParticle_Action1(SwordParticleEntity* this) { } } - super->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; + super->spriteRendering.b3 = gPlayerEntity.base.spriteRendering.b3; ptr2 = &ptr[super->animationState * 2]; - super->x.HALF.HI = ptr2[0] + gPlayerEntity.x.HALF.HI; - super->y.HALF.HI = ptr[super->animationState * 2 + 1] + gPlayerEntity.y.HALF.HI; - super->z.HALF.HI = gPlayerEntity.z.HALF.HI; - super->collisionLayer = gPlayerEntity.collisionLayer; + super->x.HALF.HI = ptr2[0] + gPlayerEntity.base.x.HALF.HI; + super->y.HALF.HI = ptr[super->animationState * 2 + 1] + gPlayerEntity.base.y.HALF.HI; + super->z.HALF.HI = gPlayerEntity.base.z.HALF.HI; + super->collisionLayer = gPlayerEntity.base.collisionLayer; switch (super->animationState) { default: super->y.HALF.HI -= this->unk_6c; @@ -168,7 +168,7 @@ void SwordParticle_Action2(SwordParticleEntity* this) { sub_08079BD8(super); super->action++; super->spriteSettings.draw = 1; - super->animationState = gPlayerEntity.animationState; + super->animationState = gPlayerEntity.base.animationState; super->spriteVramOffset = 0; super->palette.b.b0 = 4; super->spriteIndex = 0xaf; diff --git a/src/object/thunderbolt.c b/src/object/thunderbolt.c index b1984fa2..543c08c4 100644 --- a/src/object/thunderbolt.c +++ b/src/object/thunderbolt.c @@ -100,7 +100,7 @@ void sub_08093EF0(ThunderboltEntity* this) { if ((super->frame & ANIM_DONE) == 0) { return; } - if (super->parent == &gPlayerEntity) { + if (super->parent == &gPlayerEntity.base) { SoundReq(SFX_PLY_VO6); sub_08079D84(); } diff --git a/src/object/trapdoor.c b/src/object/trapdoor.c index 34622516..809643dd 100644 --- a/src/object/trapdoor.c +++ b/src/object/trapdoor.c @@ -63,7 +63,7 @@ void Trapdoor_Action2(Entity* this) { } void Trapdoor_Action3(Entity* this) { - if (EntityInRectRadius(this, &gPlayerEntity, 0xc, 0xc)) { + if (EntityInRectRadius(this, &gPlayerEntity.base, 0xc, 0xc)) { if (this->subAction == 0) { sub_08099ECC(this); RequestPriorityDuration(this, 30); @@ -79,7 +79,7 @@ void Trapdoor_Action4(Entity* this) { void sub_08099ECC(Entity* this) { this->subAction = 1; - CopyPosition(this, &gPlayerEntity); + CopyPosition(this, &gPlayerEntity.base); gPlayerState.queued_action = PLAYER_FALL; gPlayerState.field_0x38 = 0; gPlayerState.flags |= PL_PIT_IS_EXIT; diff --git a/src/object/treeHidingPortal.c b/src/object/treeHidingPortal.c index fbd447e4..dc1792c3 100644 --- a/src/object/treeHidingPortal.c +++ b/src/object/treeHidingPortal.c @@ -52,7 +52,7 @@ void TreeHidingPortal_Init(TreeHidingPortalEntity* this) { void TreeHidingPortal_Action1(TreeHidingPortalEntity* this) { - if (sub_0800419C(super, &gPlayerEntity, 0x30, 0x30)) { + if (sub_0800419C(super, &gPlayerEntity.base, 0x30, 0x30)) { if (CheckGlobalFlag(EZERO_1ST)) { if (((gRoomTransition.frameCount & 3) == 0)) { CreateSparkle(super); @@ -112,11 +112,11 @@ static u32 sub_0809E9A0(void) { u32 rv; const s16* ptr; - if (gPlayerEntity.action != PLAYER_BOUNCE) { + if (gPlayerEntity.base.action != PLAYER_BOUNCE) { rv = 0; } else { - ptr = &gUnk_080B4468[gPlayerEntity.animationState & 6]; - rv = sub_080B1AE0(COORD_TO_TILE_OFFSET(&gPlayerEntity, -ptr[0], -ptr[1]), 1); + ptr = &gUnk_080B4468[gPlayerEntity.base.animationState & 6]; + rv = sub_080B1AE0(COORD_TO_TILE_OFFSET(&gPlayerEntity.base, -ptr[0], -ptr[1]), 1); } return rv; diff --git a/src/object/vaati1Portal.c b/src/object/vaati1Portal.c index e757f9c1..78924aff 100644 --- a/src/object/vaati1Portal.c +++ b/src/object/vaati1Portal.c @@ -49,7 +49,7 @@ void Vaati1Portal_Action2(Entity* this) { if (CheckRoomFlag(1)) { sub_080A0190(this); RequestPriorityDuration(this, 30); - if (EntityInRectRadius(this, &gPlayerEntity, 0x10, 0x10)) { + if (EntityInRectRadius(this, &gPlayerEntity.base, 0x10, 0x10)) { CreateHoleManager(0x37); } } @@ -57,7 +57,7 @@ void Vaati1Portal_Action2(Entity* this) { void sub_080A0190(Entity* this) { this->subAction = 1; - CopyPosition(this, &gPlayerEntity); + CopyPosition(this, &gPlayerEntity.base); gPlayerState.queued_action = PLAYER_FALL; gPlayerState.field_0x38 = 0; gPlayerState.flags |= PL_PIT_IS_EXIT; diff --git a/src/object/vaati3PlayerObject.c b/src/object/vaati3PlayerObject.c index 0cec61c1..6420cbab 100644 --- a/src/object/vaati3PlayerObject.c +++ b/src/object/vaati3PlayerObject.c @@ -16,5 +16,5 @@ void Vaati3PlayerObject(Entity* this) { #ifndef EU gRoomControls.camera_target = this; #endif - PositionRelative(&gPlayerEntity, this, 0, Q_16_16(-40.0)); + PositionRelative(&gPlayerEntity.base, this, 0, Q_16_16(-40.0)); } diff --git a/src/object/warpPoint.c b/src/object/warpPoint.c index 166b17e2..67798907 100644 --- a/src/object/warpPoint.c +++ b/src/object/warpPoint.c @@ -69,9 +69,9 @@ void WarpPoint_Init(WarpPointEntity* this) { return; super->action = 4; super->subtimer = 96; - gPlayerEntity.x.HALF.HI = super->x.HALF.HI; - gPlayerEntity.y.HALF.HI = super->y.HALF.HI; - gPlayerEntity.animationState = 4; + gPlayerEntity.base.x.HALF.HI = super->x.HALF.HI; + gPlayerEntity.base.y.HALF.HI = super->y.HALF.HI; + gPlayerEntity.base.animationState = 4; EnqueueSFX(SFX_112); RequestPriorityDuration(super, super->subtimer + 16); } @@ -104,10 +104,10 @@ void WarpPoint_Action3(WarpPointEntity* this) { super->action = 5; super->subtimer = 96; PutAwayItems(); - gPlayerEntity.x.HALF.HI = super->x.HALF.HI; - gPlayerEntity.y.HALF.HI = super->y.HALF.HI; - gPlayerEntity.animationState = 4; - gPlayerEntity.flags &= ~ENT_COLLIDE; + gPlayerEntity.base.x.HALF.HI = super->x.HALF.HI; + gPlayerEntity.base.y.HALF.HI = super->y.HALF.HI; + gPlayerEntity.base.animationState = 4; + gPlayerEntity.base.flags &= ~ENT_COLLIDE; RequestPriorityDuration(super, super->subtimer + 16); SoundReq(SFX_113); } else { @@ -120,8 +120,8 @@ void WarpPoint_Action4(WarpPointEntity* this) { if (!--super->subtimer) { super->action = 3; super->timer = 1; - gPlayerEntity.animationState = 4; - gPlayerEntity.direction = DirectionSouth; + gPlayerEntity.base.animationState = 4; + gPlayerEntity.base.direction = DirectionSouth; return; } tmp = 0; @@ -141,7 +141,7 @@ void WarpPoint_Action4(WarpPointEntity* this) { break; case 0: if (!(super->subtimer & 7)) { - if (gPlayerEntity.animationState == 4) { + if (gPlayerEntity.base.animationState == 4) { if (super->subtimer > 0x18) { tmp = 1; } @@ -152,8 +152,8 @@ void WarpPoint_Action4(WarpPointEntity* this) { break; } if (tmp) { - gPlayerEntity.animationState += 2; - gPlayerEntity.animationState &= 6; + gPlayerEntity.base.animationState += 2; + gPlayerEntity.base.animationState &= 6; } } @@ -192,13 +192,13 @@ void WarpPoint_Action5(WarpPointEntity* this) { tmp = 1; } } else { - gPlayerEntity.spriteSettings.draw = 0; + gPlayerEntity.base.spriteSettings.draw = 0; } break; } if (tmp) { - gPlayerEntity.animationState += 2; - gPlayerEntity.animationState &= 6; + gPlayerEntity.base.animationState += 2; + gPlayerEntity.base.animationState &= 6; } } @@ -208,10 +208,10 @@ void sub_0808B73C(WarpPointEntity* this) { super->palette.b.b0 = super->parent->palette.b.b0; InitializeAnimation(super, 1); } - if (EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x28)) { + if (EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, 0x28)) { super->spriteSettings.draw = 1; } else { - if (EntityWithinDistance(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, 0x2e)) { + if (EntityWithinDistance(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI, 0x2e)) { super->spriteSettings.draw ^= 1; } else { super->spriteSettings.draw = 0; @@ -221,9 +221,10 @@ void sub_0808B73C(WarpPointEntity* this) { } u32 sub_0808B7C8(WarpPointEntity* this) { - if (!(gPlayerState.flags & PL_MINISH) && gPlayerState.framestate != PL_STATE_DIE && gPlayerEntity.health != 0 && - PlayerCanBeMoved() && EntityInRectRadius(super, &gPlayerEntity, 5, 5) && gPlayerEntity.z.HALF.HI == 0) { - if (super->timer == 0 && gPlayerEntity.action == PLAYER_08072C9C) { + if (!(gPlayerState.flags & PL_MINISH) && gPlayerState.framestate != PL_STATE_DIE && + gPlayerEntity.base.health != 0 && PlayerCanBeMoved() && EntityInRectRadius(super, &gPlayerEntity.base, 5, 5) && + gPlayerEntity.base.z.HALF.HI == 0) { + if (super->timer == 0 && gPlayerEntity.base.action == PLAYER_08072C9C) { ResetPlayerAnimationAndAction(); } return 1; diff --git a/src/object/well.c b/src/object/well.c index 83c3f324..c48948b1 100644 --- a/src/object/well.c +++ b/src/object/well.c @@ -40,8 +40,8 @@ void Well_Action1(WellEntity* this) { u32 tileIndex = GetTileType(this->unk_80, 1); if (tileIndex != 0x407D) { PausePlayer(); - gPlayerEntity.x.WORD = super->x.WORD; - gPlayerEntity.y.HALF.HI = super->y.HALF.HI + 4; + gPlayerEntity.base.x.WORD = super->x.WORD; + gPlayerEntity.base.y.HALF.HI = super->y.HALF.HI + 4; DeleteThisEntity(); } } diff --git a/src/object/whirlwind.c b/src/object/whirlwind.c index fff6ed52..979a62a3 100644 --- a/src/object/whirlwind.c +++ b/src/object/whirlwind.c @@ -59,24 +59,25 @@ void Whirlwind_Action1(Entity* this) { if (this->spriteSettings.draw != 0) { GetNextFrame(this); if ((((((gPlayerState.flags & PL_MINISH) == 0)) && (gPlayerState.field_0x3c == 0)) && - ((gPlayerEntity.action == PLAYER_JUMP || ((gPlayerEntity.flags & ENT_COLLIDE) != 0)))) && - ((gPlayerEntity.action != PLAYER_BOUNCE && (sub_0800419C(this, &gPlayerEntity, 0xc, 0xc) != 0)))) { - if (((gPlayerState.flags & PL_PARACHUTE) == 0) && (gPlayerEntity.action != PLAYER_JUMP)) { - if ((this->type2 != 1) && (-0x10 < gPlayerEntity.z.HALF.HI)) { + ((gPlayerEntity.base.action == PLAYER_JUMP || ((gPlayerEntity.base.flags & ENT_COLLIDE) != 0)))) && + ((gPlayerEntity.base.action != PLAYER_BOUNCE && + (sub_0800419C(this, &gPlayerEntity.base, 0xc, 0xc) != 0)))) { + if (((gPlayerState.flags & PL_PARACHUTE) == 0) && (gPlayerEntity.base.action != PLAYER_JUMP)) { + if ((this->type2 != 1) && (-0x10 < gPlayerEntity.base.z.HALF.HI)) { return; } - } else if (gPlayerEntity.z.HALF.HI == 0) { + } else if (gPlayerEntity.base.z.HALF.HI == 0) { return; } - CopyPosition(this, &gPlayerEntity); + CopyPosition(this, &gPlayerEntity.base); sub_08004542(this); - sub_08004542(&gPlayerEntity); - gPlayerEntity.collisionLayer = 1; - gPlayerEntity.flags |= ENT_COLLIDE; + sub_08004542(&gPlayerEntity.base); + gPlayerEntity.base.collisionLayer = 1; + gPlayerEntity.base.flags |= ENT_COLLIDE; gPlayerState.queued_action = PLAYER_PARACHUTE; gPlayerState.field_0x38 = this->type2; gPlayerState.field_0x39 = 0xff; - this->spritePriority.b0 = gPlayerEntity.spritePriority.b0 - 1; + this->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0 - 1; this->action++; PutAwayItems(); SoundReq(SFX_153); @@ -87,7 +88,7 @@ void Whirlwind_Action1(Entity* this) { void Whirlwind_Action2(Entity* this) { UpdateAnimationSingleFrame(this); - if (sub_0800419C(this, &gPlayerEntity, 0xc, 0xc) == 0) { + if (sub_0800419C(this, &gPlayerEntity.base, 0xc, 0xc) == 0) { ResetCollisionLayer(this); this->spriteOrientation.flipY = 1; this->spriteRendering.b3 = 1; diff --git a/src/object/windTribeTeleporter.c b/src/object/windTribeTeleporter.c index 8de92ec3..5a238478 100644 --- a/src/object/windTribeTeleporter.c +++ b/src/object/windTribeTeleporter.c @@ -40,8 +40,8 @@ void WindTribeTeleporter_Init(WindTribeTeleporterEntity* this) { super->hitbox = (Hitbox*)&gHitbox_22; SetEntityPriority(super, 6); if (PlayerCollidingTeleporter(this)) { - gPlayerEntity.x.HALF.HI = super->x.HALF.HI; - gPlayerEntity.y.HALF.HI = super->y.HALF.HI; + gPlayerEntity.base.x.HALF.HI = super->x.HALF.HI; + gPlayerEntity.base.y.HALF.HI = super->y.HALF.HI; SetPlayerControl(CONTROL_DISABLED); PausePlayer(); SetPlayerEventPriority(); @@ -55,8 +55,8 @@ void WindTribeTeleporter_Init(WindTribeTeleporterEntity* this) { void WindTribeTeleporter_Action1(WindTribeTeleporterEntity* this) { if (PlayerCollidingTeleporter(this)) { if (this->unk_68 == 0) { - gPlayerEntity.x.HALF.HI = super->x.HALF.HI; - gPlayerEntity.y.HALF.HI = super->y.HALF.HI; + gPlayerEntity.base.x.HALF.HI = super->x.HALF.HI; + gPlayerEntity.base.y.HALF.HI = super->y.HALF.HI; SetPlayerControl(CONTROL_DISABLED); PausePlayer(); SetPlayerEventPriority(); @@ -88,7 +88,7 @@ void WindTribeTeleporter_Action2(WindTribeTeleporterEntity* this) { SoundReq(SFX_113); } else { if ((gRoomTransition.frameCount & 7) == 0) { - gPlayerEntity.animationState = (gPlayerEntity.animationState + 2) & 6; + gPlayerEntity.base.animationState = (gPlayerEntity.base.animationState + 2) & 6; } } break; @@ -98,7 +98,7 @@ void WindTribeTeleporter_Action2(WindTribeTeleporterEntity* this) { super->timer = 30; } else { if ((gRoomTransition.frameCount & 3) == 0) { - gPlayerEntity.animationState = (gPlayerEntity.animationState + 2) & 6; + gPlayerEntity.base.animationState = (gPlayerEntity.base.animationState + 2) & 6; } } break; @@ -117,7 +117,7 @@ void WindTribeTeleporter_Action2(WindTribeTeleporterEntity* this) { #endif } else { if ((gRoomTransition.frameCount & 1) == 0) { - gPlayerEntity.animationState = (gPlayerEntity.animationState + 2) & 6; + gPlayerEntity.base.animationState = (gPlayerEntity.base.animationState + 2) & 6; } } break; @@ -134,7 +134,7 @@ void WindTribeTeleporter_Action3(WindTribeTeleporterEntity* this) { case 1: if (--super->timer != 0) { if ((gRoomTransition.frameCount & 1) == 0) { - gPlayerEntity.animationState = (gPlayerEntity.animationState + 2) & 6; + gPlayerEntity.base.animationState = (gPlayerEntity.base.animationState + 2) & 6; } } else { super->subAction++; @@ -147,7 +147,7 @@ void WindTribeTeleporter_Action3(WindTribeTeleporterEntity* this) { super->timer = 30; } else { if ((gRoomTransition.frameCount & 3) == 0) { - gPlayerEntity.animationState = (gPlayerEntity.animationState + 2) & 6; + gPlayerEntity.base.animationState = (gPlayerEntity.base.animationState + 2) & 6; } } break; @@ -156,16 +156,16 @@ void WindTribeTeleporter_Action3(WindTribeTeleporterEntity* this) { super->subAction++; } else { if ((gRoomTransition.frameCount & 7) == 0) { - gPlayerEntity.animationState = (gPlayerEntity.animationState + 2) & 6; + gPlayerEntity.base.animationState = (gPlayerEntity.base.animationState + 2) & 6; } } break; default: - if (gPlayerEntity.animationState != 4) { + if (gPlayerEntity.base.animationState != 4) { if ((gRoomTransition.frameCount & 7U) != 0) { return; } - gPlayerEntity.animationState = (gPlayerEntity.animationState + 2) & 6; + gPlayerEntity.base.animationState = (gPlayerEntity.base.animationState + 2) & 6; } else { super->action = 1; super->subAction = 0; @@ -177,7 +177,7 @@ void WindTribeTeleporter_Action3(WindTribeTeleporterEntity* this) { } static bool32 PlayerCollidingTeleporter(WindTribeTeleporterEntity* this) { - if (gPlayerEntity.z.HALF.HI != 0) { + if (gPlayerEntity.base.z.HALF.HI != 0) { return FALSE; } else { return IsCollidingPlayer(super); diff --git a/src/objectUtils.c b/src/objectUtils.c index c424e5a3..21ec9568 100644 --- a/src/objectUtils.c +++ b/src/objectUtils.c @@ -40,14 +40,14 @@ Entity* CreateLinkAnimation(Entity* parent, u32 type, u32 type2) { e->parent = parent; AppendEntityToList(e, 6); PrependEntityToList(e, 6); - CopyPosition(&gPlayerEntity, e); + CopyPosition(&gPlayerEntity.base, e); gPriorityHandler.event_priority = 6; gPauseMenuOptions.disabled = 1; // store player state - this->storeFlags = gPlayerEntity.flags; - this->storeDrawFlags = gPlayerEntity.spriteSettings.draw; - this->storeIFrames = gPlayerEntity.iframes; + this->storeFlags = gPlayerEntity.base.flags; + this->storeDrawFlags = gPlayerEntity.base.spriteSettings.draw; + this->storeIFrames = gPlayerEntity.base.iframes; this->storeField7 = gPlayerState.field_0x7; this->storeKeepFacing = gPlayerState.keepFacing; this->storeFieldA = gPlayerState.field_0xa; @@ -57,8 +57,8 @@ Entity* CreateLinkAnimation(Entity* parent, u32 type, u32 type2) { this->store8A = gPlayerState.field_0x8a; // redundant, this is done by the LinkAnimation object - gPlayerEntity.flags &= ~ENT_COLLIDE; - gPlayerEntity.spriteSettings.draw = 0; + gPlayerEntity.base.flags &= ~ENT_COLLIDE; + gPlayerEntity.base.spriteSettings.draw = 0; } return e; } @@ -290,7 +290,7 @@ void SyncPlayerToPlatform(Entity* this, bool32 param_2) { newValue1 = this->y.HALF_U.HI; diff = ((oldValue1 - newValue1)); if ((diff != 0) && (param_2 != 0)) { - sub_080044AE(&gPlayerEntity, diff << 8, 0); + sub_080044AE(&gPlayerEntity.base, diff << 8, 0); } break; case 1: @@ -299,7 +299,7 @@ void SyncPlayerToPlatform(Entity* this, bool32 param_2) { newValue2 = this->x.HALF_U.HI; diff = (newValue2 - oldValue2); if ((diff != 0) && (param_2 != 0)) { - sub_080044AE(&gPlayerEntity, diff << 8, 8); + sub_080044AE(&gPlayerEntity.base, diff << 8, 8); } break; case 2: @@ -308,7 +308,7 @@ void SyncPlayerToPlatform(Entity* this, bool32 param_2) { newValue3 = this->y.HALF_U.HI; diff = (newValue3 - oldValue2); if ((diff != 0) && (param_2 != 0)) { - sub_080044AE(&gPlayerEntity, diff << 8, 0x10); + sub_080044AE(&gPlayerEntity.base, diff << 8, 0x10); } break; case 3: @@ -317,7 +317,7 @@ void SyncPlayerToPlatform(Entity* this, bool32 param_2) { newValue4 = this->x.HALF_U.HI; diff = ((oldValue1 - newValue4)); if ((diff != 0) && (param_2 != 0)) { - sub_080044AE(&gPlayerEntity, diff << 8, 0x18); + sub_080044AE(&gPlayerEntity.base, diff << 8, 0x18); } break; } diff --git a/src/physics.c b/src/physics.c index 497dc793..206b33c3 100644 --- a/src/physics.c +++ b/src/physics.c @@ -1,14 +1,13 @@ -#include "asm.h" #include "area.h" -#include "player.h" -#include "new_player.h" -#include "physics.h" -#include "common.h" -#include "sound.h" -#include "room.h" -#include "functions.h" +#include "asm.h" #include "color.h" +#include "common.h" +#include "functions.h" +#include "physics.h" +#include "player.h" #include "playeritem.h" +#include "room.h" +#include "sound.h" const u8 gSpriteSortAboveTable[]; const u8 gSpriteSortBelowTable[]; @@ -36,17 +35,17 @@ void sub_0806F38C(void) { u32 sub_0806F39C(Entity* ent) { s32 dist; - if (gNewPlayerEntity.base.animationState & 2) { - dist = ent->x.HALF.HI - gPlayerEntity.x.HALF.HI; + if (gPlayerEntity.base.animationState & 2) { + dist = ent->x.HALF.HI - gPlayerEntity.base.x.HALF.HI; } else { - dist = ent->y.HALF.HI - gPlayerEntity.y.HALF.HI; + dist = ent->y.HALF.HI - gPlayerEntity.base.y.HALF.HI; } if (dist < 0) { dist = -dist; } if (dist > 64) { - sub_080027EA(&gPlayerEntity, ent->speed, ent->direction); + sub_080027EA(&gPlayerEntity.base, ent->speed, ent->direction); return 1; } return 0; @@ -71,16 +70,16 @@ bool32 sub_0806F3E4(Entity* ent) { } if (ent->knockbackSpeed > 0x500) ent->knockbackSpeed = 0x500; - p = &gUnk_08126EE4[gPlayerEntity.animationState & 0xE]; - tmp_ent.base.x.HALF.HI = p[0] + gPlayerEntity.x.HALF.HI; - tmp_ent.base.y.HALF.HI = p[1] + gPlayerEntity.y.HALF.HI; + p = &gUnk_08126EE4[gPlayerEntity.base.animationState & 0xE]; + tmp_ent.base.x.HALF.HI = p[0] + gPlayerEntity.base.x.HALF.HI; + tmp_ent.base.y.HALF.HI = p[1] + gPlayerEntity.base.y.HALF.HI; LinearMoveDirection(ent, ent->knockbackSpeed, GetFacingDirection(ent, &tmp_ent.base)); if (sub_0800419C(&tmp_ent.base, ent, 4, 4)) { u32 state = ent->gustJarFlags & 0xF; if (state == 2) { Entity* item; ent->subAction = 3; - gNewPlayerEntity.unk_70 = ent; + gPlayerEntity.unk_70 = ent; gPlayerState.field_0x1c = 7; item = CreatePlayerItem(PLAYER_ITEM_GUST_BIG, 0, 0, 0); if (item != NULL) { @@ -393,8 +392,8 @@ void UnloadHitbox(Entity* ent) { } bool32 CheckPlayerProximity(u32 x, u32 y, u32 distX, u32 DistY) { - s32 diffx = gPlayerEntity.x.HALF.HI - x; - s32 diffy = gPlayerEntity.y.HALF.HI - y; + s32 diffx = gPlayerEntity.base.x.HALF.HI - x; + s32 diffy = gPlayerEntity.base.y.HALF.HI - y; u32 rv = 0; if (diffx < distX && diffy < DistY) { rv = 1; @@ -482,7 +481,7 @@ bool32 sub_0806FD54(Entity* this) { if ((gPlayerState.flags & PL_USE_LANTERN) == 0) { rv = 0; } else { - rv = EntityWithinDistance(this, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI - 9, 0x48); + rv = EntityWithinDistance(this, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI - 9, 0x48); } return rv; diff --git a/src/player.c b/src/player.c index 26d12f8a..6c89f022 100644 --- a/src/player.c +++ b/src/player.c @@ -4,7 +4,6 @@ * * @brief Player entity */ -#define ENT_DEPRECATED #include "area.h" #include "asm.h" #include "collision.h" @@ -20,6 +19,7 @@ #include "object.h" #include "player.h" #include "playeritem.h" +#include "playerItem/playerItemBottle.h" #include "save.h" #include "screen.h" #include "screenTransitions.h" @@ -48,224 +48,226 @@ #define FALL_DAMAGE 2 -static EntityAction PlayerInit; -static EntityAction PlayerNormal; -// static EntityAction PlayerInit; -static EntityAction PlayerFall; -static EntityAction PlayerJump; -static EntityAction PlayerPush; -static EntityAction PlayerBounce; -static EntityAction sub_08070E9C; -static EntityAction PlayerItemGet; -static EntityAction PlayerMinish; -static EntityAction PlayerMinishDie; -static EntityAction sub_08071DB8; -static EntityAction PlayerEmptyBottle; -static EntityAction PlayerFrozen; -static EntityAction sub_0807204C; -static EntityAction PlayerRoomExit; -static EntityAction PlayerPull; -static EntityAction PlayerLava; -EntityAction PlayerWarp; // why is this defined in playerUtils.c? We may never know : ( -static EntityAction sub_08072454; -static EntityAction PlayerDrown; -static EntityAction PlayerUsePortal; -static EntityAction PlayerTalkEzlo; -static EntityAction PlayerRoomTransition; -static EntityAction PlayerRoll; -static EntityAction PlayerWaitForScroll; -static EntityAction PlayerInHole; -static EntityAction sub_08072C9C; -static EntityAction PlayerSleep; -static EntityAction PlayerClimb; -static EntityAction PlayerUseEntrance; -static EntityAction PlayerParachute; +typedef void(PlayerEntityAction)(PlayerEntity*); + +static PlayerEntityAction PlayerInit; +static PlayerEntityAction PlayerNormal; +// static PlayerEntityAction PlayerInit; +static PlayerEntityAction PlayerFall; +static PlayerEntityAction PlayerJump; +static PlayerEntityAction PlayerPush; +static PlayerEntityAction PlayerBounce; +static PlayerEntityAction sub_08070E9C; +static PlayerEntityAction PlayerItemGet; +static PlayerEntityAction PlayerMinish; +static PlayerEntityAction PlayerMinishDie; +static PlayerEntityAction sub_08071DB8; +static PlayerEntityAction PlayerEmptyBottle; +static PlayerEntityAction PlayerFrozen; +static PlayerEntityAction sub_0807204C; +static PlayerEntityAction PlayerRoomExit; +static PlayerEntityAction PlayerPull; +static PlayerEntityAction PlayerLava; +PlayerEntityAction PlayerWarp; // why is super defined in playerUtils.c? We may never know : ( +static PlayerEntityAction sub_08072454; +static PlayerEntityAction PlayerDrown; +static PlayerEntityAction PlayerUsePortal; +static PlayerEntityAction PlayerTalkEzlo; +static PlayerEntityAction PlayerRoomTransition; +static PlayerEntityAction PlayerRoll; +static PlayerEntityAction PlayerWaitForScroll; +static PlayerEntityAction PlayerInHole; +static PlayerEntityAction sub_08072C9C; +static PlayerEntityAction PlayerSleep; +static PlayerEntityAction PlayerClimb; +static PlayerEntityAction PlayerUseEntrance; +static PlayerEntityAction PlayerParachute; // PLAYER_FALL -static EntityAction PlayerFallInit; -static EntityAction PlayerFallUpdate; +static PlayerEntityAction PlayerFallInit; +static PlayerEntityAction PlayerFallUpdate; // PLAYER_BOUNCE -static EntityAction PlayerBounceInit; -static EntityAction PlayerBounceUpdate; -static EntityAction sub_08070E7C; +static PlayerEntityAction PlayerBounceInit; +static PlayerEntityAction PlayerBounceUpdate; +static PlayerEntityAction sub_08070E7C; // PLAYER_08070E9C -static EntityAction sub_08070EDC; -static EntityAction sub_08070f24; +static PlayerEntityAction sub_08070EDC; +static PlayerEntityAction sub_08070f24; // PLAYER_ITEMGET -static EntityAction PlayerItemGetInit; -static EntityAction PlayerItemGetUpdate; -static EntityAction sub_08071038; +static PlayerEntityAction PlayerItemGetInit; +static PlayerEntityAction PlayerItemGetUpdate; +static PlayerEntityAction sub_08071038; // PLAYER_JUMP -static EntityAction PlayerJumpInit; -static EntityAction sub_08071130; -static EntityAction sub_08071208; +static PlayerEntityAction PlayerJumpInit; +static PlayerEntityAction sub_08071130; +static PlayerEntityAction sub_08071208; // PLAYER_DROWN -static EntityAction PlayerDrownInit; -static EntityAction sub_080712F0; +static PlayerEntityAction PlayerDrownInit; +static PlayerEntityAction sub_080712F0; // PLAYER_USEPORTAL -static EntityAction PortalJumpOnUpdate; -static EntityAction PortalStandUpdate; -static EntityAction PortalActivateInit; -static EntityAction PortalActivateUpdate; -static EntityAction PortalShrinkInit; -static EntityAction PortalShrinkUpdate; -static EntityAction PortalEnterUpdate; -static EntityAction PortalUnknownUpdate; +static PlayerEntityAction PortalJumpOnUpdate; +static PlayerEntityAction PortalStandUpdate; +static PlayerEntityAction PortalActivateInit; +static PlayerEntityAction PortalActivateUpdate; +static PlayerEntityAction PortalShrinkInit; +static PlayerEntityAction PortalShrinkUpdate; +static PlayerEntityAction PortalEnterUpdate; +static PlayerEntityAction PortalUnknownUpdate; // PLAYER_TALKEZLO -static EntityAction PlayerTalkEzlo_Init; -static EntityAction PlayerTalkEzlo_CreateMessage; -static EntityAction PlayerTalkEzlo_MessageIdle; -static EntityAction PlayerTalkEzlo_Leave; +static PlayerEntityAction PlayerTalkEzlo_Init; +static PlayerEntityAction PlayerTalkEzlo_CreateMessage; +static PlayerEntityAction PlayerTalkEzlo_MessageIdle; +static PlayerEntityAction PlayerTalkEzlo_Leave; // PLAYER_PUSH -static EntityAction PlayerPushInit; -static EntityAction PlayerPushUpdate; -static EntityAction PlayerPushEnd; +static PlayerEntityAction PlayerPushInit; +static PlayerEntityAction PlayerPushUpdate; +static PlayerEntityAction PlayerPushEnd; // PLAYER_MINISHDIE -static EntityAction PlayerMinishDieInit; -static EntityAction sub_08071CAC; -static EntityAction sub_08071D04; -static EntityAction sub_08071D80; +static PlayerEntityAction PlayerMinishDieInit; +static PlayerEntityAction sub_08071CAC; +static PlayerEntityAction sub_08071D04; +static PlayerEntityAction sub_08071D80; // PLAYER_08071DB8 -static EntityAction sub_08071DD0; -static EntityAction sub_08071E04; -static EntityAction sub_08071E74; +static PlayerEntityAction sub_08071DD0; +static PlayerEntityAction sub_08071E04; +static PlayerEntityAction sub_08071E74; // PLAYER_EMPTYBOTTLE -static EntityAction PlayerEmptyBottleInit; -static EntityAction PlayerEmptyBottleUpdate; +static PlayerEntityAction PlayerEmptyBottleInit; +static PlayerEntityAction PlayerEmptyBottleUpdate; // PLAYER_FROZEN -static EntityAction PlayerFrozenInit; -static EntityAction PlayerFrozenUpdate; +static PlayerEntityAction PlayerFrozenInit; +static PlayerEntityAction PlayerFrozenUpdate; // PLAYER_0807204C -static EntityAction sub_08072064; -static EntityAction sub_08072098; +static PlayerEntityAction sub_08072064; +static PlayerEntityAction sub_08072098; // PLAYER_ROOM_EXIT -static EntityAction sub_08072100; -static EntityAction sub_08072168; +static PlayerEntityAction sub_08072100; +static PlayerEntityAction sub_08072168; // PLAYER_PULL -static EntityAction sub_08072214; -static EntityAction sub_08072260; +static PlayerEntityAction sub_08072214; +static PlayerEntityAction sub_08072260; // PLAYER_LAVA -static EntityAction PlayerLavaInit; -static EntityAction sub_08072354; -static EntityAction sub_080723D0; -static EntityAction sub_0807240C; +static PlayerEntityAction PlayerLavaInit; +static PlayerEntityAction sub_08072354; +static PlayerEntityAction sub_080723D0; +static PlayerEntityAction sub_0807240C; // PLAYER_08072454 -static EntityAction sub_0807246C; -static EntityAction sub_08072490; +static PlayerEntityAction sub_0807246C; +static PlayerEntityAction sub_08072490; // PLAYER_ROOMTRANSITION -static EntityAction sub_080724DC; -static EntityAction sub_0807258C; +static PlayerEntityAction sub_080724DC; +static PlayerEntityAction sub_0807258C; // PLAYER_ROLL -static EntityAction PlayerRollInit; -static EntityAction PlayerRollUpdate; +static PlayerEntityAction PlayerRollInit; +static PlayerEntityAction PlayerRollUpdate; // PLAYER_INHOLE -static EntityAction PlayerInHoleInit; -static EntityAction PlayerInHoleUpdate; -static EntityAction sub_08072ACC; -static EntityAction sub_08072B5C; -static EntityAction sub_08072C48; +static PlayerEntityAction PlayerInHoleInit; +static PlayerEntityAction PlayerInHoleUpdate; +static PlayerEntityAction sub_08072ACC; +static PlayerEntityAction sub_08072B5C; +static PlayerEntityAction sub_08072C48; // PLAYER_08072C9C -static EntityAction sub_08072CC0; -static EntityAction sub_08072CFC; -static EntityAction sub_08072D54; -static EntityAction sub_08072F14; +static PlayerEntityAction sub_08072CC0; +static PlayerEntityAction sub_08072CFC; +static PlayerEntityAction sub_08072D54; +static PlayerEntityAction sub_08072F14; // PLAYER_CLIMB -static EntityAction sub_08072F94; -static EntityAction sub_08073094; +static PlayerEntityAction sub_08072F94; +static PlayerEntityAction sub_08073094; // PLAYER_USEENTRANCE -static EntityAction PlayerUseStairs; -static EntityAction sub_080732D0; -static EntityAction sub_0807332C; -static EntityAction sub_080733BC; +static PlayerEntityAction PlayerUseStairs; +static PlayerEntityAction sub_080732D0; +static PlayerEntityAction sub_0807332C; +static PlayerEntityAction sub_080733BC; // PLAYER_PARACHUTE -static EntityAction sub_08073468; -static EntityAction sub_080734D4; -static EntityAction sub_08073504; -static EntityAction sub_08073584; -static EntityAction sub_0807379C; -static EntityAction sub_080737BC; -static EntityAction sub_0807380C; -static EntityAction sub_08073884; +static PlayerEntityAction sub_08073468; +static PlayerEntityAction sub_080734D4; +static PlayerEntityAction sub_08073504; +static PlayerEntityAction sub_08073584; +static PlayerEntityAction sub_0807379C; +static PlayerEntityAction sub_080737BC; +static PlayerEntityAction sub_0807380C; +static PlayerEntityAction sub_08073884; // DoJump... ? -static EntityAction sub_08073924; -static EntityAction sub_08073968; -static EntityAction sub_080739EC; -static EntityAction sub_08073A94; -static EntityAction sub_08073B8C; -static EntityAction sub_08073C30; +static PlayerEntityAction sub_08073924; +static PlayerEntityAction sub_08073968; +static PlayerEntityAction sub_080739EC; +static PlayerEntityAction sub_08073A94; +static PlayerEntityAction sub_08073B8C; +static PlayerEntityAction sub_08073C30; // PLAYER_MINISH -static EntityAction sub_08073C80; -static EntityAction sub_08073D20; -static EntityAction sub_08073F04; -static EntityAction sub_08073F4C; -static EntityAction sub_08073FD0; -static EntityAction sub_08074018; -static EntityAction sub_08074060; -static EntityAction sub_080740D8; +static PlayerEntityAction sub_08073C80; +static PlayerEntityAction sub_08073D20; +static PlayerEntityAction sub_08073F04; +static PlayerEntityAction sub_08073F4C; +static PlayerEntityAction sub_08073FD0; +static PlayerEntityAction sub_08074018; +static PlayerEntityAction sub_08074060; +static PlayerEntityAction sub_080740D8; // PLAYER_SLEEP -static EntityAction sub_08074C68; -static EntityAction sub_08074CF8; -static EntityAction sub_08074F00; -static EntityAction sub_080750F4; +static PlayerEntityAction sub_08074C68; +static PlayerEntityAction sub_08074CF8; +static PlayerEntityAction sub_08074F00; +static PlayerEntityAction sub_080750F4; // ... -static EntityAction sub_08074F1C; -static EntityAction sub_08074F2C; -static EntityAction sub_08074F44; -static EntityAction sub_08074F8C; -static EntityAction sub_08074FEC; -static EntityAction sub_0807501C; -static EntityAction sub_0807508C; +static PlayerEntityAction sub_08074F1C; +static PlayerEntityAction sub_08074F2C; +static PlayerEntityAction sub_08074F44; +static PlayerEntityAction sub_08074F8C; +static PlayerEntityAction sub_08074FEC; +static PlayerEntityAction sub_0807501C; +static PlayerEntityAction sub_0807508C; // ... -static EntityAction sub_08075110; -static EntityAction sub_0807513C; -static EntityAction sub_0807518C; -static EntityAction sub_080751B4; +static PlayerEntityAction sub_08075110; +static PlayerEntityAction sub_0807513C; +static PlayerEntityAction sub_0807518C; +static PlayerEntityAction sub_080751B4; // static helper functions -static void DoJump(Entity*); -static void sub_080717F8(Entity*); +static void DoJump(PlayerEntity*); +static void sub_080717F8(PlayerEntity*); static void reset_priority(void); -static void break_out(Entity* this); -static void sub_08073AD4(Entity* this); -static void sub_08073B60(Entity*); -static void sub_08074244(Entity*, u32, u32); -static void hide(Entity*); -static void conveyer_push(Entity*); -static void sub_08074D34(Entity*, ScriptExecutionContext*); -static void sub_08070BEC(Entity*, u32); -static void sub_08074808(Entity* this); +static void break_out(PlayerEntity* this); +static void sub_08073AD4(PlayerEntity* this); +static void sub_08073B60(PlayerEntity*); +static void sub_08074244(PlayerEntity*, u32, u32); +static void hide(PlayerEntity*); +static void conveyer_push(PlayerEntity*); +static void sub_08074D34(PlayerEntity*, ScriptExecutionContext*); +static void sub_08070BEC(PlayerEntity*, u32); +static void sub_08074808(PlayerEntity* this); // exports -void SurfaceAction_Water(Entity*); -void SurfaceAction_Ladder(Entity*); -void SurfaceAction_AutoLadder(Entity*); +void SurfaceAction_Water(PlayerEntity*); +void SurfaceAction_Ladder(PlayerEntity*); +void SurfaceAction_AutoLadder(PlayerEntity*); extern void InitPauseMenu(void); extern u32 UpdatePlayerCollision(void); @@ -298,8 +300,8 @@ bool32 CheckInitPauseMenu(void) { return TRUE; } -void DoPlayerAction(Entity* this) { - static void (*const sPlayerActions[])(Entity*) = { +void DoPlayerAction(PlayerEntity* this) { + static void (*const sPlayerActions[])(PlayerEntity*) = { [PLAYER_INIT] = PlayerInit, [PLAYER_NORMAL] = PlayerNormal, [PLAYER_DUMMY] = PlayerInit, @@ -333,32 +335,32 @@ void DoPlayerAction(Entity* this) { [PLAYER_USEENTRANCE] = PlayerUseEntrance, [PLAYER_PARACHUTE] = PlayerParachute, }; - sPlayerActions[this->action](this); + sPlayerActions[super->action](this); } -static void PlayerInit(Entity* this) { +static void PlayerInit(PlayerEntity* this) { u32 equipSlot; gPlayerState.prevAnim = 0xff; - gPlayerState.startPosX = gPlayerEntity.x.HALF.HI; - gPlayerState.startPosY = gPlayerEntity.y.HALF.HI; - COLLISION_ON(this); - this->spritePriority.b0 = 0xc; - this->spritePriority.b1 = 1; - this->spriteSettings.shadow = 1; - this->carryFlags = 0x20; - this->flags2 = 8; - this->hitType = 0x79; - this->hitbox = (Hitbox*)&gPlayerHitbox; - this->spriteIndex = 1; + gPlayerState.startPosX = gPlayerEntity.base.x.HALF.HI; + gPlayerState.startPosY = gPlayerEntity.base.y.HALF.HI; + COLLISION_ON(super); + super->spritePriority.b0 = 0xc; + super->spritePriority.b1 = 1; + super->spriteSettings.shadow = 1; + super->carryFlags = 0x20; + super->flags2 = 8; + super->hitType = 0x79; + super->hitbox = (Hitbox*)&gPlayerHitbox; + super->spriteIndex = 1; #ifndef EU gPlayerState.animation = ANIM_DEFAULT; #endif - sub_0806FDA0(this); - LoadSwapGFX(this, 1, 2); - InitAnimationForceUpdate(this, 2); - if (this->collisionLayer == 0) { - ResolveCollisionLayer(this); + sub_0806FDA0(super); + LoadSwapGFX(super, 1, 2); + InitAnimationForceUpdate(super, 2); + if (super->collisionLayer == 0) { + ResolveCollisionLayer(super); } equipSlot = IsItemEquipped(ITEM_LANTERN_ON); @@ -376,7 +378,7 @@ static void PlayerInit(Entity* this) { gPlayerState.swim_state = 1; ResolvePlayerAnimation(); gPlayerState.framestate = PL_STATE_SWIM; - PlayerSwimming(this); + PlayerSwimming(super); ent = FindEntity(OBJECT, SPECIAL_FX, 0x6, FX_WATER_SPLASH, 0x0); if (ent != NULL) { DeleteEntity(ent); @@ -385,48 +387,48 @@ static void PlayerInit(Entity* this) { } } -static void PlayerNormal(Entity* this) { +static void PlayerNormal(PlayerEntity* this) { gPlayerState.framestate = PL_STATE_IDLE; if (gPlayerState.flags & PL_CAPTURED) { - this->spritePriority.b1 = 0; - this->knockbackDuration = 0; - this->speed = WALK_SPEED; + super->spritePriority.b1 = 0; + super->knockbackDuration = 0; + super->speed = WALK_SPEED; gPlayerState.pushedObject = 0x80; gPlayerState.framestate = PL_STATE_TRAPPED; - if ((this->animationState >> 1) + 92 == this->animIndex && (u16)this->spriteIndex == 2) - UpdateAnimationSingleFrame(&gPlayerEntity); + if ((super->animationState >> 1) + 92 == super->animIndex && (u16)super->spriteIndex == 2) + UpdateAnimationSingleFrame(&gPlayerEntity.base); else gPlayerState.animation = ANIM_TRAPPED; - sub_0806F948(&gPlayerEntity); + sub_0806F948(&gPlayerEntity.base); ResetActiveItems(); - UpdateActiveItems(this); + UpdateActiveItems(super); return; } if (gPlayerState.flags & PL_IN_MINECART) { - this->hurtType = 30; + super->hurtType = 30; gPlayerState.framestate = PL_STATE_C; - sub_08070BEC(this, this->speed == 0 ? 1 : 0); + sub_08070BEC(this, super->speed == 0 ? 1 : 0); return; } if (gPlayerState.flags & PL_MOLDWORM_CAPTURED) { ResolvePlayerAnimation(); return; } - sub_080085B0(this); - this->hurtType = 0; + sub_080085B0(super); + super->hurtType = 0; if (CheckQueuedAction()) { return; } if (!gPlayerState.swim_state && (gPlayerState.jump_status & 0xC0) == 0) { if (gPlayerState.shield_status || gPlayerState.bow_state) { - this->speed = SHIELDING_SPEED; + super->speed = SHIELDING_SPEED; } else { if (gPlayerState.sword_state) { - this->speed = SWORD_CHARGE_SPEED; + super->speed = SWORD_CHARGE_SPEED; } else if (gPlayerState.field_0x1c) { - this->speed = GUST_JAR_SPEED; + super->speed = GUST_JAR_SPEED; } else { - this->speed = WALK_SPEED; + super->speed = WALK_SPEED; } } } @@ -440,7 +442,7 @@ static void PlayerNormal(Entity* this) { } if (gPlayerState.jump_status == 0 && (gPlayerState.flags & PL_BURNING) == 0) { - if (this->knockbackDuration == 0 && sub_080782C0()) { + if (super->knockbackDuration == 0 && sub_080782C0()) { if (gRoomVars.shopItemType == 0) { ResetActiveItems(); } @@ -461,7 +463,7 @@ static void PlayerNormal(Entity* this) { gPlayerState.pushedObject = 0x80; break; case 15: - this->flags &= ~ENT_COLLIDE; + super->flags &= ~ENT_COLLIDE; sub_080797EC(); return; case 4: @@ -477,18 +479,18 @@ static void PlayerNormal(Entity* this) { } } - this->collisionFlags = 0; - this->spritePriority.b0 = 4; - if (sub_0807AC54(this)) { + super->collisionFlags = 0; + super->spritePriority.b0 = 4; + if (sub_0807AC54(super)) { return; } - UpdateActiveItems(this); + UpdateActiveItems(super); if (CheckQueuedAction()) return; sub_080792D8(); - if ((gPlayerState.jump_status | gPlayerState.field_0xa) == 0 && (sub_08079550() || sub_08078F74(this))) { + if ((gPlayerState.jump_status | gPlayerState.field_0xa) == 0 && (sub_08079550() || sub_08078F74(super))) { return; } DoJump(this); @@ -500,69 +502,69 @@ static void PlayerNormal(Entity* this) { gPlayerState.framestate = PL_STATE_CAPE; if ((gPlayerState.jump_status & 0xC0) == 0) { if ((gPlayerState.jump_status & 7) != 3 && (gPlayerState.jump_status & 0x20) == 0) { - this->speed = gPlayerState.jump_status & 0x20; - sub_08008926(this); + super->speed = gPlayerState.jump_status & 0x20; + sub_08008926(super); } else { - this->direction = DIR_NONE; + super->direction = DIR_NONE; } } UpdatePlayerMovement(); - if ((this->frame & 2) == 0 && !gPlayerState.attack_status) - UpdateAnimationSingleFrame(this); + if ((super->frame & 2) == 0 && !gPlayerState.attack_status) + UpdateAnimationSingleFrame(super); return; } - if (this->knockbackDuration == 0) { + if (super->knockbackDuration == 0) { u32 v13; if (gPlayerState.swim_state) { gPlayerState.framestate = PL_STATE_SWIM; - PlayerSwimming(this); + PlayerSwimming(super); } else { if ((gPlayerState.flags & PL_CONVEYOR_PUSHED) == 0) - this->spritePriority.b1 = 1; + super->spritePriority.b1 = 1; if (gPlayerState.dash_state & 0x40) { - sub_08008AA0(this); + sub_08008AA0(super); } else { if (gPlayerState.floor_type == SURFACE_ICE) { - sub_08008926(this); + sub_08008926(super); } else if (gPlayerState.floor_type == SURFACE_PIT) { ResetPlayerVelocity(); } else { - sub_08008AA0(this); + sub_08008AA0(super); } } if ((gPlayerState.sword_state & 0x10) == 0) { - this->direction = gPlayerState.direction; + super->direction = gPlayerState.direction; if (gPlayerState.flags & PL_BURNING) { - this->speed = BURNING_SPEED; + super->speed = BURNING_SPEED; if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) != 0) - this->direction = 4 * (this->animationState & 0xE); + super->direction = 4 * (super->animationState & 0xE); DeleteClones(); } } } v13 = 0; - if ((((gPlayerState.field_0x7 | this->direction) & DIR_NOT_MOVING_CHECK) | gPlayerState.field_0xa) == 0 && + if ((((gPlayerState.field_0x7 | super->direction) & DIR_NOT_MOVING_CHECK) | gPlayerState.field_0xa) == 0 && (gPlayerState.field_0x7 & 0x10) == 0) { v13 = 1; - if (this->knockbackDuration == 0 && + if (super->knockbackDuration == 0 && ((gPlayerState.dash_state & 0x40) || gPlayerState.floor_type != SURFACE_ICE)) v13 = 3; } sub_08070BEC(this, v13); - sub_08008AC6(this); - if (this->knockbackDuration == 0 && gPlayerState.keepFacing == 0 && gPlayerState.floor_type != SURFACE_LADDER) - sub_0806F948(this); + sub_08008AC6(super); + if (super->knockbackDuration == 0 && gPlayerState.keepFacing == 0 && gPlayerState.floor_type != SURFACE_LADDER) + sub_0806F948(super); } else { if (gPlayerState.item == NULL) - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); if (gPlayerState.swim_state != 0 && (gRoomTransition.frameCount & 7) == 0) - CreateWaterTrace(this); + CreateWaterTrace(super); return; } } -static void sub_08070BEC(Entity* this, u32 r0) { +static void sub_08070BEC(PlayerEntity* this, u32 r0) { if (r0 & 1) sub_080797EC(); else @@ -572,8 +574,8 @@ static void sub_08070BEC(Entity* this, u32 r0) { UpdatePlayerMovement(); } -static void PlayerFall(Entity* this) { - static EntityAction* const sPlayerFallStates[] = { +static void PlayerFall(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerFallStates[] = { PlayerFallInit, PlayerFallUpdate, }; @@ -582,11 +584,11 @@ static void PlayerFall(Entity* this) { gPlayerState.pushedObject = 0x80; gPlayerState.framestate = PL_STATE_FALL; - sPlayerFallStates[this->subAction](this); + sPlayerFallStates[super->subAction](this); } -static void PlayerFallInit(Entity* this) { - sub_08004168(this); +static void PlayerFallInit(PlayerEntity* this) { + sub_08004168(super); gPlayerState.flags |= PL_BUSY | PL_DROWNING; gPlayerState.flags &= ~PL_BURNING; @@ -600,58 +602,58 @@ static void PlayerFallInit(Entity* this) { else gPlayerState.animation = ANIM_FALL; - this->subAction++; - COLLISION_OFF(this); - this->spritePriority.b1 = 0; + super->subAction++; + COLLISION_OFF(super); + super->spritePriority.b1 = 0; ResetActiveItems(); DeleteClones(); SoundReq(SFX_PLY_VO7); SoundReq(SFX_FALL_HOLE); } -static void PlayerFallUpdate(Entity* this) { - UpdateAnimationSingleFrame(this); - if (this->frame & ANIM_DONE) { +static void PlayerFallUpdate(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); + if (super->frame & ANIM_DONE) { if ((gSave.stats.health != 0) && (gPlayerState.flags & PL_PIT_IS_EXIT)) { // pit leads to another room gPlayerState.flags &= ~(PL_BUSY | PL_DROWNING); - this->spriteSettings.draw = 0; + super->spriteSettings.draw = 0; } else { - // stay in this room + // stay in super room gPlayerState.flags &= ~(PL_DROWNING | PL_PIT_IS_EXIT); RespawnPlayer(); gPlayerState.field_0xa = 0; - this->iframes = 32; + super->iframes = 32; ModHealth(-FALL_DAMAGE); } } } -static void PlayerBounce(Entity* this) { - static EntityAction* const sPlayerBounceStates[] = { +static void PlayerBounce(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerBounceStates[] = { PlayerBounceInit, PlayerBounceUpdate, sub_08070E7C, }; - sPlayerBounceStates[this->subAction](this); + sPlayerBounceStates[super->subAction](this); } -static void PlayerBounceInit(Entity* this) { - COLLISION_OFF(this); - this->direction = DirectionTurnAround(Direction8FromAnimationState(AnimationStateWalk(this->animationState))); - this->speed = BOUNCE_SPEED_FWD; - this->knockbackDuration = 0; - this->subAction++; - this->timer = gPlayerState.field_0x38; - this->spriteIndex = 1; +static void PlayerBounceInit(PlayerEntity* this) { + COLLISION_OFF(super); + super->direction = DirectionTurnAround(Direction8FromAnimationState(AnimationStateWalk(super->animationState))); + super->speed = BOUNCE_SPEED_FWD; + super->knockbackDuration = 0; + super->subAction++; + super->timer = gPlayerState.field_0x38; + super->spriteIndex = 1; if (!(gPlayerState.flags & PL_MINISH)) { - this->zVelocity = BOUNCE_SPEED_Z; + super->zVelocity = BOUNCE_SPEED_Z; gPlayerState.animation = ANIM_BOUNCE; InitScreenShake(16, 0); } else { gPlayerState.animation = ANIM_BOUNCE_MINISH; - this->zVelocity = (BOUNCE_SPEED_Z * 3) / 4; + super->zVelocity = (BOUNCE_SPEED_Z * 3) / 4; } gPlayerState.jump_status = 0x80; @@ -660,13 +662,13 @@ static void PlayerBounceInit(Entity* this) { ResetPlayerVelocity(); } -static void PlayerBounceUpdate(Entity* this) { - UpdateAnimationSingleFrame(this); - sub_080085B0(this); +static void PlayerBounceUpdate(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); + sub_080085B0(super); UpdatePlayerMovement(); UpdateFloorType(); - if (CheckQueuedAction() || GravityUpdate(this, GRAVITY_RATE)) + if (CheckQueuedAction() || GravityUpdate(super, GRAVITY_RATE)) return; gPlayerState.jump_status = 0; @@ -680,12 +682,12 @@ static void PlayerBounceUpdate(Entity* this) { return; } - if (this->timer-- != 0) { - this->zVelocity = Q_16_16(1.0); + if (super->timer-- != 0) { + super->zVelocity = Q_16_16(1.0); return; } - COLLISION_ON(this); + COLLISION_ON(super); if ((gPlayerState.field_0x14 == 0) && PlayerCheckNEastTile()) { gPlayerState.surfacePositionSameTimer = 7; @@ -694,23 +696,23 @@ static void PlayerBounceUpdate(Entity* this) { return; } - this->spriteIndex = 1; - this->timer = 8; - this->subAction++; + super->spriteIndex = 1; + super->timer = 8; + super->subAction++; if (!(gPlayerState.flags & PL_MINISH)) gPlayerState.animation = ANIM_DEFAULT; } -static void sub_08070E7C(Entity* this) { - if (--this->timer == 0) { +static void sub_08070E7C(PlayerEntity* this) { + if (--super->timer == 0) { gPlayerState.jump_status = 0; ResetPlayerAnimationAndAction(); } } -static void sub_08070E9C(Entity* this) { - static EntityAction* const gUnk_0811BA74[] = { +static void sub_08070E9C(PlayerEntity* this) { + static PlayerEntityAction* const gUnk_0811BA74[] = { sub_08070EDC, sub_08070f24, }; @@ -721,15 +723,15 @@ static void sub_08070E9C(Entity* this) { gPlayerState.field_0x27[0] = 4; gPlayerState.framestate = PL_STATE_TALKEZLO; UpdateFloorType(); - gUnk_0811BA74[this->subAction](this); + gUnk_0811BA74[super->subAction](this); } } -static void sub_08070EDC(Entity* this) { - this->updatePriority = PRIO_MESSAGE; +static void sub_08070EDC(PlayerEntity* this) { + super->updatePriority = PRIO_MESSAGE; if (gMessage.state & MESSAGE_ACTIVE) - this->subAction = 1; + super->subAction = 1; if ((gPlayerState.flags & PL_MINISH) == 0) ResolvePlayerAnimation(); @@ -737,16 +739,16 @@ static void sub_08070EDC(Entity* this) { gPlayerState.animation = ANIM_BOUNCE_MINISH; } -static void sub_08070f24(Entity* this) { - UpdateAnimationSingleFrame(this); +static void sub_08070f24(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); if ((gMessage.state & MESSAGE_ACTIVE) == 0) { - this->updatePriority = this->updatePriorityPrev; + super->updatePriority = super->updatePriorityPrev; ResetPlayerAnimationAndAction(); } } -static void PlayerItemGet(Entity* this) { - static EntityAction* const sPlayerItemGetStates[] = { +static void PlayerItemGet(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerItemGetStates[] = { PlayerItemGetInit, PlayerItemGetUpdate, sub_08071038, @@ -756,21 +758,21 @@ static void PlayerItemGet(Entity* this) { u8* temp; gPlayerState.framestate = PL_STATE_ITEMGET; - COLLISION_OFF(this); - sPlayerItemGetStates[this->subAction](this); + COLLISION_OFF(super); + sPlayerItemGetStates[super->subAction](this); - child = this->child; + child = super->child; if (child != NULL) { - PositionEntityOnTop(this, child); - temp = GetSpriteSubEntryOffsetDataPointer((u16)this->spriteIndex, this->frameIndex); + PositionEntityOnTop(super, child); + temp = GetSpriteSubEntryOffsetDataPointer((u16)super->spriteIndex, super->frameIndex); child->spriteOffsetX = temp[0]; child->spriteOffsetY = temp[1]; } } -static void PlayerItemGetInit(Entity* this) { - this->spriteSettings.flipX = FALSE; - this->animationState = IdleSouth; +static void PlayerItemGetInit(PlayerEntity* this) { + super->spriteSettings.flipX = FALSE; + super->animationState = IdleSouth; gPlayerState.flags |= PL_BUSY; gPlayerState.jump_status = 0; @@ -793,50 +795,50 @@ static void PlayerItemGetInit(Entity* this) { gPlayerState.animation = anim; } - this->subAction = 1; + super->subAction = 1; ResetActiveItems(); ResetPlayerVelocity(); } -static void PlayerItemGetUpdate(Entity* this) { - UpdateAnimationSingleFrame(this); - if (this->frame != 0) /* entire animation is a static frame, wait for advance */ - this->subAction = 2; +static void PlayerItemGetUpdate(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); + if (super->frame != 0) /* entire animation is a static frame, wait for advance */ + super->subAction = 2; } -static void sub_08071038(Entity* this) { - UpdateAnimationSingleFrame(this); +static void sub_08071038(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); // player is still reading message if (CheckQueuedAction() || (gMessage.state & MESSAGE_ACTIVE)) return; - if (this->frame & ANIM_DONE) { + if (super->frame & ANIM_DONE) { // remove the item - // is this actually deleted? - this->child = NULL; - this->knockbackDuration = 0; - this->iframes = 248; + // is super actually deleted? + super->child = NULL; + super->knockbackDuration = 0; + super->iframes = 248; gPlayerState.jump_status = 0; ResetPlayerAnimationAndAction(); } } -static void PlayerJump(Entity* this) { - static EntityAction* const sPlayerJumpStates[] = { +static void PlayerJump(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerJumpStates[] = { PlayerJumpInit, sub_08071130, sub_08071208, }; gPlayerState.framestate = PL_STATE_JUMP; - sPlayerJumpStates[this->subAction](this); + sPlayerJumpStates[super->subAction](this); } -static void PlayerJumpInit(Entity* this) { +static void PlayerJumpInit(PlayerEntity* this) { s32 temp; - this->subAction++; + super->subAction++; gPlayerState.flags |= PL_BUSY; gPlayerState.flags &= ~(PL_BURNING | PL_FROZEN); @@ -855,44 +857,44 @@ static void PlayerJumpInit(Entity* this) { } gPlayerState.dash_state = 0; - this->direction = Direction8FromAnimationState(AnimationStateWalk(this->animationState)); + super->direction = Direction8FromAnimationState(AnimationStateWalk(super->animationState)); temp = sub_08079FC4(1); temp <<= 4; temp -= 4; temp <<= 12; - this->zVelocity = temp; + super->zVelocity = temp; - this->speed = JUMP_SPEED_FWD; + super->speed = JUMP_SPEED_FWD; DeleteClones(); SoundReq(SFX_PLY_JUMP); SoundReq(SFX_PLY_VO4); } -static void sub_08071130(Entity* this) { +static void sub_08071130(PlayerEntity* this) { if (CheckQueuedAction()) return; if (gPlayerState.sword_state == 0) { - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); - if (this->frame & 1) + if (super->frame & 1) return; } - LinearMoveUpdate(this); + LinearMoveUpdate(super); - if (GravityUpdate(this, GRAVITY_RATE)) + if (GravityUpdate(super, GRAVITY_RATE)) return; gPlayerState.jump_status = 0; - ResetCollisionLayer(this); + ResetCollisionLayer(super); - if (*(Entity**)&this->field_0x74 != NULL) - ResetCollisionLayer(*(Entity**)&this->field_0x74); + if (this->unk_74 != NULL) + ResetCollisionLayer(this->unk_74); - sub_08008790(this, 7); + sub_08008790(super, 7); if (gPlayerState.field_0x14) return; @@ -908,7 +910,7 @@ static void sub_08071130(Entity* this) { return; } - this->timer = 6; + super->timer = 6; if (((gPlayerState.heldObject | gPlayerState.keepFacing) == 0) && ((gPlayerState.flags & PL_MINISH) == 0)) { if (gPlayerState.flags & PL_NO_CAP) { @@ -916,53 +918,53 @@ static void sub_08071130(Entity* this) { } else { gPlayerState.animation = ANIM_LAND; } - this->animIndex = 0xff; + super->animIndex = 0xff; } - this->subAction++; + super->subAction++; ResetPlayerVelocity(); - this->knockbackDuration = 0; + super->knockbackDuration = 0; SoundReq(SFX_PLY_LAND); } -static void sub_08071208(Entity* this) { +static void sub_08071208(PlayerEntity* this) { if ((gPlayerState.heldObject | gPlayerState.keepFacing) == 0) { if ((gPlayerState.flags & PL_MINISH) == 0) { - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); } } - if (this->timer-- == 0) { + if (super->timer-- == 0) { gPlayerState.jump_status = 0; ResetPlayerAnimationAndAction(); } } -static void PlayerDrown(Entity* this) { - static EntityAction* const sPlayerDrownStates[] = { +static void PlayerDrown(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerDrownStates[] = { PlayerDrownInit, sub_080712F0, }; gPlayerState.framestate = PL_STATE_DROWN; gPlayerState.flags |= PL_DROWNING; - COLLISION_OFF(this); - sPlayerDrownStates[this->subAction](this); + COLLISION_OFF(super); + sPlayerDrownStates[super->subAction](this); } -static void PlayerDrownInit(Entity* this) { - this->subAction = 1; - this->spritePriority.b1 = 0; +static void PlayerDrownInit(PlayerEntity* this) { + super->subAction = 1; + super->spritePriority.b1 = 0; if (gPlayerState.flags & PL_MINISH) { - this->timer = 60; + super->timer = 60; gPlayerState.animation = ANIM_DROWN_MINISH; SoundReq(SFX_WATER_SPLASH); } else { if (!(gPlayerState.flags & PL_FLAGS10000)) - sub_08004168(this); + sub_08004168(super); - CreateFx(this, FX_WATER_SPLASH, 0); + CreateFx(super, FX_WATER_SPLASH, 0); if (!(gPlayerState.flags & PL_NO_CAP)) gPlayerState.animation = ANIM_DROWN; @@ -972,44 +974,44 @@ static void PlayerDrownInit(Entity* this) { ResetActiveItems(); } -static void sub_080712F0(Entity* this) { +static void sub_080712F0(PlayerEntity* this) { u32 temp; - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); temp = FALSE; if (gPlayerState.flags & PL_MINISH) { - if (--this->timer == 0) + if (--super->timer == 0) temp = TRUE; - } else if ((this->frame & ANIM_DONE) != 0) { - if (this->animIndex != 0xce) + } else if ((super->frame & ANIM_DONE) != 0) { + if (super->animIndex != 0xce) gPlayerState.animation = ANIM_DROWN_RESPAWN; else temp = TRUE; } if (temp) { - this->knockbackDuration = 0; - this->iframes = 32; - this->spritePriority.b1 = 1; - this->spriteSettings.draw = FALSE; + super->knockbackDuration = 0; + super->iframes = 32; + super->spritePriority.b1 = 1; + super->spriteSettings.draw = FALSE; gPlayerState.flags &= ~PL_DROWNING; RespawnPlayer(); } } -static void PlayerUsePortal(Entity* this) { - static EntityAction* const sPlayerUsePortalStates[] = { +static void PlayerUsePortal(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerUsePortalStates[] = { PortalJumpOnUpdate, PortalStandUpdate, PortalActivateInit, PortalActivateUpdate, PortalShrinkInit, PortalShrinkUpdate, PortalEnterUpdate, PortalUnknownUpdate, }; gPlayerState.framestate = PL_STATE_USEPORTAL; - sPlayerUsePortalStates[this->subAction](this); + sPlayerUsePortalStates[super->subAction](this); // probably a switch - if ((this->subAction == 7) || (this->subAction < 3)) + if ((super->subAction == 7) || (super->subAction < 3)) return; if (!(gPlayerState.flags & PL_USE_PORTAL)) @@ -1019,8 +1021,8 @@ static void PlayerUsePortal(Entity* this) { return; if (AreaIsDungeon() || gArea.portal_type == PT_DUNGEON) { - this->subAction = 7; - this->timer = 30; + super->subAction = 7; + super->timer = 30; SetFade(FADE_IN_OUT | FADE_BLACK_WHITE | FADE_INSTANT, 16); SoundReq(SFX_F8); } else { @@ -1028,116 +1030,116 @@ static void PlayerUsePortal(Entity* this) { } } -static void PortalJumpOnUpdate(Entity* this) { +static void PortalJumpOnUpdate(PlayerEntity* this) { u16 x; u16 y; - COLLISION_OFF(this); - this->knockbackDuration = 0; + COLLISION_OFF(super); + super->knockbackDuration = 0; x = gArea.portal_x; y = gArea.portal_y; - if ((this->x.HALF.HI != x) || (this->y.HALF.HI != y)) { - this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, gArea.portal_x, gArea.portal_y); - this->speed = JUMP_SPEED_FWD; + if ((super->x.HALF.HI != x) || (super->y.HALF.HI != y)) { + super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, gArea.portal_x, gArea.portal_y); + super->speed = JUMP_SPEED_FWD; UpdatePlayerMovement(); } DoJump(this); - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); if (gPlayerState.jump_status == 0) { gPlayerState.flags |= PL_USE_PORTAL; - this->subAction = 1; - this->animationState = IdleSouth; - this->spriteSettings.flipX = FALSE; + super->subAction = 1; + super->animationState = IdleSouth; + super->spriteSettings.flipX = FALSE; if (gArea.portal_type == PT_JAR) { gPlayerState.animation = ANIM_ENTER_POT; } } - this->timer = 8; + super->timer = 8; if (gArea.portal_type != PT_DUNGEON) { - this->spritePriority.b0 = 3; + super->spritePriority.b0 = 3; } } -static void PortalStandUpdate(Entity* this) { +static void PortalStandUpdate(PlayerEntity* this) { switch (gArea.portal_type) { case PT_JAR: case PT_5: - sub_0806F948(&gPlayerEntity); + sub_0806F948(&gPlayerEntity.base); break; } if ((gPlayerState.direction & (DIR_NOT_MOVING_CHECK | DIR_DIAGONAL)) == 0) { - if (this->direction != gPlayerState.direction) { - this->timer = 8; + if (super->direction != gPlayerState.direction) { + super->timer = 8; } - if (this->timer-- == 0) { - this->direction = gPlayerState.direction; - this->animationState = Direction8ToAnimationState(this->direction); - this->zVelocity = Q_16_16(2.0); - this->speed = JUMP_SPEED_FWD; - this->action = PLAYER_MINISH; - this->subAction = 7; - this->subtimer = 0; + if (super->timer-- == 0) { + super->direction = gPlayerState.direction; + super->animationState = Direction8ToAnimationState(super->direction); + super->zVelocity = Q_16_16(2.0); + super->speed = JUMP_SPEED_FWD; + super->action = PLAYER_MINISH; + super->subAction = 7; + super->subtimer = 0; gPlayerState.animation = (gPlayerState.flags & PL_NO_CAP) ? ANIM_HOP_NOCAP : ANIM_HOP; gPlayerState.flags &= ~PL_USE_PORTAL; return; } - this->direction = gPlayerState.direction; + super->direction = gPlayerState.direction; } else { - this->timer = 8; + super->timer = 8; } if (gArea.portal_type == PT_JAR) { - if (this->frame == 0) { - UpdateAnimationSingleFrame(this); + if (super->frame == 0) { + UpdateAnimationSingleFrame(super); return; } } else { - UpdateActiveItems(this); + UpdateActiveItems(super); } ResolvePlayerAnimation(); } -static void PortalActivateInit(Entity* this) { +static void PortalActivateInit(PlayerEntity* this) { gRoomControls.camera_target = NULL; gPauseMenuOptions.disabled = 1; - this->subAction = 3; - this->subtimer = 30; + super->subAction = 3; + super->subtimer = 30; gPlayerState.animation = ANIM_PORTAL_ACTIVATE; - CreateObjectWithParent(this, EZLO_CAP, 1, 0); + CreateObjectWithParent(super, EZLO_CAP, 1, 0); PutAwayItems(); SetPlayerEventPriority(); } -static void PortalActivateUpdate(Entity* this) { - if (this->subtimer) +static void PortalActivateUpdate(PlayerEntity* this) { + if (super->subtimer) return; - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); if (gPlayerState.flags & PL_MINISH) - this->subAction = 4; + super->subAction = 4; } -static void PortalShrinkInit(Entity* this) { - this->subAction = 5; - this->spritePriority.b1 = 0; - this->subtimer = 0; - this->spriteRendering.b0 = 3; - *(u32*)&this->field_0x80.HWORD = 0x100; - *(u32*)&this->cutsceneBeh = 0x100; - SetAffineInfo(this, 0x100, 0x100, 0); +static void PortalShrinkInit(PlayerEntity* this) { + super->subAction = 5; + super->spritePriority.b1 = 0; + super->subtimer = 0; + super->spriteRendering.b0 = 3; + this->unk_80.WORD = 0x100; + this->unk_84.WORD = 0x100; + SetAffineInfo(super, 0x100, 0x100, 0); gPlayerState.animation = ANIM_PORTAL_SHRINK; gPlayerState.flags |= PL_MINISH; SoundReq(SFX_PLY_SHRINKING); } -static void PortalShrinkUpdate(Entity* this) { +static void PortalShrinkUpdate(PlayerEntity* this) { static const u8 gUnk_0811BABC[] = { 1, 1, 1, 1, 2, 4, 8, 16, }; @@ -1146,12 +1148,12 @@ static void PortalShrinkUpdate(Entity* this) { u32 uVar7; u32 uVar8; - if (this->field_0x80.HALF.HI) { - uVar7 = (u32)((*(int*)&this->field_0x80 + 0x80) * 0x100000) >> 0x17; + if (this->unk_80.BYTES.byte1) { + uVar7 = (u32)((this->unk_80.WORD + 0x80) * 0x100000) >> 0x17; } else { - uVar7 = (0x10 / (((this->field_0x80.HALF.LO >> 6) ^ 3) + 1)) >> 1; + uVar7 = (0x10 / (((this->unk_80.BYTES.byte0 >> 6) ^ 3) + 1)) >> 1; } - uVar5 = *(u32*)&this->cutsceneBeh; + uVar5 = this->unk_84.WORD; if (uVar5 >= 0x101) { uVar5 = (uVar5 + 0x80) * 0x100000 >> 0x17; } else { @@ -1163,64 +1165,64 @@ static void PortalShrinkUpdate(Entity* this) { } iVar3 = Q_16_16(1); - switch (this->frame) { + switch (super->frame) { case 1: - this->spritePriority.b1 = 0; - if (0x80 < *(u32*)&this->field_0x80) { - *(u32*)&this->field_0x80 -= uVar7; + super->spritePriority.b1 = 0; + if (0x80 < this->unk_80.WORD_U) { + this->unk_80.WORD_U -= uVar7; } - *(u32*)&this->cutsceneBeh += uVar5 * 2; - this->y.WORD += iVar3 * 2; + this->unk_84.WORD_U += uVar5 * 2; + super->y.WORD_U += iVar3 * 2; break; case 2: - *(u32*)&this->field_0x80 += uVar7; - uVar8 = *(u32*)&this->cutsceneBeh; + this->unk_80.WORD_U += uVar7; + uVar8 = this->unk_84.WORD_U; if (uVar8 >= 0x101) { if (uVar8 < 0x180) { uVar5 = uVar5 >> 1; } if (uVar8 - uVar5 < 0x100) { - *(u32*)&this->cutsceneBeh = 0x100; + this->unk_84.WORD_U = 0x100; } else { - *(u32*)&this->cutsceneBeh = uVar8 - uVar5; + this->unk_84.WORD_U = uVar8 - uVar5; } } else { if (0x80 < uVar8) { - *(u32*)&this->cutsceneBeh = uVar8 - uVar5; + this->unk_84.WORD_U = uVar8 - uVar5; } } - this->z.WORD = this->z.WORD - iVar3; + super->z.WORD = super->z.WORD - iVar3; break; case 3: - if (*(u32*)&this->field_0x80 < 0x340) { - *(u32*)&this->field_0x80 += uVar7; + if (this->unk_80.WORD_U < 0x340) { + this->unk_80.WORD_U += uVar7; } - if (*(u32*)&this->cutsceneBeh >= 0x340) { - this->timer = 8; - this->subtimer = 30; - this->subAction = 6; + if (this->unk_84.WORD_U >= 0x340) { + super->timer = 8; + super->subtimer = 30; + super->subAction = 6; } else { - *(u32*)&this->cutsceneBeh += uVar5 * 2; + this->unk_84.WORD_U += uVar5 * 2; } - this->z.WORD = this->z.WORD - iVar3 * 2; + super->z.WORD = super->z.WORD - iVar3 * 2; break; } - SetAffineInfo(this, *(u32*)&this->field_0x80, *(u32*)&this->cutsceneBeh, 0); - UpdateAnimationSingleFrame(this); + SetAffineInfo(super, this->unk_80.WORD, this->unk_84.WORD, 0); + UpdateAnimationSingleFrame(super); } -static void PortalEnterUpdate(Entity* this) { - if (this->timer == 0) { - if (GravityUpdate(this, GRAVITY_RATE)) +static void PortalEnterUpdate(PlayerEntity* this) { + if (super->timer == 0) { + if (GravityUpdate(super, GRAVITY_RATE)) return; - this->spriteSettings.draw = FALSE; + super->spriteSettings.draw = FALSE; if (gArea.portal_type == PT_DUNGEON) { - if (--this->subtimer == 0) + if (--super->subtimer == 0) sub_080717F8(this); return; } @@ -1231,15 +1233,15 @@ static void PortalEnterUpdate(Entity* this) { return; } - this->timer--; + super->timer--; } -static void PortalUnknownUpdate(Entity* this) { +static void PortalUnknownUpdate(PlayerEntity* this) { if (gFadeControl.active) return; - if (this->timer != 0) { - this->timer--; + if (super->timer != 0) { + super->timer--; return; } @@ -1247,25 +1249,25 @@ static void PortalUnknownUpdate(Entity* this) { SetFadeInverted(0x10); } -static void sub_080717F8(Entity* this) { +static void sub_080717F8(PlayerEntity* this) { static const s16 sOffsets[] = { 0, -22, 22, 0, 0, 22, -22, 0, }; - this->animationState = gArea.portal_exit_dir << 1; - this->x.HALF.HI = gArea.portal_x + sOffsets[gArea.portal_exit_dir * 2]; - this->y.HALF.HI = gArea.portal_y + sOffsets[gArea.portal_exit_dir * 2 + 1]; + super->animationState = gArea.portal_exit_dir << 1; + super->x.HALF.HI = gArea.portal_x + sOffsets[gArea.portal_exit_dir * 2]; + super->y.HALF.HI = gArea.portal_y + sOffsets[gArea.portal_exit_dir * 2 + 1]; gArea.portal_timer = 180; gPauseMenuOptions.disabled = 0; - this->action = PLAYER_MINISH; - this->subAction = 0; + super->action = PLAYER_MINISH; + super->subAction = 0; gPlayerState.flags = (gPlayerState.flags & ~PL_USE_PORTAL) | PL_MINISH; - sub_0805EC60(this); + sub_0805EC60(super); ResetPlayerEventPriority(); } -static void PlayerTalkEzlo(Entity* this) { - static EntityAction* const sPlayerTalkEzloStates[] = { +static void PlayerTalkEzlo(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerTalkEzloStates[] = { PlayerTalkEzlo_Init, PlayerTalkEzlo_CreateMessage, PlayerTalkEzlo_MessageIdle, @@ -1277,52 +1279,52 @@ static void PlayerTalkEzlo(Entity* this) { reset_priority(); } else { gPlayerState.framestate = PL_STATE_TALKEZLO; - COLLISION_OFF(this); - sPlayerTalkEzloStates[this->subAction](this); + COLLISION_OFF(super); + sPlayerTalkEzloStates[super->subAction](this); } } -static void PlayerTalkEzlo_Init(Entity* this) { +static void PlayerTalkEzlo_Init(PlayerEntity* this) { ResetActiveItems(); gActiveItems[ACTIVE_ITEM_LANTERN].animPriority = 0; - this->iframes = 0; + super->iframes = 0; gPriorityHandler.event_priority = PRIO_PLAYER_EVENT; - this->updatePriority = PRIO_PLAYER_EVENT; + super->updatePriority = PRIO_PLAYER_EVENT; if (gPlayerState.flags & PL_MINISH) { - this->subAction = 2; - this->spritePriority.b1 = 0; + super->subAction = 2; + super->spritePriority.b1 = 0; DisplayEzloMessage(); return; } if (gPlayerState.jump_status == 0) { - this->subAction++; + super->subAction++; - if (this->animationState == IdleEast) { + if (super->animationState == IdleEast) { gPlayerState.animation = ANIM_EZLO_APPEAR_RIGHT; } else { gPlayerState.animation = ANIM_EZLO_APPEAR_LEFT; } - this->spriteSettings.flipX = 0; + super->spriteSettings.flipX = 0; return; } - if (!GravityUpdate(this, GRAVITY_RATE)) { + if (!GravityUpdate(super, GRAVITY_RATE)) { gPlayerState.jump_status = 0; } } -static void PlayerTalkEzlo_CreateMessage(Entity* this) { +static void PlayerTalkEzlo_CreateMessage(PlayerEntity* this) { Entity* child; - UpdateAnimationSingleFrame(this); - if (this->frame & ANIM_DONE) { - this->subAction++; - this->child = CreateObjectWithParent(this, EZLO_CAP, 0, 0); - if (this->child != NULL) { - if (this->animationState == IdleEast) { + UpdateAnimationSingleFrame(super); + if (super->frame & ANIM_DONE) { + super->subAction++; + super->child = CreateObjectWithParent(super, EZLO_CAP, 0, 0); + if (super->child != NULL) { + if (super->animationState == IdleEast) { gPlayerState.animation = ANIM_EZLO_EYES_MIDDLE; } else { gPlayerState.animation = ANIM_EZLO_EYES_UP; @@ -1332,13 +1334,13 @@ static void PlayerTalkEzlo_CreateMessage(Entity* this) { } } -static void PlayerTalkEzlo_MessageIdle(Entity* this) { +static void PlayerTalkEzlo_MessageIdle(PlayerEntity* this) { u32 rightOrLeft; if ((gMessage.state & MESSAGE_ACTIVE) == 0) { - this->subAction++; + super->subAction++; if ((gPlayerState.flags & PL_MINISH) == 0) { - if (this->animationState == IdleEast) + if (super->animationState == IdleEast) gPlayerState.animation = ANIM_EZLO_LEAVE_RIGHT; else gPlayerState.animation = ANIM_EZLO_LEAVE_LEFT; @@ -1352,28 +1354,28 @@ static void PlayerTalkEzlo_MessageIdle(Entity* this) { if (gPlayerState.flags & PL_MINISH) return; - if (this->animationState == IdleEast) + if (super->animationState == IdleEast) rightOrLeft = 4; else rightOrLeft = 0; - if (this->child->timer != 0) { - if ((u8)(rightOrLeft + 200) != this->animIndex) { + if (super->child->timer != 0) { + if ((u8)(rightOrLeft + 200) != super->animIndex) { gPlayerState.animation = rightOrLeft + ANIM_EZLO_HEAD_DOWN; return; } } else { - if ((u8)(rightOrLeft + 199) != this->animIndex) { + if ((u8)(rightOrLeft + 199) != super->animIndex) { gPlayerState.animation = rightOrLeft + ANIM_EZLO_EYES_UP; return; } } - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); } -static void PlayerTalkEzlo_Leave(Entity* this) { - UpdateAnimationSingleFrame(this); - if (this->frame & ANIM_DONE) { +static void PlayerTalkEzlo_Leave(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); + if (super->frame & ANIM_DONE) { reset_priority(); PlayerSetNormalAndCollide(); } @@ -1381,35 +1383,35 @@ static void PlayerTalkEzlo_Leave(Entity* this) { static void reset_priority(void) { gPriorityHandler.event_priority = PRIO_MIN; - gPlayerEntity.updatePriority = gPlayerEntity.updatePriorityPrev; + gPlayerEntity.base.updatePriority = gPlayerEntity.base.updatePriorityPrev; } -static void PlayerPush(Entity* this) { - static EntityAction* const sPlayerPushStates[] = { +static void PlayerPush(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerPushStates[] = { PlayerPushInit, PlayerPushUpdate, PlayerPushEnd, }; gPlayerState.framestate = PL_STATE_PUSH; - sPlayerPushStates[this->subAction](this); + sPlayerPushStates[super->subAction](this); } -static void PlayerPushInit(Entity* this) { - this->subAction++; +static void PlayerPushInit(PlayerEntity* this) { + super->subAction++; gPlayerState.flags |= PL_BUSY; - if (this->type == 1) { + if (super->type == 1) { // scripted push? - this->speed = 0; - this->timer = 0; - this->subtimer = 1; + super->speed = 0; + super->timer = 0; + super->subtimer = 1; } else { - this->speed = (gPlayerState.flags & PL_MINISH) ? PUSH_SPEED / 2 : PUSH_SPEED; + super->speed = (gPlayerState.flags & PL_MINISH) ? PUSH_SPEED / 2 : PUSH_SPEED; } PlayerPushUpdate(this); } -static void PlayerPushUpdate(Entity* this) { +static void PlayerPushUpdate(PlayerEntity* this) { typedef struct { u8 frame; u16 speed; @@ -1434,62 +1436,62 @@ static void PlayerPushUpdate(Entity* this) { }; gPlayerState.speed_modifier = 0; - UpdateAnimationSingleFrame(this); - if (this->type == 1) { - if (--this->subtimer == 0) { - if (sPushFrames[this->timer].frame != 0xff) { - this->subtimer = sPushFrames[this->timer].frame; - this->speed = sPushFrames[this->timer].speed; - this->timer++; + UpdateAnimationSingleFrame(super); + if (super->type == 1) { + if (--super->subtimer == 0) { + if (sPushFrames[super->timer].frame != 0xff) { + super->subtimer = sPushFrames[super->timer].frame; + super->speed = sPushFrames[super->timer].speed; + super->timer++; } else { - this->subAction++; + super->subAction++; return; } } } else { gPlayerState.pushedObject--; if ((gPlayerState.pushedObject & 0x7f) == 0) { - this->subAction++; + super->subAction++; } } UpdatePlayerMovement(); } -static void PlayerPushEnd(Entity* this) { +static void PlayerPushEnd(PlayerEntity* this) { gPlayerState.pushedObject = 2; gPlayerState.flags &= ~PL_BUSY; - this->type = 0; - this->knockbackDuration = 0; + super->type = 0; + super->knockbackDuration = 0; PlayerWaitForScroll(this); // Final push? - this->subtimer = 6; + super->subtimer = 6; if (!(gPlayerState.flags & PL_MINISH)) { gPlayerState.animation = ANIM_WALK; - this->spriteIndex = 3; - InitAnimationForceUpdate(this, (this->animationState >> 1) + 0x3c); + super->spriteIndex = 3; + InitAnimationForceUpdate(super, (super->animationState >> 1) + 0x3c); } } -static void PlayerMinishDie(Entity* this) { - static EntityAction* const sPlayerMinishDieStates[] = { +static void PlayerMinishDie(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerMinishDieStates[] = { PlayerMinishDieInit, sub_08071CAC, sub_08071D04, sub_08071D80, }; - COLLISION_OFF(this); - sPlayerMinishDieStates[this->subAction](this); + COLLISION_OFF(super); + sPlayerMinishDieStates[super->subAction](this); gPlayerState.framestate = PL_STATE_DIE; } -static void PlayerMinishDieInit(Entity* this) { +static void PlayerMinishDieInit(PlayerEntity* this) { u32 deathAnim; if (gPlayerState.flags & (PL_CAPTURED | PL_DISABLE_ITEMS)) return; - if (GravityUpdate(this, GRAVITY_RATE)) { + if (GravityUpdate(super, GRAVITY_RATE)) { if (gPlayerState.flags & PL_NO_CAP) gPlayerState.animation = ANIM_JUMP_NOCAP; else @@ -1501,9 +1503,9 @@ static void PlayerMinishDieInit(Entity* this) { if (gPlayerState.flags & PL_MINISH) { if (gPlayerState.floor_type == SURFACE_MINISH_DOOR_FRONT || gPlayerState.floor_type == SURFACE_MINISH_DOOR_BACK || gPlayerState.floor_type == SURFACE_A) { - EnablePlayerDraw(this); + EnablePlayerDraw(super); RespawnPlayer(); - this->action = PLAYER_MINISHDIE; + super->action = PLAYER_MINISHDIE; } deathAnim = ANIM_DIE1_MINISH; } else { @@ -1513,20 +1515,20 @@ static void PlayerMinishDieInit(Entity* this) { gPlayerState.flags &= ~(PL_PARACHUTE | PL_MOLDWORM_RELEASED | PL_ROLLING | PL_FROZEN | PL_BURNING | PL_DISABLE_ITEMS | PL_BUSY); - this->subAction = 1; - this->animationState = IdleSouth; - this->spritePriority.b1 = 1; - this->spriteSettings.draw = 3; + super->subAction = 1; + super->animationState = IdleSouth; + super->spritePriority.b1 = 1; + super->spriteSettings.draw = 3; gPlayerState.jump_status = 0; gPlayerState.pushedObject = 0; - sub_0800451C(this); + sub_0800451C(super); ResetActiveItems(); SoundReq(SFX_PLY_DIE); } -static void sub_08071CAC(Entity* this) { - UpdateAnimationSingleFrame(this); - if (this->frame & ANIM_DONE) { +static void sub_08071CAC(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); + if (super->frame & ANIM_DONE) { u32 deathAnim; if ((gPlayerState.flags & PL_MINISH) == 0) deathAnim = (gPlayerState.flags & PL_NO_CAP) ? ANIM_DIE2_NOCAP : ANIM_DIE2; @@ -1534,18 +1536,18 @@ static void sub_08071CAC(Entity* this) { deathAnim = ANIM_DIE2_MINISH; gPlayerState.animation = deathAnim; - this->subAction = 2; - this->timer = 240; + super->subAction = 2; + super->timer = 240; SoundReq(SFX_PLY_VO7); } } -static void sub_08071D04(Entity* this) { +static void sub_08071D04(PlayerEntity* this) { int idx; int deltaHealth; - UpdateAnimationSingleFrame(this); - if (this->frame == 0) + UpdateAnimationSingleFrame(super); + if (super->frame == 0) return; deltaHealth = 0; @@ -1558,11 +1560,11 @@ static void sub_08071D04(Entity* this) { if (deltaHealth != 0) { ModHealth(deltaHealth); - this->subAction = 3; + super->subAction = 3; gPlayerState.field_0x3c = 0; - this->direction = DIR_NONE; - this->speed = 0; - this->zVelocity = Q_16_16(1.5); + super->direction = DIR_NONE; + super->speed = 0; + super->zVelocity = Q_16_16(1.5); gPlayerState.jump_status = 1; gPlayerState.swim_state = 0; return; @@ -1571,42 +1573,42 @@ static void sub_08071D04(Entity* this) { gRoomTransition.field_0x4[1] = 1; } -static void sub_08071D80(Entity* this) { - UpdateAnimationSingleFrame(this); +static void sub_08071D80(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); gPlayerState.field_0x14 = 1; DoJump(this); if ((gPlayerState.jump_status & 7) == 3) { gPlayerState.jump_status = 0; - this->iframes = 226; + super->iframes = 226; ResetPlayerEventPriority(); ResetPlayerAnimationAndAction(); } } -static void sub_08071DB8(Entity* this) { - static EntityAction* const gUnk_0811BB3C[] = { +static void sub_08071DB8(PlayerEntity* this) { + static PlayerEntityAction* const gUnk_0811BB3C[] = { sub_08071DD0, sub_08071E04, sub_08071E74, }; - gUnk_0811BB3C[this->subAction](this); + gUnk_0811BB3C[super->subAction](this); } -static void sub_08071DD0(Entity* this) { - this->timer = gPlayerState.field_0x38; +static void sub_08071DD0(PlayerEntity* this) { + super->timer = gPlayerState.field_0x38; if (gPlayerState.field_0x39 != 0) { gPlayerState.field_0x39 = 0; - this->subAction = 2; + super->subAction = 2; gPlayerState.animation = ANIM_DEFAULT; } else { - this->subAction = 1; + super->subAction = 1; gPlayerState.animation = ANIM_BOUNCE; } } -static void sub_08071E04(Entity* this) { - if ((this->z.WORD != 0) && (gPlayerState.field_0x14 == 0)) { +static void sub_08071E04(PlayerEntity* this) { + if ((super->z.WORD != 0) && (gPlayerState.field_0x14 == 0)) { UpdateFloorType(); if (gPlayerState.floor_type == SURFACE_PIT) { gPlayerState.surfacePositionSameTimer = 7; @@ -1616,49 +1618,49 @@ static void sub_08071E04(Entity* this) { } } - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); if (sub_08079B24() == 0) { - sub_08079708(this); + sub_08079708(super); return; } sub_080792D8(); if (sub_0807953C()) - this->timer -= 2; + super->timer -= 2; else - this->timer--; + super->timer--; - if ((s8)this->timer < 1) + if ((s8)super->timer < 1) SetPlayerActionNormal(); } -static void sub_08071E74(Entity* this) { +static void sub_08071E74(PlayerEntity* this) { u32 temp; - GravityUpdate(this, GRAVITY_RATE); + GravityUpdate(super, GRAVITY_RATE); UpdatePlayerMovement(); - temp = this->timer--; + temp = super->timer--; if (temp == 0) SetPlayerActionNormal(); } -static void PlayerEmptyBottle(Entity* this) { - static EntityAction* const sPlayerEmptyBottleStates[] = { +static void PlayerEmptyBottle(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerEmptyBottleStates[] = { PlayerEmptyBottleInit, PlayerEmptyBottleUpdate, }; - sPlayerEmptyBottleStates[this->subAction](this); + sPlayerEmptyBottleStates[super->subAction](this); } -static void PlayerEmptyBottleInit(Entity* this) { - Entity* ent; +static void PlayerEmptyBottleInit(PlayerEntity* this) { + PlayerItemBottleEntity* entity; ResetActiveItems(); - ent = CreatePlayerItemWithParent((ItemBehavior*)this, PLAYER_ITEM_BOTTLE); - if (ent != NULL) { - ent->field_0x68.HALF.LO = gPlayerState.field_0x38; - this->subAction++; + entity = (PlayerItemBottleEntity*)CreatePlayerItemWithParent((ItemBehavior*)super, PLAYER_ITEM_BOTTLE); + if (entity != NULL) { + entity->bottleIndex = gPlayerState.field_0x38; + super->subAction++; switch (gPlayerState.field_0x38) { case 0x20: gPlayerState.animation = ANIM_BOTTLE_SWING; @@ -1674,35 +1676,35 @@ static void PlayerEmptyBottleInit(Entity* this) { } } -static void PlayerEmptyBottleUpdate(Entity* this) { - UpdateAnimationSingleFrame(this); - if (this->frame & ANIM_DONE) { +static void PlayerEmptyBottleUpdate(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); + if (super->frame & ANIM_DONE) { gPlayerState.item = NULL; PlayerSetNormalAndCollide(); } } -static void PlayerFrozen(Entity* this) { - static EntityAction* const sPlayerFrozenStates[] = { +static void PlayerFrozen(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerFrozenStates[] = { PlayerFrozenInit, PlayerFrozenUpdate, }; - sPlayerFrozenStates[this->subAction](this); + sPlayerFrozenStates[super->subAction](this); } -static void PlayerFrozenInit(Entity* this) { - COLLISION_OFF(this); - this->timer = 120; - this->subAction++; +static void PlayerFrozenInit(PlayerEntity* this) { + COLLISION_OFF(super); + super->timer = 120; + super->subAction++; gPlayerState.animation = ANIM_FROZEN; PutAwayItems(); SoundReq(SFX_195); } -static void PlayerFrozenUpdate(Entity* this) { - if (GravityUpdate(this, GRAVITY_RATE) == 0) { - UpdateSpriteForCollisionLayer(this); +static void PlayerFrozenUpdate(PlayerEntity* this) { + if (GravityUpdate(super, GRAVITY_RATE) == 0) { + UpdateSpriteForCollisionLayer(super); gPlayerState.jump_status = 0; if (gPlayerState.field_0x14 == 0) { if (sub_08079D48() == 0) { @@ -1712,16 +1714,16 @@ static void PlayerFrozenUpdate(Entity* this) { } } if (sub_08079B24() == 0) { - sub_08079708(this); + sub_08079708(super); } else { if (gPlayerState.flags & PL_FROZEN) { if (sub_0807953C() != 0) { - this->timer -= 3; - this->spriteOffsetX = 2; + super->timer -= 3; + super->spriteOffsetX = 2; } else { - this->spriteOffsetX = 0; + super->spriteOffsetX = 0; } - if ((s8)this->timer > 0) { + if ((s8)super->timer > 0) { return; } } @@ -1729,68 +1731,68 @@ static void PlayerFrozenUpdate(Entity* this) { break_out(this); } -static void break_out(Entity* this) { - this->iframes = 160; - this->knockbackDuration = 0; - COLLISION_ON(this); - this->spriteOffsetX = 0; +static void break_out(PlayerEntity* this) { + super->iframes = 160; + super->knockbackDuration = 0; + COLLISION_ON(super); + super->spriteOffsetX = 0; gPlayerState.flags &= ~(PL_FROZEN | PL_BUSY); - CreateFx(this, FX_ICE, 0); + CreateFx(super, FX_ICE, 0); SetPlayerActionNormal(); } -static void sub_0807204C(Entity* this) { - static EntityAction* const gUnk_0811BB58[] = { +static void sub_0807204C(PlayerEntity* this) { + static PlayerEntityAction* const gUnk_0811BB58[] = { sub_08072064, sub_08072098, }; - gUnk_0811BB58[this->subAction](this); + gUnk_0811BB58[super->subAction](this); } -static void sub_08072064(Entity* this) { - this->subAction = 1; - COLLISION_OFF(this); - this->timer = gPlayerState.field_0x3a; +static void sub_08072064(PlayerEntity* this) { + super->subAction = 1; + COLLISION_OFF(super); + super->timer = gPlayerState.field_0x3a; gPlayerState.animation = gPlayerState.field_0x38 | (gPlayerState.field_0x39 << 8); ResetActiveItems(); } -static void sub_08072098(Entity* this) { - UpdateAnimationSingleFrame(this); - if (this->timer != 0) { - if (this->timer-- != 0) { +static void sub_08072098(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); + if (super->timer != 0) { + if (super->timer-- != 0) { return; } - } else if ((this->frame & ANIM_DONE) == 0) { + } else if ((super->frame & ANIM_DONE) == 0) { return; } - if (this->health != 0) { - COLLISION_ON(this); + if (super->health != 0) { + COLLISION_ON(super); } SetPlayerActionNormal(); } -static void PlayerRoomExit(Entity* this) { - static EntityAction* const gUnk_0811BB60[] = { +static void PlayerRoomExit(PlayerEntity* this) { + static PlayerEntityAction* const gUnk_0811BB60[] = { sub_08072100, sub_08072168, }; if (CheckQueuedAction() == 0) - gUnk_0811BB60[this->subAction](this); + gUnk_0811BB60[super->subAction](this); } -static void sub_08072100(Entity* this) { - this->spriteSettings.draw = 3; - this->speed = 0x140; - this->hitbox = (Hitbox*)&gPlayerHitbox; - this->timer = gPlayerState.field_0x38; - this->subAction = 1; - COLLISION_OFF(this); +static void sub_08072100(PlayerEntity* this) { + super->spriteSettings.draw = 3; + super->speed = 0x140; + super->hitbox = (Hitbox*)&gPlayerHitbox; + super->timer = gPlayerState.field_0x38; + super->subAction = 1; + COLLISION_OFF(super); if (gPlayerState.field_0x39) - this->direction = DIR_NONE; + super->direction = DIR_NONE; if (gPlayerState.flags & PL_NO_CAP) { gPlayerState.animation = ANIM_WALK_NOCAP; @@ -1801,43 +1803,43 @@ static void sub_08072100(Entity* this) { sub_08072168(this); } -static void sub_08072168(Entity* this) { +static void sub_08072168(PlayerEntity* this) { u32 i; - UpdateAnimationSingleFrame(this); - i = (u16)sub_0806F854(this, 0, -12) ? GRAVITY_RATE * 2 : GRAVITY_RATE; - GravityUpdate(this, i); + UpdateAnimationSingleFrame(super); + i = (u16)sub_0806F854(super, 0, -12) ? GRAVITY_RATE * 2 : GRAVITY_RATE; + GravityUpdate(super, i); if (gPlayerState.field_0x3a) { - LinearMoveUpdate(this); + LinearMoveUpdate(super); } else { UpdatePlayerMovement(); } - gPlayerState.direction = this->direction; + gPlayerState.direction = super->direction; UpdatePlayerCollision(); - if (this->timer-- == 0) { - this->knockbackDuration = 0; - COLLISION_ON(this); - UpdateSpriteForCollisionLayer(this); + if (super->timer-- == 0) { + super->knockbackDuration = 0; + COLLISION_ON(super); + UpdateSpriteForCollisionLayer(super); SetPlayerActionNormal(); } } -static void PlayerPull(Entity* this) { - static EntityAction* const sPlayerPullStates[] = { +static void PlayerPull(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerPullStates[] = { sub_08072214, sub_08072260, }; gPlayerState.framestate = PL_STATE_PULL; - sPlayerPullStates[this->subAction](this); + sPlayerPullStates[super->subAction](this); gUnk_0200AF00.rActionGrabbing = R_ACTION_GRAB; } -static void sub_08072214(Entity* this) { - this->subAction = 1; - this->speed = PULL_SPEED; - this->timer = gPlayerState.field_0x38; - this->direction = Direction8FromAnimationState(AnimationStateFlip180(this->animationState)); +static void sub_08072214(PlayerEntity* this) { + super->subAction = 1; + super->speed = PULL_SPEED; + super->timer = gPlayerState.field_0x38; + super->direction = Direction8FromAnimationState(AnimationStateFlip180(super->animationState)); if ((gPlayerState.flags & PL_NO_CAP) == 0) { gPlayerState.animation = ANIM_PULL2; } else { @@ -1847,24 +1849,24 @@ static void sub_08072214(Entity* this) { sub_08072260(this); } -static void sub_08072260(Entity* this) { +static void sub_08072260(PlayerEntity* this) { gPlayerState.speed_modifier = 0; UpdatePlayerMovement(); - UpdateAnimationSingleFrame(this); - if (--this->timer == 0) { + UpdateAnimationSingleFrame(super); + if (--super->timer == 0) { gPlayerState.flags &= ~PL_BUSY; if ((gPlayerState.flags & PL_NO_CAP) == 0) { gPlayerState.animation = ANIM_PULL2; } else { gPlayerState.animation = ANIM_PULL_NOCAP; } - this->knockbackDuration = 0; + super->knockbackDuration = 0; SetPlayerActionNormal(); } } -static void PlayerLava(Entity* this) { - static EntityAction* const sPlayerLavaStates[] = { +static void PlayerLava(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerLavaStates[] = { PlayerLavaInit, sub_08072354, sub_080723D0, @@ -1872,25 +1874,25 @@ static void PlayerLava(Entity* this) { }; gPlayerState.framestate = PL_STATE_FALL; - sPlayerLavaStates[this->subAction](this); + sPlayerLavaStates[super->subAction](this); } -static void PlayerLavaInit(Entity* this) { +static void PlayerLavaInit(PlayerEntity* this) { Entity* ent; - COLLISION_OFF(this); + COLLISION_OFF(super); if ((gPlayerState.flags & PL_MINISH) == 0) { - this->subAction = 1; - this->zVelocity = Q_16_16(2.5); + super->subAction = 1; + super->zVelocity = Q_16_16(2.5); ent = CreateObject(LINK_FIRE, 0x80, 0); if (ent != NULL) { - ent->child = this; + ent->child = super; } gPlayerState.animation = ANIM_BOUNCE; } else { - this->spriteSettings.draw = 0; - this->subAction = 3; - this->knockbackDuration = 10; + super->spriteSettings.draw = 0; + super->subAction = 3; + super->knockbackDuration = 10; } gPlayerState.flags |= (PL_BURNING | PL_BUSY); ResetActiveItems(); @@ -1898,156 +1900,156 @@ static void PlayerLavaInit(Entity* this) { SoundReq(SFX_PLY_VO6); } -static void sub_08072354(Entity* this) { - sub_0806F854(this, 0, -12); - UpdateAnimationSingleFrame(this); - sub_08079744(this); - if (GravityUpdate(this, GRAVITY_RATE)) +static void sub_08072354(PlayerEntity* this) { + sub_0806F854(super, 0, -12); + UpdateAnimationSingleFrame(super); + sub_08079744(super); + if (GravityUpdate(super, GRAVITY_RATE)) return; - this->spritePriority.b1 = 0; - this->knockbackDuration = 0; - this->subAction = 2; - this->timer = 60; + super->spritePriority.b1 = 0; + super->knockbackDuration = 0; + super->subAction = 2; + super->timer = 60; gPlayerState.animation = ANIM_IN_LAVA; gPlayerState.flags &= ~PL_BURNING; - UpdateSpriteForCollisionLayer(this); - CreateFx(this, FX_LAVA_SPLASH, 0); + UpdateSpriteForCollisionLayer(super); + CreateFx(super, FX_LAVA_SPLASH, 0); SoundReq(SFX_1A6); } -static void sub_080723D0(Entity* this) { - UpdateAnimationSingleFrame(this); - if (this->timer-- == 0) { - this->spritePriority.b1 = 1; - this->iframes = 20; +static void sub_080723D0(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); + if (super->timer-- == 0) { + super->spritePriority.b1 = 1; + super->iframes = 20; ModHealth(-2); RespawnPlayer(); } } -static void sub_0807240C(Entity* this) { - if (this->knockbackDuration-- == 0) { - this->spriteSettings.draw = 3; - this->iframes = 20; +static void sub_0807240C(PlayerEntity* this) { + if (super->knockbackDuration-- == 0) { + super->spriteSettings.draw = 3; + super->iframes = 20; gPlayerState.flags &= ~PL_BURNING; ModHealth(-2); RespawnPlayer(); } } -static void sub_08072454(Entity* this) { - static EntityAction* const gUnk_0811BB80[] = { +static void sub_08072454(PlayerEntity* this) { + static PlayerEntityAction* const gUnk_0811BB80[] = { sub_0807246C, sub_08072490, }; - gUnk_0811BB80[this->subAction](this); + gUnk_0811BB80[super->subAction](this); } -static void sub_0807246C(Entity* this) { - this->subAction = 1; - this->timer = gPlayerState.field_0x38; +static void sub_0807246C(PlayerEntity* this) { + super->subAction = 1; + super->timer = gPlayerState.field_0x38; gPlayerState.animation = ANIM_LAUNCHED; SoundReq(SFX_PLY_VO7); } -static void sub_08072490(Entity* this) { - if (this->timer-- != 0) { - UpdateAnimationSingleFrame(this); +static void sub_08072490(PlayerEntity* this) { + if (super->timer-- != 0) { + UpdateAnimationSingleFrame(super); UpdatePlayerMovement(); } else { - this->iframes = 60; + super->iframes = 60; ModHealth(-8); ResetPlayerAnimationAndAction(); } } -static void PlayerRoomTransition(Entity* this) { - static EntityAction* const sPlayerRoomTransitionStates[] = { +static void PlayerRoomTransition(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerRoomTransitionStates[] = { sub_080724DC, sub_0807258C, }; - sPlayerRoomTransitionStates[this->subAction](this); + sPlayerRoomTransitionStates[super->subAction](this); } -static void sub_080724DC(Entity* this) { - this->knockbackDuration = 0; +static void sub_080724DC(PlayerEntity* this) { + super->knockbackDuration = 0; DeleteClones(); - if (GetTileUnderEntity(this) != 0x29) { + if (GetTileUnderEntity(super) != 0x29) { if ((gPlayerState.remainingDiveTime == 0) && (gPlayerState.swim_state != 0)) { - PlayerUpdateSwimming(this); + PlayerUpdateSwimming(super); } if (gRoomControls.reload_flags == 0) { - this->updatePriority = this->updatePriorityPrev; + super->updatePriority = super->updatePriorityPrev; PlayerWaitForScroll(this); } else if (gPlayerState.field_0x1c == 0) { - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); } } else { - this->spriteSettings.draw = 3; - this->subAction = 1; + super->spriteSettings.draw = 3; + super->subAction = 1; if (gRoomVars.field_0x0 == 0) { if (gPlayerState.flags & PL_MINISH) { gPlayerState.animation = ANIM_BOUNCE_MINISH; } else { gPlayerState.animation = ANIM_WALK; } - this->direction = Direction8FromAnimationState(this->animationState); + super->direction = Direction8FromAnimationState(super->animationState); } } } -static void sub_0807258C(Entity* this) { +static void sub_0807258C(PlayerEntity* this) { if (gRoomControls.reload_flags == 0) { - if (GetCollisionTileInFront(this) == 0x29) { + if (GetCollisionTileInFront(super) == 0x29) { UpdatePlayerMovement(); if (sub_080797C4() != 0) { - gPlayerState.startPosX = gPlayerEntity.x.HALF.HI; - gPlayerState.startPosY = gPlayerEntity.y.HALF.HI; - this->updatePriority = this->updatePriorityPrev; + gPlayerState.startPosX = gPlayerEntity.base.x.HALF.HI; + gPlayerState.startPosY = gPlayerEntity.base.y.HALF.HI; + super->updatePriority = super->updatePriorityPrev; PlayerWaitForScroll(this); } else { - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); } } else { - gPlayerState.startPosX = gPlayerEntity.x.HALF.HI; - gPlayerState.startPosY = gPlayerEntity.y.HALF.HI; - this->updatePriority = this->updatePriorityPrev; + gPlayerState.startPosX = gPlayerEntity.base.x.HALF.HI; + gPlayerState.startPosY = gPlayerEntity.base.y.HALF.HI; + super->updatePriority = super->updatePriorityPrev; PlayerWaitForScroll(this); } } if ((gPlayerState.remainingDiveTime == 0) && (gPlayerState.swim_state != 0)) { - PlayerUpdateSwimming(this); + PlayerUpdateSwimming(super); } } -static void PlayerRoll(Entity* this) { - static EntityAction* const sPlayerRollStates[] = { +static void PlayerRoll(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerRollStates[] = { PlayerRollInit, PlayerRollUpdate, }; gPlayerState.framestate = PL_STATE_ROLL; - sPlayerRollStates[this->subAction](this); + sPlayerRollStates[super->subAction](this); } -static void PlayerRollInit(Entity* this) { +static void PlayerRollInit(PlayerEntity* this) { u32 playerFlags; if ((gPlayerState.flags & PL_MOLDWORM_RELEASED) == 0) { - sub_0806F948(&gPlayerEntity); - this->direction = Direction8FromAnimationState(this->animationState); + sub_0806F948(&gPlayerEntity.base); + super->direction = Direction8FromAnimationState(super->animationState); } - this->subAction = 1; - this->timer = 0; + super->subAction = 1; + super->timer = 0; ResetActiveItems(); playerFlags = gPlayerState.flags; if (gPlayerState.flags & PL_MINISH) { - this->spritePriority.b1 = 0; + super->spritePriority.b1 = 0; gPlayerState.animation = ANIM_ROLL_MINISH; } else { - this->hurtType = 0x1e; + super->hurtType = 0x1e; if (playerFlags & PL_NO_CAP) { gPlayerState.animation = ANIM_ROLL_NOCAP; } else { @@ -2063,9 +2065,9 @@ static void PlayerRollInit(Entity* this) { SoundReq(SFX_7E); } -static void PlayerRollUpdate(Entity* this) { +static void PlayerRollUpdate(PlayerEntity* this) { if (((gPlayerState.flags & (PL_ROLLING | PL_MOLDWORM_CAPTURED)) != PL_ROLLING) || - (!(gPlayerState.flags & PL_MOLDWORM_RELEASED) && (this->iframes != 0) && (this->contactFlags & 0x80))) { + (!(gPlayerState.flags & PL_MOLDWORM_RELEASED) && (super->iframes != 0) && (super->contactFlags & 0x80))) { gPlayerState.flags &= ~PL_ROLLING; if (CheckQueuedAction()) return; @@ -2074,10 +2076,10 @@ static void PlayerRollUpdate(Entity* this) { return; } - this->direction = Direction8FromAnimationState(AnimationStateIdle(this->animationState)); - if (!(gPlayerState.flags & PL_MINISH) && (this->timer-- == 0)) { - CreateFx(&gPlayerEntity, FX_DASH, 0x40); - this->timer = 4; + super->direction = Direction8FromAnimationState(AnimationStateIdle(super->animationState)); + if (!(gPlayerState.flags & PL_MINISH) && (super->timer-- == 0)) { + CreateFx(&gPlayerEntity.base, FX_DASH, 0x40); + super->timer = 4; } if (!(gPlayerState.flags & PL_FLAGS2)) { UpdateFloorType(); @@ -2092,7 +2094,7 @@ static void PlayerRollUpdate(Entity* this) { return; } - if (sub_0807AC54(this)) { + if (sub_0807AC54(super)) { return; } @@ -2104,60 +2106,60 @@ static void PlayerRollUpdate(Entity* this) { if (gPlayerState.floor_type == SURFACE_ICE) { // roll in place when on ice - UpdateIcePlayerVelocity(this); + UpdateIcePlayerVelocity(super); } else { - switch (this->frame & 0xf) { + switch (super->frame & 0xf) { case 0: - if ((this->frame & 0xf) == 0) { - this->speed = ROLL_SPEED; + if ((super->frame & 0xf) == 0) { + super->speed = ROLL_SPEED; } break; case 1: - this->speed += ROLL_SPEED / 16; + super->speed += ROLL_SPEED / 16; break; case 2: - this->speed = (ROLL_SPEED * 3 / 2); + super->speed = (ROLL_SPEED * 3 / 2); break; case 3: - this->speed = 0; + super->speed = 0; break; } CheckPlayerVelocity(); UpdatePlayerMovement(); } - if (((this->frame & 0x10) == 0) && !(gPlayerState.flags & PL_MINISH)) { + if (((super->frame & 0x10) == 0) && !(gPlayerState.flags & PL_MINISH)) { // dont take damage - this->hurtType = 0; + super->hurtType = 0; } - if (this->frame & 0x40) { + if (super->frame & 0x40) { UpdateActiveItems(this); } - if ((this->frame & ANIM_DONE) || (gPlayerState.attack_status != 0)) { + if ((super->frame & ANIM_DONE) || (gPlayerState.attack_status != 0)) { ResetPlayerAnimationAndAction(); } - if (this->frame & ANIM_DONE) { + if (super->frame & ANIM_DONE) { gPlayerState.flags &= ~(PL_MOLDWORM_RELEASED | PL_ROLLING); } - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); } -static void PlayerWaitForScroll(Entity* this) { +static void PlayerWaitForScroll(PlayerEntity* this) { ResolvePlayerAnimation(); if (gPlayerState.flags & PL_MINISH) - sub_0807B068(this); + sub_0807B068(super); else ResetPlayerVelocity(); if (gPlayerState.swim_state != 0) - this->speed = 0; + super->speed = 0; if (!(gPlayerState.flags & PL_HIDDEN)) - gPlayerEntity.spriteSettings.draw = 3; + gPlayerEntity.base.spriteSettings.draw = 3; if (!(gPlayerState.flags & PL_MINISH)) - gPlayerEntity.spritePriority.b1 = 1; + gPlayerEntity.base.spritePriority.b1 = 1; if (!(gRoomControls.scroll_flags & 4)) { if (gPlayerState.flags & PL_HIDDEN) - COLLISION_ON(this); + COLLISION_ON(super); ResetPlayerAnimationAndAction(); } if ((gPlayerState.flags & PL_FLAGS2) == 0) { @@ -2165,127 +2167,127 @@ static void PlayerWaitForScroll(Entity* this) { } } -static void PlayerInHole(Entity* this) { - static EntityAction* const sPlayerInHoleStates[] = { +static void PlayerInHole(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerInHoleStates[] = { PlayerInHoleInit, PlayerInHoleUpdate, sub_08072ACC, sub_08072B5C, sub_08072C48, }; gPlayerState.framestate = PL_STATE_HOLE; - sPlayerInHoleStates[this->subAction](this); + sPlayerInHoleStates[super->subAction](this); } -static void PlayerInHoleInit(Entity* this) { - if (this->health != 0) { - this->subAction = 1; - this->x.HALF.HI = (this->x.HALF.HI & ~0xF) | 8; - this->y.HALF.HI = (this->y.HALF.HI & ~0XF) | 10; - COLLISION_OFF(this); - this->spritePriority.b0 = 7; - this->spritePriority.b1 = 0; - this->timer = 0; +static void PlayerInHoleInit(PlayerEntity* this) { + if (super->health != 0) { + super->subAction = 1; + super->x.HALF.HI = (super->x.HALF.HI & ~0xF) | 8; + super->y.HALF.HI = (super->y.HALF.HI & ~0XF) | 10; + COLLISION_OFF(super); + super->spritePriority.b0 = 7; + super->spritePriority.b1 = 0; + super->timer = 0; gPlayerState.flags |= PL_IN_HOLE; if (gPlayerState.flags & PL_NO_CAP) { gPlayerState.animation = ANIM_FALL_IN_HOLE_NOCAP; } else { gPlayerState.animation = ANIM_FALL_IN_HOLE; - if (GetTileIndex(COORD_TO_TILE(this), this->collisionLayer) == 0x4020) { - this->timer = 1; + if (GetTileIndex(COORD_TO_TILE(super), super->collisionLayer) == 0x4020) { + super->timer = 1; } } - SetTile(0x4070, COORD_TO_TILE(this), this->collisionLayer); + SetTile(0x4070, COORD_TO_TILE(super), super->collisionLayer); ResetActiveItems(); PlayerInHoleUpdate(this); SoundReq(SFX_81); } } -static void PlayerInHoleUpdate(Entity* this) { - if (this->frame & ANIM_DONE) { - if (this->timer == 1) { - this->subAction = 3; - this->timer = 40; - this->spritePriority.b1 = 1; +static void PlayerInHoleUpdate(PlayerEntity* this) { + if (super->frame & ANIM_DONE) { + if (super->timer == 1) { + super->subAction = 3; + super->timer = 40; + super->spritePriority.b1 = 1; gPlayerState.animation = ANIM_SPRING_JUMP; return; } - this->subAction = 2; + super->subAction = 2; if (gPlayerState.flags & PL_NO_CAP) { gPlayerState.animation = ANIM_IN_HOLE_NOCAP; } else { gPlayerState.animation = ANIM_IN_HOLE; } } else { - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); } } -static void sub_08072ACC(Entity* this) { +static void sub_08072ACC(PlayerEntity* this) { if (gPlayerState.direction == DIR_NONE) { - this->subtimer = 0; - } else if (this->subtimer > 7) { - COLLISION_ON(this); - this->direction = gPlayerState.direction; - this->zVelocity = JUMP_SPEED_HOLE_Z; - this->speed = JUMP_SPEED_HOLE_FWD; - this->spritePriority.b0 = 4; - this->spritePriority.b1 = 1; + super->subtimer = 0; + } else if (super->subtimer > 7) { + COLLISION_ON(super); + super->direction = gPlayerState.direction; + super->zVelocity = JUMP_SPEED_HOLE_Z; + super->speed = JUMP_SPEED_HOLE_FWD; + super->spritePriority.b0 = 4; + super->spritePriority.b1 = 1; gPlayerState.jump_status = 0x41; PlayerSetNormalAndCollide(); - RestorePrevTileEntity(COORD_TO_TILE(this), this->collisionLayer); + RestorePrevTileEntity(COORD_TO_TILE(super), super->collisionLayer); } else { - this->animationState = Direction8ToAnimationState(gPlayerState.direction); - this->subtimer++; + super->animationState = Direction8ToAnimationState(gPlayerState.direction); + super->subtimer++; } } -static void sub_08072B5C(Entity* this) { +static void sub_08072B5C(PlayerEntity* this) { u32 temp; - sub_080042BA(this, ((40 - this->timer) >> 4) + 1); - sub_0806F948(this); - if (this->timer != 0) { - this->timer--; + sub_080042BA(super, ((40 - super->timer) >> 4) + 1); + sub_0806F948(super); + if (super->timer != 0) { + super->timer--; return; } - SetTile(0x4021, COORD_TO_TILE(this), this->collisionLayer); - this->direction = Direction8FromAnimationState(this->animationState); + SetTile(0x4021, COORD_TO_TILE(super), super->collisionLayer); + super->direction = Direction8FromAnimationState(super->animationState); temp = sub_0807A2F8(1); if (!temp) { - COLLISION_ON(this); - this->spritePriority.b0 = 4; - this->speed = 0x40; - this->zVelocity = Q_16_16(3.5625); - this->z.WORD--; + COLLISION_ON(super); + super->spritePriority.b0 = 4; + super->speed = 0x40; + super->zVelocity = Q_16_16(3.5625); + super->z.WORD--; gPlayerState.jump_status = 0x41; - sub_0806F854(this, 0, -12); + sub_0806F854(super, 0, -12); PlayerSetNormalAndCollide(); return; } if (!AreaIsOverworld()) { - sub_08004542(this); + sub_08004542(super); } - this->subAction++; + super->subAction++; temp <<= 4; temp -= 4; temp <<= 12; - this->zVelocity = temp; + super->zVelocity = temp; - this->speed = JUMP_SPEED_FWD; + super->speed = JUMP_SPEED_FWD; gPlayerState.animation = ANIM_JUMP; SoundReq(SFX_PLY_JUMP); } -static void sub_08072C48(Entity* this) { - UpdateAnimationSingleFrame(this); - LinearMoveUpdate(this); - if (GravityUpdate(this, GRAVITY_RATE)) +static void sub_08072C48(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); + LinearMoveUpdate(super); + if (GravityUpdate(super, GRAVITY_RATE)) return; - sub_08008790(this, 7); + sub_08008790(super, 7); if (gPlayerState.field_0x14) { if (PlayerCheckNEastTile()) { gPlayerState.surfacePositionSameTimer = 7; @@ -2298,43 +2300,43 @@ static void sub_08072C48(Entity* this) { } } -static void sub_08072C9C(Entity* this) { - static EntityAction* const gUnk_0811BBAC[] = { +static void sub_08072C9C(PlayerEntity* this) { + static PlayerEntityAction* const gUnk_0811BBAC[] = { sub_08072CC0, sub_08072CFC, sub_08072D54, sub_08072F14, }; gPlayerState.framestate = PL_STATE_11; - gUnk_0811BBAC[this->subAction](this); + gUnk_0811BBAC[super->subAction](this); } -static void sub_08072CC0(Entity* this) { - this->subAction = 1; - COLLISION_OFF(this); - this->subtimer = (gPlayerState.field_0x3a >> 2) + 1; - this->direction = gPlayerState.field_0x39; - this->speed = 0x400; +static void sub_08072CC0(PlayerEntity* this) { + super->subAction = 1; + COLLISION_OFF(super); + super->subtimer = (gPlayerState.field_0x3a >> 2) + 1; + super->direction = gPlayerState.field_0x39; + super->speed = 0x400; gPlayerState.animation = ANIM_GUSTJAR_524; gPlayerState.heldObject = 0; } -static void sub_08072CFC(Entity* this) { - sub_080042BA(this, 2); - if (this->subtimer-- != 0) { - LinearMoveUpdate(this); +static void sub_08072CFC(PlayerEntity* this) { + sub_080042BA(super, 2); + if (super->subtimer-- != 0) { + LinearMoveUpdate(super); return; } - this->subAction = 2; + super->subAction = 2; if (gPlayerState.field_0x38 < 8) { gPlayerState.field_0x38 = 8; } - this->zVelocity = gPlayerState.field_0x38 << 0xc; - this->speed = 0x200; + super->zVelocity = gPlayerState.field_0x38 << 0xc; + super->speed = 0x200; gPlayerState.animation = ANIM_JUMP; - this->timer = 5; - this->subtimer = 0; + super->timer = 5; + super->subtimer = 0; ResetActiveItems(); } @@ -2349,65 +2351,65 @@ static const u16* const sTileTable[] = { sTiles + 9, }; -static void sub_08072D54(Entity* this) { +static void sub_08072D54(PlayerEntity* this) { u32 uVar2; - UpdateAnimationSingleFrame(this); - sub_0806F854(this, 0, -12); - if (this->timer != 0) { - LinearMoveUpdate(this); - this->timer--; + UpdateAnimationSingleFrame(super); + sub_0806F854(super, 0, -12); + if (super->timer != 0) { + LinearMoveUpdate(super); + super->timer--; } else { - uVar2 = GetTileType(sub_0806F730(this), this->collisionLayer); - switch (this->subtimer) { + uVar2 = GetTileType(sub_0806F730(super), super->collisionLayer); + switch (super->subtimer) { case 0: - if (sub_08007DD6(uVar2, sTileTable[gPlayerEntity.animationState >> 1])) { - this->timer = 1; - this->subtimer = 1; + if (sub_08007DD6(uVar2, sTileTable[gPlayerEntity.base.animationState >> 1])) { + super->timer = 1; + super->subtimer = 1; } break; case 1: - if (sub_08007DD6(uVar2, sTileTable[gPlayerEntity.animationState >> 1])) { - this->timer = 1; + if (sub_08007DD6(uVar2, sTileTable[gPlayerEntity.base.animationState >> 1])) { + super->timer = 1; } else { - this->subtimer = 2; + super->subtimer = 2; } break; case 2: - this->animationState ^= 4; - if (sub_08007DD6(uVar2, sTileTable[gPlayerEntity.animationState >> 1]) != 0) { - this->timer = 1; - this->subtimer = 3; + super->animationState ^= 4; + if (sub_08007DD6(uVar2, sTileTable[gPlayerEntity.base.animationState >> 1]) != 0) { + super->timer = 1; + super->subtimer = 3; } - this->animationState ^= 4; + super->animationState ^= 4; break; case 3: - this->animationState ^= 4; - if (sub_08007DD6(uVar2, sTileTable[gPlayerEntity.animationState >> 1])) { - this->timer = 1; + super->animationState ^= 4; + if (sub_08007DD6(uVar2, sTileTable[gPlayerEntity.base.animationState >> 1])) { + super->timer = 1; } else { - this->subtimer = 4; + super->subtimer = 4; } - this->animationState ^= 4; + super->animationState ^= 4; break; } - if (this->timer != 0) { - LinearMoveUpdate(this); + if (super->timer != 0) { + LinearMoveUpdate(super); } else { UpdatePlayerMovement(); } - this->timer = 0; + super->timer = 0; } - if (!GravityUpdate(this, GRAVITY_RATE)) { - COLLISION_ON(this); - if (this->collisionLayer == 1) { - ResetCollisionLayer(this); + if (!GravityUpdate(super, GRAVITY_RATE)) { + COLLISION_ON(super); + if (super->collisionLayer == 1) { + ResetCollisionLayer(super); } else { - sub_08004542(this); + sub_08004542(super); } - sub_08008790(this, 7); + sub_08008790(super, 7); if (gPlayerState.field_0x14 != 0) { if (PlayerCheckNEastTile()) { gPlayerState.surfacePositionSameTimer = 7; @@ -2421,45 +2423,45 @@ static void sub_08072D54(Entity* this) { } else { gPlayerState.animation = ANIM_LAND; } - this->timer = 6; - this->subAction = 3; - this->knockbackDuration = 0; + super->timer = 6; + super->subAction = 3; + super->knockbackDuration = 0; SoundReq(SFX_PLY_LAND); } } } -static void sub_08072F14(Entity* this) { - if (this->timer-- != 0) { +static void sub_08072F14(PlayerEntity* this) { + if (super->timer-- != 0) { PlayerSetNormalAndCollide(); } else { - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); } } -static void PlayerClimb(Entity* this) { - static EntityAction* const sPlayerClimbStates[] = { +static void PlayerClimb(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerClimbStates[] = { sub_08072F94, sub_08073094, }; if (!CheckQueuedAction()) { gPlayerState.framestate = PL_STATE_CLIMB; - gPlayerState.floor_type = GetSurfaceCalcType(this, 0, 0); - sPlayerClimbStates[this->subAction](this); - if (this->knockbackDuration != 0) { + gPlayerState.floor_type = GetSurfaceCalcType(super, 0, 0); + sPlayerClimbStates[super->subAction](this); + if (super->knockbackDuration != 0) { sub_080792D8(); - if (this->knockbackDuration == 0) { - this->action = PLAYER_CLIMB; - this->subAction = 0; - this->y.HALF.LO = 0; + if (super->knockbackDuration == 0) { + super->action = PLAYER_CLIMB; + super->subAction = 0; + super->y.HALF.LO = 0; gPlayerState.animation = ANIM_CLIMB1_UP; } } } } -static void sub_08072F94(Entity* this) { +static void sub_08072F94(PlayerEntity* this) { u32 direction; switch (gPlayerState.floor_type) { @@ -2470,15 +2472,15 @@ static void sub_08072F94(Entity* this) { case SURFACE_AUTO_LADDER: case SURFACE_CLIMB_WALL: case SURFACE_2C: - this->spritePriority.b1 = 0; + super->spritePriority.b1 = 0; direction = gPlayerState.direction; if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) == 0) { - this->direction = gPlayerState.direction; + super->direction = gPlayerState.direction; if ((gPlayerState.direction == DirectionEast) || (gPlayerState.direction == DirectionWest)) { if (gPlayerState.floor_type == SURFACE_LADDER) { return; } - if ((this->frame & 0x10)) { + if ((super->frame & 0x10)) { gPlayerState.animation = ANIM_CLIMB_LEFT; } else { gPlayerState.animation = ANIM_CLIMB_RIGHT; @@ -2486,25 +2488,25 @@ static void sub_08072F94(Entity* this) { sub_08073094(this); } else { if ((gPlayerState.floor_type == SURFACE_LADDER) && ((direction & (DIR_DIAGONAL | 0x3)) != 0)) { - this->direction = (direction + 8) & DirectionSouth; + super->direction = (direction + 8) & DirectionSouth; } - if (this->direction & DirectionSouth) { - if (this->frame & 0x10) { + if (super->direction & DirectionSouth) { + if (super->frame & 0x10) { gPlayerState.animation = ANIM_CLIMB1_DOWN; } else { gPlayerState.animation = ANIM_CLIMB2_DOWN; } } else { - if (this->frame & 0x10) { + if (super->frame & 0x10) { gPlayerState.animation = ANIM_CLIMB1_UP; } else { gPlayerState.animation = ANIM_CLIMB2_UP; } } } - this->subAction++; + super->subAction++; } else { - if (this->frame & 0x10) { + if (super->frame & 0x10) { gPlayerState.animation = ANIM_CLIMB_LEFT; } else { gPlayerState.animation = ANIM_CLIMB_RIGHT; @@ -2514,13 +2516,13 @@ static void sub_08072F94(Entity* this) { } } -static void sub_08073094(Entity* this) { +static void sub_08073094(PlayerEntity* this) { static const u16 sSpeeds[] = { 0x0, 0x40, 0x60, 0x80, 0x100, 0xC0, }; - this->spritePriority.b1 = 0; - this->speed = sSpeeds[this->frame & 0xf]; + super->spritePriority.b1 = 0; + super->speed = sSpeeds[super->frame & 0xf]; UpdatePlayerMovement(); if (!UpdatePlayerCollision()) { gPlayerState.pushedObject ^= 0x80; @@ -2532,13 +2534,13 @@ static void sub_08073094(Entity* this) { switch (gPlayerState.floor_type) { case SURFACE_AUTO_LADDER: case SURFACE_2C: - this->knockbackDuration = 0; + super->knockbackDuration = 0; gPlayerState.flags |= PL_CLIMBING; - UpdateAnimationSingleFrame(this); - if (this->frame & 0x40) { + UpdateAnimationSingleFrame(super); + if (super->frame & 0x40) { UpdateFloorType(); if (!CheckQueuedAction()) { - this->subAction--; + super->subAction--; } } break; @@ -2551,11 +2553,11 @@ static void sub_08073094(Entity* this) { break; case SURFACE_LADDER: case SURFACE_CLIMB_WALL: - UpdateAnimationSingleFrame(this); - if (this->frame & 0x40) { + UpdateAnimationSingleFrame(super); + if (super->frame & 0x40) { UpdateFloorType(); if (!CheckQueuedAction()) { - this->subAction--; + super->subAction--; } } break; @@ -2564,8 +2566,8 @@ static void sub_08073094(Entity* this) { } } -static void PlayerUseEntrance(Entity* this) { - static EntityAction* const sPlayerUseEntranceStates[] = { +static void PlayerUseEntrance(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerUseEntranceStates[] = { PlayerUseStairs, sub_080732D0, sub_0807332C, @@ -2574,37 +2576,37 @@ static void PlayerUseEntrance(Entity* this) { gPlayerState.framestate = PL_STATE_STAIRS; RequestPriorityDuration(NULL, 8); - sPlayerUseEntranceStates[this->subAction](this); + sPlayerUseEntranceStates[super->subAction](this); } -static void PlayerUseStairs(Entity* this) { - COLLISION_OFF(this); - this->speed = 0x40; - this->animationState = IdleNorth; - this->x.HALF.HI = (this->x.HALF.HI & ~0xF) | 8; - this->x.HALF.LO = 0; +static void PlayerUseStairs(PlayerEntity* this) { + COLLISION_OFF(super); + super->speed = 0x40; + super->animationState = IdleNorth; + super->x.HALF.HI = (super->x.HALF.HI & ~0xF) | 8; + super->x.HALF.LO = 0; if (gPlayerState.field_0x38 == 0) { - this->subAction = 1; + super->subAction = 1; } else { - this->spriteSettings.draw = 3; - this->subAction = 3; - this->field_0x7c.HALF.HI = this->y.HALF.HI; - this->y.HALF.HI -= 16; - this->child = CreateObjectWithParent(this, OBJECT_70, 1, 0); + super->spriteSettings.draw = 3; + super->subAction = 3; + this->unk_7c.HALF.HI = super->y.HALF.HI; + super->y.HALF.HI -= 16; + super->child = CreateObjectWithParent(super, OBJECT_70, 1, 0); if (gPlayerState.field_0x39 == 7) { - this->y.HALF.HI = (this->y.HALF.HI & ~0xF) + 8; - this->x.HALF.HI &= ~0xF; - this->direction = DirectionEast; - this->animationState = IdleEast; + super->y.HALF.HI = (super->y.HALF.HI & ~0xF) + 8; + super->x.HALF.HI &= ~0xF; + super->direction = DirectionEast; + super->animationState = IdleEast; SoundReq(SFX_STAIRS_ASCEND); } else { - this->y.HALF.HI = (this->y.HALF.HI & ~0xF) + 2; - this->x.HALF.HI = (this->x.HALF.HI & ~0xF) + 15; - this->direction = DirectionWest; - this->animationState = IdleWest; + super->y.HALF.HI = (super->y.HALF.HI & ~0xF) + 2; + super->x.HALF.HI = (super->x.HALF.HI & ~0xF) + 15; + super->direction = DirectionWest; + super->animationState = IdleWest; SoundReq(SFX_STAIRS_DESCEND); } - SetZeldaFollowTarget(this); + SetZeldaFollowTarget(super); } if (gPlayerState.flags & PL_NO_CAP) { gPlayerState.animation = ANIM_WALK_NOCAP; @@ -2616,15 +2618,15 @@ static void PlayerUseStairs(Entity* this) { ResetActiveItems(); } -static void sub_080732D0(Entity* this) { - UpdateAnimationSingleFrame(this); - if (GetTileUnderEntity(this) != 40) { - this->direction = DirectionNorth; - LinearMoveUpdate(this); +static void sub_080732D0(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); + if (GetTileUnderEntity(super) != 40) { + super->direction = DirectionNorth; + LinearMoveUpdate(super); } else { - this->subAction++; - this->y.HALF.LO = 0; - CreateObjectWithParent(this, OBJECT_70, 1, 0); + super->subAction++; + super->y.HALF.LO = 0; + CreateObjectWithParent(super, OBJECT_70, 1, 0); if (gPlayerState.field_0x39 == 7) { SoundReq(SFX_STAIRS_ASCEND); } else { @@ -2633,31 +2635,31 @@ static void sub_080732D0(Entity* this) { } } -static void sub_0807332C(Entity* this) { - UpdateAnimationSingleFrame(this); +static void sub_0807332C(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); if (gPlayerState.field_0x39 == 7) { - this->direction = IdleNorth; + super->direction = IdleNorth; } else { - this->direction = DirectionNorthWest; + super->direction = DirectionNorthWest; } - if ((this->x.HALF.HI & 0xF) != 0xF) { + if ((super->x.HALF.HI & 0xF) != 0xF) { if (gPlayerState.field_0x39 == 7) { - this->animationState = IdleEast; - this->direction = DIR_DIAGONAL; + super->animationState = IdleEast; + super->direction = DIR_DIAGONAL; } else { - this->animationState = IdleWest; - if (this->direction <= DirectionWest) { - LinearMoveUpdate(this); + super->animationState = IdleWest; + if (super->direction <= DirectionWest) { + LinearMoveUpdate(super); return; } - this->direction = (this->direction - 1) & - (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest); + super->direction = (super->direction - 1) & + (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest); } - LinearMoveUpdate(this); + LinearMoveUpdate(super); return; } if (gPlayerState.field_0x38 != 0) { - gRoomControls.camera_target = this; + gRoomControls.camera_target = super; SetPlayerActionNormal(); } else { gMain.substate = GAMEMAIN_CHANGEAREA; @@ -2666,91 +2668,91 @@ static void sub_0807332C(Entity* this) { } } -static void sub_080733BC(Entity* this) { - UpdateAnimationSingleFrame(this); - if ((this->x.HALF.HI & 0xF) == 8) { +static void sub_080733BC(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); + if ((super->x.HALF.HI & 0xF) == 8) { Entity* c; - this->direction = DirectionSouth; - this->animationState = IdleSouth; - c = this->child; + super->direction = DirectionSouth; + super->animationState = IdleSouth; + c = super->child; if (c != NULL) { DeleteEntity(c); - this->child = NULL; - if (this->collisionLayer == 1) { - sub_0807AABC(this); + super->child = NULL; + if (super->collisionLayer == 1) { + sub_0807AABC(super); } else { - sub_0807AA80(this); + sub_0807AA80(super); } } } - LinearMoveUpdate(this); - if (this->field_0x7c.HALF_U.HI == this->y.HALF.HI) { - gRoomControls.camera_target = this; + LinearMoveUpdate(super); + if (this->unk_7c.HALF_U.HI == super->y.HALF.HI) { + gRoomControls.camera_target = super; PlayerSetNormalAndCollide(); } } -static void PlayerParachute(Entity* this) { - static EntityAction* const sPlayerParachuteStates[] = { +static void PlayerParachute(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerParachuteStates[] = { sub_08073468, sub_080734D4, sub_08073504, sub_08073584, sub_0807379C, sub_080737BC, sub_0807380C, sub_08073884, }; if (!CheckQueuedAction()) { UpdateFloorType(); - this->spriteOrientation.flipY = 1; - this->spriteRendering.b3 = 1; + super->spriteOrientation.flipY = 1; + super->spriteRendering.b3 = 1; gPlayerState.framestate = PL_STATE_PARACHUTE; - sPlayerParachuteStates[this->subAction](this); + sPlayerParachuteStates[super->subAction](this); } } -static void sub_08073468(Entity* this) { +static void sub_08073468(PlayerEntity* this) { gPlayerState.animation = ANIM_PARACHUTE_ACTIVATE; gPlayerState.jump_status = 0; - this->zVelocity = Q_16_16(-1.0); - this->subAction++; - this->field_0x7c.WORD = 480; - this->direction = Direction8FromAnimationState(this->animationState); + super->zVelocity = Q_16_16(-1.0); + super->subAction++; + this->unk_7c.WORD = 480; + super->direction = Direction8FromAnimationState(super->animationState); if ((gPlayerState.flags & PL_PARACHUTE) == 0) { gPlayerState.flags |= PL_PARACHUTE; - CreateObjectWithParent(this, EZLO_CAP_FLYING, 0, 0); + CreateObjectWithParent(super, EZLO_CAP_FLYING, 0, 0); } ResetActiveItems(); - if (this->zVelocity > 0 || gPlayerState.field_0x38 == 1) - COLLISION_OFF(this); + if (super->zVelocity > 0 || gPlayerState.field_0x38 == 1) + COLLISION_OFF(super); } -static void sub_080734D4(Entity* this) { - GravityUpdate(this, -(GRAVITY_RATE / 2)); - if (this->zVelocity > 0 || gPlayerState.field_0x38 == 1) { - this->zVelocity = Q_16_16(4.5625); - this->subAction++; +static void sub_080734D4(PlayerEntity* this) { + GravityUpdate(super, -(GRAVITY_RATE / 2)); + if (super->zVelocity > 0 || gPlayerState.field_0x38 == 1) { + super->zVelocity = Q_16_16(4.5625); + super->subAction++; } } -static void sub_08073504(Entity* this) { - GravityUpdate(this, this->zVelocity < 0 ? GRAVITY_RATE / 4 : GRAVITY_RATE * 2); - if (this->zVelocity < 0 && this->z.HALF.HI > -32) { - this->subAction++; - *((u32*)&this->field_0x80.HWORD) = this->direction << 8; - this->field_0x86.HALF.HI = 0; - this->field_0x86.HALF.LO = 0; +static void sub_08073504(PlayerEntity* this) { + GravityUpdate(super, super->zVelocity < 0 ? GRAVITY_RATE / 4 : GRAVITY_RATE * 2); + if (super->zVelocity < 0 && super->z.HALF.HI > -32) { + super->subAction++; + this->unk_80.WORD = super->direction << 8; + this->unk_84.BYTES.byte3 = 0; + this->unk_84.BYTES.byte2 = 0; gPlayerState.animation = ANIM_PARACHUTE; if (gPlayerState.field_0x38 == 1) { - COLLISION_OFF(this); - this->subAction = 6; - this->speed = 16; - this->timer = 30; + COLLISION_OFF(super); + super->subAction = 6; + super->speed = 16; + super->timer = 30; SoundReq(SFX_NEAR_PORTAL); } } - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); } -static void sub_08073584(Entity* this) { +static void sub_08073584(PlayerEntity* this) { u32 state, dir, idx; - if ((gPlayerState.playerInput.newInput & INPUT_ACTION) || this->iframes > 0 || gPlayerState.field_0x3c || + if ((gPlayerState.playerInput.newInput & INPUT_ACTION) || super->iframes > 0 || gPlayerState.field_0x3c || (gPlayerState.flags & PL_PARACHUTE) == 0) { gPlayerState.jump_status |= 0x40; PlayerSetNormalAndCollide(); @@ -2761,53 +2763,53 @@ static void sub_08073584(Entity* this) { gUnk_0200AF00.rActionPlayerState = R_ACTION_CANCEL; if (sub_0807A2F8(0)) { - this->subAction++; - this->direction = 4 * (this->animationState & IdleWest); - COLLISION_OFF(this); + super->subAction++; + super->direction = 4 * (super->animationState & IdleWest); + COLLISION_OFF(super); return; } if (gArea.locationIndex == 16) - this->speed = 0x100; + super->speed = 0x100; else - this->speed = 0x80; + super->speed = 0x80; if ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) == 0) { - if (this->direction != gPlayerState.direction) { - if (((this->direction - gPlayerState.direction) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | - DirectionSouth | DirectionWest)) < DirectionSouth) - *(u32*)&this->field_0x80 -= 0x20; + if (super->direction != gPlayerState.direction) { + if (((super->direction - gPlayerState.direction) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | + DirectionSouth | DirectionWest)) < DirectionSouth) + this->unk_80.WORD_U -= 0x20; else - *(u32*)&this->field_0x80 += 0x20; + this->unk_80.WORD_U += 0x20; } } - this->direction = (*(u32*)&this->field_0x80 >> 8) & - (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest); + super->direction = (this->unk_80.WORD_U >> 8) & + (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest); UpdatePlayerMovement(); - state = 4 * this->animationState; - dir = this->direction; - if (this->animationState == IdleNorth) { + state = 4 * super->animationState; + dir = super->direction; + if (super->animationState == IdleNorth) { state = (state + 8) & 0x1F; dir = (dir + 8) & (0x3 | DIR_DIAGONAL | DirectionNorth | DirectionEast | DirectionSouth | DirectionWest); } if (state - 7 > dir) { - state = (this->animationState - 2) & 7; + state = (super->animationState - 2) & 7; } else if (state + 7 < dir) { - state = (this->animationState + 2) & 7; + state = (super->animationState + 2) & 7; } else { - state = this->animationState; + state = super->animationState; } - if (state != this->animationState) { - this->field_0x86.HALF.HI = 20; + if (state != super->animationState) { + this->unk_84.BYTES.byte3 = 20; } - this->animationState = state; + super->animationState = state; idx = 0; state = gPlayerState.direction >> 2; - if (!this->field_0x86.HALF.HI || - ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) == 0 && this->animationState != state)) { + if (!this->unk_84.BYTES.byte3 || + ((gPlayerState.direction & DIR_NOT_MOVING_CHECK) == 0 && super->animationState != state)) { static const u16 sAnims1[] = { ANIM_PARACHUTE, ANIM_PARACHUTE_TURN_LEFT, @@ -2816,12 +2818,12 @@ static void sub_08073584(Entity* this) { }; if (!(gPlayerState.direction & DIR_NOT_MOVING_CHECK)) { - if (this->animationState != state) { - if (this->animationState == (state ^ 4)) { + if (super->animationState != state) { + if (super->animationState == (state ^ 4)) { idx = 2; } else { - if (this->animationState == (((state & 6) + 2) & 7)) { + if (super->animationState == (((state & 6) + 2) & 7)) { idx = 1; } else { idx = 3; @@ -2832,13 +2834,13 @@ static void sub_08073584(Entity* this) { if (sAnims1[idx] == gPlayerState.animation) { if (gArea.locationIndex == 16) - sub_080042BA(this, 2); + sub_080042BA(super, 2); else - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); } else { gPlayerState.animation = sAnims1[idx]; } - this->field_0x86.HALF.LO = idx; + this->unk_84.BYTES.byte2 = idx; } else { static const u16 sAnims2[] = { ANIM_PARACHUTE, @@ -2847,50 +2849,50 @@ static void sub_08073584(Entity* this) { ANIM_PARACHUTE_TURN2_RIGHT, }; - this->field_0x86.HALF.HI--; - if (sAnims2[this->field_0x86.HALF.LO] == gPlayerState.animation) - UpdateAnimationSingleFrame(this); + this->unk_84.BYTES.byte3--; + if (sAnims2[this->unk_84.BYTES.byte2] == gPlayerState.animation) + UpdateAnimationSingleFrame(super); else - gPlayerState.animation = sAnims2[this->field_0x86.HALF.LO]; + gPlayerState.animation = sAnims2[this->unk_84.BYTES.byte2]; } - if (--this->field_0x7c.WORD == -1) { + if (--this->unk_7c.WORD_U == -1) { gPlayerState.jump_status |= 0x40; PlayerSetNormalAndCollide(); } else { - u32 di = (this->field_0x7c.WORD / 20); - this->z.HALF.HI = -8 - di; + u32 di = (this->unk_7c.WORD / 20); + super->z.HALF.HI = -8 - di; } } -static void sub_0807379C(Entity* this) { - if (this->z.HALF.HI > -32) { - this->z.HALF.HI--; +static void sub_0807379C(PlayerEntity* this) { + if (super->z.HALF.HI > -32) { + super->z.HALF.HI--; } else { - this->subAction++; + super->subAction++; } } -static void sub_080737BC(Entity* this) { +static void sub_080737BC(PlayerEntity* this) { u16 pos; u32 tmp; - UpdateAnimationSingleFrame(this); - LinearMoveUpdate(this); - this->z.WORD += Q_16_16(0.296875); - if (DirectionIsHorizontal(this->direction)) - pos = this->x.HALF.HI; + UpdateAnimationSingleFrame(super); + LinearMoveUpdate(super); + super->z.WORD += Q_16_16(0.296875); + if (DirectionIsHorizontal(super->direction)) + pos = super->x.HALF.HI; else - pos = this->y.HALF.HI; + pos = super->y.HALF.HI; tmp = 0xf; tmp &= pos; - if (tmp == 8 && !sub_080B1B0C(this)) { + if (tmp == 8 && !sub_080B1B0C(super)) { gPlayerState.jump_status |= 0x40; PlayerSetNormalAndCollide(); } } -static void sub_0807380C(Entity* this) { +static void sub_0807380C(PlayerEntity* this) { static const u16 sAnims[] = { ANIM_PARACHUTE, ANIM_PARACHUTE_TURN_LEFT, @@ -2899,24 +2901,24 @@ static void sub_0807380C(Entity* this) { }; if ((gRoomTransition.frameCount & 3) == 0) { - u32 tmp = (this->animationState + 2) & IdleWest; - this->animationState = tmp; - this->direction = 4 * tmp; + u32 tmp = (super->animationState + 2) & IdleWest; + super->animationState = tmp; + super->direction = 4 * tmp; } - gPlayerState.animation = sAnims[this->animationState >> 1]; - if (this->z.HALF.HI < -16) { - GravityUpdate(this, GRAVITY_RATE / 16); + gPlayerState.animation = sAnims[super->animationState >> 1]; + if (super->z.HALF.HI < -16) { + GravityUpdate(super, GRAVITY_RATE / 16); } else { - if (--this->timer == 0) { - this->subAction = 7; - this->timer = 60; - this->zVelocity = Q_16_16(2.0); + if (--super->timer == 0) { + super->subAction = 7; + super->timer = 60; + super->zVelocity = Q_16_16(2.0); } } - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); } -void sub_08073884(Entity* this) { +void sub_08073884(PlayerEntity* this) { static const u16 sAnims[] = { ANIM_PARACHUTE, ANIM_PARACHUTE_TURN_LEFT, @@ -2925,42 +2927,42 @@ void sub_08073884(Entity* this) { }; if ((gRoomTransition.frameCount & 1) == 0) { - u32 tmp = (this->animationState + 2) & IdleWest; - this->animationState = tmp; - this->direction = 4 * tmp; + u32 tmp = (super->animationState + 2) & IdleWest; + super->animationState = tmp; + super->direction = 4 * tmp; } - gPlayerState.animation = sAnims[this->animationState >> 1]; - if (--this->timer == 0) { + gPlayerState.animation = sAnims[super->animationState >> 1]; + if (--super->timer == 0) { if (gPlayerState.field_0x39 != 0xff) DoExitTransition(&gUnk_0813AD88[gPlayerState.field_0x39]); else InitParachuteRoom(); } - GravityUpdate(this, -((GRAVITY_RATE * 3) / 4)); - UpdateAnimationSingleFrame(this); + GravityUpdate(super, -((GRAVITY_RATE * 3) / 4)); + UpdateAnimationSingleFrame(super); } -static void DoJump(Entity* this) { - static EntityAction* const sStates[] = { +static void DoJump(PlayerEntity* this) { + static PlayerEntityAction* const sStates[] = { sub_08073924, sub_08073968, sub_080739EC, sub_08073A94, sub_08073B8C, sub_08073C30, }; sStates[gPlayerState.jump_status & 7](this); } -static void sub_08073924(Entity* this) { - if (!(gPlayerState.flags & PL_ROLLING) && (this->z.HALF.HI & 0x8000) && !gPlayerState.field_0xa) { +static void sub_08073924(PlayerEntity* this) { + if (!(gPlayerState.flags & PL_ROLLING) && (super->z.HALF.HI & 0x8000) && !gPlayerState.field_0xa) { gPlayerState.jump_status = 0x40; gPlayerState.direction = DIR_NONE; - this->direction = DIR_NONE; + super->direction = DIR_NONE; PutAwayItems(); sub_08073968(this); } } -static void sub_08073968(Entity* this) { +static void sub_08073968(PlayerEntity* this) { if ((gPlayerState.jump_status & 0xC0) == 0) { - this->direction = gPlayerState.direction; + super->direction = gPlayerState.direction; } CheckPlayerVelocity(); if ((gPlayerState.heldObject | gPlayerState.keepFacing) == 0) { @@ -2976,23 +2978,23 @@ static void sub_08073968(Entity* this) { } } if ((gPlayerState.jump_status & 0xC0) == 0) { - sub_0806F948(this); + sub_0806F948(super); } SoundReq(SFX_PLY_JUMP); } gPlayerState.jump_status = (gPlayerState.jump_status & ~7) | 2; } -static void sub_080739EC(Entity* this) { +static void sub_080739EC(PlayerEntity* this) { u32 v; if ((gPlayerState.jump_status & 0xC0) != 0) { - gPlayerState.direction = this->direction; + gPlayerState.direction = super->direction; if (gPlayerState.jump_status & 0x80) - this->collisions = COL_NONE; + super->collisions = COL_NONE; v = GRAVITY_RATE; } else { - if ((u16)sub_0806F854(this, 0, -12)) { + if ((u16)sub_0806F854(super, 0, -12)) { gPlayerState.jump_status |= 8; v = GRAVITY_RATE * 2; } else { @@ -3002,39 +3004,39 @@ static void sub_080739EC(Entity* this) { } } if ((gPlayerState.jump_status & 0xC0) == 0) { - if ((gPlayerState.jump_status & 0x20) && this->zVelocity == 0) { - this->zVelocity = Q_16_16(2.5); - this->timer = 10; - this->direction = DIR_NONE; + if ((gPlayerState.jump_status & 0x20) && super->zVelocity == 0) { + super->zVelocity = Q_16_16(2.5); + super->timer = 10; + super->direction = DIR_NONE; gPlayerState.jump_status += 2; gPlayerState.animation = ANIM_DOWN_THRUST; ResetPlayerVelocity(); return; } } - if (!GravityUpdate(this, v)) + if (!GravityUpdate(super, v)) sub_08073AD4(this); } -void sub_08073A94(Entity* this) { - if ((this->frame & ANIM_DONE) || this->knockbackDuration != 0) { +void sub_08073A94(PlayerEntity* this) { + if ((super->frame & ANIM_DONE) || super->knockbackDuration != 0) { sub_08073B60(this); } - if (gPlayerEntity.z.WORD != 0) { + if (gPlayerEntity.base.z.WORD != 0) { gPlayerState.jump_status = 0; sub_08073924(this); } } -static void sub_08073AD4(Entity* this) { +static void sub_08073AD4(PlayerEntity* this) { u32 tmp; - if ((this->collisionLayer & 2) == 0) { - this->spriteOrientation.flipY = 2; - this->spriteRendering.b3 = 2; + if ((super->collisionLayer & 2) == 0) { + super->spriteOrientation.flipY = 2; + super->spriteRendering.b3 = 2; } tmp = (gPlayerState.jump_status & ~0xC0); - if (this->action != PLAYER_MINISHDIE) { + if (super->action != PLAYER_MINISHDIE) { sub_0807A2B8(); gPlayerState.jump_status = 0; UpdateFloorType(); @@ -3052,95 +3054,95 @@ static void sub_08073AD4(Entity* this) { SoundReq(SFX_PLY_LAND); } -static void sub_08073B60(Entity* this) { +static void sub_08073B60(PlayerEntity* this) { gPlayerState.sword_state = 0; gPlayerState.attack_status = 0; gPlayerState.jump_status = 0; ResolvePlayerAnimation(); - sub_080085B0(this); + sub_080085B0(super); if ((gPlayerState.flags & PL_USE_PORTAL) == 0) { SetPlayerActionNormal(); } } -void sub_08073B8C(Entity* this) { +void sub_08073B8C(PlayerEntity* this) { if (!gPlayerState.attack_status) { sub_08073B60(this); return; } - sub_0806F854(this, 0, -12); - if ((this->frame & 1) == 0) - UpdateAnimationSingleFrame(this); - COLLISION_OFF(this); - if (this->timer != 0) { - --this->timer; + sub_0806F854(super, 0, -12); + if ((super->frame & 1) == 0) + UpdateAnimationSingleFrame(super); + COLLISION_OFF(super); + if (super->timer != 0) { + --super->timer; return; } - GravityUpdate(this, GRAVITY_RATE * 2); - if (this->z.HALF.HI >= -8) { + GravityUpdate(super, GRAVITY_RATE * 2); + if (super->z.HALF.HI >= -8) { if (!gPlayerState.field_0x14 && (sub_0807A2B8() || !sub_08079D48())) { - COLLISION_ON(this); + COLLISION_ON(super); sub_08073B60(this); return; } gPlayerState.jump_status++; - this->timer = 15; + super->timer = 15; InitScreenShake(16, 0); SoundReq(SFX_14C); } } -void sub_08073C30(Entity* this) { - if (!gPlayerState.attack_status || this->timer-- == 0) { +void sub_08073C30(PlayerEntity* this) { + if (!gPlayerState.attack_status || super->timer-- == 0) { sub_08073B60(this); } else { - COLLISION_ON(this); - UpdateAnimationSingleFrame(this); + COLLISION_ON(super); + UpdateAnimationSingleFrame(super); } } -static void PlayerMinish(Entity* this) { - static EntityAction* const sPlayerMinishStates[] = { +static void PlayerMinish(PlayerEntity* this) { + static PlayerEntityAction* const sPlayerMinishStates[] = { sub_08073C80, sub_08073D20, sub_08073F04, sub_08073F4C, sub_08073FD0, sub_08074018, sub_08074060, sub_080740D8, }; - sPlayerMinishStates[this->subAction](this); + sPlayerMinishStates[super->subAction](this); } -static void sub_08073C80(Entity* this) { +static void sub_08073C80(PlayerEntity* this) { static const Hitbox sMinishHitbox = { 0, -1, { 3, 2, 2, 3 }, 2, 2 }; gPlayerState.flags |= PL_MINISH; gPlayerState.animation = ANIM_BOUNCE_MINISH; - this->spriteSettings.draw = 3; - this->spritePriority.b1 = 3; - this->spriteSettings.shadow = 0; - this->spriteRendering.b0 = 0; - this->hitbox = (Hitbox*)&sMinishHitbox; - this->timer = 0; - this->subtimer = 2; - this->knockbackDuration = 0; - this->subAction = 1; - LoadSwapGFX(this, 1, 2); - gRoomControls.camera_target = this; + super->spriteSettings.draw = 3; + super->spritePriority.b1 = 3; + super->spriteSettings.shadow = 0; + super->spriteRendering.b0 = 0; + super->hitbox = (Hitbox*)&sMinishHitbox; + super->timer = 0; + super->subtimer = 2; + super->knockbackDuration = 0; + super->subAction = 1; + LoadSwapGFX(super, 1, 2); + gRoomControls.camera_target = super; sub_080809D4(); if (gRoomTransition.player_status.spawn_type == PL_SPAWN_9) { gRoomTransition.player_status.spawn_type = PL_SPAWN_DEFAULT; - this->spriteSettings.draw = 0; - this->subAction = 2; + super->spriteSettings.draw = 0; + super->subAction = 2; } else { CreateObject(MINISH_EMOTICON, 0, 0); } } -static void sub_08073D20(Entity* this) { +static void sub_08073D20(PlayerEntity* this) { gPlayerState.framestate = PL_STATE_IDLE; - this->spritePriority.b1 = 3; - this->hurtType = 1; + super->spritePriority.b1 = 3; + super->hurtType = 1; ResetPlayerVelocity(); if (!gPlayerState.swim_state) - this->speed = 0xC0; /* todo: shielding speed? */ + super->speed = 0xC0; /* todo: shielding speed? */ if (!sub_08079B24()) { - sub_08079708(this); + sub_08079708(super); return; } if (!CheckQueuedAction()) { @@ -3150,36 +3152,36 @@ static void sub_08073D20(Entity* this) { gPlayerState.framestate = PL_STATE_CAPE; if (gPlayerState.floor_type != SURFACE_SHALLOW_WATER && gPlayerState.floor_type != SURFACE_WATER) { gPlayerState.swim_state = 0; - this->collisionFlags &= ~4; + super->collisionFlags &= ~4; } - if (!CheckQueuedAction() && this->subAction != 2) { + if (!CheckQueuedAction() && super->subAction != 2) { if ((gPlayerState.flags & PL_HIDDEN) == 0) { - sub_080085B0(this); + sub_080085B0(super); sub_080792D8(); if (!gPlayerState.field_0xa && sub_08079550()) return; - if (this->knockbackDuration) { - this->direction = this->knockbackDirection; + if (super->knockbackDuration) { + super->direction = super->knockbackDirection; return; } if (sub_080782C0()) { CheckQueuedAction(); return; } - COLLISION_ON(this); + COLLISION_ON(super); } if (!UpdatePlayerCollision()) { - UpdateActiveItems(this); - if (!GravityUpdate(this, GRAVITY_RATE)) + UpdateActiveItems(super); + if (!GravityUpdate(super, GRAVITY_RATE)) gPlayerState.jump_status = 0; if ((gPlayerState.field_0x7 & 0x80) == 0 && !gPlayerState.field_0xa) { - if (this->iframes <= 8) { + if (super->iframes <= 8) { if (gPlayerState.swim_state) { gPlayerState.framestate = PL_STATE_SWIM; - PlayerSwimming(this); + PlayerSwimming(super); UpdatePlayerMovement(); } else { - this->direction = gPlayerState.direction; + super->direction = gPlayerState.direction; if (!(gPlayerState.direction & DIR_NOT_MOVING_CHECK)) { gPlayerState.framestate = PL_STATE_WALK; UpdatePlayerMovement(); @@ -3187,19 +3189,19 @@ static void sub_08073D20(Entity* this) { } } if (!gPlayerState.keepFacing) - sub_0806F948(this); - UpdateAnimationSingleFrame(this); - sub_0807B068(this); + sub_0806F948(super); + UpdateAnimationSingleFrame(super); + sub_0807B068(super); if (sub_080793E4(16)) { - this->iframes = 20; - this->knockbackDuration = 4; - this->knockbackDirection = - DirectionTurnAround(Direction8FromAnimationState(this->animationState)); + super->iframes = 20; + super->knockbackDuration = 4; + super->knockbackDirection = + DirectionTurnAround(Direction8FromAnimationState(super->animationState)); ModHealth(-2); SoundReq(SFX_PLY_VO6); } if ((gPlayerState.flags & PL_HIDDEN) == 0) - sub_08008AC6(this); + sub_08008AC6(super); else gPlayerState.framestate = PL_STATE_D; } @@ -3208,121 +3210,121 @@ static void sub_08073D20(Entity* this) { } } -static void sub_08073F04(Entity* this) { - this->spritePriority.b1 = 2; - this->spriteSettings.draw = 0; - this->subAction++; - this->zVelocity = Q_16_16(2.5); - this->speed = 0x100; +static void sub_08073F04(PlayerEntity* this) { + super->spritePriority.b1 = 2; + super->spriteSettings.draw = 0; + super->subAction++; + super->zVelocity = Q_16_16(2.5); + super->speed = 0x100; gPlayerState.flags &= ~PL_MINISH; ResetActiveItems(); } -static void sub_08073F4C(Entity* this) { +static void sub_08073F4C(PlayerEntity* this) { u32 x = gArea.portal_x; u32 y = gArea.portal_y; - if (this->x.HALF.HI != x || this->y.HALF.HI != y) { - this->direction = CalculateDirectionTo(this->x.HALF.HI, this->y.HALF.HI, gArea.portal_x, gArea.portal_y); - this->speed = 0x100; - LinearMoveUpdate(this); + if (super->x.HALF.HI != x || super->y.HALF.HI != y) { + super->direction = CalculateDirectionTo(super->x.HALF.HI, super->y.HALF.HI, gArea.portal_x, gArea.portal_y); + super->speed = 0x100; + LinearMoveUpdate(super); } else { - COLLISION_OFF(this); - this->timer = 30; - this->subAction++; - this->spriteSettings.flipX = 0; - *(u32*)&this->field_0x80.HWORD = 1152; - *(u32*)&this->cutsceneBeh.HWORD = 1152; - this->spriteRendering.b0 = 3; + COLLISION_OFF(super); + super->timer = 30; + super->subAction++; + super->spriteSettings.flipX = 0; + this->unk_80.WORD_U = 1152; + this->unk_84.WORD_U = 1152; + super->spriteRendering.b0 = 3; sub_08074018(this); gPlayerState.animation = ANIM_GROW; } } -static void sub_08073FD0(Entity* this) { - if (this->timer != 0) { - if (--this->timer != 0) { +static void sub_08073FD0(PlayerEntity* this) { + if (super->timer != 0) { + if (--super->timer != 0) { return; } - if (this->spriteSettings.draw == 0) { - this->spriteSettings.draw = 3; + if (super->spriteSettings.draw == 0) { + super->spriteSettings.draw = 3; SoundReq(SFX_PLY_JUMP); } } - GravityUpdate(this, GRAVITY_RATE); - if (this->zVelocity == 0) { - this->subAction++; + GravityUpdate(super, GRAVITY_RATE); + if (super->zVelocity == 0) { + super->subAction++; SoundReq(SFX_PLY_GROW); } } -static void sub_08074018(Entity* this) { - if (*(u32*)&this->field_0x80 > 0x100) - *(u32*)&this->field_0x80 -= 32; - if (*(u32*)&this->cutsceneBeh > 0x100) - *(u32*)&this->cutsceneBeh -= 32; +static void sub_08074018(PlayerEntity* this) { + if (this->unk_80.WORD_U > 0x100) + this->unk_80.WORD_U -= 32; + if (this->unk_84.WORD_U > 0x100) + this->unk_84.WORD_U -= 32; else - this->subAction++; - SetAffineInfo(this, *(u32*)&this->field_0x80, *(u32*)&this->cutsceneBeh, 0); - UpdateAnimationSingleFrame(this); + super->subAction++; + SetAffineInfo(super, this->unk_80.WORD_U, this->unk_84.WORD_U, 0); + UpdateAnimationSingleFrame(super); } -static void sub_08074060(Entity* this) { - if (!GravityUpdate(this, GRAVITY_RATE)) { - this->hitbox = (Hitbox*)&gPlayerHitbox; - this->direction = DirectionSouth; - this->animationState = IdleSouth; - this->speed = 0x100; - this->spritePriority.b1 = 1; - this->spriteSettings.shadow = 1; - this->subtimer = 0; - this->subAction++; - this->zVelocity = Q_16_16(2.0); +static void sub_08074060(PlayerEntity* this) { + if (!GravityUpdate(super, GRAVITY_RATE)) { + super->hitbox = (Hitbox*)&gPlayerHitbox; + super->direction = DirectionSouth; + super->animationState = IdleSouth; + super->speed = 0x100; + super->spritePriority.b1 = 1; + super->spriteSettings.shadow = 1; + super->subtimer = 0; + super->subAction++; + super->zVelocity = Q_16_16(2.0); gPlayerState.animation = ANIM_HOP; - sub_0805EC60(this); + sub_0805EC60(super); } else { - UpdateAnimationSingleFrame(this); + UpdateAnimationSingleFrame(super); } } -void sub_080740D8(Entity* this) { +void sub_080740D8(PlayerEntity* this) { int y; int x; u32 dir; - UpdateAnimationSingleFrame(this); - if (!this->subtimer) - dir = this->direction; + UpdateAnimationSingleFrame(super); + if (!super->subtimer) + dir = super->direction; else - dir = DirectionTurnAround(this->direction); + dir = DirectionTurnAround(super->direction); switch (dir) { case 24: - x = this->x.HALF.HI - this->hitbox->unk2[0] + this->hitbox->offset_x - gRoomControls.origin_x; - y = this->y.HALF.HI + this->hitbox->offset_y - gRoomControls.origin_y; + x = super->x.HALF.HI - super->hitbox->unk2[0] + super->hitbox->offset_x - gRoomControls.origin_x; + y = super->y.HALF.HI + super->hitbox->offset_y - gRoomControls.origin_y; break; case 8: - x = this->x.HALF.HI + this->hitbox->unk2[0] + this->hitbox->offset_x - gRoomControls.origin_x; - y = this->y.HALF.HI + this->hitbox->offset_y - gRoomControls.origin_y; + x = super->x.HALF.HI + super->hitbox->unk2[0] + super->hitbox->offset_x - gRoomControls.origin_x; + y = super->y.HALF.HI + super->hitbox->offset_y - gRoomControls.origin_y; break; case 16: - x = this->x.HALF.HI + this->hitbox->offset_x - gRoomControls.origin_x; - y = this->y.HALF.HI + this->hitbox->unk2[3] + this->hitbox->offset_y - gRoomControls.origin_y; + x = super->x.HALF.HI + super->hitbox->offset_x - gRoomControls.origin_x; + y = super->y.HALF.HI + super->hitbox->unk2[3] + super->hitbox->offset_y - gRoomControls.origin_y; break; case 0: - x = this->x.HALF.HI + this->hitbox->offset_x - gRoomControls.origin_x; - y = this->y.HALF.HI - this->hitbox->unk2[3] + this->hitbox->offset_y - gRoomControls.origin_y; + x = super->x.HALF.HI + super->hitbox->offset_x - gRoomControls.origin_x; + y = super->y.HALF.HI - super->hitbox->unk2[3] + super->hitbox->offset_y - gRoomControls.origin_y; break; } if (sub_080086B4(x, y, gUnk_080082DC)) - LinearMoveUpdate(this); + LinearMoveUpdate(super); else - this->subtimer = 1; - if (!GravityUpdate(this, GRAVITY_RATE)) + super->subtimer = 1; + if (!GravityUpdate(super, GRAVITY_RATE)) PlayerSetNormalAndCollide(); } u32 sub_080741C4(void) { - if ((gPlayerState.jump_status && (gPlayerState.jump_status & 7) != 3) || gPlayerEntity.z.WORD != 0) { + if ((gPlayerState.jump_status && (gPlayerState.jump_status & 7) != 3) || gPlayerEntity.base.z.WORD != 0) { gPlayerState.surfacePositionSameTimer = 0; gPlayerState.surfaceTimer = 0; return 1; @@ -3330,38 +3332,38 @@ u32 sub_080741C4(void) { return 0; } -void SurfaceAction_DoNothing(Entity* this) { +void SurfaceAction_DoNothing(PlayerEntity* this) { } -void SurfaceAction_Pit(Entity* this) { - if (!sub_080741C4() && sub_08079C30(this)) { - if (this->action != PLAYER_FALL) { +void SurfaceAction_Pit(PlayerEntity* this) { + if (!sub_080741C4() && sub_08079C30(super)) { + if (super->action != PLAYER_FALL) { ResetActiveItems(); gPlayerState.queued_action = PLAYER_FALL; } } } -void SurfaceAction_SlopeGndGndVertical(Entity* this) { +void SurfaceAction_SlopeGndGndVertical(PlayerEntity* this) { sub_08074244(this, DirectionEast, DirectionWest); } -void SurfaceAction_SlopeGndGndHorizontal(Entity* this) { +void SurfaceAction_SlopeGndGndHorizontal(PlayerEntity* this) { sub_08074244(this, DirectionNorth, DirectionSouth); } -static void sub_08074244(Entity* this, u32 a1, u32 a2) { +static void sub_08074244(PlayerEntity* this, u32 a1, u32 a2) { if (gPlayerState.floor_type != SURFACE_LIGHT_GRADE && gPlayerState.floor_type != SURFACE_29) { - this->collisionLayer = 3; - this->spriteOrientation.flipY = 1; - this->spriteRendering.b3 = 1; + super->collisionLayer = 3; + super->spriteOrientation.flipY = 1; + super->spriteRendering.b3 = 1; } if (!sub_080741C4()) { u32 tmp; if (gPlayerState.dash_state == 0) { tmp = gPlayerState.direction; } else { - tmp = 4 * this->animationState; + tmp = 4 * super->animationState; } if (a1 != tmp || a2 != tmp) { gPlayerState.speed_modifier -= SLOPE_SPEED_MODIFIER; @@ -3369,82 +3371,82 @@ static void sub_08074244(Entity* this, u32 a1, u32 a2) { } } -void SurfaceAction_6(Entity* this) { +void SurfaceAction_6(PlayerEntity* this) { if (gPlayerState.swim_state != 0) { gPlayerState.swim_state = 0; } - this->spritePriority.b0 = 4; - this->collisionFlags &= ~4; + super->spritePriority.b0 = 4; + super->collisionFlags &= ~4; } -void SurfaceAction_7(Entity* this) { +void SurfaceAction_7(PlayerEntity* this) { if (!sub_080741C4() && (gPlayerState.flags & PL_MINISH) == 0 && gPlayerState.surfacePositionSameTimer == 15) { - CreateObjectWithParent(this, CRACKING_GROUND, 0, 0); + CreateObjectWithParent(super, CRACKING_GROUND, 0, 0); } } -void SurfaceAction_MinishDoorFront(Entity* this) { - if ((this->y.HALF.HI & 0xF) <= 0xD) { - this->collisions = COL_EAST_FULL | COL_WEST_FULL; +void SurfaceAction_MinishDoorFront(PlayerEntity* this) { + if ((super->y.HALF.HI & 0xF) <= 0xD) { + super->collisions = COL_EAST_FULL | COL_WEST_FULL; hide(this); } else { - EnablePlayerDraw(this); + EnablePlayerDraw(super); } } -void SurfaceAction_MinishDoorBack(Entity* this) { - if ((this->y.HALF.HI & 0xF) > 1) { - this->collisions = COL_EAST_FULL | COL_WEST_FULL; +void SurfaceAction_MinishDoorBack(PlayerEntity* this) { + if ((super->y.HALF.HI & 0xF) > 1) { + super->collisions = COL_EAST_FULL | COL_WEST_FULL; hide(this); } else { - EnablePlayerDraw(this); + EnablePlayerDraw(super); } } -void SurfaceAction_A(Entity* this) { - if ((this->x.HALF.HI & 0xF) < 12) { - this->collisions = COL_NORTH_FULL | COL_SOUTH_FULL; +void SurfaceAction_A(PlayerEntity* this) { + if ((super->x.HALF.HI & 0xF) < 12) { + super->collisions = COL_NORTH_FULL | COL_SOUTH_FULL; hide(this); } else { - EnablePlayerDraw(this); + EnablePlayerDraw(super); } } -void SurfaceAction_B(Entity* this) { - if ((this->x.HALF.HI & 0xF) > 4) { - this->collisions = COL_NORTH_FULL | COL_SOUTH_FULL; +void SurfaceAction_B(PlayerEntity* this) { + if ((super->x.HALF.HI & 0xF) > 4) { + super->collisions = COL_NORTH_FULL | COL_SOUTH_FULL; hide(this); } else { - EnablePlayerDraw(this); + EnablePlayerDraw(super); } } -static void hide(Entity* this) { +static void hide(PlayerEntity* this) { gPlayerState.flags |= PL_HIDDEN; - this->type2 = 0x80; - this->spriteSettings.draw = 0; - COLLISION_OFF(this); - this->knockbackDuration = 0; + super->type2 = 0x80; + super->spriteSettings.draw = 0; + COLLISION_OFF(super); + super->knockbackDuration = 0; ResetActiveItems(); } -void SurfaceAction_14(Entity* this) { +void SurfaceAction_14(PlayerEntity* this) { if (!sub_080741C4()) { - if (sub_08079C30(this)) { + if (sub_08079C30(super)) { u32 spd; - sub_0807AABC(this); + sub_0807AABC(super); sub_08074808(this); - spd = this->speed; - this->speed = 0x300; - this->direction = DirectionSouth; + spd = super->speed; + super->speed = 0x300; + super->direction = DirectionSouth; gPlayerState.field_0xa |= 0x80; - LinearMoveUpdate(this); - this->speed = spd; + LinearMoveUpdate(super); + super->speed = spd; } } } -void SurfaceAction_CloneTile(Entity* this) { +void SurfaceAction_CloneTile(PlayerEntity* this) { if (gPlayerState.chargeState.action == 4) { u32 item, n, i; if (ItemIsSword(gSave.stats.equipped[SLOT_A])) { @@ -3475,52 +3477,52 @@ void SurfaceAction_CloneTile(Entity* this) { break; } if (n > i) { - Entity* e = CreateObjectWithParent(this, PLAYER_CLONE, i, 0); + Entity* e = CreateObjectWithParent(super, PLAYER_CLONE, i, 0); gPlayerClones[i] = e; if (e != NULL) { - CopyPosition(this, e); + CopyPosition(super, e); } } else { gPlayerState.sword_state |= 0x80; gPlayerState.flags |= PL_CLONING; - this->x.WORD = (this->x.WORD & ~0xFFFFF) | 0x80000; - this->y.WORD = (this->y.WORD & ~0xFFFFF) | 0x80000; + super->x.WORD = (super->x.WORD & ~0xFFFFF) | 0x80000; + super->y.WORD = (super->y.WORD & ~0xFFFFF) | 0x80000; ResetLantern(); } } } -void SurfaceAction_16(Entity* this) { +void SurfaceAction_16(PlayerEntity* this) { if (!sub_080741C4() && !gPlayerState.field_0x14) { - if (this->iframes == 0) { + if (super->iframes == 0) { ModHealth(-2); SoundReq(SFX_PLY_VO6); - this->iframes = 24; - this->knockbackDuration = 4; - this->knockbackDirection = CalculateDirectionTo( - (this->x.HALF.HI & 0xFFF0) | 8, (this->y.HALF.HI & 0xFFF0) | 8, this->x.HALF.HI, this->y.HALF.HI); + super->iframes = 24; + super->knockbackDuration = 4; + super->knockbackDirection = CalculateDirectionTo( + (super->x.HALF.HI & 0xFFF0) | 8, (super->y.HALF.HI & 0xFFF0) | 8, super->x.HALF.HI, super->y.HALF.HI); } if ((gPlayerState.flags & PL_MINISH) == 0) - sub_08008790(this, 7); + sub_08008790(super, 7); } } -void SurfaceAction_Ice(Entity* this) { - if (!sub_080741C4() && ((gPlayerState.field_0x35 & 0x80) == 0 || this->knockbackDuration != 0)) { +void SurfaceAction_Ice(PlayerEntity* this) { + if (!sub_080741C4() && ((gPlayerState.field_0x35 & 0x80) == 0 || super->knockbackDuration != 0)) { ResetPlayerVelocity(); } } -void SurfaceAction_ShallowWater(Entity* this) { +void SurfaceAction_ShallowWater(PlayerEntity* this) { if (!sub_080741C4()) { if (gPlayerState.flags & PL_MINISH) { - this->spritePriority.b1 = 0; + super->spritePriority.b1 = 0; SurfaceAction_Water(this); } else { if (gPlayerState.swim_state) { - COLLISION_ON(this); - this->collisionFlags &= ~4; - this->spritePriority.b0 = 4; + COLLISION_ON(super); + super->collisionFlags &= ~4; + super->spritePriority.b0 = 4; gPlayerState.swim_state = 0; } if ((gPlayerState.playerInput.newInput & INPUT_ANY_DIRECTION) || gPlayerState.surfacePositionSameTimer == 1) @@ -3529,24 +3531,24 @@ void SurfaceAction_ShallowWater(Entity* this) { } } -void SurfaceAction_SlopeGndWater(Entity* this) { +void SurfaceAction_SlopeGndWater(PlayerEntity* this) { if (gPlayerState.swim_state) { - COLLISION_ON(this); - this->collisionFlags &= ~4; - this->spritePriority.b0 = 4; + COLLISION_ON(super); + super->collisionFlags &= ~4; + super->spritePriority.b0 = 4; gPlayerState.swim_state = 0; } } -void SurfaceAction_Swamp(Entity* this) { +void SurfaceAction_Swamp(PlayerEntity* this) { if (sub_080741C4()) { gPlayerState.surfacePositionSameTimer = 0; gPlayerState.surfaceTimer = 0; return; } - if (this->health) { - if (sub_08079C30(this) == 0) { + if (super->health) { + if (sub_08079C30(super) == 0) { gPlayerState.surfacePositionSameTimer = 0; gPlayerState.surfaceTimer = 0; return; @@ -3563,8 +3565,8 @@ void SurfaceAction_Swamp(Entity* this) { } if (gPlayerState.surfaceTimer == 1) { - CreateObjectWithParent(this, OBJECT_70, 0, 0); - CreateFx(this, FX_GREEN_SPLASH, 0); + CreateObjectWithParent(super, OBJECT_70, 0, 0); + CreateFx(super, FX_GREEN_SPLASH, 0); SoundReq(SFX_161); } else if ((gPlayerState.playerInput.newInput & INPUT_ANY_DIRECTION) != 0) { SoundReq(SFX_161); @@ -3580,28 +3582,28 @@ void SurfaceAction_Swamp(Entity* this) { } } gPlayerState.flags &= ~PL_ROLLING; - CreateFx(this, FX_GREEN_SPLASH, 0); - this->iframes = 0x20; + CreateFx(super, FX_GREEN_SPLASH, 0); + super->iframes = 0x20; ModHealth(-4); RespawnPlayer(); } -void SurfaceAction_Water(Entity* this) { +void SurfaceAction_Water(PlayerEntity* this) { if (!sub_080741C4()) { if (gPlayerState.field_0x14 == 0) { gPlayerState.spriteOffsetY += 2; } else { gPlayerState.swim_state = 0; - this->spritePriority.b0 = 4; - this->collisionFlags &= ~4; + super->spritePriority.b0 = 4; + super->collisionFlags &= ~4; } - if ((gPlayerState.swim_state & 0xF) || sub_08079C30(this)) { + if ((gPlayerState.swim_state & 0xF) || sub_08079C30(super)) { sub_08074808(this); } } } -static void sub_08074808(Entity* this) { +static void sub_08074808(PlayerEntity* this) { ResetLantern(); if (GetInventoryValue(ITEM_FLIPPERS) == 1) { if (!gPlayerState.swim_state) { @@ -3609,26 +3611,26 @@ static void sub_08074808(Entity* this) { gPlayerState.swim_state = 1; else gPlayerState.swim_state = 8; - this->speed = 0; + super->speed = 0; gPlayerState.remainingDiveTime = 0; if ((gPlayerState.flags & PL_MINISH) == 0) - CreateFx(this, FX_WATER_SPLASH, 0); + CreateFx(super, FX_WATER_SPLASH, 0); SoundReq(SFX_1A5); ResetActiveItems(); } if ((gPlayerState.swim_state & 0xF) != 1) { - sub_08079744(this); + sub_08079744(super); gPlayerState.swim_state--; } gPlayerState.flags &= ~(PL_BURNING | PL_FROZEN); - if ((gPlayerState.flags & PL_DRUGGED) != 0 && this->field_0x7a.HWORD <= 0xEu) - this->field_0x7a.HWORD = 15; + if ((gPlayerState.flags & PL_DRUGGED) != 0 && this->unk_7a <= 0xEu) + this->unk_7a = 15; } else { gPlayerState.queued_action = PLAYER_DROWN; } } -void SurfaceAction_Button(Entity* this) { +void SurfaceAction_Button(PlayerEntity* this) { gPlayerState.spriteOffsetY -= 2; } @@ -3636,112 +3638,112 @@ void sub_080748D4(void) { sub_080741C4(); } -void SurfaceAction_1B(Entity* this) { +void SurfaceAction_1B(PlayerEntity* this) { if (!sub_080741C4()) { - if (this->collisionLayer != 1) { - this->y.HALF.HI += 12; + if (super->collisionLayer != 1) { + super->y.HALF.HI += 12; if ((gPlayerState.flags & PL_MINISH) == 0) - this->z.HALF.HI -= 12; + super->z.HALF.HI -= 12; } - sub_0807AABC(this); + sub_0807AABC(super); } } -void SurfaceAction_1C(Entity* this) { +void SurfaceAction_1C(PlayerEntity* this) { if (!sub_080741C4()) { - if (sub_08079C30(this)) { + if (sub_08079C30(super)) { gPlayerState.queued_action = PLAYER_LAVA; } } } -void SurfaceAction_ClimbWall(Entity* this) { +void SurfaceAction_ClimbWall(PlayerEntity* this) { if (GetInventoryValue(ITEM_GRIP_RING) == 1) { SurfaceAction_Ladder(this); } else { - this->y.HALF.HI = (this->y.HALF.HI & 0xFFF0) | 0xF; + super->y.HALF.HI = (super->y.HALF.HI & 0xFFF0) | 0xF; gPlayerState.floor_type = SURFACE_NORMAL; } } -void SurfaceAction_Ladder(Entity* this) { +void SurfaceAction_Ladder(PlayerEntity* this) { if (!sub_080741C4()) { gPlayerState.jump_status = 0; - this->spriteRendering.b3 = 1; - this->spriteOrientation.flipY = 1; - this->animationState = IdleNorth; - this->collisionLayer = 3; + super->spriteRendering.b3 = 1; + super->spriteOrientation.flipY = 1; + super->animationState = IdleNorth; + super->collisionLayer = 3; ResetActiveItems(); } } -void SurfaceAction_2C(Entity* this) { +void SurfaceAction_2C(PlayerEntity* this) { if (GetInventoryValue(ITEM_GRIP_RING) == 1) { SurfaceAction_AutoLadder(this); } else { - this->y.HALF.HI &= 0xFFF0; + super->y.HALF.HI &= 0xFFF0; gPlayerState.floor_type = SURFACE_NORMAL; } } -void SurfaceAction_AutoLadder(Entity* this) { +void SurfaceAction_AutoLadder(PlayerEntity* this) { if (!sub_080741C4()) { - this->spriteRendering.b3 = 1; - this->spriteOrientation.flipY = 1; - this->animationState = IdleNorth; - this->collisionLayer = 3; + super->spriteRendering.b3 = 1; + super->spriteOrientation.flipY = 1; + super->animationState = IdleNorth; + super->collisionLayer = 3; gPlayerState.swim_state = 0; - this->collisionFlags &= ~4; - if ((this->y.HALF.HI & 0xF) <= 7) { + super->collisionFlags &= ~4; + if ((super->y.HALF.HI & 0xF) <= 7) { gPlayerState.animation = ANIM_CLIMB_FROM_TOP; - this->direction = DirectionSouth; + super->direction = DirectionSouth; } else { gPlayerState.animation = ANIM_CLIMB_TO_TOP; - this->direction = DirectionNorth; + super->direction = DirectionNorth; } ResetActiveItems(); } } -void SurfaceAction_20(Entity* this) { +void SurfaceAction_20(PlayerEntity* this) { if (gPlayerState.swim_state & 0x80) { - Entity* e = CreateObjectWithParent(&gPlayerEntity, GROUND_ITEM, ITEM_RUPEE1, 0); + Entity* e = CreateObjectWithParent(&gPlayerEntity.base, GROUND_ITEM, ITEM_RUPEE1, 0); if (e != NULL) { e->timer = 1; UpdateSpriteForCollisionLayer(e); - CloneTile(57, gPlayerState.tilePosition, this->collisionLayer); + CloneTile(57, gPlayerState.tilePosition, super->collisionLayer); } } SurfaceAction_Water(this); } -void SurfaceAction_22(Entity* this) { +void SurfaceAction_22(PlayerEntity* this) { } -void SurfaceAction_Dust(Entity* this) { +void SurfaceAction_Dust(PlayerEntity* this) { if (!sub_080741C4()) { gPlayerState.speed_modifier -= 128; if (gPlayerState.surfacePositionSameTimer == 1 || (gPlayerState.playerInput.newInput & INPUT_ANY_DIRECTION) != 0) { if (gPlayerState.floor_type == SURFACE_DUST) - CreateObjectWithParent(this, DIRT_PARTICLE, 1, 0); + CreateObjectWithParent(super, DIRT_PARTICLE, 1, 0); else - CreateObjectWithParent(this, DIRT_PARTICLE, 1, 1); + CreateObjectWithParent(super, DIRT_PARTICLE, 1, 1); } } } -void SurfaceAction_26(Entity* this) { +void SurfaceAction_26(PlayerEntity* this) { u32 v1; if (gPlayerState.dash_state == 0) v1 = gPlayerState.direction; else - v1 = 4 * this->animationState; + v1 = 4 * super->animationState; sub_08074244(this, v1, v1); } -void SurfaceAction_Hole(Entity* this) { +void SurfaceAction_Hole(PlayerEntity* this) { if (!gPlayerState.field_0x14 && !sub_080741C4()) { if (gPlayerState.flags & PL_MINISH) SurfaceAction_Pit(this); @@ -3750,51 +3752,51 @@ void SurfaceAction_Hole(Entity* this) { } } -void SurfaceAction_ConveyerNorth(Entity* this) { +void SurfaceAction_ConveyerNorth(PlayerEntity* this) { if (!sub_080741C4() && (gPlayerState.flags & PL_MINISH) == 0) { - this->animationState = IdleNorth; - this->direction = DirectionNorth; + super->animationState = IdleNorth; + super->direction = DirectionNorth; conveyer_push(this); } } -void SurfaceAction_ConveyerSouth(Entity* this) { +void SurfaceAction_ConveyerSouth(PlayerEntity* this) { if (!sub_080741C4() && (gPlayerState.flags & PL_MINISH) == 0) { - this->animationState = IdleSouth; - this->direction = DirectionSouth; + super->animationState = IdleSouth; + super->direction = DirectionSouth; conveyer_push(this); } } -void SurfaceAction_ConveyerWest(Entity* this) { +void SurfaceAction_ConveyerWest(PlayerEntity* this) { if (!sub_080741C4() && (gPlayerState.flags & PL_MINISH) == 0) { - this->animationState = IdleWest; - this->direction = DirectionWest; + super->animationState = IdleWest; + super->direction = DirectionWest; conveyer_push(this); } } -void SurfaceAction_ConveyerEast(Entity* this) { +void SurfaceAction_ConveyerEast(PlayerEntity* this) { if (!sub_080741C4() && (gPlayerState.flags & PL_MINISH) == 0) { - this->animationState = IdleEast; - this->direction = DirectionEast; + super->animationState = IdleEast; + super->direction = DirectionEast; conveyer_push(this); } } -static void conveyer_push(Entity* this) { +static void conveyer_push(PlayerEntity* this) { ResetActiveItems(); - this->spritePriority.b1 = 0; - this->speed = WALK_SPEED; + super->spritePriority.b1 = 0; + super->speed = WALK_SPEED; gPlayerState.flags |= PL_CONVEYOR_PUSHED; gPlayerState.field_0xa |= 0x80; gPlayerState.mobility |= 0x80; gPlayerState.field_0x27[0]++; - LinearMoveUpdate(this); + LinearMoveUpdate(super); } -static void PlayerSleep(Entity* this) { - static EntityAction* const gUnk_0811BC88[] = { +static void PlayerSleep(PlayerEntity* this) { + static PlayerEntityAction* const gUnk_0811BC88[] = { sub_08074C68, sub_08074CF8, sub_08074F00, @@ -3802,24 +3804,24 @@ static void PlayerSleep(Entity* this) { }; if (!CheckQueuedAction()) - gUnk_0811BC88[this->subAction](this); + gUnk_0811BC88[super->subAction](this); } -static void sub_08074C68(Entity* this) { - this->field_0x68.HALF.LO = 0; +static void sub_08074C68(PlayerEntity* this) { + this->unk_68.BYTES.byte0 = 0; if (gPlayerState.field_0x38 != 1) { - if (*(ScriptExecutionContext**)&this->cutsceneBeh.HWORD == &gPlayerScriptExecutionContext) { - this->subAction = 1; - sub_0807DD64(this); + if (*(ScriptExecutionContext**)&this->unk_84.WORD == &gPlayerScriptExecutionContext) { + super->subAction = 1; + sub_0807DD64(super); sub_08074CF8(this); } } else { - this->spriteSettings.draw = 1; - this->animationState = IdleNorth; - this->spritePriority.b1 = 0; - this->subAction = 2; - this->field_0x68.HALF.LO = 1; - sub_0807DD64(this); + super->spriteSettings.draw = 1; + super->animationState = IdleNorth; + super->spritePriority.b1 = 0; + super->subAction = 2; + this->unk_68.BYTES.byte0 = 1; + sub_0807DD64(super); if (!gPlayerState.field_0x39) gPlayerState.animation = ANIM_SLEEP_NOCAP; else @@ -3828,19 +3830,19 @@ static void sub_08074C68(Entity* this) { } } -static void sub_08074CF8(Entity* this) { +static void sub_08074CF8(PlayerEntity* this) { u32 v3; - v3 = this->animationState; - ExecuteScript(this, *(ScriptExecutionContext**)&this->cutsceneBeh.HWORD); - sub_08074D34(this, *(ScriptExecutionContext**)&this->cutsceneBeh.HWORD); - if ((this->field_0x82.HWORD & 1) != 0) - this->animationState = v3; - GravityUpdate(this, GRAVITY_RATE); - UpdateAnimationSingleFrame(this); + v3 = super->animationState; + ExecuteScript(super, *(ScriptExecutionContext**)&this->unk_84.WORD); + sub_08074D34(this, *(ScriptExecutionContext**)&this->unk_84.WORD); + if ((this->unk_80.HALF.HI & 1) != 0) + super->animationState = v3; + GravityUpdate(super, GRAVITY_RATE); + UpdateAnimationSingleFrame(super); } -void sub_08074D34(Entity* this, ScriptExecutionContext* ctx) { +void sub_08074D34(PlayerEntity* this, ScriptExecutionContext* ctx) { while (ctx->postScriptActions) { u32 bit = (~ctx->postScriptActions + 1) & ctx->postScriptActions; ctx->postScriptActions ^= bit; @@ -3866,77 +3868,77 @@ void sub_08074D34(Entity* this, ScriptExecutionContext* ctx) { gPlayerState.animation = ANIM_HOP_NOCAP; else gPlayerState.animation = ANIM_HOP; - this->zVelocity = Q_16_16(1.5); + super->zVelocity = Q_16_16(1.5); break; case 0x10: - CreateSpeechBubbleExclamationMark(this, 8, -24); + CreateSpeechBubbleExclamationMark(super, 8, -24); break; case 0x20: - CreateSpeechBubbleQuestionMark(this, 8, -24); + CreateSpeechBubbleQuestionMark(super, 8, -24); break; case 0x80: - this->spriteSettings.draw = 1; + super->spriteSettings.draw = 1; break; case 0x100: - this->spriteSettings.draw = 0; + super->spriteSettings.draw = 0; break; case 0x200: - this->field_0x82.HWORD = 0; + this->unk_80.HALF_U.HI = 0; break; case 0x1000: - this->field_0x82.HWORD &= ~1; + this->unk_80.HALF_U.HI &= ~1; break; case 0x2000: - this->field_0x82.HWORD |= 1; + this->unk_80.HALF_U.HI |= 1; break; case 0x4000: - this->field_0x82.HWORD |= 8; + this->unk_80.HALF_U.HI |= 8; break; case 0x8000: - this->field_0x82.HWORD |= 4; + this->unk_80.HALF_U.HI |= 4; break; case 0x20000: - this->spriteSettings.flipX ^= 1; + super->spriteSettings.flipX ^= 1; break; case 0x100000: - this->subAction = 2; - this->field_0x68.HALF.LO = 2; + super->subAction = 2; + this->unk_68.BYTES.byte0 = 2; break; case 0x200000: - this->subAction = 3; - this->field_0x68.HALF.LO = 0; + super->subAction = 3; + this->unk_68.BYTES.byte0 = 0; break; } } } -static void sub_08074F00(Entity* this) { - static EntityAction* const gUnk_0811BC98[] = { +static void sub_08074F00(PlayerEntity* this) { + static PlayerEntityAction* const gUnk_0811BC98[] = { sub_08074F1C, sub_08074F2C, sub_08074F44, sub_08074F8C, sub_08074FEC, sub_0807501C, sub_0807508C, }; - gUnk_0811BC98[this->field_0x68.HALF.LO](this); + gUnk_0811BC98[this->unk_68.BYTES.byte0](this); } -void sub_08074F1C(Entity* this) { - this->field_0x68.HALF.LO = 1; - this->animationState = IdleNorth; +void sub_08074F1C(PlayerEntity* this) { + this->unk_68.BYTES.byte0 = 1; + super->animationState = IdleNorth; } -void sub_08074F2C(Entity* this) { - ExecuteScript(this, *(ScriptExecutionContext**)&this->cutsceneBeh.HWORD); - sub_08074D34(this, *(ScriptExecutionContext**)&this->cutsceneBeh.HWORD); +void sub_08074F2C(PlayerEntity* this) { + ExecuteScript(super, *(ScriptExecutionContext**)&this->unk_84.WORD); + sub_08074D34(this, *(ScriptExecutionContext**)&this->unk_84.WORD); } -void sub_08074F44(Entity* this) { +void sub_08074F44(PlayerEntity* this) { typedef struct { u8 fill[0x6c]; Entity* e; } fixme; - this->field_0x68.HALF.LO++; - if (((fixme*)&gPlayerEntity)->e) - DeleteEntity(((fixme*)&gPlayerEntity)->e); + this->unk_68.BYTES.byte0++; + if (((fixme*)&gPlayerEntity.base)->e) + DeleteEntity(((fixme*)&gPlayerEntity.base)->e); if (!gPlayerState.field_0x39) { gPlayerState.animation = ANIM_WAKEUP_NOCAP; gPlayerState.flags |= PL_NO_CAP; @@ -3945,16 +3947,16 @@ void sub_08074F44(Entity* this) { } } -void sub_08074F8C(Entity* this) { - UpdateAnimationSingleFrame(this); - if (this->frame == 1) { - this->frame = 0; +void sub_08074F8C(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); + if (super->frame == 1) { + super->frame = 0; gActiveScriptInfo.syncFlags |= 4; } - if (this->frame & ANIM_DONE) { - this->field_0x68.HALF.LO++; - this->timer = 8; - this->animationState = IdleSouth; + if (super->frame & ANIM_DONE) { + this->unk_68.BYTES.byte0++; + super->timer = 8; + super->animationState = IdleSouth; if (!gPlayerState.field_0x39) { gPlayerState.animation = ANIM_DEFAULT_NOCAP; } else { @@ -3963,37 +3965,37 @@ void sub_08074F8C(Entity* this) { } } -void sub_08074FEC(Entity* this) { - UpdateAnimationSingleFrame(this); - if (--this->timer == 0) { - this->field_0x68.HALF.LO++; - this->timer = 4; - this->animationState = gPlayerState.field_0x3a; +void sub_08074FEC(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); + if (--super->timer == 0) { + this->unk_68.BYTES.byte0++; + super->timer = 4; + super->animationState = gPlayerState.field_0x3a; } } -void sub_0807501C(Entity* this) { - if (--this->timer == 0) { - this->animationState = gPlayerState.field_0x3a; +void sub_0807501C(PlayerEntity* this) { + if (--super->timer == 0) { + super->animationState = gPlayerState.field_0x3a; if (!gPlayerState.field_0x39) { gPlayerState.animation = ANIM_HOP_NOCAP; } else { gPlayerState.animation = ANIM_HOP; } - this->spritePriority.b1 = 1; - this->direction = Direction8FromAnimationState(this->animationState); - this->speed = 200; - this->zVelocity = Q_16_16(2.0); - this->timer = 8; - this->field_0x68.HALF.LO++; + super->spritePriority.b1 = 1; + super->direction = Direction8FromAnimationState(super->animationState); + super->speed = 200; + super->zVelocity = Q_16_16(2.0); + super->timer = 8; + this->unk_68.BYTES.byte0++; SoundReq(SFX_PLY_JUMP); } } -void sub_0807508C(Entity* this) { - UpdateAnimationSingleFrame(this); - if (GravityUpdate(this, GRAVITY_RATE)) { - LinearMoveUpdate(this); +void sub_0807508C(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); + if (GravityUpdate(super, GRAVITY_RATE)) { + LinearMoveUpdate(super); } else { if (!gPlayerState.field_0x39) { gPlayerState.animation = ANIM_DEFAULT_NOCAP; @@ -4001,63 +4003,63 @@ void sub_0807508C(Entity* this) { gPlayerState.flags &= ~PL_NO_CAP; gPlayerState.animation = ANIM_DEFAULT; } - if (--this->timer == 0) { - this->animationState = IdleSouth; - this->subAction = 1; - this->field_0x68.HALF.LO = 0; + if (--super->timer == 0) { + super->animationState = IdleSouth; + super->subAction = 1; + this->unk_68.BYTES.byte0 = 0; SoundReq(SFX_PLY_LAND); } } } -void sub_080750F4(Entity* this) { - static EntityAction* const gUnk_0811BCB4[] = { +void sub_080750F4(PlayerEntity* this) { + static PlayerEntityAction* const gUnk_0811BCB4[] = { sub_08075110, sub_0807513C, sub_0807518C, sub_080751B4, }; - gUnk_0811BCB4[this->field_0x68.HALF.LO](this); + gUnk_0811BCB4[this->unk_68.BYTES.byte0](this); } -void sub_08075110(Entity* this) { - this->field_0x68.HALF.LO++; - this->subtimer = this->animationState; - this->animationState = IdleNorth; +void sub_08075110(PlayerEntity* this) { + this->unk_68.BYTES.byte0++; + super->subtimer = super->animationState; + super->animationState = IdleNorth; gPlayerState.animation = ANIM_PUT_ON_EZLO; gPlayerState.flags &= ~PL_NO_CAP; } -void sub_0807513C(Entity* this) { - UpdateAnimationSingleFrame(this); - if (this->frame == 1) { - this->frame = 0; +void sub_0807513C(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); + if (super->frame == 1) { + super->frame = 0; SoundReq(SFX_PLY_JUMP); } - if (this->frame == 2) { - this->frame = 0; + if (super->frame == 2) { + super->frame = 0; SoundReq(SFX_14B); SoundReq(SFX_PLY_VO6); } - if (this->frame & ANIM_DONE) { - this->field_0x68.HALF.LO++; - this->timer = 60; + if (super->frame & ANIM_DONE) { + this->unk_68.BYTES.byte0++; + super->timer = 60; } } -void sub_0807518C(Entity* this) { - if (--this->timer == 0) { - this->field_0x68.HALF.LO++; +void sub_0807518C(PlayerEntity* this) { + if (--super->timer == 0) { + this->unk_68.BYTES.byte0++; gPlayerState.animation = ANIM_EZLO_LEAVE_LEFT; } } -void sub_080751B4(Entity* this) { - UpdateAnimationSingleFrame(this); - if (this->frame & ANIM_DONE) { - this->animationState = IdleSouth; - this->subAction = 1; - this->field_0x68.HALF.LO = 0; +void sub_080751B4(PlayerEntity* this) { + UpdateAnimationSingleFrame(super); + if (super->frame & ANIM_DONE) { + super->animationState = IdleSouth; + super->subAction = 1; + this->unk_68.BYTES.byte0 = 0; gPlayerState.animation = ANIM_DEFAULT; } } @@ -4073,7 +4075,7 @@ void sub_080751E8(u32 a1, u32 a2, void* script) { MemClear(&gPlayerScriptExecutionContext, sizeof(ScriptExecutionContext)); gPlayerScriptExecutionContext.scriptInstructionPointer = script; - ((fixme*)&gPlayerEntity)->ctx = &gPlayerScriptExecutionContext; + ((fixme*)&gPlayerEntity.base)->ctx = &gPlayerScriptExecutionContext; gPlayerState.queued_action = PLAYER_SLEEP; gPlayerState.field_0x38 = 1; gPlayerState.field_0x39 = 0; @@ -4088,24 +4090,24 @@ void sub_080751E8(u32 a1, u32 a2, void* script) { } e = CreateObject(BED_COVER, !gPlayerState.field_0x39 ? 2 : 0, 0); if (e != NULL) { - CopyPosition(&gPlayerEntity, e); + CopyPosition(&gPlayerEntity.base, e); StartCutscene(e, script); } - e2 = CreateSpeechBubbleSleep(&gPlayerEntity, -14, -28); - *(Entity**)&gPlayerEntity.field_0x6c.HWORD = e2; + e2 = CreateSpeechBubbleSleep(&gPlayerEntity.base, -14, -28); + *(Entity**)&gPlayerEntity.unk_6c = e2; if (e2 != NULL) { SetEntityPriority(e2, PRIO_NO_BLOCK); } } -void sub_0807529C(Entity* this) { - CreateSpeechBubbleQuestionMark(this, 8, -32); +void sub_0807529C(PlayerEntity* this) { + CreateSpeechBubbleQuestionMark(super, 8, -32); } -void sub_080752AC(Entity* this, ScriptExecutionContext* ctx) { - LinearMoveUpdate(this); +void sub_080752AC(PlayerEntity* this, ScriptExecutionContext* ctx) { + LinearMoveUpdate(super); if (!ctx->unk_18) { - if (GetTileUnderEntity(this) != 41) { + if (GetTileUnderEntity(super) != 41) { ctx->unk_18 = 1; ctx->unk_19 = 6; } diff --git a/src/playerItem.c b/src/playerItem.c index 10e8ac0c..dcf2532b 100644 --- a/src/playerItem.c +++ b/src/playerItem.c @@ -1,4 +1,3 @@ -#define ENT_DEPRECATED #include "global.h" #include "functions.h" #include "player.h" @@ -92,7 +91,7 @@ void ItemInit(Entity* this) { if (definition->bitfield == 0xff) { u32 tmp = definition->firstItemIndex; definition = gAdditionalPlayerItemDefinitions[definition->index]; - definition = &definition[this->field_0x68.HALF.LO - tmp]; + definition = &definition[((GenericEntity*)this)->field_0x68.HALF.LO - tmp]; } tmp3 = definition->bitfield; tmp2 = tmp3 & 0xf; @@ -102,18 +101,18 @@ void ItemInit(Entity* this) { this->hitType = definition->hitType; this->spriteIndex = definition->spriteIndex; if (definition->gfx == 0) { - this->spriteVramOffset = gPlayerEntity.spriteVramOffset; + this->spriteVramOffset = gPlayerEntity.base.spriteVramOffset; } else { this->spriteVramOffset = definition->gfx & 0x3ff; } if (this->animationState == IdleNorth) { - this->animationState = gPlayerEntity.animationState & 6; + this->animationState = gPlayerEntity.base.animationState & 6; } - this->collisionLayer = gPlayerEntity.collisionLayer; - this->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; - this->spritePriority.b0 = gPlayerEntity.spritePriority.b0; - this->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; + this->collisionLayer = gPlayerEntity.base.collisionLayer; + this->spriteRendering.b3 = gPlayerEntity.base.spriteRendering.b3; + this->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0; + this->spriteOrientation.flipY = gPlayerEntity.base.spriteOrientation.flipY; this->health = 1; this->flags |= ENT_DID_INIT; } diff --git a/src/playerItem/playerItemBoomerang.c b/src/playerItem/playerItemBoomerang.c index 498843e4..0f7a8662 100644 --- a/src/playerItem/playerItemBoomerang.c +++ b/src/playerItem/playerItemBoomerang.c @@ -67,13 +67,13 @@ void PlayerItemBoomerang_Init(PlayerItemBoomerangEntity* this) { super->frameIndex = 0xff; this->unk_80 = 0; #ifdef EU - super->spriteVramOffset = gPlayerEntity.spriteVramOffset; + super->spriteVramOffset = gPlayerEntity.base.spriteVramOffset; #endif super->animIndex = 11; - super->parent = &gPlayerEntity; + super->parent = &gPlayerEntity.base; this->unk_86 = 0; if ((super->animationState & 2) != 0) { - super->spriteSettings.flipX = ~gPlayerEntity.spriteSettings.flipX; + super->spriteSettings.flipX = ~gPlayerEntity.base.spriteSettings.flipX; } if (this->unk_68 == 12) { super->speed = 0x280; @@ -104,31 +104,31 @@ void PlayerItemBoomerang_Action1(PlayerItemBoomerangEntity* this) { sub_0801B804(this); if ((gPlayerState.attack_status == 0) || (gPlayerState.mobility != 0) || gPlayerState.item != super || - (gPlayerState.item == super && gPlayerEntity.action != PLAYER_NORMAL)) { + (gPlayerState.item == super && gPlayerEntity.base.action != PLAYER_NORMAL)) { if (gPlayerState.item == super) { gPlayerState.item = NULL; } DeleteThisEntity(); } - if ((gPlayerEntity.frame & 1) == 0) { + if ((gPlayerEntity.base.frame & 1) == 0) { if (this->unk_68 == 12) { cVar3 = 6; } else { cVar3 = 0; } - frameIndex = (gPlayerEntity.frame >> 4) + cVar3; + frameIndex = (gPlayerEntity.base.frame >> 4) + cVar3; if (super->frameIndex != frameIndex) { super->frameIndex = frameIndex; sub_080042D0(super, super->frameIndex, super->spriteIndex); } - sub_08078E84(super, &gPlayerEntity); + sub_08078E84(super, &gPlayerEntity.base); } else { super->action = 2; super->spriteVramOffset = 0xd5; COLLISION_ON(super); super->collisionFlags |= 1; - super->flags2 = gPlayerEntity.flags2; + super->flags2 = gPlayerEntity.base.flags2; super->spriteIndex = 0xa6; super->spriteSettings.flipX = 0; super->spriteSettings.draw = 1; @@ -171,7 +171,7 @@ void PlayerItemBoomerang_Action2(PlayerItemBoomerangEntity* this) { } } - if (sub_080B1BA4(COORD_TO_TILE(super), gPlayerEntity.collisionLayer, 0x80) == 0) { + if (sub_080B1BA4(COORD_TO_TILE(super), gPlayerEntity.base.collisionLayer, 0x80) == 0) { if (!uVar6) { uVar6 = sub_080040E2(super, &gUnk_08003E44); } @@ -214,9 +214,9 @@ void PlayerItemBoomerang_Action3(PlayerItemBoomerangEntity* this) { if (super->speed < 0x280) { super->speed += 8; } - super->direction = GetFacingDirection(super, &gPlayerEntity); + super->direction = GetFacingDirection(super, &gPlayerEntity.base); LinearMoveUpdate(super); - if (sub_0800419C(super, &gPlayerEntity, 2, 2) != 0) { + if (sub_0800419C(super, &gPlayerEntity.base, 2, 2) != 0) { DeleteThisEntity(); } } diff --git a/src/playerItem/playerItemBottle.c b/src/playerItem/playerItemBottle.c index 5cb0217d..8196ba8b 100644 --- a/src/playerItem/playerItemBottle.c +++ b/src/playerItem/playerItemBottle.c @@ -4,20 +4,14 @@ * * @brief Bottle Player Item */ -#include "entity.h" +#include "playerItem/playerItemBottle.h" + #include "functions.h" #include "item.h" #include "object.h" #include "save.h" #include "sound.h" -typedef struct { - /*0x00*/ Entity base; - /*0x68*/ u8 bottleIndex; /**< @see Item */ - /*0x69*/ u8 unused[6]; - /*0x6f*/ u8 bottleContent; /**< @see Item */ -} PlayerItemBottleEntity; - void PlayerItemBottle_UseEmptyBottle(Entity*); void PlayerItemBottle_Action1(PlayerItemBottleEntity*); void sub_0801BDE8(Entity*, Entity*); @@ -53,8 +47,8 @@ void PlayerItemBottle_Init(PlayerItemBottleEntity* this) { return; } COLLISION_ON(super); - super->collisionFlags = (gPlayerEntity.collisionFlags + 1) | 0x20; - super->flags2 = gPlayerEntity.flags2; + super->collisionFlags = (gPlayerEntity.base.collisionFlags + 1) | 0x20; + super->flags2 = gPlayerEntity.base.flags2; super->hurtType = 0x1f; super->type = 1; super->type2 = ITEM_BOTTLE_EMPTY; @@ -107,7 +101,7 @@ void PlayerItemBottle_Action1(PlayerItemBottleEntity* this) { } DeleteThisEntity(); } - sub_0801BDE8(super, &gPlayerEntity); + sub_0801BDE8(super, &gPlayerEntity.base); switch (this->bottleContent) { case ITEM_BOTTLE_EMPTY: PlayerItemBottle_UseEmptyBottle2(super); @@ -123,8 +117,8 @@ void PlayerItemBottle_Action1(PlayerItemBottleEntity* this) { case ITEM_BOTTLE_PICOLYTE_GREEN: case ITEM_BOTTLE_PICOLYTE_BLUE: case ITEM_BOTTLE_PICOLYTE_WHITE: - if (gPlayerEntity.frame == 1) { - gPlayerEntity.frame = 0; + if (gPlayerEntity.base.frame == 1) { + gPlayerEntity.base.frame = 0; PlayerItemBottle_UsePotionOrPicolyte(this); } break; @@ -175,7 +169,7 @@ void PlayerItemBottle_UsePotionOrPicolyte(PlayerItemBottleEntity* this) { } void PlayerItemBottle_UseOther(PlayerItemBottleEntity* this) { - if (gPlayerEntity.frame == 1) { + if (gPlayerEntity.base.frame == 1) { if (this->bottleContent != ITEM_QST_DOGFOOD) { SetBottleContents(ITEM_BOTTLE_EMPTY, this->bottleIndex - 0x1c); } @@ -198,7 +192,7 @@ void PlayerItemBottle_UseOther(PlayerItemBottleEntity* this) { SoundReq(SFX_ELEMENT_CHARGE); } } - if (gPlayerEntity.frame == 2) { + if (gPlayerEntity.base.frame == 2) { switch (this->bottleContent) { case ITEM_BOTTLE_WATER: CreateObjectWithParent(super, LINK_EMPTYING_BOTTLE, 0, 0); @@ -208,7 +202,7 @@ void PlayerItemBottle_UseOther(PlayerItemBottleEntity* this) { break; } } - if (gPlayerEntity.frame == 3) { + if (gPlayerEntity.base.frame == 3) { switch (this->bottleContent) { case ITEM_BOTTLE_WATER: CreateObjectWithParent(super, LINK_EMPTYING_BOTTLE, 0, 0); @@ -233,7 +227,7 @@ void sub_0801BDE8(Entity* this, Entity* ent2) { flipX = ent2->spriteSettings.flipX; animationState = (ent2->animationState >> 1); this->spriteSettings.flipX = flipX ^ (animationState & 1); - sub_08078E84(this, &gPlayerEntity); + sub_08078E84(this, &gPlayerEntity.base); } void PlayerItemBottle_UseEmptyBottle(Entity* this) { @@ -278,9 +272,9 @@ void PlayerItemBottle_UseEmptyBottle(Entity* this) { this->hitbox->offset_y = ptr[1]; this->hitbox->width = ptr[2]; this->hitbox->height = ptr[3]; - if ((gPlayerEntity.frame & 0xf) != 0) { + if ((gPlayerEntity.base.frame & 0xf) != 0) { if (this->type2 == ITEM_BOTTLE_EMPTY) { - ptr2 = &gUnk_080B7878[((gPlayerEntity.frame & 0xf) - 1) * 2]; + ptr2 = &gUnk_080B7878[((gPlayerEntity.base.frame & 0xf) - 1) * 2]; iVar2 = ptr2[0]; if (this->spriteSettings.flipX != 0) { iVar2 = -iVar2; @@ -292,6 +286,6 @@ void PlayerItemBottle_UseEmptyBottle(Entity* this) { } if (this->type2 != ITEM_BOTTLE_EMPTY) { - COLLISION_OFF(&gPlayerEntity); + COLLISION_OFF(&gPlayerEntity.base); } } diff --git a/src/playerItem/playerItemBow.c b/src/playerItem/playerItemBow.c index e3aba91b..ecedd873 100644 --- a/src/playerItem/playerItemBow.c +++ b/src/playerItem/playerItemBow.c @@ -86,17 +86,17 @@ void PlayerItemBow_Init(PlayerItemBowEntity* this) { super->speed = 0x300; } super->direction = super->animationState << 2; - super->collisionFlags = gPlayerEntity.collisionFlags + 1; - super->flags2 = gPlayerEntity.flags2; + super->collisionFlags = gPlayerEntity.base.collisionFlags + 1; + super->flags2 = gPlayerEntity.base.flags2; if (super->collisionLayer == 2) { super->type2 = 1; } else { super->type2 = 0; } - super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; + super->spriteOrientation.flipY = gPlayerEntity.base.spriteOrientation.flipY; ptr = &gUnk_080B3E40[super->animationState >> 1]; - super->x.HALF.HI = gPlayerEntity.x.HALF.HI + ptr->x; - super->y.HALF.HI = gPlayerEntity.y.HALF.HI + ptr->y; + super->x.HALF.HI = gPlayerEntity.base.x.HALF.HI + ptr->x; + super->y.HALF.HI = gPlayerEntity.base.y.HALF.HI + ptr->y; super->spriteSettings.flipX = ptr->spriteSettings; super->spriteSettings.flipY = ptr->unk_3; super->animIndex = ptr->animIndex; @@ -163,7 +163,7 @@ void PlayerItemBow_Action1(PlayerItemBowEntity* this) { if (super->type2 == 0) { sub_0800451C(super); } - if ((sub_080B1BA4(COORD_TO_TILE(super), gPlayerEntity.collisionLayer, 0x80) == 0) && (!tmp2) && + if ((sub_080B1BA4(COORD_TO_TILE(super), gPlayerEntity.base.collisionLayer, 0x80) == 0) && (!tmp2) && sub_080040D8(super, &gUnk_08003E44, super->x.HALF.HI, super->y.HALF.HI) != 0) { super->timer = 30; super->action++; @@ -224,21 +224,21 @@ void PlayerItemBow_Action1(PlayerItemBowEntity* this) { } } arrowCount = gSave.stats.arrowCount; - if (super->frameIndex - this->unk_78 != gPlayerEntity.frameIndex) { - super->frameIndex = gPlayerEntity.frameIndex + this->unk_78; + if (super->frameIndex - this->unk_78 != gPlayerEntity.base.frameIndex) { + super->frameIndex = gPlayerEntity.base.frameIndex + this->unk_78; if (arrowCount == 0) { super->frameIndex += 0x2a; } sub_080042D0(super, super->frameIndex, super->spriteIndex); } - if ((gPlayerEntity.frame & 1) != 0 && arrowCount != 0) { + if ((gPlayerEntity.base.frame & 1) != 0 && arrowCount != 0) { entity = CreatePlayerItem(PLAYER_ITEM_BOW, 1, super->hurtType, 9); if (entity != NULL) { gPlayerState.attack_status |= 0x80; ModArrows(-1); } } - sub_08078E84(super, &gPlayerEntity); + sub_08078E84(super, &gPlayerEntity.base); } } diff --git a/src/playerItem/playerItemCellOverwriteSet.c b/src/playerItem/playerItemCellOverwriteSet.c index 22c3f8da..cf841e9f 100644 --- a/src/playerItem/playerItemCellOverwriteSet.c +++ b/src/playerItem/playerItemCellOverwriteSet.c @@ -23,7 +23,7 @@ extern const u8 gUnk_080B7A3E[]; // TODO figure out type from arm_sub_080B1B84 a void PlayerItemCellOverwriteSet(PlayerItemCellOverwriteSetEntity* this) { static const s8 gUnk_080B7B6C[] = { 0x0, -0x10, 0x10, 0x0, 0x0, 0x10, -0x10, 0x0 }; u32 tmp; - Entity* player = &gPlayerEntity; + Entity* player = &gPlayerEntity.base; if (super->action == 0) { this->tileType = GetTileType(TILE(player->x.HALF.HI + gUnk_080B7B6C[player->animationState & 0xe], diff --git a/src/playerItem/playerItemDashSword.c b/src/playerItem/playerItemDashSword.c index 497e128e..ef127535 100644 --- a/src/playerItem/playerItemDashSword.c +++ b/src/playerItem/playerItemDashSword.c @@ -67,13 +67,13 @@ void sub_0801B938(Entity* this) { const s8* ptr; if ((this->animationState & 2)) { - this->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX ^ 1; + this->spriteSettings.flipX = gPlayerEntity.base.spriteSettings.flipX ^ 1; } else { - this->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX; + this->spriteSettings.flipX = gPlayerEntity.base.spriteSettings.flipX; } - if ((u8)(gPlayerEntity.animIndex + 0x68) < 4) { - this->frameIndex = gPlayerEntity.frameIndex + 0x2e; + if ((u8)(gPlayerEntity.base.animIndex + 0x68) < 4) { + this->frameIndex = gPlayerEntity.base.frameIndex + 0x2e; sub_080042D0(this, this->frameIndex, this->spriteIndex); } else { this->frameIndex = 0xff; @@ -82,7 +82,7 @@ void sub_0801B938(Entity* this) { this->hitbox = (Hitbox*)&gUnk_080B7850[this->animationState >> 1]; ptr = &gUnk_080B7848[(this->animationState >> 1) * 2]; sub_08008782(this, -(gPlayerState.skills & SKILL_ROCK_BREAKER) != 0, ptr[0], ptr[1]); - sub_08078E84(this, &gPlayerEntity); + sub_08078E84(this, &gPlayerEntity.base); } void sub_0801B9F0(Entity* this) { diff --git a/src/playerItem/playerItemFireRodProjectile.c b/src/playerItem/playerItemFireRodProjectile.c index 04612e50..eb5c4005 100644 --- a/src/playerItem/playerItemFireRodProjectile.c +++ b/src/playerItem/playerItemFireRodProjectile.c @@ -38,7 +38,7 @@ void PlayerItemFireRodProjectile_Init(PlayerItemFireRodProjectileEntity* this) { super->action = 1; CopyPosition(super->parent, super); if (super->type == 0) { - super->collisionFlags = gPlayerEntity.collisionFlags + 1; + super->collisionFlags = gPlayerEntity.base.collisionFlags + 1; super->hitbox = (Hitbox*)&gUnk_08127278; super->speed = 0x400; if (super->collisionLayer == 2) { @@ -70,7 +70,7 @@ void PlayerItemFireRodProjectile_Action1(PlayerItemFireRodProjectileEntity* this if (super->type2 == 0) { sub_0800451C(super); } - if (sub_080B1BA4(COORD_TO_TILE(super), gPlayerEntity.collisionLayer, 0x80) == 0 && + if (sub_080B1BA4(COORD_TO_TILE(super), gPlayerEntity.base.collisionLayer, 0x80) == 0 && sub_080040D8(super, &gUnk_08003E44, super->x.HALF.HI, super->y.HALF.HI)) { CreateFx(super, FX_SWORD_MAGIC, 0); DeleteThisEntity(); diff --git a/src/playerItem/playerItemGust.c b/src/playerItem/playerItemGust.c index cea176c4..40e2a1be 100644 --- a/src/playerItem/playerItemGust.c +++ b/src/playerItem/playerItemGust.c @@ -70,7 +70,7 @@ void PlayerItemGust(Entity* this) { static void PlayerItemGust_Init(PlayerItemGustEntity* this) { super->action = GUST_UPDATE; - super->flags2 = gPlayerEntity.flags2; + super->flags2 = gPlayerEntity.base.flags2; super->direction = super->animationState << 2; super->speed = 0x200; super->flags |= ENT_COLLIDE | ENT_PERSIST; @@ -166,8 +166,8 @@ bool32 sub_080ACDB0(PlayerItemGustEntity* this) { u32 tmp; if (super->type == 0) { - super->x.HALF.HI = gPlayerEntity.x.HALF.HI + gUnk_08126EE4[super->animationState]; - super->y.HALF.HI = gPlayerEntity.y.HALF.HI + gUnk_08126EE4[super->animationState + 1]; + super->x.HALF.HI = gPlayerEntity.base.x.HALF.HI + gUnk_08126EE4[super->animationState]; + super->y.HALF.HI = gPlayerEntity.base.y.HALF.HI + gUnk_08126EE4[super->animationState + 1]; } else { if ((super->animationState & 2) != 0) { super->y.HALF.HI = super->parent->y.HALF.HI - 3; @@ -219,7 +219,7 @@ bool32 sub_080ACDB0(PlayerItemGustEntity* this) { } } } - super->collisionLayer = gPlayerEntity.collisionLayer; + super->collisionLayer = gPlayerEntity.base.collisionLayer; return 0; } diff --git a/src/playerItem/playerItemGustBig.c b/src/playerItem/playerItemGustBig.c index 913be2b1..15e95c2d 100644 --- a/src/playerItem/playerItemGustBig.c +++ b/src/playerItem/playerItemGustBig.c @@ -8,7 +8,6 @@ #include "entity.h" #include "functions.h" #include "global.h" -#include "new_player.h" #include "player.h" #include "sound.h" @@ -67,14 +66,14 @@ void PlayerItemGustBig_Init(PlayerItemGustBigEntity* this) { u8 uVar2; Entity* pEVar3; - this->unk_84 = super->x.WORD = gPlayerEntity.x.WORD; - this->unk_80 = super->y.WORD = gPlayerEntity.y.WORD; - uVar2 = super->animationState = gPlayerEntity.animationState & 0xe; + this->unk_84 = super->x.WORD = gPlayerEntity.base.x.WORD; + this->unk_80 = super->y.WORD = gPlayerEntity.base.y.WORD; + uVar2 = super->animationState = gPlayerEntity.base.animationState & 0xe; super->direction = (u8)(uVar2 << 2); super->speed = 0x400; super->hitType = 0x96; - super->collisionFlags = (gPlayerEntity.collisionFlags + 1) | 0x80; - super->flags2 = gPlayerEntity.flags2; + super->collisionFlags = (gPlayerEntity.base.collisionFlags + 1) | 0x80; + super->flags2 = gPlayerEntity.base.flags2; pEVar3 = super->child; if (pEVar3 != NULL) { super->action = 1; @@ -99,9 +98,9 @@ void PlayerItemGustBig_Init(PlayerItemGustBigEntity* this) { super->damage = gUnk_080B3DE0[super->type * 2 + 1]; super->hurtType = 0x1b; super->hitbox = (Hitbox*)gUnk_080B3DE8[super->type]; - gNewPlayerEntity.unk_70 = super; - sub_08078CD0(&gPlayerEntity); - gNewPlayerEntity.unk_70 = pEVar3; + gPlayerEntity.unk_70 = super; + sub_08078CD0(&gPlayerEntity.base); + gPlayerEntity.unk_70 = pEVar3; InitializeAnimation(super, super->type + 10); sub_08018FA0(super); } @@ -129,7 +128,7 @@ void PlayerItemGustBig_Action1(PlayerItemGustBigEntity* this) { sub_08018FA0(super); break; } - sub_08078CD0(&gPlayerEntity); + sub_08078CD0(&gPlayerEntity.base); } void PlayerItemGustBig_Action2(PlayerItemGustBigEntity* this) { @@ -207,7 +206,7 @@ void PlayerItemGustBig_Action3(PlayerItemGustBigEntity* this) { } void sub_08018FA0(Entity* this) { - this->collisionLayer = gPlayerEntity.collisionLayer; + this->collisionLayer = gPlayerEntity.base.collisionLayer; if (this->collisionLayer == 2) { this->type2 = 1; } diff --git a/src/playerItem/playerItemGustJar.c b/src/playerItem/playerItemGustJar.c index 4afa8857..b3ebcb29 100644 --- a/src/playerItem/playerItemGustJar.c +++ b/src/playerItem/playerItemGustJar.c @@ -33,7 +33,7 @@ void PlayerItemGustJar(Entity* this) { DeleteThisEntity(); } PlayerItemGustJar_Actions[this->action](this); - sub_08078E84(this, &gPlayerEntity); + sub_08078E84(this, &gPlayerEntity.base); } void PlayerItemGustJar_Init(Entity* this) { @@ -65,10 +65,10 @@ void PlayerItemGustJar_Action2(Entity* this) { if (gPlayerState.field_0x1c == 3) { this->action++; - InitAnimationForceUpdate(this, (gPlayerEntity.animationState >> 1) + 8); + InitAnimationForceUpdate(this, (gPlayerEntity.base.animationState >> 1) + 8); } else if (gPlayerState.field_0x1c == 6) { this->action = 4; - InitAnimationForceUpdate(this, (gPlayerEntity.animationState >> 1) + 4); + InitAnimationForceUpdate(this, (gPlayerEntity.base.animationState >> 1) + 4); } else { windSound = 0; if (this->type != 0) { @@ -121,7 +121,7 @@ void PlayerItemGustJar_Action2(Entity* this) { } this->subtimer = 15; } - this->frameIndex = gPlayerEntity.frameIndex - (gPlayerEntity.frame & 0x7f); + this->frameIndex = gPlayerEntity.base.frameIndex - (gPlayerEntity.base.frame & 0x7f); } } @@ -129,7 +129,7 @@ void PlayerItemGustJar_Action3(Entity* this) { switch (gPlayerState.field_0x1c & 0xf) { case 6: this->action++; - InitAnimationForceUpdate(this, (gPlayerEntity.animationState >> 1) + 4); + InitAnimationForceUpdate(this, (gPlayerEntity.base.animationState >> 1) + 4); break; case 1: sub_080ADCA0(this, 0); @@ -150,11 +150,11 @@ void PlayerItemGustJar_Action4(Entity* this) { } void sub_080ADC84(Entity* this) { - this->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX; + this->spriteSettings.flipX = gPlayerEntity.base.spriteSettings.flipX; } void sub_080ADCA0(Entity* this, u32 param_2) { - const u8* pFVar1 = gUnk_08132714[(param_2 + (gPlayerEntity.animationState >> 1))]; + const u8* pFVar1 = gUnk_08132714[(param_2 + (gPlayerEntity.base.animationState >> 1))]; const u8* pFVar2; this->animPtr = (void*)pFVar1; diff --git a/src/playerItem/playerItemHeldObject.c b/src/playerItem/playerItemHeldObject.c index 60ad9ecb..e7fb4643 100644 --- a/src/playerItem/playerItemHeldObject.c +++ b/src/playerItem/playerItemHeldObject.c @@ -8,7 +8,6 @@ #include "effects.h" #include "entity.h" #include "functions.h" -#include "new_player.h" #include "player.h" #include "sound.h" @@ -87,7 +86,7 @@ void PlayerItemHeldObject_SubAction1(PlayerItemHeldObjectEntity* this) { PlayerDropHeldObject(); DeleteThisEntity(); } else { - if ((gPlayerState.heldObject == 0) || ((gNewPlayerEntity.unk_79 & 0x7f) != 0)) { + if ((gPlayerState.heldObject == 0) || ((gPlayerEntity.unk_79 & 0x7f) != 0)) { sub_080AD27C(this); super->subAction++; super->flags &= ~0x80; @@ -205,13 +204,13 @@ void PlayerItemHeldObject_SubAction2(PlayerItemHeldObjectEntity* this) { } } else { - tmp = gPlayerEntity.frame & 1; + tmp = gPlayerEntity.base.frame & 1; if (tmp != 0) { SoundReq(SFX_PLY_VO5); sub_080AD27C(this); return; } - if ((gPlayerState.heldObject != 0) && ((gNewPlayerEntity.unk_79 & 0x80) == 0)) { + if ((gPlayerState.heldObject != 0) && ((gPlayerEntity.unk_79 & 0x80) == 0)) { return; } sub_080AD27C(this); @@ -236,7 +235,7 @@ void sub_080AD27C(PlayerItemHeldObjectEntity* this) { static const u32 gUnk_081320D4[] = { Q_16_16(0), Q_16_16(0.5), Q_16_16(1.25), Q_16_16(1.25) }; u32 tmp; PlayerItemHeldObjectEntity* child = (PlayerItemHeldObjectEntity*)super->child; - gNewPlayerEntity.unk_74 = NULL; + gPlayerEntity.unk_74 = NULL; if ((this->unk_6c == (u16)(child->base).kind) && (this->unk_6e == (u16)(child->base).id)) { if (child != this) { (child->base).subAction = 2; @@ -250,9 +249,9 @@ void sub_080AD27C(PlayerItemHeldObjectEntity* this) { (child->base).z.HALF.HI += 8; super->z.HALF.HI = (child->base).z.HALF.HI; super->collisionLayer = (child->base).collisionLayer; - super->y.HALF.HI = gPlayerEntity.y.HALF.HI; - super->x.HALF.HI = gPlayerEntity.x.HALF.HI; - super->collisionFlags = gPlayerEntity.collisionFlags; + super->y.HALF.HI = gPlayerEntity.base.y.HALF.HI; + super->x.HALF.HI = gPlayerEntity.base.x.HALF.HI; + super->collisionFlags = gPlayerEntity.base.collisionFlags; super->flags |= 0x80; sub_0801766C(super); } else { diff --git a/src/playerItem/playerItemLantern.c b/src/playerItem/playerItemLantern.c index 3e66b86f..04664464 100644 --- a/src/playerItem/playerItemLantern.c +++ b/src/playerItem/playerItemLantern.c @@ -30,7 +30,7 @@ void PlayerItemLantern_Init(Entity* this) { this->updatePriority = 6; this->collisionFlags = 7; this->flags2 = -0x80; - this->animationState = gPlayerEntity.animationState & 0xe; + this->animationState = gPlayerEntity.base.animationState & 0xe; if (AllocMutableHitbox(this) == NULL) { DeleteThisEntity(); } @@ -42,27 +42,27 @@ void PlayerItemLantern_Init(Entity* this) { void PlayerItemLantern_Action1(Entity* this) { Entity* object; static const s8 offsets[] = { 6, -6, 7, -3, -5, 2, -7, -3 }; - this->animationState = gPlayerEntity.animationState & 0xe; + this->animationState = gPlayerEntity.base.animationState & 0xe; this->hitbox->offset_x = offsets[this->animationState]; this->hitbox->offset_y = offsets[this->animationState + 1]; this->hitbox->width = 4; this->hitbox->height = 4; - if (!((gPlayerEntity.frameIndex < 0x37) && ((u32)gPlayerEntity.spriteIndex == 6))) { + if (!((gPlayerEntity.base.frameIndex < 0x37) && ((u32)gPlayerEntity.base.spriteIndex == 6))) { this->frameIndex = 0xff; this->flags &= ~ENT_COLLIDE; } else { this->flags |= ENT_COLLIDE; - this->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX; - this->spriteSettings.flipY = gPlayerEntity.spriteSettings.flipY; - if (gPlayerEntity.frameIndex != this->frameIndex) { - this->frameIndex = gPlayerEntity.frameIndex; + this->spriteSettings.flipX = gPlayerEntity.base.spriteSettings.flipX; + this->spriteSettings.flipY = gPlayerEntity.base.spriteSettings.flipY; + if (gPlayerEntity.base.frameIndex != this->frameIndex) { + this->frameIndex = gPlayerEntity.base.frameIndex; sub_080042D0(this, this->frameIndex, this->spriteIndex); } - this->frame = gPlayerEntity.frame; - this->frameSpriteSettings = gPlayerEntity.frameSpriteSettings; + this->frame = gPlayerEntity.base.frame; + this->frameSpriteSettings = gPlayerEntity.base.frameSpriteSettings; } if (IsItemEquipped(ITEM_LANTERN_ON) < EQUIP_SLOT_NONE) { - if (((this->frameIndex != 0xff) && (gPlayerEntity.spriteSettings.draw != 0)) && (this->timer-- == 0)) { + if (((this->frameIndex != 0xff) && (gPlayerEntity.base.spriteSettings.draw != 0)) && (this->timer-- == 0)) { this->timer = 4; object = CreateObject(LAMP_PARTICLE, 0, 0x10); if (object != NULL) { @@ -72,7 +72,7 @@ void PlayerItemLantern_Action1(Entity* this) { object->spriteOffsetY = offsets[this->animationState + 1]; } } - sub_08078E84(this, &gPlayerEntity); + sub_08078E84(this, &gPlayerEntity.base); } else { DeleteThisEntity(); } diff --git a/src/playerItem/playerItemPacciCane.c b/src/playerItem/playerItemPacciCane.c index 65c665ad..a6ef2553 100644 --- a/src/playerItem/playerItemPacciCane.c +++ b/src/playerItem/playerItemPacciCane.c @@ -35,30 +35,30 @@ void PlayerItemPacciCane_Action1(Entity* this) { u32 playerFrame; u32 frameIndex; u32 flipX; - if (((gPlayerEntity.frame & ANIM_DONE) != 0) || (this != gPlayerState.item)) { + if (((gPlayerEntity.base.frame & ANIM_DONE) != 0) || (this != gPlayerState.item)) { if (this == gPlayerState.item) { gPlayerState.item = NULL; } DeleteEntity(this); } else { - playerFrame = gPlayerEntity.frame & 0xf; + playerFrame = gPlayerEntity.base.frame & 0xf; if (playerFrame != 0xf) { - frameIndex = gPlayerEntity.frameIndex; + frameIndex = gPlayerEntity.base.frameIndex; playerFrame += 0x91; if (frameIndex - playerFrame != this->frameIndex) { this->frameIndex = frameIndex + 0x6f; sub_080042D0(this, this->frameIndex, this->spriteIndex); } - sub_08078E84(this, &gPlayerEntity); + sub_08078E84(this, &gPlayerEntity.base); } else { this->frameIndex = -1; } } - if ((gPlayerEntity.animationState & 2)) { - flipX = gPlayerEntity.spriteSettings.flipX ^ 1; + if ((gPlayerEntity.base.animationState & 2)) { + flipX = gPlayerEntity.base.spriteSettings.flipX ^ 1; } else { - flipX = gPlayerEntity.spriteSettings.flipX; + flipX = gPlayerEntity.base.spriteSettings.flipX; } this->spriteSettings.flipX = flipX; } diff --git a/src/playerItem/playerItemPacciCaneProjectile.c b/src/playerItem/playerItemPacciCaneProjectile.c index 9bc25f27..ef2bee36 100644 --- a/src/playerItem/playerItemPacciCaneProjectile.c +++ b/src/playerItem/playerItemPacciCaneProjectile.c @@ -71,8 +71,8 @@ void PlayerItemPacciCaneProjectile_Init(PlayerItemPacciCaneProjectileEntity* thi super->speed = 0x200; this->unk_74 = 0x40; this->unk_78 = 0x1e0; - super->x.HALF.HI = gPlayerEntity.x.HALF.HI + gUnk_0811B9A0[super->animationState]; - super->y.HALF.HI = gPlayerEntity.y.HALF.HI + gUnk_0811B9A0[super->animationState + 1]; + super->x.HALF.HI = gPlayerEntity.base.x.HALF.HI + gUnk_0811B9A0[super->animationState]; + super->y.HALF.HI = gPlayerEntity.base.y.HALF.HI + gUnk_0811B9A0[super->animationState + 1]; super->collisionFlags = 7; super->flags2 = 0x8a; super->hitbox = (Hitbox*)&gUnk_0811B9D0; @@ -81,7 +81,7 @@ void PlayerItemPacciCaneProjectile_Init(PlayerItemPacciCaneProjectileEntity* thi } else { super->type = 0; } - super->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; + super->spriteOrientation.flipY = gPlayerEntity.base.spriteOrientation.flipY; ptr = &gUnk_0811B9A8[(super->animationState >> 1)]; super->spriteSettings.flipX = ptr->flipX; super->spriteSettings.flipY = ptr->flipY; @@ -125,7 +125,7 @@ void PlayerItemPacciCaneProjectile_Action1(PlayerItemPacciCaneProjectileEntity* if (super->type == 0) { sub_0800451C(super); } - if (sub_080B1BA4(COORD_TO_TILE(super), gPlayerEntity.collisionLayer, 0x80) == 0) { + if (sub_080B1BA4(COORD_TO_TILE(super), gPlayerEntity.base.collisionLayer, 0x80) == 0) { if (sub_080040D8(super, &gUnk_08003E44, super->x.HALF.HI, super->y.HALF.HI) == 0) { if (GetTileUnderEntity(super) == 0x19) { super->action = 4; diff --git a/src/playerItem/playerItemShield.c b/src/playerItem/playerItemShield.c index a1b38a61..bb592f74 100644 --- a/src/playerItem/playerItemShield.c +++ b/src/playerItem/playerItemShield.c @@ -75,7 +75,7 @@ void PlayerItemShield_Init(PlayerItemShieldEntity* this) { } else { this->unk_70 = 0; } - super->animationState = gPlayerEntity.animationState & 0xe; + super->animationState = gPlayerEntity.base.animationState & 0xe; sub_08079BD8(super); LoadSwapGFX(super, 1, 3); PlayerItemShield_Action1(this); @@ -86,10 +86,10 @@ void PlayerItemShield_Action1(PlayerItemShieldEntity* this) { u8* pbVar3; u32 tmp2; - if ((gPlayerEntity.iframes == 0) || ((u8)gPlayerEntity.iframes == 0x81)) { - gPlayerEntity.iframes = super->iframes; - gPlayerEntity.knockbackDirection = super->knockbackDirection; - gPlayerEntity.knockbackDuration = super->knockbackDuration; + if ((gPlayerEntity.base.iframes == 0) || ((u8)gPlayerEntity.base.iframes == 0x81)) { + gPlayerEntity.base.iframes = super->iframes; + gPlayerEntity.base.knockbackDirection = super->knockbackDirection; + gPlayerEntity.base.knockbackDuration = super->knockbackDuration; super->knockbackDuration = 0; super->iframes = 0; } @@ -97,7 +97,7 @@ void PlayerItemShield_Action1(PlayerItemShieldEntity* this) { if ((gPlayerState.shield_status != 0) && (super == gPlayerState.item)) { if ((gPlayerState.shield_status & 0x80) != 0) { super->hitbox = (Hitbox*)gUnk_08127240[super->animationState >> 1]; - super->collisionFlags = (gPlayerEntity.collisionFlags + 1) | 0x20; + super->collisionFlags = (gPlayerEntity.base.collisionFlags + 1) | 0x20; COLLISION_ON(super); gPlayerState.shield_status &= ~0x80; sub_080176E4(super); @@ -131,16 +131,16 @@ void PlayerItemShield_Action1(PlayerItemShieldEntity* this) { DeleteThisEntity(); } - if (((gPlayerEntity.spriteIndex == 1u) || (gPlayerEntity.spriteIndex == 4u)) && - ((u8)(gPlayerEntity.frameIndex - 0x25) < 0x3f)) { - super->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX; - super->spriteSettings.flipY = gPlayerEntity.spriteSettings.flipY; - if ((gPlayerEntity.frameIndex - 0x25 + this->unk_70 != super->frameIndex) && - ((super->frameIndex = gPlayerEntity.frameIndex - 0x25 + this->unk_70, - this->unk_68 != 0xe || ((gPlayerEntity.frame & 0x7f) == 0)))) { + if (((gPlayerEntity.base.spriteIndex == 1u) || (gPlayerEntity.base.spriteIndex == 4u)) && + ((u8)(gPlayerEntity.base.frameIndex - 0x25) < 0x3f)) { + super->spriteSettings.flipX = gPlayerEntity.base.spriteSettings.flipX; + super->spriteSettings.flipY = gPlayerEntity.base.spriteSettings.flipY; + if ((gPlayerEntity.base.frameIndex - 0x25 + this->unk_70 != super->frameIndex) && + ((super->frameIndex = gPlayerEntity.base.frameIndex - 0x25 + this->unk_70, + this->unk_68 != 0xe || ((gPlayerEntity.base.frame & 0x7f) == 0)))) { sub_080042D0(super, super->frameIndex, super->spriteIndex); } - if (((this->unk_68 == 0xe) && ((gPlayerEntity.frame & 0x7f) != 0))) { + if (((this->unk_68 == 0xe) && ((gPlayerEntity.base.frame & 0x7f) != 0))) { if (--this->unk_78 == 0) { this->unk_74++; tmp2 = this->unk_74 * 4; @@ -155,16 +155,16 @@ void PlayerItemShield_Action1(PlayerItemShieldEntity* this) { pbVar3 = &this->unk_7c[this->unk_74 * 4]; this->unk_78 = pbVar3[1]; if ((gPlayerState.shield_status & 0x40) != 0) { - u32 temp = (gPlayerEntity.frame & 0x7f) + 8; + u32 temp = (gPlayerEntity.base.frame & 0x7f) + 8; sub_080042D0(super, temp + pbVar3[0], super->spriteIndex); } else { - sub_080042D0(super, (gPlayerEntity.frame & 0x7f) + pbVar3[0], super->spriteIndex); + sub_080042D0(super, (gPlayerEntity.base.frame & 0x7f) + pbVar3[0], super->spriteIndex); } } } - super->frame = gPlayerEntity.frame; - super->frameSpriteSettings = gPlayerEntity.frameSpriteSettings; - sub_08078E84(super, &gPlayerEntity); + super->frame = gPlayerEntity.base.frame; + super->frameSpriteSettings = gPlayerEntity.base.frameSpriteSettings; + sub_08078E84(super, &gPlayerEntity.base); } else { super->frameIndex = 0xff; } diff --git a/src/playerItem/playerItemSpiralBeam.c b/src/playerItem/playerItemSpiralBeam.c index 76901cab..e381d594 100644 --- a/src/playerItem/playerItemSpiralBeam.c +++ b/src/playerItem/playerItemSpiralBeam.c @@ -31,10 +31,10 @@ void PlayerItemSpiralBeam(PlayerItemSpiralBeamEntity* this) { void PlayerItemSpiralBeam_Init(PlayerItemSpiralBeamEntity* this) { static const Hitbox gUnk_08109AD0 = { 0, 0, { 4, 0, 0, 0 }, 6, 6 }; - CopyPosition(&gPlayerEntity, super); + CopyPosition(&gPlayerEntity.base, super); super->action++; super->spriteSettings.draw = TRUE; - super->collisionFlags = gPlayerEntity.collisionFlags + 1; + super->collisionFlags = gPlayerEntity.base.collisionFlags + 1; super->hitbox = (Hitbox*)&gUnk_08109AD0; super->speed = 0x380; super->animationState = super->animationState & 0x7f; @@ -58,7 +58,7 @@ void PlayerItemSpiralBeam_Action1(PlayerItemSpiralBeamEntity* this) { if (super->type2 == 0) { sub_0800451C(super); } - if (!sub_080B1BA4(COORD_TO_TILE(super), gPlayerEntity.collisionLayer, 0x80) && + if (!sub_080B1BA4(COORD_TO_TILE(super), gPlayerEntity.base.collisionLayer, 0x80) && sub_080040D8(super, &gUnk_08003E44, super->x.HALF.HI, super->y.HALF.HI)) { CreateFx(super, FX_SWORD_MAGIC, 0); DeleteThisEntity(); diff --git a/src/playerItem/playerItemSword.c b/src/playerItem/playerItemSword.c index 647ea097..6df61709 100644 --- a/src/playerItem/playerItemSword.c +++ b/src/playerItem/playerItemSword.c @@ -33,7 +33,7 @@ void PlayerItemSword(Entity* this) { }; PlayerItemSword_Actions[this->action]((PlayerItemSwordEntity*)this); if (this->type == 0) { - sub_08078E84(this, &gPlayerEntity); + sub_08078E84(this, &gPlayerEntity.base); this->hitbox->offset_x += this->spriteOffsetX; this->hitbox->offset_y += this->spriteOffsetY; } @@ -58,8 +58,8 @@ void PlayerItemSword_Init(PlayerItemSwordEntity* this) { DeleteThisEntity(); } LoadSwapGFX(super, 1, 3); - super->collisionFlags = (gPlayerEntity.collisionFlags + 1) | 0x20; - super->flags2 = gPlayerEntity.flags2; + super->collisionFlags = (gPlayerEntity.base.collisionFlags + 1) | 0x20; + super->flags2 = gPlayerEntity.base.flags2; super->updatePriority = 6; super->contactFlags = 0; super->iframes = 0; @@ -182,7 +182,7 @@ void PlayerItemSword_Action1(PlayerItemSwordEntity* this) { break; } } - if ((gPlayerEntity.frame & 0x20) != 0) { + if ((gPlayerEntity.base.frame & 0x20) != 0) { SoundReq(SFX_116); } } else { @@ -194,7 +194,7 @@ void PlayerItemSword_Action1(PlayerItemSwordEntity* this) { super->hurtType = 0xb; } } - if (((gPlayerState.swordDamage) != 0) && ((gPlayerEntity.frame & 0x40) != 0)) { + if (((gPlayerState.swordDamage) != 0) && ((gPlayerEntity.base.frame & 0x40) != 0)) { type = FX_BLUE_SPARKLE; if ((gPlayerState.swordDamage) == 1) { type = FX_SPARKLE2; @@ -211,7 +211,7 @@ void PlayerItemSword_Action1(PlayerItemSwordEntity* this) { } } } - sub_080A78B8(this, &gPlayerEntity); + sub_080A78B8(this, &gPlayerEntity.base); sub_080A7A84(this); } else { if (!((gPlayerState.attack_status == 0) || (gPlayerState.item->hurtType == 0))) { @@ -235,18 +235,18 @@ void PlayerItemSword_Action2(PlayerItemSwordEntity* this) { gPlayerState.item = NULL; DeleteThisEntity(); } - if ((gPlayerEntity.frame & 0x80) != 0) { + if ((gPlayerEntity.base.frame & 0x80) != 0) { gPlayerState.item = NULL; DeleteThisEntity(); } else { - sub_080A78B8(this, &gPlayerEntity); - if ((gPlayerEntity.frame & 0x20) != 0) { + sub_080A78B8(this, &gPlayerEntity.base); + if ((gPlayerEntity.base.frame & 0x20) != 0) { SoundReq(SFX_PLY_VO3); } if (super->frameIndex > 0x8a) { super->frameIndex = 0xff; } - if ((gPlayerEntity.frame & 8) != 0) { + if ((gPlayerEntity.base.frame & 8) != 0) { super->flags |= ENT_COLLIDE; sub_080A7B98(this); } else { @@ -335,7 +335,7 @@ void sub_080A78B8(PlayerItemSwordEntity* this, Entity* param_2) { void sub_080A7A54(PlayerItemSwordEntity* this) { const u8* tmp; - tmp = &gUnk_08129096[(gPlayerEntity.frameIndex - 0x6a) * 4]; + tmp = &gUnk_08129096[(gPlayerEntity.base.frameIndex - 0x6a) * 4]; super->hitbox->offset_x = tmp[0]; super->hitbox->offset_y = tmp[1]; super->hitbox->width = tmp[2]; @@ -353,11 +353,11 @@ void sub_080A7A84(PlayerItemSwordEntity* this) { u32 tmp2; u32 r5; - if ((gPlayerEntity.frame & 0xf) != 0) { - uVar3 = gUnk_08129072[((gPlayerEntity.frame & 0xf) - 1)][0]; + if ((gPlayerEntity.base.frame & 0xf) != 0) { + uVar3 = gUnk_08129072[((gPlayerEntity.base.frame & 0xf) - 1)][0]; one = 1; - r5 = gUnk_08129072[(gPlayerEntity.frame & 0xf) - 1][one]; - if (((gPlayerState.sword_state & 0xc0) == 0) && (gPlayerEntity.spriteSettings.flipX == 1)) { + r5 = gUnk_08129072[(gPlayerEntity.base.frame & 0xf) - 1][one]; + if (((gPlayerState.sword_state & 0xc0) == 0) && (gPlayerEntity.base.spriteSettings.flipX == 1)) { uVar3 = -uVar3; } if (super->type != 0) { @@ -374,9 +374,9 @@ void sub_080A7A84(PlayerItemSwordEntity* this) { ((gPlayerState.sword_state & 0xc0) == 0)) { new_var2 = super; if (GetRelativeCollisionTile(new_var2, new_var, r5) == 0x2e) { - SoundReqClipped(&gPlayerEntity, SFX_ITEM_GLOVES_KNOCKBACK); + SoundReqClipped(&gPlayerEntity.base, SFX_ITEM_GLOVES_KNOCKBACK); } else { - SoundReqClipped(&gPlayerEntity, SFX_METAL_CLINK); + SoundReqClipped(&gPlayerEntity.base, SFX_METAL_CLINK); } effect = CreateObject(SPECIAL_FX, FX_LIGHTNING, 0); if (effect != NULL) { diff --git a/src/playerItem/playerItemSwordBeam.c b/src/playerItem/playerItemSwordBeam.c index dfe78825..0d572c09 100644 --- a/src/playerItem/playerItemSwordBeam.c +++ b/src/playerItem/playerItemSwordBeam.c @@ -40,10 +40,10 @@ static const u8 PlayerItemSwordBeam_Palettes[] = { 0, 4, 1, 2, 0xff }; void PlayerItemSwordBeam_Init(PlayerItemSwordBeamEntity* this) { static const Hitbox hitbox = { 0, 0, { 4, 0, 0, 0 }, 6, 6 }; - CopyPosition(&gPlayerEntity, super); + CopyPosition(&gPlayerEntity.base, super); super->action++; super->spriteSettings.draw = 1; - super->collisionFlags = gPlayerEntity.collisionFlags + 1; + super->collisionFlags = gPlayerEntity.base.collisionFlags + 1; super->hitbox = (Hitbox*)&hitbox; super->speed = 0x380; this->unk_74 = 2; @@ -88,7 +88,7 @@ void PlayerItemSwordBeam_Action1(PlayerItemSwordBeamEntity* this) { if (super->type2 == 0) { sub_0800451C(super); } - if ((sub_080B1BA4(COORD_TO_TILE(super), gPlayerEntity.collisionLayer, 0x80) == 0) && + if ((sub_080B1BA4(COORD_TO_TILE(super), gPlayerEntity.base.collisionLayer, 0x80) == 0) && (sub_080040D8(super, &gUnk_08003E44, super->x.HALF.HI, super->y.HALF.HI) != 0)) { CreateFx(super, FX_SWORD_MAGIC, 0); DeleteThisEntity(); diff --git a/src/playerItemUtils.c b/src/playerItemUtils.c index 6e7bb5f8..446bbdc7 100644 --- a/src/playerItemUtils.c +++ b/src/playerItemUtils.c @@ -25,7 +25,7 @@ void CreateItemEntity(u32 type, u32 type2, u32 delay) { void InitItemGetSequence(u32 type, u32 type2, u32 delay) { Entity* e = GiveItemWithCutscene(type, type2, delay); if (e != NULL) { - e->parent = &gPlayerEntity; + e->parent = &gPlayerEntity.base; SetPlayerItemGetState(e, e->type, 0); } } diff --git a/src/playerUtils.c b/src/playerUtils.c index 4625029f..16eb6033 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -1,23 +1,22 @@ #include "area.h" #include "asm.h" -#include "common.h" #include "collision.h" +#include "common.h" #include "entity.h" #include "functions.h" #include "game.h" #include "global.h" #include "item.h" #include "kinstone.h" +#include "main.h" #include "manager/diggingCaveEntranceManager.h" #include "message.h" -#include "new_player.h" #include "object.h" #include "player.h" #include "room.h" #include "save.h" #include "screen.h" #include "screenTransitions.h" -#include "main.h" static void sub_08077E54(ItemBehavior* beh); @@ -218,14 +217,14 @@ bool32 IsPreventedFromUsingItem(void) { switch (gArea.portal_mode) { case 2: if (gArea.portal_timer == 0) { - gPlayerEntity.subAction++; + gPlayerEntity.base.subAction++; } break; case 3: if ((gArea.portal_timer == 0) && ((gPlayerState.flags & PL_MINISH) != 0)) { - gPlayerEntity.subAction++; - gPlayerEntity.flags &= ~ENT_COLLIDE; - RequestPriorityDuration(&gPlayerEntity, 180); + gPlayerEntity.base.subAction++; + gPlayerEntity.base.flags &= ~ENT_COLLIDE; + RequestPriorityDuration(&gPlayerEntity.base, 180); return TRUE; } return FALSE; @@ -272,7 +271,7 @@ bool32 IsTryingToPickupObject(void) { ItemBehavior* item; if (!((((gPlayerState.flags & (PL_USE_PORTAL | PL_MINISH | PL_ROLLING)) == 0) && - (((gNewPlayerEntity.unk_79 != 0 || (gPlayerState.heldObject != 0)) || + (((gPlayerEntity.unk_79 != 0 || (gPlayerState.heldObject != 0)) || ((gPlayerState.playerInput.newInput & INPUT_LIFT_THROW) != 0)))) && (((sub_080789A8() != 0 || ((gPlayerState.playerInput.heldInput & (INPUT_ANY_DIRECTION | INPUT_USE_ITEM1 | INPUT_USE_ITEM2)) == 0)))))) { @@ -301,7 +300,7 @@ ItemBehavior* (*const gCreateItemsFuncs[])(Item) = { ItemBehavior* CreateItem(Item itemId) { if (((((gPlayerState.queued_action == PLAYER_ROLL) && (itemId != ITEM_TRY_PICKUP_OBJECT)) || (((gPlayerState.flags & (PL_ROLLING | PL_CLONING)) != 0 && (ITEM_FOURSWORD < itemId)))) || - ((((gPlayerState.jump_status != 0 || (gPlayerEntity.z.WORD != 0)) && (ITEM_FOURSWORD < itemId)) || + ((((gPlayerState.jump_status != 0 || (gPlayerEntity.base.z.WORD != 0)) && (ITEM_FOURSWORD < itemId)) || (((gPlayerState.flags & PL_MINISH) && !gItemDefinitions[itemId].isUseableAsMinish))))) || ((gPlayerState.floor_type == SURFACE_SWAMP && ((gPlayerState.surfaceTimer != 0 && (1 < itemId - 0x14)))))) { return NULL; @@ -406,7 +405,7 @@ void ResetActiveItems() { gPlayerState.heldObject = 0; gPlayerState.flags &= ~(PL_ROLLING | PL_SWORD_THRUST); - gNewPlayerEntity.unk_70 = NULL; + gPlayerEntity.unk_70 = NULL; if ((gPlayerState.jump_status & 0xc0) == 0) { gPlayerState.jump_status = 0; @@ -519,7 +518,7 @@ void sub_08077D38(ItemBehavior* this, u32 index) { gPlayerState.field_0xa |= 8 >> index; gPlayerState.keepFacing |= 8 >> index; - this->playerAnimationState = gPlayerEntity.animationState; + this->playerAnimationState = gPlayerEntity.base.animationState; if (this->stateID == 0) { this->stateID++; } @@ -564,26 +563,26 @@ void SetItemAnim(ItemBehavior* this, u32 animIndex) { if ((animIndex & 0xff) > 0xb8) { animIndex += this->playerAnimationState >> 1; } - gPlayerEntity.spriteIndex = (s16)(animIndex >> 8); - InitAnimationForceUpdate(&gPlayerEntity, (u8)animIndex); + gPlayerEntity.base.spriteIndex = (s16)(animIndex >> 8); + InitAnimationForceUpdate(&gPlayerEntity.base, (u8)animIndex); sub_08077E54(this); } void UpdateItemAnim(ItemBehavior* this) { - UpdateAnimationSingleFrame(&gPlayerEntity); + UpdateAnimationSingleFrame(&gPlayerEntity.base); sub_08077E54(this); } void sub_08077E3C(ItemBehavior* this, u32 index) { - sub_080042BA(&gPlayerEntity, index); + sub_080042BA(&gPlayerEntity.base, index); sub_08077E54(this); } static void sub_08077E54(ItemBehavior* this) { - this->playerAnimIndex = gPlayerEntity.animIndex; - this->playerFrameIndex = gPlayerEntity.frameIndex; - this->playerFrameDuration = gPlayerEntity.frameDuration; - this->playerFrame = gPlayerEntity.frame; + this->playerAnimIndex = gPlayerEntity.base.animIndex; + this->playerFrameIndex = gPlayerEntity.base.frameIndex; + this->playerFrameDuration = gPlayerEntity.base.frameDuration; + this->playerFrame = gPlayerEntity.base.frame; } void DeleteItemBehavior(ItemBehavior* this, u32 index) { @@ -878,16 +877,16 @@ const u16 gUnk_0811C466[] = { 803, 819, 822, 825, 820, 828, 826, 829, 821, 823, void sub_08077F84(void) { Entity* obj; - if ((gPlayerEntity.collisionLayer & 2) == 0) { - u32 tile = GetTileTypeByPos(gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI - 12, 2); + if ((gPlayerEntity.base.collisionLayer & 2) == 0) { + u32 tile = GetTileTypeByPos(gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI - 12, 2); if (tile == 0x343 || tile == 0x344 || tile == 0x345 || tile == 0x346) { - sub_0807AA80(&gPlayerEntity); + sub_0807AA80(&gPlayerEntity.base); gPlayerState.jump_status |= 8; obj = CreateObject(ROTATING_TRAPDOOR, 0, 0); if (obj != NULL) { - obj->x = gPlayerEntity.x; - obj->y.HALF.HI = gPlayerEntity.y.HALF.HI - 0xc; - gPlayerEntity.y.HALF.HI -= 0xc; + obj->x = gPlayerEntity.base.x; + obj->y.HALF.HI = gPlayerEntity.base.y.HALF.HI - 0xc; + gPlayerEntity.base.y.HALF.HI -= 0xc; } } } @@ -986,7 +985,7 @@ bool32 sub_08078140(ChargeState* info) { void ForceSetPlayerState(u32 framestate) { gPlayerState.framestate = framestate; - gPlayerEntity.flags &= ~ENT_COLLIDE; + gPlayerEntity.base.flags &= ~ENT_COLLIDE; PausePlayer(); } @@ -1105,7 +1104,7 @@ bool32 sub_080782C0(void) { if (gPlayerState.heldObject != 4) { return FALSE; } - if ((gNewPlayerEntity.unk_74)->child->kind != OBJECT || (gNewPlayerEntity.unk_74)->child->id != SHOP_ITEM) { + if ((gPlayerEntity.unk_74)->child->kind != OBJECT || (gPlayerEntity.unk_74)->child->id != SHOP_ITEM) { return FALSE; } } @@ -1204,14 +1203,14 @@ InteractableObject* sub_080784E4(void) { if (HasDungeonBigKey()) { r7 |= PL_FLAGS2; } - interactOffsets = (s8*)gPlayerInteractHitboxOffsetNormal + (gPlayerEntity.animationState & 6); + interactOffsets = (s8*)gPlayerInteractHitboxOffsetNormal + (gPlayerEntity.base.animationState & 6); } else { - interactOffsets = (s8*)gPlayerInteractHitboxOffsetMinish + (gPlayerEntity.animationState & 6); + interactOffsets = (s8*)gPlayerInteractHitboxOffsetMinish + (gPlayerEntity.base.animationState & 6); r7 = 0; } - interactX = gPlayerEntity.x.HALF.HI + interactOffsets[0]; - interactY = gPlayerEntity.y.HALF.HI + interactOffsets[1]; + interactX = gPlayerEntity.base.x.HALF.HI + interactOffsets[0]; + interactY = gPlayerEntity.base.y.HALF.HI + interactOffsets[1]; for (index = 0; index < 0x20; index++) { iObject = gInteractableObjects + index; @@ -1220,8 +1219,8 @@ InteractableObject* sub_080784E4(void) { continue; if (entity->interactType < 0) break; - if (((iObject->ignoreLayer & 1) == 0 && (gPlayerEntity.collisionLayer & entity->collisionLayer) == 0) || - (iObject->interactDirections >> (gPlayerEntity.animationState >> 1) & 1) != 0) + if (((iObject->ignoreLayer & 1) == 0 && (gPlayerEntity.base.collisionLayer & entity->collisionLayer) == 0) || + (iObject->interactDirections >> (gPlayerEntity.base.animationState >> 1) & 1) != 0) continue; switch (iObject->type) { case INTERACTION_NONE: @@ -1433,7 +1432,7 @@ u32 sub_080789A8(void) { return (u32)gCarriedEntity.unk_1; if (!(gPlayerState.flags & PL_MINISH)) { - uVar4 = sub_080B1B0C(&gPlayerEntity); + uVar4 = sub_080B1B0C(&gPlayerEntity.base); if (uVar4 >= 0x10 && (gUnk_080084BC[uVar4 - 0x10] == 0xf)) return 0; if (gPlayerState.floor_type == 0x12) @@ -1443,11 +1442,11 @@ u32 sub_080789A8(void) { uVar4 = (u32)gCarriedEntity.count; if (uVar4 > 0) { - ptr2 = &gUnk_0811BFE0[gPlayerEntity.animationState & 6]; + ptr2 = &gUnk_0811BFE0[gPlayerEntity.base.animationState & 6]; while (uVar4 > 0) { tmp1 = &gCarriedEntity.unk_8 + uVar4; entity = *tmp1; - if ((entity != NULL) && (sub_0807A180(&gPlayerEntity, entity, ptr2[0], ptr2[1]) != 0)) { + if ((entity != NULL) && (sub_0807A180(&gPlayerEntity.base, entity, ptr2[0], ptr2[1]) != 0)) { gCarriedEntity.unk_8 = *tmp1; gCarriedEntity.unk_1 = 2; return 2; @@ -1456,8 +1455,8 @@ u32 sub_080789A8(void) { } } - ptr = &gUnk_08007DF4[gPlayerEntity.animationState & 6]; - gCarriedEntity.unk_4 = uVar2 = sub_080B1A0C(&gPlayerEntity, (s8)ptr[0], (s8)ptr[1]); + ptr = &gUnk_08007DF4[gPlayerEntity.base.animationState & 6]; + gCarriedEntity.unk_4 = uVar2 = sub_080B1A0C(&gPlayerEntity.base, (s8)ptr[0], (s8)ptr[1]); if (!sub_0806FC24(uVar2, 6)) return 0; @@ -1497,9 +1496,9 @@ void SetPlayerItemGetState(Entity* item, u8 param_2, u8 param_3) { gPlayerState.framestate = PL_STATE_ITEMGET; gPlayerState.swim_state = 0; gPlayerState.field_0x14 = 1; - gPlayerEntity.child = item; - gPlayerEntity.flags &= ~ENT_COLLIDE; - gPlayerEntity.updatePriority = 2; + gPlayerEntity.base.child = item; + gPlayerEntity.base.flags &= ~ENT_COLLIDE; + gPlayerEntity.base.updatePriority = 2; DeleteClones(); } @@ -1524,7 +1523,7 @@ void PausePlayer(void) { } break; } - gPlayerEntity.iframes = -2; + gPlayerEntity.base.iframes = -2; gPlayerState.field_0x8a = 2; } @@ -1605,26 +1604,26 @@ void sub_08078D60(void) { Entity* iVar4; Entity* player; - player = &gPlayerEntity; + player = &gPlayerEntity.base; iVar4 = (*(Entity**)&((GenericEntity*)player)->field_0x74)->child; if (iVar4->action != 2) return; - iVar4->z.HALF.HI = gPlayerEntity.spriteOffsetY + gPlayerEntity.z.HALF.HI; - iVar4->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; - iVar4->collisionLayer = gPlayerEntity.collisionLayer; - uVar3 = gPlayerEntity.frame & 0x7f; + iVar4->z.HALF.HI = gPlayerEntity.base.spriteOffsetY + gPlayerEntity.base.z.HALF.HI; + iVar4->spriteOrientation.flipY = gPlayerEntity.base.spriteOrientation.flipY; + iVar4->collisionLayer = gPlayerEntity.base.collisionLayer; + uVar3 = gPlayerEntity.base.frame & 0x7f; puVar2 = gUnk_0811C0E8[iVar4->carryFlags >> 4]; - if (gPlayerEntity.spriteSettings.flipX) { - iVar4->x.HALF.HI = gPlayerEntity.x.HALF.HI - puVar2[uVar3]; + if (gPlayerEntity.base.spriteSettings.flipX) { + iVar4->x.HALF.HI = gPlayerEntity.base.x.HALF.HI - puVar2[uVar3]; } else { - iVar4->x.HALF.HI = gPlayerEntity.x.HALF.HI + puVar2[uVar3]; + iVar4->x.HALF.HI = gPlayerEntity.base.x.HALF.HI + puVar2[uVar3]; } iVar4->z.HALF.HI = puVar2[uVar3 + 1] + iVar4->z.HALF.HI; - iVar4->y.HALF.HI = gPlayerEntity.y.HALF.HI; - SortEntityAbove(&gPlayerEntity, iVar4); + iVar4->y.HALF.HI = gPlayerEntity.base.y.HALF.HI; + SortEntityAbove(&gPlayerEntity.base, iVar4); if (gPlayerState.heldObject == 4) { - iVar4->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; + iVar4->spriteRendering.b3 = gPlayerEntity.base.spriteRendering.b3; sub_0806F8DC(iVar4); if ((iVar4->carryFlags & 0xf) == 2) { switch (gRoomTransition.frameCount & 3) { @@ -1637,20 +1636,20 @@ void sub_08078D60(void) { } } } else { - if (gPlayerEntity.animationState >> 1 != 0) { - iVar4->spritePriority.b0 = gPlayerEntity.spritePriority.b0 - 1; + if (gPlayerEntity.base.animationState >> 1 != 0) { + iVar4->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0 - 1; } else { - iVar4->spritePriority.b0 = gPlayerEntity.spritePriority.b0 + 1; + iVar4->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0 + 1; } } } void sub_08078E84(Entity* param_1, Entity* param_2) { SpriteFrame* frame; - if (param_2 == &gPlayerEntity) { + if (param_2 == &gPlayerEntity.base) { sub_08079BD8(param_1); - param_1->spriteOffsetX = gPlayerEntity.spriteOffsetX; - param_1->spriteOffsetY = gPlayerEntity.spriteOffsetY; + param_1->spriteOffsetX = gPlayerEntity.base.spriteOffsetX; + param_1->spriteOffsetY = gPlayerEntity.base.spriteOffsetY; } frame = &gSpritePtrs[(u16)param_2->spriteIndex].frames[param_2->frameIndex]; if (frame->unk_1 != 0) { @@ -1661,18 +1660,18 @@ void sub_08078E84(Entity* param_1, Entity* param_2) { } void ResetPlayerPosition(void) { - gPlayerEntity.x.HALF.HI = gPlayerState.startPosX; - gPlayerEntity.y.HALF.HI = gPlayerState.startPosY; + gPlayerEntity.base.x.HALF.HI = gPlayerState.startPosX; + gPlayerEntity.base.y.HALF.HI = gPlayerState.startPosY; } bool32 CheckQueuedAction(void) { if (gPlayerState.queued_action == PLAYER_INIT) { return FALSE; } else { - gPlayerEntity.action = gPlayerState.queued_action; - gPlayerEntity.subAction = 0; + gPlayerEntity.base.action = gPlayerState.queued_action; + gPlayerEntity.base.subAction = 0; gPlayerState.queued_action = PLAYER_INIT; - DoPlayerAction(&gPlayerEntity); + DoPlayerAction(&gPlayerEntity.base); return TRUE; } } @@ -1816,7 +1815,7 @@ void sub_080790E4(Entity* this) { void PlayerDropHeldObject(void) { gPlayerState.heldObject = 0; gPlayerState.grab_status = 0; - gNewPlayerEntity.unk_74 = NULL; + gPlayerEntity.unk_74 = NULL; } void PlayerResetStateFromFusion(void) { @@ -1828,17 +1827,17 @@ void PlayerResetStateFromFusion(void) { } void SetPlayerActionNormal(void) { - gPlayerEntity.action = PLAYER_NORMAL; - gPlayerEntity.subAction = 0; - gPlayerEntity.subtimer = 0; + gPlayerEntity.base.action = PLAYER_NORMAL; + gPlayerEntity.base.subAction = 0; + gPlayerEntity.base.subtimer = 0; } void ResetPlayerAnimationAndAction(void) { if (!(gPlayerState.flags & PL_HIDDEN)) { - gPlayerEntity.spriteSettings.draw = 3; + gPlayerEntity.base.spriteSettings.draw = 3; } if (!(gPlayerState.flags & PL_MINISH)) { - gPlayerEntity.spritePriority.b1 = 1; + gPlayerEntity.base.spritePriority.b1 = 1; PlayerSetNormalAndCollide(); } else { PlayerMinishSetNormalAndCollide(); @@ -1846,40 +1845,40 @@ void ResetPlayerAnimationAndAction(void) { } void PlayerSetNormalAndCollide(void) { - gPlayerEntity.flags |= ENT_COLLIDE; - gPlayerEntity.spriteSettings.draw = 3; + gPlayerEntity.base.flags |= ENT_COLLIDE; + gPlayerEntity.base.spriteSettings.draw = 3; gPlayerState.flags &= ~(PL_BUSY | PL_DROWNING | PL_DISABLE_ITEMS | PL_FROZEN | PL_ROLLING | PL_IN_HOLE | PL_MOLDWORM_RELEASED | PL_PARACHUTE); ResolvePlayerAnimation(); SetPlayerActionNormal(); - SetEntityPriorityForKind(&gPlayerEntity); + SetEntityPriorityForKind(&gPlayerEntity.base); } void PlayerMinishSetNormalAndCollide(void) { if (!(gPlayerState.flags & PL_HIDDEN)) { - gPlayerEntity.flags |= ENT_COLLIDE; - gPlayerEntity.spriteSettings.draw = 3; + gPlayerEntity.base.flags |= ENT_COLLIDE; + gPlayerEntity.base.spriteSettings.draw = 3; } - gPlayerEntity.action = PLAYER_MINISH; - gPlayerEntity.subAction = 1; - gPlayerEntity.collisionFlags &= 0xfb; + gPlayerEntity.base.action = PLAYER_MINISH; + gPlayerEntity.base.subAction = 1; + gPlayerEntity.base.collisionFlags &= 0xfb; gPlayerState.animation = ANIM_BOUNCE_MINISH; gPlayerState.flags &= ~(PL_BUSY | PL_DROWNING | PL_DISABLE_ITEMS | PL_IN_HOLE | PL_MOLDWORM_RELEASED | PL_PARACHUTE); gPlayerState.swim_state = 0; gPlayerState.queued_action = PLAYER_INIT; - SetEntityPriorityForKind(&gPlayerEntity); + SetEntityPriorityForKind(&gPlayerEntity.base); } void sub_080792BC(s32 speed, u32 direction, u32 field_0x38) { gPlayerState.queued_action = PLAYER_08072454; gPlayerState.field_0x38 = field_0x38; - gPlayerEntity.speed = speed; - gPlayerEntity.direction = direction; + gPlayerEntity.base.speed = speed; + gPlayerEntity.base.direction = direction; } void sub_080792D8(void) { - Entity* playerEntity = &gPlayerEntity; + Entity* playerEntity = &gPlayerEntity.base; if (playerEntity->knockbackDuration == 0) return; @@ -1919,13 +1918,13 @@ void sub_080792D8(void) { bool32 sub_080793E4(u32 param_1) { u32 tmp; if (!gPlayerState.swim_state) { - tmp = gUnk_0811C0F8[gPlayerEntity.animationState >> 1]; + tmp = gUnk_0811C0F8[gPlayerEntity.base.animationState >> 1]; } else { - tmp = gUnk_0811C0F8[gPlayerEntity.direction >> 2]; + tmp = gUnk_0811C0F8[gPlayerEntity.base.direction >> 2]; } if (sub_08079778() && (gPlayerState.playerInput.heldInput & tmp)) { if (param_1 != 0) { - if (!sub_080B1BA4(GetPlayerTilePos(), gPlayerEntity.collisionLayer, param_1)) { + if (!sub_080B1BA4(GetPlayerTilePos(), gPlayerEntity.base.collisionLayer, param_1)) { return FALSE; } } @@ -1936,7 +1935,7 @@ bool32 sub_080793E4(u32 param_1) { } void RespawnPlayer(void) { - Entity* player = &gPlayerEntity; + Entity* player = &gPlayerEntity.base; player->action = PLAYER_080728AC; player->z.WORD = 0; player->zVelocity = 0; @@ -1950,16 +1949,18 @@ void RespawnPlayer(void) { u32 i; for (i = 0; i <= 0xf && gPlayerState.path_memory[i] != -1; i++) { if (sub_080B1B44((u16)gPlayerState.path_memory[i], gPlayerState.path_memory[i] >> 0x1e) != 0xf) { - gPlayerEntity.collisionLayer = gPlayerState.path_memory[i] >> 0x1e; - gPlayerEntity.x.HALF.HI = gRoomControls.origin_x + (gPlayerState.path_memory[i] & 0x3f) * 16 + 8; - gPlayerEntity.y.HALF.HI = gRoomControls.origin_y + (gPlayerState.path_memory[i] & 0xfc0) / 4 + 8; - COLLISION_ON(&gPlayerEntity); + gPlayerEntity.base.collisionLayer = gPlayerState.path_memory[i] >> 0x1e; + gPlayerEntity.base.x.HALF.HI = + gRoomControls.origin_x + (gPlayerState.path_memory[i] & 0x3f) * 16 + 8; + gPlayerEntity.base.y.HALF.HI = + gRoomControls.origin_y + (gPlayerState.path_memory[i] & 0xfc0) / 4 + 8; + COLLISION_ON(&gPlayerEntity.base); break; } } } } - UpdateSpriteForCollisionLayer(&gPlayerEntity); + UpdateSpriteForCollisionLayer(&gPlayerEntity.base); } void sub_08079520(Entity* this) { @@ -1985,38 +1986,39 @@ bool32 sub_08079550(void) { if (!gDiggingCaveEntranceTransition.isDiggingCave) { if ((!gPlayerState.dash_state || (gPlayerState.flags & PL_BURNING)) && (gPlayerState.swim_state || (gPlayerState.sword_state & 0x40) || - gPlayerEntity.direction != gPlayerState.direction || (gPlayerEntity.direction & DIR_NOT_MOVING_CHECK))) { - gPlayerEntity.subtimer = 0; + gPlayerEntity.base.direction != gPlayerState.direction || + (gPlayerEntity.base.direction & DIR_NOT_MOVING_CHECK))) { + gPlayerEntity.base.subtimer = 0; return FALSE; } if (sub_08079778()) { - ptr = &gUnk_0811C100[gPlayerEntity.animationState & 6]; - if ((gPlayerEntity.animationState & 2) != 0) { - tilePos1 = COORD_TO_TILE_OFFSET(&gPlayerEntity, -ptr[0], -(gPlayerEntity.hitbox)->unk2[1]); - tilePos2 = COORD_TO_TILE_OFFSET(&gPlayerEntity, -ptr[0], +(gPlayerEntity.hitbox)->unk2[1]); + ptr = &gUnk_0811C100[gPlayerEntity.base.animationState & 6]; + if ((gPlayerEntity.base.animationState & 2) != 0) { + tilePos1 = COORD_TO_TILE_OFFSET(&gPlayerEntity.base, -ptr[0], -(gPlayerEntity.base.hitbox)->unk2[1]); + tilePos2 = COORD_TO_TILE_OFFSET(&gPlayerEntity.base, -ptr[0], +(gPlayerEntity.base.hitbox)->unk2[1]); } else { - tilePos1 = COORD_TO_TILE_OFFSET(&gPlayerEntity, -(gPlayerEntity.hitbox)->unk2[2], -ptr[1]); - tilePos2 = COORD_TO_TILE_OFFSET(&gPlayerEntity, (gPlayerEntity.hitbox)->unk2[2], -ptr[1]); + tilePos1 = COORD_TO_TILE_OFFSET(&gPlayerEntity.base, -(gPlayerEntity.base.hitbox)->unk2[2], -ptr[1]); + tilePos2 = COORD_TO_TILE_OFFSET(&gPlayerEntity.base, (gPlayerEntity.base.hitbox)->unk2[2], -ptr[1]); } - uVar3 = sub_080B1AE0(tilePos1, gPlayerEntity.collisionLayer); - uVar3 = sub_08007DD6(uVar3, gUnk_0811C1E8[gPlayerEntity.animationState >> 1]); + uVar3 = sub_080B1AE0(tilePos1, gPlayerEntity.base.collisionLayer); + uVar3 = sub_08007DD6(uVar3, gUnk_0811C1E8[gPlayerEntity.base.animationState >> 1]); if (uVar3 != 0) { - uVar3 = sub_080B1AE0(tilePos2, gPlayerEntity.collisionLayer); - uVar3 = sub_08007DD6(uVar3, gUnk_0811C1E8[gPlayerEntity.animationState >> 1]); + uVar3 = sub_080B1AE0(tilePos2, gPlayerEntity.base.collisionLayer); + uVar3 = sub_08007DD6(uVar3, gUnk_0811C1E8[gPlayerEntity.base.animationState >> 1]); if (uVar3 != 0) { gPlayerState.pushedObject |= 0x80; - if (gPlayerState.dash_state == 0 && (++gPlayerEntity.subtimer <= 5)) { + if (gPlayerState.dash_state == 0 && (++gPlayerEntity.base.subtimer <= 5)) { return FALSE; } - gPlayerEntity.animationState = uVar3 - 1; - gPlayerEntity.action = 4; - gPlayerEntity.subAction = 0; - COLLISION_OFF(&gPlayerEntity); + gPlayerEntity.base.animationState = uVar3 - 1; + gPlayerEntity.base.action = 4; + gPlayerEntity.base.subAction = 0; + COLLISION_OFF(&gPlayerEntity.base); gPlayerState.jump_status = 0x81; - DoPlayerAction(&gPlayerEntity); + DoPlayerAction(&gPlayerEntity.base); return TRUE; } } @@ -2060,16 +2062,16 @@ void sub_08079744(Entity* this) { bool32 sub_08079778(void) { u32 tmp; if (!gPlayerState.swim_state) { - tmp = gUnk_0811C108[gPlayerEntity.animationState >> 1]; + tmp = gUnk_0811C108[gPlayerEntity.base.animationState >> 1]; } else { - tmp = gUnk_0811C108[gPlayerEntity.direction >> 2]; + tmp = gUnk_0811C108[gPlayerEntity.base.direction >> 2]; } - return tmp == (gPlayerEntity.collisions & tmp); + return tmp == (gPlayerEntity.base.collisions & tmp); } u32 sub_080797C4(void) { - u32 tmp = gUnk_0811C110[gPlayerEntity.direction >> 3]; - return tmp == (gPlayerEntity.collisions & tmp); + u32 tmp = gUnk_0811C110[gPlayerEntity.base.direction >> 3]; + return tmp == (gPlayerEntity.base.collisions & tmp); } void sub_080797EC(void) { @@ -2096,7 +2098,7 @@ void sub_080797EC(void) { } else { animation = ANIM_SWORD_CHARGE_WALK; if (sub_080793E4(0)) { - if (sub_080B1B44(GetPlayerTilePos(), gPlayerEntity.collisionLayer) != 0xff) { + if (sub_080B1B44(GetPlayerTilePos(), gPlayerEntity.base.collisionLayer) != 0xff) { gPlayerState.sword_state &= ~8; animation = ANIM_SWORD_CHARGE_BUMP; } @@ -2130,7 +2132,7 @@ void sub_080797EC(void) { } else if (gPlayerState.sword_state) { animation = ANIM_SWORD_CHARGE_WALK; if (sub_080793E4(0)) { - if (sub_080B1B44(GetPlayerTilePos(), (u32)gPlayerEntity.collisionLayer) != 0xff) { + if (sub_080B1B44(GetPlayerTilePos(), (u32)gPlayerEntity.base.collisionLayer) != 0xff) { gPlayerState.sword_state &= ~8; animation = ANIM_SWORD_CHARGE_BUMP; } @@ -2152,7 +2154,7 @@ void sub_080797EC(void) { gPlayerState.animation = animation; if (!gPlayerState.shield_status) { - UpdateAnimationSingleFrame(&gPlayerEntity); + UpdateAnimationSingleFrame(&gPlayerEntity.base); } } @@ -2263,28 +2265,28 @@ void ResolvePlayerAnimation(void) { return; } if ((u8)anim == gPlayerState.prevAnim) { - UpdateAnimationSingleFrame(&gPlayerEntity); + UpdateAnimationSingleFrame(&gPlayerEntity.base); } } gPlayerState.prevAnim = anim; } bool32 sub_08079B24(void) { - if ((gPlayerEntity.action != PLAYER_MINISHDIE) && (gPlayerEntity.health == 0)) { + if ((gPlayerEntity.base.action != PLAYER_MINISHDIE) && (gPlayerEntity.base.health == 0)) { gPlayerState.flags &= ~PL_PARACHUTE; - gPlayerEntity.knockbackDuration = gPlayerEntity.health; + gPlayerEntity.base.knockbackDuration = gPlayerEntity.base.health; if (gPlayerState.field_0x7 == 0) { if (gPlayerState.swim_state != 0) { RespawnPlayer(); } else { if ((gPlayerState.field_0x14 == 0) && ((gPlayerState.flags & PL_IN_MINECART) == 0)) { - if (gPlayerEntity.z.HALF.HI < 0) { - if (gPlayerEntity.zVelocity > 0) { - gPlayerEntity.zVelocity = 0; + if (gPlayerEntity.base.z.HALF.HI < 0) { + if (gPlayerEntity.base.zVelocity > 0) { + gPlayerEntity.base.zVelocity = 0; } if ((gPlayerState.jump_status & 0x41) == 0) { gPlayerState.jump_status = 0x41; - gPlayerEntity.direction = DIR_NONE; + gPlayerEntity.base.direction = DIR_NONE; gPlayerState.direction = DIR_NONE; return TRUE; } else { @@ -2297,7 +2299,7 @@ bool32 sub_08079B24(void) { } } } - gPlayerEntity.flags &= ~ENT_COLLIDE; + gPlayerEntity.base.flags &= ~ENT_COLLIDE; return FALSE; } } @@ -2305,13 +2307,13 @@ bool32 sub_08079B24(void) { } void sub_08079BD8(Entity* this) { - this->x = gPlayerEntity.x; - this->y = gPlayerEntity.y; - this->z = gPlayerEntity.z; - this->collisionLayer = gPlayerEntity.collisionLayer; - this->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; - this->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; - this->spritePriority.b0 = gPlayerEntity.spritePriority.b0; + this->x = gPlayerEntity.base.x; + this->y = gPlayerEntity.base.y; + this->z = gPlayerEntity.base.z; + this->collisionLayer = gPlayerEntity.base.collisionLayer; + this->spriteRendering.b3 = gPlayerEntity.base.spriteRendering.b3; + this->spriteOrientation.flipY = gPlayerEntity.base.spriteOrientation.flipY; + this->spritePriority.b0 = gPlayerEntity.base.spritePriority.b0; } bool32 sub_08079C30(Entity* param_1) { @@ -2344,11 +2346,11 @@ bool32 sub_08079C30(Entity* param_1) { } bool32 sub_08079D48(void) { - if (!sub_08079C30(&gPlayerEntity)) { + if (!sub_08079C30(&gPlayerEntity.base)) { return TRUE; } else { if (!PlayerCheckNEastTile()) { - if (!sub_08007DD6((u16)GetTileUnderEntity(&gPlayerEntity), gUnk_0811C268)) { + if (!sub_08007DD6((u16)GetTileUnderEntity(&gPlayerEntity.base), gUnk_0811C268)) { return TRUE; } } @@ -2357,19 +2359,19 @@ bool32 sub_08079D48(void) { } void sub_08079D84(void) { - if ((gPlayerEntity.action == PLAYER_NORMAL) || (gPlayerEntity.action == PLAYER_ROLL)) { + if ((gPlayerEntity.base.action == PLAYER_NORMAL) || (gPlayerEntity.base.action == PLAYER_ROLL)) { gPlayerState.field_0x38 = 0x9c; gPlayerState.field_0x39 = 2; gPlayerState.field_0x3a = 0x3c; gPlayerState.queued_action = PLAYER_0807204C; - gPlayerEntity.iframes = 0x7c; + gPlayerEntity.base.iframes = 0x7c; PutAwayItems(); SoundReq(SFX_193); } } void sub_08079DCC(void) { - if (gPlayerEntity.action == PLAYER_NORMAL) { + if (gPlayerEntity.base.action == PLAYER_NORMAL) { gPlayerState.field_0x38 = 0xa0; gPlayerState.field_0x39 = 3; gPlayerState.field_0x3a = 0; @@ -2379,23 +2381,23 @@ void sub_08079DCC(void) { } void UpdatePlayerMovement(void) { - if ((gPlayerEntity.speed != 0) && - (gPlayerEntity.speed += gPlayerState.speed_modifier, gPlayerEntity.speed < 0x20)) { - gPlayerEntity.speed = 0x20; + if ((gPlayerEntity.base.speed != 0) && + (gPlayerEntity.base.speed += gPlayerState.speed_modifier, gPlayerEntity.base.speed < 0x20)) { + gPlayerEntity.base.speed = 0x20; } - if ((gPlayerEntity.direction & 4) == 0) { - sub_08079E90(gPlayerEntity.direction); + if ((gPlayerEntity.base.direction & 4) == 0) { + sub_08079E90(gPlayerEntity.base.direction); } - sub_0800857C(&gPlayerEntity); - sub_0807A5B8(gPlayerEntity.direction); + sub_0800857C(&gPlayerEntity.base); + sub_0807A5B8(gPlayerEntity.base.direction); } void sub_08079E58(s32 speed, u32 direction) { - if ((gPlayerEntity.direction & 4) == 0) { + if ((gPlayerEntity.base.direction & 4) == 0) { sub_08079E90(direction); } - sub_080085B0(&gPlayerEntity); - sub_080027EA(&gPlayerEntity, (s16)speed, (u8)direction); + sub_080085B0(&gPlayerEntity.base); + sub_080027EA(&gPlayerEntity.base, (s16)speed, (u8)direction); sub_0807A5B8(direction); } @@ -2403,28 +2405,28 @@ bool32 sub_08079E90(u32 param_1) { s16 tmp1; s16 tmp2; - if (gPlayerEntity.direction & DirectionEast) { - if (gPlayerEntity.direction & DirectionSouth) { - tmp2 = -gPlayerEntity.hitbox->unk2[0]; + if (gPlayerEntity.base.direction & DirectionEast) { + if (gPlayerEntity.base.direction & DirectionSouth) { + tmp2 = -gPlayerEntity.base.hitbox->unk2[0]; } else { - tmp2 = gPlayerEntity.hitbox->unk2[0]; + tmp2 = gPlayerEntity.base.hitbox->unk2[0]; } - tmp1 = gPlayerEntity.hitbox->unk2[1]; + tmp1 = gPlayerEntity.base.hitbox->unk2[1]; } else { - tmp2 = gPlayerEntity.hitbox->unk2[2]; - if (gPlayerEntity.direction != DirectionNorth) { - tmp1 = gPlayerEntity.hitbox->unk2[3]; + tmp2 = gPlayerEntity.base.hitbox->unk2[2]; + if (gPlayerEntity.base.direction != DirectionNorth) { + tmp1 = gPlayerEntity.base.hitbox->unk2[3]; } else { - tmp1 = -gPlayerEntity.hitbox->unk2[3]; + tmp1 = -gPlayerEntity.base.hitbox->unk2[3]; } } - if (!sub_08079F48(param_1, sub_080B1AF0(&gPlayerEntity, tmp2, tmp1))) { - if ((gPlayerEntity.direction & DirectionSouth) != 0) { + if (!sub_08079F48(param_1, sub_080B1AF0(&gPlayerEntity.base, tmp2, tmp1))) { + if ((gPlayerEntity.base.direction & DirectionSouth) != 0) { tmp1 = -tmp1; } else { tmp2 = -tmp2; } - if (!sub_08079F48(param_1, sub_080B1AF0(&gPlayerEntity, tmp2, tmp1))) { + if (!sub_08079F48(param_1, sub_080B1AF0(&gPlayerEntity.base, tmp2, tmp1))) { return FALSE; } } @@ -2433,12 +2435,12 @@ bool32 sub_08079E90(u32 param_1) { bool32 sub_08079F48(u32 param_1, u32 param_2) { if (gUnk_0811C118[param_1 >> 2] == param_2) { - gPlayerEntity.direction = (gPlayerEntity.direction + 4) & 0x1f; + gPlayerEntity.base.direction = (gPlayerEntity.base.direction + 4) & 0x1f; } else { if (gUnk_0811C118[(param_1 >> 2) + 1] != param_2) { return FALSE; } - gPlayerEntity.direction = (gPlayerEntity.direction - 4) & 0x1f; + gPlayerEntity.base.direction = (gPlayerEntity.base.direction - 4) & 0x1f; } return TRUE; @@ -2448,8 +2450,8 @@ bool32 PlayerCanBeMoved(void) { if ((gPlayerState.flags & (PL_BUSY | PL_DROWNING | PL_CAPTURED | PL_USE_PORTAL | PL_HIDDEN | PL_FROZEN | PL_FALLING | PL_DISABLE_ITEMS | PL_PIT_IS_EXIT | PL_IN_MINECART | PL_MOLDWORM_CAPTURED | PL_IN_HOLE | PL_CONVEYOR_PUSHED | PL_CLIMBING)) != 0 || - gPlayerState.field_0x3c != 0 || gPlayerEntity.action == PLAYER_FALL || - gPlayerEntity.action == PLAYER_08071DB8) { + gPlayerState.field_0x3c != 0 || gPlayerEntity.base.action == PLAYER_FALL || + gPlayerEntity.base.action == PLAYER_08071DB8) { return FALSE; } else { return TRUE; @@ -2457,7 +2459,7 @@ bool32 PlayerCanBeMoved(void) { } u32 sub_08079FC4(u32 param_1) { - return sub_08079FD4(&gPlayerEntity, param_1); + return sub_08079FD4(&gPlayerEntity.base, param_1); } u32 sub_08079FD4(Entity* this, u32 param_2) { @@ -2499,7 +2501,7 @@ void UpdatePlayerPalette(void) { palette = GetPlayerPalette(FALSE); if (palette != gPlayerState.playerPalette) { gPlayerState.playerPalette = palette; - ChangeObjPalette(&gPlayerEntity, palette); + ChangeObjPalette(&gPlayerEntity.base, palette); } } @@ -2541,7 +2543,7 @@ void DeleteClones(void) { gPlayerClones[1] = NULL; gPlayerClones[2] = NULL; gPlayerState.flags &= ~PL_CLONING; - if (((gPlayerEntity.action != PLAYER_ROOMTRANSITION) || (gPlayerState.chargeState.action != 4)) && + if (((gPlayerEntity.base.action != PLAYER_ROOMTRANSITION) || (gPlayerState.chargeState.action != 4)) && (gPlayerState.chargeState.action == 4 || gPlayerState.chargeState.action == 5)) { gPlayerState.chargeState.action = 1; } @@ -2563,13 +2565,13 @@ u32 sub_0807A180(Entity* param_1, Entity* param_2, u32 param_3, u32 param_4) { } void UpdateFloorType(void) { - gPlayerState.floor_type = GetSurfaceCalcType(&gPlayerEntity, 0, 0); - gUnk_0811C120[gPlayerState.floor_type](&gPlayerEntity); + gPlayerState.floor_type = GetSurfaceCalcType(&gPlayerEntity.base, 0, 0); + gUnk_0811C120[gPlayerState.floor_type](&gPlayerEntity.base); } SurfaceType GetSurfaceCalcType(Entity* param_1, s32 x, s32 y) { u32 position = TILE(param_1->x.HALF.HI + (u32)x, param_1->y.HALF.HI + y); - u32 tileType = GetTileTypeByPos(param_1->x.HALF.HI + x, param_1->y.HALF.HI + y, gPlayerEntity.collisionLayer); + u32 tileType = GetTileTypeByPos(param_1->x.HALF.HI + x, param_1->y.HALF.HI + y, gPlayerEntity.base.collisionLayer); if (tileType != gPlayerState.tileType) { gPlayerState.surfaceTimer = 0; } @@ -2600,8 +2602,8 @@ bool32 sub_0807A2B8(void) { if (PlayerCheckNEastTile()) { return TRUE; } else { - if (((gPlayerState.jump_status & 200) == 0) && (gPlayerEntity.collisionLayer != 1)) { - CreateObjectWithParent(&gPlayerEntity, ROTATING_TRAPDOOR, 0, 0); + if (((gPlayerState.jump_status & 200) == 0) && (gPlayerEntity.base.collisionLayer != 1)) { + CreateObjectWithParent(&gPlayerEntity.base, ROTATING_TRAPDOOR, 0, 0); } return FALSE; } @@ -2617,32 +2619,32 @@ u32 sub_0807A2F8(u32 param_1) { if ((gRoomControls.area == 8) || (sub_08079778() | param_1) == 0) return 0; - if ((gPlayerEntity.animationState & 2) != 0) { + if ((gPlayerEntity.base.animationState & 2) != 0) { - uVar2 = COORD_TO_TILE_OFFSET(&gPlayerEntity, 0, -gPlayerEntity.hitbox->unk2[3]) << 1; - uVar1 = COORD_TO_TILE_OFFSET(&gPlayerEntity, 0, gPlayerEntity.hitbox->unk2[3]) << 1; + uVar2 = COORD_TO_TILE_OFFSET(&gPlayerEntity.base, 0, -gPlayerEntity.base.hitbox->unk2[3]) << 1; + uVar1 = COORD_TO_TILE_OFFSET(&gPlayerEntity.base, 0, gPlayerEntity.base.hitbox->unk2[3]) << 1; } else { - uVar2 = COORD_TO_TILE_OFFSET(&gPlayerEntity, -gPlayerEntity.hitbox->unk2[0], 0) << 1; - uVar1 = COORD_TO_TILE_OFFSET(&gPlayerEntity, gPlayerEntity.hitbox->unk2[0], 0) << 1; + uVar2 = COORD_TO_TILE_OFFSET(&gPlayerEntity.base, -gPlayerEntity.base.hitbox->unk2[0], 0) << 1; + uVar1 = COORD_TO_TILE_OFFSET(&gPlayerEntity.base, gPlayerEntity.base.hitbox->unk2[0], 0) << 1; } for (uVar5 = 0; uVar5 < 2; uVar5++) { iVar4 = 0; - uVar2 = sub_08004202(&gPlayerEntity, auStack36, uVar2); + uVar2 = sub_08004202(&gPlayerEntity.base, auStack36, uVar2); if (sub_080B1B44(uVar2 >> 1, 1)) { - if (!sub_08007DD6((u16)sub_080B1AE0((u16)(uVar2 >> 1), gPlayerEntity.collisionLayer), - gUnk_0811C1D8[gPlayerEntity.animationState >> 1])) { + if (!sub_08007DD6((u16)sub_080B1AE0((u16)(uVar2 >> 1), gPlayerEntity.base.collisionLayer), + gUnk_0811C1D8[gPlayerEntity.base.animationState >> 1])) { break; } } else { iVar4 = 1; } - uVar1 = sub_08004202(&gPlayerEntity, auStack36, uVar1); + uVar1 = sub_08004202(&gPlayerEntity.base, auStack36, uVar1); if (sub_080B1B44(uVar1 >> 1, 1)) { - if (!sub_08007DD6((u16)sub_080B1AE0((uVar1 >> 1), gPlayerEntity.collisionLayer), - gUnk_0811C1D8[gPlayerEntity.animationState >> 1])) { + if (!sub_08007DD6((u16)sub_080B1AE0((uVar1 >> 1), gPlayerEntity.base.collisionLayer), + gUnk_0811C1D8[gPlayerEntity.base.animationState >> 1])) { break; } } else { @@ -2658,9 +2660,9 @@ u32 sub_0807A2F8(u32 param_1) { } if (uVar5 != 0) { if (AreaIsDungeon()) { - uVar2 = sub_08004202(&gPlayerEntity, auStack36, uVar2); + uVar2 = sub_08004202(&gPlayerEntity.base, auStack36, uVar2); if (!sub_080B1B44(uVar2 >> 1, 2)) { - uVar1 = sub_08004202(&gPlayerEntity, auStack36, uVar1); + uVar1 = sub_08004202(&gPlayerEntity.base, auStack36, uVar1); if (sub_080B1B44(uVar1 >> 1, 2)) { return 0; } @@ -2669,11 +2671,11 @@ u32 sub_0807A2F8(u32 param_1) { } } else { if (uVar5 == 2) { - uVar2 = sub_08004202(&gPlayerEntity, auStack36, uVar2); + uVar2 = sub_08004202(&gPlayerEntity.base, auStack36, uVar2); } if (sub_080B1B44(uVar2 >> 1, 1) == 0) { if (uVar5 == 2) { - uVar1 = sub_08004202(&gPlayerEntity, auStack36, uVar1); + uVar1 = sub_08004202(&gPlayerEntity.base, auStack36, uVar1); } if (sub_080B1B44(uVar1 >> 1, 1)) { return 0; @@ -2689,18 +2691,21 @@ u32 sub_0807A2F8(u32 param_1) { } u32 GetPlayerTilePos(void) { - switch (gPlayerEntity.animationState >> 1) { + switch (gPlayerEntity.base.animationState >> 1) { case 0: - return TILE(gPlayerEntity.x.HALF.HI, - gPlayerEntity.y.HALF.HI - gPlayerEntity.hitbox->unk2[3] + gPlayerEntity.hitbox->offset_y); + return TILE(gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI - + gPlayerEntity.base.hitbox->unk2[3] + + gPlayerEntity.base.hitbox->offset_y); case 2: - return TILE(gPlayerEntity.x.HALF.HI, - gPlayerEntity.y.HALF.HI + gPlayerEntity.hitbox->unk2[3] + gPlayerEntity.hitbox->offset_y); + return TILE(gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI + + gPlayerEntity.base.hitbox->unk2[3] + + gPlayerEntity.base.hitbox->offset_y); case 1: - return COORD_TO_TILE_OFFSET(&gPlayerEntity, -gPlayerEntity.hitbox->unk2[0], - -gPlayerEntity.hitbox->offset_y); + return COORD_TO_TILE_OFFSET(&gPlayerEntity.base, -gPlayerEntity.base.hitbox->unk2[0], + -gPlayerEntity.base.hitbox->offset_y); case 3: - return COORD_TO_TILE_OFFSET(&gPlayerEntity, gPlayerEntity.hitbox->unk2[0], -gPlayerEntity.hitbox->offset_y); + return COORD_TO_TILE_OFFSET(&gPlayerEntity.base, gPlayerEntity.base.hitbox->unk2[0], + -gPlayerEntity.base.hitbox->offset_y); default: return 0; } @@ -2726,26 +2731,30 @@ void sub_0807A5B8(u32 direction) { } if (direction != DirectionNorth && direction != DirectionSouth) { - uVar3 = (gPlayerEntity.x.HALF.HI + (gPlayerEntity.hitbox)->unk2[0] + (gPlayerEntity.hitbox)->offset_x) - + uVar3 = (gPlayerEntity.base.x.HALF.HI + (gPlayerEntity.base.hitbox)->unk2[0] + + (gPlayerEntity.base.hitbox)->offset_x) - gRoomControls.origin_x; - uVar2 = (gPlayerEntity.y.HALF.HI + (gPlayerEntity.hitbox)->offset_y) - gRoomControls.origin_y; + uVar2 = (gPlayerEntity.base.y.HALF.HI + (gPlayerEntity.base.hitbox)->offset_y) - gRoomControls.origin_y; if (sub_080086B4(uVar3, uVar2, pbVar4) != 0) { sub_0807A750(uVar3, uVar2, pbVar4, 1); } - uVar3 = ((gPlayerEntity.x.HALF.HI - (gPlayerEntity.hitbox)->unk2[0]) + (gPlayerEntity.hitbox)->offset_x) - + uVar3 = ((gPlayerEntity.base.x.HALF.HI - (gPlayerEntity.base.hitbox)->unk2[0]) + + (gPlayerEntity.base.hitbox)->offset_x) - gRoomControls.origin_x; if (sub_080086B4(uVar3, uVar2, pbVar4) != 0) { sub_0807A750(uVar3, uVar2, pbVar4, 3); } } if (direction != DirectionEast && direction != DirectionWest) { - uVar3 = (gPlayerEntity.x.HALF.HI + (gPlayerEntity.hitbox)->offset_x) - gRoomControls.origin_x; - uVar2 = (gPlayerEntity.y.HALF.HI + (gPlayerEntity.hitbox)->unk2[3] + (gPlayerEntity.hitbox)->offset_y) - + uVar3 = (gPlayerEntity.base.x.HALF.HI + (gPlayerEntity.base.hitbox)->offset_x) - gRoomControls.origin_x; + uVar2 = (gPlayerEntity.base.y.HALF.HI + (gPlayerEntity.base.hitbox)->unk2[3] + + (gPlayerEntity.base.hitbox)->offset_y) - gRoomControls.origin_y; if (sub_080086B4(uVar3, uVar2, pbVar4) != 0) { sub_0807A750(uVar3, uVar2, pbVar4, 2); } - uVar2 = ((gPlayerEntity.y.HALF.HI - (gPlayerEntity.hitbox)->unk2[3]) + (gPlayerEntity.hitbox)->offset_y) - + uVar2 = ((gPlayerEntity.base.y.HALF.HI - (gPlayerEntity.base.hitbox)->unk2[3]) + + (gPlayerEntity.base.hitbox)->offset_y) - gRoomControls.origin_y; if (sub_080086B4(uVar3, uVar2, pbVar4) != 0) { sub_0807A750(uVar3, uVar2, pbVar4, 0); @@ -2766,7 +2775,7 @@ void sub_0807A750(u32 param_1, u32 param_2, const u8* param_3, u32 param_4) { index = param_1 % 16; } if ((index != 0) && (index != 0xf)) { - uVar2 = sub_080B1B44((param_1 >> 4 & 0x3f) | (param_2 >> 4 & 0x3f) << 6, gPlayerEntity.collisionLayer); + uVar2 = sub_080B1B44((param_1 >> 4 & 0x3f) | (param_2 >> 4 & 0x3f) << 6, gPlayerEntity.base.collisionLayer); if (uVar2 > 0xf) { if (uVar2 != 0xff) { uVar2 = param_3[uVar2 - 0x10]; @@ -2794,7 +2803,7 @@ void sub_0807A750(u32 param_1, u32 param_2, const u8* param_3, u32 param_4) { } index++; } - gPlayerEntity.y.HALF.HI += index - (param_2 % 16); + gPlayerEntity.base.y.HALF.HI += index - (param_2 % 16); } else { uVar5 = ptr[param_2 % 16]; if (param_4 == 1) { @@ -2818,7 +2827,7 @@ void sub_0807A750(u32 param_1, u32 param_2, const u8* param_3, u32 param_4) { } index--; } - gPlayerEntity.x.HALF.HI += (index - (param_1 % 16)); + gPlayerEntity.base.x.HALF.HI += (index - (param_1 % 16)); } } } @@ -2858,20 +2867,20 @@ void sub_0807A8D8(Entity* this) { u32 tmp; if ((gPlayerState.flags & PL_MINISH) == 0) { - tmp = sub_080B1B84(COORD_TO_TILE_OFFSET(this, 0, 1), gPlayerEntity.collisionLayer); + tmp = sub_080B1B84(COORD_TO_TILE_OFFSET(this, 0, 1), gPlayerEntity.base.collisionLayer); if ((tmp & 0x20) != 0) { sub_0807AAF8(this, COORD_TO_TILE_OFFSET(this, 0, 1)); } - tmp = sub_080B1B84(COORD_TO_TILE_OFFSET(this, -2, 0), gPlayerEntity.collisionLayer); + tmp = sub_080B1B84(COORD_TO_TILE_OFFSET(this, -2, 0), gPlayerEntity.base.collisionLayer); if ((tmp & 0x20) != 0) { sub_0807AAF8(this, COORD_TO_TILE_OFFSET(this, -2, 0)); } - tmp = sub_080B1B84(COORD_TO_TILE_OFFSET(this, 2, 0), gPlayerEntity.collisionLayer); + tmp = sub_080B1B84(COORD_TO_TILE_OFFSET(this, 2, 0), gPlayerEntity.base.collisionLayer); if ((tmp & 0x20) != 0) { sub_0807AAF8(this, COORD_TO_TILE_OFFSET(this, 2, 0)); } } - tmp = sub_080B1B84(COORD_TO_TILE(this), gPlayerEntity.collisionLayer); + tmp = sub_080B1B84(COORD_TO_TILE(this), gPlayerEntity.base.collisionLayer); if ((tmp & 0x20) != 0) { sub_0807AAF8(this, COORD_TO_TILE(this)); } @@ -3095,7 +3104,7 @@ void UpdatePlayerSkills(void) { void PlayerShrinkByRay(void) { Entity* effect; PutAwayItems(); - effect = CreateFx(&gPlayerEntity, FX_BIG_EXPLOSION2, 0); + effect = CreateFx(&gPlayerEntity.base, FX_BIG_EXPLOSION2, 0); if (effect != NULL) { effect->y.HALF.HI++; } @@ -3138,10 +3147,10 @@ void sub_0807B068(Entity* entity) { } void sub_0807B0C8(void) { - sub_0806FEBC(&gPlayerEntity, 0, 0); - sub_0806FEBC(&gPlayerEntity, 1, 0); - sub_0806FEBC(&gPlayerEntity, 2, &gPlayerEntity); - sub_0806FEBC(&gPlayerEntity, 3, 0); + sub_0806FEBC(&gPlayerEntity.base, 0, 0); + sub_0806FEBC(&gPlayerEntity.base, 1, 0); + sub_0806FEBC(&gPlayerEntity.base, 2, &gPlayerEntity.base); + sub_0806FEBC(&gPlayerEntity.base, 3, 0); } void PlayerWarp(PlayerEntity* this) { @@ -3209,7 +3218,7 @@ void sub_0807B21C(PlayerEntity* this) { super->timer = 120; super->subtimer = 0; this->unk_6e++; - this->unk_68 = super->z.WORD; + this->unk_68.WORD = super->z.WORD; } } @@ -3220,7 +3229,7 @@ void sub_0807B264(PlayerEntity* this) { tmp = gSineTable[super->subtimer]; tmp >>= 7; tmp <<= 0x10; - super->z.WORD = this->unk_68 + tmp; + super->z.WORD = this->unk_68.WORD + tmp; if (--super->timer == 0) { super->timer = 80; super->zVelocity = Q_16_16(0.5); @@ -3657,7 +3666,7 @@ bool32 sub_0807BD14(Entity* this, u32 scrollDirection) { break; } } - gPlayerEntity.updatePriority = 6; + gPlayerEntity.base.updatePriority = 6; SetInitializationPriority(); return TRUE; } else { @@ -4166,7 +4175,7 @@ void sub_0807C810(void) { RoomControls* ctrls; sub_0807BFD0(); ptr = &gDiggingCaveEntranceTransition; - player = &gPlayerEntity; + player = &gPlayerEntity.base; ctrls = &gRoomControls; player->x.HALF.HI = ((ptr->entrance)->targetTilePosition & 0x3f) * 0x10 + ctrls->origin_x + ptr->offsetX; player->y.HALF.HI = (((ptr->entrance)->targetTilePosition & 0xfc0) >> 2) + ctrls->origin_y + ptr->offsetY; diff --git a/src/projectile/darkNutSwordSlash.c b/src/projectile/darkNutSwordSlash.c index ac30135b..e95ab908 100644 --- a/src/projectile/darkNutSwordSlash.c +++ b/src/projectile/darkNutSwordSlash.c @@ -30,7 +30,7 @@ void DarkNutSwordSlash(Entity* this) { if ((this->parent == NULL) || (this->parent->health == 0)) { DeleteThisEntity(); } - if (((this->contactFlags & 0x80) != 0) && (this->contactedEntity == &gPlayerEntity)) { + if (((this->contactFlags & 0x80) != 0) && (this->contactedEntity == &gPlayerEntity.base)) { this->iframes = -0x2d; } this->contactFlags = 0; diff --git a/src/projectile/dirtBallProjectile.c b/src/projectile/dirtBallProjectile.c index e1cfe8f1..5a56b0d3 100644 --- a/src/projectile/dirtBallProjectile.c +++ b/src/projectile/dirtBallProjectile.c @@ -107,7 +107,7 @@ void DirtBallProjectile_Action1(Entity* this) { break; case 2: this->z.HALF.HI += Q_8_8(1.0 / 16.0 - 1.0 / 128.0); - if (EntityInRectRadius(this, &gPlayerEntity, 0xe, 0xe) != 0) { + if (EntityInRectRadius(this, &gPlayerEntity.base, 0xe, 0xe) != 0) { this->action = 2; ((DirtBallProjectileEntity*)parent)->unk_83 = 0xc0; } diff --git a/src/projectile/gleerokProjectile.c b/src/projectile/gleerokProjectile.c index f42d8e17..ed957966 100644 --- a/src/projectile/gleerokProjectile.c +++ b/src/projectile/gleerokProjectile.c @@ -54,7 +54,7 @@ void GleerokProjectile_Init(GleerokProjectileEntity* this) { switch (super->type) { case 0: case 1: - iVar2 = sub_080041DC(super, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI); + iVar2 = sub_080041DC(super, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI); if (super->type == 1) { uVar1 = Random() & 0x1ff; if ((gRoomTransition.frameCount & 1U) == 0) { @@ -104,7 +104,7 @@ void GleerokProjectile_Action1(GleerokProjectileEntity* this) { LinearMoveUpdate(super); if ((super->type != 2) && (super->subtimer-- == 0)) { super->subtimer = 30; - sub_08004596(super, GetFacingDirection(super, &gPlayerEntity)); + sub_08004596(super, GetFacingDirection(super, &gPlayerEntity.base)); } if (GravityUpdate(super, 0) == 0) { super->action = 2; diff --git a/src/projectile/gyorgMaleEnergyProjectile.c b/src/projectile/gyorgMaleEnergyProjectile.c index e243cec9..b3ee446d 100644 --- a/src/projectile/gyorgMaleEnergyProjectile.c +++ b/src/projectile/gyorgMaleEnergyProjectile.c @@ -70,7 +70,7 @@ void GyorgMaleEnergyProjectile_Action1(Entity* this) { if (--this->timer == 0) { this->action = 2; COLLISION_ON(this); - this->direction = GetFacingDirection(this, &gPlayerEntity); + this->direction = GetFacingDirection(this, &gPlayerEntity.base); SoundReq(SFX_12E); } } diff --git a/src/projectile/keatonDagger.c b/src/projectile/keatonDagger.c index bccb2b96..4f5b95af 100644 --- a/src/projectile/keatonDagger.c +++ b/src/projectile/keatonDagger.c @@ -20,7 +20,7 @@ void KeatonDagger(Entity* this) { } parent = this->parent; if (((parent == NULL) || (parent->health == 0)) || (parent->next == NULL)) { - if (((this->contactFlags & 0x80) != 0) && (this->contactedEntity == &gPlayerEntity)) { + if (((this->contactFlags & 0x80) != 0) && (this->contactedEntity == &gPlayerEntity.base)) { sub_0803C0AC(this); } DeleteEntity(this); diff --git a/src/projectile/lakituCloudProjectile.c b/src/projectile/lakituCloudProjectile.c index fe4faed2..8c0a11f2 100644 --- a/src/projectile/lakituCloudProjectile.c +++ b/src/projectile/lakituCloudProjectile.c @@ -48,7 +48,7 @@ void LakituCloudProjectile_SubAction2(Entity* this) { if (sub_0806F3E4(this) != 0) { if (this->hitType == 0xa6) { ModHealth(-2); - SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6); + SoundReqClipped(&gPlayerEntity.base, SFX_PLY_VO6); sub_08079D84(); } CreateFx(this, FX_DEATH, 0); diff --git a/src/projectile/octorokBossProjectile.c b/src/projectile/octorokBossProjectile.c index e4dcdb93..3786d872 100644 --- a/src/projectile/octorokBossProjectile.c +++ b/src/projectile/octorokBossProjectile.c @@ -77,7 +77,7 @@ void OctorokBossProjectile_Init(OctorokBossProjectileEntity* this) { InitializeAnimation(super, 5); break; case 3: - CopyPosition(&gPlayerEntity, super); + CopyPosition(&gPlayerEntity.base, super); super->z.WORD = Q_16_16(-160.0); super->x.HALF.HI += 0x60; super->y.HALF.HI += 0x40; diff --git a/src/projectile/projectile5.c b/src/projectile/projectile5.c index f1817057..31471e10 100644 --- a/src/projectile/projectile5.c +++ b/src/projectile/projectile5.c @@ -40,7 +40,7 @@ void Projectile5_OnCollision(Entity* this) { pbVar2 = &((Projectile5Entity*)this->parent)->unk_83; if ((((Projectile5Entity*)this->parent)->unk_83 & 0x3f) == 3) { if (gPlayerState.hurtBlinkSpeed != 0) { - if (sub_080B1B44(TILE(this->x.HALF.HI, this->y.HALF.HI), gPlayerEntity.collisionLayer) == 0) { + if (sub_080B1B44(TILE(this->x.HALF.HI, this->y.HALF.HI), gPlayerEntity.base.collisionLayer) == 0) { if (this->contactFlags == 0x80) { *pbVar2 = *pbVar2 & 0x7f; DeleteThisEntity(); diff --git a/src/projectile/spiderWeb.c b/src/projectile/spiderWeb.c index a5075b2c..dca0bc9a 100644 --- a/src/projectile/spiderWeb.c +++ b/src/projectile/spiderWeb.c @@ -95,7 +95,7 @@ void SpiderWeb_OnGrabbed(SpiderWebEntity* this) { u32 animationState; if (super->subAction == 0) { - animationState = (gPlayerEntity.animationState >> 1); + animationState = (gPlayerEntity.base.animationState >> 1); if (animationState != super->type) { super->gustJarState &= ~4; if (AnimationStateFlip90(animationState) != super->type) { @@ -170,7 +170,7 @@ void SpiderWeb_SubAction0(SpiderWebEntity* this) { u16 y; Entity* entity; - entity = &gPlayerEntity; + entity = &gPlayerEntity.base; if (this->unk_84 == 0) { tmp = super->type; @@ -187,7 +187,8 @@ void SpiderWeb_SubAction0(SpiderWebEntity* this) { InitAnimationForceUpdate(super, super->type + 4); } if ((entity->animationState >> 1 == super->type) && (gPlayerState.framestate == PL_STATE_PULL) && - ((gPlayerState.heldObject & 2) != 0) && ((gPlayerEntity.frame & 2) != 0) && ((super->frame & ANIM_DONE) == 0)) { + ((gPlayerState.heldObject & 2) != 0) && ((gPlayerEntity.base.frame & 2) != 0) && + ((super->frame & ANIM_DONE) == 0)) { UpdateAnimationSingleFrame(super); if ((super->frame & 1) != 0) { entity->x.HALF.HI = gUnk_0812A06C[entity->animationState] + entity->x.HALF.HI; @@ -216,8 +217,8 @@ void sub_080AA9E0(Entity* this) { s32 diff; const Struct_0812A074* ptr; - diff = - (this->type & 0x1) ? (gPlayerEntity.x.HALF.HI - this->x.HALF.HI) : (gPlayerEntity.y.HALF.HI - this->y.HALF.HI); + diff = (this->type & 0x1) ? (gPlayerEntity.base.x.HALF.HI - this->x.HALF.HI) + : (gPlayerEntity.base.y.HALF.HI - this->y.HALF.HI); ptr = gUnk_0812A074 + (this->type << 1); switch (this->type) { case 0: diff --git a/src/projectile/v1DarkMagicProjectile.c b/src/projectile/v1DarkMagicProjectile.c index 9a1ad6f7..248612e4 100644 --- a/src/projectile/v1DarkMagicProjectile.c +++ b/src/projectile/v1DarkMagicProjectile.c @@ -49,7 +49,7 @@ void V1DarkMagicProjectile_OnCollision(V1DarkMagicProjectileEntity* this) { super->action = 2; COLLISION_OFF(super); if (super->type == 0) { - SortEntityAbove(&gPlayerEntity, super); + SortEntityAbove(&gPlayerEntity.base, super); } else { SortEntityAbove(super->parent, super); } @@ -57,7 +57,7 @@ void V1DarkMagicProjectile_OnCollision(V1DarkMagicProjectileEntity* this) { gPlayerState.mobility |= 0x80; gPlayerState.field_0xa |= 0x80; } - if (gPlayerEntity.health == 0) { + if (gPlayerEntity.base.health == 0) { super->health = 0; } } else { @@ -144,7 +144,7 @@ void V1DarkMagicProjectile_Init(V1DarkMagicProjectileEntity* this) { super->spriteOrientation.flipY = 1; super->spriteRendering.b3 = 1; super->spritePriority.b0 = 4; - super->direction = GetFacingDirection(super, &gPlayerEntity); + super->direction = GetFacingDirection(super, &gPlayerEntity.base); this->unk_86 = 0; this->unk_84 = 300; entity = CreateProjectile(V1_DARK_MAGIC_PROJECTILE); @@ -169,7 +169,7 @@ void V1DarkMagicProjectile_Action1(V1DarkMagicProjectileEntity* this) { case 0: if (--super->subtimer == 0) { super->subtimer = 4; - uVar2 = GetFacingDirection(super, &gPlayerEntity); + uVar2 = GetFacingDirection(super, &gPlayerEntity.base); sub_08004596(super, uVar2); } LinearMoveUpdate(super); @@ -219,25 +219,25 @@ void sub_080AAF74(V1DarkMagicProjectileEntity* this) { } if (++super->timer == 0x3c) { super->timer = 30; - gPlayerEntity.iframes = 8; + gPlayerEntity.base.iframes = 8; ModHealth(-4); - SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6); - if (gPlayerEntity.health == 0) { + SoundReqClipped(&gPlayerEntity.base, SFX_PLY_VO6); + if (gPlayerEntity.base.health == 0) { super->health = 0; } } if (!((this->unk_80 < 0x31) && (this->unk_81 != 0x10))) { super->action = 1; this->unk_80 = 0; - gPlayerEntity.iframes = 0xf0; + gPlayerEntity.base.iframes = 0xf0; gPlayerState.mobility = 0; super->health = 0; } else { ResetActiveItems(); gPlayerState.mobility |= 0x80; gPlayerState.field_0xa |= 0x80; - CopyPosition(&gPlayerEntity, super); - super->z.HALF.HI = gPlayerEntity.z.HALF.HI - 4; + CopyPosition(&gPlayerEntity.base, super); + super->z.HALF.HI = gPlayerEntity.base.z.HALF.HI - 4; } } diff --git a/src/projectile/v2Projectile.c b/src/projectile/v2Projectile.c index cd42ab11..cb59c16a 100644 --- a/src/projectile/v2Projectile.c +++ b/src/projectile/v2Projectile.c @@ -91,7 +91,7 @@ void nullsub_542(Entity* this) { void sub_080ABC90(Entity* this) { if (sub_0806F3E4(this) != 0) { ModHealth(-2); - SoundReqClipped(&gPlayerEntity, SFX_PLY_VO6); + SoundReqClipped(&gPlayerEntity.base, SFX_PLY_VO6); sub_08079D84(); CreateFx(this, FX_DEATH, 0); DeleteThisEntity(); diff --git a/src/projectile/v3ElectricProjectile.c b/src/projectile/v3ElectricProjectile.c index fdd1b670..2fe12fb2 100644 --- a/src/projectile/v3ElectricProjectile.c +++ b/src/projectile/v3ElectricProjectile.c @@ -90,7 +90,7 @@ void V3ElectricProjectile_Action1(V3ElectricProjectileEntity* this) { if ((super->frame & 1) != 0) { if (super->type == 0) { super->action = 2; - super->direction = GetFacingDirection(super, &gPlayerEntity); + super->direction = GetFacingDirection(super, &gPlayerEntity.base); super->speed = 0x180; SoundReq(SFX_193); } else { @@ -119,7 +119,7 @@ void V3ElectricProjectile_Action2(V3ElectricProjectileEntity* this) { } if (super->timer < 0x1e) { if (((++super->timer) & super->subtimer) == 0) { - sub_08004596(super, GetFacingDirection(super, &gPlayerEntity)); + sub_08004596(super, GetFacingDirection(super, &gPlayerEntity.base)); } } } @@ -136,7 +136,7 @@ void V3ElectricProjectile_Action3(V3ElectricProjectileEntity* this) { super->timer = 4; rand = Random() & 0x7; super->subtimer = gUnk_0812A982[rand]; - dir = GetFacingDirection(super, &gPlayerEntity); + dir = GetFacingDirection(super, &gPlayerEntity.base); if (((V3ElectricProjectileEntity*)super->parent)->unk_84 == 3) { dir -= projectileDirections[rand]; super->type2 = 0; diff --git a/src/projectile/v3HandProjectile.c b/src/projectile/v3HandProjectile.c index 9f9b984d..ff594836 100644 --- a/src/projectile/v3HandProjectile.c +++ b/src/projectile/v3HandProjectile.c @@ -19,7 +19,7 @@ void V3HandProjectile(Entity* this) { void V3HandProjectile_OnTick(Entity* this) { if (this->action == 0) { this->action = 1; - this->direction = GetFacingDirection(this, &gPlayerEntity); + this->direction = GetFacingDirection(this, &gPlayerEntity.base); InitializeAnimation(this, 0); SoundReq(SFX_199); } diff --git a/src/room.c b/src/room.c index c0c868f4..b999efce 100644 --- a/src/room.c +++ b/src/room.c @@ -1,4 +1,3 @@ -#define ENT_DEPRECATED #include "area.h" #include "common.h" #include "flags.h" @@ -110,7 +109,7 @@ void RegisterRoomEntity(Entity* ent, const EntityData* dat) { AppendEntityToList(ent, list); } } - offset = &ent->field_0x78; + offset = &((GenericEntity*)ent)->field_0x78; if (kind == MANAGER) offset = &ent->y; MemCopy(dat, offset, sizeof(EntityData)); @@ -123,7 +122,7 @@ void sub_0804AF0C(Entity* ent, const EntityData* dat) { ent->y.HALF.HI = dat->yPos + gRoomControls.origin_y; break; case 0x20: - ent->field_0x6c.HALF.HI |= 0x20; + ((GenericEntity*)ent)->field_0x6c.HALF.HI |= 0x20; ent->x.HALF.HI = dat->xPos + gRoomControls.origin_x; ent->y.HALF.HI = dat->yPos + gRoomControls.origin_y; break; @@ -198,7 +197,7 @@ static void sub_0804B058(EntityData* dat) { if (sub_08049D1C(uVar2) != 0) { ent = LoadRoomEntity(dat); if ((ent != NULL) && (ent->kind == ENEMY)) { - ent->field_0x6c.HALF.LO = uVar2 | 0x80; + ((GenericEntity*)ent)->field_0x6c.HALF.LO = uVar2 | 0x80; } } } else { diff --git a/src/roomInit.c b/src/roomInit.c index bbe55eae..58d70bc1 100644 --- a/src/roomInit.c +++ b/src/roomInit.c @@ -238,7 +238,7 @@ void sub_StateChange_MinishPaths_MayorsCabin(void) { sub_080575C8(0x20); - if (gPlayerEntity.y.HALF.HI - gRoomControls.origin_y > 0x40) + if (gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y > 0x40) LoadRoomEntityList(&Entities_MinishPaths_MayorsCabin_gUnk_080D6138); } @@ -409,8 +409,8 @@ void sub_StateChange_HouseInteriors1_InnWestRoom(void) { if (CheckLocalFlag(YADO_CHECKIN)) { ClearLocalFlag(YADO_CHECKIN); SetFade(FADE_IN_OUT | FADE_INSTANT, 256); - gPlayerEntity.x.HALF.HI = gRoomControls.origin_x + 0x50; - gPlayerEntity.y.HALF.HI = gRoomControls.origin_y + 0x38; + gPlayerEntity.base.x.HALF.HI = gRoomControls.origin_x + 0x50; + gPlayerEntity.base.y.HALF.HI = gRoomControls.origin_y + 0x38; sub_080751E8(1, 2, &script_PlayerSleepingInn); } } @@ -435,8 +435,8 @@ void sub_StateChange_HouseInteriors1_InnMiddleRoom(void) { if (CheckLocalFlag(YADO_CHECKIN) != 0) { ClearLocalFlag(YADO_CHECKIN); SetFade(FADE_IN_OUT | FADE_INSTANT, 256); - gPlayerEntity.x.HALF.HI = gRoomControls.origin_x + 0x50; - gPlayerEntity.y.HALF.HI = gRoomControls.origin_y + 0x38; + gPlayerEntity.base.x.HALF.HI = gRoomControls.origin_x + 0x50; + gPlayerEntity.base.y.HALF.HI = gRoomControls.origin_y + 0x38; sub_080751E8(1, 2, &script_PlayerSleepingInn); } } @@ -461,8 +461,8 @@ void sub_StateChange_HouseInteriors1_InnEastRoom(void) { if (CheckLocalFlag(YADO_CHECKIN)) { ClearLocalFlag(YADO_CHECKIN); SetFade(FADE_IN_OUT | FADE_INSTANT, 256); - gPlayerEntity.x.HALF.HI = gRoomControls.origin_x + 0x60; - gPlayerEntity.y.HALF.HI = gRoomControls.origin_y + 0x38; + gPlayerEntity.base.x.HALF.HI = gRoomControls.origin_x + 0x60; + gPlayerEntity.base.y.HALF.HI = gRoomControls.origin_y + 0x38; sub_080751E8(1, 2, &script_PlayerSleepingInn); } } @@ -681,8 +681,8 @@ extern u32 script_PlayerWakingUpInHyruleCastle; void sub_StateChange_HyruleCastle_4(void) { if (!CheckLocalFlag(CASTLE_04_MEZAME)) { SetFade(FADE_IN_OUT | FADE_INSTANT, 256); - gPlayerEntity.x.HALF.HI = gRoomControls.origin_x + 0xb0; - gPlayerEntity.y.HALF.HI = gRoomControls.origin_y + 0x40; + gPlayerEntity.base.x.HALF.HI = gRoomControls.origin_x + 0xb0; + gPlayerEntity.base.y.HALF.HI = gRoomControls.origin_y + 0x40; sub_080751E8(0, 6, &script_PlayerWakingUpInHyruleCastle); #ifdef EU SoundReq(SONG_STOP_ALL); @@ -2125,7 +2125,7 @@ u32 sub_unk3_DeepwoodShrine_Madderpillar(void) { extern EntityData gUnk_080DE4C8; void sub_StateChange_DeepwoodShrine_Madderpillar(void) { - if ((gPlayerEntity.y.HALF.HI - gRoomControls.origin_y) < (gRoomControls.height >> 1)) { + if ((gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y) < (gRoomControls.height >> 1)) { if (!CheckLocalFlag(0x17)) { LoadRoomEntityList(&gUnk_080DE4C8); } @@ -2517,7 +2517,7 @@ void sub_StateChange_CaveOfFlamesBoss_Main(void) { if (CheckGlobalFlag(LV2_CLEAR)) { gMapTop.bgSettings = 0; gScreen.lcd.displayControl &= ~DISPCNT_BG1_ON; - sub_0807AABC(&gPlayerEntity); + sub_0807AABC(&gPlayerEntity.base); LoadRoomEntityList(&gUnk_additional_a_CaveOfFlamesBoss_Main); } else { SoundReq(SONG_STOP_BGM); @@ -3593,14 +3593,14 @@ void sub_StateChange_Vaati3_Main(void) { if ((gRoomTransition.field_0x38 & 1) && gRoomTransition.field_0x39) { if (gRoomTransition.field_0x3c == 1) { - gPlayerEntity.x.HALF.HI = gRoomTransition.field_0x48; - gPlayerEntity.y.HALF.HI = gRoomTransition.field_0x4a + 8; + gPlayerEntity.base.x.HALF.HI = gRoomTransition.field_0x48; + gPlayerEntity.base.y.HALF.HI = gRoomTransition.field_0x4a + 8; } else { if (gRoomTransition.field_0x3c) { return; } - gPlayerEntity.x.HALF.HI = gRoomTransition.field_0x44; - gPlayerEntity.y.HALF.HI = gRoomTransition.field_0x46 + 8; + gPlayerEntity.base.x.HALF.HI = gRoomTransition.field_0x44; + gPlayerEntity.base.y.HALF.HI = gRoomTransition.field_0x46 + 8; } } } @@ -4939,8 +4939,8 @@ void sub_StateChange_HouseInteriors2_LinksHouseBedroom(void) { extern u32 script_PlayerWakeAfterRest; void sub_0804E864(void) { - gPlayerEntity.x.HALF.HI = gRoomControls.origin_x + 0x90; - gPlayerEntity.y.HALF.HI = gRoomControls.origin_y + 0x38; + gPlayerEntity.base.x.HALF.HI = gRoomControls.origin_x + 0x90; + gPlayerEntity.base.y.HALF.HI = gRoomControls.origin_y + 0x38; sub_080751E8(1, 6, &script_PlayerWakeAfterRest); ModHealth(0xa0); } diff --git a/src/script.c b/src/script.c index 2f50621e..6a10ec96 100644 --- a/src/script.c +++ b/src/script.c @@ -1,4 +1,3 @@ -#define ENT_DEPRECATED #include "area.h" #include "functions.h" #include "game.h" @@ -198,15 +197,15 @@ ScriptExecutionContext* StartCutscene(Entity* entity, Script* script) { void InitScriptForEntity(Entity* entity, ScriptExecutionContext* context, Script* script) { entity->flags |= ENT_SCRIPTED; - *(ScriptExecutionContext**)&entity->cutsceneBeh = context; + *(ScriptExecutionContext**)&((GenericEntity*)entity)->cutsceneBeh = context; InitScriptExecutionContext(context, script); } void UnloadCutsceneData(Entity* entity) { if (entity->flags & ENT_SCRIPTED) { entity->flags &= ~ENT_SCRIPTED; - DestroyScriptExecutionContext(*(ScriptExecutionContext**)&entity->cutsceneBeh); - *(ScriptExecutionContext**)&entity->cutsceneBeh = NULL; + DestroyScriptExecutionContext(*(ScriptExecutionContext**)&((GenericEntity*)entity)->cutsceneBeh); + *(ScriptExecutionContext**)&((GenericEntity*)entity)->cutsceneBeh = NULL; } } @@ -215,8 +214,8 @@ void StartPlayerScript(Script* script) { MemClear(&gPlayerScriptExecutionContext, sizeof(gPlayerScriptExecutionContext)); gPlayerScriptExecutionContext.scriptInstructionPointer = script; - player = &gPlayerEntity; - *(ScriptExecutionContext**)&player->cutsceneBeh = &gPlayerScriptExecutionContext; + player = &gPlayerEntity.base; + *(ScriptExecutionContext**)&((GenericEntity*)player)->cutsceneBeh = &gPlayerScriptExecutionContext; gPlayerState.queued_action = PLAYER_SLEEP; gPlayerState.field_0x3a = 0; gPlayerState.field_0x39 = 0; @@ -248,10 +247,10 @@ void HandlePostScriptActions(Entity* entity, ScriptExecutionContext* context) { context->postScriptActions ^= bit; switch (bit) { case 1 << 0x00: - entity->field_0x80.HWORD = 0; + ((GenericEntity*)entity)->field_0x80.HWORD = 0; break; case 1 << 0x01: - entity->field_0x80.HWORD = 4; + ((GenericEntity*)entity)->field_0x80.HWORD = 4; break; case 1 << 0x02: break; @@ -276,37 +275,37 @@ void HandlePostScriptActions(Entity* entity, ScriptExecutionContext* context) { case 1 << 0x09: entity->spriteOffsetY = 0; entity->spriteOffsetX = 0; - entity->field_0x82.HWORD = 0; + ((GenericEntity*)entity)->field_0x82.HWORD = 0; break; case 1 << 0x0a: - entity->field_0x82.HWORD |= 2; + ((GenericEntity*)entity)->field_0x82.HWORD |= 2; break; case 1 << 0x0b: - entity->field_0x82.HWORD &= ~2; + ((GenericEntity*)entity)->field_0x82.HWORD &= ~2; break; case 1 << 0x0c: - entity->field_0x82.HWORD &= ~1; + ((GenericEntity*)entity)->field_0x82.HWORD &= ~1; break; case 1 << 0x0d: - entity->field_0x82.HWORD |= 1; + ((GenericEntity*)entity)->field_0x82.HWORD |= 1; break; case 1 << 0x0e: - entity->field_0x82.HWORD |= 8; + ((GenericEntity*)entity)->field_0x82.HWORD |= 8; break; case 1 << 0x0f: - entity->field_0x82.HWORD ^= 4; + ((GenericEntity*)entity)->field_0x82.HWORD ^= 4; break; case 1 << 0x10: - entity->field_0x82.HWORD ^= 0x10; + ((GenericEntity*)entity)->field_0x82.HWORD ^= 0x10; break; case 1 << 0x11: entity->spriteSettings.flipX ^= 1; break; case 1 << 0x12: - entity->field_0x82.HWORD |= 0x20; + ((GenericEntity*)entity)->field_0x82.HWORD |= 0x20; break; case 1 << 0x13: - entity->field_0x82.HWORD &= ~0x20; + ((GenericEntity*)entity)->field_0x82.HWORD &= ~0x20; break; default: break; @@ -323,12 +322,12 @@ void InitScriptForNPC(Entity* entity) { void sub_0807DD64(Entity* entity) { entity->subtimer = entity->animationState; entity->animIndex = 0xff; - entity->field_0x80.HWORD = 0; - entity->field_0x82.HWORD = 0; + ((GenericEntity*)entity)->field_0x80.HWORD = 0; + ((GenericEntity*)entity)->field_0x82.HWORD = 0; } void sub_0807DD80(Entity* entity, Script* script) { - InitScriptExecutionContext(*(ScriptExecutionContext**)&entity->cutsceneBeh, script); + InitScriptExecutionContext(*(ScriptExecutionContext**)&((GenericEntity*)entity)->cutsceneBeh, script); sub_0807DD64(entity); } @@ -341,7 +340,7 @@ void ExecuteScriptAndHandleAnimation(Entity* entity, void (*postScriptCallback)( void ExecuteScriptForEntity(Entity* entity, void (*postScriptCallback)(Entity*, ScriptExecutionContext*)) { ScriptExecutionContext** piVar1; - piVar1 = (ScriptExecutionContext**)&entity->cutsceneBeh; + piVar1 = (ScriptExecutionContext**)&((GenericEntity*)entity)->cutsceneBeh; if (*piVar1) { ExecuteScript(entity, *piVar1); if (postScriptCallback) { @@ -360,7 +359,7 @@ void HandleEntity0x82Actions(Entity* entity) { u32 bit; u32 loopVar; - loopVar = entity->field_0x82.HWORD; + loopVar = ((GenericEntity*)entity)->field_0x82.HWORD; while (loopVar) { bit = (~loopVar + 1) & loopVar; loopVar = loopVar ^ bit; @@ -399,9 +398,9 @@ void sub_0807DE80(Entity* entity) { u32 temp; - local2 = entity->field_0x80.HWORD; + local2 = ((GenericEntity*)entity)->field_0x80.HWORD; if (local2 < 8) { - if (entity->field_0x82.HWORD & 1) { + if (((GenericEntity*)entity)->field_0x82.HWORD & 1) { u32 t1, t2; t1 = local2 & 0xfc; t2 = entity->subtimer >> 1; @@ -417,7 +416,7 @@ void sub_0807DE80(Entity* entity) { if (local2 != entity->animIndex) { InitAnimationForceUpdate(entity, local2); } - temp = entity->field_0x82.HWORD & 4; + temp = ((GenericEntity*)entity)->field_0x82.HWORD & 4; local1 = 1; if (temp) { local1 = 2; @@ -803,14 +802,14 @@ void ScriptCommand_CheckEntityInteractType(Entity* entity, ScriptExecutionContex void ScriptCommand_FacePlayerAndCheckDist(Entity* entity, ScriptExecutionContext* context) { if ((context->unk_1A & 0xF) == 0 && (gPlayerState.flags & PL_MINISH) == 0 && - EntityInRectRadius(entity, &gPlayerEntity, 40, 40)) { - entity->animationState = GetAnimationStateForDirection8(GetFacingDirection(entity, &gPlayerEntity)); + EntityInRectRadius(entity, &gPlayerEntity.base, 40, 40)) { + entity->animationState = GetAnimationStateForDirection8(GetFacingDirection(entity, &gPlayerEntity.base)); } context->unk_1A++; if (entity->interactType) { entity->interactType = INTERACTION_NONE; context->condition = 1; - entity->animationState = GetAnimationStateForDirection8(GetFacingDirection(entity, &gPlayerEntity)); + entity->animationState = GetAnimationStateForDirection8(GetFacingDirection(entity, &gPlayerEntity.base)); } else { context->condition = 0; } @@ -901,12 +900,12 @@ void ScriptCommand_EntityHasHeight(Entity* entity, ScriptExecutionContext* conte } void ScriptCommand_ComparePlayerAction(Entity* entity, ScriptExecutionContext* context) { - context->condition = context->scriptInstructionPointer[1] == gPlayerEntity.action; + context->condition = context->scriptInstructionPointer[1] == gPlayerEntity.base.action; gActiveScriptInfo.flags |= 1; } void ScriptCommand_ComparePlayerAnimationState(Entity* entity, ScriptExecutionContext* context) { - context->condition = context->scriptInstructionPointer[1] == gPlayerEntity.animationState; + context->condition = context->scriptInstructionPointer[1] == gPlayerEntity.base.animationState; gActiveScriptInfo.flags |= 1; } @@ -968,7 +967,7 @@ void ScriptCommand_WaitForSyncFlagAndClear(Entity* entity, ScriptExecutionContex } void ScriptCommand_WaitPlayerGetItem(Entity* entity, ScriptExecutionContext* context) { - if (gPlayerEntity.action == PLAYER_ITEMGET) { + if (gPlayerEntity.base.action == PLAYER_ITEMGET) { gActiveScriptInfo.commandSize = 0; } else { context->wait = 45; @@ -976,7 +975,7 @@ void ScriptCommand_WaitPlayerGetItem(Entity* entity, ScriptExecutionContext* con } void ScriptCommand_WaitForPlayerEnterRoom(Entity* entity, ScriptExecutionContext* context) { - if (gPlayerEntity.action != PLAYER_ROOMTRANSITION) { + if (gPlayerEntity.base.action != PLAYER_ROOMTRANSITION) { gActiveScriptInfo.flags |= 1; } else { gActiveScriptInfo.commandSize = 0; @@ -1085,7 +1084,7 @@ void ScriptCommand_SetPlayerAnimation(Entity* entity, ScriptExecutionContext* co void ScriptCommand_0807E8E4(Entity* entity, ScriptExecutionContext* context) { u32 tmp = (gUnk_08016984 & 0x3FF); u32 tmp2; - gPlayerEntity.animationState = tmp2 = (context->scriptInstructionPointer[0] - tmp) << 1; + gPlayerEntity.base.animationState = tmp2 = (context->scriptInstructionPointer[0] - tmp) << 1; } void ScriptCommand_SetAction(Entity* entity, ScriptExecutionContext* context) { @@ -1103,7 +1102,7 @@ void ScriptCommand_SetVariableToFrame(Entity* entity, ScriptExecutionContext* co } void ScriptCommand_SetAnimation(Entity* entity, ScriptExecutionContext* context) { - entity->field_0x80.HWORD = context->scriptInstructionPointer[1]; + ((GenericEntity*)entity)->field_0x80.HWORD = context->scriptInstructionPointer[1]; InitAnimationForceUpdate(entity, context->scriptInstructionPointer[1]); } @@ -1243,11 +1242,12 @@ void ScriptCommand_0807EB4C(Entity* entity, ScriptExecutionContext* context) { } void ScriptCommand_FacePlayer(Entity* entity, ScriptExecutionContext* context) { - entity->animationState = GetAnimationStateForDirection8(GetFacingDirection(entity, &gPlayerEntity)); + entity->animationState = GetAnimationStateForDirection8(GetFacingDirection(entity, &gPlayerEntity.base)); } void ScriptCommand_FaceAwayFromPlayer(Entity* entity, ScriptExecutionContext* context) { - gPlayerEntity.animationState = GetAnimationStateForDirection8(GetFacingDirection(&gPlayerEntity, entity)) & ~1; + gPlayerEntity.base.animationState = + GetAnimationStateForDirection8(GetFacingDirection(&gPlayerEntity.base, entity)) & ~1; } void ScriptCommand_SetEntityDirection(Entity* entity, ScriptExecutionContext* context) { @@ -1278,7 +1278,7 @@ void ScriptCommand_OffsetEntityPosition(Entity* entity, ScriptExecutionContext* } void ScriptCommand_MoveEntityToPlayer(Entity* entity, ScriptExecutionContext* context) { - CopyPosition(&gPlayerEntity, entity); + CopyPosition(&gPlayerEntity.base, entity); } void ScriptCommandNop3(Entity* entity, ScriptExecutionContext* context) { @@ -1413,7 +1413,7 @@ void ScriptCommand_0807EE30(Entity* entity, ScriptExecutionContext* context) { void ScriptCommand_0807EEB4(Entity* entity, ScriptExecutionContext* context) { if (!context->unk_18) { context->unk_18 = 1; - sub_0807DEDC(entity, context, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI); + sub_0807DEDC(entity, context, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI); } ScriptCommand_0807EE30(entity, context); if (!context->condition) { @@ -1517,7 +1517,7 @@ void ScriptCommand_CameraTargetEntity(Entity* entity, ScriptExecutionContext* co } void ScriptCommand_CameraTargetPlayer(Entity* entity, ScriptExecutionContext* context) { - gRoomControls.camera_target = &gPlayerEntity; + gRoomControls.camera_target = &gPlayerEntity.base; } void ScriptCommand_SetScrollSpeed(Entity* entity, ScriptExecutionContext* context) { @@ -1564,8 +1564,8 @@ void SetCollisionLayer1(Entity* entity, ScriptExecutionContext* context) { } void SetPlayerCollisionLayer1(Entity* entity, ScriptExecutionContext* context) { - gPlayerEntity.collisionLayer = 1; - UpdateSpriteForCollisionLayer(&gPlayerEntity); + gPlayerEntity.base.collisionLayer = 1; + UpdateSpriteForCollisionLayer(&gPlayerEntity.base); } void SetCollisionLayer2(Entity* entity, ScriptExecutionContext* context) { @@ -1578,7 +1578,7 @@ void sub_0807F190(Entity* entity, ScriptExecutionContext* context) { } void sub_0807F1A0(Entity* entity, ScriptExecutionContext* context) { - sub_0807DEDC(entity, context, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI); + sub_0807DEDC(entity, context, gPlayerEntity.base.x.HALF.HI, gPlayerEntity.base.y.HALF.HI); gActiveScriptInfo.flags |= 1; } @@ -1659,7 +1659,7 @@ void WaitForAnimDone(Entity* entity, ScriptExecutionContext* context) { } void WaitForPlayerAnim(Entity* entity, ScriptExecutionContext* context) { - if ((gPlayerEntity.frame & ANIM_DONE) != 0) { + if ((gPlayerEntity.base.frame & ANIM_DONE) != 0) { gActiveScriptInfo.flags |= 1; } else { gActiveScriptInfo.commandSize = 0; @@ -1703,15 +1703,15 @@ void sub_0807F3C8(Entity* entity, ScriptExecutionContext* context) { void sub_0807F3D8(Entity* entity, ScriptExecutionContext* context) { InitAnimationForceUpdate(entity, context->intVariable + (entity->animationState >> 1)); - entity->field_0x80.HWORD = entity->animIndex; + ((GenericEntity*)entity)->field_0x80.HWORD = entity->animIndex; } void CreatePlayerExclamationMark(Entity* entity, ScriptExecutionContext* context) { - CreateSpeechBubbleExclamationMark(&gPlayerEntity, 8, -24); + CreateSpeechBubbleExclamationMark(&gPlayerEntity.base, 8, -24); } void CreatePlayerQuestionMark(Entity* entity, ScriptExecutionContext* context) { - CreateSpeechBubbleQuestionMark(&gPlayerEntity, 8, -24); + CreateSpeechBubbleQuestionMark(&gPlayerEntity.base, 8, -24); } void LoadMenu(Entity* entity, ScriptExecutionContext* context) { @@ -1784,7 +1784,7 @@ void sub_0807F4F8(Entity* entity, ScriptExecutionContext* context) { } void ReadPlayerAnimationState(Entity* entity, ScriptExecutionContext* context) { - context->intVariable = gPlayerEntity.animationState >> 1; + context->intVariable = gPlayerEntity.base.animationState >> 1; } void WaitForPlayerIdle(Entity* entity, ScriptExecutionContext* context) { @@ -1833,12 +1833,12 @@ void sub_0807F650(Entity* entity, ScriptExecutionContext* context) { } void sub_0807F680(Entity* entity, ScriptExecutionContext* context) { - context->condition = gPlayerEntity.x.HALF.HI - gRoomControls.origin_x > (s32)(context->intVariable & 0xffff); + context->condition = gPlayerEntity.base.x.HALF.HI - gRoomControls.origin_x > (s32)(context->intVariable & 0xffff); gActiveScriptInfo.flags |= 1; } void sub_0807F6B4(Entity* entity, ScriptExecutionContext* context) { - context->condition = gPlayerEntity.y.HALF.HI - gRoomControls.origin_y > (s32)(context->intVariable & 0xffff); + context->condition = gPlayerEntity.base.y.HALF.HI - gRoomControls.origin_y > (s32)(context->intVariable & 0xffff); gActiveScriptInfo.flags |= 1; } @@ -1866,8 +1866,8 @@ void sub_0807F738(Entity* entity, ScriptExecutionContext* context) { void SetPlayerPos(Entity* entity, ScriptExecutionContext* context) { s32 s32Var = context->intVariable; - gPlayerEntity.x.HALF.HI = (s32Var >> 16) + gRoomControls.origin_x; - gPlayerEntity.y.HALF.HI = (s32Var & 0xffff) + gRoomControls.origin_y; + gPlayerEntity.base.x.HALF.HI = (s32Var >> 16) + gRoomControls.origin_x; + gPlayerEntity.base.y.HALF.HI = (s32Var & 0xffff) + gRoomControls.origin_y; } void GetConditionSet(Entity* entity, ScriptExecutionContext* context) { @@ -1960,10 +1960,10 @@ void DoGravity(Entity* entity, ScriptExecutionContext* context) { } void sub_0807F8E8(Entity* entity, ScriptExecutionContext* context) { - Entity* c = CreateObjectWithParent(entity, SANCTUARY_STONE_TABLET, 0, 0); - if (c != NULL) { - c->parent = entity; - c->field_0x86.HWORD = (context->intVariable & 0x3ff) | 0x8000; + Entity* stoneTablet = CreateObjectWithParent(entity, SANCTUARY_STONE_TABLET, 0, 0); + if (stoneTablet != NULL) { + stoneTablet->parent = entity; + ((GenericEntity*)stoneTablet)->field_0x86.HWORD = (context->intVariable & 0x3ff) | 0x8000; } } @@ -2094,12 +2094,12 @@ void sub_0807FB28(Entity* entity, ScriptExecutionContext* context) { } void SetPlayerIFrames(Entity* entity, ScriptExecutionContext* context) { - gPlayerEntity.iframes = context->intVariable; + gPlayerEntity.base.iframes = context->intVariable; } void DisablePlayerSwimState(Entity* entity, ScriptExecutionContext* context) { gPlayerState.swim_state = 0; - gPlayerEntity.collisionFlags &= ~4; + gPlayerEntity.base.collisionFlags &= ~4; } void sub_0807FB94(Entity* entity, ScriptExecutionContext* context) { diff --git a/src/scroll.c b/src/scroll.c index 815c2be2..7c30e701 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -1,6 +1,5 @@ #include "scroll.h" -#define ENT_DEPRECATED #include "asm.h" #include "collision.h" #include "common.h" @@ -202,8 +201,8 @@ void sub_0807FDF8(RoomControls* controls) { case 0: controls->scroll_y -= 4; pEVar2 = controls->camera_target; - if (pEVar2 == &gPlayerEntity) { - pEVar2->y.WORD = gPlayerEntity.y.WORD - Q_16_16(0.375); + if (pEVar2 == &gPlayerEntity.base) { + pEVar2->y.WORD = gPlayerEntity.base.y.WORD - Q_16_16(0.375); } if (controls->unk_18 == 0x28) { sub_0807FEC8(controls); @@ -211,8 +210,8 @@ void sub_0807FDF8(RoomControls* controls) { break; case 1: controls->scroll_x = controls->scroll_x + 4; - if (controls->camera_target == &gPlayerEntity) { - gPlayerEntity.x.WORD += Q_16_16(0.25); + if (controls->camera_target == &gPlayerEntity.base) { + gPlayerEntity.base.x.WORD += Q_16_16(0.25); } if (controls->unk_18 == 0x3c) { sub_0807FEC8(controls); @@ -221,8 +220,8 @@ void sub_0807FDF8(RoomControls* controls) { case 2: controls->scroll_y = controls->scroll_y + 4; pEVar2 = controls->camera_target; - if (pEVar2 == &gPlayerEntity) { - pEVar2->y.WORD = gPlayerEntity.y.WORD + Q_16_16(0.375); + if (pEVar2 == &gPlayerEntity.base) { + pEVar2->y.WORD = gPlayerEntity.base.y.WORD + Q_16_16(0.375); } if (controls->unk_18 == 0x28) { sub_0807FEC8(controls); @@ -230,8 +229,8 @@ void sub_0807FDF8(RoomControls* controls) { break; case 3: controls->scroll_x -= 4; - if (controls->camera_target == &gPlayerEntity) { - gPlayerEntity.x.WORD -= Q_16_16(0.25); + if (controls->camera_target == &gPlayerEntity.base) { + gPlayerEntity.base.x.WORD -= Q_16_16(0.25); } if (controls->unk_18 == 0x3c) { sub_0807FEC8(controls); @@ -291,9 +290,9 @@ void sub_0807FF6C(RoomControls* controls) { ResetActiveItems(); ResetPlayerAnimationAndAction(); if (gDiggingCaveEntranceTransition.isDiggingCave) { - gPlayerEntity.animationState = 4; + gPlayerEntity.base.animationState = 4; } else { - gPlayerEntity.animationState = 0; + gPlayerEntity.base.animationState = 0; } sub_080809D4(); } @@ -848,7 +847,7 @@ void UpdateDoorTransition() { u32 uVar3; u32 uVar4; RoomControls* controls = &gRoomControls; - if (gRoomControls.camera_target != &gPlayerEntity) { + if (gRoomControls.camera_target != &gPlayerEntity.base) { return; } if (gPlayerState.jump_status != 0) { @@ -956,10 +955,10 @@ void sub_08080CB4(Entity* this) { if (this->spriteSettings.draw != 0) { switch (this->type) { case 0x60: - if (this->field_0x6a.HALF.LO != 0) { - this->field_0x6a.HALF.LO--; + if (((GenericEntity*)this)->field_0x6a.HALF.LO != 0) { + ((GenericEntity*)this)->field_0x6a.HALF.LO--; } else { - this->field_0x6a.HALF.LO = (Random() & 0x1f) + 10; + ((GenericEntity*)this)->field_0x6a.HALF.LO = (Random() & 0x1f) + 10; effect = CreateFx(this, FX_SPARKLE, 0); if (effect != NULL) { effect->spriteOffsetX = this->spriteOffsetX; diff --git a/src/subtask/subtaskFastTravel.c b/src/subtask/subtaskFastTravel.c index 6e4749e6..b457a10c 100644 --- a/src/subtask/subtaskFastTravel.c +++ b/src/subtask/subtaskFastTravel.c @@ -138,7 +138,7 @@ void Subtask_FastTravel_3(void) { SetFade(FADE_IN_OUT | FADE_INSTANT, 8); } else { ResetPlayerAnimationAndAction(); - sub_080042D0(&gPlayerEntity, (u32)gPlayerEntity.animIndex, gPlayerEntity.spriteIndex); + sub_080042D0(&gPlayerEntity.base, (u32)gPlayerEntity.base.animIndex, gPlayerEntity.base.spriteIndex); Subtask_Exit(); gPauseMenuOptions.disabled = 0; SoundReq(SFX_MENU_CANCEL); diff --git a/src/vram.c b/src/vram.c index 9c57a8f3..73a2b0e8 100644 --- a/src/vram.c +++ b/src/vram.c @@ -1,9 +1,6 @@ -#define ENT_DEPRECATED // Due to sub_080AE218 indexing with gPlayerEntity -#include "global.h" #include "common.h" -#include "structures.h" #include "fileselect.h" -#include "new_player.h" +#include "structures.h" extern u32 gFixedTypeGfxData[]; @@ -364,7 +361,7 @@ void sub_080AE218(u32 param1, u32 param2) { r7 = r3 + ((u32)gGFXSlots.slots[param1].slotCount << 4); for (index1 = 0; index1 < 0x50; index1++) { - Entity* ent = &(&gPlayerEntity)[index1]; + Entity* ent = (Entity*)&(&gPlayerEntity)[index1]; if (ent->next != NULL) { if (param1 == ent->spriteAnimation[0]) { ent->spriteAnimation[0] = param2; diff --git a/src/worldEvent/worldEvent15.c b/src/worldEvent/worldEvent15.c index e30a5c39..2d1bbf39 100644 --- a/src/worldEvent/worldEvent15.c +++ b/src/worldEvent/worldEvent15.c @@ -4,7 +4,6 @@ * * @brief World Event 15 */ -#define ENT_DEPRECATED #include "fade.h" #include "flags.h" #include "menu.h" @@ -34,7 +33,7 @@ void WorldEvent_15_0(void) { entity = LoadRoomEntity((EntityData*)gUnk_080FEE48); if (entity != NULL) { entity->type2 = 2; - entity->field_0x86.HWORD = 0x80ff; + ((GenericEntity*)entity)->field_0x86.HWORD = 0x80ff; } sub_08054A14(gMenu.field_0x4); sub_08055B70(gMenu.field_0x4, 0, 0, 0);