CFlyingPirate: First draft almost done

This commit is contained in:
Luke Street 2020-03-13 04:11:17 -04:00
parent 11ea9d3aa6
commit 13d8c3fdd1
9 changed files with 1049 additions and 135 deletions

View File

@ -77,13 +77,13 @@ public:
explicit operator bool() const { return HasReference(); }
bool HasReference() const { return x0_objRef != nullptr; }
virtual void Unlock();
void Unlock();
void Lock();
bool IsLocked() const { return x4_lockHeld; }
bool IsLoaded() const;
IObj* GetObj();
const IObj* GetObj() const { return const_cast<CToken*>(this)->GetObj(); }
virtual CToken& operator=(const CToken& other);
CToken& operator=(const CToken& other);
CToken& operator=(CToken&& other);
CToken() = default;
CToken(const CToken& other);
@ -101,6 +101,7 @@ public:
return TObjOwnerDerivedFromIObj<T>::GetNewDerivedObject(std::move(obj));
}
TToken() = default;
virtual ~TToken() = default;
TToken(const CToken& other) : CToken(other) {}
TToken(CToken&& other) : CToken(std::move(other)) {}
TToken(std::unique_ptr<T>&& obj) : CToken(GetIObjObjectFor(std::move(obj))) {}
@ -108,6 +109,8 @@ public:
*this = CToken(GetIObjObjectFor(std::move(obj)));
return this;
}
virtual void Unlock() { CToken::Unlock(); }
virtual void Lock() { CToken::Lock(); }
virtual T* GetObj() {
TObjOwnerDerivedFromIObj<T>* owner = static_cast<TObjOwnerDerivedFromIObj<T>*>(CToken::GetObj());
if (owner)
@ -115,6 +118,10 @@ public:
return nullptr;
}
virtual const T* GetObj() const { return const_cast<TToken<T>*>(this)->GetObj(); }
virtual TToken& operator=(const CToken& other) {
CToken::operator=(other);
return *this;
}
T* operator->() { return GetObj(); }
const T* operator->() const { return GetObj(); }
T& operator*() { return *GetObj(); }
@ -142,12 +149,12 @@ public:
}
TCachedToken& operator=(const TCachedToken& other) {
CToken::operator=(other);
TToken<T>::operator=(other);
m_obj = nullptr;
return *this;
}
TCachedToken& operator=(const CToken& other) {
CToken::operator=(other);
TToken<T>::operator=(other);
m_obj = nullptr;
return *this;
}

View File

@ -29,9 +29,9 @@ public:
CAnimFormatUnion(CInputStream& in, IObjectStore& store);
~CAnimFormatUnion();
EAnimFormat GetFormat() const { return x0_format; }
const CAnimSource& GetAsCAnimSource() const { return *reinterpret_cast<const CAnimSource*>(x4_storage); }
const CFBStreamedCompression& GetAsCFBStreamedCompression() const {
return *reinterpret_cast<const CFBStreamedCompression*>(x4_storage);
CAnimSource& GetAsCAnimSource() { return *reinterpret_cast<CAnimSource*>(x4_storage); }
CFBStreamedCompression& GetAsCFBStreamedCompression() {
return *reinterpret_cast<CFBStreamedCompression*>(x4_storage);
}
};

View File

