summaryrefslogtreecommitdiff
path: root/src/game/g_admin.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/g_admin.c')
-rw-r--r--src/game/g_admin.c116
1 files changed, 115 insertions, 1 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index ca641e0..b696cc9 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -117,6 +117,11 @@ g_admin_cmd_t g_admin_cmds[ ] =
"[^3name|slot#^7] ..."
},
+ {"curse", G_admin_curse, "curse",
+ "punish players without making it obvious",
+ "[^3name|slot#^7] ([^3option^7] [^5value^7])"
+ },
+
{"demo", G_admin_demo, "demo",
"turn admin chat off for the caller so it does not appear in demos. "
"this is a toggle use !demo again to turn warnings back on",
@@ -375,7 +380,7 @@ g_admin_cmd_t g_admin_cmds[ ] =
"sets the admin level of a player",
"[^3name|slot#|admin#^7] [^3level^7]"
},
-
+
{"showbans", G_admin_showbans, "showbans",
"display a (partial) list of active bans",
"(^5start at ban#^7) (^5name|IP|'-subnet'^7)"
@@ -10530,3 +10535,112 @@ qboolean G_admin_versions(gentity_t *ent, int skiparg)
ADMBP_end();
return qtrue;
}
+
+qboolean G_admin_curse(gentity_t *ent, int skiparg)
+{
+ char arg_name_raw[MAX_NAME_LENGTH];
+ char arg_name[MAX_NAME_LENGTH];
+ char arg_option[30];
+ int i, target_id;
+ float value;
+ gentity_t *target;
+ adminCurses_t *curses;
+
+ if (G_SayArgc() < 2 + skiparg) {
+ ADMP("^3!curse: ^7usage: !curse [target] ([option] [value])\n");
+ return qfalse;
+ }
+
+ G_SayArgv(1 + skiparg, arg_name_raw, sizeof(arg_name_raw));
+
+ if (!Q_stricmp(arg_name_raw, "-reset")) {
+ for (i = 0; i < level.maxclients; i++)
+ memset(&level.clients[i].curses, 0, sizeof(adminCurses_t));
+
+ G_AdminsPrintf("^3!curses: ^7reset by %s\n",
+ ent ? G_admin_adminPrintName(ent) : "console");
+ return qtrue;
+ }
+
+ G_SanitiseString(arg_name_raw, arg_name, sizeof(arg_name));
+
+ if (is_numeric(arg_name)) {
+ target_id = atoi(arg_name);
+
+ if (target_id < 0 || target_id >= MAX_CLIENTS) {
+ ADMP(va("^3!curse: ^7invalid client number\n"));
+ return qfalse;
+ }
+ } else {
+ int pids[ MAX_CLIENTS ];
+
+ if (G_ClientNumbersFromString(arg_name, pids) != 1) {
+ char error[MAX_STRING_CHARS];
+
+ G_MatchOnePlayer(pids, error, sizeof(error));
+ ADMP(va("^3!curse: ^7%s\n", error));
+ return qfalse;
+ }
+
+ target_id = pids[0];
+ }
+
+ target = g_entities + target_id;
+
+ if (!target->client ||
+ target->client->pers.connected != CON_CONNECTED) {
+ ADMP("^3!curse: ^7invalid target\n");
+ return qfalse;
+ }
+
+ curses = &target->client->curses;
+
+ if (G_SayArgc() < 4 + skiparg) {
+ ADMP(va("^3!curse: ^7info for %s^7:\n",
+ target->client->pers.netname));
+ ADMP(va("outDamage = %f\n", curses->outDamage));
+ ADMP(va("incDamage = %f\n", curses->incDamage));
+ ADMP(va("damageFeedback = %f\n", curses->damageFeedback));
+ ADMP(va("staminaUse = %f\n", curses->staminaUse));
+ ADMP(va("staminaRegen = %f\n", curses->staminaRegen));
+ return qtrue;
+ }
+
+ if (!g_adminCurses.integer) {
+ ADMP("^3!curse: ^7disabled by the server operator\n");
+ return qfalse;
+ }
+
+ if (!admin_higher(ent, target)) {
+ ADMP("^3!curse: ^7sorry, but your intended victim has a higher admin level than you\n");
+ return qfalse;
+ }
+
+ G_SayArgv(3 + skiparg, arg_option, sizeof(arg_option)); // var reuse
+ value = atof(arg_option);
+ G_SayArgv(2 + skiparg, arg_option, sizeof(arg_option));
+
+ if (!Q_stricmp(arg_option, "outdamage"))
+ curses->outDamage = value - 1.0f;
+ else if (!Q_stricmp(arg_option, "incdamage"))
+ curses->incDamage = value - 1.0f;
+ else if (!Q_stricmp(arg_option, "damagefeedback"))
+ curses->damageFeedback = value;
+ else if (!Q_stricmp(arg_option, "ffoutdamage"))
+ curses->ffOutDamage = value;
+ else if (!Q_stricmp(arg_option, "fffeedback"))
+ curses->ffFeedback = value;
+ else if (!Q_stricmp(arg_option, "staminause"))
+ curses->staminaUse = value - 1.0f;
+ else if (!Q_stricmp(arg_option, "staminaregen"))
+ curses->staminaRegen = value - 1.0f;
+ else {
+ ADMP("^3!curse: ^7unrecognized option\n");
+ return qfalse;
+ }
+
+ G_AdminsPrintf("^3!curse: ^7%s^7 cursed %s^7 with %s = %f\n",
+ ent ? G_admin_adminPrintName(ent) : "console",
+ target->client->pers.netname, arg_option, value);
+ return qtrue;
+}