summaryrefslogtreecommitdiff
path: root/src/d/actor/d_a_swLBall.cpp
diff options
context:
space:
mode:
authorhatal175 <hatal175@users.noreply.github.com>2024-10-20 07:47:49 +0300
committerGitHub <noreply@github.com>2024-10-19 21:47:49 -0700
commitf8814c757b86bc59fc077f3acd631270dbb9a870 (patch)
tree4fda1eafb793d0c82dba7bd49b3ee31ba3194288 /src/d/actor/d_a_swLBall.cpp
parent3dadc80c5e314907020b033131f8f9dadbbce684 (diff)
daSwLBall_c OK (#2220)
Diffstat (limited to 'src/d/actor/d_a_swLBall.cpp')
-rw-r--r--src/d/actor/d_a_swLBall.cpp379
1 files changed, 209 insertions, 170 deletions
diff --git a/src/d/actor/d_a_swLBall.cpp b/src/d/actor/d_a_swLBall.cpp
index 6121ac1576..1bda985f0c 100644
--- a/src/d/actor/d_a_swLBall.cpp
+++ b/src/d/actor/d_a_swLBall.cpp
@@ -4,136 +4,132 @@
*/
#include "d/actor/d_a_swLBall.h"
-#include "dol2asm.h"
-
-
-//
-// Forward References:
-//
-
-extern "C" static void s_lb_sub__FPvPv();
-extern "C" void checkArea_sub__11daSwLBall_cFP10fopAc_ac_c();
-extern "C" void checkArea__11daSwLBall_cFv();
-extern "C" void search_lb__11daSwLBall_cFv();
-extern "C" void Create__11daSwLBall_cFv();
-extern "C" void create__11daSwLBall_cFv();
-extern "C" void execute__11daSwLBall_cFv();
-extern "C" void actionInit__11daSwLBall_cFv();
-extern "C" void actionRun__11daSwLBall_cFv();
-extern "C" void actionStop__11daSwLBall_cFv();
-extern "C" void PutCrrPos__11daSwLBall_cFv();
-extern "C" bool _delete__11daSwLBall_cFv();
-extern "C" static void daSwLBall_Execute__FP11daSwLBall_c();
-extern "C" static void daSwLBall_Delete__FP11daSwLBall_c();
-extern "C" static void daSwLBall_Create__FP10fopAc_ac_c();
-extern "C" void func_80D4F4AC(void* _this, u8*);
-
-//
-// External References:
-//
-
-extern "C" void __ct__10fopAc_ac_cFv();
-extern "C" void fopAc_IsActor__FPv();
-extern "C" void fopAcIt_Judge__FPFPvPv_PvPv();
-extern "C" void fopAcM_searchActorDistanceXZ__FPC10fopAc_ac_cPC10fopAc_ac_c();
-extern "C" void fpcEx_Search__FPFPvPv_PvPv();
-extern "C" void fpcSch_JudgeByID__FPvPv();
-extern "C" void dLib_checkActorInRectangle__FP10fopAc_ac_cP10fopAc_ac_cPC4cXyzPC4cXyz();
-extern "C" void onSwitch__10dSv_info_cFii();
-extern "C" void offSwitch__10dSv_info_cFii();
-extern "C" void isSwitch__10dSv_info_cCFii();
-extern "C" void cLib_chaseF__FPfff();
-extern "C" void cLib_targetAngleY__FPC3VecPC3Vec();
-extern "C" void __ptmf_scall();
-extern "C" void _savegpr_26();
-extern "C" void _savegpr_28();
-extern "C" void _restgpr_26();
-extern "C" void _restgpr_28();
-extern "C" extern u8 g_dComIfG_gameInfo[122384];
-
-//
-// Declarations:
-//
+#include "SSystem/SComponent/c_phase.h"
+#include "d/actor/d_a_obj_carry.h"
+#include "d/actor/d_a_player.h"
+#include "d/d_lib.h"
+#include "f_op/f_op_actor_mng.h"
/* ############################################################################################## */
/* 80D4F5A0-80D4F5A8 000000 0008+00 2/2 0/0 0/0 .bss l_target_info */
-static u8 l_target_info[8];
+static daObjCarry_c* l_target_info[2];
/* 80D4F5A8-80D4F5AC 000008 0004+00 2/2 0/0 0/0 .bss l_target_info_count */
-static u8 l_target_info_count[4];
+static int l_target_info_count;
/* 80D4EAF8-80D4EB8C 000078 0094+00 1/1 0/0 0/0 .text s_lb_sub__FPvPv */
-static void s_lb_sub(void* param_0, void* param_1) {
- // NONMATCHING
+static void* s_lb_sub(void* param_1, void* param_2) {
+ if ((fopAcM_IsActor(param_1) && fopAcM_GetName(param_1) == PROC_Obj_Carry) &&
+ static_cast<daObjCarry_c*>(param_1)->prm_chk_type_lightball())
+ {
+ if (l_target_info_count < 2) {
+ l_target_info[l_target_info_count] = (daObjCarry_c*)param_1;
+ l_target_info_count++;
+ }
+ }
+ return 0;
}
-/* ############################################################################################## */
-/* 80D4F4D0-80D4F4D4 000000 0004+00 2/2 0/0 0/0 .rodata @3723 */
-SECTION_RODATA static f32 const lit_3723 = 10.0f;
-COMPILER_STRIP_GATE(0x80D4F4D0, &lit_3723);
-
-/* 80D4F4D4-80D4F4D8 000004 0004+00 0/1 0/0 0/0 .rodata @3724 */
-#pragma push
-#pragma force_active on
-SECTION_RODATA static f32 const lit_3724 = 100.0f;
-COMPILER_STRIP_GATE(0x80D4F4D4, &lit_3724);
-#pragma pop
-
-/* 80D4F4D8-80D4F4DC 000008 0004+00 0/1 0/0 0/0 .rodata @3725 */
-#pragma push
-#pragma force_active on
-SECTION_RODATA static f32 const lit_3725 = -100.0f;
-COMPILER_STRIP_GATE(0x80D4F4D8, &lit_3725);
-#pragma pop
-
-/* 80D4F4DC-80D4F4E0 00000C 0004+00 0/2 0/0 0/0 .rodata @3726 */
-#pragma push
-#pragma force_active on
-SECTION_RODATA static u8 const lit_3726[4] = {
- 0x00,
- 0x00,
- 0x00,
- 0x00,
-};
-COMPILER_STRIP_GATE(0x80D4F4DC, &lit_3726);
-#pragma pop
-
/* 80D4EB8C-80D4ECCC 00010C 0140+00 2/2 0/0 0/0 .text checkArea_sub__11daSwLBall_cFP10fopAc_ac_c
*/
-void daSwLBall_c::checkArea_sub(fopAc_ac_c* param_0) {
- // NONMATCHING
+int daSwLBall_c::checkArea_sub(fopAc_ac_c* param_1) {
+ if (getType() == 0) {
+ if (param_1->current.pos.y >= current.pos.y - 10.0f &&
+ param_1->current.pos.y < current.pos.y + scale.y * 100.0f &&
+ fopAcM_searchActorDistanceXZ(this, param_1) < scale.x * 100.0f)
+ {
+ return 1;
+ }
+ } else if (getType() == 1) {
+ cXyz cStack_1c(scale.x * -100.0f, 0.0f, scale.z * -100.0f);
+ cXyz cStack_28(scale.x * 100.0f, scale.y * 100.0f, scale.z * 100.0f);
+ cStack_1c.y += current.pos.y - 10.0f;
+ cStack_28.y += current.pos.y;
+ if (param_1->current.pos.y >= cStack_1c.y && param_1->current.pos.y < cStack_28.y &&
+ dLib_checkActorInRectangle(param_1, this, &cStack_1c, &cStack_28))
+ {
+ return 1;
+ }
+ }
+ return 0;
}
/* 80D4ECCC-80D4ED80 00024C 00B4+00 1/1 0/0 0/0 .text checkArea__11daSwLBall_cFv */
-void daSwLBall_c::checkArea() {
- // NONMATCHING
+int daSwLBall_c::checkArea() {
+ fopAc_ac_c* actors[4];
+ for (int i = 0; i < 2; i++) {
+ if (mProcIds[i] != -1) {
+ actors[i] = fopAcM_SearchByID(mProcIds[i]);
+ } else {
+ actors[i] = NULL;
+ }
+ if (actors[i] != NULL && checkArea_sub(actors[i]) != 0) {
+ return 1;
+ }
+ }
+ return 0;
}
/* 80D4ED80-80D4EEAC 000300 012C+00 2/2 0/0 0/0 .text search_lb__11daSwLBall_cFv */
void daSwLBall_c::search_lb() {
- // NONMATCHING
+ l_target_info_count = 0;
+ for (int i = 0; i < 2; i++) {
+ l_target_info[i] = NULL;
+ }
+ fpcM_Search(s_lb_sub, this);
+ for (int i = 0; i < l_target_info_count; i++) {
+ if (l_target_info[i] != NULL) {
+ fpc_ProcID targetProcId = fopAcM_GetID(l_target_info[i]);
+ if (targetProcId != -1) {
+ int targetIdx = -1;
+ for (int j = 0; j < 2; j++) {
+ if (targetProcId == mProcIds[j]) {
+ targetIdx = j;
+ break;
+ }
+ }
+ if (targetIdx < 0) {
+ for (int j = 0; j < 2; j++) {
+ if (mProcIds[j] == -1) {
+ mProcIds[j] = targetProcId;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
}
/* 80D4EEAC-80D4EEF8 00042C 004C+00 1/1 0/0 0/0 .text Create__11daSwLBall_cFv */
-void daSwLBall_c::Create() {
- // NONMATCHING
+int daSwLBall_c::Create() {
+ for (int i = 0; i < 2; i++) {
+ mProcIds[i] = -1;
+ }
+ setAction(ACTION_INIT);
+ execute();
+ return 1;
}
/* 80D4EEF8-80D4EF60 000478 0068+00 1/1 0/0 0/0 .text create__11daSwLBall_cFv */
-void daSwLBall_c::create() {
- // NONMATCHING
+int daSwLBall_c::create() {
+ fopAcM_SetupActor(this, daSwLBall_c);
+ if (!Create()) {
+ return cPhs_ERROR_e;
+ }
+ return cPhs_COMPLEATE_e;
}
/* ############################################################################################## */
/* 80D4F4E4-80D4F4F0 000000 000C+00 1/1 0/0 0/0 .data cNullVec__6Z2Calc */
-SECTION_DATA static u8 cNullVec__6Z2Calc[12] = {
+static u8 cNullVec__6Z2Calc[12] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
/* 80D4F4F0-80D4F504 00000C 0004+10 0/0 0/0 0/0 .data @1787 */
#pragma push
#pragma force_active on
-SECTION_DATA static u32 lit_1787[1 + 4 /* padding */] = {
+static u32 lit_1787[1 + 4 /* padding */] = {
0x02000201,
/* padding */
0x40080000,
@@ -143,115 +139,158 @@ SECTION_DATA static u32 lit_1787[1 + 4 /* padding */] = {
};
#pragma pop
-/* 80D4F504-80D4F510 -00001 000C+00 0/1 0/0 0/0 .data @3835 */
-#pragma push
-#pragma force_active on
-SECTION_DATA static void* lit_3835[3] = {
- (void*)NULL,
- (void*)0xFFFFFFFF,
- (void*)actionInit__11daSwLBall_cFv,
-};
-#pragma pop
-
-/* 80D4F510-80D4F51C -00001 000C+00 0/1 0/0 0/0 .data @3836 */
-#pragma push
-#pragma force_active on
-SECTION_DATA static void* lit_3836[3] = {
- (void*)NULL,
- (void*)0xFFFFFFFF,
- (void*)actionRun__11daSwLBall_cFv,
-};
-#pragma pop
-
-/* 80D4F51C-80D4F528 -00001 000C+00 0/1 0/0 0/0 .data @3837 */
-#pragma push
-#pragma force_active on
-SECTION_DATA static void* lit_3837[3] = {
- (void*)NULL,
- (void*)0xFFFFFFFF,
- (void*)actionStop__11daSwLBall_cFv,
-};
-#pragma pop
-
-/* 80D4F528-80D4F54C 000044 0024+00 0/1 0/0 0/0 .data l_func$3834 */
-#pragma push
-#pragma force_active on
-SECTION_DATA static u8 l_func[36] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
-#pragma pop
-
-/* 80D4F5AC-80D4F5B0 00000C 0004+00 1/1 0/0 0/0 .bss None */
-static u8 data_80D4F5AC[4];
-
/* 80D4EF60-80D4F008 0004E0 00A8+00 2/2 0/0 0/0 .text execute__11daSwLBall_cFv */
-void daSwLBall_c::execute() {
- // NONMATCHING
+int daSwLBall_c::execute() {
+ static actionFunc funcs[3] = {
+ &daSwLBall_c::actionInit,
+ &daSwLBall_c::actionRun,
+ &daSwLBall_c::actionStop,
+ };
+
+ (this->*(funcs[mAction]))();
+ return 1;
}
/* 80D4F008-80D4F080 000588 0078+00 1/0 0/0 0/0 .text actionInit__11daSwLBall_cFv */
void daSwLBall_c::actionInit() {
- // NONMATCHING
+ search_lb();
+ if (getArg0() == 1 && fopAcM_isSwitch(this, getSwbit())) {
+ field_0x572 = 3;
+ } else {
+ field_0x572 = 0;
+ }
+ setAction(ACTION_RUN);
}
/* 80D4F080-80D4F220 000600 01A0+00 1/0 0/0 0/0 .text actionRun__11daSwLBall_cFv */
void daSwLBall_c::actionRun() {
- // NONMATCHING
+ search_lb();
+ int isArea = checkArea();
+ switch(field_0x572) {
+ case 0:
+ if (isArea != 0) {
+ mRunTimer = getArg1();
+ if (mRunTimer == 0xff) {
+ mRunTimer = 15;
+ }
+ if (getArg0() == 1) {
+ if (mRunTimer == 0) {
+ fopAcM_onSwitch(this, getSwbit());
+ field_0x572 = 3;
+ }
+ } else if (mRunTimer == 0) {
+ fopAcM_onSwitch(this, getSwbit());
+ field_0x572 = 2;
+ }
+ field_0x572 = 1;
+ }
+ fopAcM_offSwitch(this, getSwbit());
+ break;
+ case 1:
+ if (isArea == 0) {
+ field_0x572 = 0;
+ } else {
+ if (cLib_calcTimer(&mRunTimer) == 0) {
+ field_0x572 = 2;
+ }
+ }
+ break;
+ case 2:
+ fopAcM_onSwitch(this, getSwbit());
+ if (getArg0() == 1) {
+ field_0x572 = 3;
+ } else if (isArea == 0) {
+ field_0x572 = 0;
+ }
+ break;
+ case 3:
+ break;
+ }
+ PutCrrPos();
}
/* 80D4F220-80D4F224 0007A0 0004+00 1/0 0/0 0/0 .text actionStop__11daSwLBall_cFv */
void daSwLBall_c::actionStop() {
- /* empty function */
}
-/* ############################################################################################## */
-/* 80D4F4E0-80D4F4E4 000010 0004+00 0/1 0/0 0/0 .rodata @4000 */
-#pragma push
-#pragma force_active on
-SECTION_RODATA static f32 const lit_4000 = 300.0f;
-COMPILER_STRIP_GATE(0x80D4F4E0, &lit_4000);
-#pragma pop
-
/* 80D4F224-80D4F444 0007A4 0220+00 1/1 0/0 0/0 .text PutCrrPos__11daSwLBall_cFv */
void daSwLBall_c::PutCrrPos() {
- // NONMATCHING
+ if (checkPullLBall()) {
+ daPy_py_c* player = daPy_getPlayerActorClass();
+ s16 angleDiff = cLib_targetAngleY(&player->current.pos, &current.pos) - player->shape_angle.y;
+ if (fopAcM_searchPlayerDistanceXZ(this) < 300.0f && angleDiff < 0x4000) {
+ fopAc_ac_c* carryObj = (fopAc_ac_c*)fopAcM_SearchByID(player->getGrabActorID());
+ if (carryObj != NULL && fopAcM_IsActor(carryObj) &&
+ fopAcM_GetName(carryObj) == PROC_Obj_Carry &&
+ static_cast<daObjCarry_c*>(carryObj)->prm_chk_type_lightball())
+ {
+ player->setForcePutPos(current.pos);
+ }
+ }
+ for (int i = 0; i < 2; i++) {
+ fopAc_ac_c* actor;
+ if (mProcIds[i] != -1) {
+ actor = fopAcM_SearchByID(mProcIds[i]);
+ } else {
+ actor = NULL;
+ }
+ if (actor != NULL) {
+ switch (mIsPulled[i]) {
+ case 0:
+ if (!fopAcM_checkCarryNow(actor) &&
+ checkArea_sub(actor) &&
+ (current.pos.x != actor->current.pos.x ||
+ current.pos.z != actor->current.pos.z))
+ {
+ ((daObjCarry_c*)actor)->startCtrl();
+ mIsPulled[i] = 1;
+ }
+ break;
+ case 1:
+ cLib_chaseF(&actor->current.pos.x, current.pos.x, 10.0f);
+ cLib_chaseF(&actor->current.pos.z, current.pos.z, 10.0f);
+ if (fopAcM_searchActorDistanceXZ(this, actor) == 0.0f) {
+ ((daObjCarry_c*)actor)->endCtrl();
+ mIsPulled[i] = 0;
+ }
+ break;
+ }
+ mIsActorCarrying[i] = fopAcM_checkCarryNow(actor) != 0;
+ }
+ }
+ }
}
/* 80D4F444-80D4F44C 0009C4 0008+00 1/1 0/0 0/0 .text _delete__11daSwLBall_cFv */
-bool daSwLBall_c::_delete() {
- return true;
+int daSwLBall_c::_delete() {
+ return 1;
}
/* 80D4F44C-80D4F46C 0009CC 0020+00 1/0 0/0 0/0 .text daSwLBall_Execute__FP11daSwLBall_c
*/
-static void daSwLBall_Execute(daSwLBall_c* param_0) {
- // NONMATCHING
+static int daSwLBall_Execute(daSwLBall_c* i_this) {
+ return i_this->execute();
}
/* 80D4F46C-80D4F48C 0009EC 0020+00 1/0 0/0 0/0 .text daSwLBall_Delete__FP11daSwLBall_c
*/
-static void daSwLBall_Delete(daSwLBall_c* param_0) {
- // NONMATCHING
+static int daSwLBall_Delete(daSwLBall_c* i_this) {
+ return i_this->_delete();
}
/* 80D4F48C-80D4F4AC 000A0C 0020+00 1/0 0/0 0/0 .text daSwLBall_Create__FP10fopAc_ac_c */
-static void daSwLBall_Create(fopAc_ac_c* param_0) {
- // NONMATCHING
-}
-
-/* 80D4F4AC-80D4F4C8 000A2C 001C+00 1/1 0/0 0/0 .text cLib_calcTimer<Uc>__FPUc */
-extern "C" void func_80D4F4AC(void* _this, u8* param_0) {
- // NONMATCHING
+static int daSwLBall_Create(fopAc_ac_c* i_this) {
+ return static_cast<daSwLBall_c*>(i_this)->create();
}
/* ############################################################################################## */
/* 80D4F54C-80D4F56C -00001 0020+00 1/0 0/0 0/0 .data l_daSwLBall_Method */
static actor_method_class l_daSwLBall_Method = {
- (process_method_func)daSwLBall_Create__FP10fopAc_ac_c,
- (process_method_func)daSwLBall_Delete__FP11daSwLBall_c,
- (process_method_func)daSwLBall_Execute__FP11daSwLBall_c,
+ (process_method_func)daSwLBall_Create,
+ (process_method_func)daSwLBall_Delete,
+ (process_method_func)daSwLBall_Execute,
+ NULL,
+ NULL,
};
/* 80D4F56C-80D4F59C -00001 0030+00 0/0 0/0 1/0 .data g_profile_SwLBall */
@@ -270,4 +309,4 @@ extern actor_process_profile_definition g_profile_SwLBall = {
0x00040000, // mStatus
fopAc_ACTOR_e, // mActorType
fopAc_CULLBOX_CUSTOM_e, // cullType
-}; \ No newline at end of file
+};