]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/func/fourier.qc
Merge branch 'master' into terencehill/infomessages_panel_update
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / fourier.qc
1 #ifdef SVQC
2 /*QUAKED spawnfunc_func_fourier (0 .5 .8) ?
3 Brush model that moves in a pattern of added up sine waves, can be used e.g. for circular motions.
4 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
5 speed: how long one cycle of frequency multiplier 1 in seconds (default 4)
6 height: amplitude modifier (default 32)
7 phase: cycle timing adjustment (0-1 as a fraction of the cycle, default 0)
8 noise: path/name of looping .wav file to play.
9 dmg: Do this mutch dmg every .dmgtime intervall when blocked
10 dmgtime: See above.
11 */
12
13 void func_fourier_controller_think(entity this)
14 {
15         vector v;
16         float n, i, t;
17
18         this.nextthink = time + 0.1;
19         if(this.owner.active != ACTIVE_ACTIVE)
20         {
21                 this.owner.velocity = '0 0 0';
22                 return;
23         }
24
25
26         n = floor((tokenize_console(this.owner.netname)) / 5);
27         t = this.nextthink * this.owner.cnt + this.owner.phase * 360;
28
29         v = this.owner.destvec;
30
31         for(i = 0; i < n; ++i)
32         {
33                 makevectors((t * stof(argv(i*5)) + stof(argv(i*5+1)) * 360) * '0 1 0');
34                 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;
35         }
36
37         if(this.owner.classname == "func_fourier") // don't brake stuff if the func_fourier was killtarget'ed
38                 // * 10 so it will arrive in 0.1 sec
39                 this.owner.velocity = (v - this.owner.origin) * 10;
40 }
41
42 spawnfunc(func_fourier)
43 {
44         entity controller;
45         if (this.noise != "")
46         {
47                 precache_sound(this.noise);
48                 soundto(MSG_INIT, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
49         }
50
51         if (!this.speed)
52                 this.speed = 4;
53         if (!this.height)
54                 this.height = 32;
55         this.destvec = this.origin;
56         this.cnt = 360 / this.speed;
57
58         setblocked(this, generic_plat_blocked);
59         if(this.dmg && (this.message == ""))
60                 this.message = " was squished";
61     if(this.dmg && (this.message2 == ""))
62                 this.message2 = "was squished by";
63         if(this.dmg && (!this.dmgtime))
64                 this.dmgtime = 0.25;
65         this.dmgtime2 = time;
66
67         if(this.netname == "")
68                 this.netname = "1 0 0 0 1";
69
70         if (!InitMovingBrushTrigger(this))
71                 return;
72
73         this.active = ACTIVE_ACTIVE;
74
75         // wait for targets to spawn
76         controller = new(func_fourier_controller);
77         controller.owner = this;
78         controller.nextthink = time + 1;
79         setthink(controller, func_fourier_controller_think);
80         this.SUB_NEXTTHINK = this.SUB_LTIME + 999999999;
81         SUB_THINK(this, SUB_NullThink); // for PushMove
82
83         // Savage: Reduce bandwith, critical on e.g. nexdm02
84         this.effects |= EF_LOWPRECISION;
85
86         // TODO make a reset function for this one
87 }
88 #endif