Additional HUD work

This commit is contained in:
Jack Andersen 2017-04-08 20:14:22 -10:00
parent e070844e8a
commit 9cd421888d
17 changed files with 313 additions and 35 deletions

View File

@ -50,7 +50,7 @@ struct ITweakGui : ITweak
virtual float GetVisorBeamMenuItemActiveScale() const=0; virtual float GetVisorBeamMenuItemActiveScale() const=0;
virtual float GetVisorBeamMenuItemInactiveScale() const=0; virtual float GetVisorBeamMenuItemInactiveScale() const=0;
virtual float GetVisorBeamMenuItemTranslate() const=0; virtual float GetVisorBeamMenuItemTranslate() const=0;
virtual float GetMaxThreatEnergy() const=0; virtual float GetThreatRange() const=0;
virtual float GetRadarScopeCoordRadius() const=0; virtual float GetRadarScopeCoordRadius() const=0;
virtual float GetRadarPlayerPaintRadius() const=0; virtual float GetRadarPlayerPaintRadius() const=0;
virtual float GetRadarEnemyPaintRadius() const=0; virtual float GetRadarEnemyPaintRadius() const=0;
@ -66,6 +66,7 @@ struct ITweakGui : ITweak
virtual float GetFreeLookSfxPitchScale() const=0; virtual float GetFreeLookSfxPitchScale() const=0;
virtual bool GetNoAbsoluteFreeLookSfxPitch() const=0; virtual bool GetNoAbsoluteFreeLookSfxPitch() const=0;
virtual float GetMissileWarningPulseTime() const=0; virtual float GetMissileWarningPulseTime() const=0;
virtual float GetHudLagOffsetScale() const=0;
virtual float GetScanAppearanceOffset() const=0; virtual float GetScanAppearanceOffset() const=0;
virtual float GetBallViewportYReduction() const=0; virtual float GetBallViewportYReduction() const=0;
virtual float GetScanSpeed(int idx) const=0; virtual float GetScanSpeed(int idx) const=0;

View File

@ -13,6 +13,7 @@ struct ITweakPlayer : ITweak
virtual float GetX54() const=0; virtual float GetX54() const=0;
virtual float GetX58() const=0; virtual float GetX58() const=0;
virtual float GetX5C() const=0; virtual float GetX5C() const=0;
virtual float GetHudLagAmount() const=0;
virtual float GetScanningRange() const=0; // x218 virtual float GetScanningRange() const=0; // x218
virtual bool GetScanFreezesGame() const=0; // x21c_25 virtual bool GetScanFreezesGame() const=0; // x21c_25
virtual float GetPlayerHeight() const=0; // x26c virtual float GetPlayerHeight() const=0; // x26c

View File

@ -62,7 +62,7 @@ struct CTweakGui : ITweakGui
Value<float> xd8_; Value<float> xd8_;
Value<float> xdc_; Value<float> xdc_;
Value<float> xe0_; Value<float> xe0_;
Value<float> xe4_maxThreatEnergy; Value<float> xe4_threatRange;
Value<float> xe8_radarScopeCoordRadius; Value<float> xe8_radarScopeCoordRadius;
Value<float> xec_radarPlayerPaintRadius; Value<float> xec_radarPlayerPaintRadius;
Value<float> xf0_radarEnemyPaintRadius; Value<float> xf0_radarEnemyPaintRadius;
@ -110,7 +110,7 @@ struct CTweakGui : ITweakGui
Value<float> x1d0_; Value<float> x1d0_;
Value<float> x1d4_; Value<float> x1d4_;
Value<float> x1d8_; Value<float> x1d8_;
Value<float> x1dc_; Value<float> x1dc_hudLagOffsetScale;
Value<float> x1e0_; Value<float> x1e0_;
Value<float> x1e4_; Value<float> x1e4_;
Value<float> x1e8_; Value<float> x1e8_;
@ -218,7 +218,7 @@ struct CTweakGui : ITweakGui
float GetVisorBeamMenuItemActiveScale() const { return xc4_visorBeamMenuItemActiveScale; } float GetVisorBeamMenuItemActiveScale() const { return xc4_visorBeamMenuItemActiveScale; }
float GetVisorBeamMenuItemInactiveScale() const { return xc8_visorBeamMenuItemInactiveScale; } float GetVisorBeamMenuItemInactiveScale() const { return xc8_visorBeamMenuItemInactiveScale; }
float GetVisorBeamMenuItemTranslate() const { return xcc_visorBeamMenuItemTranslate; } float GetVisorBeamMenuItemTranslate() const { return xcc_visorBeamMenuItemTranslate; }
float GetMaxThreatEnergy() const { return xe4_maxThreatEnergy; } float GetThreatRange() const { return xe4_threatRange; }
float GetRadarScopeCoordRadius() const { return xe8_radarScopeCoordRadius; } float GetRadarScopeCoordRadius() const { return xe8_radarScopeCoordRadius; }
float GetRadarPlayerPaintRadius() const { return xec_radarPlayerPaintRadius; } float GetRadarPlayerPaintRadius() const { return xec_radarPlayerPaintRadius; }
float GetRadarEnemyPaintRadius() const { return xf0_radarEnemyPaintRadius; } float GetRadarEnemyPaintRadius() const { return xf0_radarEnemyPaintRadius; }
@ -234,6 +234,7 @@ struct CTweakGui : ITweakGui
float GetFreeLookSfxPitchScale() const { return x12c_freeLookSfxPitchScale; } float GetFreeLookSfxPitchScale() const { return x12c_freeLookSfxPitchScale; }
bool GetNoAbsoluteFreeLookSfxPitch() const { return x130_noAbsoluteFreeLookSfxPitch; } bool GetNoAbsoluteFreeLookSfxPitch() const { return x130_noAbsoluteFreeLookSfxPitch; }
float GetMissileWarningPulseTime() const { return x1a0_missileWarningPulseTime; } float GetMissileWarningPulseTime() const { return x1a0_missileWarningPulseTime; }
float GetHudLagOffsetScale() const { return x1dc_hudLagOffsetScale; }
float GetScanAppearanceOffset() const { return x244_scanAppearanceOffset; } float GetScanAppearanceOffset() const { return x244_scanAppearanceOffset; }
float GetBallViewportYReduction() const { return x254_ballViewportYReduction; } float GetBallViewportYReduction() const { return x254_ballViewportYReduction; }
float GetXrayBlurScaleLinear() const { return x204_xrayBlurScaleLinear; } float GetXrayBlurScaleLinear() const { return x204_xrayBlurScaleLinear; }

