CChozoGhost: InPosition -> ShouldAttack

This commit is contained in:
Luke Street 2020-03-11 00:22:03 -04:00
parent 155cd3759f
commit 123ddfd33a
2 changed files with 35 additions and 35 deletions

View File

@ -17,51 +17,51 @@ namespace urde::MP1 {
CChozoGhost::CBehaveChance::CBehaveChance(CInputStream& in)
: x0_propertyCount(in.readUint32Big())
, x4_lurk(in.readFloatBig())
, x8_(in.readFloatBig())
, x8_taunt(in.readFloatBig())
, xc_attack(in.readFloatBig())
, x10_move(in.readFloatBig())
, x14_lurkTime(in.readFloatBig())
, x18_chargeAttack(x0_propertyCount <= 5 ? 0.5f : in.readFloatBig() * .01f)
, x1c_numBolts(x0_propertyCount <= 6 ? 2 : in.readUint32Big()) {
float f2 = 1.f / (x10_move + xc_attack + x4_lurk + x8_);
, x18_chargeAttack(x0_propertyCount < 6 ? 0.5f : in.readFloatBig() * .01f)
, x1c_numBolts(x0_propertyCount < 7 ? 2 : in.readUint32Big()) {
float f2 = 1.f / (x10_move + xc_attack + x4_lurk + x8_taunt);
x4_lurk *= f2;
x8_ *= f2;
x8_taunt *= f2;
xc_attack *= f2;
x10_move *= f2;
}
EBehaveType CChozoGhost::CBehaveChance::GetBehave(EBehaveType type, CStateManager& mgr) const {
float dVar5 = x4_lurk;
float dVar4 = x8_;
float dVar3 = xc_attack;
float lurkChance = x4_lurk;
float tauntChance = x8_taunt;
float attackChance = xc_attack;
if (type == EBehaveType::Lurk) {
float dVar2 = dVar5 / 3.f;
dVar5 = 0.f;
dVar4 += dVar2;
dVar3 += dVar2;
} else if (type == EBehaveType::One) {
float dVar2 = dVar4 / 3.f;
dVar4 = 0.f;
dVar5 += dVar2;
dVar3 += dVar2;
float delta = lurkChance / 3.f;
lurkChance = 0.f;
tauntChance += delta;
attackChance += delta;
} else if (type == EBehaveType::Taunt) {
float delta = tauntChance / 3.f;
tauntChance = 0.f;
lurkChance += delta;
attackChance += delta;
} else if (type == EBehaveType::Attack) {
float dVar2 = dVar3 / 3.f;
dVar3 = 0.f;
dVar5 += dVar2;
dVar4 += dVar2;
float delta = attackChance / 3.f;
attackChance = 0.f;
lurkChance += delta;
tauntChance += delta;
} else if (type == EBehaveType::Move) {
float dVar2 = x10_move / 3.f;
dVar5 += dVar2;
dVar4 += dVar2;
dVar3 += dVar2;
float delta = x10_move / 3.f;
lurkChance += delta;
tauntChance += delta;
attackChance += delta;
}
float rnd = mgr.GetActiveRandom()->Float();
if (dVar5 > rnd)
if (lurkChance > rnd)
return EBehaveType::Lurk;
else if (dVar4 > (rnd - dVar5))
return EBehaveType::One;
else if (dVar3 > (rnd - dVar5) - dVar4)
else if (tauntChance > rnd - lurkChance)
return EBehaveType::Taunt;
else if (attackChance > rnd - lurkChance - tauntChance)
return EBehaveType::Attack;
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::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::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; }

View File

@ -10,14 +10,14 @@
#include <zeus/CVector3f.hpp>
namespace urde::MP1 {
enum class EBehaveType { Lurk, One, Attack, Move, Four };
enum class EBehaveType { Lurk, Taunt, Attack, Move, Four };
class CChozoGhost : public CPatterned {
public:
class CBehaveChance {
u32 x0_propertyCount;
float x4_lurk;
float x8_;
float x8_taunt;
float xc_attack;
float x10_move;
float x14_lurkTime;
@ -29,7 +29,7 @@ public:
EBehaveType GetBehave(EBehaveType type, CStateManager& mgr) const;
float GetLurk() const { return x4_lurk; }
float GetX8() const { return x8_; }
float GetTaunt() const { return x8_taunt; }
float GetAttack() const { return xc_attack; }
float GetMove() const { return x10_move; }
float GetLurkTime() const { return x14_lurkTime; }
@ -138,7 +138,7 @@ public:
void Lurk(CStateManager& mgr, EStateMsg msg, float arg) override;
bool Leash(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 ShouldTaunt(CStateManager& mgr, float arg) override;
bool ShouldFlinch(CStateManager& mgr, float arg) override;