]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/pathlib/movenode.qc
- rename sys_ticrate global to sys_frametime, and premultiply it with slowmo (fixes...
[divverent/nexuiz.git] / data / qcsrc / server / pathlib / movenode.qc
1 vector pathlib_wateroutnode(vector start,vector end)
2 {
3     vector surface;
4
5     pathlib_movenode_goodnode = 0;
6
7     end_x = fsnap(end_x, pathlib_gridsize);
8     end_y = fsnap(end_y, pathlib_gridsize);
9
10     traceline(end + ('0 0 0.25' * pathlib_gridsize),end - ('0 0 1' * pathlib_gridsize),MOVE_WORLDONLY,self);
11     end = trace_endpos;
12
13     if not(pointcontents(end - '0 0 1') == CONTENT_SOLID)
14         return end;
15
16     for(surface = start ; surface_z < (end_z + 32); ++surface_z)
17     {
18         if(pointcontents(surface) == CONTENT_EMPTY)
19             break;
20     }
21
22     if(pointcontents(surface + '0 0 1') != CONTENT_EMPTY)
23         return end;
24
25     tracebox(start + '0 0 64', movenode_boxmin,movenode_boxmax, end + '0 0 64', MOVE_WORLDONLY, self);
26     if(trace_fraction == 1)
27         pathlib_movenode_goodnode = 1;
28
29     if(fabs(surface_z - end_z) > 32)
30         pathlib_movenode_goodnode = 0;
31
32     return end;
33 }
34
35 vector pathlib_swimnode(vector start,vector end)
36 {
37     pathlib_movenode_goodnode = 0;
38
39     if(pointcontents(start) != CONTENT_WATER)
40         return end;
41
42     end_x = fsnap(end_x, pathlib_gridsize);
43     end_y = fsnap(end_y, pathlib_gridsize);
44
45     if(pointcontents(end) == CONTENT_EMPTY)
46         return pathlib_wateroutnode( start, end);
47
48     tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, self);
49     if(trace_fraction == 1)
50         pathlib_movenode_goodnode = 1;
51
52     return end;
53 }
54
55 vector pathlib_flynode(vector start,vector end)
56 {
57     pathlib_movenode_goodnode = 0;
58
59     end_x = fsnap(end_x, pathlib_gridsize);
60     end_y = fsnap(end_y, pathlib_gridsize);
61
62     tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, self);
63     if(trace_fraction == 1)
64         pathlib_movenode_goodnode = 1;
65
66     return end;
67 }
68
69 vector pathlib_walknode(vector start,vector end,float doedge)
70 {
71     vector direction,point,last_point,s,e;
72     float steps, distance, i;
73
74     pathlib_movenode_goodnode = 0;
75
76     end_x = fsnap(end_x,pathlib_gridsize);
77     end_y = fsnap(end_y,pathlib_gridsize);
78     start_x = fsnap(start_x,pathlib_gridsize);
79     start_y = fsnap(start_y,pathlib_gridsize);
80
81     // Find the floor
82     traceline(start + movenode_stepup, start - movenode_maxdrop,MOVE_WORLDONLY,self);
83     if(trace_fraction == 1.0)
84         return trace_endpos;
85
86     start = trace_endpos;
87
88     // Find the direcion, without Z
89     s   = start; e   = end;
90     //e_z = 0; s_z = 0;
91     direction = normalize(e - s);
92
93     distance  = vlen(start - end);
94     steps     = rint(distance / movenode_stepsize);
95
96     last_point = start;
97     for(i = 1; i < steps; ++i)
98     {
99         point = last_point + (direction * movenode_stepsize);
100         traceline(point + movenode_stepup,point - movenode_maxdrop,MOVE_WORLDONLY,self);
101         if(trace_fraction == 1.0)
102             return trace_endpos;
103
104         last_point = trace_endpos;
105     }
106
107     point = last_point + (direction * movenode_stepsize);
108     point_x = fsnap(point_x,pathlib_gridsize);
109     point_y = fsnap(point_y,pathlib_gridsize);
110
111     //dprint("end_x:  ",ftos(end_x),  "  end_y:  ",ftos(end_y),"\n");
112     //dprint("point_x:",ftos(point_x),"  point_y:",ftos(point_y),"\n\n");
113
114     traceline(point + movenode_stepup, point - movenode_maxdrop,MOVE_WORLDONLY,self);
115     if(trace_fraction == 1.0)
116         return trace_endpos;
117
118     last_point = trace_endpos;
119
120     tracebox(start + movenode_boxup, movenode_boxmin,movenode_boxmax, last_point + movenode_boxup, MOVE_WORLDONLY, self);
121     if(trace_fraction != 1.0)
122         return trace_endpos;
123
124     pathlib_movenode_goodnode = 1;
125     return last_point;
126 }