View File

@ -162,7 +162,7 @@ void CTweakPlayer::read(athena::io::IStreamReader& __dna_reader)
/* x134_ */ /* x134_ */
x134_ = __dna_reader.readFloatBig(); x134_ = __dna_reader.readFloatBig();
/* x138_ */ /* x138_ */
x138_ = __dna_reader.readFloatBig(); x138_hudLagAmount = __dna_reader.readFloatBig();
/* x13c_ */ /* x13c_ */
x13c_ = __dna_reader.readFloatBig(); x13c_ = __dna_reader.readFloatBig();
/* x140_ */ /* x140_ */
@ -602,7 +602,7 @@ void CTweakPlayer::write(athena::io::IStreamWriter& __dna_writer) const
/* x134_ */ /* x134_ */
__dna_writer.writeFloatBig(x134_); __dna_writer.writeFloatBig(x134_);
/* x138_ */ /* x138_ */
__dna_writer.writeFloatBig(x138_); __dna_writer.writeFloatBig(x138_hudLagAmount);
/* x13c_ */ /* x13c_ */
__dna_writer.writeFloatBig(x13c_); __dna_writer.writeFloatBig(x13c_);
/* x140_ */ /* x140_ */
@ -1072,7 +1072,7 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin)
/* x134_ */ /* x134_ */
x134_ = __dna_docin.readFloat("x134_"); x134_ = __dna_docin.readFloat("x134_");
/* x138_ */ /* x138_ */
x138_ = __dna_docin.readFloat("x138_"); x138_hudLagAmount = __dna_docin.readFloat("x138_");
/* x13c_ */ /* x13c_ */
x13c_ = __dna_docin.readFloat("x13c_"); x13c_ = __dna_docin.readFloat("x13c_");
/* x140_ */ /* x140_ */
@ -1581,7 +1581,7 @@ void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout)
/* x134_ */ /* x134_ */
__dna_docout.writeFloat("x134_", x134_); __dna_docout.writeFloat("x134_", x134_);
/* x138_ */ /* x138_ */
__dna_docout.writeFloat("x138_", x138_); __dna_docout.writeFloat("x138_", x138_hudLagAmount);
/* x13c_ */ /* x13c_ */
__dna_docout.writeFloat("x13c_", x13c_); __dna_docout.writeFloat("x13c_", x13c_);
/* x140_ */ /* x140_ */
@ -1904,7 +1904,7 @@ void CTweakPlayer::FixupValues()
{ {
x130_ = zeus::degToRad(x130_); x130_ = zeus::degToRad(x130_);
x134_ = zeus::degToRad(x134_); x134_ = zeus::degToRad(x134_);
x138_ = zeus::degToRad(x138_); x138_hudLagAmount = zeus::degToRad(x138_hudLagAmount);
x13c_ = zeus::degToRad(x13c_); x13c_ = zeus::degToRad(x13c_);
x140_ = zeus::degToRad(x140_); x140_ = zeus::degToRad(x140_);
x144_ = zeus::degToRad(x144_); x144_ = zeus::degToRad(x144_);

View File

@ -46,7 +46,7 @@ struct CTweakPlayer : ITweakPlayer
Value<float> x12c_; Value<float> x12c_;
Value<float> x130_; Value<float> x130_;
Value<float> x134_; Value<float> x134_;
Value<float> x138_; Value<float> x138_hudLagAmount;
Value<float> x13c_; Value<float> x13c_;
Value<float> x140_; Value<float> x140_;
Value<float> x144_; Value<float> x144_;
@ -179,6 +179,7 @@ struct CTweakPlayer : ITweakPlayer
float GetX54() const { return x44_[4]; } float GetX54() const { return x44_[4]; }
float GetX58() const { return x44_[5]; } float GetX58() const { return x44_[5]; }
float GetX5C() const { return x44_[6]; } float GetX5C() const { return x44_[6]; }
float GetHudLagAmount() const { return x138_hudLagAmount; }
float GetScanningRange() const { return x218_scanningRange; } float GetScanningRange() const { return x218_scanningRange; }
bool GetScanFreezesGame() const { return x21c_25_scanFreezesGame; } bool GetScanFreezesGame() const { return x21c_25_scanFreezesGame; }
float GetPlayerHeight() const { return x26c_playerHeight; } float GetPlayerHeight() const { return x26c_playerHeight; }
@ -197,7 +198,7 @@ struct CTweakPlayer : ITweakPlayer
float GetX29C() const { return x29c_; } float GetX29C() const { return x29c_; }
float GetX280() const { return x280_; } float GetX280() const { return x280_; }
float GetX2B0() const { return x2b0_; } float GetX2B0() const { return x2b0_; }
float GetX138() const { return x138_; } float GetX138() const { return x138_hudLagAmount; }
float GetX14C() const { return x14c_; } float GetX14C() const { return x14c_; }
float GetLeftLogicalThreshold() const { return x150_leftDiv; } float GetLeftLogicalThreshold() const { return x150_leftDiv; }
float GetRightLogicalThreshold() const { return x154_rightDiv; } float GetRightLogicalThreshold() const { return x154_rightDiv; }

View File

@ -316,6 +316,17 @@ void CSfxManager::PitchBend(const CSfxHandle& handle, float pitch)
} }
} }
void CSfxManager::SfxVolume(const CSfxHandle& handle, float vol)
{
if (handle->IsEmitter())
{
CSfxWrapper& wrapper = static_cast<CSfxWrapper&>(*handle);
wrapper.SetVolume(vol);
}
if (handle->IsPlaying())
handle->GetVoice()->setVolume(vol);
}
u16 CSfxManager::TranslateSFXID(u16 id) u16 CSfxManager::TranslateSFXID(u16 id)
{ {
if (mpSfxTranslationTable == nullptr) if (mpSfxTranslationTable == nullptr)

View File

@ -71,6 +71,8 @@ public:
bool x14_27_inArea:1; bool x14_27_inArea:1;
bool x14_28_available:1; bool x14_28_available:1;
bool x14_29_useAcoustics:1; bool x14_29_useAcoustics:1;
protected:
bool m_isEmitter:1;
public: public:
virtual ~CBaseSfxWrapper() = default; virtual ~CBaseSfxWrapper() = default;
virtual void SetActive(bool v) { x14_24_isActive = v; } virtual void SetActive(bool v) { x14_24_isActive = v; }
@ -95,6 +97,7 @@ public:
virtual void UpdateEmitterSilent()=0; virtual void UpdateEmitterSilent()=0;
virtual void UpdateEmitter()=0; virtual void UpdateEmitter()=0;
virtual void SetReverb(float rev)=0; virtual void SetReverb(float rev)=0;
bool IsEmitter() const { return m_isEmitter; }
void Release() { x14_28_available = true; x4_timeRemaining = 15.f; } void Release() { x14_28_available = true; x4_timeRemaining = 15.f; }
bool Available() const { return x14_28_available; } bool Available() const { return x14_28_available; }
@ -130,7 +133,10 @@ public:
CSfxEmitterWrapper(bool looped, s16 prio, const CAudioSys::C3DEmitterParmData& data, CSfxEmitterWrapper(bool looped, s16 prio, const CAudioSys::C3DEmitterParmData& data,
/*const CSfxHandle& handle,*/ bool useAcoustics, TAreaId area) /*const CSfxHandle& handle,*/ bool useAcoustics, TAreaId area)
: CBaseSfxWrapper(looped, prio, /*handle,*/ useAcoustics, area), x24_parmData(data) {} : CBaseSfxWrapper(looped, prio, /*handle,*/ useAcoustics, area), x24_parmData(data)
{
m_isEmitter = true;
}
}; };
class CSfxWrapper : public CBaseSfxWrapper class CSfxWrapper : public CBaseSfxWrapper
@ -151,13 +157,15 @@ public:
void UpdateEmitterSilent(); void UpdateEmitterSilent();
void UpdateEmitter(); void UpdateEmitter();
void SetReverb(float rev); void SetReverb(float rev);
void SetVolume(float vol) { x20_vol = vol; }
void SetVolume(s16 vol) { x20_vol = vol; }
CSfxWrapper(bool looped, s16 prio, u16 sfxId, float vol, float pan, CSfxWrapper(bool looped, s16 prio, u16 sfxId, float vol, float pan,
/*const CSfxHandle& handle,*/ bool useAcoustics, TAreaId area) /*const CSfxHandle& handle,*/ bool useAcoustics, TAreaId area)
: CBaseSfxWrapper(looped, prio, /*handle,*/ useAcoustics, area), : CBaseSfxWrapper(looped, prio, /*handle,*/ useAcoustics, area),
x18_sfxId(sfxId), x20_vol(vol), x22_pan(pan) {} x18_sfxId(sfxId), x20_vol(vol), x22_pan(pan)
{
m_isEmitter = false;
}
}; };
static CSfxChannel m_channels[4]; static CSfxChannel m_channels[4];
@ -197,6 +205,7 @@ public:
static float GetReverbAmount(); static float GetReverbAmount();
static void RemoveEmitter(const CSfxHandle&) {} static void RemoveEmitter(const CSfxHandle&) {}
static void PitchBend(const CSfxHandle& handle, float pitch); static void PitchBend(const CSfxHandle& handle, float pitch);
static void SfxVolume(const CSfxHandle& handle, float vol);
static u16 TranslateSFXID(u16); static u16 TranslateSFXID(u16);
static void SfxStop(const CSfxHandle& handle); static void SfxStop(const CSfxHandle& handle);
static CSfxHandle SfxStart(u16 id, float vol, float pan, bool useAcoustics, s16 prio, bool looped, s32 areaId); static CSfxHandle SfxStart(u16 id, float vol, float pan, bool useAcoustics, s16 prio, bool looped, s32 areaId);

