Skip to content

Commit

Permalink
Fix miscalculations
Browse files Browse the repository at this point in the history
  • Loading branch information
KSSBrawl committed Dec 6, 2024
1 parent 97be2cb commit e6d6c14
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/EnemyEclInstr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ void ExInsStage6XFunc6(Enemy *enemy, EclRawInstr *instr)
effect->unk_11c.x = (g_Rng.GetRandomF32ZeroToOne() * 40.0f - 20.0f) / 60.0f;
effect->unk_11c.y = (8.0f * baseAngleModifier) / 60.0f - (4.0f / 15.0f);
effect->unk_11c.z = 0.0;
effect->unk_128 = -effect->unk_11c / RECIPROCAL(120.0f);
effect->unk_128 = -effect->unk_11c / 120.0f;

particlePos = enemy->position;
particlePos.x -= cosf(finalAngle) * distanceModifier;
Expand All @@ -783,7 +783,7 @@ void ExInsStage6XFunc6(Enemy *enemy, EclRawInstr *instr)
effect->unk_11c.x = (g_Rng.GetRandomF32ZeroToOne() * 40.0f - 20.0f) / 60.0f;
effect->unk_11c.y = (8.0f * baseAngleModifier) / 60.0f - (4.0f / 15.0f);
effect->unk_11c.z = 0.0;
effect->unk_128 = -effect->unk_11c / RECIPROCAL(120.0f);
effect->unk_128 = -effect->unk_11c / 120.0f;
}

enemy->exInsFunc6Timer.Tick();
Expand Down
6 changes: 3 additions & 3 deletions src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,8 +1319,8 @@ i32 Player::CalcLaserHitbox(D3DXVECTOR3 *laserCenter, D3DXVECTOR3 *laserSize, D3
playerRelativeTopLeft = laserTopLeft - this->hitboxSize;
playerRelativeBottomRight = laserTopLeft + this->hitboxSize;

laserTopLeft = *laserCenter - *laserSize / RECIPROCAL(2.0f);
laserBottomRight = *laserCenter + *laserSize / RECIPROCAL(2.0f);
laserTopLeft = *laserCenter - *laserSize / 2.0f;
laserBottomRight = *laserCenter + *laserSize / 2.0f;

if (!(playerRelativeTopLeft.x > laserBottomRight.x || playerRelativeBottomRight.x < laserTopLeft.x ||
playerRelativeTopLeft.y > laserBottomRight.y || playerRelativeBottomRight.y < laserTopLeft.y))
Expand Down Expand Up @@ -1399,7 +1399,7 @@ void Player::ScoreGraze(D3DXVECTOR3 *center)
}
}

particlePosition = (this->positionCenter + *center) / RECIPROCAL(2.0f);
particlePosition = (this->positionCenter + *center) / 2.0f;
g_EffectManager.SpawnParticles(PARTICLE_EFFECT_UNK_8, &particlePosition, 1, COLOR_WHITE);
g_GameManager.AddScore(500);
g_GameManager.IncreaseSubrank(6);
Expand Down
7 changes: 5 additions & 2 deletions src/ZunMath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include <Windows.h>
#include <d3dx8math.h>

#define RECIPROCAL(x) (1.0f / x)

struct ZunVec2
{
f32 x;
Expand Down Expand Up @@ -88,3 +86,8 @@ void __inline sincosmul(D3DXVECTOR3 *out_vel, f32 input, f32 multiplier)
fstp [eax+4]
}
}

f32 __inline invertf(f32 x)
{
return 1.f / x;
}

0 comments on commit e6d6c14

Please sign in to comment.