r1876 - in branches/nexuiz-2.0/data: . qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Aug 30 15:22:35 EDT 2006


Author: div0
Date: 2006-08-30 15:22:35 -0400 (Wed, 30 Aug 2006)
New Revision: 1876

Modified:
   branches/nexuiz-2.0/data/default.cfg
   branches/nexuiz-2.0/data/qcsrc/server/constants.qh
   branches/nexuiz-2.0/data/qcsrc/server/g_damage.qc
Log:
merged mirror damage


Modified: branches/nexuiz-2.0/data/default.cfg
===================================================================
--- branches/nexuiz-2.0/data/default.cfg	2006-08-30 15:17:46 UTC (rev 1875)
+++ branches/nexuiz-2.0/data/default.cfg	2006-08-30 19:22:35 UTC (rev 1876)
@@ -233,7 +233,15 @@
 
 // common team values
 set  g_tdm				0
+
 seta teamplay_default			3	// default teamplay setting in team games
+  // 1 = no friendly fire, self damage
+  // 2 = friendly fire and self damage enabled
+  // 3 = no friendly fire, but self damage enabled
+  // 4 = obey the following two cvars
+seta g_mirrordamage 0.0              // for teamplay 4: mirror damage factor
+seta g_friendlyfire 1.0              // for teamplay 4: fiendly fire factor
+
 set deathmatch_force_teamplay		0	// always play TDM on dm maps
 seta g_balance_teams			0	// automatically balance out players entering instead of asking them for their preferred team
 seta g_balance_teams_force		0	// automatically balance out teams when players move or disconnect

Modified: branches/nexuiz-2.0/data/qcsrc/server/constants.qh
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/constants.qh	2006-08-30 15:17:46 UTC (rev 1875)
+++ branches/nexuiz-2.0/data/qcsrc/server/constants.qh	2006-08-30 19:22:35 UTC (rev 1876)
@@ -150,6 +150,7 @@
 float	DEATH_CAMP				= 10011;
 float	DEATH_SHOOTING_STAR			= 10012;
 float	DEATH_ROT				= 10013;
+float	DEATH_MIRRORDAMAGE		= 10014;
 
 float	IT_LASER				= 4096;
 float	IT_SHOTGUN				= 1;

Modified: branches/nexuiz-2.0/data/qcsrc/server/g_damage.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/g_damage.qc	2006-08-30 15:17:46 UTC (rev 1875)
+++ branches/nexuiz-2.0/data/qcsrc/server/g_damage.qc	2006-08-30 19:22:35 UTC (rev 1876)
@@ -128,6 +128,8 @@
 				centerprint(targ, strcat("^1You were killed for running out of ammo...\n\n\n"));
 			else if (deathtype == DEATH_ROT)
 				centerprint(targ, strcat("^1You grew too old without taking your medcine\n\n\n"));
+			else if (deathtype == DEATH_MIRRORDAMAGE)
+				centerprint(targ, strcat("^1Don't shoot your team mates!\n\n\n"));
 			else
 				centerprint(targ, strcat("^1You killed your own dumb self!\n\n\n"));
 
@@ -148,6 +150,8 @@
 			}
 			else if (deathtype == DEATH_CAMP)
 				bprint ("^1",s, "^1 thought he found a nice camping ground\n");
+			else if (deathtype == DEATH_MIRRORDAMAGE)
+				bprint ("^1",s, "^1 didn't become friends with the Lord of Teamplay\n");
 			else if (deathtype != DEATH_TEAMCHANGE)
 				bprint ("^1",s, "^1 couldn't resist the urge to self-destruct\n");
 
@@ -316,6 +320,12 @@
 
 void Damage (entity targ, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
 {
+	float mirrordamage;
+	float mirrorforce;
+	entity attacker_save;
+	mirrordamage = 0;
+	mirrorforce = 0;
+
 	if (gameover || targ.killcount == -666)
 		return;
 
@@ -325,12 +335,7 @@
         damage_targ = targ;
         damage_inflictor = inflictor;
         damage_attacker = attacker;
-	// nullify damage if teamplay is on
-	if (teamplay)
-	if (attacker.team)
-	if (attacker.team == targ.team)
-	if (teamplay == 1 || (teamplay == 3 && attacker != targ))
-		damage = 0;
+		attacker_save = attacker;
 
 	if (targ.classname == "player")
 	if (attacker.classname == "player")
@@ -338,6 +343,34 @@
 	if (attacker.isbot)
 		damage = damage * bound(0.1, (skill + 5) * 0.1, 1);
 
+	// nullify damage if teamplay is on
+	if(teamplay == 1)
+		if(attacker.team)
+			if(attacker.team == targ.team)
+				damage = 0;
+	if(teamplay == 3)
+		if(attacker != targ)
+			if(attacker.team)
+				if(attacker.team == targ.team)
+					damage = 0;
+	if(teamplay == 4)
+		if(attacker != targ)
+			if(attacker.team == targ.team)
+				if(attacker.classname == "player")
+					if(targ.classname == "player")
+					{
+						mirrordamage = cvar("g_mirrordamage") * damage;
+						mirrorforce = cvar("g_mirrordamage") * vlen(force);
+						if(cvar("g_minstagib"))
+						{
+							if(cvar("g_friendlyfire") == 0)
+								damage = 0;
+						}
+						else
+							damage = cvar("g_friendlyfire") * damage;
+						// mirrordamage will be used LATER
+					}
+
 	if(cvar("g_lms"))
 	if(targ.classname == "player")
 	if(attacker.classname == "player")
@@ -381,7 +414,9 @@
 				if (targ.classname == "player")
 					centerprint(attacker, "Secondary fire inflicts no damage!\n");
 				damage = 0;
+				mirrordamage = 0;
 				force = '0 0 0';
+				// keep mirrorforce
 				attacker = targ;
 			}
 		}
@@ -488,6 +523,26 @@
 			}
 		}
 	}
+
+	// apply mirror damage if any
+	if(mirrordamage > 0 || mirrorforce > 0)
+	{
+		attacker = attacker_save;
+		if(cvar("g_minstagib"))
+			if(mirrordamage > 0)
+			{
+				// just lose extra LIVES, don't kill the player for mirror damage
+				if(attacker.armorvalue > 0)
+				{
+					attacker.armorvalue = attacker.armorvalue - 1;
+					centerprint(attacker, strcat("^3Remaining extra lives: ",ftos(attacker.armorvalue),"\n"));
+					if(clienttype(attacker) == CLIENTTYPE_REAL) stuffcmd(attacker, "play2 misc/hit.wav\n");
+				}
+				mirrordamage = 0;
+			}
+		force = normalize(attacker.origin + attacker.view_ofs - hitloc) * mirrorforce;
+		Damage(attacker, inflictor, attacker, mirrordamage, DEATH_MIRRORDAMAGE, attacker.origin, force);
+	}
 }
 
 void RadiusDamage (entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity ignore, float forceintensity, float deathtype)




More information about the nexuiz-commits mailing list