2018-10-11 22:57:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-03-09 02:52:21 +00:00
|
|
|
#include "Runtime/Character/CBoneTracking.hpp"
|
2020-03-31 18:17:47 +00:00
|
|
|
#include "Runtime/Collision/CCollisionActorManager.hpp"
|
2020-03-26 07:30:54 +00:00
|
|
|
#include "Runtime/Collision/CJointCollisionDescription.hpp"
|
2020-03-29 07:28:14 +00:00
|
|
|
#include "Runtime/MP1/World/CGrenadeLauncher.hpp"
|
2020-03-26 22:09:50 +00:00
|
|
|
#include "Runtime/MP1/World/CShockWave.hpp"
|
2019-09-28 02:53:03 +00:00
|
|
|
#include "Runtime/World/CActorParameters.hpp"
|
|
|
|
#include "Runtime/World/CAnimationParameters.hpp"
|
2020-03-09 02:52:21 +00:00
|
|
|
#include "Runtime/World/CPathFindSearch.hpp"
|
2020-03-26 22:09:50 +00:00
|
|
|
#include "Runtime/World/CPatterned.hpp"
|
2018-10-11 22:57:05 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce::MP1 {
|
2018-12-08 05:30:43 +00:00
|
|
|
class CElitePirateData {
|
2020-03-31 00:40:38 +00:00
|
|
|
private:
|
2020-03-29 07:28:14 +00:00
|
|
|
float x0_tauntInterval;
|
|
|
|
float x4_tauntVariance;
|
2018-12-08 05:30:43 +00:00
|
|
|
float x8_;
|
|
|
|
float xc_;
|
2020-03-31 00:40:38 +00:00
|
|
|
float x10_attackChance;
|
|
|
|
float x14_shotAtTime;
|
|
|
|
float x18_shotAtTimeVariance;
|
2020-05-07 23:13:43 +00:00
|
|
|
float x1c_projectileAttractionRadius;
|
|
|
|
CAssetId x20_energyAbsorbParticleDescId;
|
|
|
|
u16 x24_energyAbsorbSfxId;
|
2020-03-26 19:24:56 +00:00
|
|
|
CActorParameters x28_launcherActParams;
|
|
|
|
CAnimationParameters x90_launcherAnimParams;
|
2020-05-07 23:13:43 +00:00
|
|
|
CAssetId x9c_launcherParticleGenDescId;
|
|
|
|
u16 xa0_launcherSfxId;
|
|
|
|
CAssetId xa4_grenadeModelId;
|
|
|
|
CDamageInfo xa8_grenadeDamageInfo;
|
2020-03-29 07:28:14 +00:00
|
|
|
float xc4_launcherHp;
|
2020-05-07 23:13:43 +00:00
|
|
|
CAssetId xc8_grenadeElementGenDescId1;
|
|
|
|
CAssetId xcc_grenadeElementGenDescId2;
|
|
|
|
CAssetId xd0_grenadeElementGenDescId3;
|
|
|
|
CAssetId xd4_grenadeElementGenDescId4;
|
|
|
|
SGrenadeVelocityInfo xd8_grenadeVelocityInfo;
|
|
|
|
SGrenadeTrajectoryInfo xe0_grenadeTrajectoryInfo;
|
2020-03-30 07:05:16 +00:00
|
|
|
u32 xf0_grenadeNumBounces;
|
2020-05-07 23:13:43 +00:00
|
|
|
u16 xf4_grenadeBounceSfxId;
|
|
|
|
u16 xf6_grenadeExplodeSfxId;
|
|
|
|
CAssetId xf8_shockwaveParticleDescId;
|
|
|
|
CDamageInfo xfc_shockwaveDamageInfo;
|
|
|
|
CAssetId x118_shockwaveWeaponDescId;
|
|
|
|
u16 x11c_shockwaveElectrocuteSfxId;
|
|
|
|
bool x11e_canCallForBackup;
|
|
|
|
bool x11f_fastWhenAttractingEnergy;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-03-31 00:40:38 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CElitePirateData(CInputStream&, u32 propCount);
|
2020-03-09 02:52:21 +00:00
|
|
|
|
2020-03-31 00:40:38 +00:00
|
|
|
[[nodiscard]] float GetTauntInterval() const { return x0_tauntInterval; }
|
|
|
|
[[nodiscard]] float GetTauntVariance() const { return x4_tauntVariance; }
|
|
|
|
[[nodiscard]] float GetAttackChance() const { return x10_attackChance; }
|
|
|
|
[[nodiscard]] float GetShotAtTime() const { return x14_shotAtTime; }
|
|
|
|
[[nodiscard]] float GetShotAtTimeVariance() const { return x18_shotAtTimeVariance; }
|
2020-05-07 23:13:43 +00:00
|
|
|
[[nodiscard]] float GetProjectileAttractionRadius() const { return x1c_projectileAttractionRadius; }
|
|
|
|
[[nodiscard]] CAssetId GetEnergyAbsorbParticleDescId() const { return x20_energyAbsorbParticleDescId; }
|
|
|
|
[[nodiscard]] u16 GetEnergyAbsorbSfxId() const { return x24_energyAbsorbSfxId; }
|
2020-03-31 00:40:38 +00:00
|
|
|
[[nodiscard]] const CActorParameters& GetLauncherActParams() const { return x28_launcherActParams; }
|
|
|
|
[[nodiscard]] const CAnimationParameters& GetLauncherAnimParams() const { return x90_launcherAnimParams; }
|
|
|
|
[[nodiscard]] float GetLauncherHP() const { return xc4_launcherHp; }
|
2020-05-07 23:13:43 +00:00
|
|
|
[[nodiscard]] const SGrenadeTrajectoryInfo& GetGrenadeTrajectoryInfo() const { return xe0_grenadeTrajectoryInfo; }
|
|
|
|
[[nodiscard]] CAssetId GetShockwaveParticleDescId() const { return xf8_shockwaveParticleDescId; }
|
|
|
|
[[nodiscard]] const CDamageInfo& GetShockwaveDamageInfo() const { return xfc_shockwaveDamageInfo; }
|
|
|
|
[[nodiscard]] CAssetId GetShockwaveWeaponDescId() const { return x118_shockwaveWeaponDescId; }
|
|
|
|
[[nodiscard]] u16 GetShockwaveElectrocuteSfxId() const { return x11c_shockwaveElectrocuteSfxId; }
|
|
|
|
[[nodiscard]] bool CanCallForBackup() const { return x11e_canCallForBackup; }
|
|
|
|
[[nodiscard]] bool IsFastWhenAttractingEnergy() const { return x11f_fastWhenAttractingEnergy; }
|
2020-03-31 00:40:38 +00:00
|
|
|
|
|
|
|
[[nodiscard]] SBouncyGrenadeData GetBouncyGrenadeData() const {
|
2020-05-07 23:13:43 +00:00
|
|
|
return {
|
|
|
|
xd8_grenadeVelocityInfo, xa8_grenadeDamageInfo, xc8_grenadeElementGenDescId1,
|
|
|
|
xcc_grenadeElementGenDescId2, xd0_grenadeElementGenDescId3, xd4_grenadeElementGenDescId4,
|
|
|
|
xf0_grenadeNumBounces, xf4_grenadeBounceSfxId, xf6_grenadeExplodeSfxId,
|
|
|
|
};
|
2020-03-31 00:40:38 +00:00
|
|
|
}
|
|
|
|
[[nodiscard]] SGrenadeLauncherData GetGrenadeLauncherData() const {
|
2020-05-07 23:13:43 +00:00
|
|
|
return {
|
|
|
|
GetBouncyGrenadeData(), xa4_grenadeModelId, x9c_launcherParticleGenDescId,
|
|
|
|
xa0_launcherSfxId, xe0_grenadeTrajectoryInfo,
|
|
|
|
};
|
2020-03-31 00:40:38 +00:00
|
|
|
}
|
2018-10-11 22:57:05 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CElitePirate : public CPatterned {
|
2020-04-02 06:15:23 +00:00
|
|
|
protected:
|
|
|
|
enum class EState {
|
|
|
|
Invalid = -1,
|
|
|
|
Zero = 0,
|
|
|
|
One = 1,
|
|
|
|
Two = 2,
|
|
|
|
Over = 3,
|
|
|
|
};
|
|
|
|
|
2020-03-31 00:40:38 +00:00
|
|
|
private:
|
2020-05-07 23:13:43 +00:00
|
|
|
struct SPositionHistory {
|
2020-03-31 00:40:38 +00:00
|
|
|
private:
|
2020-05-07 23:13:43 +00:00
|
|
|
float x0_magSquared;
|
|
|
|
rstl::reserved_vector<zeus::CVector3f, 16> x4_values;
|
2020-03-31 00:40:38 +00:00
|
|
|
|
|
|
|
public:
|
2020-05-07 23:13:43 +00:00
|
|
|
explicit SPositionHistory(float mag) : x0_magSquared(mag * mag) {}
|
|
|
|
zeus::CVector3f GetValue(const zeus::CVector3f& pos, const zeus::CVector3f& face);
|
|
|
|
void AddValue(const zeus::CVector3f& pos);
|
|
|
|
void Clear() { x4_values.clear(); }
|
2020-03-09 02:52:21 +00:00
|
|
|
};
|
|
|
|
|
2020-04-01 18:54:01 +00:00
|
|
|
EState x568_state = EState::Invalid;
|
2020-03-26 07:30:54 +00:00
|
|
|
CDamageVulnerability x56c_vulnerability;
|
2020-04-01 18:54:01 +00:00
|
|
|
std::unique_ptr<CCollisionActorManager> x5d4_collisionActorMgr;
|
2020-03-26 07:30:54 +00:00
|
|
|
CElitePirateData x5d8_data;
|
|
|
|
CBoneTracking x6f8_boneTracking;
|
2020-04-01 18:54:01 +00:00
|
|
|
std::unique_ptr<CCollisionActorManager> x730_collisionActorMgrHead;
|
2020-03-31 00:40:38 +00:00
|
|
|
// s32 x734_;
|
2020-04-01 18:54:01 +00:00
|
|
|
CCollidableAABox x738_collisionAabb;
|
2020-03-29 07:28:14 +00:00
|
|
|
std::optional<TLockedToken<CGenDescription>> x760_energyAbsorbDesc;
|
2020-03-26 07:30:54 +00:00
|
|
|
TUniqueId x770_collisionHeadId = kInvalidUniqueId;
|
2020-03-26 19:24:56 +00:00
|
|
|
TUniqueId x772_launcherId = kInvalidUniqueId;
|
2020-03-27 01:42:18 +00:00
|
|
|
rstl::reserved_vector<TUniqueId, 7> x774_collisionRJointIds;
|
|
|
|
rstl::reserved_vector<TUniqueId, 7> x788_collisionLJointIds;
|
2020-05-07 23:13:43 +00:00
|
|
|
TUniqueId x79c_energyAttractorId = kInvalidUniqueId;
|
2020-03-31 00:40:38 +00:00
|
|
|
float x7a0_initialSpeed;
|
2020-04-01 18:54:01 +00:00
|
|
|
float x7a4_steeringSpeed = 1.f;
|
|
|
|
float x7a8_pathShaggedTime = 0.f;
|
2020-03-29 07:28:14 +00:00
|
|
|
float x7ac_energyAbsorbCooldown = 0.f;
|
2020-03-09 02:52:21 +00:00
|
|
|
float x7b0_ = 1.f;
|
2020-03-26 19:24:56 +00:00
|
|
|
float x7b4_hp = 0.f;
|
2020-03-29 07:28:14 +00:00
|
|
|
float x7b8_attackTimer = 0.f;
|
|
|
|
float x7bc_tauntTimer = 0.f;
|
2020-03-31 00:40:38 +00:00
|
|
|
float x7c0_shotAtTimer = 0.f;
|
2020-04-01 18:54:01 +00:00
|
|
|
float x7c4_absorbUpdateTimer = 0.f;
|
2020-03-29 07:28:14 +00:00
|
|
|
s32 x7c8_currAnimId = -1;
|
2020-04-01 07:39:05 +00:00
|
|
|
u32 x7cc_activeMaterialSet = 0;
|
2020-03-26 07:30:54 +00:00
|
|
|
CPathFindSearch x7d0_pathFindSearch;
|
2020-04-01 18:54:01 +00:00
|
|
|
zeus::CVector3f x8b4_targetDestPos;
|
2020-05-07 23:13:43 +00:00
|
|
|
SPositionHistory x8c0_positionHistory{5.0f};
|
2020-04-21 07:22:41 +00:00
|
|
|
bool x988_24_damageOn : 1 = false;
|
|
|
|
bool x988_25_attackingRightClaw : 1 = false;
|
|
|
|
bool x988_26_attackingLeftClaw : 1 = false;
|
|
|
|
bool x988_27_shotAt : 1 = false;
|
|
|
|
bool x988_28_alert : 1 = false;
|
|
|
|
bool x988_29_shockWaveAnim : 1 = false;
|
|
|
|
bool x988_30_calledForBackup : 1 = false;
|
|
|
|
bool x988_31_running : 1 = false;
|
|
|
|
bool x989_24_onPath : 1 = false;
|
2020-03-09 02:52:21 +00:00
|
|
|
|
2018-10-11 22:57:05 +00:00
|
|
|
public:
|
2020-08-23 19:03:33 +00:00
|
|
|
DEFINE_PATTERNED(ElitePirate);
|
2018-10-11 22:57:05 +00:00
|
|
|
|
2020-03-09 02:52:21 +00:00
|
|
|
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);
|
2020-03-09 02:52:21 +00:00
|
|
|
|
|
|
|
void Accept(IVisitor& visitor) override;
|
|
|
|
void Think(float dt, CStateManager& mgr) override;
|
|
|
|
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override;
|
|
|
|
void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override;
|
|
|
|
const CDamageVulnerability* GetDamageVulnerability() const override;
|
|
|
|
const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f& pos, const zeus::CVector3f& dir,
|
|
|
|
const CDamageInfo& dInfo) const override;
|
|
|
|
zeus::CVector3f GetOrbitPosition(const CStateManager& mgr) const override;
|
|
|
|
zeus::CVector3f GetAimPosition(const CStateManager& mgr, float) const override;
|
|
|
|
void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) override;
|
|
|
|
const CCollisionPrimitive* GetCollisionPrimitive() const override;
|
2020-03-29 07:28:14 +00:00
|
|
|
void KnockBack(const zeus::CVector3f&, CStateManager& mgr, const CDamageInfo& info, EKnockBackType type,
|
|
|
|
bool inDeferred, float magnitude) override;
|
2020-03-09 02:52:21 +00:00
|
|
|
void TakeDamage(const zeus::CVector3f&, float arg) override;
|
2020-03-29 07:28:14 +00:00
|
|
|
void Patrol(CStateManager& mgr, EStateMsg msg, float dt) override;
|
|
|
|
void PathFind(CStateManager& mgr, EStateMsg msg, float dt) override;
|
|
|
|
void TargetPatrol(CStateManager& mgr, EStateMsg msg, float dt) override;
|
|
|
|
void Halt(CStateManager& mgr, EStateMsg msg, float dt) override;
|
|
|
|
void Run(CStateManager& mgr, EStateMsg msg, float dt) override;
|
|
|
|
void Generate(CStateManager& mgr, EStateMsg msg, float dt) override;
|
|
|
|
void Attack(CStateManager& mgr, EStateMsg msg, float dt) override;
|
|
|
|
void Taunt(CStateManager& mgr, EStateMsg msg, float dt) override;
|
|
|
|
void ProjectileAttack(CStateManager& mgr, EStateMsg msg, float dt) override;
|
2020-03-30 03:45:55 +00:00
|
|
|
void Cover(CStateManager& mgr, EStateMsg msg, float dt) override;
|
2020-03-29 07:28:14 +00:00
|
|
|
void SpecialAttack(CStateManager& mgr, EStateMsg msg, float dt) override;
|
|
|
|
void CallForBackup(CStateManager& mgr, EStateMsg msg, float dt) override;
|
|
|
|
bool TooClose(CStateManager& mgr, float arg) override;
|
|
|
|
bool InDetectionRange(CStateManager& mgr, float arg) override;
|
|
|
|
bool SpotPlayer(CStateManager& mgr, float arg) override;
|
|
|
|
bool AnimOver(CStateManager& mgr, float arg) override;
|
|
|
|
bool ShouldAttack(CStateManager& mgr, float arg) override;
|
|
|
|
bool InPosition(CStateManager& mgr, float arg) override;
|
|
|
|
bool ShouldTurn(CStateManager& mgr, float arg) override;
|
|
|
|
bool AggressionCheck(CStateManager& mgr, float arg) override;
|
|
|
|
bool ShouldTaunt(CStateManager& mgr, float arg) override;
|
|
|
|
bool ShouldFire(CStateManager& mgr, float arg) override;
|
|
|
|
bool ShotAt(CStateManager& mgr, float arg) override;
|
|
|
|
bool ShouldSpecialAttack(CStateManager& mgr, float arg) override;
|
|
|
|
bool ShouldCallForBackup(CStateManager& mgr, float arg) override;
|
2020-03-09 02:52:21 +00:00
|
|
|
CPathFindSearch* GetSearchPath() override;
|
2020-04-01 18:54:01 +00:00
|
|
|
virtual bool HasWeakPointHead() const { return true; }
|
|
|
|
virtual bool IsElitePirate() const { return true; }
|
2020-03-27 01:42:18 +00:00
|
|
|
virtual void SetupHealthInfo(CStateManager& mgr);
|
2020-04-01 18:54:01 +00:00
|
|
|
virtual void SetLaunchersActive(CStateManager& mgr, bool val);
|
2023-06-21 20:22:49 +00:00
|
|
|
virtual CShockWaveInfo GetShockWaveData() const {
|
2020-05-07 23:13:43 +00:00
|
|
|
return {x5d8_data.GetShockwaveParticleDescId(), x5d8_data.GetShockwaveDamageInfo(), 16.5217f,
|
|
|
|
x5d8_data.GetShockwaveWeaponDescId(), x5d8_data.GetShockwaveElectrocuteSfxId()};
|
2020-03-26 07:30:54 +00:00
|
|
|
}
|
|
|
|
|
2020-04-02 06:15:23 +00:00
|
|
|
protected:
|
2020-03-31 00:40:38 +00:00
|
|
|
void SetShotAt(bool val, CStateManager& mgr);
|
2020-04-02 21:24:59 +00:00
|
|
|
void CreateGrenadeLauncher(CStateManager& mgr, TUniqueId uid);
|
|
|
|
zeus::CVector3f GetLockOnPosition(const CActor* actor) const;
|
|
|
|
bool ShouldFireFromLauncher(CStateManager& mgr, TUniqueId launcherId);
|
|
|
|
bool ShouldCallForBackupFromLauncher(const CStateManager& mgr, TUniqueId uid) const;
|
|
|
|
void SetupLauncherHealthInfo(CStateManager& mgr, TUniqueId uid);
|
|
|
|
void SetLauncherActive(CStateManager& mgr, bool val, TUniqueId uid);
|
|
|
|
void SetupPathFindSearch();
|
|
|
|
void UpdateActorTransform(CStateManager& mgr, TUniqueId& uid, std::string_view name);
|
|
|
|
|
|
|
|
const CElitePirateData& GetData() const { return x5d8_data; }
|
|
|
|
EState GetState() const { return x568_state; }
|
|
|
|
void SetState(EState state) { x568_state = state; }
|
|
|
|
TUniqueId GetLauncherId() const { return x772_launcherId; }
|
|
|
|
void SetAlert(bool val) { x988_28_alert = val; }
|
2020-04-04 07:38:32 +00:00
|
|
|
const CCollisionActorManager& GetCollisionActorManager() const { return *x5d4_collisionActorMgr; }
|
2020-04-02 21:24:59 +00:00
|
|
|
|
|
|
|
private:
|
2020-03-26 07:30:54 +00:00
|
|
|
void AddSphereCollisionList(const SSphereJointInfo* joints, size_t count,
|
|
|
|
std::vector<CJointCollisionDescription>& outJoints) const;
|
|
|
|
void AddCollisionList(const SJointInfo* joints, size_t count,
|
|
|
|
std::vector<CJointCollisionDescription>& outJoints) const;
|
2020-03-27 01:42:18 +00:00
|
|
|
void SetupCollisionManager(CStateManager& mgr);
|
|
|
|
void SetupCollisionActorInfo(CStateManager& mgr);
|
2020-03-29 07:28:14 +00:00
|
|
|
void ApplyDamageToHead(CStateManager& mgr, TUniqueId uid);
|
|
|
|
void CreateEnergyAbsorb(CStateManager& mgr, const zeus::CTransform& xf);
|
2020-04-01 18:54:01 +00:00
|
|
|
bool CanKnockBack(const CDamageInfo& info) const;
|
|
|
|
void UpdateDestPos(CStateManager& mgr);
|
|
|
|
void CheckAttackChance(CStateManager& mgr);
|
2020-03-31 03:10:51 +00:00
|
|
|
void AttractProjectiles(CStateManager& mgr);
|
2020-04-01 18:54:01 +00:00
|
|
|
void UpdateAbsorbBodyState(CStateManager& mgr, float dt);
|
2020-04-02 05:55:35 +00:00
|
|
|
bool IsAttractingEnergy() const;
|
2020-03-31 03:10:51 +00:00
|
|
|
void UpdateTimers(float dt);
|
2020-04-01 18:54:01 +00:00
|
|
|
void UpdatePositionHistory();
|
|
|
|
void UpdateHealthInfo(CStateManager& mgr);
|
2020-03-31 03:10:51 +00:00
|
|
|
void ExtendTouchBounds(const CStateManager& mgr, const rstl::reserved_vector<TUniqueId, 7>& uids,
|
|
|
|
const zeus::CVector3f& vec) const;
|
2021-06-07 00:07:45 +00:00
|
|
|
bool IsClosestEnergyAttractor(const CStateManager& mgr, const EntityList& charNearList,
|
2020-03-31 03:10:51 +00:00
|
|
|
const zeus::CVector3f& projectilePos) const;
|
2020-05-13 03:51:03 +00:00
|
|
|
void ShakeCamera(CStateManager& mgr);
|
2018-10-11 22:57:05 +00:00
|
|
|
};
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce::MP1
|