View File

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

View File

@ -246,7 +246,7 @@ private:
bool xf94_27_inMapScreen : 1; bool xf94_27_inMapScreen : 1;
bool xf94_28_inSaveUI : 1; bool xf94_28_inSaveUI : 1;
bool xf94_29_ : 1; bool xf94_29_ : 1;
bool xf94_30_ : 1; bool xf94_30_fullThreat : 1;
}; };
u32 xf94_ = 0; u32 xf94_ = 0;
}; };
@ -409,6 +409,7 @@ public:
void SetInSaveUI(bool b) { xf94_28_inSaveUI = b; } void SetInSaveUI(bool b) { xf94_28_inSaveUI = b; }
void SetInMapScreen(bool b) { xf94_27_inMapScreen = b; } void SetInMapScreen(bool b) { xf94_27_inMapScreen = b; }
bool GetInMapScreen() const { return xf94_27_inMapScreen; } bool GetInMapScreen() const { return xf94_27_inMapScreen; }
bool IsFullThreat() const { return xf94_30_fullThreat; }
const std::shared_ptr<CPlayerState>& GetPlayerState() const {return x8b8_playerState;} const std::shared_ptr<CPlayerState>& GetPlayerState() const {return x8b8_playerState;}
CRandom16* GetActiveRandom() {return x900_activeRandom;} CRandom16* GetActiveRandom() {return x900_activeRandom;}

