]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/warpzonelib/common.qc
MinstaNex now can shoot through warpzones... using warpzone-aware tracebox and trailp...
[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         // FIXME when a roll comes out and angle is near +/-90 degrees
22         // then roll can be incorporated into yaw and cancelled out
23
24         /*
25         print(vtos(ang), " output\n");
26         makevectors(ang);
27         print(vtos(vf), " -> ", vtos(v_forward), "\n");
28         print(vtos(vr), " -> ", vtos(v_right), "\n");
29         print(vtos(vu), " -> ", vtos(v_up), "\n");
30         */
31
32         ang = AnglesTransform_Normalize(ang, TRUE);
33         ang = AnglesTransform_CancelRoll(ang);
34
35         /*
36         print(vtos(ang), " output\n");
37         */
38
39         ang_z = roll;
40         return ang;
41 }
42
43 vector WarpZoneLib_BoxTouchesBrush_mins;
44 vector WarpZoneLib_BoxTouchesBrush_maxs;
45 entity WarpZoneLib_BoxTouchesBrush_ent;
46 entity WarpZoneLib_BoxTouchesBrush_ignore;
47 float WarpZoneLib_BoxTouchesBrush_Recurse()
48 {
49         float s;
50         entity se;
51         float f;
52
53         tracebox('0 0 0', WarpZoneLib_BoxTouchesBrush_mins, WarpZoneLib_BoxTouchesBrush_maxs, '0 0 0', MOVE_NOMONSTERS, WarpZoneLib_BoxTouchesBrush_ignore);
54 #ifdef CSQC
55         if (trace_networkentity)
56         {
57                 dprint("hit a network ent, cannot continue WarpZoneLib_BoxTouchesBrush\n");
58                 // we cannot continue, as a player blocks us...
59                 // so, abort
60                 return 0;
61         }
62 #endif
63         if not(trace_ent)
64                 return 0;
65         if (trace_ent == WarpZoneLib_BoxTouchesBrush_ent)
66                 return 1;
67
68         
69
70         se = trace_ent;
71         s = se.solid;
72         se.solid = SOLID_NOT;
73         f = WarpZoneLib_BoxTouchesBrush_Recurse();
74         se.solid = s;
75
76         return f;
77 }
78
79 float WarpZoneLib_BoxTouchesBrush(vector mi, vector ma, entity e, entity ig)
80 {
81     float f, s;
82
83     if not(e.modelindex)
84         return 1;
85
86     s = e.solid;
87     e.solid = SOLID_BSP;
88     WarpZoneLib_BoxTouchesBrush_mins = mi;
89     WarpZoneLib_BoxTouchesBrush_maxs = ma;
90     WarpZoneLib_BoxTouchesBrush_ent = e;
91     WarpZoneLib_BoxTouchesBrush_ignore = ig;
92     f = WarpZoneLib_BoxTouchesBrush_Recurse();
93     e.solid = s;
94
95     return f;
96 }
97
98 entity WarpZone_Find(vector mi, vector ma)
99 {
100         // if we are near any warpzone planes - MOVE AWAY (work around nearclip)
101         entity e;
102         for(e = world; (e = find(e, classname, "trigger_warpzone")); )
103                 if(WarpZoneLib_BoxTouchesBrush(mi, ma, e, world))
104                         return e;
105         return world;
106 }
107
108 void WarpZone_MakeAllSolid()
109 {
110         entity e;
111         for(e = world; (e = find(e, classname, "trigger_warpzone")); )
112                 e.solid = SOLID_BSP;
113 }
114
115 void WarpZone_MakeAllOther()
116 {
117         entity e;
118         for(e = world; (e = find(e, classname, "trigger_warpzone")); )
119                 e.solid = SOLID_TRIGGER;
120 }