Various fixes and minor code cleanup, issue warning when attempting to load an unimplemented object

This commit is contained in:
Phillip Stephens 2019-01-31 12:44:05 -08:00
parent 7d29c6e25a
commit 0bb51f067c
34 changed files with 362 additions and 360 deletions

View File

@ -82,10 +82,14 @@ void ViewManager::TestGameView::think() {
overlayText += hecl::Format( overlayText += hecl::Format(
"Player Position: x %f, y %f, z %f\n" "Player Position: x %f, y %f, z %f\n"
" Roll: %f, Pitch: %f, Yaw: %f\n" " Roll: %f, Pitch: %f, Yaw: %f\n"
" Momentum: x %f, y: %f, z: %f\n"
" Velocity: x %f, y: %f, z: %f\n"
"Camera Position: x %f, y %f, z %f\n" "Camera Position: x %f, y %f, z %f\n"
" Roll: %f, Pitch: %f, Yaw: %f\n", " Roll: %f, Pitch: %f, Yaw: %f\n",
pl.GetTranslation().x(), pl.GetTranslation().y(), pl.GetTranslation().z(), pl.GetTranslation().x(), pl.GetTranslation().y(), pl.GetTranslation().z(),
zeus::radToDeg(plQ.roll()), zeus::radToDeg(plQ.pitch()), zeus::radToDeg(plQ.yaw()), zeus::radToDeg(plQ.roll()), zeus::radToDeg(plQ.pitch()), zeus::radToDeg(plQ.yaw()),
pl.GetMomentum().x(), pl.GetMomentum().y(), pl.GetMomentum().z(),
pl.GetVelocity().x(), pl.GetVelocity().y(), pl.GetVelocity().z(),
camXf.origin.x(), camXf.origin.y(), camXf.origin.z(), camXf.origin.x(), camXf.origin.y(), camXf.origin.z(),
zeus::radToDeg(camQ.roll()), zeus::radToDeg(camQ.pitch()), zeus::radToDeg(camQ.yaw())); zeus::radToDeg(camQ.roll()), zeus::radToDeg(camQ.pitch()), zeus::radToDeg(camQ.yaw()));
} }

View File

@ -141,7 +141,7 @@ CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker,
x90c_loaderFuncs[int(EScriptObjectType::AIKeyframe)] = ScriptLoader::LoadAIKeyframe; x90c_loaderFuncs[int(EScriptObjectType::AIKeyframe)] = ScriptLoader::LoadAIKeyframe;
x90c_loaderFuncs[int(EScriptObjectType::PointOfInterest)] = ScriptLoader::LoadPointOfInterest; x90c_loaderFuncs[int(EScriptObjectType::PointOfInterest)] = ScriptLoader::LoadPointOfInterest;
x90c_loaderFuncs[int(EScriptObjectType::Drone)] = ScriptLoader::LoadDrone; x90c_loaderFuncs[int(EScriptObjectType::Drone)] = ScriptLoader::LoadDrone;
x90c_loaderFuncs[int(EScriptObjectType::MetroidAlpha)] = ScriptLoader::LoadMetroidAlpha; x90c_loaderFuncs[int(EScriptObjectType::Metroid)] = ScriptLoader::LoadMetroid;
x90c_loaderFuncs[int(EScriptObjectType::DebrisExtended)] = ScriptLoader::LoadDebrisExtended; x90c_loaderFuncs[int(EScriptObjectType::DebrisExtended)] = ScriptLoader::LoadDebrisExtended;
x90c_loaderFuncs[int(EScriptObjectType::Steam)] = ScriptLoader::LoadSteam; x90c_loaderFuncs[int(EScriptObjectType::Steam)] = ScriptLoader::LoadSteam;
x90c_loaderFuncs[int(EScriptObjectType::Ripple)] = ScriptLoader::LoadRipple; x90c_loaderFuncs[int(EScriptObjectType::Ripple)] = ScriptLoader::LoadRipple;

View File

