[nexuiz-commits] r6700 - in trunk/data: . qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun May 10 14:56:07 EDT 2009


Author: div0
Date: 2009-05-10 14:56:07 -0400 (Sun, 10 May 2009)
New Revision: 6700

Modified:
   trunk/data/defaultNexuiz.cfg
   trunk/data/qcsrc/server/cl_client.qc
   trunk/data/qcsrc/server/cl_weaponsystem.qc
   trunk/data/qcsrc/server/defs.qh
   trunk/data/qcsrc/server/g_world.qc
   trunk/data/qcsrc/server/w_campingrifle.qc
Log:
hitplot writing


Modified: trunk/data/defaultNexuiz.cfg
===================================================================
--- trunk/data/defaultNexuiz.cfg	2009-05-10 15:25:17 UTC (rev 6699)
+++ trunk/data/defaultNexuiz.cfg	2009-05-10 18:56:07 UTC (rev 6700)
@@ -1521,6 +1521,8 @@
 set cl_effects_lightningarc_branchfactor_start 0.25
 set cl_effects_lightningarc_branchfactor_add 0.1
 
+set g_hitplots 0 "when set to 1, hitplots are stored by the server to provide a means of proving that a triggerbot was used"
+
 rcon_secure 1
 
 set menu_updatecheck 1

Modified: trunk/data/qcsrc/server/cl_client.qc
===================================================================
--- trunk/data/qcsrc/server/cl_client.qc	2009-05-10 15:25:17 UTC (rev 6699)
+++ trunk/data/qcsrc/server/cl_client.qc	2009-05-10 18:56:07 UTC (rev 6700)
@@ -1350,6 +1350,14 @@
 		stuffcmd(self, strcat("\nfog ", world.fog, "\nr_fog_exp2 0\nr_drawfog 1\n"));
 
 	SoundEntity_Attach(self);
