X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmapobjects%2Ffunc%2Fbobbing.qc;fp=qcsrc%2Fcommon%2Fmapobjects%2Ffunc%2Fbobbing.qc;h=b647e15a826e48164f03db46c5f62114a8e6afc6;hp=0000000000000000000000000000000000000000;hb=fbd313c7ceb26a09310d8062926f4ac2468623a8;hpb=15560a4a494efe42e0e5fa69a628eebc11d97fc7 diff --git a/qcsrc/common/mapobjects/func/bobbing.qc b/qcsrc/common/mapobjects/func/bobbing.qc new file mode 100644 index 000000000..b647e15a8 --- /dev/null +++ b/qcsrc/common/mapobjects/func/bobbing.qc @@ -0,0 +1,85 @@ +#include "bobbing.qh" +#ifdef SVQC +.float height; +void func_bobbing_controller_think(entity this) +{ + vector v; + this.nextthink = time + 0.1; + + if(this.owner.active != ACTIVE_ACTIVE) + { + this.owner.velocity = '0 0 0'; + return; + } + + // calculate sinewave using makevectors + makevectors((this.nextthink * this.owner.cnt + this.owner.phase * 360) * '0 1 0'); + v = this.owner.destvec + this.owner.movedir * v_forward_y; + if(this.owner.classname == "func_bobbing") // don't brake stuff if the func_bobbing was killtarget'ed + // * 10 so it will arrive in 0.1 sec + this.owner.velocity = (v - this.owner.origin) * 10; +} + +/*QUAKED spawnfunc_func_bobbing (0 .5 .8) ? X_AXIS Y_AXIS +Brush model that moves back and forth on one axis (default Z). +speed : how long one cycle takes in seconds (default 4) +height : how far the cycle moves (default 32) +phase : cycle timing adjustment (0-1 as a fraction of the cycle, default 0) +noise : path/name of looping .wav file to play. +dmg : Do this mutch dmg every .dmgtime intervall when blocked +dmgtime : See above. +*/ +spawnfunc(func_bobbing) +{ + entity controller; + if (this.noise != "") + { + precache_sound(this.noise); + soundto(MSG_INIT, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE); + } + if (!this.speed) + this.speed = 4; + if (!this.height) + this.height = 32; + // center of bobbing motion + this.destvec = this.origin; + // time scale to get degrees + this.cnt = 360 / this.speed; + + this.active = ACTIVE_ACTIVE; + + // damage when blocked + setblocked(this, generic_plat_blocked); + if(this.dmg && (this.message == "")) + this.message = " was squished"; + if(this.dmg && (this.message2 == "")) + this.message2 = "was squished by"; + if(this.dmg && (!this.dmgtime)) + this.dmgtime = 0.25; + this.dmgtime2 = time; + + // how far to bob + if (this.spawnflags & BOBBING_XAXIS) + this.movedir = '1 0 0' * this.height; + else if (this.spawnflags & BOBBING_YAXIS) + this.movedir = '0 1 0' * this.height; + else // Z + this.movedir = '0 0 1' * this.height; + + if (!InitMovingBrushTrigger(this)) + return; + + // wait for targets to spawn + controller = new(func_bobbing_controller); + controller.owner = this; + controller.nextthink = time + 1; + setthink(controller, func_bobbing_controller_think); + this.nextthink = this.ltime + 999999999; + setthink(this, SUB_NullThink); + + // Savage: Reduce bandwith, critical on e.g. nexdm02 + this.effects |= EF_LOWPRECISION; + + // TODO make a reset function for this one +} +#endif