mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-15 16:46:10 +00:00
Work on CParasite
This commit is contained in:
@@ -6,12 +6,14 @@
|
||||
#include "World/CGameArea.hpp"
|
||||
#include "World/CPlayer.hpp"
|
||||
#include "World/CScriptWaypoint.hpp"
|
||||
#include "World/CScriptDoor.hpp"
|
||||
#include "CStateManager.hpp"
|
||||
#include "TCastTo.hpp"
|
||||
#include "GameGlobalObjects.hpp"
|
||||
#include "CSimplePool.hpp"
|
||||
#include "Graphics/CSkinnedModel.hpp"
|
||||
#include "Collision/CGameCollision.hpp"
|
||||
#include "Collision/CCollisionActor.hpp"
|
||||
|
||||
namespace urde::MP1
|
||||
{
|
||||
@@ -24,33 +26,39 @@ const float CParasite::skRetreatVelocity = 3.f / 2.f * std::sqrt(2.5f / 24.52500
|
||||
|
||||
CParasite::CParasite(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo &info,
|
||||
const zeus::CTransform &xf, CModelData &&mData, const CPatternedInfo &pInfo, EBodyType bodyType,
|
||||
float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9,
|
||||
float f10, float f11, float f12, float f13, float f14, float f15, float f16, float f17, float f18,
|
||||
bool b1, EWalkerType wType, const CDamageVulnerability& dVuln,const CDamageInfo& parInfo, u16 sfxId1,
|
||||
u16 sfxId2, u16 sfxId3, CAssetId modelRes, CAssetId skinRes, float f19, const CActorParameters &aParams)
|
||||
float maxTelegraphReactDist, float advanceWpRadius, float f3, float alignAngVel, float f5,
|
||||
float stuckTimeThreshold, float collisionCloseMargin, float parasiteSearchRadius,
|
||||
float parasiteSeparationDist, float parasiteSeparationWeight, float parasiteAlignmentWeight,
|
||||
float parasiteCohesionWeight, float destinationSeekWeight, float forwardMoveWeight,
|
||||
float playerSeparationDist, float playerSeparationWeight, float playerObstructionMinDist,
|
||||
float haltDelay, bool disableMove, EWalkerType wType, const CDamageVulnerability& dVuln,
|
||||
const CDamageInfo& parInfo, u16 haltSfx, u16 getUpSfx, u16 crouchSfx, CAssetId modelRes,
|
||||
CAssetId skinRes, float iceZoomerJointHP,
|
||||
const CActorParameters& aParams)
|
||||
: CWallWalker(ECharacter::Parasite, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Flyer,
|
||||
EColliderType::Zero, bodyType, aParams, f7, f4, EKnockBackVariant::Small, f2, wType, f17, b1)
|
||||
, x64c_(dVuln)
|
||||
, x6b4_(parInfo)
|
||||
, x6d0_(f1)
|
||||
EColliderType::Zero, bodyType, aParams, collisionCloseMargin, alignAngVel, EKnockBackVariant::Small,
|
||||
advanceWpRadius, wType, playerObstructionMinDist, disableMove)
|
||||
, x64c_oculusHaltDVuln(dVuln)
|
||||
, x6b4_oculusHaltDInfo(parInfo)
|
||||
, x6d0_maxTelegraphReactDist(maxTelegraphReactDist)
|
||||
, x6d4_(f3)
|
||||
, x6dc_(f5)
|
||||
, x6e0_(f6)
|
||||
, x6e4_(f8)
|
||||
, x6e8_(f9)
|
||||
, x6ec_(f10)
|
||||
, x6f0_(f11)
|
||||
, x6f4_(f12)
|
||||
, x6f8_(f13)
|
||||
, x6fc_(f14)
|
||||
, x700_(f15)
|
||||
, x704_(f16)
|
||||
, x708_(pInfo.GetHeight() * 0.5f)
|
||||
, x710_(f18)
|
||||
, x714_(f19)
|
||||
, x73c_haltSfx(CSfxManager::TranslateSFXID(sfxId1))
|
||||
, x73e_getUpSfx(CSfxManager::TranslateSFXID(sfxId2))
|
||||
, x740_crouchSfx(CSfxManager::TranslateSFXID(sfxId3))
|
||||
, x6e0_stuckTimeThreshold(stuckTimeThreshold)
|
||||
, x6e4_parasiteSearchRadius(parasiteSearchRadius)
|
||||
, x6e8_parasiteSeparationDist(parasiteSeparationDist)
|
||||
, x6ec_parasiteSeparationWeight(parasiteSeparationWeight)
|
||||
, x6f0_parasiteAlignmentWeight(parasiteAlignmentWeight)
|
||||
, x6f4_parasiteCohesionWeight(parasiteCohesionWeight)
|
||||
, x6f8_destinationSeekWeight(destinationSeekWeight)
|
||||
, x6fc_forwardMoveWeight(forwardMoveWeight)
|
||||
, x700_playerSeparationDist(playerSeparationDist)
|
||||
, x704_playerSeparationWeight(playerSeparationWeight)
|
||||
, x708_unmorphedRadius(pInfo.GetHeight() * 0.5f)
|
||||
, x710_haltDelay(haltDelay)
|
||||
, x714_iceZoomerJointHP(iceZoomerJointHP)
|
||||
, x73c_haltSfx(CSfxManager::TranslateSFXID(haltSfx))
|
||||
, x73e_getUpSfx(CSfxManager::TranslateSFXID(getUpSfx))
|
||||
, x740_crouchSfx(CSfxManager::TranslateSFXID(crouchSfx))
|
||||
{
|
||||
x742_28_onGround = true;
|
||||
x742_30_attackOver = true;
|
||||
@@ -85,33 +93,114 @@ CParasite::CParasite(TUniqueId uid, std::string_view name, EFlavorType flavor, c
|
||||
|
||||
void CParasite::Accept(IVisitor &visitor) { visitor.Visit(this); }
|
||||
|
||||
void CParasite::SetupIceZoomerCollision(CStateManager& mgr)
|
||||
{
|
||||
std::vector<CJointCollisionDescription> descs;
|
||||
descs.reserve(2);
|
||||
descs.push_back(CJointCollisionDescription::SphereCollision(
|
||||
x64_modelData->GetAnimationData()->GetLocatorSegId("Ice_LCTR"sv), 0.4f, "Ice_LCTR"sv, 0.001f));
|
||||
RemoveMaterial(EMaterialTypes::Solid, mgr);
|
||||
AddMaterial(EMaterialTypes::ProjectilePassthrough, mgr);
|
||||
x620_collisionActorManager =
|
||||
std::make_unique<CCollisionActorManager>(mgr, GetUniqueId(), GetAreaIdAlways(),
|
||||
descs, GetActive());
|
||||
}
|
||||
|
||||
void CParasite::SetupIceZoomerVulnerability(CStateManager& mgr, const CDamageVulnerability& dVuln,
|
||||
const CHealthInfo& hInfo)
|
||||
{
|
||||
for (u32 i = 0; i < x620_collisionActorManager->GetNumCollisionActors(); ++i)
|
||||
{
|
||||
const CJointCollisionDescription& cDesc = x620_collisionActorManager->GetCollisionDescFromIndex(i);
|
||||
if (TCastToPtr<CCollisionActor> act = mgr.ObjectById(cDesc.GetCollisionActorId()))
|
||||
{
|
||||
act->SetDamageVulnerability(dVuln);
|
||||
*act->HealthInfo(mgr) = hInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CParasite::AddDoorRepulsors(CStateManager& mgr)
|
||||
{
|
||||
u32 doorCount = 0;
|
||||
for (CEntity* ent : mgr.GetPhysicsActorObjectList())
|
||||
if (TCastToPtr<CScriptDoor> door = ent)
|
||||
if (door->GetAreaIdAlways() == GetAreaIdAlways())
|
||||
++doorCount;
|
||||
x5d8_doorRepulsors.reserve(doorCount);
|
||||
for (CEntity* ent : mgr.GetPhysicsActorObjectList())
|
||||
if (TCastToPtr<CScriptDoor> door = ent)
|
||||
if (door->GetAreaIdAlways() == GetAreaIdAlways())
|
||||
{
|
||||
if (auto tb = door->GetTouchBounds())
|
||||
{
|
||||
float diagMag = (tb->min - tb->max).magnitude() * 0.75f;
|
||||
x5d8_doorRepulsors.emplace_back(tb->center(), diagMag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static TUniqueId lastParasite = kInvalidUniqueId;
|
||||
|
||||
void CParasite::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
|
||||
{
|
||||
CPatterned::AcceptScriptMsg(msg, uid, mgr);
|
||||
if (msg == EScriptObjectMessage::Registered)
|
||||
switch (msg)
|
||||
{
|
||||
case EScriptObjectMessage::Registered:
|
||||
x450_bodyController->Activate(mgr);
|
||||
/* TODO: Finish 8015A0E8*/
|
||||
}
|
||||
else if (msg == EScriptObjectMessage::Deleted)
|
||||
{
|
||||
//mgr.xf54_.sub80125d88(GetUniqueId());
|
||||
if (x5d0_walkerType != EWalkerType::IceZoomer)
|
||||
mgr.GetActiveParasites().push_back(GetUniqueId());
|
||||
CActor::CreateShadow(false);
|
||||
x604_activeSpeed = x3b4_speed;
|
||||
CPhysicsActor::SetBoundingBox(
|
||||
zeus::CAABox(zeus::CVector3f(-x590_colSphere.GetSphere().radius),
|
||||
zeus::CVector3f(x590_colSphere.GetSphere().radius)));
|
||||
lastParasite = GetUniqueId();
|
||||
AddDoorRepulsors(mgr);
|
||||
if (x5d0_walkerType == EWalkerType::IceZoomer)
|
||||
{
|
||||
SetupIceZoomerCollision(mgr);
|
||||
SetupIceZoomerVulnerability(mgr, x64c_oculusHaltDVuln,
|
||||
CHealthInfo(x714_iceZoomerJointHP, HealthInfo(mgr)->GetKnockbackResistance()));
|
||||
}
|
||||
break;
|
||||
case EScriptObjectMessage::Deleted:
|
||||
mgr.GetActiveParasites().remove(GetUniqueId());
|
||||
if (x5d0_walkerType == EWalkerType::IceZoomer)
|
||||
DestroyActorManager(mgr);
|
||||
}
|
||||
else if (msg == EScriptObjectMessage::Jumped && x742_25_jumpVelDirty)
|
||||
{
|
||||
UpdateJumpVelocity();
|
||||
x742_25_jumpVelDirty = false;
|
||||
}
|
||||
else if (msg == EScriptObjectMessage::Activate)
|
||||
{
|
||||
x5d6_27_ = false;
|
||||
if (x5d0_walkerType != EWalkerType::Parasite)
|
||||
break;
|
||||
case EScriptObjectMessage::Jumped:
|
||||
if (x742_25_jumpVelDirty)
|
||||
{
|
||||
UpdateJumpVelocity();
|
||||
x742_25_jumpVelDirty = false;
|
||||
}
|
||||
break;
|
||||
case EScriptObjectMessage::Activate:
|
||||
x5d6_27_disableMove = false;
|
||||
if (x5d0_walkerType == EWalkerType::Parasite)
|
||||
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Lurk);
|
||||
}
|
||||
else if (msg == EScriptObjectMessage::SuspendedMove)
|
||||
{
|
||||
break;
|
||||
case EScriptObjectMessage::InvulnDamage:
|
||||
if (x5d0_walkerType == EWalkerType::Oculus)
|
||||
{
|
||||
if (TCastToConstPtr<CActor> act = mgr.GetObjectById(uid))
|
||||
{
|
||||
float distSq = (act->GetTranslation() - GetTranslation()).magSquared();
|
||||
auto tb = GetTouchBounds();
|
||||
float maxComp = std::max(std::max(tb->max.y - tb->min.y, tb->max.z - tb->min.z), tb->max.x - tb->min.x);
|
||||
float maxCompSq = maxComp * maxComp + 1.f;
|
||||
if (distSq < maxCompSq * maxCompSq)
|
||||
x743_26_oculusShotAt = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EScriptObjectMessage::SuspendedMove:
|
||||
if (x620_collisionActorManager)
|
||||
x620_collisionActorManager->SetMovable(mgr, false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,60 +210,83 @@ void CParasite::PreThink(float dt, CStateManager& mgr)
|
||||
x743_26_oculusShotAt = false;
|
||||
}
|
||||
|
||||
void CParasite::UpdateCollisionActors(float dt, CStateManager& mgr)
|
||||
{
|
||||
x620_collisionActorManager->Update(dt, mgr, CCollisionActorManager::EUpdateOptions::ObjectSpace);
|
||||
if (!x743_25_vulnerable)
|
||||
{
|
||||
float totalHP = 0.f;
|
||||
for (u32 i = 0; i < x620_collisionActorManager->GetNumCollisionActors(); ++i)
|
||||
{
|
||||
const CJointCollisionDescription& cDesc = x620_collisionActorManager->GetCollisionDescFromIndex(i);
|
||||
if (TCastToPtr<CCollisionActor> cact = mgr.ObjectById(cDesc.GetCollisionActorId()))
|
||||
totalHP += cact->HealthInfo(mgr)->GetHP();
|
||||
}
|
||||
if (totalHP <= 0.f)
|
||||
{
|
||||
x743_25_vulnerable = true;
|
||||
AddMaterial(EMaterialTypes::Solid, mgr);
|
||||
RemoveMaterial(EMaterialTypes::ProjectilePassthrough, mgr);
|
||||
DestroyActorManager(mgr);
|
||||
x64_modelData->AnimationData()->SubstituteModelData(x624_extraModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CParasite::Think(float dt, CStateManager& mgr)
|
||||
{
|
||||
if (!GetActive())
|
||||
return;
|
||||
|
||||
++x5d4_;
|
||||
++x5d4_thinkCounter;
|
||||
if (x5d0_walkerType == EWalkerType::IceZoomer)
|
||||
UpdateCollisionActors(mgr);
|
||||
UpdateCollisionActors(dt, mgr);
|
||||
|
||||
x5d6_26_ = false;
|
||||
x5d6_26_playerObstructed = false;
|
||||
CGameArea* area = mgr.WorldNC()->GetArea(GetAreaIdAlways());
|
||||
|
||||
CGameArea::EOcclusionState r6 = CGameArea::EOcclusionState::Occluded;
|
||||
if (area->IsPostConstructed())
|
||||
r6 = area->GetPostConstructed()->x10dc_occlusionState;
|
||||
if (r6 != CGameArea::EOcclusionState::Visible)
|
||||
x5d6_26_ = true;
|
||||
x5d6_26_playerObstructed = true;
|
||||
|
||||
if (!x5d6_26_)
|
||||
if (!x5d6_26_playerObstructed)
|
||||
{
|
||||
zeus::CVector3f plVec = mgr.GetPlayer().GetTranslation();
|
||||
float distance = (GetTranslation() - plVec).magnitude() ;
|
||||
|
||||
if (distance > x5c4_)
|
||||
if (distance > x5c4_playerObstructionMinDist)
|
||||
{
|
||||
CRayCastResult res = mgr.RayStaticIntersection(plVec, (GetTranslation() - plVec).normalized(), distance,
|
||||
CMaterialFilter::skPassEverything);
|
||||
if (res.IsValid())
|
||||
x5d6_26_ = true;
|
||||
x5d6_26_playerObstructed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (x5d6_26_)
|
||||
if (x5d6_26_playerObstructed)
|
||||
{
|
||||
xf8_24_movable = x5d6_26_;
|
||||
xf8_24_movable = x5d6_26_playerObstructed;
|
||||
return;
|
||||
}
|
||||
|
||||
xf8_24_movable = !xf8_24_movable;
|
||||
|
||||
if (!x5d6_27_)
|
||||
if (!x5d6_27_disableMove)
|
||||
{
|
||||
if (x450_bodyController->IsFrozen())
|
||||
{
|
||||
if ((GetTranslation() - x614_).magSquared() < 0.3f /* <- Used to be a static variable */ * dt)
|
||||
x60c_ += dt;
|
||||
if ((GetTranslation() - x614_lastStuckPos).magSquared() < 0.3f /* <- Used to be a static variable */ * dt)
|
||||
x60c_stuckTime += dt;
|
||||
else
|
||||
x60c_ = 0.f;
|
||||
x60c_stuckTime = 0.f;
|
||||
|
||||
x614_ = GetTranslation();
|
||||
if (x608_ > 0.f)
|
||||
x608_ -= dt;
|
||||
x614_lastStuckPos = GetTranslation();
|
||||
if (x608_telegraphRemTime > 0.f)
|
||||
x608_telegraphRemTime -= dt;
|
||||
else
|
||||
x608_ = 0.f;
|
||||
x608_telegraphRemTime = 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +297,7 @@ void CParasite::Think(float dt, CStateManager& mgr)
|
||||
if (pl->GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed && !x742_30_attackOver)
|
||||
radius = x590_colSphere.GetSphere().radius;
|
||||
else
|
||||
radius = x708_;
|
||||
radius = x708_unmorphedRadius;
|
||||
|
||||
zeus::CAABox aabox{GetTranslation() - radius, GetTranslation() + radius};
|
||||
auto plBox = pl->GetTouchBounds();
|
||||
@@ -209,14 +321,14 @@ void CParasite::Think(float dt, CStateManager& mgr)
|
||||
|
||||
CWallWalker::Think(dt, mgr);
|
||||
|
||||
if (x5d6_27_)
|
||||
if (x5d6_27_disableMove)
|
||||
return;
|
||||
|
||||
if (x450_bodyController->IsFrozen())
|
||||
return;
|
||||
|
||||
x3b4_speed = x604_;
|
||||
if (x5d6_24_)
|
||||
x3b4_speed = x604_activeSpeed;
|
||||
if (x5d6_24_alignToFloor)
|
||||
AlignToFloor(mgr, x590_colSphere.GetSphere().radius, GetTranslation() + 2.f * dt * x138_velocity, dt);
|
||||
|
||||
x742_27_landed = false;
|
||||
@@ -232,11 +344,11 @@ const CDamageVulnerability* CParasite::GetDamageVulnerability() const
|
||||
switch (x5d0_walkerType)
|
||||
{
|
||||
case EWalkerType::Oculus:
|
||||
if (x743_24_)
|
||||
return &x64c_;
|
||||
if (x743_24_halted)
|
||||
return &x64c_oculusHaltDVuln;
|
||||
break;
|
||||
case EWalkerType::IceZoomer:
|
||||
if (!x743_25_)
|
||||
if (!x743_25_vulnerable)
|
||||
return &CDamageVulnerability::ImmuneVulnerabilty();
|
||||
break;
|
||||
default:
|
||||
@@ -245,6 +357,13 @@ const CDamageVulnerability* CParasite::GetDamageVulnerability() const
|
||||
return CAi::GetDamageVulnerability();
|
||||
}
|
||||
|
||||
CDamageInfo CParasite::GetContactDamage() const
|
||||
{
|
||||
if (x5d0_walkerType == EWalkerType::Oculus && x743_24_halted)
|
||||
return x6b4_oculusHaltDInfo;
|
||||
return CPatterned::GetContactDamage();
|
||||
}
|
||||
|
||||
void CParasite::Touch(CActor& actor, CStateManager& mgr)
|
||||
{
|
||||
CPatterned::Touch(actor, mgr);
|
||||
@@ -262,7 +381,7 @@ void CParasite::CollidedWith(TUniqueId uid, const CCollisionInfoList& list, CSta
|
||||
{
|
||||
for (const auto& info : list)
|
||||
{
|
||||
if (!x5d6_24_ && info.GetMaterialLeft().Intersection(testList) == 0)
|
||||
if (!x5d6_24_alignToFloor && info.GetMaterialLeft().Intersection(testList) == 0)
|
||||
{
|
||||
OrientToSurfaceNormal(info.GetNormalLeft(), 360.f);
|
||||
CPhysicsActor::Stop();
|
||||
@@ -288,30 +407,30 @@ void CParasite::Patrol(CStateManager& mgr, EStateMsg msg, float dt)
|
||||
{
|
||||
case EStateMsg::Activate:
|
||||
x742_26_ = true;
|
||||
x5d6_24_ = true;
|
||||
if (!x5d6_27_ && x5d0_walkerType == EWalkerType::Parasite)
|
||||
x5d6_24_alignToFloor = true;
|
||||
if (!x5d6_27_disableMove && x5d0_walkerType == EWalkerType::Parasite)
|
||||
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Lurk);
|
||||
SetMomentumWR(zeus::CVector3f::skZero);
|
||||
x5d6_25_ = false;
|
||||
x5d6_25_hasAlignSurface = false;
|
||||
xf8_24_movable = false;
|
||||
break;
|
||||
case EStateMsg::Update:
|
||||
if (x5bc_ > 0.f)
|
||||
if (x5bc_patrolPauseRemTime > 0.f)
|
||||
{
|
||||
x5bc_ -= dt;
|
||||
if (x5bc_ <= 0.f)
|
||||
x5bc_patrolPauseRemTime -= dt;
|
||||
if (x5bc_patrolPauseRemTime <= 0.f)
|
||||
{
|
||||
if (x5d0_walkerType == EWalkerType::Parasite)
|
||||
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Lurk);
|
||||
x5bc_ = 0.f;
|
||||
x5bc_patrolPauseRemTime = 0.f;
|
||||
}
|
||||
}
|
||||
GotoNextWaypoint(mgr);
|
||||
if (x5bc_ <= 0.f && !x5d6_27_)
|
||||
if (x5bc_patrolPauseRemTime <= 0.f && !x5d6_27_disableMove)
|
||||
DoFlockingBehavior(mgr);
|
||||
break;
|
||||
case EStateMsg::Deactivate:
|
||||
x5d6_24_ = false;
|
||||
x5d6_24_alignToFloor = false;
|
||||
xf8_24_movable = true;
|
||||
break;
|
||||
default:
|
||||
@@ -328,13 +447,14 @@ void CParasite::DoFlockingBehavior(CStateManager& mgr)
|
||||
{
|
||||
zeus::CVector3f upVec = x34_transform.basis[2];
|
||||
rstl::reserved_vector<TUniqueId, 1024> _834;
|
||||
zeus::CAABox aabb(GetTranslation() - x6e4_, GetTranslation() + x6e4_);
|
||||
if (x5d4_ % 6 == 0)
|
||||
zeus::CAABox aabb(GetTranslation() - x6e4_parasiteSearchRadius,
|
||||
GetTranslation() + x6e4_parasiteSearchRadius);
|
||||
if ((x5d4_thinkCounter % 6) == 0)
|
||||
{
|
||||
rstl::reserved_vector<TUniqueId, 1024> nearList;
|
||||
static CMaterialFilter filter = CMaterialFilter::MakeInclude(EMaterialTypes::Character);
|
||||
CParasite* closestParasite = nullptr;
|
||||
float minDistSq = 2.f + x6e8_ * x6e8_;
|
||||
float minDistSq = 2.f + x6e8_parasiteSeparationDist * x6e8_parasiteSeparationDist;
|
||||
mgr.BuildNearList(nearList, aabb, filter, nullptr);
|
||||
for (TUniqueId id : nearList)
|
||||
{
|
||||
@@ -352,25 +472,28 @@ void CParasite::DoFlockingBehavior(CStateManager& mgr)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (closestParasite && x6ec_ > 0.f && x6e8_ > 0.f)
|
||||
x628_ = x45c_steeringBehaviors.Separation(*this, closestParasite->GetTranslation(), x6e8_) * x604_;
|
||||
if (closestParasite && x6ec_parasiteSeparationWeight > 0.f && x6e8_parasiteSeparationDist > 0.f)
|
||||
x628_parasiteSeparationMove = x45c_steeringBehaviors.Separation(*this, closestParasite->GetTranslation(),
|
||||
x6e8_parasiteSeparationDist) * x604_activeSpeed;
|
||||
else
|
||||
x628_ = zeus::CVector3f::skZero;
|
||||
x634_ = x45c_steeringBehaviors.Cohesion(*this, _834, 0.6f, mgr) * x604_;
|
||||
x640_ = x45c_steeringBehaviors.Alignment(*this, _834, mgr) * x604_;
|
||||
x628_parasiteSeparationMove = zeus::CVector3f::skZero;
|
||||
x634_parasiteCohesionMove = x45c_steeringBehaviors.Cohesion(*this, _834, 0.6f, mgr) * x604_activeSpeed;
|
||||
x640_parasiteAlignmentMove = x45c_steeringBehaviors.Alignment(*this, _834, mgr) * x604_activeSpeed;
|
||||
}
|
||||
|
||||
if ((mgr.GetPlayer().GetTranslation() - GetTranslation()).magSquared() < x700_ * x700_)
|
||||
if ((mgr.GetPlayer().GetTranslation() - GetTranslation()).magSquared() <
|
||||
x700_playerSeparationDist * x700_playerSeparationDist)
|
||||
{
|
||||
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(ProjectVectorToPlane(
|
||||
x45c_steeringBehaviors.Separation(*this, mgr.GetPlayer().GetTranslation(), x700_), upVec) * x604_,
|
||||
zeus::CVector3f::skZero, x704_));
|
||||
x45c_steeringBehaviors.Separation(*this, mgr.GetPlayer().GetTranslation(),
|
||||
x700_playerSeparationDist), upVec) * x604_activeSpeed,
|
||||
zeus::CVector3f::skZero, x704_playerSeparationWeight));
|
||||
}
|
||||
|
||||
if (x628_ != zeus::CVector3f::skZero)
|
||||
if (x628_parasiteSeparationMove != zeus::CVector3f::skZero)
|
||||
{
|
||||
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(ProjectVectorToPlane(
|
||||
x628_, upVec), zeus::CVector3f::skZero, x6ec_));
|
||||
x628_parasiteSeparationMove, upVec), zeus::CVector3f::skZero, x6ec_parasiteSeparationWeight));
|
||||
}
|
||||
|
||||
for (const auto& r : x5d8_doorRepulsors)
|
||||
@@ -378,23 +501,23 @@ void CParasite::DoFlockingBehavior(CStateManager& mgr)
|
||||
if ((r.GetVector() - GetTranslation()).magSquared() < r.GetFloat() * r.GetFloat())
|
||||
{
|
||||
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(ProjectVectorToPlane(
|
||||
x45c_steeringBehaviors.Separation(*this, r.GetVector(), r.GetFloat()) * x604_, upVec),
|
||||
x45c_steeringBehaviors.Separation(*this, r.GetVector(), r.GetFloat()) * x604_activeSpeed, upVec),
|
||||
zeus::CVector3f::skZero, 1.f));
|
||||
}
|
||||
}
|
||||
|
||||
if (x608_ <= 0.f)
|
||||
if (x608_telegraphRemTime <= 0.f)
|
||||
{
|
||||
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(ProjectVectorToPlane(
|
||||
x634_, upVec), zeus::CVector3f::skZero, x6f4_));
|
||||
x634_parasiteCohesionMove, upVec), zeus::CVector3f::skZero, x6f4_parasiteCohesionWeight));
|
||||
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(ProjectVectorToPlane(
|
||||
x640_, upVec), zeus::CVector3f::skZero, x6f0_));
|
||||
x640_parasiteAlignmentMove, upVec), zeus::CVector3f::skZero, x6f0_parasiteAlignmentWeight));
|
||||
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(
|
||||
ProjectVectorToPlane(ProjectVectorToPlane(
|
||||
x45c_steeringBehaviors.Seek(*this, x2e0_destPos), upVec) * x604_, upVec),
|
||||
zeus::CVector3f::skZero, x6f8_));
|
||||
x45c_steeringBehaviors.Seek(*this, x2e0_destPos), upVec) * x604_activeSpeed, upVec),
|
||||
zeus::CVector3f::skZero, x6f8_destinationSeekWeight));
|
||||
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(
|
||||
x34_transform.basis[1] * x604_, zeus::CVector3f::skZero, x6fc_));
|
||||
x34_transform.basis[1] * x604_activeSpeed, zeus::CVector3f::skZero, x6fc_forwardMoveWeight));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,7 +527,7 @@ void CParasite::PathFind(CStateManager& mgr, EStateMsg msg, float dt)
|
||||
{
|
||||
case EStateMsg::Activate:
|
||||
x742_26_ = true;
|
||||
x5d6_24_ = true;
|
||||
x5d6_24_alignToFloor = true;
|
||||
if (x5d0_walkerType == EWalkerType::Parasite)
|
||||
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Lurk);
|
||||
SetMomentumWR(zeus::CVector3f::skZero);
|
||||
@@ -416,7 +539,7 @@ void CParasite::PathFind(CStateManager& mgr, EStateMsg msg, float dt)
|
||||
break;
|
||||
case EStateMsg::Deactivate:
|
||||
xf8_24_movable = true;
|
||||
x5d6_24_ = false;
|
||||
x5d6_24_alignToFloor = false;
|
||||
x742_26_ = false;
|
||||
break;
|
||||
default:
|
||||
@@ -429,11 +552,11 @@ void CParasite::TargetPlayer(CStateManager& mgr, EStateMsg msg, float dt)
|
||||
switch (msg)
|
||||
{
|
||||
case EStateMsg::Activate:
|
||||
x5f8_ = mgr.GetPlayer().GetTranslation() + zeus::CVector3f(0.f, 0.f, 1.5f);
|
||||
x5f8_targetPos = mgr.GetPlayer().GetTranslation() + zeus::CVector3f(0.f, 0.f, 1.5f);
|
||||
break;
|
||||
case EStateMsg::Update:
|
||||
x450_bodyController->FaceDirection3D(
|
||||
ProjectVectorToPlane(x5f8_ - GetTranslation(), x34_transform.basis[2]),
|
||||
ProjectVectorToPlane(x5f8_targetPos - GetTranslation(), x34_transform.basis[2]),
|
||||
x34_transform.basis[1], 2.f);
|
||||
break;
|
||||
default:
|
||||
@@ -513,10 +636,10 @@ void CParasite::Halt(CStateManager& mgr, EStateMsg msg, float)
|
||||
switch (msg)
|
||||
{
|
||||
case EStateMsg::Activate:
|
||||
x330_stateMachineState.SetDelay(x710_);
|
||||
x330_stateMachineState.SetDelay(x710_haltDelay);
|
||||
x32c_animState = EAnimState::One;
|
||||
x743_24_ = true;
|
||||
x5d6_24_ = true;
|
||||
x743_24_halted = true;
|
||||
x5d6_24_alignToFloor = true;
|
||||
if (x5d0_walkerType == EWalkerType::Geemer)
|
||||
CSfxManager::AddEmitter(x73c_haltSfx, GetTranslation(), zeus::CVector3f::skZero,
|
||||
true, false, 0x7f, kInvalidAreaId);
|
||||
@@ -528,8 +651,8 @@ void CParasite::Halt(CStateManager& mgr, EStateMsg msg, float)
|
||||
case EStateMsg::Deactivate:
|
||||
x450_bodyController->GetCommandMgr().DeliverCmd(CBodyStateCmd(EBodyStateCmd::ExitState));
|
||||
x32c_animState = EAnimState::Zero;
|
||||
x743_24_ = false;
|
||||
x5d6_24_ = false;
|
||||
x743_24_halted = false;
|
||||
x5d6_24_alignToFloor = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -546,20 +669,20 @@ void CParasite::Generate(CStateManager&, EStateMsg msg, float)
|
||||
switch (msg)
|
||||
{
|
||||
case EStateMsg::Activate:
|
||||
x5e8_ = 0;
|
||||
x5e8_stateProgress = 0;
|
||||
break;
|
||||
case EStateMsg::Update:
|
||||
switch (x5e8_)
|
||||
switch (x5e8_stateProgress)
|
||||
{
|
||||
case 0:
|
||||
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Generate)
|
||||
x5e8_ = 1;
|
||||
x5e8_stateProgress = 1;
|
||||
else
|
||||
x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(pas::EGenerateType::Zero));
|
||||
break;
|
||||
case 1:
|
||||
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Generate)
|
||||
x5e8_ = 2;
|
||||
x5e8_stateProgress = 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -575,15 +698,15 @@ void CParasite::Deactivate(CStateManager& mgr, EStateMsg msg, float)
|
||||
switch (msg)
|
||||
{
|
||||
case EStateMsg::Activate:
|
||||
x5e8_ = 0;
|
||||
SendScriptMsgs(EScriptObjectState::UNKS2, mgr, EScriptObjectMessage::None);
|
||||
x5e8_stateProgress = 0;
|
||||
SendScriptMsgs(EScriptObjectState::DeactivateState, mgr, EScriptObjectMessage::None);
|
||||
mgr.FreeScriptObject(GetUniqueId());
|
||||
break;
|
||||
case EStateMsg::Update:
|
||||
if (x5e8_ == 0)
|
||||
if (x5e8_stateProgress == 0)
|
||||
{
|
||||
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Generate)
|
||||
x5e8_ = 1;
|
||||
x5e8_stateProgress = 1;
|
||||
else
|
||||
x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(pas::EGenerateType::One));
|
||||
}
|
||||
@@ -598,41 +721,41 @@ void CParasite::Attack(CStateManager& mgr, EStateMsg msg, float)
|
||||
switch (msg)
|
||||
{
|
||||
case EStateMsg::Activate:
|
||||
x608_ = 0.f;
|
||||
x608_telegraphRemTime = 0.f;
|
||||
if (mgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed)
|
||||
{
|
||||
float rz = mgr.GetActiveRandom()->Float();
|
||||
float ry = mgr.GetActiveRandom()->Float();
|
||||
float rx = mgr.GetActiveRandom()->Float();
|
||||
x5f8_ = (zeus::CVector3f(rx, ry, rz) - 0.5f) * 0.5f + mgr.GetPlayer().GetTranslation();
|
||||
x5f8_targetPos = (zeus::CVector3f(rx, ry, rz) - 0.5f) * 0.5f + mgr.GetPlayer().GetTranslation();
|
||||
}
|
||||
else
|
||||
{
|
||||
float rz = mgr.GetActiveRandom()->Float();
|
||||
float ry = mgr.GetActiveRandom()->Float();
|
||||
float rx = mgr.GetActiveRandom()->Float();
|
||||
x5f8_ = (zeus::CVector3f(rx, ry, rz) + mgr.GetPlayer().GetTranslation() - GetTranslation())
|
||||
x5f8_targetPos = (zeus::CVector3f(rx, ry, rz) + mgr.GetPlayer().GetTranslation() - GetTranslation())
|
||||
.normalized() * 15.f + GetTranslation();
|
||||
}
|
||||
FaceTarget(x5f8_);
|
||||
x5e8_ = 0;
|
||||
FaceTarget(x5f8_targetPos);
|
||||
x5e8_stateProgress = 0;
|
||||
x742_30_attackOver = false;
|
||||
x742_24_ = false;
|
||||
x742_24_receivedTelegraph = false;
|
||||
x742_28_onGround = false;
|
||||
break;
|
||||
case EStateMsg::Update:
|
||||
switch (x5e8_)
|
||||
switch (x5e8_stateProgress)
|
||||
{
|
||||
case 0:
|
||||
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Jump)
|
||||
{
|
||||
x5e8_ = 1;
|
||||
x5e8_stateProgress = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
x742_25_jumpVelDirty = true;
|
||||
FaceTarget(x5f8_);
|
||||
x450_bodyController->GetCommandMgr().DeliverCmd(CBCJumpCmd(x5f8_, pas::EJumpType::Normal));
|
||||
FaceTarget(x5f8_targetPos);
|
||||
x450_bodyController->GetCommandMgr().DeliverCmd(CBCJumpCmd(x5f8_targetPos, pas::EJumpType::Normal));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -675,20 +798,21 @@ void CParasite::TelegraphAttack(CStateManager& mgr, EStateMsg msg, float)
|
||||
switch (msg)
|
||||
{
|
||||
case EStateMsg::Activate:
|
||||
for (auto it = mgr.GetParasiteTelegraphs().begin(); it != mgr.GetParasiteTelegraphs().end();)
|
||||
for (auto it = mgr.GetActiveParasites().begin(); it != mgr.GetActiveParasites().end();)
|
||||
{
|
||||
CParasite* other = CPatterned::CastTo<CParasite>(mgr.ObjectById(*it));
|
||||
if (!other)
|
||||
{
|
||||
it = mgr.GetParasiteTelegraphs().erase(it);
|
||||
it = mgr.GetActiveParasites().erase(it);
|
||||
continue;
|
||||
}
|
||||
if (other != this && other->IsAlive() &&
|
||||
(other->GetTranslation() - GetTranslation()).magSquared() < x6d0_ * x6d0_)
|
||||
(other->GetTranslation() - GetTranslation()).magSquared() <
|
||||
x6d0_maxTelegraphReactDist * x6d0_maxTelegraphReactDist)
|
||||
{
|
||||
other->x742_24_ = true;
|
||||
other->x608_ = mgr.GetActiveRandom()->Float() * 0.5f + 0.5f;
|
||||
other->x5f8_ = GetTranslation();
|
||||
other->x742_24_receivedTelegraph = true;
|
||||
other->x608_telegraphRemTime = mgr.GetActiveRandom()->Float() * 0.5f + 0.5f;
|
||||
other->x5f8_targetPos = GetTranslation();
|
||||
}
|
||||
++it;
|
||||
}
|
||||
@@ -707,7 +831,7 @@ void CParasite::Jump(CStateManager& mgr, EStateMsg msg, float)
|
||||
AddMaterial(EMaterialTypes::GroundCollider, mgr);
|
||||
SetMomentumWR({0.f, 0.f, -GetWeight()});
|
||||
x742_28_onGround = false;
|
||||
x5d6_24_ = false;
|
||||
x5d6_24_alignToFloor = false;
|
||||
x742_27_landed = false;
|
||||
x743_27_inJump = true;
|
||||
break;
|
||||
@@ -744,13 +868,13 @@ void CParasite::Retreat(CStateManager& mgr, EStateMsg msg, float)
|
||||
dir.normalize();
|
||||
else
|
||||
dir = mgr.GetPlayer().GetTransform().basis[1];
|
||||
x5f8_ = GetTranslation() - dir * 3.f;
|
||||
FaceTarget(x5f8_);
|
||||
x5e8_ = 0;
|
||||
x5f8_targetPos = GetTranslation() - dir * 3.f;
|
||||
FaceTarget(x5f8_targetPos);
|
||||
x5e8_stateProgress = 0;
|
||||
x742_27_landed = false;
|
||||
x742_28_onGround = false;
|
||||
x742_25_jumpVelDirty = true;
|
||||
x450_bodyController->GetCommandMgr().DeliverCmd(CBCJumpCmd(x5f8_, pas::EJumpType::One));
|
||||
x450_bodyController->GetCommandMgr().DeliverCmd(CBCJumpCmd(x5f8_targetPos, pas::EJumpType::One));
|
||||
break;
|
||||
}
|
||||
case EStateMsg::Update:
|
||||
@@ -764,13 +888,13 @@ void CParasite::Retreat(CStateManager& mgr, EStateMsg msg, float)
|
||||
|
||||
bool CParasite::AnimOver(CStateManager&, float)
|
||||
{
|
||||
return x5e8_ == 2;
|
||||
return x5e8_stateProgress == 2;
|
||||
}
|
||||
|
||||
bool CParasite::ShouldAttack(CStateManager& mgr, float arg)
|
||||
{
|
||||
bool shouldAttack = false;
|
||||
if (x742_24_ && x608_ > 0.1f)
|
||||
if (x742_24_receivedTelegraph && x608_telegraphRemTime > 0.1f)
|
||||
shouldAttack = true;
|
||||
if (!TooClose(mgr, arg) && InMaxRange(mgr, arg))
|
||||
return shouldAttack || InDetectionRange(mgr, 0.f);
|
||||
@@ -790,14 +914,14 @@ bool CParasite::CloseToWall(CStateManager& mgr)
|
||||
|
||||
bool CParasite::HitSomething(CStateManager& mgr, float)
|
||||
{
|
||||
if (x5d4_ & 0x1)
|
||||
if (x5d4_thinkCounter & 0x1)
|
||||
return true;
|
||||
return x5b8_ < 270.f && CloseToWall(mgr);
|
||||
return x5b8_tumbleAngle < 270.f && CloseToWall(mgr);
|
||||
}
|
||||
|
||||
bool CParasite::Stuck(CStateManager&, float)
|
||||
{
|
||||
return x60c_ > x6e0_;
|
||||
return x60c_stuckTime > x6e0_stuckTimeThreshold;
|
||||
}
|
||||
|
||||
bool CParasite::Landed(CStateManager&, float)
|
||||
@@ -845,7 +969,7 @@ void CParasite::UpdateWalkerAnimation(CStateManager& mgr, float dt)
|
||||
|
||||
void CParasite::DestroyActorManager(CStateManager& mgr)
|
||||
{
|
||||
//x620_->Destroy(mgr);
|
||||
x620_collisionActorManager->Destroy(mgr);
|
||||
}
|
||||
|
||||
void CParasite::UpdateJumpVelocity()
|
||||
@@ -865,8 +989,8 @@ void CParasite::UpdateJumpVelocity()
|
||||
}
|
||||
|
||||
float f30 = x150_momentum.z / xe8_mass;
|
||||
float f31 = x5f8_.z - GetTranslation().z;
|
||||
zeus::CVector3f vec2 = x5f8_ - GetTranslation();
|
||||
float f31 = x5f8_targetPos.z - GetTranslation().z;
|
||||
zeus::CVector3f vec2 = x5f8_targetPos - GetTranslation();
|
||||
vec2.z = 0.f;
|
||||
float f29 = vec2.magnitude();
|
||||
|
||||
@@ -895,8 +1019,4 @@ void CParasite::UpdateJumpVelocity()
|
||||
SetVelocityWR(vec);
|
||||
}
|
||||
|
||||
void CParasite::AlignToFloor(CStateManager&, float, const zeus::CVector3f&, float)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace urde::MP1
|
||||
|
||||
Reference in New Issue
Block a user