From d16ee29425e21b0379a013d2d91d8ecf13a55d24 Mon Sep 17 00:00:00 2001 From: Zeclos Date: Thu, 3 Apr 2025 23:34:13 +0200 Subject: [PATCH] D a w bird (#733) * create functions * actionend matched * matched a func i think. progress on setstartpos * progress on setstartpos, 2 small functions done * rodata + actionselect * 100% match * cleanup * configure.py matching * removed unecessary cast * removes the linker warning from arcname * added the setaction inline. moved logic * setAction now takes unsigned char --- configure.py | 2 +- include/d/actor/d_a_wbird.h | 19 +++- include/d/d_kankyo_wether.h | 2 + src/d/actor/d_a_wbird.cpp | 180 ++++++++++++++++++++++++++++++++---- 4 files changed, 179 insertions(+), 24 deletions(-) diff --git a/configure.py b/configure.py index 1a2f479f9..d5f8845d4 100755 --- a/configure.py +++ b/configure.py @@ -1445,7 +1445,7 @@ config.libs = [ ActorRel(NonMatching, "d_a_tsubo"), ActorRel(NonMatching, "d_a_warpdm20"), ActorRel(NonMatching, "d_a_warphr"), - ActorRel(NonMatching, "d_a_wbird"), + ActorRel(Matching, "d_a_wbird"), ActorRel(NonMatching, "d_a_ykgr"), ActorRel(Matching, "d_a_alldie"), ActorRel(Matching, "d_a_am", extra_cflags=['-pragma "nosyminline on"']), diff --git a/include/d/actor/d_a_wbird.h b/include/d/actor/d_a_wbird.h index c68f571cb..528e54df2 100644 --- a/include/d/actor/d_a_wbird.h +++ b/include/d/actor/d_a_wbird.h @@ -7,19 +7,28 @@ class daWbird_c : public fopAc_ac_c { public: inline BOOL draw(); inline BOOL execute(); - void setAction(unsigned char) {} + void setAction(unsigned char action) { + mAction = action; + } void calcMtx(); void setStartPos(); - void CreateInit(); + BOOL CreateInit(); cPhs_State create(); void actionWait(); void actionEnd(); void actionMove(); void actionSelect(); -public: - /* Place member variables here */ -}; + static const char M_arcname[]; +public: + /* 0x290 */ u8 field_0x290[0x29C - 0x290]; + /* 0x29C */ u8 mAction; + /* 0x29D */ bool field_0x29D; + /* 0x29E */ s16 field_0x29E; + /* 0x2A0 */ f32 field_0x2A0; + /* 0x2A4 */ s16 mAngle; + /* 0x2A6 */ s16 mEventIdx; +}; // Size: 0x2A8 #endif /* D_A_WBIRD_H */ diff --git a/include/d/d_kankyo_wether.h b/include/d/d_kankyo_wether.h index e59abfa08..196b07490 100644 --- a/include/d/d_kankyo_wether.h +++ b/include/d/d_kankyo_wether.h @@ -374,5 +374,7 @@ cXyz dKyw_get_AllWind_vecpow(cXyz* param_0); int dKyw_get_tactwind_dir(); BOOL dKyw_gbwind_use_check(); void dKyw_tornado_Notice(cXyz* param_0); +void dKyw_custom_windpower(f32 i_windpower); +void dKyw_tact_wind_set_go(); #endif /* D_KANKYO_WETHER_H */ diff --git a/src/d/actor/d_a_wbird.cpp b/src/d/actor/d_a_wbird.cpp index a9e09dc58..e84af75e8 100644 --- a/src/d/actor/d_a_wbird.cpp +++ b/src/d/actor/d_a_wbird.cpp @@ -5,70 +5,214 @@ #include "d/actor/d_a_wbird.h" #include "d/d_procname.h" +#include "d/d_com_inf_game.h" +#include "d/d_kankyo_wether.h" +#include "SSystem/SComponent/c_angle.h" +#include "d/actor/d_a_player.h" + +const char daWbird_c::M_arcname[] = "Wbird"; /* 00000078-000000AC .text calcMtx__9daWbird_cFv */ void daWbird_c::calcMtx() { - /* Nonmatching */ + eyePos = current.pos; + attention_info.position = current.pos; } /* 000000AC-00000324 .text setStartPos__9daWbird_cFv */ void daWbird_c::setStartPos() { - /* Nonmatching */ + daPy_py_c* player = daPy_getPlayerActorClass(); + cXyz *wind = dKyw_get_wind_vec(); + dScnKy_env_light_c& envLight = dKy_getEnvlight(); + + cSGlobe globe(*wind); + cSAngle angle(globe.U()); + s32 a = globe.U() - player->current.angle.y; + s32 transformedResult = a > cSAngle::_0.Val(); + + if (transformedResult != 0) { + angle += cSAngle::_90; + } + else { + angle -= cSAngle::_90; + } + + current.pos = player->current.pos; + current.pos.x += (angle.Cos() * 20.0f); + current.pos.z += (angle.Sin() * 20.0f); + home.pos = current.pos; + current.pos.y += 150.0f; + + cXyz sp18; + sp18.x = cM_scos(envLight.mWind.mTactWindAngleX) * cM_scos((u16)envLight.mWind.mTactWindAngleY); + sp18.y = cM_ssin(envLight.mWind.mTactWindAngleX); + sp18.z = cM_scos(envLight.mWind.mTactWindAngleX) * cM_ssin((u16)envLight.mWind.mTactWindAngleY); + int iVar5 = cM_atan2s(sp18.x, sp18.z); + + current.angle.y = iVar5; + shape_angle.y = iVar5; + field_0x29E = 80; + speed.x = sp18.x * 40.0f; + speed.z = sp18.z * 40.0f; + float fVar1 = field_0x29E * 0.5f; + current.pos.z = current.pos.z - fVar1 * speed.z; + current.pos.x = current.pos.x - fVar1 * speed.x; + field_0x29E = field_0x29E + 60; + field_0x2A0 = 1.0f; + current.pos.y += field_0x2A0 * fVar1 * fVar1 * 0.5f; + speed.y = -(field_0x2A0 * fVar1); } /* 00000324-00000388 .text CreateInit__9daWbird_cFv */ -void daWbird_c::CreateInit() { - /* Nonmatching */ +BOOL daWbird_c::CreateInit() { + tevStr.mRoomNo = current.roomNo; + setAction(3); + fopAcM_orderChangeEvent(this, "TACT_WINDOW", 0, -1); + field_0x29E = 0; + calcMtx(); + return TRUE; } /* 00000388-000003E0 .text create__9daWbird_cFv */ cPhs_State daWbird_c::create() { - /* Nonmatching */ + fopAcM_SetupActor(this, daWbird_c); + CreateInit(); + return cPhs_COMPLEATE_e; } /* 000003E0-000003E4 .text actionWait__9daWbird_cFv */ void daWbird_c::actionWait() { - /* Nonmatching */ } /* 000003E4-00000474 .text actionEnd__9daWbird_cFv */ void daWbird_c::actionEnd() { - /* Nonmatching */ + if (dComIfGp_evmng_endCheck(mEventIdx)){ + dComIfGp_event_reset(); + fopAcM_delete(this); + } else { + dComIfGp_evmng_cutEnd(dComIfGp_evmng_getMyStaffId("WINDMAN")); + } } /* 00000474-000005DC .text actionMove__9daWbird_cFv */ void daWbird_c::actionMove() { - /* Nonmatching */ + daPy_py_c* player = (daPy_py_c*)daPy_getPlayerActorClass(); + if(field_0x29D){ + field_0x29D = false; + mDoAud_seStart(JA_SE_TAKT_WIND_DEMO); + } + if (field_0x29E > 0) { + field_0x29E--; + if (field_0x29E > 60) { + fopAcM_posMove(this, NULL); + speed.y = speed.y + field_0x2A0; + } + if (field_0x29E < 15) { + dKyw_custom_windpower(0.0f); + } + if (field_0x29E == 70) { + dKyw_tact_wind_set_go(); + } + } else { + dComIfGp_evmng_cutEnd(dComIfGp_evmng_getMyStaffId("WINDMAN")); + player->changeDemoMoveAngle(mAngle); + setAction(1); + mDoAud_seStart(JA_SE_TAKT_WIND_END); + } } /* 000005DC-00000850 .text actionSelect__9daWbird_cFv */ void daWbird_c::actionSelect() { - /* Nonmatching */ + short sVar2 = field_0x29E; + if (sVar2 == 10) { + dComIfGp_setOperateWindOn(); + mDoAud_seStart(JA_SE_TAKT_WIND_DISP); + field_0x29E++; + } else if(sVar2 > 10){ + mDoAud_seStart(JA_SE_SYS_WTAKT_WIND_AMB); + switch (dComIfGp_getOperateWind()) { + case 1: { + mDoAud_seStart(JA_SE_TAKT_WIND_DECIDE); + setStartPos(); + setAction(2); + daPy_py_c* player = daPy_getPlayerActorClass(); + sVar2 = current.angle.y + 0x7fff; + mAngle = player->shape_angle.y; + player->setPlayerPosAndAngle(&player->current.pos, sVar2); + if(dComIfGp_checkPlayerStatus0(0, 0x00010000)){ + mEventIdx = dComIfGp_evmng_getEventIdx("TACT_WINDOW2_SHIP"); + } else{ + mEventIdx = dComIfGp_evmng_getEventIdx("TACT_WINDOW2"); + } + fopAcM_orderChangeEventId(this, mEventIdx, 0, 0xFFFF); + player = daPy_getPlayerActorClass(); + player->cancelOriginalDemo(); + dKyw_custom_windpower(1.0f); + field_0x29D = true; + break; + } + case 0 : { + mDoAud_seStart(JA_SE_TAKT_WIND_CANCEL); + dComIfGp_event_reset(); + fopAcM_delete(this); + break; + } + } + } + else { + field_0x29E++; + } + } +BOOL daWbird_c::draw(){ + return TRUE; +} + +BOOL daWbird_c::execute(){ + switch(mAction) { + case 3: + actionSelect(); + break; + case 2: + actionMove(); + break; + case 1: + actionEnd(); + break; + default: + actionWait(); + break; + } + calcMtx(); + return TRUE; +} + + /* 00000850-00000858 .text daWbird_Draw__FP9daWbird_c */ -static BOOL daWbird_Draw(daWbird_c*) { - /* Nonmatching */ +static BOOL daWbird_Draw(daWbird_c* i_this) { + return i_this->draw(); } /* 00000858-000008D0 .text daWbird_Execute__FP9daWbird_c */ -static BOOL daWbird_Execute(daWbird_c*) { - /* Nonmatching */ +static BOOL daWbird_Execute(daWbird_c* i_this) { + return i_this->execute(); } /* 000008D0-000008D8 .text daWbird_IsDelete__FP9daWbird_c */ static BOOL daWbird_IsDelete(daWbird_c*) { - /* Nonmatching */ + return TRUE; } /* 000008D8-00000908 .text daWbird_Delete__FP9daWbird_c */ -static BOOL daWbird_Delete(daWbird_c*) { - /* Nonmatching */ +static BOOL daWbird_Delete(daWbird_c* i_this) { + i_this->~daWbird_c(); + return TRUE; } /* 00000908-00000928 .text daWbird_Create__FP10fopAc_ac_c */ -static cPhs_State daWbird_Create(fopAc_ac_c*) { - /* Nonmatching */ +static cPhs_State daWbird_Create(fopAc_ac_c* i_this) { + daWbird_c* a_this = (daWbird_c*)i_this; + return a_this->create(); } static actor_method_class l_daWbird_Method = {