From e37a6ae184a7977f0043b2653b6739b9843cc2af Mon Sep 17 00:00:00 2001 From: div0 Date: Fri, 9 Jan 2009 16:50:53 +0000 Subject: [PATCH] hooray! func_vectormamamam can now also project to planes, or to vectors! git-svn-id: svn://svn.icculus.org/nexuiz/trunk@5475 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/t_plats.qc | 93 ++++++++++++++++++++++-------------- data/scripts/entities.def | 11 ++++- 2 files changed, 68 insertions(+), 36 deletions(-) diff --git a/data/qcsrc/server/t_plats.qc b/data/qcsrc/server/t_plats.qc index c9d7fdc18..15b5fcdcf 100644 --- a/data/qcsrc/server/t_plats.qc +++ b/data/qcsrc/server/t_plats.qc @@ -1642,73 +1642,84 @@ void spawnfunc_func_fourier() .entity wp00, wp01, wp02, wp03; .float targetfactor, target2factor, target3factor, target4factor; +.vector targetnormal, target2normal, target3normal, target4normal; -void func_vectormamamam_controller_think() +vector func_vectormamamam_origin(entity o, float t) { - vector v; + vector v, p; + float f; entity e; - self.nextthink = time + 0.1; + f = o.spawnflags; + v = '0 0 0'; - v = self.owner.destvec; - - e = self.owner.wp00; + e = o.wp00; if(e) - v = v + e.origin + 0.1 * e.velocity; + { + p = e.origin + t * e.velocity; + if(f & 1) + v = v + (p * o.targetnormal) * o.targetnormal * o.targetfactor; + else + v = v + (p - (p * o.targetnormal) * o.targetnormal) * o.targetfactor; + } - e = self.owner.wp01; + e = o.wp01; if(e) - v = v + e.origin + 0.1 * e.velocity; + { + p = e.origin + t * e.velocity; + if(f & 2) + v = v + (p * o.target2normal) * o.target2normal * o.target2factor; + else + v = v + (p - (p * o.target2normal) * o.target2normal) * o.target2factor; + } - e = self.owner.wp02; + e = o.wp02; if(e) - v = v + e.origin + 0.1 * e.velocity; + { + p = e.origin + t * e.velocity; + if(f & 4) + v = v + (p * o.target3normal) * o.target3normal * o.target3factor; + else + v = v + (p - (p * o.target3normal) * o.target3normal) * o.target3factor; + } - e = self.owner.wp03; + e = o.wp03; if(e) - v = v + e.origin + 0.1 * e.velocity; + { + p = e.origin + t * e.velocity; + if(f & 8) + v = v + (p * o.target4normal) * o.target4normal * o.target4factor; + else + v = v + (p - (p * o.target4normal) * o.target4normal) * o.target4factor; + } - self.owner.velocity = (v - self.owner.origin) * 10; + return v; } -void func_vectormamamam_findtarget() +void func_vectormamamam_controller_think() { - vector s0; - - s0 = '0 0 0'; + self.nextthink = time + 0.1; + self.owner.velocity = (self.owner.destvec + func_vectormamamam_origin(self.owner, 0.1) - self.owner.origin) * 10; +} +void func_vectormamamam_findtarget() +{ if(self.target != "") - { self.wp00 = find(world, targetname, self.target); - if(self.wp00) - s0 = s0 + self.wp00.origin * self.targetfactor; - } if(self.target2 != "") - { self.wp01 = find(world, targetname, self.target2); - if(self.wp01) - s0 = s0 + self.wp01.origin * self.target2factor; - } if(self.target3 != "") - { self.wp02 = find(world, targetname, self.target3); - if(self.wp02) - s0 = s0 + self.wp02.origin * self.target3factor; - } if(self.target4 != "") - { self.wp03 = find(world, targetname, self.target4); - if(self.wp03) - s0 = s0 + self.wp03.origin * self.target4factor; - } if(!self.wp00 && !self.wp01 && !self.wp02 && !self.wp03) objerror("No reference entity found, so there is nothing to move. Aborting."); - self.destvec = self.origin - s0; + self.destvec = self.origin - func_vectormamamam_origin(self.owner, 0); local entity controller; controller = spawn(); @@ -1738,6 +1749,18 @@ void spawnfunc_func_vectormamamam() if(!self.target4factor) self.target4factor = 1; + if(vlen(self.targetnormal)) + self.targetnormal = normalize(self.targetnormal); + + if(vlen(self.target2normal)) + self.target2normal = normalize(self.target2normal); + + if(vlen(self.target3normal)) + self.target3normal = normalize(self.target3normal); + + if(vlen(self.target4normal)) + self.target4normal = normalize(self.target4normal); + self.blocked = generic_plat_blocked; if(self.dmg & (!self.message)) self.message = " was squished"; diff --git a/data/scripts/entities.def b/data/scripts/entities.def index b94ed7b01..b146f2d02 100644 --- a/data/scripts/entities.def +++ b/data/scripts/entities.def @@ -1333,20 +1333,29 @@ message2: death message when someone gets pushed into this (default: "was thrown netname: list of quadruples, separated by spaces; note that phase 0 represents a sine wave, and phase 0.25 a cosine wave (by default, it uses 1 0 0 0 1, to match func_bobbing's defaults */ -/*QUAKED func_vectormamamam (0 .5 .8) ? +/*QUAKED func_vectormamamam (0 .5 .8) ? PROJECT_ON_TARGETNORMAL TARGET2NORMAL_IS_DIRECTION TARGET3NORMAL_IS_DIRECTION TARGET4NORMAL_IS_DIRECTION Solid entity that moves according to the movement of multiple given entities (max 4) -------- KEYS -------- target: first reference entity targetfactor: factor by which to take the first reference entity (default 1). +targetnormal: if set, the first reference entity's location is first projected onto a plane with that normal target2: second reference entity target2factor: factor by which to take the second reference entity (default 1). +target2normal: if set, the second reference entity's location is first projected onto a plane with that normal target3: third reference entity (optional) target3factor: factor by which to take the third reference entity (default 1). +target3normal: if set, the third reference entity's location is first projected onto a plane with that normal target4: fourth reference entity (optional) target4factor: factor by which to take the fourth reference entity (default 1). +target4normal: if set, the fourth reference entity's location is first projected onto a plane with that normal noise: path/name of .wav or .ogg file to play. Use looping sounds only (e.g. sound/world/drone6.wav - See Notes). dmg: damage a player who gets crushed by it receives dmgtime: interval to apply dmg to a player who is s in the way message: death message when a player gets crushed message2: death message when someone gets pushed into this (default: "was thrown into a world of hurt by"). The # character is replaced by the attacker name if present (and it instead does not get appended to the end) +-------- SPAWNFLAGS -------- +PROJECT_ON_TARGETNORMAL: target's origin is projected onto the given direction vector, not on the plane perpendicular to it +PROJECT_ON_TARGET2NORMAL: target2's origin is projected onto the given direction vector, not on the plane perpendicular to it +PROJECT_ON_TARGET3NORMAL: target3's origin is projected onto the given direction vector, not on the plane perpendicular to it +PROJECT_ON_TARGET4NORMAL: target4's origin is projected onto the given direction vector, not on the plane perpendicular to it */ -- 2.39.2