instant movetoteam cmd (patch by Spaceman)
authorfruitiex <fruitiex@f962a42d-fe04-0410-a3ab-8c8b0445ebaa>
Wed, 2 Dec 2009 21:23:30 +0000 (21:23 +0000)
committerfruitiex <fruitiex@f962a42d-fe04-0410-a3ab-8c8b0445ebaa>
Wed, 2 Dec 2009 21:23:30 +0000 (21:23 +0000)
git-svn-id: svn://svn.icculus.org/nexuiz/trunk@8359 f962a42d-fe04-0410-a3ab-8c8b0445ebaa

Docs/eventlog.txt
data/defaultNexuiz.cfg
data/qcsrc/common/constants.qh
data/qcsrc/server/cl_player.qc
data/qcsrc/server/g_damage.qc
data/qcsrc/server/gamecommand.qc
data/qcsrc/server/miscfunctions.qc

index ba9ce73..030ba52 100644 (file)
@@ -88,6 +88,7 @@ join types:
     2 = auto\r
     3 = manual\r
     4 = spectating\r
+    6 = adminmove\r
 \r
 label flags:\r
    !! = primary sorting key\r
index d2d0030..4194e4c 100644 (file)
@@ -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)
index f07309d..a199dc0 100644 (file)
@@ -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;
index 42a5172..475d90d 100644 (file)
@@ -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
index 166124a..543f09d 100644 (file)
@@ -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
index 7e3011e..189d327 100644 (file)
@@ -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")
index 7c7fbea..f62b64b 100644 (file)
@@ -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