summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorElijah Thomas <42302100+elijah-thomas774@users.noreply.github.com>2025-12-05 14:14:59 -0500
committerGitHub <noreply@github.com>2025-12-05 14:14:59 -0500
commitfca71a77bc890960800eef0e331b16dcec114aaf (patch)
tree3aa82a9e98c53936031d3fa569ff29d2de358fef /include
parent4e39bcca32c51cc0fb109d1a6918828499da8309 (diff)
parentad47fd3eb383679d9b502323cd8cbdc3434c10ba (diff)
Merge pull request #280 from lepelog/d_t_insect
d_t_insect
Diffstat (limited to 'include')
-rw-r--r--include/c/c_lib.h1
-rw-r--r--include/d/a/d_a_base.h8
-rw-r--r--include/d/a/d_a_insect_butterfly.h11
-rw-r--r--include/d/a/obj/d_a_obj_base.h5
-rw-r--r--include/d/a/obj/d_a_obj_soil.h7
-rw-r--r--include/d/a/obj/d_a_obj_warp.h48
-rw-r--r--include/d/flag/storyflag_map.h8
-rw-r--r--include/d/t/d_t_insect.h85
-rw-r--r--include/nw4r/math/math_geometry.h1
9 files changed, 165 insertions, 9 deletions
diff --git a/include/c/c_lib.h b/include/c/c_lib.h
index 04829ddd..be7b0d5e 100644
--- a/include/c/c_lib.h
+++ b/include/c/c_lib.h
@@ -8,6 +8,7 @@ namespace cLib {
s16 targetAngleY(const mVec3_c &target, const mVec3_c &source);
s16 targetAngleX(const mVec3_c &target, const mVec3_c &source);
+s16 offsetPos(mVec3_c &target, const mVec3_c &v1, s16 angle, const mVec3_c &v2);
void addCalcPos2(mVec3_c *src, const mVec3_c &target, f32 scale, f32 maxStep);
f32 addCalcPosXZ(mVec3_c *src, const mVec3_c &target, f32 scale, f32 maxStep, f32 minStep);
f32 addCalcPos(mVec3_c *src, const mVec3_c &target, f32 scale, f32 maxStep, f32 minStep);
diff --git a/include/d/a/d_a_base.h b/include/d/a/d_a_base.h
index c24f8ed7..6df2237e 100644
--- a/include/d/a/d_a_base.h
+++ b/include/d/a/d_a_base.h
@@ -4,6 +4,7 @@
#include "common.h"
#include "d/d_base.h"
#include "d/snd/d_snd_source_if.h"
+#include "f/f_profile_name.h"
#include "m/m_allocator.h"
#include "m/m_angle.h"
#include "m/m_vec.h"
@@ -180,6 +181,9 @@ public:
bool checkBeyondRadius(const mVec3_c &point, f32 radius) {
return getSquareDistanceTo(point) > radius;
}
+ bool checkInRadius(const mVec3_c &point, f32 radius) {
+ return getSquareDistanceTo(point) < radius;
+ }
u32 getRoomId() {
return mRoomID;
@@ -195,6 +199,10 @@ public:
return mActorProperties & property;
}
+ dAcBase_c* searchNextActor(dAcBase_c* parent) {
+ return static_cast<dAcBase_c*>(fManager_c::searchBaseByGroupType(dAcBase_c::ACTOR, parent));
+ }
+
public:
static void setTempCreateParams(
mVec3_c *pos, mAng3_c *rot, mVec3_c *scale, s32 roomId, u32 params2, dAcBase_c *parent, u8 subtype, u16 unkFlag,
diff --git a/include/d/a/d_a_insect_butterfly.h b/include/d/a/d_a_insect_butterfly.h
index 84c32694..14ccfd5d 100644
--- a/include/d/a/d_a_insect_butterfly.h
+++ b/include/d/a/d_a_insect_butterfly.h
@@ -4,8 +4,9 @@
#include "d/a/obj/d_a_obj_base.h"
#include "s/s_State.hpp"
#include "s/s_StateMgr.hpp"
+#include "d/a/d_a_insect.h"
-class dAcInsectButterfly_c : public dAcObjBase_c {
+class dAcInsectButterfly_c : public dAcOInsect_c {
public:
dAcInsectButterfly_c() : mStateMgr(*this, sStateID::null) {}
virtual ~dAcInsectButterfly_c() {}
@@ -16,8 +17,14 @@ public:
STATE_FUNC_DECLARE(dAcInsectButterfly_c, Finalize);
STATE_FUNC_DECLARE(dAcInsectButterfly_c, Dead);
+ void setKillSignal() {
+ mKillSignal = 1;
+ }
private:
- /* 0x??? */ STATE_MGR_DECLARE(dAcInsectButterfly_c);
+ /* 0x468 */ u8 field_0x468[0xA34-0x468];
+ /* 0xA34 */ STATE_MGR_DECLARE(dAcInsectButterfly_c);
+ /* 0xA70 */ u8 field_0xA70[0xAC6-0xA70];
+ /* 0xAC6 */ u8 mKillSignal;
};
#endif
diff --git a/include/d/a/obj/d_a_obj_base.h b/include/d/a/obj/d_a_obj_base.h
index 1faa9589..6b798af5 100644
--- a/include/d/a/obj/d_a_obj_base.h
+++ b/include/d/a/obj/d_a_obj_base.h
@@ -220,7 +220,12 @@ public:
fProfile::PROFILE_NAME_e actorId, u32 params1, mVec3_c *pos, mAng3_c *rot, mVec3_c *scale, u32 params2,
u32 roomId
);
+
// These may not belong here
+ static dAcBase_c* createInsectActor(
+ dAcBase_c* parent,
+ fProfile::PROFILE_NAME_e actorId, u32 params1, mVec3_c *pos, mAng3_c *rot, mVec3_c *scale, u32 params2, s32 roomId
+ );
static dAcBase_c *createActorUnkGroup3(
fProfile::PROFILE_NAME_e actorId, u32 roomId, u32 params1, mVec3_c *pos, mAng3_c *rot, mVec3_c *scale,
u32 params2
diff --git a/include/d/a/obj/d_a_obj_soil.h b/include/d/a/obj/d_a_obj_soil.h
index c4e24b31..64f1f0f9 100644
--- a/include/d/a/obj/d_a_obj_soil.h
+++ b/include/d/a/obj/d_a_obj_soil.h
@@ -14,8 +14,13 @@ public:
STATE_FUNC_DECLARE(dAcOsoil_c, Hole);
STATE_FUNC_DECLARE(dAcOsoil_c, Ready);
+ bool isStateHole() {
+ return mStateMgr.isState(StateID_Hole);
+ }
+
private:
- /* 0x??? */ STATE_MGR_DECLARE(dAcOsoil_c);
+ /* 0x330 */ u8 field_0x330[0x6CC-0x330];
+ /* 0x6CC */ STATE_MGR_DECLARE(dAcOsoil_c);
};
#endif
diff --git a/include/d/a/obj/d_a_obj_warp.h b/include/d/a/obj/d_a_obj_warp.h
index 1c64e61c..0b2f4874 100644
--- a/include/d/a/obj/d_a_obj_warp.h
+++ b/include/d/a/obj/d_a_obj_warp.h
@@ -2,6 +2,7 @@
#define D_A_OBJ_WARP_H
#include "d/a/obj/d_a_obj_base.h"
+#include "d/flag/storyflag_manager.h"
#include "s/s_State.hpp"
#include "s/s_StateMgr.hpp"
@@ -18,7 +19,54 @@ public:
STATE_FUNC_DECLARE(dAcOWarp_c, GateIn);
STATE_FUNC_DECLARE(dAcOWarp_c, GateClear);
+ virtual void fn_0x80();
+ virtual void fn_0x84();
+ virtual void fn_0x88();
+ virtual s32 checkStateGateOpen();
+ virtual s32 fn_0x90();
+ virtual s32 checkThisHasSongItem();
+
+ bool isFaronTrial() const {
+ return mTrialIndexBitmask & 0x10;
+ }
+
+ bool isEldinTrial() const {
+ return mTrialIndexBitmask & 0x40;
+ }
+
+ bool isLanayruTrial() const {
+ return mTrialIndexBitmask & 0x20;
+ }
+
+ bool isHyliaTrial() const {
+ return mTrialIndexBitmask & 0x80;
+ }
+
+ bool isFaronTrialAndCompleted() const {
+ return isFaronTrial() && StoryflagManager::sInstance->getFlag(STORYFLAG_FARON_TRIAL_COMPLETE);
+ }
+
+ bool isEdlinTrialAndCompleted() const {
+ return isEldinTrial() && StoryflagManager::sInstance->getFlag(STORYFLAG_ELDIN_TRIAL_COMPLETE);
+ }
+
+ bool isLanayruTrialAndCompleted() const {
+ return isLanayruTrial() && StoryflagManager::sInstance->getFlag(STORYFLAG_LANAYRU_TRIAL_COMPLETE);
+ }
+
+ bool isHyliaTrialAndCompleted() const {
+ return isHyliaTrial() && StoryflagManager::sInstance->getFlag(STORYFLAG_HYLIA_TRIAL_COMPLETE);
+ }
+
+ bool isTrialComplete() const {
+ return isFaronTrialAndCompleted()
+ || isEdlinTrialAndCompleted()
+ || isLanayruTrialAndCompleted()
+ || isHyliaTrialAndCompleted();
+ }
private:
+ /* 0x330 */ u8 field_0x330[0xC66-0x330];
+ /* 0xC66 */ u8 mTrialIndexBitmask;
/* 0x??? */ STATE_MGR_DECLARE(dAcOWarp_c);
};
diff --git a/include/d/flag/storyflag_map.h b/include/d/flag/storyflag_map.h
index 86271424..940380fd 100644
--- a/include/d/flag/storyflag_map.h
+++ b/include/d/flag/storyflag_map.h
@@ -1050,22 +1050,22 @@ enum StoryFlags_e {
* layer 3 / Skyview Boss Room layer 3 / Lake Floria layer 1 / Water Dragon's Lair layer 1)] Story Flag #206
* (0x00CE) - JP 805ACD70 0x04 / US 805A9AF0 0x04
*/
- STORYFLAG_206,
+ STORYFLAG_FARON_TRIAL_COMPLETE,
/** [Eldin Trial Completed (removes fi trigger in front of Volcano Summit)]
* Story Flag #207 (0x00CF) - JP 805ACD70 0x08 / US 805A9AF0 0x08
*/
- STORYFLAG_207,
+ STORYFLAG_ELDIN_TRIAL_COMPLETE,
/** [Lanayru Trial Completed (Lanayru Caves layer 1)]
* Story Flag #208 (0x00D0) - JP 805ACD70 0x10 / US 805A9AF0 0x10
*/
- STORYFLAG_208,
+ STORYFLAG_LANAYRU_TRIAL_COMPLETE,
/** [Hylia's Trial Completed (Triggers Fi Text after Skyloft Trial)]
* Story Flag #209 (0x00D1) - JP 805ACD70 0x20 / US 805A9AF0 0x20
*/
- STORYFLAG_209,
+ STORYFLAG_HYLIA_TRIAL_COMPLETE,
/** [Obtain Stone of Trials]
* Story Flag #210 (0x00D2) - JP 805ACD70 0x40 / US 805A9AF0 0x40
diff --git a/include/d/t/d_t_insect.h b/include/d/t/d_t_insect.h
index 25287d12..36ef7e62 100644
--- a/include/d/t/d_t_insect.h
+++ b/include/d/t/d_t_insect.h
@@ -2,21 +2,102 @@
#define D_T_INSECT_H
#include "d/a/d_a_base.h"
+#include "d/t/d_tg.h"
+#include "m/m_vec.h"
#include "s/s_State.hpp"
#include "s/s_StateMgr.hpp"
-class dTgInsect_c : public dAcBase_c {
+extern "C" bool fn_801BB750(nw4r::math::AABB *aabb, f32 f);
+
+class dTgInsect_c : public dTg_c {
public:
+ enum Subtype {
+ SUBTYPE_INVALID0,
+ SUBTYPE_INVALID1,
+ SUBTYPE_INVALID2,
+ SUBTYPE_VOLCANIC_LADYBUG,
+ SUBTYPE_GERUDO_DRAGONFLY,
+ SUBTYPE_WOODLAND_RHINO_BEETLE,
+ SUBTYPE_SAND_CICADA,
+ SUBTYPE_FARON_GRASSHOPPER,
+ SUBTYPE_LANAYRU_ANT,
+ SUBTYPE_SKY_STAG_BEETLE,
+ SUBTYPE_BUTTERFLY,
+ SUBTYPE_SKYLOFT_MANTIS,
+ SUBTYPE_EDLIN_ROLLER,
+ SUBTYPE_STARRY_FIREFLY,
+ };
+ enum SpawnSubtype {
+ SPAWN_SKYLOFT_BUGKID_TREE = 1,
+ SPAWN_BUG_MINIGAME,
+ SPAWN_TRIAL_GATE,
+ SPAWN_GOSSIP_STONE,
+ SPAWN_GODDESS_WALL,
+ SPAWN_DEFAULT = 0xF,
+ };
dTgInsect_c() : mStateMgr(*this, sStateID::null) {}
virtual ~dTgInsect_c() {}
+ virtual int doDelete() override;
+ virtual int draw() override;
+ virtual int actorCreate() override;
+ virtual int actorPostCreate() override;
+ virtual int actorExecute() override;
+
+ void setKillSignal() {
+ mKillSignal = 1;
+ }
+
+ static const f32 SCALE_X;
+ static const f32 SCALE_Y;
+
STATE_FUNC_DECLARE(dTgInsect_c, Wait);
STATE_FUNC_DECLARE(dTgInsect_c, WaitCreate);
STATE_FUNC_DECLARE(dTgInsect_c, WaitForceEscape);
STATE_FUNC_DECLARE(dTgInsect_c, End);
private:
- /* 0x??? */ STATE_MGR_DECLARE(dTgInsect_c);
+ /* 0x0FC */ STATE_MGR_DECLARE(dTgInsect_c);
+ /* 0x138 */ dAcRef_c<dAcBase_c> mLinks[16];
+ /* 0x1F8 */ u8 field_0x1f8[16];
+ /* 0x208 */ s32 mInsectRespawnTimers[16];
+ /* 0x248 */ s32 mInsectCount;
+ /* 0x24C */ u8 mRevealed; // used by OBJ_SOIL and OBJ_VSD to signal that the insect should be spawned now
+ /* 0x24D */ u8 mKillSignal; // used by goddess walls to signal that the insects should despawn
+ /* 0x24E */ u8 field_0x24e;
+ /* 0x24F */ u8 field_0x24f;
+ /* 0x250 */ u8 mShouldSpawn[16];
+ /* 0x260 */ mVec3_c mRevealedSpawnPos;
+ /* 0x26C */ dAcRef_c<dAcBase_c> mWarpRef;
+
+ SpawnSubtype getSpawnSubtype() const {
+ return (SpawnSubtype)(mParams >> 8 & 0xF);
+ }
+ bool isSpawnSubtype(SpawnSubtype spanwSubtype) const {
+ return getSpawnSubtype() == spanwSubtype;
+ }
+ Subtype getSubtype() const {
+ return (Subtype)(mParams >> 4 & 0xF);
+ }
+ bool isSubtype(Subtype subtype) const {
+ return getSubtype() == subtype;
+ }
+ s32 getInsectCount() const {
+ return (mParams & 0xF);
+ }
+ void spawnInsect(s32 index);
+ bool shouldSpawn();
+ void spawnAll();
+ bool checkValidSpawnLocation(const mVec3_c &pos, bool updateRotation);
+ bool isTrialGateType() const {
+ return getSubtype() != SUBTYPE_BUTTERFLY ? false : getSpawnSubtype() == SPAWN_TRIAL_GATE;
+ }
+ bool isGossipStoneType() const {
+ return getSubtype() != SUBTYPE_BUTTERFLY ? false : getSpawnSubtype() == SPAWN_GOSSIP_STONE;
+ }
+ bool isGoddessWallType() const {
+ return getSubtype() != SUBTYPE_BUTTERFLY ? false : getSpawnSubtype() == SPAWN_GODDESS_WALL;
+ }
};
#endif
diff --git a/include/nw4r/math/math_geometry.h b/include/nw4r/math/math_geometry.h
index 922942e8..657c95b3 100644
--- a/include/nw4r/math/math_geometry.h
+++ b/include/nw4r/math/math_geometry.h
@@ -36,6 +36,7 @@ struct AABB {
AABB() {}
AABB(const VEC3 &min, const VEC3 &max) : min(min), max(max) {}
+ AABB(f32 minX, f32 minY, f32 minZ, f32 maxX, f32 maxY, f32 maxZ) : min(minX, minY, minZ), max(maxX, maxY, maxZ) {}
void Set(const VEC3 *points, unsigned int num);
void Set(const AABB *box, const MTX34 *mtx);