summaryrefslogtreecommitdiff
path: root/src/00_Core
diff options
context:
space:
mode:
authorAetias <144526980+AetiasHax@users.noreply.github.com>2025-07-22 17:54:33 +0200
committerGitHub <noreply@github.com>2025-07-22 17:54:33 +0200
commitd45ea18bf4210b34d747930b5f1c9aa24d1a525a (patch)
treefa7218884dd6dd04a387981c277e703f0d82c85d /src/00_Core
parentcf8f5a80b13c4edd7fd8ebb33ab0de81d64f609b (diff)
PlayerBase OK (#126)
* Map symbol in Game * PlayerBase OK * Fix ActorRefill * Fix MapManager * Mark PlayerBase as complete * Fix MapManager
Diffstat (limited to 'src/00_Core')
-rw-r--r--src/00_Core/Map/MapManager.cpp59
-rw-r--r--src/00_Core/Player/PlayerBase.cpp183
2 files changed, 189 insertions, 53 deletions
diff --git a/src/00_Core/Map/MapManager.cpp b/src/00_Core/Map/MapManager.cpp
index 69dcfc96..f991890e 100644
--- a/src/00_Core/Map/MapManager.cpp
+++ b/src/00_Core/Map/MapManager.cpp
@@ -8,6 +8,7 @@
#include "Actor/ActorSpawner.hpp"
#include "DTCM/UnkStruct_027e077c.hpp"
#include "DTCM/UnkStruct_027e0d38.hpp"
+#include "DTCM/UnkStruct_027e0f64.hpp"
#include "DTCM/UnkStruct_027e0fd4.hpp"
#include "DTCM/UnkStruct_027e103c.hpp"
#include "Player/PlayerBase.hpp"
@@ -28,7 +29,6 @@ extern void func_ov000_020798bc(s32 *param_1, s32 param_2);
extern void func_ov000_02088000(unk32 param_1, s32 param_2);
extern void func_ov000_02088130(u8 *param_1, unk32 param_2);
extern void func_ov000_02088144(u8 *param_1, unk32 param_2);
-extern void func_ov000_0208b13c(s32 *param_1);
extern unk32 func_ov000_0208b180(s32 *param_1);
extern s32 func_ov000_0208b73c(s32 param_1, unk32 param_2);
extern s32 func_ov000_0208b7d0(s32 param_1, Vec3p *param_2);
@@ -110,7 +110,6 @@ extern unk32 *data_027e0c68;
extern u32 *data_027e0ce0[];
extern UnkStruct_0202e894 *data_027e0ce4;
extern unk32 *data_027e0d3c;
-extern unk32 data_027e0f64[];
extern unk32 *data_027e0f68;
extern unk32 *data_027e0f6c;
extern unk32 *data_027e0f70;
@@ -475,19 +474,12 @@ ARM s32 MapManager::func_ov00_02082914(unk32 param_2) {
int iVar4;
int iVar5;
Vec3p pVar1;
- Entrance local_44;
- Entrance local_30;
switch (param_2) {
case 0xfa:
- pvVar1 = data_027e0d38->mUnk_28;
- local_30.mPos.x = *(int *) ((int) pvVar1 + 0x5c);
- local_30.mPos.y = *(int *) ((int) pvVar1 + 0x60);
- local_30.mPos.z = *(int *) ((int) pvVar1 + 100);
- local_30.mAngle = *(unk16 *) ((int) pvVar1 + 0x68);
- local_30.mId = *(unk8 *) ((int) pvVar1 + 0x6a);
- local_30.mUnk_10 = *(int *) ((int) pvVar1 + 0x6c);
- iVar3 = this->mMap->AddEntrance(&local_30);
+ pvVar1 = data_027e0d38->mUnk_28;
+ Entrance local_30(*(Entrance *) ((s32) pvVar1 + 0x5c));
+ iVar3 = this->mMap->AddEntrance(&local_30);
return iVar3;
case 0xfb:
case 0xfc:
@@ -497,13 +489,12 @@ ARM s32 MapManager::func_ov00_02082914(unk32 param_2) {
default:
return (int) this;
}
- local_44.mId = -1;
- local_44.mUnk_10 = 0;
- pvVar1 = data_027e0d38->mUnk_28;
- pVar1 = *(Vec3p *) ((int) pvVar1 + 0x38);
- iVar3 = 0x2000;
- iVar4 = 0x2000;
- iVar5 = 0xfd;
+ Entrance local_44;
+ pvVar1 = data_027e0d38->mUnk_28;
+ pVar1 = *(Vec3p *) ((int) pvVar1 + 0x38);
+ iVar3 = 0x2000;
+ iVar4 = 0x2000;
+ iVar5 = 0xfd;
if (this->mCourse->mType == CourseType_Sea) {
iVar3 = this->mMap->vfunc_88();
iVar3 = iVar3 + 0xa000;
@@ -577,7 +568,7 @@ void MapManager::func_ov00_02082b3c(unk32 *param_2, Vec2b *param_3) {
this->mMap->vfunc_18();
} else {
gAdventureFlags->func_ov00_020976c8();
- func_ov000_0208b13c(data_027e0f64);
+ data_027e0f64->func_ov000_0208b13c();
uVar5 = this->func_ov00_02082d08();
gActorManager->func_ov004_02105608(param_3->x, param_3->y, uVar5);
this->mMap->vfunc_2c();
@@ -961,8 +952,6 @@ ARM bool MapManager::GetEntrancePos(Entrance *param_1, unk32 entranceId) {
ARM bool MapManager::func_ov00_02083664(Entrance *param_2, unk32 entranceId) {
Entrance entrance;
- entrance.mId = (u8) 0xff;
- entrance.mUnk_10 = 0;
if (this->GetEntrancePos(&entrance, entranceId)) {
param_2->mPos.x = entrance.mPos.x;
param_2->mPos.y = entrance.mPos.y;
@@ -1022,9 +1011,9 @@ ARM bool MapManager::func_ov00_02083790(s32 param_2) {
if (param_2 == 0) {
return true;
}
- *(int *) (*(int *) (*(unk32 *) data_027e0f64 + 8) + 0x1b4) = param_2;
- *(int *) (*(int *) (*(unk32 *) data_027e0f64 + 4) + 0x1b4) = param_2;
- iVar2 = data_027e0d38->func_ov000_02078b40();
+ *(int *) (*(int *) ((unk32 *) data_027e0f64 + 2) + 0x1b4) = param_2;
+ *(int *) (*(int *) ((unk32 *) data_027e0f64 + 1) + 0x1b4) = param_2;
+ iVar2 = data_027e0d38->func_ov000_02078b40();
if ((iVar2 != 0) && (bVar1 = this->func_ov00_02082e1c(&aiStack_14, &iStack_18), !bVar1)) {
func_ov000_02079898(data_027e0d3c, param_2, 0x10);
gActorManager->func_ov00_020c3ce8(param_2, true);
@@ -1040,9 +1029,9 @@ ARM bool MapManager::func_ov00_02083840(s32 param_2) {
if (param_2 == 0) {
return true;
}
- *(unk32 *) (*(unk32 *) (*(unk32 *) data_027e0f64 + 8) + 0x1b4) = -1;
- *(unk32 *) (*(unk32 *) (*(unk32 *) data_027e0f64 + 4) + 0x1b4) = -1;
- iVar4 = func_ov000_02078fe8(data_027e0d3c);
+ *(unk32 *) (*(unk32 *) ((unk32 *) data_027e0f64 + 2) + 0x1b4) = -1;
+ *(unk32 *) (*(unk32 *) ((unk32 *) data_027e0f64 + 1) + 0x1b4) = -1;
+ iVar4 = func_ov000_02078fe8(data_027e0d3c);
if (0 <= iVar4) {
func_ov000_020798bc(data_027e0d3c, 0x10);
gActorManager->func_ov00_020c3ce8(param_2, false);
@@ -1959,7 +1948,7 @@ s32 MapManager::func_ov00_02084d4c(unk32 param_2, unk32 param_3, Vec3p *param_4)
int iStack_18;
Vec3p VStack_14;
- iVar1 = func_ov000_0208df78(data_027e0f64 + 4, param_2, param_3, &VStack_14, &iStack_20);
+ iVar1 = func_ov000_0208df78((s32 *) data_027e0f64 + 1, param_2, param_3, &VStack_14, &iStack_20);
// object = PTR_DWORD_overlay_d_0__020e2510_overlay_d_0__02084ea8;
if (iVar1 == -1) {
return -1;
@@ -2109,10 +2098,10 @@ s32 MapManager::func_ov00_02085108(Vec3p *param_2) {
int local_2c;
unk32 local_28;
- uVar2 = func_ov000_0208b180(data_027e0f64);
+ uVar2 = data_027e0f64->func_ov000_0208b180();
func_ov000_02088130(&local_38, uVar2);
local_44 = (u32) local_38;
- uVar2 = func_ov000_0208b180(data_027e0f64);
+ uVar2 = data_027e0f64->func_ov000_0208b180();
func_ov000_02088144(&local_3a, uVar2);
if (local_44 <= local_37) {
do {
@@ -2165,10 +2154,10 @@ s32 MapManager::func_ov00_0208527c(MapManager *param_1, unk32 param_2, unk32 *pa
unk32 local_30;
unk32 local_2c;
- uVar3 = func_ov000_0208b180(data_027e0f64);
+ uVar3 = data_027e0f64->func_ov000_0208b180();
func_ov000_02088130(&local_3c, uVar3);
uVar7 = (u32) local_3c;
- uVar3 = func_ov000_0208b180(data_027e0f64);
+ uVar3 = data_027e0f64->func_ov000_0208b180();
func_ov000_02088144(&local_3e, uVar3);
local_4c = (u32) local_3e;
uVar6 = (u32) local_3d;
@@ -2229,10 +2218,10 @@ s32 MapManager::func_ov00_020853fc(MapManager *param_1, Vec3p *param_2, s32 *par
unk32 local_30;
unk32 local_2c;
- uVar2 = func_ov000_0208b180(data_027e0f64);
+ uVar2 = data_027e0f64->func_ov000_0208b180();
func_ov000_02088130(&local_3c, uVar2);
local_48 = (u32) local_3c;
- uVar2 = func_ov000_0208b180(data_027e0f64);
+ uVar2 = data_027e0f64->func_ov000_0208b180();
func_ov000_02088144(&local_3e, uVar2);
local_50 = local_3e;
uVar6 = local_3d;
diff --git a/src/00_Core/Player/PlayerBase.cpp b/src/00_Core/Player/PlayerBase.cpp
index a33dc210..6f89f0d1 100644
--- a/src/00_Core/Player/PlayerBase.cpp
+++ b/src/00_Core/Player/PlayerBase.cpp
@@ -1,20 +1,167 @@
#include "Player/PlayerBase.hpp"
+#include "Actor/Navi/ActorNaviBase.hpp"
+#include "DTCM/UnkStruct_027e0c54.hpp"
+#include "DTCM/UnkStruct_027e0e58.hpp"
+#include "DTCM/UnkStruct_027e0f64.hpp"
+#include "Item/ItemManager.hpp"
+#include "Map/MapManager.hpp"
+#include "Player/PlayerControl.hpp"
-bool PlayerBase::vfunc_04() {}
-ItemFlag PlayerBase::GetEquipId() {}
-bool PlayerBase::CanMove() {}
-void PlayerBase::SetUpdatePos(bool updatePos) {}
-void PlayerBase::SetVisible(bool visible) {}
-EquipSword *PlayerBase::GetEquipSword() {}
-EquipShield *PlayerBase::GetEquipShield() {}
-void PlayerBase::LookAt(Vec3p *target) {}
-bool PlayerBase::func_ov00_020a7c00(s32 param1) {}
-bool PlayerBase::CollidesWith(Cylinder *cylinder) {}
-bool PlayerBase::func_ov00_020a7c60(Vec3p *param1, Vec3p *param2, s32 param3) {}
-bool PlayerBase::EquipCollidesWith(Cylinder *cylinder, ItemFlag equipId) {}
-s32 PlayerBase::EquipItem_vfunc_2c() {}
-void PlayerBase::SetHealth(s16 health) {}
-void PlayerBase::AddHealth(s16 amount) {}
-bool PlayerBase::Teleport(Vec3p *pos, s16 angle, unk32 param3, bool param4, bool param5) {}
-bool PlayerBase::TeleportToEntrance(unk32 entranceId, bool param2) {}
-bool PlayerBase::TeleportToLastEntrance(bool param1) {}
+static const char *sShipParts[] = {"anc", "bow", "hul", "can", "dco", "pdl", "fnl", "brg"};
+
+ARM bool PlayerBase::vfunc_04() {
+ return true;
+}
+
+ARM ItemFlag PlayerBase::GetEquipId() {
+ return ItemFlag_None;
+}
+
+ARM bool PlayerBase::CanMove() {
+ return true;
+}
+
+ARM void PlayerBase::SetUpdatePos(bool updatePos) {
+ mUpdatePos = updatePos;
+}
+
+ARM void PlayerBase::SetVisible(bool visible) {
+ mVisible = visible;
+
+ ItemManager *pItemManager = gItemManager;
+ ActorNaviBase *fairy = pItemManager->GetFairy(pItemManager->GetEquippedFairy());
+ if (fairy != NULL) {
+ fairy->mVisible = mVisible;
+ }
+
+ s16 var_r0 = visible ? 0x1f : 0;
+ this->GetEquipSword()->mUnk_5c = var_r0;
+ this->GetEquipShield()->mUnk_0e = var_r0;
+ data_027e0e58->func_ov000_0207c5d4(1, visible);
+}
+
+ARM EquipSword *PlayerBase::GetEquipSword() {
+ return (EquipSword *) gItemManager->GetEquipItemUnchecked(ItemFlag_OshusSword);
+}
+
+ARM EquipShield *PlayerBase::GetEquipShield() {
+ return (EquipShield *) gItemManager->GetEquipItemUnchecked(ItemFlag_WoodenShield);
+}
+
+ARM void PlayerBase::LookAt(Vec3p *target) {
+ Vec3p vec;
+ Vec3p_Sub(target, &gPlayerPos, &vec);
+ if (vec.x == 0 && vec.z == 0) {
+ return;
+ }
+ gPlayerAngle = Atan2(*(vs32 *) &vec.x, vec.z);
+}
+
+ARM bool PlayerBase::func_ov00_020a7c00(s32 param1) {
+ return param1 == data_027e0c54.mUnk_0;
+}
+
+ARM bool PlayerBase::CollidesWith(Cylinder *cylinder) {
+ Cylinder hitbox;
+ this->vfunc_10(&hitbox);
+ if (hitbox.size < 0) {
+ return false;
+ }
+ return cylinder->Overlaps(&hitbox);
+}
+
+ARM bool PlayerBase::func_ov00_020a7c60(Vec3p *param1, Vec3p *param2, s32 param3) {
+ Cylinder hitbox;
+ this->vfunc_10(&hitbox);
+ if (hitbox.size < 0) {
+ return false;
+ }
+ Vec3p vec1 = {param1->x, param1->y, param1->z};
+ Vec3p vec2 = {param2->x, param2->y, param2->z};
+ return hitbox.func_ov000_0208f030(&vec1, &vec2, param3);
+}
+
+ARM bool PlayerBase::EquipCollidesWith(Cylinder *cylinder, ItemFlag equipId) {
+ return gItemManager->EquipCollidesWith(cylinder, equipId);
+}
+
+ARM s32 PlayerBase::EquipItem_vfunc_2c() {
+ ItemFlag equippedItem = this->GetEquipId();
+ if (equippedItem == ItemFlag_None) {
+ return 0;
+ }
+ return gItemManager->EquipItem_vfunc_2c(equippedItem);
+}
+
+ARM void PlayerBase::SetHealth(s16 health) {
+ if (mInvincible) {
+ return;
+ }
+
+ mHealth = health;
+ if (mHealth > this->GetMaxHealth()) {
+ mHealth = this->GetMaxHealth();
+ } else if (mHealth < 0) {
+ mHealth = 0;
+ }
+}
+
+ARM void PlayerBase::AddHealth(s16 amount) {
+ if (mInvincible) {
+ return;
+ }
+
+ if (mHealth <= 0) {
+ return;
+ }
+ mHealth += amount;
+ if (mHealth > this->GetMaxHealth()) {
+ mHealth = this->GetMaxHealth();
+ } else if (mHealth < 0) {
+ mHealth = 0;
+ }
+}
+
+ARM bool PlayerBase::TeleportToEntrance(unk32 entranceId, bool param2) {
+ Entrance entrance;
+ gMapManager->GetEntrancePos(&entrance, entranceId);
+ if (this->Teleport(&entrance.mPos, entrance.mAngle, entrance.mUnk_10, param2, false)) {
+ mEntranceId = entranceId;
+ return true;
+ }
+ return false;
+}
+
+extern unk16 data_027e0fb0;
+ARM bool PlayerBase::Teleport(Vec3p *pos, s16 angle, unk32 param3, bool param4, bool param5) {
+ gPlayerPos = *pos;
+ Vec3p subroutine_arg0 = {pos->x, pos->y, pos->z};
+
+ q20 maxY = gMapManager->MapData_vfunc_68(&subroutine_arg0, 1);
+ q20 y = pos->y;
+ if (y <= maxY) {
+ y = maxY;
+ }
+ gPlayerPos.y = y;
+
+ gPlayerAngle = angle;
+ gPlayerVel.x = 0;
+ data_027e0fb0 = 0;
+ gPlayerVel.y = 0;
+ gPlayerVel.z = 0;
+
+ gPlayerControl->UpdateAim();
+ gActorManager->Actor_vfunc_10(param4);
+ if (param4) {
+ gMapManager->func_ov00_02082af4();
+ gAdventureFlags->func_ov00_02097700();
+ }
+ if (!param5) {
+ data_027e0f64->func_ov000_0208ae94();
+ }
+ return true;
+}
+
+ARM bool PlayerBase::TeleportToLastEntrance(bool param1) {
+ this->TeleportToEntrance(mEntranceId, param1);
+}