4 void func_pendulum_controller_think(entity this)
7 this.nextthink = time + 0.1;
9 if (!(this.owner.active == ACTIVE_ACTIVE))
11 this.owner.avelocity_x = 0;
15 // calculate sinewave using makevectors
16 makevectors((this.nextthink * this.owner.freq + this.owner.phase) * '0 360 0');
17 v = this.owner.speed * v_forward_y + this.cnt;
18 if(this.owner.classname == "func_pendulum") // don't brake stuff if the func_bobbing was killtarget'ed
20 // * 10 so it will arrive in 0.1 sec
21 this.owner.avelocity_z = (remainder(v - this.owner.angles_z, 360)) * 10;
25 spawnfunc(func_pendulum)
30 precache_sound(this.noise);
31 soundto(MSG_INIT, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
34 this.active = ACTIVE_ACTIVE;
36 // keys: angle, speed, phase, noise, freq
40 // not initializing this.dmg to 2, to allow damageless pendulum
42 if(this.dmg && (this.message == ""))
43 this.message = " was squished";
44 if(this.dmg && (this.message2 == ""))
45 this.message2 = "was squished by";
46 if(this.dmg && (!this.dmgtime))
50 setblocked(this, generic_plat_blocked);
52 this.avelocity_z = 0.0000001;
53 if (!InitMovingBrushTrigger(this))
58 // find pendulum length (same formula as Q3A)
59 this.freq = 1 / (M_PI * 2) * sqrt(autocvar_sv_gravity / (3 * max(8, fabs(this.mins_z))));
63 this.cnt = this.angles_z;
65 // wait for targets to spawn
66 controller = new(func_pendulum_controller);
67 controller.owner = this;
68 controller.nextthink = time + 1;
69 setthink(controller, func_pendulum_controller_think);
70 this.nextthink = this.ltime + 999999999;
71 setthink(this, SUB_NullThink); // for PushMove
73 //this.effects |= EF_LOWPRECISION;
75 // TODO make a reset function for this one