2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2017-07-05 18:34:12 +00:00
|
|
|
|
2019-09-28 02:53:03 +00:00
|
|
|
#include <optional>
|
|
|
|
#include <string_view>
|
|
|
|
|
2020-05-08 08:19:51 +00:00
|
|
|
#include "Runtime/Collision/CCollidableSphere.hpp"
|
|
|
|
#include "Runtime/World/CActorParameters.hpp"
|
2019-09-28 02:53:03 +00:00
|
|
|
#include "Runtime/World/CAnimationParameters.hpp"
|
2020-05-08 08:19:51 +00:00
|
|
|
#include "Runtime/World/CPathFindSearch.hpp"
|
2019-09-28 02:53:03 +00:00
|
|
|
#include "Runtime/World/CPatterned.hpp"
|
2020-05-08 08:19:51 +00:00
|
|
|
#include "Runtime/World/CPatternedInfo.hpp"
|
|
|
|
#include "Runtime/MP1/World/CSpacePirate.hpp"
|
2017-07-05 18:34:12 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde::MP1 {
|
|
|
|
|
|
|
|
class CMetroidData {
|
2020-05-08 08:19:51 +00:00
|
|
|
private:
|
2019-01-31 20:44:05 +00:00
|
|
|
static constexpr u32 skNumProperties = 20;
|
2020-05-08 09:05:47 +00:00
|
|
|
CDamageVulnerability x0_frozenVulnerability;
|
|
|
|
CDamageVulnerability x68_energyDrainVulnerability;
|
2020-05-17 06:46:23 +00:00
|
|
|
float xd0_energyDrainPerSec;
|
2020-05-09 06:51:02 +00:00
|
|
|
float xd4_maxEnergyDrainAllowed;
|
2020-05-09 22:39:11 +00:00
|
|
|
float xd8_telegraphAttackTime;
|
2020-05-09 06:51:02 +00:00
|
|
|
float xdc_stage2GrowthScale;
|
|
|
|
float xe0_stage2GrowthEnergy;
|
|
|
|
float xe4_explosionGrowthEnergy;
|
2019-06-12 02:05:17 +00:00
|
|
|
std::optional<CAnimationParameters> xe8_animParms1;
|
|
|
|
std::optional<CAnimationParameters> xf8_animParms2;
|
|
|
|
std::optional<CAnimationParameters> x108_animParms3;
|
|
|
|
std::optional<CAnimationParameters> x118_animParms4;
|
2020-05-08 08:19:51 +00:00
|
|
|
bool x128_24_startsInWall : 1;
|
2017-07-05 18:34:12 +00:00
|
|
|
|
|
|
|
public:
|
2020-03-31 03:52:22 +00:00
|
|
|
explicit CMetroidData(CInputStream& in);
|
2019-01-31 20:44:05 +00:00
|
|
|
static u32 GetNumProperties() { return skNumProperties; }
|
2020-05-08 09:05:47 +00:00
|
|
|
const CDamageVulnerability& GetFrozenVulnerability() const { return x0_frozenVulnerability; }
|
|
|
|
const CDamageVulnerability& GetEnergyDrainVulnerability() const { return x68_energyDrainVulnerability; }
|
2020-05-17 06:46:23 +00:00
|
|
|
float GetEnergyDrainPerSec() const { return xd0_energyDrainPerSec; }
|
2020-05-09 06:51:02 +00:00
|
|
|
float GetMaxEnergyDrainAllowed() const { return xd4_maxEnergyDrainAllowed; }
|
2020-05-09 22:39:11 +00:00
|
|
|
float GetTelegraphAttackTime() const { return xd8_telegraphAttackTime; }
|
2020-05-09 06:51:02 +00:00
|
|
|
float GetStage2GrowthScale() const { return xdc_stage2GrowthScale; }
|
|
|
|
float GetStage2GrowthEnergy() const { return xe0_stage2GrowthEnergy; }
|
|
|
|
float GetExplosionGrowthEnergy() const { return xe4_explosionGrowthEnergy; }
|
|
|
|
bool GetStartsInWall() const { return x128_24_startsInWall; }
|
2017-07-05 18:34:12 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CMetroid : public CPatterned {
|
2020-05-08 08:19:51 +00:00
|
|
|
private:
|
|
|
|
enum class EState {
|
|
|
|
Invalid = -1,
|
|
|
|
Zero,
|
|
|
|
One,
|
|
|
|
Two,
|
|
|
|
Over,
|
|
|
|
} x568_state = EState::Invalid;
|
|
|
|
CMetroidData x56c_data;
|
|
|
|
TUniqueId x698_teamAiMgrId = kInvalidUniqueId;
|
|
|
|
CCollidableSphere x6a0_collisionPrimitive;
|
|
|
|
CPathFindSearch x6c0_pathFindSearch;
|
|
|
|
zeus::CVector3f x7a4_;
|
|
|
|
TUniqueId x7b0_attackTarget = kInvalidUniqueId;
|
|
|
|
float x7b4_attackChance = 0.f;
|
|
|
|
float x7b8_telegraphAttackTime = 0.f;
|
2020-05-21 16:50:17 +00:00
|
|
|
float x7bc_energyDrained = 0.f;
|
|
|
|
float x7c0_energyDrainTime = 0.f;
|
2020-05-08 08:19:51 +00:00
|
|
|
float x7c4_ = 0.f;
|
2020-05-21 16:50:17 +00:00
|
|
|
enum class EAttackState {
|
|
|
|
None,
|
|
|
|
Attached,
|
|
|
|
Draining,
|
|
|
|
Over,
|
|
|
|
} x7c8_attackState = EAttackState::None;
|
2020-05-08 09:22:12 +00:00
|
|
|
enum class EGammaType {
|
|
|
|
Invalid = -1,
|
|
|
|
Normal,
|
|
|
|
Red,
|
|
|
|
White,
|
|
|
|
Purple,
|
|
|
|
Orange,
|
|
|
|
} x7cc_gammaType;
|
2020-05-08 08:19:51 +00:00
|
|
|
zeus::CVector3f x7d0_scale1;
|
|
|
|
zeus::CVector3f x7dc_scale2;
|
|
|
|
zeus::CVector3f x7e8_scale3;
|
2020-05-21 16:50:17 +00:00
|
|
|
float x7f4_growthDuration = 0.f;
|
|
|
|
float x7f8_growthEnergy = 0.f;
|
|
|
|
float x7fc_lastGrowthEnergy = 0.f;
|
|
|
|
float x800_seekTime = 0.f;
|
|
|
|
float x804_maxSeekTime = 0.f;
|
2020-05-08 08:19:51 +00:00
|
|
|
float x808_loopAttackDistance = 0.f;
|
2020-05-21 16:50:17 +00:00
|
|
|
zeus::CVector3f x80c_detachPos;
|
2020-05-08 08:19:51 +00:00
|
|
|
pas::EStepDirection x818_dodgeDirection = pas::EStepDirection::Invalid;
|
|
|
|
CPatternedInfo x81c_patternedInfo;
|
|
|
|
CActorParameters x954_actParams;
|
2020-05-21 16:50:17 +00:00
|
|
|
TUniqueId x9bc_parent;
|
2020-05-08 08:19:51 +00:00
|
|
|
u8 x9be_ = 0;
|
|
|
|
bool x9bf_24_alert : 1 = false;
|
2020-05-21 16:50:17 +00:00
|
|
|
bool x9bf_25_growing : 1 = false;
|
2020-05-08 08:19:51 +00:00
|
|
|
bool x9bf_26_shotAt : 1 = false;
|
|
|
|
bool x9bf_27_ : 1 = false;
|
|
|
|
bool x9bf_28_ : 1 = false;
|
|
|
|
bool x9bf_29_isAttacking : 1 = false;
|
2020-05-21 16:50:17 +00:00
|
|
|
bool x9bf_30_restoreSolidCollision : 1 = false;
|
|
|
|
bool x9bf_31_restoreCharacterCollision : 1 = false;
|
2020-05-17 15:21:52 +00:00
|
|
|
bool x9c0_24_isEnergyDrainVulnerable : 1 = false;
|
2019-01-31 20:44:05 +00:00
|
|
|
|
2017-07-05 18:34:12 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
DEFINE_PATTERNED(Metroid)
|
|
|
|
CMetroid(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info,
|
|
|
|
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, const CActorParameters& aParms,
|
2019-01-31 20:44:05 +00:00
|
|
|
const CMetroidData& metroidData, TUniqueId);
|
2020-05-08 08:19:51 +00:00
|
|
|
|
|
|
|
void Accept(IVisitor& visitor) override { visitor.Visit(this); }
|
|
|
|
void Think(float dt, CStateManager& mgr) override;
|
|
|
|
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override;
|
|
|
|
void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType eType, float dt) override;
|
|
|
|
const CCollisionPrimitive* GetCollisionPrimitive() const override { return &x6a0_collisionPrimitive; }
|
|
|
|
EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f& vec1, const zeus::CVector3f& vec2,
|
|
|
|
const CWeaponMode& mode,
|
|
|
|
EProjectileAttrib attribute) const override;
|
|
|
|
const CDamageVulnerability* GetDamageVulnerability() const override;
|
|
|
|
const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f& vec1, const zeus::CVector3f& vec2,
|
|
|
|
const CDamageInfo& dInfo) const override {
|
|
|
|
return GetDamageVulnerability();
|
|
|
|
}
|
|
|
|
zeus::CVector3f GetOrigin(const CStateManager& mgr, const CTeamAiRole& role,
|
|
|
|
const zeus::CVector3f& aimPos) const override;
|
|
|
|
CPathFindSearch* GetSearchPath() override { return &x6c0_pathFindSearch; }
|
|
|
|
std::optional<zeus::CAABox> GetTouchBounds() const override {
|
|
|
|
return x6a0_collisionPrimitive.CalculateAABox(GetTransform());
|
|
|
|
}
|
|
|
|
bool IsListening() const override { return true; }
|
|
|
|
void Render(CStateManager& mgr) override { return CPatterned::Render(mgr); }
|
|
|
|
void SelectTarget(CStateManager& mgr, EStateMsg msg, float arg) override;
|
|
|
|
void Touch(CActor& act, CStateManager& mgr) override;
|
|
|
|
|
|
|
|
void Attack(CStateManager& mgr, EStateMsg msg, float dt) override;
|
2020-05-09 22:39:11 +00:00
|
|
|
void Dodge(CStateManager& mgr, EStateMsg msg, float dt) override;
|
|
|
|
void Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state) override;
|
|
|
|
void Generate(CStateManager& mgr, EStateMsg msg, float arg) override;
|
|
|
|
void KnockBack(const zeus::CVector3f& dir, CStateManager& mgr, const CDamageInfo& info, EKnockBackType type,
|
|
|
|
bool inDeferred, float magnitude) override;
|
2020-05-08 08:19:51 +00:00
|
|
|
void PathFind(CStateManager& mgr, EStateMsg msg, float arg) override;
|
2020-05-17 15:21:52 +00:00
|
|
|
void Patrol(CStateManager& mgr, EStateMsg msg, float arg) override;
|
|
|
|
void TargetPatrol(CStateManager& mgr, EStateMsg msg, float dt) override;
|
2020-05-17 06:46:23 +00:00
|
|
|
void TelegraphAttack(CStateManager& mgr, EStateMsg msg, float dt) override;
|
2020-05-17 15:21:52 +00:00
|
|
|
void TurnAround(CStateManager& mgr, EStateMsg msg, float dt) override;
|
|
|
|
void WallHang(CStateManager& mgr, EStateMsg msg, float dt) override;
|
2020-05-08 08:19:51 +00:00
|
|
|
|
|
|
|
bool AnimOver(CStateManager&, float arg) override { return x568_state == EState::Over; }
|
|
|
|
bool AggressionCheck(CStateManager& mgr, float arg) override;
|
2020-05-09 22:39:11 +00:00
|
|
|
bool Attacked(CStateManager& mgr, float arg) override;
|
|
|
|
bool AttackOver(CStateManager& mgr, float arg) override;
|
|
|
|
bool InAttackPosition(CStateManager& mgr, float arg) override;
|
|
|
|
bool InDetectionRange(CStateManager& mgr, float arg) override;
|
2020-05-17 15:21:52 +00:00
|
|
|
bool InPosition(CStateManager& mgr, float arg) override;
|
|
|
|
bool InRange(CStateManager& mgr, float arg) override;
|
|
|
|
bool Inside(CStateManager& mgr, float arg) override;
|
|
|
|
bool Leash(CStateManager& mgr, float arg) override;
|
|
|
|
bool LostInterest(CStateManager& mgr, float arg) override;
|
|
|
|
bool PatternShagged(CStateManager& mgr, float arg) override;
|
2020-05-08 08:19:51 +00:00
|
|
|
bool ShotAt(CStateManager& mgr, float arg) override { return x9bf_26_shotAt; }
|
|
|
|
bool ShouldAttack(CStateManager& mgr, float arg) override;
|
2020-05-17 15:21:52 +00:00
|
|
|
bool ShouldDodge(CStateManager& mgr, float arg) override;
|
|
|
|
bool ShouldTurn(CStateManager& mgr, float arg) override;
|
2020-05-08 08:19:51 +00:00
|
|
|
bool ShouldWallHang(CStateManager& mgr, float arg) override { return x56c_data.GetStartsInWall(); }
|
2020-05-17 15:21:52 +00:00
|
|
|
bool SpotPlayer(CStateManager& mgr, float arg) override;
|
2020-05-08 08:19:51 +00:00
|
|
|
|
|
|
|
bool IsAttacking() const { return x9bf_29_isAttacking; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
float ComputeMorphingPlayerSuckZPos(const CPlayer& player) const;
|
2020-05-17 15:21:52 +00:00
|
|
|
bool IsPirateValidTarget(const CSpacePirate* target, CStateManager& mgr);
|
2020-05-08 08:19:51 +00:00
|
|
|
bool CanAttack(CStateManager& mgr);
|
|
|
|
void UpdateAttackChance(CStateManager& mgr, float dt);
|
|
|
|
bool IsPlayerUnderwater(CStateManager& mgr);
|
|
|
|
bool IsHunterAttacking(CStateManager& mgr);
|
|
|
|
bool IsAttackInProgress(CStateManager& mgr);
|
2020-05-17 06:46:23 +00:00
|
|
|
void ComputeSuckPiratePosRot(CStateManager& mgr, zeus::CVector3f& outPos, zeus::CQuaternion& outRot);
|
2020-05-08 09:22:12 +00:00
|
|
|
EGammaType GetRandomGammaType(CStateManager& mgr, EGammaType previous);
|
2020-05-08 08:19:51 +00:00
|
|
|
void SpawnGammaMetroid(CStateManager& mgr);
|
|
|
|
bool ShouldSpawnGammaMetroid();
|
2020-05-17 06:46:23 +00:00
|
|
|
void ComputeSuckPlayerPosRot(CStateManager& mgr, zeus::CVector3f& outPos, zeus::CQuaternion& outRot);
|
|
|
|
void ComputeSuckTargetPosRot(CStateManager& mgr, zeus::CVector3f& outPos, zeus::CQuaternion& outRot);
|
2020-05-08 08:19:51 +00:00
|
|
|
void InterpolateToPosRot(CStateManager& mgr, float dt);
|
|
|
|
void SuckEnergyFromTarget(CStateManager& mgr, float dt);
|
|
|
|
bool ShouldReleaseFromTarget(CStateManager& mgr);
|
|
|
|
void DisableSolidCollision(CMetroid* target);
|
|
|
|
void RestoreSolidCollision(CStateManager& mgr);
|
|
|
|
void PreventWorldCollisions(CStateManager& mgr, float dt);
|
2020-05-09 06:51:02 +00:00
|
|
|
void SetupExitFaceHugDirection(CActor* actor, CStateManager& mgr, const zeus::CVector3f& vec,
|
2020-05-08 08:19:51 +00:00
|
|
|
const zeus::CTransform& xf);
|
|
|
|
void DetachFromTarget(CStateManager& mgr);
|
|
|
|
bool AttachToTarget(CStateManager& mgr);
|
|
|
|
void SwarmRemove(CStateManager& mgr);
|
|
|
|
void SwarmAdd(CStateManager& mgr);
|
|
|
|
void ApplySplitGammas(CStateManager& mgr, float arg);
|
|
|
|
void ApplyForwardSteering(CStateManager& mgr, const zeus::CVector3f& vec);
|
|
|
|
void ApplySeparationBehavior(CStateManager& mgr, float arg);
|
|
|
|
void SetUpPathFindBehavior(CStateManager& mgr);
|
|
|
|
void ApplyGrowth(float arg);
|
|
|
|
bool PreDamageSpacePirate(CStateManager& mgr);
|
|
|
|
float GetDamageMultiplier() { return 0.5f * (GetGrowthStage() - 1.f) + 1.f; }
|
|
|
|
float GetGrowthStage();
|
|
|
|
zeus::CVector3f GetAttackTargetPos(CStateManager& mgr);
|
2020-05-08 09:05:47 +00:00
|
|
|
bool IsSuckingEnergy() const;
|
2020-05-08 08:19:51 +00:00
|
|
|
void UpdateVolume();
|
|
|
|
void UpdateTouchBounds();
|
2017-07-05 18:34:12 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde::MP1
|