CChozoGhost: Minor fixes & renaming

This commit is contained in:
Luke Street 2020-03-11 02:16:55 -04:00
parent 123ddfd33a
commit 860f7c7f33
2 changed files with 111 additions and 112 deletions

View File

@ -87,8 +87,8 @@ CChozoGhost::CChozoGhost(TUniqueId uid, std::string_view name, const CEntityInfo
, x608_(chance3) , x608_(chance3)
, x628_soundImpact(soundImpact) , x628_soundImpact(soundImpact)
, x62c_(f5) , x62c_(f5)
, x630_(sId2) , x630_sfxFadeIn(sId2)
, x632_(sId3) , x632_sfxFadeOut(sId3)
, x634_(f6) , x634_(f6)
, x638_hurlRecoverTime(hurlRecoverTime) , x638_hurlRecoverTime(hurlRecoverTime)
, x63c_(w2) , x63c_(w2)
@ -97,21 +97,21 @@ CChozoGhost::CChozoGhost(TUniqueId uid, std::string_view name, const CEntityInfo
, x658_(f9) , x658_(f9)
, x65c_nearChance(nearChance) , x65c_nearChance(nearChance)
, x660_midChance(midChance) , x660_midChance(midChance)
, x664_24_(w1) , x664_24_behaviorEnabled(w1)
, x664_25_flinch(!w1) , x664_25_flinch(!w1)
, x664_26_(false) , x664_26_alert(false)
, x664_27_onGround(false) , x664_27_onGround(false)
, x664_28_(false) , x664_28_(false)
, x664_29_(false) , x664_29_fadedIn(false)
, x664_30_(false) , x664_30_fadedOut(false)
, x664_31_(false) , x664_31_(false)
, x665_24_(true) , x665_24_(true)
, x665_25_(false) , x665_25_(false)
, x665_26_(false) , x665_26_shouldSwoosh(false)
, x665_27_playerInLeashRange(false) , x665_27_playerInLeashRange(false)
, x665_28_inRange(false) , x665_28_inRange(false)
, x665_29_aggressive(false) , x665_29_aggressive(false)
, x680_behaveType(x664_24_ ? EBehaveType::Attack : EBehaveType::Four) , x680_behaveType(x664_24_behaviorEnabled ? EBehaveType::Attack : EBehaveType::None)
, x68c_boneTracking(*GetModelData()->GetAnimationData(), "Head_1"sv, zeus::degToRad(80.f), zeus::degToRad(180.f), , x68c_boneTracking(*GetModelData()->GetAnimationData(), "Head_1"sv, zeus::degToRad(80.f), zeus::degToRad(180.f),
EBoneTrackingFlags::None) { EBoneTrackingFlags::None) {
x578_.Token().Lock(); x578_.Token().Lock();
@ -121,7 +121,7 @@ CChozoGhost::CChozoGhost(TUniqueId uid, std::string_view name, const CEntityInfo
x66c_ = GetModelData()->GetScale().z() * x66c_ = GetModelData()->GetScale().z() *
GetAnimationDistance(CPASAnimParmData(15, CPASAnimParm::FromEnum(1), CPASAnimParm::FromReal32(90.f))); GetAnimationDistance(CPASAnimParmData(15, CPASAnimParm::FromEnum(1), CPASAnimParm::FromReal32(90.f)));
x670_ = GetModelData()->GetScale().z() * x670_ = GetModelData()->GetScale().z() *
GetAnimationDistance(CPASAnimParmData(7, CPASAnimParm::FromEnum(1), CPASAnimParm::FromEnum(2))); GetAnimationDistance(CPASAnimParmData(7, CPASAnimParm::FromEnum(2), CPASAnimParm::FromEnum(1)));
if (projectileVisorEffect.IsValid()) if (projectileVisorEffect.IsValid())
x640_projectileVisor = g_SimplePool->GetObj({SBIG('PART'), projectileVisorEffect}); x640_projectileVisor = g_SimplePool->GetObj({SBIG('PART'), projectileVisorEffect});
@ -149,9 +149,9 @@ void CChozoGhost::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStat
x665_29_aggressive = true; x665_29_aggressive = true;
break; break;
case EScriptObjectMessage::Alert: case EScriptObjectMessage::Alert:
if (x664_26_) if (x664_26_alert)
break; break;
x664_26_ = true; x664_26_alert = true;
x400_24_hitByPlayerProjectile = true; x400_24_hitByPlayerProjectile = true;
break; break;
case EScriptObjectMessage::Falling: case EScriptObjectMessage::Falling:
@ -176,7 +176,7 @@ void CChozoGhost::Think(float dt, CStateManager& mgr) {
CPatterned::Think(dt, mgr); CPatterned::Think(dt, mgr);
UpdateThermalFrozenState(false); UpdateThermalFrozenState(false);
x68c_boneTracking.Update(dt); x68c_boneTracking.Update(dt);
x6c8_ = std::max(0.f, x6c8_ - dt); x6c8_spaceWarpTime = std::max(0.f, x6c8_spaceWarpTime - dt);
xe7_31_targetable = IsVisibleEnough(mgr); xe7_31_targetable = IsVisibleEnough(mgr);
} }
@ -213,8 +213,8 @@ void CChozoGhost::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) {
} }
void CChozoGhost::Render(const CStateManager& mgr) const { void CChozoGhost::Render(const CStateManager& mgr) const {
if (x6c8_ > 0.f) if (x6c8_spaceWarpTime > 0.f)
mgr.DrawSpaceWarp(x6cc_, std::sin((M_PIF * x6c8_) / x56c_fadeOutDelay)); mgr.DrawSpaceWarp(x6cc_spaceWarpPosition, std::sin((M_PIF * x6c8_spaceWarpTime) / x56c_fadeOutDelay));
if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay) { if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay) {
CElementGen::SetSubtractBlend(true); CElementGen::SetSubtractBlend(true);
@ -256,18 +256,18 @@ EWeaponCollisionResponseTypes CChozoGhost::GetCollisionResponseType(const zeus::
void CChozoGhost::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) { void CChozoGhost::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) {
if (type == EUserEventType::FadeIn) { if (type == EUserEventType::FadeIn) {
if (x664_30_) { if (x664_30_fadedOut) {
x3e8_alphaDelta = 2.f; x3e8_alphaDelta = 2.f;
CSfxManager::AddEmitter(x630_, GetTranslation(), {}, false, false, 127, -1); CSfxManager::AddEmitter(x630_sfxFadeIn, GetTranslation(), {}, false, false, 127, -1);
} }
AddMaterial(EMaterialTypes::Target, mgr); AddMaterial(EMaterialTypes::Target, mgr);
x664_30_ = false; x664_30_fadedOut = false;
x664_29_ = true; x664_29_fadedIn = true;
return; return;
} else if (type == EUserEventType::Projectile) { } else if (type == EUserEventType::Projectile) {
zeus::CTransform xf = const zeus::CTransform& xf =
zeus::lookAt(GetLctrTransform(node.GetLocatorName()).origin, mgr.GetPlayer().GetAimPosition(mgr, 0.f)); zeus::lookAt(GetLctrTransform(node.GetLocatorName()).origin, mgr.GetPlayer().GetAimPosition(mgr, 0.f));
if (x67c_ == 2) { if (x67c_attackType == 2) {
CGameProjectile* proj = CGameProjectile* proj =
LaunchProjectile(xf, mgr, 2, EProjectileAttrib::BigStrike | EProjectileAttrib::StaticInterference, true, LaunchProjectile(xf, mgr, 2, EProjectileAttrib::BigStrike | EProjectileAttrib::StaticInterference, true,
x640_projectileVisor, x650_sound_ProjectileVisor, false, zeus::skOne3f); x640_projectileVisor, x650_sound_ProjectileVisor, false, zeus::skOne3f);
@ -292,14 +292,14 @@ void CChozoGhost::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node,
} }
return; return;
} else if (type == EUserEventType::FadeOut) { } else if (type == EUserEventType::FadeOut) {
if (x664_29_) { if (x664_29_fadedIn) {
x3e8_alphaDelta = -2.f; x3e8_alphaDelta = -2.f;
CSfxManager::AddEmitter(x632_, GetTranslation(), {}, false, false, 127, -1); CSfxManager::AddEmitter(x632_sfxFadeOut, GetTranslation(), {}, false, false, 127, -1);
} }
RemoveMaterial(EMaterialTypes::Target, mgr); RemoveMaterial(EMaterialTypes::Target, mgr);
x664_29_ = false; x664_29_fadedIn = false;
x664_30_ = true; x664_30_fadedOut = true;
x665_26_ = true; x665_26_shouldSwoosh = true;
return; return;
} }
@ -326,25 +326,25 @@ void CChozoGhost::KnockBack(const zeus::CVector3f& dir, CStateManager& mgr, cons
} }
} }
bool CChozoGhost::CanBeShot(const CStateManager& mgr, int w1) { return IsVisibleEnough(mgr); } bool CChozoGhost::CanBeShot(const CStateManager& mgr, int) { return IsVisibleEnough(mgr); }
void CChozoGhost::Dead(CStateManager& mgr, EStateMsg msg, float arg) { void CChozoGhost::Dead(CStateManager& mgr, EStateMsg msg, float) {
if (msg == EStateMsg::Activate) { if (msg == EStateMsg::Activate) {
ReleaseCoverPoint(mgr, x674_coverPoint); ReleaseCoverPoint(mgr, x674_coverPoint);
x3e8_alphaDelta = 4.f; x3e8_alphaDelta = 4.f;
x664_30_ = false; x664_30_fadedOut = false;
x664_29_ = false; x664_29_fadedIn = false;
x68c_boneTracking.SetActive(false); x68c_boneTracking.SetActive(false);
Stop(); Stop();
} }
} }
void CChozoGhost::SelectTarget(CStateManager& mgr, EStateMsg msg, float arg) { void CChozoGhost::SelectTarget(CStateManager& mgr, EStateMsg msg, float) {
if (msg == EStateMsg::Activate) if (msg == EStateMsg::Activate)
FindBestAnchor(mgr); FindBestAnchor(mgr);
} }
void CChozoGhost::Run(CStateManager& mgr, EStateMsg msg, float arg) { void CChozoGhost::Run(CStateManager& mgr, EStateMsg msg, float dt) {
if (msg == EStateMsg::Activate) { if (msg == EStateMsg::Activate) {
GetBodyController()->SetLocomotionType(pas::ELocomotionType::Lurk); GetBodyController()->SetLocomotionType(pas::ELocomotionType::Lurk);
x400_24_hitByPlayerProjectile = false; x400_24_hitByPlayerProjectile = false;
@ -352,13 +352,13 @@ void CChozoGhost::Run(CStateManager& mgr, EStateMsg msg, float arg) {
x665_28_inRange = false; x665_28_inRange = false;
} else if (msg == EStateMsg::Update) { } else if (msg == EStateMsg::Update) {
GetBodyController()->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(x688_.Seek(*this, x2e0_destPos), {}, 1.f)); GetBodyController()->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(x688_.Seek(*this, x2e0_destPos), {}, 1.f));
if (x665_26_) { if (x665_26_shouldSwoosh) {
x678_ = x2e0_destPos.z(); x678_floorLevel = x2e0_destPos.z();
FloatToLevel(x678_, arg); FloatToLevel(x678_floorLevel, dt);
GetModelData()->GetAnimationData()->SetParticleEffectState("SpeedSwoosh", true, mgr); GetModelData()->GetAnimationData()->SetParticleEffectState("SpeedSwoosh", true, mgr);
x665_24_ = false; x665_24_ = false;
if (!x665_28_inRange) { if (!x665_28_inRange) {
const float range = 2.5f * (arg * x138_velocity.magnitude()) + x66c_; const float range = 2.5f * (dt * x138_velocity.magnitude()) + x66c_;
x665_28_inRange = (GetTranslation() - x2e0_destPos).magSquared() < range * range; x665_28_inRange = (GetTranslation() - x2e0_destPos).magSquared() < range * range;
} }
} }
@ -371,34 +371,35 @@ void CChozoGhost::Run(CStateManager& mgr, EStateMsg msg, float arg) {
} }
} }
void CChozoGhost::Generate(CStateManager& mgr, EStateMsg msg, float arg) { void CChozoGhost::Generate(CStateManager& mgr, EStateMsg msg, float dt) {
if (msg == EStateMsg::Activate) { if (msg == EStateMsg::Activate) {
x330_stateMachineState.SetDelay(x56c_fadeOutDelay); x330_stateMachineState.SetDelay(x56c_fadeOutDelay);
x32c_animState = EAnimState::Ready; x32c_animState = EAnimState::Ready;
x664_27_onGround = false; x664_27_onGround = false;
CRayCastResult res = mgr.RayStaticIntersection(GetTranslation(), zeus::skDown, 100.f, const CRayCastResult& res = mgr.RayStaticIntersection(GetTranslation(), zeus::skDown, 100.f,
CMaterialFilter::MakeInclude({EMaterialTypes::Floor})); CMaterialFilter::MakeInclude({EMaterialTypes::Floor}));
if (res.IsInvalid()) { if (res.IsInvalid()) {
x678_ = mgr.GetPlayer().GetTranslation().z(); x678_floorLevel = mgr.GetPlayer().GetTranslation().z();
} else } else {
x678_ = res.GetPoint().z(); x678_floorLevel = res.GetPoint().z();
}
x3e8_alphaDelta = 1.f; x3e8_alphaDelta = 1.f;
x664_29_ = true; x664_29_fadedIn = true;
if (x56c_fadeOutDelay > 0.f) { if (x56c_fadeOutDelay > 0.f) {
x6c8_ = x56c_fadeOutDelay; x6c8_spaceWarpTime = x56c_fadeOutDelay;
FindNearestSolid(mgr, zeus::skDown); FindSpaceWarpPosition(mgr, zeus::skDown);
} }
} else if (msg == EStateMsg::Update) { } else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::Jump, &CPatterned::TryJump, 0); TryCommand(mgr, pas::EAnimationState::Jump, &CPatterned::TryJump, 0);
if (x32c_animState == EAnimState::Over) { if (x32c_animState == EAnimState::Over) {
x68c_boneTracking.SetActive(true); x68c_boneTracking.SetActive(true);
x68c_boneTracking.SetTarget(mgr.GetPlayer().GetUniqueId()); x68c_boneTracking.SetTarget(mgr.GetPlayer().GetUniqueId());
FloatToLevel(x678_, arg); FloatToLevel(x678_floorLevel, dt);
} else if (x32c_animState == EAnimState::Repeat) { } else if (x32c_animState == EAnimState::Repeat) {
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Crouch); x450_bodyController->SetLocomotionType(pas::ELocomotionType::Crouch);
if (!x664_27_onGround) { if (!x664_27_onGround) {
zeus::CVector3f pos = GetTranslation(); const zeus::CVector3f& pos = GetTranslation();
SetTranslation({pos.x(), pos.y(), x678_ + x668_}); SetTranslation({pos.x(), pos.y(), x678_floorLevel + x668_});
x664_27_onGround = true; x664_27_onGround = true;
} }
} }
@ -409,7 +410,7 @@ void CChozoGhost::Generate(CStateManager& mgr, EStateMsg msg, float arg) {
} }
} }
void CChozoGhost::Deactivate(CStateManager& mgr, EStateMsg msg, float arg) { void CChozoGhost::Deactivate(CStateManager& mgr, EStateMsg msg, float) {
if (msg == EStateMsg::Activate) { if (msg == EStateMsg::Activate) {
x68c_boneTracking.SetActive(false); x68c_boneTracking.SetActive(false);
ReleaseCoverPoint(mgr, x674_coverPoint); ReleaseCoverPoint(mgr, x674_coverPoint);
@ -424,39 +425,39 @@ void CChozoGhost::Deactivate(CStateManager& mgr, EStateMsg msg, float arg) {
} }
} }
void CChozoGhost::Attack(CStateManager& mgr, EStateMsg msg, float arg) { void CChozoGhost::Attack(CStateManager& mgr, EStateMsg msg, float dt) {
if (msg == EStateMsg::Activate) { if (msg == EStateMsg::Activate) {
CTeamAiMgr::AddAttacker(CTeamAiMgr::EAttackType::Melee, mgr, x6c4_teamMgr, GetUniqueId()); CTeamAiMgr::AddAttacker(CTeamAiMgr::EAttackType::Melee, mgr, x6c4_teamMgr, GetUniqueId());
x32c_animState = EAnimState::Ready; x32c_animState = EAnimState::Ready;
if (x6d8_ == 1) if (x6d8_ == 1)
x67c_ = 3; x67c_attackType = 3;
else if (x6d8_ == 2) else if (x6d8_ == 2)
x67c_ = 4; x67c_attackType = 4;
else if (x6d8_ == 3) else if (x6d8_ == 3)
x67c_ = 5; x67c_attackType = 5;
if (x665_26_ && mgr.RayStaticIntersection(GetTranslation() + (zeus::skUp * 0.5f), zeus::skUp, x670_, const CRayCastResult& res = mgr.RayStaticIntersection(GetTranslation() + (zeus::skUp * 0.5f), zeus::skUp, x670_,
CMaterialFilter::MakeInclude({EMaterialTypes::Solid})) CMaterialFilter::MakeInclude({EMaterialTypes::Solid}));
.IsValid()) { if (x665_26_shouldSwoosh && res.IsValid()) {
x67c_ = 2; x67c_attackType = 2;
x460_knockBackController.SetAvailableState(EKnockBackAnimationState::KnockBack, false); x460_knockBackController.SetAvailableState(EKnockBackAnimationState::KnockBack, false);
} }
x150_momentum.zeroOut(); x150_momentum.zeroOut();
xfc_constantForce.zeroOut(); xfc_constantForce.zeroOut();
} else if (msg == EStateMsg::Update) { } else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::MeleeAttack, &CPatterned::TryMeleeAttack, x67c_); TryCommand(mgr, pas::EAnimationState::MeleeAttack, &CPatterned::TryMeleeAttack, x67c_attackType);
GetBodyController()->GetCommandMgr().SetTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation()); GetBodyController()->GetCommandMgr().SetTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation());
if (x67c_ != 2) if (x67c_attackType != 2)
FloatToLevel(x678_, arg); FloatToLevel(x678_floorLevel, dt);
} else if (msg == EStateMsg::Deactivate) { } else if (msg == EStateMsg::Deactivate) {
x32c_animState = EAnimState::NotReady; x32c_animState = EAnimState::NotReady;
x665_26_ = false; x665_26_shouldSwoosh = false;
x460_knockBackController.SetAvailableState(EKnockBackAnimationState::KnockBack, true); x460_knockBackController.SetAvailableState(EKnockBackAnimationState::KnockBack, true);
CTeamAiMgr::ResetTeamAiRole(CTeamAiMgr::EAttackType::Ranged, mgr, x6c4_teamMgr, GetUniqueId(), true); CTeamAiMgr::ResetTeamAiRole(CTeamAiMgr::EAttackType::Ranged, mgr, x6c4_teamMgr, GetUniqueId(), true);
} }
} }
void CChozoGhost::Shuffle(CStateManager& mgr, EStateMsg msg, float arg) { void CChozoGhost::Shuffle(CStateManager& mgr, EStateMsg msg, float) {
if (msg != EStateMsg::Activate) if (msg != EStateMsg::Activate)
return; return;
@ -480,7 +481,7 @@ void CChozoGhost::Shuffle(CStateManager& mgr, EStateMsg msg, float arg) {
x665_27_playerInLeashRange = false; x665_27_playerInLeashRange = false;
} }
void CChozoGhost::InActive(CStateManager& mgr, EStateMsg msg, float arg) { void CChozoGhost::InActive(CStateManager& mgr, EStateMsg msg, float) {
if (msg == EStateMsg::Activate) { if (msg == EStateMsg::Activate) {
if (!x450_bodyController->GetActive()) if (!x450_bodyController->GetActive())
x450_bodyController->Activate(mgr); x450_bodyController->Activate(mgr);
@ -499,19 +500,19 @@ void CChozoGhost::InActive(CStateManager& mgr, EStateMsg msg, float arg) {
} }
} }
void CChozoGhost::Taunt(CStateManager& mgr, EStateMsg msg, float arg) { void CChozoGhost::Taunt(CStateManager& mgr, EStateMsg msg, float dt) {
if (msg == EStateMsg::Activate) { if (msg == EStateMsg::Activate) {
x32c_animState = EAnimState::Ready; x32c_animState = EAnimState::Ready;
} else if (msg == EStateMsg::Update) { } else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::Taunt, &CPatterned::TryTaunt, 0); TryCommand(mgr, pas::EAnimationState::Taunt, &CPatterned::TryTaunt, 0);
FloatToLevel(x678_, arg); FloatToLevel(x678_floorLevel, dt);
} else { } else {
x32c_animState = EAnimState::NotReady; x32c_animState = EAnimState::NotReady;
x665_26_ = false; x665_26_shouldSwoosh = false;
} }
} }
void CChozoGhost::Hurled(CStateManager& mgr, EStateMsg msg, float arg) { void CChozoGhost::Hurled(CStateManager& mgr, EStateMsg msg, float) {
if (msg == EStateMsg::Activate) { if (msg == EStateMsg::Activate) {
x328_25_verticalMovement = false; x328_25_verticalMovement = false;
x664_27_onGround = false; x664_27_onGround = false;
@ -522,15 +523,13 @@ void CChozoGhost::Hurled(CStateManager& mgr, EStateMsg msg, float arg) {
return; return;
if (x138_velocity.z() < 0.f) { if (x138_velocity.z() < 0.f) {
CRayCastResult res = mgr.RayStaticIntersection(GetTranslation() + zeus::skUp, zeus::skDown, 2.f, const CRayCastResult& res = mgr.RayStaticIntersection(GetTranslation() + zeus::skUp, zeus::skDown, 2.f,
CMaterialFilter::MakeInclude({EMaterialTypes::Floor})); CMaterialFilter::MakeInclude({EMaterialTypes::Floor}));
if (res.IsValid()) { if (res.IsValid()) {
x664_27_onGround = true; x664_27_onGround = true;
x150_momentum.zeroOut(); x150_momentum.zeroOut();
zeus::CVector3f velNoZ = x138_velocity; SetVelocityWR({x138_velocity.x(), x138_velocity.y(), 0.f});
velNoZ.z() = 0.f; x678_floorLevel = res.GetPoint().z();
SetVelocityWR(velNoZ);
x678_ = res.GetPoint().z();
x330_stateMachineState.SetCodeTrigger(); x330_stateMachineState.SetCodeTrigger();
} }
} }
@ -545,14 +544,14 @@ void CChozoGhost::Hurled(CStateManager& mgr, EStateMsg msg, float arg) {
} }
} }
void CChozoGhost::WallDetach(CStateManager& mgr, EStateMsg msg, float arg) { void CChozoGhost::WallDetach(CStateManager& mgr, EStateMsg msg, float) {
if (msg == EStateMsg::Activate) { if (msg == EStateMsg::Activate) {
x330_stateMachineState.SetDelay(x56c_fadeOutDelay); x330_stateMachineState.SetDelay(x56c_fadeOutDelay);
x3e8_alphaDelta = 0.f; x3e8_alphaDelta = 0.f;
x664_29_ = false; x664_29_fadedIn = false;
if (x56c_fadeOutDelay > 0.f) { if (x56c_fadeOutDelay > 0.f) {
x6c8_ = x56c_fadeOutDelay; x6c8_spaceWarpTime = x56c_fadeOutDelay;
FindNearestSolid(mgr, GetTransform().basis[1]); FindSpaceWarpPosition(mgr, GetTransform().basis[1]);
} }
TUniqueId wpId = GetWaypointForState(mgr, EScriptObjectState::Attack, EScriptObjectMessage::Follow); TUniqueId wpId = GetWaypointForState(mgr, EScriptObjectState::Attack, EScriptObjectMessage::Follow);
TCastToConstPtr<CScriptWaypoint> wp; TCastToConstPtr<CScriptWaypoint> wp;
@ -573,15 +572,15 @@ void CChozoGhost::WallDetach(CStateManager& mgr, EStateMsg msg, float arg) {
} }
} }
void CChozoGhost::Growth(CStateManager& mgr, EStateMsg msg, float arg) { void CChozoGhost::Growth(CStateManager& mgr, EStateMsg msg, float) {
if (msg == EStateMsg::Activate) { if (msg == EStateMsg::Activate) {
x330_stateMachineState.SetDelay(x56c_fadeOutDelay); x330_stateMachineState.SetDelay(x56c_fadeOutDelay);
GetBodyController()->SetLocomotionType(pas::ELocomotionType::Crouch); GetBodyController()->SetLocomotionType(pas::ELocomotionType::Crouch);
x3e8_alphaDelta = 1.f; x3e8_alphaDelta = 1.f;
x664_29_ = true; x664_29_fadedIn = true;
if (x56c_fadeOutDelay > 0.f) { if (x56c_fadeOutDelay > 0.f) {
x6c8_ = x56c_fadeOutDelay; x6c8_spaceWarpTime = x56c_fadeOutDelay;
FindNearestSolid(mgr, zeus::skUp); FindSpaceWarpPosition(mgr, zeus::skUp);
} }
} else if (msg == EStateMsg::Deactivate) { } else if (msg == EStateMsg::Deactivate) {
x665_24_ = false; x665_24_ = false;
@ -590,20 +589,20 @@ void CChozoGhost::Growth(CStateManager& mgr, EStateMsg msg, float arg) {
} }
} }
void CChozoGhost::Land(CStateManager& mgr, EStateMsg msg, float arg) { void CChozoGhost::Land(CStateManager& mgr, EStateMsg msg, float dt) {
if (msg == EStateMsg::Update) { if (msg == EStateMsg::Update) {
FloatToLevel(x678_, arg); FloatToLevel(x678_floorLevel, dt);
if (std::fabs(x678_ - GetTranslation().z()) < 0.05f) { if (std::fabs(x678_floorLevel - GetTranslation().z()) < 0.05f) {
x330_stateMachineState.SetCodeTrigger(); x330_stateMachineState.SetCodeTrigger();
} }
} }
} }
void CChozoGhost::Lurk(CStateManager& mgr, EStateMsg msg, float arg) { void CChozoGhost::Lurk(CStateManager& mgr, EStateMsg msg, float dt) {
if (msg == EStateMsg::Activate) { if (msg == EStateMsg::Activate) {
x330_stateMachineState.SetDelay(x684_lurkDelay); x330_stateMachineState.SetDelay(x684_lurkDelay);
} else if (msg == EStateMsg::Update) { } else if (msg == EStateMsg::Update) {
FloatToLevel(x678_, arg); FloatToLevel(x678_floorLevel, dt);
} }
} }
@ -633,7 +632,7 @@ u8 CChozoGhost::GetModelAlphau8(const CStateManager& mgr) const {
bool CChozoGhost::IsOnGround() const { return x664_27_onGround; } bool CChozoGhost::IsOnGround() const { return x664_27_onGround; }
CProjectileInfo* CChozoGhost::GetProjectileInfo() { return x67c_ == 2 ? &x578_ : &x5a0_; } CProjectileInfo* CChozoGhost::GetProjectileInfo() { return x67c_attackType == 2 ? &x578_ : &x5a0_; }
void CChozoGhost::AddToTeam(CStateManager& mgr) { void CChozoGhost::AddToTeam(CStateManager& mgr) {
if (x6c4_teamMgr == kInvalidUniqueId) if (x6c4_teamMgr == kInvalidUniqueId)
@ -659,9 +658,9 @@ void CChozoGhost::RemoveFromTeam(CStateManager& mgr) {
} }
} }
void CChozoGhost::FloatToLevel(float f1, float f2) { void CChozoGhost::FloatToLevel(float level, float dt) {
const zeus::CVector3f& pos = GetTranslation(); const zeus::CVector3f& pos = GetTranslation();
SetTranslation({pos.x(), pos.y(), 4.f * (f1 - pos.z()) * f2 + pos.z()}); SetTranslation({pos.x(), pos.y(), 4.f * (level - pos.z()) * dt + pos.z()});
} }
const CChozoGhost::CBehaveChance& CChozoGhost::ChooseBehaveChanceRange(CStateManager& mgr) { const CChozoGhost::CBehaveChance& CChozoGhost::ChooseBehaveChanceRange(CStateManager& mgr) {
@ -674,14 +673,14 @@ const CChozoGhost::CBehaveChance& CChozoGhost::ChooseBehaveChanceRange(CStateMan
return x5c8_; return x5c8_;
} }
void CChozoGhost::FindNearestSolid(CStateManager& mgr, const zeus::CVector3f& dir) { void CChozoGhost::FindSpaceWarpPosition(CStateManager& mgr, const zeus::CVector3f& dir) {
const zeus::CVector3f& center = GetBoundingBox().center(); const zeus::CVector3f& center = GetBoundingBox().center();
const CRayCastResult& res = const CRayCastResult& res =
mgr.RayStaticIntersection(center + (dir * 8.f), -dir, 8.f, CMaterialFilter::MakeInclude({EMaterialTypes::Solid})); mgr.RayStaticIntersection(center + (dir * 8.f), -dir, 8.f, CMaterialFilter::MakeInclude({EMaterialTypes::Solid}));
if (res.IsInvalid()) { if (res.IsInvalid()) {
x6cc_ = center + dir; x6cc_spaceWarpPosition = center + dir;
} else { } else {
x6cc_ = res.GetPoint(); x6cc_spaceWarpPosition = res.GetPoint();
} }
} }

View File

@ -10,7 +10,7 @@
#include <zeus/CVector3f.hpp> #include <zeus/CVector3f.hpp>
namespace urde::MP1 { namespace urde::MP1 {
enum class EBehaveType { Lurk, Taunt, Attack, Move, Four }; enum class EBehaveType { Lurk, Taunt, Attack, Move, None };
class CChozoGhost : public CPatterned { class CChozoGhost : public CPatterned {
public: public:
@ -49,8 +49,8 @@ private:
CBehaveChance x608_; CBehaveChance x608_;
s16 x628_soundImpact; s16 x628_soundImpact;
float x62c_; float x62c_;
s16 x630_; s16 x630_sfxFadeIn;
s16 x632_; s16 x632_sfxFadeOut;
float x634_; float x634_;
float x638_hurlRecoverTime; float x638_hurlRecoverTime;
u32 x63c_; u32 x63c_;
@ -60,17 +60,17 @@ private:
float x658_; float x658_;
u32 x65c_nearChance; u32 x65c_nearChance;
u32 x660_midChance; u32 x660_midChance;
bool x664_24_ : 1; bool x664_24_behaviorEnabled : 1;
bool x664_25_flinch : 1; bool x664_25_flinch : 1;
bool x664_26_ : 1; bool x664_26_alert : 1;
bool x664_27_onGround : 1; bool x664_27_onGround : 1;
bool x664_28_ : 1; bool x664_28_ : 1;
bool x664_29_ : 1; bool x664_29_fadedIn : 1;
bool x664_30_ : 1; bool x664_30_fadedOut : 1;
bool x664_31_ : 1; bool x664_31_ : 1;
bool x665_24_ : 1; bool x665_24_ : 1;
bool x665_25_ : 1; bool x665_25_ : 1;
bool x665_26_ : 1; bool x665_26_shouldSwoosh : 1;
bool x665_27_playerInLeashRange : 1; bool x665_27_playerInLeashRange : 1;
bool x665_28_inRange : 1; bool x665_28_inRange : 1;
bool x665_29_aggressive : 1; bool x665_29_aggressive : 1;
@ -78,23 +78,23 @@ private:
float x66c_ = 0.f; float x66c_ = 0.f;
float x670_ = 0.f; float x670_ = 0.f;
TUniqueId x674_coverPoint = kInvalidUniqueId; TUniqueId x674_coverPoint = kInvalidUniqueId;
float x678_ = 0.f; float x678_floorLevel = 0.f;
u32 x67c_ = -1; u32 x67c_attackType = -1;
EBehaveType x680_behaveType = EBehaveType::Lurk; EBehaveType x680_behaveType = EBehaveType::Lurk;
float x684_lurkDelay = 1.f; float x684_lurkDelay = 1.f;
CSteeringBehaviors x688_; CSteeringBehaviors x688_;
CBoneTracking x68c_boneTracking; CBoneTracking x68c_boneTracking;
TUniqueId x6c4_teamMgr = kInvalidUniqueId; TUniqueId x6c4_teamMgr = kInvalidUniqueId;
float x6c8_ = 0.f; float x6c8_spaceWarpTime = 0.f;
zeus::CVector3f x6cc_; zeus::CVector3f x6cc_spaceWarpPosition;
u32 x6d8_ = 1; u32 x6d8_ = 1;
void AddToTeam(CStateManager& mgr); void AddToTeam(CStateManager& mgr);
void RemoveFromTeam(CStateManager& mgr); void RemoveFromTeam(CStateManager& mgr);
void FloatToLevel(float f1, float f2); void FloatToLevel(float f1, float dt);
const CBehaveChance& ChooseBehaveChanceRange(CStateManager& mgr); const CBehaveChance& ChooseBehaveChanceRange(CStateManager& mgr);
bool IsVisibleEnough(const CStateManager& mgr) const { return GetModelAlphau8(mgr) > 31; } bool IsVisibleEnough(const CStateManager& mgr) const { return GetModelAlphau8(mgr) > 31; }
void FindNearestSolid(CStateManager& mgr, const zeus::CVector3f& dir); void FindSpaceWarpPosition(CStateManager& mgr, const zeus::CVector3f& dir);
void FindBestAnchor(CStateManager& mgr); void FindBestAnchor(CStateManager& mgr);
public: public:
@ -124,18 +124,18 @@ public:
} }
void Dead(CStateManager& mgr, EStateMsg msg, float arg) override; void Dead(CStateManager& mgr, EStateMsg msg, float arg) override;
void SelectTarget(CStateManager& mgr, EStateMsg msg, float arg) override; void SelectTarget(CStateManager& mgr, EStateMsg msg, float arg) override;
void Run(CStateManager& mgr, EStateMsg msg, float arg) override; void Run(CStateManager& mgr, EStateMsg msg, float dt) override;
void Generate(CStateManager& mgr, EStateMsg msg, float arg) override; void Generate(CStateManager& mgr, EStateMsg msg, float dt) override;
void Deactivate(CStateManager& mgr, EStateMsg msg, float arg) override; void Deactivate(CStateManager& mgr, EStateMsg msg, float arg) override;
void Attack(CStateManager& mgr, EStateMsg msg, float arg) override; void Attack(CStateManager& mgr, EStateMsg msg, float dt) override;
void Shuffle(CStateManager& mgr, EStateMsg msg, float arg) override; void Shuffle(CStateManager& mgr, EStateMsg msg, float arg) override;
void InActive(CStateManager& mgr, EStateMsg msg, float arg) override; void InActive(CStateManager& mgr, EStateMsg msg, float arg) override;
void Taunt(CStateManager& mgr, EStateMsg msg, float arg) override; void Taunt(CStateManager& mgr, EStateMsg msg, float dt) override;
void Hurled(CStateManager& mgr, EStateMsg msg, float arg) override; void Hurled(CStateManager& mgr, EStateMsg msg, float arg) override;
void WallDetach(CStateManager& mgr, EStateMsg msg, float arg) override; void WallDetach(CStateManager& mgr, EStateMsg msg, float arg) override;
void Growth(CStateManager& mgr, EStateMsg msg, float arg) override; void Growth(CStateManager& mgr, EStateMsg msg, float dt) override;
void Land(CStateManager& mgr, EStateMsg msg, float arg) override; void Land(CStateManager& mgr, EStateMsg msg, float dt) override;
void Lurk(CStateManager& mgr, EStateMsg msg, float arg) override; void Lurk(CStateManager& mgr, EStateMsg msg, float dt) 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 ShouldAttack(CStateManager& mgr, float arg) override; bool ShouldAttack(CStateManager& mgr, float arg) override;