Fix Flaahgra's attack by using the correct variable in CBodyController

This commit is contained in:
Phillip Stephens 2021-05-09 16:05:36 -07:00
parent e579d9454f
commit 6718f697dd
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
2 changed files with 83 additions and 86 deletions

View File

@ -798,13 +798,13 @@ void CFlaahgra::SetMaterialProperties(const std::unique_ptr<CCollisionActorManag
}
}
bool CFlaahgra::ShouldTurn(CStateManager& mgr, float /*unused*/) {
bool CFlaahgra::ShouldTurn(CStateManager& mgr, float /*arg*/) {
zeus::CVector2f posDiff = mgr.GetPlayer().GetTranslation().toVec2f() - GetTranslation().toVec2f();
zeus::CVector2f frontVec = x34_transform.frontVector().toVec2f();
return zeus::CVector2f::getAngleDiff(frontVec, posDiff) > zeus::degToRad(15.f);
}
void CFlaahgra::TurnAround(CStateManager& mgr, EStateMsg msg, float /*unused*/) {
void CFlaahgra::TurnAround(CStateManager& mgr, EStateMsg msg, float /*arg*/) {
if (msg == EStateMsg::Activate) {
x6cc_boneTracking->SetTarget(mgr.GetPlayer().GetUniqueId());
x6cc_boneTracking->SetActive(true);
@ -833,7 +833,7 @@ bool CFlaahgra::IsSphereCollider(TUniqueId uid) const {
return it != x7fc_sphereColliders.end();
}
void CFlaahgra::GetUp(CStateManager& mgr, EStateMsg msg, float /*unused*/) {
void CFlaahgra::GetUp(CStateManager& mgr, EStateMsg msg, float /*arg*/) {
if (msg == EStateMsg::Activate) {
x568_state = EState::Zero;
x784_ = x780_;
@ -923,7 +923,7 @@ float CFlaahgra::GetEndActionTime() const {
return eventTime.GetSeconds();
}
void CFlaahgra::Generate(CStateManager& mgr, EStateMsg msg, float /*unused*/) {
void CFlaahgra::Generate(CStateManager& mgr, EStateMsg msg, float /*arg*/) {
if (msg == EStateMsg::Activate) {
x568_state = EState::Zero;
} else if (msg == EStateMsg::Update) {
@ -1015,7 +1015,7 @@ void CFlaahgra::Faint(CStateManager& mgr, EStateMsg msg, float arg) {
}
}
void CFlaahgra::Dead(CStateManager& mgr, EStateMsg msg, float /*dt*/) {
void CFlaahgra::Dead(CStateManager& mgr, EStateMsg msg, float /*arg*/) {
if (msg == EStateMsg::Activate) {
x568_state = (x450_bodyController->GetFallState() != pas::EFallState::Zero ||
x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::Fall)
@ -1054,6 +1054,9 @@ void CFlaahgra::Dead(CStateManager& mgr, EStateMsg msg, float /*dt*/) {
}
void CFlaahgra::Attack(CStateManager& mgr, EStateMsg msg, float arg) {
fmt::print(FMT_STRING("CFlaahgra::Attack {}\n"), (msg == EStateMsg::Activate ? "Activate"
: msg == EStateMsg::Update ? "Update"
: "Deactivate"));
static constexpr std::array kStates1{
-1, -1, -1, 2, -1,
};
@ -1076,24 +1079,22 @@ void CFlaahgra::Attack(CStateManager& mgr, EStateMsg msg, float arg) {
}
x78c_ = sub801ae754(mgr);
x798_meleeInitialAnimState = x450_bodyController->GetBodyStateInfo().GetCurrentStateId();
x798_meleeInitialAnimState = x450_bodyController->GetCurrentAnimId();
} else {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCMeleeAttackCmd(kSeverity[x7a8_]));
}
} else if (x568_state == EState::One) {
if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::MeleeAttack) {
x568_state = EState::Four;
} else {
if (x798_meleeInitialAnimState != x450_bodyController->GetBodyStateInfo().GetCurrentStateId()) {
x568_state = EState::Two;
} else {
if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::MeleeAttack) {
if (x798_meleeInitialAnimState == x450_bodyController->GetCurrentAnimId()) {
x450_bodyController->GetCommandMgr().DeliverTargetVector(x78c_);
if (!ShouldAttack(mgr, 0.f)) {
return;
if (ShouldAttack(mgr, 0.f)) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCMeleeAttackCmd(kSeverity[kStates1[x7a8_]]));
}
x450_bodyController->GetCommandMgr().DeliverCmd(CBCMeleeAttackCmd(kSeverity[kStates1[x7a8_]]));
} else {
x568_state = EState::Two;
}
} else {
x568_state = EState::Four;
}
} else if (x568_state == EState::Two) {
if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::MeleeAttack) {
@ -1120,10 +1121,9 @@ void CFlaahgra::Attack(CStateManager& mgr, EStateMsg msg, float arg) {
u32 CFlaahgra::sub801ae828(const CStateManager& mgr) const {
const CPlayer& player = mgr.GetPlayer();
if (player.GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Morphed) {
if (x7cc_generateEndCooldown > 0.f || player.GetVelocity().magSquared() < 25.f) {
return 3;
}
if (player.GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Morphed &&
(x7cc_generateEndCooldown > 0.f || player.GetVelocity().magSquared() < 25.f)) {
return 3;
}
if (GetTransform().basis[0].dot(player.GetVelocity()) > 0.f) {
@ -1161,7 +1161,7 @@ void CFlaahgra::Dizzy(CStateManager& /*unused*/, EStateMsg msg, float arg) {
}
}
void CFlaahgra::Suck(CStateManager& mgr, EStateMsg msg, float /*unused*/) {
void CFlaahgra::Suck(CStateManager& mgr, EStateMsg msg, float /*arg*/) {
if (msg == EStateMsg::Activate) {
x568_state = EState::Zero;
x8e4_26_ = false;
@ -1190,7 +1190,7 @@ void CFlaahgra::Suck(CStateManager& mgr, EStateMsg msg, float /*unused*/) {
}
}
void CFlaahgra::ProjectileAttack(CStateManager& mgr, EStateMsg msg, float /*unused*/) {
void CFlaahgra::ProjectileAttack(CStateManager& mgr, EStateMsg msg, float /*arg*/) {
if (msg == EStateMsg::Activate) {
x568_state = EState::Zero;
SendScriptMsgs(EScriptObjectState::Attack, mgr, EScriptObjectMessage::None);
@ -1237,7 +1237,7 @@ void CFlaahgra::ProjectileAttack(CStateManager& mgr, EStateMsg msg, float /*unus
}
}
void CFlaahgra::Cover(CStateManager& mgr, EStateMsg msg, float /*unused*/) {
void CFlaahgra::Cover(CStateManager& mgr, EStateMsg msg, float /*arg*/) {
static constexpr std::array severities{pas::ESeverity::Eight, pas::ESeverity::Seven};
if (msg == EStateMsg::Activate) {
x77c_targetMirrorWaypointId = GetMirrorNearestPlayer(mgr);
@ -1285,7 +1285,7 @@ void CFlaahgra::Cover(CStateManager& mgr, EStateMsg msg, float /*unused*/) {
}
}
void CFlaahgra::SpecialAttack(CStateManager& mgr, EStateMsg msg, float /*unused*/) {
void CFlaahgra::SpecialAttack(CStateManager& mgr, EStateMsg msg, float /*arg*/) {
if (msg == EStateMsg::Activate) {
x568_state = EState::Zero;
x8e5_24_ = false;
@ -1317,7 +1317,7 @@ void CFlaahgra::SpecialAttack(CStateManager& mgr, EStateMsg msg, float /*unused*
}
}
bool CFlaahgra::CoverCheck(CStateManager& mgr, float /*unused*/) {
bool CFlaahgra::CoverCheck(CStateManager& mgr, float /*arg*/) {
if (x7f8_ <= 0 && x7bc_ > 0.f) {
return false;
}
@ -1353,7 +1353,7 @@ TUniqueId CFlaahgra::GetMirrorNearestPlayer(const CStateManager& mgr) const {
return nearId;
}
void CFlaahgra::Enraged(CStateManager& /*unused*/, EStateMsg msg, float /*unused*/) {
void CFlaahgra::Enraged(CStateManager& /*mgr*/, EStateMsg msg, float /*arg*/) {
if (msg == EStateMsg::Activate) {
x568_state = EState::Zero;
} else if (msg == EStateMsg::Update) {

View File

@ -5,13 +5,13 @@
#include <vector>
#include "Runtime/CDependencyGroup.hpp"
#include "Runtime/rstl.hpp"
#include "Runtime/Collision/CJointCollisionDescription.hpp"
#include "Runtime/MP1/World/CFlaahgraProjectile.hpp"
#include "Runtime/Weapon/CProjectileInfo.hpp"
#include "Runtime/World/CActorParameters.hpp"
#include "Runtime/World/CAnimationParameters.hpp"
#include "Runtime/World/CPatterned.hpp"
#include "Runtime/rstl.hpp"
#include <zeus/CAABox.hpp>
#include <zeus/CColor.hpp>
@ -51,7 +51,7 @@ public:
static constexpr u32 GetNumProperties() { return 23; }
explicit CFlaahgraData(CInputStream&);
const CAnimationParameters& GetAnimationParameters() const { return x14c_animationParameters; }
[[nodiscard]] const CAnimationParameters& GetAnimationParameters() const { return x14c_animationParameters; }
};
class CFlaahgraRenderer : public CActor {
@ -60,9 +60,9 @@ class CFlaahgraRenderer : public CActor {
public:
CFlaahgraRenderer(TUniqueId, TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&);
void AddToRenderer(const zeus::CFrustum&, CStateManager&) override;
void Accept(IVisitor&) override;
std::optional<zeus::CAABox> GetTouchBounds() const override { return {}; }
void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override;
void Accept(IVisitor& visitor) override;
[[nodiscard]] std::optional<zeus::CAABox> GetTouchBounds() const override { return {}; }
};
class CFlaahgraPlants : public CActor {
@ -78,23 +78,16 @@ public:
CFlaahgraPlants(const TToken<CGenDescription>&, const CActorParameters&, TUniqueId, TAreaId, TUniqueId,
const zeus::CTransform&, const CDamageInfo&, const zeus::CVector3f&);
void Accept(IVisitor&) override;
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override;
void Think(float, CStateManager&) override;
void AddToRenderer(const zeus::CFrustum&, CStateManager&) override;
std::optional<zeus::CAABox> GetTouchBounds() const override;
void Touch(CActor&, CStateManager&) override;
void Accept(IVisitor& visitor) override;
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) override;
void Think(float dt, CStateManager& mgr) override;
void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override;
[[nodiscard]] std::optional<zeus::CAABox> GetTouchBounds() const override;
void Touch(CActor& actor, CStateManager& mgr) override;
};
class CFlaahgra : public CPatterned {
enum class EState {
Invalid = -1,
Zero,
One,
Two,
Three,
Four
} x568_state = EState::Invalid;
enum class EState { Invalid = -1, Zero, One, Two, Three, Four } x568_state = EState::Invalid;
CFlaahgraData x56c_data;
std::unique_ptr<CBoneTracking> x6cc_boneTracking; // Used to be an rstl::optional_object<CBoneTracking*>
TUniqueId x6d0_rendererId = kInvalidUniqueId;
@ -109,7 +102,7 @@ class CFlaahgra : public CPatterned {
u32 x784_ = 1;
u32 x788_stage = 0;
zeus::CVector3f x78c_;
pas::EAnimationState x798_meleeInitialAnimState = pas::EAnimationState::Invalid;
s32 x798_meleeInitialAnimState = -1;
std::unique_ptr<CCollisionActorManager> x79c_leftArmCollision;
std::unique_ptr<CCollisionActorManager> x7a0_rightArmCollision;
std::unique_ptr<CCollisionActorManager> x7a4_sphereCollision;
@ -173,25 +166,25 @@ class CFlaahgra : public CPatterned {
void UpdateHealthInfo(CStateManager&);
void UpdateAimPosition(CStateManager&, float);
void SetMaterialProperties(const std::unique_ptr<CCollisionActorManager>&, CStateManager&);
bool sub801ae650() const { return (x7a8_ == 0 || x7a8_ == 1); }
bool sub801ae670() const { return (x7a8_ == 2 || x7a8_ == 3 || x7a8_ == 4); }
bool IsSphereCollider(TUniqueId) const;
[[nodiscard]] bool sub801ae650() const { return x7a8_ == 0 || x7a8_ == 1; }
[[nodiscard]] bool sub801ae670() const { return (x7a8_ == 2 || x7a8_ == 3 || x7a8_ == 4); }
[[nodiscard]] bool IsSphereCollider(TUniqueId) const;
void SetCollisionActorBounds(CStateManager& mgr, const std::unique_ptr<CCollisionActorManager>& colMgr,
const zeus::CVector3f& extendedBounds);
void UpdateScale(float, float, float);
float GetEndActionTime() const;
[[nodiscard]] float GetEndActionTime() const;
void SetupHealthInfo(CStateManager&);
zeus::CVector3f GetAttackTargetPos(const CStateManager& mgr) const;
[[nodiscard]] zeus::CVector3f GetAttackTargetPos(const CStateManager& mgr) const;
void RattlePlayer(CStateManager& mgr, const zeus::CVector3f& vec);
void CalculateFallDirection();
void UpdateHeadDamageVulnerability(CStateManager&, bool);
u32 sub801ae828(const CStateManager&) const;
zeus::CVector3f sub801ae754(const CStateManager&) const;
[[nodiscard]] u32 sub801ae828(const CStateManager&) const;
[[nodiscard]] zeus::CVector3f sub801ae754(const CStateManager&) const;
CFlaahgraProjectile* CreateProjectile(const zeus::CTransform& xf, CStateManager& mgr);
TUniqueId GetMirrorNearestPlayer(const CStateManager&) const;
[[nodiscard]] TUniqueId GetMirrorNearestPlayer(const CStateManager&) const;
bool sub_801ae638();
public:
@ -200,47 +193,51 @@ public:
const CPatternedInfo&, const CActorParameters&, CFlaahgraData);
void Accept(IVisitor& visitor) override;
void Think(float, CStateManager&) override;
void PreThink(float, CStateManager&) override;
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override;
void AddToRenderer(const zeus::CFrustum&, CStateManager&) override;
bool CanRenderUnsorted(const CStateManager&) const override { return true; }
zeus::CVector3f GetAimPosition(const CStateManager&, float) const override { return x820_aimPosition; }
void Death(CStateManager&, const zeus::CVector3f&, EScriptObjectState) override;
void DoUserAnimEvent(CStateManager&, const CInt32POINode&, EUserEventType, float dt) override;
void Think(float dt, CStateManager& mgr) override;
void PreThink(float dt, CStateManager& mgr) override;
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) override;
void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override;
[[nodiscard]] bool CanRenderUnsorted(const CStateManager& mgr) const override { return true; }
[[nodiscard]] zeus::CVector3f GetAimPosition(const CStateManager& mgr, float dt) const override {
return x820_aimPosition;
}
void Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state) override;
void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) override;
CProjectileInfo* GetProjectileInfo() override {
return x8e4_30_bigStrike ? &x704_bigStrikeProjectileInfo : &x6dc_normalProjectileInfo;
}
bool AnimOver(CStateManager&, float) override { return x568_state == EState::Four; }
bool AIStage(CStateManager&, float arg) override { return x780_ == u32(arg); }
bool HitSomething(CStateManager&, float arg) override { return x7d0_hitSomethingTime > 0.f; }
bool OffLine(CStateManager&, float) override { return (x8e5_29_ && x8e5_28_); }
bool ShouldTurn(CStateManager&, float) override;
bool ShouldAttack(CStateManager&, float) override;
bool BreakAttack(CStateManager&, float) override { return x7d4_faintTime >= x56c_data.xc_faintDuration && !x8e4_29_getup; }
bool IsDizzy(CStateManager&, float) override {
bool AnimOver(CStateManager& mgr, float arg) override { return x568_state == EState::Four; }
bool AIStage(CStateManager& mgr, float arg) override { return x780_ == u32(arg); }
bool HitSomething(CStateManager& mgr, float arg) override { return x7d0_hitSomethingTime > 0.f; }
bool OffLine(CStateManager& mgr, float arg) override { return (x8e5_29_ && x8e5_28_); }
bool ShouldTurn(CStateManager& mgr, float arg) override;
bool ShouldAttack(CStateManager& mgr, float arg) override;
bool BreakAttack(CStateManager& mgr, float arg) override {
return x7d4_faintTime >= x56c_data.xc_faintDuration && !x8e4_29_getup;
}
bool IsDizzy(CStateManager& mgr, float arg) override {
return x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::LoopReaction;
}
bool CoverCheck(CStateManager&, float) override;
bool CoverCheck(CStateManager& mgr, float arg) override;
bool ShouldSpecialAttack(CStateManager& mgr, float arg) override;
bool ShouldFire(CStateManager& mgr, float arg) override;
void FadeIn(CStateManager&, EStateMsg, float) override;
void FadeOut(CStateManager&, EStateMsg, float) override;
void TurnAround(CStateManager&, EStateMsg, float) override;
void GetUp(CStateManager&, EStateMsg, float) override;
void Growth(CStateManager&, EStateMsg, float) override;
void Generate(CStateManager&, EStateMsg, float) override;
void Faint(CStateManager&, EStateMsg, float) override;
void Dead(CStateManager&, EStateMsg, float) override;
void Attack(CStateManager&, EStateMsg, float) override;
void Dizzy(CStateManager&, EStateMsg, float) override;
void Suck(CStateManager&, EStateMsg, float) override;
void ProjectileAttack(CStateManager&, EStateMsg, float) override;
void Cover(CStateManager&, EStateMsg, float) override;
void SpecialAttack(CStateManager&, EStateMsg, float) override;
void Enraged(CStateManager&, EStateMsg, float) override;
void FadeIn(CStateManager& mgr, EStateMsg msg, float arg) override;
void FadeOut(CStateManager& mgr, EStateMsg msg, float arg) override;
void TurnAround(CStateManager& mgr, EStateMsg msg, float arg) override;
void GetUp(CStateManager& mgr, EStateMsg msg, float arg) override;
void Growth(CStateManager& mgr, EStateMsg msg, float arg) override;
void Generate(CStateManager& mgr, EStateMsg msg, float arg) override;
void Faint(CStateManager& mgr, EStateMsg msg, float arg) override;
void Dead(CStateManager& mgr, EStateMsg msg, float arg) override;
void Attack(CStateManager& mgr, EStateMsg msg, float arg) override;
void Dizzy(CStateManager& mgr, EStateMsg msg, float arg) override;
void Suck(CStateManager& mgr, EStateMsg msg, float arg) override;
void ProjectileAttack(CStateManager& mgr, EStateMsg msg, float arg) override;
void Cover(CStateManager& mgr, EStateMsg msg, float arg) override;
void SpecialAttack(CStateManager& mgr, EStateMsg msg, float arg) override;
void Enraged(CStateManager& mgr, EStateMsg msg, float arg) override;
};
} // namespace metaforce::MP1