@ -7,17 +7,13 @@
#include "CStateManager.hpp" #include "CStateManager.hpp"
namespace urde::MP1 { namespace urde::MP1 {
const std::string_view CAtomicAlpha::skBombLocators[4] = { const std::string_view CAtomicAlpha::skBombLocators[4] = {"bomb1_LCTR"sv, "bomb2_LCTR"sv, "bomb3_LCTR"sv,
"bomb1_LCTR"sv, "bomb4_LCTR"sv};
"bomb2_LCTR"sv,
"bomb3_LCTR"sv,
"bomb4_LCTR"sv
};
CAtomicAlpha::CAtomicAlpha(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, CAtomicAlpha::CAtomicAlpha(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const CActorParameters& actParms, const CPatternedInfo& pInfo, CModelData&& mData, const CActorParameters& actParms, const CPatternedInfo& pInfo,
CAssetId bombWeapon, const CDamageInfo& bombDamage, float bombDropDelay, float f2, float f3, CAssetId cmdl, CAssetId bombWeapon, const CDamageInfo& bombDamage, float bombDropDelay, float f2, float f3,
bool invisible, bool b2) CAssetId cmdl, bool invisible, bool b2)
: CPatterned(ECharacter::AtomicAlpha, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo, : CPatterned(ECharacter::AtomicAlpha, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo,
EMovementType::Flyer, EColliderType::One, EBodyType::Flyer, actParms, EKnockBackVariant::Medium) EMovementType::Flyer, EColliderType::One, EBodyType::Flyer, actParms, EKnockBackVariant::Medium)
, x568_24_inRange(false) , x568_24_inRange(false)
@ -32,7 +28,7 @@ CAtomicAlpha::CAtomicAlpha(TUniqueId uid, std::string_view name, const CEntityIn
const_cast<TToken<CWeaponDescription>*>(&x668_bombProjectile.Token())->Lock(); const_cast<TToken<CWeaponDescription>*>(&x668_bombProjectile.Token())->Lock();
for (u32 i = 0; i < skBombCount; ++i) { for (u32 i = 0; i < skBombCount; ++i) {
x6dc_bombLocators.push_back( x6dc_bombLocators.push_back(
SBomb(skBombLocators[i], pas::ELocomotionType(u32(pas::ELocomotionType::Internal10) + i))); SBomb(skBombLocators[i], pas::ELocomotionType(u32(pas::ELocomotionType::Internal10) + i)));
} }
} }
@ -54,8 +50,10 @@ void CAtomicAlpha::Render(const CStateManager& mgr) const {
CPatterned::Render(mgr); CPatterned::Render(mgr);
for (const SBomb& bomb : x6dc_bombLocators) { for (const SBomb& bomb : x6dc_bombLocators) {
zeus::CTransform locatorXf = GetTransform() * GetScaledLocatorTransform(bomb.x0_locatorName) * zeus::CTransform locatorXf =
zeus::CTransform::Scale(std::min(1.f, std::max(0.f, bomb.x14_scaleTime - x570_bombReappearDelay) / x570_bombReappearDelay)); GetTransform() * GetScaledLocatorTransform(bomb.x0_locatorName) *
zeus::CTransform::Scale(
std::min(1.f, std::max(0.f, bomb.x14_scaleTime - x570_bombReappearDelay) / x570_bombReappearDelay));
CModelFlags flags; CModelFlags flags;
flags.x2_flags = 1 | 2; flags.x2_flags = 1 | 2;
flags.x4_color = zeus::CColor::skWhite; flags.x4_color = zeus::CColor::skWhite;

View File

@ -13,8 +13,7 @@ class CAtomicAlpha : public CPatterned {
pas::ELocomotionType x10_locomotionType; pas::ELocomotionType x10_locomotionType;
float x14_scaleTime = FLT_MAX; float x14_scaleTime = FLT_MAX;
SBomb(const std::string_view locator, pas::ELocomotionType locomotionType) SBomb(const std::string_view locator, pas::ELocomotionType locomotionType)
: x0_locatorName(locator.data()) : x0_locatorName(locator.data()), x10_locomotionType(locomotionType) {}
, x10_locomotionType(locomotionType) {}
}; };
bool x568_24_inRange : 1; bool x568_24_inRange : 1;
bool x568_25_invisible : 1; bool x568_25_invisible : 1;
@ -29,6 +28,7 @@ class CAtomicAlpha : public CPatterned {
CProjectileInfo x668_bombProjectile; CProjectileInfo x668_bombProjectile;
CModelData x690_bombModel; CModelData x690_bombModel;
rstl::reserved_vector<SBomb, skBombCount> x6dc_bombLocators; rstl::reserved_vector<SBomb, skBombCount> x6dc_bombLocators;
public: public:
DEFINE_PATTERNED(AtomicAlpha) DEFINE_PATTERNED(AtomicAlpha)

View File

@ -8,17 +8,13 @@
#include "CSimplePool.hpp" #include "CSimplePool.hpp"
namespace urde::MP1 { namespace urde::MP1 {
const std::string_view CAtomicBeta::skBombLocators[3] = { const std::string_view CAtomicBeta::skBombLocators[3] = {"bomb2_LCTR"sv, "bomb3_LCTR"sv, "bomb4_LCTR"sv};
"bomb2_LCTR"sv,
"bomb3_LCTR"sv,
"bomb4_LCTR"sv
};
CAtomicBeta::CAtomicBeta(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, CAtomicBeta::CAtomicBeta(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const CActorParameters& actParms, const CPatternedInfo& pInfo, CModelData&& mData, const CActorParameters& actParms, const CPatternedInfo& pInfo,
CAssetId electricId, CAssetId weaponId, const CDamageInfo& dInfo, CAssetId particleId, CAssetId electricId, CAssetId weaponId, const CDamageInfo& dInfo, CAssetId particleId,
float f1, float beamRadius, float f3, const CDamageVulnerability& dVuln, float f4, float f5, float f6, float f1, float beamRadius, float f3, const CDamageVulnerability& dVuln, float f4, float f5,
s16 sId1, s16 sId2, s16 sId3, float f7) float f6, s16 sId1, s16 sId2, s16 sId3, float f7)
: CPatterned(ECharacter::AtomicBeta, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo, : CPatterned(ECharacter::AtomicBeta, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo,
EMovementType::Flyer, EColliderType::One, EBodyType::RestrictedFlyer, actParms, EKnockBackVariant::Small) EMovementType::Flyer, EColliderType::One, EBodyType::RestrictedFlyer, actParms, EKnockBackVariant::Small)
, x578_(f5) , x578_(f5)
@ -115,7 +111,7 @@ void CAtomicBeta::Think(float dt, CStateManager& mgr) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(movementVec, x5f4_, 1.f)); x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(movementVec, x5f4_, 1.f));
float mag = float mag =
x63c_ * std::max(1.f - (mgr.GetPlayer().GetTranslation() - GetTranslation()).magSquared() / (x640_ / x640_), 0.f); x63c_ * std::max(1.f - (mgr.GetPlayer().GetTranslation() - GetTranslation()).magSquared() / (x640_ / x640_), 0.f);
if (!zeus::close_enough(mag, 0.f)) if (!zeus::close_enough(mag, 0.f))
mgr.GetPlayerState()->GetStaticInterference().AddSource(GetUniqueId(), mag, 0.5f); mgr.GetPlayerState()->GetStaticInterference().AddSource(GetUniqueId(), mag, 0.5f);

View File

@ -8,7 +8,7 @@ class CWeaponDescription;
namespace urde::MP1 { namespace urde::MP1 {
class CAtomicBeta final : public CPatterned { class CAtomicBeta final : public CPatterned {
static const std::string_view skBombLocators[3]; static const std::string_view skBombLocators[3];
static constexpr u32 kBombCount = 3; static constexpr u32 kBombCount = 3;
rstl::reserved_vector<TUniqueId, kBombCount> x568_projectileIds; rstl::reserved_vector<TUniqueId, kBombCount> x568_projectileIds;
bool x574_beamFired = false; bool x574_beamFired = false;
float x578_; float x578_;

View File

@ -33,8 +33,9 @@ CBeetle::CBeetle(TUniqueId uid, std::string_view name, const CEntityInfo& info,
, x814_attackDelayTimer(initialAttackDelay) , x814_attackDelayTimer(initialAttackDelay)
, x834_retreatTime(retreatTime) { , x834_retreatTime(retreatTime) {
x5a0_headbuttDist = GetAnimationDistance(CPASAnimParmData(7, CPASAnimParm::FromEnum(0), CPASAnimParm::FromEnum(1))); x5a0_headbuttDist = GetAnimationDistance(CPASAnimParmData(7, CPASAnimParm::FromEnum(0), CPASAnimParm::FromEnum(1)));
x5a4_jumpBackwardDist = x64_modelData->GetScale().y() * x5a4_jumpBackwardDist =
GetAnimationDistance(CPASAnimParmData(3, CPASAnimParm::FromEnum(1), CPASAnimParm::FromEnum(0))); x64_modelData->GetScale().y() *
GetAnimationDistance(CPASAnimParmData(3, CPASAnimParm::FromEnum(1), CPASAnimParm::FromEnum(0)));
MakeThermalColdAndHot(); MakeThermalColdAndHot();
if (x3fc_flavor == EFlavorType::One) if (x3fc_flavor == EFlavorType::One)
x460_knockBackController.SetLocomotionDuringElectrocution(true); x460_knockBackController.SetLocomotionDuringElectrocution(true);
@ -45,8 +46,8 @@ void CBeetle::Accept(IVisitor& visitor) { visitor.Visit(this); }
void CBeetle::SquadAdd(CStateManager& mgr) { void CBeetle::SquadAdd(CStateManager& mgr) {
if (x570_aiMgr != kInvalidUniqueId) if (x570_aiMgr != kInvalidUniqueId)
if (TCastToPtr<CTeamAiMgr> aimgr = mgr.ObjectById(x570_aiMgr)) if (TCastToPtr<CTeamAiMgr> aimgr = mgr.ObjectById(x570_aiMgr))
aimgr->AssignTeamAiRole(*this, CTeamAiRole::ETeamAiRole::Melee, aimgr->AssignTeamAiRole(*this, CTeamAiRole::ETeamAiRole::Melee, CTeamAiRole::ETeamAiRole::Unknown,
CTeamAiRole::ETeamAiRole::Unknown, CTeamAiRole::ETeamAiRole::Invalid); CTeamAiRole::ETeamAiRole::Invalid);
} }
void CBeetle::SquadRemove(CStateManager& mgr) { void CBeetle::SquadRemove(CStateManager& mgr) {
@ -60,9 +61,9 @@ void CBeetle::Think(float dt, CStateManager& mgr) {
if (!GetActive()) if (!GetActive())
return; return;
if (CTeamAiRole* role = CTeamAiMgr::GetTeamAiRole(mgr, x570_aiMgr, GetUniqueId())) { if (CTeamAiRole* role = CTeamAiMgr::GetTeamAiRole(mgr, x570_aiMgr, GetUniqueId())) {
x450_bodyController->SetLocomotionType( x450_bodyController->SetLocomotionType(role->GetTeamAiRole() == CTeamAiRole::ETeamAiRole::Melee
role->GetTeamAiRole() == CTeamAiRole::ETeamAiRole::Melee ? ? pas::ELocomotionType::Lurk
pas::ELocomotionType::Lurk : pas::ELocomotionType::Relaxed); : pas::ELocomotionType::Relaxed);
} else { } else {
SquadAdd(mgr); SquadAdd(mgr);
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Lurk); x450_bodyController->SetLocomotionType(pas::ELocomotionType::Lurk);
@ -119,8 +120,7 @@ void CBeetle::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CState
SquadAdd(mgr); SquadAdd(mgr);
} }
SetupRetreatPoints(mgr); SetupRetreatPoints(mgr);
x5fc_pathFindSearch.SetArea( x5fc_pathFindSearch.SetArea(mgr.GetWorld()->GetAreaAlways(GetAreaIdAlways())->GetPostConstructed()->x10bc_pathArea);
mgr.GetWorld()->GetAreaAlways(GetAreaIdAlways())->GetPostConstructed()->x10bc_pathArea);
break; break;
default: default:
break; break;
@ -174,8 +174,7 @@ const CDamageVulnerability* CBeetle::GetDamageVulnerability() const {
return CAi::GetDamageVulnerability(); return CAi::GetDamageVulnerability();
} }
const CDamageVulnerability* CBeetle::GetDamageVulnerability(const zeus::CVector3f& pos, const CDamageVulnerability* CBeetle::GetDamageVulnerability(const zeus::CVector3f& pos, const zeus::CVector3f& dir,
const zeus::CVector3f& dir,
const CDamageInfo& dInfo) const { const CDamageInfo& dInfo) const {
if (x838_25_burrowing) if (x838_25_burrowing)
return &CDamageVulnerability::PassThroughVulnerabilty(); return &CDamageVulnerability::PassThroughVulnerabilty();
@ -220,13 +219,12 @@ zeus::CVector3f CBeetle::GetAimPosition(const CStateManager& mgr, float dt) cons
} }
} }
EWeaponCollisionResponseTypes CBeetle::GetCollisionResponseType(const zeus::CVector3f& pos, EWeaponCollisionResponseTypes CBeetle::GetCollisionResponseType(const zeus::CVector3f& pos, const zeus::CVector3f& dir,
const zeus::CVector3f& dir,
const CWeaponMode& wMode, const CWeaponMode& wMode,
EProjectileAttrib attribs) const { EProjectileAttrib attribs) const {
if (x450_bodyController->IsFrozen() && wMode.GetType() == EWeaponType::Ice) if (x450_bodyController->IsFrozen() && wMode.GetType() == EWeaponType::Ice)
return EWeaponCollisionResponseTypes::None; return EWeaponCollisionResponseTypes::None;
if(x838_25_burrowing) if (x838_25_burrowing)
return EWeaponCollisionResponseTypes::Unknown69; return EWeaponCollisionResponseTypes::Unknown69;
if (x3fc_flavor == EFlavorType::One) { if (x3fc_flavor == EFlavorType::One) {
if (GetTransform().basis[1].dot(dir) > 0.f && if (GetTransform().basis[1].dot(dir) > 0.f &&
@ -254,11 +252,11 @@ void CBeetle::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUs
break; break;
case EUserEventType::DamageOn: { case EUserEventType::DamageOn: {
zeus::CVector3f center = zeus::CVector3f center =
GetTransform() * (x64_modelData->GetScale() * GetLocatorTransform("LCTR_GARMOUTH"sv).origin); GetTransform() * (x64_modelData->GetScale() * GetLocatorTransform("LCTR_GARMOUTH"sv).origin);
zeus::CVector3f extent = x64_modelData->GetScale() * zeus::CVector3f(2.f, 2.f, 0.5f); zeus::CVector3f extent = x64_modelData->GetScale() * zeus::CVector3f(2.f, 2.f, 0.5f);
if (zeus::CAABox(center - extent, center + extent).intersects(mgr.GetPlayer().GetBoundingBox())) { if (zeus::CAABox(center - extent, center + extent).intersects(mgr.GetPlayer().GetBoundingBox())) {
mgr.ApplyDamage(GetUniqueId(), mgr.GetPlayer().GetUniqueId(), GetUniqueId(), x584_touchDamage, mgr.ApplyDamage(GetUniqueId(), mgr.GetPlayer().GetUniqueId(), GetUniqueId(), x584_touchDamage,
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), zeus::CVector3f::skZero); CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), zeus::CVector3f::skZero);
} }
handled = true; handled = true;
break; break;
@ -297,13 +295,9 @@ void CBeetle::Death(CStateManager& mgr, const zeus::CVector3f& direction, EScrip
} }
} }
void CBeetle::TakeDamage(const zeus::CVector3f& direction, float magnitude) { void CBeetle::TakeDamage(const zeus::CVector3f& direction, float magnitude) { x428_damageCooldownTimer = 0.33f; }
x428_damageCooldownTimer = 0.33f;
}
bool CBeetle::IsListening() const { bool CBeetle::IsListening() const { return true; }
return true;
}
zeus::CVector3f CBeetle::GetOrigin(const CStateManager& mgr, const CTeamAiRole& role, zeus::CVector3f CBeetle::GetOrigin(const CStateManager& mgr, const CTeamAiRole& role,
const zeus::CVector3f& aimPos) const { const zeus::CVector3f& aimPos) const {
@ -326,14 +320,12 @@ void CBeetle::FollowPattern(CStateManager& mgr, EStateMsg msg, float dt) {
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Step) { if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Step) {
x568_stateProg = 3; x568_stateProg = 3;
} else if (IsOnGround()) { } else if (IsOnGround()) {
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(CBCStepCmd(pas::EStepDirection::Left, pas::EStepType::Normal));
CBCStepCmd(pas::EStepDirection::Left, pas::EStepType::Normal));
} }
break; break;
case 3: case 3:
if (x450_bodyController->GetCurrentStateId() != pas::EAnimationState::Step && IsOnGround()) { if (x450_bodyController->GetCurrentStateId() != pas::EAnimationState::Step && IsOnGround()) {
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(CBCStepCmd(pas::EStepDirection::Right, pas::EStepType::Normal));
CBCStepCmd(pas::EStepDirection::Right, pas::EStepType::Normal));
x568_stateProg = 2; x568_stateProg = 2;
} }
break; break;
@ -344,8 +336,7 @@ void CBeetle::FollowPattern(CStateManager& mgr, EStateMsg msg, float dt) {
default: default:
break; break;
} }
x450_bodyController->GetCommandMgr().DeliverTargetVector( x450_bodyController->GetCommandMgr().DeliverTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation());
mgr.GetPlayer().GetTranslation() - GetTranslation());
break; break;
default: default:
break; break;
@ -359,7 +350,7 @@ void CBeetle::RefinePathFindDest(CStateManager& mgr, zeus::CVector3f& dest) {
} else { } else {
zeus::CVector3f thisToDest = dest - GetTranslation(); zeus::CVector3f thisToDest = dest - GetTranslation();
dest += (thisToDest.canBeNormalized() ? thisToDest.normalized() : GetTransform().basis[1]) * dest += (thisToDest.canBeNormalized() ? thisToDest.normalized() : GetTransform().basis[1]) *
(0.5f * (x2fc_minAttackRange + x300_maxAttackRange)); (0.5f * (x2fc_minAttackRange + x300_maxAttackRange));
} }
} }
@ -496,8 +487,8 @@ void CBeetle::Deactivate(CStateManager& mgr, EStateMsg msg, float dt) {
switch (x568_stateProg) { switch (x568_stateProg) {
case 0: case 0:
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Generate) { if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Generate) {
RemoveMaterial(EMaterialTypes::Character, EMaterialTypes::Solid, RemoveMaterial(EMaterialTypes::Character, EMaterialTypes::Solid, EMaterialTypes::Target, EMaterialTypes::Orbit,
EMaterialTypes::Target, EMaterialTypes::Orbit, mgr); mgr);
mgr.GetPlayer().SetOrbitRequestForTarget(GetUniqueId(), CPlayer::EPlayerOrbitRequest::ActivateOrbitSource, mgr); mgr.GetPlayer().SetOrbitRequestForTarget(GetUniqueId(), CPlayer::EPlayerOrbitRequest::ActivateOrbitSource, mgr);
x838_25_burrowing = true; x838_25_burrowing = true;
x5a8_animTimeRem = x450_bodyController->GetAnimTimeRemaining(); x5a8_animTimeRem = x450_bodyController->GetAnimTimeRemaining();
@ -506,7 +497,7 @@ void CBeetle::Deactivate(CStateManager& mgr, EStateMsg msg, float dt) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(pas::EGenerateType::One)); x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(pas::EGenerateType::One));
} else { } else {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd( x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(
x45c_steeringBehaviors.Seek(*this, mgr.GetPlayer().GetTranslation()), zeus::CVector3f::skZero, 1.f)); x45c_steeringBehaviors.Seek(*this, mgr.GetPlayer().GetTranslation()), zeus::CVector3f::skZero, 1.f));
} }
break; break;
case 2: case 2:
@ -603,7 +594,7 @@ void CBeetle::JumpBack(CStateManager&, EStateMsg msg, float dt) {
x568_stateProg = 2; x568_stateProg = 2;
} else if (IsOnGround()) { } else if (IsOnGround()) {
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(
CBCStepCmd(pas::EStepDirection::Backward, pas::EStepType::Normal)); CBCStepCmd(pas::EStepDirection::Backward, pas::EStepType::Normal));
} }
break; break;
case 2: case 2:
@ -671,8 +662,8 @@ void CBeetle::Shuffle(CStateManager& mgr, EStateMsg msg, float dt) {
if (GetTransform().basis[1].dot(move) >= 0.f || GetTransform().basis[1].dot(playerToThis) >= 0.f) { if (GetTransform().basis[1].dot(move) >= 0.f || GetTransform().basis[1].dot(playerToThis) >= 0.f) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(move, zeus::CVector3f::skZero, 1.f)); x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(move, zeus::CVector3f::skZero, 1.f));
} else { } else {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(move, x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(
playerToThis.canBeNormalized() ? -playerToThis.normalized() : GetTransform().basis[1], 1.f)); move, playerToThis.canBeNormalized() ? -playerToThis.normalized() : GetTransform().basis[1], 1.f));
} }
break; break;
} }
@ -707,8 +698,9 @@ void CBeetle::TurnAround(CStateManager& mgr, EStateMsg msg, float dt) {
x568_stateProg = 2; x568_stateProg = 2;
} else { } else {
zeus::CVector3f thisToPlayer = mgr.GetPlayer().GetTranslation() - GetTranslation(); zeus::CVector3f thisToPlayer = mgr.GetPlayer().GetTranslation() - GetTranslation();
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(zeus::CVector3f::skZero, x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(
(thisToPlayer.magnitude() > FLT_EPSILON) ? thisToPlayer.normalized() : zeus::CVector3f::skZero, 1.f)); zeus::CVector3f::skZero,
(thisToPlayer.magnitude() > FLT_EPSILON) ? thisToPlayer.normalized() : zeus::CVector3f::skZero, 1.f));
} }
break; break;
case 2: case 2:
@ -748,7 +740,7 @@ void CBeetle::Taunt(CStateManager& mgr, EStateMsg msg, float dt) {
switch (msg) { switch (msg) {
case EStateMsg::Activate: case EStateMsg::Activate:
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(
CBCTauntCmd(mgr.GetActiveRandom()->Float() < 0.75f ? pas::ETauntType::One : pas::ETauntType::Zero)); CBCTauntCmd(mgr.GetActiveRandom()->Float() < 0.75f ? pas::ETauntType::One : pas::ETauntType::Zero));
x568_stateProg = 2; x568_stateProg = 2;
break; break;
case EStateMsg::Update: case EStateMsg::Update:
@ -795,10 +787,9 @@ void CBeetle::Retreat(CStateManager& mgr, EStateMsg msg, float dt) {
switch (x568_stateProg) { switch (x568_stateProg) {
case 0: case 0:
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Generate) { if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Generate) {
RemoveMaterial(EMaterialTypes::Character, EMaterialTypes::Solid, RemoveMaterial(EMaterialTypes::Character, EMaterialTypes::Solid, EMaterialTypes::Target, EMaterialTypes::Orbit,
EMaterialTypes::Target, EMaterialTypes::Orbit, mgr); mgr);
mgr.GetPlayer().SetOrbitRequestForTarget(GetUniqueId(), mgr.GetPlayer().SetOrbitRequestForTarget(GetUniqueId(), CPlayer::EPlayerOrbitRequest::ActivateOrbitSource, mgr);
CPlayer::EPlayerOrbitRequest::ActivateOrbitSource, mgr);
x838_25_burrowing = true; x838_25_burrowing = true;
x5a8_animTimeRem = x450_bodyController->GetAnimTimeRemaining(); x5a8_animTimeRem = x450_bodyController->GetAnimTimeRemaining();
x568_stateProg = 2; x568_stateProg = 2;
@ -806,7 +797,7 @@ void CBeetle::Retreat(CStateManager& mgr, EStateMsg msg, float dt) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(pas::EGenerateType::One)); x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(pas::EGenerateType::One));
} else { } else {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd( x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(
x45c_steeringBehaviors.Seek(*this, mgr.GetPlayer().GetTranslation()), zeus::CVector3f::skZero, 1.f)); x45c_steeringBehaviors.Seek(*this, mgr.GetPlayer().GetTranslation()), zeus::CVector3f::skZero, 1.f));
} }
break; break;
case 2: case 2:
@ -828,8 +819,8 @@ void CBeetle::Retreat(CStateManager& mgr, EStateMsg msg, float dt) {
} else { } else {
auto aabb = GetBoundingBox(); auto aabb = GetBoundingBox();
zeus::CVector3f downVec = (aabb.max.z() - aabb.min.z()) * 3.f * zeus::CVector3f::skDown; zeus::CVector3f downVec = (aabb.max.z() - aabb.min.z()) * 3.f * zeus::CVector3f::skDown;
SetTranslation(((x834_retreatTime > 0.f) ? SetTranslation(((x834_retreatTime > 0.f) ? (1.f / x834_retreatTime) * downVec : downVec) * dt +
(1.f / x834_retreatTime) * downVec : downVec) * dt + GetTranslation()); GetTranslation());
} }
break; break;
default: default:
@ -840,8 +831,7 @@ void CBeetle::Retreat(CStateManager& mgr, EStateMsg msg, float dt) {
s32 idx = FindFurthestRetreatPoint(mgr); s32 idx = FindFurthestRetreatPoint(mgr);
if (idx != -1) { if (idx != -1) {
SetTranslation(x6e0_retreatPoints[idx]); SetTranslation(x6e0_retreatPoints[idx]);
AddMaterial(EMaterialTypes::Character, EMaterialTypes::Solid, AddMaterial(EMaterialTypes::Character, EMaterialTypes::Solid, EMaterialTypes::Target, EMaterialTypes::Orbit, mgr);
EMaterialTypes::Target, EMaterialTypes::Orbit, mgr);
} else { } else {
SendScriptMsgs(EScriptObjectState::DeactivateState, mgr, EScriptObjectMessage::None); SendScriptMsgs(EScriptObjectState::DeactivateState, mgr, EScriptObjectMessage::None);
mgr.FreeScriptObject(GetUniqueId()); mgr.FreeScriptObject(GetUniqueId());
@ -862,9 +852,7 @@ bool CBeetle::InAttackPosition(CStateManager& mgr, float arg) {
return false; return false;
} }
bool CBeetle::PathShagged(CStateManager&, float arg) { bool CBeetle::PathShagged(CStateManager&, float arg) { return false; }
return false;
}
bool CBeetle::InRange(CStateManager& mgr, float arg) { bool CBeetle::InRange(CStateManager& mgr, float arg) {
zeus::CVector3f targetPos = mgr.GetPlayer().GetTranslation(); zeus::CVector3f targetPos = mgr.GetPlayer().GetTranslation();
@ -875,17 +863,11 @@ bool CBeetle::InRange(CStateManager& mgr, float arg) {
return (targetPos - GetTranslation()).magSquared() < 100.f; return (targetPos - GetTranslation()).magSquared() < 100.f;
} }
bool CBeetle::PatternOver(CStateManager& mgr, float arg) { bool CBeetle::PatternOver(CStateManager& mgr, float arg) { return AnimOver(mgr, arg); }
return AnimOver(mgr, arg);
}
bool CBeetle::HasAttackPattern(CStateManager&, float arg) { bool CBeetle::HasAttackPattern(CStateManager&, float arg) { return true; }
return true;
}
bool CBeetle::AnimOver(CStateManager&, float arg) { bool CBeetle::AnimOver(CStateManager&, float arg) { return x568_stateProg == 4; }
return x568_stateProg == 4;
}
bool CBeetle::ShouldAttack(CStateManager& mgr, float arg) { bool CBeetle::ShouldAttack(CStateManager& mgr, float arg) {
if (x814_attackDelayTimer <= 0.f) { if (x814_attackDelayTimer <= 0.f) {
@ -908,10 +890,11 @@ bool CBeetle::ShouldDoubleSnap(CStateManager& mgr, float arg) {
if (delta.magSquared() > dist * dist && GetTransform().basis[1].dot(delta.normalized()) > 0.98f) { if (delta.magSquared() > dist * dist && GetTransform().basis[1].dot(delta.normalized()) > 0.98f) {
rstl::reserved_vector<TUniqueId, 1024> nearList; rstl::reserved_vector<TUniqueId, 1024> nearList;
mgr.BuildNearList(nearList, GetTranslation(), GetTransform().basis[1], x5a0_headbuttDist, mgr.BuildNearList(nearList, GetTranslation(), GetTransform().basis[1], x5a0_headbuttDist,
CMaterialFilter::MakeInclude({EMaterialTypes::Character}), this); CMaterialFilter::MakeInclude({EMaterialTypes::Character}), this);
TUniqueId bestId = kInvalidUniqueId; TUniqueId bestId = kInvalidUniqueId;
CRayCastResult res = mgr.RayWorldIntersection(bestId, GetTranslation(), GetTransform().basis[1], CRayCastResult res =
x5a0_headbuttDist, CMaterialFilter::MakeInclude({EMaterialTypes::Solid}), nearList); mgr.RayWorldIntersection(bestId, GetTranslation(), GetTransform().basis[1], x5a0_headbuttDist,
CMaterialFilter::MakeInclude({EMaterialTypes::Solid}), nearList);
if (res.IsInvalid()) if (res.IsInvalid())
return true; return true;
} }
@ -921,12 +904,11 @@ bool CBeetle::ShouldDoubleSnap(CStateManager& mgr, float arg) {
bool CBeetle::ShouldTurn(CStateManager& mgr, float arg) { bool CBeetle::ShouldTurn(CStateManager& mgr, float arg) {
return zeus::CVector2f::getAngleDiff(GetTransform().basis[1].toVec2f(), return zeus::CVector2f::getAngleDiff(GetTransform().basis[1].toVec2f(),
(mgr.GetPlayer().GetTranslation() - GetTranslation()).toVec2f()) > zeus::degToRad(30.f); (mgr.GetPlayer().GetTranslation() - GetTranslation()).toVec2f()) >
zeus::degToRad(30.f);
} }
bool CBeetle::HitSomething(CStateManager&, float arg) { bool CBeetle::HitSomething(CStateManager&, float arg) { return x838_24_hitSomething; }
return x838_24_hitSomething;
}
bool CBeetle::ShouldJumpBack(CStateManager& mgr, float arg) { bool CBeetle::ShouldJumpBack(CStateManager& mgr, float arg) {
zeus::CVector3f backDir = -GetTransform().basis[1]; zeus::CVector3f backDir = -GetTransform().basis[1];
@ -934,20 +916,16 @@ bool CBeetle::ShouldJumpBack(CStateManager& mgr, float arg) {
zeus::CVector3f pos = GetTranslation() + zeus::CVector3f(0.f, 0.f, (aabb.max.z() - aabb.min.z()) * 0.5f); zeus::CVector3f pos = GetTranslation() + zeus::CVector3f(0.f, 0.f, (aabb.max.z() - aabb.min.z()) * 0.5f);
rstl::reserved_vector<TUniqueId, 1024> nearList; rstl::reserved_vector<TUniqueId, 1024> nearList;
mgr.BuildNearList(nearList, pos, backDir, x5a4_jumpBackwardDist, mgr.BuildNearList(nearList, pos, backDir, x5a4_jumpBackwardDist,
CMaterialFilter::MakeInclude({EMaterialTypes::Character}), this); CMaterialFilter::MakeInclude({EMaterialTypes::Character}), this);
TUniqueId bestId = kInvalidUniqueId; TUniqueId bestId = kInvalidUniqueId;
CRayCastResult res = mgr.RayWorldIntersection(bestId, pos, backDir, x5a4_jumpBackwardDist, CRayCastResult res = mgr.RayWorldIntersection(bestId, pos, backDir, x5a4_jumpBackwardDist,
CMaterialFilter::MakeInclude({EMaterialTypes::Solid}), nearList); CMaterialFilter::MakeInclude({EMaterialTypes::Solid}), nearList);
return res.IsInvalid(); return res.IsInvalid();
} }
bool CBeetle::Stuck(CStateManager&, float arg) { bool CBeetle::Stuck(CStateManager&, float arg) { return x820_posDeviationCounter > 30; }
return x820_posDeviationCounter > 30;
}
bool CBeetle::NoPathNodes(CStateManager&, float arg) { bool CBeetle::NoPathNodes(CStateManager&, float arg) { return false; }
return false;
}
bool CBeetle::ShouldTaunt(CStateManager& mgr, float arg) { bool CBeetle::ShouldTaunt(CStateManager& mgr, float arg) {
if (CTeamAiRole* role = CTeamAiMgr::GetTeamAiRole(mgr, x570_aiMgr, GetUniqueId())) { if (CTeamAiRole* role = CTeamAiMgr::GetTeamAiRole(mgr, x570_aiMgr, GetUniqueId())) {
@ -1001,12 +979,8 @@ void CBeetle::Shock(CStateManager& mgr, float duration, float damage) {
} }
} }
CPathFindSearch* CBeetle::GetSearchPath() { CPathFindSearch* CBeetle::GetSearchPath() { return &x5fc_pathFindSearch; }
return &x5fc_pathFindSearch;
}
float CBeetle::GetGravityConstant() const { float CBeetle::GetGravityConstant() const { return 4.f * 24.525f; }
return 4.f * 24.525f;
}
} // namespace urde::MP1 } // namespace urde::MP1

View File

@ -51,11 +51,10 @@ private:
public: public:
DEFINE_PATTERNED(Beetle) DEFINE_PATTERNED(Beetle)
CBeetle(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, CBeetle(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData,
CModelData&& mData, const CPatternedInfo& pInfo, CPatterned::EFlavorType flavor, const CPatternedInfo& pInfo, CPatterned::EFlavorType flavor, CBeetle::EEntranceType entranceType,
CBeetle::EEntranceType entranceType, const CDamageInfo& touchDamage, const CDamageInfo& touchDamage, const CDamageVulnerability& platingVuln,
const CDamageVulnerability& platingVuln, const zeus::CVector3f& tailAimReference, const zeus::CVector3f& tailAimReference, float initialAttackDelay, float retreatTime, float f3,
float initialAttackDelay, float retreatTime, float f3,
const CDamageVulnerability& tailVuln, const CActorParameters& aParams, const CDamageVulnerability& tailVuln, const CActorParameters& aParams,
const rstl::optional<CStaticRes>& tailModel); const rstl::optional<CStaticRes>& tailModel);
@ -66,22 +65,18 @@ public:
void Render(const CStateManager& mgr) const; void Render(const CStateManager& mgr) const;
const CDamageVulnerability* GetDamageVulnerability() const; const CDamageVulnerability* GetDamageVulnerability() const;
const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f& pos, const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f& pos, const zeus::CVector3f& dir,
const zeus::CVector3f& dir,
const CDamageInfo& dInfo) const; const CDamageInfo& dInfo) const;
zeus::CVector3f GetOrbitPosition(const CStateManager&) const; zeus::CVector3f GetOrbitPosition(const CStateManager&) const;
zeus::CVector3f GetAimPosition(const CStateManager& mgr, float) const; zeus::CVector3f GetAimPosition(const CStateManager& mgr, float) const;
EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f& pos, EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f& pos, const zeus::CVector3f& dir,
const zeus::CVector3f& dir, const CWeaponMode& wMode, EProjectileAttrib attribs) const;
const CWeaponMode& wMode,
EProjectileAttrib attribs) const;
void DoUserAnimEvent(CStateManager&, const CInt32POINode&, EUserEventType, float dt); void DoUserAnimEvent(CStateManager&, const CInt32POINode&, EUserEventType, float dt);
void CollidedWith(TUniqueId, const CCollisionInfoList&, CStateManager& mgr); void CollidedWith(TUniqueId, const CCollisionInfoList&, CStateManager& mgr);
void Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state); void Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state);
void TakeDamage(const zeus::CVector3f& direction, float magnitude); void TakeDamage(const zeus::CVector3f& direction, float magnitude);
bool IsListening() const; bool IsListening() const;
zeus::CVector3f GetOrigin(const CStateManager& mgr, const CTeamAiRole& role, zeus::CVector3f GetOrigin(const CStateManager& mgr, const CTeamAiRole& role, const zeus::CVector3f& aimPos) const;
const zeus::CVector3f& aimPos) const;
void FollowPattern(CStateManager&, EStateMsg msg, float dt); void FollowPattern(CStateManager&, EStateMsg msg, float dt);
void PathFind(CStateManager& mgr, EStateMsg msg, float dt); void PathFind(CStateManager& mgr, EStateMsg msg, float dt);
@ -118,7 +113,6 @@ public:
CPathFindSearch* GetSearchPath(); CPathFindSearch* GetSearchPath();
float GetGravityConstant() const; float GetGravityConstant() const;
}; };
} // namespace MP1 } // namespace MP1
} // namespace urde } // namespace urde

