mirror of
https://github.com/zeldaret/ss
synced 2026-06-16 23:00:00 -04:00
dAcOtrapRock1_c OK (#93)
* dAcOtrapRock1_c but it's angles again * dAcOtrapRock1_c OK (thanks LagoLunatic and Zeldex!)
This commit is contained in:
@@ -17,3 +17,6 @@ REL/global_destructor_chain.c:
|
||||
REL/d/a/obj/d_a_obj_trap_rock_1.cpp:
|
||||
.text start:0x000000F0 end:0x00001118
|
||||
.ctors start:0x00000000 end:0x00000004
|
||||
.rodata start:0x00000000 end:0x00000024
|
||||
.data start:0x00000000 end:0x0000028C
|
||||
.bss start:0x00000008 end:0x000000D8
|
||||
|
||||
@@ -8,13 +8,13 @@ __dt__28sFState_c<15dAcOtrapRock1_c>Fv = .text:0x000001C0; // type:function size
|
||||
__dt__31sFStateFct_c<15dAcOtrapRock1_c>Fv = .text:0x00000220; // type:function size:0x6C
|
||||
__dt__84sStateMgr_c<15dAcOtrapRock1_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000290; // type:function size:0xA0
|
||||
__dt__54sFStateMgr_c<15dAcOtrapRock1_c,20sStateMethodUsr_FI_c>Fv = .text:0x00000330; // type:function size:0xA4
|
||||
AcOtrapRock__initModels = .text:0x000003E0; // type:function size:0xE0
|
||||
AcOtrapRock__init = .text:0x000004C0; // type:function size:0x178
|
||||
createHeap__15dAcOtrapRock1_cFv = .text:0x000003E0; // type:function size:0xE0
|
||||
create__15dAcOtrapRock1_cFv = .text:0x000004C0; // type:function size:0x178
|
||||
changeState__84sStateMgr_c<15dAcOtrapRock1_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x00000640; // type:function size:0x10
|
||||
fn_261_650 = .text:0x00000650; // type:function size:0x8
|
||||
AcOtrapRock__update = .text:0x00000660; // type:function size:0x5C
|
||||
doDelete__15dAcOtrapRock1_cFv = .text:0x00000650; // type:function size:0x8
|
||||
actorExecute__15dAcOtrapRock1_cFv = .text:0x00000660; // type:function size:0x5C
|
||||
executeState__84sStateMgr_c<15dAcOtrapRock1_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x000006C0; // type:function size:0x10
|
||||
AcOtrapRock__draw = .text:0x000006D0; // type:function size:0x28
|
||||
draw__15dAcOtrapRock1_cFv = .text:0x000006D0; // type:function size:0x28
|
||||
initializeState_TrapWait__15dAcOtrapRock1_cFv = .text:0x00000700; // type:function size:0x4
|
||||
executeState_TrapWait__15dAcOtrapRock1_cFv = .text:0x00000710; // type:function size:0x74
|
||||
finalizeState_TrapWait__15dAcOtrapRock1_cFv = .text:0x00000790; // type:function size:0x4
|
||||
@@ -46,20 +46,20 @@ isSameName__30sFStateID_c<15dAcOtrapRock1_c>CFPCc = .text:0x00001090; // type:fu
|
||||
_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_261_rodata_0 = .rodata:0x00000000; // type:object size:0xC data:float
|
||||
lbl_261_rodata_C = .rodata:0x0000000C; // type:object size:0x4 data:float
|
||||
lbl_261_rodata_10 = .rodata:0x00000010; // type:object size:0x4 data:float
|
||||
lbl_261_rodata_18 = .rodata:0x00000018; // type:object size:0xC
|
||||
g_profile_OBJ_TRAP_ROCK_1 = .data:0x00000000; // type:object size:0x50 data:4byte
|
||||
lbl_261_data_50 = .data:0x00000050; // type:object size:0x20
|
||||
lbl_261_data_70 = .data:0x00000070; // type:object size:0x80
|
||||
lbl_261_data_F0 = .data:0x000000F0; // type:object size:0x30
|
||||
lbl_261_data_120 = .data:0x00000120; // type:object size:0x30
|
||||
lbl_261_data_150 = .data:0x00000150; // type:object size:0x18
|
||||
lbl_261_data_168 = .data:0x00000168; // type:object size:0xF0
|
||||
lbl_261_data_258 = .data:0x00000258; // type:object size:0x34
|
||||
lbl_261_rodata_0 = .rodata:0x00000000; // type:object size:0xC scope:local data:float
|
||||
lbl_261_rodata_C = .rodata:0x0000000C; // type:object size:0x4 scope:local data:float
|
||||
lbl_261_rodata_10 = .rodata:0x00000010; // type:object size:0x4 scope:local data:float
|
||||
lbl_261_rodata_18 = .rodata:0x00000018; // type:object size:0xC scope:local
|
||||
g_profile_OBJ_TRAP_ROCK_1 = .data:0x00000000; // type:object size:0x10 data:4byte
|
||||
lbl_261_data_50 = .data:0x00000050; // type:object size:0x20 scope:local
|
||||
__vt__15dAcOtrapRock1_c = .data:0x00000070; // type:object size:0x80
|
||||
__vt__54sFStateMgr_c<15dAcOtrapRock1_c,20sStateMethodUsr_FI_c> = .data:0x000000F0; // type:object size:0x30
|
||||
__vt__84sStateMgr_c<15dAcOtrapRock1_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x00000120; // type:object size:0x30
|
||||
__vt__31sFStateFct_c<15dAcOtrapRock1_c> = .data:0x00000150; // type:object size:0x14
|
||||
__vt__28sFState_c<15dAcOtrapRock1_c> = .data:0x00000168; // type:object size:0x18
|
||||
__vt__30sFStateID_c<15dAcOtrapRock1_c> = .data:0x00000258; // type:object size:0x34
|
||||
__global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global
|
||||
lbl_261_bss_8 = .bss:0x00000008; // type:object size:0x10 data:4byte
|
||||
lbl_261_bss_18 = .bss:0x00000018; // type:object size:0x40 data:4byte
|
||||
lbl_261_bss_58 = .bss:0x00000058; // type:object size:0x40 data:4byte
|
||||
lbl_261_bss_98 = .bss:0x00000098; // type:object size:0x40 data:4byte
|
||||
lbl_261_bss_8 = .bss:0x00000008; // type:object size:0xC scope:local data:4byte
|
||||
StateID_TrapWait__15dAcOtrapRock1_c = .bss:0x00000018; // type:object size:0x30 data:4byte
|
||||
StateID_TrapAction__15dAcOtrapRock1_c = .bss:0x00000058; // type:object size:0x30 data:4byte
|
||||
StateID_TrapReturn__15dAcOtrapRock1_c = .bss:0x00000098; // type:object size:0x30 data:4byte
|
||||
|
||||
+1
-1
@@ -1670,7 +1670,7 @@ config.libs = [
|
||||
Rel(
|
||||
NonMatching, "d_a_obj_trap_bird_wood", "REL/d/a/obj/d_a_obj_trap_bird_wood.cpp"
|
||||
),
|
||||
Rel(NonMatching, "d_a_obj_trap_rock_1", "REL/d/a/obj/d_a_obj_trap_rock_1.cpp"),
|
||||
Rel(Matching, "d_a_obj_trap_rock_1", "REL/d/a/obj/d_a_obj_trap_rock_1.cpp"),
|
||||
Rel(
|
||||
NonMatching,
|
||||
"d_a_obj_treasure_island",
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#define D_A_OBJ_TRAP_ROCK_1_H
|
||||
|
||||
#include "d/a/obj/d_a_obj_base.h"
|
||||
#include "d/col/bg/d_bg_w.h"
|
||||
#include "m/m3d/m_smdl.h"
|
||||
#include "nw4r/g3d/g3d_resfile.h"
|
||||
#include "s/s_State.hpp"
|
||||
#include "s/s_StateMgr.hpp"
|
||||
|
||||
@@ -10,12 +13,28 @@ public:
|
||||
dAcOtrapRock1_c() : mStateMgr(*this, sStateID::null) {}
|
||||
virtual ~dAcOtrapRock1_c() {}
|
||||
|
||||
virtual bool createHeap() override;
|
||||
virtual int create() override;
|
||||
virtual int doDelete() override;
|
||||
virtual int actorExecute() override;
|
||||
virtual int draw() override;
|
||||
|
||||
STATE_FUNC_DECLARE(dAcOtrapRock1_c, TrapWait);
|
||||
STATE_FUNC_DECLARE(dAcOtrapRock1_c, TrapAction);
|
||||
STATE_FUNC_DECLARE(dAcOtrapRock1_c, TrapReturn);
|
||||
|
||||
private:
|
||||
/* 0x??? */ STATE_MGR_DECLARE(dAcOtrapRock1_c);
|
||||
/* 0x300 */ nw4r::g3d::ResFile mResFile;
|
||||
/* 0x334 */ m3d::smdl_c mMdl;
|
||||
/* 0x350 */ dBgW mBgW;
|
||||
/* 0x560 */ STATE_MGR_DECLARE(dAcOtrapRock1_c);
|
||||
/* 0x59C */ u8 mActivationSceneFlag;
|
||||
/* 0x59D */ u8 mReturnSceneFlag;
|
||||
/* 0x59E */ s16 field_0x59E;
|
||||
/* 0x5A0 */ s16 field_0x5A0;
|
||||
/* 0x5A2 */ s16 field_0x5A2;
|
||||
/* 0x5A4 */ u8 mFrameCounter;
|
||||
/* 0x5A5 */ s8 field_0x5A5;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,17 +1,140 @@
|
||||
#include "d/a/obj/d_a_obj_trap_rock_1.h"
|
||||
|
||||
#include "d/col/bg/d_bg_s.h"
|
||||
#include "d/flag/sceneflag_manager.h"
|
||||
#include "m/m_vec.h"
|
||||
#include "nw4r/math/math_arithmetic.h"
|
||||
#include "s/s_Math.h"
|
||||
|
||||
SPECIAL_ACTOR_PROFILE(OBJ_TRAP_ROCK_1, dAcOtrapRock1_c, fProfile::OBJ_TRAP_ROCK_1, 0x26B, 0, 2);
|
||||
|
||||
STATE_DEFINE(dAcOtrapRock1_c, TrapWait);
|
||||
STATE_DEFINE(dAcOtrapRock1_c, TrapAction);
|
||||
STATE_DEFINE(dAcOtrapRock1_c, TrapReturn);
|
||||
|
||||
bool dAcOtrapRock1_c::createHeap() {
|
||||
mResFile = getOarcResFile("TrapRockRoll");
|
||||
nw4r::g3d::ResMdl m = mResFile.GetResMdl("TrapRockRoll");
|
||||
|
||||
TRY_CREATE(mMdl.create(m, &heap_allocator, 0x120));
|
||||
mMdl.setPriorityDraw(0x1C, 0x09);
|
||||
void *dzb = getOarcFile("TrapRockRoll", "dzb/TrapRockRoll.dzb");
|
||||
void *plc = getOarcFile("TrapRockRoll", "dat/TrapRockRoll.plc");
|
||||
updateMatrix();
|
||||
return !mBgW.Set((cBgD_t *)dzb, (PLC *)plc, cBgW::MOVE_BG_e, &mWorldMtx, nullptr);
|
||||
}
|
||||
|
||||
int dAcOtrapRock1_c::create() {
|
||||
mActivationSceneFlag = params & 0xFF;
|
||||
mReturnSceneFlag = (params >> 8) & 0xFF;
|
||||
CREATE_ALLOCATOR(dAcOtrapRock1_c);
|
||||
|
||||
mBgW.SetCrrFunc(dBgS_MoveBGProc_Typical);
|
||||
dBgS::GetInstance()->Regist(&mBgW, this);
|
||||
forwardAccel = 0.0f;
|
||||
forwardMaxSpeed = -40.0f;
|
||||
mStateMgr.changeState(StateID_TrapWait);
|
||||
mVec3_c min, max;
|
||||
mMdl.getBounds(&min, &max);
|
||||
static mVec3_c offset = mVec3_c(50.0f, 50.0f, 50.0f);
|
||||
min -= offset;
|
||||
max += offset;
|
||||
boundingBox.Set(min, max);
|
||||
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
int dAcOtrapRock1_c::doDelete() {
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
int dAcOtrapRock1_c::actorExecute() {
|
||||
mStateMgr.executeState();
|
||||
updateMatrix();
|
||||
mMdl.setLocalMtx(mWorldMtx);
|
||||
mBgW.Move();
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
int dAcOtrapRock1_c::draw() {
|
||||
drawModelType1(&mMdl);
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
void dAcOtrapRock1_c::initializeState_TrapWait() {}
|
||||
void dAcOtrapRock1_c::executeState_TrapWait() {}
|
||||
void dAcOtrapRock1_c::executeState_TrapWait() {
|
||||
if (SceneflagManager::sInstance->checkBoolFlag(roomid, mActivationSceneFlag)) {
|
||||
mStateMgr.changeState(StateID_TrapAction);
|
||||
}
|
||||
}
|
||||
void dAcOtrapRock1_c::finalizeState_TrapWait() {}
|
||||
void dAcOtrapRock1_c::initializeState_TrapAction() {}
|
||||
void dAcOtrapRock1_c::executeState_TrapAction() {}
|
||||
void dAcOtrapRock1_c::initializeState_TrapAction() {
|
||||
mFrameCounter = 0;
|
||||
field_0x59E = 0x2000;
|
||||
field_0x5A0 = 0x2000;
|
||||
field_0x5A5 = 1;
|
||||
field_0x5A2 = 0x2D8;
|
||||
playSound(0xB0E);
|
||||
}
|
||||
|
||||
void dAcOtrapRock1_c::executeState_TrapAction() {
|
||||
if (SceneflagManager::sInstance->checkBoolFlag(roomid, mReturnSceneFlag)) {
|
||||
mStateMgr.changeState(StateID_TrapReturn);
|
||||
} else if (field_0x59E == 0 || mFrameCounter > 4) {
|
||||
// After 5 frames, move rotation.x to 0x4000, then stay until return
|
||||
bool reachedPoint = sLib::chaseAngle(&rotation.x.mVal, 0x4000, 0x14);
|
||||
if (reachedPoint) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
f32 ratio;
|
||||
if (mFrameCounter == 0 && rotation.x < 0x4000) {
|
||||
ratio = 0.1f;
|
||||
} else {
|
||||
f32 b = field_0x5A0;
|
||||
f32 r = (rotation.x - 0x4000) / b;
|
||||
ratio = nw4r::math::FAbs(r);
|
||||
}
|
||||
if (ratio > 1.0f) {
|
||||
ratio = 1.0f;
|
||||
}
|
||||
else if (ratio < 0.1f) {
|
||||
ratio = 0.1f;
|
||||
}
|
||||
s16 newAng = field_0x5A5 * (1.0f - ratio) * field_0x5A2;
|
||||
static const u16 sSomeValue = 0x3C;
|
||||
if (field_0x5A5 > 0) {
|
||||
if ((u16)newAng <= sSomeValue - 1) {
|
||||
newAng = sSomeValue;
|
||||
}
|
||||
} else if ((u16)(newAng + sSomeValue - 1) <= sSomeValue - 1) {
|
||||
newAng = -sSomeValue;
|
||||
}
|
||||
|
||||
rotation.x += (int)newAng;
|
||||
if (field_0x59E > 0 && rotation.x > field_0x59E + 0x4000 ||
|
||||
field_0x59E < 0 && rotation.x < field_0x59E + 0x4000) {
|
||||
rotation.x = field_0x59E + 0x4000;
|
||||
u8 r6 = field_0x5A5;
|
||||
field_0x5A5 = r6 - (r6 * 2);
|
||||
field_0x5A0 = field_0x59E;
|
||||
field_0x59E = field_0x59E - (field_0x59E * 2);
|
||||
if (mFrameCounter >= 1) {
|
||||
field_0x59E = field_0x59E >> 1;
|
||||
field_0x5A2 = field_0x5A2 >> 2;
|
||||
} else {
|
||||
field_0x5A2 = field_0x5A2 * 2 / 3;
|
||||
}
|
||||
mFrameCounter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
void dAcOtrapRock1_c::finalizeState_TrapAction() {}
|
||||
void dAcOtrapRock1_c::initializeState_TrapReturn() {}
|
||||
void dAcOtrapRock1_c::executeState_TrapReturn() {}
|
||||
void dAcOtrapRock1_c::executeState_TrapReturn() {
|
||||
bool reachedReturnPoint = sLib::chaseAngle(&rotation.x.mVal, 0, 0x222);
|
||||
if (reachedReturnPoint) {
|
||||
mStateMgr.changeState(StateID_TrapWait);
|
||||
}
|
||||
}
|
||||
void dAcOtrapRock1_c::finalizeState_TrapReturn() {}
|
||||
|
||||
Reference in New Issue
Block a user