View File

@ -54,7 +54,7 @@ CHudThreatInterface::CHudThreatInterface(CGuiFrame& selHud, EHudType hudType, fl
x6c_energybart01_threatbar->SetEmptyColor(g_tweakGuiColors->GetThreatBarEmpty()); x6c_energybart01_threatbar->SetEmptyColor(g_tweakGuiColors->GetThreatBarEmpty());
x6c_energybart01_threatbar->SetCoordFunc(CoordFuncs[int(hudType)]); x6c_energybart01_threatbar->SetCoordFunc(CoordFuncs[int(hudType)]);
x6c_energybart01_threatbar->SetTesselation(hudType == EHudType::Combat ? 1.f : 0.1f); x6c_energybart01_threatbar->SetTesselation(hudType == EHudType::Combat ? 1.f : 0.1f);
x6c_energybart01_threatbar->SetMaxEnergy(g_tweakGui->GetMaxThreatEnergy()); x6c_energybart01_threatbar->SetMaxEnergy(g_tweakGui->GetThreatRange());
x6c_energybart01_threatbar->SetFilledDrainSpeed(9999.f); x6c_energybart01_threatbar->SetFilledDrainSpeed(9999.f);
x6c_energybart01_threatbar->SetShadowDrainSpeed(9999.f); x6c_energybart01_threatbar->SetShadowDrainSpeed(9999.f);
x6c_energybart01_threatbar->SetShadowDrainDelay(0.f); x6c_energybart01_threatbar->SetShadowDrainDelay(0.f);
@ -98,7 +98,7 @@ void CHudThreatInterface::Update(float dt)
g_tweakGuiColors->GetThreatIconWarningColor(), g_tweakGuiColors->GetThreatIconWarningColor(),
x50_warningColorLerp); x50_warningColorLerp);
float maxThreatEnergy = g_tweakGui->GetMaxThreatEnergy(); float maxThreatEnergy = g_tweakGui->GetThreatRange();
if (x70_textpane_threatdigits) if (x70_textpane_threatdigits)
{ {
if (x10_threatDist < maxThreatEnergy) if (x10_threatDist < maxThreatEnergy)

View File

@ -9,12 +9,14 @@ namespace urde
class CStateManager; class CStateManager;
class CTargetingManager class CTargetingManager
{ {
zeus::CQuaternion x0_rot;
public: public:
CTargetingManager(const CStateManager&); CTargetingManager(const CStateManager&);
bool CheckLoadComplete(); bool CheckLoadComplete();
void Update(float, const CStateManager&); void Update(float, const CStateManager&);
void Draw(const CStateManager&) const; void Draw(const CStateManager&) const;
void Touch() const; void Touch() const;
void SetRotation(const zeus::CQuaternion& rot) { x0_rot = rot; }
}; };
} }

View File

