More CPlayer implementations

This commit is contained in:
Jack Andersen 2017-07-19 07:47:57 -10:00
parent ccc3b99940
commit c5514b3374
6 changed files with 122 additions and 13 deletions

View File

@ -42,6 +42,9 @@ struct ITweakPlayerGun : ITweak
virtual float GetX38() const = 0; // x38 virtual float GetX38() const = 0; // x38
virtual float GetGunHolsterTime() const=0; virtual float GetGunHolsterTime() const=0;
virtual float GetGunNotFiringTime() const=0; virtual float GetGunNotFiringTime() const=0;
virtual float GetFixedVerticalAim() const=0;
virtual const zeus::CVector3f& GetGunPosition() const=0;
virtual const zeus::CVector3f& GetGrapplingArmPosition() const=0;
virtual float GetRichochetDamage(atUint32) const = 0; virtual float GetRichochetDamage(atUint32) const = 0;
}; };
} }

View File

@ -27,11 +27,11 @@ struct CTweakPlayerGun : ITweakPlayerGun
Value<float> x38_; Value<float> x38_;
Value<float> x3c_gunHolsterTime; Value<float> x3c_gunHolsterTime;
Value<float> x40_gunNotFiringTime; Value<float> x40_gunNotFiringTime;
Value<float> x44_; Value<float> x44_fixedVerticalAim;
Value<float> x48_; Value<float> x48_;
Value<zeus::CVector3f> x4c_; Value<zeus::CVector3f> x4c_gunPosition;
Value<zeus::CVector3f> x58_; Value<zeus::CVector3f> x58_;
Value<zeus::CVector3f> x64_; Value<zeus::CVector3f> x64_grapplingArmPosition;
SShotParam x70_bomb; SShotParam x70_bomb;
SShotParam x8c_powerBomb; SShotParam x8c_powerBomb;
SShotParam x1d4_missile; SShotParam x1d4_missile;
@ -50,7 +50,7 @@ struct CTweakPlayerGun : ITweakPlayerGun
CTweakPlayerGun(athena::io::IStreamReader& r) CTweakPlayerGun(athena::io::IStreamReader& r)
{ {
this->read(r); this->read(r);
x44_ = zeus::degToRad(x44_); x44_fixedVerticalAim = zeus::degToRad(x44_fixedVerticalAim);
} }
float GetX24() const { return x24_; } float GetX24() const { return x24_; }
@ -61,6 +61,9 @@ struct CTweakPlayerGun : ITweakPlayerGun
float GetX38() const { return x38_; } float GetX38() const { return x38_; }
float GetGunHolsterTime() const { return x3c_gunHolsterTime; } float GetGunHolsterTime() const { return x3c_gunHolsterTime; }
float GetGunNotFiringTime() const { return x40_gunNotFiringTime; } float GetGunNotFiringTime() const { return x40_gunNotFiringTime; }
float GetFixedVerticalAim() const { return x44_fixedVerticalAim; }
const zeus::CVector3f& GetGunPosition() const { return x4c_gunPosition; }
const zeus::CVector3f& GetGrapplingArmPosition() const { return x64_grapplingArmPosition; }
float GetRichochetDamage(atUint32 type) const float GetRichochetDamage(atUint32 type) const
{ {
switch (type) switch (type)

View File

@ -32,6 +32,7 @@ private:
struct struct
{ {
bool x3b2_25_beamActive : 1; bool x3b2_25_beamActive : 1;
bool x3b2_27_armMoving : 1;
}; };
u32 _dummy = 0; u32 _dummy = 0;
}; };
@ -43,6 +44,7 @@ public:
void SetAnimState(EArmState state); void SetAnimState(EArmState state);
EArmState GetAnimState() const { return x334_animState; } EArmState GetAnimState() const { return x334_animState; }
bool BeamActive() const { return x3b2_25_beamActive; } bool BeamActive() const { return x3b2_25_beamActive; }
bool IsArmMoving() const { return x3b2_27_armMoving; }
void Activate(bool); void Activate(bool);
void GrappleBeamDisconnected(); void GrappleBeamDisconnected();
void GrappleBeamConnected(); void GrappleBeamConnected();

View File

