]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/func/vectormamamam.qc
Merge branch 'master' into terencehill/menu_gametype_tooltips_2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / vectormamamam.qc
1 #ifdef SVQC
2 // reusing some fields havocbots declared
3 .entity wp00, wp01, wp02, wp03;
4
5 .float targetfactor, target2factor, target3factor, target4factor;
6 .vector targetnormal, target2normal, target3normal, target4normal;
7
8 vector func_vectormamamam_origin(entity o, float t)
9 {
10         vector v, p;
11         float f;
12         entity e;
13
14         f = o.spawnflags;
15         v = '0 0 0';
16
17         e = o.wp00;
18         if(e)
19         {
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         e = o.wp01;
28         if(e)
29         {
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         e = o.wp02;
38         if(e)
39         {
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         e = o.wp03;
48         if(e)
49         {
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         return v;
58 }
59
60 void func_vectormamamam_controller_think()
61 {SELFPARAM();
62         self.nextthink = time + 0.1;
63
64         if(self.owner.active != ACTIVE_ACTIVE)
65         {
66                 self.owner.velocity = '0 0 0';
67                 return;
68         }
69
70         if(self.owner.classname == "func_vectormamamam") // don't brake stuff if the func_vectormamamam was killtarget'ed
71                 self.owner.velocity = (self.owner.destvec + func_vectormamamam_origin(self.owner, 0.1) - self.owner.origin) * 10;
72 }
73
74 void func_vectormamamam_findtarget()
75 {SELFPARAM();
76         if(self.target != "")
77                 self.wp00 = find(world, targetname, self.target);
78
79         if(self.target2 != "")
80                 self.wp01 = find(world, targetname, self.target2);
81
82         if(self.target3 != "")
83                 self.wp02 = find(world, targetname, self.target3);
84
85         if(self.target4 != "")
86                 self.wp03 = find(world, targetname, self.target4);
87
88         if(!self.wp00 && !self.wp01 && !self.wp02 && !self.wp03)
89                 objerror("No reference entity found, so there is nothing to move. Aborting.");
90
91         self.destvec = self.origin - func_vectormamamam_origin(self, 0);
92
93         entity controller;
94         controller = spawn();
95         controller.classname = "func_vectormamamam_controller";
96         controller.owner = self;
97         controller.nextthink = time + 1;
98         controller.think = func_vectormamamam_controller_think;
99 }
100
101 spawnfunc(func_vectormamamam)
102 {
103         if (self.noise != "")
104         {
105                 precache_sound(self.noise);
106                 soundto(MSG_INIT, self, CH_TRIGGER_SINGLE, self.noise, VOL_BASE, ATTEN_IDLE);
107         }
108
109         if(!self.targetfactor)
110                 self.targetfactor = 1;
111
112         if(!self.target2factor)
113                 self.target2factor = 1;
114
115         if(!self.target3factor)
116                 self.target3factor = 1;
117
118         if(!self.target4factor)
119                 self.target4factor = 1;
120
121         if(vlen(self.targetnormal))
122                 self.targetnormal = normalize(self.targetnormal);
123
124         if(vlen(self.target2normal))
125                 self.target2normal = normalize(self.target2normal);
126
127         if(vlen(self.target3normal))
128                 self.target3normal = normalize(self.target3normal);
129
130         if(vlen(self.target4normal))
131                 self.target4normal = normalize(self.target4normal);
132
133         self.blocked = generic_plat_blocked;
134         if(self.dmg && (self.message == ""))
135                 self.message = " was squished";
136     if(self.dmg && (self.message == ""))
137                 self.message2 = "was squished by";
138         if(self.dmg && (!self.dmgtime))
139                 self.dmgtime = 0.25;
140         self.dmgtime2 = time;
141
142         if(self.netname == "")
143                 self.netname = "1 0 0 0 1";
144
145         if (!InitMovingBrushTrigger())
146                 return;
147
148         // wait for targets to spawn
149         self.SUB_NEXTTHINK = self.SUB_LTIME + 999999999;
150         self.SUB_THINK = SUB_NullThink; // for PushMove
151
152         // Savage: Reduce bandwith, critical on e.g. nexdm02
153         self.effects |= EF_LOWPRECISION;
154
155         self.active = ACTIVE_ACTIVE;
156
157         InitializeEntity(self, func_vectormamamam_findtarget, INITPRIO_FINDTARGET);
158 }
159 #endif