View File

@ -120,9 +120,9 @@ void CEyeball::CreateBeam(CStateManager& mgr) {
if (x5ec_projectileId != kInvalidUniqueId) if (x5ec_projectileId != kInvalidUniqueId)
return; return;
CBeamInfo beamInfo(3, x5dc_beamContactFxId, x5e0_beamPulseFxId, x5e4_beamTextureId, x5e8_beamGlowTextureId, CBeamInfo beamInfo(3, x5dc_beamContactFxId, x5e0_beamPulseFxId, x5e4_beamTextureId, x5e8_beamGlowTextureId, 50, 0.05f,
50, 0.05f, 1.f, 2.f, 20.f, 1.f, 1.f, 2.f, zeus::CColor(1.f, 1.f, 1.f, 0.f), 1.f, 2.f, 20.f, 1.f, 1.f, 2.f, zeus::CColor(1.f, 1.f, 1.f, 0.f), zeus::CColor(0.f, 1.f, 0.5f, 0.f),
zeus::CColor(0.f, 1.f, 0.5f, 0.f), 150.f); 150.f);
x5ec_projectileId = mgr.AllocateUniqueId(); x5ec_projectileId = mgr.AllocateUniqueId();
mgr.AddObject(new CPlasmaProjectile(x5b4_projectileInfo.Token(), "EyeBall_Beam"sv, EWeaponType::AI, beamInfo, mgr.AddObject(new CPlasmaProjectile(x5b4_projectileInfo.Token(), "EyeBall_Beam"sv, EWeaponType::AI, beamInfo,
zeus::CTransform::Identity(), EMaterialTypes::Immovable, zeus::CTransform::Identity(), EMaterialTypes::Immovable,

View File

@ -39,8 +39,8 @@ public:
CEyeball(TUniqueId uid, std::string_view name, CPatterned::EFlavorType flavor, const CEntityInfo& info, CEyeball(TUniqueId uid, std::string_view name, CPatterned::EFlavorType flavor, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, float attackDelay, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, float attackDelay,
float attackStartTime, CAssetId wpscId, const CDamageInfo& dInfo, CAssetId beamContactFxId, float attackStartTime, CAssetId wpscId, const CDamageInfo& dInfo, CAssetId beamContactFxId,
CAssetId beamPulseFxId, CAssetId beamTextureId, CAssetId beamGlowTextureId, u32 anim0, u32 anim1, CAssetId beamPulseFxId, CAssetId beamTextureId, CAssetId beamGlowTextureId, u32 anim0, u32 anim1, u32 anim2,
u32 anim2, u32 anim3, u32 beamSfx, bool attackDisabled, const CActorParameters& actParms); u32 anim3, u32 beamSfx, bool attackDisabled, const CActorParameters& actParms);
void Accept(IVisitor& visitor); void Accept(IVisitor& visitor);
void PreRender(CStateManager&, const zeus::CFrustum&); void PreRender(CStateManager&, const zeus::CFrustum&);

View File

@ -119,7 +119,7 @@ void CFireFlea::TargetPatrol(CStateManager& mgr, EStateMsg msg, float arg) {
} }
} else { } else {
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(
CBCLocomotionCmd(x45c_steeringBehaviors.Arrival(*this, xd80_targetPos, 5.f), {}, 1.f)); CBCLocomotionCmd(x45c_steeringBehaviors.Arrival(*this, xd80_targetPos, 5.f), {}, 1.f));
} }
} }
} }

View File

@ -145,8 +145,7 @@ bool CFlickerBat::CanBeShot(CStateManager& mgr, int) {
mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::XRay); mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::XRay);
} }
void CFlickerBat::Patrol(CStateManager& mgr, EStateMsg state, float dt) void CFlickerBat::Patrol(CStateManager& mgr, EStateMsg state, float dt) {
{
CPatterned::Patrol(mgr, state, dt); CPatterned::Patrol(mgr, state, dt);
x450_bodyController->GetCommandMgr().DeliverFaceVector((x2e0_destPos - GetTranslation()).normalized()); x450_bodyController->GetCommandMgr().DeliverFaceVector((x2e0_destPos - GetTranslation()).normalized());
} }
@ -154,7 +153,7 @@ void CFlickerBat::Patrol(CStateManager& mgr, EStateMsg state, float dt)
void CFlickerBat::Attack(CStateManager&, EStateMsg msg, float) { void CFlickerBat::Attack(CStateManager&, EStateMsg msg, float) {
if (msg == EStateMsg::Update) { if (msg == EStateMsg::Update) {
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(
CBCLocomotionCmd((x2e0_destPos - GetTranslation()).normalized(), {}, 1.f)); CBCLocomotionCmd((x2e0_destPos - GetTranslation()).normalized(), {}, 1.f));
} }
} }

View File

@ -22,6 +22,7 @@ private:
void NotifyNeighbors(CStateManager&); void NotifyNeighbors(CStateManager&);
void ToggleVisible(CStateManager&); void ToggleVisible(CStateManager&);
void SetHeardShot(bool heardShot) { x580_25_heardShot = heardShot; } void SetHeardShot(bool heardShot) { x580_25_heardShot = heardShot; }
public: public:
DEFINE_PATTERNED(FlickerBat) DEFINE_PATTERNED(FlickerBat)
CFlickerBat(TUniqueId, std::string_view name, EFlavorType, const CEntityInfo&, const zeus::CTransform&, CModelData&&, CFlickerBat(TUniqueId, std::string_view name, EFlavorType, const CEntityInfo&, const zeus::CTransform&, CModelData&&,

View File

@ -19,4 +19,24 @@ CMagdolite::CMagdolite(TUniqueId uid, std::string_view name, const CEntityInfo&
const urde::MP1::CMagdolite::CMagdoliteData& magData, float f7, float f8, float f9) const urde::MP1::CMagdolite::CMagdoliteData& magData, float f7, float f8, float f9)
: CPatterned(ECharacter::Magdolite, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo, : CPatterned(ECharacter::Magdolite, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo,
EMovementType::Flyer, EColliderType::One, EBodyType::BiPedal, actParms, EKnockBackVariant::Large) {} EMovementType::Flyer, EColliderType::One, EBodyType::BiPedal, actParms, EKnockBackVariant::Large) {}
void CMagdolite::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
switch(msg) {
case EScriptObjectMessage::Damage:
case EScriptObjectMessage::InvulnDamage:
/* TODO Implement */
return;
case EScriptObjectMessage::Registered:
x450_bodyController->Activate(mgr);
RemoveMaterial(EMaterialTypes::Solid, mgr);
AddMaterial(EMaterialTypes::NonSolidDamageable, mgr);
//x584_boneTracker.SetActive(false);
CreateShadow(false);
/* TODO Finish */
default:
break;
}
CPatterned::AcceptScriptMsg(msg, uid, mgr);
}
} // namespace urde::MP1 } // namespace urde::MP1

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "World/CPatterned.hpp" #include "World/CPatterned.hpp"
#include "Character/CBoneTracking.hpp"
namespace urde::MP1 { namespace urde::MP1 {
class CMagdolite : public CPatterned { class CMagdolite : public CPatterned {
@ -19,11 +20,14 @@ public:
}; };
private: private:
//CBoneTracking x584_boneTracker;
public: public:
DEFINE_PATTERNED(Magdolite) DEFINE_PATTERNED(Magdolite)
CMagdolite(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&, CMagdolite(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const CPatternedInfo&, const CActorParameters&, float, float, const CDamageInfo&, const CDamageInfo&, const CPatternedInfo&, const CActorParameters&, float, float, const CDamageInfo&, const CDamageInfo&,
const CDamageVulnerability&, const CDamageVulnerability&, CAssetId, CAssetId, float, float, float, float, const CDamageVulnerability&, const CDamageVulnerability&, CAssetId, CAssetId, float, float, float, float,
const CMagdoliteData&, float, float, float); const CMagdoliteData&, float, float, float);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
}; };
} // namespace urde::MP1 } // namespace urde::MP1

View File

@ -21,7 +21,7 @@ CMetroidData::CMetroidData(CInputStream& in)
CMetroid::CMetroid(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info, CMetroid::CMetroid(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo,
const CActorParameters& aParms, const CMetroidData& metroidData) const CActorParameters& aParms, const CMetroidData& metroidData, TUniqueId)
: CPatterned(ECharacter::Metroid, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Flyer, : CPatterned(ECharacter::Metroid, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Flyer,
EColliderType::One, EBodyType::Flyer, aParms, EKnockBackVariant::Medium) {} EColliderType::One, EBodyType::Flyer, aParms, EKnockBackVariant::Medium) {}

View File

@ -6,6 +6,7 @@
namespace urde::MP1 { namespace urde::MP1 {
class CMetroidData { class CMetroidData {
static constexpr u32 skNumProperties = 20;
CDamageVulnerability x0_dVuln1; CDamageVulnerability x0_dVuln1;
CDamageVulnerability x68_dVuln2; CDamageVulnerability x68_dVuln2;
float xd0_; float xd0_;
@ -22,6 +23,7 @@ class CMetroidData {
public: public:
CMetroidData(CInputStream& in); CMetroidData(CInputStream& in);
static u32 GetNumProperties() { return skNumProperties; }
}; };
class CMetroid : public CPatterned { class CMetroid : public CPatterned {
@ -31,11 +33,12 @@ class CMetroid : public CPatterned {
}; };
u32 _dummy = 0; u32 _dummy = 0;
}; };
public: public:
DEFINE_PATTERNED(Metroid) DEFINE_PATTERNED(Metroid)
CMetroid(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info, CMetroid(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, const CActorParameters& aParms, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, const CActorParameters& aParms,
const CMetroidData& metroidData); const CMetroidData& metroidData, TUniqueId);
bool GetX9BF_29() const { return x9bf_29_; } bool GetX9BF_29() const { return x9bf_29_; }
}; };

View File

