Lots of CPlayer implementations

This commit is contained in:
Jack Andersen 2017-06-11 18:23:34 -10:00
parent 46c70ecf11
commit 4f33422423
50 changed files with 940 additions and 245 deletions

View File

@ -13,6 +13,7 @@ struct ITweakPlayer : ITweak
virtual float GetX54() const=0;
virtual float GetX58() const=0;
virtual float GetX5C() const=0;
virtual float GetHardLandingVelocityThreshold() const=0;
virtual float GetHudLagAmount() const=0;
virtual uint32_t GetOrbitScreenBoxHalfExtentX(int zone) const=0;
virtual uint32_t GetOrbitScreenBoxHalfExtentY(int zone) const=0;
@ -22,6 +23,7 @@ struct ITweakPlayer : ITweak
virtual uint32_t GetEnemyScreenBoxCenterY(int zone) const=0;
virtual float GetOrbitNearX() const=0;
virtual float GetOrbitNearZ() const=0;
virtual float GetOrbitZRange() const=0;
virtual float GetScanningRange() const=0; // x218
virtual bool GetScanFreezesGame() const=0; // x21c_25
virtual float GetScanningFrameSenseRange() const=0;
@ -30,9 +32,10 @@ struct ITweakPlayer : ITweak
virtual bool GetX228_24() const=0; // x228_24
virtual float GetX274() const=0; // x274
virtual float GetX278() const=0; // x278
virtual float GetX27C() const=0; // x27c
virtual float GetPlayerBallHalfExtent() const=0; // x27c
virtual float GetX124() const=0; // x134
virtual float GetX184() const=0; // x184
virtual float GetX1fc() const=0;
virtual float GetX288() const=0; // x288
virtual float GetX28c() const=0; // x28c
virtual float GetX290() const=0; // x290
@ -45,6 +48,7 @@ struct ITweakPlayer : ITweak
virtual float GetX14C() const=0; // x14c
virtual float GetLeftLogicalThreshold() const=0;
virtual float GetRightLogicalThreshold() const=0;
virtual float GetX164(int type) const=0;
virtual float GetVariaDamageReduction() const=0;
virtual float GetGravityDamageReduction() const=0;
virtual float GetPhazonDamageReduction() const=0;

View File

@ -40,6 +40,7 @@ struct ITweakPlayerGun : ITweak
virtual float GetX30() const = 0; // x30
virtual float GetX34() const = 0; // x34
virtual float GetX38() const = 0; // x38
virtual float GetGunNotFiringTime() const=0;
virtual float GetRichochetDamage(atUint32) const = 0;
};
}

View File

@ -103,8 +103,8 @@ void CTweakPlayer::read(athena::io::IStreamReader& __dna_reader)
xa4_[6] = __dna_reader.readFloatBig();
/* xa4_[7] */
xa4_[7] = __dna_reader.readFloatBig();
/* xc4_ */
xc4_ = __dna_reader.readFloatBig();
/* xc4_hardLandingVelocityThreshold */
xc4_hardLandingVelocityThreshold = __dna_reader.readFloatBig();
/* xc8_ */
xc8_ = __dna_reader.readFloatBig();
/* xcc_ */
@ -325,8 +325,8 @@ void CTweakPlayer::read(athena::io::IStreamReader& __dna_reader)
x1e4_ = __dna_reader.readFloatBig();
/* x1e8_ */
x1e8_ = __dna_reader.readFloatBig();
/* x1ec_ */
x1ec_ = __dna_reader.readFloatBig();
/* x1ec_orbitZRange */
x1ec_orbitZRange = __dna_reader.readFloatBig();
/* x1f0_ */
x1f0_ = __dna_reader.readFloatBig();
/* x1f4_ */
@ -543,8 +543,8 @@ void CTweakPlayer::write(athena::io::IStreamWriter& __dna_writer) const
__dna_writer.writeFloatBig(xa4_[6]);
/* xa4_[7] */
__dna_writer.writeFloatBig(xa4_[7]);
/* xc4_ */
__dna_writer.writeFloatBig(xc4_);
/* xc4_hardLandingVelocityThreshold */
__dna_writer.writeFloatBig(xc4_hardLandingVelocityThreshold);
/* xc8_ */
__dna_writer.writeFloatBig(xc8_);
/* xcc_ */
@ -765,8 +765,8 @@ void CTweakPlayer::write(athena::io::IStreamWriter& __dna_writer) const
__dna_writer.writeFloatBig(x1e4_);
/* x1e8_ */
__dna_writer.writeFloatBig(x1e8_);
/* x1ec_ */
__dna_writer.writeFloatBig(x1ec_);
/* x1ec_orbitZRange */
__dna_writer.writeFloatBig(x1ec_orbitZRange);
/* x1f0_ */
__dna_writer.writeFloatBig(x1f0_);
/* x1f4_ */
@ -1013,8 +1013,8 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin)
/* xa4_[7] */
xa4_[7] = __dna_docin.readFloat("xa4_");
}
/* xc4_ */
xc4_ = __dna_docin.readFloat("xc4_");
/* xc4_hardLandingVelocityThreshold */
xc4_hardLandingVelocityThreshold = __dna_docin.readFloat("xc4_hardLandingVelocityThreshold");
/* xc8_ */
xc8_ = __dna_docin.readFloat("xc8_");
/* xcc_ */
@ -1280,8 +1280,8 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin)
x1e4_ = __dna_docin.readFloat("x1e4_");
/* x1e8_ */
x1e8_ = __dna_docin.readFloat("x1e8_");
/* x1ec_ */
x1ec_ = __dna_docin.readFloat("x1ec_");
/* x1ec_orbitZRange */
x1ec_orbitZRange = __dna_docin.readFloat("x1ec_orbitZRange");
/* x1f0_ */
x1f0_ = __dna_docin.readFloat("x1f0_");
/* x1f4_ */
@ -1522,8 +1522,8 @@ void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout)
/* xa4_[7] */
__dna_docout.writeFloat("xa4_", xa4_[7]);
}
/* xc4_ */
__dna_docout.writeFloat("xc4_", xc4_);
/* xc4_hardLandingVelocityThreshold */
__dna_docout.writeFloat("xc4_hardLandingVelocityThreshold", xc4_hardLandingVelocityThreshold);
/* xc8_ */
__dna_docout.writeFloat("xc8_", xc8_);
/* xcc_ */
@ -1780,8 +1780,8 @@ void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout)
__dna_docout.writeFloat("x1e4_", x1e4_);
/* x1e8_ */
__dna_docout.writeFloat("x1e8_", x1e8_);
/* x1ec_ */
__dna_docout.writeFloat("x1ec_", x1ec_);
/* x1ec_orbitZRange */
__dna_docout.writeFloat("x1ec_orbitZRange", x1ec_orbitZRange);
/* x1f0_ */
__dna_docout.writeFloat("x1f0_", x1f0_);
/* x1f4_ */

View File

@ -17,7 +17,7 @@ struct CTweakPlayer : ITweakPlayer
Value<float> x64_[8];
Value<float> x84_[8];
Value<float> xa4_[8];
Value<float> xc4_;
Value<float> xc4_hardLandingVelocityThreshold;
Value<float> xc8_;
Value<float> xcc_;
Value<float> xd0_;
@ -79,7 +79,7 @@ struct CTweakPlayer : ITweakPlayer
Value<float> x1e0_;
Value<float> x1e4_;
Value<float> x1e8_;
Value<float> x1ec_;
Value<float> x1ec_orbitZRange;
Value<float> x1f0_;
Value<float> x1f4_;
Value<float> x1f8_;
@ -179,6 +179,7 @@ struct CTweakPlayer : ITweakPlayer
float GetX54() const { return x44_[4]; }
float GetX58() const { return x44_[5]; }
float GetX5C() const { return x44_[6]; }
float GetHardLandingVelocityThreshold() const { return xc4_hardLandingVelocityThreshold; }
float GetHudLagAmount() const { return x138_hudLagAmount; }
uint32_t GetOrbitScreenBoxHalfExtentX(int zone) const { return x1a8_orbitScreenBoxHalfExtentX[zone]; }
uint32_t GetOrbitScreenBoxHalfExtentY(int zone) const { return x1b0_orbitScreenBoxHalfExtentY[zone]; }
@ -188,6 +189,7 @@ struct CTweakPlayer : ITweakPlayer
uint32_t GetEnemyScreenBoxCenterY(int zone) const { return x1d0_enemyScreenBoxCenterY[zone]; }
float GetOrbitNearX() const { return x1d8_orbitNearX; }
float GetOrbitNearZ() const { return x1dc_orbitNearZ; }
float GetOrbitZRange() const { return x1ec_orbitZRange; }
float GetScanningRange() const { return x218_scanningRange; }
bool GetScanFreezesGame() const { return x21c_25_scanFreezesGame; }
float GetScanningFrameSenseRange() const { return x224_scanningFrameSenseRange; }
@ -195,9 +197,10 @@ struct CTweakPlayer : ITweakPlayer
float GetPlayerXYHalfExtent() const { return x270_playerXYHalfExtent; }
float GetX274() const { return x274_; }
float GetX278() const { return x278_; }
float GetX27C() const { return x27c_playerBallHalfExtent; }
float GetPlayerBallHalfExtent() const { return x27c_playerBallHalfExtent; }
float GetX124() const { return x134_; }
float GetX184() const { return x184_; }
float GetX1fc() const { return x1fc_; }
bool GetX228_24() const { return x228_24_; }
float GetX288() const { return x288_; }
float GetX28c() const { return x28c_; }
@ -211,6 +214,7 @@ struct CTweakPlayer : ITweakPlayer
float GetX14C() const { return x14c_; }
float GetLeftLogicalThreshold() const { return x150_leftDiv; }
float GetRightLogicalThreshold() const { return x154_rightDiv; }
float GetX164(int type) const { return x164_[type]; }
float GetVariaDamageReduction() const { return x300_variaDamageReduction; }
float GetGravityDamageReduction() const { return x304_gravityDamageReduction; }
float GetPhazonDamageReduction() const { return x308_phazonDamageReduction; }

View File

