From 01d94367dc0025f917758dd9224e5eaca923d260 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 2 Oct 2020 23:28:05 -0700 Subject: [PATCH] Add ability to disable AI --- Runtime/MP1/MP1.cpp | 2 ++ Runtime/World/CPatterned.cpp | 17 ++++++++++++++++- Runtime/World/CPatterned.hpp | 1 + Runtime/World/CStateMachine.cpp | 6 +++++- hecl | 2 +- 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index de9f46362..1f4b67403 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -59,6 +59,7 @@ #include "Runtime/Particle/CParticleSwooshDataFactory.hpp" #include "Runtime/Particle/CProjectileWeaponDataFactory.hpp" #include "Runtime/Particle/CWeaponDescription.hpp" +#include "Runtime/World/CPatterned.hpp" #include "Runtime/World/CPlayer.hpp" #include "Runtime/World/CStateMachine.hpp" #include "Runtime/World/CScriptMazeNode.hpp" @@ -412,6 +413,7 @@ void CMain::InitializeSubsystems() { CAnimData::InitializeCache(); CDecalManager::Initialize(); CGBASupport::Initialize(); + CPatterned::Initialize(); CGraphics::g_BooFactory->waitUntilShadersReady(); } diff --git a/Runtime/World/CPatterned.cpp b/Runtime/World/CPatterned.cpp index 4db58ca19..da386d3c6 100644 --- a/Runtime/World/CPatterned.cpp +++ b/Runtime/World/CPatterned.cpp @@ -21,9 +21,14 @@ #include "Runtime/World/CScriptWaypoint.hpp" #include "Runtime/World/CStateMachine.hpp" +#include + #include "TCastTo.hpp" // Generated file, do not modify include path namespace urde { +namespace { +hecl::CVar* cv_disableAi = nullptr; +} constexpr CMaterialList skPatternedGroundMaterialList(EMaterialTypes::Character, EMaterialTypes::Solid, EMaterialTypes::Orbit, EMaterialTypes::GroundCollider, @@ -195,8 +200,11 @@ void CPatterned::UpdateThermalFrozenState(bool thawed) { } void CPatterned::Think(float dt, CStateManager& mgr) { - if (!GetActive()) + if (!GetActive() || (cv_disableAi && cv_disableAi->toBoolean())) { + Stop(); + ClearForcesAndTorques(); return; + } if (x402_30_updateThermalFrozenState) UpdateThermalFrozenState(x450_bodyController->GetPercentageFrozen() == 0.f); @@ -1731,4 +1739,11 @@ bool CPatterned::ApplyBoneTracking() const { return false; } +void CPatterned::Initialize() { + if (cv_disableAi == nullptr) { + cv_disableAi = hecl::CVarManager::instance()->findOrMakeCVar("disableAi"sv, "Disables AI state machines", false, + hecl::CVar::EFlags::Cheat | hecl::CVar::EFlags::Game); + } +} + } // namespace urde diff --git a/Runtime/World/CPatterned.hpp b/Runtime/World/CPatterned.hpp index 7c2bf7e6f..7fc995b68 100644 --- a/Runtime/World/CPatterned.hpp +++ b/Runtime/World/CPatterned.hpp @@ -416,6 +416,7 @@ public: return nullptr; } + static void Initialize(); // endregion }; } // namespace urde diff --git a/Runtime/World/CStateMachine.cpp b/Runtime/World/CStateMachine.cpp index 9d2083988..5ed6c249a 100644 --- a/Runtime/World/CStateMachine.cpp +++ b/Runtime/World/CStateMachine.cpp @@ -3,8 +3,12 @@ #include "Runtime/CStateManager.hpp" #include "Runtime/World/CAi.hpp" +#include + namespace urde { -static logvisor::Module Log("urde::CStateMachine"); +namespace { +logvisor::Module Log("urde::CStateMachine"); +} CStateMachine::CStateMachine(CInputStream& in) { CAiTrigger* lastTrig = nullptr; diff --git a/hecl b/hecl index ce85cff37..6395cf6cd 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit ce85cff3701419a7f9b5376dc784349e2b01bc84 +Subproject commit 6395cf6cd8304056ff54271c6779d54170237c07