r2341 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Apr 18 13:32:07 EDT 2007


Author: div0
Date: 2007-04-18 13:32:07 -0400 (Wed, 18 Apr 2007)
New Revision: 2341

Modified:
   trunk/data/qcsrc/server/bots.qc
   trunk/data/qcsrc/server/miscfunctions.qc
Log:
move waypoints out of solid when needed;
when following an attached entity, follow its owner


Modified: trunk/data/qcsrc/server/bots.qc
===================================================================
--- trunk/data/qcsrc/server/bots.qc	2007-04-18 17:29:52 UTC (rev 2340)
+++ trunk/data/qcsrc/server/bots.qc	2007-04-18 17:32:07 UTC (rev 2341)
@@ -586,7 +586,10 @@
 	w.classname = "waypoint";
 	w.wpflags = f;
 	setorigin(w, org);
+	setsize(w, PL_MIN + m1, PL_MAX + m2);
+	move_out_of_solid(w);
 	setsize(w, m1, m2);
+
 	waypoint_clearlinks(w);
 	//waypoint_schedulerelink(w);
 	return w;
@@ -941,6 +944,8 @@
 	local float dist, bestdist;
 	local vector v, org;
 	org = player.origin + (player.mins_z - PL_MIN_z) * '0 0 1';
+	if(player.tag_entity)
+		org = org + player.tag_entity.origin;
 	if (navigation_testtracewalk)
 		te_plasmaburn(org);
 	best = world;

Modified: trunk/data/qcsrc/server/miscfunctions.qc
===================================================================
--- trunk/data/qcsrc/server/miscfunctions.qc	2007-04-18 17:29:52 UTC (rev 2340)
+++ trunk/data/qcsrc/server/miscfunctions.qc	2007-04-18 17:32:07 UTC (rev 2341)
@@ -1,3 +1,51 @@
+void move_out_of_solid_expand(entity e, vector by)
+{
+	float eps = 0.0625;
+	tracebox(e.origin, e.mins - '1 1 1' * eps, e.maxs + '1 1 1' * eps, e.origin + by, MOVE_WORLDONLY, e);
+	if(trace_startsolid)
+		error("could not get out of solid");
+	if(trace_fraction < 1)
+	{
+		// hit something
+		// adjust origin in the other direction...
+		e.origin = e.origin - by * (1 - trace_fraction);
+	}
+	return by;
+}
+
+void move_out_of_solid(entity e)
+{
+	vector o, m0, m1, mnew;
+
+	o = e.origin;
+	traceline(o, o, MOVE_WORLDONLY, e);
+	if(trace_startsolid)
+	{
+		print("origin is in solid too!");
+		return;
+	}
+
+	tracebox(o, e.mins, e.maxs, o, MOVE_WORLDONLY, e);
+	if(!trace_startsolid)
+		return;
+
+	m0 = e.mins;
+	m1 = e.maxs;
+	e.mins = '0 0 0';
+	e.maxs = '0 0 0';
+	move_out_of_solid_expand(e, '1 0 0' * m0_x); e.mins_x = m0_x;
+	move_out_of_solid_expand(e, '1 0 0' * m1_x); e.maxs_x = m1_x;
+	move_out_of_solid_expand(e, '0 1 0' * m0_y); e.mins_y = m0_y;
+	move_out_of_solid_expand(e, '0 1 0' * m1_y); e.maxs_y = m1_y;
+	move_out_of_solid_expand(e, '0 0 1' * m0_z); e.mins_z = m0_z;
+	move_out_of_solid_expand(e, '0 0 1' * m1_z); e.maxs_z = m1_z;
+	setorigin(e, e.origin);
+
+	tracebox(e.origin, e.mins, e.maxs, e.origin, MOVE_WORLDONLY, e);
+	if(trace_startsolid)
+		error("could not get out of solid");
+}
+
 // converts a number to a string with the indicated number of decimals
 // works for up to 10 decimals!
 string ftos_decimals(float number, float decimals)




More information about the nexuiz-commits mailing list