3 void func_bobbing_controller_think()
6 self.nextthink = time + 0.1;
8 if(self.owner.active != ACTIVE_ACTIVE)
10 self.owner.velocity = '0 0 0';
14 // calculate sinewave using makevectors
15 makevectors((self.nextthink * self.owner.cnt + self.owner.phase * 360) * '0 1 0');
16 v = self.owner.destvec + self.owner.movedir * v_forward_y;
17 if(self.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 self.owner.velocity = (v - self.owner.SUB_ORIGIN) * 10;
22 /*QUAKED spawnfunc_func_bobbing (0 .5 .8) ? X_AXIS Y_AXIS
23 Brush model that moves back and forth on one axis (default Z).
24 speed : how long one cycle takes in seconds (default 4)
25 height : how far the cycle moves (default 32)
26 phase : cycle timing adjustment (0-1 as a fraction of the cycle, default 0)
27 noise : path/name of looping .wav file to play.
28 dmg : Do this mutch dmg every .dmgtime intervall when blocked
31 spawnfunc(func_bobbing)
36 precache_sound(this.noise);
37 soundto(MSG_INIT, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
43 // center of bobbing motion
44 this.destvec = this.origin;
45 // time scale to get degrees
46 this.cnt = 360 / this.speed;
48 this.active = ACTIVE_ACTIVE;
50 // damage when blocked
51 this.blocked = generic_plat_blocked;
52 if(this.dmg && (this.message == ""))
53 this.message = " was squished";
54 if(this.dmg && (this.message2 == ""))
55 this.message2 = "was squished by";
56 if(this.dmg && (!this.dmgtime))
61 if (this.spawnflags & 1) // X
62 this.movedir = '1 0 0' * this.height;
63 else if (this.spawnflags & 2) // Y
64 this.movedir = '0 1 0' * this.height;
66 this.movedir = '0 0 1' * this.height;
68 if (!InitMovingBrushTrigger(this))
71 // wait for targets to spawn
72 controller = new(func_bobbing_controller);
73 controller.owner = this;
74 controller.nextthink = time + 1;
75 setthink(controller, func_bobbing_controller_think);
76 this.SUB_NEXTTHINK = this.SUB_LTIME + 999999999;
77 this.SUB_THINK = SUB_NullThink;
79 // Savage: Reduce bandwith, critical on e.g. nexdm02
80 this.effects |= EF_LOWPRECISION;
82 // TODO make a reset function for this one