@ -111,7 +111,7 @@ private:
float x3a0_ = 0.f; float x3a0_ = 0.f;
CFidget x3a4_fidget; CFidget x3a4_fidget;
zeus::CVector3f x3dc_damageLocation; zeus::CVector3f x3dc_damageLocation;
zeus::CTransform x3e8_; zeus::CTransform x3e8_xf;
zeus::CTransform x418_; zeus::CTransform x418_;
zeus::CTransform x448_; zeus::CTransform x448_;
zeus::CTransform x478_; zeus::CTransform x478_;
@ -220,7 +220,7 @@ public:
u32 GetSelectedBeam() const { return x310_selectedBeam; } u32 GetSelectedBeam() const { return x310_selectedBeam; }
u32 GetPendingSelectedBeam() const { return x314_pendingSelectedBeam; } u32 GetPendingSelectedBeam() const { return x314_pendingSelectedBeam; }
const CGunMorph& GetGunMorph() const { return x678_morph; } const CGunMorph& GetGunMorph() const { return x678_morph; }
void SetX3e8(const zeus::CTransform& xf) { x3e8_ = xf; } void SetTransform(const zeus::CTransform& xf) { x3e8_xf = xf; }
CGrappleArm& GetGrappleArm() { return *x740_grappleArm; } CGrappleArm& GetGrappleArm() { return *x740_grappleArm; }
void DamageRumble(const zeus::CVector3f& location, float damage, const CStateManager& mgr); void DamageRumble(const zeus::CVector3f& location, float damage, const CStateManager& mgr);
void ProcessInput(const CFinalInput& input, CStateManager& mgr); void ProcessInput(const CFinalInput& input, CStateManager& mgr);

View File

