From 95fbcf914c1dcf1f19e9a09032d48d0fd9ee8d18 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 6 Sep 2018 22:24:55 -0700 Subject: [PATCH] Finish CAi imps --- Runtime/World/CAi.cpp | 37 +++++++++++++++++++++++++++++++++++++ Runtime/World/CAi.hpp | 6 ++++++ 2 files changed, 43 insertions(+) diff --git a/Runtime/World/CAi.cpp b/Runtime/World/CAi.cpp index f576ea4de..4533f8e3b 100644 --- a/Runtime/World/CAi.cpp +++ b/Runtime/World/CAi.cpp @@ -4,6 +4,7 @@ #include "CStateMachine.hpp" #include "GameGlobalObjects.hpp" #include "CSimplePool.hpp" +#include "CScriptWater.hpp" namespace urde { @@ -51,6 +52,42 @@ void CAi::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager CActor::AcceptScriptMsg(msg, uid, mgr); } +EWeaponCollisionResponseTypes CAi::GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, + const urde::CWeaponMode&, urde::EProjectileAttrib) const +{ + return EWeaponCollisionResponseTypes::EnemyNormal; +} + +void CAi::FluidFXThink(EFluidState state, CScriptWater& water, urde::CStateManager& mgr) +{ + if (state == EFluidState::EnteredFluid || state == EFluidState::LeftFluid) + { + float dt = mgr.GetFluidPlaneManager()->GetLastSplashDeltaTime(GetUniqueId()); + if (dt >= 0.02f) + { + float vel = (0.5f * GetMass()) * GetVelocity().magSquared(); + + if (vel > 500.f) + { + zeus::CVector3f pos = x34_transform.origin; + pos.z = water.GetTriggerBoundsWR().max.z; + mgr.GetFluidPlaneManager()->CreateSplash(GetUniqueId(), mgr, water, pos, + 0.1f + ((0.4f * zeus::min(vel, 30000.f) - 500.f) / 29500.f), + true); + } + } + } + + if (mgr.GetFluidPlaneManager()->GetLastRippleDeltaTime(GetUniqueId()) < (GetHealthInfo(mgr)->GetHP() > 0.f ? 0.2f : 0.7f)) + return; + + zeus::CVector3f pos = x34_transform.origin; + zeus::CVector3f center = pos; + center.z = water.GetTriggerBoundsWR().max.z; + pos.normalize(); + water.GetFluidPlane().AddRipple(GetMass(), GetUniqueId(), center, GetVelocity(), water, mgr, pos); +} + CAiStateFunc CAi::GetStateFunc(const char* func) { return m_FuncMap->GetStateFunc(func); } CAiTriggerFunc CAi::GetTrigerFunc(const char* func) { return m_FuncMap->GetTriggerFunc(func); } diff --git a/Runtime/World/CAi.hpp b/Runtime/World/CAi.hpp index f58812143..1b3e127fc 100644 --- a/Runtime/World/CAi.hpp +++ b/Runtime/World/CAi.hpp @@ -30,6 +30,7 @@ enum class EKnockBackType class CAiFuncMap; class CStateManager; +class CScriptWater; class CAi : public CPhysicsActor { static CAiFuncMap* m_FuncMap; @@ -53,11 +54,16 @@ public: virtual void Death(CStateManager&, const zeus::CVector3f&, EStateMsg)=0; virtual void KnockBack(const zeus::CVector3f&, CStateManager&, const CDamageInfo& info, EKnockBackType, bool, float)=0; virtual const CDamageVulnerability* GetDamageVulnerability() const { return &x260_damageVulnerability; } + virtual const CDamageVulnerability* GetDamageVulnerability() { return &x260_damageVulnerability; } virtual void TakeDamage(const zeus::CVector3f&, float) {} virtual bool CanBeShot(const CStateManager&, int) { return true; } virtual bool IsListening() const { return false; } virtual int Listen(const zeus::CVector3f&, EListenNoiseType) { return 0; } + virtual EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, + const CWeaponMode&, EProjectileAttrib) const; + void FluidFXThink(EFluidState, CScriptWater&, CStateManager&); + virtual zeus::CVector3f GetOrigin() const { return x34_transform.origin; } virtual void Patrol(CStateManager&, EStateMsg, float) {} virtual void FollowPattern(CStateManager&, EStateMsg, float) {} virtual void Dead(CStateManager&, EStateMsg, float) {}