]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/func/vectormamamam.qc
take3: format 903 files
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / vectormamamam.qc
1 #include "vectormamamam.qh"
2 #ifdef SVQC
3 // reusing some fields havocbots declared
4 .entity wp00, wp01, wp02, wp03;
5
6 .float targetfactor, target2factor, target3factor, target4factor;
7 .vector targetnormal, target2normal, target3normal, target4normal;
8
9 vector func_vectormamamam_origin(entity o, float t)
10 {
11         vector v, p;
12         float f;
13         entity e;
14
15         f = o.spawnflags;
16         v = '0 0 0';
17
18         e = o.wp00;
19         if (e) {
20                 p = e.origin + t * e.velocity;
21                 if (f & 1) {
22                         v = v + (p * o.targetnormal) * o.targetnormal * o.targetfactor;
23                 } else {
24                         v = v + (p - (p * o.targetnormal) * o.targetnormal) * o.targetfactor;
25                 }
26         }
27
28         e = o.wp01;
29         if (e) {
30                 p = e.origin + t * e.velocity;
31                 if (f & 2) {
32                         v = v + (p * o.target2normal) * o.target2normal * o.target2factor;
33                 } else {
34                         v = v + (p - (p * o.target2normal) * o.target2normal) * o.target2factor;
35                 }
36         }
37
38         e = o.wp02;
39         if (e) {
40                 p = e.origin + t * e.velocity;
41                 if (f & 4) {
42                         v = v + (p * o.target3normal) * o.target3normal * o.target3factor;
43                 } else {
44                         v = v + (p - (p * o.target3normal) * o.target3normal) * o.target3factor;
45                 }
46         }
47
48         e = o.wp03;
49         if (e) {
50                 p = e.origin + t * e.velocity;
51                 if (f & 8) {
52                         v = v + (p * o.target4normal) * o.target4normal * o.target4factor;
53                 } else {
54                         v = v + (p - (p * o.target4normal) * o.target4normal) * o.target4factor;
55                 }
56         }
57
58         return v;
59 }
60
61 void func_vectormamamam_controller_think(entity this)
62 {
63         this.nextthink = time + 0.1;
64
65         if (this.owner.active != ACTIVE_ACTIVE) {
66                 this.owner.velocity = '0 0 0';
67                 return;
68         }
69
70         if (this.owner.classname == "func_vectormamamam") { // don't brake stuff if the func_vectormamamam was killtarget'ed
71                 this.owner.velocity = (this.owner.destvec + func_vectormamamam_origin(this.owner, 0.1) - this.owner.origin) * 10;
72         }
73 }
74
75 void func_vectormamamam_findtarget(entity this)
76 {
77         if (this.target != "") {
78                 this.wp00 = find(NULL, targetname, this.target);
79         }
80
81         if (this.target2 != "") {
82                 this.wp01 = find(NULL, targetname, this.target2);
83         }
84
85         if (this.target3 != "") {
86                 this.wp02 = find(NULL, targetname, this.target3);
87         }
88
89         if (this.target4 != "") {
90                 this.wp03 = find(NULL, targetname, this.target4);
91         }
92
93         if (!this.wp00 && !this.wp01 && !this.wp02 && !this.wp03) {
94                 objerror(this, "No reference entity found, so there is nothing to move. Aborting.");
95         }
96
97         this.destvec = this.origin - func_vectormamamam_origin(this, 0);
98
99         entity controller;
100         controller = new(func_vectormamamam_controller);
101         controller.owner = this;
102         controller.nextthink = time + 1;
103         setthink(controller, func_vectormamamam_controller_think);
104 }
105
106 spawnfunc(func_vectormamamam)
107 {
108         if (this.noise != "") {
109                 precache_sound(this.noise);
110                 soundto(MSG_INIT, this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_IDLE);
111         }
112
113         if (!this.targetfactor) {
114                 this.targetfactor = 1;
115         }
116
117         if (!this.target2factor) {
118                 this.target2factor = 1;
119         }
120
121         if (!this.target3factor) {
122                 this.target3factor = 1;
123         }
124
125         if (!this.target4factor) {
126                 this.target4factor = 1;
127         }
128
129         if (this.targetnormal) {
130                 this.targetnormal = normalize(this.targetnormal);
131         }
132
133         if (this.target2normal) {
134                 this.target2normal = normalize(this.target2normal);
135         }
136
137         if (this.target3normal) {
138                 this.target3normal = normalize(this.target3normal);
139         }
140
141         if (this.target4normal) {
142                 this.target4normal = normalize(this.target4normal);
143         }
144
145         setblocked(this, generic_plat_blocked);
146         if (this.dmg && (this.message == "")) {
147                 this.message = " was squished";
148         }
149         if (this.dmg && (this.message == "")) {
150                 this.message2 = "was squished by";
151         }
152         if (this.dmg && (!this.dmgtime)) {
153                 this.dmgtime = 0.25;
154         }
155         this.dmgtime2 = time;
156
157         if (this.netname == "") {
158                 this.netname = "1 0 0 0 1";
159         }
160
161         if (!InitMovingBrushTrigger(this)) {
162                 return;
163         }
164
165         // wait for targets to spawn
166         this.nextthink = this.ltime + 999999999;
167         setthink(this, SUB_NullThink); // for PushMove
168
169         // Savage: Reduce bandwith, critical on e.g. nexdm02
170         this.effects |= EF_LOWPRECISION;
171
172         this.active = ACTIVE_ACTIVE;
173
174         InitializeEntity(this, func_vectormamamam_findtarget, INITPRIO_FINDTARGET);
175 }
176 #endif