Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
bobbing.qc
Go to the documentation of this file.
1#include "bobbing.qh"
2#ifdef SVQC
3.float height;
5{
6 vector v;
7 this.nextthink = time + 0.1;
8
9 if(this.owner.active != ACTIVE_ACTIVE)
10 {
11 this.owner.velocity = '0 0 0';
12 return;
13 }
14
15 // calculate sinewave using makevectors
16 makevectors((this.nextthink * this.owner.cnt + this.owner.phase * 360) * '0 1 0');
17 v = this.owner.destvec + this.owner.movedir * v_forward_y;
18 if(this.owner.classname == "func_bobbing") // don't brake stuff if the func_bobbing was killtarget'ed
19 // * 10 so it will arrive in 0.1 sec
20 this.owner.velocity = (v - this.owner.origin) * 10;
21}
22
23/*QUAKED spawnfunc_func_bobbing (0 .5 .8) ? X_AXIS Y_AXIS
24Brush model that moves back and forth on one axis (default Z).
25speed : how long one cycle takes in seconds (default 4)
26height : how far the cycle moves (default 32)
27phase : cycle timing adjustment (0-1 as a fraction of the cycle, default 0)
28noise : path/name of looping .wav file to play.
29dmg : Do this mutch dmg every .dmgtime intervall when blocked
30dmgtime : See above.
31*/
32spawnfunc(func_bobbing)
33{
34 entity controller;
35 if (this.noise != "")
36 {
39 }
40 if (!this.speed)
41 this.speed = 4;
42 if (!this.height)
43 this.height = 32;
44 // center of bobbing motion
45 this.destvec = this.origin;
46 // time scale to get degrees
47 this.cnt = 360 / this.speed;
48
49 this.active = ACTIVE_ACTIVE;
50
51 this.draggable = drag_undraggable;
52
53 // damage when blocked
55 if(this.dmg && (this.message == ""))
56 this.message = " was squished";
57 if(this.dmg && (this.message2 == ""))
58 this.message2 = "was squished by";
59 if(this.dmg && (!this.dmgtime))
60 this.dmgtime = 0.25;
61 this.dmgtime2 = time;
62
63 // how far to bob
64 if (this.spawnflags & BOBBING_XAXIS)
65 this.movedir = '1 0 0' * this.height;
66 else if (this.spawnflags & BOBBING_YAXIS)
67 this.movedir = '0 1 0' * this.height;
68 else // Z
69 this.movedir = '0 0 1' * this.height;
70
71 if (!InitMovingBrushTrigger(this))
72 return;
73
74 // wait for targets to spawn
75 controller = new_pure(func_bobbing_controller);
76 controller.owner = this;
77 controller.nextthink = time + 1;
79 this.nextthink = this.ltime + 999999999;
81
82 // Savage: Reduce bandwith, critical on e.g. nexdm02
84
85 // TODO make a reset function for this one
86}
87#endif
float height
Definition bobbing.qc:3
void func_bobbing_controller_think(entity this)
Definition bobbing.qc:4
const int BOBBING_YAXIS
Definition bobbing.qh:5
const int BOBBING_XAXIS
Definition bobbing.qh:4
float dmg
Definition breakable.qc:12
bool drag_undraggable(entity draggee, entity dragger)
Definition cheats.qc:903
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float cnt
Definition powerups.qc:24
string message
Definition powerups.qc:19
entity owner
Definition main.qh:87
int spawnflags
Definition ammo.qh:15
float effects
float time
float nextthink
vector origin
int active
Definition defs.qh:34
const int ACTIVE_ACTIVE
Definition defs.qh:37
float EF_LOWPRECISION
float speed
Definition dynlight.qc:9
vector movedir
Definition viewloc.qh:18
string precache_sound(string sample)
float MSG_INIT
Definition menudefs.qc:58
float ltime
Definition net.qc:10
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:67
void generic_plat_blocked(entity this, entity blocker)
Definition platforms.qc:3
float dmgtime
Definition platforms.qh:7
float dmgtime2
Definition platforms.qh:8
#define makevectors
Definition post.qh:21
#define setthink(e, f)
vector
Definition self.qh:92
#define setblocked(e, f)
const int CH_TRIGGER_SINGLE
Definition sound.qh:13
const float VOL_BASE
Definition sound.qh:36
const float ATTEN_IDLE
Definition sound.qh:32
void soundto(int _dest, entity e, int chan, string samp, float vol, float _atten, float _pitch)
Definition all.qc:74
#define spawnfunc(id)
Definition spawnfunc.qh:96
bool InitMovingBrushTrigger(entity this)
Definition subs.qc:577
void SUB_NullThink(entity this)
Definition subs.qc:3
vector destvec
Definition subs.qh:35
string noise
Definition subs.qh:83
string message2
Definition triggers.qh:19