2016-04-25 05:03:38 +00:00
|
|
|
#include "CPatterned.hpp"
|
2018-09-14 00:49:34 +00:00
|
|
|
#include "Runtime/CStateManager.hpp"
|
2016-04-25 05:03:38 +00:00
|
|
|
#include "CPatternedInfo.hpp"
|
2017-01-17 01:23:19 +00:00
|
|
|
#include "TCastTo.hpp"
|
2017-08-25 06:18:09 +00:00
|
|
|
#include "CActorParameters.hpp"
|
2018-09-07 23:51:07 +00:00
|
|
|
#include "Character/CPASAnimParmData.hpp"
|
|
|
|
#include "GameGlobalObjects.hpp"
|
|
|
|
#include "CSimplePool.hpp"
|
|
|
|
#include "CPlayer.hpp"
|
|
|
|
#include "Weapon/CGameProjectile.hpp"
|
|
|
|
#include "Character/CAnimData.hpp"
|
2018-09-14 00:49:34 +00:00
|
|
|
#include "TCastTo.hpp"
|
|
|
|
#include "MP1/World/CSpacePirate.hpp"
|
|
|
|
#include "World/CStateMachine.hpp"
|
2018-11-06 06:16:12 +00:00
|
|
|
#include "CExplosion.hpp"
|
2018-11-08 00:53:38 +00:00
|
|
|
#include "Graphics/CSkinnedModel.hpp"
|
2018-11-11 03:27:54 +00:00
|
|
|
#include "CPathFindSearch.hpp"
|
|
|
|
#include "Camera/CFirstPersonCamera.hpp"
|
|
|
|
#include "World/CScriptWaypoint.hpp"
|
|
|
|
#include "World/CScriptActorKeyframe.hpp"
|
2016-04-25 05:03:38 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
2018-09-07 23:51:07 +00:00
|
|
|
const zeus::CColor CPatterned::skDamageColor(0.5f, 0.f, 0.f);
|
2016-12-29 21:38:59 +00:00
|
|
|
CMaterialList gkPatternedGroundMaterialList(EMaterialTypes::Character, EMaterialTypes::Solid,
|
|
|
|
EMaterialTypes::Orbit, EMaterialTypes::GroundCollider,
|
|
|
|
EMaterialTypes::Target);
|
|
|
|
CMaterialList gkPatternedFlyerMaterialList(EMaterialTypes::Character, EMaterialTypes::Solid,
|
|
|
|
EMaterialTypes::Orbit, EMaterialTypes::Target);
|
2016-04-25 05:03:38 +00:00
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
CPatterned::CPatterned(ECharacter character, TUniqueId uid, std::string_view name, CPatterned::EFlavorType flavor,
|
2016-04-25 05:46:28 +00:00
|
|
|
const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData,
|
2018-09-07 23:51:07 +00:00
|
|
|
const CPatternedInfo& pInfo, CPatterned::EMovementType moveType,
|
|
|
|
CPatterned::EColliderType colliderType, EBodyType bodyType, const CActorParameters& actorParms,
|
2018-11-05 06:12:53 +00:00
|
|
|
EKnockBackVariant kbVariant)
|
2016-12-19 18:27:58 +00:00
|
|
|
: CAi(uid, pInfo.xf8_active, name, info, xf, std::move(mData),
|
|
|
|
zeus::CAABox(pInfo.xcc_bodyOrigin - zeus::CVector3f{pInfo.xc4_halfExtent, pInfo.xc4_halfExtent, 0.f},
|
|
|
|
pInfo.xcc_bodyOrigin +
|
|
|
|
zeus::CVector3f{pInfo.xc4_halfExtent, pInfo.xc4_halfExtent, pInfo.xc8_height}),
|
|
|
|
pInfo.x0_mass, pInfo.x54_healthInfo, pInfo.x5c_damageVulnerability,
|
|
|
|
moveType == EMovementType::Flyer ? gkPatternedFlyerMaterialList : gkPatternedGroundMaterialList,
|
2017-06-12 04:23:34 +00:00
|
|
|
pInfo.xfc_stateMachineId, actorParms, pInfo.xd8_stepUpHeight, 0.8f),
|
2018-09-07 23:51:07 +00:00
|
|
|
x2fc_minAttackRange(pInfo.x18_minAttackRange),
|
|
|
|
x300_maxAttackRange(pInfo.x1c_maxAttackRange),
|
|
|
|
x304_averageAttackTime(pInfo.x20_averageAttackTime),
|
|
|
|
x308_attackTimeVariation(pInfo.x24_attackTimeVariation),
|
|
|
|
x34c_character(character),
|
|
|
|
x388_anim(pInfo.GetAnimationParameters().GetInitialAnimation()),
|
|
|
|
x3b4_speed(pInfo.x4_speed),
|
|
|
|
x3b8_turnSpeed(pInfo.x8_turnSpeed),
|
|
|
|
x3bc_detectionRange(pInfo.xc_detectionRange),
|
|
|
|
x3c0_detectionHeightRange(pInfo.x10_detectionHeightRange),
|
|
|
|
x3c4_detectionAngle(std::cos(zeus::degToRad(pInfo.x14_dectectionAngle))),
|
|
|
|
x3c8_leashRadius(pInfo.x28_leashRadius),
|
|
|
|
x3cc_playerLeashRadius(pInfo.x2c_playerLeashRadius),
|
|
|
|
x3d0_playerLeashTime(pInfo.x30_playerLeashTime),
|
2018-11-11 03:27:54 +00:00
|
|
|
x3d8_xDamageThreshold(pInfo.xdc_xDamage),
|
|
|
|
x3dc_frozenXDamageThreshold(pInfo.xe0_frozenXDamage),
|
|
|
|
x3e0_xDamageDelay(pInfo.xe4_xDamageDelay),
|
2018-11-05 06:12:53 +00:00
|
|
|
x3fc_flavor(flavor),
|
|
|
|
x460_knockBackController(kbVariant)
|
2016-04-25 05:03:38 +00:00
|
|
|
{
|
2018-11-05 06:12:53 +00:00
|
|
|
x400_25_alive = true;
|
2018-11-11 03:27:54 +00:00
|
|
|
x400_31_isFlyer = moveType == CPatterned::EMovementType::Flyer;
|
|
|
|
x402_29_drawParticles = true;
|
|
|
|
x402_30_updateThermalFrozenState = x402_31_thawed = actorParms.HasThermalHeat();
|
|
|
|
x403_25_enableStateMachine = true;
|
|
|
|
x403_26_stateControlledMassiveDeath = true;
|
2018-09-14 00:49:34 +00:00
|
|
|
x404_contactDamage = pInfo.x34_contactDamageInfo;
|
2018-09-07 23:51:07 +00:00
|
|
|
x424_damageWaitTime = pInfo.x50_damageWaitTime;
|
|
|
|
x454_deathSfx = pInfo.xe8_deathSfx;
|
|
|
|
x458_iceShatterSfx = pInfo.x134_iceShatterSfx;
|
2018-11-11 03:27:54 +00:00
|
|
|
x4f4_intoFreezeDur = pInfo.x100_intoFreezeDur;
|
|
|
|
x4f8_outofFreezeDur = pInfo.x104_outofFreezeDur;
|
2018-09-07 23:51:07 +00:00
|
|
|
x4fc_ = pInfo.x108_;
|
|
|
|
x508_colliderType = colliderType;
|
2018-11-11 03:27:54 +00:00
|
|
|
x50c_baseDamageMag = actorParms.GetThermalMag();
|
2018-11-06 06:16:12 +00:00
|
|
|
x514_deathExplosionOffset = pInfo.x110_particle1Scale;
|
|
|
|
x540_iceDeathExplosionOffset = pInfo.x124_particle2Scale;
|
2018-09-07 23:51:07 +00:00
|
|
|
|
|
|
|
if (pInfo.x11c_particle1.IsValid())
|
2018-11-06 06:16:12 +00:00
|
|
|
x520_deathExplosionParticle = { g_SimplePool->GetObj({FOURCC('PART'), pInfo.x11c_particle1})};
|
2018-09-07 23:51:07 +00:00
|
|
|
|
|
|
|
if (pInfo.x120_electric.IsValid())
|
2018-11-06 06:16:12 +00:00
|
|
|
x530_deathExplosionElectric = { g_SimplePool->GetObj({FOURCC('ELSC'), pInfo.x120_electric})};
|
2018-09-07 23:51:07 +00:00
|
|
|
|
|
|
|
if (pInfo.x130_particle2.IsValid())
|
2018-11-06 06:16:12 +00:00
|
|
|
x54c_iceDeathExplosionParticle = { g_SimplePool->GetObj({FOURCC('PART'), pInfo.x130_particle2})};
|
2018-09-07 23:51:07 +00:00
|
|
|
|
2018-09-14 00:49:34 +00:00
|
|
|
if (x404_contactDamage.GetRadius() > 0.f)
|
|
|
|
x404_contactDamage.SetRadius(0.f);
|
2018-09-07 23:51:07 +00:00
|
|
|
|
|
|
|
xe6_29_renderParticleDBInside = false;
|
2018-11-11 03:27:54 +00:00
|
|
|
x402_27_noXrayModel = !x64_modelData->HasModel(CModelData::EWhichModel::XRay);
|
2018-09-07 23:51:07 +00:00
|
|
|
BuildBodyController(bodyType);
|
|
|
|
}
|
|
|
|
|
2018-09-14 00:49:34 +00:00
|
|
|
void CPatterned::Accept(urde::IVisitor& visitor)
|
|
|
|
{
|
|
|
|
visitor.Visit(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
|
|
|
|
{
|
|
|
|
CAi::AcceptScriptMsg(msg, uid, mgr);
|
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
switch (msg)
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
|
|
|
case EScriptObjectMessage::Registered:
|
|
|
|
{
|
2018-11-05 06:12:53 +00:00
|
|
|
if (x508_colliderType != EColliderType::One)
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
|
|
|
CMaterialList include = GetMaterialFilter().GetIncludeList();
|
|
|
|
CMaterialList exclude = GetMaterialFilter().GetExcludeList();
|
|
|
|
include.Remove(EMaterialTypes::Character);
|
|
|
|
exclude.Add(EMaterialTypes::Character);
|
|
|
|
SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HasModelData() && GetModelData()->HasAnimData() && GetModelData()->GetAnimationData()->GetIceModel())
|
|
|
|
{
|
2018-11-05 06:12:53 +00:00
|
|
|
const auto& baseAABB = GetBaseBoundingBox();
|
|
|
|
float diagExtent = (baseAABB.max - baseAABB.min).magnitude() * 0.5f;
|
|
|
|
x510_vertexMorph = std::make_shared<CVertexMorphEffect>(zeus::CVector3f::skRight,
|
|
|
|
zeus::CVector3f{}, diagExtent, 0.f, *mgr.GetActiveRandom());
|
2018-09-14 00:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
xf8_25_angularEnabled = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::OnFloor:
|
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
if (!x328_25_verticalMovement)
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
|
|
|
x150_momentum = {};
|
|
|
|
AddMaterial(EMaterialTypes::GroundCollider, mgr);
|
|
|
|
}
|
|
|
|
x328_27_onGround = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::Falling:
|
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
if (!x328_25_verticalMovement)
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
|
|
|
if (x450_bodyController->GetPercentageFrozen() == 0.f)
|
|
|
|
{
|
|
|
|
x150_momentum = {0.f, 0.f, -GetWeight()};
|
|
|
|
RemoveMaterial(EMaterialTypes::GroundCollider, mgr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
x328_27_onGround = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::Activate:
|
2018-11-11 03:27:54 +00:00
|
|
|
x3a0_latestLeashPosition = GetTranslation();
|
2018-09-14 00:49:34 +00:00
|
|
|
break;
|
|
|
|
case EScriptObjectMessage::Deleted:
|
|
|
|
if (x330_stateMachineState.GetActorState() != nullptr)
|
|
|
|
x330_stateMachineState.GetActorState()->CallFunc(mgr, *this, EStateMsg::Two, 0.f);
|
|
|
|
break;
|
|
|
|
case EScriptObjectMessage::Damage:
|
|
|
|
{
|
|
|
|
if (TCastToConstPtr<CGameProjectile> proj = mgr.GetObjectById(uid))
|
|
|
|
{
|
|
|
|
const CDamageInfo& info = proj->GetDamageInfo();
|
|
|
|
if (info.GetWeaponMode().GetType() == EWeaponType::Wave)
|
|
|
|
{
|
2018-11-06 06:16:12 +00:00
|
|
|
if (x460_knockBackController.x81_26_enableShock && info.GetWeaponMode().IsComboed() && HealthInfo(mgr))
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
x401_31_nextPendingShock = true;
|
2018-11-06 06:16:12 +00:00
|
|
|
KnockBack(GetTransform().frontVector(), mgr, info, EKnockBackType::Radius, false,
|
2018-09-14 00:49:34 +00:00
|
|
|
info.GetKnockBackPower());
|
2018-11-05 06:12:53 +00:00
|
|
|
x460_knockBackController.DeferKnockBack(EWeaponType::Wave);
|
2018-09-14 00:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (info.GetWeaponMode().GetType() == EWeaponType::Plasma)
|
|
|
|
{
|
2018-11-06 06:16:12 +00:00
|
|
|
if (x460_knockBackController.x81_27_enableBurn && info.GetWeaponMode().IsCharged() && HealthInfo(mgr))
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
2018-11-06 06:16:12 +00:00
|
|
|
KnockBack(GetTransform().frontVector(), mgr, info, EKnockBackType::Radius,
|
2018-11-05 06:12:53 +00:00
|
|
|
false, info.GetKnockBackPower());
|
|
|
|
x460_knockBackController.DeferKnockBack(EWeaponType::Plasma);
|
2018-09-14 00:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mgr.GetPlayer().GetUniqueId() == proj->GetOwnerId())
|
2018-11-11 03:27:54 +00:00
|
|
|
x400_24_hitByPlayerProjectile = true;
|
2018-09-14 00:49:34 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::InvulnDamage:
|
|
|
|
{
|
|
|
|
if (TCastToConstPtr<CGameProjectile> proj = mgr.GetObjectById(uid))
|
|
|
|
{
|
|
|
|
if (proj->GetOwnerId() == mgr.GetPlayer().GetUniqueId())
|
2018-11-11 03:27:54 +00:00
|
|
|
x400_24_hitByPlayerProjectile = true;
|
2018-09-14 00:49:34 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
void CPatterned::UpdateThermalFrozenState(bool thawed)
|
2018-11-05 06:12:53 +00:00
|
|
|
{
|
|
|
|
x402_31_thawed = thawed;
|
|
|
|
if (x403_24_keepThermalVisorState)
|
|
|
|
return;
|
2018-11-11 03:27:54 +00:00
|
|
|
xe6_27_thermalVisorFlags = u8(thawed ? 2 : 1);
|
2018-11-05 06:12:53 +00:00
|
|
|
}
|
|
|
|
|
2018-09-14 00:49:34 +00:00
|
|
|
void CPatterned::Think(float dt, CStateManager& mgr)
|
2018-09-07 23:51:07 +00:00
|
|
|
{
|
|
|
|
if (!GetActive())
|
|
|
|
return;
|
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
if (x402_30_updateThermalFrozenState)
|
|
|
|
UpdateThermalFrozenState(x450_bodyController->GetPercentageFrozen() == 0.f);
|
2018-09-07 23:51:07 +00:00
|
|
|
|
|
|
|
if (x64_modelData->GetAnimationData()->GetIceModel())
|
2018-11-05 06:12:53 +00:00
|
|
|
x510_vertexMorph->Update(dt);
|
2018-09-07 23:51:07 +00:00
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
if (x402_26_dieIf80PercFrozen)
|
2018-09-07 23:51:07 +00:00
|
|
|
{
|
|
|
|
float froz = x450_bodyController->GetPercentageFrozen();
|
|
|
|
if (froz > 0.8f)
|
2018-11-11 03:27:54 +00:00
|
|
|
x400_29_pendingMassiveFrozenDeath = true;
|
2018-09-07 23:51:07 +00:00
|
|
|
}
|
2018-09-14 00:49:34 +00:00
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
if (!x400_25_alive)
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
if ((x400_28_pendingMassiveDeath || x400_29_pendingMassiveFrozenDeath) && x3e0_xDamageDelay <= 0.f)
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
if (x400_29_pendingMassiveFrozenDeath)
|
|
|
|
{
|
|
|
|
SendScriptMsgs(EScriptObjectState::AboutToMassivelyDie, mgr, EScriptObjectMessage::None);
|
|
|
|
MassiveFrozenDeath(mgr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SendScriptMsgs(EScriptObjectState::AboutToMassivelyDie, mgr, EScriptObjectMessage::None);
|
|
|
|
MassiveDeath(mgr);
|
|
|
|
}
|
2018-09-14 00:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
x3e0_xDamageDelay -= dt;
|
|
|
|
if (x403_26_stateControlledMassiveDeath && x330_stateMachineState.GetName())
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
bool isDead = x330_stateMachineState.GetName() == "Dead"sv;
|
|
|
|
if (isDead && x330_stateMachineState.x8_time > 15.f)
|
|
|
|
MassiveDeath(mgr);
|
2018-09-14 00:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
UpdateAlphaDelta(dt, mgr);
|
2018-09-14 00:49:34 +00:00
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
x3e4_lastHP = HealthInfo(mgr)->GetHP();
|
2018-09-14 00:49:34 +00:00
|
|
|
if (!x330_stateMachineState.x4_state)
|
|
|
|
x330_stateMachineState.SetState(mgr, *this, GetStateMachine(), "Start"sv);
|
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
zeus::CVector3f diffVec = x4e4_latestPredictedTranslation - GetTranslation();
|
|
|
|
if (!x328_25_verticalMovement)
|
2018-09-14 00:49:34 +00:00
|
|
|
diffVec.z = 0.f;
|
|
|
|
|
|
|
|
if (diffVec.magSquared() > (0.1f * dt))
|
2018-11-11 03:27:54 +00:00
|
|
|
x4f0_predictedLeashTime += dt;
|
2018-09-14 00:49:34 +00:00
|
|
|
else
|
2018-11-11 03:27:54 +00:00
|
|
|
x4f0_predictedLeashTime = 0.f;
|
2018-09-14 00:49:34 +00:00
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
if (x460_knockBackController.x81_26_enableShock)
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
/* Shock on logical falling edge */
|
|
|
|
if (!x401_31_nextPendingShock && x402_24_pendingShock)
|
|
|
|
Shock(0.5f + mgr.GetActiveRandom()->Range(0.f, 0.5f), 0.2f);
|
|
|
|
x402_24_pendingShock = x401_31_nextPendingShock;
|
|
|
|
x401_31_nextPendingShock = false;
|
|
|
|
|
|
|
|
if (x450_bodyController->IsElectrocuting())
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
mgr.GetActorModelParticles()->StartElectric(*this);
|
|
|
|
if (x3f0_pendingShockDamage > 0.f && x400_25_alive)
|
|
|
|
{
|
|
|
|
CDamageInfo dInfo({EWeaponType::Wave}, x3f0_pendingShockDamage, 0.f, 0.f);
|
|
|
|
mgr.ApplyDamage(kInvalidUniqueId, GetUniqueId(), kInvalidUniqueId, dInfo,
|
|
|
|
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
|
|
|
|
}
|
2018-09-14 00:49:34 +00:00
|
|
|
}
|
2018-11-11 03:27:54 +00:00
|
|
|
else
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
if (x3f0_pendingShockDamage != 0.f)
|
|
|
|
{
|
|
|
|
x450_bodyController->StopElectrocution();
|
|
|
|
mgr.GetActorModelParticles()->StopElectric(*this);
|
|
|
|
}
|
2018-09-14 00:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x450_bodyController->IsOnFire())
|
|
|
|
{
|
2018-11-05 06:12:53 +00:00
|
|
|
if (x400_25_alive)
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
|
|
|
mgr.GetActorModelParticles()->LightDudeOnFire(*this);
|
2018-11-11 03:27:54 +00:00
|
|
|
CDamageInfo dInfo({EWeaponType::Plasma}, x3ec_pendingFireDamage, 0.f, 0.f);
|
2018-09-14 00:49:34 +00:00
|
|
|
mgr.ApplyDamage(kInvalidUniqueId, GetUniqueId(), kInvalidUniqueId, dInfo,
|
|
|
|
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
|
|
|
|
}
|
|
|
|
}
|
2018-11-11 03:27:54 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (x3ec_pendingFireDamage > 0.f)
|
|
|
|
x3ec_pendingFireDamage = 0.f;
|
|
|
|
if (x450_bodyController->IsFrozen())
|
|
|
|
mgr.GetActorModelParticles()->StopThermalHotParticles(*this);
|
|
|
|
}
|
2018-09-14 00:49:34 +00:00
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
if (x401_27_phazingOut || x401_28_burning)
|
|
|
|
x3e8_alphaDelta = -0.33333334f;
|
2018-09-14 00:49:34 +00:00
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
if (x401_30_pendingDeath)
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
x401_30_pendingDeath = false;
|
2018-11-06 06:16:12 +00:00
|
|
|
Death(mgr, GetTransform().frontVector(), EScriptObjectState::DeathRattle);
|
2018-09-14 00:49:34 +00:00
|
|
|
}
|
|
|
|
|
2018-11-08 00:53:38 +00:00
|
|
|
float thinkDt = (x400_25_alive ? dt : dt * CalcDyingThinkRate());
|
2018-09-14 00:49:34 +00:00
|
|
|
|
|
|
|
x450_bodyController->Update(thinkDt, mgr);
|
|
|
|
x450_bodyController->MultiplyPlaybackRate(x3b4_speed);
|
|
|
|
SAdvancementDeltas deltas = UpdateAnimation(thinkDt, mgr, !x450_bodyController->IsFrozen());
|
|
|
|
x434_posDelta = deltas.x0_posDelta;
|
|
|
|
x440_rotDelta = deltas.xc_rotDelta;
|
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
if (x403_25_enableStateMachine && x450_bodyController->GetPercentageFrozen() < 1.f)
|
2018-09-14 00:49:34 +00:00
|
|
|
x330_stateMachineState.Update(mgr, *this, thinkDt);
|
|
|
|
|
|
|
|
ThinkAboutMove(thinkDt);
|
|
|
|
|
2018-11-05 06:12:53 +00:00
|
|
|
x460_knockBackController.Update(thinkDt, mgr, *this);
|
2018-11-11 03:27:54 +00:00
|
|
|
x4e4_latestPredictedTranslation = GetTranslation() + PredictMotion(thinkDt).x0_translation;
|
|
|
|
x328_26_longJump = false;
|
|
|
|
if (x420_curDamageRemTime > 0.f)
|
|
|
|
x420_curDamageRemTime -= dt;
|
2018-09-14 00:49:34 +00:00
|
|
|
|
2018-11-08 00:53:38 +00:00
|
|
|
if (x401_28_burning && x3f4_burnThinkRateTimer > dt)
|
|
|
|
x3f4_burnThinkRateTimer -= dt;
|
2018-09-14 00:49:34 +00:00
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
xd0_damageMag = x50c_baseDamageMag;
|
|
|
|
UpdateDamageColor(dt);
|
2018-09-14 00:49:34 +00:00
|
|
|
|
|
|
|
if (!x450_bodyController->IsFrozen())
|
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
if (x3a0_latestLeashPosition == zeus::CVector3f())
|
|
|
|
x3a0_latestLeashPosition = GetTranslation();
|
2018-09-14 00:49:34 +00:00
|
|
|
|
|
|
|
if (x3cc_playerLeashRadius != 0.f)
|
|
|
|
{
|
|
|
|
zeus::CVector3f diffVec = (GetTranslation() - mgr.GetPlayer().GetTranslation());
|
|
|
|
if (diffVec.magSquared() > x3cc_playerLeashRadius)
|
|
|
|
x3d4_curPlayerLeashTime += dt;
|
|
|
|
else
|
|
|
|
x3d4_curPlayerLeashTime = 0.f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2018-11-11 03:27:54 +00:00
|
|
|
{
|
2018-09-14 00:49:34 +00:00
|
|
|
RemoveEmitter();
|
2018-11-11 03:27:54 +00:00
|
|
|
}
|
2018-09-14 00:49:34 +00:00
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
if (x2f8_waypointPauseRemTime > 0.f)
|
|
|
|
x2f8_waypointPauseRemTime -= dt;
|
2018-09-07 23:51:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::Touch(CActor& act, CStateManager& mgr)
|
|
|
|
{
|
2018-11-05 06:12:53 +00:00
|
|
|
if (!x400_25_alive)
|
2018-09-07 23:51:07 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (TCastToPtr<CGameProjectile> proj = act)
|
|
|
|
{
|
|
|
|
if (mgr.GetPlayer().GetUniqueId() == proj->GetOwnerId())
|
2018-11-11 03:27:54 +00:00
|
|
|
x400_24_hitByPlayerProjectile = true;
|
2018-09-07 23:51:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-14 00:49:34 +00:00
|
|
|
std::experimental::optional<zeus::CAABox> CPatterned::GetTouchBounds() const
|
|
|
|
{
|
|
|
|
return GetBoundingBox();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::CanRenderUnsorted(const urde::CStateManager& mgr) const
|
|
|
|
{
|
|
|
|
return x64_modelData->GetAnimationData()->GetParticleDB().AreAnySystemsDrawnWithModel() ? false :
|
|
|
|
CActor::CanRenderUnsorted(mgr);
|
|
|
|
}
|
|
|
|
|
2018-09-07 23:51:07 +00:00
|
|
|
zeus::CVector3f CPatterned::GetAimPosition(const urde::CStateManager& mgr, float dt) const
|
|
|
|
{
|
|
|
|
zeus::CVector3f offset;
|
|
|
|
if (dt > 0.f)
|
|
|
|
offset = PredictMotion(dt).x0_translation;
|
|
|
|
|
|
|
|
CSegId segId = GetModelData()->GetAnimationData()->GetLocatorSegId("lockon_target_LCTR"sv);
|
|
|
|
if (segId != 0xFF)
|
|
|
|
{
|
|
|
|
zeus::CTransform xf = GetModelData()->GetAnimationData()->GetLocatorTransform(segId, nullptr);
|
|
|
|
zeus::CVector3f scaledOrigin = GetModelData()->GetScale() * xf.origin;
|
|
|
|
if (GetTouchBounds())
|
|
|
|
return offset + GetTouchBounds()->clampToBox(x34_transform * scaledOrigin);
|
|
|
|
|
|
|
|
zeus::CAABox aabox = GetBaseBoundingBox();
|
|
|
|
|
|
|
|
zeus::CAABox primBox(aabox.min + GetPrimitiveOffset(), aabox.max + GetPrimitiveOffset());
|
|
|
|
|
|
|
|
return offset + (x34_transform * primBox.clampToBox(scaledOrigin));
|
|
|
|
}
|
|
|
|
|
|
|
|
return offset + GetBoundingBox().center();
|
|
|
|
}
|
|
|
|
|
2018-11-06 06:16:12 +00:00
|
|
|
void CPatterned::DeathDelete(CStateManager& mgr)
|
|
|
|
{
|
|
|
|
SendScriptMsgs(EScriptObjectState::Dead, mgr, EScriptObjectMessage::None);
|
|
|
|
if (x450_bodyController->IsElectrocuting())
|
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
x3f0_pendingShockDamage = 0.f;
|
2018-11-06 06:16:12 +00:00
|
|
|
x450_bodyController->StopElectrocution();
|
|
|
|
mgr.GetActorModelParticles()->StopElectric(*this);
|
|
|
|
}
|
|
|
|
mgr.FreeScriptObject(GetUniqueId());
|
|
|
|
}
|
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
void CPatterned::Death(CStateManager& mgr, const zeus::CVector3f& dir, EScriptObjectState state)
|
|
|
|
{
|
|
|
|
if (x400_25_alive)
|
|
|
|
{
|
|
|
|
if (!x450_bodyController->IsOnFire())
|
|
|
|
{
|
|
|
|
x402_25_lostMassiveFrozenHP = (x3e4_lastHP - HealthInfo(mgr)->GetHP()) >=
|
|
|
|
x3dc_frozenXDamageThreshold;
|
|
|
|
if (x402_25_lostMassiveFrozenHP && x54c_iceDeathExplosionParticle &&
|
|
|
|
x450_bodyController->GetPercentageFrozen() > 0.8f)
|
|
|
|
{
|
|
|
|
x400_29_pendingMassiveFrozenDeath = true;
|
|
|
|
}
|
|
|
|
else if ((x3e4_lastHP - HealthInfo(mgr)->GetHP()) >= x3d8_xDamageThreshold)
|
|
|
|
{
|
|
|
|
x400_28_pendingMassiveDeath = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (x400_28_pendingMassiveDeath || x400_29_pendingMassiveFrozenDeath)
|
|
|
|
{
|
|
|
|
if (x328_30_lookAtDeathDir && x3e0_xDamageDelay <= 0.f && dir != zeus::CVector3f::skZero)
|
|
|
|
{
|
|
|
|
SetTransform(zeus::lookAt(GetTranslation(), GetTranslation() - dir) *
|
|
|
|
zeus::CTransform::RotateX(zeus::degToRad(45.f)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x330_stateMachineState.SetState(mgr, *this, GetStateMachine(), "Dead"sv);
|
|
|
|
RemoveMaterial(EMaterialTypes::GroundCollider, mgr);
|
|
|
|
x328_25_verticalMovement = false;
|
|
|
|
}
|
|
|
|
x400_25_alive = false;
|
|
|
|
if (x450_bodyController->HasBodyState(pas::EAnimationState::Hurled) &&
|
|
|
|
x450_bodyController->GetBodyType() == EBodyType::Flyer)
|
|
|
|
{
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCHurledCmd(-dir, zeus::CVector3f::skZero));
|
|
|
|
}
|
|
|
|
else if (x450_bodyController->HasBodyState(pas::EAnimationState::Fall))
|
|
|
|
{
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCKnockDownCmd(-dir, pas::ESeverity::One));
|
|
|
|
}
|
|
|
|
if (state != EScriptObjectState::Any)
|
|
|
|
{
|
|
|
|
SendScriptMsgs(state, mgr, EScriptObjectMessage::None);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-05 06:12:53 +00:00
|
|
|
void CPatterned::KnockBack(const zeus::CVector3f& backVec, CStateManager& mgr, const CDamageInfo& info,
|
|
|
|
EKnockBackType type, bool inDeferred, float magnitude)
|
|
|
|
{
|
|
|
|
CHealthInfo* hInfo = HealthInfo(mgr);
|
2018-11-11 03:27:54 +00:00
|
|
|
if (!x401_27_phazingOut && !x401_28_burning && hInfo)
|
2018-11-05 06:12:53 +00:00
|
|
|
{
|
|
|
|
x460_knockBackController.KnockBack(backVec, mgr, *this, info, type, magnitude);
|
2018-11-06 06:16:12 +00:00
|
|
|
if (x450_bodyController->IsFrozen() && x460_knockBackController.GetActiveParms().xc_ >= 0.f)
|
|
|
|
x450_bodyController->FrozenBreakout();
|
|
|
|
switch (x460_knockBackController.GetActiveParms().x4_animFollowup)
|
|
|
|
{
|
|
|
|
case EKnockBackAnimationFollowUp::Freeze:
|
|
|
|
Freeze(mgr, zeus::CVector3f::skZero, zeus::CUnitVector3f(x34_transform.transposeRotate(backVec)),
|
|
|
|
x460_knockBackController.GetActiveParms().x8_followupMagnitude);
|
|
|
|
break;
|
|
|
|
case EKnockBackAnimationFollowUp::PhazeOut:
|
|
|
|
PhazeOut(mgr);
|
|
|
|
break;
|
|
|
|
case EKnockBackAnimationFollowUp::Shock:
|
|
|
|
Shock(x460_knockBackController.GetActiveParms().x8_followupMagnitude, -1.f);
|
|
|
|
break;
|
|
|
|
case EKnockBackAnimationFollowUp::Burn:
|
|
|
|
Burn(x460_knockBackController.GetActiveParms().x8_followupMagnitude, 0.25f);
|
|
|
|
break;
|
2018-11-08 00:53:38 +00:00
|
|
|
case EKnockBackAnimationFollowUp::LaggedBurnDeath:
|
|
|
|
x401_29_laggedBurnDeath = true;
|
|
|
|
case EKnockBackAnimationFollowUp::BurnDeath:
|
2018-11-06 06:16:12 +00:00
|
|
|
Burn(x460_knockBackController.GetActiveParms().x8_followupMagnitude, -1.f);
|
|
|
|
Death(mgr, zeus::CVector3f::skZero, EScriptObjectState::DeathRattle);
|
2018-11-11 03:27:54 +00:00
|
|
|
x400_28_pendingMassiveDeath = x400_29_pendingMassiveFrozenDeath = false;
|
|
|
|
x400_27_fadeToDeath = x401_28_burning = true;
|
2018-11-08 00:53:38 +00:00
|
|
|
x3f4_burnThinkRateTimer = 1.5f;
|
2018-11-11 03:27:54 +00:00
|
|
|
x402_29_drawParticles = false;
|
2018-11-06 06:16:12 +00:00
|
|
|
x450_bodyController->DouseFlames();
|
|
|
|
mgr.GetActorModelParticles()->StopThermalHotParticles(*this);
|
2018-11-08 00:53:38 +00:00
|
|
|
mgr.GetActorModelParticles()->StartBurnDeath(*this);
|
|
|
|
if (!x401_29_laggedBurnDeath)
|
2018-11-06 06:16:12 +00:00
|
|
|
{
|
|
|
|
mgr.GetActorModelParticles()->EnsureFirePopLoaded(*this);
|
|
|
|
mgr.GetActorModelParticles()->EnsureIceBreakLoaded(*this);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EKnockBackAnimationFollowUp::Death:
|
|
|
|
Death(mgr, zeus::CVector3f::skZero, EScriptObjectState::DeathRattle);
|
|
|
|
break;
|
|
|
|
case EKnockBackAnimationFollowUp::ExplodeDeath:
|
|
|
|
Death(mgr, zeus::CVector3f::skZero, EScriptObjectState::DeathRattle);
|
|
|
|
if (GetDeathExplosionParticle() || x530_deathExplosionElectric)
|
2018-11-11 03:27:54 +00:00
|
|
|
MassiveDeath(mgr);
|
2018-11-06 06:16:12 +00:00
|
|
|
else if (x450_bodyController->IsFrozen())
|
|
|
|
x450_bodyController->FrozenBreakout();
|
|
|
|
break;
|
|
|
|
case EKnockBackAnimationFollowUp::IceDeath:
|
|
|
|
Death(mgr, zeus::CVector3f::skZero, EScriptObjectState::DeathRattle);
|
|
|
|
if (x54c_iceDeathExplosionParticle)
|
2018-11-11 03:27:54 +00:00
|
|
|
MassiveFrozenDeath(mgr);
|
2018-11-06 06:16:12 +00:00
|
|
|
else if (x450_bodyController->IsFrozen())
|
|
|
|
x450_bodyController->FrozenBreakout();
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2018-11-05 06:12:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
void CPatterned::TakeDamage(const zeus::CVector3f&, float arg)
|
|
|
|
{
|
|
|
|
x428_damageCooldownTimer = 0.33f;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::FixedRandom(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
return x330_stateMachineState.GetRandom() < x330_stateMachineState.x14_;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::Random(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
return x330_stateMachineState.GetRandom() < arg;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::CodeTrigger(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
return x330_stateMachineState.x18_24_;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::FixedDelay(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
return x330_stateMachineState.GetTime() > x330_stateMachineState.GetDelay();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::RandomDelay(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
return x330_stateMachineState.GetTime() > arg * x330_stateMachineState.GetRandom();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::Delay(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
return x330_stateMachineState.GetTime() > arg;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::PatrolPathOver(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
return x2dc_destObj == kInvalidUniqueId;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::Stuck(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
return x4f0_predictedLeashTime > 0.2f;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::AnimOver(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
return x32c_animState == EAnimState::Over;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::InPosition(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
return x328_24_inPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::HasPatrolPath(CStateManager& mgr, float arg)
|
|
|
|
{
|
|
|
|
return GetWaypointForState(mgr, EScriptObjectState::Patrol,
|
|
|
|
EScriptObjectMessage::Follow) != kInvalidUniqueId;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::Attacked(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
return x400_24_hitByPlayerProjectile;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::PatternShagged(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
return x400_30_patternShagged;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::PatternOver(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
return x38c_patterns.size() <= x39c_curPattern;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::HasRetreatPattern(CStateManager& mgr, float arg)
|
|
|
|
{
|
|
|
|
return GetWaypointForState(mgr, EScriptObjectState::Retreat,
|
|
|
|
EScriptObjectMessage::Follow) != kInvalidUniqueId;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::HasAttackPattern(CStateManager& mgr, float arg)
|
|
|
|
{
|
|
|
|
return GetWaypointForState(mgr, EScriptObjectState::Attack,
|
|
|
|
EScriptObjectMessage::Follow) != kInvalidUniqueId;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::NoPathNodes(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
if (CPathFindSearch* search = GetSearchPath())
|
|
|
|
return search->OnPath(GetTranslation()) != CPathFindSearch::EResult::Success;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const float skActorApproachDistance = 3.f;
|
|
|
|
|
|
|
|
bool CPatterned::PathShagged(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
if (CPathFindSearch* search = GetSearchPath())
|
|
|
|
{
|
|
|
|
if (search->IsShagged())
|
|
|
|
return true;
|
|
|
|
if (search->GetCurrentWaypoint() > 0 && x401_24_pathOverCount == 0)
|
|
|
|
{
|
|
|
|
zeus::CVector3f origPoint = GetTranslation() + 0.3f * zeus::CVector3f::skUp;
|
|
|
|
zeus::CVector3f point = origPoint;
|
|
|
|
search->GetSplinePoint(point, GetTranslation());
|
|
|
|
return (point - origPoint).magSquared() > 4.f *
|
|
|
|
skActorApproachDistance * skActorApproachDistance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::PathFound(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
if (CPathFindSearch* search = GetSearchPath())
|
|
|
|
if (!search->IsShagged())
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::PathOver(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
if (CPathFindSearch* search = GetSearchPath())
|
|
|
|
if (x328_25_verticalMovement || x328_27_onGround)
|
|
|
|
if (!search->IsShagged() && search->IsOver())
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::Landed(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
bool ret = x328_27_onGround && !x328_28_prevOnGround;
|
|
|
|
x328_28_prevOnGround = x328_27_onGround;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::PlayerSpot(CStateManager& mgr, float arg)
|
|
|
|
{
|
|
|
|
if (mgr.GetPlayer().GetMorphballTransitionState() ==
|
|
|
|
CPlayer::EPlayerMorphBallState::Unmorphed)
|
|
|
|
{
|
|
|
|
zeus::CVector3f aimPosition = mgr.GetPlayer().GetAimPosition(mgr, 0.f);
|
|
|
|
zeus::CVector3f center = GetBoundingBox().center();
|
|
|
|
zeus::CVector3f aimToCenter = center - aimPosition;
|
|
|
|
float aimToCenterMag = aimToCenter.magnitude();
|
|
|
|
zeus::CVector3f aimToCenterNorm = aimToCenter * (1.f / aimToCenterMag);
|
|
|
|
zeus::CVector3f screenSpace = mgr.GetCameraManager()->
|
|
|
|
GetFirstPersonCamera()->ConvertToScreenSpace(center);
|
|
|
|
if (screenSpace.z > 0.f &&
|
|
|
|
screenSpace.x * screenSpace.x < 1.f &&
|
|
|
|
screenSpace.y * screenSpace.y < 1.f)
|
|
|
|
{
|
|
|
|
CRayCastResult res =
|
|
|
|
mgr.RayStaticIntersection(aimPosition, aimToCenterNorm, aimToCenterMag,
|
|
|
|
CMaterialFilter::MakeInclude(EMaterialTypes::Solid));
|
|
|
|
return res.IsInvalid();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::SpotPlayer(CStateManager& mgr, float arg)
|
|
|
|
{
|
|
|
|
zeus::CVector3f gunToPlayer = mgr.GetPlayer().GetAimPosition(mgr, 0.f) - GetGunEyePos();
|
|
|
|
float lookDot = gunToPlayer.dot(x34_transform.basis[1]);
|
|
|
|
if (lookDot > 0.f)
|
|
|
|
return lookDot * lookDot > gunToPlayer.magSquared() * x3c4_detectionAngle;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::Leash(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
bool ret = x3d4_curPlayerLeashTime > x3d0_playerLeashTime;
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
float posToLeashMagSq = (x3a0_latestLeashPosition - GetTranslation()).magSquared();
|
|
|
|
if (posToLeashMagSq > x3c8_leashRadius * x3c8_leashRadius)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::InDetectionRange(CStateManager& mgr, float arg)
|
|
|
|
{
|
|
|
|
zeus::CVector3f delta = mgr.GetPlayer().GetTranslation() - GetTranslation();
|
|
|
|
if (delta.magSquared() < x3bc_detectionRange * x3bc_detectionRange)
|
|
|
|
{
|
|
|
|
if (x3c0_detectionHeightRange > 0.f)
|
|
|
|
return delta.z * delta.z < x3c0_detectionHeightRange * x3c0_detectionHeightRange;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::InMaxRange(CStateManager& mgr, float arg)
|
|
|
|
{
|
|
|
|
return (mgr.GetPlayer().GetTranslation() - GetTranslation()).magSquared() <
|
|
|
|
x300_maxAttackRange * x300_maxAttackRange;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::TooClose(CStateManager& mgr, float arg)
|
|
|
|
{
|
|
|
|
return (mgr.GetPlayer().GetTranslation() - GetTranslation()).magSquared() <
|
|
|
|
x2fc_minAttackRange * x2fc_minAttackRange;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::InRange(CStateManager& mgr, float arg)
|
|
|
|
{
|
|
|
|
float range = 0.5f * (x2fc_minAttackRange + x300_maxAttackRange);
|
|
|
|
return (mgr.GetPlayer().GetTranslation() - GetTranslation()).magSquared() < range * range;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::OffLine(CStateManager&, float arg)
|
|
|
|
{
|
|
|
|
zeus::CVector3f curLine = GetTranslation() - x2ec_reflectedDestPos;
|
|
|
|
zeus::CVector3f pathLine = x2e0_destPos - x2ec_reflectedDestPos;
|
|
|
|
float distSq;
|
|
|
|
if (curLine.dot(pathLine) <= 0.f)
|
|
|
|
{
|
|
|
|
distSq = curLine.magSquared();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pathLine.normalize();
|
|
|
|
distSq = (curLine - pathLine.dot(curLine) * pathLine).magSquared();
|
|
|
|
zeus::CVector3f delta = GetTranslation() - x2e0_destPos;
|
|
|
|
if (pathLine.dot(delta) > 0.f)
|
|
|
|
distSq = delta.magSquared();
|
|
|
|
}
|
|
|
|
return distSq > arg * arg;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::PathFind(CStateManager& mgr, EStateMsg msg, float arg)
|
|
|
|
{
|
|
|
|
if (CPathFindSearch* search = GetSearchPath())
|
|
|
|
{
|
|
|
|
u32 curWp = search->GetCurrentWaypoint();
|
|
|
|
const auto& waypoints = search->GetWaypoints();
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case EStateMsg::Zero:
|
|
|
|
{
|
|
|
|
if (search->Search(GetTranslation(), x2e0_destPos) == CPathFindSearch::EResult::Success)
|
|
|
|
{
|
|
|
|
x2ec_reflectedDestPos = GetTranslation();
|
|
|
|
zeus::CVector3f destPos;
|
|
|
|
if (curWp + 1 < waypoints.size())
|
|
|
|
destPos = waypoints[curWp + 1];
|
|
|
|
else
|
|
|
|
destPos = waypoints[curWp];
|
|
|
|
SetDestPos(destPos);
|
|
|
|
x328_24_inPosition = false;
|
|
|
|
ApproachDest(mgr);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EStateMsg::One:
|
|
|
|
{
|
|
|
|
if (curWp < waypoints.size() - 1)
|
|
|
|
{
|
|
|
|
if (x328_24_inPosition || x328_27_onGround)
|
|
|
|
x401_24_pathOverCount += 1;
|
|
|
|
zeus::CVector3f biasedPos = GetTranslation() + 0.3f * zeus::CVector3f::skUp;
|
|
|
|
x2ec_reflectedDestPos = biasedPos - (x2e0_destPos - biasedPos);
|
|
|
|
ApproachDest(mgr);
|
|
|
|
zeus::CVector3f biasedForward = x34_transform.basis[1] * x64_modelData->GetScale().y + biasedPos;
|
|
|
|
search->GetSplinePointWithLookahead(biasedForward, biasedPos, 3.f * x64_modelData->GetScale().y);
|
|
|
|
SetDestPos(biasedForward);
|
|
|
|
if (search->SegmentOver(biasedPos))
|
|
|
|
search->SetCurrentWaypoint(search->GetCurrentWaypoint() + 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::Dead(CStateManager& mgr, EStateMsg msg, float arg)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case EStateMsg::Zero:
|
|
|
|
x31c_faceVec = zeus::CVector3f::skZero;
|
|
|
|
break;
|
|
|
|
case EStateMsg::One:
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBodyStateCmd(EBodyStateCmd::Die));
|
|
|
|
if (!x400_27_fadeToDeath)
|
|
|
|
{
|
|
|
|
if (x450_bodyController->GetBodyStateInfo().GetCurrentState()->IsDead())
|
|
|
|
{
|
|
|
|
x400_27_fadeToDeath = true;
|
|
|
|
x3e8_alphaDelta = -0.333333f;
|
|
|
|
RemoveMaterial(EMaterialTypes::Character, EMaterialTypes::Solid,
|
|
|
|
EMaterialTypes::Target, EMaterialTypes::Orbit, mgr);
|
|
|
|
AddMaterial(EMaterialTypes::ProjectilePassthrough, mgr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::TargetPlayer(CStateManager& mgr, EStateMsg msg, float arg)
|
|
|
|
{
|
|
|
|
if (msg == EStateMsg::Zero)
|
|
|
|
{
|
|
|
|
x2dc_destObj = mgr.GetPlayer().GetUniqueId();
|
|
|
|
SetDestPos(mgr.GetPlayer().GetTranslation());
|
|
|
|
x2ec_reflectedDestPos = GetTranslation();
|
|
|
|
x328_24_inPosition = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::TargetPatrol(CStateManager& mgr, EStateMsg msg, float arg)
|
|
|
|
{
|
|
|
|
if (msg == EStateMsg::Zero)
|
|
|
|
{
|
|
|
|
x2dc_destObj = GetWaypointForState(mgr, EScriptObjectState::Patrol, EScriptObjectMessage::Follow);
|
|
|
|
if (TCastToConstPtr<CActor> act = mgr.GetObjectById(x2dc_destObj))
|
|
|
|
SetDestPos(act->GetTranslation());
|
|
|
|
x2ec_reflectedDestPos = GetTranslation();
|
|
|
|
x328_24_inPosition = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::FollowPattern(CStateManager& mgr, EStateMsg msg, float arg)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case EStateMsg::Zero:
|
|
|
|
SetupPattern(mgr);
|
|
|
|
if (x328_29_noPatternShagging || !IsPatternObstructed(mgr, GetTranslation(), x2e0_destPos))
|
|
|
|
{
|
|
|
|
ApproachDest(mgr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x39c_curPattern = x38c_patterns.size();
|
|
|
|
x400_30_patternShagged = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EStateMsg::One:
|
|
|
|
if (x328_24_inPosition)
|
|
|
|
{
|
|
|
|
x39c_curPattern += 1;
|
|
|
|
UpdatePatternDestPos(mgr);
|
|
|
|
if (!x328_29_noPatternShagging && IsPatternObstructed(mgr, GetTranslation(), x2e0_destPos))
|
|
|
|
{
|
|
|
|
x39c_curPattern = x38c_patterns.size();
|
|
|
|
x400_30_patternShagged = true;
|
|
|
|
}
|
|
|
|
else if (x39c_curPattern < x38c_patterns.size())
|
|
|
|
{
|
|
|
|
x2ec_reflectedDestPos = GetTranslation();
|
|
|
|
x328_24_inPosition = false;
|
|
|
|
x3b0_moveSpeed = x38c_patterns[x39c_curPattern].GetSpeed();
|
|
|
|
x380_behaviour = EBehaviour(x38c_patterns[x39c_curPattern].GetBehaviour());
|
|
|
|
x30c_behaviourOrient = EBehaviourOrient(x38c_patterns[x39c_curPattern].GetBehaviourOrient());
|
|
|
|
x384_behaviourModifiers = EBehaviourModifiers(x38c_patterns[x39c_curPattern].GetBehaviourModifiers());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UpdatePatternDestPos(mgr);
|
|
|
|
}
|
|
|
|
ApproachDest(mgr);
|
|
|
|
break;
|
|
|
|
case EStateMsg::Two:
|
|
|
|
x38c_patterns.clear();
|
|
|
|
x400_30_patternShagged = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::Patrol(CStateManager& mgr, EStateMsg msg, float arg)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case EStateMsg::Zero:
|
|
|
|
if (x3ac_lastPatrolDest == kInvalidUniqueId)
|
|
|
|
{
|
|
|
|
x2dc_destObj = GetWaypointForState(mgr, EScriptObjectState::Patrol, EScriptObjectMessage::Follow);
|
|
|
|
x30c_behaviourOrient = EBehaviourOrient::MoveDir;
|
|
|
|
x3b0_moveSpeed = 1.f;
|
|
|
|
if (x2dc_destObj != kInvalidUniqueId)
|
|
|
|
{
|
|
|
|
if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(x2dc_destObj))
|
|
|
|
{
|
|
|
|
x30c_behaviourOrient = EBehaviourOrient(wp->GetBehaviourOrient());
|
|
|
|
x3b0_moveSpeed = wp->GetSpeed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x2dc_destObj = x3ac_lastPatrolDest;
|
|
|
|
}
|
|
|
|
x2ec_reflectedDestPos = GetTranslation();
|
|
|
|
x328_24_inPosition = false;
|
|
|
|
x2d8_patrolState = EPatrolState::Patrol;
|
|
|
|
x2f8_waypointPauseRemTime = 0.f;
|
|
|
|
break;
|
|
|
|
case EStateMsg::One:
|
|
|
|
switch (x2d8_patrolState)
|
|
|
|
{
|
|
|
|
case EPatrolState::Patrol:
|
|
|
|
if (x328_24_inPosition && x2dc_destObj != kInvalidUniqueId)
|
|
|
|
{
|
|
|
|
if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(x2dc_destObj))
|
|
|
|
{
|
|
|
|
if (wp->GetPause() > 0.f)
|
|
|
|
{
|
|
|
|
x2f8_waypointPauseRemTime = wp->GetPause();
|
|
|
|
x2d8_patrolState = EPatrolState::Pause;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (x2dc_destObj == kInvalidUniqueId)
|
|
|
|
x2d8_patrolState = EPatrolState::Done;
|
|
|
|
UpdateDest(mgr);
|
|
|
|
ApproachDest(mgr);
|
|
|
|
break;
|
|
|
|
case EPatrolState::Pause:
|
|
|
|
if (x2f8_waypointPauseRemTime <= 0.f)
|
|
|
|
x2d8_patrolState = EPatrolState::Patrol;
|
|
|
|
break;
|
|
|
|
case EPatrolState::Done:
|
|
|
|
if (x2dc_destObj != kInvalidUniqueId)
|
|
|
|
x2d8_patrolState = EPatrolState::Patrol;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EStateMsg::Two:
|
|
|
|
x3ac_lastPatrolDest = x2dc_destObj;
|
|
|
|
x2d8_patrolState = EPatrolState::Invalid;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-07 23:51:07 +00:00
|
|
|
void CPatterned::BuildBodyController(EBodyType bodyType)
|
|
|
|
{
|
|
|
|
if (x450_bodyController)
|
|
|
|
return;
|
|
|
|
|
|
|
|
x450_bodyController.reset(new CBodyController(*this, x3b8_turnSpeed, bodyType));
|
|
|
|
auto anim = x450_bodyController->GetPASDatabase().FindBestAnimation(CPASAnimParmData(24,
|
|
|
|
CPASAnimParm::FromEnum(0)), -1);
|
2018-11-11 03:27:54 +00:00
|
|
|
x460_knockBackController.x81_26_enableShock = anim.first > 0.f;
|
2018-11-06 06:16:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::GenerateDeathExplosion(CStateManager& mgr)
|
|
|
|
{
|
|
|
|
if (auto particle = GetDeathExplosionParticle())
|
|
|
|
{
|
|
|
|
zeus::CTransform xf(GetTransform());
|
|
|
|
xf.origin = GetTransform() * (x64_modelData->GetScale() * x514_deathExplosionOffset);
|
|
|
|
CExplosion* explo = new CExplosion(*particle, mgr.AllocateUniqueId(), true,
|
|
|
|
CEntityInfo(GetAreaIdAlways(), CEntity::NullConnectionList), "", xf, 1,
|
|
|
|
zeus::CVector3f::skOne, zeus::CColor::skWhite);
|
|
|
|
mgr.AddObject(explo);
|
|
|
|
}
|
|
|
|
else if (x530_deathExplosionElectric)
|
|
|
|
{
|
|
|
|
zeus::CTransform xf(GetTransform());
|
|
|
|
xf.origin = GetTransform() * (x64_modelData->GetScale() * x514_deathExplosionOffset);
|
|
|
|
CExplosion* explo = new CExplosion(*x530_deathExplosionElectric, mgr.AllocateUniqueId(), true,
|
|
|
|
CEntityInfo(GetAreaIdAlways(), CEntity::NullConnectionList), "", xf, 1,
|
|
|
|
zeus::CVector3f::skOne, zeus::CColor::skWhite);
|
|
|
|
mgr.AddObject(explo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
void CPatterned::MassiveDeath(CStateManager& mgr)
|
2018-11-06 06:16:12 +00:00
|
|
|
{
|
|
|
|
CSfxManager::AddEmitter(x454_deathSfx, GetTranslation(), zeus::CVector3f::skZero,
|
|
|
|
true, false, 0x7f, kInvalidAreaId);
|
2018-11-08 00:53:38 +00:00
|
|
|
if (!x401_28_burning)
|
2018-11-06 06:16:12 +00:00
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::MassiveDeath, mgr, EScriptObjectMessage::None);
|
2018-11-06 06:16:12 +00:00
|
|
|
GenerateDeathExplosion(mgr);
|
|
|
|
}
|
|
|
|
DeathDelete(mgr);
|
2018-11-11 03:27:54 +00:00
|
|
|
x400_28_pendingMassiveDeath = x400_29_pendingMassiveFrozenDeath = false;
|
2018-11-06 06:16:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::GenerateIceDeathExplosion(CStateManager& mgr)
|
|
|
|
{
|
|
|
|
if (x54c_iceDeathExplosionParticle)
|
|
|
|
{
|
|
|
|
zeus::CTransform xf(GetTransform());
|
|
|
|
xf.origin = GetTransform() * (x64_modelData->GetScale() * x540_iceDeathExplosionOffset);
|
|
|
|
CExplosion* explo = new CExplosion(*x54c_iceDeathExplosionParticle, mgr.AllocateUniqueId(), true,
|
|
|
|
CEntityInfo(GetAreaIdAlways(), CEntity::NullConnectionList), "", xf, 1,
|
|
|
|
zeus::CVector3f::skOne, zeus::CColor::skWhite);
|
|
|
|
mgr.AddObject(explo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
void CPatterned::MassiveFrozenDeath(CStateManager& mgr)
|
2018-11-06 06:16:12 +00:00
|
|
|
{
|
|
|
|
if (x458_iceShatterSfx == 0xffff)
|
|
|
|
x458_iceShatterSfx = x454_deathSfx;
|
|
|
|
CSfxManager::AddEmitter(x458_iceShatterSfx, GetTranslation(), zeus::CVector3f::skZero,
|
|
|
|
true, false, 0x7f, kInvalidAreaId);
|
2018-11-11 03:27:54 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::MassiveFrozenDeath, mgr, EScriptObjectMessage::None);
|
2018-11-06 06:16:12 +00:00
|
|
|
GenerateIceDeathExplosion(mgr);
|
|
|
|
float toPlayerDist = (mgr.GetPlayer().GetTranslation() - GetTranslation()).magnitude();
|
|
|
|
if (toPlayerDist < 40.f)
|
|
|
|
mgr.GetCameraManager()->AddCameraShaker(CCameraShakeData::BuildPatternedExplodeShakeData(
|
|
|
|
GetTranslation(), 0.25f, 0.3f, 40.f), true);
|
|
|
|
DeathDelete(mgr);
|
2018-11-11 03:27:54 +00:00
|
|
|
x400_28_pendingMassiveDeath = x400_29_pendingMassiveFrozenDeath = false;
|
2018-09-07 23:51:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
zeus::CVector3f CPatterned::GetGunEyePos() const
|
|
|
|
{
|
|
|
|
zeus::CVector3f origin = GetOrigin();
|
|
|
|
zeus::CAABox baseBox = GetBaseBoundingBox();
|
|
|
|
origin.z = 0.6f * (baseBox.max.z - baseBox.min.z) + origin.z;
|
|
|
|
|
|
|
|
return origin;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::SetupPlayerCollision(bool v)
|
|
|
|
{
|
|
|
|
CMaterialList include = GetMaterialFilter().GetIncludeList();
|
|
|
|
CMaterialList exclude = GetMaterialFilter().GetExcludeList();
|
|
|
|
CMaterialList* modList = (v ? &exclude : &include);
|
|
|
|
modList->Add(EMaterialTypes::Player);
|
|
|
|
SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude));
|
2016-04-25 05:03:38 +00:00
|
|
|
}
|
2017-01-17 01:23:19 +00:00
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
void CPatterned::UpdateAlphaDelta(float dt, CStateManager& mgr)
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
if (x3e8_alphaDelta == 0.f)
|
2018-11-08 00:53:38 +00:00
|
|
|
return;
|
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
float alpha = dt * x3e8_alphaDelta + x42c_color.a;
|
2018-11-08 00:53:38 +00:00
|
|
|
if (alpha > 1.f)
|
|
|
|
{
|
|
|
|
alpha = 1.f;
|
2018-11-11 03:27:54 +00:00
|
|
|
x3e8_alphaDelta = 0.f;
|
2018-11-08 00:53:38 +00:00
|
|
|
}
|
|
|
|
else if (alpha < 0.f)
|
|
|
|
{
|
|
|
|
alpha = 0.f;
|
2018-11-11 03:27:54 +00:00
|
|
|
x3e8_alphaDelta = 0.f;
|
|
|
|
if (x400_27_fadeToDeath)
|
2018-11-08 00:53:38 +00:00
|
|
|
DeathDelete(mgr);
|
|
|
|
}
|
|
|
|
x94_simpleShadow->SetUserAlpha(alpha);
|
2018-11-11 03:27:54 +00:00
|
|
|
SetModelAlpha(alpha);
|
|
|
|
x64_modelData->AnimationData()->GetParticleDB().
|
|
|
|
SetModulationColorAllActiveEffects(zeus::CColor(1.f, alpha));
|
2018-11-08 00:53:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float CPatterned::CalcDyingThinkRate()
|
|
|
|
{
|
|
|
|
float f0 = (x401_28_burning ? (x3f4_burnThinkRateTimer / 1.5f) : 1.f);
|
2018-09-14 00:49:34 +00:00
|
|
|
return zeus::max(0.1f, f0);
|
|
|
|
}
|
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
void CPatterned::UpdateDamageColor(float dt)
|
|
|
|
{
|
|
|
|
if (x428_damageCooldownTimer > 0.f)
|
|
|
|
{
|
|
|
|
x428_damageCooldownTimer = std::max(0.f, x428_damageCooldownTimer - dt);
|
|
|
|
float alpha = x42c_color.a;
|
|
|
|
x42c_color = zeus::CColor::lerp(zeus::CColor::skBlack, x430_damageColor,
|
|
|
|
std::min(x428_damageCooldownTimer / 0.33f, 1.f));
|
|
|
|
x42c_color.a = alpha;
|
|
|
|
if (!x450_bodyController->IsFrozen())
|
|
|
|
xd0_damageMag = x50c_baseDamageMag + x428_damageCooldownTimer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TUniqueId CPatterned::GetWaypointForState(CStateManager& mgr, EScriptObjectState state,
|
|
|
|
EScriptObjectMessage msg) const
|
|
|
|
{
|
|
|
|
rstl::reserved_vector<TUniqueId, 12> ids;
|
|
|
|
for (const auto& conn : GetConnectionList())
|
|
|
|
{
|
|
|
|
if (conn.x0_state == state && conn.x4_msg == msg)
|
|
|
|
{
|
|
|
|
TUniqueId id = mgr.GetIdForScript(conn.x8_objId);
|
|
|
|
if (const CEntity* ent = mgr.GetObjectById(id))
|
|
|
|
if (ent->GetActive())
|
|
|
|
ids.push_back(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ids.empty())
|
|
|
|
return ids[mgr.GetActiveRandom()->Next() % ids.size()];
|
|
|
|
|
|
|
|
return kInvalidUniqueId;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::UpdateActorKeyframe(CStateManager& mgr) const
|
|
|
|
{
|
|
|
|
if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(x2dc_destObj))
|
|
|
|
for (const auto& conn : wp->GetConnectionList())
|
|
|
|
if (conn.x0_state == EScriptObjectState::Arrived && conn.x4_msg == EScriptObjectMessage::Action)
|
|
|
|
if (TCastToPtr<CScriptActorKeyframe> kf = mgr.ObjectById(mgr.GetIdForScript(conn.x8_objId)))
|
|
|
|
if (kf->GetActive() && kf->IsPassive())
|
|
|
|
kf->UpdateEntity(GetUniqueId(), mgr);
|
|
|
|
}
|
|
|
|
|
|
|
|
pas::EStepDirection CPatterned::GetStepDirection(const zeus::CVector3f& moveVec) const
|
|
|
|
{
|
|
|
|
zeus::CVector3f localMove = x34_transform.transposeRotate(moveVec);
|
|
|
|
float angle = zeus::CVector3f::getAngleDiff(localMove, zeus::CVector3f::skForward);
|
|
|
|
if (angle < zeus::degToRad(45.f))
|
|
|
|
return pas::EStepDirection::Forward;
|
|
|
|
else if (angle > zeus::degToRad(135.f))
|
|
|
|
return pas::EStepDirection::Backward;
|
|
|
|
else if (localMove.dot(zeus::CVector3f::skRight) > 0.f)
|
|
|
|
return pas::EStepDirection::Right;
|
|
|
|
else
|
|
|
|
return pas::EStepDirection::Left;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPatterned::IsPatternObstructed(CStateManager& mgr,
|
|
|
|
const zeus::CVector3f& p0, const zeus::CVector3f& p1) const
|
|
|
|
{
|
|
|
|
CMaterialFilter filter = CMaterialFilter::MakeInclude(EMaterialTypes::Character);
|
|
|
|
zeus::CVector3f delta = p1 - p0;
|
|
|
|
rstl::reserved_vector<TUniqueId, 1024> nearList;
|
|
|
|
bool ret = false;
|
|
|
|
if (delta.canBeNormalized())
|
|
|
|
{
|
|
|
|
zeus::CVector3f deltaNorm = delta.normalized();
|
|
|
|
float deltaMag = delta.magnitude();
|
|
|
|
mgr.BuildNearList(nearList, p0, deltaNorm, deltaMag, filter, this);
|
|
|
|
TUniqueId bestId = kInvalidUniqueId;
|
|
|
|
CRayCastResult res =
|
|
|
|
mgr.RayWorldIntersection(bestId, p0, deltaNorm, deltaMag,
|
|
|
|
CMaterialFilter::MakeInclude(EMaterialTypes::Solid), nearList);
|
|
|
|
ret = res.IsValid();
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::UpdateDest(CStateManager& mgr)
|
|
|
|
{
|
|
|
|
if (x328_24_inPosition && x2dc_destObj != kInvalidUniqueId)
|
|
|
|
{
|
|
|
|
if (TCastToPtr<CScriptWaypoint> wp = mgr.ObjectById(x2dc_destObj))
|
|
|
|
{
|
|
|
|
UpdateActorKeyframe(mgr);
|
|
|
|
x2dc_destObj = wp->NextWaypoint(mgr);
|
|
|
|
if (x2dc_destObj != kInvalidUniqueId)
|
|
|
|
{
|
|
|
|
x2ec_reflectedDestPos = GetTranslation();
|
|
|
|
x328_24_inPosition = false;
|
|
|
|
if (TCastToConstPtr<CScriptWaypoint> wp2 = mgr.GetObjectById(x2dc_destObj))
|
|
|
|
{
|
|
|
|
x3b0_moveSpeed = wp->GetSpeed();
|
|
|
|
x30c_behaviourOrient = EBehaviourOrient(wp->GetBehaviourOrient());
|
|
|
|
if (wp->GetBehaviourModifiers() & 0x2)
|
|
|
|
{
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(
|
|
|
|
CBCJumpCmd(wp2->GetTranslation(), pas::EJumpType::Normal));
|
|
|
|
}
|
|
|
|
else if (wp->GetBehaviourModifiers() & 0x4)
|
|
|
|
{
|
|
|
|
TUniqueId wp3Id = wp2->NextWaypoint(mgr);
|
|
|
|
if (wp3Id != kInvalidUniqueId)
|
|
|
|
{
|
|
|
|
if (TCastToConstPtr<CScriptWaypoint> wp3 = mgr.GetObjectById(wp3Id))
|
|
|
|
{
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(
|
|
|
|
CBCJumpCmd(wp2->GetTranslation(), wp3->GetTranslation(),
|
|
|
|
pas::EJumpType::Normal));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mgr.SendScriptMsg(wp.GetPtr(), GetUniqueId(), EScriptObjectMessage::Arrived);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x2dc_destObj != kInvalidUniqueId)
|
|
|
|
if (TCastToConstPtr<CActor> act = mgr.GetObjectById(x2dc_destObj))
|
|
|
|
SetDestPos(act->GetTranslation());
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::ApproachDest(CStateManager& mgr)
|
|
|
|
{
|
|
|
|
zeus::CVector3f faceVec = mgr.GetPlayer().GetTranslation() - GetTranslation();
|
|
|
|
zeus::CVector3f moveVec = x2e0_destPos - GetTranslation();
|
|
|
|
if (!x328_25_verticalMovement)
|
|
|
|
moveVec.z = 0.f;
|
|
|
|
zeus::CVector3f pathLine = x2e0_destPos - x2ec_reflectedDestPos;
|
|
|
|
if (pathLine.dot(moveVec) <= 0.f)
|
|
|
|
x328_24_inPosition = true;
|
|
|
|
else if (moveVec.magSquared() < 3.f * 3.f)
|
|
|
|
moveVec = pathLine;
|
|
|
|
if (!x328_24_inPosition)
|
|
|
|
{
|
|
|
|
if (moveVec.canBeNormalized())
|
|
|
|
moveVec.normalize();
|
|
|
|
switch (x30c_behaviourOrient)
|
|
|
|
{
|
|
|
|
case EBehaviourOrient::MoveDir:
|
|
|
|
faceVec = moveVec;
|
|
|
|
break;
|
|
|
|
case EBehaviourOrient::Destination:
|
|
|
|
if (x39c_curPattern && x39c_curPattern < x38c_patterns.size())
|
|
|
|
{
|
|
|
|
faceVec = x38c_patterns[x39c_curPattern].GetForward();
|
|
|
|
}
|
|
|
|
else if (x2dc_destObj != kInvalidUniqueId)
|
|
|
|
{
|
|
|
|
if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(x2dc_destObj))
|
|
|
|
faceVec = wp->GetTransform().basis[1];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
x31c_faceVec = faceVec;
|
|
|
|
x310_moveVec = x3b0_moveSpeed * moveVec;
|
|
|
|
pas::EStepDirection stepDir;
|
|
|
|
if (!KnockbackWhenFrozen())
|
|
|
|
{
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(
|
|
|
|
CBCLocomotionCmd(x310_moveVec, x31c_faceVec, 1.f));
|
|
|
|
}
|
|
|
|
else if (x30c_behaviourOrient == EBehaviourOrient::MoveDir ||
|
|
|
|
!x450_bodyController->HasBodyState(pas::EAnimationState::Step))
|
|
|
|
{
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(
|
|
|
|
CBCLocomotionCmd(x310_moveVec, zeus::CVector3f::skZero, 1.f));
|
|
|
|
}
|
|
|
|
else if ((stepDir = GetStepDirection(x310_moveVec)) != pas::EStepDirection::Forward)
|
|
|
|
{
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(
|
|
|
|
CBCStepCmd(stepDir, pas::EStepType::Normal));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(
|
|
|
|
CBCLocomotionCmd(x310_moveVec, zeus::CVector3f::skZero, 1.f));
|
|
|
|
}
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverTargetVector(x31c_faceVec);
|
|
|
|
}
|
|
|
|
else if (x450_bodyController->GetBodyStateInfo().GetMaxSpeed() > FLT_EPSILON)
|
|
|
|
{
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(
|
|
|
|
(x138_velocity.magnitude() / x450_bodyController->GetBodyStateInfo().GetMaxSpeed()) *
|
|
|
|
x34_transform.basis[1], zeus::CVector3f::skZero, 1.f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::pair<CScriptWaypoint*, CScriptWaypoint*> CPatterned::GetDestWaypoints(CStateManager& mgr) const
|
|
|
|
{
|
|
|
|
std::pair<CScriptWaypoint*, CScriptWaypoint*> ret {};
|
|
|
|
if (TCastToPtr<CScriptWaypoint> wp = mgr.ObjectById(x2dc_destObj))
|
|
|
|
{
|
|
|
|
ret.first = wp.GetPtr();
|
|
|
|
ret.second = TCastToPtr<CScriptWaypoint>(mgr.ObjectById(wp->FollowWaypoint(mgr))).GetPtr();
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
zeus::CQuaternion CPatterned::FindPatternRotation(const zeus::CVector3f& dir) const
|
|
|
|
{
|
|
|
|
zeus::CVector3f wpDeltaFlat = x368_destWPDelta;
|
|
|
|
wpDeltaFlat.z = 0.f;
|
|
|
|
wpDeltaFlat.normalize();
|
|
|
|
zeus::CVector3f dirFlat = dir;
|
|
|
|
dirFlat.z = 0.f;
|
|
|
|
dirFlat.normalize();
|
|
|
|
|
|
|
|
zeus::CQuaternion q;
|
|
|
|
if ((wpDeltaFlat - dirFlat).magSquared() > 3.99f)
|
|
|
|
q.rotateZ(zeus::degToRad(180.f));
|
|
|
|
else
|
|
|
|
q = zeus::CQuaternion::shortestRotationArc(wpDeltaFlat, dirFlat);
|
|
|
|
|
|
|
|
if (x328_25_verticalMovement)
|
|
|
|
{
|
|
|
|
q = zeus::CQuaternion::shortestRotationArc(
|
|
|
|
(q * zeus::CQuaternion(0.f, x368_destWPDelta) * q.inverse()).getImaginary().normalized(),
|
|
|
|
dir.normalized()) * q;
|
|
|
|
}
|
|
|
|
|
|
|
|
return q;
|
|
|
|
}
|
|
|
|
|
|
|
|
zeus::CVector3f CPatterned::FindPatternDir(CStateManager& mgr) const
|
|
|
|
{
|
|
|
|
zeus::CVector3f ret;
|
|
|
|
switch (x378_patternOrient)
|
|
|
|
{
|
|
|
|
case EPatternOrient::StartToPlayerStart:
|
|
|
|
ret = x35c_patternStartPlayerPos - x350_patternStartPos;
|
|
|
|
break;
|
|
|
|
case EPatternOrient::StartToPlayer:
|
|
|
|
ret = mgr.GetPlayer().GetTranslation() - x350_patternStartPos;
|
|
|
|
break;
|
|
|
|
case EPatternOrient::ReversePlayerForward:
|
|
|
|
ret = -mgr.GetPlayer().GetTransform().basis[1];
|
|
|
|
break;
|
|
|
|
case EPatternOrient::Forward:
|
|
|
|
ret = GetTransform().basis[1];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::UpdatePatternDestPos(CStateManager& mgr)
|
|
|
|
{
|
|
|
|
if (x39c_curPattern < x38c_patterns.size())
|
|
|
|
{
|
|
|
|
if (x368_destWPDelta != zeus::CVector3f::skZero)
|
|
|
|
{
|
|
|
|
zeus::CVector3f patternDir = FindPatternDir(mgr);
|
|
|
|
SetDestPos(FindPatternRotation(patternDir).transform(x38c_patterns[x39c_curPattern].GetPos()));
|
|
|
|
if (x37c_patternFit == EPatternFit::Zero)
|
|
|
|
{
|
|
|
|
float magSq;
|
|
|
|
if (x328_25_verticalMovement)
|
|
|
|
magSq = patternDir.magSquared() / x368_destWPDelta.magSquared();
|
|
|
|
else
|
|
|
|
magSq = patternDir.toVec2f().magSquared() / x368_destWPDelta.toVec2f().magSquared();
|
|
|
|
SetDestPos(std::sqrt(magSq) * x2e0_destPos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetDestPos(x38c_patterns[x39c_curPattern].GetPos());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (x374_patternTranslate)
|
|
|
|
{
|
|
|
|
case EPatternTranslate::RelativeStart:
|
|
|
|
SetDestPos(x2e0_destPos + x350_patternStartPos);
|
|
|
|
break;
|
|
|
|
case EPatternTranslate::RelativePlayerStart:
|
|
|
|
SetDestPos(x2e0_destPos + x35c_patternStartPlayerPos);
|
|
|
|
break;
|
|
|
|
case EPatternTranslate::RelativePlayer:
|
|
|
|
SetDestPos(x2e0_destPos + mgr.GetPlayer().GetTranslation());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::SetupPattern(CStateManager& mgr)
|
|
|
|
{
|
|
|
|
EScriptObjectState state = GetDesiredAttackState(mgr);
|
|
|
|
x2dc_destObj = GetWaypointForState(mgr, state, EScriptObjectMessage::Follow);
|
|
|
|
if (x2dc_destObj == kInvalidUniqueId && state != EScriptObjectState::Attack)
|
|
|
|
x2dc_destObj = GetWaypointForState(mgr, EScriptObjectState::Attack, EScriptObjectMessage::Follow);
|
|
|
|
x38c_patterns.clear();
|
|
|
|
if (x2dc_destObj != kInvalidUniqueId)
|
|
|
|
{
|
|
|
|
x350_patternStartPos = GetTranslation();
|
|
|
|
x35c_patternStartPlayerPos = mgr.GetPlayer().GetTranslation();
|
|
|
|
auto destWPs = GetDestWaypoints(mgr);
|
|
|
|
if (destWPs.first)
|
|
|
|
{
|
|
|
|
x374_patternTranslate = EPatternTranslate(destWPs.first->GetPatternTranslate());
|
|
|
|
x378_patternOrient = EPatternOrient(destWPs.first->GetPatternOrient());
|
|
|
|
x37c_patternFit = EPatternFit(destWPs.first->GetPatternFit());
|
|
|
|
if (destWPs.second)
|
|
|
|
x368_destWPDelta = destWPs.second->GetTranslation() - destWPs.first->GetTranslation();
|
|
|
|
else
|
|
|
|
x368_destWPDelta = zeus::CVector3f::skZero;
|
|
|
|
|
|
|
|
int numPatterns = 0;
|
|
|
|
CScriptWaypoint* curWp = destWPs.first;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
++numPatterns;
|
|
|
|
curWp = TCastToPtr<CScriptWaypoint>(mgr.ObjectById(curWp->NextWaypoint(mgr))).GetPtr();
|
|
|
|
if (!curWp)
|
|
|
|
break;
|
|
|
|
} while (curWp->GetUniqueId() != destWPs.first->GetUniqueId());
|
|
|
|
x38c_patterns.reserve(numPatterns);
|
|
|
|
|
|
|
|
zeus::CVector3f basePos;
|
|
|
|
switch (x374_patternTranslate)
|
|
|
|
{
|
|
|
|
case EPatternTranslate::RelativePlayerStart:
|
|
|
|
if (destWPs.second)
|
|
|
|
basePos = destWPs.second->GetTranslation();
|
|
|
|
break;
|
|
|
|
case EPatternTranslate::Absolute:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
basePos = destWPs.first->GetTranslation();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
curWp = destWPs.first;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
zeus::CVector3f wpForward = curWp->GetTransform().basis[1];
|
|
|
|
if (x368_destWPDelta != zeus::CVector3f::skZero)
|
|
|
|
wpForward = FindPatternRotation(FindPatternDir(mgr)).transform(wpForward);
|
|
|
|
x38c_patterns.emplace_back(curWp->GetTranslation() - basePos, wpForward,
|
|
|
|
curWp->GetSpeed(), curWp->GetBehaviour(),
|
|
|
|
curWp->GetBehaviourOrient(), curWp->GetBehaviourModifiers(),
|
|
|
|
curWp->GetAnimation());
|
|
|
|
curWp = TCastToPtr<CScriptWaypoint>(mgr.ObjectById(curWp->NextWaypoint(mgr))).GetPtr();
|
|
|
|
if (!curWp)
|
|
|
|
break;
|
|
|
|
} while (curWp->GetUniqueId() != destWPs.first->GetUniqueId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
x400_30_patternShagged = false;
|
|
|
|
x39c_curPattern = 0;
|
|
|
|
x328_24_inPosition = false;
|
|
|
|
x2ec_reflectedDestPos = GetTranslation();
|
|
|
|
if (!x38c_patterns.empty())
|
|
|
|
{
|
|
|
|
x3b0_moveSpeed = x38c_patterns.front().GetSpeed();
|
|
|
|
x380_behaviour = EBehaviour(x38c_patterns.front().GetBehaviour());
|
|
|
|
x30c_behaviourOrient = EBehaviourOrient(x38c_patterns.front().GetBehaviourOrient());
|
|
|
|
x384_behaviourModifiers = EBehaviourModifiers(x38c_patterns.front().GetBehaviourModifiers());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EScriptObjectState CPatterned::GetDesiredAttackState(CStateManager& mgr) const
|
|
|
|
{
|
|
|
|
float deltaMagSq = (GetTranslation() - mgr.GetPlayer().GetTranslation()).magSquared();
|
|
|
|
if (deltaMagSq < x2fc_minAttackRange * x2fc_minAttackRange)
|
|
|
|
return EScriptObjectState::Retreat;
|
|
|
|
else if (deltaMagSq > x300_maxAttackRange * x300_maxAttackRange)
|
|
|
|
return EScriptObjectState::CloseIn;
|
|
|
|
else
|
|
|
|
return EScriptObjectState::Attack;
|
|
|
|
}
|
|
|
|
|
2018-09-14 00:49:34 +00:00
|
|
|
void CPatterned::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum)
|
|
|
|
{
|
2018-11-06 06:16:12 +00:00
|
|
|
if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::Thermal)
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
|
|
|
SetCalculateLighting(false);
|
|
|
|
x90_actorLights->BuildConstantAmbientLighting(zeus::CColor::skWhite);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetCalculateLighting(true);
|
|
|
|
|
2018-11-08 00:53:38 +00:00
|
|
|
zeus::CColor col = x42c_color;
|
2018-09-14 00:49:34 +00:00
|
|
|
u8 alpha = GetModelAlphau8(mgr);
|
2018-11-11 03:27:54 +00:00
|
|
|
if (x402_27_noXrayModel && mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay)
|
2018-11-08 00:53:38 +00:00
|
|
|
alpha = 76;
|
2018-09-14 00:49:34 +00:00
|
|
|
|
2018-11-08 00:53:38 +00:00
|
|
|
if (alpha < 255)
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
|
|
|
if (col.r == 0.f && col.g == 0.f && col.b == 0.f)
|
2018-11-11 03:27:54 +00:00
|
|
|
col = zeus::CColor::skWhite; /* Not being damaged */
|
2018-09-14 00:49:34 +00:00
|
|
|
|
2018-11-08 00:53:38 +00:00
|
|
|
if (x401_29_laggedBurnDeath)
|
|
|
|
{
|
|
|
|
int stripedAlpha = 255;
|
|
|
|
if (alpha > 127)
|
|
|
|
stripedAlpha = (alpha - 128) * 2;
|
|
|
|
xb4_drawFlags = CModelFlags(3, 0, 3, zeus::CColor(0.f, (stripedAlpha * stripedAlpha) / 65025.f));
|
|
|
|
}
|
|
|
|
else if (x401_28_burning)
|
|
|
|
{
|
|
|
|
xb4_drawFlags = CModelFlags(5, 0, 3, zeus::CColor(0.f, 1.f));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
zeus::CColor col2 = col;
|
|
|
|
col2.a = alpha / 255.f;
|
|
|
|
xb4_drawFlags = CModelFlags(5, 0, 3, col2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
2018-11-08 00:53:38 +00:00
|
|
|
if (col.r != 0.f || col.g != 0.f || col.b != 0.f)
|
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
/* Being damaged */
|
2018-11-08 00:53:38 +00:00
|
|
|
zeus::CColor col2 = col;
|
|
|
|
col2.a = alpha / 255.f;
|
|
|
|
xb4_drawFlags = CModelFlags(2, 0, 3, col2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xb4_drawFlags = CModelFlags(0, 0, 3, zeus::CColor::skWhite);
|
|
|
|
}
|
2018-09-14 00:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CActor::PreRender(mgr, frustum);
|
2018-11-08 00:53:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::RenderIceModelWithFlags(const CModelFlags& flags) const
|
|
|
|
{
|
|
|
|
CModelFlags useFlags = flags;
|
|
|
|
useFlags.x1_matSetIdx = 0;
|
|
|
|
CAnimData* animData = x64_modelData->AnimationData();
|
|
|
|
if (CMorphableSkinnedModel* iceModel = animData->IceModel().GetObj())
|
|
|
|
animData->Render(*iceModel, useFlags, {*x510_vertexMorph}, iceModel->GetMorphMagnitudes());
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::Render(const CStateManager& mgr) const
|
|
|
|
{
|
|
|
|
int mask = 0;
|
|
|
|
int target = 0;
|
2018-11-11 03:27:54 +00:00
|
|
|
if (x402_29_drawParticles)
|
2018-11-08 00:53:38 +00:00
|
|
|
{
|
|
|
|
mgr.GetCharacterRenderMaskAndTarget(x402_31_thawed, mask, target);
|
|
|
|
x64_modelData->GetAnimationData()->GetParticleDB().RenderSystemsToBeDrawnFirstMasked(mask, target);
|
|
|
|
}
|
|
|
|
if ((mgr.GetThermalDrawFlag() == EThermalDrawFlag::Cold && !x402_31_thawed) ||
|
|
|
|
(mgr.GetThermalDrawFlag() == EThermalDrawFlag::Hot && x402_31_thawed) ||
|
|
|
|
mgr.GetThermalDrawFlag() == EThermalDrawFlag::Bypass)
|
|
|
|
{
|
|
|
|
if (x401_28_burning)
|
|
|
|
{
|
|
|
|
const CTexture* ashy = mgr.GetActorModelParticles()->GetAshyTexture(*this);
|
|
|
|
u8 alpha = GetModelAlphau8(mgr);
|
|
|
|
if (ashy && ((!x401_29_laggedBurnDeath && alpha <= 255) || alpha <= 127))
|
|
|
|
{
|
|
|
|
if (xe5_31_pointGeneratorParticles)
|
|
|
|
mgr.SetupParticleHook(*this);
|
|
|
|
zeus::CColor addColor;
|
|
|
|
if (x401_29_laggedBurnDeath)
|
|
|
|
{
|
|
|
|
addColor = zeus::CColor::skClear;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
addColor = mgr.GetThermalDrawFlag() == EThermalDrawFlag::Hot ?
|
|
|
|
zeus::CColor::skWhite : zeus::CColor::skBlack;
|
|
|
|
}
|
|
|
|
x64_modelData->DisintegrateDraw(mgr, GetTransform(), *ashy, addColor,
|
|
|
|
alpha * (x401_29_laggedBurnDeath ? 0.00787402f : 0.00392157f));
|
|
|
|
if (xe5_31_pointGeneratorParticles)
|
|
|
|
{
|
|
|
|
CSkinnedModel::ClearPointGeneratorFunc();
|
|
|
|
mgr.GetActorModelParticles()->Render(*this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CPhysicsActor::Render(mgr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CPhysicsActor::Render(mgr);
|
|
|
|
}
|
2018-09-14 00:49:34 +00:00
|
|
|
|
2018-11-08 00:53:38 +00:00
|
|
|
if (x450_bodyController->IsFrozen() && !x401_28_burning)
|
|
|
|
{
|
|
|
|
RenderIceModelWithFlags(CModelFlags(0, 0, 3, zeus::CColor::skWhite));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
if (x402_29_drawParticles)
|
2018-11-08 00:53:38 +00:00
|
|
|
{
|
|
|
|
x64_modelData->GetAnimationData()->GetParticleDB().RenderSystemsToBeDrawnLastMasked(mask, target);
|
|
|
|
}
|
2018-09-14 00:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CPatterned::ThinkAboutMove(float dt)
|
|
|
|
{
|
|
|
|
bool doMove = true;
|
2018-11-11 03:27:54 +00:00
|
|
|
if (!x328_25_verticalMovement && !x328_27_onGround)
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
x310_moveVec.zeroOut();
|
2018-09-14 00:49:34 +00:00
|
|
|
doMove = false;
|
|
|
|
}
|
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
if (doMove && x39c_curPattern < x38c_patterns.size())
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
|
|
|
zeus::CVector3f frontVec = GetTransform().frontVector();
|
2018-11-11 03:27:54 +00:00
|
|
|
zeus::CVector3f x31cCpy = x31c_faceVec;
|
|
|
|
if (x31c_faceVec.magSquared() > 0.1f)
|
2018-09-14 00:49:34 +00:00
|
|
|
x31cCpy.normalize();
|
|
|
|
float mag = frontVec.dot(x31cCpy);
|
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
switch (x3f8_moveState)
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
case EMoveState::Zero:
|
|
|
|
if (!x328_26_longJump)
|
2018-09-14 00:49:34 +00:00
|
|
|
break;
|
2018-11-11 03:27:54 +00:00
|
|
|
case EMoveState::One:
|
2018-09-14 00:49:34 +00:00
|
|
|
doMove = false;
|
2018-11-11 03:27:54 +00:00
|
|
|
if (mag > 0.85f)
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
|
|
|
doMove = true;
|
2018-11-11 03:27:54 +00:00
|
|
|
x3f8_moveState = EMoveState::Two;
|
2018-09-14 00:49:34 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-11-11 03:27:54 +00:00
|
|
|
x3f8_moveState = EMoveState::One;
|
|
|
|
break;
|
|
|
|
case EMoveState::Two:
|
|
|
|
x3f8_moveState = EMoveState::Three;
|
|
|
|
case EMoveState::Three:
|
2018-09-14 00:49:34 +00:00
|
|
|
doMove = true;
|
2018-11-11 03:27:54 +00:00
|
|
|
if (!x328_26_longJump)
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
2018-11-11 03:27:54 +00:00
|
|
|
x3f8_moveState = EMoveState::Zero;
|
2018-09-14 00:49:34 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-11-11 03:27:54 +00:00
|
|
|
if (mag > 0.9f)
|
|
|
|
x3f8_moveState = EMoveState::Four;
|
2018-09-14 00:49:34 +00:00
|
|
|
break;
|
2018-11-11 03:27:54 +00:00
|
|
|
case EMoveState::Four:
|
|
|
|
x328_24_inPosition = true;
|
2018-09-14 00:49:34 +00:00
|
|
|
doMove = false;
|
2018-11-11 03:27:54 +00:00
|
|
|
x3f8_moveState = EMoveState::Zero;
|
|
|
|
break;
|
2018-09-14 00:49:34 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-11 03:27:54 +00:00
|
|
|
if (!x401_26_disableMove && doMove)
|
2018-09-14 00:49:34 +00:00
|
|
|
{
|
|
|
|
const CBodyState* state = x450_bodyController->GetBodyStateInfo().GetCurrentState();
|
2018-09-16 23:22:35 +00:00
|
|
|
if (state->ApplyAnimationDeltas() && !zeus::close_enough(x2e0_destPos - GetTranslation(), {}))
|
2018-11-11 03:27:54 +00:00
|
|
|
MoveToOR((x64_modelData->GetScale() * x434_posDelta) * x55c_moveScale, dt);
|
2018-09-14 00:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RotateToOR(x440_rotDelta, dt);
|
|
|
|
}
|
2016-04-25 05:03:38 +00:00
|
|
|
}
|