@ -2,6 +2,7 @@
#include "CSimplePool.hpp" #include "CSimplePool.hpp"
#include "GameGlobalObjects.hpp" #include "GameGlobalObjects.hpp"
#include "World/CPlayer.hpp" #include "World/CPlayer.hpp"
#include "World/CScriptTrigger.hpp"
#include "GuiSys/CGuiFrame.hpp" #include "GuiSys/CGuiFrame.hpp"
#include "GuiSys/CGuiTextPane.hpp" #include "GuiSys/CGuiTextPane.hpp"
#include "GuiSys/CGuiLight.hpp" #include "GuiSys/CGuiLight.hpp"
@ -511,27 +512,125 @@ void CSamusHud::UpdateFreeLook(float dt, const CStateManager& mgr)
void CSamusHud::UpdateMissile(float dt, const CStateManager& mgr, bool init) void CSamusHud::UpdateMissile(float dt, const CStateManager& mgr, bool init)
{ {
CPlayerGun& gun = *mgr.GetPlayer().GetPlayerGun();
CPlayerState& playerState = *mgr.GetPlayerState();
u32 numMissles = playerState.GetItemAmount(CPlayerState::EItemType::Missiles);
u32 missileCap = playerState.GetItemCapacity(CPlayerState::EItemType::Missiles);
CPlayerGun::EMissleMode missileMode = gun.GetMissleMode();
float chargeFactor = gun.IsCharging() ? gun.GetChargeBeamFactor() : 0.f;
if (x294_missileIntf)
x294_missileIntf->SetChargeBeamFactor(chargeFactor);
if (init || numMissles != x2d8_missileAmount || missileMode != x2ec_missileMode ||
missileCap != x2dc_missileCapacity)
{
if (x294_missileIntf)
{
if (missileCap != x2dc_missileCapacity)
x294_missileIntf->SetMissileCapacity(missileCap);
if (numMissles != x2d8_missileAmount)
x294_missileIntf->SetNumMissiles(numMissles, mgr);
if (missileMode != x2ec_missileMode)
x294_missileIntf->SetIsMissilesActive(missileMode == CPlayerGun::EMissleMode::Active);
}
x2d8_missileAmount = numMissles;
x2ec_missileMode = missileMode;
x2dc_missileCapacity = missileCap;
}
} }
void CSamusHud::UpdateVideoBands(float dt, const CStateManager& mgr) void CSamusHud::UpdateVideoBands(float dt, const CStateManager& mgr)
{ {
for (int i=0 ; i<4 ; ++i)
if (x5a4_videoBands[i].x0_videoband)
x5a4_videoBands[i].x0_videoband->SetIsVisible(false);
} }
void CSamusHud::UpdateBallMode(const CStateManager& mgr, bool init) void CSamusHud::UpdateBallMode(const CStateManager& mgr, bool init)
{ {
if (!x2b0_ballIntf)
return;
CPlayer& player = mgr.GetPlayer();
CPlayerGun& gun = *player.GetPlayerGun();
CPlayerState& playerState = *mgr.GetPlayerState();
u32 numPbs = playerState.GetItemAmount(CPlayerState::EItemType::PowerBombs);
u32 pbCap = playerState.GetItemCapacity(CPlayerState::EItemType::PowerBombs);
u32 bombCount = gun.IsBombReady() ? gun.GetBombCount() : 0;
bool hasBombs = playerState.HasPowerUp(CPlayerState::EItemType::MorphBallBombs);
bool pbReady = gun.IsPowerBombReady() &&
player.GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed;
x2b0_ballIntf->SetBombParams(numPbs, pbCap, bombCount, hasBombs, pbReady, false);
} }
void CSamusHud::UpdateThreatAssessment(float dt, const CStateManager& mgr) void CSamusHud::UpdateThreatAssessment(float dt, const CStateManager& mgr)
{ {
CMaterialFilter filter(CMaterialList(EMaterialTypes::Trigger), CMaterialList(),
CMaterialFilter::EFilterType::Include);
CPlayer& player = mgr.GetPlayer();
zeus::CAABox playerAABB = zeus::CAABox::skNullBox;
if (rstl::optional_object<zeus::CAABox> aabb = player.GetTouchBounds())
playerAABB = *aabb;
zeus::CAABox aabb;
aabb.accumulateBounds(player.GetTranslation() - g_tweakGui->GetThreatRange());
aabb.accumulateBounds(player.GetTranslation() + g_tweakGui->GetThreatRange());
rstl::reserved_vector<TUniqueId, 1024> nearList;
mgr.BuildNearList(nearList, aabb, filter, nullptr);
float threatDist = 9999.f;
for (TUniqueId id : nearList)
{
const CEntity* ent = mgr.GetObjectById(id);
if (TCastToConstPtr<CScriptTrigger> trigger = ent)
{
if (!bool(trigger->GetTriggerFlags() & ETriggerFlags::DetectPlayer))
continue;
if (trigger->GetDamageInfo().GetDamage() == 0.f)
continue;
if (rstl::optional_object<zeus::CAABox> aabb = trigger->GetTouchBounds())
{
float dist = playerAABB.distanceBetween(*aabb);
if (dist < threatDist)
threatDist = dist;
}
}
}
if (player.GetThreatOverride() > 0.f)
threatDist = std::min((1.f - player.GetThreatOverride()) * g_tweakGui->GetThreatRange(), threatDist);
if (mgr.IsFullThreat())
threatDist = 0.f;
if (x290_threatIntf)
x290_threatIntf->SetThreatDistance(threatDist);
} }
void CSamusHud::UpdateVisorAndBeamMenus(float dt, const CStateManager& mgr) void CSamusHud::UpdateVisorAndBeamMenus(float dt, const CStateManager& mgr)
{ {
CPlayer& player = mgr.GetPlayer();
CPlayerGun& gun = *player.GetPlayerGun();
CPlayerState& playerState = *mgr.GetPlayerState();
float beamInterp = zeus::clamp(0.f, gun.GetGunMorph().x18_, 1.f);
float visorInterp = playerState.GetVisorTransitionFactor();
if (x2a8_beamMenu)
{
x2a8_beamMenu->SetSelection(gun.GetSelectedBeam(), gun.GetPendingSelectedBeam(), beamInterp);
x2a8_beamMenu->SetPlayerHas(BuildPlayerHasBeams(mgr));
}
if (x2a4_visorMenu)
{
x2a4_visorMenu->SetSelection(int(playerState.GetCurrentVisor()),
int(playerState.GetTransitioningVisor()), visorInterp);
x2a4_visorMenu->SetPlayerHas(BuildPlayerHasVisors(mgr));
}
} }
void CSamusHud::UpdateCameraDebugSettings() void CSamusHud::UpdateCameraDebugSettings()
@ -563,15 +662,106 @@ void CSamusHud::UpdateEnergyLow(float dt, const CStateManager& mgr)
CSfxManager::SfxStart(1405, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); CSfxManager::SfxStart(1405, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
} }
void CSamusHud::ApplyClassicLag(const zeus::CUnitVector3f& lookDir, zeus::CQuaternion& rot,
const CStateManager& mgr, float dt, bool invert)
{
zeus::CQuaternion lookRot = zeus::CQuaternion::lookAt(lookDir, zeus::CVector3f::skForward, 2.f * M_PIF);
zeus::CQuaternion lookRot2;
if (invert)
{
zeus::CUnitVector3f v1(lookRot.transform(x2f8_fpCamDir));
lookRot2 = zeus::CQuaternion::lookAt(v1, zeus::CVector3f::skForward, 2.f * M_PIF);
}
else
{
zeus::CUnitVector3f v1(lookRot.transform(x2f8_fpCamDir));
lookRot2 = zeus::CQuaternion::lookAt(zeus::CVector3f::skForward, v1, 2.f * M_PIF);
}
zeus::CQuaternion doubleRot = lookRot2 * lookRot2;
float dot = doubleRot.toTransform().basis[1].dot(rot.toTransform().basis[1]);
if (std::fabs(dot) > 1.f)
dot = (dot >= 0.f) ? 1.f : -1.f;
float angle = std::acos(dot);
float tmp = 0.f;
if (angle > 0.f)
tmp = 0.5f * dt * g_tweakPlayer->GetHudLagAmount() / angle;
float t = zeus::clamp(0.f, 18.f * dt * tmp, 1.f);
rot = zeus::CQuaternion::slerp(rot, doubleRot, t);
}
void CSamusHud::UpdateHudLag(float dt, const CStateManager& mgr) void CSamusHud::UpdateHudLag(float dt, const CStateManager& mgr)
{ {
CPlayer& player = mgr.GetPlayer();
if (x29c_decoIntf)
x29c_decoIntf->SetDecoRotation(player.GetYaw());
if (!g_GameState->GameOptions().GetHUDLag())
{
if (x2a0_helmetIntf)
{
x2a0_helmetIntf->SetHudLagRotation(zeus::CMatrix3f::skIdentityMatrix3f);
x2a0_helmetIntf->SetHudLagOffset(zeus::CVector3f::skZero);
}
if (x29c_decoIntf)
{
x29c_decoIntf->SetReticuleTransform(zeus::CMatrix3f::skIdentityMatrix3f);
x29c_decoIntf->SetHudRotation(zeus::CQuaternion::skNoRotation);
x29c_decoIntf->SetHudOffset(zeus::CVector3f::skZero);
}
x588_base_basewidget_pivot->SetTransform(
zeus::CTransform::Translate(x588_base_basewidget_pivot->GetWorldPosition()));
x274_loadedFrmeBaseHud->GetFrameCamera()->SetO2WTransform(
BuildFinalCameraTransform(zeus::CQuaternion::skNoRotation, x304_basewidgetIdlePos, x310_cameraPos));
x8_targetingMgr.SetRotation(zeus::CQuaternion::skNoRotation);
}
else
{
zeus::CVector3f fpCamDir = x2f8_fpCamDir;
if (TCastToConstPtr<CFirstPersonCamera> fpCam = mgr.GetCameraManager()->GetCurrentCamera(mgr))
fpCamDir = fpCam->GetTransform().buildMatrix3f()[1];
ApplyClassicLag(fpCamDir, x31c_hudLag, mgr, dt, false);
ApplyClassicLag(fpCamDir, x32c_invHudLag, mgr, dt, true);
zeus::CQuaternion rot = zeus::CQuaternion::lookAt(zeus::CUnitVector3f(x2f8_fpCamDir), fpCamDir, 2.f * M_PIF);
rot *= rot;
rot *= rot;
x8_targetingMgr.SetRotation(rot);
zeus::CVector3f bobTranslation = player.GetCameraBob()->GetHelmetBobTranslation();
zeus::CQuaternion lagRot = x44c_ * x31c_hudLag;
zeus::CVector3f lagOff = x41c_ * g_tweakGui->GetHudLagOffsetScale();
lagOff.z += bobTranslation.z;
if (x2a0_helmetIntf)
{
x2a0_helmetIntf->SetHudLagRotation(lagRot);
x2a0_helmetIntf->SetHudLagOffset(lagOff);
}
if (x29c_decoIntf)
{
x29c_decoIntf->SetReticuleTransform(x32c_invHudLag);
x29c_decoIntf->SetHudRotation(lagRot);
x29c_decoIntf->SetHudOffset(lagOff);
}
x274_loadedFrmeBaseHud->GetFrameCamera()->SetO2WTransform(
BuildFinalCameraTransform(lagRot, x304_basewidgetIdlePos + lagOff, x310_cameraPos));
x2f8_fpCamDir = fpCamDir;
}
} }
void CSamusHud::UpdateHudDynamicLights(float dt, const CStateManager& mgr) void CSamusHud::UpdateHudDynamicLights(float dt, const CStateManager& mgr)
{
if (TCastToConstPtr<CFirstPersonCamera> fpCam = mgr.GetCameraManager()->GetCurrentCamera(mgr))
{ {
} }
}
void CSamusHud::UpdateHudDamage(float dt, const CStateManager& mgr, void CSamusHud::UpdateHudDamage(float dt, const CStateManager& mgr,
DataSpec::ITweakGui::EHelmetVisMode helmetVis) DataSpec::ITweakGui::EHelmetVisMode helmetVis)
@ -579,9 +769,57 @@ void CSamusHud::UpdateHudDamage(float dt, const CStateManager& mgr,
} }
void CSamusHud::UpdateStaticSfx(CSfxHandle& handle, float& cycleTimer, u16 sfxId, float dt,
float oldStaticInterp, float staticThreshold)
{
if ((oldStaticInterp > staticThreshold && x510_staticInterp <= staticThreshold) ||
(oldStaticInterp <= staticThreshold && x510_staticInterp > staticThreshold))
{
cycleTimer = 0.f;
}
else
{
if (cycleTimer < 0.1f)
cycleTimer = std::min(cycleTimer + dt, 0.1f);
if (cycleTimer == 0.1f)
{
if (x510_staticInterp > staticThreshold)
{
if (!handle)
handle = CSfxManager::SfxStart(sfxId, 1.f, 0.f, false, 0x7f, true, kInvalidAreaId);
}
else
{
CSfxManager::SfxStop(handle);
handle.reset();
}
}
}
}
void CSamusHud::UpdateStaticInterference(float dt, const CStateManager& mgr) void CSamusHud::UpdateStaticInterference(float dt, const CStateManager& mgr)
{ {
float intf = mgr.GetPlayerState()->GetStaticInterference().GetTotalInterference();
float oldStaticInterp = x510_staticInterp;
if (x510_staticInterp < intf)
x510_staticInterp = std::min(x510_staticInterp + dt, intf);
else
x510_staticInterp = std::max(intf, x510_staticInterp - dt);
UpdateStaticSfx(x508_staticSfxHi, x514_staticCycleTimerHi, 1402, dt, oldStaticInterp, 0.1f);
UpdateStaticSfx(x50c_staticSfxLo, x518_staticCycleTimerLo, 1403, dt, oldStaticInterp, 0.5f);
if (x510_staticInterp > 0.f)
{
zeus::CColor color = zeus::CColor::skWhite;
color.a = x510_staticInterp;
x51c_camFilter2.SetFilter(CCameraFilterPass::EFilterType::Blend,
CCameraFilterPass::EFilterShape::RandomStatic, 0.f, color, -1);
}
else
{
x51c_camFilter2.DisableFilter(0.f);
}
} }
void CSamusHud::ShowDamage(const zeus::CVector3f& position, float dam, float prevDam, void CSamusHud::ShowDamage(const zeus::CVector3f& position, float dam, float prevDam,
@ -592,12 +830,14 @@ void CSamusHud::ShowDamage(const zeus::CVector3f& position, float dam, float pre
void CSamusHud::EnterFirstPerson(const CStateManager& mgr) void CSamusHud::EnterFirstPerson(const CStateManager& mgr)
{ {
CSfxManager::SfxVolume(x508_staticSfxHi, 1.f);
CSfxManager::SfxVolume(x50c_staticSfxLo, 1.f);
} }
void CSamusHud::LeaveFirstPerson(const CStateManager& mgr) void CSamusHud::LeaveFirstPerson(const CStateManager& mgr)
{ {
CSfxManager::SfxVolume(x508_staticSfxHi, 0.f);
CSfxManager::SfxVolume(x50c_staticSfxLo, 0.f);
} }
EHudState CSamusHud::GetDesiredHudState(const CStateManager& mgr) EHudState CSamusHud::GetDesiredHudState(const CStateManager& mgr)

View File

@ -141,13 +141,13 @@ class CSamusHud
u32 x2e4_ = 0; u32 x2e4_ = 0;
u32 x2e8_ = 0; u32 x2e8_ = 0;
u32 x2ec_missilesActive = 0; CPlayerGun::EMissleMode x2ec_missileMode = CPlayerGun::EMissleMode::Inactive;
float x2f0_visorBeamMenuAlpha = 1.f; float x2f0_visorBeamMenuAlpha = 1.f;
zeus::CVector3f x2f8_fpCamDir; zeus::CVector3f x2f8_fpCamDir;
zeus::CVector3f x304_basewidgetIdlePos; zeus::CVector3f x304_basewidgetIdlePos;
zeus::CVector3f x310_cameraPos; zeus::CVector3f x310_cameraPos;
zeus::CQuaternion x31c_; zeus::CQuaternion x31c_hudLag;
zeus::CQuaternion x32c_; zeus::CQuaternion x32c_invHudLag;
std::unique_ptr<CActorLights> x33c_lights; std::unique_ptr<CActorLights> x33c_lights;
rstl::reserved_vector<SCachedHudLight, 3> x340_hudLights; rstl::reserved_vector<SCachedHudLight, 3> x340_hudLights;
CSfxHandle x3a4_damageSfx; CSfxHandle x3a4_damageSfx;
@ -173,11 +173,11 @@ class CSamusHud
float x464_ = 0.f; float x464_ = 0.f;
rstl::reserved_vector<zeus::CTransform, 3> x46c_; rstl::reserved_vector<zeus::CTransform, 3> x46c_;
zeus::CVector2f x500_viewportScale = {1.f, 1.f}; zeus::CVector2f x500_viewportScale = {1.f, 1.f};
u32 x508_ = 0; CSfxHandle x508_staticSfxHi;
u32 x50c_ = 0; CSfxHandle x50c_staticSfxLo;
float x510_ = 0.f; float x510_staticInterp = 0.f;
float x514_ = 0.f; float x514_staticCycleTimerHi = 0.f;
float x518_ = 0.f; float x518_staticCycleTimerLo = 0.f;
CCameraFilterPass x51c_camFilter2; CCameraFilterPass x51c_camFilter2;
CHUDMemoParms x548_hudMemoParms; CHUDMemoParms x548_hudMemoParms;
TLockedToken<CStringTable> x550_hudMemoString; TLockedToken<CStringTable> x550_hudMemoString;
@ -222,10 +222,14 @@ class CSamusHud
void UpdateVisorAndBeamMenus(float dt, const CStateManager& mgr); void UpdateVisorAndBeamMenus(float dt, const CStateManager& mgr);
void UpdateCameraDebugSettings(); void UpdateCameraDebugSettings();
void UpdateEnergyLow(float dt, const CStateManager& mgr); void UpdateEnergyLow(float dt, const CStateManager& mgr);
void ApplyClassicLag(const zeus::CUnitVector3f& lookDir, zeus::CQuaternion& rot,
const CStateManager& mgr, float dt, bool invert);
void UpdateHudLag(float dt, const CStateManager& mgr); void UpdateHudLag(float dt, const CStateManager& mgr);
void UpdateHudDynamicLights(float dt, const CStateManager& mgr); void UpdateHudDynamicLights(float dt, const CStateManager& mgr);
void UpdateHudDamage(float dt, const CStateManager& mgr, void UpdateHudDamage(float dt, const CStateManager& mgr,
DataSpec::ITweakGui::EHelmetVisMode helmetVis); DataSpec::ITweakGui::EHelmetVisMode helmetVis);
void UpdateStaticSfx(CSfxHandle& handle, float& cycleTimer, u16 sfxId, float dt,
float oldStaticInterp, float staticThreshold);
void UpdateStaticInterference(float dt, const CStateManager& mgr); void UpdateStaticInterference(float dt, const CStateManager& mgr);
void ShowDamage(const zeus::CVector3f& position, float dam, float prevDam, const CStateManager& mgr); void ShowDamage(const zeus::CVector3f& position, float dam, float prevDam, const CStateManager& mgr);
void EnterFirstPerson(const CStateManager& mgr); void EnterFirstPerson(const CStateManager& mgr);

View File

@ -70,8 +70,8 @@ private:
u32 x304_ = 0; u32 x304_ = 0;
u32 x308_bombCount = 3; u32 x308_bombCount = 3;
u32 x30c_ = 0; u32 x30c_ = 0;
u32 x310_ = 0; u32 x310_selectedBeam = 0;
u32 x314_ = 0; u32 x314_pendingSelectedBeam = 0;
u32 x318_ = 0; u32 x318_ = 0;
EMissleMode x31c_missileMode = EMissleMode::Inactive; EMissleMode x31c_missileMode = EMissleMode::Inactive;
u32 x320_ = 0; u32 x320_ = 0;
@ -214,6 +214,9 @@ public:
bool IsBombReady() const { return x835_28_bombReady; } bool IsBombReady() const { return x835_28_bombReady; }
u32 GetBombCount() const { return x308_bombCount; } u32 GetBombCount() const { return x308_bombCount; }
bool IsPowerBombReady() const { return x835_29_powerBombReady; } bool IsPowerBombReady() const { return x835_29_powerBombReady; }
u32 GetSelectedBeam() const { return x310_selectedBeam; }
u32 GetPendingSelectedBeam() const { return x314_pendingSelectedBeam; }
const CGunMorph& GetGunMorph() const { return x678_morph; }
}; };
} }

