From: Rudolf Polzer Date: Sun, 31 Oct 2010 21:20:53 +0000 (+0100) Subject: func_pendulum X-Git-Tag: xonotic-v0.1.0preview~219 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0297ce23b1f759dbebeca6c2af8656969302e6c7;p=xonotic%2Fxonotic-data.pk3dir.git func_pendulum --- diff --git a/qcsrc/server/t_plats.qc b/qcsrc/server/t_plats.qc index 553f19558..fed2480dc 100644 --- a/qcsrc/server/t_plats.qc +++ b/qcsrc/server/t_plats.qc @@ -487,6 +487,78 @@ void spawnfunc_func_bobbing() // TODO make a reset function for this one }; +.float freq; +void func_pendulum_controller_think() +{ + local float v; + self.nextthink = time + 0.1; + + if not (self.owner.active == ACTIVE_ACTIVE) + { + self.owner.avelocity_x = 0; + return; + } + + // calculate sinewave using makevectors + makevectors((self.nextthink * self.owner.freq + self.owner.phase) * '0 360 0'); + v = self.owner.speed * v_forward_y; + if(self.owner.classname == "func_pendulum") // don't brake stuff if the func_bobbing was killtarget'ed + { + // * 10 so it will arrive in 0.1 sec + self.owner.avelocity_x = (remainder(v - self.owner.angles_x, 360)) * 10; + } +}; + +void spawnfunc_func_pendulum() +{ + local entity controller; + if (self.noise != "") + { + precache_sound(self.noise); + soundto(MSG_INIT, self, CHAN_TRIGGER, self.noise, VOL_BASE, ATTN_IDLE); + } + + self.active = ACTIVE_ACTIVE; + + // keys: angle, speed, phase, noise, freq + + if(!self.speed) + self.speed = 30; + // not initializing self.dmg to 2, to allow damageless pendulum + + if(self.dmg & (!self.message)) + self.message = " was squished"; + if(self.dmg && (!self.message2)) + self.message2 = "was squished by"; + if(self.dmg && (!self.dmgtime)) + self.dmgtime = 0.25; + self.dmgtime2 = time; + + self.blocked = generic_plat_blocked; + + if not(InitMovingBrushTrigger()) + return; + + if(!self.freq) + { + // find pendulum length (same formula as Q3A) + self.freq = 1 / (M_PI * 2) * sqrt(cvar("sv_gravity") / (3 * fabs(self.mins_z))); + } + + // wait for targets to spawn + controller = spawn(); + controller.classname = "func_pendulum_controller"; + controller.owner = self; + controller.nextthink = time + 1; + controller.think = func_pendulum_controller_think; + self.nextthink = self.ltime + 999999999; + self.think = SUB_Null; + + //self.effects |= EF_LOWPRECISION; + + // TODO make a reset function for this one +}; + // button and multiple button void() button_wait;