]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/g_subs.qc
make the SUB_CalcMove controller think every frame. This increases smoothness and...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_subs.qc
1 void SUB_Null() {};
2 float SUB_True() { return 1; }
3 float SUB_False() { return 0; }
4
5 void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove;
6 void()  SUB_CalcMoveDone;
7 void() SUB_CalcAngleMoveDone;
8 //void() SUB_UseTargets;
9 void() SUB_Remove;
10
11 void spawnfunc_info_null (void)
12 {
13         remove(self);
14         // if anything breaks, tell the mapper to fix his map! info_null is meant to remove itself immediately.
15 }
16
17 void setanim(entity e, vector anim, float looping, float override, float restart)
18 {
19         if (anim_x == e.animstate_startframe)
20         if (anim_y == e.animstate_numframes)
21         if (anim_z == e.animstate_framerate)
22         {
23                 if(restart)
24                 {
25                         if(restart > 0)
26                         if(anim_y == 1) // ZYM animation
27                                 BITXOR_ASSIGN(e.effects, EF_RESTARTANIM_BIT);
28                 }
29                 else
30                         return;
31         }
32         e.animstate_startframe = anim_x;
33         e.animstate_numframes = anim_y;
34         e.animstate_framerate = anim_z;
35         e.animstate_starttime = servertime - 0.1 * serverframetime; // shift it a little bit into the past to prevent float inaccuracy hiccups
36         e.animstate_endtime = e.animstate_starttime + e.animstate_numframes / e.animstate_framerate;
37         e.animstate_looping = looping;
38         e.animstate_override = override;
39         e.frame = e.animstate_startframe;
40         e.frame1time = servertime;
41 };
42
43 void updateanim(entity e)
44 {
45         if (time >= e.animstate_endtime)
46         {
47                 if (e.animstate_looping)
48                 {
49                         e.animstate_starttime = e.animstate_endtime;
50                         e.animstate_endtime = e.animstate_starttime + e.animstate_numframes / e.animstate_framerate;
51                 }
52                 e.animstate_override = FALSE;
53         }
54         e.frame = e.animstate_startframe + bound(0, (time - e.animstate_starttime) * e.animstate_framerate, e.animstate_numframes - 1);
55         //print(ftos(time), " -> ", ftos(e.frame), "\n");
56 };
57
58 float animparseerror;
59 vector animparseline(float animfile)
60 {
61         local string line;
62         local float c;
63         local vector anim;
64         if (animfile < 0)
65                 return '0 1 2';
66         line = fgets(animfile);
67         c = tokenize_console(line);
68         if (c < 3)
69         {
70                 animparseerror = TRUE;
71                 return '0 1 2';
72         }
73         anim_x = stof(argv(0));
74         anim_y = stof(argv(1));
75         anim_z = stof(argv(2));
76         // don't allow completely bogus values
77         if (anim_x < 0 || anim_y < 1 || anim_z < 0.001)
78                 anim = '0 1 2';
79         return anim;
80 };
81
82 /*
83 ==================
84 SUB_Remove
85
86 Remove self
87 ==================
88 */
89 void SUB_Remove (void)
90 {
91         remove (self);
92 }
93
94 /*
95 ==================
96 SUB_Friction
97
98 Applies some friction to self
99 ==================
100 */
101 .float friction;
102 void SUB_Friction (void)
103 {
104         self.nextthink = time;
105         if(self.flags & FL_ONGROUND)
106                 self.velocity = self.velocity * (1 - frametime * self.friction);
107 }
108
109 /*
110 ==================
111 SUB_VanishOrRemove
112
113 Makes client invisible or removes non-client
114 ==================
115 */
116 void SUB_VanishOrRemove (entity ent)
117 {
118         if (ent.flags & FL_CLIENT)
119         {
120                 // vanish
121                 ent.model = "";
122                 ent.effects = 0;
123                 ent.glow_size = 0;
124                 ent.pflags = 0;
125         }
126         else
127         {
128                 // remove
129                 remove (ent);
130         }
131 }
132
133 void SUB_SetFade_Think (void)
134 {
135         self.think = SUB_SetFade_Think;
136         self.nextthink = self.fade_time;
137         self.alpha = 1 - (time - self.fade_time) * self.fade_rate;
138         if (self.alpha < 0.01)
139                 SUB_VanishOrRemove(self);
140         self.alpha = bound(0.01, self.alpha, 1);
141 }
142
143 /*
144 ==================
145 SUB_SetFade
146
147 Fade 'ent' out when time >= 'when'
148 ==================
149 */
150 void SUB_SetFade (entity ent, float when, float fadetime)
151 {
152         //if (ent.flags & FL_CLIENT) // && ent.deadflag != DEAD_NO)
153         //      return;
154         //ent.alpha = 1;
155         ent.fade_rate = 1/fadetime;
156         ent.fade_time = when;
157         ent.think = SUB_SetFade_Think;
158         ent.nextthink = when;
159 }
160
161 /*
162 =============
163 SUB_CalcMove
164
165 calculate self.velocity and self.nextthink to reach dest from
166 self.origin traveling at speed
167 ===============
168 */
169 void SUB_CalcMoveDone (void)
170 {
171         // After moving, set origin to exact final destination
172
173         setorigin (self, self.finaldest);
174         self.velocity = '0 0 0';
175         self.nextthink = -1;
176         if (self.think1)
177                 self.think1 ();
178 }
179
180 void SUB_CalcMove_controller_think (void)
181 {
182         entity oldself;
183         float traveltime;
184         float phasepos;
185         float nexttick;
186         vector delta;
187         vector veloc;
188         vector nextpos;
189         if(time < self.animstate_endtime) {
190                 delta = self.destvec;
191                 nexttick = time + sys_frametime;
192
193                 if(nexttick < self.animstate_endtime) {
194                         traveltime = self.animstate_endtime - self.animstate_starttime;
195                         phasepos = (nexttick - self.animstate_starttime) / traveltime; // range: [0, 1]
196                         phasepos = 3.14159265 + (phasepos * 3.14159265); // range: [pi, 2pi]
197                         phasepos = cos(phasepos); // cos [pi, 2pi] is in [-1, 1]
198                         phasepos = phasepos + 1; // correct range to [0, 2]
199                         phasepos = phasepos / 2; // correct range to [0, 1]
200                         nextpos = self.origin + (delta * phasepos);
201
202                         veloc = nextpos - self.owner.origin;
203                         veloc = veloc * (1 / sys_frametime); // so it arrives for the next frame
204
205                 } else {
206                         veloc = self.finaldest - self.owner.origin;
207                         veloc = veloc * (1 / sys_frametime); // so it arrives for the next frame
208                 }
209                 self.owner.velocity = veloc;
210                 self.nextthink = nexttick;
211         } else {
212                 oldself = self;
213                 self.owner.think = self.think1;
214                 self = self.owner;
215                 remove(oldself);
216                 self.think();
217         }
218 }
219
220 void SUB_CalcMove (vector tdest, float tspeed, void() func)
221 {
222         vector  delta;
223         float   traveltime;
224         entity controller;
225
226         if (!tspeed)
227                 objerror ("No speed is defined!");
228
229         self.think1 = func;
230         self.finaldest = tdest;
231         self.think = SUB_CalcMoveDone;
232
233         if (tdest == self.origin)
234         {
235                 self.velocity = '0 0 0';
236                 self.nextthink = self.ltime + 0.1;
237                 return;
238         }
239
240         delta = tdest - self.origin;
241         traveltime = vlen (delta) / tspeed;
242
243         if (traveltime < 0.1)
244         {
245                 self.velocity = '0 0 0';
246                 self.nextthink = self.ltime + 0.1;
247                 return;
248         }
249
250         // very short animations don't really show off the effect
251         // of controlled animation, so let's just use linear movement
252         if (traveltime < 0.15)
253         {
254                 self.velocity = delta * (1/traveltime); // QuakeC doesn't allow vector/float division
255                 self.nextthink = self.ltime + traveltime;
256                 return;
257         }
258
259         controller = spawn();
260         controller.classname = "SUB_CalcMove_controller";
261         controller.owner = self;
262         controller.origin = self.origin; // starting point
263         controller.finaldest = tdest; // where do we want to end?
264         controller.destvec = delta;
265         controller.animstate_starttime = time;
266         controller.animstate_endtime = time + traveltime;
267         controller.think = SUB_CalcMove_controller_think;
268         controller.think1 = self.think;
269
270         // the thinking is now done by the controller
271         self.think = SUB_Null;
272         self.nextthink = self.ltime + traveltime;
273         
274         // invoke controller
275         self = controller;
276         self.think();
277         self = self.owner;
278 }
279
280 void SUB_CalcMoveEnt (entity ent, vector tdest, float tspeed, void() func)
281 {
282         entity  oldself;
283
284         oldself = self;
285         self = ent;
286
287         SUB_CalcMove (tdest, tspeed, func);
288
289         self = oldself;
290 }
291
292 /*
293 =============
294 SUB_CalcAngleMove
295
296 calculate self.avelocity and self.nextthink to reach destangle from
297 self.angles rotating
298
299 The calling function should make sure self.think is valid
300 ===============
301 */
302 void SUB_CalcAngleMoveDone (void)
303 {
304         // After rotating, set angle to exact final angle
305         self.angles = self.finalangle;
306         self.avelocity = '0 0 0';
307         self.nextthink = -1;
308         if (self.think1)
309                 self.think1 ();
310 }
311
312 // FIXME: I fixed this function only for rotation around the main axes
313 void SUB_CalcAngleMove (vector destangle, float tspeed, void() func)
314 {
315         vector  delta;
316         float   traveltime;
317
318         if (!tspeed)
319                 objerror ("No speed is defined!");
320
321         // take the shortest distance for the angles
322         self.angles_x -= 360 * floor((self.angles_x - destangle_x) / 360 + 0.5);
323         self.angles_y -= 360 * floor((self.angles_y - destangle_y) / 360 + 0.5);
324         self.angles_z -= 360 * floor((self.angles_z - destangle_z) / 360 + 0.5);
325         delta = destangle - self.angles;
326         traveltime = vlen (delta) / tspeed;
327
328         self.think1 = func;
329         self.finalangle = destangle;
330         self.think = SUB_CalcAngleMoveDone;
331
332         if (traveltime < 0.1)
333         {
334                 self.avelocity = '0 0 0';
335                 self.nextthink = self.ltime + 0.1;
336                 return;
337         }
338
339         self.avelocity = delta * (1 / traveltime);
340         self.nextthink = self.ltime + traveltime;
341 }
342
343 void SUB_CalcAngleMoveEnt (entity ent, vector destangle, float tspeed, void() func)
344 {
345         entity  oldself;
346
347         oldself = self;
348         self = ent;
349
350         SUB_CalcAngleMove (destangle, tspeed, func);
351
352         self = oldself;
353 }
354
355 /*
356 ==================
357 main
358
359 unused but required by the engine
360 ==================
361 */
362 void main (void)
363 {
364
365 }
366
367 // Misc
368
369 /*
370 ==================
371 traceline_antilag
372
373 A version of traceline that must be used by SOLID_SLIDEBOX things that want to hit SOLID_CORPSE things with a trace attack
374 Additionally it moves players back into the past before the trace and restores them afterward.
375 ==================
376 */
377 void tracebox_antilag_force_wz (entity source, vector v1, vector mi, vector ma, vector v2, float nomonst, entity forent, float lag, float wz)
378 {
379         local entity player;
380         local float oldsolid;
381
382         // check whether antilagged traces are enabled
383         if (lag < 0.001)
384                 lag = 0;
385         if (clienttype(forent) != CLIENTTYPE_REAL)
386                 lag = 0; // only antilag for clients
387
388         // change shooter to SOLID_BBOX so the shot can hit corpses
389         if(source)
390         {
391                 oldsolid = source.dphitcontentsmask;
392                 source.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
393         }
394
395         if (lag)
396         {
397                 // take players back into the past
398                 player = player_list;
399                 while (player)
400                 {
401                         antilag_takeback(player, time - lag);
402                         player = player.nextplayer;
403                 }
404         }
405
406         // do the trace
407         if(wz)
408                 WarpZone_TraceBox (v1, mi, ma, v2, nomonst, forent);
409         else
410                 tracebox (v1, mi, ma, v2, nomonst, forent);
411
412         // restore players to current positions
413         if (lag)
414         {
415                 player = player_list;
416                 while (player)
417                 {
418                         antilag_restore(player);
419                         player = player.nextplayer;
420                 }
421         }
422
423         // restore shooter solid type
424         if(source)
425                 source.dphitcontentsmask = oldsolid;
426 }
427 void traceline_antilag_force (entity source, vector v1, vector v2, float nomonst, entity forent, float lag)
428 {
429         tracebox_antilag_force_wz(source, v1, '0 0 0', '0 0 0', v2, nomonst, forent, lag, FALSE);
430 }
431 void traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag)
432 {
433         if (cvar("g_antilag") != 2 || source.cvar_cl_noantilag)
434                 lag = 0;
435         traceline_antilag_force(source, v1, v2, nomonst, forent, lag);
436 }
437 void tracebox_antilag (entity source, vector v1, vector mi, vector ma, vector v2, float nomonst, entity forent, float lag)
438 {
439         if (cvar("g_antilag") != 2 || source.cvar_cl_noantilag)
440                 lag = 0;
441         tracebox_antilag_force_wz(source, v1, mi, ma, v2, nomonst, forent, lag, FALSE);
442 }
443 void WarpZone_traceline_antilag_force (entity source, vector v1, vector v2, float nomonst, entity forent, float lag)
444 {
445         tracebox_antilag_force_wz(source, v1, '0 0 0', '0 0 0', v2, nomonst, forent, lag, TRUE);
446 }
447 void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag)
448 {
449         if (cvar("g_antilag") != 2 || source.cvar_cl_noantilag)
450                 lag = 0;
451         WarpZone_traceline_antilag_force(source, v1, v2, nomonst, forent, lag);
452 }
453 void WarpZone_tracebox_antilag (entity source, vector v1, vector mi, vector ma, vector v2, float nomonst, entity forent, float lag)
454 {
455         if (cvar("g_antilag") != 2 || source.cvar_cl_noantilag)
456                 lag = 0;
457         tracebox_antilag_force_wz(source, v1, mi, ma, v2, nomonst, forent, lag, TRUE);
458 }
459
460 float tracebox_inverted (vector v1, vector mi, vector ma, vector v2, float nomonsters, entity forent) // returns the number of traces done, for benchmarking
461 {
462         vector pos, dir, t;
463         float nudge;
464
465         //nudge = 2 * cvar("collision_impactnudge"); // why not?
466         nudge = 0.5;
467
468         dir = normalize(v2 - v1);
469
470         pos = v1 + dir * nudge;
471
472         float c;
473         c = 0;
474
475         for(;;)
476         {
477                 if((pos - v1) * dir >= (v2 - v1) * dir)
478                 {
479                         // went too far
480                         trace_fraction = 1;
481                         trace_endpos = v2;
482                         return c;
483                 }
484
485                 tracebox(pos, mi, ma, v2, nomonsters, forent);
486                 ++c;
487
488                 if(c == 50)
489                 {
490                         dprint("HOLY SHIT! When tracing from ", vtos(v1), " to ", vtos(v2), "\n");
491                         dprint("  Nudging gets us nowhere at ", vtos(pos), "\n");
492                         dprint("  trace_endpos is ", vtos(trace_endpos), "\n");
493                         dprint("  trace distance is ", ftos(vlen(pos - trace_endpos)), "\n");
494                 }
495
496                 if(trace_startsolid)
497                 {
498                         // we started inside solid.
499                         // then trace from endpos to pos
500                         t = trace_endpos;
501                         tracebox(t, mi, ma, pos, nomonsters, forent);
502                         ++c;
503                         if(trace_startsolid)
504                         {
505                                 // t is still inside solid? bad
506                                 // force advance, then, and retry
507                                 pos = t + dir * nudge;
508                         }
509                         else
510                         {
511                                 // we actually LEFT solid!
512                                 trace_fraction = ((trace_endpos - v1) * dir) / ((v2 - v1) * dir);
513                                 return c;
514                         }
515                 }
516                 else
517                 {
518                         // pos is outside solid?!? but why?!? never mind, just return it.
519                         trace_endpos = pos;
520                         trace_fraction = ((trace_endpos - v1) * dir) / ((v2 - v1) * dir);
521                         return c;
522                 }
523         }
524 }
525
526 void traceline_inverted (vector v1, vector v2, float nomonsters, entity forent)
527 {
528 #if 0
529         vector pos, dir, t;
530         float nudge;
531
532         //nudge = 2 * cvar("collision_impactnudge"); // why not?
533         nudge = 0.5;
534
535         dir = normalize(v2 - v1);
536
537         pos = v1 + dir * nudge;
538
539         for(;;)
540         {
541                 if((pos - v1) * dir >= (v2 - v1) * dir)
542                 {
543                         // went too far
544                         trace_fraction = 1;
545                         return;
546                 }
547
548                 traceline(pos, v2, nomonsters, forent);
549
550                 if(trace_startsolid)
551                 {
552                         // we started inside solid.
553                         // then trace from endpos to pos
554                         t = trace_endpos;
555                         traceline(t, pos, nomonsters, forent);
556                         if(trace_startsolid)
557                         {
558                                 // t is inside solid? bad
559                                 // force advance, then
560                                 pos = pos + dir * nudge;
561                         }
562                         else
563                         {
564                                 // we actually LEFT solid!
565                                 trace_fraction = ((trace_endpos - v1) * dir) / ((v2 - v1) * dir);
566                                 return;
567                         }
568                 }
569                 else
570                 {
571                         // pos is outside solid?!? but why?!? never mind, just return it.
572                         trace_endpos = pos;
573                         trace_fraction = ((trace_endpos - v1) * dir) / ((v2 - v1) * dir);
574                         return;
575                 }
576         }
577 #else
578         tracebox_inverted(v1, '0 0 0', '0 0 0', v2, nomonsters, forent);
579 }
580
581 /*
582 ==================
583 findbetterlocation
584
585 Returns a point at least 12 units away from walls
586 (useful for explosion animations, although the blast is performed where it really happened)
587 Ripped from DPMod
588 ==================
589 */
590 vector findbetterlocation (vector org, float mindist)
591 {
592         vector  loc;
593         vector vec;
594         float c, h;
595
596         vec = mindist * '1 0 0';
597         c = 0;
598         while (c < 6)
599         {
600                 traceline (org, org + vec, TRUE, world);
601                 vec = vec * -1;
602                 if (trace_fraction < 1)
603                 {
604                         loc = trace_endpos;
605                         traceline (loc, loc + vec, TRUE, world);
606                         if (trace_fraction >= 1)
607                                 org = loc + vec;
608                 }
609                 if (c & 1)
610                 {
611                         h = vec_y;
612                         vec_y = vec_x;
613                         vec_x = vec_z;
614                         vec_z = h;
615                 }
616                 c = c + 1;
617         }
618
619         return org;
620 }
621
622 /*
623 ==================
624 crandom
625
626 Returns a random number between -1.0 and 1.0
627 ==================
628 */
629 float crandom (void)
630 {
631         return 2 * (random () - 0.5);
632 }
633
634 /*
635 ==================
636 Angc used for animations
637 ==================
638 */
639
640
641 float angc (float a1, float a2)
642 {
643         float   a;
644
645         while (a1 > 180)
646                 a1 = a1 - 360;
647         while (a1 < -179)
648                 a1 = a1 + 360;
649
650         while (a2 > 180)
651                 a2 = a2 - 360;
652         while (a2 < -179)
653                 a2 = a2 + 360;
654
655         a = a1 - a2;
656         while (a > 180)
657                 a = a - 360;
658         while (a < -179)
659                 a = a + 360;
660
661         return a;
662 }
663
664 .string lodtarget1;
665 .string lodtarget2;
666 .string lodmodel1;
667 .string lodmodel2;
668 .float lodmodelindex0;
669 .float lodmodelindex1;
670 .float lodmodelindex2;
671 .float loddistance1;
672 .float loddistance2;
673
674 float LOD_customize()
675 {
676         float d;
677
678         if(cvar("loddebug"))
679         {
680                 d = cvar("loddebug");
681                 if(d == 1)
682                         self.modelindex = self.lodmodelindex0;
683                 else if(d == 2 || !self.lodmodelindex2)
684                         self.modelindex = self.lodmodelindex1;
685                 else // if(d == 3)
686                         self.modelindex = self.lodmodelindex2;
687                 return TRUE;
688         }
689
690         // TODO csqc network this so it only gets sent once
691         d = vlen(NearestPointOnBox(self, other.origin) - other.origin);
692         if(d < self.loddistance1)
693                 self.modelindex = self.lodmodelindex0;
694         else if(!self.lodmodelindex2 || d < self.loddistance2)
695                 self.modelindex = self.lodmodelindex1;
696         else
697                 self.modelindex = self.lodmodelindex2;
698
699         return TRUE;
700 }
701
702 void LOD_uncustomize()
703 {
704         self.modelindex = self.lodmodelindex0;
705 }
706
707 void LODmodel_attach()
708 {
709         entity e;
710
711         if(!self.loddistance1)
712                 self.loddistance1 = 1000;
713         if(!self.loddistance2)
714                 self.loddistance2 = 2000;
715         self.lodmodelindex0 = self.modelindex;
716
717         if(self.lodtarget1 != "")
718         {
719                 e = find(world, targetname, self.lodtarget1);
720                 if(e)
721                 {
722                         self.lodmodel1 = e.model;
723                         remove(e);
724                 }
725         }
726         if(self.lodtarget2 != "")
727         {
728                 e = find(world, targetname, self.lodtarget2);
729                 if(e)
730                 {
731                         self.lodmodel2 = e.model;
732                         remove(e);
733                 }
734         }
735
736         if(cvar("loddebug") < 0)
737         {
738                 self.lodmodel1 = self.lodmodel2 = ""; // don't even initialize
739         }
740
741         if(self.lodmodel1 != "")
742         {
743                 vector mi, ma;
744                 mi = self.mins;
745                 ma = self.maxs;
746
747                 precache_model(self.lodmodel1);
748                 setmodel(self, self.lodmodel1);
749                 self.lodmodelindex1 = self.modelindex;
750
751                 if(self.lodmodel2 != "")
752                 {
753                         precache_model(self.lodmodel2);
754                         setmodel(self, self.lodmodel2);
755                         self.lodmodelindex2 = self.modelindex;
756                 }
757
758                 self.modelindex = self.lodmodelindex0;
759                 setsize(self, mi, ma);
760         }
761
762         if(self.lodmodelindex1)
763                 if not(self.SendEntity)
764                         SetCustomizer(self, LOD_customize, LOD_uncustomize);
765 }
766
767 void SetBrushEntityModel()
768 {
769         if(self.model != "")
770         {
771                 precache_model(self.model);
772                 setmodel(self, self.model); // no precision needed
773                 InitializeEntity(self, LODmodel_attach, INITPRIO_FINDTARGET);
774         }
775         setorigin(self, self.origin);
776         if(self.scale)
777                 setsize(self, self.mins * self.scale, self.maxs * self.scale);
778         else
779                 setsize(self, self.mins, self.maxs);
780 }
781
782 void SetBrushEntityModelNoLOD()
783 {
784         if(self.model != "")
785         {
786                 precache_model(self.model);
787                 setmodel(self, self.model); // no precision needed
788         }
789         setorigin(self, self.origin);
790         if(self.scale)
791                 setsize(self, self.mins * self.scale, self.maxs * self.scale);
792         else
793                 setsize(self, self.mins, self.maxs);
794 }
795
796 /*
797 ================
798 InitTrigger
799 ================
800 */
801
802 void SetMovedir()
803 {
804         if (self.movedir != '0 0 0')
805                 self.movedir = normalize(self.movedir);
806         else
807         {
808                 makevectors (self.angles);
809                 self.movedir = v_forward;
810         }
811
812         self.angles = '0 0 0';
813 };
814
815 void InitTrigger()
816 {
817 // trigger angles are used for one-way touches.  An angle of 0 is assumed
818 // to mean no restrictions, so use a yaw of 360 instead.
819         if (self.movedir == '0 0 0')
820         if (self.angles != '0 0 0')
821                 SetMovedir ();
822         self.solid = SOLID_TRIGGER;
823         SetBrushEntityModel();
824         self.movetype = MOVETYPE_NONE;
825         self.modelindex = 0;
826         self.model = "";
827 };
828
829 void InitSolidBSPTrigger()
830 {
831 // trigger angles are used for one-way touches.  An angle of 0 is assumed
832 // to mean no restrictions, so use a yaw of 360 instead.
833         if (self.movedir == '0 0 0')
834         if (self.angles != '0 0 0')
835                 SetMovedir ();
836         self.solid = SOLID_BSP;
837         SetBrushEntityModel();
838         self.movetype = MOVETYPE_NONE; // why was this PUSH? -div0
839 //      self.modelindex = 0;
840         self.model = "";
841 };
842
843 float InitMovingBrushTrigger()
844 {
845 // trigger angles are used for one-way touches.  An angle of 0 is assumed
846 // to mean no restrictions, so use a yaw of 360 instead.
847         self.solid = SOLID_BSP;
848         SetBrushEntityModel();
849         self.movetype = MOVETYPE_PUSH;
850         if(self.modelindex == 0)
851         {
852                 objerror("InitMovingBrushTrigger: no brushes found!");
853                 return 0;
854         }
855         return 1;
856 };