@ -26,7 +26,7 @@ struct CTweakPlayerGun : ITweakPlayerGun
Value<float> x34_;
Value<float> x38_;
Value<float> x3c_;
Value<float> x40_;
Value<float> x40_gunNotFiringTime;
Value<float> x44_;
Value<float> x48_;
Value<zeus::CVector3f> x4c_;
@ -59,6 +59,7 @@ struct CTweakPlayerGun : ITweakPlayerGun
float GetX30() const { return x30_; }
float GetX34() const { return x34_; }
float GetX38() const { return x38_; }
float GetGunNotFiringTime() const { return x40_gunNotFiringTime; }
float GetRichochetDamage(atUint32 type) const
{
switch (type)

View File

@ -384,6 +384,13 @@ CSfxHandle CSfxManager::SfxStart(u16 id, float vol, float pan, bool useAcoustics
return wrapper;
}
bool CSfxManager::IsPlaying(const CSfxHandle& handle)
{
if (!handle)
return false;
return handle->IsPlaying();
}
void CSfxManager::RemoveEmitter(const CSfxHandle& handle)
{
StopSound(handle);

View File

@ -220,6 +220,7 @@ public:
static u16 TranslateSFXID(u16);
static void SfxStop(const CSfxHandle& handle);
static CSfxHandle SfxStart(u16 id, float vol, float pan, bool useAcoustics, s16 prio, bool looped, s32 areaId);
static bool IsPlaying(const CSfxHandle& handle);
static void RemoveEmitter(const CSfxHandle& handle);
static void UpdateEmitter(const CSfxHandle& handle, const zeus::CVector3f& pos, const zeus::CVector3f& dir,
float maxVol);

View File

@ -86,7 +86,7 @@ add_library(RuntimeCommon
CSimplePool.hpp CSimplePool.cpp
CGameOptions.hpp CGameOptions.cpp
CGameOptionsTouchBar.hpp CGameOptionsTouchBar.cpp
CStaticInterference.hpp
CStaticInterference.hpp CStaticInterference.cpp
CCRC32.hpp CCRC32.cpp
IFactory.hpp
IObjFactory.hpp

View File

@ -174,7 +174,7 @@ public:
bool IsPlayerAlive() const { return x0_24_alive; }
void SetPlayerAlive(bool alive) { x0_24_alive = alive; }
void InitializeScanTimes();
const CStaticInterference& GetStaticInterference() const { return x188_staticIntf; }
CStaticInterference& GetStaticInterference() { return x188_staticIntf; }
const rstl::reserved_vector<std::pair<ResId, float>, 846>& GetScanTimes() const { return x170_scanTimes; }
CPlayerState();
CPlayerState(CBitStreamReader& stream);

View File

@ -1310,8 +1310,10 @@ void CStateManager::KnockBackPlayer(CPlayer& player, const zeus::CVector3f& pos,
if (player.GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Morphed)
{
usePower = power * 1000.f;
u32 something = player.x2b0_ == 2 ? player.x2ac_ : 4;
if (something != 0 && player.GetOrbitState() == CPlayer::EPlayerOrbitState::Zero)
CPlayer::EPlayerMovementSurface surface =
player.x2b0_ == 2 ? player.x2ac_movementSurface : CPlayer::EPlayerMovementSurface::Four;
if (surface != CPlayer::EPlayerMovementSurface::Normal &&
player.GetOrbitState() == CPlayer::EPlayerOrbitState::Zero)
usePower /= 7.f;
}
else
@ -1442,7 +1444,7 @@ void CStateManager::ApplyRadiusDamage(const CActor& a1, const zeus::CVector3f& p
if (dam > 0.f)
ApplyLocalDamage(pos, delta, a2, dam, info.GetWeaponMode());
a2.SendScriptMsgs(EScriptObjectState::Damage, *this, EScriptObjectMessage::None);
SendScriptMsg(&a2, a1.GetUniqueId(), EScriptObjectMessage::InternalMessage19);
SendScriptMsg(&a2, a1.GetUniqueId(), EScriptObjectMessage::Damage);
}
else
{
@ -1692,7 +1694,7 @@ bool CStateManager::ApplyDamage(TUniqueId id0, TUniqueId id1, TUniqueId id2,
if (info.GetDamage() > 0.f)
ApplyLocalDamage(position, direction, *act1, info.GetDamage(), info.GetWeaponMode());
act1->SendScriptMsgs(EScriptObjectState::Damage, *this, EScriptObjectMessage::None);
SendScriptMsg(act1.GetPtr(), id0, EScriptObjectMessage::InternalMessage19);
SendScriptMsg(act1.GetPtr(), id0, EScriptObjectMessage::Damage);
}
else
{
@ -2225,7 +2227,7 @@ void CStateManager::CreateStandardGameObjects()
float xyHe = g_tweakPlayer->GetPlayerXYHalfExtent();
float unk1 = g_tweakPlayer->GetX274();
float unk2 = g_tweakPlayer->GetX278();
float unk3 = g_tweakPlayer->GetX27C();
float unk3 = g_tweakPlayer->GetPlayerBallHalfExtent();
zeus::CAABox pBounds = {{-xyHe, -xyHe, 0.f}, {xyHe, xyHe, height}};
auto q = zeus::CQuaternion::fromAxisAngle(zeus::CVector3f{0.f, 0.f, 1.f}, zeus::degToRad(129.6f));
x84c_player.reset(new CPlayer(

View File

@ -0,0 +1,70 @@
#include "CStaticInterference.hpp"
namespace urde
{
CStaticInterference::CStaticInterference(int sourceCount)
{
m_sources.reserve(sourceCount);
}
void CStaticInterference::RemoveSource(TUniqueId id)
{
auto iter = std::find_if(m_sources.begin(), m_sources.end(),
[id](const CStaticInterferenceSource& src)->bool{
return src.id == id;
});
if (iter != m_sources.end())
m_sources.erase(iter);
}
void CStaticInterference::Update(CStateManager&, float dt)
{
std::vector<CStaticInterferenceSource> newSources;
newSources.reserve(m_sources.size());
for (CStaticInterferenceSource& src : m_sources)
{
if (src.timeLeft >= 0.0)
{
src.timeLeft -= dt;
newSources.push_back(src);
}
}
m_sources = std::move(newSources);
}
float CStaticInterference::GetTotalInterference() const
{
float validAccum = 0.0;
float invalidAccum = 0.0;
for (const CStaticInterferenceSource& src : m_sources)
{
if (src.id == kInvalidUniqueId)
invalidAccum += src.magnitude;
else
validAccum += src.magnitude;
}
if (validAccum > 0.80000001)
validAccum = 0.80000001;
validAccum += invalidAccum;
if (validAccum > 1.0)
return 1.0;
return validAccum;
}
void CStaticInterference::AddSource(TUniqueId id, float magnitude, float duration)
{
magnitude = zeus::clamp(0.f, magnitude, 1.f);
auto search = std::find_if(m_sources.begin(), m_sources.end(),
[id](CStaticInterferenceSource& source) { return source.id == id; });
if (search != m_sources.end())
{
search->magnitude = magnitude;
search->timeLeft = duration;
return;
}
if (m_sources.size() < m_sources.capacity())
m_sources.push_back({id, magnitude, duration});
}
}

View File

@ -19,66 +19,11 @@ class CStaticInterference
{
std::vector<CStaticInterferenceSource> m_sources;
public:
CStaticInterference(int sourceCount)
{
m_sources.reserve(sourceCount);
}
void AddSource(TUniqueId id, float magnitude, float duration)
{
for (CStaticInterferenceSource& src : m_sources)
{
if (src.id == id)
{
src.magnitude = magnitude;
src.timeLeft = duration;
return;
}
}
m_sources.push_back({id, magnitude, duration});
}
void RemoveSource(TUniqueId id)
{
auto iter = std::find_if(m_sources.begin(), m_sources.end(), [&id](const CStaticInterferenceSource& src)->bool{
return src.id == id;
});
if (iter != m_sources.end())
m_sources.erase(iter);
}
void Update(CStateManager&, float dt)
{
std::vector<CStaticInterferenceSource> newSources;
newSources.reserve(m_sources.size());
for (CStaticInterferenceSource& src : m_sources)
{
if (src.timeLeft >= 0.0)
{
src.timeLeft -= dt;
newSources.push_back(src);
}
}
m_sources = std::move(newSources);
}
float GetTotalInterference() const
{
float validAccum = 0.0;
float invalidAccum = 0.0;
for (const CStaticInterferenceSource& src : m_sources)
{
if (src.id == kInvalidUniqueId)
invalidAccum += src.magnitude;
else
validAccum += src.magnitude;
}
if (validAccum > 0.80000001)
validAccum = 0.80000001;
validAccum += invalidAccum;
if (validAccum > 1.0)
return 1.0;
return validAccum;
}
CStaticInterference(int sourceCount);
void RemoveSource(TUniqueId id);
void Update(CStateManager&, float dt);
float GetTotalInterference() const;
void AddSource(TUniqueId id, float magnitude, float duration);
};
}

View File

@ -36,6 +36,28 @@ CCameraShakeData::CCameraShakeData(float f1, float f2)
SCameraShakePoint{1, 0.f, 0.f, 0.5f * f1, 2.f}})
{}
CCameraShakeData CCameraShakeData::BuildLandingCameraShakeData(float f1, float f2)
{
return CCameraShakeData(f1, 100.f, 0, zeus::CVector3f::skZero,
CCameraShakerComponent(1,
SCameraShakePoint(0, 0.15f * f1, 0.f, 0.85f * f1, f2),
SCameraShakePoint(1, 0.f, 0.f, 0.4f * f1, 1.5f)),
CCameraShakerComponent(),
CCameraShakerComponent(1,
SCameraShakePoint(0, 0.25f * f1, 0.f, 0.75f * f1, f2),
SCameraShakePoint(1, 0.f, 0.f, 0.5f * f1, 2.f)));
}
CCameraShakeData CCameraShakeData::BuildProjectileCameraShake(float f1, float f2)
{
return CCameraShakeData(f1, 100.f, 0, zeus::CVector3f::skZero,
CCameraShakerComponent(1,
SCameraShakePoint(0, 0.f, 0.f, f1, f2),
SCameraShakePoint(1, 0.f, 0.f, 0.5f * f1, 3.f)),
CCameraShakerComponent(),
CCameraShakerComponent());
}
float CCameraShakeData::GetSomething() const
{
float ret = 0.f;

View File

@ -55,6 +55,8 @@ public:
const CCameraShakerComponent& shaker1, const CCameraShakerComponent& shaker2,
const CCameraShakerComponent& shaker3);
CCameraShakeData(float f1, float f2);
static CCameraShakeData BuildLandingCameraShakeData(float f1, float f2);
static CCameraShakeData BuildProjectileCameraShake(float f1, float f2);
//zeus::CVector3f GeneratePoint(float dt, CRandom16& r);
float GetSomething() const;
float GetSomething2() const;

View File

@ -110,10 +110,10 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
if (player->GetOrbitState() == CPlayer::EPlayerOrbitState::Four ||
player->GetOrbitState() == CPlayer::EPlayerOrbitState::One)
{
const CActor* act = TCastToConstPtr<CActor>(mgr.GetObjectById(player->x310_lockonObjectId));
const CActor* act = TCastToConstPtr<CActor>(mgr.GetObjectById(player->x310_orbitTargetId));
if (act && act->GetMaterialList().Intersection(CMaterialList(EMaterialTypes::Lava)) != 0)
{
zeus::CVector3f v = player->x318_ - eyePos;
zeus::CVector3f v = player->x314_orbitPoint.y - eyePos;
if (v.canBeNormalized())
v.normalize();
@ -174,7 +174,7 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
qGun = zeus::CQuaternion::lookAt(rVec, gunFrontVec, scaledDt * clampedAngle);
const CScriptGrapplePoint* gPoint =
TCastToConstPtr<CScriptGrapplePoint>(mgr.GetObjectById(player->x310_lockonObjectId));
TCastToConstPtr<CScriptGrapplePoint>(mgr.GetObjectById(player->x310_orbitTargetId));
if (gPoint && player->x29c_ > 0.f)
{
gunFrontVec = x190_gunFollowXf.frontVector();

View File

@ -29,12 +29,12 @@ CGameCamera::CGameCamera(TUniqueId uid, bool active, const std::string& name, co
void CGameCamera::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
{
if (msg == EScriptObjectMessage::InternalMessage15)
if (msg == EScriptObjectMessage::UpdateSplashInhabitant)
{
mgr.GetCameraManager()->SetInsideFluid(true, uid);
return;
}
else if (msg == EScriptObjectMessage::InternalMessage17)
else if (msg == EScriptObjectMessage::RemoveSplashInhabitant)
{
mgr.GetCameraManager()->SetInsideFluid(false, kInvalidUniqueId);
return;

View File

@ -74,7 +74,7 @@ void CCollisionActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, C
case EScriptObjectMessage::InitializedInArea:
break;
case EScriptObjectMessage::Alert:
case EScriptObjectMessage::InternalMessage10:
case EScriptObjectMessage::LandOnNotFloor:
case EScriptObjectMessage::Registered:
{
CEntity* ent = mgr.ObjectById(x25c_owner);

View File

@ -75,11 +75,11 @@ void CGameCollision::SendMaterialMessage(CStateManager& mgr, const CMaterialList
{
EScriptObjectMessage msg;
if (mat.HasMaterial(EMaterialTypes::Ice))
msg = EScriptObjectMessage::InternalMessage05;
msg = EScriptObjectMessage::OnIceSurface;
else if (mat.HasMaterial(EMaterialTypes::MudSlow))
msg = EScriptObjectMessage::InternalMessage06;
msg = EScriptObjectMessage::OnMudSlowSurface;
else
msg = EScriptObjectMessage::InternalMessage07;
msg = EScriptObjectMessage::OnNormalSurface;
mgr.SendScriptMsg(&act, kInvalidUniqueId, msg);
}

View File

@ -40,6 +40,7 @@ public:
void MakeInvalid();
bool IsInvalid() const { return x20_invalid == EInvalid::Invalid; }
bool IsValid() const { return x20_invalid == EInvalid::Valid; }
float GetT() const { return x0_t; }
const zeus::CVector3f& GetPoint() const { return x4_point; }
const zeus::CPlane& GetPlane() const { return x10_plane; }

View File

@ -271,9 +271,9 @@ void CHudDecoInterfaceScan::UpdateScanDisplay(const CStateManager& stateMgr, flo
if (player.GetScanningObjectId() != x1d2_latestScanningObject)
x1d2_latestScanningObject = player.GetScanningObjectId();
if (player.GetLockonObjectId() != x1d0_latestHudPoi)
if (player.GetOrbitTargetId() != x1d0_latestHudPoi)
{
x1d0_latestHudPoi = player.GetLockonObjectId();
x1d0_latestHudPoi = player.GetOrbitTargetId();
if (x1d0_latestHudPoi != kInvalidUniqueId)
{
if (!player.ObjectInScanningRange(x1d0_latestHudPoi, stateMgr))
@ -611,7 +611,7 @@ void CHudDecoInterfaceThermal::SetDamageTransform(const zeus::CMatrix3f& rotatio
void CHudDecoInterfaceThermal::Update(float dt, const CStateManager& stateMgr)
{
float oldLockonScale = x68_lockonScale;
if (stateMgr.GetPlayer().GetLockonObjectId() != kInvalidUniqueId)
if (stateMgr.GetPlayer().GetOrbitTargetId() != kInvalidUniqueId)
x68_lockonScale = std::max(x68_lockonScale - 15.f * dt, 1.f);
else
x68_lockonScale = std::min(x68_lockonScale + 15.f * dt, 5.f);

View File

@ -8,7 +8,8 @@ namespace urde
enum class ERumbleFxId
{
Seven = 7,
Eleven = 11
Eleven = 11,
Fifteen = 15
};
enum class ERumblePriority
{

View File

@ -135,7 +135,7 @@ bool CPlayerVisor::DrawScanObjectIndicators(const CStateManager& mgr) const
else
{
float tmp = 1.f;
if (mgr.GetPlayer().GetLockonObjectId() == tgt.x0_objId)
if (mgr.GetPlayer().GetOrbitTargetId() == tgt.x0_objId)
tmp = 0.75f * x2c_scanDimInterp + 0.25f;
iconAlpha = tgt.x4_timer * tmp;
}

View File

@ -141,7 +141,7 @@ void CSamusHud::InitializeFrameGlueMutable(const CStateManager& mgr)
CPlayerGun& gun = *player.GetPlayerGun();
float chargeFactor = gun.IsCharging() ? gun.GetChargeBeamFactor() : 0.f;
bool missilesActive = gun.GetMissleMode() == CPlayerGun::EMissleMode::Active;
bool lockedOnObj = player.GetLockonObjectId() != kInvalidUniqueId;
bool lockedOnObj = player.GetOrbitTargetId() != kInvalidUniqueId;
switch (x2bc_nextState)
{
@ -501,7 +501,7 @@ void CSamusHud::UpdateFreeLook(float dt, const CStateManager& mgr)
if (x298_freeLookIntf)
x298_freeLookIntf->SetFreeLookState(inFreeLook, lookControlHeld,
player.GetLockonObjectId() != kInvalidUniqueId,
player.GetOrbitTargetId() != kInvalidUniqueId,
offHorizonAngle);
if (x564_freeLookSfx)

View File

@ -12,7 +12,7 @@ CBeetle::CBeetle(TUniqueId uid, const std::string& name, const CEntityInfo& info
const CPatternedInfo& pInfo, CPatterned::EFlavorType flavor, CBeetle::EEntranceType, const CDamageInfo&,
const CDamageVulnerability&, const zeus::CVector3f&, float, float, float, const CDamageVulnerability&,
const CActorParameters& aParams, const rstl::optional_object<CStaticRes>)
: CPatterned(EUnknown::Three, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Ground,
: CPatterned(ECharacter::Beetle, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Ground,
EColliderType::One, EBodyType::One, aParams, bool(flavor))
{

View File

@ -5,6 +5,7 @@ set(MP1_WORLD_SOURCES
CSpacePirate.hpp CSpacePirate.cpp
CBabygoth.hpp CBabygoth.cpp
CMetroidPrimeRelay.hpp CMetroidPrimeRelay.cpp
CActorContraption.hpp CActorContraption.cpp)
CActorContraption.hpp CActorContraption.cpp
CThardusRockProjectile.hpp CThardusRockProjectile.cpp)
runtime_add_list(World MP1_WORLD_SOURCES)

View File

@ -11,7 +11,7 @@ CNewIntroBoss::CNewIntroBoss(TUniqueId uid, const std::string& name, const CEnti
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo,
const CActorParameters& actParms, float, u32, const CDamageInfo& dInfo,
u32, u32, u32, u32)
: CPatterned(EUnknown::TwentyThree, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo,
: CPatterned(ECharacter::NewIntroBoss, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo,
EMovementType::Flyer, EColliderType::One, EBodyType::Two, actParms, true)
{
}

View File

@ -9,7 +9,7 @@ namespace MP1
CSpacePirate::CSpacePirate(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const CActorParameters& aParams, const CPatternedInfo& pInfo, CInputStream& in,
u32 propCount)
: CPatterned(EUnknown::ThirtyFour, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo, EMovementType::Ground,
: CPatterned(ECharacter::SpacePirate, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo, EMovementType::Ground,
EColliderType::One, EBodyType::One, aParams, true)
{
}

View File

@ -0,0 +1,16 @@
#include "CThardusRockProjectile.hpp"
namespace urde
{
CThardusRockProjectile::CThardusRockProjectile(
TUniqueId uid, const std::string& name, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& modelData, const CActorParameters& aParms,
const CPatternedInfo& patternedInfo, const std::vector<CModelData>& mDataVec, u32)
: CPatterned(ECharacter::ThardusRockProjectile, uid, name, EFlavorType::Zero, info, xf, std::move(modelData),
patternedInfo, EMovementType::Flyer, EColliderType::One, EBodyType::Three, aParms, true)
{
}
}

View File

@ -0,0 +1,20 @@
#ifndef __URDE_MP1_CTHARDUSROCKPROJECTILE_HPP__
#define __URDE_MP1_CTHARDUSROCKPROJECTILE_HPP__
#include "World/CPatterned.hpp"
namespace urde
{
class CThardusRockProjectile : public CPatterned
{
public:
static constexpr ECharacter CharacterType = ECharacter::ThardusRockProjectile;
CThardusRockProjectile(TUniqueId uid, const std::string& name, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& modelData, const CActorParameters& aParms,
const CPatternedInfo& patternedInfo, const std::vector<CModelData>& mDataVec, u32);
};
}
#endif // __URDE_MP1_CTHARDUSROCKPROJECTILE_HPP__

View File

@ -10,7 +10,7 @@ CWarWasp::CWarWasp(TUniqueId uid, const std::string& name, const CEntityInfo& in
CModelData&& mData, const CPatternedInfo& pInfo, CPatterned::EFlavorType flavor,
CPatterned::EColliderType collider, const CDamageInfo& dInfo1, const CActorParameters& actorParms,
ResId weapon, const CDamageInfo& dInfo2, ResId particle, u32 w3)
: CPatterned(EUnknown::ThirtyNine, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Flyer, collider,
: CPatterned(ECharacter::WarWasp, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Flyer, collider,
EBodyType::Three, actorParms, false)
{
}

View File

@ -30,6 +30,7 @@ CENTITY_TYPES = (
EndNamespace(),
('CPathCamera', 'Camera/CPathCamera.hpp'),
('CAi', 'World/CAi.hpp'),
('CPatterned', 'World/CPatterned.hpp'),
('CPhysicsActor', 'World/CPhysicsActor.hpp'),
('CPlayer', 'World/CPhysicsActor.hpp'),
('CRepulsor', 'World/CRepulsor.hpp'),

View File

@ -0,0 +1,20 @@
#include "CEnergyProjectile.hpp"
namespace urde
{
CEnergyProjectile::CEnergyProjectile(bool active, const TToken<CWeaponDescription>& desc, EWeaponType type,
const zeus::CTransform& xf, EMaterialTypes materials, const CDamageInfo& damage,
TUniqueId id0, TAreaId aid, TUniqueId id1, TUniqueId id2, u32 w1, bool b1,
const zeus::CVector3f& scale,
const rstl::optional_object<TLockedToken<CGenDescription>>& particle,
s16 w2, bool b2)
: CGameProjectile(active, desc, "GameProjectile", type, xf, materials, damage, id0, aid,
id1, id2, w1, b1, scale, particle, w2, b2),
x2ec_dir(xf.basis[1]), x2f8_mag(x2ec_dir.magnitude()),
x2fc_camShake(CCameraShakeData::BuildProjectileCameraShake(0.5f, 0.75f))
{
xe6_27_ = 2;
}
}

View File

@ -0,0 +1,39 @@
#ifndef __URDE_CENERGYPROJECTILE_HPP__
#define __URDE_CENERGYPROJECTILE_HPP__
#include "CGameProjectile.hpp"
#include "Camera/CCameraShakeData.hpp"
namespace urde
{
class CEnergyProjectile : public CGameProjectile
{
u32 x2e8_ = 0;
zeus::CVector3f x2ec_dir;
float x2f8_mag;
CCameraShakeData x2fc_camShake;
union
{
struct
{
bool x3d0_24_ : 1;
bool x3d0_25_ : 1;
bool x3d0_26_ : 1;
bool x3d0_27_ : 1;
};
u32 _dummy = 0;
};
float x3d4_ = 0.f;
public:
CEnergyProjectile(bool active, const TToken<CWeaponDescription>& desc, EWeaponType type,
const zeus::CTransform& xf, EMaterialTypes materials, const CDamageInfo& damage,
TUniqueId id0, TAreaId aid, TUniqueId id1, TUniqueId id2, u32 w1, bool b1,
const zeus::CVector3f& scale,
const rstl::optional_object<TLockedToken<CGenDescription>>& particle,
s16 w2, bool b2);
};
}
#endif // __URDE_CENERGYPROJECTILE_HPP__

View File

@ -23,7 +23,7 @@ void CGameProjectile::Accept(urde::IVisitor& visitor) { visitor.Visit(this); }
void CGameProjectile::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId /*uid*/, CStateManager& mgr)
{
if (msg == EScriptObjectMessage::InternalMessage15)
if (msg == EScriptObjectMessage::UpdateSplashInhabitant)
{
if (!x2e4_27_)
{
@ -31,12 +31,12 @@ void CGameProjectile::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId /*uid*
x2e4_26_ = true;
}
}
else if (msg == EScriptObjectMessage::InternalMessage16)
else if (msg == EScriptObjectMessage::UpdateSplashInhabitant)
{
if (!x2e4_26_)
x2e4_26_ = true;
}
else if (msg == EScriptObjectMessage::InternalMessage17)
else if (msg == EScriptObjectMessage::RemoveSplashInhabitant)
{
if (x2e4_26_)
{

View File

@ -24,6 +24,11 @@ CPlayerGun::CPlayerGun(TUniqueId id)
/* TODO: Finish */
}
void CPlayerGun::AcceptScriptMessage(EScriptObjectMessage, TUniqueId, CStateManager&)
{
}
void CPlayerGun::AsyncLoadSuit(CStateManager& mgr)
{
x72c_currentBeam->AsyncLoadSuitArm(mgr);

View File

@ -18,6 +18,7 @@
#include "Particle/CElementGen.hpp"
#include "Character/CModelData.hpp"
#include "World/CWorldShadow.hpp"
#include "World/ScriptObjectSupport.hpp"
namespace urde
{
@ -206,6 +207,7 @@ private:
public:
CPlayerGun(TUniqueId id);
void AcceptScriptMessage(EScriptObjectMessage, TUniqueId, CStateManager&);
void AsyncLoadSuit(CStateManager& mgr);
void TouchModel(CStateManager& stateMgr);
EMissleMode GetMissleMode() const { return x31c_missileMode; }

View File

@ -21,6 +21,7 @@ public:
Unknown1 = (1 << 7),
Bombs = (1 << 8),
PowerBombs = (1 << 9),
StaticInterference = (1 << 14),
};
private:
@ -35,7 +36,7 @@ private:
float x148_;
float x14c_;
float x150_;
float x154_;
float x154_interferenceDuration;
public:
CWeapon(TUniqueId, TAreaId, bool, TUniqueId, EWeaponType, const std::string&, const zeus::CTransform&,
const CMaterialFilter&, const CMaterialList&, const CDamageInfo&, EProjectileAttrib, CModelData&&);
@ -51,6 +52,7 @@ public:
const CDamageInfo& GetDamageInfo() const;
CDamageInfo& DamageInfo();
void SetDamageInfo(const CDamageInfo&);
float GetInterferenceDuration() const { return x154_interferenceDuration; }
void Think(float, CStateManager &) {}
void Render(const CStateManager&) const {}

View File

@ -81,10 +81,10 @@ void CActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMana
}
}
break;
case EScriptObjectMessage::InternalMessage15: // 37
case EScriptObjectMessage::UpdateSplashInhabitant: // 37
SetInFluid(true, uid);
break;
case EScriptObjectMessage::InternalMessage17: // 39
case EScriptObjectMessage::RemoveSplashInhabitant: // 39
SetInFluid(false, kInvalidUniqueId);
break;
default:
@ -251,16 +251,16 @@ void CActor::SetInFluid(bool in, TUniqueId uid)
{
if (in)
{
xe6_26_inFluid = false;
xe6_24_fluidCounter += 1;
xc4_fluidId = uid;
}
else
{
if (!xe6_26_inFluid)
if (!xe6_24_fluidCounter)
return;
xe6_26_inFluid = true;
if (xe6_26_inFluid == 0)
xe6_24_fluidCounter -= 1;
if (xe6_24_fluidCounter == 0)
xc4_fluidId = kInvalidUniqueId;
}
}

View File

@ -63,7 +63,7 @@ protected:
bool xe5_26_muted : 1;
bool xe5_27_useInSortedLists : 1;
bool xe5_28_callTouch : 1;
bool xe6_26_inFluid : 1;
u8 xe6_24_fluidCounter : 3;
u8 xe6_27_ : 3;
bool xe6_30_enablePitchBend : 1;
bool xe7_29_ : 1;

View File

@ -26,7 +26,7 @@ private:
u32 x8_;
u32 xc_;
float x40_;
EFluidType x44_;
EFluidType x44_fluidType;
float x48_;
public:
CFluidPlane(u32, u32, u32, EFluidType, float, const CFluidUVMotion&, float);
@ -35,7 +35,7 @@ public:
CScriptWater& water, CStateManager& mgr);
virtual void Update();
float GetAlpha() const;
EFluidType GetFluidType() const;
EFluidType GetFluidType() const { return x44_fluidType; }
const CFluidUVMotion& GetUVMotion() const;
void GetColorTexture() const;
bool HasColorTexture() const;

View File

@ -11,6 +11,11 @@ CMorphBall::CMorphBall(CPlayer& player, float)
{
}
void CMorphBall::AcceptScriptMessage(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr)
{
}
void CMorphBall::DrawBallShadow(const CStateManager& mgr)
{
if (!x1e50_shadow)

View File

@ -31,11 +31,13 @@ public:
};
private:
CPlayer& x0_player;
u32 x187c_ = 0;
float x1DE8_boostTime = 0.f;
CMorphBallShadow* x1e50_shadow = nullptr;
public:
CMorphBall(CPlayer& player, float);
void AcceptScriptMessage(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr);
ESpiderBallState GetSpiderBallState() const { return ESpiderBallState::Zero; }
bool InSpiderBallMode() const { return false; }
zeus::CVector3f GetBallContactSurfaceNormal() const { return {}; }
@ -49,7 +51,7 @@ public:
float GetBallRadius() const { return 0.f; }
float GetBallTouchRadius() const { return 0.f; }
void ForwardInput(const CFinalInput&) const {}
void ComputBallMovement(const CFinalInput&, CStateManager&, float) {}
void ComputeBallMovement(const CFinalInput&, CStateManager&, float) {}
bool IsMovementAllowed() const { return false; }
void UpdateSpiderBall(const CFinalInput&, CStateManager&, float) {}
void ApplySpiderBallSwingingForces(const CFinalInput&, CStateManager&, float) {}
@ -101,7 +103,7 @@ public:
void IsMorphBallTransitionFlashValid() const {}
void RenderDamageEffects(const CStateManager&, const zeus::CTransform&) const {}
void UpdateHalfPipeStatus(CStateManager&, float) {}
void GetIsInHalfPipeMode() const {}
bool GetIsInHalfPipeMode() const { return false; }
void SetIsInHalfPipeMode(bool) {}
void GetIsInHalfPipeModeInAir() const {}
void SetIsInHalfPipeModeInAir(bool) {}
@ -132,6 +134,8 @@ public:
void LoadAnimationTokens(const std::string&) {}
void TakeDamage(float) {}
void DrawBallShadow(const CStateManager& mgr);
void StartLandingSfx() {}
bool GetX187c() const { return x187c_; }
};
}

View File

@ -11,7 +11,7 @@ CMaterialList gkPatternedGroundMaterialList(EMaterialTypes::Character, EMaterial
CMaterialList gkPatternedFlyerMaterialList(EMaterialTypes::Character, EMaterialTypes::Solid,
EMaterialTypes::Orbit, EMaterialTypes::Target);
CPatterned::CPatterned(EUnknown, TUniqueId uid, const std::string& name, CPatterned::EFlavorType flavor,
CPatterned::CPatterned(ECharacter character, TUniqueId uid, const std::string& name, CPatterned::EFlavorType flavor,
const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData,
const CPatternedInfo& pInfo, CPatterned::EMovementType moveType, CPatterned::EColliderType,
EBodyType, const CActorParameters& actorParms, bool)
@ -21,7 +21,8 @@ CPatterned::CPatterned(EUnknown, TUniqueId uid, const std::string& name, CPatter
zeus::CVector3f{pInfo.xc4_halfExtent, pInfo.xc4_halfExtent, pInfo.xc8_height}),
pInfo.x0_mass, pInfo.x54_healthInfo, pInfo.x5c_damageVulnerability,
moveType == EMovementType::Flyer ? gkPatternedFlyerMaterialList : gkPatternedGroundMaterialList,
pInfo.xfc_stateMachineId, actorParms, pInfo.xd8_stepUpHeight, 0.8f)
pInfo.xfc_stateMachineId, actorParms, pInfo.xd8_stepUpHeight, 0.8f),
x34c_character(character)
{
}

View File

@ -3,6 +3,7 @@
#include "CAi.hpp"
#include "Character/CBodyController.hpp"
#include "TCastTo.hpp"
namespace urde
{
@ -11,13 +12,47 @@ class CPatternedInfo;
class CPatterned : public CAi
{
public:
enum class EUnknown
enum class ECharacter
{
Zero = 0,
Three = 3,
TwentyThree = 23,
ThirtyFour = 34,
ThirtyNine
AtomicAlpha = 0,
AtomicBeta = 1,
Babygoth = 2,
Beetle = 3,
BloodFlower = 4,
Burrower = 5,
ChozoGhost = 6,
Drone = 7,
ElitePirate = 8,
EyeBall = 9,
FireFlea = 10,
Flaahgra = 11,
FlaahgraTentacle = 12,
FlickerBat = 13,
FlyingPirate = 14,
IceSheeegoth = 15,
JellyZap = 16,
Magdolite = 17,
Metaree = 18,
Metroid = 19,
MetroidBeta = 20,
MetroidPrimeExo = 21,
MetroidPrimeEssence = 22,
NewIntroBoss = 23,
Parasite = 24,
PuddleSpore = 27,
PuddleToad = 28,
Puffer = 29,
Ridley = 30,
Ripper = 31,
Seedling = 32,
SpacePirate = 34,
SpankWeed = 35,
PhazonHealingNodule = 35,
Thardus = 36,
ThardusRockProjectile = 37,
Tryclops = 38,
WarWasp = 39,
EnergyBall = 40
};
enum class EFlavorType
{
@ -35,14 +70,33 @@ public:
};
private:
ECharacter x34c_character;
public:
CPatterned(EUnknown unk, TUniqueId uid, const std::string& name, EFlavorType flavor, const CEntityInfo& info,
CPatterned(ECharacter character, TUniqueId uid, const std::string& name, EFlavorType flavor, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pinfo,
CPatterned::EMovementType movement, EColliderType collider, EBodyType body,
const CActorParameters& params, bool b1);
virtual void Death(CStateManager&, const zeus::CVector3f&, EStateMsg) {}
virtual void KnockBack(const zeus::CVector3f&, CStateManager&, const CDamageInfo& info, EKnockBackType, bool, float) {}
template <class T>
static T* CastTo(CEntity* ent)
{
if (TCastToPtr<CPatterned> patterned = ent)
if (patterned->x34c_character == T::CharacterType)
return static_cast<T*>(patterned.GetPtr());
return nullptr;
}
template <class T>
static const T* CastTo(const CEntity* ent)
{
if (TCastToConstPtr<CPatterned> patterned = ent)
if (patterned->x34c_character == T::CharacterType)
return static_cast<const T*>(patterned.GetPtr());
return nullptr;
}
};
}

View File

@ -103,8 +103,8 @@ const zeus::CAABox& CPhysicsActor::GetBaseBoundingBox() const { return x1a4_base
void CPhysicsActor::AddMotionState(const CMotionState& mst)
{
zeus::CNUQuaternion q{x34_transform.buildMatrix3f()};
// TODO: Jack please verify this assignment: 8011B514
x34_transform = zeus::CTransform::Translate(x34_transform.origin) * zeus::CMatrix3f(q);
q += mst.xc_orientation;
x34_transform = zeus::CTransform(q, x34_transform.origin);
xe4_27_ = true;
xe4_28_ = true;
@ -124,7 +124,7 @@ CMotionState CPhysicsActor::GetMotionState() const
void CPhysicsActor::SetMotionState(const CMotionState& mst)
{
x34_transform = zeus::CTransform::Translate(x34_transform.origin) * zeus::CMatrix3f(mst.xc_orientation);
x34_transform = zeus::CTransform(mst.xc_orientation, x34_transform.origin);
xe4_27_ = true;
xe4_28_ = true;
@ -275,7 +275,7 @@ bool CPhysicsActor::WillMove(const CStateManager&)
void CPhysicsActor::SetPhysicsState(const CPhysicsState& state)
{
SetTranslation(state.GetTranslation());
x34_transform = zeus::CTransform::Translate(x34_transform.origin) * zeus::CMatrix3f(state.GetOrientation());
x34_transform = zeus::CTransform(state.GetOrientation(), x34_transform.origin);
xe4_27_ = true;
xe4_28_ = true;
xe4_29_ = true;
@ -368,41 +368,4 @@ void CPhysicsActor::UseCollisionImpulses()
ComputeDerivedQuantities();
}
CPhysicsState::CPhysicsState(const zeus::CVector3f& translation, const zeus::CQuaternion& orient,
const zeus::CVector3f& v2, const zeus::CAxisAngle& a1, const zeus::CVector3f& v3,
const zeus::CVector3f& v4, const zeus::CVector3f& v5, const zeus::CAxisAngle& a2,
const zeus::CAxisAngle& a3)
: x0_translation(translation)
, xc_orientation(orient)
, x1c_constantForce(v2)
, x28_angularMomentum(a1)
, x34_momentum(v3)
, x40_force(v4)
, x4c_impulse(v5)
, x58_torque(a2)
, x64_angularImpulse(a3)
{
}
void CPhysicsState::SetTranslation(const zeus::CVector3f& tr) { x0_translation = tr; }
void CPhysicsState::SetOrientation(const zeus::CQuaternion& orient) { xc_orientation = orient; }
const zeus::CQuaternion& CPhysicsState::GetOrientation() const { return xc_orientation; }
const zeus::CVector3f& CPhysicsState::GetTranslation() const { return x0_translation; }
const zeus::CVector3f& CPhysicsState::GetConstantForceWR() const { return x1c_constantForce; }
const zeus::CAxisAngle& CPhysicsState::GetAngularMomentumWR() const { return x28_angularMomentum; }
const zeus::CVector3f& CPhysicsState::GetMomentumWR() const { return x34_momentum; }
const zeus::CVector3f& CPhysicsState::GetForceWR() const { return x40_force; }
const zeus::CVector3f& CPhysicsState::GetImpulseWR() const { return x4c_impulse; }
const zeus::CAxisAngle& CPhysicsState::GetTorque() const { return x58_torque; }
const zeus::CAxisAngle& CPhysicsState::GetAngularImpulseWR() const { return x64_angularImpulse; }
}

View File

@ -46,21 +46,32 @@ class CPhysicsState
zeus::CAxisAngle x64_angularImpulse;
public:
CPhysicsState(const zeus::CVector3f&, const zeus::CQuaternion&, const zeus::CVector3f&, const zeus::CAxisAngle&,
const zeus::CVector3f&, const zeus::CVector3f&, const zeus::CVector3f&, const zeus::CAxisAngle&,
const zeus::CAxisAngle&);
CPhysicsState(const zeus::CVector3f& translation, const zeus::CQuaternion& orient,
const zeus::CVector3f& v2, const zeus::CAxisAngle& a1, const zeus::CVector3f& v3,
const zeus::CVector3f& v4, const zeus::CVector3f& v5, const zeus::CAxisAngle& a2,
const zeus::CAxisAngle& a3)
: x0_translation(translation)
, xc_orientation(orient)
, x1c_constantForce(v2)
, x28_angularMomentum(a1)
, x34_momentum(v3)
, x40_force(v4)
, x4c_impulse(v5)
, x58_torque(a2)
, x64_angularImpulse(a3)
{}
void SetOrientation(const zeus::CQuaternion&);
const zeus::CQuaternion& GetOrientation() const;
void SetTranslation(const zeus::CVector3f&);
const zeus::CVector3f& GetTranslation() const;
const zeus::CVector3f& GetConstantForceWR() const;
const zeus::CAxisAngle& GetAngularMomentumWR() const;
const zeus::CVector3f& GetMomentumWR() const;
const zeus::CVector3f& GetForceWR() const;
const zeus::CVector3f& GetImpulseWR() const;
const zeus::CAxisAngle& GetTorque() const;
const zeus::CAxisAngle& GetAngularImpulseWR() const;
void SetTranslation(const zeus::CVector3f& tr) { x0_translation = tr; }
void SetOrientation(const zeus::CQuaternion& orient) { xc_orientation = orient; }
const zeus::CQuaternion& GetOrientation() const { return xc_orientation; }
const zeus::CVector3f& GetTranslation() const { return x0_translation; }
const zeus::CVector3f& GetConstantForceWR() const { return x1c_constantForce; }
const zeus::CAxisAngle& GetAngularMomentumWR() const { return x28_angularMomentum; }
const zeus::CVector3f& GetMomentumWR() const { return x34_momentum; }
const zeus::CVector3f& GetForceWR() const { return x40_force; }
const zeus::CVector3f& GetImpulseWR() const { return x4c_impulse; }
const zeus::CAxisAngle& GetTorque() const { return x58_torque; }
const zeus::CAxisAngle& GetAngularImpulseWR() const { return x64_angularImpulse; }
};
class CPhysicsActor : public CActor

View File

@ -11,6 +11,10 @@
#include "Camera/CCinematicCamera.hpp"
#include "TCastTo.hpp"
#include "CScriptGrapplePoint.hpp"
#include "CPatterned.hpp"
#include "CScriptWater.hpp"
#include "Weapon/CEnergyProjectile.hpp"
#include "MP1/World/CThardusRockProjectile.hpp"
namespace urde
{
@ -28,6 +32,8 @@ CPlayer::CPlayer(TUniqueId uid, const zeus::CTransform& xf, const zeus::CAABox&
stepDown), x7d0_animRes(resId, 0, playerScale, 0, true)
{
x490_gun.reset(new CPlayerGun(uid));
x49c_gunNotFiringTimeout = g_tweakPlayerGun->GetGunNotFiringTime();
x4a0_inputFilter.reset(new CInputFilter());
x768_morphball.reset(new CMorphBall(*this, f4));
x76c_cameraBob.reset(new CPlayerCameraBob(CPlayerCameraBob::ECameraBobType::One,
zeus::CVector2f{CPlayerCameraBob::kCameraBobExtentX,
@ -45,6 +51,31 @@ bool CPlayer::IsTransparent() const { return x588_alpha < 1.f; }
void CPlayer::Update(float, CStateManager& mgr) {}
bool CPlayer::StartSamusVoiceSfx(u16 sfx, float vol, int prio)
{
if (x2f8_morphTransState == EPlayerMorphBallState::Morphed)
return false;
bool started = true;
if (x77c_samusVoiceSfx)
{
if (CSfxManager::IsPlaying(x77c_samusVoiceSfx))
{
started = false;
if (prio > x780_samusVoicePriority)
{
CSfxManager::SfxStop(x77c_samusVoiceSfx);
started = true;
}
}
if (started)
{
x77c_samusVoiceSfx = CSfxManager::SfxStart(sfx, vol, 0.f, false, 0x7f, false, kInvalidAreaId);
x780_samusVoicePriority = prio;
}
}
return started;
}
bool CPlayer::IsPlayerDeadEnough() const
{
if (x2f8_morphTransState == CPlayer::EPlayerMorphBallState::Unmorphed)
@ -140,6 +171,40 @@ void CPlayer::UpdateFreeLook(float dt) {}
float CPlayer::GetMaximumPlayerPositiveVerticalVelocity(CStateManager&) const { return 0.f; }
void CPlayer::StartLandingControlFreeze()
{
x760_controlsFrozen = true;
x764_controlsFrozenTimeout = 0.75f;
}
void CPlayer::EndLandingControlFreeze()
{
x760_controlsFrozen = false;
x764_controlsFrozenTimeout = 0.f;
}
void CPlayer::ProcessFrozenInput(float dt, CStateManager& mgr)
{
x764_controlsFrozenTimeout -= dt;
if (x764_controlsFrozenTimeout <= 0.f)
{
EndLandingControlFreeze();
}
else
{
CFinalInput dummy;
if (x2f8_morphTransState == EPlayerMorphBallState::Morphed)
{
x768_morphball->ComputeBallMovement(dummy, mgr, dt);
x768_morphball->UpdateBallDynamics(mgr, dt);
}
else
{
ComputeMovement(dummy, mgr, dt);
}
}
}
void CPlayer::ProcessInput(const CFinalInput&, CStateManager&) {}
void CPlayer::Stop(CStateManager& stateMgr)
@ -160,13 +225,218 @@ void CPlayer::PreThink(float dt, CStateManager& mgr)
xa04_ = dt;
}
void CPlayer::AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) {}
static const u16 skPlayerLandSfxSoft[] =
{
0xFFFF, 0x05E4, 0x05D2, 0x0621, 0x0658, 0xFFFF, 0x05E3, 0x0606,
0x05C0, 0x088E, 0x0694, 0x0638, 0x062B, 0xFFFF, 0x0621, 0x05D2,
0x05D2, 0x05C0, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x05FB, 0x0625
};
static const u16 skPlayerLandSfxHard[] =
{
0xFFFF, 0x0651, 0x064B, 0x0647, 0x065A, 0xFFFF, 0x0648, 0x064E,
0x064F, 0x08D7, 0x0696, 0x0650, 0x064C, 0xFFFF, 0x0647, 0x064B,
0x064B, 0x064F, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0652, 0x064D
};
static const CMaterialFilter SolidMaterialFilter =
CMaterialFilter::MakeInclude(CMaterialList(EMaterialTypes::Solid));
void CPlayer::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr)
{
switch (msg)
{
case EScriptObjectMessage::OnGround:
if (x258_movementState != EPlayerMovementState::OnGround &&
x2f8_morphTransState != EPlayerMorphBallState::Morphed &&
x300_fallingTime > 0.3f)
{
if (x258_movementState != EPlayerMovementState::Falling)
{
float hardThres = 30.f * 2.f * -g_tweakPlayer->GetHardLandingVelocityThreshold();
hardThres = (hardThres != 0.f) ? hardThres * std::sqrt(hardThres) : 0.f;
float landVol = zeus::clamp(95.f, 1.6f * -x794_.z + 95.f, 127.f) / 127.f;
u16 landSfx;
if (-x794_.z < hardThres)
{
landSfx = GetMaterialSoundUnderPlayer(mgr, skPlayerLandSfxSoft, 24, 0xffff);
}
else
{
landSfx = GetMaterialSoundUnderPlayer(mgr, skPlayerLandSfxHard, 24, 0xffff);
StartSamusVoiceSfx(1550, 1.f, 5);
x55c_ = 0.f;
x560_ = 10.f;
x564_ = x34_transform.origin;
x558_ = true;
mgr.GetCameraManager()->AddCameraShaker(
CCameraShakeData::BuildLandingCameraShakeData(0.3f, 1.25f), false);
StartLandingControlFreeze();
}
CSfxHandle handle =
CSfxManager::SfxStart(landSfx, landVol, 0.f, false, 0x7f, false, kInvalidAreaId);
ApplySubmergedPitchBend(handle);
float rumbleMag = -x794_.z / 110.f;
if (rumbleMag > 0.f)
{
if (std::fabs(rumbleMag) > 0.8f)
rumbleMag = (rumbleMag > 0.f) ? 0.8f : -0.8f;
mgr.GetRumbleManager().Rumble(mgr, ERumbleFxId::Fifteen, rumbleMag, ERumblePriority::One);
}
x2a0_ = 0.f;
}
}
else if (x258_movementState != EPlayerMovementState::OnGround &&
x2f8_morphTransState == EPlayerMorphBallState::Morphed)
{
if (x138_velocity.z < -40.f && !x768_morphball->GetIsInHalfPipeMode() &&
x258_movementState == EPlayerMovementState::StartingJump &&
x300_fallingTime > 0.75f)
SetCoefficientOfRestitutionModifier(0.2f);
x768_morphball->StartLandingSfx();
if (x138_velocity.z < -5.f)
{
float rumbleMag = -x138_velocity.z / 110.f * 0.5f;
if (std::fabs(rumbleMag) > 0.8f)
rumbleMag = (rumbleMag > 0.f) ? 0.8f : -0.8f;
mgr.GetRumbleManager().Rumble(mgr, ERumbleFxId::Fifteen, rumbleMag, ERumblePriority::One);
x2a0_ = 0.f;
}
if (x138_velocity.z < -30.f)
{
float rumbleMag = -x138_velocity.z / 110.f;
if (std::fabs(rumbleMag) > 0.8f)
rumbleMag = (rumbleMag > 0.f) ? 0.8f : -0.8f;
mgr.GetRumbleManager().Rumble(mgr, ERumbleFxId::Fifteen, rumbleMag, ERumblePriority::One);
x2a0_ = 0.f;
}
}
x300_fallingTime = 0.f;
SetMoveState(EPlayerMovementState::OnGround, mgr);
break;
case EScriptObjectMessage::Falling:
if (x2f8_morphTransState == EPlayerMorphBallState::Morphed)
if (x768_morphball->GetX187c() == 1)
break;
if (x2f8_morphTransState != EPlayerMorphBallState::Morphed)
SetMoveState(EPlayerMovementState::Falling, mgr);
else if (x258_movementState == EPlayerMovementState::OnGround)
SetMoveState(EPlayerMovementState::FallingMorphed, mgr);
break;
case EScriptObjectMessage::LandOnNotFloor:
if (x2f8_morphTransState == EPlayerMorphBallState::Morphed &&
x768_morphball->GetX187c() == 1 &&
x258_movementState != EPlayerMovementState::StartingJump)
SetMoveState(EPlayerMovementState::StartingJump, mgr);
break;
case EScriptObjectMessage::OnIceSurface:
x2ac_movementSurface = EPlayerMovementSurface::Ice;
break;
case EScriptObjectMessage::OnMudSlowSurface:
x2ac_movementSurface = EPlayerMovementSurface::MudSlow;
break;
case EScriptObjectMessage::OnNormalSurface:
x2ac_movementSurface = EPlayerMovementSurface::Normal;
break;
case EScriptObjectMessage::InSnakeWeed:
x2ac_movementSurface = EPlayerMovementSurface::SnakeWeed;
break;
case EScriptObjectMessage::AddSplashInhabitant:
{
SetInFluid(true, sender);
UpdateSubmerged(mgr);
CRayCastResult result =
mgr.RayStaticIntersection(x34_transform.origin, zeus::CVector3f::skDown,
0.5f * GetEyeHeight(), SolidMaterialFilter);
if (result.IsInvalid())
{
SetVelocityWR(x138_velocity * 0.095f);
xfc_constantForce *= 0.095f;
}
break;
}
case EScriptObjectMessage::UpdateSplashInhabitant:
UpdateSubmerged(mgr);
if (CheckSubmerged() && !mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::GravitySuit))
{
if (TCastToPtr<CScriptWater> water = mgr.ObjectById(xc4_fluidId))
{
switch (water->GetFluidPlane().GetFluidType())
{
case CFluidPlane::EFluidType::Zero:
x2b0_ = 0;
break;
case CFluidPlane::EFluidType::Two:
case CFluidPlane::EFluidType::Five:
x2ac_movementSurface = EPlayerMovementSurface::Fluid2Or5;
break;
case CFluidPlane::EFluidType::One:
x2b0_ = 0;
break;
case CFluidPlane::EFluidType::Three:
x2ac_movementSurface = EPlayerMovementSurface::Fluid3;
break;
default: break;
}
}
}
x9c5_25_splashUpdated = true;
break;
case EScriptObjectMessage::RemoveSplashInhabitant:
SetInFluid(false, kInvalidUniqueId);
UpdateSubmerged(mgr);
break;
case EScriptObjectMessage::ProjectileCollide:
x378_ = g_tweakPlayer->GetX1fc();
SetOrbitRequest(EPlayerOrbitRequest::Nine, mgr);
break;
case EScriptObjectMessage::AddPlatformRider:
x82e_ridingPlatform = sender;
break;
case EScriptObjectMessage::Damage:
if (TCastToPtr<CEnergyProjectile> energ = mgr.ObjectById(sender))
{
if ((energ->GetAttribField() & CWeapon::EProjectileAttrib::StaticInterference) !=
CWeapon::EProjectileAttrib::None)
{
mgr.GetPlayerState()->GetStaticInterference().
AddSource(GetUniqueId(), 0.3f, energ->GetInterferenceDuration());
}
}
break;
case EScriptObjectMessage::Deleted:
mgr.GetPlayerState()->ResetVisor();
x730_.clear();
break;
default: break;
}
x490_gun->AcceptScriptMessage(msg, sender, mgr);
x768_morphball->AcceptScriptMessage(msg, sender, mgr);
CActor::AcceptScriptMsg(msg, sender, mgr);
}
void CPlayer::SetVisorSteam(float, float, float, u32, bool) {}
void CPlayer::UpdateFootstepBounds(const CFinalInput& input, CStateManager&, float) {}
u16 CPlayer::GetMaterialSoundUnderPlayer(CStateManager& mgr, const u16*, int, u16) { return 0; }
u16 CPlayer::GetMaterialSoundUnderPlayer(CStateManager& mgr, const u16* table, u32 length, u16 defId)
{
u16 ret = defId;
zeus::CAABox aabb = GetBoundingBox();
aabb.accumulateBounds(x34_transform.origin + zeus::CVector3f::skDown);
rstl::reserved_vector<TUniqueId, 1024> nearList;
mgr.BuildNearList(nearList, aabb, SolidMaterialFilter, nullptr);
TUniqueId collideId = kInvalidUniqueId;
CRayCastResult result = mgr.RayWorldIntersection(collideId, x34_transform.origin,
zeus::CVector3f::skDown,
1.5f, SolidMaterialFilter, nearList);
if (result.IsValid())
ret = SfxIdFromMaterial(result.GetMaterial(), table, length, defId);
return ret;
}
u16 CPlayer::SfxIdFromMaterial(const CMaterialList& mat, const u16* idList, u32 tableLen, u16 defId)
{
@ -231,6 +501,24 @@ void CPlayer::BeginGrapple(zeus::CVector3f&, CStateManager& mgr) {}
void CPlayer::BreakGrapple(CStateManager& mgr) {}
void CPlayer::SetOrbitRequest(EPlayerOrbitRequest req, CStateManager& mgr)
{
x30c_orbitRequest = req;
switch (req)
{
case EPlayerOrbitRequest::Eight:
case EPlayerOrbitRequest::Seven:
SetOrbitState(EPlayerOrbitState::Two, mgr);
x314_orbitPoint = g_tweakPlayer->GetX164(int(x308_orbitType)) *
x34_transform.basis[1] + x34_transform.origin;
break;
default:
SetOrbitState(EPlayerOrbitState::Zero, mgr);
break;
}
}
void CPlayer::PreventFallingCameraPitch() {}
void CPlayer::OrbitCarcass(CStateManager&) {}
@ -241,15 +529,66 @@ zeus::CVector3f CPlayer::GetHUDOrbitTargetPosition() const { return {}; }
void CPlayer::SetOrbitState(EPlayerOrbitState, CStateManager& mgr) {}
void CPlayer::SetOrbitTargetId(TUniqueId, CStateManager& mgr) {}
void CPlayer::SetOrbitTargetId(TUniqueId id, CStateManager& mgr)
{
if (id != kInvalidUniqueId)
{
x394_ = (TCastToPtr<CPatterned>(mgr.ObjectById(id)) ||
TCastToPtr<CWallCrawlerSwarm>(mgr.ObjectById(id)) ||
CPatterned::CastTo<CThardusRockProjectile>(mgr.ObjectById(id)) ||
TCastToPtr<CScriptGunTurret>(mgr.ObjectById(id)));
}
void CPlayer::UpdateOrbitPosition(float, CStateManager& mgr) {}
x310_orbitTargetId = id;
if (x310_orbitTargetId == kInvalidUniqueId)
x374_ = false;
}
void CPlayer::UpdateOrbitZPosition() {}
void CPlayer::UpdateOrbitPosition(float pos, CStateManager& mgr)
{
switch (x304_orbitState)
{
case EPlayerOrbitState::Two:
case EPlayerOrbitState::Three:
SetOrbitPosition(pos, mgr);
break;
case EPlayerOrbitState::One:
case EPlayerOrbitState::Four:
case EPlayerOrbitState::Five:
if (TCastToPtr<CActor> act = mgr.ObjectById(x310_orbitTargetId))
if (x310_orbitTargetId != kInvalidUniqueId)
x314_orbitPoint = act->GetOrbitPosition(mgr);
break;
default: break;
}
}
void CPlayer::UpdateOrbitFixedPosition() {}
void CPlayer::UpdateOrbitZPosition()
{
if (x304_orbitState == EPlayerOrbitState::Two)
{
if (std::fabs(x320_orbitVector.z) < g_tweakPlayer->GetOrbitZRange())
x314_orbitPoint.z = x320_orbitVector.z + x34_transform.origin.z + GetEyeHeight();
}
}
void CPlayer::SetOrbitPosition(float, CStateManager& mgr) {}
void CPlayer::UpdateOrbitFixedPosition()
{
x314_orbitPoint = x34_transform.rotate(x320_orbitVector) + GetEyePosition();
}
void CPlayer::SetOrbitPosition(float pos, CStateManager& mgr)
{
zeus::CTransform camXf = GetFirstPersonCameraTransform(mgr);
if (x304_orbitState == EPlayerOrbitState::Two && x30c_orbitRequest == EPlayerOrbitRequest::Seven)
camXf = x34_transform;
zeus::CVector3f fwd = camXf.basis[1];
float dot = fwd.normalized().dot(fwd);
if (std::fabs(dot) > 1.f)
dot = (dot > 0.f) ? 1.f : -1.f;
x314_orbitPoint = camXf.rotate(zeus::CVector3f(0.f, pos / dot, 0.f)) + camXf.origin;
x320_orbitVector = zeus::CVector3f(0.f, pos, x314_orbitPoint.z - camXf.origin.z);
}
void CPlayer::UpdateAimTarget(CStateManager& mgr) {}
@ -272,7 +611,10 @@ TUniqueId CPlayer::CheckEnemiesAgainstOrbitZone(const std::vector<TUniqueId>&, E
return {};
}
TUniqueId CPlayer::FindOrbitTargetId(CStateManager& mgr) { return {}; }
TUniqueId CPlayer::FindOrbitTargetId(CStateManager& mgr)
{
return FindBestOrbitableObject(x354_onScreenOrbitObjects, x330_orbitZone, mgr);
}
static zeus::CAABox BuildNearListBox(bool cropBottom, const zeus::CTransform& xf, float x, float z, float y)
{
@ -425,7 +767,7 @@ void CPlayer::AddOrbitDisableSource(CStateManager& mgr, TUniqueId addId)
return;
x9e4_orbitDisableList.push_back(addId);
ResetAimTargetPrediction(kInvalidUniqueId);
if (!TCastToConstPtr<CScriptGrapplePoint>(mgr.GetObjectById(x310_lockonObjectId)))
if (!TCastToConstPtr<CScriptGrapplePoint>(mgr.GetObjectById(x310_orbitTargetId)))
SetOrbitTargetId(kInvalidUniqueId, mgr);
}
@ -437,6 +779,25 @@ void CPlayer::UpdateOrbitZone(CStateManager& mgr) {}
void CPlayer::UpdateOrbitInput(const CFinalInput& input, CStateManager& mgr) {}
void CPlayer::ActivateOrbitSource(CStateManager& mgr)
{
switch (x390_orbitSource)
{
default:
OrbitCarcass(mgr);
break;
case 1:
SetOrbitRequest(EPlayerOrbitRequest::Six, mgr);
break;
case 2:
if (x394_)
OrbitPoint(EPlayerOrbitType::One, mgr);
else
OrbitCarcass(mgr);
break;
}
}
void CPlayer::UpdateOrbitSelection(const CFinalInput& input, CStateManager& mgr) {}
void CPlayer::UpdateOrbitOrientation(CStateManager& mgr) {}
@ -610,22 +971,85 @@ void CPlayer::CVisorSteam::Update(float dt)
x24_ = 0.1f;
}
void CPlayer::CInputFilter::Reset()
{
x0_stateSamples.clear();
x54_posSamples.clear();
x148_velSamples.clear();
x23c_inputSamples.clear();
}
void CPlayer::CInputFilter::AddSample(EInputState state, const zeus::CVector3f& pos,
const zeus::CVector3f& vel, const zeus::CVector2f& input)
{
if (x0_stateSamples.size() >= 20)
x0_stateSamples.resize(19);
x0_stateSamples.insert(x0_stateSamples.begin(), state);
if (x54_posSamples.size() >= 20)
x54_posSamples.resize(19);
x54_posSamples.insert(x54_posSamples.begin(), pos);
if (x148_velSamples.size() >= 20)
x148_velSamples.resize(19);
x148_velSamples.insert(x148_velSamples.begin(), vel);
if (x23c_inputSamples.size() >= 20)
x23c_inputSamples.resize(19);
x23c_inputSamples.insert(x23c_inputSamples.begin(), input);
}
bool CPlayer::CInputFilter::Passes() const
{
// TODO: Do
return false;
}
void CPlayer::SetSpawnedMorphBallState(CPlayer::EPlayerMorphBallState, CStateManager&) {}
void CPlayer::DecrementPhazon()
{
if (xa10_ == 0)
if (xa10_phazonCounter == 0)
return;
xa10_--;
xa10_phazonCounter--;
}
void CPlayer::IncrementPhazon()
{
if (xa10_ != 0)
xa10_++;
if (xa10_phazonCounter != 0)
xa10_phazonCounter++;
else
xa14_ = 0.f;
}
bool CPlayer::CheckSubmerged() const
{
if (!xe6_24_fluidCounter)
return false;
return x828_waterLevelOnPlayer >= (x2f8_morphTransState == EPlayerMorphBallState::Morphed ?
2.f * g_tweakPlayer->GetPlayerBallHalfExtent() : 0.5f * GetEyeHeight());
}
void CPlayer::UpdateSubmerged(CStateManager& mgr)
{
x82c_ = false;
x828_waterLevelOnPlayer = 0.f;
if (xe6_24_fluidCounter)
{
if (TCastToPtr<CScriptWater> water = mgr.ObjectById(xc4_fluidId))
{
x828_waterLevelOnPlayer =
-(zeus::CVector3f::skUp.dot(x34_transform.origin) - water->GetTriggerBoundsWR().max.z);
CFluidPlane::EFluidType fluidType = water->GetFluidPlane().GetFluidType();
x82c_ = (fluidType == CFluidPlane::EFluidType::Two || fluidType == CFluidPlane::EFluidType::Five);
CheckSubmerged();
}
}
}
void CPlayer::ApplySubmergedPitchBend(CSfxHandle& sfx)
{
if (CheckSubmerged())
CSfxManager::PitchBend(sfx, -1.f);
}
}

View File

@ -35,9 +35,13 @@ public:
Scanning,
ScanComplete
};
enum class EPlayerOrbitType
{
Zero,
One
};
enum class EPlayerOrbitState
{
Zero,
@ -47,19 +51,42 @@ public:
Four,
Five
};
enum class EPlayerOrbitRequest
{
Zero,
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Ten
};
enum class EPlayerZoneInfo
{
Zero,
One
};
enum class EPlayerZoneType
{
Always = -1,
Box = 0,
Ellipse
};
enum class EPlayerMovementState
{
OnGround,
Jump,
StartingJump,
Falling,
FallingMorphed
};
enum class EPlayerMorphBallState
@ -79,6 +106,18 @@ public:
Four
};
enum class EPlayerMovementSurface
{
Normal,
One,
Ice,
MudSlow,
Four,
Fluid2Or5,
Fluid3,
SnakeWeed
};
private:
struct CVisorSteam
{
@ -101,9 +140,30 @@ private:
void Update(float dt);
float GetAlpha() const { return x20_alpha; }
};
zeus::CVector3f x1b4_;
TUniqueId x1c4_ = kInvalidUniqueId;
u32 x258_jumpState = 0;
class CInputFilter
{
public:
enum class EInputState
{
Jump,
StartingJump,
Moving
};
private:
rstl::reserved_vector<EInputState, 20> x0_stateSamples;
rstl::reserved_vector<zeus::CVector3f, 20> x54_posSamples;
rstl::reserved_vector<zeus::CVector3f, 20> x148_velSamples;
rstl::reserved_vector<zeus::CVector2f, 20> x23c_inputSamples;
public:
void Reset();
void AddSample(EInputState state, const zeus::CVector3f& pos,
const zeus::CVector3f& vel, const zeus::CVector2f& input);
bool Passes() const;
};
EPlayerMovementState x258_movementState = EPlayerMovementState::OnGround;
std::vector<u32> x25c_;
TUniqueId x26c_ = kInvalidUniqueId;
float x270_ = 0.f;
CPlayerEnergyDrain x274_energyDrain = CPlayerEnergyDrain(4);
@ -116,7 +176,7 @@ private:
float x2a0_ = 0.f;
u8 x2a4_ = 0;
float x2a8_ = 1000.f;
u32 x2ac_ = 0;
EPlayerMovementSurface x2ac_movementSurface = EPlayerMovementSurface::Normal;
u32 x2b0_ = 2;
u32 x2b4_ = 0;
u32 x2d0_ = 3;
@ -126,17 +186,13 @@ private:
EPlayerCameraState x2f4_cameraState = EPlayerCameraState::Zero;
EPlayerMorphBallState x2f8_morphTransState = EPlayerMorphBallState::Unmorphed;
u32 x2fc_ = 0;
float x300_ = 0.f;
float x300_fallingTime = 0.f;
EPlayerOrbitState x304_orbitState = EPlayerOrbitState::Zero;
u32 x308_ = 0;
u32 x30c_ = 0;
TUniqueId x310_lockonObjectId = kInvalidUniqueId;
float x314_ = 0.f;
float x318_ = 0.f;
float x31c_ = 0.f;
float x320_ = 0.f;
float x324_ = 0.f;
float x328_ = 0.f;
EPlayerOrbitType x308_orbitType = EPlayerOrbitType::Zero;
EPlayerOrbitRequest x30c_orbitRequest = EPlayerOrbitRequest::Three;
TUniqueId x310_orbitTargetId = kInvalidUniqueId;
zeus::CVector3f x314_orbitPoint;
zeus::CVector3f x320_orbitVector;
float x32c_ = 0.f;
EPlayerZoneInfo x330_orbitZone = EPlayerZoneInfo::Zero;
EPlayerZoneType x334_orbitType = EPlayerZoneType::Ellipse;
@ -153,7 +209,7 @@ private:
float x384_ = 0.f;
float x388_ = 0.f;
bool x38c_ = false;
u32 x390_ = 2;
u32 x390_orbitSource = 2;
u8 x394_ = 0;
float x398_ = 1.5f;
u8 x39c_ = 0;
@ -186,8 +242,8 @@ private:
float x48c_ = 0.f;
std::unique_ptr<CPlayerGun> x490_gun;
float x494_mapAlpha = 1.f;
float x49c_; /* Value retrieved from TweakPlayerGun */
// std::unqiue_ptr<> x4a0_;
float x49c_gunNotFiringTimeout;
std::unique_ptr<CInputFilter> x4a0_inputFilter;
u32 x4a4_ = 0;
float x4f8_ = 0.f;
float x4fc_ = 0.f;
@ -205,9 +261,7 @@ private:
u32 x594_ = 0;
u32 x658_ = 0;
u32 x71c_ = 0;
u32 x734_ = 0;
u32 x738_ = 0;
u32 x73c_ = 0;
std::vector<std::unique_ptr<CModelData>> x730_;
float x740_ = 0.f;
float x744_ = 0.f;
float x748_ = 0.f;
@ -216,15 +270,15 @@ private:
u32 x754_ = 0;
float x758_ = 0.f;
u32 x75c_ = 0;
u32 x760_ = 0;
float x764_ = 0.f;
bool x760_controlsFrozen = false;
float x764_controlsFrozenTimeout = 0.f;
std::unique_ptr<CMorphBall> x768_morphball;
std::unique_ptr<CPlayerCameraBob> x76c_cameraBob;
CSfxHandle x770_;
float x774_ = 0.f;
u32 x778_ = 0;
u32 x77c_ = 0;
u32 x780_ = 0;
CSfxHandle x77c_samusVoiceSfx;
int x780_samusVoicePriority = 0;
float x784_ = 0.f;
u16 x788_ = 0;
float x78c_ = 0.f;
@ -237,9 +291,9 @@ private:
std::unique_ptr<CModelData> x7f0_ballTransitionBeamModel;
zeus::CTransform x7f4_;
float x824_ = 0.f;
float x828_ = 0.f;
float x828_waterLevelOnPlayer = 0.f;
bool x82c_ = false;
TUniqueId x82e_ = kInvalidUniqueId;
TUniqueId x82e_ridingPlatform = kInvalidUniqueId;
TUniqueId x830_ = kInvalidUniqueId;
u32 x834_ = 1000;
u32 x838_ = 0;
@ -259,7 +313,7 @@ private:
bool x9c4_30_ : 1;
bool x9c4_31_ : 1;
bool x9c5_24_ : 1;
bool x9c5_25_ : 1;
bool x9c5_25_splashUpdated : 1;
bool x9c5_26_ : 1;
bool x9c5_27_ : 1;
bool x9c5_28_ : 1;
@ -296,7 +350,7 @@ private:
float xa04_ = 0.f;
ResId xa08_steamTextureId = -1;
ResId xa0c_;
u32 xa10_ = 0;
u32 xa10_phazonCounter = 0;
float xa14_ = 0.f;
float xa18_ = 0.f;
float xa1c_threatOverride = 0.f;
@ -306,12 +360,19 @@ private:
u32 xa2c_ = 2;
float xa30_ = 4.f;
void StartLandingControlFreeze();
void EndLandingControlFreeze();
void ProcessFrozenInput(float dt, CStateManager& mgr);
bool CheckSubmerged() const;
void UpdateSubmerged(CStateManager& mgr);
public:
CPlayer(TUniqueId, const zeus::CTransform&, const zeus::CAABox&, unsigned int w1, const zeus::CVector3f&, float, float,
float, float, const CMaterialList&);
bool IsTransparent() const;
void Update(float, CStateManager& mgr);
bool StartSamusVoiceSfx(u16 sfx, float vol, int prio);
bool IsPlayerDeadEnough() const;
void AsyncLoadSuit(CStateManager& mgr);
void LoadAnimationTokens();
@ -357,7 +418,7 @@ public:
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
void SetVisorSteam(float, float, float, u32, bool);
void UpdateFootstepBounds(const CFinalInput& input, CStateManager&, float);
u16 GetMaterialSoundUnderPlayer(CStateManager& mgr, const u16*, int, u16);
u16 GetMaterialSoundUnderPlayer(CStateManager& mgr, const u16*, u32, u16);
u16 SfxIdFromMaterial(const CMaterialList&, const u16*, u32, u16);
void UpdateCrosshairsState(const CFinalInput&);
void UpdateVisorTransition(float, CStateManager& mgr);
@ -380,6 +441,7 @@ public:
void ApplyGrappleJump(CStateManager& mgr);
void BeginGrapple(zeus::CVector3f&, CStateManager& mgr);
void BreakGrapple(CStateManager& mgr);
void SetOrbitRequest(EPlayerOrbitRequest req, CStateManager& mgr);
void PreventFallingCameraPitch();
void OrbitCarcass(CStateManager&);
void OrbitPoint(EPlayerOrbitType, CStateManager& mgr);
@ -412,6 +474,7 @@ public:
void UpdateOrbitModeTimer(float);
void UpdateOrbitZone(CStateManager& mgr);
void UpdateOrbitInput(const CFinalInput& input, CStateManager& mgr);
void ActivateOrbitSource(CStateManager& mgr);
void UpdateOrbitSelection(const CFinalInput& input, CStateManager& mgr);
void UpdateOrbitOrientation(CStateManager& mgr);
void UpdateOrbitTarget(CStateManager& mgr);
@ -449,7 +512,7 @@ public:
EPlayerOrbitState GetOrbitState() const { return x304_orbitState; }
EPlayerScanState GetScanningState() const { return x3a8_scanState; }
float GetScanningTime() const { return x3ac_scanningTime; }
TUniqueId GetLockonObjectId() const { return x310_lockonObjectId; }
TUniqueId GetOrbitTargetId() const { return x310_orbitTargetId; }
TUniqueId GetScanningObjectId() const { return x3b4_scanningObject; }
bool IsNewScanScanning() const { return x9c6_30_newScanScanning; }
float GetThreatOverride() const { return xa1c_threatOverride; }
@ -477,6 +540,7 @@ public:
void DecrementPhazon();
void IncrementPhazon();
void ApplySubmergedPitchBend(CSfxHandle& sfx);
};
}

View File

@ -19,7 +19,7 @@ private:
float x1f4_;
float x1f8_ = 0.f;
zeus::CVector3f x1d4_;
std::vector<std::pair<TUniqueId, bool>> x200_waterInhabitants;
std::list<std::pair<TUniqueId, bool>> x1fc_waterInhabitants;
u32 x210_;
float x214_;
float x218_;

View File

@ -200,26 +200,28 @@ enum class EScriptObjectMessage
Play = 20,
Alert = 21,
InternalMessage00 = 22,
InternalMessage01 = 23,
OnGround = 23,
InternalMessage02 = 24,
InternalMessage03 = 25,
InternalMessage04 = 26,
InternalMessage05 = 27,
InternalMessage06 = 28,
InternalMessage07 = 29,
Falling = 26,
OnIceSurface = 27,
OnMudSlowSurface = 28,
OnNormalSurface = 29,
InternalMessage08 = 30,
InternalMessage09 = 31,
InternalMessage10 = 32,
Registered = 33,
Deleted = 34,
AddPlatformRider = 31,
LandOnNotFloor = 32,
Registered = 33,
Deleted = 34,
InitializedInArea = 35,
InternalMessage14 = 36,
InternalMessage15 = 37,
InternalMessage16 = 38,
InternalMessage17 = 39,
AddSplashInhabitant = 37,
UpdateSplashInhabitant = 38,
RemoveSplashInhabitant = 39,
InternalMessage18 = 40,
InternalMessage19 = 41,
Damage = 41,
InternalMessage20 = 42,
ProjectileCollide = 43,
InSnakeWeed = 44,
InternalMessage26 = 48
};