diff --git a/include/d/a/d_a_player.h b/include/d/a/d_a_player.h index a964f9e1c01..36cf27edd66 100644 --- a/include/d/a/d_a_player.h +++ b/include/d/a/d_a_player.h @@ -833,6 +833,10 @@ public: mDemo.setParam2(i_param2); } + void i_changeDemoParam2(s16 i_param2) { + mDemo.setParam2(i_param2); + } + void changeDemoPos0(const cXyz* i_posP) { mDemo.setPos0(i_posP); } void changeDemoMoveAngle(s16 i_angle) { mDemo.setMoveAngle(i_angle); } diff --git a/include/rel/d/a/d_a_mg_fish/d_a_mg_fish.h b/include/rel/d/a/d_a_mg_fish/d_a_mg_fish.h index 7f07f06e733..5b012d05855 100644 --- a/include/rel/d/a/d_a_mg_fish/d_a_mg_fish.h +++ b/include/rel/d/a/d_a_mg_fish/d_a_mg_fish.h @@ -64,7 +64,9 @@ public: /* 0x890 */ u8 field_0x890[0x218]; /* 0xAA8 */ dCcD_Stts mCcStatus; /* 0xAE4 */ dCcD_Cyl mCcCyl; - /* 0xC20 */ u8 field_0xc20[0x28]; + /* 0xC20 */ u8 field_0xc20[0x1c]; + /* 0xC3C */ u8 field_0xc3c; + /* 0xC3D */ u8 field_0xc3d[0xb]; /* 0xC48 */ J3DJointCallBack mNodeCallBack; /* 0xC4C */ u32 field_0xc4c; }; diff --git a/include/rel/d/a/npc/d_a_npc_ne/d_a_npc_ne.h b/include/rel/d/a/npc/d_a_npc_ne/d_a_npc_ne.h index 8f8e11938d9..b786c0e564d 100644 --- a/include/rel/d/a/npc/d_a_npc_ne/d_a_npc_ne.h +++ b/include/rel/d/a/npc/d_a_npc_ne/d_a_npc_ne.h @@ -8,7 +8,7 @@ #include "d/msg/d_msg_flow.h" #include "f_op/f_op_actor.h" -class npc_ne_class : public fopAc_ac_c { +class npc_ne_class : public fopEn_enemy_c { public: enum Action { ACT_WAIT = 0, @@ -55,14 +55,27 @@ public: ANM_WALK = 25, }; + enum Behavior { + BHV_NONE = 0, + BHV_TAME = 1, + BHV_PIER = 2, + BHV_DISH = 3, + }; + + enum LookMode { + LOOK_FORWARD = 0, + LOOK_PLAYER = 1, + LOOK_TARGET = 2, + LOOK_NONE = 3, + }; + /* 80A92118 */ npc_ne_class(); - /* 0x568 */ u8 field_0x568[0x44]; /* 0x5AC */ request_of_phase_process_class mPhase; - /* 0x5B4 */ u8 field_0x5b4; - /* 0x5B5 */ u8 field_0x5b5; + /* 0x5B4 */ u8 mBehavior; + /* 0x5B5 */ u8 mTexture; /* 0x5B6 */ u8 mSize; - /* 0x5B7 */ u8 field_0x5b7; + /* 0x5B7 */ u8 mIsGengle; /* 0x5B8 */ u8 mPathIndex; /* 0x5B9 */ u8 field_0x5b9; /* 0x5BC */ dPath* mpPath; @@ -73,95 +86,102 @@ public: /* 0x5D4 */ f32 mAngleYStep; /* 0x5D8 */ f32 mDistToTarget; /* 0x5DC */ s16 mAngleToPlayer; - /* 0x5E0 */ f32 field_0x5e0; + /* 0x5E0 */ f32 mDistScale; /* 0x5E4 */ char* mResName; /* 0x5E8 */ mDoExt_McaMorf* mpMorf; /* 0x5EC */ mDoExt_btkAnm* mpBtkAnm; /* 0x5F0 */ mDoExt_btpAnm* mpBtpAnm; /* 0x5F4 */ s8 mBtkFrame; /* 0x5F6 */ s16 mBtpFrame; - /* 0x5F8 */ s8 field_0x5f8; + /* 0x5F8 */ s8 mBtpReset; /* 0x5FC */ mDoExt_McaMorf* mpDishMorf; /* 0x600 */ cXyz mDishPos; /* 0x60C */ Z2SoundObjSimple mSound; - /* 0x62C */ s16 field_0x62c; - /* 0x62E */ u8 field_0x62e[2]; + /* 0x62C */ s16 mBtpTimer; /* 0x630 */ int mAnmID; /* 0x634 */ u8 field_0x634[4]; /* 0x638 */ f32 mAnmSpeed; /* 0x63C */ u8 field_0x63c[4]; - /* 0x640 */ s16 field_0x640; + /* 0x640 */ s16 mCounter; /* 0x642 */ s16 mAction; /* 0x644 */ u8 field_0x644[2]; - /* 0x646 */ s16 mState; + /* 0x646 */ s16 mMode; /* 0x648 */ u32 mShadowKey; /* 0x64C */ s16 mTimers[5]; - /* 0x656 */ s16 field_0x656; - /* 0x658 */ s16 field_0x658; + /* 0x656 */ s16 mCcDisableTimer; + /* 0x658 */ s16 mSplashTimer; /* 0x65C */ f32 field_0x65c; /* 0x660 */ s16 field_0x660; /* 0x662 */ s16 mHeadAngleZ; /* 0x664 */ s16 mHeadAngleY; /* 0x666 */ s16 mHeadAngleX; - /* 0x668 */ s8 field_0x668; - /* 0x66C */ cXyz field_0x66c; - /* 0x678 */ s16 field_0x678; - /* 0x67A */ s16 field_0x67a; - /* 0x67C */ s16 field_0x67c; + /* 0x668 */ s8 mLookMode; + /* 0x66C */ cXyz mLookTarget; + /* 0x678 */ s16 mLookNoMoveTimer; + /* 0x67A */ s16 mLookDownTimer; + /* 0x67C */ s16 mLookUpTimer; /* 0x67E */ s16 mHeadTargetAngleY; /* 0x680 */ s16 mHeadTargetAngleZ; - /* 0x682 */ s16 field_0x682; - /* 0x684 */ s16 field_0x684[2]; - /* 0x688 */ s16 field_0x688; - /* 0x68A */ s16 field_0x68a; - /* 0x68C */ f32 field_0x68c; - /* 0x690 */ f32 field_0x690; - /* 0x694 */ s16 field_0x694; - /* 0x696 */ s16 field_0x696; + /* 0x682 */ s16 mNeckAngleY; + /* 0x684 */ s16 mTailSwayAngle[2]; + /* 0x688 */ s16 mTailAngle; + /* 0x68A */ s16 mTailTargetAngle; + /* 0x68C */ f32 mTailSway; + /* 0x690 */ f32 mTailSwayTarget; + /* 0x694 */ s16 mBackboneAngleY; + /* 0x696 */ s16 mBackboneTargetAngleY; /* 0x698 */ u8 field_0x698[2]; - /* 0x69A */ s16 mHeadMinorAngleY; - /* 0x69C */ s16 mHeadMinorAngleX; + /* 0x69A */ s16 mHeadBobAngleY; + /* 0x69C */ s16 mHeadBobAngleX; /* 0x69E */ u8 field_0x69e[2]; - /* 0x6A0 */ s16 mHeadMinorTargetAngleY; - /* 0x6A2 */ s16 mHeadMinorTargetAngleX; - /* 0x6A4 */ s16 field_0x6a4; + /* 0x6A0 */ s16 mHeadBobTargetAngleY; + /* 0x6A2 */ s16 mHeadBobTargetAngleX; + /* 0x6A4 */ s16 mHeadBobTimer; /* 0x6A6 */ u8 field_0x6a6[0x12]; /* 0x6B8 */ f32 field_0x6b8; - /* 0x6BC */ f32 field_0x6bc; + /* 0x6BC */ f32 mWaterY; /* 0x6C0 */ u8 field_0x6c0[0x14]; /* 0x6D4 */ f32 field_0x6d4; /* 0x6D8 */ cXyz mBaseScale; - /* 0x6E4 */ cXyz field_0x6e4; - /* 0x6F0 */ s8 field_0x6f0; + /* 0x6E4 */ cXyz mClimbPos; + /* 0x6F0 */ s8 mCarryTimer; /* 0x6F1 */ u8 field_0x6f1[7]; - /* 0x6F8 */ s8 field_0x6f8; + /* 0x6F8 */ s8 mSearchBall; /* 0x6FC */ int mHomePathIdx; /* 0x700 */ s8 mNoFollow; - /* 0x701 */ s8 field_0x701; + /* 0x701 */ s8 mWantsFish; /* 0x704 */ dBgS_AcchCir mAcchCir; /* 0x744 */ dBgS_ObjAcch mAcch; - /* 0x91C */ f32 field_0x91c; + /* 0x91C */ f32 mGroundY; /* 0x920 */ dCcD_Stts mStts; /* 0x95C */ dCcD_Sph mCcSph; /* 0xA94 */ dCcD_Sph mAtSph; - /* 0xBCC */ s8 field_0xbcc; + /* 0xBCC */ s8 mAtEnable; /* 0xBCD */ u8 field_0xbcd[0x27]; /* 0xBF4 */ f32 field_0xbf4; /* 0xBF8 */ u8 field_0xbf8[8]; /* 0xC00 */ u32 mParticle[2]; - /* 0xC08 */ s8 field_0xc08; - /* 0xC09 */ s16 field_0xc0a; + /* 0xC08 */ s8 mMessageState; + /* 0xC09 */ s16 mIsTalking; /* 0xC0C */ s16 mFlowID; /* 0xC10 */ dMsgFlow_c mMsgFlow; - /* 0xC5C */ s16 field_0xc5c; - /* 0xC5E */ s16 field_0xc5e; - /* 0xC60 */ u8 field_0xc60[0x54]; - /* 0xCB4 */ u8 field_0xcb4; + /* 0xC5C */ s16 mDemoMode; + /* 0xC5E */ s16 mDemoCounter; + /* 0xC60 */ s16 mDemoTimer; + /* 0xC64 */ cXyz mCameraEye1; + /* 0xC70 */ cXyz mCameraCenter1; + /* 0xC7C */ u8 field_0xc7c[0xc]; + /* 0xC88 */ f32 mCameraFovY; + /* 0xC8C */ u8 field_0xc8c[4]; + /* 0xC90 */ cXyz mDemoFishPos; + /* 0xC9C */ cXyz mCameraEye2; + /* 0xCA8 */ cXyz mCameraCenter2; + /* 0xCB4 */ bool field_0xcb4; /* 0xCB6 */ s16 field_0xcb6; /* 0xCB8 */ f32 field_0xcb8; /* 0xCBC */ u32 mFishID; - /* 0xCC0 */ u8 field_0xcc0; - /* 0xCC1 */ u8 field_0xcc1; + /* 0xCC0 */ bool field_0xcc0; + /* 0xCC1 */ bool mHIOInit; }; STATIC_ASSERT(sizeof(npc_ne_class) == 0xCC4); @@ -177,7 +197,7 @@ public: #endif /* 0x04 */ s8 field_0x04; - /* 0x08 */ f32 scale; + /* 0x08 */ f32 mScale; /* 0x0C */ f32 mWalkSpeed; /* 0x10 */ f32 mRunSpeed; /* 0x14 */ f32 mSwimSpeed; diff --git a/rel/d/a/npc/d_a_npc_ne/d_a_npc_ne.cpp b/rel/d/a/npc/d_a_npc_ne/d_a_npc_ne.cpp index 4c1a65fa391..3024e71bb2a 100644 --- a/rel/d/a/npc/d_a_npc_ne/d_a_npc_ne.cpp +++ b/rel/d/a/npc/d_a_npc_ne/d_a_npc_ne.cpp @@ -1,7 +1,7 @@ -// -// Generated By: dol2asm -// Translation Unit: d_a_npc_ne -// +/** + * d_a_npc_ne.cpp + * NPC - Cat + */ #include "rel/d/a/npc/d_a_npc_ne/d_a_npc_ne.h" #include "SSystem/SComponent/c_counter.h" @@ -75,6 +75,11 @@ extern "C" void __sinit_d_a_npc_ne_cpp(); extern "C" static void func_80A923F8(); extern "C" static void func_80A92400(); extern "C" extern char const* const d_a_npc_ne__stringBase0; +static cPhs__Step daNpc_Ne_Create(fopAc_ac_c*); +static int daNpc_Ne_Delete(npc_ne_class*); +static int daNpc_Ne_Execute(npc_ne_class*); +static int daNpc_Ne_IsDelete(npc_ne_class*); +static int daNpc_Ne_Draw(npc_ne_class*); // // External References: @@ -406,25 +411,30 @@ static dCcD_SrcSph at_sph_src = { }; /* 80A929D0-80A929F0 -00001 0020+00 1/0 0/0 0/0 .data l_daNpc_Ne_Method */ -SECTION_DATA static void* l_daNpc_Ne_Method[8] = { - (void*)daNpc_Ne_Create__FP10fopAc_ac_c, - (void*)daNpc_Ne_Delete__FP12npc_ne_class, - (void*)daNpc_Ne_Execute__FP12npc_ne_class, - (void*)daNpc_Ne_IsDelete__FP12npc_ne_class, - (void*)daNpc_Ne_Draw__FP12npc_ne_class, - (void*)NULL, - (void*)NULL, - (void*)NULL, +static actor_method_class l_daNpc_Ne_Method = { + (process_method_func)daNpc_Ne_Create, + (process_method_func)daNpc_Ne_Delete, + (process_method_func)daNpc_Ne_Execute, + (process_method_func)daNpc_Ne_IsDelete, + (process_method_func)daNpc_Ne_Draw, }; /* 80A929F0-80A92A20 -00001 0030+00 0/0 0/0 1/0 .data g_profile_NPC_NE */ -SECTION_DATA extern void* g_profile_NPC_NE[12] = { - (void*)0xFFFFFFFD, (void*)0x0007FFFD, - (void*)0x010D0000, (void*)&g_fpcLf_Method, - (void*)0x00000CC4, (void*)NULL, - (void*)NULL, (void*)&g_fopAc_Method, - (void*)0x02BC0000, (void*)&l_daNpc_Ne_Method, - (void*)0x08044000, (void*)0x04000000, +extern actor_process_profile_definition g_profile_NPC_NE = { + fpcLy_CURRENT_e, + 7, + fpcPi_CURRENT_e, + PROC_NPC_NE, + &g_fpcLf_Method.mBase, + sizeof(npc_ne_class), + 0, + 0, + &g_fopAc_Method.base, + 0x2BC, + &l_daNpc_Ne_Method, + 0x8044000, + fopAc_NPC_e, + fopAc_CULLBOX_0_e, }; /* 80A92A20-80A92A2C 000430 000C+00 2/2 0/0 0/0 .data __vt__8cM3dGSph */ @@ -480,10 +490,10 @@ SECTION_DATA extern void* __vt__14daNpc_Ne_HIO_c[3] = { // matches with literals daNpc_Ne_HIO_c::daNpc_Ne_HIO_c() : field_0x04(-1), - scale(1.0f), + mScale(1.0f), mWalkSpeed(2.5f), mRunSpeed(12.0f), - field_0x14(2.0f), + mSwimSpeed(2.0f), field_0x18(0) { /* empty function */ @@ -518,7 +528,8 @@ COMPILER_STRIP_GATE(0x80A92430, &lit_4019); #ifdef NONMATCHING // matches with literals static void anm_init(npc_ne_class* i_this, int i_resNo, f32 i_morf, u8 i_attr, f32 i_speed) { - J3DAnmTransform* anm = (J3DAnmTransform*)dComIfG_getObjectRes(i_this->mResName, i_resNo); + J3DAnmTransform* anm = + static_cast(dComIfG_getObjectRes(i_this->mResName, i_resNo)); i_this->mpMorf->setAnm(anm, i_attr, i_morf, i_speed, 0.0f, -1.0f, NULL); i_this->mAnmID = i_resNo; } @@ -544,29 +555,29 @@ static int nodeCallBack(J3DJoint* i_joint, int param_1) { // head if (jnt_no == 4) { - mDoMtx_YrotM(*calc_mtx, _this->mHeadAngleY + _this->mHeadMinorAngleY); - mDoMtx_XrotM(*calc_mtx, _this->mHeadAngleX + _this->mHeadMinorAngleX); + mDoMtx_YrotM(*calc_mtx, _this->mHeadAngleY + _this->mHeadBobAngleY); + mDoMtx_XrotM(*calc_mtx, _this->mHeadAngleX + _this->mHeadBobAngleX); mDoMtx_ZrotM(*calc_mtx, _this->mHeadAngleZ); } // backbone1 / backbone2 / neck if (jnt_no == 1 || jnt_no == 2 || jnt_no == 3) { - mDoMtx_YrotM(*calc_mtx, _this->field_0x694); + mDoMtx_YrotM(*calc_mtx, _this->mBackboneAngleY); if (jnt_no == 3) { - mDoMtx_YrotM(*calc_mtx, _this->field_0x682); + mDoMtx_YrotM(*calc_mtx, _this->mNeckAngleY); } } // tail1 / tail2 if (jnt_no == 20 || jnt_no == 21) { if (jnt_no == 20) { - mDoMtx_ZrotM(*calc_mtx, _this->field_0x688); + mDoMtx_ZrotM(*calc_mtx, _this->mTailAngle); } else if (jnt_no == 21) { - if (_this->field_0x688 > 0) { - mDoMtx_ZrotM(*calc_mtx, _this->field_0x688 * 2); + if (_this->mTailAngle > 0) { + mDoMtx_ZrotM(*calc_mtx, _this->mTailAngle * 2); } } - mDoMtx_ZrotM(*calc_mtx, _this->field_0x684[jnt_no - 20]); + mDoMtx_ZrotM(*calc_mtx, _this->mTailSwayAngle[jnt_no - 20]); } // center @@ -627,13 +638,13 @@ static int daNpc_Ne_Draw(npc_ne_class* i_this) { if (!fopAcM_checkCarryNow(i_this)) { cXyz vec(i_this->current.pos.x, i_this->current.pos.y + 100.0f, i_this->current.pos.z); i_this->mShadowKey = dComIfGd_setShadow( - i_this->mShadowKey, 1, model, &vec, 0.0f, 400.0f, i_this->current.pos.y, + i_this->mShadowKey, 1, model, &vec, 400.0f, 0.0f, i_this->current.pos.y, i_this->mAcch.GetGroundH(), i_this->mAcch.m_gnd, &i_this->tevStr, 0, 1.0f, dDlst_shadowControl_c::getSimpleTex() ); } - if (i_this->field_0x5b4 == 3) { + if (i_this->mBehavior == npc_ne_class::BHV_DISH) { g_env_light.setLightTevColorType_MAJI(i_this->mpDishMorf->getModel(), &i_this->tevStr); i_this->mpDishMorf->entryDL(); } @@ -644,13 +655,14 @@ static int daNpc_Ne_Draw(npc_ne_class* i_this) { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -static asm void daNpc_Ne_Draw(npc_ne_class* param_0) { +static asm int daNpc_Ne_Draw(npc_ne_class* param_0) { nofralloc #include "asm/rel/d/a/npc/d_a_npc_ne/d_a_npc_ne/daNpc_Ne_Draw__FP12npc_ne_class.s" } #pragma pop #endif +#ifndef NONMATCHING /* 80A89160-80A8919C 000580 003C+00 1/1 0/0 0/0 .text __dt__4cXyzFv */ #pragma push #pragma optimization_level 0 @@ -661,6 +673,7 @@ extern "C" asm void __dt__4cXyzFv() { #include "asm/rel/d/a/npc/d_a_npc_ne/d_a_npc_ne/__dt__4cXyzFv.s" } #pragma pop +#endif /* ############################################################################################## */ /* 80A9243C-80A92440 000020 0004+00 1/11 0/0 0/0 .rodata @4183 */ @@ -703,7 +716,7 @@ static asm BOOL other_bg_check(fopAc_ac_c* param_0, fopAc_ac_c* param_1) { static BOOL ne_carry_check(npc_ne_class* i_this) { if (i_this->mAction != npc_ne_class::ACT_CARRY && fopAcM_checkCarryNow(i_this)) { i_this->mAction = npc_ne_class::ACT_CARRY; - i_this->mState = 0; + i_this->mMode = 0; i_this->mNoFollow = false; return true; } else { @@ -742,23 +755,24 @@ COMPILER_STRIP_GATE(0x80A9244C, &lit_4326); /* 80A892D4-80A895F8 0006F4 0324+00 2/2 0/0 0/0 .text way_bg_check__FP12npc_ne_classs */ #ifdef NONMATCHING -// misplaced `mr` instruction +// matches with literals static int way_bg_check(npc_ne_class* i_this, s16 i_angle) { + fopAc_ac_c* _this = static_cast(i_this); dBgS_LinChk lin_chk; dBgS_GndChk gnd_chk; cM3dGPla plane; cXyz vec1, vec2, vec3; - vec1 = i_this->current.pos; + vec1 = _this->current.pos; vec1.y += 50.0f; - mDoMtx_YrotS(*calc_mtx, i_this->current.angle.y + i_angle); - if (i_this->current.angle.x < 0) { - mDoMtx_XrotM(*calc_mtx, i_this->current.angle.x); + mDoMtx_YrotS(*calc_mtx, _this->current.angle.y + i_angle); + if (_this->current.angle.x < 0) { + mDoMtx_XrotM(*calc_mtx, _this->current.angle.x); } vec3.set(0.0f, 0.0f, 150.0f); MtxPosition(&vec3, &vec2); vec2 += vec1; - lin_chk.Set(&vec1, &vec2, i_this); + lin_chk.Set(&vec1, &vec2, _this); if (dComIfG_Bgsp().LineCross(&lin_chk)) { dComIfG_Bgsp().GetTriPla(lin_chk, &plane); if (plane.mNormal.y >= 0.8f) { @@ -766,13 +780,13 @@ static int way_bg_check(npc_ne_class* i_this, s16 i_angle) { } } - mDoMtx_YrotS(*calc_mtx, i_this->current.angle.y + i_angle); + mDoMtx_YrotS(*calc_mtx, _this->current.angle.y + i_angle); vec3.set(0.0f, 150.0f, 150.0f); MtxPosition(&vec3, &vec2); - vec2 += i_this->current.pos; + vec2 += _this->current.pos; vec1 = vec2; vec2.y -= 250.0f; - lin_chk.Set(&vec1, &vec2, i_this); + lin_chk.Set(&vec1, &vec2, _this); if (!dComIfG_Bgsp().LineCross(&lin_chk)) { return 2; } @@ -800,6 +814,7 @@ static asm int way_bg_check(npc_ne_class* param_0, s16 param_1) { #pragma pop #endif +#ifndef NONMATCHING /* 80A895F8-80A89640 000A18 0048+00 1/0 0/0 0/0 .text __dt__8cM3dGPlaFv */ #pragma push #pragma optimization_level 0 @@ -810,6 +825,7 @@ extern "C" asm void __dt__8cM3dGPlaFv() { #include "asm/rel/d/a/npc/d_a_npc_ne/d_a_npc_ne/__dt__8cM3dGPlaFv.s" } #pragma pop +#endif /* ############################################################################################## */ /* 80A92450-80A92454 000034 0004+00 0/5 0/0 0/0 .rodata @4351 */ @@ -842,11 +858,11 @@ static int water_check(npc_ne_class* i_this, f32 param_1) { vec.y = lin_chk.i_GetCross().y - 10.0f; } gnd_chk_spl.SetPos(&vec); - i_this->field_0x6bc = dComIfG_Bgsp().GroundCross(&gnd_chk_spl); + i_this->mWaterY = dComIfG_Bgsp().GroundCross(&gnd_chk_spl); gnd_chk.SetPos(&vec); f32 cross = dComIfG_Bgsp().GroundCross(&gnd_chk); - if (i_this->current.pos.y <= i_this->field_0x6bc - && i_this->field_0x6bc - cross > param_1 * 2.0f * i_this->mBaseScale.z) + if (i_this->current.pos.y <= i_this->mWaterY + && i_this->mWaterY - cross > param_1 * 2.0f * i_this->mBaseScale.z) { return 1; } else { @@ -912,19 +928,19 @@ static s16 climb_angle_get(npc_ne_class* i_this) { vec3.set(0.0f, 50.0f, 10.0f); MtxPosition(&vec3, &vec1); vec1 += i_this->current.pos; - vec3.y = -50.0f; + vec3.y = -100.0f; MtxPosition(&vec3, &vec2); vec2 += i_this->current.pos; lin_chk.Set(&vec1, &vec2, i_this); if (dComIfG_Bgsp().LineCross(&lin_chk)) { - i_this->field_0x6e4 = lin_chk.i_GetCross(); + i_this->mClimbPos = lin_chk.i_GetCross(); vec3.z = 20.0f; MtxPosition(&vec3, &vec2); vec2 += i_this->current.pos; lin_chk.Set(&vec1, &vec2, i_this); if (dComIfG_Bgsp().LineCross(&lin_chk)) { vec2 = lin_chk.i_GetCross(); - vec3 = vec2 - i_this->field_0x6e4; + vec3 = vec2 - i_this->mClimbPos; return -cM_atan2s(vec3.y, JMAFastSqrt(vec3.x * vec3.x + vec3.z * vec3.z)); } return 0; @@ -1060,7 +1076,7 @@ static BOOL target_bgc[5]; static int target_info_count; /* 80A899C0-80A89A38 000DE0 0078+00 1/1 0/0 0/0 .text s_bl_sub__FPvPv */ -static void* s_bl_sub(void* i_proc, void* i_data) { +static void* s_bl_sub(void* i_proc, void* i_this) { if (fopAc_IsActor(i_proc) && (fopAcM_GetName(i_proc) == PROC_OBJ_FOOD || fopAcM_GetName(i_proc) == PROC_BD) && target_info_count < 5) @@ -1072,7 +1088,7 @@ static void* s_bl_sub(void* i_proc, void* i_data) { } /* 80A89A38-80A89AB0 000E58 0078+00 1/1 0/0 0/0 .text s_ss_sub__FPvPv */ -static void* s_ss_sub(void* i_proc, void* i_data) { +static void* s_ss_sub(void* i_proc, void* i_this) { if (fopAc_IsActor(i_proc) && (fopAcM_GetName(i_proc) == PROC_NI || fopAcM_GetName(i_proc) == PROC_BD) && target_info_count < 5) @@ -1100,23 +1116,26 @@ COMPILER_STRIP_GATE(0x80A92470, &lit_4572); /* 80A89AB0-80A89D28 000ED0 0278+00 3/3 0/0 0/0 .text search_bird__FP12npc_ne_class */ #ifdef NONMATCHING -// regalloc and an extra `cror` +// matches with literals static fopAc_ac_c* search_bird(npc_ne_class* i_this) { target_info_count = 0; for (int i = 0; i < 5; i++) { target_info[i] = NULL; target_bgc[i] = false; } - if (i_this->field_0x6f8) { + + if (i_this->mSearchBall) { fpcEx_Search(s_bl_sub, i_this); } else { fpcEx_Search(s_ss_sub, i_this); } + f32 f = 200.0f; if (target_info_count != 0) { + fopAc_ac_c* actor; int i = 0; while (i < target_info_count) { - fopAc_ac_c* actor = target_info[i]; + actor = target_info[i]; cXyz eye_delta, delta; eye_delta.x = actor->current.pos.x - i_this->eyePos.x; eye_delta.y = actor->current.pos.y + 50.0f - i_this->eyePos.y; @@ -1125,7 +1144,8 @@ static fopAc_ac_c* search_bird(npc_ne_class* i_this) { delta.z = actor->current.pos.z - i_this->current.pos.z; f32 eye_dist = JMAFastSqrt(eye_delta.x * eye_delta.x + eye_delta.z * eye_delta.z); f32 dist = JMAFastSqrt(delta.x * delta.x + delta.z * delta.z); - if (eye_dist < f && dist <= i_this->mDistToTarget + 30.0f) { + + if (eye_dist < f && !(dist > i_this->mDistToTarget + 30.0f)) { if (target_bgc[i] || other_bg_check(i_this, actor)) { target_bgc[i] = true; } else { @@ -1137,6 +1157,7 @@ static fopAc_ac_c* search_bird(npc_ne_class* i_this) { } } } + i++; if (i == target_info_count) { i = 0; @@ -1172,11 +1193,12 @@ COMPILER_STRIP_GATE(0x80A92474, &lit_4635); /* 80A89D28-80A89EF4 001148 01CC+00 2/2 0/0 0/0 .text way_check__FP12npc_ne_classs */ #ifdef NONMATCHING -// regalloc +// matches with literals static BOOL way_check(npc_ne_class* i_this, s16 i_angleY) { + fopAc_ac_c* _this = static_cast(i_this); f32 fvar1 = 1000.0f; cXyz vec1, vec2, vec3, vec4; - vec2 = i_this->current.pos; + vec2 = _this->current.pos; vec2.y += 20.0f; for (int i = 0; i < 5; i++) { for (int j = 0; j < 0x10; j++) { @@ -1185,12 +1207,12 @@ static BOOL way_check(npc_ne_class* i_this, s16 i_angleY) { MtxPosition(&vec1, &vec3); vec3 += vec2; dBgS_LinChk lin_chk; - lin_chk.Set(&vec2, &vec3, i_this); + lin_chk.Set(&vec2, &vec3, _this); if (dComIfG_Bgsp().LineCross(&lin_chk)) { i_angleY += 0x1000; } else { vec4.set(vec3.x, vec3.y - 250.0f, vec3.z); - lin_chk.Set(&vec3, &vec4, i_this); + lin_chk.Set(&vec3, &vec4, _this); if (!dComIfG_Bgsp().LineCross(&lin_chk)) { i_angleY += 0x1000; } else { @@ -1273,15 +1295,18 @@ COMPILER_STRIP_GATE(0x80A92494, &lit_4684); /* 80A89EF4-80A8A234 001314 0340+00 1/1 0/0 0/0 .text npc_ne_wait__FP12npc_ne_class */ #ifdef NONMATCHING -// regalloc +// matches with literals static void npc_ne_wait(npc_ne_class* i_this) { - fopAc_ac_c* player = dComIfGp_getPlayer(0); - cLib_addCalc0(&i_this->speedF, 1.0f, 1.3f); + fopAc_ac_c* _this = static_cast(i_this); + daPy_py_c* player = static_cast(dComIfGp_getPlayer(0)); + cLib_addCalc0(&_this->speedF, 1.0f, 1.3f); + if (i_this->mResName == "Npc_net") { - switch (i_this->mState) { + switch (i_this->mMode) { case 0: - i_this->mTargetAngleY = cM_rndF(65536.0f); - // no break + i_this->mTargetAngleY = cM_rndF(0x10000); + // fallthrough + case 1: if (cM_rndF(1.0f) < 0.5f) { if (i_this->mAnmID != npc_ne_class::ANM_WAIT) { @@ -1293,44 +1318,49 @@ static void npc_ne_wait(npc_ne_class* i_this) { } } i_this->mTimers[0] = cM_rndF(200.0f) + 500.0f; - i_this->mState = 2; + i_this->mMode = 2; break; + case 2: if (i_this->mTimers[0] == 0) { - i_this->mState = 1; + i_this->mMode = 1; } break; } - cLib_addCalcAngleS2(&i_this->current.angle.y, i_this->mTargetAngleY, 4, 0x400); - i_this->field_0xc08 = 2; + + cLib_addCalcAngleS2(&_this->current.angle.y, i_this->mTargetAngleY, 4, 0x400); + i_this->mMessageState = 2; } else { - i_this->field_0x668 = 1; + i_this->mLookMode = npc_ne_class::LOOK_PLAYER; s16 angle_diff; - switch (i_this->mState) { + + switch (i_this->mMode) { case 0: i_this->mAnmSpeed = 1.5f; anm_init(i_this, npc_ne_class::ANM_WALK, 2.0f, 2, i_this->mAnmSpeed); - i_this->mState++; + i_this->mMode++; if (cM_rndF(1.0f) < 0.5f) { i_this->mTargetAngleY = i_this->mAngleToPlayer + 0xB000; } else { i_this->mTargetAngleY = i_this->mAngleToPlayer + 0x5000; } - // no break + // fallthrough + case 1: - cLib_addCalcAngleS2(&i_this->current.angle.y, i_this->mTargetAngleY, 4, 0x400); - angle_diff = i_this->current.angle.y - i_this->mTargetAngleY; + cLib_addCalcAngleS2(&_this->current.angle.y, i_this->mTargetAngleY, 4, 0x400); + angle_diff = _this->current.angle.y - i_this->mTargetAngleY; if (angle_diff < 0x200 && angle_diff > -0x200) { i_this->mAnmSpeed = cM_rndF(0.1f) + 0.5f; anm_init(i_this, npc_ne_class::ANM_WAIT, 3.0f, 2, i_this->mAnmSpeed); - i_this->mState++; + i_this->mMode++; i_this->mTimers[0] = cM_rndF(100.0f) + 200.0f; } break; + case 2: - angle_diff = i_this->current.angle.y - i_this->mAngleToPlayer + 0x8000; + angle_diff = _this->current.angle.y - i_this->mAngleToPlayer + 0x8000; if (angle_diff < 0x800 && angle_diff > -0x800) { - i_this->mState = 0; + i_this->mMode = 0; } if (i_this->mTimers[0] == 1) { i_this->mAnmSpeed = 1.0f; @@ -1338,11 +1368,12 @@ static void npc_ne_wait(npc_ne_class* i_this) { } break; } - if (!(i_this->field_0x640 & 0xf) && !other_bg_check(i_this, player) && + + if (!(i_this->mCounter & 0xf) && !other_bg_check(_this, player) && (!i_this->mNoFollow || i_this->mDistToTarget < 350.0f)) { i_this->mAction = npc_ne_class::ACT_AWAY; - i_this->mState = 0; + i_this->mMode = 0; i_this->mTimers[3] = 0; i_this->mTimers[2] = 0; i_this->mTimers[1] = 0; @@ -1433,37 +1464,38 @@ COMPILER_STRIP_GATE(0x80A924BC, &lit_4781); /* 80A8A234-80A8A8F4 001654 06C0+00 1/1 0/0 0/0 .text npc_ne_away__FP12npc_ne_class */ #ifdef NONMATCHING -// regalloc +// matches with literals static void npc_ne_away(npc_ne_class* i_this) { if (!i_this->mNoFollow) { i_this->mAction = npc_ne_class::ACT_TAME; - i_this->mState = 0; + i_this->mMode = 0; return; } + int ivar4; s16 max_angle_step = 0xa00; - int ivar4 = 0; - switch (i_this->mState) { + ivar4 = 0; + switch (i_this->mMode) { case 0: i_this->mAnmSpeed = 1.0f; anm_init(i_this, npc_ne_class::ANM_WALK, 5.0f, 2, i_this->mAnmSpeed); i_this->mTargetAngleY = i_this->mAngleToPlayer + 0x8000 + (s16)cM_rndFX(4000.0f); way_check(i_this, i_this->mTargetAngleY); - i_this->mState++; - i_this->field_0x5e0 = cM_rndFX(0.2f) + 1.0f; - // no break + i_this->mMode++; + i_this->mDistScale = cM_rndFX(0.2f) + 1.0f; + // fallthrough case 1: max_angle_step = 0x200; if (i_this->mTimers[3] == 0) { i_this->mTimers[3] = cM_rndF(40.0f) + 40.0f; - i_this->field_0x678 = cM_rndF(20.0f) + 20.0f; + i_this->mLookNoMoveTimer = cM_rndF(20.0f) + 20.0f; } cLib_addCalc2(&i_this->mAnmSpeed, 2.0f, 1.0f, 0.05f); cLib_addCalc2(&i_this->speedF, i_this->mAnmSpeed * l_HIO.mWalkSpeed, 1.0f, l_HIO.mWalkSpeed * 0.2f); if (i_this->mDistToTarget > 500.0f) { - i_this->mState = 2; + i_this->mMode = 2; if (i_this->mTargetAngleY > (s16)(i_this->mAngleToPlayer + 0x8000)) { i_this->mTargetAngleY = i_this->mAngleToPlayer + 0xB000; } else { @@ -1472,16 +1504,16 @@ static void npc_ne_away(npc_ne_class* i_this) { i_this->mTimers[0] = 20; i_this->mTimers[1] = 0; } else if (i_this->mDistToTarget < 200.0f) { - i_this->mState = 5; + i_this->mMode = 5; i_this->mTargetAngleY = i_this->mAngleToPlayer + 0x8000 + (s16)cM_rndFX(4000.0f); way_check(i_this, i_this->mTargetAngleY); i_this->mSound.startSound(Z2SE_CAT_CRY_ANNOY, 0, -1); } else { if (i_this->mTimers[1] == 0) { - if (i_this->field_0x640 & 1) { + if (i_this->mCounter & 1) { ivar4 = way_bg_check(i_this, 0); } - if (ivar4 || i_this->mAcch.ChkWallHit() || !(i_this->field_0x640 & 1)) { + if (ivar4 || i_this->mAcch.ChkWallHit() || !(i_this->mCounter & 0x1f)) { i_this->mTargetAngleY = i_this->mAngleToPlayer + 0x8000 + (s16)cM_rndFX(3000.0f); way_check(i_this, i_this->mTargetAngleY); @@ -1510,12 +1542,12 @@ static void npc_ne_away(npc_ne_class* i_this) { } else { max_angle_step = 0x400; } - i_this->field_0x668 = 1; + i_this->mLookMode = npc_ne_class::LOOK_PLAYER; if (i_this->mTimers[0] == 0) { i_this->mAction = npc_ne_class::ACT_WAIT; i_this->mAnmSpeed = cM_rndF(0.1f) + 0.5f; anm_init(i_this, npc_ne_class::ANM_WAIT, 3.0f, 2, i_this->mAnmSpeed); - i_this->mState = 2; + i_this->mMode = 2; i_this->mTimers[0] = cM_rndF(100.0f) + 200.0f; } break; @@ -1523,21 +1555,21 @@ static void npc_ne_away(npc_ne_class* i_this) { case 5: i_this->mAnmSpeed = 1.0f; anm_init(i_this, npc_ne_class::ANM_RUN, 3.0f, 2, i_this->mAnmSpeed); - i_this->mState++; - // no break + i_this->mMode++; + // fallthrough case 6: if (i_this->mTimers[3] == 0) { i_this->mTimers[3] = cM_rndF(20.0f) + 20.0f; - i_this->field_0x678 = cM_rndF(10.0f) + 10.0f; + i_this->mLookNoMoveTimer = cM_rndF(10.0f) + 10.0f; } cLib_addCalc2(&i_this->mAnmSpeed, 1.5f, 1.0f, 0.1f); cLib_addCalc2(&i_this->speedF, i_this->mAnmSpeed * l_HIO.mRunSpeed, 1.0f, l_HIO.mRunSpeed * 0.5f); - if (i_this->field_0x640 & 1) { + if (i_this->mCounter & 1) { ivar4 = way_bg_check(i_this, 0); } - if (ivar4 || i_this->mAcch.ChkWallHit() || !(i_this->field_0x640 & 1)) { + if (ivar4 || i_this->mAcch.ChkWallHit() || !(i_this->mCounter & 0xf)) { i_this->mTargetAngleY = i_this->mAngleToPlayer + 0x8000 + (s16)cM_rndFX(4000.0f); way_check(i_this, i_this->mTargetAngleY); } @@ -1547,7 +1579,7 @@ static void npc_ne_away(npc_ne_class* i_this) { } if (i_this->mDistToTarget > 400.0f && i_this->mTimers[2] == 0) { i_this->mAction = npc_ne_class::ACT_WAIT; - i_this->mState = 0; + i_this->mMode = 0; } break; } @@ -1561,15 +1593,17 @@ static void npc_ne_away(npc_ne_class* i_this) { ang_z = -4000.0f; } i_this->current.angle.z = ang_z; + if (max_angle_step >= 0x400) { - f32 fvar2 = i_this->speedF * (i_this->current.angle.y - prev_angle) * 0.1f; - if (fvar2 > 5000.0f) { - fvar2 = 5000.0f; - } else if (fvar2 < -5000.0f) { - fvar2 = -5000.0f; + f32 ang_y = i_this->speedF * (i_this->current.angle.y - prev_angle) * 0.1f; + if (ang_y > 5000.0f) { + ang_y = 5000.0f; + } else if (ang_y < -5000.0f) { + ang_y = -5000.0f; } - i_this->field_0x696 = fvar2; + i_this->mBackboneTargetAngleY = ang_y; } + i_this->mpMorf->setPlaySpeed(i_this->mAnmSpeed); } #else @@ -1600,9 +1634,9 @@ COMPILER_STRIP_GATE(0x80A924C8, &lit_4839); /* 80A8A8F4-80A8AAE8 001D14 01F4+00 1/1 0/0 0/0 .text ground_search__FP12npc_ne_class */ #ifdef NONMATCHING -// regalloc +// matches with literals static cXyz ground_search(npc_ne_class* i_this) { - fopAc_ac_c* player = dComIfGp_getPlayer(0); + daPy_py_c* player = static_cast(dComIfGp_getPlayer(0)); dBgS_ObjGndChk_Spl gnd_chk_spl; dBgS_GndChk gnd_chk; cXyz vec1, vec2; @@ -1626,7 +1660,7 @@ static cXyz ground_search(npc_ne_class* i_this) { vec1.z = 100.0f; } MtxPosition(&vec1, &vec2); - vec2 += i_this->current.pos; + vec2 += player->current.pos; gnd_chk.SetPos(&vec2); vec2.y = dComIfG_Bgsp().GroundCross(&gnd_chk); if (fabsf(vec2.y - player->current.pos.y) < 100.0f) { @@ -1650,8 +1684,8 @@ static asm cXyz ground_search(npc_ne_class* param_0) { #endif /* 80A8AAE8-80A8AB70 001F08 0088+00 1/1 0/0 0/0 .text s_fish_sub__FPvPv */ -static void* s_fish_sub(void* i_proc, void* i_data) { - npc_ne_class* _this = static_cast(i_data); +static void* s_fish_sub(void* i_proc, void* i_this) { + npc_ne_class* _this = static_cast(i_this); if (fopAc_IsActor(i_proc) && fopAcM_GetName(i_proc) == PROC_MG_FISH) { mg_fish_class* fish = static_cast(i_proc); if (fish->field_0x5b6 == 0x35 && fish->field_0x5b8 >= 10) { @@ -1679,22 +1713,23 @@ COMPILER_STRIP_GATE(0x80A924D0, &lit_5005); /* 80A8AB70-80A8B530 001F90 09C0+00 2/1 0/0 0/0 .text npc_ne_tame__FP12npc_ne_class */ #ifdef NONMATCHING -// regalloc +// matches with literals static void npc_ne_tame(npc_ne_class* i_this) { + fopAc_ac_c* _this = static_cast(i_this); if (i_this->mNoFollow) { i_this->mAction = npc_ne_class::ACT_AWAY; - i_this->mState = 0; + i_this->mMode = 0; i_this->mTimers[3] = 0; i_this->mTimers[2] = 0; i_this->mTimers[1] = 0; i_this->mTimers[0] = 0; } else { - fopAc_ac_c* player = dComIfGp_getPlayer(0); + daPy_py_c* player = static_cast(dComIfGp_getPlayer(0)); s16 angle_max_step = 0; - i_this->field_0x668 = 1; + i_this->mLookMode = npc_ne_class::LOOK_PLAYER; f32 dist1, dist2, dist3; - if (i_this->field_0x701) { + if (i_this->mWantsFish) { dist1 = 250.0f; dist2 = 350.0f; dist3 = 150.0f; @@ -1706,29 +1741,29 @@ static void npc_ne_tame(npc_ne_class* i_this) { int ivar7 = 0; s16 angle_diff; - switch (i_this->mState) { + switch (i_this->mMode) { case 0: i_this->mAnmSpeed = 1.0f; anm_init(i_this, npc_ne_class::ANM_WALK, 5.0f, 2, i_this->mAnmSpeed); - i_this->mState++; - i_this->field_0x5e0 = cM_rndFX(0.2f) + 1.0f; - // no break + i_this->mMode++; + i_this->mDistScale = cM_rndFX(0.2f) + 1.0f; + // fallthrough case 1: i_this->mTargetAngleY = i_this->mAngleToPlayer; angle_max_step = 0x400; - i_this->field_0x68a = -15000; - i_this->field_0x690 = 3000.0f; + i_this->mTailTargetAngle = -15000; + i_this->mTailSwayTarget = 3000.0f; if (i_this->mDistToTarget < dist1) { cLib_addCalc2(&i_this->mAnmSpeed, 1.0f, 1.0f, 0.05f); - cLib_addCalc0(&i_this->speedF, 1.0f, 2.5f); - if (i_this->speedF < 4.0f) { + cLib_addCalc0(&_this->speedF, 1.0f, 2.5f); + if (_this->speedF < 4.0f) { i_this->mTimers[0] = cM_rndF(100.0f) + 200.0f; - i_this->mState = 2; + i_this->mMode = 2; i_this->mTimers[1] = 30; } } else if (i_this->mDistToTarget > dist2) { - i_this->mState = 5; + i_this->mMode = 5; } else { f32 target_anm_speed = (i_this->mDistToTarget - dist1) * 0.1f; if (target_anm_speed > 3.5f) { @@ -1738,14 +1773,14 @@ static void npc_ne_tame(npc_ne_class* i_this) { target_anm_speed = 2.0f; } cLib_addCalc2(&i_this->mAnmSpeed, target_anm_speed, 1.0f, 0.1f); - cLib_addCalc2(&i_this->speedF, i_this->mAnmSpeed * l_HIO.mWalkSpeed, + cLib_addCalc2(&_this->speedF, i_this->mAnmSpeed * l_HIO.mWalkSpeed, 1.0f, 0.2f * l_HIO.mWalkSpeed); } break; case 2: i_this->mTargetAngleY = i_this->mAngleToPlayer; - angle_diff = i_this->current.angle.y - i_this->mTargetAngleY; + angle_diff = _this->current.angle.y - i_this->mTargetAngleY; if (i_this->mTimers[1] != 0) { if (angle_diff > 0x4000 || angle_diff < -0x4000) { angle_max_step = 0x800; @@ -1761,13 +1796,13 @@ static void npc_ne_tame(npc_ne_class* i_this) { } if (i_this->mTimers[0] != 0) { - i_this->field_0x68a = -15000; - i_this->field_0x690 = 3000.0f; + i_this->mTailTargetAngle = -15000; + i_this->mTailSwayTarget = 3000.0f; } if (i_this->mDistToTarget < dist3 || (i_this->mTimers[3] == 0 && i_this->mAcch.ChkWallHit())) { - i_this->mState = 7; + i_this->mMode = 7; i_this->mTimers[3] = 30; } else if (i_this->mDistToTarget < dist3 + 30.0f) { if (i_this->mTimers[2] == 0 && i_this->mTimers[1] == 0 @@ -1778,7 +1813,7 @@ static void npc_ne_tame(npc_ne_class* i_this) { i_this->mAnmSpeed = -3.0f; } } else if (i_this->mDistToTarget > dist1 + 50.0f) { - i_this->mState = 0; + i_this->mMode = 0; } if (i_this->mTimers[2] != 0) { @@ -1786,10 +1821,10 @@ static void npc_ne_tame(npc_ne_class* i_this) { i_this->mAnmSpeed = cM_rndF(0.1f) + 0.5f; anm_init(i_this, npc_ne_class::ANM_WAIT, 5.0f, 2, i_this->mAnmSpeed); } - cLib_addCalc2(&i_this->speedF, -3.5f, 1.0f, 1.0f); + cLib_addCalc2(&_this->speedF, -3.5f, 1.0f, 1.0f); angle_max_step = 0x400; } else { - cLib_addCalc0(&i_this->speedF, 1.0f, 1.0f); + cLib_addCalc0(&_this->speedF, 1.0f, 1.0f); } if (i_this->mTimers[0] == 1) { @@ -1801,42 +1836,42 @@ static void npc_ne_tame(npc_ne_class* i_this) { case 5: i_this->mAnmSpeed = 1.0f; anm_init(i_this, npc_ne_class::ANM_RUN, 3.0f, 2, i_this->mAnmSpeed); - i_this->mState++; + i_this->mMode++; i_this->mSound.startSound(Z2SE_CAT_CRY_FAMILIER, 0, -1); - // no break + // fallthrough case 6: i_this->mTargetAngleY = i_this->mAngleToPlayer; angle_max_step = 0xa00; cLib_addCalc2(&i_this->mAnmSpeed, 1.5f, 1.0f, 0.1f); - cLib_addCalc2(&i_this->speedF, i_this->mAnmSpeed * l_HIO.mRunSpeed, + cLib_addCalc2(&_this->speedF, i_this->mAnmSpeed * l_HIO.mRunSpeed, 1.0f, 0.5f * l_HIO.mRunSpeed); if (i_this->mDistToTarget < dist1 + 100.0f) { i_this->mAnmSpeed = 3.5f; anm_init(i_this, npc_ne_class::ANM_WALK, 2.0f, 2, i_this->mAnmSpeed); - i_this->mState = 1; + i_this->mMode = 1; } break; case 7: i_this->mAnmSpeed = 1.0f; anm_init(i_this, npc_ne_class::ANM_RUN, 3.0f, 2, i_this->mAnmSpeed); - i_this->mState++; + i_this->mMode++; i_this->mSound.startSound(Z2SE_CAT_CRY_FAMILIER, 0, -1); i_this->mTargetAngleY = i_this->mAngleToPlayer + 0x8000; - // no break + // fallthrough case 8: angle_max_step = 0xa00; cLib_addCalc2(&i_this->mAnmSpeed, 1.5f, 1.0f, 0.1f); - cLib_addCalc2(&i_this->speedF, i_this->mAnmSpeed * l_HIO.mRunSpeed, + cLib_addCalc2(&_this->speedF, i_this->mAnmSpeed * l_HIO.mRunSpeed, 1.0f, 0.5f * l_HIO.mRunSpeed); - if (i_this->field_0x640 & 1) { + if (i_this->mCounter & 1) { ivar7 = way_bg_check(i_this, 0); } - if (ivar7 != 0 || i_this->mAcch.ChkWallHit() || !(i_this->field_0x640 & 0xf)) + if (ivar7 != 0 || i_this->mAcch.ChkWallHit() || !(i_this->mCounter & 0xf)) { i_this->mTargetAngleY = i_this->mAngleToPlayer + 0x8000 + (s16)cM_rndFX(4000.0f); @@ -1846,91 +1881,92 @@ static void npc_ne_tame(npc_ne_class* i_this) { if (i_this->mDistToTarget > dist3 + 40.0f) { i_this->mAnmSpeed = 3.5f; anm_init(i_this, npc_ne_class::ANM_WALK, 2.0f, 2, i_this->mAnmSpeed); - i_this->mState = 1; + i_this->mMode = 1; } break; case 10: case 11: i_this->mTargetAngleY = i_this->mAngleToPlayer; - cLib_addCalc0(&i_this->speedF, 1.0f, 3.0f); - angle_diff = i_this->current.angle.y - i_this->mTargetAngleY; + cLib_addCalc0(&_this->speedF, 1.0f, 3.0f); + angle_diff = _this->current.angle.y - i_this->mTargetAngleY; - if (i_this->mState == 10) { + if (i_this->mMode == 10) { if (angle_diff > 0x400 || angle_diff < -0x400) { i_this->mAnmSpeed = 1.0f; anm_init(i_this, npc_ne_class::ANM_WALK, 5.0f, 2, i_this->mAnmSpeed); - i_this->mState = 11; + i_this->mMode = 11; } } else { angle_max_step = 0x600; - i_this->field_0x67a = 0; + i_this->mLookDownTimer = 0; if (angle_diff <= 0x400 && angle_diff >= -0x400) { i_this->mAnmSpeed = cM_rndF(0.1f) + 0.5f; anm_init(i_this, npc_ne_class::ANM_WAIT, 5.0f, 2, i_this->mAnmSpeed); - i_this->mState = 10; + i_this->mMode = 10; } } if (i_this->mDistToTarget < dist3) { - i_this->mState = 7; + i_this->mMode = 7; i_this->mTimers[2] = 20; } break; } - if (i_this->mState < 7) { + if (i_this->mMode < 7) { if (i_this->mTimers[2] == 0) { ivar7 = way_bg_check(i_this, 0); if (ivar7 != 0) { if (ivar7 == -1) { i_this->mAction = npc_ne_class::ACT_CLIMB; - i_this->mState = 0; + i_this->mMode = 0; } else { - i_this->mState = 10; + i_this->mMode = 10; i_this->mAnmSpeed = cM_rndF(0.1f) + 0.5f; anm_init(i_this, npc_ne_class::ANM_WAIT, 5.0f, 2, i_this->mAnmSpeed); if (ivar7 >= 2) { - i_this->field_0x67a = 30; + i_this->mLookDownTimer = 30; } } } } - } else if (i_this->mState >= 10 && way_bg_check(i_this, 0) == 0) { - i_this->mState = 0; + } else if (i_this->mMode >= 10 && way_bg_check(i_this, 0) == 0) { + i_this->mMode = 0; } - s16 prev_angle_y = i_this->current.angle.y; - cLib_addCalcAngleS2(&i_this->current.angle.y, i_this->mTargetAngleY, 4, angle_max_step); - f32 fvar2 = i_this->speedF * (i_this->current.angle.y - prev_angle_y) * -0.5f; - if (fvar2 > 4000.0f) { - fvar2 = 4000.0f; - } else if (fvar2 < -4000.0f) { - fvar2 = -4000.0f; + s16 prev_angle_y = _this->current.angle.y; + cLib_addCalcAngleS2(&_this->current.angle.y, i_this->mTargetAngleY, 4, angle_max_step); + f32 angle = _this->speedF * (_this->current.angle.y - prev_angle_y) * -0.5f; + if (angle > 4000.0f) { + angle = 4000.0f; + } else if (angle < -4000.0f) { + angle = -4000.0f; } - i_this->current.angle.z = fvar2; + _this->current.angle.z = angle; + if (angle_max_step > 0x600) { - fvar2 = i_this->speedF * (i_this->current.angle.y - prev_angle_y) * -0.5f; - if (fvar2 > 4000.0f) { - fvar2 = 4000.0f; - } else if (fvar2 < -4000.0f) { - fvar2 = -4000.0f; + angle = _this->speedF * (_this->current.angle.y - prev_angle_y) * 0.1f; + if (angle > 5000.0f) { + angle = 5000.0f; + } else if (angle < -5000.0f) { + angle = -5000.0f; } - i_this->field_0x696 = fvar2; + i_this->mBackboneTargetAngleY = angle; } i_this->mpMorf->setPlaySpeed(i_this->mAnmSpeed); if (dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[470])) { - if (fpcEx_Search(s_fish_sub, i_this) != NULL) { + if (fpcEx_Search(s_fish_sub, _this) != NULL) { i_this->mAction = npc_ne_class::ACT_HOME; - i_this->mState = 10; + i_this->mMode = 10; } } - if ((i_this->field_0x640 & 0x1f) == 0xf && other_bg_check(i_this, player)) { + if ((i_this->mCounter & 0x1f) == 0xf && other_bg_check(_this, player)) { i_this->mAction = npc_ne_class::ACT_WAIT; - i_this->mState = 0; + i_this->mMode = 0; } } } @@ -1949,19 +1985,19 @@ static asm void npc_ne_tame(npc_ne_class* param_0) { #ifdef NONMATCHING // matches with literals static void npc_ne_sanbasi(npc_ne_class* i_this) { - switch (i_this->mState) { + switch (i_this->mMode) { case 0: anm_init(i_this, npc_ne_class::ANM_WAIT, 5.0f, 2, 1.0f); - i_this->mState = 1; + i_this->mMode = 1; break; case 1: - i_this->field_0x67a = 30; + i_this->mLookDownTimer = 30; } if (i_this->mDistToTarget < 500.0f || !i_this->mNoFollow) { i_this->mAction = npc_ne_class::ACT_TAME; - i_this->mState = 0; - i_this->field_0x67a = 0; + i_this->mMode = 0; + i_this->mLookDownTimer = 0; if (!i_this->mNoFollow) { i_this->mSound.startSound(Z2SE_CAT_CRY_FAMILIER, 0, -1); } @@ -2046,10 +2082,10 @@ COMPILER_STRIP_GATE(0x80A924FC, &lit_5109); #ifdef NONMATCHING // matches with literals static void npc_ne_bird(npc_ne_class* i_this) { - fopAc_ac_c* bird = static_cast(search_bird(i_this)); + fopAc_ac_c* bird = search_bird(i_this); if (bird == NULL) { i_this->mAction = npc_ne_class::ACT_WAIT; - i_this->mState = 0; + i_this->mMode = 0; return; } @@ -2059,21 +2095,21 @@ static void npc_ne_bird(npc_ne_class* i_this) { i_this->mDistToTarget = delta.abs(); s16 max_angle_step = 0; - i_this->field_0x668 = 2; - i_this->field_0x66c = i_this->mTargetPos; + i_this->mLookMode = npc_ne_class::LOOK_TARGET; + i_this->mLookTarget = i_this->mTargetPos; - switch(i_this->mState) { + switch(i_this->mMode) { case 0: i_this->mAnmSpeed = 1.0f; anm_init(i_this, npc_ne_class::ANM_WALK, 5.0f, 2, i_this->mAnmSpeed); - i_this->mState++; - i_this->field_0x5e0 = cM_rndFX(0.2f) + 1.0f; - // no break + i_this->mMode++; + i_this->mDistScale = cM_rndFX(0.2f) + 1.0f; + // fallthrough case 1: max_angle_step = 0x400; - i_this->field_0x68a = -15000; - i_this->field_0x690 = 3000.0f; + i_this->mTailTargetAngle = -15000; + i_this->mTailSwayTarget = 3000.0f; if (i_this->mDistToTarget < 200.0f) { cLib_addCalc2(&i_this->mAnmSpeed, 1.0f, 1.0f, 0.05f); cLib_addCalc0(&i_this->speedF, 1.0f, 2.5f); @@ -2082,10 +2118,10 @@ static void npc_ne_bird(npc_ne_class* i_this) { anm_init(i_this, npc_ne_class::ANM_WAIT, 5.0f, 2, i_this->mAnmSpeed); i_this->mTimers[0] = cM_rndF(100.0f) + 200.0f; i_this->mTimers[1] = cM_rndF(20.0f) + 3.0f; - i_this->mState = 2; + i_this->mMode = 2; } } else if (i_this->mDistToTarget > 500.0f) { - i_this->mState = 5; + i_this->mMode = 5; } else { f32 target_anm_speed = (i_this->mDistToTarget - 200.0f) * 0.1f; if (target_anm_speed > 3.5f) { @@ -2102,16 +2138,16 @@ static void npc_ne_bird(npc_ne_class* i_this) { case 2: if (i_this->mTimers[0] != 0) { - i_this->field_0x68a = -15000; - i_this->field_0x690 = 3000.0f; + i_this->mTailTargetAngle = -15000; + i_this->mTailSwayTarget = 3000.0f; } cLib_addCalc0(&i_this->speedF, 1.0f, 1.0f); if (i_this->mDistToTarget > 250.0f) { - i_this->mState = 0; + i_this->mMode = 0; } if (i_this->mTimers[1] == 1 && cM_rndF(1.0f) < 0.75f) { i_this->mAction = npc_ne_class::ACT_JUMP; - i_this->mState = 0; + i_this->mMode = 0; } if (i_this->mTimers[0] == 1) { i_this->mAnmSpeed = 1.0f; @@ -2122,8 +2158,8 @@ static void npc_ne_bird(npc_ne_class* i_this) { case 5: i_this->mAnmSpeed = 1.0f; anm_init(i_this, npc_ne_class::ANM_RUN, 3.0f, 2, i_this->mAnmSpeed); - i_this->mState++; - // no break + i_this->mMode++; + // fallthrough case 6: max_angle_step = 0xa00; @@ -2133,7 +2169,7 @@ static void npc_ne_bird(npc_ne_class* i_this) { if (i_this->mDistToTarget < 350.0f) { i_this->mAnmSpeed = 3.5f; anm_init(i_this, npc_ne_class::ANM_WALK, 2.0f, 2, i_this->mAnmSpeed); - i_this->mState = 1; + i_this->mMode = 1; } break; } @@ -2169,47 +2205,47 @@ COMPILER_STRIP_GATE(0x80A92504, &lit_5212); /* 80A8BAFC-80A8C094 002F1C 0598+00 2/1 0/0 0/0 .text npc_ne_ball__FP12npc_ne_class */ #ifdef NONMATCHING -// isStop regalloc +// matches with literals static void npc_ne_ball(npc_ne_class* i_this) { - fopAc_ac_c* bird = static_cast(search_bird(i_this)); - if (bird == NULL) { + fopAc_ac_c* ball = search_bird(i_this); + if (ball == NULL) { i_this->mAction = npc_ne_class::ACT_WAIT; - i_this->mState = 0; + i_this->mMode = 0; return; } - i_this->mTargetPos = bird->current.pos; + i_this->mTargetPos = ball->current.pos; cXyz delta = i_this->mTargetPos - i_this->current.pos; i_this->mTargetAngleY = cM_atan2s(delta.x, delta.z); i_this->mDistToTarget = delta.abs(); s16 max_angle_step = 0; - i_this->field_0x668 = 2; - i_this->field_0x66c = i_this->mTargetPos; + i_this->mLookMode = npc_ne_class::LOOK_TARGET; + i_this->mLookTarget = i_this->mTargetPos; - switch (i_this->mState) { + switch (i_this->mMode) { case 0: i_this->mAnmSpeed = 1.0f; anm_init(i_this, npc_ne_class::ANM_WALK, 5.0f, 2, i_this->mAnmSpeed); - i_this->mState++; - i_this->field_0x5e0 = cM_rndFX(0.2f) + 1.0f; + i_this->mMode++; + i_this->mDistScale = cM_rndFX(0.2f) + 1.0f; if (cM_rndF(1.0f) < 0.35f) { i_this->field_0x6d4 = 70.0f; } else { i_this->field_0x6d4 = 40.0f; } - // no break + // fallthrough case 1: max_angle_step = 0x400; - i_this->field_0x68a = -15000; - i_this->field_0x690 = 3000.0f; + i_this->mTailTargetAngle = -15000; + i_this->mTailSwayTarget = 3000.0f; if (i_this->mDistToTarget < i_this->field_0x6d4) { cLib_addCalc2(&i_this->mAnmSpeed, 1.0f, 1.0f, 0.05f); cLib_addCalc0(&i_this->speedF, 1.0f, 2.5f); if (i_this->speedF < 1.0f) { if (i_this->field_0x6d4 < 50.0f) { - i_this->mState = 3; + i_this->mMode = 3; if (cM_rndF(1.0f) < 0.5f) { anm_init(i_this, npc_ne_class::ANM_FAWN_L, 10.0f, 0, 1.0f); } else { @@ -2220,11 +2256,11 @@ static void npc_ne_ball(npc_ne_class* i_this) { anm_init(i_this, npc_ne_class::ANM_WAIT, 5.0f, 2, i_this->mAnmSpeed); i_this->mTimers[0] = cM_rndF(100.0f) + 200.0f; i_this->mTimers[1] = cM_rndF(20.0f) + 3.0f; - i_this->mState = 2; + i_this->mMode = 2; } } } else if (i_this->mDistToTarget > 200.0f) { - i_this->mState = 5; + i_this->mMode = 5; } else { f32 target_anm_speed = (i_this->mDistToTarget - 70.0f) * 0.1f; if (target_anm_speed > 3.5f) { @@ -2240,25 +2276,25 @@ static void npc_ne_ball(npc_ne_class* i_this) { break; case 2: - i_this->field_0x68a = -15000; - i_this->field_0x690 = 3000.0f; + i_this->mTailTargetAngle = -15000; + i_this->mTailSwayTarget = 3000.0f; cLib_addCalc0(&i_this->speedF, 1.0f, 1.0f); if (i_this->mDistToTarget > 100.0f) { - i_this->mState = 0; + i_this->mMode = 0; } if (i_this->mTimers[1] == 1) { i_this->mAction = npc_ne_class::ACT_S_JUMP; - i_this->mState = 0; + i_this->mMode = 0; } break; case 3: - i_this->field_0x68a = -15000; - i_this->field_0x690 = 3000.0f; + i_this->mTailTargetAngle = -15000; + i_this->mTailSwayTarget = 3000.0f; cLib_addCalc0(&i_this->speedF, 1.0f, 1.0f); if (i_this->mpMorf->isStop()) { i_this->mAction = npc_ne_class::ACT_WAIT; - i_this->mState = 0; + i_this->mMode = 0; } if (i_this->mpMorf->getFrame() >= 16.0f) { cLib_addCalc2(&i_this->field_0xbf4, 80.0f, 1.0f, 20.0f); @@ -2268,8 +2304,8 @@ static void npc_ne_ball(npc_ne_class* i_this) { case 5: i_this->mAnmSpeed = 1.0f; anm_init(i_this, npc_ne_class::ANM_RUN, 3.0f, 2, i_this->mAnmSpeed); - i_this->mState++; - // no break + i_this->mMode++; + // fallthrough case 6: max_angle_step = 0xa00; @@ -2279,7 +2315,7 @@ static void npc_ne_ball(npc_ne_class* i_this) { if (i_this->mDistToTarget < 150.0f) { i_this->mAnmSpeed = 3.5f; anm_init(i_this, npc_ne_class::ANM_WALK, 2.0f, 2, i_this->mAnmSpeed); - i_this->mState = 1; + i_this->mMode = 1; } } @@ -2331,12 +2367,12 @@ COMPILER_STRIP_GATE(0x80A92514, &lit_5298); #ifdef NONMATCHING // matches with literals static void npc_ne_pathwalk(npc_ne_class* i_this) { - switch (i_this->mState) { + switch (i_this->mMode) { case 0: i_this->mAnmSpeed = 1.5f; anm_init(i_this, npc_ne_class::ANM_WALK, 2.0f, 2, i_this->mAnmSpeed); - i_this->mState = 1; - // no break + i_this->mMode = 1; + // fallthrough case 1: i_this->mPathPointNo += i_this->mPathDir; @@ -2351,21 +2387,23 @@ static void npc_ne_pathwalk(npc_ne_class* i_this) { i_this->mPathDir = 1; i_this->mPathPointNo = 1; } - dStage_dPnt_c& point = i_this->mpPath->m_points[i_this->mPathPointNo]; - i_this->mTargetPos.x = point.m_position.x + cM_rndFX(50.0f); - i_this->mTargetPos.y = point.m_position.y; - i_this->mTargetPos.z = point.m_position.z + cM_rndFX(50.0f); - i_this->mState = 2; + dStage_dPnt_c* point = i_this->mpPath->m_points; + point += i_this->mPathPointNo; + i_this->mTargetPos.x = point->m_position.x + cM_rndFX(50.0f); + i_this->mTargetPos.y = point->m_position.y; + i_this->mTargetPos.z = point->m_position.z + cM_rndFX(50.0f); + i_this->mMode = 2; i_this->mAngleYStep = 0.0f; break; case 2: - i_this->field_0x66c = i_this->mTargetPos; + i_this->mLookTarget = i_this->mTargetPos; cXyz delta = i_this->mTargetPos - i_this->current.pos; if (delta.abs() < i_this->speedF * 10.0f) { - i_this->mState = 1; + i_this->mMode = 1; } i_this->mTargetAngleY = cM_atan2s(delta.x, delta.z); + break; } if (i_this->mAnmID == npc_ne_class::ANM_WALK) { @@ -2374,11 +2412,11 @@ static void npc_ne_pathwalk(npc_ne_class* i_this) { target_speed = 3.0f; if (i_this->mTimers[3] == 0) { i_this->mTimers[3] = cM_rndF(40.0f) + 40.0f; - i_this->field_0x678 = cM_rndF(20.0f) + 20.0f; + i_this->mLookNoMoveTimer = cM_rndF(20.0f) + 20.0f; } } else { target_speed = 1.5f; - i_this->field_0x668 = 2; + i_this->mLookMode = npc_ne_class::LOOK_TARGET; } cLib_addCalc2(&i_this->mAnmSpeed, target_speed, 1.0f, 0.05f); cLib_addCalc2(&i_this->speedF, i_this->mAnmSpeed * l_HIO.mWalkSpeed * 0.9f, @@ -2414,24 +2452,24 @@ static asm void npc_ne_pathwalk(npc_ne_class* param_0) { /* 80A8C508-80A8C748 003928 0240+00 1/1 0/0 0/0 .text npc_ne_jump__FP12npc_ne_class */ #ifdef NONMATCHING -// isStop regalloc +// matches with literals static void npc_ne_jump(npc_ne_class* i_this) { int frame = i_this->mpMorf->getFrame(); f32 target_speed = 0.0f; f32 max_speed_step = 3.0f; - switch (i_this->mState) { + switch (i_this->mMode) { case 0: i_this->mAnmSpeed = 1.0f; anm_init(i_this, npc_ne_class::ANM_TO_JUMP, 5.0f, 0, 1.0f); - i_this->mState++; + i_this->mMode++; break; case 1: cLib_addCalcAngleS2(&i_this->current.angle.y, i_this->mTargetAngleY, 4, 0x1000); if (i_this->mpMorf->isStop()) { anm_init(i_this, npc_ne_class::ANM_JUMP_LOOP, 2.0f, 0, 1.0f); - i_this->mState++; + i_this->mMode++; i_this->mSound.startSound(Z2SE_CAT_CRY_ATTACK, 0, -1); } break; @@ -2443,7 +2481,7 @@ static void npc_ne_jump(npc_ne_class* i_this) { if (frame < 10) { target_speed = 25.0f; max_speed_step = 25.0f; - i_this->field_0xbcc = 1; + i_this->mAtEnable = 1; i_this->mAtSph.OffAtVsPlayerBit(); } else { target_speed = 0.0f; @@ -2452,14 +2490,14 @@ static void npc_ne_jump(npc_ne_class* i_this) { } if (i_this->mpMorf->isStop()) { anm_init(i_this, npc_ne_class::ANM_TO_WAIT, 2.0f, 0, 1.0f); - i_this->mState++; + i_this->mMode++; } break; case 3: if (i_this->mpMorf->isStop()) { i_this->mAction = npc_ne_class::ACT_WAIT; - i_this->mState = 0; + i_this->mMode = 0; } break; } @@ -2485,18 +2523,18 @@ static void npc_ne_s_jump(npc_ne_class* i_this) { f32 target_speed = 0.0f; f32 max_speed_step = 3.0f; - switch (i_this->mState) { + switch (i_this->mMode) { case 0: i_this->mAnmSpeed = 1.0f; anm_init(i_this, npc_ne_class::ANM_TO_JUMP, 3.0f, 0, 1.5f); - i_this->mState++; + i_this->mMode++; break; case 1: cLib_addCalcAngleS2(&i_this->current.angle.y, i_this->mTargetAngleY, 2, 0x2000); if (frame >= 3) { anm_init(i_this, npc_ne_class::ANM_JUMP_START, 2.0f, 0, 1.0f); - i_this->mState++; + i_this->mMode++; } break; @@ -2511,14 +2549,14 @@ static void npc_ne_s_jump(npc_ne_class* i_this) { if (frame >= 3) { anm_init(i_this, npc_ne_class::ANM_JUMP_END, 3.0f, 0, 1.0f); i_this->mpMorf->setFrame(4.0f); - i_this->mState++; + i_this->mMode++; } break; case 3: if (i_this->mpMorf->isStop()) { i_this->mAction = npc_ne_class::ACT_WAIT; - i_this->mState = 0; + i_this->mMode = 0; } break; } @@ -2540,13 +2578,13 @@ static asm void npc_ne_s_jump(npc_ne_class* param_0) { #ifdef NONMATCHING // matches with literals static void npc_ne_roof(npc_ne_class* i_this) { - i_this->field_0x656 = 5; - i_this->field_0x668 = 1; + i_this->mCcDisableTimer = 5; + i_this->mLookMode = npc_ne_class::LOOK_PLAYER; - switch (i_this->mState) { + switch (i_this->mMode) { case 0: anm_init(i_this, npc_ne_class::ANM_WAIT, 5.0f, 2, 1.0f); - i_this->mState = 1; + i_this->mMode = 1; i_this->mTimers[0] = cM_rndF(100.0f) + 200.0f; break; @@ -2555,14 +2593,14 @@ static void npc_ne_roof(npc_ne_class* i_this) { anm_init(i_this, npc_ne_class::ANM_SIT_B, 20.0f, 0, 1.0f); } if (i_this->mDistToTarget < 500.0f) { - i_this->mState = 0; + i_this->mMode = 0; } break; } if (i_this->mDistToTarget < 200.0f) { i_this->mAction = npc_ne_class::ACT_HOME; - i_this->mState = 0; + i_this->mMode = 0; i_this->mSound.startSound(Z2SE_CAT_CRY_ANNOY, 0, -1); } } @@ -2580,7 +2618,7 @@ static asm void npc_ne_roof(npc_ne_class* param_0) { /* 80A8CA20-80A8CC64 003E40 0244+00 1/1 0/0 0/0 .text home_path_search__FP12npc_ne_classi */ #ifdef NONMATCHING -// regalloc / instruction ordering +// matches with literals static int home_path_search(npc_ne_class* i_this, int param_1) { f32 max_dist = 100.0f; BOOL local_1c0[100]; @@ -2592,7 +2630,7 @@ static int home_path_search(npc_ne_class* i_this, int param_1) { if (home_path[i].mNo >= 0) { if (home_path[i].mNo >= param_1 && (i_this->mHomePathIdx == 1000 - || home_path[i].mNo + 1 == home_path[i_this->mHomePathIdx].mNo) + || home_path[i_this->mHomePathIdx].mNo == home_path[i].mNo + 1) && !local_1c0[i]) { cXyz delta, pos; @@ -2668,37 +2706,38 @@ SECTION_DEAD static char const* const stringBase_80A925D8 = " PN %d"; /* 80A8CC64-80A8D608 004084 09A4+00 2/1 0/0 0/0 .text npc_ne_home__FP12npc_ne_class */ #ifdef NONMATCHING -// isStop regalloc -static int npc_ne_home(npc_ne_class* i_this) { - int ret = 1; - i_this->field_0x656 = 10; +// matches with literals +static BOOL npc_ne_home(npc_ne_class* i_this) { + BOOL ret = true; + i_this->mCcDisableTimer = 10; int frame = i_this->mpMorf->getFrame(); f32 target_speed = 0.0f; f32 max_speed_step = 4.0f; cXyz vec; f32 dist_xz; + s16 angle; - switch (i_this->mState) { + switch (i_this->mMode) { case 0: anm_init(i_this, npc_ne_class::ANM_RUN, 3.0f, 2, 1.5f); - i_this->mState = 1; + i_this->mMode = 1; i_this->mHomePathIdx = 1000; i_this->mAngleYStep = 10000.0f; i_this->mTimers[0] = 0; - // no break + // fallthrough case 1: i_this->mHomePathIdx = home_path_search(i_this, 0); if (i_this->mHomePathIdx < 0) { i_this->mAction = npc_ne_class::ACT_TAME; - i_this->mState = 0; - return 1; + i_this->mMode = 0; + return true; } - if (i_this->field_0xc5c == 0) { - i_this->field_0xc5c = 1; + if (i_this->mDemoMode == 0) { + i_this->mDemoMode = 1; } - i_this->mState = 2; - // no break + i_this->mMode = 2; + // fallthrough case 2: target_speed = l_HIO.mRunSpeed * 1.5f; @@ -2710,14 +2749,14 @@ static int npc_ne_home(npc_ne_class* i_this) { dist_xz = JMAFastSqrt(vec.x * vec.x + vec.z * vec.z); if (dist_xz <= target_speed * 1.2f) { if (i_this->mHomePathIdx == 1) { - i_this->mState = 20; - i_this->field_0xc5c = 3; - i_this->field_0xc5e = 0; + i_this->mMode = 20; + i_this->mDemoMode = 3; + i_this->mDemoCounter = 0; i_this->current.pos.set(236.0f, 93.3f, -777.5f); i_this->current.angle.y = 0x5f94; i_this->mSound.startSound(Z2SE_CAT_CRY_CARRY, 0, -1); } else if (i_this->mHomePathIdx == 5 || i_this->mHomePathIdx == 4) { - i_this->mState = 3; + i_this->mMode = 3; i_this->speedF = 0.0f; if (i_this->mHomePathIdx == 5) { i_this->mTimers[1] = 8; @@ -2726,7 +2765,7 @@ static int npc_ne_home(npc_ne_class* i_this) { } anm_init(i_this, npc_ne_class::ANM_TO_JUMP, 2.0f, 0, 1.0f); } else { - i_this->mState = 1; + i_this->mMode = 1; i_this->mAngleYStep = 5000.0f; } } @@ -2735,14 +2774,14 @@ static int npc_ne_home(npc_ne_class* i_this) { } if (i_this->mTimers[0] > 30) { i_this->mAction = npc_ne_class::ACT_TAME; - i_this->mState = 0; + i_this->mMode = 0; } break; case 3: i_this->speedF = 0.0f; if (i_this->mTimers[1] == 0) { - i_this->mState = 4; + i_this->mMode = 4; anm_init(i_this, npc_ne_class::ANM_JUMP_LOOP, 2.0f, 0, 1.0f); i_this->mTimers[1] = 6; } @@ -2752,7 +2791,7 @@ static int npc_ne_home(npc_ne_class* i_this) { i_this->current.angle.x = 0x3000; target_speed = l_HIO.mRunSpeed; if (i_this->mTimers[1] == 0 && i_this->mAcch.i_ChkGroundHit()) { - i_this->mState = 1; + i_this->mMode = 1; anm_init(i_this, npc_ne_class::ANM_RUN, 2.0f, 2, 1.5f); } break; @@ -2766,27 +2805,27 @@ static int npc_ne_home(npc_ne_class* i_this) { i_this->current.pos.z = home_path[i_this->mHomePathIdx].mPosition.z; i_this->old.pos = i_this->current.pos; anm_init(i_this, npc_ne_class::ANM_TO_JUMP, 5.0f, 0, 1.0f); - i_this->mState = 11; + i_this->mMode = 11; i_this->mHomePathIdx = home_path_search(i_this, 0); vec.x = home_path[i_this->mHomePathIdx].mPosition.x; vec.y = home_path[i_this->mHomePathIdx].mPosition.y; vec.z = home_path[i_this->mHomePathIdx].mPosition.z; vec -= i_this->current.pos; - s16 angle = cM_atan2s(vec.x, vec.z); + angle = cM_atan2s(vec.x, vec.z); i_this->shape_angle.y = angle; i_this->current.angle.y = angle; i_this->mTargetAngleY = angle; - i_this->field_0xc5c = 10; + i_this->mDemoMode = 10; i_this->mTimers[0] = 30; i_this->mSound.startSound(Z2SE_CAT_CRY_ANNOY_D, 0, -1); - // no break + // fallthrough case 11: - i_this->field_0x682 = cM_ssin(g_Counter.mTimer * 5000) * 500.0f; + i_this->mNeckAngleY = cM_ssin(g_Counter.mTimer * 5000) * 500.0f; if (i_this->mTimers[0] == 0 && i_this->mpMorf->isStop()) { anm_init(i_this, npc_ne_class::ANM_JUMP_LOOP, 2.0f, 0, 1.0f); i_this->mSound.startSound(Z2SE_CAT_CRY_ATTACK_D, 0, -1); - i_this->mState = 12; + i_this->mMode = 12; } break; @@ -2804,7 +2843,7 @@ static int npc_ne_home(npc_ne_class* i_this) { } if (i_this->mpMorf->isStop()) { anm_init(i_this, npc_ne_class::ANM_RUN, 3.0f, 2, 1.5f); - i_this->mState = 13; + i_this->mMode = 13; } break; @@ -2812,12 +2851,12 @@ static int npc_ne_home(npc_ne_class* i_this) { i_this->mHomePathIdx = home_path_search(i_this, 0); if (i_this->mHomePathIdx < 0) { i_this->mAction = npc_ne_class::ACT_TAME; - i_this->mState = 0; - i_this->field_0xc5c = 99; - return 1; + i_this->mMode = 0; + i_this->mDemoMode = 99; + return true; } - i_this->mState = 14; - // no break + i_this->mMode = 14; + // fallthrough case 14: target_speed = l_HIO.mRunSpeed * 1.5f; @@ -2829,25 +2868,25 @@ static int npc_ne_home(npc_ne_class* i_this) { dist_xz = JMAFastSqrt(vec.x * vec.x + vec.z * vec.z); if (dist_xz <= 70.0f) { if (i_this->mHomePathIdx == 1) { - i_this->mState = 20; - i_this->field_0xc5c = 3; - i_this->field_0xc5e = 0; + i_this->mMode = 20; + i_this->mDemoMode = 3; + i_this->mDemoCounter = 0; i_this->current.pos.set(236.0f, 93.3f, -777.5f); i_this->current.angle.y = 0x5f94; i_this->mAngleYStep = 5000.0f; dComIfGs_onEventBit(0x1001); } else { - i_this->mState = 13; + i_this->mMode = 13; i_this->mAngleYStep = 0.0f; JUTReport(200, 150, " PN %d", home_path[i_this->mHomePathIdx].mNo); - if (home_path[i_this->mHomePathIdx].mNo >= 4 && i_this->field_0xc5e > 0xa0) { + if (home_path[i_this->mHomePathIdx].mNo >= 4 && i_this->mDemoCounter > 0xa0) { i_this->mHomePathIdx = home_path_search(i_this, 0); i_this->current.pos.x = home_path[i_this->mHomePathIdx].mPosition.x; i_this->current.pos.y = home_path[i_this->mHomePathIdx].mPosition.y; i_this->current.pos.z = home_path[i_this->mHomePathIdx].mPosition.z; i_this->old.pos = i_this->current.pos; - i_this->field_0xcb4 = 1; - i_this->field_0xc5e = 0x7a; + i_this->field_0xcb4 = true; + i_this->mDemoCounter = 122; } } } @@ -2855,13 +2894,13 @@ static int npc_ne_home(npc_ne_class* i_this) { i_this->mTimers[0] += 2; } if (i_this->mTimers[0] > 30) { - i_this->field_0xc5c = 99; + i_this->mDemoMode = 99; } break; case 20: target_speed = l_HIO.mRunSpeed * 1.5f; - ret = 0; + ret = false; i_this->speed.y = 0.0f; i_this->gravity = 0.0f; vec.x = home_path[0].mPosition.x; @@ -2886,13 +2925,13 @@ static int npc_ne_home(npc_ne_class* i_this) { i_this->current.angle.z = ang_z; if (i_this->mAngleYStep > 1000.0f) { - f32 fvar1 = i_this->speedF * (i_this->current.angle.y - prev_ang_y) * 0.1f; - if (fvar1 > 5000.0f) { - fvar1 = 5000.0f; - } else if (fvar1 < -5000.0f) { - fvar1 = -5000.0f; + f32 ang_y = i_this->speedF * (i_this->current.angle.y - prev_ang_y) * 0.1f; + if (ang_y > 5000.0f) { + ang_y = 5000.0f; + } else if (ang_y < -5000.0f) { + ang_y = -5000.0f; } - i_this->field_0x696 = fvar1; + i_this->mBackboneTargetAngleY = ang_y; } return ret; @@ -2918,22 +2957,23 @@ COMPILER_STRIP_GATE(0x80A9252C, &lit_5718); /* 80A8D608-80A8D7C4 004A28 01BC+00 2/2 0/0 0/0 .text wall_angle_get__FP12npc_ne_class */ #ifdef NONMATCHING -// regalloc +// matches with literals static s16 wall_angle_get(npc_ne_class* i_this) { + fopAc_ac_c* _this = static_cast(i_this); dBgS_LinChk lin_chk; - mDoMtx_YrotS(*calc_mtx, i_this->shape_angle.y); + mDoMtx_YrotS(*calc_mtx, _this->shape_angle.y); cXyz vec1, vec2, vec3[2]; vec1.set(0.0f, 50.0f, -50.0f); MtxPosition(&vec1, &vec2); - vec2 += i_this->current.pos; + vec2 += _this->current.pos; vec1.set(5.0f, 0.0f, 200.0f); for (int i = 0; i < 2; i++) { MtxPosition(&vec1, &vec3[i]); vec1.x *= -1.0f; vec3[i] += vec2; - lin_chk.Set(&vec2, &vec3[i], i_this); + lin_chk.Set(&vec2, &vec3[i], _this); if (dComIfG_Bgsp().LineCross(&lin_chk)) { - i_this->field_0x6e4 = lin_chk.i_GetCross(); + i_this->mClimbPos = lin_chk.i_GetCross(); vec3[i] = lin_chk.i_GetCross(); } else { return 1; @@ -2963,12 +3003,13 @@ SECTION_DEAD static char const* const stringBase_80A925DF = "F_SP103"; /* 80A8D7C4-80A8DD54 004BE4 0590+00 1/1 0/0 0/0 .text search_ground_1__FP12npc_ne_class */ #ifdef NONMATCHING -// regalloc +// matches with literals static void search_ground_1(npc_ne_class* i_this) { + fopAc_ac_c* _this = static_cast(i_this); dBgS_LinChk lin_chk; cXyz pos[16]; cXyz vec1, vec2, vec3; - s16 ang_y = i_this->shape_angle.y; + s16 ang_y = _this->shape_angle.y; f32 var_y, var_z; if (!strcmp(dComIfGp_getStartStageName(), "F_SP103")) { var_y = 200.0f; @@ -2979,13 +3020,13 @@ static void search_ground_1(npc_ne_class* i_this) { } for (int i = 0; i < 16; i++) { - vec1 = i_this->current.pos; - vec1.y = i_this->field_0x6bc; + vec1 = _this->current.pos; + vec1.y = i_this->mWaterY; mDoMtx_YrotS(*calc_mtx, ang_y); vec3.set(0.0f, 0.0f, 5000.0f); MtxPosition(&vec3, &vec2); vec2 += vec1; - lin_chk.Set(&vec1, &vec2, i_this); + lin_chk.Set(&vec1, &vec2, _this); if (dComIfG_Bgsp().LineCross(&lin_chk)) { vec2 = lin_chk.i_GetCross(); vec3.set(0.0f, var_y, var_z); @@ -2993,7 +3034,7 @@ static void search_ground_1(npc_ne_class* i_this) { vec1 += vec2; vec2 = vec1; vec2.y -= var_y + 20.0f; - lin_chk.Set(&vec1, &vec2, i_this); + lin_chk.Set(&vec1, &vec2, _this); if (dComIfG_Bgsp().LineCross(&lin_chk)) { pos[i] = lin_chk.i_GetCross(); vec1 = lin_chk.i_GetCross(); @@ -3001,13 +3042,13 @@ static void search_ground_1(npc_ne_class* i_this) { vec3.set(0.0f, 0.0f, 200.0f); MtxPosition(&vec3, &vec2); vec2 += vec1; - lin_chk.Set(&vec1, &vec2, i_this); + lin_chk.Set(&vec1, &vec2, _this); if (dComIfG_Bgsp().LineCross(&lin_chk)) { - pos[i] = i_this->current.pos; + pos[i] = _this->current.pos; pos[i].x += 10000.0f; } } else { - pos[i] = i_this->current.pos; + pos[i] = _this->current.pos; pos[i].x += 10000.0f; } } @@ -3016,7 +3057,7 @@ static void search_ground_1(npc_ne_class* i_this) { int i = 0; for (int j = 1; j < 16; j++) { - if ((pos[i] - i_this->current.pos).abs() > (pos[j] - i_this->current.pos).abs()) { + if ((pos[i] - _this->current.pos).abs() > (pos[j] - _this->current.pos).abs()) { i = j; } } @@ -3050,12 +3091,13 @@ COMPILER_STRIP_GATE(0x80A92530, &lit_5891); /* 80A8DD58-80A8DEE0 005178 0188+00 1/1 0/0 0/0 .text search_ground_2__FP12npc_ne_classs */ #ifdef NONMATCHING -// regalloc +// matches with literals static BOOL search_ground_2(npc_ne_class* i_this, s16 i_wallAngle) { + fopAc_ac_c* _this = static_cast(i_this); dBgS_LinChk lin_chk; cXyz vec1, vec2, vec3; - vec2 = i_this->current.pos; - vec2.y = i_this->field_0x6bc; + vec2 = _this->current.pos; + vec2.y = i_this->mWaterY; f32 var_y, var_z; if (!strcmp(dComIfGp_getStartStageName(), "F_SP103")) { var_y = 120.0f; @@ -3070,7 +3112,7 @@ static BOOL search_ground_2(npc_ne_class* i_this, s16 i_wallAngle) { vec1 += vec2; vec2 = vec1; vec2.y -= 200.0f; - lin_chk.Set(&vec1, &vec2, i_this); + lin_chk.Set(&vec1, &vec2, _this); if (dComIfG_Bgsp().LineCross(&lin_chk)) { i_this->mTargetPos = lin_chk.i_GetCross(); return true; @@ -3103,22 +3145,22 @@ COMPILER_STRIP_GATE(0x80A92534, &lit_5924); static void npc_ne_swim(npc_ne_class* i_this) { s16 max_angle_step = 0; - switch (i_this->mState) { + switch (i_this->mMode) { case 0: anm_init(i_this, npc_ne_class::ANM_SWIM, 5.0f, 2, 1.0f); - i_this->mState++; - i_this->field_0x5e0 = cM_rndFX(0.2f) + 1.0f; + i_this->mMode++; + i_this->mDistScale = cM_rndFX(0.2f) + 1.0f; i_this->speedF = 0.0f; i_this->mTimers[1] = 50; search_ground_1(i_this); - // no break + // fallthrough case 1: if (i_this->mpMorf->checkFrame(4.0f) || i_this->mpMorf->checkFrame(12.0f)) { i_this->mSound.startSound(Z2SE_CAT_SWIM, 0, -1); } max_angle_step = 0x100; - if ((i_this->field_0x640 & 0x3f) == 0) { + if ((i_this->mCounter & 0x3f) == 0) { search_ground_1(i_this); } cXyz delta = i_this->mTargetPos - i_this->current.pos; @@ -3131,12 +3173,12 @@ static void npc_ne_swim(npc_ne_class* i_this) { i_this->speed.y = 0.0f; i_this->gravity = 0.0f; cLib_addCalc2(&i_this->current.pos.y, - i_this->field_0x6bc - i_this->mBaseScale.z * 45.0f, 1.0f, 5.0f); + i_this->mWaterY - i_this->mBaseScale.z * 45.0f, 1.0f, 5.0f); if (i_this->mTimers[1] == 0 && i_this->mAcch.ChkWallHit()) { s16 wall_angle = wall_angle_get(i_this); if (wall_angle != 1 && search_ground_2(i_this, wall_angle)) { i_this->mAction = npc_ne_class::ACT_OUT_SWIM; - i_this->mState = 0; + i_this->mMode = 0; i_this->mTargetAngleY = wall_angle_get(i_this); } } @@ -3154,22 +3196,24 @@ static asm void npc_ne_swim(npc_ne_class* param_0) { /* 80A8E0E4-80A8E428 005504 0344+00 1/1 0/0 0/0 .text npc_ne_outswim__FP12npc_ne_class */ #ifdef NONMATCHING -// isStop regalloc +// matches with literals static void npc_ne_outswim(npc_ne_class* i_this) { - switch (i_this->mState) { + cXyz delta; + + switch (i_this->mMode) { case 0: anm_init(i_this, npc_ne_class::ANM_RUN, 5.0f, 2, 2.0f); - i_this->mState++; + i_this->mMode++; i_this->speedF = 0.0f; - // no break + // fallthrough case 1: i_this->current.angle.x = -0x4000; cLib_addCalc2(&i_this->current.pos.y, i_this->mTargetPos.y - 10.0f, 1.0f, 5.0f); - cLib_addCalc2(&i_this->current.pos.x, i_this->field_0x6e4.x, 1.0f, 5.0f); - cLib_addCalc2(&i_this->current.pos.z, i_this->field_0x6e4.z, 1.0f, 5.0f); + cLib_addCalc2(&i_this->current.pos.x, i_this->mClimbPos.x, 1.0f, 5.0f); + cLib_addCalc2(&i_this->current.pos.z, i_this->mClimbPos.z, 1.0f, 5.0f); if (fabsf(i_this->current.pos.y - (i_this->mTargetPos.y - 10.0f)) < 1.0f) { - i_this->mState++; + i_this->mMode++; i_this->mTimers[0] = 5; } break; @@ -3179,12 +3223,12 @@ static void npc_ne_outswim(npc_ne_class* i_this) { cLib_addCalc2(&i_this->current.pos.x, i_this->mTargetPos.x, 1.0f, 5.0f); cLib_addCalc2(&i_this->current.pos.y, i_this->mTargetPos.y, 1.0f, 5.0f); cLib_addCalc2(&i_this->current.pos.z, i_this->mTargetPos.z, 1.0f, 5.0f); - cXyz delta = i_this->current.pos - i_this->mTargetPos; + delta = i_this->current.pos - i_this->mTargetPos; if (i_this->mTimers[0] == 1) { anm_init(i_this, npc_ne_class::ANM_JUMP_END, 3.0f, 0, 1.0f); } if (delta.abs() < 1.0f) { - i_this->mState++; + i_this->mMode++; if (i_this->mAnmID != npc_ne_class::ANM_JUMP_END) { anm_init(i_this, npc_ne_class::ANM_JUMP_END, 2.0f, 0, 2.0f); } @@ -3194,7 +3238,7 @@ static void npc_ne_outswim(npc_ne_class* i_this) { case 3: if (i_this->mpMorf->isStop()) { i_this->mAction = npc_ne_class::ACT_AWAY; - i_this->mState = 0; + i_this->mMode = 0; i_this->mTimers[3] = 0; i_this->mTimers[2] = 0; i_this->mTimers[1] = 0; @@ -3228,106 +3272,108 @@ COMPILER_STRIP_GATE(0x80A92538, &lit_6108); /* 80A8E428-80A8EA78 005848 0650+00 1/1 0/0 0/0 .text npc_ne_climb__FP12npc_ne_class */ #ifdef NONMATCHING -// regalloc -static int npc_ne_climb(npc_ne_class* i_this) { - int ret = 0; - i_this->field_0x656 = 10; +// matches with literals +static BOOL npc_ne_climb(npc_ne_class* i_this) { + fopAc_ac_c* _this = static_cast(i_this); + BOOL ret = false; + i_this->mCcDisableTimer = 10; cXyz vec1, vec2, delta; - switch (i_this->mState) { + switch (i_this->mMode) { case 0: i_this->mAnmSpeed = 1.0f; anm_init(i_this, npc_ne_class::ANM_RUN, 3.0f, 2, i_this->mAnmSpeed); - i_this->mState++; - // no break + i_this->mMode++; + // fallthrough case 1: - ret = 1; - cLib_addCalc2(&i_this->speedF, i_this->mAnmSpeed * l_HIO.mRunSpeed, + ret = true; + cLib_addCalc2(&_this->speedF, i_this->mAnmSpeed * l_HIO.mRunSpeed, 1.0f, 0.5f * l_HIO.mRunSpeed); - delta = i_this->field_0x6e4 - i_this->current.pos; + delta = i_this->mClimbPos - _this->current.pos; if (delta.abs() < 40.0f || i_this->mAcch.ChkWallHit() || - fopAcM_wayBgCheck(i_this, 35.0f * i_this->mBaseScale.z, 30.0f * i_this->mBaseScale.y)) + fopAcM_wayBgCheck(_this, 35.0f * i_this->mBaseScale.z, 30.0f * i_this->mBaseScale.y)) { s16 wall_angle = wall_angle_get(i_this); if (wall_angle != 1) { anm_init(i_this, npc_ne_class::ANM_TO_JUMP, 5.0f, 0, 1.0f); - i_this->current.angle.y = wall_angle; - i_this->current.pos = i_this->old.pos; - i_this->speedF = 0.0f; - i_this->mState++; + _this->current.angle.y = wall_angle; + _this->current.pos = _this->old.pos; + _this->speedF = 0.0f; + i_this->mMode++; } else { i_this->mAction = npc_ne_class::ACT_WAIT; - i_this->mState = 0; + i_this->mMode = 0; } } break; case 2: - i_this->field_0x67c = 2; + i_this->mLookUpTimer = 2; if (i_this->mpMorf->isStop()) { anm_init(i_this, npc_ne_class::ANM_RUN, 5.0f, 2, 2.0f); - i_this->mState++; + i_this->mMode++; i_this->mTimers[0] = 50; } break; case 3: - i_this->current.angle.x = climb_angle_get(i_this); + _this->current.angle.x = climb_angle_get(i_this); if (i_this->mTimers[0] >= 47) { - i_this->current.angle.x = -0x3800; + _this->current.angle.x = -0x3800; } - cLib_addCalc2(&i_this->current.pos.y, i_this->mTargetPos.y, 1.0f, 15.0f); - if (i_this->current.angle.x <= -0x2000) { - cLib_addCalc2(&i_this->current.pos.x, i_this->field_0x6e4.x, 1.0f, 15.0f); - cLib_addCalc2(&i_this->current.pos.z, i_this->field_0x6e4.z, 1.0f, 15.0f); + cLib_addCalc2(&_this->current.pos.y, i_this->mTargetPos.y, 1.0f, 15.0f); + if (_this->current.angle.x <= -0x2000) { + cLib_addCalc2(&_this->current.pos.x, i_this->mClimbPos.x, 1.0f, 15.0f); + cLib_addCalc2(&_this->current.pos.z, i_this->mClimbPos.z, 1.0f, 15.0f); + break; } else { - mDoMtx_YrotS(*calc_mtx, i_this->current.angle.y); + mDoMtx_YrotS(*calc_mtx, _this->current.angle.y); vec1.x = 0.0f; vec1.y = 100.0f; vec1.z = 40.0f * i_this->mBaseScale.z; MtxPosition(&vec1, &vec2); - vec2 += i_this->current.pos; + vec2 += _this->current.pos; dBgS_GndChk gnd_chk; gnd_chk.SetPos(&vec2); i_this->mTargetPos.y = dComIfG_Bgsp().GroundCross(&gnd_chk); i_this->mTargetPos.x = vec2.x; i_this->mTargetPos.z = vec2.z; - i_this->mState = 4; + i_this->mMode = 4; } - // no break + // fallthrough case 4: i_this->current.angle.x = climb_angle_get(i_this); - cLib_addCalc2(&i_this->current.pos.x, i_this->mTargetPos.x, 1.0f, 15.0f); - cLib_addCalc2(&i_this->current.pos.y, i_this->mTargetPos.y, 1.0f, 15.0f); - cLib_addCalc2(&i_this->current.pos.z, i_this->mTargetPos.z, 1.0f, 15.0f); - delta = i_this->mTargetPos - i_this->current.pos; + cLib_addCalc2(&_this->current.pos.x, i_this->mTargetPos.x, 1.0f, 15.0f); + cLib_addCalc2(&_this->current.pos.y, i_this->mTargetPos.y, 1.0f, 15.0f); + cLib_addCalc2(&_this->current.pos.z, i_this->mTargetPos.z, 1.0f, 15.0f); + delta = i_this->mTargetPos - _this->current.pos; if (delta.abs() < 30.0f || i_this->mTimers[0] == 0) { anm_init(i_this, npc_ne_class::ANM_JUMP_END, 2.0f, 0, 1.0f); - i_this->mState = 5; + i_this->mMode = 5; } break; case 5: - cLib_addCalc2(&i_this->current.pos.x, i_this->mTargetPos.x, 0.2f, 15.0f); - cLib_addCalc2(&i_this->current.pos.y, i_this->mTargetPos.y, 1.0f, 15.0f); - cLib_addCalc2(&i_this->current.pos.z, i_this->mTargetPos.z, 0.2f, 15.0f); + cLib_addCalc2(&_this->current.pos.x, i_this->mTargetPos.x, 0.2f, 15.0f); + cLib_addCalc2(&_this->current.pos.y, i_this->mTargetPos.y, 1.0f, 15.0f); + cLib_addCalc2(&_this->current.pos.z, i_this->mTargetPos.z, 0.2f, 15.0f); if (i_this->mpMorf->isStop()) { - if (i_this->field_0x5b4 == 2) { + if (i_this->mBehavior == npc_ne_class::BHV_PIER) { i_this->mAction = npc_ne_class::ACT_HOME; } else { i_this->mAction = npc_ne_class::ACT_WAIT; } - i_this->mState = 0; + i_this->mMode = 0; } break; } - if (ret == 0) { - i_this->speed.y = 0.0f; - i_this->speedF = 0.0f; - i_this->gravity = 0.0f; + if (!ret) { + _this->speed.y = 0.0f; + _this->speedF = 0.0f; + _this->gravity = 0.0f; } return ret; } @@ -3346,13 +3392,13 @@ static asm int npc_ne_climb(npc_ne_class* param_0) { #ifdef NONMATCHING // matches with literals static void npc_ne_drop(npc_ne_class* i_this) { - switch (i_this->mState) { + switch (i_this->mMode) { case 0: - i_this->mState++; + i_this->mMode++; i_this->speedF = 0.0f; i_this->speed.y = 0.0f; anm_init(i_this, npc_ne_class::ANM_JUMP_END, 3.0f, 0, 0.0f); - // no break + // fallthrough case 1: i_this->current.angle.x = 0x3000; @@ -3361,14 +3407,14 @@ static void npc_ne_drop(npc_ne_class* i_this) { i_this->current.angle.x = 0; i_this->mpMorf->setPlaySpeed(2.0f); i_this->mTimers[0] = 10; - i_this->mState++; + i_this->mMode++; } break; case 2: if (i_this->mTimers[0] == 0) { i_this->mAction = npc_ne_class::ACT_WAIT; - i_this->mState = 0; + i_this->mMode = 0; i_this->mNoFollow = true; } break; @@ -3387,21 +3433,21 @@ static asm void npc_ne_drop(npc_ne_class* param_0) { /* 80A8EB60-80A8ED58 005F80 01F8+00 1/1 0/0 0/0 .text npc_ne_s_drop__FP12npc_ne_class */ #ifdef NONMATCHING -// isStop regalloc +// matches with literals static void npc_ne_s_drop(npc_ne_class* i_this) { int frame = i_this->mpMorf->getFrame(); f32 target_speed = 0.0f; f32 max_speed_step = 3.0f; - switch (i_this->mState) { + switch (i_this->mMode) { case 0: i_this->mAnmSpeed = 1.0f; anm_init(i_this, npc_ne_class::ANM_TO_JUMP, 3.0f, 0, 1.0f); - i_this->mState++; + i_this->mMode++; break; case 1: - i_this->field_0x67a = 3; + i_this->mLookDownTimer = 3; i_this->speed.y = 0.0f; i_this->speedF = 0.0f; i_this->gravity = 0.0f; @@ -3409,10 +3455,10 @@ static void npc_ne_s_drop(npc_ne_class* i_this) { break; } anm_init(i_this, npc_ne_class::ANM_JUMP_START, 2.0f, 0, 1.0f); - i_this->mState++; + i_this->mMode++; i_this->mTimers[0] = 3; i_this->shape_angle.x = 0x1c00; - // no break + // fallthrough case 2: i_this->current.angle.x = 0x3800; @@ -3424,7 +3470,7 @@ static void npc_ne_s_drop(npc_ne_class* i_this) { if (i_this->mTimers[0] == 0 && i_this->mAcch.i_ChkGroundHit()) { anm_init(i_this, npc_ne_class::ANM_JUMP_END, 3.0f, 0, 1.0f); i_this->mpMorf->setFrame(4.0f); - i_this->mState++; + i_this->mMode++; } break; @@ -3432,7 +3478,7 @@ static void npc_ne_s_drop(npc_ne_class* i_this) { max_speed_step = 1.0f; if (i_this->mpMorf->isStop()) { i_this->mAction = npc_ne_class::ACT_WAIT; - i_this->mState = 0; + i_this->mMode = 0; } break; } @@ -3474,18 +3520,19 @@ COMPILER_STRIP_GATE(0x80A92544, &lit_6253); /* 80A8ED58-80A8F0FC 006178 03A4+00 1/1 0/0 0/0 .text npc_ne_carry__FP12npc_ne_class */ #ifdef NONMATCHING -// regalloc -static int npc_ne_carry(npc_ne_class* i_this) { - int ret = 0; - i_this->field_0x656 = 5; +// matches with literals +static BOOL npc_ne_carry(npc_ne_class* i_this) { + fopAc_ac_c* _this = static_cast(i_this); + BOOL ret = false; + i_this->mCcDisableTimer = 5; - switch (i_this->mState) { + switch (i_this->mMode) { case 0: anm_init(i_this, npc_ne_class::ANM_TO_CARRY_B, 1.0f, 0, daPy_getLinkPlayerActorClass()->getBaseAnimeFrameRate()); i_this->mpMorf->setFrame(daPy_getLinkPlayerActorClass()->getBaseAnimeFrame()); i_this->mTimers[0] = 20; - i_this->mState++; + i_this->mMode++; break; case 1: @@ -3496,49 +3543,49 @@ static int npc_ne_carry(npc_ne_class* i_this) { anm_init(i_this, npc_ne_class::ANM_TO_CARRY_B, 1.0f, 0, daPy_getLinkPlayerActorClass()->getBaseAnimeFrameRate()); i_this->mpMorf->setFrame(daPy_getLinkPlayerActorClass()->getBaseAnimeFrame()); - i_this->mState++; + i_this->mMode++; } break; } - i_this->field_0x690 = 1300.0f; + i_this->mTailSwayTarget = 1300.0f; - if (!fopAcM_checkCarryNow(i_this)) { + if (!fopAcM_checkCarryNow(_this)) { i_this->mAction = npc_ne_class::ACT_TAME; - i_this->mState = 0; + i_this->mMode = 0; dBgS_GndChk gnd_chk; - cXyz pos = i_this->current.pos; + cXyz pos = _this->current.pos; pos.y += 50.0f; gnd_chk.SetPos(&pos); - if (fabsf(i_this->current.pos.y - dComIfG_Bgsp().GroundCross(&gnd_chk)) < 30.0f) { - i_this->current.pos.y = dComIfG_Bgsp().GroundCross(&gnd_chk); - i_this->field_0x91c = i_this->current.pos.y; - i_this->gravity = 0.0f; + if (fabsf(_this->current.pos.y - dComIfG_Bgsp().GroundCross(&gnd_chk)) < 30.0f) { + _this->current.pos.y = dComIfG_Bgsp().GroundCross(&gnd_chk); + i_this->mGroundY = _this->current.pos.y; + _this->gravity = 0.0f; } else { i_this->mAction = npc_ne_class::ACT_DROP; - i_this->mState = 0; + i_this->mMode = 0; i_this->mSound.startSound(Z2SE_CAT_CRY_ANNOY, 0, -1); - i_this->speed.y = -10.0f; - return 0; + _this->speed.y = -10.0f; + return false; } } - i_this->speedF = 0.0f; + _this->speedF = 0.0f; if (i_this->mTimers[0] != 0) { - ret = 1; - i_this->speed.y = -0.1f; + ret = true; + _this->speed.y = -0.1f; } else { - i_this->speed.y = 0.0f; + _this->speed.y = 0.0f; } - i_this->field_0x6f0 = 10; + i_this->mCarryTimer = 10; fopAc_ac_c* player = dComIfGp_getPlayer(0); dBgS_LinChk lin_chk; - cXyz pos = i_this->current.pos; + cXyz pos = _this->current.pos; pos.y += 2.0f; - lin_chk.Set(&player->eyePos, &pos, i_this); + lin_chk.Set(&player->eyePos, &pos, _this); if (dComIfG_Bgsp().LineCross(&lin_chk)) { - i_this->current.pos = lin_chk.i_GetCross(); + _this->current.pos = lin_chk.i_GetCross(); } return ret; @@ -3566,20 +3613,20 @@ COMPILER_STRIP_GATE(0x80A92548, &lit_6270); #ifdef NONMATCHING // matches with literals static void npc_ne_dish(npc_ne_class* i_this) { - i_this->field_0x656 = 10; + i_this->mCcDisableTimer = 10; - switch (i_this->mState) { + switch (i_this->mMode) { case 0: anm_init(i_this, npc_ne_class::ANM_MILK, 1.0f, 2, 1.0f); - i_this->mState++; - // no break + i_this->mMode++; + // fallthrough case 1: default: if (!dComIfGs_isEventBit(0x1001)) { i_this->current.pos.y = 20000.0f; i_this->speed.y = 0.0f; - fopAcM_OffStatus(i_this, 0x100); + fopAcM_OffStatus(i_this, fopAcStts_CULL_e); } break; } @@ -3599,21 +3646,21 @@ static asm void npc_ne_dish(npc_ne_class* param_0) { #ifdef NONMATCHING // matches with literals static void npc_ne_message(npc_ne_class* i_this) { - i_this->field_0x668 = 1; + i_this->mLookMode = npc_ne_class::LOOK_PLAYER; - switch (i_this->mState) { + switch (i_this->mMode) { case 0: anm_init(i_this, npc_ne_class::ANM_WAIT, 3.0f, 2, 1.0f); - i_this->mState++; - // no break + i_this->mMode++; + // fallthrough case 1: default: cLib_addCalc0(&i_this->speedF, 1.0f, 2.0f); cLib_addCalcAngleS2(&i_this->current.angle.y, i_this->mAngleToPlayer, 2, 0x1000); - if (i_this->field_0xc0a == 0 && i_this->mDistToTarget > 400.0f) { + if (!i_this->mIsTalking && i_this->mDistToTarget > 400.0f) { i_this->mAction = npc_ne_class::ACT_WAIT; - i_this->mState = 0; + i_this->mMode = 0; } break; } @@ -3644,20 +3691,22 @@ COMPILER_STRIP_GATE(0x80A92550, &lit_6812); /* 80A8F278-80A903E8 006698 1170+00 2/1 0/0 0/0 .text action__FP12npc_ne_class */ #ifdef NONMATCHING -// regalloc +// matches with literals static void action(npc_ne_class* i_this) { - fopAc_ac_c* player = dComIfGp_getPlayer(0); - i_this->gravity = -7.0f; + fopAc_ac_c* _this = static_cast(i_this); + daPy_py_c* player = static_cast(dComIfGp_getPlayer(0)); + + _this->gravity = -7.0f; if (i_this->mResName == "Npc_net") { i_this->mDistToTarget = 10000.0f; } else { - i_this->mDistToTarget = i_this->field_0x5e0 * fopAcM_searchPlayerDistance(i_this); + i_this->mDistToTarget = i_this->mDistScale * fopAcM_searchPlayerDistance(_this); } if (daPy_getPlayerActorClass()->checkHorseRide()) { i_this->mDistToTarget -= 100.0f; } - i_this->mAngleToPlayer = fopAcM_searchPlayerAngleY(i_this); + i_this->mAngleToPlayer = fopAcM_searchPlayerAngleY(_this); i_this->field_0x6b8 = fabsf(player->eyePos.y - player->current.pos.y); if (fabsf(i_this->current.pos.y - player->current.pos.y) > 50.0f) { @@ -3665,41 +3714,41 @@ static void action(npc_ne_class* i_this) { } i_this->field_0x6b8 *= 0.7f; - int ivar11 = 1; - int ivar10 = 1; - BOOL bvar4 = true; - int ivar5 = 0; - BOOL bvar9 = true; + BOOL ground_check = true; + int water_check_state = 1; + BOOL drop_check = true; + int water_state = 0; + BOOL carry_check = true; i_this->mCcSph.OnCoSetBit(); if (i_this->field_0x65c < 1.0f) { - BOOL bvar3 = false; + BOOL bird_check = false; i_this->field_0x560 = 1; - i_this->field_0xc08 = 0; + i_this->mMessageState = 0; switch (i_this->mAction) { case npc_ne_class::ACT_WAIT: - i_this->field_0xc08 = 1; + i_this->mMessageState = 1; npc_ne_wait(i_this); - bvar3 = true; + bird_check = true; break; case npc_ne_class::ACT_AWAY: npc_ne_away(i_this); - bvar3 = true; - i_this->field_0xc08 = 1; + bird_check = true; + i_this->mMessageState = 1; break; case npc_ne_class::ACT_TAME: npc_ne_tame(i_this); - bvar3 = true; - i_this->field_0xc08 = 1; + bird_check = true; + i_this->mMessageState = 1; break; case npc_ne_class::ACT_HOME: - ivar11 = npc_ne_home(i_this); - bvar4 = false; + ground_check = npc_ne_home(i_this); + drop_check = false; break; case npc_ne_class::ACT_ROOF: npc_ne_roof(i_this); - bvar4 = true; + drop_check = true; break; case npc_ne_class::ACT_BIRD: npc_ne_bird(i_this); @@ -3710,117 +3759,117 @@ static void action(npc_ne_class* i_this) { break; case npc_ne_class::ACT_SANBASI: npc_ne_sanbasi(i_this); - bvar4 = false; - bvar9 = false; + drop_check = false; + carry_check = false; break; case npc_ne_class::ACT_JUMP: npc_ne_jump(i_this); - bvar9 = false; + carry_check = false; break; case npc_ne_class::ACT_S_JUMP: npc_ne_s_jump(i_this); - bvar9 = false; + carry_check = false; break; case npc_ne_class::ACT_PATH_WALK: npc_ne_pathwalk(i_this); - bvar3 = true; - i_this->field_0xc08 = 1; + bird_check = true; + i_this->mMessageState = 1; break; case npc_ne_class::ACT_SWIM: npc_ne_swim(i_this); - ivar10 = 2; - ivar5 = 2; - bvar4 = false; - fopAcM_riverStream(&i_this->current.pos, &i_this->field_0xcb6, + water_check_state = 2; + water_state = 2; + drop_check = false; + fopAcM_riverStream(&_this->current.pos, &i_this->field_0xcb6, &i_this->field_0xcb8, 0.5f); break; case npc_ne_class::ACT_OUT_SWIM: npc_ne_outswim(i_this); - ivar10 = 0; - ivar11 = 0; - bvar4 = false; + water_check_state = 0; + ground_check = false; + drop_check = false; break; case npc_ne_class::ACT_CLIMB: - ivar11 = npc_ne_climb(i_this); - ivar10 = 0; - bvar4 = false; + ground_check = npc_ne_climb(i_this); + water_check_state = 0; + drop_check = false; break; case npc_ne_class::ACT_DROP: npc_ne_drop(i_this); - bvar4 = false; - bvar9 = false; + drop_check = false; + carry_check = false; break; case npc_ne_class::ACT_S_DROP: npc_ne_s_drop(i_this); - bvar4 = false; - bvar9 = false; + drop_check = false; + carry_check = false; break; case npc_ne_class::ACT_MESSAGE: npc_ne_message(i_this); - i_this->field_0xc08 = 2; + i_this->mMessageState = 2; break; case npc_ne_class::ACT_DISH: npc_ne_dish(i_this); - ivar10 = 0; - bvar4 = false; - bvar9 = false; + water_check_state = 0; + drop_check = false; + carry_check = false; break; case npc_ne_class::ACT_CARRY: - ivar11 = npc_ne_carry(i_this); - ivar10 = 0; - bvar4 = false; + ground_check = npc_ne_carry(i_this); + water_check_state = 0; + drop_check = false; i_this->mCcSph.OffCoSetBit(); - bvar9 = false; + carry_check = false; break; } if (i_this->mResName != "Npc_net") { - if (i_this->field_0xc08 == 1 && daPy_py_c::i_checkNowWolf() - && i_this->mDistToTarget < 300.0f) { + if (i_this->mMessageState == 1 && daPy_py_c::i_checkNowWolf() + && i_this->mDistToTarget < 300.0f) { i_this->mAction = npc_ne_class::ACT_MESSAGE; - i_this->mState = 0; - bvar3 = false; + i_this->mMode = 0; + bird_check = false; } - if (bvar3 && i_this->field_0x701 == 0) { - fopAc_ac_c* bird = search_bird(i_this); - if (bird != NULL) { - if (fopAcM_GetName(bird) == PROC_OBJ_FOOD) { + if (bird_check && !i_this->mWantsFish) { + fopAc_ac_c* bird_or_ball = search_bird(i_this); + if (bird_or_ball != NULL) { + if (fopAcM_GetName(bird_or_ball) == PROC_OBJ_FOOD) { i_this->mAction = npc_ne_class::ACT_BALL; - i_this->mState = 0; - bvar9 = true; + i_this->mMode = 0; + carry_check = true; } else { i_this->mAction = npc_ne_class::ACT_BIRD; - i_this->mState = 0; - bvar9 = true; + i_this->mMode = 0; + carry_check = true; } } } } } - if (bvar9 && i_this->field_0x701 == 0) { - cLib_onBit(i_this->attention_info.flags, 0x10); + if (carry_check && !i_this->mWantsFish) { + cLib_onBit(_this->attention_info.flags, 0x10); if (ne_carry_check(i_this)) { return; } } else { - cLib_offBit(i_this->attention_info.flags, 0x10); + cLib_offBit(_this->attention_info.flags, 0x10); } cXyz vec1, vec2, vec3; - if (i_this->field_0x701 != 0 && i_this->mAction != npc_ne_class::ACT_SANBASI - && player->current.pos.z > -2800.0f) { + if (i_this->mWantsFish && i_this->mAction != npc_ne_class::ACT_SANBASI + && player->current.pos.z > -2800.0f) { dmg_rod_class* rod = static_cast(fopAcM_SearchByName(PROC_MG_ROD)); if (rod != NULL && rod->field_0xf7c == 1 && rod->field_0xf7e != 5 && rod->field_0x13b4 != 0 && !i_this->mNoFollow) { if (i_this->mDistToTarget > 500.0f) { - i_this->current.pos = ground_search(i_this); - i_this->old = i_this->current; + _this->current.pos = ground_search(i_this); + _this->old = _this->current; } } else if (!i_this->mNoFollow) { - if (i_this->mDistToTarget > 700.0f && fopAcM_CheckCondition(i_this, 4) - && i_this->speedF > 2.0f) { + if (i_this->mDistToTarget > 700.0f && fopAcM_CheckCondition(_this, 4) + && player->speedF > 2.0f) { camera_class* camera = dComIfGp_getCamera(0); vec1.x = camera->mLookat.mEye.x - camera->mLookat.mCenter.x; vec1.z = camera->mLookat.mEye.z - camera->mLookat.mCenter.z; @@ -3834,47 +3883,47 @@ static void action(npc_ne_class* i_this) { dBgS_GndChk gnd_chk; gnd_chk.SetPos(&vec2); vec2.y = dComIfG_Bgsp().GroundCross(&gnd_chk); - if (cross <= vec2.y && fabsf(vec2.y - player->current.pos.y) < 100.0f) { + if (vec2.y >= cross && fabsf(vec2.y - player->current.pos.y) < 100.0f) { if (i_this->mAction != npc_ne_class::ACT_TAME) { i_this->mAction = npc_ne_class::ACT_TAME; - i_this->mState = 0; + i_this->mMode = 0; } - i_this->current.pos = vec2; - i_this->old = i_this->current; + _this->current.pos = vec2; + _this->old = _this->current; } } } else { - if (i_this->mDistToTarget > 500.0f) { + if (player->current.pos.y > 500.0f) { i_this->mAction = npc_ne_class::ACT_SANBASI; - i_this->mState = 0; - i_this->current.pos.set(3400.0f, 84.13f, 64.0f); - i_this->current.angle.y = -0x6987; - i_this->shape_angle.y = i_this->current.angle.y; - i_this->old = i_this->home = i_this->current; - i_this->speedF = 0.0f; + i_this->mMode = 0; + _this->current.pos.set(3400.0f, 84.13f, 64.0f); + _this->current.angle.y = -0x6987; + _this->shape_angle.y = _this->current.angle.y; + _this->old = _this->home = _this->current; + _this->speedF = 0.0f; } } } - cLib_addCalcAngleS2(&i_this->current.angle.x, 0, 1, 0x400); - mDoMtx_YrotS(*calc_mtx, i_this->current.angle.y); + cLib_addCalcAngleS2(&_this->current.angle.x, 0, 1, 0x400); + mDoMtx_YrotS(*calc_mtx, _this->current.angle.y); vec1.x = 0.0f; vec1.y = 0.0f; - vec1.z = i_this->speedF * i_this->mBaseScale.z; + vec1.z = _this->speedF * i_this->mBaseScale.z; MtxPosition(&vec1, &vec2); - i_this->speed.x = vec2.x; - i_this->speed.z = vec2.z; - i_this->speed.y += i_this->gravity; - i_this->current.pos += i_this->speed; - if (i_this->speed.y < -120.0f) { - i_this->speed.y = -120.0f; + _this->speed.x = vec2.x; + _this->speed.z = vec2.z; + _this->speed.y += _this->gravity; + _this->current.pos += _this->speed; + if (_this->speed.y < -120.0f) { + _this->speed.y = -120.0f; } - if (!fopAcM_checkCarryNow(i_this) && i_this->mAction != npc_ne_class::ACT_PATH_WALK) { + if (!fopAcM_checkCarryNow(_this) && i_this->mAction != npc_ne_class::ACT_PATH_WALK) { cXyz* cc_move = i_this->mStts.GetCCMoveP(); if (cc_move != NULL) { - i_this->current.pos.x += cc_move->x * 0.1f; - i_this->current.pos.y += cc_move->y * 0.1f; - i_this->current.pos.z += cc_move->z * 0.1f; + _this->current.pos.x += cc_move->x * 0.1f; + _this->current.pos.y += cc_move->y * 0.1f; + _this->current.pos.z += cc_move->z * 0.1f; } } @@ -3884,111 +3933,112 @@ static void action(npc_ne_class* i_this) { vec1.z = -i_this->field_0x65c; mDoMtx_YrotS(*calc_mtx, i_this->field_0x660); MtxPosition(&vec1, &vec2); - vec2 += i_this->current.pos; + _this->current.pos += vec2; cLib_addCalc0(&i_this->field_0x65c, 1.0f, 6.0f); - i_this->speedF = 0.0f; + _this->speedF = 0.0f; } - if (ivar11 != 0) { + if (ground_check) { i_this->mAcch.CrrPos(dComIfG_Bgsp()); - i_this->field_0x91c = i_this->mAcch.GetGroundH(); + i_this->mGroundY = i_this->mAcch.GetGroundH(); } else { - i_this->field_0x91c = i_this->current.pos.y; + i_this->mGroundY = _this->current.pos.y; } - if (ivar11 != 0 && i_this->mAcch.ChkGroundHit()) { + if (ground_check && i_this->mAcch.ChkGroundHit()) { dBgS_GndChk gnd_chk; - mDoMtx_YrotS(*calc_mtx, i_this->shape_angle.y); + mDoMtx_YrotS(*calc_mtx, _this->shape_angle.y); vec1.x = 0.0f; vec1.y = 0.0f; vec1.z = i_this->mBaseScale.z * -25.0f; MtxPosition(&vec1, &vec2); - vec2 += i_this->current.pos; + vec2 += _this->current.pos; vec3.set(vec2.x, vec2.y + 100.0f, vec2.z); gnd_chk.SetPos(&vec3); vec2.y = dComIfG_Bgsp().GroundCross(&gnd_chk); - vec1 = vec2 - i_this->current.pos; + vec1 = vec2 - _this->current.pos; if (fabsf(vec1.y) < 50.0f) { f32 vec1_xz = JMAFastSqrt(vec1.x * vec1.x + vec1.z * vec1.z); - i_this->current.angle.x = cM_atan2s(vec1.y, vec1_xz); + _this->current.angle.x = cM_atan2s(vec1.y, vec1_xz); } } - cLib_addCalcAngleS2(&i_this->shape_angle.y, i_this->current.angle.y, 2, 0x2000); - cLib_addCalcAngleS2(&i_this->shape_angle.x, i_this->current.angle.x, 2, 0x1000); - cLib_addCalcAngleS2(&i_this->shape_angle.z, i_this->current.angle.z, 4, 0x1000); - i_this->current.angle.z = 0; - cLib_addCalcAngleS2(&i_this->field_0x694, i_this->field_0x696, 2, 0x400); + cLib_addCalcAngleS2(&_this->shape_angle.y, _this->current.angle.y, 2, 0x2000); + cLib_addCalcAngleS2(&_this->shape_angle.x, _this->current.angle.x, 2, 0x1000); + cLib_addCalcAngleS2(&_this->shape_angle.z, _this->current.angle.z, 4, 0x1000); + _this->current.angle.z = 0; + cLib_addCalcAngleS2(&i_this->mBackboneAngleY, i_this->mBackboneTargetAngleY, 2, 0x400); - if (bvar4) { - f32 fvar15 = i_this->current.pos.y - i_this->field_0x91c; - if (fvar15 > 300.0f) { + if (drop_check) { + f32 height = _this->current.pos.y - i_this->mGroundY; + if (height > 300.0f) { i_this->mAction = npc_ne_class::ACT_DROP; - i_this->mState = 0; + i_this->mMode = 0; i_this->mSound.startSound(Z2SE_CAT_CRY_ANNOY, 0, -1); - } else if (fvar15 > 30.0f && i_this->mAction != npc_ne_class::ACT_ROOF) { - i_this->current.pos = i_this->old.pos; + } else if (height > 30.0f && i_this->mAction != npc_ne_class::ACT_ROOF) { + _this->current.pos = _this->old.pos; i_this->mAction = npc_ne_class::ACT_S_DROP; - i_this->mState = 0; + i_this->mMode = 0; } } - if (ivar10 == 1) { + if (water_check_state == 1) { if (water_check(i_this, 5.0f) > 0) { i_this->mAction = npc_ne_class::ACT_SWIM; - i_this->mState = 0; + i_this->mMode = 0; i_this->mNoFollow = true; - ivar5 = 1; - if (i_this->field_0x5b4 == 2) { - i_this->field_0x5b4 = 0; + water_state = 1; + if (i_this->mBehavior == npc_ne_class::BHV_PIER) { + i_this->mBehavior = npc_ne_class::BHV_NONE; } i_this->field_0x65c = 0.0f; } - } else if (ivar10 == 2) { + } else if (water_check_state == 2) { if (water_check(i_this, 5.0f) != 1) { i_this->mAction = npc_ne_class::ACT_AWAY; - i_this->mState = 5; + i_this->mMode = 5; i_this->mTimers[2] = cM_rndF(5.0f) + 10.0f; i_this->mTimers[3] = 30; - i_this->mTargetAngleY = i_this->shape_angle.y; + i_this->mTargetAngleY = _this->shape_angle.y; i_this->mTimers[0] = cM_rndF(5.0f) + 10.0f; i_this->mTimers[1] = 20; } } - if (i_this->field_0x678 != 0) { - i_this->field_0x678--; - i_this->field_0x668 = 3; + if (i_this->mLookNoMoveTimer != 0) { + i_this->mLookNoMoveTimer--; + i_this->mLookMode = npc_ne_class::LOOK_NONE; } - if (i_this->field_0x67a != 0) { - i_this->field_0x67a--; - i_this->field_0x668 = 2; - mDoMtx_YrotS(*calc_mtx, i_this->current.angle.y); + if (i_this->mLookDownTimer != 0) { + i_this->mLookDownTimer--; + i_this->mLookMode = npc_ne_class::LOOK_TARGET; + mDoMtx_YrotS(*calc_mtx, _this->current.angle.y); vec1.set(0.0f, -30.0f, 50.0f); - MtxPosition(&vec1, &i_this->field_0x66c); - i_this->field_0x66c += i_this->current.pos; + MtxPosition(&vec1, &i_this->mLookTarget); + i_this->mLookTarget += _this->current.pos; } - if (i_this->field_0x67c != 0) { - i_this->field_0x67c--; - i_this->field_0x668 = 2; - mDoMtx_YrotS(*calc_mtx, i_this->current.angle.y); + if (i_this->mLookUpTimer != 0) { + i_this->mLookUpTimer--; + i_this->mLookMode = npc_ne_class::LOOK_TARGET; + mDoMtx_YrotS(*calc_mtx, _this->current.angle.y); vec1.set(0.0f, 30.0f, 50.0f); - MtxPosition(&vec1, &i_this->field_0x66c); - i_this->field_0x66c += i_this->current.pos; + MtxPosition(&vec1, &i_this->mLookTarget); + i_this->mLookTarget += _this->current.pos; } - if (i_this->field_0x694 < 0x800 && i_this->field_0x694 > -0x800 && i_this->field_0x668 != 0) { - if ((i_this->field_0x640 & 0xf) == 0 || i_this->field_0x668 <= 2) { - if (i_this->field_0x668 == 2) { - vec1 = i_this->field_0x66c - i_this->current.pos; + if (i_this->mBackboneAngleY < 0x800 && i_this->mBackboneAngleY > -0x800 + && i_this->mLookMode != npc_ne_class::LOOK_FORWARD) { + if ((i_this->mCounter & 0xf) == 0 || i_this->mLookMode <= npc_ne_class::LOOK_TARGET) { + if (i_this->mLookMode == npc_ne_class::LOOK_TARGET) { + vec1 = i_this->mLookTarget - i_this->current.pos; } else { vec1 = player->eyePos - i_this->current.pos; if (!daPy_py_c::i_checkNowWolf()) { vec1.y += i_this->mBaseScale.z * -40.0f; } } - i_this->mHeadTargetAngleY = cM_atan2s(vec1.x, vec1.z) - i_this->shape_angle.y; + i_this->mHeadTargetAngleY = cM_atan2s(vec1.x, vec1.z) - _this->shape_angle.y; f32 vec1_xz = JMAFastSqrt(vec1.x * vec1.x + vec1.z * vec1.z); - i_this->mHeadTargetAngleZ = cM_atan2s(vec1.y, vec1_xz) + i_this->shape_angle.x; + i_this->mHeadTargetAngleZ = cM_atan2s(vec1.y, vec1_xz) + _this->shape_angle.x; if (i_this->mHeadTargetAngleY > 15000) { i_this->mHeadTargetAngleY = 15000; } else if (i_this->mHeadTargetAngleY < -15000) { @@ -4000,71 +4050,71 @@ static void action(npc_ne_class* i_this) { i_this->mHeadTargetAngleZ = -15000; } } - i_this->field_0x668 = 0; + i_this->mLookMode = npc_ne_class::LOOK_FORWARD; } else { i_this->mHeadTargetAngleZ = 0; i_this->mHeadTargetAngleY = 0; } - i_this->field_0x696 = 0; + i_this->mBackboneTargetAngleY = 0; cLib_addCalcAngleS2(&i_this->mHeadAngleY, i_this->mHeadTargetAngleY, 4, 0x1000); cLib_addCalcAngleS2(&i_this->mHeadAngleZ, i_this->mHeadTargetAngleZ, 4, 0x1000); - cLib_addCalcAngleS2(&i_this->mHeadMinorAngleY, i_this->mHeadMinorTargetAngleY, 4, 0x400); - cLib_addCalcAngleS2(&i_this->mHeadMinorAngleX, i_this->mHeadMinorTargetAngleX, 4, 0x400); + cLib_addCalcAngleS2(&i_this->mHeadBobAngleY, i_this->mHeadBobTargetAngleY, 4, 0x400); + cLib_addCalcAngleS2(&i_this->mHeadBobAngleX, i_this->mHeadBobTargetAngleX, 4, 0x400); if (fabsf(player->speedF) < 2.0f) { - if (i_this->field_0x6a4 != 0) { - i_this->field_0x6a4--; - if (i_this->field_0x6a4 == 0) { - i_this->field_0x6a4 = cM_rndF(20.0f) + 20.0f; + if (i_this->mHeadBobTimer != 0) { + i_this->mHeadBobTimer--; + if (i_this->mHeadBobTimer == 0) { + i_this->mHeadBobTimer = cM_rndF(20.0f) + 20.0f; if (cM_rndF(1.0f) < 0.5f) { - i_this->mHeadMinorTargetAngleY = cM_rndFX(1500.0f); + i_this->mHeadBobTargetAngleY = cM_rndFX(1500.0f); } if (cM_rndF(1.0f) < 0.5f) { - i_this->mHeadMinorTargetAngleX = cM_rndFX(1500.0f); + i_this->mHeadBobTargetAngleX = cM_rndFX(1500.0f); } } } } else { - i_this->mHeadMinorTargetAngleX = 0; - i_this->mHeadMinorTargetAngleY = 0; - i_this->field_0x6a4 = cM_rndF(40.0f) + 40.0f; + i_this->mHeadBobTargetAngleX = 0; + i_this->mHeadBobTargetAngleY = 0; + i_this->mHeadBobTimer = cM_rndF(40.0f) + 40.0f; } for (int i = 0; i < 2; i++) { - i_this->field_0x684[i] = - i_this->field_0x68c * cM_ssin(i_this->field_0x640 * 2000 + i * -22000); + i_this->mTailSwayAngle[i] = + i_this->mTailSway * cM_ssin(i_this->mCounter * 2000 + i * -22000); } - cLib_addCalc2(&i_this->field_0x68c, i_this->field_0x690, 0.1f, 100.0f); - i_this->field_0x690 = 0.0f; - cLib_addCalcAngleS2(&i_this->field_0x688, i_this->field_0x68a, 8, 1000); - i_this->field_0x68a = 0; + cLib_addCalc2(&i_this->mTailSway, i_this->mTailSwayTarget, 0.1f, 100.0f); + i_this->mTailSwayTarget = 0.0f; + cLib_addCalcAngleS2(&i_this->mTailAngle, i_this->mTailTargetAngle, 8, 1000); + i_this->mTailTargetAngle = 0; - if (ivar5 != 0) { - cXyz vec4 = i_this->eyePos; - vec4.y = i_this->field_0x6bc; - if (ivar5 == 1) { - if (i_this->field_0x658 == 0) { - i_this->field_0x658 = 20; - fopKyM_createWpillar(&vec4, 0.7f, 0); + if (water_state != 0) { + cXyz splash_pos = _this->eyePos; + splash_pos.y = i_this->mWaterY; + if (water_state == 1) { + if (i_this->mSplashTimer == 0) { + i_this->mSplashTimer = 20; + fopKyM_createWpillar(&splash_pos, 0.7f, 0); i_this->mSound.startSound(Z2SE_CM_BODYFALL_WATER_S, 0, -1); } } else { - fopAcM_effHamonSet(i_this->mParticle, &vec4, 0.7f, 0.1f); + fopAcM_effHamonSet(i_this->mParticle, &splash_pos, 0.7f, 0.1f); } } - if (i_this->field_0x5f8 != 0) { + if (i_this->mBtpReset != 0) { cLib_addCalcAngleS2(&i_this->mBtpFrame, 3, 1, 1); - i_this->field_0x5f8 = 0; - i_this->field_0x62c = 60; + i_this->mBtpReset = 0; + i_this->mBtpTimer = 60; } else { - if (i_this->field_0x62c == 0) { - i_this->field_0x62c = cM_rndF(100.0f) + 30.0f; + if (i_this->mBtpTimer == 0) { + i_this->mBtpTimer = cM_rndF(100.0f) + 30.0f; } else { - i_this->field_0x62c--; - if (i_this->field_0x62c <= 5) { - i_this->mBtpFrame = 5 - i_this->field_0x62c; + i_this->mBtpTimer--; + if (i_this->mBtpTimer <= 5) { + i_this->mBtpFrame = 5 - i_this->mBtpTimer; } else { i_this->mBtpFrame = 0; } @@ -4237,27 +4287,275 @@ COMPILER_STRIP_GATE(0x80A925A8, &lit_7061); #pragma pop /* 80A903E8-80A90E28 007808 0A40+00 1/1 0/0 0/0 .text demo_camera__FP12npc_ne_class */ +#ifdef NONMATCHING +// matches with literals +static void demo_camera(npc_ne_class* i_this) { + fopAc_ac_c* _this = static_cast(i_this); + daPy_py_c* player = static_cast(dComIfGp_getPlayer(0)); + camera_class* camera = dComIfGp_getCamera(dComIfGp_getPlayerCameraID(0)); + + if (i_this->mDemoTimer != 0) { + i_this->mDemoTimer--; + } + + dBgS_LinChk lin_chk; + dBgS_GndChk gnd_chk; + fopAc_ac_c* fish; + cXyz vec, eye, center; + BOOL bvar1 = false; + BOOL bird_check = false; + + switch (i_this->mDemoMode) { + case 0: + break; + + case 1: + if (!_this->eventInfo.i_checkCommandDemoAccrpt()) { + fopAcM_orderPotentialEvent(_this, 2, 0xffff, 0); + _this->eventInfo.i_onCondition(dEvtCnd_CANDEMO_e); + return; + } + + camera->mCamera.Stop(); + i_this->mDemoMode = 2; + i_this->mDemoCounter = 0; + i_this->mCameraFovY = 55.0f; + camera->mCamera.SetTrimSize(3); + daPy_getPlayerActorClass()->changeOriginalDemo(); + // fallthrough + + case 2: + daPy_getPlayerActorClass()->setPlayerPosAndAngle(&player->current.pos, + i_this->mAngleToPlayer + 0x8000, 0); + + center = _this->current.pos; + eye = _this->current.pos; + eye.y += 200.0f; + eye.z += 500.0f; + + if (i_this->mDemoTimer == 0) { + i_this->mCameraEye1 = eye; + i_this->mCameraCenter1 = center; + } else { + cLib_addCalc2(&i_this->mCameraEye1.x, eye.x, 0.1f, 30.0f); + cLib_addCalc2(&i_this->mCameraEye1.y, eye.y, 0.1f, 30.0f); + cLib_addCalc2(&i_this->mCameraEye1.z, eye.z, 0.1f, 30.0f); + cLib_addCalc2(&i_this->mCameraCenter1.x, center.x, 0.2f, 30.0f); + cLib_addCalc2(&i_this->mCameraCenter1.y, center.y, 0.2f, 30.0f); + cLib_addCalc2(&i_this->mCameraCenter1.z, center.z, 0.2f, 30.0f); + } + break; + + case 3: + if (i_this->mDemoCounter == 0) { + i_this->mCameraCenter1.set(387.0f, 133.0f, -866.0f); + i_this->mCameraEye1.set(284.0f, 208.0f, -585.0f); + } + + if (i_this->mDemoCounter == 12) { + fopAc_ac_c* door = fopAcM_SearchByName(PROC_OBJ_NDOOR); + if (door != NULL) { + door->field_0x567 = 10; + Z2GetAudioMgr()->seStart(Z2SE_OBJ_CAT_DOOR, &door->current.pos, + 0, 0, 1.0f, 1.0f, -1.0f, -1.0f, 0); + } + Z2GetAudioMgr()->changeBgmStatus(0); + } + + cLib_addCalc2(&i_this->mCameraFovY, 35.0f, 0.1f, 0.33f); + + if (i_this->field_0xcc0 && i_this->mDemoCounter == 52) { + Z2GetAudioMgr()->seStart(Z2SE_READ_RIDDLE_B, NULL, 0, 0, 1.0f, 1.0f, -1.0f, -1.0f, 0); + } + + if (i_this->mDemoCounter > 110) { + i_this->mDemoMode = 99; + } + break; + + case 10: + if (!_this->eventInfo.i_checkCommandDemoAccrpt()) { + fopAcM_orderPotentialEvent(_this, 2, 0xffff, 0); + _this->eventInfo.i_onCondition(dEvtCnd_CANDEMO_e); + return; + } + + camera->mCamera.Stop(); + i_this->mDemoMode = 11; + i_this->mDemoCounter = 0; + i_this->mCameraFovY = 45.0f; + camera->mCamera.SetTrimSize(3); + daPy_getPlayerActorClass()->changeOriginalDemo(); + // fallthrough + + case 11: + daPy_getPlayerActorClass()->setPlayerPosAndAngle(&player->current.pos, + i_this->mAngleToPlayer + 0x8000, 0); + + mDoMtx_YrotS(*calc_mtx, _this->current.angle.y); + + if (i_this->mMode >= 13) { + center = _this->current.pos; + center.y += 20.0f; + } else { + vec.x = 0.0f; + vec.y = 0.0f; + vec.z = 100.0f; + MtxPosition(&vec, ¢er); + center += _this->current.pos; + } + + if (i_this->mDemoCounter <= 38) { + mg_fish_class* fish = static_cast(fopAcM_SearchByID(i_this->mFishID)); + if (i_this->mDemoCounter == 0) { + vec.x = 0.0f; + vec.y = 0.0f; + vec.z = 200.0f; + MtxPosition(&vec, &i_this->mDemoFishPos); + i_this->mDemoFishPos += i_this->current.pos; + } + fish->current.pos.x = i_this->mDemoFishPos.x; + fish->current.pos.z = i_this->mDemoFishPos.z; + if (i_this->mDemoCounter >= 25) { + cLib_addCalc2(&fish->current.pos.y, i_this->mAcch.GetGroundH() + 10.0f, + 0.2f, 30.0f); + } + if (i_this->mDemoCounter == 38) { + fish->field_0xc3c = 1; + i_this->field_0xcc0 = true; + Z2GetAudioMgr()->changeBgmStatus(1); + } + } + + if (i_this->mDemoCounter == 0) { + if (cM_rndF(1.0f) < 0.5f) { + vec.x = 50.0f; + } else { + vec.x = -50.0f; + } + vec.y = 150.0f; + vec.z = 350.0f; + MtxPosition(&vec, &i_this->mCameraEye1); + i_this->mCameraEye1 += _this->current.pos; + i_this->mCameraCenter1 = center; + } else { + cLib_addCalc2(&i_this->mCameraCenter1.x, center.x, 0.2f, 30.0f); + cLib_addCalc2(&i_this->mCameraCenter1.y, center.y, 0.2f, 30.0f); + cLib_addCalc2(&i_this->mCameraCenter1.z, center.z, 0.2f, 30.0f); + if (i_this->mMode >= 13) { + cLib_addCalc2(&i_this->mCameraFovY, 45.0f, 0.03f, 0.2f); + i_this->mCameraEye1.x += 0.2f * _this->speed.x; + i_this->mCameraEye1.z += 0.2f * _this->speed.z; + } else { + cLib_addCalc2(&i_this->mCameraFovY, 55.0f, 0.05f, 0.2f); + } + + if (home_path[i_this->mHomePathIdx].mNo > 3) { + bvar1 = true; + } + + if (i_this->mDemoCounter >= 80 && i_this->mDemoCounter <= 120) { + bird_check = true; + if (i_this->mDemoCounter == 80) { + i_this->mCameraCenter2 = player->eyePos; + i_this->mCameraCenter2.y += -10.0f; + mDoMtx_YrotS(*calc_mtx, player->shape_angle.y); + vec.x = 30.0f; + vec.y = 130.0f; + vec.z = 120.0f; + MtxPosition(&vec, &i_this->mCameraEye2); + i_this->mCameraEye2 += player->current.pos; + player->i_changeDemoParam2(2); + } else if (i_this->mDemoCounter == 120) { + player->i_changeDemoParam2(0); + } + } + } + break; + + case 99: + fopAcM_delete(_this); + fish = fopAcM_SearchByID(i_this->mFishID); + if (fish != NULL) { + fopAcM_delete(fish); + } + // fallthrough + + case 100: + camera->mCamera.Start(); + camera->mCamera.SetTrimSize(0); + dComIfGp_event_reset(); + i_this->mDemoMode = 0; + break; + } + + if (i_this->mDemoMode != 0) { + if (bird_check) { + camera->mCamera.Set(i_this->mCameraCenter2, i_this->mCameraEye2, + i_this->mCameraFovY, 0); + } else { + if (bvar1) { + lin_chk.Set(&i_this->mCameraCenter1, &i_this->mCameraEye1, _this); + if (dComIfG_Bgsp().LineCross(&lin_chk)) { + i_this->field_0xcb4 = true; + i_this->mDemoCounter = 122; + } + } + + if (i_this->field_0xcb4) { + i_this->field_0xcb4 = false; + mDoMtx_YrotS(*calc_mtx, _this->current.angle.y); + vec.x = cM_rndF(50.0f) + 100.0f; + if (cM_rndF(1.0f) < 0.5f) { + vec.x *= -1.0f; + } + vec.y = cM_rndF(100.0f) + 170.0f; + if (home_path[i_this->mHomePathIdx].mNo > 3) { + vec.z = cM_rndFX(100.0f) + 200.0f; + } else { + vec.z = cM_rndF(100.0f) + -300.0f; + } + MtxPosition(&vec, &i_this->mCameraEye1); + i_this->mCameraEye1 += _this->current.pos; + i_this->mCameraCenter1 = _this->current.pos; + i_this->mCameraCenter1.y += 20.0f; + i_this->mCameraFovY = 55.0f; + } + + camera->mCamera.Set(i_this->mCameraCenter1, i_this->mCameraEye1, + i_this->mCameraFovY, 0); + } + + i_this->mDemoCounter++; + + if (i_this->mDemoMode < 10 && i_this->mAction != npc_ne_class::ACT_HOME) { + i_this->mDemoMode = 100; + } + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -static asm void demo_camera(npc_ne_class* param_0) { +static asm void demo_camera(npc_ne_class* i_this) { nofralloc #include "asm/rel/d/a/npc/d_a_npc_ne/d_a_npc_ne/demo_camera__FP12npc_ne_class.s" } #pragma pop +#endif /* 80A90E28-80A91004 008248 01DC+00 1/1 0/0 0/0 .text message__FP12npc_ne_class */ static int message(npc_ne_class* i_this) { if (i_this->mResName == "Npc_net" && !dComIfGs_wolfeye_effect_check()) { - i_this->field_0xc08 = 0; + i_this->mMessageState = 0; } - if (i_this->field_0xc0a != 0) { - i_this->field_0x656 = 10; + if (i_this->mIsTalking) { + i_this->mCcDisableTimer = 10; if (i_this->mMsgFlow.doFlow(i_this, NULL, 0)) { dComIfGp_event_reset(); - i_this->field_0xc0a = 0; - if (i_this->field_0x5b7 == 1 && (i_this->mMsgFlow.getNowMsgNo() == 0x18a1 || + i_this->mIsTalking = 0; + if (i_this->mIsGengle == 1 && (i_this->mMsgFlow.getNowMsgNo() == 0x18a1 || i_this->mMsgFlow.getNowMsgNo() == 0x18a2)) { fopAcM_createItem(&dComIfGp_getPlayer(0)->eyePos, SILVER_RUPEE, -1, fopAcM_GetRoomNo(i_this), NULL, NULL, 3); @@ -4267,20 +4565,20 @@ static int message(npc_ne_class* i_this) { } else { if (dComIfGp_event_runCheck() && i_this->eventInfo.checkCommandTalk()) { i_this->mMsgFlow.init(i_this, i_this->mFlowID, 0, NULL); - i_this->field_0xc0a = 1; + i_this->mIsTalking = 1; } - if (i_this->field_0xc08 == 2 && i_this->mFlowID != -1 && daPy_py_c::i_checkNowWolf() && + if (i_this->mMessageState == 2 && i_this->mFlowID != -1 && daPy_py_c::i_checkNowWolf() && !fopAcM_otherBgCheck(daPy_getLinkPlayerActorClass(), i_this)) { fopAcM_OnStatus(i_this, 0); - i_this->attention_info.flags |= 0xa; + cLib_onBit(i_this->attention_info.flags, 0xa); if (i_this->mResName == "Npc_net") { - i_this->attention_info.flags |= 0xc00000; + cLib_onBit(i_this->attention_info.flags, 0xc00000); } - i_this->eventInfo.i_onCondition(1); + i_this->eventInfo.i_onCondition(dEvtCnd_CANTALK_e); } else { fopAcM_OffStatus(i_this, 0); - i_this->attention_info.flags &= ~0xc0000a; + cLib_offBit(i_this->attention_info.flags, 0xc0000a); } return 0; @@ -4325,9 +4623,9 @@ static int daNpc_Ne_Execute(npc_ne_class* i_this) { } cXyz vec1(0.0f, 0.0f, 0.0f); - i_this->field_0x640++; + i_this->mCounter++; - if (i_this->field_0x701 != 0 && (i_this->field_0x640 & 0xf) == 0) { + if (i_this->mWantsFish && (i_this->mCounter & 0xf) == 0) { if (dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[470]) && i_this->mDistToTarget < 1500.0f) { if (fopAcM_SearchByName(PROC_MG_ROD) != NULL) { @@ -4345,16 +4643,16 @@ static int daNpc_Ne_Execute(npc_ne_class* i_this) { i_this->mTimers[i]--; } } - if (i_this->field_0x656 != 0) { - i_this->field_0x656--; + if (i_this->mCcDisableTimer != 0) { + i_this->mCcDisableTimer--; } - if (i_this->field_0x6f0 != 0) { - i_this->field_0x6f0--; + if (i_this->mCarryTimer != 0) { + i_this->mCarryTimer--; } - if (i_this->field_0x658 != 0) { - i_this->field_0x658--; + if (i_this->mSplashTimer != 0) { + i_this->mSplashTimer--; } - i_this->field_0x682 = 0; + i_this->mNeckAngleY = 0; action(i_this); @@ -4362,7 +4660,7 @@ static int daNpc_Ne_Execute(npc_ne_class* i_this) { mDoMtx_stack_c::YrotM(i_this->shape_angle.y); mDoMtx_stack_c::XrotM(i_this->shape_angle.x); mDoMtx_stack_c::ZrotM(i_this->shape_angle.z); - i_this->scale.x = i_this->mBaseScale.x * l_HIO.scale; + i_this->scale.x = i_this->mBaseScale.x * l_HIO.mScale; mDoMtx_stack_c::scaleM(i_this->scale.x, i_this->scale.x, i_this->scale.x); J3DModel* model = i_this->mpMorf->getModel(); model->setBaseTRMtx(mDoMtx_stack_c::get()); @@ -4371,7 +4669,7 @@ static int daNpc_Ne_Execute(npc_ne_class* i_this) { i_this->mpBtpAnm->setFrame(i_this->mBtpFrame); i_this->mpMorf->modelCalc(); - if (i_this->field_0x5b4 == 3) { + if (i_this->mBehavior == npc_ne_class::BHV_DISH) { mDoMtx_stack_c::transS(i_this->mDishPos.x, i_this->mDishPos.y, i_this->mDishPos.z); mDoMtx_stack_c::YrotM(i_this->shape_angle.y); i_this->mpDishMorf->getModel()->setBaseTRMtx(mDoMtx_stack_c::get()); @@ -4387,23 +4685,23 @@ static int daNpc_Ne_Execute(npc_ne_class* i_this) { PSMTXCopy(model->getAnmMtx(3), *calc_mtx); vec1.set(i_this->field_0xbf4 + -30.0f, 0.0f, 0.0f); cLib_addCalc0(&i_this->field_0xbf4, 1.0f, 5.0f); - cXyz vec2; - MtxPosition(&vec1, &vec2); - if (i_this->field_0x656 != 0) { - vec2.y += 100000.0f; + cXyz center; + MtxPosition(&vec1, ¢er); + if (i_this->mCcDisableTimer != 0) { + center.y += 100000.0f; } - i_this->mCcSph.SetC(vec2); + i_this->mCcSph.SetC(center); i_this->mCcSph.SetR(i_this->mBaseScale.z * 30.0f); dComIfG_Ccsp()->Set(&i_this->mCcSph); cXyz vec3(-20000.0f, 300000.0f, -10000.0f); - vec2 = i_this->eyePos; - if (i_this->field_0xbcc == 0) { - vec2 += vec3; + center = i_this->eyePos; + if (i_this->mAtEnable == 0) { + center += vec3; } else { - i_this->field_0xbcc = 0; + i_this->mAtEnable = 0; } - i_this->mAtSph.SetC(vec2); + i_this->mAtSph.SetC(center); i_this->mAtSph.SetR(25.0f); dComIfG_Ccsp()->Set(&i_this->mAtSph); @@ -4423,7 +4721,7 @@ static int daNpc_Ne_Execute(npc_ne_class* i_this) { } } - if (i_this->mFishID != -1 && i_this->field_0xcc0 != 0) { + if (i_this->mFishID != -1 && i_this->field_0xcc0) { mg_fish_class* fish = static_cast(fopAcM_SearchByID(i_this->mFishID)); PSMTXCopy(model->getAnmMtx(4), mDoMtx_stack_c::get()); mDoMtx_stack_c::ZrotM(-19000); @@ -4454,7 +4752,7 @@ static int daNpc_Ne_Execute(npc_ne_class* i_this) { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -static asm void daNpc_Ne_Execute(npc_ne_class* param_0) { +static asm int daNpc_Ne_Execute(npc_ne_class* param_0) { nofralloc #include "asm/rel/d/a/npc/d_a_npc_ne/d_a_npc_ne/daNpc_Ne_Execute__FP12npc_ne_class.s" } @@ -4471,7 +4769,7 @@ static int daNpc_Ne_IsDelete(npc_ne_class* i_this) { */ static int daNpc_Ne_Delete(npc_ne_class* i_this) { dComIfG_resDelete(&i_this->mPhase, i_this->mResName); - if (i_this->field_0xcc1 != 0) { + if (i_this->mHIOInit != 0) { l_hioInit = false; } if (i_this->heap != NULL) { @@ -4486,15 +4784,17 @@ static int daNpc_Ne_Delete(npc_ne_class* i_this) { static int useHeapInit(fopAc_ac_c* i_this) { npc_ne_class* _this = static_cast(i_this); _this->mpMorf = - new mDoExt_McaMorf((J3DModelData*)dComIfG_getObjectRes(_this->mResName, 28), NULL, NULL, - (J3DAnmTransform*)dComIfG_getObjectRes(_this->mResName, 24), + new mDoExt_McaMorf(static_cast(dComIfG_getObjectRes(_this->mResName, 28)), + NULL, NULL, + static_cast(dComIfG_getObjectRes(_this->mResName, 24)), 2, 1.0f, 0, -1, 1, NULL, 0x80000, 0x11020284); if (_this->mpMorf == NULL || _this->mpMorf->getModel() == NULL) { return 0; } + J3DModel* model = _this->mpMorf->getModel(); - _this->model = model; - model->mUserArea = (u32)_this; + i_this->model = model; + model->setUserArea((u32)i_this); for (u16 i = 0; i < model->getModelData()->getJointNum(); i++) { if (i == 1 || i == 2 || i == 3 || i == 4 || i == 20 || i == 21) { @@ -4506,7 +4806,8 @@ static int useHeapInit(fopAc_ac_c* i_this) { if (_this->mpBtkAnm == NULL) { return 0; } - J3DAnmTextureSRTKey* btk = (J3DAnmTextureSRTKey*)dComIfG_getObjectRes(_this->mResName, 32); + J3DAnmTextureSRTKey* btk = + static_cast(dComIfG_getObjectRes(_this->mResName, 32)); if (!_this->mpBtkAnm->init(_this->mpMorf->getModel()->getModelData(), btk, 1, 0, 1.0f, 0, -1)) { return 0; } @@ -4515,20 +4816,22 @@ static int useHeapInit(fopAc_ac_c* i_this) { if (_this->mpBtpAnm == NULL) { return 0; } - J3DAnmTexPattern* btp = (J3DAnmTexPattern*)dComIfG_getObjectRes(_this->mResName, 35); + J3DAnmTexPattern* btp = + static_cast(dComIfG_getObjectRes(_this->mResName, 35)); if (!_this->mpBtpAnm->init(_this->mpMorf->getModel()->getModelData(), btp, 1, 0, 1.0f, 0, -1)) { return 0; } - _this->mSound.init(&_this->current.pos, 1); + _this->mSound.init(&i_this->current.pos, 1); - if (_this->field_0x5b4 == 3) { - static int dish_bck[2] = {9, 8}; - int dish_flag = dComIfGs_isEventBit(0x1001) ? 1 : 0; - _this->mpDishMorf = - new mDoExt_McaMorf((J3DModelData*)dComIfG_getObjectRes(_this->mResName, 29), NULL, NULL, - (J3DAnmTransform*)dComIfG_getObjectRes(_this->mResName, dish_bck[dish_flag]), - 2, 1.0f, 0, -1, 1, NULL, 0x80000, 0x11000084); + if (_this->mBehavior == npc_ne_class::BHV_DISH) { + static int dish_bck[2] = {npc_ne_class::ANM_EMPTY_DISH, npc_ne_class::ANM_DRINK_DISH}; + s32 dish_flag = dComIfGs_isEventBit(0x1001) ? 1 : 0; + _this->mpDishMorf = new mDoExt_McaMorf( + static_cast(dComIfG_getObjectRes(_this->mResName, 29)), NULL, NULL, + static_cast(dComIfG_getObjectRes(_this->mResName, + dish_bck[dish_flag])), + 2, 1.0f, 0, -1, 1, NULL, 0x80000, 0x11000084); if (_this->mpDishMorf == NULL || _this->mpDishMorf->getModel() == NULL) { return 0; } @@ -4547,6 +4850,7 @@ static asm int useHeapInit(fopAc_ac_c* param_0) { #pragma pop #endif +#ifndef NONMATCHING /* 80A91B40-80A91B88 008F60 0048+00 1/0 0/0 0/0 .text __dt__12J3DFrameCtrlFv */ #pragma push #pragma optimization_level 0 @@ -4557,6 +4861,7 @@ extern "C" asm void __dt__12J3DFrameCtrlFv() { #include "asm/rel/d/a/npc/d_a_npc_ne/d_a_npc_ne/__dt__12J3DFrameCtrlFv.s" } #pragma pop +#endif /* 80A925BC-80A925C0 0001A0 0004+00 0/1 0/0 0/0 .rodata @7656 */ #pragma push @@ -4601,10 +4906,10 @@ SECTION_DEAD static char const* const stringBase_80A925E7 = "Npc_ne"; /* 80A91B88-80A92118 008FA8 0590+00 1/0 0/0 0/0 .text daNpc_Ne_Create__FP10fopAc_ac_c */ #ifdef NONMATCHING -// ordering of `mr` at start +// matches with literals static cPhs__Step daNpc_Ne_Create(fopAc_ac_c* i_this) { npc_ne_class* _this = static_cast(i_this); - fopAcM_SetupActor(_this, npc_ne_class); + fopAcM_SetupActor(i_this, npc_ne_class); if (dKy_darkworld_check()) { _this->mResName = "Npc_net"; @@ -4614,27 +4919,27 @@ static cPhs__Step daNpc_Ne_Create(fopAc_ac_c* i_this) { cPhs__Step step = (cPhs__Step)dComIfG_resLoad(&_this->mPhase, _this->mResName); if (step == cPhs_COMPLEATE_e) { - _this->field_0x5b4 = (u8)fopAcM_GetParam(_this); - _this->field_0x5b5 = (u8)(fopAcM_GetParam(_this) >> 8) & 0xf; + _this->mBehavior = (u8)fopAcM_GetParam(_this); + _this->mTexture = (u8)(fopAcM_GetParam(_this) >> 8) & 0xf; _this->mSize = (u8)(fopAcM_GetParam(_this) >> 0xc) & 0xf; _this->mPathIndex = (u8)(fopAcM_GetParam(_this) >> 0x10); - _this->field_0x5b7 = (u8)(fopAcM_GetParam(_this) >> 0x18); + _this->mIsGengle = (u8)(fopAcM_GetParam(_this) >> 0x18); - if (_this->field_0x5b7 == 1 && + if (_this->mIsGengle == 1 && !dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[457])) { return cPhs_ERROR_e; } - _this->mFlowID = _this->current.angle.x; - _this->shape_angle.x = 0; - _this->current.angle.x = 0; + _this->mFlowID = i_this->current.angle.x; + i_this->shape_angle.x = 0; + i_this->current.angle.x = 0; - if (!fopAcM_entrySolidHeap(_this, useHeapInit, 0x2a50)) { + if (!fopAcM_entrySolidHeap(i_this, useHeapInit, 0x2a50)) { return cPhs_ERROR_e; } if (_this->mPathIndex != 0xff) { - _this->mpPath = dPath_GetRoomPath(_this->mPathIndex, fopAcM_GetRoomNo(_this)); + _this->mpPath = dPath_GetRoomPath(_this->mPathIndex, fopAcM_GetRoomNo(i_this)); if (_this->mpPath == NULL) { return cPhs_ERROR_e; } @@ -4642,43 +4947,43 @@ static cPhs__Step daNpc_Ne_Create(fopAc_ac_c* i_this) { _this->mPathDir = 1; _this->mAction = npc_ne_class::ACT_PATH_WALK; } else { - if (_this->field_0x5b4 == 1) { + if (_this->mBehavior == npc_ne_class::BHV_TAME) { _this->mAction = npc_ne_class::ACT_TAME; - } else if (_this->field_0x5b4 == 2) { + } else if (_this->mBehavior == npc_ne_class::BHV_PIER) { if (dComIfGs_isEventBit(0x1001)) { _this->mAction = npc_ne_class::ACT_ROOF; - _this->current.pos.set(1005.0f, 766.0f, -1423.0f); - _this->old = _this->home = _this->current; - _this->current.angle.y = 0; + i_this->current.pos.set(1005.0f, 766.0f, -1423.0f); + i_this->old = i_this->home = i_this->current; + i_this->current.angle.y = 0; _this->mNoFollow = true; } else { _this->mAction = npc_ne_class::ACT_SANBASI; - _this->current.pos.set(3400.0f, 84.13f, 64.0f); - _this->current.angle.y = -0x6987; - _this->shape_angle.y = _this->current.angle.y; - _this->old = _this->home = _this->current; + i_this->current.pos.set(3400.0f, 84.13f, 64.0f); + i_this->current.angle.y = -0x6987; + i_this->shape_angle.y = i_this->current.angle.y; + i_this->old = _this->home = i_this->current; _this->mNoFollow = true; - _this->field_0x701 = 1; + _this->mWantsFish = 1; } - } else if (_this->field_0x5b4 == 3) { + } else if (_this->mBehavior == npc_ne_class::BHV_DISH) { _this->mAction = npc_ne_class::ACT_DISH; - _this->mDishPos = _this->current.pos; - fopAcM_OnStatus(_this, 0x20000); + _this->mDishPos = i_this->current.pos; + fopAcM_OnStatus(i_this, fopAcStts_NOPAUSE_e); } } if (!l_hioInit) { - _this->field_0xcc1 = 1; + _this->mHIOInit = 1; l_hioInit = true; l_HIO.field_0x04 = -1; } - fopAcM_OnStatus(_this, 0x100); - fopAcM_OnCarryType(_this, fopAcM_CARRY_TYPE_8); - _this->attention_info.flags = 0; - _this->attention_info.field_0x0[4] = 7; - fopAcM_SetMtx(_this, _this->mpMorf->getModel()->getBaseTRMtx()); - _this->health = 1; + fopAcM_OnStatus(i_this, fopAcStts_CULL_e); + fopAcM_OnCarryType(i_this, fopAcM_CARRY_TYPE_8); + i_this->attention_info.flags = 0; + i_this->attention_info.field_0x0[4] = 7; + fopAcM_SetMtx(i_this, _this->mpMorf->getModel()->getBaseTRMtx()); + i_this->health = 1; _this->field_0x560 = 1; /* 80A92950-80A92990 000360 0040+00 1/1 0/0 0/0 .data cc_sph_src$7518 */ @@ -4707,39 +5012,39 @@ static cPhs__Step daNpc_Ne_Create(fopAc_ac_c* i_this) { } // mSphAttr }; - _this->mStts.Init(0x1e, 0, _this); + _this->mStts.Init(0x1e, 0, i_this); _this->mCcSph.Set(cc_sph_src); _this->mCcSph.SetStts(&_this->mStts); _this->mAtSph.Set(at_sph_src); _this->mAtSph.SetStts(&_this->mStts); _this->mCcSph.OnTgNoHitMark(); - if (_this->field_0x5b5 == 0xf) { + if (_this->mTexture == 0xf) { _this->mBtkFrame = cM_rndF(3.999f); } else { - _this->mBtkFrame = _this->field_0x5b5; + _this->mBtkFrame = _this->mTexture; if (_this->mBtkFrame > 3) { _this->mBtkFrame = 3; } } - _this->field_0x640 = cM_rndF(65536.0f); + _this->mCounter = cM_rndF(0x10000); if (_this->mSize == 1) { _this->mBaseScale.set(0.75f, 0.75f, 0.75f); - _this->field_0x6f8 = 1; + _this->mSearchBall = 1; } else if (_this->mSize == 2) { _this->mBaseScale.set(0.625f, 0.625f, 0.625f); - _this->field_0x6f8 = 1; + _this->mSearchBall = 1; } else { _this->mBaseScale.set(1.0f, 1.0f, 1.0f); } - _this->mAcch.Set(&_this->current.pos, &_this->old.pos, _this, 1, - &_this->mAcchCir, &_this->speed, NULL, NULL); + _this->mAcch.Set(fopAcM_GetPosition_p(i_this), fopAcM_GetOldPosition_p(i_this), i_this, 1, + &_this->mAcchCir, fopAcM_GetSpeed_p(i_this), NULL, NULL); _this->mAcchCir.SetWall(_this->mBaseScale.y * 30.0f, _this->mBaseScale.z * 35.0f); - _this->field_0x5e0 = cM_rndFX(0.2f) + 1.0f; - _this->field_0x91c = _this->current.pos.y; + _this->mDistScale = cM_rndFX(0.2f) + 1.0f; + _this->mGroundY = i_this->current.pos.y; if (_this->mResName == "Npc_net") { _this->mAction = npc_ne_class::ACT_WAIT; - _this->mState = 0; + _this->mMode = 0; } _this->mFishID = -1; @@ -4751,7 +5056,7 @@ static cPhs__Step daNpc_Ne_Create(fopAc_ac_c* i_this) { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -static asm void daNpc_Ne_Create(fopAc_ac_c* param_0) { +static asm cPhs__Step daNpc_Ne_Create(fopAc_ac_c* param_0) { nofralloc #include "asm/rel/d/a/npc/d_a_npc_ne/d_a_npc_ne/daNpc_Ne_Create__FP10fopAc_ac_c.s" }