View File

@ -294,7 +294,7 @@ private:
u32 xa10_ = 0; u32 xa10_ = 0;
float xa14_ = 0.f; float xa14_ = 0.f;
float xa18_ = 0.f; float xa18_ = 0.f;
float xa1c_ = 0.f; float xa1c_threatOverride = 0.f;
float xa20_radarXYRadiusOverride = 1.f; float xa20_radarXYRadiusOverride = 1.f;
float xa24_radarZRadiusOverride = 1.f; float xa24_radarZRadiusOverride = 1.f;
float xa28_ = 0.f; float xa28_ = 0.f;
@ -443,6 +443,7 @@ public:
TUniqueId GetLockonObjectId() const { return x310_lockonObjectId; } TUniqueId GetLockonObjectId() const { return x310_lockonObjectId; }
TUniqueId GetScanningObjectId() const { return x3b4_scanningObject; } TUniqueId GetScanningObjectId() const { return x3b4_scanningObject; }
bool IsNewScanScanning() const { return x9c6_30_newScanScanning; } bool IsNewScanScanning() const { return x9c6_30_newScanScanning; }
float GetThreatOverride() const { return xa1c_threatOverride; }
bool IsOverrideRadarRadius() const { return x9c6_31_overrideRadarRadius; } bool IsOverrideRadarRadius() const { return x9c6_31_overrideRadarRadius; }
float GetRadarXYRadiusOverride() const { return xa20_radarXYRadiusOverride; } float GetRadarXYRadiusOverride() const { return xa20_radarXYRadiusOverride; }
float GetRadarZRadiusOverride() const { return xa24_radarZRadiusOverride; } float GetRadarZRadiusOverride() const { return xa24_radarZRadiusOverride; }
@ -453,9 +454,9 @@ public:
bool IsLookControlHeld() const { return x3de_lookControlHeld; } bool IsLookControlHeld() const { return x3de_lookControlHeld; }
CPlayerGun* GetPlayerGun() const { return x490_gun.get(); } CPlayerGun* GetPlayerGun() const { return x490_gun.get(); }
CMorphBall* GetMorphBall() const { return x768_morphball.get(); } CMorphBall* GetMorphBall() const { return x768_morphball.get(); }
CPlayerCameraBob* GetCameraBob() const { return x76c_cameraBob.get(); }
void Touch(); void Touch();
const std::unique_ptr<CPlayerCameraBob>& GetCameraBob() const { return x76c_cameraBob; }
void DecrementPhazon(); void DecrementPhazon();
void IncrementPhazon(); void IncrementPhazon();

