2017-11-20 17:33:21 +00:00
|
|
|
#include "CParasite.hpp"
|
2018-05-02 00:43:31 +00:00
|
|
|
#include "Character/CModelData.hpp"
|
2018-05-07 00:47:40 +00:00
|
|
|
#include "World/CActorParameters.hpp"
|
|
|
|
#include "World/CPatternedInfo.hpp"
|
2018-09-16 23:22:35 +00:00
|
|
|
#include "World/CWorld.hpp"
|
|
|
|
#include "World/CGameArea.hpp"
|
|
|
|
#include "World/CPlayer.hpp"
|
2018-11-12 04:21:36 +00:00
|
|
|
#include "World/CScriptWaypoint.hpp"
|
2018-11-13 09:20:11 +00:00
|
|
|
#include "World/CScriptDoor.hpp"
|
2018-09-16 23:22:35 +00:00
|
|
|
#include "CStateManager.hpp"
|
|
|
|
#include "TCastTo.hpp"
|
2018-11-12 04:21:36 +00:00
|
|
|
#include "GameGlobalObjects.hpp"
|
|
|
|
#include "CSimplePool.hpp"
|
|
|
|
#include "Graphics/CSkinnedModel.hpp"
|
|
|
|
#include "Collision/CGameCollision.hpp"
|
2018-11-13 09:20:11 +00:00
|
|
|
#include "Collision/CCollisionActor.hpp"
|
2018-09-16 23:22:35 +00:00
|
|
|
|
|
|
|
namespace urde::MP1
|
|
|
|
{
|
2018-05-02 00:43:31 +00:00
|
|
|
|
2018-09-16 23:22:35 +00:00
|
|
|
const float CParasite::flt_805A8FB0 = 2.f * std::sqrt(2.5f / 24.525002f);
|
|
|
|
const float CParasite::skAttackVelocity = 15.f / 2.f * (std::sqrt(2.5f / 24.525002f));
|
|
|
|
short CParasite::word_805A8FC0 = 0;
|
|
|
|
const float CParasite::flt_805A8FB8 = 2.f * std::sqrt(2.5f / 24.525002f);
|
|
|
|
const float CParasite::skRetreatVelocity = 3.f / 2.f * std::sqrt(2.5f / 24.525002f);
|
2018-05-02 00:43:31 +00:00
|
|
|
|
2018-09-16 23:22:35 +00:00
|
|
|
CParasite::CParasite(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo &info,
|
|
|
|
const zeus::CTransform &xf, CModelData &&mData, const CPatternedInfo &pInfo, EBodyType bodyType,
|
2018-11-13 09:20:11 +00:00
|
|
|
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)
|
2018-09-16 23:22:35 +00:00
|
|
|
: CWallWalker(ECharacter::Parasite, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Flyer,
|
2018-11-13 09:20:11 +00:00
|
|
|
EColliderType::Zero, bodyType, aParams, collisionCloseMargin, alignAngVel, EKnockBackVariant::Small,
|
|
|
|
advanceWpRadius, wType, playerObstructionMinDist, disableMove)
|
|
|
|
, x64c_oculusHaltDVuln(dVuln)
|
|
|
|
, x6b4_oculusHaltDInfo(parInfo)
|
|
|
|
, x6d0_maxTelegraphReactDist(maxTelegraphReactDist)
|
2018-09-16 23:22:35 +00:00
|
|
|
, x6d4_(f3)
|
|
|
|
, x6dc_(f5)
|
2018-11-13 09:20:11 +00:00
|
|
|
, 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))
|
2018-05-02 00:43:31 +00:00
|
|
|
{
|
2018-11-12 04:21:36 +00:00
|
|
|
x742_28_onGround = true;
|
|
|
|
x742_30_attackOver = true;
|
2018-09-16 23:22:35 +00:00
|
|
|
|
2018-11-12 04:21:36 +00:00
|
|
|
switch (x5d0_walkerType)
|
2018-09-16 23:22:35 +00:00
|
|
|
{
|
2018-11-12 04:21:36 +00:00
|
|
|
case EWalkerType::Geemer:
|
2018-11-06 06:16:12 +00:00
|
|
|
x460_knockBackController.SetEnableFreeze(false);
|
2018-11-12 04:21:36 +00:00
|
|
|
case EWalkerType::Oculus:
|
2018-11-05 06:12:53 +00:00
|
|
|
x460_knockBackController.SetAutoResetImpulse(false);
|
2018-09-16 23:22:35 +00:00
|
|
|
break;
|
2018-11-12 04:21:36 +00:00
|
|
|
case EWalkerType::IceZoomer:
|
|
|
|
{
|
|
|
|
TLockedToken<CModel> model = g_SimplePool->GetObj({FOURCC('CMDL'), modelRes});
|
|
|
|
TLockedToken<CModel> skin = g_SimplePool->GetObj({FOURCC('CSKR'), skinRes});
|
|
|
|
x624_extraModel = CToken(
|
|
|
|
TObjOwnerDerivedFromIObj<CSkinnedModel>::GetNewDerivedObject(std::make_unique<CSkinnedModel>(
|
|
|
|
model, skin, x64_modelData->AnimationData()->GetModelData()->GetLayoutInfo(), 1, 1)));
|
|
|
|
}
|
2018-09-16 23:22:35 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2018-11-12 04:21:36 +00:00
|
|
|
if (x5d0_walkerType == EWalkerType::Oculus)
|
2018-09-16 23:22:35 +00:00
|
|
|
{
|
2018-11-12 04:21:36 +00:00
|
|
|
x460_knockBackController.SetEnableShock(false);
|
|
|
|
x460_knockBackController.SetEnableBurn(false);
|
|
|
|
x460_knockBackController.SetEnableBurnDeath(false);
|
|
|
|
x460_knockBackController.SetEnableExplodeDeath(false);
|
|
|
|
x460_knockBackController.SetX82_24(false);
|
2018-09-16 23:22:35 +00:00
|
|
|
}
|
2018-05-02 00:43:31 +00:00
|
|
|
}
|
2018-05-07 00:47:40 +00:00
|
|
|
|
|
|
|
void CParasite::Accept(IVisitor &visitor) { visitor.Visit(this); }
|
2018-09-16 23:22:35 +00:00
|
|
|
|
2018-11-13 09:20:11 +00:00
|
|
|
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;
|
|
|
|
|
2018-09-16 23:22:35 +00:00
|
|
|
void CParasite::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
|
|
|
|
{
|
|
|
|
CPatterned::AcceptScriptMsg(msg, uid, mgr);
|
2018-11-13 09:20:11 +00:00
|
|
|
switch (msg)
|
2018-09-16 23:22:35 +00:00
|
|
|
{
|
2018-11-13 09:20:11 +00:00
|
|
|
case EScriptObjectMessage::Registered:
|
2018-09-16 23:22:35 +00:00
|
|
|
x450_bodyController->Activate(mgr);
|
2018-11-13 09:20:11 +00:00
|
|
|
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)
|
2018-09-16 23:22:35 +00:00
|
|
|
DestroyActorManager(mgr);
|
2018-11-13 09:20:11 +00:00
|
|
|
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)
|
2018-09-16 23:22:35 +00:00
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Lurk);
|
2018-11-13 09:20:11 +00:00
|
|
|
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;
|
2018-09-16 23:22:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::PreThink(float dt, CStateManager& mgr)
|
|
|
|
{
|
|
|
|
CWallWalker::PreThink(dt, mgr);
|
2018-11-12 04:21:36 +00:00
|
|
|
x743_26_oculusShotAt = false;
|
2018-09-16 23:22:35 +00:00
|
|
|
}
|
|
|
|
|
2018-11-13 09:20:11 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-16 23:22:35 +00:00
|
|
|
void CParasite::Think(float dt, CStateManager& mgr)
|
|
|
|
{
|
|
|
|
if (!GetActive())
|
|
|
|
return;
|
|
|
|
|
2018-11-13 09:20:11 +00:00
|
|
|
++x5d4_thinkCounter;
|
2018-11-12 04:21:36 +00:00
|
|
|
if (x5d0_walkerType == EWalkerType::IceZoomer)
|
2018-11-13 09:20:11 +00:00
|
|
|
UpdateCollisionActors(dt, mgr);
|
2018-09-16 23:22:35 +00:00
|
|
|
|
2018-11-13 09:20:11 +00:00
|
|
|
x5d6_26_playerObstructed = false;
|
2018-09-16 23:22:35 +00:00
|
|
|
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)
|
2018-11-13 09:20:11 +00:00
|
|
|
x5d6_26_playerObstructed = true;
|
2018-09-16 23:22:35 +00:00
|
|
|
|
2018-11-13 09:20:11 +00:00
|
|
|
if (!x5d6_26_playerObstructed)
|
2018-09-16 23:22:35 +00:00
|
|
|
{
|
|
|
|
zeus::CVector3f plVec = mgr.GetPlayer().GetTranslation();
|
|
|
|
float distance = (GetTranslation() - plVec).magnitude() ;
|
|
|
|
|
2018-11-13 09:20:11 +00:00
|
|
|
if (distance > x5c4_playerObstructionMinDist)
|
2018-09-16 23:22:35 +00:00
|
|
|
{
|
|
|
|
CRayCastResult res = mgr.RayStaticIntersection(plVec, (GetTranslation() - plVec).normalized(), distance,
|
|
|
|
CMaterialFilter::skPassEverything);
|
|
|
|
if (res.IsValid())
|
2018-11-13 09:20:11 +00:00
|
|
|
x5d6_26_playerObstructed = true;
|
2018-09-16 23:22:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-13 09:20:11 +00:00
|
|
|
if (x5d6_26_playerObstructed)
|
2018-09-16 23:22:35 +00:00
|
|
|
{
|
2018-11-13 09:20:11 +00:00
|
|
|
xf8_24_movable = x5d6_26_playerObstructed;
|
2018-09-16 23:22:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
xf8_24_movable = !xf8_24_movable;
|
|
|
|
|
2018-11-13 09:20:11 +00:00
|
|
|
if (!x5d6_27_disableMove)
|
2018-09-16 23:22:35 +00:00
|
|
|
{
|
|
|
|
if (x450_bodyController->IsFrozen())
|
|
|
|
{
|
2018-11-13 09:20:11 +00:00
|
|
|
if ((GetTranslation() - x614_lastStuckPos).magSquared() < 0.3f /* <- Used to be a static variable */ * dt)
|
|
|
|
x60c_stuckTime += dt;
|
2018-09-16 23:22:35 +00:00
|
|
|
else
|
2018-11-13 09:20:11 +00:00
|
|
|
x60c_stuckTime = 0.f;
|
2018-09-16 23:22:35 +00:00
|
|
|
|
2018-11-13 09:20:11 +00:00
|
|
|
x614_lastStuckPos = GetTranslation();
|
|
|
|
if (x608_telegraphRemTime > 0.f)
|
|
|
|
x608_telegraphRemTime -= dt;
|
2018-09-16 23:22:35 +00:00
|
|
|
else
|
2018-11-13 09:20:11 +00:00
|
|
|
x608_telegraphRemTime = 0.f;
|
2018-09-16 23:22:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-05 06:12:53 +00:00
|
|
|
if (x400_25_alive)
|
2018-09-16 23:22:35 +00:00
|
|
|
{
|
|
|
|
CPlayer* pl = mgr.Player();
|
|
|
|
float radius;
|
2018-11-12 04:21:36 +00:00
|
|
|
if (pl->GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed && !x742_30_attackOver)
|
2018-09-16 23:22:35 +00:00
|
|
|
radius = x590_colSphere.GetSphere().radius;
|
|
|
|
else
|
2018-11-13 09:20:11 +00:00
|
|
|
radius = x708_unmorphedRadius;
|
2018-09-16 23:22:35 +00:00
|
|
|
|
|
|
|
zeus::CAABox aabox{GetTranslation() - radius, GetTranslation() + radius};
|
|
|
|
auto plBox = pl->GetTouchBounds();
|
|
|
|
|
|
|
|
if (plBox && plBox->intersects(aabox))
|
|
|
|
{
|
2018-11-12 04:21:36 +00:00
|
|
|
if (!x742_30_attackOver)
|
2018-09-16 23:22:35 +00:00
|
|
|
{
|
2018-11-12 04:21:36 +00:00
|
|
|
x742_30_attackOver = true;
|
|
|
|
x742_27_landed = false;
|
2018-09-16 23:22:35 +00:00
|
|
|
}
|
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
if (x420_curDamageRemTime <= 0.f)
|
2018-09-16 23:22:35 +00:00
|
|
|
{
|
|
|
|
mgr.ApplyDamage(GetUniqueId(), pl->GetUniqueId(), GetUniqueId(), GetContactDamage(),
|
|
|
|
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
|
2018-11-11 03:27:54 +00:00
|
|
|
x420_curDamageRemTime = x424_damageWaitTime;
|
2018-09-16 23:22:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CWallWalker::Think(dt, mgr);
|
|
|
|
|
2018-11-13 09:20:11 +00:00
|
|
|
if (x5d6_27_disableMove)
|
2018-09-16 23:22:35 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (x450_bodyController->IsFrozen())
|
|
|
|
return;
|
|
|
|
|
2018-11-13 09:20:11 +00:00
|
|
|
x3b4_speed = x604_activeSpeed;
|
|
|
|
if (x5d6_24_alignToFloor)
|
2018-09-16 23:22:35 +00:00
|
|
|
AlignToFloor(mgr, x590_colSphere.GetSphere().radius, GetTranslation() + 2.f * dt * x138_velocity, dt);
|
|
|
|
|
2018-11-12 04:21:36 +00:00
|
|
|
x742_27_landed = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::Render(const CStateManager& mgr) const
|
|
|
|
{
|
|
|
|
CWallWalker::Render(mgr);
|
|
|
|
}
|
|
|
|
|
|
|
|
const CDamageVulnerability* CParasite::GetDamageVulnerability() const
|
|
|
|
{
|
|
|
|
switch (x5d0_walkerType)
|
|
|
|
{
|
|
|
|
case EWalkerType::Oculus:
|
2018-11-13 09:20:11 +00:00
|
|
|
if (x743_24_halted)
|
|
|
|
return &x64c_oculusHaltDVuln;
|
2018-11-12 04:21:36 +00:00
|
|
|
break;
|
|
|
|
case EWalkerType::IceZoomer:
|
2018-11-13 09:20:11 +00:00
|
|
|
if (!x743_25_vulnerable)
|
2018-11-12 04:21:36 +00:00
|
|
|
return &CDamageVulnerability::ImmuneVulnerabilty();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return CAi::GetDamageVulnerability();
|
|
|
|
}
|
|
|
|
|
2018-11-13 09:20:11 +00:00
|
|
|
CDamageInfo CParasite::GetContactDamage() const
|
|
|
|
{
|
|
|
|
if (x5d0_walkerType == EWalkerType::Oculus && x743_24_halted)
|
|
|
|
return x6b4_oculusHaltDInfo;
|
|
|
|
return CPatterned::GetContactDamage();
|
|
|
|
}
|
|
|
|
|
2018-11-12 04:21:36 +00:00
|
|
|
void CParasite::Touch(CActor& actor, CStateManager& mgr)
|
|
|
|
{
|
|
|
|
CPatterned::Touch(actor, mgr);
|
|
|
|
}
|
|
|
|
|
|
|
|
zeus::CVector3f CParasite::GetAimPosition(const CStateManager&, float) const
|
|
|
|
{
|
|
|
|
return GetTranslation();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::CollidedWith(TUniqueId uid, const CCollisionInfoList& list, CStateManager&)
|
|
|
|
{
|
|
|
|
static CMaterialList testList(EMaterialTypes::Character, EMaterialTypes::Player);
|
|
|
|
if (x743_27_inJump)
|
|
|
|
{
|
|
|
|
for (const auto& info : list)
|
|
|
|
{
|
2018-11-13 09:20:11 +00:00
|
|
|
if (!x5d6_24_alignToFloor && info.GetMaterialLeft().Intersection(testList) == 0)
|
2018-11-12 04:21:36 +00:00
|
|
|
{
|
|
|
|
OrientToSurfaceNormal(info.GetNormalLeft(), 360.f);
|
|
|
|
CPhysicsActor::Stop();
|
|
|
|
SetVelocityWR(zeus::CVector3f::skZero);
|
|
|
|
x742_27_landed = true;
|
|
|
|
x742_28_onGround = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state)
|
|
|
|
{
|
|
|
|
CPhysicsActor::Stop();
|
|
|
|
TelegraphAttack(mgr, EStateMsg::Activate, 0.f);
|
|
|
|
SetMomentumWR({0.f, 0.f, -GetWeight()});
|
|
|
|
CPatterned::Death(mgr, direction, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::Patrol(CStateManager& mgr, EStateMsg msg, float dt)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case EStateMsg::Activate:
|
|
|
|
x742_26_ = true;
|
2018-11-13 09:20:11 +00:00
|
|
|
x5d6_24_alignToFloor = true;
|
|
|
|
if (!x5d6_27_disableMove && x5d0_walkerType == EWalkerType::Parasite)
|
2018-11-12 04:21:36 +00:00
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Lurk);
|
|
|
|
SetMomentumWR(zeus::CVector3f::skZero);
|
2018-11-13 09:20:11 +00:00
|
|
|
x5d6_25_hasAlignSurface = false;
|
2018-11-12 04:21:36 +00:00
|
|
|
xf8_24_movable = false;
|
|
|
|
break;
|
|
|
|
case EStateMsg::Update:
|
2018-11-13 09:20:11 +00:00
|
|
|
if (x5bc_patrolPauseRemTime > 0.f)
|
2018-11-12 04:21:36 +00:00
|
|
|
{
|
2018-11-13 09:20:11 +00:00
|
|
|
x5bc_patrolPauseRemTime -= dt;
|
|
|
|
if (x5bc_patrolPauseRemTime <= 0.f)
|
2018-11-12 04:21:36 +00:00
|
|
|
{
|
|
|
|
if (x5d0_walkerType == EWalkerType::Parasite)
|
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Lurk);
|
2018-11-13 09:20:11 +00:00
|
|
|
x5bc_patrolPauseRemTime = 0.f;
|
2018-11-12 04:21:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
GotoNextWaypoint(mgr);
|
2018-11-13 09:20:11 +00:00
|
|
|
if (x5bc_patrolPauseRemTime <= 0.f && !x5d6_27_disableMove)
|
2018-11-12 04:21:36 +00:00
|
|
|
DoFlockingBehavior(mgr);
|
|
|
|
break;
|
|
|
|
case EStateMsg::Deactivate:
|
2018-11-13 09:20:11 +00:00
|
|
|
x5d6_24_alignToFloor = false;
|
2018-11-12 04:21:36 +00:00
|
|
|
xf8_24_movable = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::UpdatePFDestination(CStateManager& mgr)
|
|
|
|
{
|
|
|
|
// Empty
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::DoFlockingBehavior(CStateManager& mgr)
|
|
|
|
{
|
|
|
|
zeus::CVector3f upVec = x34_transform.basis[2];
|
|
|
|
rstl::reserved_vector<TUniqueId, 1024> _834;
|
2018-11-13 09:20:11 +00:00
|
|
|
zeus::CAABox aabb(GetTranslation() - x6e4_parasiteSearchRadius,
|
|
|
|
GetTranslation() + x6e4_parasiteSearchRadius);
|
|
|
|
if ((x5d4_thinkCounter % 6) == 0)
|
2018-11-12 04:21:36 +00:00
|
|
|
{
|
|
|
|
rstl::reserved_vector<TUniqueId, 1024> nearList;
|
|
|
|
static CMaterialFilter filter = CMaterialFilter::MakeInclude(EMaterialTypes::Character);
|
|
|
|
CParasite* closestParasite = nullptr;
|
2018-11-13 09:20:11 +00:00
|
|
|
float minDistSq = 2.f + x6e8_parasiteSeparationDist * x6e8_parasiteSeparationDist;
|
2018-11-12 04:21:36 +00:00
|
|
|
mgr.BuildNearList(nearList, aabb, filter, nullptr);
|
|
|
|
for (TUniqueId id : nearList)
|
|
|
|
{
|
|
|
|
if (CParasite* parasite = CPatterned::CastTo<CParasite>(mgr.ObjectById(id)))
|
|
|
|
{
|
|
|
|
if (parasite != this && parasite->IsAlive())
|
|
|
|
{
|
|
|
|
_834.push_back(parasite->GetUniqueId());
|
|
|
|
float distSq = (parasite->GetTranslation() - GetTranslation()).magSquared();
|
|
|
|
if (distSq < minDistSq)
|
|
|
|
{
|
|
|
|
minDistSq = distSq;
|
|
|
|
closestParasite = parasite;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-11-13 09:20:11 +00:00
|
|
|
if (closestParasite && x6ec_parasiteSeparationWeight > 0.f && x6e8_parasiteSeparationDist > 0.f)
|
|
|
|
x628_parasiteSeparationMove = x45c_steeringBehaviors.Separation(*this, closestParasite->GetTranslation(),
|
|
|
|
x6e8_parasiteSeparationDist) * x604_activeSpeed;
|
2018-11-12 04:21:36 +00:00
|
|
|
else
|
2018-11-13 09:20:11 +00:00
|
|
|
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;
|
2018-11-12 04:21:36 +00:00
|
|
|
}
|
|
|
|
|
2018-11-13 09:20:11 +00:00
|
|
|
if ((mgr.GetPlayer().GetTranslation() - GetTranslation()).magSquared() <
|
|
|
|
x700_playerSeparationDist * x700_playerSeparationDist)
|
2018-11-12 04:21:36 +00:00
|
|
|
{
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(ProjectVectorToPlane(
|
2018-11-13 09:20:11 +00:00
|
|
|
x45c_steeringBehaviors.Separation(*this, mgr.GetPlayer().GetTranslation(),
|
|
|
|
x700_playerSeparationDist), upVec) * x604_activeSpeed,
|
|
|
|
zeus::CVector3f::skZero, x704_playerSeparationWeight));
|
2018-11-12 04:21:36 +00:00
|
|
|
}
|
|
|
|
|
2018-11-13 09:20:11 +00:00
|
|
|
if (x628_parasiteSeparationMove != zeus::CVector3f::skZero)
|
2018-11-12 04:21:36 +00:00
|
|
|
{
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(ProjectVectorToPlane(
|
2018-11-13 09:20:11 +00:00
|
|
|
x628_parasiteSeparationMove, upVec), zeus::CVector3f::skZero, x6ec_parasiteSeparationWeight));
|
2018-11-12 04:21:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (const auto& r : x5d8_doorRepulsors)
|
|
|
|
{
|
|
|
|
if ((r.GetVector() - GetTranslation()).magSquared() < r.GetFloat() * r.GetFloat())
|
|
|
|
{
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(ProjectVectorToPlane(
|
2018-11-13 09:20:11 +00:00
|
|
|
x45c_steeringBehaviors.Separation(*this, r.GetVector(), r.GetFloat()) * x604_activeSpeed, upVec),
|
2018-11-12 04:21:36 +00:00
|
|
|
zeus::CVector3f::skZero, 1.f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-13 09:20:11 +00:00
|
|
|
if (x608_telegraphRemTime <= 0.f)
|
2018-11-12 04:21:36 +00:00
|
|
|
{
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(ProjectVectorToPlane(
|
2018-11-13 09:20:11 +00:00
|
|
|
x634_parasiteCohesionMove, upVec), zeus::CVector3f::skZero, x6f4_parasiteCohesionWeight));
|
2018-11-12 04:21:36 +00:00
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(ProjectVectorToPlane(
|
2018-11-13 09:20:11 +00:00
|
|
|
x640_parasiteAlignmentMove, upVec), zeus::CVector3f::skZero, x6f0_parasiteAlignmentWeight));
|
2018-11-12 04:21:36 +00:00
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(
|
|
|
|
ProjectVectorToPlane(ProjectVectorToPlane(
|
2018-11-13 09:20:11 +00:00
|
|
|
x45c_steeringBehaviors.Seek(*this, x2e0_destPos), upVec) * x604_activeSpeed, upVec),
|
|
|
|
zeus::CVector3f::skZero, x6f8_destinationSeekWeight));
|
2018-11-12 04:21:36 +00:00
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(
|
2018-11-13 09:20:11 +00:00
|
|
|
x34_transform.basis[1] * x604_activeSpeed, zeus::CVector3f::skZero, x6fc_forwardMoveWeight));
|
2018-11-12 04:21:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::PathFind(CStateManager& mgr, EStateMsg msg, float dt)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case EStateMsg::Activate:
|
|
|
|
x742_26_ = true;
|
2018-11-13 09:20:11 +00:00
|
|
|
x5d6_24_alignToFloor = true;
|
2018-11-12 04:21:36 +00:00
|
|
|
if (x5d0_walkerType == EWalkerType::Parasite)
|
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Lurk);
|
|
|
|
SetMomentumWR(zeus::CVector3f::skZero);
|
|
|
|
xf8_24_movable = false;
|
|
|
|
break;
|
|
|
|
case EStateMsg::Update:
|
|
|
|
UpdatePFDestination(mgr);
|
|
|
|
DoFlockingBehavior(mgr);
|
|
|
|
break;
|
|
|
|
case EStateMsg::Deactivate:
|
|
|
|
xf8_24_movable = true;
|
2018-11-13 09:20:11 +00:00
|
|
|
x5d6_24_alignToFloor = false;
|
2018-11-12 04:21:36 +00:00
|
|
|
x742_26_ = false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::TargetPlayer(CStateManager& mgr, EStateMsg msg, float dt)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case EStateMsg::Activate:
|
2018-11-13 09:20:11 +00:00
|
|
|
x5f8_targetPos = mgr.GetPlayer().GetTranslation() + zeus::CVector3f(0.f, 0.f, 1.5f);
|
2018-11-12 04:21:36 +00:00
|
|
|
break;
|
|
|
|
case EStateMsg::Update:
|
|
|
|
x450_bodyController->FaceDirection3D(
|
2018-11-13 09:20:11 +00:00
|
|
|
ProjectVectorToPlane(x5f8_targetPos - GetTranslation(), x34_transform.basis[2]),
|
2018-11-12 04:21:36 +00:00
|
|
|
x34_transform.basis[1], 2.f);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TUniqueId CParasite::RecursiveFindClosestWayPoint(CStateManager& mgr, TUniqueId id, float& dist)
|
|
|
|
{
|
|
|
|
TUniqueId ret = id;
|
|
|
|
TCastToPtr<CScriptWaypoint> wp = mgr.ObjectById(id);
|
|
|
|
if (!wp)
|
|
|
|
return ret;
|
|
|
|
wp->SetActive(false);
|
|
|
|
dist = (wp->GetTranslation() - GetTranslation()).magSquared();
|
|
|
|
for (const auto& conn : wp->GetConnectionList())
|
|
|
|
{
|
|
|
|
if (conn.x0_state == EScriptObjectState::Arrived && conn.x4_msg == EScriptObjectMessage::Next)
|
|
|
|
{
|
|
|
|
TUniqueId nextId = mgr.GetIdForScript(conn.x8_objId);
|
|
|
|
if (nextId != kInvalidUniqueId)
|
|
|
|
{
|
|
|
|
if (TCastToConstPtr<CScriptWaypoint> wp2 = mgr.GetObjectById(nextId))
|
|
|
|
{
|
|
|
|
if (wp2->GetActive())
|
|
|
|
{
|
|
|
|
float nextDist;
|
|
|
|
TUniqueId closestWp = RecursiveFindClosestWayPoint(mgr, nextId, nextDist);
|
|
|
|
if (nextDist < dist)
|
|
|
|
{
|
|
|
|
dist = nextDist;
|
|
|
|
ret = closestWp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wp->SetActive(true);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
TUniqueId CParasite::GetClosestWaypointForState(EScriptObjectState state, CStateManager& mgr)
|
|
|
|
{
|
|
|
|
float minDist = FLT_MAX;
|
|
|
|
TUniqueId ret = kInvalidUniqueId;
|
|
|
|
for (const auto& conn : GetConnectionList())
|
|
|
|
{
|
|
|
|
if (conn.x0_state == state && conn.x4_msg == EScriptObjectMessage::Follow)
|
|
|
|
{
|
|
|
|
TUniqueId id = mgr.GetIdForScript(conn.x8_objId);
|
|
|
|
float dist;
|
|
|
|
TUniqueId closestWp = RecursiveFindClosestWayPoint(mgr, id, dist);
|
|
|
|
if (dist < minDist)
|
|
|
|
{
|
|
|
|
minDist = dist;
|
|
|
|
ret = closestWp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::TargetPatrol(CStateManager& mgr, EStateMsg msg, float dt)
|
|
|
|
{
|
|
|
|
if (msg == EStateMsg::Activate)
|
|
|
|
{
|
|
|
|
SetMomentumWR(zeus::CVector3f::skZero);
|
|
|
|
TUniqueId wpId = GetClosestWaypointForState(EScriptObjectState::Patrol, mgr);
|
|
|
|
if (wpId != kInvalidUniqueId)
|
|
|
|
x2dc_destObj = wpId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::Halt(CStateManager& mgr, EStateMsg msg, float)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case EStateMsg::Activate:
|
2018-11-13 09:20:11 +00:00
|
|
|
x330_stateMachineState.SetDelay(x710_haltDelay);
|
2018-11-12 04:21:36 +00:00
|
|
|
x32c_animState = EAnimState::One;
|
2018-11-13 09:20:11 +00:00
|
|
|
x743_24_halted = true;
|
|
|
|
x5d6_24_alignToFloor = true;
|
2018-11-12 04:21:36 +00:00
|
|
|
if (x5d0_walkerType == EWalkerType::Geemer)
|
|
|
|
CSfxManager::AddEmitter(x73c_haltSfx, GetTranslation(), zeus::CVector3f::skZero,
|
|
|
|
true, false, 0x7f, kInvalidAreaId);
|
|
|
|
break;
|
|
|
|
case EStateMsg::Update:
|
|
|
|
TryCommand(mgr, pas::EAnimationState::LoopReaction, &CPatterned::TryLoopReaction, 1);
|
|
|
|
x400_24_hitByPlayerProjectile = false;
|
|
|
|
break;
|
|
|
|
case EStateMsg::Deactivate:
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBodyStateCmd(EBodyStateCmd::ExitState));
|
|
|
|
x32c_animState = EAnimState::Zero;
|
2018-11-13 09:20:11 +00:00
|
|
|
x743_24_halted = false;
|
|
|
|
x5d6_24_alignToFloor = false;
|
2018-11-12 04:21:36 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::Run(CStateManager&, EStateMsg, float)
|
|
|
|
{
|
|
|
|
// Empty
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::Generate(CStateManager&, EStateMsg msg, float)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case EStateMsg::Activate:
|
2018-11-13 09:20:11 +00:00
|
|
|
x5e8_stateProgress = 0;
|
2018-11-12 04:21:36 +00:00
|
|
|
break;
|
|
|
|
case EStateMsg::Update:
|
2018-11-13 09:20:11 +00:00
|
|
|
switch (x5e8_stateProgress)
|
2018-11-12 04:21:36 +00:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Generate)
|
2018-11-13 09:20:11 +00:00
|
|
|
x5e8_stateProgress = 1;
|
2018-11-12 04:21:36 +00:00
|
|
|
else
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(pas::EGenerateType::Zero));
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Generate)
|
2018-11-13 09:20:11 +00:00
|
|
|
x5e8_stateProgress = 2;
|
2018-11-12 04:21:36 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::Deactivate(CStateManager& mgr, EStateMsg msg, float)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case EStateMsg::Activate:
|
2018-11-13 09:20:11 +00:00
|
|
|
x5e8_stateProgress = 0;
|
|
|
|
SendScriptMsgs(EScriptObjectState::DeactivateState, mgr, EScriptObjectMessage::None);
|
2018-11-12 04:21:36 +00:00
|
|
|
mgr.FreeScriptObject(GetUniqueId());
|
|
|
|
break;
|
|
|
|
case EStateMsg::Update:
|
2018-11-13 09:20:11 +00:00
|
|
|
if (x5e8_stateProgress == 0)
|
2018-11-12 04:21:36 +00:00
|
|
|
{
|
|
|
|
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Generate)
|
2018-11-13 09:20:11 +00:00
|
|
|
x5e8_stateProgress = 1;
|
2018-11-12 04:21:36 +00:00
|
|
|
else
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(pas::EGenerateType::One));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::Attack(CStateManager& mgr, EStateMsg msg, float)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case EStateMsg::Activate:
|
2018-11-13 09:20:11 +00:00
|
|
|
x608_telegraphRemTime = 0.f;
|
2018-11-12 04:21:36 +00:00
|
|
|
if (mgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed)
|
|
|
|
{
|
|
|
|
float rz = mgr.GetActiveRandom()->Float();
|
|
|
|
float ry = mgr.GetActiveRandom()->Float();
|
|
|
|
float rx = mgr.GetActiveRandom()->Float();
|
2018-11-13 09:20:11 +00:00
|
|
|
x5f8_targetPos = (zeus::CVector3f(rx, ry, rz) - 0.5f) * 0.5f + mgr.GetPlayer().GetTranslation();
|
2018-11-12 04:21:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float rz = mgr.GetActiveRandom()->Float();
|
|
|
|
float ry = mgr.GetActiveRandom()->Float();
|
|
|
|
float rx = mgr.GetActiveRandom()->Float();
|
2018-11-13 09:20:11 +00:00
|
|
|
x5f8_targetPos = (zeus::CVector3f(rx, ry, rz) + mgr.GetPlayer().GetTranslation() - GetTranslation())
|
2018-11-12 04:21:36 +00:00
|
|
|
.normalized() * 15.f + GetTranslation();
|
|
|
|
}
|
2018-11-13 09:20:11 +00:00
|
|
|
FaceTarget(x5f8_targetPos);
|
|
|
|
x5e8_stateProgress = 0;
|
2018-11-12 04:21:36 +00:00
|
|
|
x742_30_attackOver = false;
|
2018-11-13 09:20:11 +00:00
|
|
|
x742_24_receivedTelegraph = false;
|
2018-11-12 04:21:36 +00:00
|
|
|
x742_28_onGround = false;
|
|
|
|
break;
|
|
|
|
case EStateMsg::Update:
|
2018-11-13 09:20:11 +00:00
|
|
|
switch (x5e8_stateProgress)
|
2018-11-12 04:21:36 +00:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Jump)
|
|
|
|
{
|
2018-11-13 09:20:11 +00:00
|
|
|
x5e8_stateProgress = 1;
|
2018-11-12 04:21:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x742_25_jumpVelDirty = true;
|
2018-11-13 09:20:11 +00:00
|
|
|
FaceTarget(x5f8_targetPos);
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCJumpCmd(x5f8_targetPos, pas::EJumpType::Normal));
|
2018-11-12 04:21:36 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EStateMsg::Deactivate:
|
|
|
|
x742_28_onGround = true;
|
|
|
|
x742_30_attackOver = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::Crouch(CStateManager&, EStateMsg msg, float)
|
|
|
|
{
|
|
|
|
if (msg == EStateMsg::Activate)
|
|
|
|
{
|
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Crouch);
|
|
|
|
if (x5d0_walkerType == EWalkerType::Geemer)
|
|
|
|
CSfxManager::AddEmitter(x740_crouchSfx, GetTranslation(), zeus::CVector3f::skZero,
|
|
|
|
true, false, 0x7f, kInvalidAreaId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::GetUp(CStateManager&, EStateMsg msg, float)
|
|
|
|
{
|
|
|
|
if (msg == EStateMsg::Activate)
|
|
|
|
{
|
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
|
|
|
if (x5d0_walkerType == EWalkerType::Geemer)
|
|
|
|
CSfxManager::AddEmitter(x73e_getUpSfx, GetTranslation(), zeus::CVector3f::skZero,
|
|
|
|
true, false, 0x7f, kInvalidAreaId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::TelegraphAttack(CStateManager& mgr, EStateMsg msg, float)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case EStateMsg::Activate:
|
2018-11-13 09:20:11 +00:00
|
|
|
for (auto it = mgr.GetActiveParasites().begin(); it != mgr.GetActiveParasites().end();)
|
2018-11-12 04:21:36 +00:00
|
|
|
{
|
|
|
|
CParasite* other = CPatterned::CastTo<CParasite>(mgr.ObjectById(*it));
|
|
|
|
if (!other)
|
|
|
|
{
|
2018-11-13 09:20:11 +00:00
|
|
|
it = mgr.GetActiveParasites().erase(it);
|
2018-11-12 04:21:36 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (other != this && other->IsAlive() &&
|
2018-11-13 09:20:11 +00:00
|
|
|
(other->GetTranslation() - GetTranslation()).magSquared() <
|
|
|
|
x6d0_maxTelegraphReactDist * x6d0_maxTelegraphReactDist)
|
2018-11-12 04:21:36 +00:00
|
|
|
{
|
2018-11-13 09:20:11 +00:00
|
|
|
other->x742_24_receivedTelegraph = true;
|
|
|
|
other->x608_telegraphRemTime = mgr.GetActiveRandom()->Float() * 0.5f + 0.5f;
|
|
|
|
other->x5f8_targetPos = GetTranslation();
|
2018-11-12 04:21:36 +00:00
|
|
|
}
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
x400_24_hitByPlayerProjectile = false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::Jump(CStateManager& mgr, EStateMsg msg, float)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case EStateMsg::Activate:
|
|
|
|
AddMaterial(EMaterialTypes::GroundCollider, mgr);
|
|
|
|
SetMomentumWR({0.f, 0.f, -GetWeight()});
|
|
|
|
x742_28_onGround = false;
|
2018-11-13 09:20:11 +00:00
|
|
|
x5d6_24_alignToFloor = false;
|
2018-11-12 04:21:36 +00:00
|
|
|
x742_27_landed = false;
|
|
|
|
x743_27_inJump = true;
|
|
|
|
break;
|
|
|
|
case EStateMsg::Update:
|
|
|
|
SetMomentumWR({0.f, 0.f, -GetWeight()});
|
|
|
|
break;
|
|
|
|
case EStateMsg::Deactivate:
|
|
|
|
RemoveMaterial(EMaterialTypes::GroundCollider, mgr);
|
|
|
|
SetMomentumWR(zeus::CVector3f::skZero);
|
|
|
|
x742_28_onGround = true;
|
|
|
|
x742_27_landed = false;
|
|
|
|
x743_27_inJump = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::FaceTarget(const zeus::CVector3f& target)
|
|
|
|
{
|
|
|
|
zeus::CQuaternion q =
|
|
|
|
zeus::CQuaternion::lookAt(zeus::CTransform::Identity().basis[1],
|
|
|
|
target - GetTranslation(), zeus::degToRad(360.f));
|
|
|
|
SetTransform(q.toTransform(GetTranslation()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::Retreat(CStateManager& mgr, EStateMsg msg, float)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case EStateMsg::Activate:
|
|
|
|
{
|
|
|
|
zeus::CVector3f dir = mgr.GetPlayer().GetTranslation() - GetTranslation();
|
|
|
|
dir.z = 0.f;
|
|
|
|
if (dir.canBeNormalized())
|
|
|
|
dir.normalize();
|
|
|
|
else
|
|
|
|
dir = mgr.GetPlayer().GetTransform().basis[1];
|
2018-11-13 09:20:11 +00:00
|
|
|
x5f8_targetPos = GetTranslation() - dir * 3.f;
|
|
|
|
FaceTarget(x5f8_targetPos);
|
|
|
|
x5e8_stateProgress = 0;
|
2018-11-12 04:21:36 +00:00
|
|
|
x742_27_landed = false;
|
|
|
|
x742_28_onGround = false;
|
|
|
|
x742_25_jumpVelDirty = true;
|
2018-11-13 09:20:11 +00:00
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCJumpCmd(x5f8_targetPos, pas::EJumpType::One));
|
2018-11-12 04:21:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EStateMsg::Update:
|
|
|
|
x3b4_speed = 1.f;
|
|
|
|
break;
|
|
|
|
case EStateMsg::Deactivate:
|
|
|
|
x742_28_onGround = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CParasite::AnimOver(CStateManager&, float)
|
|
|
|
{
|
2018-11-13 09:20:11 +00:00
|
|
|
return x5e8_stateProgress == 2;
|
2018-11-12 04:21:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CParasite::ShouldAttack(CStateManager& mgr, float arg)
|
|
|
|
{
|
|
|
|
bool shouldAttack = false;
|
2018-11-13 09:20:11 +00:00
|
|
|
if (x742_24_receivedTelegraph && x608_telegraphRemTime > 0.1f)
|
2018-11-12 04:21:36 +00:00
|
|
|
shouldAttack = true;
|
|
|
|
if (!TooClose(mgr, arg) && InMaxRange(mgr, arg))
|
|
|
|
return shouldAttack || InDetectionRange(mgr, 0.f);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CParasite::CloseToWall(CStateManager& mgr)
|
|
|
|
{
|
|
|
|
static CMaterialFilter filter = CMaterialFilter::MakeInclude(EMaterialTypes::Solid);
|
|
|
|
zeus::CAABox aabb = CPhysicsActor::GetBoundingBox();
|
|
|
|
float margin = x590_colSphere.GetSphere().radius + x5b0_collisionCloseMargin;
|
|
|
|
aabb.min -= zeus::CVector3f(margin);
|
|
|
|
aabb.max += zeus::CVector3f(margin);
|
|
|
|
CCollidableAABox cAABB(aabb, x68_material);
|
|
|
|
return CGameCollision::DetectStaticCollisionBoolean(mgr, cAABB, {}, filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CParasite::HitSomething(CStateManager& mgr, float)
|
|
|
|
{
|
2018-11-13 09:20:11 +00:00
|
|
|
if (x5d4_thinkCounter & 0x1)
|
2018-11-12 04:21:36 +00:00
|
|
|
return true;
|
2018-11-13 09:20:11 +00:00
|
|
|
return x5b8_tumbleAngle < 270.f && CloseToWall(mgr);
|
2018-11-12 04:21:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CParasite::Stuck(CStateManager&, float)
|
|
|
|
{
|
2018-11-13 09:20:11 +00:00
|
|
|
return x60c_stuckTime > x6e0_stuckTimeThreshold;
|
2018-11-12 04:21:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CParasite::Landed(CStateManager&, float)
|
|
|
|
{
|
|
|
|
return x742_27_landed;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CParasite::AttackOver(CStateManager&, float)
|
|
|
|
{
|
|
|
|
return x742_30_attackOver;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CParasite::ShotAt(CStateManager&, float)
|
|
|
|
{
|
|
|
|
if (x5d0_walkerType != EWalkerType::Oculus)
|
|
|
|
return x400_24_hitByPlayerProjectile;
|
|
|
|
return x743_26_oculusShotAt;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::MassiveDeath(CStateManager& mgr)
|
|
|
|
{
|
|
|
|
CPatterned::MassiveDeath(mgr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::MassiveFrozenDeath(CStateManager& mgr)
|
|
|
|
{
|
|
|
|
CPatterned::MassiveFrozenDeath(mgr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::ThinkAboutMove(float dt)
|
|
|
|
{
|
|
|
|
if (!x68_material.HasMaterial(EMaterialTypes::GroundCollider))
|
|
|
|
CPatterned::ThinkAboutMove(dt);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CParasite::IsOnGround() const
|
|
|
|
{
|
|
|
|
return x742_28_onGround;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::UpdateWalkerAnimation(CStateManager& mgr, float dt)
|
|
|
|
{
|
|
|
|
CActor::UpdateAnimation(dt, mgr, true);
|
2018-09-16 23:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::DestroyActorManager(CStateManager& mgr)
|
|
|
|
{
|
2018-11-13 09:20:11 +00:00
|
|
|
x620_collisionActorManager->Destroy(mgr);
|
2018-09-16 23:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CParasite::UpdateJumpVelocity()
|
|
|
|
{
|
2018-11-12 04:21:36 +00:00
|
|
|
SetMomentumWR({0.f, 0.f, -GetWeight()});
|
2018-09-16 23:22:35 +00:00
|
|
|
zeus::CVector3f vec;
|
|
|
|
|
2018-11-12 04:21:36 +00:00
|
|
|
if (!x742_30_attackOver)
|
2018-09-16 23:22:35 +00:00
|
|
|
{
|
|
|
|
vec = skAttackVelocity * GetTransform().frontVector();
|
|
|
|
vec.z = 0.5f * skRetreatVelocity;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vec = skRetreatVelocity * GetTransform().frontVector();
|
|
|
|
vec.z = 0.5f * skAttackVelocity;
|
|
|
|
}
|
|
|
|
|
|
|
|
float f30 = x150_momentum.z / xe8_mass;
|
2018-11-13 09:20:11 +00:00
|
|
|
float f31 = x5f8_targetPos.z - GetTranslation().z;
|
|
|
|
zeus::CVector3f vec2 = x5f8_targetPos - GetTranslation();
|
2018-09-16 23:22:35 +00:00
|
|
|
vec2.z = 0.f;
|
|
|
|
float f29 = vec2.magnitude();
|
|
|
|
|
|
|
|
if (f29 > FLT_EPSILON)
|
|
|
|
{
|
|
|
|
vec2 *= zeus::CVector3f{1.f / f29};
|
|
|
|
float f28 = vec2.dot(vec);
|
|
|
|
if (f28 > FLT_EPSILON)
|
|
|
|
{
|
|
|
|
float f27 = 0.f;
|
|
|
|
bool isNeg = f31 < 0.f;
|
2018-11-16 06:06:20 +00:00
|
|
|
float xPos, xNeg;
|
|
|
|
if (CSteeringBehaviors::SolveQuadratic(f30, vec.z, -f31, xPos, xNeg))
|
|
|
|
f27 = isNeg ? xPos : xNeg;
|
2018-09-16 23:22:35 +00:00
|
|
|
|
|
|
|
if (!isNeg)
|
|
|
|
f27 = f27 * f29 / f28;
|
|
|
|
|
|
|
|
if (f27 < 10.f)
|
|
|
|
{
|
|
|
|
vec = f29 / f27 * vec2;
|
|
|
|
vec.z = (0.5f * f30 * f27 + f31 / f27);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetVelocityWR(vec);
|
|
|
|
}
|
|
|
|
|
2018-05-07 00:47:40 +00:00
|
|
|
} // namespace urde::MP1
|