From 9ebead5740ef689eb03609e66b161cc8c76672e7 Mon Sep 17 00:00:00 2001 From: PikHacker Date: Sun, 15 Sep 2024 23:04:37 -0400 Subject: [PATCH] Kabuto.cpp closer --- docs/recommended_todo.md | 8 ++-- include/kh/khWorldMap.h | 2 +- src/plugProjectKonoU/khWorldMap.cpp | 4 +- src/plugProjectNishimuraU/Imomushi.cpp | 4 +- src/plugProjectNishimuraU/Kabuto.cpp | 51 ++++++++++++++------------ 5 files changed, 36 insertions(+), 33 deletions(-) diff --git a/docs/recommended_todo.md b/docs/recommended_todo.md index bcf9877f8..4c58e16ab 100644 --- a/docs/recommended_todo.md +++ b/docs/recommended_todo.md @@ -61,8 +61,8 @@ | File | Size (bytes) | File | Size (bytes) | | ---- | ---- | ---- | ---- | | PSBnkMgr.cpp | 10222 | PSSe.cpp | 22235 | -| PSSeq.cpp | 27178 | PSAutoBgm.cpp | 53627 | -| PSGame.cpp | 75695 | | | +| PSSeq.cpp | 27178 | PSAutoBgm.cpp | 53629 | +| PSGame.cpp | 75694 | | | ###
plugProjectKandoU
| File | Size (bytes) | File | Size (bytes) | @@ -112,12 +112,12 @@ | TyreShadow.cpp | 7271 | nslibmath.cpp | 7593 | | UmimushiShadow.cpp | 7675 | SnakeJointMgr.cpp | 7850 | | KumaChappy.cpp | 10290 | SnakeWholeShadow.cpp | 11928 | -| SnakeCrowShadow.cpp | 12091 | Kabuto.cpp | 12121 | +| SnakeCrowShadow.cpp | 12091 | Kabuto.cpp | 12136 | | BabyState.cpp | 12837 | Kogane.cpp | 14498 | | RandMapMgr.cpp | 15237 | Rock.cpp | 17638 | | Ujia.cpp | 18104 | JointShadowBase.cpp | 18414 | | Ujib.cpp | 18626 | ElecBug.cpp | 18636 | -| ImomushiState.cpp | 19604 | Imomushi.cpp | 20112 | +| ImomushiState.cpp | 19604 | Imomushi.cpp | 20110 | | UjiaState.cpp | 20343 | Armor.cpp | 20970 | | ElecHiba.cpp | 21756 | QueenState.cpp | 22553 | | MiniHoudai.cpp | 22737 | UjibState.cpp | 25546 | diff --git a/include/kh/khWorldMap.h b/include/kh/khWorldMap.h index 2648d09c7..46b6c832d 100644 --- a/include/kh/khWorldMap.h +++ b/include/kh/khWorldMap.h @@ -262,7 +262,7 @@ struct WorldMap : public Game::WorldMap::Base { inline StaticValues() { _00 = 4500.0f; - _04 = 0.01f; + _04 = 0.001f; _08 = 0.92f; _0C = 800.0f; _10 = 0.97f; diff --git a/src/plugProjectKonoU/khWorldMap.cpp b/src/plugProjectKonoU/khWorldMap.cpp index 1f02caff5..73b608eb1 100644 --- a/src/plugProjectKonoU/khWorldMap.cpp +++ b/src/plugProjectKonoU/khWorldMap.cpp @@ -4257,7 +4257,7 @@ void WorldMap::changeInfo() mScreenInfo->search(floTags[i])->hide(); f32 x = msVal._68; if (mCaveOtaNum[i] >= 10) { - x += 12.5f; + x += 11.5f; } mCaveTreasureCounterCollected[i]->getMotherPane()->move(x, 0.0f); } @@ -4267,7 +4267,7 @@ void WorldMap::changeInfo() if (!Game::playData->isStoryFlag(Game::STORY_DebtPaid) && mCaveOtaMax[i] != mCaveOtaNum[i]) { f32 x = msVal._68; if (mCaveOtaMax[i] >= 10) { - x += 12.5f; + x += 11.5f; } mCaveTreasureCounterCollected[i]->getMotherPane()->move(x, 0.0f); mCaveTreasureCounterMax[i]->getMotherPane()->hide(); diff --git a/src/plugProjectNishimuraU/Imomushi.cpp b/src/plugProjectNishimuraU/Imomushi.cpp index 77d595694..e9b150faf 100644 --- a/src/plugProjectNishimuraU/Imomushi.cpp +++ b/src/plugProjectNishimuraU/Imomushi.cpp @@ -78,8 +78,8 @@ void Obj::doAnimationStick() mClimbRotation += sep; - crossVec = cross(mClimbRotation, mClimbDirection); - mClimbDirection = cross(crossVec, mClimbRotation); + crossVec = mClimbRotation.cross(mClimbDirection); + mClimbDirection = crossVec.cross(mClimbRotation); } else { Vector3f sep = mClimbAxis - mClimbDirection; sep *= C_PROPERPARMS.mRotationCorrection.mValue; diff --git a/src/plugProjectNishimuraU/Kabuto.cpp b/src/plugProjectNishimuraU/Kabuto.cpp index dfad42bad..bf5f73a31 100644 --- a/src/plugProjectNishimuraU/Kabuto.cpp +++ b/src/plugProjectNishimuraU/Kabuto.cpp @@ -206,17 +206,19 @@ Creature* Obj::getSearchedTarget() */ bool Obj::isAttackableTarget() { - f32 theta = mFaceDir; - Vector3f angles = getRotation(theta); - f32 scale = 0.5f * C_GENERALPARMS.mSightRadius.mValue; - Vector3f pos = Vector3f(scale * angles.x + mPosition.x, scale * angles.y + mPosition.y, scale * angles.z + mPosition.z); - Sys::Sphere sphere; - sphere.mRadius = 0.75f * C_GENERALPARMS.mSightRadius.mValue; - sphere.mPosition = pos; + Vector3f angles(-sinf(mFaceDir), 0.0f, cosf(mFaceDir)); + f32 scale = 0.5f * C_GENERALPARMS.mSightRadius(); + Vector3f pos(angles.x * scale + mPosition.x, angles.y * scale + mPosition.y, angles.z * scale + mPosition.z); + Sys::Sphere sphere(pos, 0.75f * C_GENERALPARMS.mSightRadius()); CellIteratorArg iterArg(sphere); iterArg.mOptimise = true; + CellIterator iter(iterArg); + + // this is probably wrong but an extra vector3 needs to exist + Vector3f inv(angles.x, 0.0f, -angles.z); + CI_LOOP(iter) { Creature* creature = static_cast(*iter); @@ -226,11 +228,12 @@ bool Obj::isAttackableTarget() check = true; } if (check) { - Vector3f creaturePos = creature->getPosition(); - Vector3f diff = creaturePos - mPosition; - if (absVal(diff.y) < C_GENERALPARMS.mFov()) { - angles.y = 0.0f; - if (absVal(diff.dot(angles)) > 15.0f && diff.dot(angles) < C_GENERALPARMS.mSightRadius.mValue) { + Vector3f diff = creature->getPosition(); + diff -= mPosition; + + if (absVal(diff.y) < C_GENERALPARMS.mFov() && absVal(inv.dot(diff)) < 15.0f) { + f32 dist = angles.dot(diff); + if (dist > 15.0f && dist < C_GENERALPARMS.mSightRadius()) { return true; } } @@ -261,7 +264,7 @@ bool Obj::isAttackableTarget() bge lbl_802E4998 fneg f1, f3 -lbl_802E4998: + lbl_802E4998: lfs f2, lbl_8051CE24@sda21(r2) lis r3, sincosTable___5JMath@ha lfs f0, lbl_8051CDCC@sda21(r2) @@ -285,7 +288,7 @@ bool Obj::isAttackableTarget() fneg f29, f0 b lbl_802E4A08 -lbl_802E49F0: + lbl_802E49F0: fmuls f0, f3, f2 fctiwz f0, f0 stfd f0, 0xa0(r1) @@ -293,7 +296,7 @@ bool Obj::isAttackableTarget() rlwinm r0, r0, 3, 0x12, 0x1c lfsx f29, r4, r0 -lbl_802E4A08: + lbl_802E4A08: lwz r4, 0xc0(r31) fneg f31, f30 lfs f0, lbl_8051CE38@sda21(r2) @@ -324,7 +327,7 @@ bool Obj::isAttackableTarget() bl first__Q24Game12CellIteratorFv b lbl_802E4BC0 -lbl_802E4A7C: + lbl_802E4A7C: addi r3, r1, 0x44 bl __ml__Q24Game12CellIteratorFv lwz r12, 0(r3) @@ -358,7 +361,7 @@ bool Obj::isAttackableTarget() beq lbl_802E4AFC li r29, 1 -lbl_802E4AFC: + lbl_802E4AFC: clrlwi. r0, r29, 0x18 beq lbl_802E4BB8 mr r4, r30 @@ -383,10 +386,10 @@ bool Obj::isAttackableTarget() fmr f1, f3 b lbl_802E4B5C -lbl_802E4B58: + lbl_802E4B58: fneg f1, f3 -lbl_802E4B5C: + lbl_802E4B5C: lfs f0, 0x3fc(r3) fcmpo cr0, f1, f0 bge lbl_802E4BB8 @@ -398,10 +401,10 @@ bool Obj::isAttackableTarget() ble lbl_802E4B84 b lbl_802E4B88 -lbl_802E4B84: + lbl_802E4B84: fneg f0, f0 -lbl_802E4B88: + lbl_802E4B88: lfs f1, lbl_8051CE40@sda21(r2) fcmpo cr0, f0, f1 bge lbl_802E4BB8 @@ -415,18 +418,18 @@ bool Obj::isAttackableTarget() li r3, 1 b lbl_802E4BD4 -lbl_802E4BB8: + lbl_802E4BB8: addi r3, r1, 0x44 bl next__Q24Game12CellIteratorFv -lbl_802E4BC0: + lbl_802E4BC0: addi r3, r1, 0x44 bl isDone__Q24Game12CellIteratorFv clrlwi. r0, r3, 0x18 beq lbl_802E4A7C li r3, 0 -lbl_802E4BD4: + lbl_802E4BD4: psq_l f31, 232(r1), 0, qr0 lfd f31, 0xe0(r1) psq_l f30, 216(r1), 0, qr0