Xonotic
fourier.qc
Go to the documentation of this file.
1 #include "fourier.qh"
2 #ifdef SVQC
3 /*QUAKED spawnfunc_func_fourier (0 .5 .8) ?
4 Brush model that moves in a pattern of added up sine waves, can be used e.g. for circular motions.
5 netname: list of <frequencymultiplier> <phase> <x> <y> <z> quadruples, separated by spaces; note that phase 0 represents a sine wave, and phase 0.25 a cosine wave (by default, it uses 1 0 0 0 1, to match func_bobbing's defaults
6 speed: how long one cycle of frequency multiplier 1 in seconds (default 4)
7 height: amplitude modifier (default 32)
8 phase: cycle timing adjustment (0-1 as a fraction of the cycle, default 0)
9 noise: path/name of looping .wav file to play.
10 dmg: Do this mutch dmg every .dmgtime intervall when blocked
11 dmgtime: See above.
12 */
13 
14 void func_fourier_controller_think(entity this)
15 {
16  vector v;
17  float n, i, t;
18 
19  this.nextthink = time + 0.1;
20  if(this.owner.active != ACTIVE_ACTIVE)
21  {
22  this.owner.velocity = '0 0 0';
23  return;
24  }
25 
26 
27  n = floor((tokenize_console(this.owner.netname)) / 5);
28  t = this.nextthink * this.owner.cnt + this.owner.phase * 360;
29 
30  v = this.owner.destvec;
31 
32  for(i = 0; i < n; ++i)
33  {
34  makevectors((t * stof(argv(i*5)) + stof(argv(i*5+1)) * 360) * '0 1 0');
35  v = v + ('1 0 0' * stof(argv(i*5+2)) + '0 1 0' * stof(argv(i*5+3)) + '0 0 1' * stof(argv(i*5+4))) * this.owner.height * v_forward_y;
36  }
37 
38  if(this.owner.classname == "func_fourier") // don't brake stuff if the func_fourier was killtarget'ed
39  // * 10 so it will arrive in 0.1 sec
40  this.owner.velocity = (v - this.owner.origin) * 10;
41 }
42 
43 spawnfunc(func_fourier)
44 {
45  entity controller;
46  if (this.noise != "")
47  {
48  precache_sound(this.noise);
49  soundto(MSG_INIT, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE, 0);
50  }
51 
52  if (!this.speed)
53  this.speed = 4;
54  if (!this.height)
55  this.height = 32;
56  this.destvec = this.origin;
57  this.cnt = 360 / this.speed;
58 
59  setblocked(this, generic_plat_blocked);
60  if(this.dmg && (this.message == ""))
61  this.message = " was squished";
62  if(this.dmg && (this.message2 == ""))
63  this.message2 = "was squished by";
64  if(this.dmg && (!this.dmgtime))
65  this.dmgtime = 0.25;
66  this.dmgtime2 = time;
67 
68  if(this.netname == "")
69  this.netname = "1 0 0 0 1";
70 
71  if (!InitMovingBrushTrigger(this))
72  return;
73 
74  this.active = ACTIVE_ACTIVE;
75 
76  // wait for targets to spawn
77  controller = new_pure(func_fourier_controller);
78  controller.owner = this;
79  controller.nextthink = time + 1;
80  setthink(controller, func_fourier_controller_think);
81  this.nextthink = this.ltime + 999999999;
82  setthink(this, SUB_NullThink); // for PushMove
83 
84  // Savage: Reduce bandwith, critical on e.g. nexdm02
85  this.effects |= EF_LOWPRECISION;
86 
87  // TODO make a reset function for this one
88 }
89 #endif
float speed
Definition: subs.qh:41
string noise
Definition: progsdefs.qc:209
vector destvec
Definition: subs.qh:35
entity() spawn
string netname
Definition: powerups.qc:20
float dmg
Definition: platforms.qh:6
spawnfunc(info_player_attacker)
Definition: sv_assault.qc:283
origin
Definition: ent_cs.qc:114
float ltime
Definition: progsdefs.qc:107
float effects
Definition: csprogsdefs.qc:111
entity owner
Definition: main.qh:73
float cnt
Definition: powerups.qc:24
float height
Definition: jumppads.qh:12
const int ACTIVE_ACTIVE
Definition: defs.qh:37
string message
Definition: powerups.qc:19
const float VOL_BASE
Definition: sound.qh:36
float nextthink
Definition: csprogsdefs.qc:121
const int CH_TRIGGER_SINGLE
Definition: sound.qh:13
vector(float skel, float bonenum) _skel_get_boneabs_hidden
void SUB_NullThink(entity this)
Definition: subs.qc:3
#define tokenize_console
Definition: dpextensions.qh:24
float dmgtime
Definition: platforms.qh:7
vector v
Definition: ent_cs.qc:116
float dmgtime2
Definition: platforms.qh:8
void generic_plat_blocked(entity this, entity blocker)
Definition: platforms.qc:3
int active
Definition: defs.qh:34
#define new_pure(class)
purely logical entities (.origin doesn&#39;t work)
Definition: oo.qh:62
#define setthink(e, f)
float time
Definition: csprogsdefs.qc:16
#define makevectors
Definition: post.qh:21
float EF_LOWPRECISION
const float ATTEN_IDLE
Definition: sound.qh:32