X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ffunc%2Fvectormamamam.qc;h=61da52acbc483daef7c55c1e9d136000d7ace990;hp=5c2086477475abe8e6541374f1d6b12843a996a9;hb=bc50c2d7ca3e0a44ed1712400ef8e170e6df8210;hpb=719ba01817465b96db552e18c7f277721d8dbb7e diff --git a/qcsrc/common/triggers/func/vectormamamam.qc b/qcsrc/common/triggers/func/vectormamamam.qc index 5c2086477..61da52acb 100644 --- a/qcsrc/common/triggers/func/vectormamamam.qc +++ b/qcsrc/common/triggers/func/vectormamamam.qc @@ -1,3 +1,4 @@ +#include "vectormamamam.qh" #ifdef SVQC // reusing some fields havocbots declared .entity wp00, wp01, wp02, wp03; @@ -5,20 +6,20 @@ .float targetfactor, target2factor, target3factor, target4factor; .vector targetnormal, target2normal, target3normal, target4normal; -vector func_vectormamamam_origin(entity o, float t) +vector func_vectormamamam_origin(entity o, float timestep) { vector v, p; - float f; + float flags; entity e; - f = o.spawnflags; + flags = o.spawnflags; v = '0 0 0'; e = o.wp00; if(e) { - p = e.origin + t * e.velocity; - if(f & 1) + p = e.origin + timestep * e.velocity; + if(flags & PROJECT_ON_TARGETNORMAL) v = v + (p * o.targetnormal) * o.targetnormal * o.targetfactor; else v = v + (p - (p * o.targetnormal) * o.targetnormal) * o.targetfactor; @@ -27,8 +28,8 @@ vector func_vectormamamam_origin(entity o, float t) e = o.wp01; if(e) { - p = e.origin + t * e.velocity; - if(f & 2) + p = e.origin + timestep * e.velocity; + if(flags & PROJECT_ON_TARGET2NORMAL) v = v + (p * o.target2normal) * o.target2normal * o.target2factor; else v = v + (p - (p * o.target2normal) * o.target2normal) * o.target2factor; @@ -37,8 +38,8 @@ vector func_vectormamamam_origin(entity o, float t) e = o.wp02; if(e) { - p = e.origin + t * e.velocity; - if(f & 4) + p = e.origin + timestep * e.velocity; + if(flags & PROJECT_ON_TARGET3NORMAL) v = v + (p * o.target3normal) * o.target3normal * o.target3factor; else v = v + (p - (p * o.target3normal) * o.target3normal) * o.target3factor; @@ -47,8 +48,8 @@ vector func_vectormamamam_origin(entity o, float t) e = o.wp03; if(e) { - p = e.origin + t * e.velocity; - if(f & 8) + p = e.origin + timestep * e.velocity; + if(flags & PROJECT_ON_TARGET4NORMAL) v = v + (p * o.target4normal) * o.target4normal * o.target4factor; else v = v + (p - (p * o.target4normal) * o.target4normal) * o.target4factor; @@ -57,102 +58,137 @@ vector func_vectormamamam_origin(entity o, float t) return v; } -void func_vectormamamam_controller_think() -{SELFPARAM(); - self.nextthink = time + 0.1; +void func_vectormamamam_controller_think(entity this) +{ + this.nextthink = time + vectormamamam_timestep; - if(self.owner.active != ACTIVE_ACTIVE) + if(this.owner.active != ACTIVE_ACTIVE) { - self.owner.velocity = '0 0 0'; + this.owner.velocity = '0 0 0'; return; } - if(self.owner.classname == "func_vectormamamam") // don't brake stuff if the func_vectormamamam was killtarget'ed - self.owner.velocity = (self.owner.destvec + func_vectormamamam_origin(self.owner, 0.1) - self.owner.origin) * 10; + if(this.owner.classname == "func_vectormamamam") // don't brake stuff if the func_vectormamamam was killtarget'ed + this.owner.velocity = (this.owner.destvec + func_vectormamamam_origin(this.owner, vectormamamam_timestep) - this.owner.origin) * 10; } -void func_vectormamamam_findtarget() -{SELFPARAM(); - if(self.target != "") - self.wp00 = find(world, targetname, self.target); +void func_vectormamamam_findtarget(entity this) +{ + if(this.target != "") + this.wp00 = find(NULL, targetname, this.target); - if(self.target2 != "") - self.wp01 = find(world, targetname, self.target2); + if(this.target2 != "") + this.wp01 = find(NULL, targetname, this.target2); - if(self.target3 != "") - self.wp02 = find(world, targetname, self.target3); + if(this.target3 != "") + this.wp02 = find(NULL, targetname, this.target3); - if(self.target4 != "") - self.wp03 = find(world, targetname, self.target4); + if(this.target4 != "") + this.wp03 = find(NULL, targetname, this.target4); - if(!self.wp00 && !self.wp01 && !self.wp02 && !self.wp03) - objerror("No reference entity found, so there is nothing to move. Aborting."); + if(!this.wp00 && !this.wp01 && !this.wp02 && !this.wp03) + objerror(this, "No reference entity found, so there is nothing to move. Aborting."); - self.destvec = self.origin - func_vectormamamam_origin(self, 0); + this.destvec = this.origin - func_vectormamamam_origin(this, 0); entity controller; controller = new(func_vectormamamam_controller); - controller.owner = self; + controller.owner = this; controller.nextthink = time + 1; - controller.think = func_vectormamamam_controller_think; + setthink(controller, func_vectormamamam_controller_think); } -spawnfunc(func_vectormamamam) +void func_vectormamamam_setactive(entity this, int astate) +{ + if (astate == ACTIVE_TOGGLE) + { + if(this.active == ACTIVE_ACTIVE) + this.active = ACTIVE_NOT; + else + this.active = ACTIVE_ACTIVE; + } + else + this.active = astate; + + if(this.active == ACTIVE_NOT) + { + stopsound(this, CH_TRIGGER_SINGLE); + } + else + { + if(this.noise && this.noise != "") + { + _sound(this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE); + } + } +} + +void func_vectormamamam_init_for_player(entity this, entity player) { - if (self.noise != "") + if (this.noise && this.noise != "" && this.active == ACTIVE_ACTIVE && IS_REAL_CLIENT(player)) { - precache_sound(self.noise); - soundto(MSG_INIT, self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_IDLE); + msg_entity = player; + soundto(MSG_ONE, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE); } +} - if(!self.targetfactor) - self.targetfactor = 1; +spawnfunc(func_vectormamamam) +{ + if (this.noise != "") + { + precache_sound(this.noise); + } - if(!self.target2factor) - self.target2factor = 1; + if(!this.targetfactor) + this.targetfactor = 1; - if(!self.target3factor) - self.target3factor = 1; + if(!this.target2factor) + this.target2factor = 1; - if(!self.target4factor) - self.target4factor = 1; + if(!this.target3factor) + this.target3factor = 1; - if(vlen(self.targetnormal)) - self.targetnormal = normalize(self.targetnormal); + if(!this.target4factor) + this.target4factor = 1; - if(vlen(self.target2normal)) - self.target2normal = normalize(self.target2normal); + if(this.targetnormal) + this.targetnormal = normalize(this.targetnormal); - if(vlen(self.target3normal)) - self.target3normal = normalize(self.target3normal); + if(this.target2normal) + this.target2normal = normalize(this.target2normal); - if(vlen(self.target4normal)) - self.target4normal = normalize(self.target4normal); + if(this.target3normal) + this.target3normal = normalize(this.target3normal); - self.blocked = generic_plat_blocked; - if(self.dmg && (self.message == "")) - self.message = " was squished"; - if(self.dmg && (self.message == "")) - self.message2 = "was squished by"; - if(self.dmg && (!self.dmgtime)) - self.dmgtime = 0.25; - self.dmgtime2 = time; + if(this.target4normal) + this.target4normal = normalize(this.target4normal); - if(self.netname == "") - self.netname = "1 0 0 0 1"; + setblocked(this, generic_plat_blocked); + if(this.dmg && (this.message == "")) + this.message = " was squished"; + if(this.dmg && (this.message == "")) + this.message2 = "was squished by"; + if(this.dmg && (!this.dmgtime)) + this.dmgtime = 0.25; + this.dmgtime2 = time; - if (!InitMovingBrushTrigger()) + if (!InitMovingBrushTrigger(this)) return; // wait for targets to spawn - self.SUB_NEXTTHINK = self.SUB_LTIME + 999999999; - self.SUB_THINK = SUB_NullThink; // for PushMove + this.nextthink = this.ltime + 999999999; + setthink(this, SUB_NullThink); // for PushMove // Savage: Reduce bandwith, critical on e.g. nexdm02 - self.effects |= EF_LOWPRECISION; + this.effects |= EF_LOWPRECISION; + + this.setactive = func_vectormamamam_setactive; + this.setactive(this, ACTIVE_ACTIVE); - self.active = ACTIVE_ACTIVE; + // maybe send sound to new players + IL_PUSH(g_initforplayer, this); + this.init_for_player = func_vectormamamam_init_for_player; - InitializeEntity(self, func_vectormamamam_findtarget, INITPRIO_FINDTARGET); + InitializeEntity(this, func_vectormamamam_findtarget, INITPRIO_FINDTARGET); } #endif