2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 15:44:56 +00:00

Merge branch 'master' into omegapirate

# Conflicts:
#	Runtime/GuiSys/CAuiImagePane.cpp
This commit is contained in:
2020-04-19 22:12:18 -04:00
37 changed files with 149 additions and 130 deletions

View File

@@ -19,18 +19,22 @@ CBurstFire::CBurstFire(const SBurst* const* burstDefs, s32 firstBurstCount)
void CBurstFire::Update(CStateManager& mgr, float dt) {
x14_24_shouldFire = false;
if (x18_curBursts) {
x8_timeToNextShot -= dt;
if (x8_timeToNextShot < 0.f) {
x4_angleIdx += 1;
if (x18_curBursts->x4_shotAngles[x4_angleIdx] > 0) {
x14_24_shouldFire = true;
x8_timeToNextShot = x18_curBursts->x24_timeToNextShot;
x8_timeToNextShot += (mgr.GetActiveRandom()->Float() - 0.5f) * x18_curBursts->x28_timeToNextShotVariance;
} else {
x18_curBursts = nullptr;
}
}
if (!x18_curBursts) {
return;
}
x8_timeToNextShot -= dt;
if (x8_timeToNextShot >= 0.f) {
return;
}
x4_angleIdx += 1;
if (x18_curBursts->x4_shotAngles[x4_angleIdx] > 0) {
x14_24_shouldFire = true;
x8_timeToNextShot = x18_curBursts->x24_timeToNextShot;
x8_timeToNextShot += (mgr.GetActiveRandom()->Float() - 0.5f) * x18_curBursts->x28_timeToNextShotVariance;
} else {
x18_curBursts = nullptr;
}
}
@@ -67,18 +71,25 @@ void CBurstFire::Start(CStateManager& mgr) {
}
zeus::CVector3f CBurstFire::GetError(float xMag, float zMag) const {
zeus::CVector3f ret;
if (x14_24_shouldFire && x18_curBursts) {
s32 r0 = x18_curBursts->x4_shotAngles[x4_angleIdx];
if (x14_25_avoidAccuracy && (r0 == 4 || r0 == 12))
r0 = x4_angleIdx > 0 ? x18_curBursts->x4_shotAngles[x4_angleIdx - 1]
: x18_curBursts->x4_shotAngles[x4_angleIdx + 1];
if (r0 > 0) {
float angle = r0 * zeus::degToRad(-22.5f);
ret.x() = std::cos(angle) * xMag;
ret.z() = std::sin(angle) * zMag;
}
if (!x14_24_shouldFire || !x18_curBursts) {
return {};
}
s32 r0 = x18_curBursts->x4_shotAngles[x4_angleIdx];
if (x14_25_avoidAccuracy && (r0 == 4 || r0 == 12)) {
r0 =
x4_angleIdx > 0 ? x18_curBursts->x4_shotAngles[x4_angleIdx - 1] : x18_curBursts->x4_shotAngles[x4_angleIdx + 1];
}
if (r0 <= 0) {
return {};
}
const float angle = r0 * zeus::degToRad(-22.5f);
zeus::CVector3f ret;
ret.x() = std::cos(angle) * xMag;
ret.z() = std::sin(angle) * zMag;
return ret;
}

View File

@@ -13,6 +13,7 @@
#include "Runtime/Character/CAnimCharacterSet.hpp"
#include "Runtime/Collision/CMaterialList.hpp"
#include "Runtime/Particle/CElementGen.hpp"
#include "Runtime/Particle/CWeaponDescription.hpp"
#include "Runtime/Weapon/CGunController.hpp"
#include "Runtime/Weapon/CGunMotion.hpp"
#include "Runtime/Weapon/CWeaponMgr.hpp"
@@ -25,7 +26,6 @@ namespace urde {
class CActorLights;
struct CModelFlags;
class CWeaponDescription;
enum class EChargeState { Normal, Charged };

View File

@@ -501,7 +501,7 @@ void CPlayerGun::ResetCharge(CStateManager& mgr, bool resetBeam) {
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
}
}
@@ -587,7 +587,7 @@ void CPlayerGun::Reset(CStateManager& mgr, bool b1) {
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
}
} else {
x2f8_stateFlags &= ~0x7;
@@ -784,7 +784,7 @@ void CPlayerGun::CancelFiring(CStateManager& mgr) {
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
}
if (x32c_chargePhase != EChargePhase::NotCharging) {
x72c_currentBeam->ActivateCharge(false, false);
@@ -820,8 +820,7 @@ void CPlayerGun::StopContinuousBeam(CStateManager& mgr, bool b1) {
} else if (x833_28_phazonBeamActive) {
if (static_cast<CPhazonBeam*>(x72c_currentBeam)->IsFiring())
static_cast<CPhazonBeam*>(x72c_currentBeam)->StopBeam(mgr, b1);
} else if (x310_currentBeam == CPlayerState::EBeamId::Plasma) // Plasma
{
} else if (x310_currentBeam == CPlayerState::EBeamId::Plasma) {
if (static_cast<CPlasmaBeam*>(x72c_currentBeam)->IsFiring())
static_cast<CPlasmaBeam*>(x72c_currentBeam)->StopBeam(mgr, b1);
}
@@ -839,35 +838,34 @@ void CPlayerGun::CMotionState::Update(bool firing, float dt, zeus::CTransform& x
if (x0_24_extendParabola && x20_state == EMotionState::LockOn) {
float extendT = xc_curExtendDist / gGunExtendDistance;
xf = xf * zeus::CTransform::RotateZ(zeus::degToRad(extendT * -4.f * (extendT - 1.f) * 15.f));
} else {
if (x24_fireState == EFireState::StartFire || x24_fireState == EFireState::Firing) {
if (std::fabs(x14_rotationT - 1.f) < 0.1f) {
x18_startRotation = x1c_endRotation;
x14_rotationT = 0.f;
if (x24_fireState == EFireState::StartFire) {
x1c_endRotation = mgr.GetActiveRandom()->Next() % 15;
x1c_endRotation *= (mgr.GetActiveRandom()->Next() % 100) > 45 ? 1.f : -1.f;
} else {
x1c_endRotation = 0.f;
if (x18_startRotation == x1c_endRotation) {
x10_curRotation = x1c_endRotation;
x24_fireState = EFireState::NotFiring;
}
}
xf = xf * zeus::CTransform(zeus::CMatrix3f::RotateZ(zeus::degToRad(extendT * -4.f * (extendT - 1.f) * 15.f)),
{0.f, xc_curExtendDist, 0.f});
} else if (x24_fireState == EFireState::StartFire || x24_fireState == EFireState::Firing) {
if (std::fabs(x14_rotationT - 1.f) < 0.1f) {
x18_startRotation = x1c_endRotation;
x14_rotationT = 0.f;
if (x24_fireState == EFireState::StartFire) {
x1c_endRotation = mgr.GetActiveRandom()->Next() % 15;
x1c_endRotation *= (mgr.GetActiveRandom()->Next() % 100) > 45 ? 1.f : -1.f;
} else {
x10_curRotation = (x1c_endRotation - x18_startRotation) * x14_rotationT + x18_startRotation;
x1c_endRotation = 0.f;
if (x18_startRotation == x1c_endRotation) {
x10_curRotation = x1c_endRotation;
x24_fireState = EFireState::NotFiring;
}
}
x14_rotationT += (1.f - x14_rotationT) * 0.8f * (10.f * dt);
zeus::CTransform tmpXf =
zeus::CQuaternion::fromAxisAngle(xf.basis[1], zeus::degToRad(x10_curRotation)).toTransform() *
xf.getRotation();
tmpXf.origin = xf.origin;
xf = tmpXf * zeus::CTransform::Translate(0.f, xc_curExtendDist, 0.f);
} else {
xf = xf * zeus::CTransform::Translate(0.f, xc_curExtendDist, 0.f);
x10_curRotation = (x1c_endRotation - x18_startRotation) * x14_rotationT + x18_startRotation;
}
x14_rotationT += (1.f - x14_rotationT) * 0.8f * (10.f * dt);
zeus::CTransform tmpXf =
zeus::CQuaternion::fromAxisAngle(xf.frontVector(), zeus::degToRad(x10_curRotation)).toTransform() *
xf.getRotation();
tmpXf.origin = xf.origin;
xf = tmpXf * zeus::CTransform::Translate(0.f, xc_curExtendDist, 0.f);
} else {
xf = xf * zeus::CTransform::Translate(0.f, xc_curExtendDist, 0.f);
}
switch (x20_state) {
@@ -1272,7 +1270,7 @@ void CPlayerGun::UpdateAuxWeapons(float dt, const zeus::CTransform& targetXf, CS
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
}
} else if (x833_28_phazonBeamActive) {
static_cast<CPhazonBeam*>(x72c_currentBeam)->UpdateBeam(dt, targetXf, x418_beamLocalXf.origin, mgr);
@@ -1581,7 +1579,7 @@ void CPlayerGun::UpdateWeaponFire(float dt, const CPlayerState& playerState, CSt
x2f8_stateFlags &= ~0x1;
x2f8_stateFlags |= 0x6;
x318_comboAmmoIdx = 1;
x31c_missileMode = EMissleMode::Active;
x31c_missileMode = EMissileMode::Active;
}
FireSecondary(dt, mgr);
} else {
@@ -1875,7 +1873,7 @@ void CPlayerGun::Update(float grappleSwingT, float cameraBobT, float dt, CStateM
x2f8_stateFlags &= ~0x1;
x2f8_stateFlags |= 0x6;
x318_comboAmmoIdx = 1;
x31c_missileMode = EMissleMode::Active;
x31c_missileMode = EMissileMode::Active;
break;
case ENextState::ExitMissile:
if ((x2f8_stateFlags & 0x8) != 0x8) {
@@ -1883,7 +1881,7 @@ void CPlayerGun::Update(float grappleSwingT, float cameraBobT, float dt, CStateM
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
x390_cooldown = x72c_currentBeam->GetWeaponInfo().x0_coolDown;
break;
case ENextState::MissileReload:
@@ -1905,7 +1903,7 @@ void CPlayerGun::Update(float grappleSwingT, float cameraBobT, float dt, CStateM
x2f8_stateFlags &= 0xFFE9;
}
x318_comboAmmoIdx = 0;
x31c_missileMode = EMissleMode::Inactive;
x31c_missileMode = EMissileMode::Inactive;
break;
case ENextState::EnterPhazonBeam:
if (x75c_phazonBeam->IsLoaded())
@@ -1970,7 +1968,7 @@ void CPlayerGun::Update(float grappleSwingT, float cameraBobT, float dt, CStateM
zeus::CAABox aabb = x72c_currentBeam->GetBounds().getTransformedAABox(x4a8_gunWorldXf);
mgr.BuildNearList(nearList, aabb, sAimFilter, &player);
TUniqueId bestId = kInvalidUniqueId;
zeus::CVector3f dir = x4a8_gunWorldXf.basis[1].normalized();
zeus::CVector3f dir = x4a8_gunWorldXf.frontVector().normalized();
zeus::CVector3f pos = dir * -0.5f + x4a8_gunWorldXf.origin;
CRayCastResult result = mgr.RayWorldIntersection(bestId, pos, dir, 3.5f, sAimFilter, nearList);
x833_29_pointBlankWorldSurface = result.IsValid();

View File

@@ -35,7 +35,7 @@ struct CFinalInput;
class CPlayerGun {
public:
static float skTractorBeamFactor;
enum class EMissleMode { Inactive, Active };
enum class EMissileMode { Inactive, Active };
enum class EBWeapon { Bomb, PowerBomb };
enum class EPhazonBeamState { Inactive, Entering, Exiting, Active };
enum class EChargePhase {
@@ -141,7 +141,7 @@ private:
CPlayerState::EBeamId x310_currentBeam = CPlayerState::EBeamId::Power;
CPlayerState::EBeamId x314_nextBeam = CPlayerState::EBeamId::Power;
u32 x318_comboAmmoIdx = 0;
EMissleMode x31c_missileMode = EMissleMode::Inactive;
EMissileMode x31c_missileMode = EMissileMode::Inactive;
CPlayerState::EBeamId x320_currentAuxBeam = CPlayerState::EBeamId::Power;
EIdleState x324_idleState = EIdleState::Four;
float x328_animSfxPitch = 0.f;
@@ -323,7 +323,7 @@ public:
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
void AsyncLoadSuit(CStateManager& mgr);
void TouchModel(const CStateManager& stateMgr);
EMissleMode GetMissleMode() const { return x31c_missileMode; }
EMissileMode GetMissleMode() const { return x31c_missileMode; }
bool IsFidgeting() const { return x833_24_notFidgeting; }
bool IsCharging() const { return x834_24_charging; }
float GetChargeBeamFactor() const { return x340_chargeBeamFactor; }