mirror of https://github.com/AxioDL/metaforce.git
CChozoGhost: InPosition -> ShouldAttack
This commit is contained in:
parent
155cd3759f
commit
123ddfd33a
|
@ -17,51 +17,51 @@ namespace urde::MP1 {
|
||||||
CChozoGhost::CBehaveChance::CBehaveChance(CInputStream& in)
|
CChozoGhost::CBehaveChance::CBehaveChance(CInputStream& in)
|
||||||
: x0_propertyCount(in.readUint32Big())
|
: x0_propertyCount(in.readUint32Big())
|
||||||
, x4_lurk(in.readFloatBig())
|
, x4_lurk(in.readFloatBig())
|
||||||
, x8_(in.readFloatBig())
|
, x8_taunt(in.readFloatBig())
|
||||||
, xc_attack(in.readFloatBig())
|
, xc_attack(in.readFloatBig())
|
||||||
, x10_move(in.readFloatBig())
|
, x10_move(in.readFloatBig())
|
||||||
, x14_lurkTime(in.readFloatBig())
|
, x14_lurkTime(in.readFloatBig())
|
||||||
, x18_chargeAttack(x0_propertyCount <= 5 ? 0.5f : in.readFloatBig() * .01f)
|
, x18_chargeAttack(x0_propertyCount < 6 ? 0.5f : in.readFloatBig() * .01f)
|
||||||
, x1c_numBolts(x0_propertyCount <= 6 ? 2 : in.readUint32Big()) {
|
, x1c_numBolts(x0_propertyCount < 7 ? 2 : in.readUint32Big()) {
|
||||||
float f2 = 1.f / (x10_move + xc_attack + x4_lurk + x8_);
|
float f2 = 1.f / (x10_move + xc_attack + x4_lurk + x8_taunt);
|
||||||
x4_lurk *= f2;
|
x4_lurk *= f2;
|
||||||
x8_ *= f2;
|
x8_taunt *= f2;
|
||||||
xc_attack *= f2;
|
xc_attack *= f2;
|
||||||
x10_move *= f2;
|
x10_move *= f2;
|
||||||
}
|
}
|
||||||
|
|
||||||
EBehaveType CChozoGhost::CBehaveChance::GetBehave(EBehaveType type, CStateManager& mgr) const {
|
EBehaveType CChozoGhost::CBehaveChance::GetBehave(EBehaveType type, CStateManager& mgr) const {
|
||||||
float dVar5 = x4_lurk;
|
float lurkChance = x4_lurk;
|
||||||
float dVar4 = x8_;
|
float tauntChance = x8_taunt;
|
||||||
float dVar3 = xc_attack;
|
float attackChance = xc_attack;
|
||||||
if (type == EBehaveType::Lurk) {
|
if (type == EBehaveType::Lurk) {
|
||||||
float dVar2 = dVar5 / 3.f;
|
float delta = lurkChance / 3.f;
|
||||||
dVar5 = 0.f;
|
lurkChance = 0.f;
|
||||||
dVar4 += dVar2;
|
tauntChance += delta;
|
||||||
dVar3 += dVar2;
|
attackChance += delta;
|
||||||
} else if (type == EBehaveType::One) {
|
} else if (type == EBehaveType::Taunt) {
|
||||||
float dVar2 = dVar4 / 3.f;
|
float delta = tauntChance / 3.f;
|
||||||
dVar4 = 0.f;
|
tauntChance = 0.f;
|
||||||
dVar5 += dVar2;
|
lurkChance += delta;
|
||||||
dVar3 += dVar2;
|
attackChance += delta;
|
||||||
} else if (type == EBehaveType::Attack) {
|
} else if (type == EBehaveType::Attack) {
|
||||||
float dVar2 = dVar3 / 3.f;
|
float delta = attackChance / 3.f;
|
||||||
dVar3 = 0.f;
|
attackChance = 0.f;
|
||||||
dVar5 += dVar2;
|
lurkChance += delta;
|
||||||
dVar4 += dVar2;
|
tauntChance += delta;
|
||||||
} else if (type == EBehaveType::Move) {
|
} else if (type == EBehaveType::Move) {
|
||||||
float dVar2 = x10_move / 3.f;
|
float delta = x10_move / 3.f;
|
||||||
dVar5 += dVar2;
|
lurkChance += delta;
|
||||||
dVar4 += dVar2;
|
tauntChance += delta;
|
||||||
dVar3 += dVar2;
|
attackChance += delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
float rnd = mgr.GetActiveRandom()->Float();
|
float rnd = mgr.GetActiveRandom()->Float();
|
||||||
if (dVar5 > rnd)
|
if (lurkChance > rnd)
|
||||||
return EBehaveType::Lurk;
|
return EBehaveType::Lurk;
|
||||||
else if (dVar4 > (rnd - dVar5))
|
else if (tauntChance > rnd - lurkChance)
|
||||||
return EBehaveType::One;
|
return EBehaveType::Taunt;
|
||||||
else if (dVar3 > (rnd - dVar5) - dVar4)
|
else if (attackChance > rnd - lurkChance - tauntChance)
|
||||||
return EBehaveType::Attack;
|
return EBehaveType::Attack;
|
||||||
return EBehaveType::Move;
|
return EBehaveType::Move;
|
||||||
}
|
}
|
||||||
|
@ -613,11 +613,11 @@ bool CChozoGhost::Leash(CStateManager& mgr, float arg) {
|
||||||
|
|
||||||
bool CChozoGhost::InRange(CStateManager& mgr, float arg) { return x665_28_inRange; }
|
bool CChozoGhost::InRange(CStateManager& mgr, float arg) { return x665_28_inRange; }
|
||||||
|
|
||||||
bool CChozoGhost::InPosition(CStateManager& mgr, float arg) { return x680_behaveType == EBehaveType::Attack; }
|
bool CChozoGhost::ShouldAttack(CStateManager& mgr, float arg) { return x680_behaveType == EBehaveType::Attack; }
|
||||||
|
|
||||||
bool CChozoGhost::AggressionCheck(CStateManager& mgr, float arg) { return x665_29_aggressive; }
|
bool CChozoGhost::AggressionCheck(CStateManager& mgr, float arg) { return x665_29_aggressive; }
|
||||||
|
|
||||||
bool CChozoGhost::ShouldTaunt(CStateManager& mgr, float arg) { return x680_behaveType == EBehaveType::One; }
|
bool CChozoGhost::ShouldTaunt(CStateManager& mgr, float arg) { return x680_behaveType == EBehaveType::Taunt; }
|
||||||
|
|
||||||
bool CChozoGhost::ShouldFlinch(CStateManager& mgr, float arg) { return x664_25_flinch; }
|
bool CChozoGhost::ShouldFlinch(CStateManager& mgr, float arg) { return x664_25_flinch; }
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,14 @@
|
||||||
#include <zeus/CVector3f.hpp>
|
#include <zeus/CVector3f.hpp>
|
||||||
|
|
||||||
namespace urde::MP1 {
|
namespace urde::MP1 {
|
||||||
enum class EBehaveType { Lurk, One, Attack, Move, Four };
|
enum class EBehaveType { Lurk, Taunt, Attack, Move, Four };
|
||||||
|
|
||||||
class CChozoGhost : public CPatterned {
|
class CChozoGhost : public CPatterned {
|
||||||
public:
|
public:
|
||||||
class CBehaveChance {
|
class CBehaveChance {
|
||||||
u32 x0_propertyCount;
|
u32 x0_propertyCount;
|
||||||
float x4_lurk;
|
float x4_lurk;
|
||||||
float x8_;
|
float x8_taunt;
|
||||||
float xc_attack;
|
float xc_attack;
|
||||||
float x10_move;
|
float x10_move;
|
||||||
float x14_lurkTime;
|
float x14_lurkTime;
|
||||||
|
@ -29,7 +29,7 @@ public:
|
||||||
|
|
||||||
EBehaveType GetBehave(EBehaveType type, CStateManager& mgr) const;
|
EBehaveType GetBehave(EBehaveType type, CStateManager& mgr) const;
|
||||||
float GetLurk() const { return x4_lurk; }
|
float GetLurk() const { return x4_lurk; }
|
||||||
float GetX8() const { return x8_; }
|
float GetTaunt() const { return x8_taunt; }
|
||||||
float GetAttack() const { return xc_attack; }
|
float GetAttack() const { return xc_attack; }
|
||||||
float GetMove() const { return x10_move; }
|
float GetMove() const { return x10_move; }
|
||||||
float GetLurkTime() const { return x14_lurkTime; }
|
float GetLurkTime() const { return x14_lurkTime; }
|
||||||
|
@ -138,7 +138,7 @@ public:
|
||||||
void Lurk(CStateManager& mgr, EStateMsg msg, float arg) override;
|
void Lurk(CStateManager& mgr, EStateMsg msg, float arg) override;
|
||||||
bool Leash(CStateManager& mgr, float arg) override;
|
bool Leash(CStateManager& mgr, float arg) override;
|
||||||
bool InRange(CStateManager& mgr, float arg) override;
|
bool InRange(CStateManager& mgr, float arg) override;
|
||||||
bool InPosition(CStateManager& mgr, float arg) override;
|
bool ShouldAttack(CStateManager& mgr, float arg) override;
|
||||||
bool AggressionCheck(CStateManager& mgr, float arg) override;
|
bool AggressionCheck(CStateManager& mgr, float arg) override;
|
||||||
bool ShouldTaunt(CStateManager& mgr, float arg) override;
|
bool ShouldTaunt(CStateManager& mgr, float arg) override;
|
||||||
bool ShouldFlinch(CStateManager& mgr, float arg) override;
|
bool ShouldFlinch(CStateManager& mgr, float arg) override;
|
||||||
|
|
Loading…
Reference in New Issue