From 4a5abc0b82f1a3d92c6652cd9ad477095960a1e3 Mon Sep 17 00:00:00 2001 From: caxanga334 <10157643+caxanga334@users.noreply.github.com> Date: Thu, 16 May 2024 17:44:59 -0300 Subject: [PATCH] More Small Refactors --- extension/bot/interfaces/movement.cpp | 10 ++++++++-- extension/concommands_bots.cpp | 16 ---------------- extension/concommands_debug.cpp | 10 ++++++++++ extension/mods/basemod.cpp | 12 ------------ extension/mods/basemod.h | 14 ++++---------- 5 files changed, 22 insertions(+), 40 deletions(-) diff --git a/extension/bot/interfaces/movement.cpp b/extension/bot/interfaces/movement.cpp index 3952a72..3da95cb 100644 --- a/extension/bot/interfaces/movement.cpp +++ b/extension/bot/interfaces/movement.cpp @@ -861,7 +861,10 @@ IMovement::LadderState IMovement::ApproachUpLadder() { if (debug) { - NDebugOverlay::Box(GetBot()->GetAbsOrigin(), extmanager->GetMod()->GetPlayerHullMins(), extmanager->GetMod()->GetPlayerHullMaxs(), 0, 0, 255, 255, 5.0f); + Vector mins = GetBot()->GetMins(); + Vector maxs = GetBot()->GetMaxs(); + + NDebugOverlay::Box(GetBot()->GetAbsOrigin(), mins, maxs, 0, 0, 255, 255, 5.0f); GetBot()->DebugPrintToConsole(BOTDEBUG_MOVEMENT, 0, 200, 200, "%s GRABBED LADDER (UP DIR)! \n", GetBot()->GetDebugIdentifier()); } @@ -928,7 +931,10 @@ IMovement::LadderState IMovement::ApproachDownLadder() { if (debug) { - NDebugOverlay::Box(GetBot()->GetAbsOrigin(), extmanager->GetMod()->GetPlayerHullMins(), extmanager->GetMod()->GetPlayerHullMaxs(), 0, 0, 255, 255, 5.0f); + Vector mins = GetBot()->GetMins(); + Vector maxs = GetBot()->GetMaxs(); + + NDebugOverlay::Box(GetBot()->GetAbsOrigin(), mins, maxs, 0, 0, 255, 255, 5.0f); GetBot()->DebugPrintToConsole(BOTDEBUG_MOVEMENT, 0, 200, 200, "%s GRABBED LADDER (DOWN DIR)! \n", GetBot()->GetDebugIdentifier()); } diff --git a/extension/concommands_bots.cpp b/extension/concommands_bots.cpp index f111ccd..dbeeac0 100644 --- a/extension/concommands_bots.cpp +++ b/extension/concommands_bots.cpp @@ -39,19 +39,3 @@ CON_COMMAND(sm_navbot_kick, "Removes a Nav Bot from the game.") } }); } - -#ifdef EXT_DEBUG - -CON_COMMAND(sm_navbot_debug_bot_look, "Debug the bot look functions.") -{ - auto& bots = extmanager->GetAllBots(); - auto edict = gamehelpers->EdictOfIndex(1); // get listen server host - - for (auto& botptr : bots) - { - auto bot = botptr.get(); - bot->GetControlInterface()->AimAt(edict, IPlayerController::LOOK_CRITICAL, 10.0f); - } -} - -#endif // EXT_DEBUG diff --git a/extension/concommands_debug.cpp b/extension/concommands_debug.cpp index e9b14fa..6ec54d7 100644 --- a/extension/concommands_debug.cpp +++ b/extension/concommands_debug.cpp @@ -19,6 +19,16 @@ #include #ifdef EXT_DEBUG +CON_COMMAND(sm_navbot_debug_bot_look, "Debug the bot look functions.") +{ + edict_t* host = gamehelpers->EdictOfIndex(1); + Vector target = UtilHelpers::getWorldSpaceCenter(host); + + extmanager->ForEachBot([&target](CBaseBot* bot) { + bot->GetControlInterface()->AimAt(target, IPlayerController::LOOK_CRITICAL, 10.0f, "Debug command!"); + }); +} + CON_COMMAND(sm_navbot_debug_vectors, "[LISTEN SERVER] Debug player vectors") { auto edict = gamehelpers->EdictOfIndex(1); diff --git a/extension/mods/basemod.cpp b/extension/mods/basemod.cpp index 70a8442..d997fbf 100644 --- a/extension/mods/basemod.cpp +++ b/extension/mods/basemod.cpp @@ -36,18 +36,6 @@ void CBaseMod::RegisterGameEvents() // No longer used, we now hook the vtable } -const Vector& CBaseMod::GetPlayerHullMins() -{ - static Vector mins(-16.0f, -16.0f, 0.0f); - return mins; -} - -const Vector& CBaseMod::GetPlayerHullMaxs() -{ - static Vector maxs(16.0f, 16.0f, 72.0f); - return maxs; -} - CNavMesh* CBaseMod::NavMeshFactory() { return new CNavMesh; diff --git a/extension/mods/basemod.h b/extension/mods/basemod.h index fde179e..7600cbd 100644 --- a/extension/mods/basemod.h +++ b/extension/mods/basemod.h @@ -21,28 +21,22 @@ class CBaseMod // Called every server frame virtual void Frame() {} - + // Called when the map starts virtual void OnMapStart(); + // Called when the map ends virtual void OnMapEnd() {} - // Called by the manager when allocating a new bot instance virtual CBaseBot* AllocateBot(edict_t* edict); - + // Mod name (IE: Team Fortress 2) virtual const char* GetModName() { return "CBaseMod"; } - + // Mod ID virtual Mods::ModType GetModType() { return Mods::ModType::MOD_BASE; } - // Called for mods to register event listeners virtual void RegisterGameEvents(); - - virtual const Vector& GetPlayerHullMins(); - virtual const Vector& GetPlayerHullMaxs(); - // Allocates the nav mesh class used by the mod virtual CNavMesh* NavMeshFactory(); // Returns the entity index of the player resource/manager entity. virtual std::optional GetPlayerResourceEntity(); - // return false to call NavIsEntityWalkable ir order to determine if the entity is walkable. Used for nav mesh editing and generation. virtual bool NavIsEntityIgnored(edict_t* entity, unsigned int flags) { return true; } // Returns true if the entity is walkable, false if it should block nav