From 74882a8c3002d1aef14586ec137609ba9bc2634c Mon Sep 17 00:00:00 2001 From: fruitiex Date: Wed, 2 Dec 2009 21:23:30 +0000 Subject: [PATCH] instant movetoteam cmd (patch by Spaceman) git-svn-id: svn://svn.icculus.org/nexuiz/trunk@8359 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- Docs/eventlog.txt | 1 + data/defaultNexuiz.cfg | 10 ++-- data/qcsrc/common/constants.qh | 1 + data/qcsrc/server/cl_player.qc | 28 ++++++++++ data/qcsrc/server/g_damage.qc | 11 ++-- data/qcsrc/server/gamecommand.qc | 89 +++++++++++++++++++++++++----- data/qcsrc/server/miscfunctions.qc | 37 +++++++++++++ 7 files changed, 153 insertions(+), 24 deletions(-) diff --git a/Docs/eventlog.txt b/Docs/eventlog.txt index ba9ce730d..030ba52f2 100644 --- a/Docs/eventlog.txt +++ b/Docs/eventlog.txt @@ -88,6 +88,7 @@ join types: 2 = auto 3 = manual 4 = spectating + 6 = adminmove label flags: !! = primary sorting key diff --git a/data/defaultNexuiz.cfg b/data/defaultNexuiz.cfg index d2d0030f3..4194e4ca3 100644 --- a/data/defaultNexuiz.cfg +++ b/data/defaultNexuiz.cfg @@ -95,11 +95,11 @@ alias team_yellow "cmd selectteam yellow; cmd join" alias team_auto "cmd selectteam auto; cmd join" bind f6 team_auto -alias movetoteam_red "sv_cmd movetoteam $1 red" -alias movetoteam_blue "sv_cmd movetoteam $1 blue" -alias movetoteam_pink "sv_cmd movetoteam $1 pink" -alias movetoteam_yellow "sv_cmd movetoteam $1 yellow" -alias movetoteam_auto "sv_cmd movetoteam $1 auto" +alias movetoteam_red "sv_cmd movetoteam $* red" +alias movetoteam_blue "sv_cmd movetoteam $* blue" +alias movetoteam_pink "sv_cmd movetoteam $* pink" +alias movetoteam_yellow "sv_cmd movetoteam $* yellow" +alias movetoteam_auto "sv_cmd movetoteam $* auto" // merge lightmaps up to 1024x1024 textures // the default of 2048x2048 is too heavy for my rig (SavageX) diff --git a/data/qcsrc/common/constants.qh b/data/qcsrc/common/constants.qh index f07309dec..a199dc045 100644 --- a/data/qcsrc/common/constants.qh +++ b/data/qcsrc/common/constants.qh @@ -446,6 +446,7 @@ float DEATH_TOUCHEXPLODE = 10015; float DEATH_CHEAT = 10016; float DEATH_FIRE = 10017; float DEATH_TURRET = 10020; +float DEATH_QUIET = 10021; float DEATH_SBMINIGUN = 10030; float DEATH_SBROCKET = 10031; diff --git a/data/qcsrc/server/cl_player.qc b/data/qcsrc/server/cl_player.qc index 42a51727c..475d90d0e 100644 --- a/data/qcsrc/server/cl_player.qc +++ b/data/qcsrc/server/cl_player.qc @@ -1393,3 +1393,31 @@ void VoiceMessage(string type, string msg) if (!flood) PlayerSound(sample, CHAN_VOICE, voicetype); } + +void MoveToTeam(entity client, float team_colour, float type, float show_message) +{ +// show_message +// 0 (00) automove centerprint, admin message +// 1 (01) automove centerprint, no admin message +// 2 (10) no centerprint, admin message +// 3 (11) no centerprint, no admin message + + float lockteams_backup; + + lockteams_backup = lockteams; // backup any team lock + + lockteams = 0; // disable locked teams + + TeamchangeFrags(client); // move the players frags + SetPlayerColors(client, team_colour - 1); // set the players colour + Damage(client, client, client, 100000, ((show_message & 2) ? DEATH_QUIET : DEATH_AUTOTEAMCHANGE), client.origin, '0 0 0'); // kill the player + + lockteams = lockteams_backup; // restore the team lock + + LogTeamchange(client.playerid, client.team, type); + + if not(show_message & 1) // admin message + sprint(client, strcat("\{1}\{13}^3", admin_name(), "^7: You have been moved to the ", Team_ColorNameLowerCase(team_colour), " team\n")); // send a chat message + + bprint(strcat(client.netname, " joined the ", ColoredTeamName(client.team), "\n")); +} \ No newline at end of file diff --git a/data/qcsrc/server/g_damage.qc b/data/qcsrc/server/g_damage.qc index 166124ad9..543f09d41 100644 --- a/data/qcsrc/server/g_damage.qc +++ b/data/qcsrc/server/g_damage.qc @@ -266,13 +266,14 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype) centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't go against team mates!")); else centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1Don't shoot your team mates!")); + } else if (deathtype == DEATH_QUIET) { + // do nothing } else { if(sv_gentle) centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You need to be more careful!")); else centerprint(targ, strcat(DAMAGE_CENTERPRINT_SPACER, "^1You killed your own dumb self!")); } - if(sv_gentle) { if (deathtype == DEATH_CAMP) bprint ("^1",s, "^1 thought they found a nice camping ground\n"); @@ -281,7 +282,7 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype) else bprint ("^1",s, "^1 will be reinserted into the game due to their own actions\n"); - if(deathtype != DEATH_TEAMCHANGE) + if(deathtype != DEATH_TEAMCHANGE && deathtype != DEATH_QUIET) { LogDeath("suicide", deathtype, targ, targ); GiveFrags(attacker, targ, -1); @@ -311,10 +312,10 @@ void Obituary (entity attacker, entity inflictor, entity targ, float deathtype) bprint ("^1",s, "^1 unfairly eliminated themself\n"); else if (deathtype == DEATH_FIRE) bprint ("^1",s, "^1 burned to death\n"); - else if (deathtype != DEATH_TEAMCHANGE) + else if (deathtype != DEATH_TEAMCHANGE && deathtype != DEATH_QUIET) bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n"); - if(deathtype != DEATH_TEAMCHANGE) + if(deathtype != DEATH_TEAMCHANGE && deathtype != DEATH_QUIET) { LogDeath("suicide", deathtype, targ, targ); GiveFrags(attacker, targ, -1); @@ -656,7 +657,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float } } - if(deathtype == DEATH_KILL || deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE) + if(deathtype == DEATH_KILL || deathtype == DEATH_TEAMCHANGE || deathtype == DEATH_AUTOTEAMCHANGE || deathtype == DEATH_QUIET) { // These are ALWAYS lethal // No damage modification here diff --git a/data/qcsrc/server/gamecommand.qc b/data/qcsrc/server/gamecommand.qc index 7e3011e90..189d32794 100644 --- a/data/qcsrc/server/gamecommand.qc +++ b/data/qcsrc/server/gamecommand.qc @@ -805,25 +805,86 @@ void GameCommand(string command) bprint("That command can only be used in a team-based gamemode.\n"); return; } - if (argv(0) == "movetoteam") if(argc == 3) - { + if(argv(0) == "movetoteam") + if(argc == 3 || argc == 4) { +// sv_cmd movetoteam player_id team_colour +// sv_cmd movetoteam player_id team_colour type_of_move + +// type of move +// 0 (00) automove centerprint, admin message +// 1 (01) automove centerprint, no admin message +// 2 (10) no centerprint, admin message +// 3 (11) no centerprint, no admin message + + if(!teams_matter) { // death match + print("Currently not playing a team game\n"); + return; + } + entno = stof(argv(1)); - client = world; - if(entno <= maxclients) + + // player_id is out of range + if((entno < 1) | (entno > maxclients)) { + print("Player ", argv(1), " doesn't exist\n"); + return; + } + client = edict_num(entno); - if(client.flags & FL_CLIENT) - { - float lt; - lt = lockteams; - lockteams = 0; - self = client; - SV_ParseClientCommand(strcat("selectteam ", argv(2))); + // player entity is not a client + if not(client.flags & FL_CLIENT) { + print("Player ", argv(1), " doesn't exist\n"); + return; + } + + // find the team to move the player to + float team_colour; - lockteams = lt; + team_colour = ColourToNumber(argv(2)); + + if(team_colour == client.team) { // player already on the team + print("Player ", argv(1), " (", client.netname, ") is already on the ", ColoredTeamName(client.team), "\n"); + return; + } else if(team_colour == 0) // auto team + team_colour = NumberToTeamNumber(FindSmallestTeam(client, FALSE)); + + switch(team_colour) { + case COLOR_TEAM1: + if(c1 == -1) { + print("Sorry, there isn't a red team\n"); + return; } - else - print("Client not found\n"); + break; + + case COLOR_TEAM2: + if(c2 == -1) { + print("Sorry, there isn't a blue team\n"); + return; + } + break; + + case COLOR_TEAM3: + if(c3 == -1) { + print("Sorry, there isn't a yellow team\n"); + return; + } + break; + + case COLOR_TEAM4: + if(c4 == -1) { + print("Sorry, there isn't a pink team\n"); + return; + } + break; + + default: + print("Sorry, team ", argv(2), " doesn't exist\n"); + return; + } + + MoveToTeam(client, team_colour, 6, stof(argv(3))); + print("Player ", argv(1), " (", client.netname, ") has been moved to the ", ColoredTeamName(team_colour), "\n"); + return; } if (argv(0) == "teamstatus") diff --git a/data/qcsrc/server/miscfunctions.qc b/data/qcsrc/server/miscfunctions.qc index 7c7fbea23..f62b64b4f 100644 --- a/data/qcsrc/server/miscfunctions.qc +++ b/data/qcsrc/server/miscfunctions.qc @@ -723,6 +723,43 @@ string Team_ColorNameLowerCase(float t) return "neutral"; } +float ColourToNumber(string team_colour) +{ + if (team_colour == "red") + return COLOR_TEAM1; + + if (team_colour == "blue") + return COLOR_TEAM2; + + if (team_colour == "yellow") + return COLOR_TEAM3; + + if (team_colour == "pink") + return COLOR_TEAM4; + + if (team_colour == "auto") + return 0; + + return -1; +} + +float NumberToTeamNumber(float number) +{ + if (number == 1) + return COLOR_TEAM1; + + if (number == 2) + return COLOR_TEAM2; + + if (number == 3) + return COLOR_TEAM3; + + if (number == 4) + return COLOR_TEAM4; + + return -1; +} + #define CENTERPRIO_POINT 1 #define CENTERPRIO_SPAM 2 #define CENTERPRIO_VOTE 4 -- 2.39.2