+#include "../../common/command/command.qh"
+#include "common.qh"
+
+#include "../scores.qh"
+
+#include "../../common/monsters/all.qh"
+#include "../../common/notifications.qh"
+#include "../../lib/warpzone/common.qh"
+
+
// ====================================================
// Shared code for server commands, written by Samual
// Last updated: December 27th, 2011
}
// if the client is not acceptable, return a string to be used for error messages
-string GetClientErrorString(float clienterror, string original_input)
+string GetClientErrorString_color(float clienterror, string original_input, string col)
{
switch(clienterror)
{
- case CLIENT_DOESNT_EXIST: { return strcat("Client '", original_input, "' doesn't exist"); }
- case CLIENT_NOT_REAL: { return strcat("Client '", original_input, "' is not real"); }
- case CLIENT_NOT_BOT: { return strcat("Client '", original_input, "' is not a bot"); }
+ case CLIENT_DOESNT_EXIST: { return strcat(col, "Client '", original_input, col, "' doesn't exist"); }
+ case CLIENT_NOT_REAL: { return strcat(col, "Client '", original_input, col, "' is not real"); }
+ case CLIENT_NOT_BOT: { return strcat(col, "Client '", original_input, col, "' is not a bot"); }
default: { return "Incorrect usage of GetClientErrorString"; }
}
}
float VerifyClientNumber(float tmp_number)
{
if((tmp_number < 1) || (tmp_number > maxclients))
- return FALSE;
+ return false;
else
- return TRUE;
+ return true;
}
entity GetIndexedEntity(float argc, float start_index)
if(to)
sprint(to, strcat(input, "\n"));
else
- print(input, "\n");
+ LOG_INFO(input, "\n");
}
// ==========================================
// used by CommonCommand_timeout() and CommonCommand_timein() to handle game pausing and messaging and such.
void timeout_handler_reset()
-{
+{SELFPARAM();
timeout_caller = world;
timeout_time = 0;
timeout_leadtime = 0;
}
void timeout_handler_think()
-{
+{SELFPARAM();
entity tmp_player;
switch(timeout_status)
// unlock the view for players so they can move around again
FOR_EACH_REALPLAYER(tmp_player)
- tmp_player.fixangle = FALSE;
+ tmp_player.fixangle = false;
timeout_handler_reset();
}
}
}
+void CommonCommand_editmob(int request, entity caller, int argc)
+{SELFPARAM();
+ switch(request)
+ {
+ case CMD_REQUEST_COMMAND:
+ {
+ if(autocvar_g_campaign) { print_to(caller, "Monster editing is disabled in singleplayer"); return; }
+ // no checks for g_monsters here, as it may be toggled mid match which existing monsters
+
+ if(caller)
+ {
+ makevectors(self.v_angle);
+ WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * 100, MOVE_NORMAL, self);
+ }
+
+ entity mon = trace_ent;
+ bool is_visible = IS_MONSTER(mon);
+ string argument = argv(2);
+
+ switch(argv(1))
+ {
+ case "name":
+ {
+ if(!caller) { print_to(caller, "Only players can edit monsters"); return; }
+ if(!argument) { break; } // escape to usage
+ if(!autocvar_g_monsters_edit) { print_to(caller, "Monster editing is disabled"); return; }
+ if(mon.realowner != caller && autocvar_g_monsters_edit < 2) { print_to(caller, "This monster does not belong to you"); return; }
+ if(!is_visible) { print_to(caller, "You must look at your monster to edit it"); return; }
+
+ string mon_oldname = mon.monster_name;
+
+ mon.monster_name = argument;
+ if(mon.sprite) { WaypointSprite_UpdateSprites(mon.sprite, WP_Monster, WP_Null, WP_Null); }
+ print_to(caller, sprintf("Your pet '%s' is now known as '%s'", mon_oldname, mon.monster_name));
+ return;
+ }
+ case "spawn":
+ {
+ if(!caller) { print_to(caller, "Only players can spawn monsters"); return; }
+ if(!argv(2)) { break; } // escape to usage
+
+ int moveflag, tmp_moncount = 0;
+ string arg_lower = strtolower(argument);
+ moveflag = (argv(3)) ? stof(argv(3)) : 1; // follow owner if not defined
+ ret_string = "Monster spawning is currently disabled by a mutator";
+
+ if(arg_lower == "list") { print_to(caller, monsterlist_reply); return; }
+
+ FOR_EACH_MONSTER(mon) { if(mon.realowner == caller) ++tmp_moncount; }
+
+ if(!autocvar_g_monsters) { print_to(caller, "Monsters are disabled"); return; }
+ if(autocvar_g_monsters_max <= 0 || autocvar_g_monsters_max_perplayer <= 0) { print_to(caller, "Monster spawning is disabled"); return; }
+ if(!IS_PLAYER(caller)) { print_to(caller, "You must be playing to spawn a monster"); return; }
+ if(MUTATOR_CALLHOOK(AllowMobSpawning)) { print_to(caller, ret_string); return; }
+ if(caller.vehicle) { print_to(caller, "You can't spawn monsters while driving a vehicle"); return; }
+ if(caller.frozen) { print_to(caller, "You can't spawn monsters while frozen"); return; }
+ if(caller.deadflag != DEAD_NO) { print_to(caller, "You can't spawn monsters while dead"); return; }
+ if(tmp_moncount >= autocvar_g_monsters_max) { print_to(caller, "The maximum monster count has been reached"); return; }
+ if(tmp_moncount >= autocvar_g_monsters_max_perplayer) { print_to(caller, "You can't spawn any more monsters"); return; }
+
+ bool found = false;
+ for(int i = MON_FIRST; i <= MON_LAST; ++i)
+ {
+ mon = get_monsterinfo(i);
+ if(mon.netname == arg_lower) { found = true; break; }
+ }
+
+ if(!found && arg_lower != "random") { print_to(caller, "Invalid monster"); return; }
+
+ totalspawned += 1;
+ WarpZone_TraceBox (CENTER_OR_VIEWOFS(caller), caller.mins, caller.maxs, CENTER_OR_VIEWOFS(caller) + v_forward * 150, true, caller);
+ mon = spawnmonster(arg_lower, 0, caller, caller, trace_endpos, false, false, moveflag);
+ print_to(caller, strcat("Spawned ", mon.monster_name));
+ return;
+ }
+ case "kill":
+ {
+ if(!caller) { print_to(caller, "Only players can kill monsters"); return; }
+ if(mon.realowner != caller && autocvar_g_monsters_edit < 2) { print_to(caller, "This monster does not belong to you"); return; }
+ if(!is_visible) { print_to(caller, "You must look at your monster to edit it"); return; }
+
+ Damage (mon, world, world, mon.health + mon.max_health + 200, DEATH_KILL.m_id, mon.origin, '0 0 0');
+ print_to(caller, strcat("Your pet '", mon.monster_name, "' has been brutally mutilated"));
+ return;
+ }
+ case "skin":
+ {
+ if(!caller) { print_to(caller, "Only players can edit monsters"); return; }
+ if(!argument) { break; } // escape to usage
+ if(!autocvar_g_monsters_edit) { print_to(caller, "Monster editing is disabled"); return; }
+ if(!is_visible) { print_to(caller, "You must look at your monster to edit it"); return; }
+ if(mon.realowner != caller && autocvar_g_monsters_edit < 2) { print_to(caller, "This monster does not belong to you"); return; }
+ if(mon.monsterid == MON_MAGE.monsterid) { print_to(caller, "Mage skins can't be changed"); return; } // TODO
+
+ mon.skin = stof(argument);
+ print_to(caller, strcat("Monster skin successfully changed to ", ftos(mon.skin)));
+ return;
+ }
+ case "movetarget":
+ {
+ if(!caller) { print_to(caller, "Only players can edit monsters"); return; }
+ if(!argument) { break; } // escape to usage
+ if(!autocvar_g_monsters_edit) { print_to(caller, "Monster editing is disabled"); return; }
+ if(!is_visible) { print_to(caller, "You must look at your monster to edit it"); return; }
+ if(mon.realowner != caller && autocvar_g_monsters_edit < 2) { print_to(caller, "This monster does not belong to you"); return; }
+
+ mon.monster_moveflags = stof(argument);
+ print_to(caller, strcat("Monster move target successfully changed to ", ftos(mon.monster_moveflags)));
+ return;
+ }
+ case "butcher":
+ {
+ if(caller) { print_to(caller, "This command is not available to players"); return; }
+ if(MUTATOR_CALLHOOK(AllowMobButcher)) { LOG_INFO(ret_string, "\n"); return; }
+
+ int tmp_remcount = 0;
+ entity tmp_entity;
+
+ FOR_EACH_MONSTER(tmp_entity) { Monster_Remove(tmp_entity); ++tmp_remcount; }
+
+ monsters_total = monsters_killed = totalspawned = 0;
+
+ print_to(caller, (tmp_remcount) ? sprintf("Killed %d monster%s", tmp_remcount, (tmp_remcount == 1) ? "" : "s") : "No monsters to kill");
+ return;
+ }
+ }
+ }
+
+ default:
+ case CMD_REQUEST_USAGE:
+ {
+ print_to(caller, strcat("\nUsage:^3 ", GetCommandPrefix(caller), " editmob command [arguments]"));
+ print_to(caller, " Where 'command' can be butcher spawn skin movetarget kill name");
+ print_to(caller, " spawn, skin, movetarget and name require 'arguments'");
+ print_to(caller, " spawn also takes arguments list and random");
+ print_to(caller, " Monster will follow owner if third argument of spawn command is not defined");
+ return;
+ }
+ }
+}
+
void CommonCommand_info(float request, entity caller, float argc)
{
switch(request)
{
case CMD_REQUEST_COMMAND:
{
- float i;
-
- for(i = 0; i < 10; ++i)
+ for(int i = 0; i < 10; ++i)
if(records_reply[i] != "")
print_to(caller, records_reply[i]);
print_to(caller, strcat("realtime = ", ftos(gettime(GETTIME_REALTIME))));
print_to(caller, strcat("hires = ", ftos(gettime(GETTIME_HIRES))));
print_to(caller, strcat("uptime = ", ftos(gettime(GETTIME_UPTIME))));
- print_to(caller, strcat("localtime = ", strftime(TRUE, "%a %b %e %H:%M:%S %Z %Y")));
- print_to(caller, strcat("gmtime = ", strftime(FALSE, "%a %b %e %H:%M:%S %Z %Y")));
+ print_to(caller, strcat("localtime = ", strftime(true, "%a %b %e %H:%M:%S %Z %Y")));
+ print_to(caller, strcat("gmtime = ", strftime(false, "%a %b %e %H:%M:%S %Z %Y")));
return;
}
return;
}
- default: dprint("timeout status was inactive, but this code was executed anyway?"); return;
+ default: LOG_TRACE("timeout status was inactive, but this code was executed anyway?"); return;
}
}
}
{
if(caller) { caller.allowed_timeouts -= 1; }
- bprint(GetCallerName(caller), " ^7called a timeout", (caller ? strcat(" (", ftos(caller.allowed_timeouts), " timeout(s) left)") : ""), "!\n"); // write a bprint who started the timeout (and how many they have left)
+ // write a bprint who started the timeout (and how many they have left)
+ bprint(GetCallerName(caller), " ^7called a timeout", (caller ? strcat(" (", ftos(caller.allowed_timeouts), " timeout(s) left)") : ""), "!\n");
timeout_status = TIMEOUT_LEADTIME;
timeout_caller = caller;
}
}
*/
-
-
-// ==================================
-// Macro system for common commands
-// ==================================
-
-// Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
-#define COMMON_COMMANDS(request,caller,arguments,command) \
- COMMON_COMMAND("cvar_changes", CommonCommand_cvar_changes(request, caller), "Prints a list of all changed server cvars") \
- COMMON_COMMAND("cvar_purechanges", CommonCommand_cvar_purechanges(request, caller), "Prints a list of all changed gameplay cvars") \
- COMMON_COMMAND("info", CommonCommand_info(request, caller, arguments), "Request for unique server information set up by admin") \
- COMMON_COMMAND("ladder", CommonCommand_ladder(request, caller), "Get information about top players if supported") \
- COMMON_COMMAND("lsmaps", CommonCommand_lsmaps(request, caller), "List maps which can be used with the current game mode") \
- COMMON_COMMAND("printmaplist", CommonCommand_printmaplist(request, caller), "Display full server maplist reply") \
- COMMON_COMMAND("rankings", CommonCommand_rankings(request, caller), "Print information about rankings") \
- COMMON_COMMAND("records", CommonCommand_records(request, caller), "List top 10 records for the current map") \
- COMMON_COMMAND("teamstatus", CommonCommand_teamstatus(request, caller), "Show information about player and team scores") \
- COMMON_COMMAND("time", CommonCommand_time(request, caller), "Print different formats/readouts of time") \
- COMMON_COMMAND("timein", CommonCommand_timein(request, caller), "Resume the game from being paused with a timeout") \
- COMMON_COMMAND("timeout", CommonCommand_timeout(request, caller), "Call a timeout which pauses the game for certain amount of time unless unpaused") \
- COMMON_COMMAND("vote", VoteCommand(request, caller, arguments, command), "Request an action to be voted upon by players") \
- COMMON_COMMAND("who", CommonCommand_who(request, caller, arguments), "Display detailed client information about all players") \
- /* nothing */
-
-void CommonCommand_macro_help(entity caller)
-{
- #define COMMON_COMMAND(name,function,description) \
- { print_to(caller, strcat(" ^2", name, "^7: ", description)); }
-
- COMMON_COMMANDS(0, caller, 0, "")
- #undef COMMON_COMMAND
-
- return;
-}
-
-float CommonCommand_macro_command(float argc, entity caller, string command)
-{
- #define COMMON_COMMAND(name,function,description) \
- { if(name == strtolower(argv(0))) { function; return TRUE; } }
-
- COMMON_COMMANDS(CMD_REQUEST_COMMAND, caller, argc, command)
- #undef COMMON_COMMAND
-
- return FALSE;
-}
-
-float CommonCommand_macro_usage(float argc, entity caller)
-{
- #define COMMON_COMMAND(name,function,description) \
- { if(name == strtolower(argv(1))) { function; return TRUE; } }
-
- COMMON_COMMANDS(CMD_REQUEST_USAGE, caller, argc, "")
- #undef COMMON_COMMAND
-
- return FALSE;
-}
-
-void CommonCommand_macro_write_aliases(float fh)
-{
- #define COMMON_COMMAND(name,function,description) \
- { CMD_Write_Alias("qc_cmd_svcmd", name, description); }
-
- COMMON_COMMANDS(0, world, 0, "")
- #undef COMMON_COMMAND
-
- return;
-}