CChozoGhost: Fix IsOnGround

This commit is contained in:
Luke Street 2020-03-09 10:41:34 -04:00
parent 830db8772d
commit 5c9dd55b80
2 changed files with 20 additions and 19 deletions

View File

@ -12,6 +12,7 @@
#include "Runtime/World/CTeamAiMgr.hpp" #include "Runtime/World/CTeamAiMgr.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path #include "TCastTo.hpp" // Generated file, do not modify include path
namespace urde::MP1 { namespace urde::MP1 {
CChozoGhost::CBehaveChance::CBehaveChance(CInputStream& in) CChozoGhost::CBehaveChance::CBehaveChance(CInputStream& in)
: x0_propertyCount(in.readUint32Big()) : x0_propertyCount(in.readUint32Big())
@ -96,10 +97,10 @@ CChozoGhost::CChozoGhost(TUniqueId uid, std::string_view name, const CEntityInfo
, x658_(f9) , x658_(f9)
, x65c_nearChance(nearChance) , x65c_nearChance(nearChance)
, x660_midChance(midChance) , x660_midChance(midChance)
, x664_24_onGround(w1) , x664_24_(w1)
, x664_25_flinch(!w1) , x664_25_flinch(!w1)
, x664_26_(false) , x664_26_(false)
, x664_27_(false) , x664_27_onGround(false)
, x664_28_(false) , x664_28_(false)
, x664_29_(false) , x664_29_(false)
, x664_30_(false) , x664_30_(false)
@ -110,7 +111,7 @@ CChozoGhost::CChozoGhost(TUniqueId uid, std::string_view name, const CEntityInfo
, x665_27_playerInLeashRange(false) , x665_27_playerInLeashRange(false)
, x665_28_inRange(false) , x665_28_inRange(false)
, x665_29_aggressive(false) , x665_29_aggressive(false)
, x680_behaveType(x664_24_onGround ? EBehaveType::Attack : EBehaveType::Four) , x680_behaveType(x664_24_ ? EBehaveType::Attack : EBehaveType::Four)
, x68c_boneTracking(*GetModelData()->GetAnimationData(), "Head_1"sv, zeus::degToRad(80.f), zeus::degToRad(180.f), , x68c_boneTracking(*GetModelData()->GetAnimationData(), "Head_1"sv, zeus::degToRad(80.f), zeus::degToRad(180.f),
EBoneTrackingFlags::None) { EBoneTrackingFlags::None) {
x578_.Token().Lock(); x578_.Token().Lock();
@ -131,6 +132,7 @@ CChozoGhost::CChozoGhost(TUniqueId uid, std::string_view name, const CEntityInfo
CreateShadow(false); CreateShadow(false);
MakeThermalColdAndHot(); MakeThermalColdAndHot();
} }
void CChozoGhost::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) { void CChozoGhost::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
CPatterned::AcceptScriptMsg(msg, uid, mgr); CPatterned::AcceptScriptMsg(msg, uid, mgr);
@ -233,7 +235,6 @@ void CChozoGhost::Render(const CStateManager& mgr) const {
} }
void CChozoGhost::Touch(CActor& act, CStateManager& mgr) { void CChozoGhost::Touch(CActor& act, CStateManager& mgr) {
if (IsVisibleEnough(mgr)) { if (IsVisibleEnough(mgr)) {
if (TCastToPtr<CPlayer> pl = act) { if (TCastToPtr<CPlayer> pl = act) {
if (x420_curDamageRemTime <= 0.f) { if (x420_curDamageRemTime <= 0.f) {
@ -374,7 +375,7 @@ void CChozoGhost::Generate(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) { if (msg == EStateMsg::Activate) {
x330_stateMachineState.SetDelay(x56c_fadeOutDelay); x330_stateMachineState.SetDelay(x56c_fadeOutDelay);
x32c_animState = EAnimState::Ready; x32c_animState = EAnimState::Ready;
x664_27_ = false; x664_27_onGround = false;
CRayCastResult res = mgr.RayStaticIntersection(GetTranslation(), zeus::skDown, 100.f, CRayCastResult res = mgr.RayStaticIntersection(GetTranslation(), zeus::skDown, 100.f,
CMaterialFilter::MakeInclude({EMaterialTypes::Floor})); CMaterialFilter::MakeInclude({EMaterialTypes::Floor}));
if (res.IsInvalid()) { if (res.IsInvalid()) {
@ -395,16 +396,16 @@ void CChozoGhost::Generate(CStateManager& mgr, EStateMsg msg, float arg) {
FloatToLevel(x678_, arg); FloatToLevel(x678_, arg);
} else if (x32c_animState == EAnimState::Repeat) { } else if (x32c_animState == EAnimState::Repeat) {
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Crouch); x450_bodyController->SetLocomotionType(pas::ELocomotionType::Crouch);
if (!x664_27_) { if (!x664_27_onGround) {
zeus::CVector3f pos = GetTranslation(); zeus::CVector3f pos = GetTranslation();
SetTranslation({pos.x(), pos.y(), x678_ + x668_}); SetTranslation({pos.x(), pos.y(), x678_ + x668_});
x664_27_ = true; x664_27_onGround = true;
} }
} }
} else if (msg == EStateMsg::Deactivate) { } else if (msg == EStateMsg::Deactivate) {
x32c_animState = EAnimState::NotReady; x32c_animState = EAnimState::NotReady;
x665_24_ = false; x665_24_ = false;
x664_27_ = false; x664_27_onGround = false;
} }
} }
@ -513,18 +514,18 @@ void CChozoGhost::Taunt(CStateManager& mgr, EStateMsg msg, float arg) {
void CChozoGhost::Hurled(CStateManager& mgr, EStateMsg msg, float arg) { void CChozoGhost::Hurled(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) { if (msg == EStateMsg::Activate) {
x328_25_verticalMovement = false; x328_25_verticalMovement = false;
x664_27_ = false; x664_27_onGround = false;
x665_24_ = true; x665_24_ = true;
} else if (msg == EStateMsg::Update) { } else if (msg == EStateMsg::Update) {
x3e8_alphaDelta = 2.f; x3e8_alphaDelta = 2.f;
if (x664_27_) if (x664_27_onGround)
return; return;
if (x138_velocity.z() < 0.f) { if (x138_velocity.z() < 0.f) {
CRayCastResult res = mgr.RayStaticIntersection(GetTranslation() + zeus::skUp, zeus::skDown, 2.f, CRayCastResult res = mgr.RayStaticIntersection(GetTranslation() + zeus::skUp, zeus::skDown, 2.f,
CMaterialFilter::MakeInclude({EMaterialTypes::Floor})); CMaterialFilter::MakeInclude({EMaterialTypes::Floor}));
if (res.IsValid()) { if (res.IsValid()) {
x664_27_ = true; x664_27_onGround = true;
x150_momentum.zeroOut(); x150_momentum.zeroOut();
zeus::CVector3f velNoZ = x138_velocity; zeus::CVector3f velNoZ = x138_velocity;
velNoZ.z() = 0.f; velNoZ.z() = 0.f;
@ -533,7 +534,7 @@ void CChozoGhost::Hurled(CStateManager& mgr, EStateMsg msg, float arg) {
x330_stateMachineState.SetCodeTrigger(); x330_stateMachineState.SetCodeTrigger();
} }
} }
if (!x664_27_ && x638_hurlRecoverTime < x330_stateMachineState.GetTime()) { if (!x664_27_onGround && x638_hurlRecoverTime < x330_stateMachineState.GetTime()) {
GetBodyController()->GetCommandMgr().DeliverCmd(CBodyStateCmd(EBodyStateCmd::ExitState)); GetBodyController()->GetCommandMgr().DeliverCmd(CBodyStateCmd(EBodyStateCmd::ExitState));
GetBodyController()->SetLocomotionType(pas::ELocomotionType::Lurk); GetBodyController()->SetLocomotionType(pas::ELocomotionType::Lurk);
x330_stateMachineState.SetCodeTrigger(); x330_stateMachineState.SetCodeTrigger();
@ -630,7 +631,7 @@ u8 CChozoGhost::GetModelAlphau8(const CStateManager& mgr) const {
return u8(x42c_color.a() * 255); return u8(x42c_color.a() * 255);
} }
bool CChozoGhost::IsOnGround() const { return x664_24_onGround; } bool CChozoGhost::IsOnGround() const { return x664_27_onGround; }
CProjectileInfo* CChozoGhost::GetProjectileInfo() { return x67c_ == 2 ? &x578_ : &x5a0_; } CProjectileInfo* CChozoGhost::GetProjectileInfo() { return x67c_ == 2 ? &x578_ : &x5a0_; }
@ -673,6 +674,7 @@ const CChozoGhost::CBehaveChance& CChozoGhost::ChooseBehaveChanceRange(CStateMan
else else
return x5c8_; return x5c8_;
} }
void CChozoGhost::FindNearestSolid(CStateManager& mgr, const zeus::CVector3f& dir) { void CChozoGhost::FindNearestSolid(CStateManager& mgr, const zeus::CVector3f& dir) {
CRayCastResult res = mgr.RayStaticIntersection(GetBoundingBox().center() + (dir * 8.f), -dir, 8.f, CRayCastResult res = mgr.RayStaticIntersection(GetBoundingBox().center() + (dir * 8.f), -dir, 8.f,
CMaterialFilter::MakeInclude({EMaterialTypes::Solid})); CMaterialFilter::MakeInclude({EMaterialTypes::Solid}));

View File

@ -60,10 +60,10 @@ private:
float x658_; float x658_;
u32 x65c_nearChance; u32 x65c_nearChance;
u32 x660_midChance; u32 x660_midChance;
bool x664_24_onGround : 1; bool x664_24_ : 1;
bool x664_25_flinch : 1; bool x664_25_flinch : 1;
bool x664_26_ : 1; bool x664_26_ : 1;
bool x664_27_ : 1; bool x664_27_onGround : 1;
bool x664_28_ : 1; bool x664_28_ : 1;
bool x664_29_ : 1; bool x664_29_ : 1;
bool x664_30_ : 1; bool x664_30_ : 1;
@ -78,7 +78,6 @@ private:
float x66c_ = 0.f; float x66c_ = 0.f;
float x670_ = 0.f; float x670_ = 0.f;
TUniqueId x674_coverPoint = kInvalidUniqueId; TUniqueId x674_coverPoint = kInvalidUniqueId;
float x6c8_ = 0.f;
float x678_ = 0.f; float x678_ = 0.f;
u32 x67c_ = -1; u32 x67c_ = -1;
EBehaveType x680_behaveType = EBehaveType::Lurk; EBehaveType x680_behaveType = EBehaveType::Lurk;
@ -86,9 +85,9 @@ private:
CSteeringBehaviors x688_; CSteeringBehaviors x688_;
CBoneTracking x68c_boneTracking; CBoneTracking x68c_boneTracking;
TUniqueId x6c4_teamMgr = kInvalidUniqueId; TUniqueId x6c4_teamMgr = kInvalidUniqueId;
float x6c8_ = 0.f;
zeus::CVector3f x6cc_; zeus::CVector3f x6cc_;
u32 x6d8_ = 1; u32 x6d8_ = 1;
u32 x6dc_;
void AddToTeam(CStateManager& mgr); void AddToTeam(CStateManager& mgr);
void RemoveFromTeam(CStateManager& mgr); void RemoveFromTeam(CStateManager& mgr);