4 void func_bobbing_controller_think(entity this)
7 this.nextthink = time + 0.1;
9 if (this.owner.active != ACTIVE_ACTIVE) {
10 this.owner.velocity = '0 0 0';
14 // calculate sinewave using makevectors
15 makevectors((this.nextthink * this.owner.cnt + this.owner.phase * 360) * '0 1 0');
16 v = this.owner.destvec + this.owner.movedir * v_forward_y;
17 if (this.owner.classname == "func_bobbing") { // don't brake stuff if the func_bobbing was killtarget'ed
18 // * 10 so it will arrive in 0.1 sec
19 this.owner.velocity = (v - this.owner.origin) * 10;
23 /*QUAKED spawnfunc_func_bobbing (0 .5 .8) ? X_AXIS Y_AXIS
24 Brush model that moves back and forth on one axis (default Z).
25 speed : how long one cycle takes in seconds (default 4)
26 height : how far the cycle moves (default 32)
27 phase : cycle timing adjustment (0-1 as a fraction of the cycle, default 0)
28 noise : path/name of looping .wav file to play.
29 dmg : Do this mutch dmg every .dmgtime intervall when blocked
32 spawnfunc(func_bobbing)
35 if (this.noise != "") {
36 precache_sound(this.noise);
37 soundto(MSG_INIT, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
45 // center of bobbing motion
46 this.destvec = this.origin;
47 // time scale to get degrees
48 this.cnt = 360 / this.speed;
50 this.active = ACTIVE_ACTIVE;
52 // damage when blocked
53 setblocked(this, generic_plat_blocked);
54 if (this.dmg && (this.message == "")) {
55 this.message = " was squished";
57 if (this.dmg && (this.message2 == "")) {
58 this.message2 = "was squished by";
60 if (this.dmg && (!this.dmgtime)) {
66 if (this.spawnflags & 1) { // X
67 this.movedir = '1 0 0' * this.height;
68 } else if (this.spawnflags & 2) { // Y
69 this.movedir = '0 1 0' * this.height;
71 this.movedir = '0 0 1' * this.height;
74 if (!InitMovingBrushTrigger(this)) {
78 // wait for targets to spawn
79 controller = new(func_bobbing_controller);
80 controller.owner = this;
81 controller.nextthink = time + 1;
82 setthink(controller, func_bobbing_controller_think);
83 this.nextthink = this.ltime + 999999999;
84 setthink(this, SUB_NullThink);
86 // Savage: Reduce bandwith, critical on e.g. nexdm02
87 this.effects |= EF_LOWPRECISION;
89 // TODO make a reset function for this one