]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/warpzonelib/util_server.qc
git wants me to commit, so I will: begin using the improved kill delay code
[xonotic/xonotic-data.pk3dir.git] / qcsrc / warpzonelib / util_server.qc
1 void WarpZoneLib_MoveOutOfSolid_Expand(entity e, vector by)
2 {
3         float eps = 0.0625;
4         tracebox(e.origin, e.mins - '1 1 1' * eps, e.maxs + '1 1 1' * eps, e.origin + by, MOVE_WORLDONLY, e);
5         if (trace_startsolid)
6                 return;
7         if (trace_fraction < 1)
8         {
9                 // hit something
10                 // adjust origin in the other direction...
11                 setorigin(e,e.origin - by * (1 - trace_fraction));
12         }
13 }
14
15 float WarpZoneLib_MoveOutOfSolid(entity e)
16 {
17         vector o, m0, m1;
18
19         o = e.origin;
20         traceline(o, o, MOVE_WORLDONLY, e);
21         if (trace_startsolid)
22                 return FALSE;
23
24         tracebox(o, e.mins, e.maxs, o, MOVE_WORLDONLY, e);
25         if (!trace_startsolid)
26                 return TRUE;
27
28         m0 = e.mins;
29         m1 = e.maxs;
30         e.mins = '0 0 0';
31         e.maxs = '0 0 0';
32         WarpZoneLib_MoveOutOfSolid_Expand(e, '1 0 0' * m0_x);
33         e.mins_x = m0_x;
34         WarpZoneLib_MoveOutOfSolid_Expand(e, '1 0 0' * m1_x);
35         e.maxs_x = m1_x;
36         WarpZoneLib_MoveOutOfSolid_Expand(e, '0 1 0' * m0_y);
37         e.mins_y = m0_y;
38         WarpZoneLib_MoveOutOfSolid_Expand(e, '0 1 0' * m1_y);
39         e.maxs_y = m1_y;
40         WarpZoneLib_MoveOutOfSolid_Expand(e, '0 0 1' * m0_z);
41         e.mins_z = m0_z;
42         WarpZoneLib_MoveOutOfSolid_Expand(e, '0 0 1' * m1_z);
43         e.maxs_z = m1_z;
44         setorigin(e, e.origin);
45
46         tracebox(e.origin, e.mins, e.maxs, e.origin, MOVE_WORLDONLY, e);
47         if (trace_startsolid)
48         {
49                 setorigin(e, o);
50                 return FALSE;
51         }
52
53         return TRUE;
54 }
55
56 float WarpZoneLib_ExactTrigger_Touch()
57 {
58         return !WarpZoneLib_BoxTouchesBrush(other.absmin, other.absmax, self, other);
59 }
60
61 void WarpZoneLib_ExactTrigger_Init()
62 {
63         vector mi, ma;
64         if (self.movedir == '0 0 0')
65         if (self.angles != '0 0 0')
66         {
67                 makevectors (self.angles);
68                 self.movedir = v_forward;
69         }
70         self.warpzone_isboxy = 1;
71         if(self.model != "")
72         {
73                 mi = self.mins;
74                 ma = self.maxs;
75                 precache_model(self.model);
76                 setmodel(self, self.model);
77                 // let mapper-set mins/maxs override the model's bounds if set
78                 if(mi != '0 0 0' || ma != '0 0 0')
79                 {
80                         self.mins = mi;
81                         self.maxs = ma;
82                 }
83                 else
84                         self.warpzone_isboxy = 0; // enable exacttrigger matching
85         }
86         setorigin(self, self.origin);
87         if(self.scale)
88                 setsize(self, self.mins * self.scale, self.maxs * self.scale);
89         else
90                 setsize(self, self.mins, self.maxs);
91         self.movetype = MOVETYPE_NONE;
92         self.solid = SOLID_TRIGGER;
93         self.model = "";
94 }