+
+	if(cvar("g_hitplots"))
+	{
+		self.hitplotfh = fopen(strcat("hits-", matchid, "-", ftos(self.playerid), ".plot"), FILE_WRITE);
+		fputs(self.hitplotfh, strcat("#name ", self.netname, "\n"));
+	}
+	else
+		self.hitplotfh = -1;
 }
 
 /*
@@ -1370,6 +1378,9 @@
 		return;
 	}
 
+	fclose(self.hitplotfh);
+	self.hitplotfh = -1;
+
 	bot_clientdisconnect();
 
 	if(self.entcs)

Modified: trunk/data/qcsrc/server/cl_weaponsystem.qc
===================================================================
--- trunk/data/qcsrc/server/cl_weaponsystem.qc	2009-05-10 15:25:17 UTC (rev 6699)
+++ trunk/data/qcsrc/server/cl_weaponsystem.qc	2009-05-10 18:56:07 UTC (rev 6700)
@@ -25,6 +25,72 @@
 
 void(float fr, float t, void() func) weapon_thinkf;
 
+vector W_HitPlotUnnormalizedUntransform(vector screenforward, vector screenright, vector screenup, vector v)
+{
+	vector ret;
+	ret_x = screenright * v;
+	ret_y = screenup * v;
+	ret_z = screenforward * v;
+	return ret;
+}
+
+vector W_HitPlotNormalizedUntransform(vector org, entity targ, vector screenforward, vector screenright, vector screenup, vector v)
+{
+	float i, j, k;
+	vector mi, ma, thisv, myv, ret;
+
+	myv = W_HitPlotUnnormalizedUntransform(screenforward, screenright, screenup, org);
+
+	// x = 0..1 relative to hitbox; y = 0..1 relative to hitbox; z = distance
+
+	for(i = 0; i < 2; ++i) for(j = 0; j < 2; ++j) for(k = 0; k < 2; ++k)
+	{
+		thisv = targ.origin;
+		if(i) thisv_x += targ.maxs_z; else thisv_x += targ.mins_x;
+		if(j) thisv_y += targ.maxs_z; else thisv_y += targ.mins_y;
+		if(k) thisv_z += targ.maxs_z; else thisv_z += targ.mins_z;
+		thisv = W_HitPlotUnnormalizedUntransform(screenforward, screenright, screenup, thisv);
+		if(i || j || k)
+		{
+			if(mi_x > thisv_x) mi_x = thisv_x; if(ma_x < thisv_x) ma_x = thisv_x;
+			if(mi_y > thisv_y) mi_y = thisv_y; if(ma_y < thisv_y) ma_y = thisv_y;
+			//if(mi_z > thisv_z) mi_z = thisv_z; if(ma_z < thisv_z) ma_y = thisv_z;
+		}
+		else
+		{
+			// first run
+			mi = ma = thisv;
+		}
+	}
+
+	thisv = W_HitPlotUnnormalizedUntransform(screenforward, screenright, screenup, v);
+	ret_x = (thisv_x - mi_x) / (ma_x - mi_x);
+	ret_y = (thisv_y - mi_y) / (ma_y - mi_y);
+	ret_z = thisv_z - myv_z;
+	return ret;
+}
+
+void W_HitPlotAnalysis(entity player, vector screenforward, vector screenright, vector screenup)
+{
+	vector hitplot; 
+	vector org;
+	float lag;
+
+	if(player.hitplotfh >= 0)
+	{
+		lag = ANTILAG_LATENCY(player);
+		org = player.origin + player.view_ofs;
+		traceline_antilag_force(player, org, org + screenforward * MAX_SHOT_DISTANCE, MOVE_NORMAL, player, lag);
+		if(trace_ent.flags & FL_CLIENT)
+		{
+			antilag_takeback(player, time - lag);
+			hitplot = W_HitPlotNormalizedUntransform(org, trace_ent, screenforward, screenright, screenup, trace_endpos);
+			antilag_restore(player);
+			fputs(player.hitplotfh, strcat(ftos(hitplot_x), " ", ftos(hitplot_y), " ", ftos(hitplot_z), "\n"));
+		}
+	}
+}
+
 vector w_shotorg;
 vector w_shotdir;
 
@@ -42,6 +108,8 @@
 	traceline(ent.origin + ent.view_ofs, ent.origin + ent.view_ofs + v_forward * MAX_SHOT_DISTANCE, MOVE_NOMONSTERS, ent);
 	trueaimpoint = trace_endpos;
 
+	W_HitPlotAnalysis(ent, v_forward, v_right, v_up);
+
 	if(ent.weaponentity.movedir_x > 0)
 	{
 		vecs = ent.weaponentity.movedir;

Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh	2009-05-10 15:25:17 UTC (rev 6699)
+++ trunk/data/qcsrc/server/defs.qh	2009-05-10 18:56:07 UTC (rev 6700)
@@ -577,3 +577,6 @@
 .float floodcontrol_voiceteam;
 
 .float stat_shotorg; // networked stat for trueaim HUD
+
+string matchid;
+.float hitplotfh;

Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc	2009-05-10 15:25:17 UTC (rev 6699)
+++ trunk/data/qcsrc/server/g_world.qc	2009-05-10 18:56:07 UTC (rev 6700)
@@ -504,6 +504,8 @@
 	{
 		s = strcat(cvar_string("sv_eventlog_files_counter"), ".");
 		s = strcat(s, ftos(random()));
+		matchid = strzone(s);
+
 		GameLogEcho(strcat(":gamestart:", GetGametype(), "_", GetMapname(), ":", s));
 		s = ":gameinfo:mutators:LIST";
 		if(cvar("g_grappling_hook"))
@@ -531,6 +533,8 @@
 		GameLogEcho(s);
 		GameLogEcho(":gameinfo:end");
 	}
+	else
+		matchid = strzone(ftos(random()));
 
 	cvar_set("nextmap", "");
 

Modified: trunk/data/qcsrc/server/w_campingrifle.qc
===================================================================
--- trunk/data/qcsrc/server/w_campingrifle.qc	2009-05-10 15:25:17 UTC (rev 6699)
+++ trunk/data/qcsrc/server/w_campingrifle.qc	2009-05-10 18:56:07 UTC (rev 6700)
@@ -52,9 +52,9 @@
 		self.ammo_nails -= pAmmo;
 
 	if(deathtype & HITTYPE_SECONDARY)
-		W_SetupShot (self, FALSE, 2, "weapons/campingrifle_fire2.wav");
+		W_SetupShot (self, TRUE, 2, "weapons/campingrifle_fire2.wav");
 	else
-		W_SetupShot (self, FALSE, 2, "weapons/campingrifle_fire.wav");
+		W_SetupShot (self, TRUE, 2, "weapons/campingrifle_fire.wav");
 
 	pointparticles(particleeffectnum("shotgun_muzzleflash"), w_shotorg, w_shotdir * 2000, 1);
 



More information about the nexuiz-commits mailing list