@ -14,8 +14,9 @@ namespace urde::MP1 {
CNewIntroBoss::CNewIntroBoss(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, CNewIntroBoss::CNewIntroBoss(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const CPatternedInfo& pInfo, const CActorParameters& actParms, CModelData&& mData, const CPatternedInfo& pInfo, const CActorParameters& actParms,
float minTurnAngle, CAssetId projectile, const CDamageInfo& dInfo, CAssetId beamContactFxId, float minTurnAngle, CAssetId projectile, const CDamageInfo& dInfo,
CAssetId beamPulseFxId, CAssetId beamTextureId, CAssetId beamGlowTextureId) CAssetId beamContactFxId, CAssetId beamPulseFxId, CAssetId beamTextureId,
CAssetId beamGlowTextureId)
: CPatterned(ECharacter::NewIntroBoss, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo, : CPatterned(ECharacter::NewIntroBoss, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo,
EMovementType::Flyer, EColliderType::One, EBodyType::Restricted, actParms, EKnockBackVariant::Medium) EMovementType::Flyer, EColliderType::One, EBodyType::Restricted, actParms, EKnockBackVariant::Medium)
, x570_minTurnAngle(minTurnAngle) , x570_minTurnAngle(minTurnAngle)
@ -225,7 +226,8 @@ void CNewIntroBoss::Think(float dt, CStateManager& mgr) {
zeus::CTransform xf = GetLctrTransform(x5dc_damageLocator); zeus::CTransform xf = GetLctrTransform(x5dc_damageLocator);
if (x400_25_alive) { if (x400_25_alive) {
zeus::CQuaternion clampedQuat = zeus::CQuaternion::clampedRotateTo(xf.frontVector(), zeus::CQuaternion clampedQuat = zeus::CQuaternion::clampedRotateTo(
xf.frontVector(),
(x610_lookPos + (zeus::min(x628_firingTime / 1.5f, 1.f) * (x61c_startPlayerPos - x610_lookPos))) - xf.origin, (x610_lookPos + (zeus::min(x628_firingTime / 1.5f, 1.f) * (x61c_startPlayerPos - x610_lookPos))) - xf.origin,
zeus::CRelAngle::FromDegrees(30.f)); zeus::CRelAngle::FromDegrees(30.f));
zeus::CTransform newXf = clampedQuat.toTransform() * xf.getRotation(); zeus::CTransform newXf = clampedQuat.toTransform() * xf.getRotation();
@ -328,7 +330,7 @@ bool CNewIntroBoss::ShouldTurn(CStateManager& mgr, float dt) {
zeus::CVector2f diffPos = (x604_predictedPlayerPos - GetTranslation()).toVec2f(); zeus::CVector2f diffPos = (x604_predictedPlayerPos - GetTranslation()).toVec2f();
return zeus::CVector2f::getAngleDiff(GetTransform().frontVector().toVec2f(), diffPos) > return zeus::CVector2f::getAngleDiff(GetTransform().frontVector().toVec2f(), diffPos) >
zeus::degToRad(x570_minTurnAngle); zeus::degToRad(x570_minTurnAngle);
} }
bool CNewIntroBoss::ShouldAttack(CStateManager& mgr, float dt) { bool CNewIntroBoss::ShouldAttack(CStateManager& mgr, float dt) {

View File

@ -48,9 +48,9 @@ class CNewIntroBoss : public CPatterned {
public: public:
DEFINE_PATTERNED(NewIntroBoss) DEFINE_PATTERNED(NewIntroBoss)
CNewIntroBoss(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, CNewIntroBoss(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const CPatternedInfo& pInfo, const CActorParameters& actParms, CModelData&& mData, const CPatternedInfo& pInfo, const CActorParameters& actParms, float minTurnAngle,
float minTurnAngle, CAssetId projectile, const CDamageInfo& dInfo, CAssetId beamContactFxId, CAssetId projectile, const CDamageInfo& dInfo, CAssetId beamContactFxId, CAssetId beamPulseFxId,
CAssetId beamPulseFxId, CAssetId beamTextureId, CAssetId beamGlowTextureId); CAssetId beamTextureId, CAssetId beamGlowTextureId);
void Accept(IVisitor& visitor); void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager&); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager&);

View File

@ -12,22 +12,9 @@
namespace urde::MP1 { namespace urde::MP1 {
const std::string_view CPuddleSpore::kEyeLocators[16] = { const std::string_view CPuddleSpore::kEyeLocators[16] = {
"Glow_1_LCTR"sv, "Glow_1_LCTR"sv, "Glow_2_LCTR"sv, "Glow_3_LCTR"sv, "Glow_4_LCTR"sv, "Glow_5_LCTR"sv, "Glow_6_LCTR"sv,
"Glow_2_LCTR"sv, "Glow_7_LCTR"sv, "Glow_8_LCTR"sv, "Glow_9_LCTR"sv, "Glow_10_LCTR"sv, "Glow_11_LCTR"sv, "Glow_12_LCTR"sv,
"Glow_3_LCTR"sv, "Glow_13_LCTR"sv, "Glow_14_LCTR"sv, "Glow_15_LCTR"sv, "Glow_16_LCTR"sv,
"Glow_4_LCTR"sv,
"Glow_5_LCTR"sv,
"Glow_6_LCTR"sv,
"Glow_7_LCTR"sv,
"Glow_8_LCTR"sv,
"Glow_9_LCTR"sv,
"Glow_10_LCTR"sv,
"Glow_11_LCTR"sv,
"Glow_12_LCTR"sv,
"Glow_13_LCTR"sv,
"Glow_14_LCTR"sv,
"Glow_15_LCTR"sv,
"Glow_16_LCTR"sv,
}; };
CPuddleSpore::CPuddleSpore(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info, CPuddleSpore::CPuddleSpore(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo,
@ -56,9 +43,10 @@ CPuddleSpore::CPuddleSpore(TUniqueId uid, std::string_view name, EFlavorType fla
} }
zeus::CAABox CPuddleSpore::CalculateBoundingBox() const { zeus::CAABox CPuddleSpore::CalculateBoundingBox() const {
return {((zeus::CVector3f(-x590_halfExtent, -x590_halfExtent, x598_) + x584_bodyOrigin) * 0.5f) + return {
((zeus::CVector3f(-x590_halfExtent, -x590_halfExtent, x598_) + x584_bodyOrigin) * 0.5f) +
(GetBaseBoundingBox().min * 0.95f), (GetBaseBoundingBox().min * 0.95f),
((zeus::CVector3f(x590_halfExtent, x590_halfExtent, (x594_height * x59c_) + x598_) + x584_bodyOrigin) * 0.5f) + ((zeus::CVector3f(x590_halfExtent, x590_halfExtent, (x594_height * x59c_) + x598_) + x584_bodyOrigin) * 0.5f) +
(GetBaseBoundingBox().max * 0.95f)}; (GetBaseBoundingBox().max * 0.95f)};
} }
@ -78,9 +66,7 @@ bool CPuddleSpore::HitShell(const zeus::CVector3f& point) const {
return (distance <= -0.5f || distance >= 0.5f); return (distance <= -0.5f || distance >= 0.5f);
} }
void CPuddleSpore::KnockPlayer(CStateManager&, float) { void CPuddleSpore::KnockPlayer(CStateManager&, float) {}
}
void CPuddleSpore::UpdateBoundingState(const zeus::CAABox& box, CStateManager& mgr, float dt) { void CPuddleSpore::UpdateBoundingState(const zeus::CAABox& box, CStateManager& mgr, float dt) {
SetBoundingBox(box); SetBoundingBox(box);
@ -133,7 +119,7 @@ void CPuddleSpore::Think(float dt, CStateManager& mgr) {
HealthInfo(mgr)->SetHP(1000000.0f); HealthInfo(mgr)->SetHP(1000000.0f);
float t = (x56c_ / x570_) - 1.f >= -0.f ? 1.f : x56c_ / x570_; float t = (x56c_ / x570_) - 1.f >= -0.f ? 1.f : x56c_ / x570_;
zeus::CColor modColor = zeus::CColor::lerp(zeus::CColor::skWhite, zeus::CColor(1.f, 1.f, 1.f, 0.f), t); zeus::CColor modColor = zeus::CColor::lerp(zeus::CColor::skWhite, zeus::CColor(1.f, 1.f, 1.f, 0.f), t);
for (u32 i = 0 ; i < kEyeCount ; ++i) { for (u32 i = 0; i < kEyeCount; ++i) {
const auto& elemGen = x5dc_elemGens[i]; const auto& elemGen = x5dc_elemGens[i];
elemGen->SetModulationColor(modColor); elemGen->SetModulationColor(modColor);
elemGen->SetTranslation(GetLctrTransform(kEyeLocators[i]).origin); elemGen->SetTranslation(GetLctrTransform(kEyeLocators[i]).origin);
@ -178,11 +164,10 @@ void CPuddleSpore::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node
CProjectileInfo* projInfo = GetProjectileInfo(); CProjectileInfo* projInfo = GetProjectileInfo();
if (projInfo->Token() && projInfo->Token().IsLocked() && if (projInfo->Token() && projInfo->Token().IsLocked() &&
mgr.CanCreateProjectile(GetUniqueId(), EWeaponType::AI, 16)) { mgr.CanCreateProjectile(GetUniqueId(), EWeaponType::AI, 16)) {
mgr.AddObject(new CEnergyProjectile(true, projInfo->Token(), EWeaponType::AI, mgr.AddObject(new CEnergyProjectile(
GetLctrTransform(node.GetLocatorName()), EMaterialTypes::Character, true, projInfo->Token(), EWeaponType::AI, GetLctrTransform(node.GetLocatorName()), EMaterialTypes::Character,
projInfo->GetDamage(), mgr.AllocateUniqueId(), GetAreaIdAlways(), projInfo->GetDamage(), mgr.AllocateUniqueId(), GetAreaIdAlways(), GetUniqueId(), kInvalidUniqueId,
GetUniqueId(), kInvalidUniqueId, EProjectileAttrib::None, false, EProjectileAttrib::None, false, zeus::CVector3f::skOne, {}, 0xFFFF, false));
zeus::CVector3f::skOne, {}, 0xFFFF, false));
} }
} else } else
CPatterned::DoUserAnimEvent(mgr, node, type, dt); CPatterned::DoUserAnimEvent(mgr, node, type, dt);
@ -192,11 +177,8 @@ bool CPuddleSpore::ShouldTurn(CStateManager& mgr, float) {
zeus::CAABox plBox = mgr.GetPlayer().GetBoundingBox(); zeus::CAABox plBox = mgr.GetPlayer().GetBoundingBox();
zeus::CAABox selfBox = GetBoundingBox(); zeus::CAABox selfBox = GetBoundingBox();
if (plBox.max.z() >= selfBox.min.z() + selfBox.max.z() * 0.5f || if (plBox.max.z() >= selfBox.min.z() + selfBox.max.z() * 0.5f || plBox.max.x() < selfBox.min.x() ||
plBox.max.x() < selfBox.min.x() || plBox.max.y() < selfBox.min.y() || selfBox.max.x() < plBox.min.y() || selfBox.max.y() < plBox.min.y() ||
plBox.max.y() < selfBox.min.y() ||
selfBox.max.x() < plBox.min.y() ||
selfBox.max.y() < plBox.min.y() ||
x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::Getup) x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::Getup)
return x568_ >= x578_; return x568_ >= x578_;
@ -270,7 +252,8 @@ void CPuddleSpore::TurnAround(CStateManager& mgr, EStateMsg msg, float) {
} else { } else {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCKnockDownCmd({1.f, 0.f, 0.f}, pas::ESeverity::One)); x450_bodyController->GetCommandMgr().DeliverCmd(CBCKnockDownCmd({1.f, 0.f, 0.f}, pas::ESeverity::One));
} }
} else if (x5cc_ == 1 && x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::LieOnGround) { } else if (x5cc_ == 1 &&
x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::LieOnGround) {
x5cc_ = 2; x5cc_ = 2;
} }
} else if (msg == EStateMsg::Deactivate) { } else if (msg == EStateMsg::Deactivate) {
@ -291,7 +274,8 @@ void CPuddleSpore::GetUp(CStateManager& mgr, EStateMsg msg, float) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCGetupCmd(pas::EGetupType::Zero)); x450_bodyController->GetCommandMgr().DeliverCmd(CBCGetupCmd(pas::EGetupType::Zero));
if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::Getup) if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::Getup)
x5cc_ = 1; x5cc_ = 1;
} else if (x5cc_ == 1 && x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::Getup) { } else if (x5cc_ == 1 &&
x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::Getup) {
x5cc_ = 1; x5cc_ = 1;
} }
} else if (msg == EStateMsg::Deactivate) { } else if (msg == EStateMsg::Deactivate) {
@ -309,4 +293,4 @@ void CPuddleSpore::Attack(CStateManager& mgr, EStateMsg msg, float) {
x32c_animState = EAnimState::NotReady; x32c_animState = EAnimState::NotReady;
} }
} }
} } // namespace urde::MP1

View File

@ -29,14 +29,15 @@ class CPuddleSpore : public CPatterned {
bool x614_24 : 1; bool x614_24 : 1;
bool x614_25 : 1; bool x614_25 : 1;
bool HitShell(const zeus::CVector3f& ) const; bool HitShell(const zeus::CVector3f&) const;
void KnockPlayer(CStateManager&, float); void KnockPlayer(CStateManager&, float);
void UpdateBoundingState(const zeus::CAABox&, CStateManager&, float); void UpdateBoundingState(const zeus::CAABox&, CStateManager&, float);
public: public:
DEFINE_PATTERNED(PuddleSpore) DEFINE_PATTERNED(PuddleSpore)
CPuddleSpore(TUniqueId, std::string_view, EFlavorType, const CEntityInfo&, const zeus::CTransform&, CPuddleSpore(TUniqueId, std::string_view, EFlavorType, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
CModelData&&, const CPatternedInfo&, EColliderType, CAssetId, float, float, float, float, float, const CPatternedInfo&, EColliderType, CAssetId, float, float, float, float, float,
const CActorParameters&, CAssetId, const CDamageInfo&); const CActorParameters&, CAssetId, const CDamageInfo&);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr); void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr);
@ -46,20 +47,17 @@ public:
void Touch(CActor&, CStateManager&); void Touch(CActor&, CStateManager&);
void FluidFXThink(EFluidState, CScriptWater&, CStateManager&); void FluidFXThink(EFluidState, CScriptWater&, CStateManager&);
void KnockBack(const zeus::CVector3f& dir, CStateManager& mgr, const CDamageInfo& dInfo, EKnockBackType type, void KnockBack(const zeus::CVector3f& dir, CStateManager& mgr, const CDamageInfo& dInfo, EKnockBackType type,
bool inDeferred, float dt) bool inDeferred, float dt) {
{
if (x5c8_ == 1) if (x5c8_ == 1)
return; return;
CPatterned::KnockBack(dir, mgr, dInfo, type, inDeferred, dt); CPatterned::KnockBack(dir, mgr, dInfo, type, inDeferred, dt);
} }
EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f& point, const zeus::CVector3f&, EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f& point, const zeus::CVector3f&,
const CWeaponMode&, EProjectileAttrib) const const CWeaponMode&, EProjectileAttrib) const {
{
return HitShell(point) ? EWeaponCollisionResponseTypes::Unknown84 : EWeaponCollisionResponseTypes::Unknown34; return HitShell(point) ? EWeaponCollisionResponseTypes::Unknown84 : EWeaponCollisionResponseTypes::Unknown34;
} }
void DoUserAnimEvent(CStateManager&, const CInt32POINode&, EUserEventType, float); void DoUserAnimEvent(CStateManager&, const CInt32POINode&, EUserEventType, float);
void CollidedWith(TUniqueId uid, const CCollisionInfoList& colList, CStateManager& mgr) void CollidedWith(TUniqueId uid, const CCollisionInfoList& colList, CStateManager& mgr) {
{
if (x5c8_ == 2) if (x5c8_ == 2)
return; return;
CPatterned::CollidedWith(uid, colList, mgr); CPatterned::CollidedWith(uid, colList, mgr);
@ -80,4 +78,4 @@ public:
void GetUp(CStateManager&, EStateMsg, float); void GetUp(CStateManager&, EStateMsg, float);
void Attack(CStateManager&, EStateMsg, float); void Attack(CStateManager&, EStateMsg, float);
}; };
} } // namespace urde::MP1

View File

@ -219,4 +219,4 @@ void CSeedling::MassiveDeath(CStateManager& mgr) {
CPatterned::MassiveDeath(mgr); CPatterned::MassiveDeath(mgr);
} }
} } // namespace urde::MP1

View File

@ -41,4 +41,4 @@ public:
bool ShouldAttack(CStateManager&, float); bool ShouldAttack(CStateManager&, float);
void MassiveDeath(CStateManager&); void MassiveDeath(CStateManager&);
}; };
} // namespace urde } // namespace urde::MP1

View File

