]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/func/fourier.qc
take3: format 903 files
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / fourier.qc
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                 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                 makevectors((t * stof(argv(i * 5)) + stof(argv(i * 5 + 1)) * 360) * '0 1 0');
33                 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;
34         }
35
36         if (this.owner.classname == "func_fourier") { // don't brake stuff if the func_fourier was killtarget'ed
37                 // * 10 so it will arrive in 0.1 sec
38                 this.owner.velocity = (v - this.owner.origin) * 10;
39         }
40 }
41
42 spawnfunc(func_fourier)
43 {
44         entity controller;
45         if (this.noise != "") {
46                 precache_sound(this.noise);
47                 soundto(MSG_INIT, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
48         }
49
50         if (!this.speed) {
51                 this.speed = 4;
52         }
53         if (!this.height) {
54                 this.height = 32;
55         }
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         }
63         if (this.dmg && (this.message2 == "")) {
64                 this.message2 = "was squished by";
65         }
66         if (this.dmg && (!this.dmgtime)) {
67                 this.dmgtime = 0.25;
68         }
69         this.dmgtime2 = time;
70
71         if (this.netname == "") {
72                 this.netname = "1 0 0 0 1";
73         }
74
75         if (!InitMovingBrushTrigger(this)) {
76                 return;
77         }
78
79         this.active = ACTIVE_ACTIVE;
80
81         // wait for targets to spawn
82         controller = new(func_fourier_controller);
83         controller.owner = this;
84         controller.nextthink = time + 1;
85         setthink(controller, func_fourier_controller_think);
86         this.nextthink = this.ltime + 999999999;
87         setthink(this, SUB_NullThink); // for PushMove
88
89         // Savage: Reduce bandwith, critical on e.g. nexdm02
90         this.effects |= EF_LOWPRECISION;
91
92         // TODO make a reset function for this one
93 }
94 #endif