mgr: added `yb exec` command for debugging purposes
This commit is contained in:
parent
7b7ae7020b
commit
259dd18330
4 changed files with 37 additions and 10 deletions
|
|
@ -31,11 +31,12 @@ public:
|
|||
struct BotCmd {
|
||||
String name, format, help;
|
||||
Handler handler = nullptr;
|
||||
bool visible = true;
|
||||
|
||||
public:
|
||||
explicit BotCmd () = default;
|
||||
|
||||
BotCmd (StringRef name, StringRef format, StringRef help, Handler handler) : name (name), format (format), help (help), handler (cr::move (handler))
|
||||
BotCmd (StringRef name, StringRef format, StringRef help, Handler handler, bool visible = true) : name (name), format (format), help (help), handler (cr::move (handler)), visible (visible)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
|
@ -100,6 +101,7 @@ private:
|
|||
int cmdList ();
|
||||
int cmdCvars ();
|
||||
int cmdShowCustom ();
|
||||
int cmdExec ();
|
||||
int cmdNode ();
|
||||
int cmdNodeOn ();
|
||||
int cmdNodeOff ();
|
||||
|
|
@ -125,7 +127,7 @@ private:
|
|||
int cmdNodeIterateCamp ();
|
||||
int cmdNodeShowStats ();
|
||||
int cmdNodeFileInfo ();
|
||||
int cmdAdjustHeight ();
|
||||
int cmdNodeAdjustHeight ();
|
||||
|
||||
private:
|
||||
int menuMain (int item);
|
||||
|
|
|
|||
|
|
@ -776,6 +776,9 @@ public:
|
|||
debugMsgInternal (strings.format (fmt, cr::forward <Args> (args)...));
|
||||
}
|
||||
|
||||
// execute client command helper
|
||||
template <typename ...Args> void issueCommand (const char *fmt, Args &&...args);
|
||||
|
||||
private:
|
||||
// returns true if bot is using a sniper rifle
|
||||
bool usesSniper () const {
|
||||
|
|
@ -826,9 +829,6 @@ private:
|
|||
bool usesKnife () const {
|
||||
return m_weaponType == WeaponType::Melee;
|
||||
}
|
||||
|
||||
// execute client command helper
|
||||
template <typename ...Args> void issueCommand (const char *fmt, Args &&...args);
|
||||
};
|
||||
|
||||
#include "config.h"
|
||||
|
|
|
|||
|
|
@ -320,6 +320,27 @@ int BotControl::cmdShowCustom () {
|
|||
return BotCommandResult::Handled;
|
||||
}
|
||||
|
||||
int BotControl::cmdExec () {
|
||||
enum args { alias = 1, target, command };
|
||||
|
||||
if (!hasArg (target) || !hasArg (command)) {
|
||||
return BotCommandResult::BadFormat;
|
||||
}
|
||||
const auto userId = intValue (target);
|
||||
|
||||
// find our little target
|
||||
auto bot = bots.findBotByIndex (userId);
|
||||
|
||||
// bailout if not bot
|
||||
if (!bot) {
|
||||
msg ("Bot with #%d not found or not a bot.", userId);
|
||||
return BotCommandResult::Handled;
|
||||
}
|
||||
bot->issueCommand (strValue (command).chars ());
|
||||
|
||||
return BotCommandResult::Handled;
|
||||
}
|
||||
|
||||
int BotControl::cmdNode () {
|
||||
enum args { root, alias, cmd, cmd2 };
|
||||
|
||||
|
|
@ -383,7 +404,7 @@ int BotControl::cmdNode () {
|
|||
addGraphCmd ("upload", "upload", "Uploads created graph to graph database.", &BotControl::cmdNodeUpload);
|
||||
addGraphCmd ("stats", "stats [noarguments]", "Shows the stats about node types on the map.", &BotControl::cmdNodeShowStats);
|
||||
addGraphCmd ("fileinfo", "fileinfo [noarguments]", "Shows basic information about graph file.", &BotControl::cmdNodeFileInfo);
|
||||
addGraphCmd ("adjust_height", "adjust_height [height offset]", "Modifies all the graph nodes height (z-component) with specified offset.", &BotControl::cmdAdjustHeight);
|
||||
addGraphCmd ("adjust_height", "adjust_height [height offset]", "Modifies all the graph nodes height (z-component) with specified offset.", &BotControl::cmdNodeAdjustHeight);
|
||||
|
||||
// add path commands
|
||||
addGraphCmd ("path_create", "path_create [noarguments]", "Opens and displays path creation menu.", &BotControl::cmdNodePathCreate);
|
||||
|
|
@ -961,7 +982,7 @@ int BotControl::cmdNodeFileInfo () {
|
|||
return BotCommandResult::Handled;
|
||||
}
|
||||
|
||||
int BotControl::cmdAdjustHeight () {
|
||||
int BotControl::cmdNodeAdjustHeight () {
|
||||
enum args { graph_cmd = 1, cmd, offset };
|
||||
|
||||
if (!hasArg (offset)) {
|
||||
|
|
@ -1876,6 +1897,9 @@ bool BotControl::executeCommands () {
|
|||
msg ("valid commands are: ");
|
||||
|
||||
for (auto &item : m_cmds) {
|
||||
if (!item.visible) {
|
||||
continue;
|
||||
}
|
||||
msg (" %-14.11s - %s", item.name.split ("/").first (), String (conf.translate (item.help)).lowercase ());
|
||||
}
|
||||
return true;
|
||||
|
|
@ -2151,7 +2175,8 @@ BotControl::BotControl () {
|
|||
m_cmds.emplace ("list/listbots", "list [noarguments]", "Lists the bots currently playing on server.", &BotControl::cmdList);
|
||||
m_cmds.emplace ("graph/g/wp/wpt/waypoint", "graph [help]", "Handles graph operations.", &BotControl::cmdNode);
|
||||
m_cmds.emplace ("cvars", "cvars [save|save_map|cvar|defaults]", "Display all the cvars with their descriptions.", &BotControl::cmdCvars);
|
||||
m_cmds.emplace ("show_custom", "show_custom [noarguments]", "Shows the current values from custom.cfg.", &BotControl::cmdShowCustom);
|
||||
m_cmds.emplace ("show_custom", "show_custom [noarguments]", "Shows the current values from custom.cfg.", &BotControl::cmdShowCustom, false);
|
||||
m_cmds.emplace ("exec", "exec [user_id] [command]", "Executes a client command on bot entity.", &BotControl::cmdExec);
|
||||
|
||||
// declare the menus
|
||||
createMenus ();
|
||||
|
|
|
|||
|
|
@ -980,8 +980,8 @@ void Game::applyGameModes () {
|
|||
static ConVarRef zp_delay ("zp_delay");
|
||||
|
||||
// update our ignore timer if zp_elay exists
|
||||
if (zp_delay.exists () && zp_delay.value () > 0.0f && cv_ignore_enemies_after_spawn_time.float_ () < 1.0f) {
|
||||
cv_ignore_enemies_after_spawn_time.set (zp_delay.value () + 2.0f);
|
||||
if (zp_delay.exists () && zp_delay.value () > 0.0f) {
|
||||
cv_ignore_enemies_after_spawn_time.set (zp_delay.value () + 3.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue