Skip to content

Commit

Permalink
More Small Refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
caxanga334 committed May 16, 2024
1 parent 83132ed commit 4a5abc0
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 40 deletions.
10 changes: 8 additions & 2 deletions extension/bot/interfaces/movement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down Expand Up @@ -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());
}

Expand Down
16 changes: 0 additions & 16 deletions extension/concommands_bots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions extension/concommands_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
#include <sm_argbuffer.h>

#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);
Expand Down
12 changes: 0 additions & 12 deletions extension/mods/basemod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 4 additions & 10 deletions extension/mods/basemod.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> 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
Expand Down

0 comments on commit 4a5abc0

Please sign in to comment.