2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/MP1/World/CElitePirate.hpp"
|
|
|
|
|
2020-03-26 07:30:54 +00:00
|
|
|
#include "Runtime/Collision/CCollisionActor.hpp"
|
2020-03-09 02:52:21 +00:00
|
|
|
#include "Runtime/Collision/CCollisionActorManager.hpp"
|
|
|
|
#include "Runtime/CSimplePool.hpp"
|
2020-03-11 12:25:45 +00:00
|
|
|
#include "Runtime/CStateManager.hpp"
|
2020-03-09 02:52:21 +00:00
|
|
|
#include "Runtime/GameGlobalObjects.hpp"
|
2020-03-26 19:24:56 +00:00
|
|
|
#include "Runtime/MP1/World/CGrenadeLauncher.hpp"
|
|
|
|
#include "Runtime/Weapon/CGameProjectile.hpp"
|
|
|
|
#include "Runtime/World/CExplosion.hpp"
|
2020-03-09 02:52:21 +00:00
|
|
|
#include "Runtime/World/CPatternedInfo.hpp"
|
2020-03-26 07:30:54 +00:00
|
|
|
#include "Runtime/World/CPlayer.hpp"
|
2020-03-26 19:24:56 +00:00
|
|
|
#include "Runtime/World/CWorld.hpp"
|
2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/World/ScriptLoader.hpp"
|
2018-10-11 22:57:05 +00:00
|
|
|
|
2020-03-09 02:52:21 +00:00
|
|
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde::MP1 {
|
2020-03-26 07:30:54 +00:00
|
|
|
namespace {
|
2020-03-30 23:31:14 +00:00
|
|
|
constexpr std::array<SJointInfo, 3> skLeftArmJointList{{
|
2020-03-26 07:30:54 +00:00
|
|
|
{"L_shoulder", "L_elbow", 1.f, 1.5f},
|
|
|
|
{"L_wrist", "L_elbow", 0.9f, 1.3f},
|
|
|
|
{"L_knee", "L_ankle", 0.9f, 1.3f},
|
|
|
|
}};
|
|
|
|
|
2020-03-30 23:31:14 +00:00
|
|
|
constexpr std::array<SJointInfo, 3> skRightArmJointList{{
|
2020-03-26 07:30:54 +00:00
|
|
|
{"R_shoulder", "R_elbow", 1.f, 1.5f},
|
|
|
|
{"R_wrist", "R_elbow", 0.9f, 1.3f},
|
|
|
|
{"R_knee", "R_ankle", 0.9f, 1.3f},
|
|
|
|
}};
|
|
|
|
|
2020-03-30 23:31:14 +00:00
|
|
|
constexpr std::array<SSphereJointInfo, 7> skSphereJointList{{
|
2020-03-26 07:30:54 +00:00
|
|
|
{"Head_1", 1.2f},
|
|
|
|
{"L_Palm_LCTR", 1.5f},
|
|
|
|
{"R_Palm_LCTR", 1.5f},
|
|
|
|
{"Spine_1", 1.5f},
|
|
|
|
{"Collar", 1.2f},
|
|
|
|
{"L_Ball", 0.8f},
|
|
|
|
{"R_Ball", 0.8f},
|
|
|
|
}};
|
|
|
|
} // namespace
|
|
|
|
|
2018-10-11 22:57:05 +00:00
|
|
|
CElitePirateData::CElitePirateData(CInputStream& in, u32 propCount)
|
2020-03-29 07:28:14 +00:00
|
|
|
: x0_tauntInterval(in.readFloatBig())
|
|
|
|
, x4_tauntVariance(in.readFloatBig())
|
2018-12-08 05:30:43 +00:00
|
|
|
, x8_(in.readFloatBig())
|
|
|
|
, xc_(in.readFloatBig())
|
2020-03-31 00:40:38 +00:00
|
|
|
, x10_attackChance(in.readFloatBig())
|
|
|
|
, x14_shotAtTime(in.readFloatBig())
|
|
|
|
, x18_shotAtTimeVariance(in.readFloatBig())
|
2020-05-07 23:13:43 +00:00
|
|
|
, x1c_projectileAttractionRadius(in.readFloatBig())
|
|
|
|
, x20_energyAbsorbParticleDescId(in)
|
|
|
|
, x24_energyAbsorbSfxId(CSfxManager::TranslateSFXID(in.readUint32Big()))
|
2020-03-26 19:24:56 +00:00
|
|
|
, x28_launcherActParams(ScriptLoader::LoadActorParameters(in))
|
|
|
|
, x90_launcherAnimParams(ScriptLoader::LoadAnimationParameters(in))
|
2020-05-07 23:13:43 +00:00
|
|
|
, x9c_launcherParticleGenDescId(in)
|
|
|
|
, xa0_launcherSfxId(CSfxManager::TranslateSFXID(in.readUint32Big()))
|
|
|
|
, xa4_grenadeModelId(in)
|
|
|
|
, xa8_grenadeDamageInfo(in)
|
2020-03-29 07:28:14 +00:00
|
|
|
, xc4_launcherHp(in.readFloatBig())
|
2020-05-07 23:13:43 +00:00
|
|
|
, xc8_grenadeElementGenDescId1(in)
|
|
|
|
, xcc_grenadeElementGenDescId2(in)
|
|
|
|
, xd0_grenadeElementGenDescId3(in)
|
|
|
|
, xd4_grenadeElementGenDescId4(in)
|
|
|
|
, xd8_grenadeVelocityInfo(in)
|
|
|
|
, xe0_grenadeTrajectoryInfo(in)
|
2020-03-30 07:05:16 +00:00
|
|
|
, xf0_grenadeNumBounces(in.readUint32Big())
|
2020-05-07 23:13:43 +00:00
|
|
|
, xf4_grenadeBounceSfxId(CSfxManager::TranslateSFXID(in.readUint32Big()))
|
|
|
|
, xf6_grenadeExplodeSfxId(CSfxManager::TranslateSFXID(in.readUint32Big()))
|
|
|
|
, xf8_shockwaveParticleDescId(in)
|
|
|
|
, xfc_shockwaveDamageInfo(in)
|
|
|
|
, x118_shockwaveWeaponDescId(in)
|
|
|
|
, x11c_shockwaveElectrocuteSfxId(CSfxManager::TranslateSFXID(in.readUint32Big()))
|
|
|
|
, x11e_canCallForBackup(in.readBool())
|
|
|
|
, x11f_fastWhenAttractingEnergy(propCount < 42 ? true : in.readBool()) {}
|
2018-10-11 22:57:05 +00:00
|
|
|
|
|
|
|
CElitePirate::CElitePirate(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
|
|
|
|
CModelData&& mData, const CPatternedInfo& pInfo, const CActorParameters& actParms,
|
2020-03-30 23:31:14 +00:00
|
|
|
CElitePirateData data)
|
2018-12-08 05:30:43 +00:00
|
|
|
: CPatterned(ECharacter::ElitePirate, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo,
|
2020-03-09 02:52:21 +00:00
|
|
|
EMovementType::Ground, EColliderType::One, EBodyType::BiPedal, actParms, EKnockBackVariant::Large)
|
2020-03-26 07:30:54 +00:00
|
|
|
, x56c_vulnerability(pInfo.GetDamageVulnerability())
|
2020-03-30 23:31:14 +00:00
|
|
|
, x5d8_data(std::move(data))
|
2020-03-26 07:30:54 +00:00
|
|
|
, x6f8_boneTracking(*GetModelData()->GetAnimationData(), "Head_1", zeus::degToRad(80.f), zeus::degToRad(180.f),
|
|
|
|
EBoneTrackingFlags::None)
|
2020-04-01 18:54:01 +00:00
|
|
|
, x738_collisionAabb(GetBoundingBox(), GetMaterialList())
|
2020-03-31 00:40:38 +00:00
|
|
|
, x7a0_initialSpeed(x3b4_speed)
|
2020-04-21 07:22:41 +00:00
|
|
|
, x7d0_pathFindSearch(nullptr, 1, pInfo.GetPathfindingIndex(), 1.f, 1.f) {
|
2020-05-07 23:13:43 +00:00
|
|
|
if (x5d8_data.GetEnergyAbsorbParticleDescId().IsValid()) {
|
|
|
|
x760_energyAbsorbDesc = g_SimplePool->GetObj({SBIG('PART'), x5d8_data.GetEnergyAbsorbParticleDescId()});
|
2020-03-09 02:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
x460_knockBackController.SetEnableFreeze(false);
|
|
|
|
x460_knockBackController.SetAutoResetImpulse(false);
|
|
|
|
x460_knockBackController.SetEnableBurn(false);
|
|
|
|
x460_knockBackController.SetEnableExplodeDeath(false);
|
|
|
|
x460_knockBackController.SetEnableLaggedBurnDeath(false);
|
2020-04-01 18:54:01 +00:00
|
|
|
SetupPathFindSearch();
|
2020-03-09 02:52:21 +00:00
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-09 02:52:21 +00:00
|
|
|
void CElitePirate::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-29 07:28:14 +00:00
|
|
|
void CElitePirate::Think(float dt, CStateManager& mgr) {
|
|
|
|
if (GetActive()) {
|
|
|
|
CPatterned::Think(dt, mgr);
|
|
|
|
x6f8_boneTracking.Update(dt);
|
2020-04-01 18:54:01 +00:00
|
|
|
if (HasWeakPointHead()) {
|
|
|
|
x730_collisionActorMgrHead->Update(dt, mgr, CCollisionActorManager::EUpdateOptions::ObjectSpace);
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
x5d4_collisionActorMgr->Update(dt, mgr, CCollisionActorManager::EUpdateOptions::ObjectSpace);
|
2020-05-07 23:13:43 +00:00
|
|
|
if (IsAttractingEnergy() && x5d8_data.IsFastWhenAttractingEnergy()) {
|
2020-03-31 00:40:38 +00:00
|
|
|
x3b4_speed = 2.f * x7a0_initialSpeed;
|
2020-03-29 07:28:14 +00:00
|
|
|
} else {
|
2020-03-31 00:40:38 +00:00
|
|
|
x3b4_speed = x7a0_initialSpeed;
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
2020-03-31 03:10:51 +00:00
|
|
|
UpdateTimers(dt);
|
2020-04-01 18:54:01 +00:00
|
|
|
UpdatePositionHistory();
|
2020-03-31 03:10:51 +00:00
|
|
|
UpdateActorTransform(mgr, x772_launcherId, "grenadeLauncher_LCTR"sv);
|
2020-04-01 18:54:01 +00:00
|
|
|
UpdateHealthInfo(mgr);
|
2020-03-31 03:10:51 +00:00
|
|
|
x328_31_energyAttractor = IsAttractingEnergy();
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-09 02:52:21 +00:00
|
|
|
void CElitePirate::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
|
2020-03-26 19:24:56 +00:00
|
|
|
bool shouldPass = true;
|
|
|
|
|
2020-03-11 12:25:45 +00:00
|
|
|
switch (msg) {
|
|
|
|
case EScriptObjectMessage::Activate: {
|
2020-04-01 18:54:01 +00:00
|
|
|
if (HasWeakPointHead()) {
|
|
|
|
x730_collisionActorMgrHead->SetActive(mgr, true);
|
2020-03-26 07:30:54 +00:00
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
if (CEntity* ent = mgr.ObjectById(x772_launcherId)) {
|
2020-03-11 12:25:45 +00:00
|
|
|
ent->SetActive(true);
|
2020-03-26 07:30:54 +00:00
|
|
|
}
|
2020-03-11 12:25:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::Deactivate: {
|
2020-04-01 18:54:01 +00:00
|
|
|
if (HasWeakPointHead()) {
|
|
|
|
x730_collisionActorMgrHead->SetActive(mgr, false);
|
2020-03-26 07:30:54 +00:00
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
x5d4_collisionActorMgr->SetActive(mgr, false);
|
2020-03-26 19:24:56 +00:00
|
|
|
if (CEntity* ent = mgr.ObjectById(x772_launcherId)) {
|
2020-03-11 12:25:45 +00:00
|
|
|
ent->SetActive(false);
|
2020-03-26 07:30:54 +00:00
|
|
|
}
|
2020-03-11 12:25:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::Alert:
|
2020-03-26 07:30:54 +00:00
|
|
|
x988_28_alert = true;
|
2020-03-11 12:25:45 +00:00
|
|
|
break;
|
2020-03-26 07:30:54 +00:00
|
|
|
case EScriptObjectMessage::Touched: {
|
2020-03-30 23:31:14 +00:00
|
|
|
if (HealthInfo(mgr)->GetHP() <= 0.f) {
|
2020-03-26 07:30:54 +00:00
|
|
|
break;
|
2020-03-30 23:31:14 +00:00
|
|
|
}
|
2020-04-02 04:29:40 +00:00
|
|
|
const TCastToConstPtr<CCollisionActor> actor = mgr.ObjectById(uid);
|
2020-03-26 07:30:54 +00:00
|
|
|
if (!actor) {
|
2020-03-26 19:24:56 +00:00
|
|
|
if (uid == x772_launcherId && x772_launcherId != kInvalidUniqueId) {
|
2020-03-31 00:40:38 +00:00
|
|
|
SetShotAt(true, mgr);
|
2020-03-26 07:30:54 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2020-04-02 04:29:40 +00:00
|
|
|
const TUniqueId touchedUid = actor->GetLastTouchedObject();
|
2020-04-01 07:39:05 +00:00
|
|
|
if (touchedUid != mgr.GetPlayer().GetUniqueId()) {
|
2020-04-02 04:29:40 +00:00
|
|
|
if (TCastToConstPtr<CGameProjectile>(mgr.ObjectById(touchedUid))) {
|
2020-03-31 00:40:38 +00:00
|
|
|
SetShotAt(true, mgr);
|
2020-03-26 07:30:54 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2020-04-01 07:39:05 +00:00
|
|
|
if (!x988_24_damageOn) {
|
2020-03-26 07:30:54 +00:00
|
|
|
if (x420_curDamageRemTime <= 0.f) {
|
|
|
|
CDamageInfo info = GetContactDamage();
|
|
|
|
info.SetDamage(0.5f * info.GetDamage());
|
|
|
|
mgr.ApplyDamage(GetUniqueId(), mgr.GetPlayer().GetUniqueId(), GetUniqueId(), info,
|
|
|
|
CMaterialFilter::MakeInclude({EMaterialTypes::Solid}), zeus::skZero3f);
|
|
|
|
x420_curDamageRemTime = x424_damageWaitTime;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
if ((!x988_25_attackingRightClaw || !IsArmClawCollider(uid, x774_collisionRJointIds)) &&
|
|
|
|
(!x988_26_attackingLeftClaw || !IsArmClawCollider(uid, x788_collisionLJointIds))) {
|
2020-03-26 07:30:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
mgr.ApplyDamage(GetUniqueId(), mgr.GetPlayer().GetUniqueId(), GetUniqueId(), GetContactDamage(),
|
|
|
|
CMaterialFilter::MakeInclude({EMaterialTypes::Solid}), zeus::skZero3f);
|
|
|
|
x420_curDamageRemTime = x424_damageWaitTime;
|
2020-04-01 07:39:05 +00:00
|
|
|
x988_24_damageOn = false;
|
2020-03-11 12:25:45 +00:00
|
|
|
break;
|
2020-03-26 07:30:54 +00:00
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
case EScriptObjectMessage::Registered: {
|
2020-03-11 12:25:45 +00:00
|
|
|
x450_bodyController->Activate(mgr);
|
2020-03-27 01:42:18 +00:00
|
|
|
SetupCollisionManager(mgr);
|
2020-03-26 19:24:56 +00:00
|
|
|
x772_launcherId = mgr.AllocateUniqueId();
|
|
|
|
CreateGrenadeLauncher(mgr, x772_launcherId);
|
|
|
|
const auto& bodyStateInfo = x450_bodyController->GetBodyStateInfo();
|
|
|
|
if (bodyStateInfo.GetMaxSpeed() > 0.f) {
|
2020-04-01 18:54:01 +00:00
|
|
|
x7a4_steeringSpeed = (0.99f * bodyStateInfo.GetLocomotionSpeed(pas::ELocomotionAnim::Walk)) / bodyStateInfo.GetMaxSpeed();
|
2020-03-26 19:24:56 +00:00
|
|
|
}
|
|
|
|
x450_bodyController->GetCommandMgr().SetSteeringBlendMode(ESteeringBlendMode::FullSpeed);
|
2020-04-01 18:54:01 +00:00
|
|
|
x450_bodyController->GetCommandMgr().SetSteeringSpeedRange(x7a4_steeringSpeed, x7a4_steeringSpeed);
|
2020-03-26 19:24:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::Deleted:
|
2020-04-01 18:54:01 +00:00
|
|
|
if (HasWeakPointHead()) {
|
|
|
|
x730_collisionActorMgrHead->Destroy(mgr);
|
2020-03-26 19:24:56 +00:00
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
x5d4_collisionActorMgr->Destroy(mgr);
|
2020-03-26 19:24:56 +00:00
|
|
|
mgr.FreeScriptObject(x772_launcherId);
|
|
|
|
break;
|
|
|
|
case EScriptObjectMessage::InitializedInArea:
|
|
|
|
x7d0_pathFindSearch.SetArea(mgr.GetWorld()->GetAreaAlways(GetAreaIdAlways())->GetPostConstructed()->x10bc_pathArea);
|
|
|
|
break;
|
|
|
|
case EScriptObjectMessage::Damage:
|
|
|
|
shouldPass = false;
|
2020-04-02 04:29:40 +00:00
|
|
|
if (const TCastToConstPtr<CCollisionActor> actor = mgr.ObjectById(uid)) {
|
|
|
|
if (const TCastToConstPtr<CGameProjectile> projectile = mgr.ObjectById(actor->GetLastTouchedObject())) {
|
2020-03-26 19:24:56 +00:00
|
|
|
if (uid == x770_collisionHeadId) {
|
|
|
|
x428_damageCooldownTimer = 0.33f;
|
|
|
|
const auto& damageInfo = projectile->GetDamageInfo();
|
|
|
|
KnockBack(projectile->GetTranslation() - projectile->GetPreviousPos(), mgr, damageInfo,
|
|
|
|
EKnockBackType::Radius, false, damageInfo.GetKnockBackPower());
|
|
|
|
CPatterned::AcceptScriptMsg(msg, uid, mgr);
|
2020-05-07 23:13:43 +00:00
|
|
|
} else if (uid == x79c_energyAttractorId && x760_energyAbsorbDesc->IsLoaded()) {
|
2020-03-29 07:28:14 +00:00
|
|
|
CreateEnergyAbsorb(mgr, projectile->GetTransform());
|
2020-03-26 19:24:56 +00:00
|
|
|
}
|
2020-03-31 00:40:38 +00:00
|
|
|
SetShotAt(true, mgr);
|
2020-03-26 19:24:56 +00:00
|
|
|
}
|
|
|
|
} else if (uid == x772_launcherId && x772_launcherId != kInvalidUniqueId) {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(
|
|
|
|
CBCKnockBackCmd(GetTransform().frontVector(), pas::ESeverity::Eight));
|
|
|
|
} else {
|
2020-03-29 07:28:14 +00:00
|
|
|
ApplyDamageToHead(mgr, uid);
|
2020-03-26 19:24:56 +00:00
|
|
|
}
|
2020-03-26 07:30:54 +00:00
|
|
|
break;
|
2020-03-26 19:24:56 +00:00
|
|
|
case EScriptObjectMessage::InvulnDamage: {
|
2020-03-31 00:40:38 +00:00
|
|
|
SetShotAt(true, mgr);
|
2020-04-02 04:29:40 +00:00
|
|
|
if (!TCastToConstPtr<CCollisionActor>(mgr.ObjectById(uid))) {
|
2020-03-29 07:28:14 +00:00
|
|
|
ApplyDamageToHead(mgr, uid);
|
2020-03-26 19:24:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2020-03-11 12:25:45 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-03-26 19:24:56 +00:00
|
|
|
if (shouldPass) {
|
|
|
|
CPatterned::AcceptScriptMsg(msg, uid, mgr);
|
|
|
|
}
|
|
|
|
}
|
2020-03-26 07:30:54 +00:00
|
|
|
|
2020-03-26 19:24:56 +00:00
|
|
|
void CElitePirate::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) {
|
|
|
|
CPatterned::PreRender(mgr, frustum);
|
2020-05-13 00:25:30 +00:00
|
|
|
auto* modelData = GetModelData();
|
2020-03-26 19:24:56 +00:00
|
|
|
x6f8_boneTracking.PreRender(mgr, *modelData->GetAnimationData(), GetTransform(), modelData->GetScale(),
|
|
|
|
*x450_bodyController);
|
2020-05-13 00:25:30 +00:00
|
|
|
const auto numMaterialSets = modelData->GetNumMaterialSets();
|
2020-04-01 18:54:01 +00:00
|
|
|
xb4_drawFlags.x1_matSetIdx =
|
|
|
|
numMaterialSets - 1 < x7cc_activeMaterialSet ? numMaterialSets - 1 : x7cc_activeMaterialSet;
|
2020-03-09 02:52:21 +00:00
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-31 03:10:51 +00:00
|
|
|
const CDamageVulnerability* CElitePirate::GetDamageVulnerability() const {
|
2020-03-26 19:24:56 +00:00
|
|
|
return &CDamageVulnerability::PassThroughVulnerabilty();
|
|
|
|
}
|
|
|
|
|
2020-03-31 03:10:51 +00:00
|
|
|
const CDamageVulnerability* CElitePirate::GetDamageVulnerability(const zeus::CVector3f& pos, const zeus::CVector3f& dir,
|
|
|
|
const CDamageInfo& dInfo) const {
|
2020-03-26 19:24:56 +00:00
|
|
|
return &CDamageVulnerability::PassThroughVulnerabilty();
|
2020-03-09 02:52:21 +00:00
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-31 03:10:51 +00:00
|
|
|
zeus::CVector3f CElitePirate::GetOrbitPosition(const CStateManager& mgr) const {
|
2020-03-26 22:09:50 +00:00
|
|
|
if (x772_launcherId != kInvalidUniqueId &&
|
|
|
|
mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Thermal) {
|
2020-03-30 23:31:14 +00:00
|
|
|
if (const auto* actor = static_cast<const CActor*>(mgr.GetObjectById(x772_launcherId))) {
|
2020-04-01 18:54:01 +00:00
|
|
|
return GetLockOnPosition(actor);
|
2020-03-26 22:09:50 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
if (HasWeakPointHead()) {
|
2020-04-02 04:29:40 +00:00
|
|
|
if (const TCastToConstPtr<CCollisionActor> actor = mgr.GetObjectById(x770_collisionHeadId)) {
|
2020-03-26 22:09:50 +00:00
|
|
|
return actor->GetTranslation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return GetLctrTransform("lockon_target_LCTR").origin;
|
2020-03-09 02:52:21 +00:00
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-31 03:10:51 +00:00
|
|
|
zeus::CVector3f CElitePirate::GetAimPosition(const CStateManager& mgr, float) const {
|
2020-03-30 23:31:14 +00:00
|
|
|
const std::shared_ptr<CPlayerState>& playerState = mgr.GetPlayerState();
|
2020-04-01 18:54:01 +00:00
|
|
|
if (x5d4_collisionActorMgr->GetActive() && playerState->IsFiringComboBeam() &&
|
2020-03-26 22:09:50 +00:00
|
|
|
playerState->GetCurrentBeam() == CPlayerState::EBeamId::Wave) {
|
2020-05-07 23:13:43 +00:00
|
|
|
if (const TCastToConstPtr<CCollisionActor> actor = mgr.GetObjectById(x79c_energyAttractorId)) {
|
2020-03-26 22:09:50 +00:00
|
|
|
return actor->GetTranslation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return GetOrbitPosition(mgr);
|
2020-03-09 02:52:21 +00:00
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-09 02:52:21 +00:00
|
|
|
void CElitePirate::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) {
|
2020-03-26 22:09:50 +00:00
|
|
|
bool handled = false;
|
|
|
|
switch (type) {
|
|
|
|
case EUserEventType::Projectile:
|
|
|
|
if (x772_launcherId != kInvalidUniqueId) {
|
|
|
|
CEntity* launcher = mgr.ObjectById(x772_launcherId);
|
|
|
|
mgr.SendScriptMsg(launcher, GetUniqueId(), EScriptObjectMessage::Action);
|
|
|
|
}
|
|
|
|
handled = true;
|
|
|
|
break;
|
|
|
|
case EUserEventType::DamageOn:
|
|
|
|
handled = true;
|
2020-04-01 07:39:05 +00:00
|
|
|
x988_24_damageOn = true;
|
2020-03-26 22:09:50 +00:00
|
|
|
break;
|
|
|
|
case EUserEventType::DamageOff:
|
|
|
|
handled = true;
|
2020-04-01 07:39:05 +00:00
|
|
|
x988_24_damageOn = false;
|
2020-03-26 22:09:50 +00:00
|
|
|
break;
|
|
|
|
case EUserEventType::ScreenShake:
|
2020-04-01 18:54:01 +00:00
|
|
|
HasWeakPointHead();
|
2020-03-26 22:09:50 +00:00
|
|
|
handled = true;
|
|
|
|
break;
|
|
|
|
case EUserEventType::BeginAction: {
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CVector3f origin = GetTranslation();
|
|
|
|
const zeus::CVector3f front = GetTransform().frontVector();
|
|
|
|
const float dot = (GetLctrTransform(node.GetLocatorName()).origin - origin).dot(front);
|
|
|
|
const zeus::CTransform xf = zeus::CTransform::Translate({
|
2020-03-27 06:47:34 +00:00
|
|
|
origin.x() + dot * front.x(),
|
|
|
|
origin.y() + dot * front.y(),
|
|
|
|
origin.z(),
|
|
|
|
});
|
2020-03-26 22:09:50 +00:00
|
|
|
mgr.AddObject(new CShockWave(mgr.AllocateUniqueId(), "Shock Wave", {GetAreaIdAlways(), CEntity::NullConnectionList},
|
2020-04-01 18:54:01 +00:00
|
|
|
xf, GetUniqueId(), GetShockWaveData(), IsElitePirate() ? 2.f : 1.3f,
|
|
|
|
IsElitePirate() ? 0.4f : 0.5f));
|
2020-03-27 06:47:34 +00:00
|
|
|
handled = true;
|
2020-03-26 22:09:50 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EUserEventType::BecomeShootThrough:
|
2020-04-01 18:54:01 +00:00
|
|
|
if (HasWeakPointHead()) {
|
2020-04-02 04:29:40 +00:00
|
|
|
const u32 numCollisionActors = x730_collisionActorMgrHead->GetNumCollisionActors();
|
2020-04-01 19:01:44 +00:00
|
|
|
for (u32 i = 0; i < numCollisionActors; ++i) {
|
2020-04-01 18:54:01 +00:00
|
|
|
const auto& description = x730_collisionActorMgrHead->GetCollisionDescFromIndex(i);
|
2020-03-27 06:47:34 +00:00
|
|
|
if (TCastToPtr<CCollisionActor> actor = mgr.ObjectById(description.GetCollisionActorId())) {
|
|
|
|
actor->AddMaterial(EMaterialTypes::ProjectilePassthrough, mgr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handled = true;
|
2020-03-26 22:09:50 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!handled) {
|
|
|
|
CPatterned::DoUserAnimEvent(mgr, node, type, dt);
|
|
|
|
}
|
2020-03-09 02:52:21 +00:00
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-04-01 18:54:01 +00:00
|
|
|
const CCollisionPrimitive* CElitePirate::GetCollisionPrimitive() const { return &x738_collisionAabb; }
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-11 12:25:45 +00:00
|
|
|
void CElitePirate::KnockBack(const zeus::CVector3f& pos, CStateManager& mgr, const CDamageInfo& info,
|
|
|
|
EKnockBackType type, bool inDeferred, float magnitude) {
|
2020-04-01 18:54:01 +00:00
|
|
|
if (!CanKnockBack(info)) {
|
2020-03-27 06:47:34 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-03-09 02:52:21 +00:00
|
|
|
CPatterned::KnockBack(pos, mgr, info, type, inDeferred, magnitude);
|
2020-03-27 06:47:34 +00:00
|
|
|
if (info.GetWeaponMode().IsComboed() && info.GetWeaponMode().GetType() == EWeaponType::Ice) {
|
|
|
|
Freeze(mgr, zeus::skZero3f, GetTransform().transposeRotate(pos), 1.5f);
|
|
|
|
}
|
2020-03-09 02:52:21 +00:00
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-30 23:42:11 +00:00
|
|
|
void CElitePirate::TakeDamage(const zeus::CVector3f& pos, float) {}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-27 06:47:34 +00:00
|
|
|
void CElitePirate::Patrol(CStateManager& mgr, EStateMsg msg, float dt) {
|
|
|
|
if (msg == EStateMsg::Activate) {
|
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
|
|
|
x400_24_hitByPlayerProjectile = false;
|
2020-04-01 18:54:01 +00:00
|
|
|
x989_24_onPath = false;
|
2020-03-27 06:47:34 +00:00
|
|
|
}
|
|
|
|
CPatterned::Patrol(mgr, msg, dt);
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-27 06:47:34 +00:00
|
|
|
void CElitePirate::PathFind(CStateManager& mgr, EStateMsg msg, float dt) {
|
|
|
|
if (msg == EStateMsg::Activate) {
|
2020-04-01 18:54:01 +00:00
|
|
|
x989_24_onPath = true;
|
2020-03-27 06:47:34 +00:00
|
|
|
x988_28_alert = false;
|
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
|
|
|
x6f8_boneTracking.SetTarget(mgr.GetPlayer().GetUniqueId());
|
|
|
|
x6f8_boneTracking.SetActive(true);
|
2020-04-01 18:54:01 +00:00
|
|
|
UpdateDestPos(mgr);
|
2020-03-27 06:47:34 +00:00
|
|
|
CPatterned::PathFind(mgr, msg, dt);
|
2020-03-31 00:40:38 +00:00
|
|
|
x7bc_tauntTimer = x5d8_data.GetTauntVariance() * mgr.GetActiveRandom()->Float() + x5d8_data.GetTauntInterval();
|
2020-03-27 06:47:34 +00:00
|
|
|
if (TooClose(mgr, 0.f)) {
|
|
|
|
x450_bodyController->GetCommandMgr().ClearLocomotionCmds();
|
|
|
|
}
|
|
|
|
} else if (msg == EStateMsg::Update) {
|
2020-03-29 07:28:14 +00:00
|
|
|
if (x7bc_tauntTimer > 0.f) {
|
|
|
|
x7bc_tauntTimer -= dt;
|
2020-03-27 06:47:34 +00:00
|
|
|
}
|
|
|
|
if (!TooClose(mgr, 0.f) && !PathShagged(mgr, 0.f)) {
|
|
|
|
CPatterned::PathFind(mgr, msg, dt);
|
2020-03-31 03:10:51 +00:00
|
|
|
} else if (PathShagged(mgr, 0.f)) {
|
2020-05-07 23:13:43 +00:00
|
|
|
const auto move = x8c0_positionHistory.GetValue(GetTranslation(), GetTransform().frontVector());
|
2020-03-31 03:10:51 +00:00
|
|
|
if (move != zeus::skZero3f) {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(move, zeus::skZero3f, 1.f));
|
|
|
|
}
|
|
|
|
} else if (ShouldTurn(mgr, 0.f)) {
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CVector3f aim =
|
2020-03-31 03:10:51 +00:00
|
|
|
mgr.GetPlayer().GetAimPosition(mgr, 0.5f * GetModelData()->GetAnimationData()->GetSpeedScale());
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CVector3f face = aim - GetTranslation();
|
2020-03-31 03:10:51 +00:00
|
|
|
if (face.canBeNormalized()) {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(zeus::skZero3f, face.normalized(), 1.f));
|
2020-03-27 06:47:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (msg == EStateMsg::Deactivate) {
|
|
|
|
x6f8_boneTracking.SetActive(false);
|
|
|
|
}
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-29 07:28:14 +00:00
|
|
|
void CElitePirate::TargetPatrol(CStateManager& mgr, EStateMsg msg, float dt) {
|
|
|
|
if (msg == EStateMsg::Activate) {
|
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
|
|
|
if (HasPatrolPath(mgr, 0.f)) {
|
|
|
|
CPatterned::Patrol(mgr, msg, dt);
|
|
|
|
UpdateDest(mgr);
|
|
|
|
} else {
|
|
|
|
SetDestPos(x3a0_latestLeashPosition);
|
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
x8b4_targetDestPos = x2e0_destPos;
|
2020-03-29 07:28:14 +00:00
|
|
|
if (GetSearchPath() != nullptr) {
|
|
|
|
CPatterned::PathFind(mgr, msg, dt);
|
|
|
|
}
|
|
|
|
} else if (msg == EStateMsg::Update) {
|
|
|
|
if (PathShagged(mgr, 0.f)) {
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CVector3f move = x45c_steeringBehaviors.Arrival(*this, x8b4_targetDestPos, 25.f);
|
2020-03-29 07:28:14 +00:00
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(move, zeus::skZero3f, 1.f));
|
|
|
|
} else {
|
|
|
|
CPatterned::PathFind(mgr, msg, dt);
|
|
|
|
}
|
|
|
|
} else if (msg == EStateMsg::Deactivate) {
|
|
|
|
x988_28_alert = false;
|
|
|
|
}
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-30 23:42:11 +00:00
|
|
|
void CElitePirate::Halt(CStateManager& mgr, EStateMsg msg, float) {
|
2020-03-27 06:47:34 +00:00
|
|
|
if (msg == EStateMsg::Activate) {
|
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Lurk);
|
2020-04-01 18:54:01 +00:00
|
|
|
x989_24_onPath = false;
|
2020-03-27 06:47:34 +00:00
|
|
|
CMaterialFilter filter = GetMaterialFilter();
|
|
|
|
filter.ExcludeList().Add(
|
|
|
|
{EMaterialTypes::Wall, EMaterialTypes::Ceiling, EMaterialTypes::AIBlock, EMaterialTypes::Character});
|
|
|
|
SetMaterialFilter(filter);
|
|
|
|
} else if (msg == EStateMsg::Deactivate) {
|
|
|
|
CMaterialFilter filter = GetMaterialFilter();
|
|
|
|
filter.ExcludeList().Remove(
|
|
|
|
{EMaterialTypes::Wall, EMaterialTypes::Ceiling, EMaterialTypes::AIBlock, EMaterialTypes::Character});
|
|
|
|
SetMaterialFilter(filter);
|
|
|
|
}
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-27 06:47:34 +00:00
|
|
|
void CElitePirate::Run(CStateManager& mgr, EStateMsg msg, float dt) {
|
|
|
|
if (msg == EStateMsg::Activate) {
|
2020-04-01 18:54:01 +00:00
|
|
|
x988_31_running = true;
|
2020-03-27 06:47:34 +00:00
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
|
|
|
x450_bodyController->GetCommandMgr().SetSteeringSpeedRange(1.f, 1.f);
|
|
|
|
x6f8_boneTracking.SetTarget(mgr.GetPlayer().GetUniqueId());
|
|
|
|
x6f8_boneTracking.SetActive(true);
|
2020-04-01 18:54:01 +00:00
|
|
|
UpdateDestPos(mgr);
|
2020-03-27 06:47:34 +00:00
|
|
|
CPatterned::PathFind(mgr, msg, dt);
|
|
|
|
} else if (msg == EStateMsg::Update) {
|
|
|
|
if (PathShagged(mgr, 0.f)) {
|
2020-05-07 23:13:43 +00:00
|
|
|
const auto move = x8c0_positionHistory.GetValue(GetTranslation(), GetTransform().frontVector());
|
2020-03-27 06:47:34 +00:00
|
|
|
if (move != zeus::skZero3f) {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(move, zeus::skZero3f, 1.f));
|
|
|
|
} else if (ShouldTurn(mgr, 0.f)) {
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CVector3f aim =
|
2020-03-27 06:47:34 +00:00
|
|
|
mgr.GetPlayer().GetAimPosition(mgr, 0.5f * GetModelData()->GetAnimationData()->GetSpeedScale());
|
2020-04-02 04:22:45 +00:00
|
|
|
const auto face = aim - GetTranslation();
|
2020-03-29 07:28:14 +00:00
|
|
|
if (face.canBeNormalized()) {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(zeus::skZero3f, face.normalized(), 1.f));
|
2020-03-27 06:47:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
CPatterned::PathFind(mgr, msg, dt);
|
|
|
|
}
|
|
|
|
} else if (msg == EStateMsg::Deactivate) {
|
2020-04-01 18:54:01 +00:00
|
|
|
x988_31_running = false;
|
2020-03-27 06:47:34 +00:00
|
|
|
x6f8_boneTracking.SetActive(false);
|
2020-04-01 18:54:01 +00:00
|
|
|
x450_bodyController->GetCommandMgr().SetSteeringSpeedRange(x7a4_steeringSpeed, x7a4_steeringSpeed);
|
2020-03-27 06:47:34 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-30 23:42:11 +00:00
|
|
|
void CElitePirate::Generate(CStateManager& mgr, EStateMsg msg, float) {
|
2020-03-29 07:28:14 +00:00
|
|
|
if (msg == EStateMsg::Activate) {
|
2020-04-01 18:54:01 +00:00
|
|
|
x568_state = EState::One;
|
2020-03-29 07:28:14 +00:00
|
|
|
} else if (msg == EStateMsg::Update) {
|
2020-04-01 18:54:01 +00:00
|
|
|
if (x568_state == EState::Zero) {
|
2020-03-27 06:47:34 +00:00
|
|
|
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Generate) {
|
2020-04-01 18:54:01 +00:00
|
|
|
x568_state = EState::Two;
|
2020-03-27 06:47:34 +00:00
|
|
|
} else {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(pas::EGenerateType::Zero));
|
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
} else if (x568_state == EState::One) {
|
2020-03-27 06:47:34 +00:00
|
|
|
if (ShouldTurn(mgr, 0.f)) {
|
2020-04-02 04:22:45 +00:00
|
|
|
const auto face = mgr.GetPlayer().GetTranslation() - GetTranslation();
|
2020-03-29 07:28:14 +00:00
|
|
|
if (face.canBeNormalized()) {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(zeus::skZero3f, face.normalized(), 1.f));
|
2020-03-27 06:47:34 +00:00
|
|
|
}
|
|
|
|
} else {
|
2020-04-01 18:54:01 +00:00
|
|
|
x568_state = EState::Zero;
|
2020-03-27 06:47:34 +00:00
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
} else if (x568_state == EState::Two && x450_bodyController->GetCurrentStateId() != pas::EAnimationState::Generate) {
|
|
|
|
x568_state = EState::Over;
|
2020-03-27 06:47:34 +00:00
|
|
|
}
|
2020-03-29 07:28:14 +00:00
|
|
|
} else if (msg == EStateMsg::Deactivate) {
|
2020-03-31 00:40:38 +00:00
|
|
|
SetShotAt(false, mgr);
|
2020-04-01 18:54:01 +00:00
|
|
|
SetLaunchersActive(mgr, true);
|
2020-03-27 06:47:34 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-30 23:42:11 +00:00
|
|
|
void CElitePirate::Attack(CStateManager& mgr, EStateMsg msg, float) {
|
2020-03-29 07:28:14 +00:00
|
|
|
if (msg == EStateMsg::Activate) {
|
2020-04-01 18:54:01 +00:00
|
|
|
x568_state = EState::Zero;
|
2020-03-29 07:28:14 +00:00
|
|
|
ExtendTouchBounds(mgr, x774_collisionRJointIds, zeus::CVector3f(2.f));
|
|
|
|
if (x64_modelData->GetNumMaterialSets() > 1) {
|
2020-04-01 07:39:05 +00:00
|
|
|
x7cc_activeMaterialSet = 1;
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
|
|
|
} else if (msg == EStateMsg::Update) {
|
2020-04-01 18:54:01 +00:00
|
|
|
if (x568_state == EState::Zero) {
|
2020-03-29 07:28:14 +00:00
|
|
|
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::MeleeAttack) {
|
2020-04-01 18:54:01 +00:00
|
|
|
x568_state = EState::One;
|
|
|
|
x988_25_attackingRightClaw = true;
|
2020-03-29 07:28:14 +00:00
|
|
|
x7c8_currAnimId = x450_bodyController->GetCurrentAnimId();
|
|
|
|
} else {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCMeleeAttackCmd(pas::ESeverity::One));
|
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
} else if (x568_state == EState::One) {
|
2020-03-29 07:28:14 +00:00
|
|
|
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::MeleeAttack) {
|
|
|
|
if (x7c8_currAnimId == x450_bodyController->GetCurrentAnimId()) {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation());
|
|
|
|
if (ShouldAttack(mgr, 0.f)) {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCMeleeAttackCmd(pas::ESeverity::Two));
|
|
|
|
}
|
|
|
|
} else {
|
2020-04-01 18:54:01 +00:00
|
|
|
x568_state = EState::Two;
|
|
|
|
x988_25_attackingRightClaw = false;
|
|
|
|
x988_26_attackingLeftClaw = true;
|
2020-03-29 07:28:14 +00:00
|
|
|
ExtendTouchBounds(mgr, x774_collisionRJointIds, zeus::skZero3f);
|
|
|
|
ExtendTouchBounds(mgr, x788_collisionLJointIds, zeus::CVector3f(2.f));
|
|
|
|
}
|
|
|
|
} else {
|
2020-04-01 18:54:01 +00:00
|
|
|
x568_state = EState::Over;
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
} else if (x568_state == EState::Two) {
|
2020-03-29 07:28:14 +00:00
|
|
|
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::MeleeAttack) {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation());
|
|
|
|
} else {
|
2020-04-01 18:54:01 +00:00
|
|
|
x568_state = EState::Over;
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (msg == EStateMsg::Deactivate) {
|
2020-04-01 18:54:01 +00:00
|
|
|
CheckAttackChance(mgr);
|
2020-04-01 07:39:05 +00:00
|
|
|
x988_24_damageOn = false;
|
2020-04-01 18:54:01 +00:00
|
|
|
x988_26_attackingLeftClaw = false;
|
|
|
|
x988_25_attackingRightClaw = false;
|
2020-03-29 07:28:14 +00:00
|
|
|
x7c8_currAnimId = -1;
|
|
|
|
ExtendTouchBounds(mgr, x774_collisionRJointIds, zeus::skZero3f);
|
|
|
|
ExtendTouchBounds(mgr, x788_collisionLJointIds, zeus::skZero3f);
|
2020-04-01 07:39:05 +00:00
|
|
|
x7cc_activeMaterialSet = 0;
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-09 02:52:21 +00:00
|
|
|
void CElitePirate::Taunt(CStateManager& mgr, EStateMsg msg, float dt) { CAi::Taunt(mgr, msg, dt); }
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-30 23:42:11 +00:00
|
|
|
void CElitePirate::ProjectileAttack(CStateManager& mgr, EStateMsg msg, float) {
|
2020-03-27 06:47:34 +00:00
|
|
|
if (msg == EStateMsg::Activate) {
|
2020-04-01 18:54:01 +00:00
|
|
|
x568_state = EState::Zero;
|
2020-03-27 06:47:34 +00:00
|
|
|
} else if (msg == EStateMsg::Update) {
|
|
|
|
const zeus::CVector3f& playerPos = mgr.GetPlayer().GetTranslation();
|
2020-04-01 18:54:01 +00:00
|
|
|
if (x568_state == EState::Zero) {
|
2020-03-27 06:47:34 +00:00
|
|
|
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::ProjectileAttack) {
|
2020-04-01 18:54:01 +00:00
|
|
|
x568_state = EState::Two;
|
2020-03-27 06:47:34 +00:00
|
|
|
} else {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCProjectileAttackCmd(pas::ESeverity::One, playerPos, false));
|
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
} else if (x568_state == EState::Two) {
|
2020-03-27 06:47:34 +00:00
|
|
|
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::ProjectileAttack) {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverTargetVector(playerPos - GetTranslation());
|
|
|
|
} else {
|
2020-04-01 18:54:01 +00:00
|
|
|
x568_state = EState::Over;
|
2020-03-27 06:47:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (msg == EStateMsg::Deactivate) {
|
2020-04-01 18:54:01 +00:00
|
|
|
CheckAttackChance(mgr);
|
2020-03-27 06:47:34 +00:00
|
|
|
}
|
2020-03-09 02:52:21 +00:00
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-31 07:29:00 +00:00
|
|
|
void CElitePirate::SpecialAttack(CStateManager& mgr, EStateMsg msg, float) {
|
|
|
|
if (msg == EStateMsg::Activate) {
|
2020-04-01 18:54:01 +00:00
|
|
|
x568_state = EState::Zero;
|
2020-03-31 07:29:00 +00:00
|
|
|
} else if (msg == EStateMsg::Update) {
|
2020-04-01 18:54:01 +00:00
|
|
|
if (x568_state == EState::Zero) {
|
2020-03-31 07:29:00 +00:00
|
|
|
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::ProjectileAttack) {
|
2020-04-01 18:54:01 +00:00
|
|
|
x568_state = EState::Two;
|
|
|
|
x988_29_shockWaveAnim = true;
|
2020-03-31 07:29:00 +00:00
|
|
|
} else {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(
|
|
|
|
CBCProjectileAttackCmd(pas::ESeverity::Two, mgr.GetPlayer().GetTranslation(), false));
|
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
} else if (x568_state == EState::Two) {
|
2020-03-31 07:29:00 +00:00
|
|
|
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::ProjectileAttack) {
|
2020-04-05 05:36:58 +00:00
|
|
|
x450_bodyController->GetCommandMgr().DeliverTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation());
|
2020-03-31 07:29:00 +00:00
|
|
|
} else {
|
2020-04-01 18:54:01 +00:00
|
|
|
x568_state = EState::Over;
|
2020-03-31 07:29:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (msg == EStateMsg::Deactivate) {
|
2020-04-01 18:54:01 +00:00
|
|
|
CheckAttackChance(mgr);
|
|
|
|
x988_29_shockWaveAnim = false;
|
2020-03-31 07:29:00 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-30 23:42:11 +00:00
|
|
|
void CElitePirate::CallForBackup(CStateManager& mgr, EStateMsg msg, float) {
|
2020-03-29 07:28:14 +00:00
|
|
|
if (msg == EStateMsg::Activate) {
|
2020-04-01 18:54:01 +00:00
|
|
|
x568_state = EState::Zero;
|
|
|
|
x988_30_calledForBackup = true;
|
2020-03-31 00:40:38 +00:00
|
|
|
SetShotAt(false, mgr);
|
2020-03-29 07:28:14 +00:00
|
|
|
} else if (msg == EStateMsg::Update) {
|
2020-04-01 18:54:01 +00:00
|
|
|
if (x568_state == EState::Zero) {
|
2020-03-29 07:28:14 +00:00
|
|
|
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Generate) {
|
2020-04-01 18:54:01 +00:00
|
|
|
x568_state = EState::Two;
|
2020-03-29 07:28:14 +00:00
|
|
|
} else {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(pas::EGenerateType::Five, zeus::skZero3f));
|
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
} else if (x568_state == EState::Two) {
|
2020-03-29 07:28:14 +00:00
|
|
|
if (x450_bodyController->GetCurrentStateId() != pas::EAnimationState::Generate) {
|
2020-04-01 18:54:01 +00:00
|
|
|
x568_state = EState::Over;
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (msg == EStateMsg::Deactivate) {
|
|
|
|
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CElitePirate::Cover(CStateManager& mgr, EStateMsg msg, float dt) {
|
|
|
|
if (msg == EStateMsg::Activate) {
|
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Crouch);
|
2020-04-01 18:54:01 +00:00
|
|
|
if (HasWeakPointHead()) {
|
2020-03-29 07:28:14 +00:00
|
|
|
if (TCastToPtr<CCollisionActor> actor = mgr.ObjectById(x770_collisionHeadId)) {
|
|
|
|
actor->SetDamageVulnerability(CDamageVulnerability::ImmuneVulnerabilty());
|
|
|
|
}
|
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
x5d4_collisionActorMgr->SetActive(mgr, true);
|
2020-03-29 07:28:14 +00:00
|
|
|
x6f8_boneTracking.SetTarget(mgr.GetPlayer().GetUniqueId());
|
|
|
|
x6f8_boneTracking.SetActive(true);
|
2020-04-01 18:54:01 +00:00
|
|
|
UpdateDestPos(mgr);
|
2020-03-29 07:28:14 +00:00
|
|
|
CPatterned::PathFind(mgr, msg, dt);
|
|
|
|
if (TooClose(mgr, 0.f)) {
|
|
|
|
x450_bodyController->GetCommandMgr().ClearLocomotionCmds();
|
|
|
|
}
|
|
|
|
} else if (msg == EStateMsg::Update) {
|
2020-03-31 00:40:38 +00:00
|
|
|
if (x988_27_shotAt) {
|
|
|
|
x7c0_shotAtTimer -= dt;
|
|
|
|
if (x7c0_shotAtTimer <= 0.f) {
|
|
|
|
x988_27_shotAt = false;
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
x7a8_pathShaggedTime = PathShagged(mgr, 0.f) ? x7a8_pathShaggedTime + dt : 0.f;
|
2020-03-29 07:28:14 +00:00
|
|
|
if (!TooClose(mgr, 0.f) && !PathShagged(mgr, 0.f)) {
|
|
|
|
CPatterned::PathFind(mgr, msg, dt);
|
|
|
|
} else if (PathShagged(mgr, 0.f)) {
|
2020-05-07 23:13:43 +00:00
|
|
|
const auto move = x8c0_positionHistory.GetValue(GetTranslation(), GetTransform().frontVector());
|
2020-03-29 07:28:14 +00:00
|
|
|
if (move != zeus::skZero3f) {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(move, zeus::skZero3f, 1.f));
|
|
|
|
}
|
|
|
|
} else if (ShouldTurn(mgr, 0.f)) {
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CVector3f aim =
|
2020-03-29 07:28:14 +00:00
|
|
|
mgr.GetPlayer().GetAimPosition(mgr, 0.5f * GetModelData()->GetAnimationData()->GetSpeedScale());
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CVector3f face = aim - GetTranslation();
|
2020-03-29 07:28:14 +00:00
|
|
|
if (face.canBeNormalized()) {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(zeus::skZero3f, face.normalized(), 1.f));
|
|
|
|
}
|
|
|
|
}
|
2020-03-31 03:10:51 +00:00
|
|
|
AttractProjectiles(mgr);
|
2020-04-01 18:54:01 +00:00
|
|
|
UpdateAbsorbBodyState(mgr, dt);
|
2020-03-29 07:28:14 +00:00
|
|
|
} else if (msg == EStateMsg::Deactivate) {
|
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
|
|
|
x6f8_boneTracking.SetActive(false);
|
2020-04-01 18:54:01 +00:00
|
|
|
if (HasWeakPointHead()) {
|
2020-03-29 07:28:14 +00:00
|
|
|
if (TCastToPtr<CCollisionActor> actor = mgr.ObjectById(x770_collisionHeadId)) {
|
|
|
|
actor->SetDamageVulnerability(x56c_vulnerability);
|
|
|
|
}
|
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
x5d4_collisionActorMgr->SetActive(mgr, false);
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-30 23:42:11 +00:00
|
|
|
bool CElitePirate::TooClose(CStateManager& mgr, float) {
|
2020-03-29 07:28:14 +00:00
|
|
|
return x2fc_minAttackRange * x2fc_minAttackRange > (GetTranslation() - mgr.GetPlayer().GetTranslation()).magSquared();
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-27 06:47:34 +00:00
|
|
|
bool CElitePirate::InDetectionRange(CStateManager& mgr, float arg) {
|
2020-03-29 07:28:14 +00:00
|
|
|
return x988_28_alert ? true : CPatterned::InDetectionRange(mgr, arg);
|
2020-03-27 06:47:34 +00:00
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-29 07:28:14 +00:00
|
|
|
bool CElitePirate::SpotPlayer(CStateManager& mgr, float arg) {
|
|
|
|
return x988_28_alert ? true : CPatterned::SpotPlayer(mgr, arg);
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-04-01 18:54:01 +00:00
|
|
|
bool CElitePirate::AnimOver(CStateManager& mgr, float) { return x568_state == EState::Over; }
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-30 23:42:11 +00:00
|
|
|
bool CElitePirate::ShouldAttack(CStateManager& mgr, float) {
|
2020-03-27 06:47:34 +00:00
|
|
|
if ((mgr.GetPlayer().GetTranslation() - GetTranslation()).magSquared() > x2fc_minAttackRange * x2fc_minAttackRange) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !ShouldTurn(mgr, 0.f);
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-04-01 18:54:01 +00:00
|
|
|
bool CElitePirate::InPosition(CStateManager& mgr, float) {
|
|
|
|
return (x8b4_targetDestPos - GetTranslation()).magSquared() < 25.f;
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-30 23:42:11 +00:00
|
|
|
bool CElitePirate::ShouldTurn(CStateManager& mgr, float) {
|
2020-03-27 06:47:34 +00:00
|
|
|
return zeus::CVector2f::getAngleDiff((mgr.GetPlayer().GetTranslation() - GetTranslation()).toVec2f(),
|
|
|
|
GetTransform().frontVector().toVec2f()) > zeus::degToRad(15.f);
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
|
|
|
bool CElitePirate::AggressionCheck(CStateManager& mgr, float arg) {
|
|
|
|
if (x772_launcherId == kInvalidUniqueId && !PathShagged(mgr, arg)) {
|
2020-04-01 18:54:01 +00:00
|
|
|
if (x988_31_running) {
|
|
|
|
return true;
|
2020-03-26 19:24:56 +00:00
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
return 4.f * x300_maxAttackRange * x300_maxAttackRange <
|
|
|
|
(mgr.GetPlayer().GetTranslation() - GetTranslation()).magSquared();
|
2020-03-26 19:24:56 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-03-30 23:42:11 +00:00
|
|
|
bool CElitePirate::ShouldTaunt(CStateManager& mgr, float) { return x7bc_tauntTimer <= 0.f; }
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-30 23:42:11 +00:00
|
|
|
bool CElitePirate::ShouldFire(CStateManager& mgr, float) { return ShouldFireFromLauncher(mgr, x772_launcherId); }
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-31 00:40:38 +00:00
|
|
|
bool CElitePirate::ShotAt(CStateManager& mgr, float) { return x988_27_shotAt; }
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-30 23:42:11 +00:00
|
|
|
bool CElitePirate::ShouldSpecialAttack(CStateManager& mgr, float) {
|
2020-03-29 07:28:14 +00:00
|
|
|
if (x7b8_attackTimer <= 0.f && GetAreaIdAlways() == mgr.GetPlayer().GetAreaIdAlways()) {
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CVector3f dist = mgr.GetPlayer().GetAimPosition(mgr, 0.f) - GetTranslation();
|
|
|
|
const float magSquared = dist.magSquared();
|
2020-03-29 07:28:14 +00:00
|
|
|
if (x2fc_minAttackRange * x2fc_minAttackRange <= magSquared &&
|
|
|
|
magSquared <= x300_maxAttackRange * x300_maxAttackRange) {
|
|
|
|
return std::abs(dist.z()) < 3.f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-30 23:42:11 +00:00
|
|
|
bool CElitePirate::ShouldCallForBackup(CStateManager& mgr, float) {
|
2020-03-29 07:28:14 +00:00
|
|
|
return ShouldCallForBackupFromLauncher(mgr, x772_launcherId);
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-31 03:10:51 +00:00
|
|
|
CPathFindSearch* CElitePirate::GetSearchPath() { return &x7d0_pathFindSearch; }
|
2020-03-26 19:24:56 +00:00
|
|
|
|
2020-03-27 01:42:18 +00:00
|
|
|
void CElitePirate::SetupHealthInfo(CStateManager& mgr) {
|
2020-03-26 19:24:56 +00:00
|
|
|
const CHealthInfo* const health = HealthInfo(mgr);
|
|
|
|
x7b4_hp = health->GetHP();
|
2020-04-01 18:54:01 +00:00
|
|
|
if (HasWeakPointHead()) {
|
2020-03-26 19:24:56 +00:00
|
|
|
if (TCastToPtr<CCollisionActor> actor = mgr.ObjectById(x770_collisionHeadId)) {
|
2020-05-13 00:25:30 +00:00
|
|
|
auto* actHealth = actor->HealthInfo(mgr);
|
2020-03-26 19:24:56 +00:00
|
|
|
actHealth->SetHP(health->GetHP());
|
|
|
|
actHealth->SetKnockbackResistance(health->GetKnockbackResistance());
|
|
|
|
actor->SetDamageVulnerability(x56c_vulnerability);
|
|
|
|
}
|
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
SetupLauncherHealthInfo(mgr, x772_launcherId);
|
2020-03-26 19:24:56 +00:00
|
|
|
}
|
|
|
|
|
2020-04-01 18:54:01 +00:00
|
|
|
void CElitePirate::SetLaunchersActive(CStateManager& mgr, bool val) { SetLauncherActive(mgr, val, x772_launcherId); }
|
2020-03-26 07:30:54 +00:00
|
|
|
|
2020-04-01 18:54:01 +00:00
|
|
|
void CElitePirate::SetupPathFindSearch() {
|
2020-04-02 04:29:40 +00:00
|
|
|
const float scale = 1.5f * GetModelData()->GetScale().y();
|
|
|
|
const float fVar1 = IsElitePirate() ? 5.f : 1.f;
|
|
|
|
const zeus::CAABox box{{-scale, -scale, 0.f}, {scale, scale, fVar1 * scale}};
|
2020-03-26 07:30:54 +00:00
|
|
|
SetBoundingBox(box);
|
2020-04-01 18:54:01 +00:00
|
|
|
x738_collisionAabb.SetBox(box);
|
2020-03-26 07:30:54 +00:00
|
|
|
x7d0_pathFindSearch.SetCharacterRadius(scale);
|
|
|
|
x7d0_pathFindSearch.SetCharacterHeight(3.f * scale);
|
|
|
|
}
|
|
|
|
|
2020-03-31 00:40:38 +00:00
|
|
|
void CElitePirate::SetShotAt(bool val, CStateManager& mgr) {
|
2020-04-01 18:54:01 +00:00
|
|
|
if (!IsElitePirate() || x7b4_hp <= 0.f || !val) {
|
2020-03-31 00:40:38 +00:00
|
|
|
x988_27_shotAt = val;
|
2020-03-26 19:24:56 +00:00
|
|
|
} else if (HealthInfo(mgr)->GetHP() / x7b4_hp <= x7b0_) {
|
2020-03-26 07:30:54 +00:00
|
|
|
x7b0_ -= 0.2f;
|
2020-03-31 00:40:38 +00:00
|
|
|
x988_27_shotAt = true;
|
2020-03-26 07:30:54 +00:00
|
|
|
}
|
2020-03-31 00:40:38 +00:00
|
|
|
if (x988_27_shotAt) {
|
|
|
|
x7c0_shotAtTimer = mgr.GetActiveRandom()->Float() * x5d8_data.GetShotAtTimeVariance() + x5d8_data.GetShotAtTime();
|
2020-03-26 07:30:54 +00:00
|
|
|
} else {
|
2020-03-31 00:40:38 +00:00
|
|
|
x7c0_shotAtTimer = 0.f;
|
2020-03-26 07:30:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-27 01:42:18 +00:00
|
|
|
bool CElitePirate::IsArmClawCollider(TUniqueId uid, const rstl::reserved_vector<TUniqueId, 7>& vec) const {
|
2020-03-26 07:30:54 +00:00
|
|
|
return std::find(vec.begin(), vec.end(), uid) != vec.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CElitePirate::AddCollisionList(const SJointInfo* joints, size_t count,
|
|
|
|
std::vector<CJointCollisionDescription>& outJoints) const {
|
|
|
|
const CAnimData* animData = GetModelData()->GetAnimationData();
|
|
|
|
for (size_t i = 0; i < count; ++i) {
|
|
|
|
const auto& joint = joints[i];
|
|
|
|
const CSegId from = animData->GetLocatorSegId(joint.from);
|
|
|
|
const CSegId to = animData->GetLocatorSegId(joint.to);
|
|
|
|
if (to.IsInvalid() || from.IsInvalid()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
outJoints.emplace_back(CJointCollisionDescription::SphereSubdivideCollision(
|
|
|
|
to, from, joint.radius, joint.separation, CJointCollisionDescription::EOrientationType::One, joint.from, 10.f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CElitePirate::AddSphereCollisionList(const SSphereJointInfo* joints, size_t count,
|
|
|
|
std::vector<CJointCollisionDescription>& outJoints) const {
|
|
|
|
const CAnimData* animData = GetModelData()->GetAnimationData();
|
|
|
|
for (size_t i = 0; i < count; ++i) {
|
|
|
|
const auto& joint = joints[i];
|
|
|
|
const CSegId seg = animData->GetLocatorSegId(joint.name);
|
|
|
|
if (seg.IsInvalid()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
outJoints.emplace_back(CJointCollisionDescription::SphereCollision(seg, joint.radius, joint.name, 10.f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-27 01:42:18 +00:00
|
|
|
void CElitePirate::SetupCollisionManager(CStateManager& mgr) {
|
|
|
|
constexpr size_t jointInfoCount = skLeftArmJointList.size() + skRightArmJointList.size() + skSphereJointList.size();
|
2020-03-27 06:47:34 +00:00
|
|
|
std::vector<CJointCollisionDescription> joints;
|
|
|
|
joints.reserve(jointInfoCount);
|
2020-03-27 01:42:18 +00:00
|
|
|
AddCollisionList(skLeftArmJointList.data(), skLeftArmJointList.size(), joints);
|
|
|
|
AddCollisionList(skRightArmJointList.data(), skLeftArmJointList.size(), joints);
|
|
|
|
AddSphereCollisionList(skSphereJointList.data(), skSphereJointList.size(), joints);
|
2020-04-01 18:54:01 +00:00
|
|
|
if (HasWeakPointHead()) {
|
|
|
|
x730_collisionActorMgrHead =
|
2020-03-26 07:30:54 +00:00
|
|
|
std::make_unique<CCollisionActorManager>(mgr, GetUniqueId(), GetAreaIdAlways(), joints, true);
|
2020-04-01 18:54:01 +00:00
|
|
|
x730_collisionActorMgrHead->SetActive(mgr, GetActive());
|
2020-03-26 07:30:54 +00:00
|
|
|
}
|
|
|
|
x774_collisionRJointIds.clear();
|
|
|
|
x788_collisionLJointIds.clear();
|
|
|
|
|
|
|
|
const CAnimData* animData = GetModelData()->GetAnimationData();
|
|
|
|
constexpr zeus::CVector3f bounds{4.f, 4.f, 2.f};
|
|
|
|
joints.emplace_back(CJointCollisionDescription::OBBCollision(animData->GetLocatorSegId("L_Palm_LCTR"sv), bounds,
|
|
|
|
zeus::skZero3f, "Shield"sv, 10.f));
|
2020-04-01 18:54:01 +00:00
|
|
|
x5d4_collisionActorMgr =
|
2020-03-26 07:30:54 +00:00
|
|
|
std::make_unique<CCollisionActorManager>(mgr, GetUniqueId(), GetAreaIdAlways(), joints, false);
|
|
|
|
|
2020-03-27 01:42:18 +00:00
|
|
|
SetupCollisionActorInfo(mgr);
|
|
|
|
SetupHealthInfo(mgr);
|
2020-03-26 07:30:54 +00:00
|
|
|
|
|
|
|
SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(
|
|
|
|
{EMaterialTypes::Solid},
|
|
|
|
{EMaterialTypes::CollisionActor, EMaterialTypes::AIPassthrough, EMaterialTypes::Player}));
|
|
|
|
AddMaterial(EMaterialTypes::ProjectilePassthrough, mgr);
|
|
|
|
}
|
|
|
|
|
2020-03-27 01:42:18 +00:00
|
|
|
void CElitePirate::SetupCollisionActorInfo(CStateManager& mgr) {
|
2020-04-01 18:54:01 +00:00
|
|
|
if (HasWeakPointHead()) {
|
|
|
|
for (size_t i = 0; i < x730_collisionActorMgrHead->GetNumCollisionActors(); ++i) {
|
|
|
|
const auto& colDesc = x730_collisionActorMgrHead->GetCollisionDescFromIndex(i);
|
2020-04-02 04:22:45 +00:00
|
|
|
const TUniqueId uid = colDesc.GetCollisionActorId();
|
2020-03-26 07:30:54 +00:00
|
|
|
if (TCastToPtr<CCollisionActor> act = mgr.ObjectById(uid)) {
|
|
|
|
if (colDesc.GetName() == "Head_1"sv) {
|
|
|
|
x770_collisionHeadId = uid;
|
2020-03-27 01:42:18 +00:00
|
|
|
} else if (IsArmClawCollider(colDesc.GetName(), "R_Palm_LCTR"sv, skRightArmJointList.data(),
|
|
|
|
skRightArmJointList.size())) {
|
2020-03-26 07:30:54 +00:00
|
|
|
x774_collisionRJointIds.push_back(uid);
|
2020-03-27 01:42:18 +00:00
|
|
|
} else if (IsArmClawCollider(colDesc.GetName(), "L_Palm_LCTR"sv, skLeftArmJointList.data(),
|
|
|
|
skLeftArmJointList.size())) {
|
2020-03-26 07:30:54 +00:00
|
|
|
x788_collisionLJointIds.push_back(uid);
|
|
|
|
}
|
|
|
|
if (uid != x770_collisionHeadId) {
|
|
|
|
act->SetDamageVulnerability(CDamageVulnerability::ReflectVulnerabilty());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
x730_collisionActorMgrHead->AddMaterial(
|
2020-03-26 07:30:54 +00:00
|
|
|
mgr, {EMaterialTypes::AIJoint, EMaterialTypes::CameraPassthrough, EMaterialTypes::Immovable});
|
|
|
|
}
|
|
|
|
|
2020-04-01 18:54:01 +00:00
|
|
|
const CJointCollisionDescription& description = x5d4_collisionActorMgr->GetCollisionDescFromIndex(0);
|
2020-05-07 23:13:43 +00:00
|
|
|
x79c_energyAttractorId = description.GetCollisionActorId();
|
|
|
|
if (TCastToPtr<CCollisionActor> act = mgr.ObjectById(x79c_energyAttractorId)) {
|
2020-03-26 07:30:54 +00:00
|
|
|
act->SetWeaponCollisionResponseType(EWeaponCollisionResponseTypes::None);
|
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
x5d4_collisionActorMgr->AddMaterial(mgr, {EMaterialTypes::AIJoint, EMaterialTypes::CameraPassthrough});
|
2020-03-26 07:30:54 +00:00
|
|
|
}
|
|
|
|
|
2020-03-27 01:42:18 +00:00
|
|
|
bool CElitePirate::IsArmClawCollider(std::string_view name, std::string_view locator, const SJointInfo* info,
|
2020-04-02 04:37:22 +00:00
|
|
|
size_t infoCount) const {
|
2020-03-26 07:30:54 +00:00
|
|
|
if (name == locator) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
for (size_t i = 0; i < infoCount; ++i) {
|
|
|
|
if (name == info[i].from) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CElitePirate::CreateGrenadeLauncher(CStateManager& mgr, TUniqueId uid) {
|
2020-03-31 00:40:38 +00:00
|
|
|
const CAnimationParameters& params = x5d8_data.GetLauncherAnimParams();
|
2020-03-26 07:30:54 +00:00
|
|
|
if (!params.GetACSFile().IsValid()) {
|
|
|
|
return;
|
|
|
|
}
|
2020-03-26 19:24:56 +00:00
|
|
|
CModelData mData(CAnimRes(params.GetACSFile(), params.GetCharacter(), GetModelData()->GetScale(),
|
|
|
|
params.GetInitialAnimation(), true));
|
2020-04-01 06:41:31 +00:00
|
|
|
const zeus::CAABox bounds = mData.GetBounds(GetTransform().getRotation());
|
|
|
|
mgr.AddObject(
|
|
|
|
new CGrenadeLauncher(uid, "Grenade Launcher", {GetAreaIdAlways(), CEntity::NullConnectionList}, GetTransform(),
|
|
|
|
std::move(mData), bounds, CHealthInfo(x5d8_data.GetLauncherHP(), 10.f), x56c_vulnerability,
|
|
|
|
x5d8_data.GetLauncherActParams(), GetUniqueId(), x5d8_data.GetGrenadeLauncherData(), 0.f));
|
2020-03-26 19:24:56 +00:00
|
|
|
}
|
|
|
|
|
2020-03-29 07:28:14 +00:00
|
|
|
void CElitePirate::ApplyDamageToHead(CStateManager& mgr, TUniqueId uid) {
|
2020-04-01 18:54:01 +00:00
|
|
|
if (!HasWeakPointHead()) {
|
2020-03-26 19:24:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-04-02 04:29:40 +00:00
|
|
|
if (const TCastToConstPtr<CWeapon> weapon = mgr.ObjectById(uid)) {
|
2020-03-26 19:24:56 +00:00
|
|
|
CDamageInfo damageInfo = weapon->GetDamageInfo();
|
|
|
|
damageInfo.SetRadius(0.f);
|
|
|
|
mgr.ApplyDamage(uid, x770_collisionHeadId, weapon->GetOwnerId(), damageInfo,
|
|
|
|
CMaterialFilter::MakeInclude({EMaterialTypes::Solid}), zeus::skZero3f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-29 07:28:14 +00:00
|
|
|
void CElitePirate::CreateEnergyAbsorb(CStateManager& mgr, const zeus::CTransform& xf) {
|
|
|
|
if (x7ac_energyAbsorbCooldown > 0.f) {
|
2020-03-26 19:24:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-03-29 07:28:14 +00:00
|
|
|
mgr.AddObject(new CExplosion(*x760_energyAbsorbDesc, mgr.AllocateUniqueId(), true,
|
|
|
|
{GetAreaIdAlways(), CEntity::NullConnectionList}, "Absorb energy Fx", xf, 0,
|
|
|
|
GetModelData()->GetScale(), zeus::skWhite));
|
2020-05-07 23:13:43 +00:00
|
|
|
CSfxManager::AddEmitter(x5d8_data.GetEnergyAbsorbSfxId(), GetTranslation(), zeus::skUp, false, false, 0x7f,
|
2020-03-31 00:40:38 +00:00
|
|
|
GetAreaIdAlways());
|
2020-03-29 07:28:14 +00:00
|
|
|
x7ac_energyAbsorbCooldown = 0.25f;
|
2020-03-26 19:24:56 +00:00
|
|
|
}
|
|
|
|
|
2020-04-01 18:54:01 +00:00
|
|
|
void CElitePirate::SetupLauncherHealthInfo(CStateManager& mgr, TUniqueId uid) {
|
2020-03-26 19:24:56 +00:00
|
|
|
const CHealthInfo* const health = HealthInfo(mgr);
|
2020-05-13 00:25:30 +00:00
|
|
|
if (uid == kInvalidUniqueId) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (const TCastToPtr<CCollisionActor> actor = mgr.ObjectById(uid)) {
|
|
|
|
auto* actHealth = actor->HealthInfo(mgr);
|
|
|
|
actHealth->SetHP(x5d8_data.GetLauncherHP());
|
|
|
|
actHealth->SetKnockbackResistance(health->GetKnockbackResistance());
|
|
|
|
actor->SetDamageVulnerability(x56c_vulnerability);
|
2020-03-26 19:24:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-01 18:54:01 +00:00
|
|
|
void CElitePirate::SetLauncherActive(CStateManager& mgr, bool val, TUniqueId uid) {
|
2020-03-26 19:24:56 +00:00
|
|
|
if (uid == kInvalidUniqueId) {
|
|
|
|
return;
|
|
|
|
}
|
2020-05-13 00:25:30 +00:00
|
|
|
if (auto* entity = mgr.ObjectById(uid)) {
|
2020-04-01 18:54:01 +00:00
|
|
|
mgr.SendScriptMsg(entity, GetUniqueId(), val ? EScriptObjectMessage::Start : EScriptObjectMessage::Stop);
|
2020-03-26 19:24:56 +00:00
|
|
|
}
|
2020-03-26 07:30:54 +00:00
|
|
|
}
|
2020-03-26 22:09:50 +00:00
|
|
|
|
2020-04-01 18:54:01 +00:00
|
|
|
zeus::CVector3f CElitePirate::GetLockOnPosition(const CActor* actor) const {
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CTransform targetTransform = actor->GetLocatorTransform("lockon_target_LCTR"sv);
|
2020-03-26 22:09:50 +00:00
|
|
|
return actor->GetTranslation() + actor->GetTransform().rotate(targetTransform.origin);
|
|
|
|
}
|
2020-03-27 06:47:34 +00:00
|
|
|
|
2020-04-01 18:54:01 +00:00
|
|
|
bool CElitePirate::CanKnockBack(const CDamageInfo& info) const {
|
2020-03-27 06:47:34 +00:00
|
|
|
return !x400_25_alive || info.GetWeaponMode().IsComboed() || info.GetWeaponMode().GetType() != EWeaponType::Plasma;
|
|
|
|
}
|
|
|
|
|
2020-04-01 18:54:01 +00:00
|
|
|
void CElitePirate::UpdateDestPos(CStateManager& mgr) {
|
|
|
|
x8b4_targetDestPos = GetTranslation();
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CVector3f playerPos = mgr.GetPlayer().GetTranslation();
|
|
|
|
const zeus::CVector3f dist = GetTranslation() - playerPos;
|
2020-03-27 06:47:34 +00:00
|
|
|
if (dist.canBeNormalized() && dist.magSquared() > x2fc_minAttackRange * x2fc_minAttackRange) {
|
2020-03-31 03:10:51 +00:00
|
|
|
x2e0_destPos = playerPos + (x2fc_minAttackRange * dist.normalized());
|
2020-04-01 18:54:01 +00:00
|
|
|
x8b4_targetDestPos = x2e0_destPos;
|
2020-03-27 06:47:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-01 18:54:01 +00:00
|
|
|
void CElitePirate::CheckAttackChance(CStateManager& mgr) {
|
2020-03-31 00:40:38 +00:00
|
|
|
if (mgr.GetActiveRandom()->Float() > x5d8_data.GetAttackChance()) {
|
2020-03-29 07:28:14 +00:00
|
|
|
x7b8_attackTimer = x308_attackTimeVariation * mgr.GetActiveRandom()->Float() + x304_averageAttackTime;
|
2020-03-27 06:47:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-31 03:10:51 +00:00
|
|
|
void CElitePirate::AttractProjectiles(CStateManager& mgr) {
|
|
|
|
if (!IsAlive()) {
|
|
|
|
return;
|
|
|
|
}
|
2020-05-07 23:13:43 +00:00
|
|
|
const TCastToConstPtr<CCollisionActor> actor = mgr.GetObjectById(x79c_energyAttractorId);
|
2020-03-31 03:10:51 +00:00
|
|
|
if (!actor) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-07 23:13:43 +00:00
|
|
|
float radius = x5d8_data.GetProjectileAttractionRadius();
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CVector3f actorPos = actor->GetTranslation();
|
|
|
|
const zeus::CVector3f pos = GetTranslation();
|
2020-03-31 03:10:51 +00:00
|
|
|
rstl::reserved_vector<TUniqueId, 1024> projNearList;
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CAABox aabb{pos - radius, pos + radius};
|
2020-03-31 03:10:51 +00:00
|
|
|
mgr.BuildNearList(projNearList, aabb, CMaterialFilter::MakeInclude({EMaterialTypes::Projectile}), nullptr);
|
|
|
|
if (projNearList.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rstl::reserved_vector<TUniqueId, 1024> charNearList;
|
|
|
|
mgr.BuildNearList(charNearList, aabb, CMaterialFilter::MakeInclude({EMaterialTypes::Character}), nullptr);
|
|
|
|
for (const TUniqueId projId : projNearList) {
|
|
|
|
TCastToPtr<CGameProjectile> projectile = mgr.ObjectById(projId);
|
|
|
|
if (!projectile || projectile->GetType() == EWeaponType::Missile ||
|
|
|
|
projectile->GetOwnerId() != mgr.GetPlayer().GetUniqueId() ||
|
|
|
|
projectile->GetAreaIdAlways() != GetAreaIdAlways()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CVector3f projectilePos = projectile->GetTranslation();
|
2020-03-31 03:10:51 +00:00
|
|
|
const zeus::CVector3f actorProjDist = actorPos - projectilePos;
|
|
|
|
if (GetTransform().frontVector().dot(actorProjDist) < 0.f) {
|
|
|
|
const zeus::CVector3f projectileDir = projectilePos - projectile->GetPreviousPos();
|
|
|
|
if (projectileDir.canBeNormalized() && IsClosestEnergyAttractor(mgr, charNearList, projectilePos)) {
|
2020-04-02 04:29:40 +00:00
|
|
|
const float actorProjMag = actorProjDist.magnitude();
|
2020-03-31 03:10:51 +00:00
|
|
|
const zeus::CVector3f b = projectilePos + ((0.5f * actorProjMag) * projectileDir.normalized());
|
|
|
|
const zeus::CVector3f c = actorPos + zeus::CVector3f{0.f, 0.f, 0.4f * 0.4f * actorProjMag};
|
|
|
|
const zeus::CVector3f p1 = zeus::getBezierPoint(projectilePos, b, c, actorPos, 0.333f);
|
|
|
|
const zeus::CVector3f p2 = zeus::getBezierPoint(projectilePos, b, c, actorPos, 0.666f);
|
|
|
|
|
2020-04-02 04:29:40 +00:00
|
|
|
const float magAdd = (p2 - p1).magnitude() + (p1 - projectilePos).magnitude() + (actorPos - p2).magnitude();
|
2020-03-31 03:10:51 +00:00
|
|
|
const zeus::CVector3f p3 =
|
|
|
|
zeus::getBezierPoint(projectilePos, b, c, actorPos, projectileDir.magnitude() / magAdd);
|
|
|
|
|
|
|
|
const zeus::CVector3f look = p3 - projectilePos;
|
|
|
|
if (look.canBeNormalized()) {
|
|
|
|
zeus::CTransform xf = zeus::lookAt(zeus::skZero3f, look);
|
|
|
|
xf.orthonormalize();
|
|
|
|
CProjectileWeapon& weapon = projectile->ProjectileWeapon();
|
|
|
|
weapon.SetWorldSpaceOrientation(xf);
|
|
|
|
const zeus::CVector3f scaledVelocity = 0.8f * weapon.GetVelocity().normalized();
|
|
|
|
weapon.SetVelocity(weapon.GetVelocity() * 0.39999998f + (scaledVelocity * 0.6f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetShotAt(true, mgr);
|
|
|
|
}
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
|
|
|
|
2020-04-01 18:54:01 +00:00
|
|
|
void CElitePirate::UpdateAbsorbBodyState(CStateManager& mgr, float dt) {
|
2020-03-31 00:40:38 +00:00
|
|
|
if (!x988_27_shotAt || x450_bodyController->IsFrozen()) {
|
2020-03-29 07:28:14 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
x7c4_absorbUpdateTimer += dt;
|
|
|
|
if (x7c4_absorbUpdateTimer < 3.f) {
|
2020-03-29 07:28:14 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (x450_bodyController->GetCurrentStateId() != pas::EAnimationState::Turn &&
|
|
|
|
x450_bodyController->GetBodyStateInfo().GetCurrentState()->IsMoving()) {
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(
|
|
|
|
CBCAdditiveReactionCmd(pas::EAdditiveReactionType::Six, 1.f, false));
|
|
|
|
} else {
|
|
|
|
bool b = false;
|
2020-04-01 18:54:01 +00:00
|
|
|
if (HasWeakPointHead()) {
|
2020-04-02 04:22:45 +00:00
|
|
|
if (const TCastToConstPtr<CCollisionActor> actor = mgr.GetObjectById(x770_collisionHeadId)) {
|
|
|
|
const float z = actor->GetTranslation().z();
|
2020-03-29 07:28:14 +00:00
|
|
|
b = z - 0.5f * (z - GetTranslation().z()) <= mgr.GetPlayer().GetTranslation().z();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b = b || TooClose(mgr, 0.f);
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(
|
|
|
|
CBCAdditiveReactionCmd(b ? pas::EAdditiveReactionType::Seven : pas::EAdditiveReactionType::Five, 1.f, false));
|
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
x7c4_absorbUpdateTimer = 0.f;
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
|
|
|
|
2020-04-02 04:37:22 +00:00
|
|
|
bool CElitePirate::IsAttractingEnergy() const {
|
2020-03-31 03:10:51 +00:00
|
|
|
if (x450_bodyController->GetLocomotionType() == pas::ELocomotionType::Crouch) {
|
|
|
|
const auto state = x450_bodyController->GetCurrentStateId();
|
|
|
|
return state == pas::EAnimationState::Locomotion || state == pas::EAnimationState::Turn;
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
2020-03-31 03:10:51 +00:00
|
|
|
return false;
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
|
|
|
|
2020-03-31 03:10:51 +00:00
|
|
|
void CElitePirate::UpdateTimers(float dt) {
|
2020-03-29 07:28:14 +00:00
|
|
|
if (x7b8_attackTimer > 0.f) {
|
|
|
|
x7b8_attackTimer -= dt;
|
|
|
|
}
|
|
|
|
if (x7ac_energyAbsorbCooldown > 0.f) {
|
|
|
|
x7ac_energyAbsorbCooldown -= dt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-01 18:54:01 +00:00
|
|
|
void CElitePirate::UpdatePositionHistory() {
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CVector3f pos = GetTranslation();
|
2020-03-29 07:28:14 +00:00
|
|
|
if (x7d0_pathFindSearch.OnPath(pos) == CPathFindSearch::EResult::Success) {
|
2020-05-07 23:13:43 +00:00
|
|
|
x8c0_positionHistory.Clear();
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
2020-05-07 23:13:43 +00:00
|
|
|
x8c0_positionHistory.AddValue(pos);
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
|
|
|
|
2020-03-31 03:10:51 +00:00
|
|
|
void CElitePirate::UpdateActorTransform(CStateManager& mgr, TUniqueId& uid, std::string_view name) {
|
2020-03-29 07:28:14 +00:00
|
|
|
if (uid == kInvalidUniqueId) {
|
|
|
|
return;
|
|
|
|
}
|
2020-03-30 23:31:14 +00:00
|
|
|
auto* actor = static_cast<CActor*>(mgr.ObjectById(uid));
|
2020-03-29 07:28:14 +00:00
|
|
|
if (actor == nullptr) {
|
|
|
|
uid = kInvalidUniqueId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
actor->SetTransform(GetLctrTransform(name));
|
|
|
|
}
|
|
|
|
|
2020-04-01 18:54:01 +00:00
|
|
|
void CElitePirate::UpdateHealthInfo(CStateManager& mgr) {
|
2020-04-02 04:29:40 +00:00
|
|
|
const float hp = HealthInfo(mgr)->GetHP();
|
2020-04-01 18:54:01 +00:00
|
|
|
if (HasWeakPointHead()) {
|
2020-03-29 07:28:14 +00:00
|
|
|
if (TCastToPtr<CCollisionActor> actor = mgr.ObjectById(x770_collisionHeadId)) {
|
2020-04-02 04:29:40 +00:00
|
|
|
const float headHp = actor->HealthInfo(mgr)->GetHP();
|
2020-03-29 07:28:14 +00:00
|
|
|
HealthInfo(mgr)->SetHP(hp - (hp - headHp));
|
2020-05-07 23:13:43 +00:00
|
|
|
*actor->HealthInfo(mgr) = *HealthInfo(mgr);
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (HealthInfo(mgr)->GetHP() <= 0.f) {
|
|
|
|
Death(mgr, zeus::skZero3f, EScriptObjectState::DeathRattle);
|
|
|
|
RemoveMaterial(EMaterialTypes::Orbit, EMaterialTypes::Target, mgr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-31 03:10:51 +00:00
|
|
|
void CElitePirate::ExtendTouchBounds(const CStateManager& mgr, const rstl::reserved_vector<TUniqueId, 7>& uids,
|
|
|
|
const zeus::CVector3f& vec) const {
|
2020-03-29 07:28:14 +00:00
|
|
|
for (const TUniqueId uid : uids) {
|
|
|
|
if (TCastToPtr<CCollisionActor> actor = mgr.ObjectById(uid)) {
|
|
|
|
actor->SetExtendedTouchBounds(vec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CElitePirate::ShouldFireFromLauncher(CStateManager& mgr, TUniqueId launcherId) {
|
2020-03-30 23:31:14 +00:00
|
|
|
if (x7b8_attackTimer > 0.f || launcherId == kInvalidUniqueId) {
|
2020-03-30 03:45:55 +00:00
|
|
|
return false;
|
2020-03-30 23:31:14 +00:00
|
|
|
}
|
|
|
|
const auto* launcher = static_cast<const CActor*>(mgr.GetObjectById(launcherId));
|
|
|
|
if (launcher == nullptr) {
|
2020-03-30 03:45:55 +00:00
|
|
|
return false;
|
2020-03-30 23:31:14 +00:00
|
|
|
}
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CVector3f aim = mgr.GetPlayer().GetAimPosition(mgr, 0.f);
|
2020-03-30 23:31:14 +00:00
|
|
|
if (x300_maxAttackRange * x300_maxAttackRange > (aim - GetTranslation()).magSquared() || ShouldTurn(mgr, 0.f)) {
|
2020-03-30 03:45:55 +00:00
|
|
|
return false;
|
2020-03-30 23:31:14 +00:00
|
|
|
}
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CVector3f origin = GetLockOnPosition(launcher);
|
2020-03-30 23:31:14 +00:00
|
|
|
if (IsPatternObstructed(mgr, origin, aim)) {
|
2020-03-30 03:45:55 +00:00
|
|
|
return false;
|
2020-03-30 23:31:14 +00:00
|
|
|
}
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CVector3f target = CGrenadeLauncher::GrenadeTarget(mgr);
|
2020-03-31 00:40:38 +00:00
|
|
|
float angleOut = x5d8_data.GetGrenadeTrajectoryInfo().GetAngleMin();
|
|
|
|
float velocityOut = x5d8_data.GetGrenadeTrajectoryInfo().GetVelocityMin();
|
|
|
|
CGrenadeLauncher::CalculateGrenadeTrajectory(target, origin, x5d8_data.GetGrenadeTrajectoryInfo(), angleOut,
|
|
|
|
velocityOut);
|
2020-04-02 04:22:45 +00:00
|
|
|
const zeus::CVector3f rot = GetTransform().rotate({0.f, std::cos(angleOut), std::sin(angleOut)});
|
2020-03-30 03:45:55 +00:00
|
|
|
return !CPatterned::IsPatternObstructed(mgr, target, target + (7.5f * rot));
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
|
|
|
|
2020-03-31 03:10:51 +00:00
|
|
|
bool CElitePirate::ShouldCallForBackupFromLauncher(const CStateManager& mgr, TUniqueId uid) const {
|
2020-05-07 23:13:43 +00:00
|
|
|
if (x988_30_calledForBackup || uid != kInvalidUniqueId || !x5d8_data.CanCallForBackup()) {
|
2020-04-01 18:54:01 +00:00
|
|
|
return false;
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
2020-04-01 18:54:01 +00:00
|
|
|
return x7a8_pathShaggedTime >= 3.f;
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
|
|
|
|
2020-03-31 03:10:51 +00:00
|
|
|
bool CElitePirate::IsClosestEnergyAttractor(const CStateManager& mgr,
|
|
|
|
const rstl::reserved_vector<TUniqueId, 1024>& charNearList,
|
|
|
|
const zeus::CVector3f& projectilePos) const {
|
2020-04-02 04:22:45 +00:00
|
|
|
const float distance = (projectilePos - GetTranslation()).magSquared();
|
2020-03-31 03:10:51 +00:00
|
|
|
for (const auto id : charNearList) {
|
2020-04-02 04:22:45 +00:00
|
|
|
if (const TCastToConstPtr<CPatterned> actor = mgr.GetObjectById(id)) {
|
2020-03-31 03:10:51 +00:00
|
|
|
if (actor->GetUniqueId() != GetUniqueId() && actor->IsEnergyAttractor() &&
|
|
|
|
(projectilePos - actor->GetTranslation()).magSquared() < distance) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-05-07 23:13:43 +00:00
|
|
|
zeus::CVector3f CElitePirate::SPositionHistory::GetValue(const zeus::CVector3f& pos, const zeus::CVector3f& face) {
|
|
|
|
while (!x4_values.empty()) {
|
|
|
|
const zeus::CVector3f v = x4_values.back() - pos;
|
|
|
|
if (v.dot(face) > 0.f && v.isMagnitudeSafe()) {
|
2020-03-27 06:47:34 +00:00
|
|
|
return v.normalized();
|
|
|
|
}
|
2020-05-07 23:13:43 +00:00
|
|
|
x4_values.pop_back();
|
2020-03-27 06:47:34 +00:00
|
|
|
}
|
|
|
|
return zeus::skZero3f;
|
|
|
|
}
|
2020-03-29 07:28:14 +00:00
|
|
|
|
2020-05-07 23:13:43 +00:00
|
|
|
void CElitePirate::SPositionHistory::AddValue(const zeus::CVector3f& pos) {
|
|
|
|
if (x4_values.size() > 15) {
|
2020-03-29 07:28:14 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-05-07 23:13:43 +00:00
|
|
|
if (x4_values.empty()) {
|
|
|
|
x4_values.emplace_back(pos);
|
2020-03-29 07:28:14 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-05-07 23:13:43 +00:00
|
|
|
if (x4_values.back().magSquared() > x0_magSquared) {
|
|
|
|
x4_values.emplace_back(pos);
|
2020-03-29 07:28:14 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde::MP1
|