@ -71,31 +71,35 @@ template <class T>
class TSubAnimTypeToken : public TLockedToken<CAllFormatsAnimSource> {};
template <>
class TSubAnimTypeToken<CAnimSource> : public TLockedToken<CAllFormatsAnimSource> {
class TSubAnimTypeToken<CAnimSource> : public TLockedToken<CAnimSource> {
public:
TSubAnimTypeToken<CAnimSource>(const TLockedToken<CAllFormatsAnimSource>& token)
: TLockedToken<CAllFormatsAnimSource>(token) {}
TSubAnimTypeToken<CAnimSource>(const TLockedToken<CAllFormatsAnimSource>& token) : TLockedToken<CAnimSource>(token) {}
const CAnimSource* GetObj() const {
const CAllFormatsAnimSource* source = TLockedToken<CAllFormatsAnimSource>::GetObj();
CAnimSource* GetObj() {
CAllFormatsAnimSource* source = reinterpret_cast<CAllFormatsAnimSource*>(TLockedToken<CAnimSource>::GetObj());
return &source->GetAsCAnimSource();
}
const CAnimSource* operator->() const { return GetObj(); }
const CAnimSource& operator*() const { return *GetObj(); }
const CAnimSource* GetObj() const {
return const_cast<TSubAnimTypeToken<CAnimSource>*>(this)->GetObj();
}
};
template <>
class TSubAnimTypeToken<CFBStreamedCompression> : public TLockedToken<CAllFormatsAnimSource> {
class TSubAnimTypeToken<CFBStreamedCompression> : public TLockedToken<CFBStreamedCompression> {
public:
TSubAnimTypeToken<CFBStreamedCompression>(const TLockedToken<CAllFormatsAnimSource>& token)
: TLockedToken<CAllFormatsAnimSource>(token) {}
: TLockedToken<CFBStreamedCompression>(token) {}
const CFBStreamedCompression* GetObj() const {
const CAllFormatsAnimSource* source = TLockedToken<CAllFormatsAnimSource>::GetObj();
CFBStreamedCompression* GetObj() {
CAllFormatsAnimSource* source =
reinterpret_cast<CAllFormatsAnimSource*>(TLockedToken<CFBStreamedCompression>::GetObj());
return &source->GetAsCFBStreamedCompression();
}
const CFBStreamedCompression* operator->() const { return GetObj(); }
const CFBStreamedCompression& operator*() const { return *GetObj(); }
const CFBStreamedCompression* GetObj() const {
return const_cast<TSubAnimTypeToken<CFBStreamedCompression>*>(this)->GetObj();
}
};
class IAnimReader {

File diff suppressed because it is too large Load Diff

View File

@ -17,34 +17,34 @@ public:
private:
class CFlyingPirateData {
friend class CFlyingPirate;
float x0_;
float x4_;
int x8_;
CProjectileInfo xc_projInfo1;
u16 x34_sfx1;
CProjectileInfo x38_projInfo2;
CProjectileInfo x60_projInfo3;
float x88_;
float x8c_;
float x0_maxCoverDistance;
float x4_hearingDistance;
u32 x8_;
CProjectileInfo xc_gunProjectileInfo;
u16 x34_gunSfx;
CProjectileInfo x38_altProjectileInfo1;
CProjectileInfo x60_altProjectileInfo2;
float x88_knockBackDelay;
float x8c_flyingHeight;
TCachedToken<CGenDescription> x90_particleGenDesc;
CDamageInfo x9c_dInfo;
float xb8_;
float xbc_;
float xc0_;
float xc4_;
u16 xc8_sfx2;
u16 xca_sfx3;
float xcc_;
u16 xc8_ragDollSfx1;
u16 xca_ragDollSfx2;
float xcc_coverCheckChance;
float xd0_;
float xd4_;
CAssetId xd8_;
CAssetId xdc_;
CAssetId xe0_;
u16 xe4_sfx4;
u16 xe6_sfx5;
float xe8_;
CAssetId xd8_particleGen1;
CAssetId xdc_particleGen2;
CAssetId xe0_particleGen3;
u16 xe4_knockBackSfx;
u16 xe6_deathSfx;
float xe8_aggressionChance;
float xec_;
float xf0_;
float xf0_projectileHomingDistance;
public:
CFlyingPirateData(CInputStream& in, u32 propCount);
@ -63,7 +63,7 @@ private:
u16 x9c_;
int xa0_ = 0;
zeus::CVector3f xa4_;
char xb0_; // TODO flags
bool xb0_24_ : 1;
public:
CFlyingPirateRagDoll(CStateManager& mgr, CFlyingPirate* actor, u16 w1, u16 w2);
@ -84,13 +84,13 @@ public:
void CalculateRenderBounds() override;
void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) override;
void MassiveDeath(CStateManager& mgr) override;
float GetGravityConstant() const override { return 50.f; /* TODO check flags */ }
float GetGravityConstant() const override { return x6a0_25_isUnderwater ? 5.f : 50.f; }
CPathFindSearch* GetSearchPath() override { return &x6a8_pathFindSearch; }
bool IsListening() const override { return true; }
bool KnockbackWhenFrozen() const override { return false; }
bool Listen(const zeus::CVector3f& pos, EListenNoiseType type) override;
void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override;
CProjectileInfo* GetProjectileInfo() override { return &x568_data.xc_projInfo1; }
CProjectileInfo* GetProjectileInfo() override { return &x568_data.xc_gunProjectileInfo; }
void Think(float dt, CStateManager& mgr) override;
void Attack(CStateManager& mgr, EStateMsg msg, float arg) override;
@ -137,39 +137,50 @@ public:
private:
CFlyingPirateData x568_data;
rstl::reserved_vector<TCachedToken<CGenDescription>, 4> x65c_particleGenDescs;
rstl::reserved_vector<std::unique_ptr<CElementGen>, 16> x684_particleGens;
rstl::reserved_vector<TCachedToken<CGenDescription>, 3> x65c_particleGenDescs;
// was rstl::reserved_vector<rstl::optional_object<CElementGen *>, 3>
rstl::reserved_vector<std::unique_ptr<CElementGen>, 3> x684_particleGens;
bool x6a0_24_ : 1;
bool x6a0_25_ : 1;
bool x6a0_27_ : 1;
bool x6a0_29_ : 1;
bool x6a0_25_isUnderwater : 1;
bool x6a0_26_hearShot : 1;
bool x6a0_27_canPatrol : 1;
bool x6a0_28_ : 1;
bool x6a0_29_checkForProjectiles : 1;
bool x6a0_30_ : 1;
bool x6a1_26_ : 1;
bool x6a0_31_ : 1;
bool x6a1_24_ : 1;
bool x6a1_25_ : 1;
bool x6a1_26_isAttackingObject : 1;
bool x6a1_27_ : 1;
bool x6a1_28_ : 1;
bool x6a1_29_isMoving : 1;
bool x6a1_30_ : 1;
bool x6a1_31_ : 1;
bool x6a2_24_ : 1;
bool x6a2_25_ : 1;
bool x6a2_24_aggressive : 1;
bool x6a2_25_aggressionChecked : 1;
bool x6a2_26_jetpackActive : 1;
bool x6a2_27_sparksActive : 1;
bool x6a2_28_ : 1;
TUniqueId x6a4_id1 = kInvalidUniqueId;
TUniqueId x6a4_currentCoverPoint = kInvalidUniqueId;
TUniqueId x6a6_id2 = kInvalidUniqueId;
CPathFindSearch x6a8_pathFindSearch;
float x78c_ = 0.f; // not initialized in constructor?
int x790_ = 0;
int x794_health;
CSegId x798_;
CSegId x798_headSegId;
int x79c_ = -1;
CBoneTracking x7a0_boneTracking;
float x7d8_ = 0.f;
int x7dc_ = 0;
CSegId x7e0_;
CSegId x7e0_gunSegId;
float x7e4_ = 1.f;
TUniqueId x7e8_id3 = kInvalidUniqueId;
TUniqueId x7e8_targetId = kInvalidUniqueId;
CBurstFire x7ec_burstFire;
pas::EStepDirection x84c_ = pas::EStepDirection::Invalid;
float x850_ = 3.f;
pas::EStepDirection x84c_dodgeDirection = pas::EStepDirection::Invalid;
float x850_height = 3.f;
float x854_ = FLT_MAX;
float x858_ = FLT_MAX;
TUniqueId x85c_ = kInvalidUniqueId;
TUniqueId x85c_attackObjectId = kInvalidUniqueId;
float x860_ = 15.f;
rstl::reserved_vector<CSegId, 4> x864_missileSegments;
float x86c_ = 0.f;
@ -181,18 +192,19 @@ private:
float x894_ = 1.f;
float x898_ = 1.f;
std::unique_ptr<CFlyingPirateRagDoll> x89c_ragDoll;
TUniqueId x8a0_ = kInvalidUniqueId;
TUniqueId x8a0_patrolTarget = kInvalidUniqueId;
float x8a4_ = 0.f;
zeus::CVector3f AvoidActors(CStateManager& mgr);
bool CanFireMissiles(CStateManager& mgr);
void CheckForProjectiles(CStateManager& mgr);
void FireProjectile(CStateManager& mgr, const zeus::CVector3f& pos, float dt);
void FireProjectile(CStateManager& mgr, float dt);
pas::EStepDirection GetDodgeDirection(CStateManager& mgr, float arg);
zeus::CVector3f GetTargetPos(CStateManager& mgr);
bool LineOfSightTest(CStateManager& mgr, const zeus::CVector3f& pos, const zeus::CVector3f& dir, CMaterialList materials);
bool LineOfSightTest(CStateManager& mgr, const zeus::CVector3f& start, const zeus::CVector3f& end,
CMaterialList exclude);
void UpdateLandingSmoke(CStateManager& mgr, bool active);
void UpdateParticleEffects(CStateManager& mgr, float f1, bool b1);
void UpdateParticleEffects(CStateManager& mgr, float intensity, bool active);
void DeliverGetUp();
void UpdateCantSeePlayer(CStateManager& mgr);
void AddToTeam(CStateManager& mgr);

View File

@ -333,5 +333,6 @@ public:
u8 GetModelAlphau8(const CStateManager& mgr) const override;
float GetGravityConstant() const override;
CProjectileInfo* GetProjectileInfo() override;
bool GetEnableAim() const { return x637_25_enableAim; }
};
} // namespace urde::MP1

View File

@ -44,8 +44,8 @@ public:
s32 GetBurstType() const { return x0_burstType; }
void Start(CStateManager& mgr);
void Update(CStateManager& mgr, float dt);
static zeus::CVector3f GetError(float xMag, float zMag);
static zeus::CVector3f GetDistanceCompensatedError(float dist, float maxErrDist);
zeus::CVector3f GetError(float xMag, float zMag) const;
zeus::CVector3f GetDistanceCompensatedError(float dist, float maxErrDist) const;
float GetMaxXError() const;
float GetMaxZError() const;
void SetFirstBurstIndex(s32 idx) { xc_firstBurstIdx = idx; }

View File

@ -130,6 +130,7 @@ public:
void Update(float dt, CStateManager& mgr, CPatterned& parent);
void KnockBack(const zeus::CVector3f& backVec, CStateManager& mgr, CPatterned& parent, const CDamageInfo& info,
EKnockBackType type, float magnitude);
void SetSeverity(pas::ESeverity v) { x7c_severity = v; }
void SetEnableFreeze(bool b) { x81_25_enableFreeze = b; }
void SetEnableShock(bool b) { x81_26_enableShock = b; }
void SetEnableBurn(bool b) { x81_27_enableBurn = b; }
@ -146,4 +147,4 @@ public:
bool TestAvailableState(EKnockBackAnimationState s) const { return x80_availableStates.test(size_t(s)); }
};
} // namespace urde
} // namespace urde

View File

@ -1365,7 +1365,7 @@ CEntity* ScriptLoader::LoadFlyingPirate(CStateManager& mgr, CInputStream& in, in
SScaledActorHead actHead = LoadScaledActorHead(in, mgr);
auto pair = CPatternedInfo::HasCorrectParameterCount(in);
if (pair.first)
if (!pair.first)
return nullptr;
CPatternedInfo pInfo(in, pair.second);