From 4fc5e66f118e766e6e232b74a97b557270f4e578 Mon Sep 17 00:00:00 2001 From: div0 Date: Mon, 21 Jul 2008 14:25:16 +0000 Subject: [PATCH] undo the part of the trigger_impulse commit that removed the trigger_hurt list code git-svn-id: svn://svn.icculus.org/nexuiz/trunk@3866 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/g_triggers.qc | 76 ++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/data/qcsrc/server/g_triggers.qc b/data/qcsrc/server/g_triggers.qc index c0e7f078d..c93e83e27 100644 --- a/data/qcsrc/server/g_triggers.qc +++ b/data/qcsrc/server/g_triggers.qc @@ -378,6 +378,9 @@ Any object touching this will be hurt 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 @@ void spawnfunc_trigger_hurt() 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() @@ -735,10 +805,12 @@ void trigger_impulse_touch3() setsize(self, '-1 -1 -1' * self.radius,'1 1 1' * self.radius); + str = min(self.radius, vlen(self.origin - other.origin)); + if(self.falloff == 1) - str = (str / self.radius) * self.strength; + str = (1 - str / self.radius) * self.strength; // 1 in the inside else if(self.falloff == 2) - str = (1 - (str / self.radius)) * self.strength; + str = (str / self.radius) * self.strength; // 0 in the inside else str = self.strength; -- 2.39.2