From 83589324bab8f1fea92c9bcb715d1f253b966620 Mon Sep 17 00:00:00 2001 From: tzork Date: Fri, 9 May 2008 07:44:02 +0000 Subject: [PATCH] Added trigger_impulse (for wind tunnel -like effects and for damper / accelerator fields) git-svn-id: svn://svn.icculus.org/nexuiz/trunk@3618 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/entities.def | 15 ++++-- data/qcsrc/server/g_triggers.qc | 95 +++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 5 deletions(-) diff --git a/data/entities.def b/data/entities.def index d1ca700d5..352cb11d5 100644 --- a/data/entities.def +++ b/data/entities.def @@ -685,13 +685,18 @@ To make a jump pad or launch ramp, place the target_position/info_notnull entity //============================================================================= -/*QUAKED trigger_force (.5 .5 .5) ? -Similar to trigger_push, but adds force to the target as long as it is within the trigger. +/*QUAKED trigger_impulse (.5 .5 .5) ? -------- KEYS -------- -target : this points to the target_position to which the player will get pushed. +target : If this is set, this points to the target_position to which the player will get pushed. + If not, this trigger acts like a damper/accelerator field. + strength : This is how mutch force to add in the direction of .target each second + when .target is set. If not, this is hoe mutch to slow down/accelerate + someting cought inside this trigger. + -------- NOTES -------- -Use a brush textured with common/origin in the trigger to determine the origin of the force +Use a brush textured with common/origin in the trigger entity to determine the origin of the force +in directional push mode. For damper/accelerator mode this is no nessesary (and has no effect). */ //============================================================================= @@ -955,4 +960,4 @@ none // trigger_delay // trigger_once // trigger_swamp -// waypoint +// waypoint diff --git a/data/qcsrc/server/g_triggers.qc b/data/qcsrc/server/g_triggers.qc index f207ed53c..11d260c0f 100644 --- a/data/qcsrc/server/g_triggers.qc +++ b/data/qcsrc/server/g_triggers.qc @@ -624,3 +624,98 @@ void() misc_laser = self.think = misc_laser_think; self.nextthink = time; } + +.float strength; +.float lastpushtime; +void trigger_impulse_touch1() +{ + entity targ; + float pushdeltatime; + + // FIXME: Better checking for what to push and not. + if (other.classname != "player") + if (other.classname != "corpse") + if (other.classname != "body") + if (other.classname != "gib") + if (other.classname != "missile") + if (other.classname != "casing") + if (other.classname != "grenade") + if (other.classname != "plasma") + if (other.classname != "plasma_prim") + if (other.classname != "plasma_chain") + if (other.classname != "droppedweapon") + return; + + if (other.deadflag && other.classname == "player") + return; + + targ = find(world, targetname, self.target); + if(!targ) + { + objerror("trigger_force without a (valif) .target!\n"); + remove(self); + return; + } + + + pushdeltatime = time - other.lastpushtime; + if (pushdeltatime > 0.15) pushdeltatime = 0; + other.lastpushtime = time; + if(!pushdeltatime) return; + + other.velocity = other.velocity + normalize(targ.origin - self.origin) * self.strength * pushdeltatime; +} + +void trigger_impulse_touch2() +{ + + // FIXME: Better checking for what to push and not. + if (other.classname != "player") + if (other.classname != "corpse") + if (other.classname != "body") + if (other.classname != "gib") + if (other.classname != "missile") + if (other.classname != "casing") + if (other.classname != "grenade") + if (other.classname != "plasma") + if (other.classname != "plasma_prim") + if (other.classname != "plasma_chain") + if (other.classname != "droppedweapon") + return; + + if (other.deadflag && other.classname == "player") + return; + + other.velocity = other.velocity * self.strength; +} + + +/*QUAKED trigger_impulse (.5 .5 .5) ? +-------- KEYS -------- +target : If this is set, this points to the target_position to which the player will get pushed. + If not, this trigger acts like a damper/accelerator field. + +strength : This is how mutch force to add in the direction of .target each second + when .target is set. If not, this is hoe mutch to slow down/accelerate + someting cought inside this trigger. (1=no change, 0,5 half speed rougthly each tic, 2 = doubble) + +-------- NOTES -------- +Use a brush textured with common/origin in the trigger entity to determine the origin of the force +in directional push mode. For damper/accelerator mode this is no nessesary (and has no effect). +*/ + +void trigger_impulse() +{ + InitTrigger (); + if(self.target) + { + if(!self.strength) self.strength = 950; + self.touch = trigger_impulse_touch1; + } + else + { + if(!self.strength) self.strength = 0.9; + self.touch = trigger_impulse_touch2; + } +} + -- 2.39.2