From 8c2d954a01f771c9705e0732c28d2ea5cc2c3930 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 14 Aug 2020 01:08:11 -0400 Subject: [PATCH] CFlaahgraTentacle: Fixes & implement Death --- Runtime/MP1/World/CFlaahgraTentacle.cpp | 40 +++++++++++++++++-------- Runtime/MP1/World/CFlaahgraTentacle.hpp | 5 +++- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/Runtime/MP1/World/CFlaahgraTentacle.cpp b/Runtime/MP1/World/CFlaahgraTentacle.cpp index a9c5cc1c2..810a23cd9 100644 --- a/Runtime/MP1/World/CFlaahgraTentacle.cpp +++ b/Runtime/MP1/World/CFlaahgraTentacle.cpp @@ -28,8 +28,10 @@ CFlaahgraTentacle::CFlaahgraTentacle(TUniqueId uid, std::string_view name, const x460_knockBackController.SetAutoResetImpulse(false); CreateShadow(false); } -void CFlaahgraTentacle::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) { +void CFlaahgraTentacle::Accept(IVisitor& visitor) { visitor.Visit(this); } + +void CFlaahgraTentacle::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) { switch (msg) { case EScriptObjectMessage::Registered: { x450_bodyController->Activate(mgr); @@ -122,11 +124,9 @@ void CFlaahgraTentacle::SetupCollisionManager(CStateManager& mgr) { for (u32 i = 0; i < x56c_collisionManager->GetNumCollisionActors(); ++i) { const CJointCollisionDescription& desc = x56c_collisionManager->GetCollisionDescFromIndex(i); if (const TCastToPtr colAct = mgr.ObjectById(desc.GetCollisionActorId())) { - colAct->SetMaterialFilter(CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Player}, - {EMaterialTypes::Character, - EMaterialTypes::CollisionActor, - EMaterialTypes::NoStaticCollision, - EMaterialTypes::NoPlatformCollision})); + colAct->SetMaterialFilter(CMaterialFilter::MakeIncludeExclude( + {EMaterialTypes::Player}, {EMaterialTypes::Character, EMaterialTypes::CollisionActor, + EMaterialTypes::NoStaticCollision, EMaterialTypes::NoPlatformCollision})); colAct->AddMaterial(EMaterialTypes::ScanPassthrough); colAct->SetDamageVulnerability(*GetDamageVulnerability()); @@ -138,8 +138,8 @@ void CFlaahgraTentacle::SetupCollisionManager(CStateManager& mgr) { RemoveMaterial(EMaterialTypes::Solid, EMaterialTypes::Target, EMaterialTypes::Orbit, mgr); AddMaterial(EMaterialTypes::Scannable, mgr); - } + zeus::CVector3f CFlaahgraTentacle::GetAimPosition(const CStateManager& mgr, float dt) const { if (const TCastToConstPtr colAct = mgr.GetObjectById(x57c_tentacleTipAct)) { return colAct->GetTranslation(); @@ -147,6 +147,7 @@ zeus::CVector3f CFlaahgraTentacle::GetAimPosition(const CStateManager& mgr, floa return CPatterned::GetAimPosition(mgr, dt); } + void CFlaahgraTentacle::ExtractTentacle(CStateManager& mgr) { if (!Inside(mgr, 0.f)) { return; @@ -165,6 +166,7 @@ void CFlaahgraTentacle::RetractTentacle(CStateManager& mgr) { trigger->SetForceVector({}); } } + void CFlaahgraTentacle::SaveBombSlotInfo(CStateManager& mgr) { for (const SConnection& conn : GetConnectionList()) { if (conn.x0_state != EScriptObjectState::Modify || conn.x4_msg != EScriptObjectMessage::ToggleActive) { @@ -190,7 +192,7 @@ bool CFlaahgraTentacle::ShouldAttack(CStateManager& mgr, float) { } if (const TCastToConstPtr colAct = mgr.GetObjectById(x57c_tentacleTipAct)) { - const float mag = (colAct->GetTranslation().toVec2f() - mgr.GetPlayer().GetTranslation().toVec2f()).magSquared(); + const float mag = (mgr.GetPlayer().GetTranslation().toVec2f() - colAct->GetTranslation().toVec2f()).magSquared(); return mag >= (x2fc_minAttackRange * x2fc_minAttackRange) && mag <= (x300_maxAttackRange * x300_maxAttackRange); } @@ -208,16 +210,16 @@ void CFlaahgraTentacle::Attack(CStateManager& mgr, EStateMsg msg, float) { x450_bodyController->GetCommandMgr().DeliverCmd( CBCMeleeAttackCmd((x578_ > 0.f ? pas::ESeverity::Zero : pas::ESeverity::One), {})); } - - } else if (x568_ == 2 && x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::MeleeAttack) { + } else if (x568_ == 2 && + x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::MeleeAttack) { x568_ = 3; } - } else if (msg == EStateMsg::Deactivate) { x574_ = (x308_attackTimeVariation * mgr.GetActiveRandom()->Float()) + x304_averageAttackTime; x578_ = 0.f; } } + void CFlaahgraTentacle::Retreat(CStateManager& mgr, EStateMsg msg, float) { if (msg == EStateMsg::Update) { if (!x58e_24_) { @@ -229,7 +231,7 @@ void CFlaahgraTentacle::Retreat(CStateManager& mgr, EStateMsg msg, float) { } if (const TCastToConstPtr trigger = mgr.ObjectById(x58c_triggerId)) { - if (trigger->IsPlayerTriggerProc()) { + if (!trigger->IsPlayerTriggerProc()) { x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed); } } @@ -237,6 +239,7 @@ void CFlaahgraTentacle::Retreat(CStateManager& mgr, EStateMsg msg, float) { x58e_24_ = false; } } + void CFlaahgraTentacle::InActive(CStateManager& mgr, EStateMsg msg, float arg) { if (msg == EStateMsg::Activate) { x570_ = 0.f; @@ -258,4 +261,15 @@ void CFlaahgraTentacle::InActive(CStateManager& mgr, EStateMsg msg, float arg) { } } -} \ No newline at end of file +void CFlaahgraTentacle::Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state) { + if (!IsAlive()) { + return; + } + x330_stateMachineState.SetState(mgr, *this, GetStateMachine(), "Dead"); + if (GetBodyController()->GetPercentageFrozen() > 0.f) { + GetBodyController()->UnFreeze(); + } + x400_25_alive = false; +} + +} // namespace urde::MP1 diff --git a/Runtime/MP1/World/CFlaahgraTentacle.hpp b/Runtime/MP1/World/CFlaahgraTentacle.hpp index 1647f3ed9..fc2ca11e8 100644 --- a/Runtime/MP1/World/CFlaahgraTentacle.hpp +++ b/Runtime/MP1/World/CFlaahgraTentacle.hpp @@ -27,11 +27,13 @@ class CFlaahgraTentacle : public CPatterned { void ExtractTentacle(CStateManager&); void RetractTentacle(CStateManager&); void SaveBombSlotInfo(CStateManager&); + public: DEFINE_PATTERNED(FlaahgraTentacle); CFlaahgraTentacle(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&, const CPatternedInfo&, const CActorParameters&); + void Accept(IVisitor&) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void Think(float, CStateManager&) override; @@ -49,5 +51,6 @@ public: void Attack(CStateManager&, EStateMsg, float) override; void Retreat(CStateManager&, EStateMsg, float) override; void InActive(CStateManager&, EStateMsg, float) override; + void Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state) override; }; -} \ No newline at end of file +} // namespace urde::MP1