r5604 - in trunk/data/qcsrc: client server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Jan 18 14:22:38 EST 2009


Author: div0
Date: 2009-01-18 14:22:38 -0500 (Sun, 18 Jan 2009)
New Revision: 5604

Modified:
   trunk/data/qcsrc/client/damage.qc
   trunk/data/qcsrc/server/g_damage.qc
   trunk/data/qcsrc/server/w_common.qc
Log:
client projectiles: use a better way to find the trace normal


Modified: trunk/data/qcsrc/client/damage.qc
===================================================================
--- trunk/data/qcsrc/client/damage.qc	2009-01-18 19:10:02 UTC (rev 5603)
+++ trunk/data/qcsrc/client/damage.qc	2009-01-18 19:22:38 UTC (rev 5604)
@@ -1,53 +1,3 @@
-/*
-==================
-findbetterlocation
-
-Returns a point at least 12 units away from walls
-(useful for explosion animations, although the blast is performed where it really happened)
-Ripped from DPMod
-==================
-*/
-vector findbetterlocation (vector org, float mindist)
-{
-	vector loc, norm, norm2;
-	vector vec;
-	float c;
-	float h;
-
-	norm = '0 0 1';
-
-	vec = mindist * '1 0 0';
-	c = 0;
-	while (c < 6)
-	{
-		traceline (org, org + vec, MOVE_WORLDONLY, world);
-		vec = vec * -1;
-		if (trace_fraction < 1)
-		{
-			loc = trace_endpos;
-			norm2 = trace_plane_normal;
-			traceline (loc, loc + vec, MOVE_WORLDONLY, world);
-			if (trace_fraction >= 1)
-			{
-				org = loc + vec;
-				norm = norm2;
-			}
-		}
-		if (c & 1)
-		{
-			h = vec_y;
-			vec_y = vec_x;
-			vec_x = vec_z;
-			vec_z = h;
-		}
-		c = c + 1;
-	}
-
-	trace_plane_normal = norm;
-
-	return org;
-}
-
 void Ent_DamageInfo()
 {
 	float hittype, dmg, rad, edge, thisdmg;
@@ -102,7 +52,7 @@
 	if(!DEATH_ISSPECIAL(hittype))
 	{
 		float hitwep, secondary, bounce, headshot;
-		vector org2;
+		vector org2, backoff;
 		float r;
 
 		hitwep = DEATH_WEAPONOFWEAPONDEATH(hittype);
@@ -111,28 +61,32 @@
 		headshot = hittype & HITTYPE_HEADSHOT;
 		r = random();
 
+		traceline(org - normalize(force) * 16, org + normalize(force) * 16, MOVE_NOMONSTERS, world);
+		if(trace_fraction < 1)
+			backoff = trace_plane_normal;
+		else
+			backoff = -1 * normalize(force);
+
 		switch(hitwep)
 		{
 			case WEP_LASER:
-				org2 = findbetterlocation (org, 8);
-				pointparticles(particleeffectnum("laser_impact"), org2, trace_plane_normal * 1000, 1);
+				org2 = org + backoff * 8;
+				pointparticles(particleeffectnum("laser_impact"), org2, backoff * 1000, 1);
 				sound (self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
 				break;
 			case WEP_SHOTGUN:
-				org2 = findbetterlocation (org, 2);
-				pointparticles(particleeffectnum("shotgun_impact"), org2, trace_plane_normal * 1000, 1);
+				pointparticles(particleeffectnum("shotgun_impact"), org, backoff * 1000, 1);
 				break;
 			case WEP_UZI:
-				org2 = findbetterlocation (org, 2);
-				pointparticles(particleeffectnum("machinegun_impact"), org2, trace_plane_normal * 1000, 1);
+				pointparticles(particleeffectnum("machinegun_impact"), org, backoff * 1000, 1);
 				break;
 			case WEP_GRENADE_LAUNCHER:
-				org2 = findbetterlocation (org, 12);
+				org2 = org + backoff * 12;
 				pointparticles(particleeffectnum("grenade_explode"), org2, '0 0 0', 1);
 				sound (self, CHAN_PROJECTILE, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
 				break;
 			case WEP_ELECTRO:
-				org2 = findbetterlocation (org, 8);
+				org2 = org + backoff * 8;
 				if(secondary)
 				{
 					sound (self, CHAN_PROJECTILE, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
@@ -169,7 +123,7 @@
 				pointparticles(particleeffectnum("nex_impact"), org - normalize(force) * 6, '0 0 0', 1);
 				break;
 			case WEP_HAGAR:
-				org2 = findbetterlocation (org, 12);
+				org2 = org + backoff * 12;
 				if (r<0.15)
 					sound (self, CHAN_PROJECTILE, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
 				else if (r<0.7)
@@ -179,7 +133,7 @@
 				pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
 				break;
 			case WEP_ROCKET_LAUNCHER:
-				org2 = findbetterlocation (org, 16);
+				org2 = org + backoff * 16;
 				sound (self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
 				pointparticles(particleeffectnum("rocket_explode"), org2, '0 0 0', 1);
 				break;
@@ -191,12 +145,12 @@
 				pointparticles(particleeffectnum("nex_impact"), org - normalize(force) * 6, '0 0 0', 1);
 				break;
 			case WEP_HOOK:
-				org2 = findbetterlocation (org, 12);
+				org2 = org + backoff * 12;
 				sound (self, CHAN_PROJECTILE, "weapons/hookbomb_impact.wav", VOL_BASE, ATTN_NORM);
 				pointparticles(particleeffectnum("hookbomb_explode"), org2, '0 0 0', 1);
 				break;
 			case WEP_SEEKER:
-				org2 = findbetterlocation (org, 12);
+				org2 = org + backoff * 12;
 				if(secondary)
 				{
 					if (r<0.15)
@@ -236,13 +190,12 @@
 				}
 				break;
 			case WEP_HLAC:
-				org2 = findbetterlocation (org, 12);
+				org2 = org + backoff * 12;
 				sound (self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
-				pointparticles(particleeffectnum("laser_impact"), org2, trace_plane_normal * 1000, 1);
+				pointparticles(particleeffectnum("laser_impact"), org2, backoff * 1000, 1);
 				break;
 			case WEP_CAMPINGRIFLE:
-				org2 = findbetterlocation (org, 2);
-				pointparticles(particleeffectnum("machinegun_impact"), org, trace_plane_normal * 1000, 1);
+				pointparticles(particleeffectnum("machinegun_impact"), org, backoff * 1000, 1);
 				break;
 			default:
 				dprint("Unhandled damage of weapon ", ftos(hitwep), "\n");

Modified: trunk/data/qcsrc/server/g_damage.qc
===================================================================
--- trunk/data/qcsrc/server/g_damage.qc	2009-01-18 19:10:02 UTC (rev 5603)
+++ trunk/data/qcsrc/server/g_damage.qc	2009-01-18 19:22:38 UTC (rev 5604)
@@ -954,7 +954,7 @@
 	{
 		force = inflictor.velocity;
 		if(vlen(force) == 0)
-			force = '0 0 1';
+			force = '0 0 -1';
 		else
 			force = normalize(force) * forceintensity;
 		Damage_DamageInfo(blastorigin, coredamage, edgedamage, rad, forceintensity * force, deathtype);

Modified: trunk/data/qcsrc/server/w_common.qc
===================================================================
--- trunk/data/qcsrc/server/w_common.qc	2009-01-18 19:10:02 UTC (rev 5603)
+++ trunk/data/qcsrc/server/w_common.qc	2009-01-18 19:22:38 UTC (rev 5604)
@@ -120,12 +120,11 @@
 
 	f = pow(bound(0, vlen(self.velocity) / vlen(self.oldvelocity), 1), 2); // energy multiplier
 
-	Damage_DamageInfo(self.origin, self.dmg * f, 0, 0, self.dmg_force * normalize(self.velocity) * f, self.projectiledeathtype);
+	if(other.solid == SOLID_BSP)
+		Damage_DamageInfo(self.origin, self.dmg * f, 0, 0, self.dmg_force * normalize(self.velocity) * f, self.projectiledeathtype);
 
 	if(other && other != self.enemy)
 	{
-		self.enemy = other; // don't hit the same player twice with the same bullet
-
 		headshot = 0;
 		yoda = 0;
 		damage_headshotbonus = self.dmg_edge;
@@ -144,6 +143,8 @@
 
 		//sound (self, CHAN_PROJECTILE, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
 	}
+
+	self.enemy = other; // don't hit the same player twice with the same bullet
 }
 
 .void(void) W_BallisticBullet_LeaveSolid_think_save;
@@ -163,9 +164,12 @@
 	self.flags &~= FL_ONGROUND;
 	self.effects &~= EF_NODRAW;
 
-	float f;
-	f = pow(bound(0, vlen(self.velocity) / vlen(self.oldvelocity), 1), 2); // energy multiplier
-	Damage_DamageInfo(self.origin, 0, 0, 0, self.dmg_force * normalize(self.velocity) * f, self.projectiledeathtype);
+	if(self.enemy.solid == SOLID_BSP)
+	{
+		float f;
+		f = pow(bound(0, vlen(self.velocity) / vlen(self.oldvelocity), 1), 2); // energy multiplier
+		Damage_DamageInfo(self.origin, 0, 0, 0, self.dmg_force * normalize(self.velocity) * f, self.projectiledeathtype);
+	}
 	
 	UpdateCSQCProjectile(self);
 }




More information about the nexuiz-commits mailing list