r3845 - trunk/data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sat Jul 19 10:57:11 EDT 2008
Author: div0
Date: 2008-07-19 10:57:11 -0400 (Sat, 19 Jul 2008)
New Revision: 3845
Modified:
trunk/data/qcsrc/server/cl_impulse.qc
trunk/data/qcsrc/server/defs.qh
trunk/data/qcsrc/server/g_triggers.qc
Log:
add a rule for impulse 911 to not spawn above trigger_hurt entities
Modified: trunk/data/qcsrc/server/cl_impulse.qc
===================================================================
--- trunk/data/qcsrc/server/cl_impulse.qc 2008-07-18 07:33:01 UTC (rev 3844)
+++ trunk/data/qcsrc/server/cl_impulse.qc 2008-07-19 14:57:11 UTC (rev 3845)
@@ -299,6 +299,13 @@
if(trace_fraction * delta_z > 1024)
start = trace_endpos + '0 0 1024';
+ // rule 3: we must not end up in trigger_hurt
+ if(tracebox_hits_trigger_hurt(start, self.mins, self.maxs, trace_endpos))
+ {
+ dprint("trigger_hurt! ouch!\n");
+ continue;
+ }
+
// these can be traceLINES as we already verified the starting box
traceline(start, start + '1 0 0' * delta_x, MOVE_NORMAL, self);
if(trace_fraction >= 1)
Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh 2008-07-18 07:33:01 UTC (rev 3844)
+++ trunk/data/qcsrc/server/defs.qh 2008-07-19 14:57:11 UTC (rev 3845)
@@ -438,6 +438,7 @@
float sv_pogostick;
float sv_doublejump;
+float tracebox_hits_trigger_hurt(vector start, vector mi, vector ma, vector end);
float next_pingtime;
Modified: trunk/data/qcsrc/server/g_triggers.qc
===================================================================
--- trunk/data/qcsrc/server/g_triggers.qc 2008-07-18 07:33:01 UTC (rev 3844)
+++ trunk/data/qcsrc/server/g_triggers.qc 2008-07-19 14:57:11 UTC (rev 3845)
@@ -378,6 +378,9 @@
set dmg to damage amount
defalt dmg = 5
*/
+.entity trigger_hurt_next;
+entity trigger_hurt_last;
+entity trigger_hurt_first;
void spawnfunc_trigger_hurt()
{
InitTrigger ();
@@ -386,8 +389,75 @@
self.dmg = 1000;
if (!self.message)
self.message = "was in the wrong place.";
+
+ if(!trigger_hurt_first)
+ trigger_hurt_first = self;
+ if(trigger_hurt_last)
+ trigger_hurt_last.trigger_hurt_next = self;
+ trigger_hurt_last = self;
};
+float trace_hits_box_a0, trace_hits_box_a1;
+
+float trace_hits_box_1d(float end, float thmi, float thma)
+{
+ if(end == 0)
+ {
+ // just check if x is in range
+ if(0 < thmi)
+ return FALSE;
+ if(0 > thma)
+ return FALSE;
+ }
+ else
+ {
+ // do the trace with respect to x
+ // 0 -> end has to stay in thmi -> thma
+ trace_hits_box_a0 = max(trace_hits_box_a0, min(thmi / end, thma / end));
+ trace_hits_box_a1 = min(trace_hits_box_a1, max(thmi / end, thma / end));
+ if(trace_hits_box_a0 > trace_hits_box_a1)
+ return FALSE;
+ }
+ return TRUE;
+}
+
+float trace_hits_box(vector start, vector end, vector thmi, vector thma)
+{
+ end -= start;
+ thmi -= start;
+ thma -= start;
+ // now it is a trace from 0 to end
+
+ trace_hits_box_a0 = 0;
+ trace_hits_box_a1 = 1;
+
+ if(!trace_hits_box_1d(end_x, thmi_x, thma_x))
+ return FALSE;
+ if(!trace_hits_box_1d(end_y, thmi_y, thma_y))
+ return FALSE;
+ if(!trace_hits_box_1d(end_z, thmi_z, thma_z))
+ return FALSE;
+
+ return TRUE;
+}
+
+float tracebox_hits_box(vector start, vector mi, vector ma, vector end, vector thmi, vector thma)
+{
+ return trace_hits_box(start, end, thmi - ma, thma - mi);
+}
+
+float tracebox_hits_trigger_hurt(vector start, vector mi, vector ma, vector end)
+{
+ entity th;
+
+ for(th = trigger_hurt_first; th; th = th.trigger_hurt_next)
+ if(tracebox_hits_box(start, mi, ma, end, th.absmin, th.absmax))
+ return TRUE;
+
+ return FALSE;
+}
+
+
void target_speaker_use() {sound(self, CHAN_VOICE, self.noise, 1, 1);}
void spawnfunc_target_speaker()
More information about the nexuiz-commits
mailing list