View File

@ -30,7 +30,7 @@ enum class ETriggerFlags : u32
DetectUnmorphedPlayer = (1 << 16), DetectUnmorphedPlayer = (1 << 16),
BlockEnvironmentalEffects = (1 << 17) BlockEnvironmentalEffects = (1 << 17)
}; };
ENABLE_BITWISE_ENUM(ETriggerFlags); ENABLE_BITWISE_ENUM(ETriggerFlags)
class CScriptTrigger : public CActor class CScriptTrigger : public CActor
{ {
@ -85,6 +85,8 @@ public:
rstl::optional_object<zeus::CAABox> GetTouchBounds() const; rstl::optional_object<zeus::CAABox> GetTouchBounds() const;
void Touch(CActor &, CStateManager &); void Touch(CActor &, CStateManager &);
zeus::CAABox GetTriggerBoundsWR() const; zeus::CAABox GetTriggerBoundsWR() const;
const CDamageInfo& GetDamageInfo() const { return x100_damageInfo; }
ETriggerFlags GetTriggerFlags() const { return x12c_flags; }
}; };
} }

@ -1 +1 @@
Subproject commit 1b6e3472d3a2f5d8cc6e3b0283e26071fcc8755f Subproject commit ce3b1c7399061d0199268a8da1ec3fdfa15c51a2