CFlaahgraTentacle: Fixes & implement Death

This commit is contained in:
Luke Street 2020-08-14 01:08:11 -04:00
parent 9de84dace3
commit 8c2d954a01
2 changed files with 31 additions and 14 deletions

View File

@ -28,8 +28,10 @@ CFlaahgraTentacle::CFlaahgraTentacle(TUniqueId uid, std::string_view name, const
x460_knockBackController.SetAutoResetImpulse(false); x460_knockBackController.SetAutoResetImpulse(false);
CreateShadow(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) { switch (msg) {
case EScriptObjectMessage::Registered: { case EScriptObjectMessage::Registered: {
x450_bodyController->Activate(mgr); x450_bodyController->Activate(mgr);
@ -122,11 +124,9 @@ void CFlaahgraTentacle::SetupCollisionManager(CStateManager& mgr) {
for (u32 i = 0; i < x56c_collisionManager->GetNumCollisionActors(); ++i) { for (u32 i = 0; i < x56c_collisionManager->GetNumCollisionActors(); ++i) {
const CJointCollisionDescription& desc = x56c_collisionManager->GetCollisionDescFromIndex(i); const CJointCollisionDescription& desc = x56c_collisionManager->GetCollisionDescFromIndex(i);
if (const TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(desc.GetCollisionActorId())) { if (const TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(desc.GetCollisionActorId())) {
colAct->SetMaterialFilter(CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Player}, colAct->SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(
{EMaterialTypes::Character, {EMaterialTypes::Player}, {EMaterialTypes::Character, EMaterialTypes::CollisionActor,
EMaterialTypes::CollisionActor, EMaterialTypes::NoStaticCollision, EMaterialTypes::NoPlatformCollision}));
EMaterialTypes::NoStaticCollision,
EMaterialTypes::NoPlatformCollision}));
colAct->AddMaterial(EMaterialTypes::ScanPassthrough); colAct->AddMaterial(EMaterialTypes::ScanPassthrough);
colAct->SetDamageVulnerability(*GetDamageVulnerability()); colAct->SetDamageVulnerability(*GetDamageVulnerability());
@ -138,8 +138,8 @@ void CFlaahgraTentacle::SetupCollisionManager(CStateManager& mgr) {
RemoveMaterial(EMaterialTypes::Solid, EMaterialTypes::Target, EMaterialTypes::Orbit, mgr); RemoveMaterial(EMaterialTypes::Solid, EMaterialTypes::Target, EMaterialTypes::Orbit, mgr);
AddMaterial(EMaterialTypes::Scannable, mgr); AddMaterial(EMaterialTypes::Scannable, mgr);
} }
zeus::CVector3f CFlaahgraTentacle::GetAimPosition(const CStateManager& mgr, float dt) const { zeus::CVector3f CFlaahgraTentacle::GetAimPosition(const CStateManager& mgr, float dt) const {
if (const TCastToConstPtr<CCollisionActor> colAct = mgr.GetObjectById(x57c_tentacleTipAct)) { if (const TCastToConstPtr<CCollisionActor> colAct = mgr.GetObjectById(x57c_tentacleTipAct)) {
return colAct->GetTranslation(); return colAct->GetTranslation();
@ -147,6 +147,7 @@ zeus::CVector3f CFlaahgraTentacle::GetAimPosition(const CStateManager& mgr, floa
return CPatterned::GetAimPosition(mgr, dt); return CPatterned::GetAimPosition(mgr, dt);
} }
void CFlaahgraTentacle::ExtractTentacle(CStateManager& mgr) { void CFlaahgraTentacle::ExtractTentacle(CStateManager& mgr) {
if (!Inside(mgr, 0.f)) { if (!Inside(mgr, 0.f)) {
return; return;
@ -165,6 +166,7 @@ void CFlaahgraTentacle::RetractTentacle(CStateManager& mgr) {
trigger->SetForceVector({}); trigger->SetForceVector({});
} }
} }
void CFlaahgraTentacle::SaveBombSlotInfo(CStateManager& mgr) { void CFlaahgraTentacle::SaveBombSlotInfo(CStateManager& mgr) {
for (const SConnection& conn : GetConnectionList()) { for (const SConnection& conn : GetConnectionList()) {
if (conn.x0_state != EScriptObjectState::Modify || conn.x4_msg != EScriptObjectMessage::ToggleActive) { if (conn.x0_state != EScriptObjectState::Modify || conn.x4_msg != EScriptObjectMessage::ToggleActive) {
@ -190,7 +192,7 @@ bool CFlaahgraTentacle::ShouldAttack(CStateManager& mgr, float) {
} }
if (const TCastToConstPtr<CCollisionActor> colAct = mgr.GetObjectById(x57c_tentacleTipAct)) { if (const TCastToConstPtr<CCollisionActor> 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); 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( x450_bodyController->GetCommandMgr().DeliverCmd(
CBCMeleeAttackCmd((x578_ > 0.f ? pas::ESeverity::Zero : pas::ESeverity::One), {})); CBCMeleeAttackCmd((x578_ > 0.f ? pas::ESeverity::Zero : pas::ESeverity::One), {}));
} }
} else if (x568_ == 2 &&
} else if (x568_ == 2 && x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::MeleeAttack) { x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::MeleeAttack) {
x568_ = 3; x568_ = 3;
} }
} else if (msg == EStateMsg::Deactivate) { } else if (msg == EStateMsg::Deactivate) {
x574_ = (x308_attackTimeVariation * mgr.GetActiveRandom()->Float()) + x304_averageAttackTime; x574_ = (x308_attackTimeVariation * mgr.GetActiveRandom()->Float()) + x304_averageAttackTime;
x578_ = 0.f; x578_ = 0.f;
} }
} }
void CFlaahgraTentacle::Retreat(CStateManager& mgr, EStateMsg msg, float) { void CFlaahgraTentacle::Retreat(CStateManager& mgr, EStateMsg msg, float) {
if (msg == EStateMsg::Update) { if (msg == EStateMsg::Update) {
if (!x58e_24_) { if (!x58e_24_) {
@ -229,7 +231,7 @@ void CFlaahgraTentacle::Retreat(CStateManager& mgr, EStateMsg msg, float) {
} }
if (const TCastToConstPtr<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) { if (const TCastToConstPtr<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
if (trigger->IsPlayerTriggerProc()) { if (!trigger->IsPlayerTriggerProc()) {
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed); x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
} }
} }
@ -237,6 +239,7 @@ void CFlaahgraTentacle::Retreat(CStateManager& mgr, EStateMsg msg, float) {
x58e_24_ = false; x58e_24_ = false;
} }
} }
void CFlaahgraTentacle::InActive(CStateManager& mgr, EStateMsg msg, float arg) { void CFlaahgraTentacle::InActive(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) { if (msg == EStateMsg::Activate) {
x570_ = 0.f; x570_ = 0.f;
@ -258,4 +261,15 @@ void CFlaahgraTentacle::InActive(CStateManager& mgr, EStateMsg msg, float arg) {
} }
} }
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

View File

@ -27,11 +27,13 @@ class CFlaahgraTentacle : public CPatterned {
void ExtractTentacle(CStateManager&); void ExtractTentacle(CStateManager&);
void RetractTentacle(CStateManager&); void RetractTentacle(CStateManager&);
void SaveBombSlotInfo(CStateManager&); void SaveBombSlotInfo(CStateManager&);
public: public:
DEFINE_PATTERNED(FlaahgraTentacle); DEFINE_PATTERNED(FlaahgraTentacle);
CFlaahgraTentacle(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&, CFlaahgraTentacle(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const CPatternedInfo&, const CActorParameters&); const CPatternedInfo&, const CActorParameters&);
void Accept(IVisitor&) override;
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override;
void Think(float, CStateManager&) override; void Think(float, CStateManager&) override;
@ -49,5 +51,6 @@ public:
void Attack(CStateManager&, EStateMsg, float) override; void Attack(CStateManager&, EStateMsg, float) override;
void Retreat(CStateManager&, EStateMsg, float) override; void Retreat(CStateManager&, EStateMsg, float) override;
void InActive(CStateManager&, EStateMsg, float) override; void InActive(CStateManager&, EStateMsg, float) override;
void Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state) override;
}; };
} } // namespace urde::MP1