@ -67,7 +67,7 @@ CPlayer::CPlayer(TUniqueId uid, const zeus::CTransform& xf, const zeus::CAABox&
SetInertiaTensorScalar(xe8_mass); SetInertiaTensorScalar(xe8_mass);
x1f4_lastNonCollidingState = GetMotionState(); x1f4_lastNonCollidingState = GetMotionState();
x490_gun->SetX3e8(x34_transform); x490_gun->SetTransform(x34_transform);
x490_gun->GetGrappleArm().SetX220(x34_transform); x490_gun->GetGrappleArm().SetX220(x34_transform);
InitializeBallTransition(); InitializeBallTransition();
@ -1204,7 +1204,7 @@ void CPlayer::UpdateFootstepSounds(const CFinalInput& input, CStateManager& mgr,
if (x790_footstepSfxSel != EFootstepSfx::None && x78c_footstepSfxTimer > sfxDelay) if (x790_footstepSfxSel != EFootstepSfx::None && x78c_footstepSfxTimer > sfxDelay)
{ {
static float EarHeight = GetEyeHeight() - 0.1f; static float EarHeight = GetEyeHeight() - 0.1f;
if (xe6_24_fluidCounter && x828_waterLevelOnPlayer > 0.f && x828_waterLevelOnPlayer < EarHeight) if (xe6_24_fluidCounter != 0 && x828_waterLevelOnPlayer > 0.f && x828_waterLevelOnPlayer < EarHeight)
{ {
if (x82c_inLava) if (x82c_inLava)
{ {
@ -1289,11 +1289,52 @@ void CPlayer::UpdateGunState(const CFinalInput&, CStateManager& mgr)
{ {
} }
void CPlayer::ForceGunOrientation(const zeus::CTransform&, CStateManager& mgr) {} void CPlayer::ResetGun(CStateManager& mgr)
{
x498_gunHolsterState = EGunHolsterState::Holstered;
x49c_gunNotFiringTimeout = 0.f;
x490_gun->CancelFiring(mgr);
ResetAimTargetPrediction(kInvalidUniqueId);
}
void CPlayer::UpdateCameraState(CStateManager& mgr) {} void CPlayer::UpdateArmAndGunTransforms(float dt, CStateManager& mgr)
{
zeus::CVector3f grappleOffset;
zeus::CVector3f gunOffset;
if (x2f8_morphTransState == EPlayerMorphBallState::Morphed)
{
gunOffset = {0.f, 0.f, 0.6f};
}
else
{
gunOffset = g_tweakPlayerGun->GetGunPosition();
grappleOffset = x490_gun->GetGrappleArm().IsArmMoving() ?
zeus::CVector3f::skZero : g_tweakPlayerGun->GetGrapplingArmPosition();
gunOffset.z += GetEyeHeight();
grappleOffset.z += GetEyeHeight();
}
void CPlayer::UpdateDebugCamera(CStateManager& mgr) {} UpdateGunTransform(gunOffset + x76c_cameraBob->GetGunBobTransformation().origin, mgr);
UpdateGrappleArmTransform(grappleOffset, mgr, dt);
}
void CPlayer::ForceGunOrientation(const zeus::CTransform& xf, CStateManager& mgr)
{
ResetGun(mgr);
x530_ = xf.basis[1];
x490_gun->SetTransform(xf);
UpdateArmAndGunTransforms(0.01f, mgr);
}
void CPlayer::UpdateCameraState(CStateManager& mgr)
{
UpdateCinematicState(mgr);
}
void CPlayer::UpdateDebugCamera(CStateManager& mgr)
{
// Empty
}
void CPlayer::UpdateCameraTimers(float dt, const CFinalInput& input) void CPlayer::UpdateCameraTimers(float dt, const CFinalInput& input)
{ {
@ -1335,7 +1376,65 @@ CFirstPersonCamera& CPlayer::GetFirstPersonCamera(CStateManager& mgr)
return *mgr.GetCameraManager()->GetFirstPersonCamera(); return *mgr.GetCameraManager()->GetFirstPersonCamera();
} }
void CPlayer::UpdateGunTransform(const zeus::CVector3f&, float, CStateManager& mgr, bool) {} void CPlayer::UpdateGunTransform(const zeus::CVector3f& gunPos, CStateManager& mgr)
{
float eyeHeight = GetEyeHeight();
zeus::CTransform camXf = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr);
zeus::CTransform gunXf = camXf;
zeus::CVector3f viewGunPos;
if (x2f8_morphTransState == EPlayerMorphBallState::Morphing)
viewGunPos = camXf * (gunPos - zeus::CVector3f(0.f, 0.f, eyeHeight));
else
viewGunPos = camXf.rotate(gunPos - zeus::CVector3f(0.f, 0.f, eyeHeight)) + GetEyePosition();
zeus::CUnitVector3f rightDir(gunXf.basis[0]);
gunXf.origin = viewGunPos;
switch (x498_gunHolsterState)
{
case EGunHolsterState::Drawing:
{
float liftAngle = zeus::clamp(-1.f, x49c_gunNotFiringTimeout / 0.45f, 1.f);
if (liftAngle > 0.01f)
{
gunXf = zeus::CQuaternion::fromAxisAngle(rightDir, -liftAngle *
g_tweakPlayerGun->GetFixedVerticalAim()).toTransform() *
camXf.getRotation();
gunXf.origin = viewGunPos;
}
break;
}
case EGunHolsterState::Holstered:
{
gunXf = zeus::CQuaternion::fromAxisAngle(rightDir, -g_tweakPlayerGun->GetFixedVerticalAim()).toTransform() *
camXf.getRotation();
gunXf.origin = viewGunPos;
break;
}
case EGunHolsterState::Holstering:
{
float liftAngle = 1.f -
zeus::clamp(-1.f, x49c_gunNotFiringTimeout / g_tweakPlayerGun->GetGunHolsterTime(), 1.f);
if (x2f8_morphTransState == EPlayerMorphBallState::Morphing)
liftAngle = 1.f - zeus::clamp(-1.f, x49c_gunNotFiringTimeout / 0.1f, 1.f);
if (liftAngle > 0.01f)
{
gunXf = zeus::CQuaternion::fromAxisAngle(rightDir, -liftAngle *
g_tweakPlayerGun->GetFixedVerticalAim()).toTransform() *
camXf.getRotation();
gunXf.origin = viewGunPos;
}
break;
}
default:
break;
}
x490_gun->SetTransform(gunXf);
UpdateAimTargetPrediction(gunXf, mgr);
UpdateAssistedAiming(gunXf, mgr);
}
void CPlayer::UpdateAssistedAiming(const zeus::CTransform& xf, const CStateManager& mgr) void CPlayer::UpdateAssistedAiming(const zeus::CTransform& xf, const CStateManager& mgr)
{ {

View File

@ -478,13 +478,15 @@ public:
void UpdateVisorTransition(float, CStateManager& mgr); void UpdateVisorTransition(float, CStateManager& mgr);
void UpdateVisorState(const CFinalInput&, float, CStateManager& mgr); void UpdateVisorState(const CFinalInput&, float, CStateManager& mgr);
void UpdateGunState(const CFinalInput&, CStateManager& mgr); void UpdateGunState(const CFinalInput&, CStateManager& mgr);
void ResetGun(CStateManager& mgr);
void UpdateArmAndGunTransforms(float dt, CStateManager& mgr);
void ForceGunOrientation(const zeus::CTransform&, CStateManager& mgr); void ForceGunOrientation(const zeus::CTransform&, CStateManager& mgr);
void UpdateCameraState(CStateManager& mgr); void UpdateCameraState(CStateManager& mgr);
void UpdateDebugCamera(CStateManager& mgr); void UpdateDebugCamera(CStateManager& mgr);
void UpdateCameraTimers(float dt, const CFinalInput& input); void UpdateCameraTimers(float dt, const CFinalInput& input);
void UpdateMorphBallState(const CFinalInput&, CStateManager& mgr); void UpdateMorphBallState(const CFinalInput&, CStateManager& mgr);
CFirstPersonCamera& GetFirstPersonCamera(CStateManager& mgr); CFirstPersonCamera& GetFirstPersonCamera(CStateManager& mgr);
void UpdateGunTransform(const zeus::CVector3f&, float, CStateManager& mgr, bool); void UpdateGunTransform(const zeus::CVector3f&, CStateManager& mgr);
void UpdateAssistedAiming(const zeus::CTransform& xf, const CStateManager& mgr); void UpdateAssistedAiming(const zeus::CTransform& xf, const CStateManager& mgr);
void UpdateAimTargetPrediction(const zeus::CTransform& xf, const CStateManager& mgr); void UpdateAimTargetPrediction(const zeus::CTransform& xf, const CStateManager& mgr);
void ResetAimTargetPrediction(TUniqueId target); void ResetAimTargetPrediction(TUniqueId target);