[nexuiz-commits] r8359 - in trunk: Docs data data/qcsrc/common data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Dec 2 16:23:30 EST 2009


Author: fruitiex
Date: 2009-12-02 16:23:30 -0500 (Wed, 02 Dec 2009)
New Revision: 8359

Modified:
   trunk/Docs/eventlog.txt
   trunk/data/defaultNexuiz.cfg
   trunk/data/qcsrc/common/constants.qh
   trunk/data/qcsrc/server/cl_player.qc
   trunk/data/qcsrc/server/g_damage.qc
   trunk/data/qcsrc/server/gamecommand.qc
   trunk/data/qcsrc/server/miscfunctions.qc
Log:
instant movetoteam cmd (patch by Spaceman)


Modified: trunk/Docs/eventlog.txt
===================================================================
--- trunk/Docs/eventlog.txt	2009-12-02 20:48:53 UTC (rev 8358)
+++ trunk/Docs/eventlog.txt	2009-12-02 21:23:30 UTC (rev 8359)
@@ -88,6 +88,7 @@
     2 = auto
     3 = manual
     4 = spectating
+    6 = adminmove
 
 label flags:
    !! = primary sorting key

Modified: trunk/data/defaultNexuiz.cfg
===================================================================
--- trunk/data/defaultNexuiz.cfg	2009-12-02 20:48:53 UTC (rev 8358)
+++ trunk/data/defaultNexuiz.cfg	2009-12-02 21:23:30 UTC (rev 8359)
@@ -95,11 +95,11 @@
 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)

Modified: trunk/data/qcsrc/common/constants.qh
===================================================================
--- trunk/data/qcsrc/common/constants.qh	2009-12-02 20:48:53 UTC (rev 8358)
+++ trunk/data/qcsrc/common/constants.qh	2009-12-02 21:23:30 UTC (rev 8359)
@@ -446,6 +446,7 @@
 float DEATH_CHEAT = 10016;
 float DEATH_FIRE = 10017;
 float DEATH_TURRET = 10020;
+float DEATH_QUIET = 10021;
 
 float DEATH_SBMINIGUN = 10030;
 float DEATH_SBROCKET  = 10031;

Modified: trunk/data/qcsrc/server/cl_player.qc
===================================================================
--- trunk/data/qcsrc/server/cl_player.qc	2009-12-02 20:48:53 UTC (rev 8358)
+++ trunk/data/qcsrc/server/cl_player.qc	2009-12-02 21:23:30 UTC (rev 8359)
@@ -1393,3 +1393,31 @@
 	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

Modified: trunk/data/qcsrc/server/g_damage.qc
===================================================================
--- trunk/data/qcsrc/server/g_damage.qc	2009-12-02 20:48:53 UTC (rev 8358)
+++ trunk/data/qcsrc/server/g_damage.qc	2009-12-02 21:23:30 UTC (rev 8359)
@@ -266,13 +266,14 @@
 					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 @@
 				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 @@
 					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 @@
 			}
 	}
 
-	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

Modified: trunk/data/qcsrc/server/gamecommand.qc
===================================================================
--- trunk/data/qcsrc/server/gamecommand.qc	2009-12-02 20:48:53 UTC (rev 8358)
+++ trunk/data/qcsrc/server/gamecommand.qc	2009-12-02 21:23:30 UTC (rev 8359)
@@ -805,27 +805,88 @@
 			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;
+		}
 
-			lockteams = lt;
+		// find the team to move the player to
+		float team_colour;
+
+		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")
 	{
 		Score_NicePrint(world);

Modified: trunk/data/qcsrc/server/miscfunctions.qc
===================================================================
--- trunk/data/qcsrc/server/miscfunctions.qc	2009-12-02 20:48:53 UTC (rev 8358)
+++ trunk/data/qcsrc/server/miscfunctions.qc	2009-12-02 21:23:30 UTC (rev 8359)
@@ -723,6 +723,43 @@
     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



More information about the nexuiz-commits mailing list