All CPatterned functions implemented

This commit is contained in:
Jack Andersen 2018-11-10 17:27:54 -10:00
parent 87e5aea6f5
commit d4bb7d64eb
27 changed files with 1383 additions and 369 deletions

View File

@ -276,27 +276,27 @@ struct PatternedInfo : BigDNA
Value<float> damageWaitTime; Value<float> damageWaitTime;
HealthInfo healthInfo; HealthInfo healthInfo;
DamageVulnerability damageVulnerability; DamageVulnerability damageVulnerability;
Value<float> unkown1; Value<float> halfExtent;
Value<float> unkown2; Value<float> height;
Value<atVec3f> unkown3; Value<atVec3f> bodyOrigin;
Value<float> unkown4; Value<float> stepUpHeight;
Value<float> unkown5; Value<float> xDamage;
Value<float> unkown6; Value<float> frozenXDamage;
Value<float> unkown7; Value<float> xDamageDelay;
Value<atUint32> soundID1; Value<atUint32> deathSfx;
AnimationParameters animationParameters; AnimationParameters animationParameters;
Value<bool> active; Value<bool> active;
UniqueID32 stateMachine; UniqueID32 stateMachine;
Value<float> unknown8; Value<float> intoFreezeDur;
Value<float> unknown9; Value<float> outOfFreezeDur;
Value<float> unknown10; Value<float> unknown10;
Value<atUint32> unknown11; Value<atUint32> particle1Frames;
Value<atVec3f> unknown12; Value<atVec3f> particle1Scale;
UniqueID32 particle1; UniqueID32 particle1;
UniqueID32 electric; UniqueID32 electric;
Value<atVec3f> unknown14; Value<atVec3f> particle2Scale;
UniqueID32 particle2; UniqueID32 particle2;
Value<atUint32> soundID2; Value<atUint32> iceShatterSfx;
void nameIDs(PAKRouter<PAKBridge>& pakRouter, const std::string& name) const void nameIDs(PAKRouter<PAKBridge>& pakRouter, const std::string& name) const
{ {

View File

@ -13,16 +13,16 @@ struct Waypoint : IScriptObject
String<-1> name; String<-1> name;
Value<atVec3f> location; Value<atVec3f> location;
Value<atVec3f> orientation; Value<atVec3f> orientation;
Value<bool> unknown1; Value<bool> active;
Value<float> unknown2; Value<float> speed;
Value<float> unknown3; Value<float> pause;
Value<atUint32> unknown4; Value<atUint32> patternTranslate;
Value<atUint32> unknown5; Value<atUint32> patternOrient;
Value<atUint32> unknown6; Value<atUint32> patternFit;
Value<atUint32> unknown7; Value<atUint32> behaviour;
Value<atUint32> unknown8; Value<atUint32> behaviourOrient;
Value<atUint32> jumpFlags; // 0x2: single, 0x4: double Value<atUint32> behaviourModifiers; // 0x2: single, 0x4: double
Value<atUint32> unknown10; Value<atUint32> animation;
}; };
} }

View File

