]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/warpzonelib/common.qc
more warpzone fixes - now angled warpzones work too
[divverent/nexuiz.git] / data / qcsrc / warpzonelib / common.qc
1 vector WarpZone_TransformVAngles(vector t, vector ang)
2 {
3         float roll;
4
5         roll = ang_z;
6         ang_z = 0;
7
8         /*
9         vector vf, vr, vu;
10         print(vtos(ang), " input\n");
11         makevectors(ang);
12         vf = v_forward;
13         vr = v_right;
14         vu = v_up;
15         print(vtos(vf), " -> ", vtos(AnglesTransform_Apply(t, vf)), "\n");
16         print(vtos(vr), " -> ", vtos(AnglesTransform_Apply(t, vr)), "\n");
17         print(vtos(vu), " -> ", vtos(AnglesTransform_Apply(t, vu)), "\n");
18         */
19
20         ang = AnglesTransform_ApplyToVAngles(t, ang);
21
22         /*
23         print(vtos(ang), " output\n");
24         makevectors(ang);
25         print(vtos(vf), " -> ", vtos(v_forward), "\n");
26         print(vtos(vr), " -> ", vtos(v_right), "\n");
27         print(vtos(vu), " -> ", vtos(v_up), "\n");
28         */
29
30         ang = AnglesTransform_Normalize(ang, TRUE);
31
32         /*
33         print(vtos(ang), " output\n");
34         */
35
36         ang_z = roll;
37         return ang;
38 }
39
40 vector WarpZoneLib_BoxTouchesBrush_mins;
41 vector WarpZoneLib_BoxTouchesBrush_maxs;
42 entity WarpZoneLib_BoxTouchesBrush_ent;
43 entity WarpZoneLib_BoxTouchesBrush_ignore;
44 float WarpZoneLib_BoxTouchesBrush_Recurse()
45 {
46         float s;
47         entity se;
48         float f;
49
50         tracebox('0 0 0', WarpZoneLib_BoxTouchesBrush_mins, WarpZoneLib_BoxTouchesBrush_maxs, '0 0 0', MOVE_NOMONSTERS, WarpZoneLib_BoxTouchesBrush_ignore);
51 #ifdef CSQC
52         if (trace_networkentity)
53         {
54                 dprint("hit a network ent, cannot continue WarpZoneLib_BoxTouchesBrush\n");
55                 // we cannot continue, as a player blocks us...
56                 // so, abort
57                 return 0;
58         }
59 #endif
60         if not(trace_ent)
61                 return 0;
62         if (trace_ent == WarpZoneLib_BoxTouchesBrush_ent)
63                 return 1;
64
65         
66
67         se = trace_ent;
68         s = se.solid;
69         se.solid = SOLID_NOT;
70         f = WarpZoneLib_BoxTouchesBrush_Recurse();
71         se.solid = s;
72
73         return f;
74 }
75
76 float WarpZoneLib_BoxTouchesBrush(vector mi, vector ma, entity e, entity ig)
77 {
78     float f, s;
79
80     if not(e.modelindex)
81         return 1;
82
83     s = e.solid;
84     e.solid = SOLID_BSP;
85     WarpZoneLib_BoxTouchesBrush_mins = mi;
86     WarpZoneLib_BoxTouchesBrush_maxs = ma;
87     WarpZoneLib_BoxTouchesBrush_ent = e;
88     WarpZoneLib_BoxTouchesBrush_ignore = ig;
89     f = WarpZoneLib_BoxTouchesBrush_Recurse();
90     e.solid = s;
91
92     return f;
93 }