Skip to content

Commit

Permalink
Kabuto.cpp closer
Browse files Browse the repository at this point in the history
  • Loading branch information
PikHacker committed Sep 16, 2024
1 parent 96df5a4 commit 9ebead5
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 33 deletions.
8 changes: 4 additions & 4 deletions docs/recommended_todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
| File | Size (bytes) | File | Size (bytes) |
| ---- | ---- | ---- | ---- |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectHikinoU/PSBnkMgr.cpp">PSBnkMgr.cpp</a> | 10222 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectHikinoU/PSSe.cpp">PSSe.cpp</a> | 22235 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectHikinoU/PSSeq.cpp">PSSeq.cpp</a> | 27178 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectHikinoU/PSAutoBgm.cpp">PSAutoBgm.cpp</a> | 53627 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectHikinoU/PSGame.cpp">PSGame.cpp</a> | 75695 | | |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectHikinoU/PSSeq.cpp">PSSeq.cpp</a> | 27178 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectHikinoU/PSAutoBgm.cpp">PSAutoBgm.cpp</a> | 53629 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectHikinoU/PSGame.cpp">PSGame.cpp</a> | 75694 | | |

### <section id="plugProjectKandoU">plugProjectKandoU</section>
| File | Size (bytes) | File | Size (bytes) |
Expand Down Expand Up @@ -112,12 +112,12 @@
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/TyreShadow.cpp">TyreShadow.cpp</a> | 7271 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/nslibmath.cpp">nslibmath.cpp</a> | 7593 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/UmimushiShadow.cpp">UmimushiShadow.cpp</a> | 7675 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/SnakeJointMgr.cpp">SnakeJointMgr.cpp</a> | 7850 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/KumaChappy.cpp">KumaChappy.cpp</a> | 10290 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/SnakeWholeShadow.cpp">SnakeWholeShadow.cpp</a> | 11928 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/SnakeCrowShadow.cpp">SnakeCrowShadow.cpp</a> | 12091 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/Kabuto.cpp">Kabuto.cpp</a> | 12121 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/SnakeCrowShadow.cpp">SnakeCrowShadow.cpp</a> | 12091 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/Kabuto.cpp">Kabuto.cpp</a> | 12136 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/BabyState.cpp">BabyState.cpp</a> | 12837 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/Kogane.cpp">Kogane.cpp</a> | 14498 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/RandMapMgr.cpp">RandMapMgr.cpp</a> | 15237 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/Rock.cpp">Rock.cpp</a> | 17638 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/Ujia.cpp">Ujia.cpp</a> | 18104 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/JointShadowBase.cpp">JointShadowBase.cpp</a> | 18414 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/Ujib.cpp">Ujib.cpp</a> | 18626 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/ElecBug.cpp">ElecBug.cpp</a> | 18636 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/ImomushiState.cpp">ImomushiState.cpp</a> | 19604 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/Imomushi.cpp">Imomushi.cpp</a> | 20112 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/ImomushiState.cpp">ImomushiState.cpp</a> | 19604 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/Imomushi.cpp">Imomushi.cpp</a> | 20110 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/UjiaState.cpp">UjiaState.cpp</a> | 20343 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/Armor.cpp">Armor.cpp</a> | 20970 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/ElecHiba.cpp">ElecHiba.cpp</a> | 21756 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/QueenState.cpp">QueenState.cpp</a> | 22553 |
| <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/MiniHoudai.cpp">MiniHoudai.cpp</a> | 22737 | <a href="https://github.com/projectPiki/pikmin2/tree/main/src/plugProjectNishimuraU/UjibState.cpp">UjibState.cpp</a> | 25546 |
Expand Down
2 changes: 1 addition & 1 deletion include/kh/khWorldMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/plugProjectKonoU/khWorldMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/plugProjectNishimuraU/Imomushi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
51 changes: 27 additions & 24 deletions src/plugProjectNishimuraU/Kabuto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Creature*>(*iter);
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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)
Expand All @@ -285,15 +288,15 @@ bool Obj::isAttackableTarget()
fneg f29, f0
b lbl_802E4A08
lbl_802E49F0:
lbl_802E49F0:
fmuls f0, f3, f2
fctiwz f0, f0
stfd f0, 0xa0(r1)
lwz r0, 0xa4(r1)
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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 9ebead5

Please sign in to comment.