@ -1740,7 +1740,7 @@ void CStateManager::TestBombHittingWater(const CActor& damager, const zeus::CVec
} }
} }
bool CStateManager::ApplyLocalDamage(const zeus::CVector3f& vec1, const zeus::CVector3f& vec2, CActor& damagee, bool CStateManager::ApplyLocalDamage(const zeus::CVector3f& pos, const zeus::CVector3f& dir, CActor& damagee,
float dam, const CWeaponMode& weapMode) float dam, const CWeaponMode& weapMode)
{ {
CHealthInfo* hInfo = damagee.HealthInfo(*this); CHealthInfo* hInfo = damagee.HealthInfo(*this);
@ -1789,7 +1789,7 @@ bool CStateManager::ApplyLocalDamage(const zeus::CVector3f& vec1, const zeus::CV
if (player && GetPlayerState()->CanTakeDamage()) if (player && GetPlayerState()->CanTakeDamage())
{ {
player->TakeDamage(significant, vec1, mulDam, weapMode.GetType(), *this); player->TakeDamage(significant, pos, mulDam, weapMode.GetType(), *this);
if (newHp <= 0.f) if (newHp <= 0.f)
x8b8_playerState->SetPlayerAlive(false); x8b8_playerState->SetPlayerAlive(false);
} }
@ -1797,9 +1797,9 @@ bool CStateManager::ApplyLocalDamage(const zeus::CVector3f& vec1, const zeus::CV
if (ai) if (ai)
{ {
if (significant) if (significant)
ai->TakeDamage(vec2, mulDam); ai->TakeDamage(dir, mulDam);
if (newHp <= 0.f) if (newHp <= 0.f)
ai->Death(*this, vec2, EScriptObjectState::DeathRattle); ai->Death(*this, dir, EScriptObjectState::DeathRattle);
} }
return significant; return significant;

View File

@ -1023,7 +1023,7 @@ bool CBSJump::CheckForWallJump(CBodyController& bc, CStateManager& mgr)
float distToWall = (xc_waypoint1 - act->GetTranslation()).magnitude(); float distToWall = (xc_waypoint1 - act->GetTranslation()).magnitude();
zeus::CAABox aabb = act->GetBoundingBox(); zeus::CAABox aabb = act->GetBoundingBox();
float xExtent = (aabb.max.x - aabb.min.x) * 0.5f; float xExtent = (aabb.max.x - aabb.min.x) * 0.5f;
if (distToWall < 1.414f * xExtent || (act->GetX328_26() && distToWall < 3.f * xExtent)) if (distToWall < 1.414f * xExtent || (act->CanLongJump() && distToWall < 3.f * xExtent))
{ {
x4_state = x30_26_wallBounceRight ? pas::EJumpState::WallBounceRight : pas::EJumpState::WallBounceLeft; x4_state = x30_26_wallBounceRight ? pas::EJumpState::WallBounceRight : pas::EJumpState::WallBounceLeft;
CPASAnimParmData parms(13, CPASAnimParm::FromEnum(s32(x4_state)), CPASAnimParmData parms(13, CPASAnimParm::FromEnum(s32(x4_state)),
@ -1041,7 +1041,7 @@ void CBSJump::CheckForLand(CBodyController& bc, CStateManager& mgr)
{ {
if (TCastToPtr<CPatterned> act = bc.GetOwner()) if (TCastToPtr<CPatterned> act = bc.GetOwner())
{ {
if (act->GetX328_26() || act->IsOnGround()) if (act->CanLongJump() || act->IsOnGround())
{ {
x4_state = pas::EJumpState::OutOfJump; x4_state = pas::EJumpState::OutOfJump;
CPASAnimParmData parms(13, CPASAnimParm::FromEnum(s32(x4_state)), CPASAnimParmData parms(13, CPASAnimParm::FromEnum(s32(x4_state)),
@ -1275,7 +1275,7 @@ bool CBSHurled::ShouldStartStrikeWall(CBodyController& bc) const
{ {
if (TCastToPtr<CPatterned> ai = bc.GetOwner()) if (TCastToPtr<CPatterned> ai = bc.GetOwner())
{ {
if (ai->GetX328_26()) if (ai->CanLongJump())
if (!ai->IsOnGround()) if (!ai->IsOnGround())
return true; return true;
} }
@ -1652,7 +1652,7 @@ bool CBSWallHang::CheckForLand(CBodyController& bc, CStateManager& mgr)
{ {
if (TCastToPtr<CPatterned> ai = bc.GetOwner()) if (TCastToPtr<CPatterned> ai = bc.GetOwner())
{ {
if (ai->GetX328_26() || ai->IsOnGround()) if (ai->CanLongJump() || ai->IsOnGround())
{ {
x4_state = pas::EWallHangState::DetachOutOfJump; x4_state = pas::EWallHangState::DetachOutOfJump;
CPASAnimParmData parms(20, CPASAnimParm::FromEnum(s32(x4_state))); CPASAnimParmData parms(20, CPASAnimParm::FromEnum(s32(x4_state)));
@ -1673,7 +1673,7 @@ bool CBSWallHang::CheckForWall(CBodyController& bc, CStateManager& mgr)
if (wp) if (wp)
magSq = (wp->GetTranslation() - ai->GetTranslation()).magSquared(); magSq = (wp->GetTranslation() - ai->GetTranslation()).magSquared();
if (magSq < 1.f || ai->GetX328_26()) if (magSq < 1.f || ai->CanLongJump())
{ {
x4_state = pas::EWallHangState::IntoWallHang; x4_state = pas::EWallHangState::IntoWallHang;
CPASAnimParmData parms(20, CPASAnimParm::FromEnum(s32(x4_state))); CPASAnimParmData parms(20, CPASAnimParm::FromEnum(s32(x4_state)));

View File

@ -91,7 +91,8 @@ public:
CBCGenerateCmd(pas::EGenerateType type, int i) CBCGenerateCmd(pas::EGenerateType type, int i)
: CBodyStateCmd(EBodyStateCmd::Generate), x8_type(type) { x1c_24_targetTransform = false; x1c_25_overrideAnim = false; } : CBodyStateCmd(EBodyStateCmd::Generate), x8_type(type) { x1c_24_targetTransform = false; x1c_25_overrideAnim = false; }
CBCGenerateCmd(pas::EGenerateType type, const zeus::CVector3f& vec) CBCGenerateCmd(pas::EGenerateType type, const zeus::CVector3f& vec)
: CBodyStateCmd(EBodyStateCmd::Generate), x8_type(type) { x1c_24_targetTransform = false; x1c_25_overrideAnim = false; } : CBodyStateCmd(EBodyStateCmd::Generate), x8_type(type), xc_targetPos(vec)
{ x1c_24_targetTransform = false; x1c_25_overrideAnim = false; }
pas::EGenerateType GetGenerateType() const { return x8_type; } pas::EGenerateType GetGenerateType() const { return x8_type; }
const zeus::CVector3f& GetExitTargetPos() const { return xc_targetPos; } const zeus::CVector3f& GetExitTargetPos() const { return xc_targetPos; }
bool HasExitTargetPos() const { return x1c_24_targetTransform; } bool HasExitTargetPos() const { return x1c_24_targetTransform; }

View File

@ -183,11 +183,11 @@ void CParasite::Think(float dt, CStateManager& mgr)
x742_27_ = false; x742_27_ = false;
} }
if (x420_curDamageTime <= 0.f) if (x420_curDamageRemTime <= 0.f)
{ {
mgr.ApplyDamage(GetUniqueId(), pl->GetUniqueId(), GetUniqueId(), GetContactDamage(), mgr.ApplyDamage(GetUniqueId(), pl->GetUniqueId(), GetUniqueId(), GetContactDamage(),
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {}); CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
x420_curDamageTime = x424_damageWaitTime; x420_curDamageRemTime = x424_damageWaitTime;
} }
} }
} }

View File

@ -312,7 +312,7 @@ void CPlayerGun::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CSt
} }
else if (TCastToConstPtr<CPatterned> ai = mgr.GetObjectById(sender)) else if (TCastToConstPtr<CPatterned> ai = mgr.GetObjectById(sender))
{ {
if (ai->GetX402_28()) if (ai->IsMakingBigStrike())
{ {
x394_damageTimer = ai->GetDamageDuration(); x394_damageTimer = ai->GetDamageDuration();
bigStrike = true; bigStrike = true;

View File

@ -37,7 +37,7 @@ CActor::CActor(TUniqueId uid, bool active, std::string_view name, const CEntityI
x90_actorLights = mData.IsNull() ? std::unique_ptr<CActorLights>() : params.x0_lightParms.MakeActorLights(); x90_actorLights = mData.IsNull() ? std::unique_ptr<CActorLights>() : params.x0_lightParms.MakeActorLights();
if (mData.x10_animData || mData.x1c_normalModel) if (mData.x10_animData || mData.x1c_normalModel)
x64_modelData = std::make_unique<CModelData>(std::move(mData)); x64_modelData = std::make_unique<CModelData>(std::move(mData));
xd0_thermalMag = params.x64_thermalMag; xd0_damageMag = params.x64_thermalMag;
xd8_nonLoopingSfxHandles.resize(2); xd8_nonLoopingSfxHandles.resize(2);
xe4_27_notInSortedLists = true; xe4_27_notInSortedLists = true;
xe4_28_transformDirty = true; xe4_28_transformDirty = true;
@ -241,14 +241,14 @@ void CActor::RenderInternal(const CStateManager& mgr) const
{ {
float addMag; float addMag;
float mulMag = 1.f; float mulMag = 1.f;
if (xd0_thermalMag <= 1.f) if (xd0_damageMag <= 1.f)
{ {
mulMag = xd0_thermalMag; mulMag = xd0_damageMag;
addMag = 0.f; addMag = 0.f;
} }
else if (xd0_thermalMag < 2.f) else if (xd0_damageMag < 2.f)
{ {
addMag = xd0_thermalMag - 1.f; addMag = xd0_damageMag - 1.f;
} }
else else
{ {

View File

@ -45,7 +45,7 @@ protected:
TUniqueId xc6_nextDrawNode; TUniqueId xc6_nextDrawNode;
int xc8_drawnToken = -1; int xc8_drawnToken = -1;
int xcc_addedToken = -1; int xcc_addedToken = -1;
float xd0_thermalMag; float xd0_damageMag;
float xd4_maxVol = 1.f; float xd4_maxVol = 1.f;
rstl::reserved_vector<CSfxHandle, 2> xd8_nonLoopingSfxHandles; rstl::reserved_vector<CSfxHandle, 2> xd8_nonLoopingSfxHandles;
union union
@ -200,6 +200,7 @@ public:
TUniqueId GetFluidId() const { return xc4_fluidId; } TUniqueId GetFluidId() const { return xc4_fluidId; }
bool GetPointGeneratorParticles() const { return xe5_31_pointGeneratorParticles; } bool GetPointGeneratorParticles() const { return xe5_31_pointGeneratorParticles; }
void SetPointGeneratorParticles(bool s) { xe5_31_pointGeneratorParticles = s; } void SetPointGeneratorParticles(bool s) { xe5_31_pointGeneratorParticles = s; }
CSimpleShadow* Shadow() { return x94_simpleShadow.get(); }
}; };
} }

View File

@ -45,12 +45,12 @@ public:
virtual void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); virtual void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
virtual CHealthInfo* HealthInfo(CStateManager&) { return &x258_healthInfo; } virtual CHealthInfo* HealthInfo(CStateManager&) { return &x258_healthInfo; }
virtual void Death(CStateManager& mgr, const zeus::CVector3f&, EScriptObjectState)=0; virtual void Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state)=0;
virtual void KnockBack(const zeus::CVector3f&, CStateManager&, const CDamageInfo& info, virtual void KnockBack(const zeus::CVector3f&, CStateManager&, const CDamageInfo& info,
EKnockBackType type, bool inDeferred, float magnitude)=0; EKnockBackType type, bool inDeferred, float magnitude)=0;
virtual const CDamageVulnerability* GetDamageVulnerability() const { return &x260_damageVulnerability; } virtual const CDamageVulnerability* GetDamageVulnerability() const { return &x260_damageVulnerability; }
virtual const CDamageVulnerability* GetDamageVulnerability() { return &x260_damageVulnerability; } virtual const CDamageVulnerability* GetDamageVulnerability() { return &x260_damageVulnerability; }
virtual void TakeDamage(const zeus::CVector3f&, float) {} virtual void TakeDamage(const zeus::CVector3f& direction, float magnitude) {}
virtual bool CanBeShot(const CStateManager&, int) { return true; } virtual bool CanBeShot(const CStateManager&, int) { return true; }
virtual bool IsListening() const { return false; } virtual bool IsListening() const { return false; }
virtual int Listen(const zeus::CVector3f&, EListenNoiseType) { return 0; } virtual int Listen(const zeus::CVector3f&, EListenNoiseType) { return 0; }

View File

@ -7,6 +7,7 @@ namespace urde
{ {
enum class EStateMsg enum class EStateMsg
{ {
Zero = 0,
One = 1, One = 1,
Two = 2 Two = 2
}; };

View File

@ -38,6 +38,12 @@ public:
EResult FindClosestReachablePoint(const zeus::CVector3f& p1, zeus::CVector3f& p2) const; EResult FindClosestReachablePoint(const zeus::CVector3f& p1, zeus::CVector3f& p2) const;
EResult PathExists(const zeus::CVector3f& p1, const zeus::CVector3f& p2) const; EResult PathExists(const zeus::CVector3f& p1, const zeus::CVector3f& p2) const;
EResult OnPath(const zeus::CVector3f& p1) const; EResult OnPath(const zeus::CVector3f& p1) const;
EResult GetResult() const { return xcc_result; }
u32 GetCurrentWaypoint() const { return xc8_curWaypoint; }
void SetCurrentWaypoint(u32 wp) { xc8_curWaypoint = wp; }
const rstl::reserved_vector<zeus::CVector3f, 16>& GetWaypoints() const { return x4_waypoints; }
bool IsOver() const { return GetCurrentWaypoint() >= x4_waypoints.size(); }
bool IsShagged() const { return GetResult() != EResult::Success; }
bool SegmentOver(const zeus::CVector3f& p1) const; bool SegmentOver(const zeus::CVector3f& p1) const;
void GetSplinePoint(zeus::CVector3f& pOut, const zeus::CVector3f& p1) const; void GetSplinePoint(zeus::CVector3f& pOut, const zeus::CVector3f& p1) const;
void GetSplinePointWithLookahead(zeus::CVector3f& pOut, const zeus::CVector3f& p1, float lookahead) const; void GetSplinePointWithLookahead(zeus::CVector3f& pOut, const zeus::CVector3f& p1, float lookahead) const;

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,7 @@ namespace urde
{ {
class CPatternedInfo; class CPatternedInfo;
class CProjectileInfo; class CProjectileInfo;
class CPathFindSearch;
class CPatterned : public CAi class CPatterned : public CAi
{ {
@ -80,52 +81,129 @@ public:
Zero = 0, Zero = 0,
One = 1 One = 1
}; };
enum class EPatternTranslate
{
RelativeStart,
RelativePlayerStart,
RelativePlayer,
Absolute
};
enum class EPatternOrient
{
StartToPlayer,
StartToPlayerStart,
ReversePlayerForward,
Forward
};
enum class EPatternFit
{
Zero,
One
};
enum class EMoveState
{
Zero,
One,
Two,
Three,
Four
};
enum class EBehaviour
{
Zero
};
enum class EBehaviourOrient
{
MoveDir,
Constant,
Destination
};
enum class EBehaviourModifiers
{
Zero
};
enum class EPatrolState
{
Invalid = -1,
Patrol,
Pause,
Done
};
enum class EAnimState
{
Zero,
One,
Two,
Over
};
class CPatternNode
{
zeus::CVector3f x0_pos;
zeus::CVector3f xc_forward;
float x18_speed;
u8 x1c_behaviour;
u8 x1d_behaviourOrient;
u16 x1e_behaviourModifiers;
u32 x20_animation;
public:
CPatternNode(const zeus::CVector3f& pos, const zeus::CVector3f& forward, float speed,
u8 behaviour, u8 behaviourOrient, u16 behaviourModifiers, u32 animation)
: x0_pos(pos), xc_forward(forward), x18_speed(speed), x1c_behaviour(behaviour),
x1d_behaviourOrient(behaviourOrient), x1e_behaviourModifiers(behaviourModifiers),
x20_animation(animation) {}
const zeus::CVector3f& GetPos() const { return x0_pos; }
const zeus::CVector3f& GetForward() const { return xc_forward; }
float GetSpeed() const { return x18_speed; }
u8 GetBehaviour() const { return x1c_behaviour; }
u8 GetBehaviourOrient() const { return x1d_behaviourOrient; }
u16 GetBehaviourModifiers() const { return x1e_behaviourModifiers; }
};
protected: protected:
u32 x2d8_ = -1; EPatrolState x2d8_patrolState = EPatrolState::Invalid;
TUniqueId x2dc_ = kInvalidUniqueId; TUniqueId x2dc_destObj = kInvalidUniqueId;
zeus::CVector3f x2e0_destPos; zeus::CVector3f x2e0_destPos;
zeus::CVector3f x2ec_; zeus::CVector3f x2ec_reflectedDestPos;
float x2f8_ = 0.f; float x2f8_waypointPauseRemTime = 0.f;
float x2fc_minAttackRange; float x2fc_minAttackRange;
float x300_maxAttackRange; float x300_maxAttackRange;
float x304_averageAttackTime; float x304_averageAttackTime;
float x308_attackTimeVariation; float x308_attackTimeVariation;
u32 x30c_ = 0; EBehaviourOrient x30c_behaviourOrient = EBehaviourOrient::MoveDir;
zeus::CVector3f x310_; zeus::CVector3f x310_moveVec;
zeus::CVector3f x31c_; zeus::CVector3f x31c_faceVec;
union union
{ {
struct struct
{ {
bool x328_24_ : 1; bool x328_24_inPosition : 1;
bool x328_25_ : 1; bool x328_25_verticalMovement : 1;
bool x328_26_ : 1; bool x328_26_longJump : 1;
bool x328_27_onGround : 1; bool x328_27_onGround : 1;
bool x328_28_prevOnGround : 1;
bool x328_29_noPatternShagging : 1;
bool x328_30_lookAtDeathDir : 1;
}; };
u32 _dummy = 0; u32 _dummy = 0;
}; };
u32 x32c_; EAnimState x32c_animState = EAnimState::Zero;
CStateMachineState x330_stateMachineState; CStateMachineState x330_stateMachineState;
ECharacter x34c_character; ECharacter x34c_character;
zeus::CVector3f x350_; zeus::CVector3f x350_patternStartPos;
zeus::CVector3f x35c_; zeus::CVector3f x35c_patternStartPlayerPos;
zeus::CVector3f x368_; zeus::CVector3f x368_destWPDelta;
u32 x374_ = 0; EPatternTranslate x374_patternTranslate = EPatternTranslate::RelativeStart;
u32 x378_ = 2; EPatternOrient x378_patternOrient = EPatternOrient::ReversePlayerForward;
u32 x37c_ = 1; EPatternFit x37c_patternFit = EPatternFit::One;
u32 x380_ = 0; EBehaviour x380_behaviour = EBehaviour::Zero;
u32 x384_ = 0; EBehaviourModifiers x384_behaviourModifiers = EBehaviourModifiers::Zero;
s32 x388_anim; s32 x388_anim;
/*x38c_*/ std::vector<CPatternNode> x38c_patterns;
u32 x390_ = 0; u32 x39c_curPattern = 0;
u32 x394_ = 0; zeus::CVector3f x3a0_latestLeashPosition;
u32 x398_ = 0; TUniqueId x3ac_lastPatrolDest = kInvalidUniqueId;
u32 x39c_ = 0; float x3b0_moveSpeed = 1.f;
zeus::CVector3f x3a0_;
TUniqueId x3ac_ = kInvalidUniqueId;
float x3b0_ = 1.f;
float x3b4_speed; float x3b4_speed;
float x3b8_turnSpeed; float x3b8_turnSpeed;
float x3bc_detectionRange; float x3bc_detectionRange;
@ -135,128 +213,173 @@ protected:
float x3cc_playerLeashRadius; float x3cc_playerLeashRadius;
float x3d0_playerLeashTime; float x3d0_playerLeashTime;
float x3d4_curPlayerLeashTime = 0.f; float x3d4_curPlayerLeashTime = 0.f;
float x3d8_; float x3d8_xDamageThreshold;
float x3dc_; float x3dc_frozenXDamageThreshold;
float x3e0_; float x3e0_xDamageDelay;
float x3e4_ = 0.f; float x3e4_lastHP = 0.f;
float x3e8_alphaRate = 0.f; float x3e8_alphaDelta = 0.f;
float x3ec_ = 0.f; float x3ec_pendingFireDamage = 0.f;
float x3f0_ = 0.f; float x3f0_pendingShockDamage = 0.f;
float x3f4_burnThinkRateTimer = 0.f; float x3f4_burnThinkRateTimer = 0.f;
u32 x3f8_ = 0; EMoveState x3f8_moveState = EMoveState::Zero;
EFlavorType x3fc_flavor; EFlavorType x3fc_flavor;
union union
{ {
struct struct
{ {
bool x400_24_ : 1; bool x400_24_hitByPlayerProjectile : 1;
bool x400_25_alive : 1; // t bool x400_25_alive : 1; // t
bool x400_26_ : 1; bool x400_26_ : 1;
bool x400_27_deleteWhenDoneBurning : 1; bool x400_27_fadeToDeath : 1;
bool x400_28_ : 1; bool x400_28_pendingMassiveDeath : 1;
bool x400_29_ : 1; bool x400_29_pendingMassiveFrozenDeath : 1;
bool x400_30_ : 1; bool x400_30_patternShagged : 1;
bool x400_31_ : 1; // r25 == 1 bool x400_31_isFlyer : 1;
bool x401_24_ : 1; bool x401_24_pathOverCount : 2;
bool x401_25_ : 1; bool x401_26_disableMove : 1;
bool x401_26_ : 1; bool x401_27_phazingOut : 1;
bool x401_27_ : 1;
bool x401_28_burning : 1; bool x401_28_burning : 1;
bool x401_29_laggedBurnDeath : 1; bool x401_29_laggedBurnDeath : 1;
bool x401_30_ : 1; bool x401_30_pendingDeath : 1;
bool x401_31_ : 1; bool x401_31_nextPendingShock : 1;
bool x402_24_ : 1; bool x402_24_pendingShock : 1;
bool x402_25_ : 1; bool x402_25_lostMassiveFrozenHP : 1;
bool x402_26_ : 1; bool x402_26_dieIf80PercFrozen : 1;
bool x402_27_ : 1; bool x402_27_noXrayModel : 1;
bool x402_28_ : 1; bool x402_28_isMakingBigStrike : 1;
bool x402_29_ : 1; // t bool x402_29_drawParticles : 1; // t
bool x402_30_ : 1; bool x402_30_updateThermalFrozenState : 1;
bool x402_31_thawed : 1; bool x402_31_thawed : 1;
bool x403_24_keepThermalVisorState : 1; bool x403_24_keepThermalVisorState : 1;
bool x403_25_ : 1; // t bool x403_25_enableStateMachine : 1; // t
bool x403_26_ : 1; // t bool x403_26_stateControlledMassiveDeath : 1; // t
}; };
u32 _dummy2 = 0; u32 _dummy2 = 0;
}; };
CDamageInfo x404_contactDamage; CDamageInfo x404_contactDamage;
float x420_curDamageTime = 0.f; float x420_curDamageRemTime = 0.f;
float x424_damageWaitTime; float x424_damageWaitTime;
float x428_ = -1.f; float x428_damageCooldownTimer = -1.f;
zeus::CColor x42c_color = zeus::CColor::skBlack; zeus::CColor x42c_color = zeus::CColor::skBlack;
zeus::CColor x430_ = skDamageColor; zeus::CColor x430_damageColor = skDamageColor;
zeus::CVector3f x434_posDelta; zeus::CVector3f x434_posDelta;
zeus::CQuaternion x440_rotDelta; zeus::CQuaternion x440_rotDelta;
CSteeringBehaviors x45c_; CSteeringBehaviors x45c_steeringBehaviors;
std::unique_ptr<CBodyController> x450_bodyController; std::unique_ptr<CBodyController> x450_bodyController;
u16 x454_deathSfx; u16 x454_deathSfx;
u16 x458_iceShatterSfx; u16 x458_iceShatterSfx;
CKnockBackController x460_knockBackController; CKnockBackController x460_knockBackController;
zeus::CVector3f x4e4_; zeus::CVector3f x4e4_latestPredictedTranslation;
float x4f0_ = 0.f; float x4f0_predictedLeashTime = 0.f;
float x4f4_; float x4f4_intoFreezeDur;
float x4f8_; float x4f8_outofFreezeDur;
float x4fc_; float x4fc_;
float x500_ = 0.f; float x500_preThinkDt = 0.f;
float x504_damageDur = 0.f; float x504_damageDur = 0.f;
EColliderType x508_colliderType; EColliderType x508_colliderType;
float x50c_thermalMag; float x50c_baseDamageMag;
std::shared_ptr<CVertexMorphEffect> x510_vertexMorph; std::shared_ptr<CVertexMorphEffect> x510_vertexMorph;
zeus::CVector3f x514_deathExplosionOffset; zeus::CVector3f x514_deathExplosionOffset;
std::experimental::optional<TLockedToken<CGenDescription>> x520_deathExplosionParticle; std::experimental::optional<TLockedToken<CGenDescription>> x520_deathExplosionParticle;
std::experimental::optional<TLockedToken<CElectricDescription>> x530_deathExplosionElectric; std::experimental::optional<TLockedToken<CElectricDescription>> x530_deathExplosionElectric;
zeus::CVector3f x540_iceDeathExplosionOffset; zeus::CVector3f x540_iceDeathExplosionOffset;
std::experimental::optional<TLockedToken<CGenDescription>> x54c_iceDeathExplosionParticle; std::experimental::optional<TLockedToken<CGenDescription>> x54c_iceDeathExplosionParticle;
zeus::CVector3f x55c_; zeus::CVector3f x55c_moveScale = zeus::CVector3f::skOne;
void UpdateFrozenState(bool thawed);
void UpdateThermalFrozenState(bool thawed);
void GenerateIceDeathExplosion(CStateManager& mgr); void GenerateIceDeathExplosion(CStateManager& mgr);
void GenerateDeathExplosion(CStateManager& mgr); void GenerateDeathExplosion(CStateManager& mgr);
void RenderIceModelWithFlags(const CModelFlags& flags) const; void RenderIceModelWithFlags(const CModelFlags& flags) const;
TUniqueId GetWaypointForState(CStateManager& mgr, EScriptObjectState state, EScriptObjectMessage msg) const;
void UpdateActorKeyframe(CStateManager& mgr) const;
pas::EStepDirection GetStepDirection(const zeus::CVector3f& moveVec) const;
bool IsPatternObstructed(CStateManager& mgr, const zeus::CVector3f& p0, const zeus::CVector3f& p1) const;
void UpdateDest(CStateManager& mgr);
void ApproachDest(CStateManager& mgr);
std::pair<CScriptWaypoint*, CScriptWaypoint*> GetDestWaypoints(CStateManager& mgr) const;
zeus::CQuaternion FindPatternRotation(const zeus::CVector3f& dir) const;
zeus::CVector3f FindPatternDir(CStateManager& mgr) const;
void UpdatePatternDestPos(CStateManager& mgr);
void SetupPattern(CStateManager& mgr);
EScriptObjectState GetDesiredAttackState(CStateManager& mgr) const;
public: public:
CPatterned(ECharacter character, TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info, CPatterned(ECharacter character, TUniqueId uid, std::string_view name, EFlavorType flavor,
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pinfo, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData,
CPatterned::EMovementType movement, EColliderType collider, EBodyType body, const CPatternedInfo& pinfo, CPatterned::EMovementType movement,
const CActorParameters& params, EKnockBackVariant kbVariant); EColliderType collider, EBodyType body, const CActorParameters& params,
EKnockBackVariant kbVariant);
void Accept(IVisitor&); void Accept(IVisitor&);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
void PreThink(float, CStateManager& mgr) { CEntity::Think(x500_, mgr); } void PreThink(float, CStateManager& mgr) { CEntity::Think(x500_preThinkDt, mgr); }
void Think(float, CStateManager&); void Think(float, CStateManager&);
void PreRender(CStateManager&, const zeus::CFrustum&); void PreRender(CStateManager&, const zeus::CFrustum&);
void Render(const CStateManager& mgr) const; void Render(const CStateManager& mgr) const;
void Touch(CActor&, CStateManager&); void Touch(CActor& act, CStateManager& mgr);
std::experimental::optional<zeus::CAABox> GetTouchBounds() const; std::experimental::optional<zeus::CAABox> GetTouchBounds() const;
bool CanRenderUnsorted(const CStateManager& mgr) const; bool CanRenderUnsorted(const CStateManager& mgr) const;
zeus::CVector3f GetOrbitPosition(const CStateManager& mgr) const zeus::CVector3f GetOrbitPosition(const CStateManager& mgr) const
{ {
return GetAimPosition(mgr, 0.f); return GetAimPosition(mgr, 0.f);
} }
zeus::CVector3f GetAimPosition(const CStateManager& mgr, float) const; zeus::CVector3f GetAimPosition(const CStateManager& mgr, float) const;
void DeathDelete(CStateManager& mgr); void DeathDelete(CStateManager& mgr);
void Death(CStateManager& mgr, const zeus::CVector3f&, EScriptObjectState) {} void Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state);
void KnockBack(const zeus::CVector3f&, CStateManager&, const CDamageInfo& info, void KnockBack(const zeus::CVector3f&, CStateManager&, const CDamageInfo& info,
EKnockBackType type, bool inDeferred, float magnitude); EKnockBackType type, bool inDeferred, float magnitude);
void TakeDamage(const zeus::CVector3f&, float) { x428_ = 0.33f;} void TakeDamage(const zeus::CVector3f&, float arg);
bool FixedRandom(CStateManager&, float) { return x330_stateMachineState.GetRandom() < x330_stateMachineState.x14_; } bool FixedRandom(CStateManager&, float arg);
bool Random(CStateManager&, float dt) { return x330_stateMachineState.GetRandom() < dt; } bool Random(CStateManager&, float arg);
//bool FixedDelay(CStateManager&, float dt) { return x330_stateMachineState.GetDelay() == dt; } bool CodeTrigger(CStateManager&, float arg);
bool FixedDelay(CStateManager&, float arg);
bool RandomDelay(CStateManager&, float arg);
bool Delay(CStateManager&, float arg);
bool PatrolPathOver(CStateManager&, float arg);
bool Stuck(CStateManager&, float arg);
bool AnimOver(CStateManager&, float arg);
bool InPosition(CStateManager&, float arg);
bool HasPatrolPath(CStateManager& mgr, float arg);
bool Attacked(CStateManager&, float arg);
bool PatternShagged(CStateManager&, float arg);
bool PatternOver(CStateManager&, float arg);
bool HasRetreatPattern(CStateManager& mgr, float arg);
bool HasAttackPattern(CStateManager& mgr, float arg);
bool NoPathNodes(CStateManager&, float arg);
bool PathShagged(CStateManager&, float arg);
bool PathFound(CStateManager&, float arg);
bool PathOver(CStateManager&, float arg);
bool Landed(CStateManager&, float arg);
bool PlayerSpot(CStateManager&, float arg);
bool SpotPlayer(CStateManager&, float arg);
bool Leash(CStateManager&, float arg);
bool InDetectionRange(CStateManager&, float arg);
bool InMaxRange(CStateManager&, float arg);
bool TooClose(CStateManager&, float arg);
bool InRange(CStateManager&, float arg);
bool OffLine(CStateManager&, float arg);
bool Default(CStateManager&, float arg) { return true; }
void PathFind(CStateManager&, EStateMsg msg, float arg);
void Dead(CStateManager&, EStateMsg msg, float arg);
void TargetPlayer(CStateManager&, EStateMsg msg, float arg);
void TargetPatrol(CStateManager&, EStateMsg msg, float arg);
void FollowPattern(CStateManager&, EStateMsg msg, float arg);
void Patrol(CStateManager&, EStateMsg msg, float arg);
void Start(CStateManager&, EStateMsg msg, float arg) {}
bool Default() { return true; } virtual bool KnockbackWhenFrozen() const { return true; }
virtual bool KnockbackWhenFrozen() const { return true;} virtual void MassiveDeath(CStateManager& mgr);
virtual void DoDeath(CStateManager&); virtual void MassiveFrozenDeath(CStateManager& mgr);
virtual void DoIceDeath(CStateManager&);
virtual void Burn(float, float) {} virtual void Burn(float, float) {}
virtual void Shock(float, float) {} virtual void Shock(float, float) {}
virtual void Freeze(CStateManager& mgr, const zeus::CVector3f& pos, virtual void Freeze(CStateManager& mgr, const zeus::CVector3f& pos,
const zeus::CUnitVector3f& dir, float magnitude) {} const zeus::CUnitVector3f& dir, float magnitude) {}
virtual void ThinkAboutMove(float); virtual void ThinkAboutMove(float);
virtual void GetSearchPath() {} virtual CPathFindSearch* GetSearchPath() { return nullptr; }
virtual CDamageInfo GetContactDamage() const { return x404_contactDamage; } virtual CDamageInfo GetContactDamage() const { return x404_contactDamage; }
virtual u8 GetModelAlphau8(const CStateManager&) const { return u8(x42c_color.a * 255);} virtual u8 GetModelAlphau8(const CStateManager&) const { return u8(x42c_color.a * 255);}
virtual bool IsOnGround() const { return x328_27_onGround; } virtual bool IsOnGround() const { return x328_27_onGround; }
@ -277,12 +400,13 @@ public:
void SetDestPos(const zeus::CVector3f& pos) { x2e0_destPos = pos; } void SetDestPos(const zeus::CVector3f& pos) { x2e0_destPos = pos; }
void UpdateAlpha(float dt, CStateManager& mgr); void UpdateAlphaDelta(float dt, CStateManager& mgr);
void SetModelAlpha(float a) { x42c_color.a = a; }
float CalcDyingThinkRate(); float CalcDyingThinkRate();
void sub8007a5b8(float) {} void UpdateDamageColor(float dt);
bool GetX328_26() const { return x328_26_; } bool CanLongJump() const { return x328_26_longJump; }
bool GetX402_28() const { return x402_28_; } bool IsMakingBigStrike() const { return x402_28_isMakingBigStrike; }
//region Casting Functions //region Casting Functions

View File

@ -27,14 +27,14 @@ CPatternedInfo::CPatternedInfo(CInputStream& in, u32 pcount)
, xcc_bodyOrigin(zeus::CVector3f::ReadBig(in)) , xcc_bodyOrigin(zeus::CVector3f::ReadBig(in))
, xd8_stepUpHeight(in.readFloatBig()) , xd8_stepUpHeight(in.readFloatBig())
, xdc_xDamage(in.readFloatBig()) , xdc_xDamage(in.readFloatBig())
, xe0_(in.readFloatBig()) , xe0_frozenXDamage(in.readFloatBig())
, xe4_(in.readFloatBig()) , xe4_xDamageDelay(in.readFloatBig())
, xe8_deathSfx(CSfxManager::TranslateSFXID(in.readUint32Big())) , xe8_deathSfx(CSfxManager::TranslateSFXID(in.readUint32Big()))
, xec_animParams(in) , xec_animParams(in)
, xf8_active(in.readBool()) , xf8_active(in.readBool())
, xfc_stateMachineId(in.readUint32Big()) , xfc_stateMachineId(in.readUint32Big())
, x100_(in.readFloatBig()) , x100_intoFreezeDur(in.readFloatBig())
, x104_(in.readFloatBig()) , x104_outofFreezeDur(in.readFloatBig())
, x108_(in.readFloatBig()) , x108_(in.readFloatBig())
, x10c_particle1Frames(in.readUint32Big()) , x10c_particle1Frames(in.readUint32Big())
, x110_particle1Scale(zeus::CVector3f::ReadBig(in)) , x110_particle1Scale(zeus::CVector3f::ReadBig(in))

View File

@ -35,14 +35,14 @@ class CPatternedInfo
zeus::CVector3f xcc_bodyOrigin; zeus::CVector3f xcc_bodyOrigin;
float xd8_stepUpHeight; float xd8_stepUpHeight;
float xdc_xDamage; float xdc_xDamage;
float xe0_; float xe0_frozenXDamage;
float xe4_; float xe4_xDamageDelay;
u16 xe8_deathSfx; u16 xe8_deathSfx;
CAnimationParameters xec_animParams; CAnimationParameters xec_animParams;
bool xf8_active; bool xf8_active;
CAssetId xfc_stateMachineId; CAssetId xfc_stateMachineId;
float x100_; float x100_intoFreezeDur;
float x104_; float x104_outofFreezeDur;
float x108_; float x108_;
u32 x10c_particle1Frames; u32 x10c_particle1Frames;

View File

@ -8,7 +8,7 @@
namespace urde namespace urde
{ {
CScriptActorKeyframe::CScriptActorKeyframe(TUniqueId uid, std::string_view name, const CEntityInfo& info, s32 animId, CScriptActorKeyframe::CScriptActorKeyframe(TUniqueId uid, std::string_view name, const CEntityInfo& info, s32 animId,
bool looping, float lifetime, bool disableUpdate, u32 fadeOut, bool active, bool looping, float lifetime, bool isPassive, u32 fadeOut, bool active,
float totalPlayback) float totalPlayback)
: CEntity(uid, info, active, name) : CEntity(uid, info, active, name)
, x34_animationId(animId) , x34_animationId(animId)
@ -17,7 +17,7 @@ CScriptActorKeyframe::CScriptActorKeyframe(TUniqueId uid, std::string_view name,
, x40_lifetime(lifetime) , x40_lifetime(lifetime)
{ {
x44_24_looping = looping; x44_24_looping = looping;
x44_25_disableUpdate = disableUpdate; x44_25_isPassive = isPassive;
x44_26_fadeOut = fadeOut; x44_26_fadeOut = fadeOut;
x44_27_timedLoop = fadeOut; x44_27_timedLoop = fadeOut;
x44_28_playing = false; x44_28_playing = false;
@ -35,7 +35,7 @@ void CScriptActorKeyframe::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId u
{ {
if (GetActive()) if (GetActive())
{ {
if (!x44_25_disableUpdate) if (!x44_25_isPassive)
{ {
for (const SConnection& conn : x20_conns) for (const SConnection& conn : x20_conns)
{ {
@ -63,7 +63,7 @@ void CScriptActorKeyframe::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId u
void CScriptActorKeyframe::Think(float dt, CStateManager& mgr) void CScriptActorKeyframe::Think(float dt, CStateManager& mgr)
{ {
if (x44_25_disableUpdate || !x44_24_looping || !x44_27_timedLoop || !x44_28_playing || x40_lifetime <= 0.f) if (x44_25_isPassive || !x44_24_looping || !x44_27_timedLoop || !x44_28_playing || x40_lifetime <= 0.f)
{ {
CEntity::Think(dt, mgr); CEntity::Think(dt, mgr);
return; return;

View File

@ -15,7 +15,7 @@ private:
struct struct
{ {
bool x44_24_looping : 1; bool x44_24_looping : 1;
bool x44_25_disableUpdate : 1; bool x44_25_isPassive : 1;
bool x44_26_fadeOut : 1; bool x44_26_fadeOut : 1;
bool x44_27_timedLoop : 1; bool x44_27_timedLoop : 1;
bool x44_28_playing : 1; bool x44_28_playing : 1;
@ -26,13 +26,14 @@ private:
public: public:
CScriptActorKeyframe(TUniqueId uid, std::string_view name, const CEntityInfo& info, s32 animId, CScriptActorKeyframe(TUniqueId uid, std::string_view name, const CEntityInfo& info, s32 animId,
bool looping, float lifetime, bool disableUpdate, u32 fadeOut, bool active, bool looping, float lifetime, bool isPassive, u32 fadeOut, bool active,
float totalPlayback); float totalPlayback);
void Accept(IVisitor& visitor); void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr);
void Think(float, CStateManager&); void Think(float, CStateManager&);
void UpdateEntity(TUniqueId, CStateManager&); void UpdateEntity(TUniqueId, CStateManager&);
bool IsPassive() const { return x44_25_isPassive; }
}; };
} }

View File

@ -7,11 +7,15 @@ namespace urde
{ {
CScriptWaypoint::CScriptWaypoint(TUniqueId uid, std::string_view name, const CEntityInfo& info, CScriptWaypoint::CScriptWaypoint(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CTransform& xf, bool active, float f1, float f2, const zeus::CTransform& xf, bool active, float speed, float pause,
u32 w1, u32 w2, u32 w3, u32 w4, u32 w5, u32 w6, u32 w7) u32 patternTranslate, u32 patternOrient, u32 patternFit, u32 behaviour,
u32 behaviourOrient, u32 behaviourModifiers, u32 animation)
: CActor(uid, active, name, info, xf, CModelData(), CMaterialList(), : CActor(uid, active, name, info, xf, CModelData(), CMaterialList(),
CActorParameters::None(), kInvalidUniqueId), CActorParameters::None(), kInvalidUniqueId),
xe8_speed(f1), xec_(w7), xf0_(f2), xf4_(w1), xf5_(w2), xf6_(w3), xf7_(w4), xf8_(w5), xfa_jumpFlags(w6) xe8_speed(speed), xec_animation(animation), xf0_pause(pause),
xf4_patternTranslate(patternTranslate), xf5_patternOrient(patternOrient),
xf6_patternFit(patternFit), xf7_behaviour(behaviour),
xf8_behaviourOrient(behaviourOrient), xfa_behaviourModifiers(behaviourModifiers)
{ {
SetUseInSortedLists(false); SetUseInSortedLists(false);
SetCallTouch(false); SetCallTouch(false);

View File

@ -8,18 +8,19 @@ namespace urde
class CScriptWaypoint : public CActor class CScriptWaypoint : public CActor
{ {
float xe8_speed; float xe8_speed;
u32 xec_; u32 xec_animation;
float xf0_; float xf0_pause;
bool xf4_; u8 xf4_patternTranslate;
bool xf5_; u8 xf5_patternOrient;
bool xf6_; u8 xf6_patternFit;
bool xf7_; u8 xf7_behaviour;
bool xf8_; u8 xf8_behaviourOrient;
u16 xfa_jumpFlags; u16 xfa_behaviourModifiers;
public: public:
CScriptWaypoint(TUniqueId, std::string_view, const CEntityInfo&, CScriptWaypoint(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CTransform&, bool, float, float, const zeus::CTransform& xf, bool active, float speed, float pause,
u32, u32, u32, u32, u32, u32, u32); u32 patternTranslate, u32 patternOrient, u32 patternFit, u32 behaviour,
u32 behaviourOrient, u32 behaviourModifiers, u32 animation);
void Accept(IVisitor& visitor); void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr);
@ -27,7 +28,14 @@ public:
TUniqueId FollowWaypoint(CStateManager& mgr) const; TUniqueId FollowWaypoint(CStateManager& mgr) const;
TUniqueId NextWaypoint(CStateManager& mgr) const; TUniqueId NextWaypoint(CStateManager& mgr) const;
float GetSpeed() const { return xe8_speed; } float GetSpeed() const { return xe8_speed; }
float GetF0() const { return xf0_; } u32 GetAnimation() const { return xec_animation; }
float GetPause() const { return xf0_pause; }
u8 GetPatternTranslate() const { return xf4_patternTranslate; }
u8 GetPatternOrient() const { return xf5_patternOrient; }
u8 GetPatternFit() const { return xf6_patternFit; }
u8 GetBehaviour() const { return xf7_behaviour; }
u8 GetBehaviourOrient() const { return xf8_behaviourOrient; }
u16 GetBehaviourModifiers() const { return xfa_behaviourModifiers; }
}; };
} }

View File

@ -53,10 +53,6 @@ s32 CStateMachine::GetStateIndex(std::string_view state) const
return it - x0_states.begin(); return it - x0_states.begin();
} }
const std::vector<CAiState>& CStateMachine::GetStateVector() const { return x0_states; }
float CStateMachineState::GetTime() const { return x8_time; }
void CStateMachineState::SetState(CStateManager &, CAi &, s32 idx) void CStateMachineState::SetState(CStateManager &, CAi &, s32 idx)
{ {
} }
@ -87,11 +83,9 @@ void CStateMachineState::Setup(const CStateMachine* machine)
x4_state = nullptr; x4_state = nullptr;
x8_time = 0.f; x8_time = 0.f;
xc_random = 0.f; xc_random = 0.f;
x10_ = 0.f; x10_delay = 0.f;
} }
std::string CStateMachineState::GetName() const { return {}; }
CFactoryFnReturn FAiFiniteStateMachineFactory(const SObjectTag &tag, CInputStream &in, const CVParamTransfer &vparms, CObjectReference *) CFactoryFnReturn FAiFiniteStateMachineFactory(const SObjectTag &tag, CInputStream &in, const CVParamTransfer &vparms, CObjectReference *)
{ {
return TToken<CStateMachine>::GetIObjObjectFor(std::make_unique<CStateMachine>(in)); return TToken<CStateMachine>::GetIObjObjectFor(std::make_unique<CStateMachine>(in));

View File

@ -36,16 +36,7 @@ class CAiState
{ {
friend class CStateMachineState; friend class CStateMachineState;
CAiStateFunc x0_func; CAiStateFunc x0_func;
const char* x4_name; char xc_name[32];
u32 x8_;
u32 xc_;
u32 x10_;
u32 x14_;
u32 x18_;
u32 x1c_;
u32 x20_;
u32 x24_;
u32 x28_;
u32 x2c_numTriggers; u32 x2c_numTriggers;
u32 x30_; u32 x30_;
public: public:
@ -54,7 +45,7 @@ public:
s32 GetNumTriggers() const; s32 GetNumTriggers() const;
CAiTrigger& GetTrig(s32) const; CAiTrigger& GetTrig(s32) const;
const char* GetName() const { return x4_name; } const char* GetName() const { return xc_name; }
void SetTriggers(CAiTrigger* triggers); void SetTriggers(CAiTrigger* triggers);
void SetNumTriggers(s32 numTriggers) { x2c_numTriggers = numTriggers; } void SetNumTriggers(s32 numTriggers) { x2c_numTriggers = numTriggers; }
void CallFunc(CStateManager& mgr, CAi& ai, EStateMsg msg, float delta) const void CallFunc(CStateManager& mgr, CAi& ai, EStateMsg msg, float delta) const
@ -72,7 +63,7 @@ public:
CStateMachine(CInputStream& in); CStateMachine(CInputStream& in);
s32 GetStateIndex(std::string_view state) const; s32 GetStateIndex(std::string_view state) const;
const std::vector<CAiState>& GetStateVector() const; const std::vector<CAiState>& GetStateVector() const { return x0_states; }
}; };
class CStateMachineState class CStateMachineState
@ -82,7 +73,7 @@ class CStateMachineState
CAiState* x4_state = nullptr; CAiState* x4_state = nullptr;
float x8_time = 0.f; float x8_time = 0.f;
float xc_random = 0.f; float xc_random = 0.f;
float x10_ = 0.f; float x10_delay = 0.f;
float x14_; float x14_;
union union
{ {
@ -96,7 +87,6 @@ public:
CStateMachineState()=default; CStateMachineState()=default;
CAiState* GetActorState() const { return x4_state; } CAiState* GetActorState() const { return x4_state; }
float GetTime() const;
void Update(CStateManager& mgr, CAi& ai, float delta) void Update(CStateManager& mgr, CAi& ai, float delta)
{ {
@ -108,16 +98,16 @@ public:
void SetState(CStateManager&, CAi&, const CStateMachine*, std::string_view); void SetState(CStateManager&, CAi&, const CStateMachine*, std::string_view);
const std::vector<CAiState>* GetStateVector() const; const std::vector<CAiState>* GetStateVector() const;
void Setup(const CStateMachine* machine); void Setup(const CStateMachine* machine);
std::string GetName() const; void SetDelay(float delay) { x10_delay = delay; }
void SetDelay(float); float GetTime() const { return x8_time; }
float GetRandom() const { return xc_random; } float GetRandom() const { return xc_random; }
float GetDelay() const; float GetDelay() const { return x10_delay; }
u32 sub8007FB9C() const const char* GetName() const
{ {
if (x4_state) if (x4_state)
return x4_state->xc_; return x4_state->GetName();
return 0; return nullptr;
} }
}; };

View File

@ -15,7 +15,7 @@ CWallWalker::CWallWalker(ECharacter chr, TUniqueId uid, std::string_view name, E
, x590_colSphere(zeus::CSphere(zeus::CVector3f::skZero, pInfo.GetHalfExtent()), x68_material) , x590_colSphere(zeus::CSphere(zeus::CVector3f::skZero, pInfo.GetHalfExtent()), x68_material)
, x5b0_(f1) , x5b0_(f1)
, x5b4_(f2) , x5b4_(f2)
, x5c0_(f3) , x5c0_advanceWpRadius(f3)
, x5c4_(f4) , x5c4_(f4)
, x5cc_bendingHackAnim(GetModelData()->GetAnimationData()->GetCharacterInfo().GetAnimationIndex("BendingAnimationHack"sv)) , x5cc_bendingHackAnim(GetModelData()->GetAnimationData()->GetCharacterInfo().GetAnimationIndex("BendingAnimationHack"sv))
, x5d0_(w2) , x5d0_(w2)
@ -94,15 +94,15 @@ void CWallWalker::Think(float dt, CStateManager& mgr)
void CWallWalker::UpdateWPDestination(CStateManager& mgr) void CWallWalker::UpdateWPDestination(CStateManager& mgr)
{ {
if (TCastToPtr<CScriptWaypoint> wp = mgr.ObjectById(x2dc_)) if (TCastToPtr<CScriptWaypoint> wp = mgr.ObjectById(x2dc_destObj))
{ {
zeus::CVector3f wpPos = wp->GetTranslation(); zeus::CVector3f wpPos = wp->GetTranslation();
if ((wpPos - GetTranslation()).magSquared() < x5c0_ * x5c0_) if ((wpPos - GetTranslation()).magSquared() < x5c0_advanceWpRadius * x5c0_advanceWpRadius)
{ {
x2dc_ = wp->NextWaypoint(mgr); x2dc_destObj = wp->NextWaypoint(mgr);
if (std::fabs(wp->GetF0()) > 0.00001f) if (std::fabs(wp->GetPause()) > 0.00001f)
{ {
x5bc_ = wp->GetF0(); x5bc_ = wp->GetPause();
if (x5d0_ == 0) if (x5d0_ == 0)
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed); x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
mgr.SendScriptMsg(wp, GetUniqueId(), EScriptObjectMessage::Arrived); mgr.SendScriptMsg(wp, GetUniqueId(), EScriptObjectMessage::Arrived);

View File

@ -17,7 +17,7 @@ protected:
float x5b4_; float x5b4_;
float x5b8_ = 0.f; float x5b8_ = 0.f;
float x5bc_ = 0.f; float x5bc_ = 0.f;
float x5c0_; float x5c0_advanceWpRadius;
float x5c4_; float x5c4_;
float x5c8_bendingHackWeight = 0.f; float x5c8_bendingHackWeight = 0.f;
s32 x5cc_bendingHackAnim; s32 x5cc_bendingHackAnim;

View File

@ -477,18 +477,19 @@ CEntity* ScriptLoader::LoadWaypoint(CStateManager& mgr, CInputStream& in, int pr
SActorHead head = LoadActorHead(in, mgr); SActorHead head = LoadActorHead(in, mgr);
bool active = in.readBool(); bool active = in.readBool();
float f1 = in.readFloatBig(); float speed = in.readFloatBig();
float delay = in.readFloatBig(); float pause = in.readFloatBig();
u32 w1 = in.readUint32Big(); u32 patternTranslate = in.readUint32Big();
u32 w2 = in.readUint32Big(); u32 patternOrient = in.readUint32Big();
u32 w3 = in.readUint32Big(); u32 patternFit = in.readUint32Big();
u32 w4 = in.readUint32Big(); u32 behaviour = in.readUint32Big();
u32 w5 = in.readUint32Big(); u32 behaviourOrient = in.readUint32Big();
u32 w6 = in.readUint32Big(); u32 behaviourModifiers = in.readUint32Big();
u32 w7 = in.readUint32Big(); u32 animation = in.readUint32Big();
return new CScriptWaypoint(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, active, f1, delay, w1, return new CScriptWaypoint(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform,
w2, w3, w4, w5, w6, w7); active, speed, pause, patternTranslate, patternOrient, patternFit,
behaviour, behaviourOrient, behaviourModifiers, animation);
} }
CEntity* ScriptLoader::LoadDoor(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadDoor(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)

View File

@ -155,7 +155,7 @@ std::string_view ScriptObjectStateToStr(EScriptObjectState state)
case EScriptObjectState::Open: return "Open"sv; case EScriptObjectState::Open: return "Open"sv;
case EScriptObjectState::Zero: return "Zero"sv; case EScriptObjectState::Zero: return "Zero"sv;
case EScriptObjectState::Attack: return "Attack"sv; case EScriptObjectState::Attack: return "Attack"sv;
case EScriptObjectState::UNKS1: return "UNKS1"sv; case EScriptObjectState::CloseIn: return "CloseIn"sv;
case EScriptObjectState::Retreat: return "Retreat"sv; case EScriptObjectState::Retreat: return "Retreat"sv;
case EScriptObjectState::Patrol: return "Patrol"sv; case EScriptObjectState::Patrol: return "Patrol"sv;
case EScriptObjectState::Dead: return "Dead"sv; case EScriptObjectState::Dead: return "Dead"sv;
@ -163,12 +163,12 @@ std::string_view ScriptObjectStateToStr(EScriptObjectState state)
case EScriptObjectState::CameraTarget: return "CameraTarget"sv; case EScriptObjectState::CameraTarget: return "CameraTarget"sv;
case EScriptObjectState::UNKS2: return "UNKS2"sv; case EScriptObjectState::UNKS2: return "UNKS2"sv;
case EScriptObjectState::Play: return "Play"sv; case EScriptObjectState::Play: return "Play"sv;
case EScriptObjectState::DeathExplosion: return "DeathExplosion"sv; case EScriptObjectState::MassiveDeath: return "DeathExplosion"sv;
case EScriptObjectState::DeathRattle: return "DeathRattle"sv; case EScriptObjectState::DeathRattle: return "DeathRattle"sv;
case EScriptObjectState::AboutToDie: return "AboutToDie"sv; case EScriptObjectState::AboutToMassivelyDie: return "AboutToDie"sv;
case EScriptObjectState::Damage: return "Damage"sv; case EScriptObjectState::Damage: return "Damage"sv;
case EScriptObjectState::InvulnDamage: return "InvulnDamage"sv; case EScriptObjectState::InvulnDamage: return "InvulnDamage"sv;
case EScriptObjectState::IceDeathExplosion: return "IceDeathExplosion"sv; case EScriptObjectState::MassiveFrozenDeath: return "IceDeathExplosion"sv;
case EScriptObjectState::Modify: return "Modify"sv; case EScriptObjectState::Modify: return "Modify"sv;
case EScriptObjectState::ScanStart: return "ScanStart"sv; case EScriptObjectState::ScanStart: return "ScanStart"sv;
case EScriptObjectState::ScanProcessing: return "ScanProcessing"sv; case EScriptObjectState::ScanProcessing: return "ScanProcessing"sv;

View File

@ -151,7 +151,7 @@ enum class EScriptObjectState
Open = 8, Open = 8,
Zero = 9, Zero = 9,
Attack = 10, Attack = 10,
UNKS1 = 11, CloseIn = 11,
Retreat = 12, Retreat = 12,
Patrol = 13, Patrol = 13,
Dead = 14, Dead = 14,
@ -159,12 +159,12 @@ enum class EScriptObjectState
CameraTarget = 16, CameraTarget = 16,
UNKS2 = 17, UNKS2 = 17,
Play = 18, Play = 18,
DeathExplosion = 19, MassiveDeath = 19,
DeathRattle = 20, DeathRattle = 20,
AboutToDie = 21, AboutToMassivelyDie = 21,
Damage = 22, Damage = 22,
InvulnDamage = 23, InvulnDamage = 23,
IceDeathExplosion = 24, MassiveFrozenDeath = 24,
Modify = 25, Modify = 25,
ScanStart = 26, ScanStart = 26,
ScanProcessing = 27, ScanProcessing = 27,