Merge pull request #280 from lepelog/d_t_insect

d_t_insect
This commit is contained in:
Elijah Thomas
2025-12-05 14:14:59 -05:00
committed by GitHub
14 changed files with 690 additions and 51 deletions
@@ -81,9 +81,9 @@ lbl_255_data_1C8 = .data:0x000001C8; // type:object size:0xD8
lbl_255_data_2A0 = .data:0x000002A0; // type:object size:0x34
__global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global
lbl_255_bss_8 = .bss:0x00000008; // type:object size:0x10 data:4byte
AcOSoil__StateID_Soil = .bss:0x00000018; // type:object size:0x40 data:4byte
AcOSoil__StateID_Hole = .bss:0x00000058; // type:object size:0x40 data:4byte
AcOSoil__StateID_Ready = .bss:0x00000098; // type:object size:0x30 data:4byte
StateID_Soil__10dAcOsoil_c = .bss:0x00000018; // type:object size:0x40 data:4byte
StateID_Hole__10dAcOsoil_c = .bss:0x00000058; // type:object size:0x40 data:4byte
StateID_Ready__10dAcOsoil_c = .bss:0x00000098; // type:object size:0x30 data:4byte
lbl_255_bss_C8 = .bss:0x000000C8; // type:object size:0x1 data:byte
lbl_255_bss_CC = .bss:0x000000CC; // type:object size:0xC align:4 data:float
lbl_255_bss_D8 = .bss:0x000000D8; // type:object size:0x1 data:byte
+47 -31
View File
@@ -4,20 +4,20 @@ _unresolved = .text:0x00000060; // type:function size:0x4 scope:global
__register_global_object = .text:0x00000070; // type:function size:0x1C scope:global
__destroy_global_chain = .text:0x00000090; // type:function size:0x54 scope:global
dTgInsect_c_classInit__Fv = .text:0x000000F0; // type:function size:0xE0
__dt__11dTgInsect_cFv = .text:0x000001D0; // type:function size:0x58
__dt__5dTg_cFv = .text:0x000001D0; // type:function size:0x58
__dt__24sFState_c<11dTgInsect_c>Fv = .text:0x00000230; // type:function size:0x58
__dt__27sFStateFct_c<11dTgInsect_c>Fv = .text:0x00000290; // type:function size:0x6C
__dt__80sStateMgr_c<11dTgInsect_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000300; // type:function size:0xA0
__dt__50sFStateMgr_c<11dTgInsect_c,20sStateMethodUsr_FI_c>Fv = .text:0x000003A0; // type:function size:0xA4
fn_450_450 = .text:0x00000450; // type:function size:0x14
fn_450_470 = .text:0x00000470; // type:function size:0x58
fn_450_4D0 = .text:0x000004D0; // type:function size:0x140
TgInsect__init2 = .text:0x00000610; // type:function size:0x5B8
__ct__20dAcRef_c<9dAcBase_c>Fv = .text:0x00000450; // type:function size:0x14
__dt__20dAcRef_c<9dAcBase_c>Fv = .text:0x00000470; // type:function size:0x58
actorCreate__11dTgInsect_cFv = .text:0x000004D0; // type:function size:0x140
actorPostCreate__11dTgInsect_cFv = .text:0x00000610; // type:function size:0x5B8
changeState__80sStateMgr_c<11dTgInsect_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x00000BD0; // type:function size:0x10
fn_450_BE0 = .text:0x00000BE0; // type:function size:0x8
fn_450_BF0 = .text:0x00000BF0; // type:function size:0x30
doDelete__11dTgInsect_cFv = .text:0x00000BE0; // type:function size:0x8
actorExecute__11dTgInsect_cFv = .text:0x00000BF0; // type:function size:0x30
executeState__80sStateMgr_c<11dTgInsect_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000C20; // type:function size:0x10
fn_450_C30 = .text:0x00000C30; // type:function size:0x8
draw__11dTgInsect_cFv = .text:0x00000C30; // type:function size:0x8
initializeState_Wait__11dTgInsect_cFv = .text:0x00000C40; // type:function size:0x4
executeState_Wait__11dTgInsect_cFv = .text:0x00000C50; // type:function size:0x168
finalizeState_Wait__11dTgInsect_cFv = .text:0x00000DC0; // type:function size:0x4
@@ -30,11 +30,11 @@ finalizeState_WaitForceEscape__11dTgInsect_cFv = .text:0x000012A0; // type:funct
initializeState_End__11dTgInsect_cFv = .text:0x000012B0; // type:function size:0x4
executeState_End__11dTgInsect_cFv = .text:0x000012C0; // type:function size:0x4
finalizeState_End__11dTgInsect_cFv = .text:0x000012D0; // type:function size:0x4
fn_450_12E0 = .text:0x000012E0; // type:function size:0x64
fn_450_1350 = .text:0x00001350; // type:function size:0x530
fn_450_1880 = .text:0x00001880; // type:function size:0x140
fn_450_19C0 = .text:0x000019C0; // type:function size:0x1E0
fn_450_1BA0 = .text:0x00001BA0; // type:function size:0xF0
spawnAll__11dTgInsect_cFv = .text:0x000012E0; // type:function size:0x64
spawnInsect__11dTgInsect_cFl = .text:0x00001350; // type:function size:0x530
shouldSpawn__11dTgInsect_cFv = .text:0x00001880; // type:function size:0x140
checkValidSpawnLocation__11dTgInsect_cFRC7mVec3_cb = .text:0x000019C0; // type:function size:0x1E0
__dt__11dTgInsect_cFv = .text:0x00001BA0; // type:function size:0xF0
getStateID__80sStateMgr_c<11dTgInsect_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00001C90; // type:function size:0x10
build__27sFStateFct_c<11dTgInsect_c>FRC12sStateIDIf_c = .text:0x00001CA0; // type:function size:0x60
dispose__27sFStateFct_c<11dTgInsect_c>FRP10sStateIf_c = .text:0x00001D00; // type:function size:0xC
@@ -56,25 +56,41 @@ isSameName__26sFStateID_c<11dTgInsect_c>CFPCc = .text:0x00002200; // type:functi
_ctors = .ctors:0x00000000; // type:label scope:global
_dtors = .dtors:0x00000000; // type:label scope:global
__destroy_global_chain_reference = .dtors:0x00000000; // type:object size:0x4 scope:global
lbl_450_rodata_0 = .rodata:0x00000000; // type:object size:0x20 data:float
lbl_450_rodata_20 = .rodata:0x00000020; // type:object size:0x4 align:4 data:float
lbl_450_rodata_24 = .rodata:0x00000024; // type:object size:0xC
lbl_450_rodata_30 = .rodata:0x00000030; // type:object size:0x4 align:4 data:float
lbl_450_rodata_34 = .rodata:0x00000034; // type:object size:0x4 align:4 data:float
lbl_450_rodata_38 = .rodata:0x00000038; // type:object size:0x14 align:4 data:float
lbl_450_rodata_4C = .rodata:0x0000004C; // type:object size:0x20 align:4 data:float
lbl_450_rodata_6C = .rodata:0x0000006C; // type:object size:0x4 align:4 data:float
lbl_450_rodata_70 = .rodata:0x00000070; // type:object size:0x8 align:4 data:float
unused = .rodata:0x00000000; // type:object size:0x20 scope:local data:float
SCALE_X__11dTgInsect_c = .rodata:0x00000020; // type:object size:0x4 scope:global align:4 data:float
SCALE_Y__11dTgInsect_c = .rodata:0x00000024; // type:object size:0x4 scope:global align:4 data:float
unused2 = .rodata:0x00000028; // type:object size:0x8 scope:local data:float
lbl_450_rodata_30 = .rodata:0x00000030; // type:object size:0x4 scope:local align:4 data:float
lbl_450_rodata_34 = .rodata:0x00000034; // type:object size:0x4 scope:local align:4 data:float
lbl_450_rodata_38 = .rodata:0x00000038; // type:object size:0x4 scope:local align:4 data:float
lbl_450_rodata_3C = .rodata:0x0000003C; // type:object size:0x4 scope:local align:4 data:float
lbl_450_rodata_40 = .rodata:0x00000040; // type:object size:0x4 scope:local align:4 data:float
lbl_450_rodata_44 = .rodata:0x00000044; // type:object size:0x4 scope:local align:4 data:float
lbl_450_rodata_48 = .rodata:0x00000048; // type:object size:0x4 scope:local align:4 data:float
lbl_450_rodata_4C = .rodata:0x0000004C; // type:object size:0x4 scope:local align:4 data:float
FLOAT_ARRAY = .rodata:0x00000050; // type:object size:0x14 scope:local align:4 data:float
lbl_450_rodata_64 = .rodata:0x00000064; // type:object size:0x4 scope:local align:4 data:float
lbl_450_rodata_68 = .rodata:0x00000068; // type:object size:0x4 scope:local align:4 data:float
lbl_450_rodata_6C = .rodata:0x0000006C; // type:object size:0x4 scope:local align:4 data:float
lbl_450_rodata_70 = .rodata:0x00000070; // type:object size:0x4 scope:local align:4 data:4byte
lbl_450_rodata_74 = .rodata:0x00000074; // type:object size:0x4 scope:local align:4 data:4byte
g_profile_TAG_INSECT = .data:0x00000000; // type:object size:0x10 data:4byte
jumptable_450_data_10 = .data:0x00000010; // type:object size:0x2C scope:local
jumptable_450_data_3C = .data:0x0000003C; // type:object size:0x2C scope:local
lbl_450_data_68 = .data:0x00000068; // type:object size:0x78
lbl_450_data_E0 = .data:0x000000E0; // type:object size:0x30
lbl_450_data_110 = .data:0x00000110; // type:object size:0x30
lbl_450_data_140 = .data:0x00000140; // type:object size:0x18
lbl_450_data_158 = .data:0x00000158; // type:object size:0x19C
lbl_450_data_2F4 = .data:0x000002F4; // type:object size:0x34
__vt__11dTgInsect_c = .data:0x00000068; // type:object size:0x74
__vt__50sFStateMgr_c<11dTgInsect_c,20sStateMethodUsr_FI_c> = .data:0x000000E0; // type:object size:0x30
__vt__80sStateMgr_c<11dTgInsect_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x00000110; // type:object size:0x30
__vt__27sFStateFct_c<11dTgInsect_c> = .data:0x00000140; // type:object size:0x14
lbl_450_data_158 = .data:0x00000158; // type:object size:0x18 scope:local
__vt__5dTg_c = .data:0x00000170; // type:object size:0x74
lbl_450_data_1E4 = .data:0x000001E4; // type:object size:0x110
lbl_450_data_2F4 = .data:0x000002F4; // type:object size:0x34 scope:local
__global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global
lbl_450_bss_8 = .bss:0x00000008; // type:object size:0x10 data:4byte
lbl_450_bss_18 = .bss:0x00000018; // type:object size:0xC0 data:4byte
lbl_450_bss_D8 = .bss:0x000000D8; // type:object size:0x30 data:4byte
lbl_450_bss_8 = .bss:0x00000008; // type:object size:0x10 scope:local data:4byte
StateID_Wait__11dTgInsect_c = .bss:0x00000018; // type:object size:0x30 data:4byte
lbl_250_bss_48 = .bss:0x00000048; // type:object size:0x10 scope:local data:4byte
StateID_WaitCreate__11dTgInsect_c = .bss:0x00000058; // type:object size:0x30 data:4byte
lbl_250_bss_88 = .bss:0x00000088; // type:object size:0x10 scope:local data:4byte
StateID_WaitForceEscape__11dTgInsect_c = .bss:0x00000098; // type:object size:0x30 data:4byte
lbl_250_bss_C8 = .bss:0x000000C8; // type:object size:0x10 scope:local data:4byte
StateID_End__11dTgInsect_c = .bss:0x000000D8; // type:object size:0x30 data:4byte
+2 -2
View File
@@ -1142,7 +1142,7 @@ create__12dAcObjBase_cFP12dAcObjBase_cQ28fProfile14PROFILE_NAME_eUlPC7mVec3_cPC7
fn_8002EF70 = .text:0x8002EF70; // type:function size:0x28
fn_8002EFA0 = .text:0x8002EFA0; // type:function size:0x50
fn_8002eff0__12dAcObjBase_cFRCfRCsP8cCcD_ObjRCfRCf = .text:0x8002EFF0; // type:function size:0x194
fn_8002F190 = .text:0x8002F190; // type:function size:0x24
createInsectActor__12dAcObjBase_cFP9dAcBase_cQ28fProfile14PROFILE_NAME_eUlP7mVec3_cP7mAng3_cP7mVec3_cUll = .text:0x8002F190; // type:function size:0x24
createActorUnkGroup3__12dAcObjBase_cFQ28fProfile14PROFILE_NAME_eUlUlP7mVec3_cP7mAng3_cP7mVec3_cUl = .text:0x8002F1C0; // type:function size:0x98
createActorUnkGroup3__12dAcObjBase_cFPCcUlUlPC7mVec3_cPC7mAng3_cPC7mVec3_cUlUsSc = .text:0x8002F260; // type:function size:0xA0
__ct__11dAcEnBase_cFv = .text:0x8002F300; // type:function size:0x74
@@ -17270,7 +17270,7 @@ cLib__chasePos = .text:0x802E03D0; // type:function size:0x174
chasePosXZ__4cLibFR7mVec3_cR7mVec3_cf = .text:0x802E0550; // type:function size:0x124
targetAngleY__4cLibFRC7mVec3_cRC7mVec3_c = .text:0x802E0680; // type:function size:0x1C
targetAngleX__4cLibFRC7mVec3_cRC7mVec3_c = .text:0x802E06A0; // type:function size:0x68
cLib__offsetPos = .text:0x802E0710; // type:function size:0xD8
offsetPos__4cLibFR7mVec3_cRC7mVec3_csRC7mVec3_c = .text:0x802E0710; // type:function size:0xD8
easeIn__4cLibFff = .text:0x802E07F0; // type:function size:0x24
easeOut__4cLibFff = .text:0x802E0820; // type:function size:0x34
easeInOut__4cLibFff = .text:0x802E0860; // type:function size:0x60
+1 -1
View File
@@ -2903,7 +2903,7 @@ config.libs = [
Rel(NonMatching, "d_t_harp", "REL/d/t/d_t_harp.cpp"),
Rel(Matching, "d_t_heat_resist", "REL/d/t/d_t_heat_resist.cpp"),
Rel(Matching, "d_t_holy_water", "REL/d/t/d_t_holy_water.cpp"),
Rel(NonMatching, "d_t_insect", "REL/d/t/d_t_insect.cpp"),
Rel(Matching, "d_t_insect", "REL/d/t/d_t_insect.cpp"),
Rel(NonMatching, "d_t_ks", "REL/d/t/d_t_ks.cpp"),
Rel(NonMatching, "d_t_kytag", "REL/d/t/d_t_kytag.cpp"),
Rel(NonMatching, "d_t_lb_thunder", "REL/d/t/d_t_lb_thunder.cpp"),
+1
View File
@@ -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);
+8
View File
@@ -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,
+9 -2
View File
@@ -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
+5
View File
@@ -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
+6 -1
View File
@@ -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
+48
View File
@@ -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);
};
+4 -4
View File
@@ -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
+83 -2
View File
@@ -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
+1
View File
@@ -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);
+472 -5
View File
@@ -1,5 +1,31 @@
#include "d/t/d_t_insect.h"
#include "c/c_lib.h"
#include "c/c_math.h"
#include "common.h"
#include "d/a/d_a_base.h"
#include "d/a/d_a_insect_butterfly.h"
#include "d/a/d_a_item.h"
#include "d/a/d_a_itembase.h"
#include "d/a/obj/d_a_obj_base.h"
#include "d/a/obj/d_a_obj_soil.h"
#include "d/a/obj/d_a_obj_warp.h"
#include "d/col/bg/d_bg_s.h"
#include "d/col/bg/d_bg_s_gnd_chk.h"
#include "d/col/bg/d_bg_s_lin_chk.h"
#include "d/flag/itemflag_manager.h"
#include "d/flag/sceneflag_manager.h"
#include "d/flag/storyflag_manager.h"
#include "f/f_base.h"
#include "f/f_manager.h"
#include "f/f_profile.h"
#include "f/f_profile_name.h"
#include "m/m_angle.h"
#include "m/m_vec.h"
#include "nw4r/math/math_geometry.h"
#include "nw4r/math/math_types.h"
#include "rvl/MTX/mtx.h"
SPECIAL_ACTOR_PROFILE(TAG_INSECT, dTgInsect_c, fProfile::TAG_INSECT, 0x167, 0, 0);
STATE_DEFINE(dTgInsect_c, Wait);
@@ -7,15 +33,456 @@ STATE_DEFINE(dTgInsect_c, WaitCreate);
STATE_DEFINE(dTgInsect_c, WaitForceEscape);
STATE_DEFINE(dTgInsect_c, End);
static const s32 unused[] = {
0x001E0100, 0, 0, 0, 0, 0, 0, 0,
};
const f32 dTgInsect_c::SCALE_X = 100;
const f32 dTgInsect_c::SCALE_Y = 100;
static const f32 unused2[] = {150, 0.5f};
const s32 *useUnused() {
return unused + (s32)unused2;
}
int dTgInsect_c::actorCreate() {
if (getSubtype() == SUBTYPE_INVALID0) {
return FAILED;
}
if (getSubtype() == SUBTYPE_INVALID1) {
return FAILED;
}
if (getSubtype() == SUBTYPE_INVALID2) {
return FAILED;
}
mInsectCount = getInsectCount();
if (mInsectCount > 0xF) {
mInsectCount = 0xF;
} else {
if (mInsectCount == 0xF) {
mInsectCount = 1;
}
}
mScale *= 0.01f;
mRevealed = 0;
mRevealedSpawnPos = mPosition;
if (isTrialGateType() || isGossipStoneType() || isGoddessWallType() || isSpawnSubtype(SPAWN_BUG_MINIGAME)) {
field_0x24e = 1;
}
return SUCCEEDED;
}
inline bool checkProfile(u16 prof, u32 target) {
return prof == target;
}
int dTgInsect_c::actorPostCreate() {
Subtype subtype = getSubtype();
// ??? doesn't match without the double comparison
if (subtype == SUBTYPE_WOODLAND_RHINO_BEETLE
|| subtype == SUBTYPE_WOODLAND_RHINO_BEETLE
|| subtype == SUBTYPE_SAND_CICADA
|| subtype == SUBTYPE_VOLCANIC_LADYBUG
|| subtype == SUBTYPE_SKY_STAG_BEETLE) {
if (!checkValidSpawnLocation(mPosition, 1)) {
return FAILED;
}
}
dAcBase_c *obj = nullptr;
do {
obj = searchNextActor(obj);
if (obj == nullptr) {
break;
}
u16 prof = obj->mProfileName;
if ((
checkProfile(prof, fProfile::OBJ_TUBO) || checkProfile(prof, fProfile::OBJ_CARRY_STONE) ||
checkProfile(prof, fProfile::OBJ_OCT_GRASS_LEAF) || checkProfile(prof, fProfile::OBJ_FRUIT) ||
checkProfile(prof, fProfile::OBJ_BARREL) || checkProfile(prof, fProfile::OBJ_VSD) ||
checkProfile(prof, fProfile::OBJ_SOIL)
) &&
getSquareDistanceTo(obj->mPosition) < 25) {
if (subtype == SUBTYPE_FARON_GRASSHOPPER
|| subtype == SUBTYPE_SKYLOFT_MANTIS
|| subtype == SUBTYPE_LANAYRU_ANT
|| subtype == SUBTYPE_EDLIN_ROLLER) {
if (prof == fProfile::OBJ_SOIL && static_cast<dAcOsoil_c *>(obj)->isStateHole()) {
return FAILED;
}
setActorRef(obj);
}
break;
}
} while (true);
if (mActorNode.isLinked()) {
mStateMgr.changeState(StateID_WaitCreate);
} else {
if (isSpawnSubtype(SPAWN_BUG_MINIGAME)) {
for (s32 i = 0; i < (s32)ARRAY_LENGTH(field_0x1f8); i++) {
field_0x1f8[i] = 0;
}
mStateMgr.changeState(StateID_Wait);
} else if (isTrialGateType()) {
dAcOWarp_c *warp = static_cast<dAcOWarp_c *>(fManager_c::searchBaseByProfName(fProfile::OBJ_WARP));
if (warp == nullptr) {
return FAILED;
}
if (!warp->checkThisHasSongItem() || warp->isTrialComplete()) {
return FAILED;
}
if ((warp->mPosition - mPosition).squareMagXZ() < 1000000.f) {
mWarpRef.link(warp);
} else {
return FAILED;
}
mStateMgr.changeState(StateID_WaitForceEscape);
} else if (isGossipStoneType()) {
if (!ItemflagManager::sInstance->getFlagDirect(ITEM_BALLAD_OF_THE_GODDESS)) {
return FAILED;
}
if (!StoryflagManager::sInstance->getFlag(STORYFLAG_IMPRISONED_1_DEFEATED)) {
return FAILED;
}
if (SceneflagManager::sInstance->checkBoolFlag(mRoomID, mParams >> 0xC & 0xFF)) {
return FAILED;
}
} else if (isGoddessWallType()) {
if (!ItemflagManager::sInstance->getFlagDirect(ITEM_BALLAD_OF_THE_GODDESS)) {
return FAILED;
}
if (!StoryflagManager::sInstance->getFlag(STORYFLAG_FARON_TRIAL_COMPLETE)) {
return FAILED;
}
mStateMgr.changeState(StateID_WaitForceEscape);
} else {
mStateMgr.changeState(StateID_End);
}
spawnAll();
}
return SUCCEEDED;
}
int dTgInsect_c::doDelete() {
return SUCCEEDED;
}
int dTgInsect_c::actorExecute() {
mStateMgr.executeState();
return SUCCEEDED;
}
int dTgInsect_c::draw() {
return SUCCEEDED;
}
void dTgInsect_c::initializeState_Wait() {}
void dTgInsect_c::executeState_Wait() {}
#pragma opt_strength_reduction off
void dTgInsect_c::executeState_Wait() {
if (isSpawnSubtype(SPAWN_BUG_MINIGAME)) {
s32 i = 0;
for (; i < mInsectCount; i++) {
if (!mLinks[i].isLinked()) {
if (mInsectRespawnTimers[i] > 0) {
mInsectRespawnTimers[i]--;
} else if (mInsectRespawnTimers[i] == 0) {
nw4r::math::MTX34 mtx;
PSMTXTrans(mtx, mPosition.x, mPosition.y, mPosition.z);
nw4r::math::MTX34 scale;
PSMTXScale(scale, mScale.x, mScale.y, mScale.x);
PSMTXConcat(mtx, scale, mtx);
nw4r::math::AABB aabb(-100, 0, -100, 100, 100, 100);
aabb.Set(&aabb, &mtx);
if (fn_801BB750(&aabb, 10000)) {
spawnInsect(i);
}
} else {
mInsectRespawnTimers[i] = 900;
}
}
}
}
}
#pragma opt_strength_reduction on
void dTgInsect_c::finalizeState_Wait() {}
void dTgInsect_c::initializeState_WaitCreate() {}
void dTgInsect_c::executeState_WaitCreate() {}
void dTgInsect_c::initializeState_WaitCreate() {
if (!isSpawnSubtype(SPAWN_BUG_MINIGAME)) {
field_0x24f = 1;
for (s32 i = 0; i < mInsectCount; i++) {
mShouldSpawn[i] = shouldSpawn();
}
}
}
void dTgInsect_c::executeState_WaitCreate() {
if (mActorNode.isLinked()) {
if (mActorNode.get()->mProfileName == fProfile::OBJ_VSD ||
mActorNode.get()->mProfileName == fProfile::OBJ_SOIL) {
if (mRevealed == 0) {
return;
}
} else {
if (mPosition.squareDistanceToXZ(mActorNode.get()->mPosition) < 25) {
return;
}
}
}
mActorNode.unlink();
for (s32 i = 0; i < mInsectCount; i++) {
if (!isSpawnSubtype(SPAWN_BUG_MINIGAME)) {
if (mShouldSpawn[i] != 0) {
mShouldSpawn[i] = 0;
} else {
continue;
}
}
dAcBase_c *insect = nullptr;
mVec3_c tmp1 = mPosition;
if (mRevealed) {
tmp1 = mRevealedSpawnPos;
}
mAng3_c rot(0, cM::rndFX(65536), 0);
switch (getSubtype()) {
case SUBTYPE_LANAYRU_ANT:
insect = dAcObjBase_c::createInsectActor(this, fProfile::INSECT_ANT, 1, &tmp1, &rot, nullptr, 0, 0x3f);
break;
case SUBTYPE_FARON_GRASSHOPPER:
insect = dAcObjBase_c::createInsectActor(
this, fProfile::INSECT_GRASSHOPPER, 1, &tmp1, &rot, nullptr, 0, 0x3f
);
break;
case SUBTYPE_SKYLOFT_MANTIS:
insect = dAcObjBase_c::createInsectActor(
this, fProfile::INSECT_GRASSHOPPER, 0x10000001, &tmp1, &rot, nullptr, 0, 0x3f
);
break;
case SUBTYPE_EDLIN_ROLLER:
insect =
dAcObjBase_c::createInsectActor(this, fProfile::INSECT_SCARAB, 1, &tmp1, &rot, nullptr, 0, 0x3f);
break;
}
if (insect != nullptr) {
mLinks[i].link(insect);
mInsectRespawnTimers[i] = -1;
}
}
if (isSpawnSubtype(SPAWN_BUG_MINIGAME)) {
mStateMgr.changeState(StateID_Wait);
} else {
mStateMgr.changeState(StateID_End);
}
}
void dTgInsect_c::finalizeState_WaitCreate() {}
void dTgInsect_c::initializeState_WaitForceEscape() {}
void dTgInsect_c::executeState_WaitForceEscape() {}
void dTgInsect_c::initializeState_WaitForceEscape() {
for (s32 i = 0; i < mInsectCount; i++) {
dAcOInsect_c* tmp = static_cast<dAcOInsect_c*>(mLinks[i].get());
if (tmp) {
tmp->setActorProperty(AC_PROP_0x4);
}
}
}
void dTgInsect_c::executeState_WaitForceEscape() {
if (isTrialGateType()) {
if (mWarpRef.isLinked()) {
dAcOWarp_c *warp = static_cast<dAcOWarp_c *>(mWarpRef.get());
if (warp->fn_0x90()) {
for (s32 i = 0; i < mInsectCount; i++) {
if (mLinks[i].isLinked()) {
static_cast<dAcInsectButterfly_c *>(mLinks[i].get())->setKillSignal();
mStateMgr.changeState(StateID_End);
}
}
}
}
} else if (isGoddessWallType() && mKillSignal) {
for (s32 i = 0; i < mInsectCount; i++) {
if (mLinks[i].isLinked()) {
static_cast<dAcInsectButterfly_c *>(mLinks[i].get())->setKillSignal();
mStateMgr.changeState(StateID_End);
}
}
}
}
void dTgInsect_c::finalizeState_WaitForceEscape() {}
void dTgInsect_c::initializeState_End() {}
void dTgInsect_c::executeState_End() {}
void dTgInsect_c::finalizeState_End() {}
static const f32 FLOAT_ARRAY[] = {
0.1f, -0.4f, 0.3f, 0.7f, -0.7f,
};
void dTgInsect_c::spawnAll() {
for (s32 i = 0; i < mInsectCount; i++) {
if (shouldSpawn()) {
spawnInsect(i);
}
}
}
void dTgInsect_c::spawnInsect(s32 index) {
f32 scaleX;
f32 scaleY;
f32 scaleXExt;
f32 scaleYExt;
f32 scaledScaleY;
f32 scaledScaleX;
f32 mult;
f32 scaledTemp;
scaleY = mScale.y;
scaleYExt = SCALE_Y;
scaledScaleY = scaleY * scaleYExt;
mult = 0.85f;
scaleXExt = SCALE_X;
scaleX = mScale.x;
scaledTemp = scaleXExt * scaleX;
scaledScaleX = mult * scaledTemp;
s16 angle1;
mVec3_c pos;
mVec3_c tmp;
mAng3_c rot(0, 0, 0);
bool spawnFound = false;
s32 tries = 5;
do {
f32 scale = cM::rndF(scaledScaleX);
angle1 = cM::rndFX(65536.0f);
rot.y = cM::rndFX(65536.0f);
mVec3_c v2 = mVec3_c::Ez * scale;
cLib::offsetPos(pos, mPosition, angle1, v2);
switch (getSubtype()) {
case SUBTYPE_VOLCANIC_LADYBUG:
case SUBTYPE_WOODLAND_RHINO_BEETLE:
case SUBTYPE_SAND_CICADA:
case SUBTYPE_SKY_STAG_BEETLE:
pos = mPosition;
if (getSubtype() == SUBTYPE_SAND_CICADA) {
tmp = mVec3_c::Ez;
tmp.rotY(mAng(mRotation.y + 0x4000));
f32 arrayResult = FLOAT_ARRAY[index % (s32)ARRAY_LENGTH(FLOAT_ARRAY)];
f32 scaledX = SCALE_X * mScale.x;
tmp.multScalar(arrayResult * scaledX);
pos = mPosition + tmp;
f32 scaledScale = SCALE_Y * mScale.y;
pos.y = mPosition.y + scaledScale * 0.3f;
pos.y += cM::rndF(scaledScale * 0.5f);
if (!checkValidSpawnLocation(pos, 0)) {
return;
}
} else {
pos.y += cM::rndF(scaledScaleY);
}
spawnFound = true;
break;
case SUBTYPE_FARON_GRASSHOPPER:
case SUBTYPE_LANAYRU_ANT:
case SUBTYPE_SKYLOFT_MANTIS:
case SUBTYPE_EDLIN_ROLLER:
pos.y = 100 + mPosition.y;
if (dBgS_ObjGndChk::CheckPos(pos)) {
spawnFound = true;
}
break;
case SUBTYPE_GERUDO_DRAGONFLY:
case SUBTYPE_BUTTERFLY:
case SUBTYPE_STARRY_FIREFLY:
spawnFound = true;
break;
}
} while (!spawnFound && --tries);
dAcBase_c *ref = nullptr;
switch (getSubtype()) {
case SUBTYPE_VOLCANIC_LADYBUG:
ref = dAcObjBase_c::createInsectActor(this, fProfile::INSECT_LADYBUG, 0, &pos, &rot, NULL, 0, 0x3f);
break;
case SUBTYPE_GERUDO_DRAGONFLY:
ref = dAcObjBase_c::createInsectActor(this, fProfile::INSECT_DRAGONFLY, 0, &pos, &rot, NULL, 0, 0x3f);
break;
case SUBTYPE_WOODLAND_RHINO_BEETLE:
ref = dAcObjBase_c::createInsectActor(this, fProfile::INSECT_BEETLE, 0, &pos, &rot, NULL, 0, 0x3f);
break;
case SUBTYPE_FARON_GRASSHOPPER:
ref = dAcObjBase_c::createInsectActor(this, fProfile::INSECT_GRASSHOPPER, 0, &pos, &rot, NULL, 0, 0x3f);
break;
case SUBTYPE_SAND_CICADA:
ref = dAcObjBase_c::createInsectActor(this, fProfile::INSECT_CICADA, 0, &pos, &rot, NULL, 0, 0x3f);
break;
case SUBTYPE_LANAYRU_ANT:
ref = dAcObjBase_c::createInsectActor(this, fProfile::INSECT_ANT, 0, &pos, &rot, NULL, 0, 0x3f);
break;
case SUBTYPE_SKY_STAG_BEETLE:
ref = dAcObjBase_c::createInsectActor(this, fProfile::INSECT_BEETLE, 0x10000000, &pos, &rot, NULL, 0, 0x3f);
break;
case SUBTYPE_BUTTERFLY:
ref = dAcObjBase_c::createInsectActor(
this, fProfile::INSECT_BUTTERFLY, (s16)mViewClipIdx, &pos, &rot, NULL, 0, 0x3f
);
break;
case SUBTYPE_SKYLOFT_MANTIS:
ref = dAcObjBase_c::createInsectActor(
this, fProfile::INSECT_GRASSHOPPER, 0x10000000, &pos, &rot, NULL, 0, 0x3f
);
break;
case SUBTYPE_EDLIN_ROLLER:
ref = dAcObjBase_c::createInsectActor(this, fProfile::INSECT_SCARAB, 0, &pos, &rot, NULL, 0, 0x3f);
break;
case SUBTYPE_STARRY_FIREFLY:
ref = dAcObjBase_c::createInsectActor(this, fProfile::INSECT_FIREFLY, 0, &pos, &rot, NULL, 0, 0x3f);
break;
}
if (ref != nullptr) {
mLinks[index].link(ref);
mInsectRespawnTimers[index] = -1;
}
return;
}
bool dTgInsect_c::shouldSpawn() {
if (isSpawnSubtype(SPAWN_BUG_MINIGAME)) {
return true;
} else if (isSpawnSubtype(SPAWN_SKYLOFT_BUGKID_TREE)) {
return !SceneflagManager::sInstance->checkBoolFlag(mRoomID, 0x3a);
} else {
if (isTrialGateType()) {
return true;
} else if (isGossipStoneType() || isGoddessWallType()) {
return true;
} else if ((isSubtype(SUBTYPE_STARRY_FIREFLY)) && !dAcItem_c::checkFlag(ITEM_STARRY_FIREFLY)) {
return true;
} else {
if (cM::rndF(1.0f) >= 0.5f) {
return false;
} else {
return true;
}
}
}
}
bool dTgInsect_c::checkValidSpawnLocation(const mVec3_c &pos, bool updateRotation) {
mVec3_c tmp = mVec3_c::Ez * (SCALE_X * mScale.x);
tmp.rotY(mRotation.y);
tmp += pos;
dBgS_LinChk linChk;
linChk.mBackFlag = true;
linChk.mFrontFlag = false;
linChk.Set(&pos, &tmp, nullptr);
if (!dBgS::GetInstance()->LineCross(&linChk)) {
mAng yRot = mRotation.y + 0x7FFF;
if (updateRotation) {
mRotation.y = yRot;
}
tmp = mVec3_c::Ez * (SCALE_X * mScale.x);
tmp.rotY(yRot);
tmp += pos;
linChk.Set(&pos, &tmp, nullptr);
if (!dBgS::GetInstance()->LineCross(&linChk)) {
return false;
}
}
return true;
}
void moreUnused() {
static const s32 a = 0x3a;
}