@ -530,10 +530,10 @@ bool CSpacePirate::FireProjectile(float dt, CStateManager& mgr) {
zeus::CVector3f gunToPos = pos - gunXf.origin; zeus::CVector3f gunToPos = pos - gunXf.origin;
float mag = gunToPos.magnitude(); float mag = gunToPos.magnitude();
gunToPos = gunToPos / mag; gunToPos = gunToPos / mag;
float dot = (GetLctrTransform(x7b8_wristSeg).origin - float dot =
GetLctrTransform(x7b7_elbowSeg).origin).normalized().dot(gunToPos); (GetLctrTransform(x7b8_wristSeg).origin - GetLctrTransform(x7b7_elbowSeg).origin).normalized().dot(gunToPos);
if ((dot > 0.707f || (mag < 6.f && dot > 0.5f)) && LineOfSightTest(mgr, gunXf.origin, pos, if ((dot > 0.707f || (mag < 6.f && dot > 0.5f)) &&
{EMaterialTypes::Player, EMaterialTypes::ProjectilePassthrough})) { LineOfSightTest(mgr, gunXf.origin, pos, {EMaterialTypes::Player, EMaterialTypes::ProjectilePassthrough})) {
pos += GetTransform().rotate(x7c4_burstFire.GetDistanceCompensatedError(mag, 6.f)); pos += GetTransform().rotate(x7c4_burstFire.GetDistanceCompensatedError(mag, 6.f));
LaunchProjectile(zeus::lookAt(gunXf.origin, pos), mgr, 6, EProjectileAttrib::None, false, {}, 0xffff, false, LaunchProjectile(zeus::lookAt(gunXf.origin, pos), mgr, 6, EProjectileAttrib::None, false, {}, 0xffff, false,
zeus::CVector3f::skOne); zeus::CVector3f::skOne);
@ -543,11 +543,11 @@ bool CSpacePirate::FireProjectile(float dt, CStateManager& mgr) {
} }
if (ret) { if (ret) {
auto bestAnim = x450_bodyController->GetPASDatabase().FindBestAnimation({24, CPASAnimParm::FromEnum(2)}, auto bestAnim = x450_bodyController->GetPASDatabase().FindBestAnimation({24, CPASAnimParm::FromEnum(2)},
*mgr.GetActiveRandom(), -1); *mgr.GetActiveRandom(), -1);
if (bestAnim.first > 0.f) if (bestAnim.first > 0.f)
x64_modelData->AnimationData()->AddAdditiveAnimation(bestAnim.second, 1.f, false, true); x64_modelData->AnimationData()->AddAdditiveAnimation(bestAnim.second, 1.f, false, true);
CSfxManager::AddEmitter(x568_pirateData.x48_Sound_Projectile, GetTranslation(), zeus::CVector3f::skZero, CSfxManager::AddEmitter(x568_pirateData.x48_Sound_Projectile, GetTranslation(), zeus::CVector3f::skZero, true,
true, false, 0x7f, kInvalidAreaId); false, 0x7f, kInvalidAreaId);
} }
return ret; return ret;
} }
@ -628,8 +628,8 @@ zeus::CVector3f CSpacePirate::GetTargetPos(CStateManager& mgr) {
} }
void CSpacePirate::UpdateAimBodyState(float dt, CStateManager& mgr) { void CSpacePirate::UpdateAimBodyState(float dt, CStateManager& mgr) {
if (x400_25_alive && x637_25_enableAim && !x637_29_inWallHang && !x450_bodyController->IsFrozen() && if (x400_25_alive && x637_25_enableAim && !x637_29_inWallHang && !x450_bodyController->IsFrozen() && !x634_27_melee &&
!x634_27_melee && !x85c_ragDoll && (!x635_26_seated || x639_28_satUp) && x31c_faceVec.z() <= 0.f) { !x85c_ragDoll && (!x635_26_seated || x639_28_satUp) && x31c_faceVec.z() <= 0.f) {
x8c4_aimDelayTimer = std::max(0.f, x8c4_aimDelayTimer - dt); x8c4_aimDelayTimer = std::max(0.f, x8c4_aimDelayTimer - dt);
if (x8c4_aimDelayTimer == 0.f) { if (x8c4_aimDelayTimer == 0.f) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCAdditiveAimCmd()); x450_bodyController->GetCommandMgr().DeliverCmd(CBCAdditiveAimCmd());
@ -1071,19 +1071,18 @@ void CSpacePirate::Death(CStateManager& mgr, const zeus::CVector3f& direction, E
if (x400_25_alive) { if (x400_25_alive) {
CPatterned::Death(mgr, direction, state); CPatterned::Death(mgr, direction, state);
if (x7b4_attachedActor != kInvalidUniqueId) { if (x7b4_attachedActor != kInvalidUniqueId) {
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(CBCKnockDownCmd(GetTransform().basis[1], pas::ESeverity::Two));
CBCKnockDownCmd(GetTransform().basis[1], pas::ESeverity::Two));
} }
} }
} }
void CSpacePirate::KnockBack(const zeus::CVector3f& backVec, CStateManager& mgr, void CSpacePirate::KnockBack(const zeus::CVector3f& backVec, CStateManager& mgr, const CDamageInfo& info,
const CDamageInfo& info, EKnockBackType type, bool inDeferred, float magnitude) { EKnockBackType type, bool inDeferred, float magnitude) {
if (!x634_25_ceilingAmbush || !x400_25_alive || inDeferred) { if (!x634_25_ceilingAmbush || !x400_25_alive || inDeferred) {
x460_knockBackController.SetAutoResetImpulse(!x634_31_noKnockbackImpulseReset); x460_knockBackController.SetAutoResetImpulse(!x634_31_noKnockbackImpulseReset);
x460_knockBackController.SetAvailableState(EKnockBackAnimationState::KnockBack, IsOnGround()); x460_knockBackController.SetAvailableState(EKnockBackAnimationState::KnockBack, IsOnGround());
x460_knockBackController.SetEnableFreeze(!((x636_24_trooper || x635_27_shadowPirate) && x460_knockBackController.SetEnableFreeze(!((x636_24_trooper || x635_27_shadowPirate) &&
!info.GetWeaponMode().IsCharged() && !info.GetWeaponMode().IsComboed())); !info.GetWeaponMode().IsCharged() && !info.GetWeaponMode().IsComboed()));
CPatterned::KnockBack(backVec, mgr, info, type, inDeferred, magnitude); CPatterned::KnockBack(backVec, mgr, info, type, inDeferred, magnitude);
if (x635_27_shadowPirate) { if (x635_27_shadowPirate) {
if (x400_25_alive) { if (x400_25_alive) {
@ -1107,15 +1106,15 @@ void CSpacePirate::KnockBack(const zeus::CVector3f& backVec, CStateManager& mgr,
if (x400_25_alive) { if (x400_25_alive) {
if (x460_knockBackController.GetActiveParms().x0_animState == EKnockBackAnimationState::Hurled) { if (x460_knockBackController.GetActiveParms().x0_animState == EKnockBackAnimationState::Hurled) {
x330_stateMachineState.SetState(mgr, *this, GetStateMachine(), "GetUpNow"sv); x330_stateMachineState.SetState(mgr, *this, GetStateMachine(), "GetUpNow"sv);
CSfxManager::AddEmitter(x568_pirateData.xc0_Sound_Hurled, GetTranslation(), zeus::CVector3f::skZero, 1.f, CSfxManager::AddEmitter(x568_pirateData.xc0_Sound_Hurled, GetTranslation(), zeus::CVector3f::skZero, 1.f, true,
true, false, 0x7f, kInvalidAreaId); false, 0x7f, kInvalidAreaId);
} }
} else { } else {
if (x460_knockBackController.GetActiveParms().x0_animState == EKnockBackAnimationState::Hurled && if (x460_knockBackController.GetActiveParms().x0_animState == EKnockBackAnimationState::Hurled &&
x460_knockBackController.GetActiveParms().x4_animFollowup != EKnockBackAnimationFollowUp::LaggedBurnDeath && x460_knockBackController.GetActiveParms().x4_animFollowup != EKnockBackAnimationFollowUp::LaggedBurnDeath &&
x460_knockBackController.GetActiveParms().x4_animFollowup != EKnockBackAnimationFollowUp::BurnDeath) { x460_knockBackController.GetActiveParms().x4_animFollowup != EKnockBackAnimationFollowUp::BurnDeath) {
CSfxManager::AddEmitter(x568_pirateData.xc2_Sound_Death, GetTranslation(), zeus::CVector3f::skZero, 1.f, CSfxManager::AddEmitter(x568_pirateData.xc2_Sound_Death, GetTranslation(), zeus::CVector3f::skZero, 1.f, true,
true, false, 0x7f, kInvalidAreaId); false, 0x7f, kInvalidAreaId);
} }
} }
} }
@ -1143,11 +1142,11 @@ zeus::CVector3f CSpacePirate::GetOrigin(const CStateManager& mgr, const CTeamAiR
} }
void CSpacePirate::AvoidActors(CStateManager& mgr) { void CSpacePirate::AvoidActors(CStateManager& mgr) {
for (CEntity* ent : mgr.GetListeningAiObjectList()) { for (CEntity* ent : mgr.GetListeningAiObjectList()) {
if (TCastToPtr<CPatterned> ai = ent) { if (TCastToPtr<CPatterned> ai = ent) {
if (ai.GetPtr() != this && ai->GetAreaIdAlways() == GetAreaIdAlways()) { if (ai.GetPtr() != this && ai->GetAreaIdAlways() == GetAreaIdAlways()) {
zeus::CVector3f deltaVec = x45c_steeringBehaviors.Separation( zeus::CVector3f deltaVec =
*this, ai->GetTranslation(), x568_pirateData.xc8_AvoidDistance); x45c_steeringBehaviors.Separation(*this, ai->GetTranslation(), x568_pirateData.xc8_AvoidDistance);
if (!deltaVec.isZero()) { if (!deltaVec.isZero()) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(deltaVec, zeus::CVector3f::skZero, 1.f)); x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(deltaVec, zeus::CVector3f::skZero, 1.f));
if (x748_steeringDelayTimer == 0.f) { if (x748_steeringDelayTimer == 0.f) {
@ -1184,7 +1183,7 @@ void CSpacePirate::Patrol(CStateManager& mgr, EStateMsg msg, float dt) {
case EStateMsg::Activate: case EStateMsg::Activate:
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed); x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
x644_steeringSpeed = x450_bodyController->GetBodyStateInfo().GetLocomotionSpeed(pas::ELocomotionAnim::Walk) / x644_steeringSpeed = x450_bodyController->GetBodyStateInfo().GetLocomotionSpeed(pas::ELocomotionAnim::Walk) /
x450_bodyController->GetBodyStateInfo().GetLocomotionSpeed(pas::ELocomotionAnim::Run); x450_bodyController->GetBodyStateInfo().GetLocomotionSpeed(pas::ELocomotionAnim::Run);
break; break;
case EStateMsg::Deactivate: case EStateMsg::Deactivate:
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Combat); x450_bodyController->SetLocomotionType(pas::ELocomotionType::Combat);
@ -1287,13 +1286,12 @@ void CSpacePirate::PathFind(CStateManager& mgr, EStateMsg msg, float dt) {
} }
if (GetSearchPath()->Search(GetTranslation(), x2e0_destPos) == CPathFindSearch::EResult::Success) { if (GetSearchPath()->Search(GetTranslation(), x2e0_destPos) == CPathFindSearch::EResult::Success) {
x2ec_reflectedDestPos = GetTranslation(); x2ec_reflectedDestPos = GetTranslation();
x2e0_destPos = x2e0_destPos = (GetSearchPath()->GetCurrentWaypoint() + 1 < GetSearchPath()->GetWaypoints().size())
(GetSearchPath()->GetCurrentWaypoint() + 1 < GetSearchPath()->GetWaypoints().size()) ? ? GetSearchPath()->GetWaypoints()[GetSearchPath()->GetCurrentWaypoint() + 1]
GetSearchPath()->GetWaypoints()[GetSearchPath()->GetCurrentWaypoint() + 1] : : GetSearchPath()->GetWaypoints()[GetSearchPath()->GetCurrentWaypoint()];
GetSearchPath()->GetWaypoints()[GetSearchPath()->GetCurrentWaypoint()];
x328_24_inPosition = false; x328_24_inPosition = false;
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(
CBCLocomotionCmd(x2e0_destPos - GetTranslation(), zeus::CVector3f::skZero, 1.f)); CBCLocomotionCmd(x2e0_destPos - GetTranslation(), zeus::CVector3f::skZero, 1.f));
} else { } else {
CScriptAiJumpPoint* bestJp = nullptr; CScriptAiJumpPoint* bestJp = nullptr;
float minDist = FLT_MAX; float minDist = FLT_MAX;
@ -1305,14 +1303,13 @@ void CSpacePirate::PathFind(CStateManager& mgr, EStateMsg msg, float dt) {
float f30 = toJp.magSquared(); float f30 = toJp.magSquared();
if (f30 > 25.f && jp->GetTransform().basis[1].dot(toJp) > 0.f) { if (f30 > 25.f && jp->GetTransform().basis[1].dot(toJp) > 0.f) {
if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(jp->GetJumpPoint())) { if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(jp->GetJumpPoint())) {
if ((wp->GetTranslation().z() - jp->GetTranslation().z()) * if ((wp->GetTranslation().z() - jp->GetTranslation().z()) * (x2e0_destPos.z() - GetTranslation().z()) >
(x2e0_destPos.z() - GetTranslation().z()) > 0.f) { 0.f) {
zeus::CVector3f delta = x2e0_destPos - wp->GetTranslation(); zeus::CVector3f delta = x2e0_destPos - wp->GetTranslation();
f30 += 4.f * toJp.z() * toJp.z(); f30 += 4.f * toJp.z() * toJp.z();
f30 += delta.magSquared() + delta.z() * delta.z() * 9.f; f30 += delta.magSquared() + delta.z() * delta.z() * 9.f;
if (f30 < minDist && if (f30 < minDist && GetSearchPath()->PathExists(GetTranslation(), jp->GetTranslation()) ==
GetSearchPath()->PathExists(GetTranslation(), jp->GetTranslation()) == CPathFindSearch::EResult::Success) {
CPathFindSearch::EResult::Success) {
bool r24 = false; bool r24 = false;
auto res = GetSearchPath()->PathExists(wp->GetTranslation(), x2e0_destPos); auto res = GetSearchPath()->PathExists(wp->GetTranslation(), x2e0_destPos);
if (res != CPathFindSearch::EResult::Success) if (res != CPathFindSearch::EResult::Success)
@ -1336,17 +1333,16 @@ void CSpacePirate::PathFind(CStateManager& mgr, EStateMsg msg, float dt) {
x2e0_destPos = bestJp->GetTranslation(); x2e0_destPos = bestJp->GetTranslation();
if (GetSearchPath()->Search(GetTranslation(), x2e0_destPos) == CPathFindSearch::EResult::Success) { if (GetSearchPath()->Search(GetTranslation(), x2e0_destPos) == CPathFindSearch::EResult::Success) {
x2ec_reflectedDestPos = GetTranslation(); x2ec_reflectedDestPos = GetTranslation();
x2e0_destPos = x2e0_destPos = (GetSearchPath()->GetCurrentWaypoint() + 1 < GetSearchPath()->GetWaypoints().size())
(GetSearchPath()->GetCurrentWaypoint() + 1 < GetSearchPath()->GetWaypoints().size()) ? ? GetSearchPath()->GetWaypoints()[GetSearchPath()->GetCurrentWaypoint() + 1]
GetSearchPath()->GetWaypoints()[GetSearchPath()->GetCurrentWaypoint() + 1] : : GetSearchPath()->GetWaypoints()[GetSearchPath()->GetCurrentWaypoint()];
GetSearchPath()->GetWaypoints()[GetSearchPath()->GetCurrentWaypoint()];
x328_24_inPosition = false; x328_24_inPosition = false;
x840_jumpPoint = bestJp->GetUniqueId(); x840_jumpPoint = bestJp->GetUniqueId();
x824_jumpHeight = bestJp->GetJumpApex(); x824_jumpHeight = bestJp->GetJumpApex();
if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(bestJp->GetJumpPoint())) { if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(bestJp->GetJumpPoint())) {
x828_patrolDestPos = wp->GetTranslation(); x828_patrolDestPos = wp->GetTranslation();
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(
CBCLocomotionCmd(x2e0_destPos, zeus::CVector3f::skZero, 1.f)); CBCLocomotionCmd(x2e0_destPos, zeus::CVector3f::skZero, 1.f));
x30c_behaviourOrient = EBehaviourOrient::MoveDir; x30c_behaviourOrient = EBehaviourOrient::MoveDir;
} }
} }
@ -1362,8 +1358,9 @@ void CSpacePirate::PathFind(CStateManager& mgr, EStateMsg msg, float dt) {
CPatterned::PathFind(mgr, msg, dt); CPatterned::PathFind(mgr, msg, dt);
if (x840_jumpPoint != kInvalidUniqueId) { if (x840_jumpPoint != kInvalidUniqueId) {
if (TCastToPtr<CScriptAiJumpPoint> jp = mgr.ObjectById(x840_jumpPoint)) { if (TCastToPtr<CScriptAiJumpPoint> jp = mgr.ObjectById(x840_jumpPoint)) {
float f0 = (1.5f * dt + 0.1f) * x64_modelData->GetScale().y() * float f0 =
x450_bodyController->GetBodyStateInfo().GetMaxSpeed() + x7a4_intoJumpDist; (1.5f * dt + 0.1f) * x64_modelData->GetScale().y() * x450_bodyController->GetBodyStateInfo().GetMaxSpeed() +
x7a4_intoJumpDist;
if ((GetTranslation() - jp->GetTranslation()).magSquared() < f0 * f0) { if ((GetTranslation() - jp->GetTranslation()).magSquared() < f0 * f0) {
x32c_animState = EAnimState::Ready; x32c_animState = EAnimState::Ready;
TryCommand(mgr, pas::EAnimationState::Jump, &CPatterned::TryJump, 0); TryCommand(mgr, pas::EAnimationState::Jump, &CPatterned::TryJump, 0);
@ -1373,8 +1370,8 @@ void CSpacePirate::PathFind(CStateManager& mgr, EStateMsg msg, float dt) {
AvoidActors(mgr); AvoidActors(mgr);
if (!x639_27_inRange) { if (!x639_27_inRange) {
if (CScriptCoverPoint* cp = GetCoverPoint(mgr, x640_coverPoint)) { if (CScriptCoverPoint* cp = GetCoverPoint(mgr, x640_coverPoint)) {
x754_fsmRange = (1.5f * dt + 0.1f) * x64_modelData->GetScale().y() * x754_fsmRange =
x450_bodyController->GetBodyStateInfo().GetMaxSpeed(); (1.5f * dt + 0.1f) * x64_modelData->GetScale().y() * x450_bodyController->GetBodyStateInfo().GetMaxSpeed();
if (cp->ShouldWallHang()) if (cp->ShouldWallHang())
x754_fsmRange += x7a4_intoJumpDist; x754_fsmRange += x7a4_intoJumpDist;
x639_27_inRange = (GetTranslation() - cp->GetTranslation()).magSquared() < x754_fsmRange * x754_fsmRange; x639_27_inRange = (GetTranslation() - cp->GetTranslation()).magSquared() < x754_fsmRange * x754_fsmRange;
@ -1404,8 +1401,9 @@ void CSpacePirate::TargetPatrol(CStateManager& mgr, EStateMsg msg, float dt) {
case EStateMsg::Update: case EStateMsg::Update:
if (TCastToPtr<CScriptWaypoint> wp = mgr.ObjectById(x2dc_destObj)) { if (TCastToPtr<CScriptWaypoint> wp = mgr.ObjectById(x2dc_destObj)) {
if ((wp->GetBehaviourModifiers() & 0x2) != 0 || (wp->GetBehaviourModifiers() & 0x4)) { if ((wp->GetBehaviourModifiers() & 0x2) != 0 || (wp->GetBehaviourModifiers() & 0x4)) {
float f0 = (1.5f * dt + 0.1f) * x64_modelData->GetScale().y() * float f0 =
x450_bodyController->GetBodyStateInfo().GetMaxSpeed() + x7a4_intoJumpDist; (1.5f * dt + 0.1f) * x64_modelData->GetScale().y() * x450_bodyController->GetBodyStateInfo().GetMaxSpeed() +
x7a4_intoJumpDist;
if ((GetTranslation() - wp->GetTranslation()).magSquared() < f0 * f0) { if ((GetTranslation() - wp->GetTranslation()).magSquared() < f0 * f0) {
x328_24_inPosition = true; x328_24_inPosition = true;
x824_jumpHeight = (wp->GetBehaviourModifiers() & 0x2) ? 3.f : 0.f; x824_jumpHeight = (wp->GetBehaviourModifiers() & 0x2) ? 3.f : 0.f;
@ -1447,13 +1445,9 @@ void CSpacePirate::TargetCover(CStateManager& mgr, EStateMsg msg, float dt) {
} }
} }
void CSpacePirate::Halt(CStateManager& mgr, EStateMsg msg, float dt) { void CSpacePirate::Halt(CStateManager& mgr, EStateMsg msg, float dt) { x644_steeringSpeed = 0.f; }
x644_steeringSpeed = 0.f;
}
void CSpacePirate::Run(CStateManager& mgr, EStateMsg msg, float dt) { void CSpacePirate::Run(CStateManager& mgr, EStateMsg msg, float dt) { x644_steeringSpeed = 1.f; }
x644_steeringSpeed = 1.f;
}
void CSpacePirate::Generate(CStateManager& mgr, EStateMsg msg, float dt) { void CSpacePirate::Generate(CStateManager& mgr, EStateMsg msg, float dt) {
switch (msg) { switch (msg) {
@ -1580,8 +1574,7 @@ void CSpacePirate::JumpBack(CStateManager& mgr, EStateMsg msg, float dt) {
float backupChHeight = GetSearchPath()->GetCharacterHeight(); float backupChHeight = GetSearchPath()->GetCharacterHeight();
x660_pathFindSearch.SetCharacterHeight(5.f + backupChHeight); x660_pathFindSearch.SetCharacterHeight(5.f + backupChHeight);
zeus::CVector3f dest = GetTransform().basis[1] * 10.f + GetTranslation(); zeus::CVector3f dest = GetTransform().basis[1] * 10.f + GetTranslation();
if (GetSearchPath()->Search(GetTranslation(), dest) == if (GetSearchPath()->Search(GetTranslation(), dest) == CPathFindSearch::EResult::Success &&
CPathFindSearch::EResult::Success &&
(GetSearchPath()->GetWaypoints().back() - dest).magSquared() < 3.f && (GetSearchPath()->GetWaypoints().back() - dest).magSquared() < 3.f &&
std::fabs(GetSearchPath()->RemainingPathDistance(GetTranslation()) - 10.f) < 4.f) { std::fabs(GetSearchPath()->RemainingPathDistance(GetTranslation()) - 10.f) < 4.f) {
x828_patrolDestPos = GetSearchPath()->GetWaypoints().back(); x828_patrolDestPos = GetSearchPath()->GetWaypoints().back();
@ -1595,7 +1588,7 @@ void CSpacePirate::JumpBack(CStateManager& mgr, EStateMsg msg, float dt) {
case EStateMsg::Update: case EStateMsg::Update:
if (!x639_25_useJumpBackJump) { if (!x639_25_useJumpBackJump) {
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(
CBCStepCmd(pas::EStepDirection::Backward, pas::EStepType::Normal)); CBCStepCmd(pas::EStepDirection::Backward, pas::EStepType::Normal));
x450_bodyController->GetCommandMgr().SetTargetVector(GetTargetPos(mgr) - GetTranslation()); x450_bodyController->GetCommandMgr().SetTargetVector(GetTargetPos(mgr) - GetTranslation());
} else { } else {
TryCommand(mgr, pas::EAnimationState::Jump, &CPatterned::TryJump, 0); TryCommand(mgr, pas::EAnimationState::Jump, &CPatterned::TryJump, 0);
@ -1666,18 +1659,19 @@ void CSpacePirate::Shuffle(CStateManager& mgr, EStateMsg msg, float dt) {
if (msg == EStateMsg::Activate) { if (msg == EStateMsg::Activate) {
x450_bodyController->GetCommandMgr().SetSteeringBlendMode(ESteeringBlendMode::Normal); x450_bodyController->GetCommandMgr().SetSteeringBlendMode(ESteeringBlendMode::Normal);
if (!x634_28_noShuffleCloseCheck && TooClose(mgr, 0.f)) { if (!x634_28_noShuffleCloseCheck && TooClose(mgr, 0.f)) {
SetDestPos( SetDestPos(GetTranslation() +
GetTranslation() + x2fc_minAttackRange * (GetTranslation() - mgr.GetPlayer().GetTranslation()).normalized() + x2fc_minAttackRange * (GetTranslation() - mgr.GetPlayer().GetTranslation()).normalized() +
mgr.Random2f(0.f, 5.f)); mgr.Random2f(0.f, 5.f));
x2dc_destObj = kInvalidUniqueId; x2dc_destObj = kInvalidUniqueId;
x30c_behaviourOrient = EBehaviourOrient::Constant; x30c_behaviourOrient = EBehaviourOrient::Constant;
x636_30_shuffleClose = true; x636_30_shuffleClose = true;
} else { } else {
zeus::CVector3f fromPlayer = GetTranslation() - mgr.GetPlayer().GetTranslation(); zeus::CVector3f fromPlayer = GetTranslation() - mgr.GetPlayer().GetTranslation();
SetDestPos( SetDestPos(mgr.GetPlayer().GetTranslation() +
mgr.GetPlayer().GetTranslation() + (x300_maxAttackRange * mgr.GetActiveRandom()->Float() + x300_maxAttackRange) * (x300_maxAttackRange * mgr.GetActiveRandom()->Float() + x300_maxAttackRange) *
fromPlayer.normalized() + zeus::CVector3f::skUp.cross(fromPlayer).normalized() * fromPlayer.normalized() +
(2.f * x300_maxAttackRange * (mgr.GetActiveRandom()->Float() - 0.5f))); zeus::CVector3f::skUp.cross(fromPlayer).normalized() *
(2.f * x300_maxAttackRange * (mgr.GetActiveRandom()->Float() - 0.5f)));
x2dc_destObj = kInvalidUniqueId; x2dc_destObj = kInvalidUniqueId;
x30c_behaviourOrient = EBehaviourOrient::MoveDir; x30c_behaviourOrient = EBehaviourOrient::MoveDir;
x636_30_shuffleClose = false; x636_30_shuffleClose = false;
@ -1803,8 +1797,8 @@ void CSpacePirate::Taunt(CStateManager& mgr, EStateMsg msg, float dt) {
if (!x635_27_shadowPirate) { if (!x635_27_shadowPirate) {
bool withOtherPirate = true; bool withOtherPirate = true;
if (x634_27_melee) { if (x634_27_melee) {
auto bestAnim = x450_bodyController->GetPASDatabase().FindBestAnimation( auto bestAnim = x450_bodyController->GetPASDatabase().FindBestAnimation({16, CPASAnimParm::FromEnum(2)},
{16, CPASAnimParm::FromEnum(2)}, *mgr.GetActiveRandom(), -1); *mgr.GetActiveRandom(), -1);
if (bestAnim.first > 0.f) { if (bestAnim.first > 0.f) {
withOtherPirate = false; withOtherPirate = false;
x760_taunt = pas::ETauntType::Two; x760_taunt = pas::ETauntType::Two;
@ -1829,8 +1823,8 @@ void CSpacePirate::Taunt(CStateManager& mgr, EStateMsg msg, float dt) {
} }
x32c_animState = EAnimState::Ready; x32c_animState = EAnimState::Ready;
} }
CSfxManager::AddEmitter(x568_pirateData.xa4_Sound_Alert, GetTranslation(), zeus::CVector3f::skZero, true, false, 0x7f, CSfxManager::AddEmitter(x568_pirateData.xa4_Sound_Alert, GetTranslation(), zeus::CVector3f::skZero, true, false,
kInvalidAreaId); 0x7f, kInvalidAreaId);
break; break;
case EStateMsg::Update: case EStateMsg::Update:
TryCommand(mgr, pas::EAnimationState::Taunt, &CPatterned::TryTaunt, int(x760_taunt)); TryCommand(mgr, pas::EAnimationState::Taunt, &CPatterned::TryTaunt, int(x760_taunt));
@ -1971,8 +1965,8 @@ void CSpacePirate::Dodge(CStateManager& mgr, EStateMsg msg, float dt) {
if (mgr.GetActiveRandom()->Float() < if (mgr.GetActiveRandom()->Float() <
((x750_initialHP - HealthInfo(mgr)->GetHP()) * 4.f / x750_initialHP + 1.f) * 0.15f) ((x750_initialHP - HealthInfo(mgr)->GetHP()) * 4.f / x750_initialHP + 1.f) * 0.15f)
x639_29_enableBreakDodge = true; x639_29_enableBreakDodge = true;
x8c0_dodgeDelayTimer = mgr.GetActiveRandom()->Range(x568_pirateData.xb8_dodgeDelayTimeMin, x8c0_dodgeDelayTimer =
x568_pirateData.xbc_dodgeDelayTimeMax); mgr.GetActiveRandom()->Range(x568_pirateData.xb8_dodgeDelayTimeMin, x568_pirateData.xbc_dodgeDelayTimeMax);
} }
x844_dodgeDir = GetStrafeDir(mgr, x639_29_enableBreakDodge ? x84c_breakDodgeDist : x848_dodgeDist); x844_dodgeDir = GetStrafeDir(mgr, x639_29_enableBreakDodge ? x84c_breakDodgeDist : x848_dodgeDist);
if (x844_dodgeDir != pas::EStepDirection::Invalid) if (x844_dodgeDir != pas::EStepDirection::Invalid)
@ -1988,8 +1982,7 @@ void CSpacePirate::Dodge(CStateManager& mgr, EStateMsg msg, float dt) {
TryCommand(mgr, pas::EAnimationState::Step, &CPatterned::TryBreakDodge, int(x844_dodgeDir)); TryCommand(mgr, pas::EAnimationState::Step, &CPatterned::TryBreakDodge, int(x844_dodgeDir));
if (GetMaterialList().HasMaterial(EMaterialTypes::Orbit) && x330_stateMachineState.GetTime() > 0.5f) { if (GetMaterialList().HasMaterial(EMaterialTypes::Orbit) && x330_stateMachineState.GetTime() > 0.5f) {
RemoveMaterial(EMaterialTypes::Orbit, mgr); RemoveMaterial(EMaterialTypes::Orbit, mgr);
mgr.GetPlayer().SetOrbitRequestForTarget(GetUniqueId(), mgr.GetPlayer().SetOrbitRequestForTarget(GetUniqueId(), CPlayer::EPlayerOrbitRequest::ActivateOrbitSource, mgr);
CPlayer::EPlayerOrbitRequest::ActivateOrbitSource, mgr);
} }
} }
break; break;
@ -2115,7 +2108,7 @@ void CSpacePirate::Bounce(CStateManager& mgr, EStateMsg msg, float dt) {
if (TCastToConstPtr<CScriptAiJumpPoint> jp = mgr.GetObjectById(x840_jumpPoint)) { if (TCastToConstPtr<CScriptAiJumpPoint> jp = mgr.GetObjectById(x840_jumpPoint)) {
if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(jp->GetJumpTarget())) { if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(jp->GetJumpTarget())) {
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(
CBCJumpCmd(x828_patrolDestPos, wp->GetTranslation(), pas::EJumpType::Normal)); CBCJumpCmd(x828_patrolDestPos, wp->GetTranslation(), pas::EJumpType::Normal));
} }
} }
break; break;
@ -2140,8 +2133,9 @@ void CSpacePirate::PathFindEx(CStateManager& mgr, EStateMsg msg, float dt) {
AvoidActors(mgr); AvoidActors(mgr);
if (!x639_27_inRange) { if (!x639_27_inRange) {
if (TCastToConstPtr<CScriptAiJumpPoint> jp = mgr.GetObjectById(x840_jumpPoint)) { if (TCastToConstPtr<CScriptAiJumpPoint> jp = mgr.GetObjectById(x840_jumpPoint)) {
x754_fsmRange = (1.5f * dt + 0.1f) * x64_modelData->GetScale().y() * x754_fsmRange =
x450_bodyController->GetBodyStateInfo().GetMaxSpeed() + x7a4_intoJumpDist; (1.5f * dt + 0.1f) * x64_modelData->GetScale().y() * x450_bodyController->GetBodyStateInfo().GetMaxSpeed() +
x7a4_intoJumpDist;
x639_27_inRange = (GetTranslation() - jp->GetTranslation()).magSquared() < x754_fsmRange * x754_fsmRange; x639_27_inRange = (GetTranslation() - jp->GetTranslation()).magSquared() < x754_fsmRange * x754_fsmRange;
} }
} }
@ -2152,30 +2146,22 @@ void CSpacePirate::PathFindEx(CStateManager& mgr, EStateMsg msg, float dt) {
} }
} }
bool CSpacePirate::Leash(CStateManager& mgr, float arg) { bool CSpacePirate::Leash(CStateManager& mgr, float arg) { return x8dc_leashTimer > arg; }
return x8dc_leashTimer > arg;
}
bool CSpacePirate::OffLine(CStateManager& mgr, float arg) { bool CSpacePirate::OffLine(CStateManager& mgr, float arg) { return !IsOnGround(); }
return !IsOnGround();
}
bool CSpacePirate::Attacked(CStateManager& mgr, float arg) { bool CSpacePirate::Attacked(CStateManager& mgr, float arg) {
return x850_timeSinceHitByPlayer < (arg == 0.f ? 0.5f : arg); return x850_timeSinceHitByPlayer < (arg == 0.f ? 0.5f : arg);
} }
bool CSpacePirate::InRange(CStateManager& mgr, float arg) { bool CSpacePirate::InRange(CStateManager& mgr, float arg) { return x639_27_inRange; }
return x639_27_inRange;
}
bool CSpacePirate::SpotPlayer(CStateManager& mgr, float arg) { bool CSpacePirate::SpotPlayer(CStateManager& mgr, float arg) {
zeus::CVector3f toPlayer = mgr.GetPlayer().GetTranslation() - GetTranslation(); zeus::CVector3f toPlayer = mgr.GetPlayer().GetTranslation() - GetTranslation();
return toPlayer.dot(GetTransform().basis[1]) > toPlayer.magnitude() * x3c4_detectionAngle; return toPlayer.dot(GetTransform().basis[1]) > toPlayer.magnitude() * x3c4_detectionAngle;
} }
bool CSpacePirate::PatternOver(CStateManager& mgr, float arg) { bool CSpacePirate::PatternOver(CStateManager& mgr, float arg) { return x2dc_destObj == kInvalidUniqueId; }
return x2dc_destObj == kInvalidUniqueId;
}
bool CSpacePirate::PatternShagged(CStateManager& mgr, float arg) { bool CSpacePirate::PatternShagged(CStateManager& mgr, float arg) {
return CPatterned::Stuck(mgr, arg) || CPatterned::PatternShagged(mgr, arg); return CPatterned::Stuck(mgr, arg) || CPatterned::PatternShagged(mgr, arg);
@ -2219,9 +2205,7 @@ bool CSpacePirate::Stuck(CStateManager& mgr, float arg) {
return false; return false;
} }
bool CSpacePirate::Landed(CStateManager& mgr, float arg) { bool CSpacePirate::Landed(CStateManager& mgr, float arg) { return IsOnGround(); }
return IsOnGround();
}
bool CSpacePirate::HearShot(CStateManager& mgr, float arg) { bool CSpacePirate::HearShot(CStateManager& mgr, float arg) {
bool ret = x636_25_hearNoise; bool ret = x636_25_hearNoise;
@ -2232,13 +2216,11 @@ bool CSpacePirate::HearShot(CStateManager& mgr, float arg) {
bool CSpacePirate::HearPlayer(CStateManager& mgr, float arg) { bool CSpacePirate::HearPlayer(CStateManager& mgr, float arg) {
if (mgr.GetPlayer().GetVelocity().magSquared() > 0.1f) if (mgr.GetPlayer().GetVelocity().magSquared() > 0.1f)
return (mgr.GetPlayer().GetTranslation() - GetTranslation()).magSquared() < return (mgr.GetPlayer().GetTranslation() - GetTranslation()).magSquared() <
x568_pirateData.x14_HearingRadius * x568_pirateData.x14_HearingRadius; x568_pirateData.x14_HearingRadius * x568_pirateData.x14_HearingRadius;
return false; return false;
} }
bool CSpacePirate::CoverCheck(CStateManager& mgr, float arg) { bool CSpacePirate::CoverCheck(CStateManager& mgr, float arg) { return x638_27_coverCheck; }
return x638_27_coverCheck;
}
bool CSpacePirate::CoverFind(CStateManager& mgr, float arg) { bool CSpacePirate::CoverFind(CStateManager& mgr, float arg) {
bool ret = false; bool ret = false;
@ -2301,9 +2283,7 @@ bool CSpacePirate::CoveringFire(CStateManager& mgr, float arg) {
return ret; return ret;
} }
bool CSpacePirate::LineOfSight(CStateManager& mgr, float arg) { bool CSpacePirate::LineOfSight(CStateManager& mgr, float arg) { return !x637_28_noPlayerLos; }
return !x637_28_noPlayerLos;
}
bool CSpacePirate::AggressionCheck(CStateManager& mgr, float arg) { bool CSpacePirate::AggressionCheck(CStateManager& mgr, float arg) {
bool ret = false; bool ret = false;
@ -2423,9 +2403,7 @@ bool CSpacePirate::StartAttack(CStateManager& mgr, float arg) {
return false; return false;
} }
bool CSpacePirate::BreakAttack(CStateManager& mgr, float arg) { bool CSpacePirate::BreakAttack(CStateManager& mgr, float arg) { return x635_25_breakAttack; }
return x635_25_breakAttack;
}
bool CSpacePirate::ShouldStrafe(CStateManager& mgr, float arg) { bool CSpacePirate::ShouldStrafe(CStateManager& mgr, float arg) {
bool ret = false; bool ret = false;
@ -2475,10 +2453,10 @@ bool CSpacePirate::BounceFind(CStateManager& mgr, float arg) {
distSq += wpToDest.magSquared(); distSq += wpToDest.magSquared();
if (distSq < minDistSq && wp->GetTransform().basis[1].dot(wpToDest) > 0.f && if (distSq < minDistSq && wp->GetTransform().basis[1].dot(wpToDest) > 0.f &&
GetSearchPath()->PathExists(GetTranslation(), jp->GetTranslation()) == GetSearchPath()->PathExists(GetTranslation(), jp->GetTranslation()) ==
CPathFindSearch::EResult::Success) { CPathFindSearch::EResult::Success) {
bool good = false; bool good = false;
bool fail = GetSearchPath()->PathExists(wp->GetTranslation(), x2e0_destPos) != bool fail =
CPathFindSearch::EResult::Success; GetSearchPath()->PathExists(wp->GetTranslation(), x2e0_destPos) != CPathFindSearch::EResult::Success;
if (fail) if (fail)
distSq += 1000.f; distSq += 1000.f;
if (!fail) if (!fail)

View File

@ -32,6 +32,7 @@ public:
class CSpacePirate : public CPatterned { class CSpacePirate : public CPatterned {
friend class CPirateRagDoll; friend class CPirateRagDoll;
public: public:
DEFINE_PATTERNED(SpacePirate) DEFINE_PATTERNED(SpacePirate)
private: private:
@ -263,8 +264,7 @@ public:
float magnitude); float magnitude);
bool IsListening() const; bool IsListening() const;
bool Listen(const zeus::CVector3f&, EListenNoiseType); bool Listen(const zeus::CVector3f&, EListenNoiseType);
zeus::CVector3f GetOrigin(const CStateManager& mgr, const CTeamAiRole& role, zeus::CVector3f GetOrigin(const CStateManager& mgr, const CTeamAiRole& role, const zeus::CVector3f& aimPos) const;
const zeus::CVector3f& aimPos) const;
void DetachActorFromPirate() { x7b4_attachedActor = kInvalidUniqueId; } void DetachActorFromPirate() { x7b4_attachedActor = kInvalidUniqueId; }
bool AttachActorToPirate(TUniqueId id); bool AttachActorToPirate(TUniqueId id);
void SetAttackTarget(TUniqueId id); void SetAttackTarget(TUniqueId id);

View File

@ -47,9 +47,8 @@ CSpankWeed::CSpankWeed(TUniqueId uid, std::string_view name, const CEntityInfo&
x460_knockBackController.SetAutoResetImpulse(false); x460_knockBackController.SetAutoResetImpulse(false);
} }
static const SSphereJointInfo kArmCollision[] = {{"Arm_4", 1.5f}, {"Arm_6", 1.f}, {"Arm_7", 1.f}, static const SSphereJointInfo kArmCollision[] = {{"Arm_4", 1.5f}, {"Arm_6", 1.f}, {"Arm_7", 1.f}, {"Arm_8", 1.f},
{"Arm_8", 1.f}, {"Arm_9", 1.f}, {"Arm_11", 1.f}, {"Arm_9", 1.f}, {"Arm_11", 1.f}, {"Swoosh_LCTR", 1.5f}};
{"Swoosh_LCTR", 1.5f}};
void CSpankWeed::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) { void CSpankWeed::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
bool oldActive = GetActive(); bool oldActive = GetActive();
@ -119,7 +118,7 @@ void CSpankWeed::Think(float dt, CStateManager& mgr) {
if (!x598_isHiding) { if (!x598_isHiding) {
zeus::CVector3f eyeOrigin = GetLocatorTransform("Eye"sv).origin; zeus::CVector3f eyeOrigin = GetLocatorTransform("Eye"sv).origin;
MoveCollisionPrimitive(GetModelData()->GetScale() * eyeOrigin); MoveCollisionPrimitive(GetTransform().rotate(GetModelData()->GetScale() * eyeOrigin));
x594_collisionMgr->Update(dt, mgr, CCollisionActorManager::EUpdateOptions::ObjectSpace); x594_collisionMgr->Update(dt, mgr, CCollisionActorManager::EUpdateOptions::ObjectSpace);
xe4_27_notInSortedLists = true; xe4_27_notInSortedLists = true;
} }

View File

@ -1,4 +1,7 @@
#include "CTryclops.hpp" #include "CTryclops.hpp"
#include "CStateManager.hpp"
#include "World/CWorld.hpp"
#include "World/CGameArea.hpp"
namespace urde::MP1 { namespace urde::MP1 {
CTryclops::CTryclops(urde::TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, CTryclops::CTryclops(urde::TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
@ -6,4 +9,14 @@ CTryclops::CTryclops(urde::TUniqueId uid, std::string_view name, const CEntityIn
const urde::CActorParameters& actParms, float, float, float, float) const urde::CActorParameters& actParms, float, float, float, float)
: CPatterned(ECharacter::Tryclops, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo, : CPatterned(ECharacter::Tryclops, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo,
EMovementType::Ground, EColliderType::One, EBodyType::BiPedal, actParms, EKnockBackVariant::Small) {} EMovementType::Ground, EColliderType::One, EBodyType::BiPedal, actParms, EKnockBackVariant::Small) {}
void CTryclops::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
CPatterned::AcceptScriptMsg(msg, uid, mgr);
if (msg == EScriptObjectMessage::Registered) {
x450_bodyController->Activate(mgr);
} else if (msg == EScriptObjectMessage::InitializedInArea) {
//x568_pathFindSearch.SetArea(mgr.GetWorld()->GetAreaAlways(GetAreaIdAlways())->GetPostConstructed()->x10bc_pathArea);
}
}
} // namespace urde::MP1 } // namespace urde::MP1

View File

@ -8,5 +8,7 @@ public:
DEFINE_PATTERNED(Tryclops) DEFINE_PATTERNED(Tryclops)
CTryclops(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&, CTryclops(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const CPatternedInfo&, const CActorParameters&, float, float, float, float); const CPatternedInfo&, const CActorParameters&, float, float, float, float);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
}; };
} // namespace urde::MP1 } // namespace urde::MP1

View File

@ -62,9 +62,9 @@ void CWarWasp::SwarmRemove(CStateManager& mgr) {
void CWarWasp::ApplyDamage(CStateManager& mgr) { void CWarWasp::ApplyDamage(CStateManager& mgr) {
if (x72e_25_canApplyDamage && x450_bodyController->GetCurrentStateId() == pas::EAnimationState::MeleeAttack) { if (x72e_25_canApplyDamage && x450_bodyController->GetCurrentStateId() == pas::EAnimationState::MeleeAttack) {
if (mgr.GetPlayer().GetBoundingBox().pointInside( if (mgr.GetPlayer().GetBoundingBox().pointInside(
GetTransform() * (GetLocatorTransform("LCTR_WARTAIL"sv).origin * x64_modelData->GetScale()))) { GetTransform() * (GetLocatorTransform("LCTR_WARTAIL"sv).origin * x64_modelData->GetScale()))) {
mgr.ApplyDamage(GetUniqueId(), mgr.GetPlayer().GetUniqueId(), GetUniqueId(), GetContactDamage(), mgr.ApplyDamage(GetUniqueId(), mgr.GetPlayer().GetUniqueId(), GetUniqueId(), GetContactDamage(),
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), zeus::CVector3f::skZero); CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), zeus::CVector3f::skZero);
x72e_25_canApplyDamage = false; x72e_25_canApplyDamage = false;
} }
} }
@ -77,8 +77,10 @@ void CWarWasp::Think(float dt, CStateManager& mgr) {
if (x700_attackRemTime > 0.f) { if (x700_attackRemTime > 0.f) {
float rate = 1.f; float rate = 1.f;
if (mgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed) if (mgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed)
rate = 1.f - zeus::CVector2f::getAngleDiff(mgr.GetPlayer().GetTransform().basis[1].toVec2f(), rate =
GetTranslation().toVec2f() - mgr.GetPlayer().GetTranslation().toVec2f()) / M_PIF * 0.666f; 1.f - zeus::CVector2f::getAngleDiff(mgr.GetPlayer().GetTransform().basis[1].toVec2f(),
GetTranslation().toVec2f() - mgr.GetPlayer().GetTranslation().toVec2f()) /
M_PIF * 0.666f;
x700_attackRemTime -= rate * dt; x700_attackRemTime -= rate * dt;
} }
@ -141,15 +143,15 @@ void CWarWasp::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EU
rstl::reserved_vector<TUniqueId, 1024> nearList; rstl::reserved_vector<TUniqueId, 1024> nearList;
TUniqueId bestId = kInvalidUniqueId; TUniqueId bestId = kInvalidUniqueId;
CRayCastResult res = mgr.RayWorldIntersection(bestId, xf.origin, delta.normalized(), delta.magnitude(), CRayCastResult res = mgr.RayWorldIntersection(bestId, xf.origin, delta.normalized(), delta.magnitude(),
CMaterialFilter::MakeInclude({EMaterialTypes::Solid}), nearList); CMaterialFilter::MakeInclude({EMaterialTypes::Solid}), nearList);
if (res.IsValid()) if (res.IsValid())
aimPos = res.GetPoint(); aimPos = res.GetPoint();
} }
} }
LaunchProjectile( LaunchProjectile(
zeus::lookAt(xf.origin, GetProjectileInfo()->PredictInterceptPos(xf.origin, aimPos, mgr.GetPlayer(), true, dt)), zeus::lookAt(xf.origin, GetProjectileInfo()->PredictInterceptPos(xf.origin, aimPos, mgr.GetPlayer(), true, dt)),
mgr, 4, EProjectileAttrib::None, false, {x71c_projectileVisorParticle}, x72c_projectileVisorSfx, true, mgr, 4, EProjectileAttrib::None, false, {x71c_projectileVisorParticle}, x72c_projectileVisorSfx, true,
zeus::CVector3f::skOne); zeus::CVector3f::skOne);
handled = true; handled = true;
break; break;
} }
@ -175,9 +177,7 @@ void CWarWasp::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EU
CPatterned::DoUserAnimEvent(mgr, node, type, dt); CPatterned::DoUserAnimEvent(mgr, node, type, dt);
} }
const CCollisionPrimitive* CWarWasp::GetCollisionPrimitive() const { const CCollisionPrimitive* CWarWasp::GetCollisionPrimitive() const { return &x570_cSphere; }
return &x570_cSphere;
}
void CWarWasp::Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state) { void CWarWasp::Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state) {
CPatterned::Death(mgr, direction, state); CPatterned::Death(mgr, direction, state);
@ -186,9 +186,7 @@ void CWarWasp::Death(CStateManager& mgr, const zeus::CVector3f& direction, EScri
SwarmRemove(mgr); SwarmRemove(mgr);
} }
bool CWarWasp::IsListening() const { bool CWarWasp::IsListening() const { return true; }
return true;
}
bool CWarWasp::Listen(const zeus::CVector3f& pos, EListenNoiseType type) { bool CWarWasp::Listen(const zeus::CVector3f& pos, EListenNoiseType type) {
switch (type) { switch (type) {
@ -247,7 +245,7 @@ void CWarWasp::Patrol(CStateManager& mgr, EStateMsg msg, float dt) {
if (maxSpeed > 0.f) { if (maxSpeed > 0.f) {
x450_bodyController->GetCommandMgr().SetSteeringBlendMode(ESteeringBlendMode::FullSpeed); x450_bodyController->GetCommandMgr().SetSteeringBlendMode(ESteeringBlendMode::FullSpeed);
float speedFactor = float speedFactor =
x450_bodyController->GetBodyStateInfo().GetLocomotionSpeed(pas::ELocomotionAnim::Walk) * 0.9f / maxSpeed; x450_bodyController->GetBodyStateInfo().GetLocomotionSpeed(pas::ELocomotionAnim::Walk) * 0.9f / maxSpeed;
x450_bodyController->GetCommandMgr().SetSteeringSpeedRange(speedFactor, speedFactor); x450_bodyController->GetCommandMgr().SetSteeringSpeedRange(speedFactor, speedFactor);
} }
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed); x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
@ -279,8 +277,9 @@ void CWarWasp::SetUpPathFindBehavior(CStateManager& mgr) {
zeus::CVector3f delta = x2e0_destPos - aimPos; zeus::CVector3f delta = x2e0_destPos - aimPos;
if (delta.canBeNormalized()) { if (delta.canBeNormalized()) {
zeus::CVector3f dir = delta.normalized(); zeus::CVector3f dir = delta.normalized();
CRayCastResult res = mgr.RayStaticIntersection(aimPos, dir, delta.magnitude(), CRayCastResult res = mgr.RayStaticIntersection(
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {EMaterialTypes::Player})); aimPos, dir, delta.magnitude(),
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {EMaterialTypes::Player}));
if (res.IsValid()) { if (res.IsValid()) {
SetDestPos(dir * res.GetT() * 0.5f + aimPos); SetDestPos(dir * res.GetT() * 0.5f + aimPos);
x72e_29_pathObstructed = true; x72e_29_pathObstructed = true;
@ -306,13 +305,12 @@ void CWarWasp::ApplyNormalSteering(CStateManager& mgr) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCStepCmd(stepDir, pas::EStepType::Normal)); x450_bodyController->GetCommandMgr().DeliverCmd(CBCStepCmd(stepDir, pas::EStepType::Normal));
} else { } else {
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(
CBCLocomotionCmd(x45c_steeringBehaviors.Arrival(*this, teamPos, 3.f), zeus::CVector3f::skZero, 1.f)); CBCLocomotionCmd(x45c_steeringBehaviors.Arrival(*this, teamPos, 3.f), zeus::CVector3f::skZero, 1.f));
zeus::CVector3f target = GetTranslation(); zeus::CVector3f target = GetTranslation();
target.z() = float(teamPos.z()); target.z() = float(teamPos.z());
zeus::CVector3f moveVec = x45c_steeringBehaviors.Arrival(*this, target, 3.f); zeus::CVector3f moveVec = x45c_steeringBehaviors.Arrival(*this, target, 3.f);
if (moveVec.magSquared() > 0.01f) { if (moveVec.magSquared() > 0.01f) {
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(moveVec, zeus::CVector3f::skZero, 3.f));
CBCLocomotionCmd(moveVec, zeus::CVector3f::skZero, 3.f));
} }
} }
} else { } else {
@ -326,7 +324,7 @@ void CWarWasp::ApplyNormalSteering(CStateManager& mgr) {
case 2: case 2:
if (ShouldTurn(mgr, 30.f) && delta.canBeNormalized()) { if (ShouldTurn(mgr, 30.f) && delta.canBeNormalized()) {
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(
CBCLocomotionCmd(zeus::CVector3f::skZero, delta.normalized(), 1.f)); CBCLocomotionCmd(zeus::CVector3f::skZero, delta.normalized(), 1.f));
} }
break; break;
default: default:
@ -348,8 +346,7 @@ void CWarWasp::ApplySeparationBehavior(CStateManager& mgr, float sep) {
} }
zeus::CVector3f separation = x45c_steeringBehaviors.Separation(*this, ai->GetTranslation(), useSep); zeus::CVector3f separation = x45c_steeringBehaviors.Separation(*this, ai->GetTranslation(), useSep);
if (!separation.isZero()) { if (!separation.isZero()) {
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(separation, zeus::CVector3f::skZero, 1.f));
CBCLocomotionCmd(separation, zeus::CVector3f::skZero, 1.f));
} }
} }
} }
@ -387,8 +384,8 @@ bool CWarWasp::SteerToDeactivatePos(CStateManager& mgr, EStateMsg msg, float dt)
float maxSpeed = x450_bodyController->GetBodyStateInfo().GetMaxSpeed(); float maxSpeed = x450_bodyController->GetBodyStateInfo().GetMaxSpeed();
float minMoveFactor; float minMoveFactor;
if (maxSpeed > 0.f) if (maxSpeed > 0.f)
minMoveFactor = x450_bodyController->GetBodyStateInfo().GetLocomotionSpeed( minMoveFactor =
pas::ELocomotionAnim::Walk) * 0.5f / maxSpeed; x450_bodyController->GetBodyStateInfo().GetLocomotionSpeed(pas::ELocomotionAnim::Walk) * 0.5f / maxSpeed;
else else
minMoveFactor = 1.f; minMoveFactor = 1.f;
float moveFactor = zeus::clamp(minMoveFactor, arrival1.magnitude(), 1.f); float moveFactor = zeus::clamp(minMoveFactor, arrival1.magnitude(), 1.f);
@ -403,8 +400,7 @@ bool CWarWasp::SteerToDeactivatePos(CStateManager& mgr, EStateMsg msg, float dt)
if (GetSearchPath() && !PathShagged(mgr, 0.f) && !GetSearchPath()->IsOver()) { if (GetSearchPath() && !PathShagged(mgr, 0.f) && !GetSearchPath()->IsOver()) {
CPatterned::PathFind(mgr, msg, dt); CPatterned::PathFind(mgr, msg, dt);
} else { } else {
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(moveVec, zeus::CVector3f::skZero, 1.f));
CBCLocomotionCmd(moveVec, zeus::CVector3f::skZero, 1.f));
} }
} else { } else {
RemoveMaterial(EMaterialTypes::Solid, mgr); RemoveMaterial(EMaterialTypes::Solid, mgr);
@ -412,11 +408,9 @@ bool CWarWasp::SteerToDeactivatePos(CStateManager& mgr, EStateMsg msg, float dt)
target.z() = float(x3a0_latestLeashPosition.z()); target.z() = float(x3a0_latestLeashPosition.z());
zeus::CVector3f arrival2 = x45c_steeringBehaviors.Arrival(*this, target, 2.5f); zeus::CVector3f arrival2 = x45c_steeringBehaviors.Arrival(*this, target, 2.5f);
if (arrival2.magSquared() > 0.01f) { if (arrival2.magSquared() > 0.01f) {
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(arrival2, zeus::CVector3f::skZero, 3.f));
CBCLocomotionCmd(arrival2, zeus::CVector3f::skZero, 3.f));
} }
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(moveVec, zeus::CVector3f::skZero, 1.f));
CBCLocomotionCmd(moveVec, zeus::CVector3f::skZero, 1.f));
} }
} }
return false; return false;
@ -425,8 +419,9 @@ bool CWarWasp::SteerToDeactivatePos(CStateManager& mgr, EStateMsg msg, float dt)
zeus::CQuaternion q; zeus::CQuaternion q;
q.rotateZ(zeus::degToRad(180.f)); q.rotateZ(zeus::degToRad(180.f));
SetTranslation(GetTranslation() * 0.9f + x3a0_latestLeashPosition * 0.1f); SetTranslation(GetTranslation() * 0.9f + x3a0_latestLeashPosition * 0.1f);
SetTransform(zeus::CQuaternion::slerpShort(zeus::CQuaternion(GetTransform().basis), x6a0_initialRot * q, 0.1f). SetTransform(zeus::CQuaternion::slerpShort(zeus::CQuaternion(GetTransform().basis), x6a0_initialRot * q, 0.1f)
normalized().toTransform(GetTranslation())); .normalized()
.toTransform(GetTranslation()));
return false; return false;
} }
return true; return true;
@ -637,7 +632,7 @@ void CWarWasp::JumpBack(CStateManager& mgr, EStateMsg msg, float dt) {
x568_stateProg = 2; x568_stateProg = 2;
} else { } else {
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(
CBCStepCmd(pas::EStepDirection::Backward, pas::EStepType::Normal)); CBCStepCmd(pas::EStepDirection::Backward, pas::EStepType::Normal));
} }
break; break;
case 2: case 2:
@ -700,7 +695,7 @@ void CWarWasp::Shuffle(CStateManager& mgr, EStateMsg msg, float dt) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCStepCmd(stepDir, pas::EStepType::Normal)); x450_bodyController->GetCommandMgr().DeliverCmd(CBCStepCmd(stepDir, pas::EStepType::Normal));
} else { } else {
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(
CBCLocomotionCmd(x45c_steeringBehaviors.Seek(*this, shuffleDest), zeus::CVector3f::skZero, 1.f)); CBCLocomotionCmd(x45c_steeringBehaviors.Seek(*this, shuffleDest), zeus::CVector3f::skZero, 1.f));
ApplySeparationBehavior(mgr, 15.f); ApplySeparationBehavior(mgr, 15.f);
} }
} else { } else {
@ -738,7 +733,7 @@ void CWarWasp::ProjectileAttack(CStateManager& mgr, EStateMsg msg, float dt) {
} else { } else {
SetDestPos(GetProjectileAimPos(mgr, -0.07f)); SetDestPos(GetProjectileAimPos(mgr, -0.07f));
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(
CBCProjectileAttackCmd(pas::ESeverity::One, x2e0_destPos, false)); CBCProjectileAttackCmd(pas::ESeverity::One, x2e0_destPos, false));
} }
break; break;
case 2: case 2:
@ -828,8 +823,8 @@ void CWarWasp::SetUpCircleTelegraphTeam(CStateManager& mgr) {
} }
} }
} }
if (!rejoinInitial && (x70c_initialCircleAttackTeam != -1 || if (!rejoinInitial &&
targetUnitSize >= aimgr->GetMaxMeleeAttackerCount())) (x70c_initialCircleAttackTeam != -1 || targetUnitSize >= aimgr->GetMaxMeleeAttackerCount()))
++teamUnit; ++teamUnit;
JoinCircleAttackTeam(teamUnit, mgr); JoinCircleAttackTeam(teamUnit, mgr);
x714_circleTelegraphSeekHeight = mgr.GetActiveRandom()->Float() * -0.5f; x714_circleTelegraphSeekHeight = mgr.GetActiveRandom()->Float() * -0.5f;
@ -881,9 +876,7 @@ float CWarWasp::GetTeamZStratum(s32 team) {
return 0.f; return 0.f;
} }
static const float Table[] = { static const float Table[] = {0.4f, 0.6f, 1.f};
0.4f, 0.6f, 1.f
};
float CWarWasp::CalcSeekMagnitude(CStateManager& mgr) { float CWarWasp::CalcSeekMagnitude(CStateManager& mgr) {
float ret = ((x708_circleAttackTeam >= 0 && x708_circleAttackTeam < 3) ? Table[x708_circleAttackTeam] : 1.f) * 0.9f; float ret = ((x708_circleAttackTeam >= 0 && x708_circleAttackTeam < 3) ? Table[x708_circleAttackTeam] : 1.f) * 0.9f;
@ -897,8 +890,8 @@ float CWarWasp::CalcSeekMagnitude(CStateManager& mgr) {
if (const CWarWasp* other = CPatterned::CastTo<CWarWasp>(mgr.GetObjectById(role.GetOwnerId()))) { if (const CWarWasp* other = CPatterned::CastTo<CWarWasp>(mgr.GetObjectById(role.GetOwnerId()))) {
if (x708_circleAttackTeam == other->x708_circleAttackTeam && if (x708_circleAttackTeam == other->x708_circleAttackTeam &&
GetTransform().basis[1].dot(other->GetTranslation() - GetTranslation()) > 0.f) { GetTransform().basis[1].dot(other->GetTranslation() - GetTranslation()) > 0.f) {
float angle = zeus::CVector3f::getAngleDiff( float angle =
fromPlatformCenter, other->GetTranslation() - x6b0_circleBurstPos); zeus::CVector3f::getAngleDiff(fromPlatformCenter, other->GetTranslation() - x6b0_circleBurstPos);
if (angle < minAngle) if (angle < minAngle)
minAngle = angle; minAngle = angle;
} }
@ -957,8 +950,9 @@ void CWarWasp::TelegraphAttack(CStateManager& mgr, EStateMsg msg, float dt) {
moveVec = moveVec * -1.f; moveVec = moveVec * -1.f;
float seekHeight = x714_circleTelegraphSeekHeight + GetTeamZStratum(x708_circleAttackTeam); float seekHeight = x714_circleTelegraphSeekHeight + GetTeamZStratum(x708_circleAttackTeam);
float seekMag = CalcSeekMagnitude(mgr); float seekMag = CalcSeekMagnitude(mgr);
moveVec = x45c_steeringBehaviors.Seek(*this, moveVec =
seekOrigin + moveVec * 5.f + zeus::CVector3f(0.f, 0.f, seekHeight)) * seekMag; x45c_steeringBehaviors.Seek(*this, seekOrigin + moveVec * 5.f + zeus::CVector3f(0.f, 0.f, seekHeight)) *
seekMag;
} }
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(moveVec, zeus::CVector3f::skZero, 1.f)); x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(moveVec, zeus::CVector3f::skZero, 1.f));
UpdateTelegraphMoveSpeed(mgr); UpdateTelegraphMoveSpeed(mgr);
@ -999,8 +993,8 @@ void CWarWasp::Retreat(CStateManager& mgr, EStateMsg msg, float dt) {
break; break;
case EStateMsg::Update: case EStateMsg::Update:
x450_bodyController->GetCommandMgr().DeliverCmd( x450_bodyController->GetCommandMgr().DeliverCmd(
CBCLocomotionCmd(x45c_steeringBehaviors.Flee2D( CBCLocomotionCmd(x45c_steeringBehaviors.Flee2D(*this, mgr.GetPlayer().GetTranslation().toVec2f()),
*this, mgr.GetPlayer().GetTranslation().toVec2f()), zeus::CVector3f::skZero, 1.f)); zeus::CVector3f::skZero, 1.f));
break; break;
case EStateMsg::Deactivate: case EStateMsg::Deactivate:
x400_24_hitByPlayerProjectile = false; x400_24_hitByPlayerProjectile = false;
@ -1054,8 +1048,10 @@ bool CWarWasp::InAttackPosition(CStateManager& mgr, float arg) {
bool ret = magSq > negTest * negTest && magSq < posTest * posTest && !ShouldTurn(mgr, 45.f); bool ret = magSq > negTest * negTest && magSq < posTest * posTest && !ShouldTurn(mgr, 45.f);
if (ret && delta.canBeNormalized()) { if (ret && delta.canBeNormalized()) {
float deltaMag = delta.magnitude(); float deltaMag = delta.magnitude();
ret = mgr.RayStaticIntersection(GetTranslation(), delta / deltaMag, deltaMag, ret = mgr.RayStaticIntersection(
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {EMaterialTypes::Player})).IsInvalid(); GetTranslation(), delta / deltaMag, deltaMag,
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {EMaterialTypes::Player}))
.IsInvalid();
} }
return ret; return ret;
} }
@ -1063,7 +1059,8 @@ bool CWarWasp::InAttackPosition(CStateManager& mgr, float arg) {
bool CWarWasp::Leash(CStateManager& mgr, float arg) { bool CWarWasp::Leash(CStateManager& mgr, float arg) {
if ((x3a0_latestLeashPosition - GetTranslation()).magSquared() > x3c8_leashRadius * x3c8_leashRadius) { if ((x3a0_latestLeashPosition - GetTranslation()).magSquared() > x3c8_leashRadius * x3c8_leashRadius) {
if ((mgr.GetPlayer().GetTranslation() - GetTranslation()).magSquared() > if ((mgr.GetPlayer().GetTranslation() - GetTranslation()).magSquared() >
x3cc_playerLeashRadius * x3cc_playerLeashRadius && x3d4_curPlayerLeashTime > x3d0_playerLeashTime) { x3cc_playerLeashRadius * x3cc_playerLeashRadius &&
x3d4_curPlayerLeashTime > x3d0_playerLeashTime) {
return true; return true;
} }
} }
@ -1076,9 +1073,7 @@ bool CWarWasp::PathShagged(CStateManager& mgr, float arg) {
return false; return false;
} }
bool CWarWasp::AnimOver(CStateManager& mgr, float arg) { bool CWarWasp::AnimOver(CStateManager& mgr, float arg) { return x568_stateProg == 3; }
return x568_stateProg == 3;
}
bool CWarWasp::ShouldAttack(CStateManager& mgr, float arg) { bool CWarWasp::ShouldAttack(CStateManager& mgr, float arg) {
if (x700_attackRemTime <= 0.f) { if (x700_attackRemTime <= 0.f) {
@ -1108,7 +1103,8 @@ bool CWarWasp::InPosition(CStateManager& mgr, float arg) {
bool CWarWasp::ShouldTurn(CStateManager& mgr, float arg) { bool CWarWasp::ShouldTurn(CStateManager& mgr, float arg) {
return zeus::CVector2f::getAngleDiff(GetTransform().basis[1].toVec2f(), return zeus::CVector2f::getAngleDiff(GetTransform().basis[1].toVec2f(),
(mgr.GetPlayer().GetTranslation() - GetTranslation()).toVec2f()) > zeus::degToRad(arg); (mgr.GetPlayer().GetTranslation() - GetTranslation()).toVec2f()) >
zeus::degToRad(arg);
} }
bool CWarWasp::HearShot(CStateManager& mgr, float arg) { bool CWarWasp::HearShot(CStateManager& mgr, float arg) {
@ -1149,8 +1145,8 @@ bool CWarWasp::ShouldDodge(CStateManager& mgr, float arg) {
if (mgr.GetPlayer().GetUniqueId() == proj->GetOwnerId()) { if (mgr.GetPlayer().GetUniqueId() == proj->GetOwnerId()) {
zeus::CVector3f delta = proj->GetTranslation() - GetTranslation(); zeus::CVector3f delta = proj->GetTranslation() - GetTranslation();
if (zeus::CVector3f::getAngleDiff(GetTransform().basis[1], delta) < zeus::degToRad(45.f)) { if (zeus::CVector3f::getAngleDiff(GetTransform().basis[1], delta) < zeus::degToRad(45.f)) {
x704_dodgeDir = GetTransform().basis[0].dot(delta) > 0.f ? x704_dodgeDir =
pas::EStepDirection::Right : pas::EStepDirection::Left; GetTransform().basis[0].dot(delta) > 0.f ? pas::EStepDirection::Right : pas::EStepDirection::Left;
return true; return true;
} }
} }
@ -1175,8 +1171,8 @@ bool CWarWasp::CheckCircleAttackSpread(CStateManager& mgr, s32 team) {
if (wasp2->x708_circleAttackTeam == team) { if (wasp2->x708_circleAttackTeam == team) {
if (leaderWasp->GetTransform().basis[1].dot(wasp2->GetTranslation() - leaderWasp->GetTranslation()) > 0.f) if (leaderWasp->GetTransform().basis[1].dot(wasp2->GetTranslation() - leaderWasp->GetTranslation()) > 0.f)
return false; return false;
float angle = zeus::CVector3f::getAngleDiff(wasp2->GetTranslation() - x6b0_circleBurstPos, float angle =
platformToLeaderWasp); zeus::CVector3f::getAngleDiff(wasp2->GetTranslation() - x6b0_circleBurstPos, platformToLeaderWasp);
if (angle > maxAng) if (angle > maxAng)
maxAng = angle; maxAng = angle;
} }
@ -1199,8 +1195,8 @@ bool CWarWasp::ShouldSpecialAttack(CStateManager& mgr, float arg) {
zeus::CVector3f fromPlatformCenter = GetTranslation() - x6b0_circleBurstPos; zeus::CVector3f fromPlatformCenter = GetTranslation() - x6b0_circleBurstPos;
zeus::CVector3f thresholdVec = x6bc_circleBurstDir; zeus::CVector3f thresholdVec = x6bc_circleBurstDir;
if (x718_circleBurstOffTotemAngle <= zeus::degToRad(90.f)) { if (x718_circleBurstOffTotemAngle <= zeus::degToRad(90.f)) {
thresholdVec = zeus::CVector3f::slerp(x6c8_circleBurstRight, x6bc_circleBurstDir, thresholdVec =
x718_circleBurstOffTotemAngle); zeus::CVector3f::slerp(x6c8_circleBurstRight, x6bc_circleBurstDir, x718_circleBurstOffTotemAngle);
} else { } else {
thresholdVec = zeus::CVector3f::slerp(x6bc_circleBurstDir, -x6c8_circleBurstRight, thresholdVec = zeus::CVector3f::slerp(x6bc_circleBurstDir, -x6c8_circleBurstRight,
x718_circleBurstOffTotemAngle - zeus::degToRad(90.f)); x718_circleBurstOffTotemAngle - zeus::degToRad(90.f));
@ -1221,11 +1217,7 @@ bool CWarWasp::ShouldSpecialAttack(CStateManager& mgr, float arg) {
return false; return false;
} }
CPathFindSearch* CWarWasp::GetSearchPath() { CPathFindSearch* CWarWasp::GetSearchPath() { return &x590_pfSearch; }
return &x590_pfSearch;
}
CProjectileInfo* CWarWasp::GetProjectileInfo() { CProjectileInfo* CWarWasp::GetProjectileInfo() { return &x6d4_projectileInfo; }
return &x6d4_projectileInfo;
}
} // namespace urde::MP1 } // namespace urde::MP1

View File

@ -67,6 +67,7 @@ class CWarWasp : public CPatterned {
bool PathToHiveIsClear(CStateManager& mgr); bool PathToHiveIsClear(CStateManager& mgr);
bool SteerToDeactivatePos(CStateManager& mgr, EStateMsg msg, float dt); bool SteerToDeactivatePos(CStateManager& mgr, EStateMsg msg, float dt);
zeus::CVector3f CalcShuffleDest(CStateManager& mgr); zeus::CVector3f CalcShuffleDest(CStateManager& mgr);
public: public:
DEFINE_PATTERNED(WarWasp) DEFINE_PATTERNED(WarWasp)
CWarWasp(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, CWarWasp(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
@ -84,8 +85,7 @@ public:
void Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state); void Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state);
bool IsListening() const; bool IsListening() const;
bool Listen(const zeus::CVector3f&, EListenNoiseType); bool Listen(const zeus::CVector3f&, EListenNoiseType);
zeus::CVector3f GetOrigin(const CStateManager& mgr, const CTeamAiRole& role, zeus::CVector3f GetOrigin(const CStateManager& mgr, const CTeamAiRole& role, const zeus::CVector3f& aimPos) const;
const zeus::CVector3f& aimPos) const;
void UpdateTouchBounds(); void UpdateTouchBounds();
bool IsRetreating() const { return x72e_30_isRetreating; } bool IsRetreating() const { return x72e_30_isRetreating; }

View File

@ -38,6 +38,7 @@
#include "CScriptCoverPoint.hpp" #include "CScriptCoverPoint.hpp"
#include "CScriptSpiderBallWaypoint.hpp" #include "CScriptSpiderBallWaypoint.hpp"
#include "CScriptDamageableTrigger.hpp" #include "CScriptDamageableTrigger.hpp"
#include "MP1/World/CMetroid.hpp"
#include "CScriptDebris.hpp" #include "CScriptDebris.hpp"
#include "CScriptDistanceFog.hpp" #include "CScriptDistanceFog.hpp"
#include "CScriptDock.hpp" #include "CScriptDock.hpp"
@ -116,6 +117,9 @@
namespace urde { namespace urde {
static logvisor::Module Log("urde::ScriptLoader"); static logvisor::Module Log("urde::ScriptLoader");
#define UNIMPLEMENTED(name) \
Log.report(logvisor::Warning, "Attempted to load unimplemented object '%s'", name);
static SObjectTag MorphballDoorANCS = {}; static SObjectTag MorphballDoorANCS = {};
static const SObjectTag& GetMorphballDoorACS() { static const SObjectTag& GetMorphballDoorACS() {
@ -1916,6 +1920,7 @@ CEntity* ScriptLoader::LoadPlayerHint(CStateManager& mgr, CInputStream& in, int
} }
CEntity* ScriptLoader::LoadRipper(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { CEntity* ScriptLoader::LoadRipper(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
UNIMPLEMENTED("Ripper");
return nullptr; return nullptr;
} }
@ -1932,6 +1937,7 @@ CEntity* ScriptLoader::LoadPickupGenerator(CStateManager& mgr, CInputStream& in,
} }
CEntity* ScriptLoader::LoadAIKeyframe(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { CEntity* ScriptLoader::LoadAIKeyframe(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
UNIMPLEMENTED("AIKeyframe");
return nullptr; return nullptr;
} }
@ -1950,11 +1956,33 @@ CEntity* ScriptLoader::LoadPointOfInterest(CStateManager& mgr, CInputStream& in,
} }
CEntity* ScriptLoader::LoadDrone(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { CEntity* ScriptLoader::LoadDrone(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
UNIMPLEMENTED("Drone");
return nullptr; return nullptr;
} }
CEntity* ScriptLoader::LoadMetroidAlpha(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { CEntity* ScriptLoader::LoadMetroid(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
return nullptr; if (!EnsurePropertyCount(propCount, MP1::CMetroidData::GetNumProperties(), "Metroid"))
return nullptr;
std::string name = mgr.HashInstanceName(in);
CPatterned::EFlavorType flavor = CPatterned::EFlavorType(in.readUint32Big());
zeus::CTransform xf = LoadEditorTransform(in);
zeus::CVector3f scale = zeus::CVector3f::ReadBig(in);
auto pair = CPatternedInfo::HasCorrectParameterCount(in);
if (!pair.first)
return nullptr;
CPatternedInfo pInfo(in, pair.second);
CActorParameters actParms = LoadActorParameters(in);
MP1::CMetroidData metData(in);
const CAnimationParameters& animParms = pInfo.GetAnimationParameters();
if (!animParms.GetACSFile().IsValid() || flavor == CPatterned::EFlavorType::One)
return nullptr;
CModelData mData(
CAnimRes(animParms.GetACSFile(), animParms.GetCharacter(), scale, animParms.GetInitialAnimation(), true));
return new MP1::CMetroid(mgr.AllocateUniqueId(), name, flavor, info, xf, std::move(mData), pInfo, actParms, metData,
kInvalidUniqueId);
} }
CEntity* ScriptLoader::LoadDebrisExtended(CStateManager& mgr, CInputStream& in, int propCount, CEntity* ScriptLoader::LoadDebrisExtended(CStateManager& mgr, CInputStream& in, int propCount,
@ -2109,6 +2137,7 @@ CEntity* ScriptLoader::LoadEMPulse(CStateManager& mgr, CInputStream& in, int pro
} }
CEntity* ScriptLoader::LoadIceSheegoth(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { CEntity* ScriptLoader::LoadIceSheegoth(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
UNIMPLEMENTED("IceSheegoth");
return nullptr; return nullptr;
} }
@ -2156,6 +2185,7 @@ CEntity* ScriptLoader::LoadPlayerActor(CStateManager& mgr, CInputStream& in, int
} }
CEntity* ScriptLoader::LoadFlaahgra(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { CEntity* ScriptLoader::LoadFlaahgra(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
UNIMPLEMENTED("Flaahgra");
return nullptr; return nullptr;
} }
@ -2338,6 +2368,7 @@ CEntity* ScriptLoader::LoadVisorGoo(CStateManager& mgr, CInputStream& in, int pr
} }
CEntity* ScriptLoader::LoadJellyZap(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { CEntity* ScriptLoader::LoadJellyZap(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
UNIMPLEMENTED("JellyZap");
return nullptr; return nullptr;
} }
@ -2390,6 +2421,7 @@ CEntity* ScriptLoader::LoadPlayerStateChange(CStateManager& mgr, CInputStream& i
} }
CEntity* ScriptLoader::LoadThardus(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { CEntity* ScriptLoader::LoadThardus(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
UNIMPLEMENTED("Thardus");
return nullptr; return nullptr;
} }
@ -2456,6 +2488,7 @@ CEntity* ScriptLoader::LoadAiJumpPoint(CStateManager& mgr, CInputStream& in, int
CEntity* ScriptLoader::LoadFlaahgraTentacle(CStateManager& mgr, CInputStream& in, int propCount, CEntity* ScriptLoader::LoadFlaahgraTentacle(CStateManager& mgr, CInputStream& in, int propCount,
const CEntityInfo& info) { const CEntityInfo& info) {
UNIMPLEMENTED("FlaahgraTentacle");
return nullptr; return nullptr;
} }
@ -2524,6 +2557,7 @@ CEntity* ScriptLoader::LoadColorModulate(CStateManager& mgr, CInputStream& in, i
CEntity* ScriptLoader::LoadThardusRockProjectile(CStateManager& mgr, CInputStream& in, int propCount, CEntity* ScriptLoader::LoadThardusRockProjectile(CStateManager& mgr, CInputStream& in, int propCount,
const CEntityInfo& info) { const CEntityInfo& info) {
UNIMPLEMENTED("ThardusRockProjectile");
return nullptr; return nullptr;
} }
@ -2862,6 +2896,7 @@ CEntity* ScriptLoader::LoadActorContraption(CStateManager& mgr, CInputStream& in
} }
CEntity* ScriptLoader::LoadOculus(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { CEntity* ScriptLoader::LoadOculus(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
UNIMPLEMENTED("Oculus");
return nullptr; return nullptr;
} }
@ -3077,6 +3112,7 @@ CEntity* ScriptLoader::LoadAtomicBeta(CStateManager& mgr, CInputStream& in, int
} }
CEntity* ScriptLoader::LoadIceZoomer(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { CEntity* ScriptLoader::LoadIceZoomer(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
UNIMPLEMENTED("IceZoomer");
return nullptr; return nullptr;
} }
@ -3269,6 +3305,7 @@ CEntity* ScriptLoader::LoadWorldLightFader(CStateManager& mgr, CInputStream& in,
CEntity* ScriptLoader::LoadMetroidPrimeStage2(CStateManager& mgr, CInputStream& in, int propCount, CEntity* ScriptLoader::LoadMetroidPrimeStage2(CStateManager& mgr, CInputStream& in, int propCount,
const CEntityInfo& info) { const CEntityInfo& info) {
UNIMPLEMENTED("MetroidPrimeStage2");
return nullptr; return nullptr;
} }
@ -3321,15 +3358,18 @@ CEntity* ScriptLoader::LoadMazeNode(CStateManager& mgr, CInputStream& in, int pr
} }
CEntity* ScriptLoader::LoadOmegaPirate(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { CEntity* ScriptLoader::LoadOmegaPirate(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
UNIMPLEMENTED("OmegaPirate");
return nullptr; return nullptr;
} }
CEntity* ScriptLoader::LoadPhazonPool(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { CEntity* ScriptLoader::LoadPhazonPool(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
UNIMPLEMENTED("PhazonPool");
return nullptr; return nullptr;
} }
CEntity* ScriptLoader::LoadPhazonHealingNodule(CStateManager& mgr, CInputStream& in, int propCount, CEntity* ScriptLoader::LoadPhazonHealingNodule(CStateManager& mgr, CInputStream& in, int propCount,
const CEntityInfo& info) { const CEntityInfo& info) {
UNIMPLEMENTED("PhazonHealingNodule");
return nullptr; return nullptr;
} }
@ -3373,6 +3413,7 @@ CEntity* ScriptLoader::LoadShadowProjector(CStateManager& mgr, CInputStream& in,
} }
CEntity* ScriptLoader::LoadEnergyBall(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { CEntity* ScriptLoader::LoadEnergyBall(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
UNIMPLEMENTED("EnergyBall");
return nullptr; return nullptr;
} }
} // namespace urde } // namespace urde

View File

@ -92,7 +92,7 @@ public:
static CEntity* LoadAIKeyframe(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadAIKeyframe(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadPointOfInterest(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadPointOfInterest(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadDrone(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadDrone(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadMetroidAlpha(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadMetroid(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadDebrisExtended(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadDebrisExtended(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadSteam(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadSteam(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadRipple(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info); static CEntity* LoadRipple(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);

View File

@ -124,8 +124,8 @@ std::string_view ScriptObjectTypeToStr(EScriptObjectType type) {
return "PointOfInterest"sv; return "PointOfInterest"sv;
case EScriptObjectType::Drone: case EScriptObjectType::Drone:
return "Drone"sv; return "Drone"sv;
case EScriptObjectType::MetroidAlpha: case EScriptObjectType::Metroid:
return "MetroidAlpha"sv; return "Metroid"sv;
case EScriptObjectType::DebrisExtended: case EScriptObjectType::DebrisExtended:
return "DebrisExtended"sv; return "DebrisExtended"sv;
case EScriptObjectType::Steam: case EScriptObjectType::Steam:

View File

@ -64,7 +64,7 @@ enum class EScriptObjectType {
AIKeyframe = 0x41, AIKeyframe = 0x41,
PointOfInterest = 0x42, PointOfInterest = 0x42,
Drone = 0x43, Drone = 0x43,
MetroidAlpha = 0x44, Metroid = 0x44,
DebrisExtended = 0x45, DebrisExtended = 0x45,
Steam = 0x46, Steam = 0x46,
Ripple = 0x47, Ripple = 0x47,