diff options
author | Theriaca <reichmeister@protonmail.com> | 2018-11-13 02:52:51 +0100 |
---|---|---|
committer | Theriaca <reichmeister@protonmail.com> | 2018-11-13 08:55:50 +0100 |
commit | bc4579cc888a13527a6f2013adea8d0c73257c18 (patch) | |
tree | f7e1844589a95d8ab2f4e23421e6ac9d0d9f5480 | |
parent | 35a81dd50a340b1175c715bb754ce2b2e454425e (diff) |
implement !showff, a targetable FFire tracker
-rw-r--r-- | src/game/g_admin.c | 102 | ||||
-rw-r--r-- | src/game/g_admin.h | 1 |
2 files changed, 102 insertions, 1 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c index ea8efe5..93c1d54 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -361,7 +361,7 @@ g_admin_cmd_t g_admin_cmds[ ] = "[^3report#^7] (^3!^7) - ^3!^7 means archive instead of report" }, - {"rshow", G_admin_rshow, "reportmanage", + {"rshow", G_admin_rshow, "reportmanage", "shows a report/archive entry in its entirety", "[^3rshow#^7] (^3!^7) [report#] - ^3!^7 shows archive instead of report" }, @@ -391,6 +391,13 @@ g_admin_cmd_t g_admin_cmds[ ] = "(^5start at ban#^7) (^5name|IP|'-subnet'^7)" }, + {"showff", G_admin_showff, "showff", + "shows how much friendly damage a player has done this game" + "\nno arguments will list all connected players", + "([^3name|slot^7] (^5-v|--verbose^7))" + "\n ^3Example:^7 ^120% ^7means 1/5th of the damage dealt this game was dealt to the team" + }, + {"slap", G_admin_slap, "slap", "Do damage to a player, and send them flying", "[^3name|slot^7] (damage)" @@ -10713,3 +10720,96 @@ skip_protection: target->client->pers.netname, arg_option, value); return qtrue; } + +static int calc_ff_pct(statsCounters_t *sc) { + if (sc->dmgdone + sc->structdmgdone <= 0) { + if (sc->ffdmgdone <= 0) + return 0; + else + return 100; + } else { + return round((float)sc->ffdmgdone / (sc->ffdmgdone + sc->dmgdone + sc->structdmgdone) * 100); + } +} + +qboolean G_admin_showff(gentity_t *ent, int skiparg) +{ + char arg_name_raw[MAX_NAME_LENGTH]; + char arg_name[MAX_NAME_LENGTH]; + char arg_opt[MAX_STRING_CHARS]; + int target_id, ffpct; + gentity_t *target; + statsCounters_t *sc; + + if (G_SayArgc() == 1 + skiparg) { + int i; + char team[4]; + gclient_t *client; + + ADMBP_begin(); + ADMBP("^3!showff:^7 friendly fire damage percentage for all connected players\n"); + + for (i = 0; i < level.maxclients; i++) { + client = &level.clients[i]; + + if (client->pers.connected != CON_CONNECTED) + continue; + + if (client->pers.teamSelection == PTE_HUMANS) + sprintf(team, "^4H"); + else if (client->pers.teamSelection == PTE_ALIENS) + sprintf(team, "^1A"); + else + sprintf(team, "^3S"); + + ffpct = calc_ff_pct(&client->pers.statscounters); + ADMBP(va("%2d %s ^1%3d%% ^7%s^7\n", i, team, ffpct, client->pers.netname)); + } + + ADMBP("^7for detailed information, use ^3!showff player|slot -v^7\n"); + ADMBP_end(); + return qtrue; + } + + G_SayArgv(1 + skiparg, arg_name_raw, sizeof(arg_name_raw)); + G_SayArgv(2 + skiparg, arg_opt, sizeof(arg_opt)); + 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!showff: ^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!showff: ^7%s\n", error)); + return qfalse; + } + + target_id = pids[0]; + } + + target = g_entities + target_id; + sc = &target->client->pers.statscounters; + ffpct = calc_ff_pct(sc); + + if(!strcmp(arg_opt, "-v") || !strcmp(arg_opt, "--verbose")) { + ADMP(va("^3!showff: ^7detailed FF information for %s^7:\n", + target->client->pers.netname)); + ADMP(va("^7damage to: Enemies: ^1%d^7, structures: ^1%d^7, friendlies: ^1%d\n", + sc->dmgdone, sc->structdmgdone, sc->ffdmgdone)); + ADMP(va("dealt ^1%d%%^7 of their total damage to the team\n", ffpct)); + } else { + ADMP(va("^3!showff: %s^7 dealt ^1%d%%^7 of their total damage to the team\n", + target->client->pers.netname, ffpct)); + } + + return qtrue; +} diff --git a/src/game/g_admin.h b/src/game/g_admin.h index 051cd06..b2ac338 100644 --- a/src/game/g_admin.h +++ b/src/game/g_admin.h @@ -320,6 +320,7 @@ qboolean G_admin_mute( gentity_t *ent, int skiparg ); qboolean G_admin_denybuild( gentity_t *ent, int skiparg ); qboolean G_admin_denyweapon( gentity_t *ent, int skiparg ); qboolean G_admin_showbans( gentity_t *ent, int skiparg ); +qboolean G_admin_showff(gentity_t *ent, int skiparg); qboolean G_admin_help( gentity_t *ent, int skiparg ); qboolean G_admin_admintest( gentity_t *ent, int skiparg ); qboolean G_admin_allready( gentity_t *ent, int skiparg ); |