3 #include <common/mapobjects/triggers.qh>
4 #include <common/stats.qh>
5 #include <common/weapons/_all.qh>
6 #include <server/pathlib/pathlib.qh>
7 #include <server/pathlib/utility.qh>
11 vector pathlib_wateroutnode(entity this, vector start, vector end, float doedge)
15 pathlib_movenode_goodnode = false;
17 end.x = fsnap(end.x, pathlib_gridsize);
18 end.y = fsnap(end.y, pathlib_gridsize);
20 traceline(end + ('0 0 0.25' * pathlib_gridsize),end - ('0 0 1' * pathlib_gridsize),MOVE_WORLDONLY,this);
23 if (!(pointcontents(end - '0 0 1') == CONTENT_SOLID))
26 for(surface = start ; surface.z < (end.z + 32); ++surface.z)
28 if(pointcontents(surface) == CONTENT_EMPTY)
32 if(pointcontents(surface + '0 0 1') != CONTENT_EMPTY)
35 tracebox(start + '0 0 64', movenode_boxmin,movenode_boxmax, end + '0 0 64', MOVE_WORLDONLY, this);
36 if(trace_fraction == 1)
37 pathlib_movenode_goodnode = true;
39 if(fabs(surface.z - end.z) > 32)
40 pathlib_movenode_goodnode = false;
45 vector pathlib_swimnode(entity this, vector start, vector end, float doedge)
47 pathlib_movenode_goodnode = false;
49 if(pointcontents(start) != CONTENT_WATER)
52 end.x = fsnap(end.x, pathlib_gridsize);
53 end.y = fsnap(end.y, pathlib_gridsize);
55 if(pointcontents(end) == CONTENT_EMPTY)
56 return pathlib_wateroutnode(this, start, end, doedge);
58 tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, this);
59 if(trace_fraction == 1)
60 pathlib_movenode_goodnode = true;
65 vector pathlib_flynode(entity this, vector start, vector end, float doedge)
67 pathlib_movenode_goodnode = false;
69 end.x = fsnap(end.x, pathlib_gridsize);
70 end.y = fsnap(end.y, pathlib_gridsize);
72 tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, this);
73 if(trace_fraction == 1)
74 pathlib_movenode_goodnode = true;
79 void a_think(entity this)
81 te_lightning1(this,this.origin, this.pos1);
85 this.nextthink = time + 0.2;
88 vector pathlib_walknode(entity this, vector start, vector end, float doedge)
92 LOG_DEBUG("Walking node from ", vtos(start), " to ", vtos(end));
94 pathlib_movenode_goodnode = false;
96 end.x = fsnap(end.x,pathlib_gridsize);
97 end.y = fsnap(end.y,pathlib_gridsize);
98 start.x = fsnap(start.x,pathlib_gridsize);
99 start.y = fsnap(start.y,pathlib_gridsize);
102 traceline(start + movenode_stepup, start - movenode_maxdrop, MOVE_WORLDONLY, this);
103 if(trace_fraction == 1.0)
107 setthink(a, a_think);
109 setorigin(a, start + movenode_stepup);
110 a.pos1 = trace_endpos;
111 //start - movenode_maxdrop
114 LOG_TRACE("I cant walk on air!");
118 start = trace_endpos;
120 // Find the direcion, without Z
124 vector direction = normalize(e - s);
126 float distance = vlen(start - end);
127 int steps = rint(distance / movenode_stepsize);
129 vector last_point = start;
130 for(int i = 1; i < steps; ++i)
132 point = last_point + (direction * movenode_stepsize);
133 traceline(point + movenode_stepup,point - movenode_maxdrop,MOVE_WORLDONLY,this);
134 if(trace_fraction == 1.0)
137 last_point = trace_endpos;
140 point = last_point + (direction * movenode_stepsize);
141 point.x = fsnap(point.x,pathlib_gridsize);
142 point.y = fsnap(point.y,pathlib_gridsize);
144 //dprint("end_x: ",ftos(end_x), " end_y: ",ftos(end_y),"\n");
145 //dprint("point_x:",ftos(point_x)," point_y:",ftos(point_y),"\n\n");
147 traceline(point + movenode_stepup, point - movenode_maxdrop,MOVE_WORLDONLY,this);
148 if(trace_fraction == 1.0)
151 last_point = trace_endpos;
153 tracebox(start + movenode_boxup, movenode_boxmin,movenode_boxmax, last_point + movenode_boxup, MOVE_WORLDONLY, this);
154 if(trace_fraction != 1.0)
157 pathlib_movenode_goodnode = true;