3 #include <server/defs.qh>
4 #include <server/miscfunctions.qh>
10 vector pathlib_wateroutnode(entity this, vector start, vector end, float doedge)
14 pathlib_movenode_goodnode = false;
16 end.x = fsnap(end.x, pathlib_gridsize);
17 end.y = fsnap(end.y, pathlib_gridsize);
19 traceline(end + ('0 0 0.25' * pathlib_gridsize),end - ('0 0 1' * pathlib_gridsize),MOVE_WORLDONLY,this);
22 if (!(pointcontents(end - '0 0 1') == CONTENT_SOLID))
25 for(surface = start ; surface.z < (end.z + 32); ++surface.z)
27 if(pointcontents(surface) == CONTENT_EMPTY)
31 if(pointcontents(surface + '0 0 1') != CONTENT_EMPTY)
34 tracebox(start + '0 0 64', movenode_boxmin,movenode_boxmax, end + '0 0 64', MOVE_WORLDONLY, this);
35 if(trace_fraction == 1)
36 pathlib_movenode_goodnode = true;
38 if(fabs(surface.z - end.z) > 32)
39 pathlib_movenode_goodnode = false;
44 vector pathlib_swimnode(entity this, vector start, vector end, float doedge)
46 pathlib_movenode_goodnode = false;
48 if(pointcontents(start) != CONTENT_WATER)
51 end.x = fsnap(end.x, pathlib_gridsize);
52 end.y = fsnap(end.y, pathlib_gridsize);
54 if(pointcontents(end) == CONTENT_EMPTY)
55 return pathlib_wateroutnode(this, start, end, doedge);
57 tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, this);
58 if(trace_fraction == 1)
59 pathlib_movenode_goodnode = true;
64 vector pathlib_flynode(entity this, vector start, vector end, float doedge)
66 pathlib_movenode_goodnode = false;
68 end.x = fsnap(end.x, pathlib_gridsize);
69 end.y = fsnap(end.y, pathlib_gridsize);
71 tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, this);
72 if(trace_fraction == 1)
73 pathlib_movenode_goodnode = true;
78 void a_think(entity this)
80 te_lightning1(this,this.origin, this.pos1);
84 this.nextthink = time + 0.2;
87 vector pathlib_walknode(entity this, vector start, vector end, float doedge)
91 LOG_DEBUG("Walking node from ", vtos(start), " to ", vtos(end));
93 pathlib_movenode_goodnode = false;
95 end.x = fsnap(end.x,pathlib_gridsize);
96 end.y = fsnap(end.y,pathlib_gridsize);
97 start.x = fsnap(start.x,pathlib_gridsize);
98 start.y = fsnap(start.y,pathlib_gridsize);
101 traceline(start + movenode_stepup, start - movenode_maxdrop, MOVE_WORLDONLY, this);
102 if(trace_fraction == 1.0)
106 setthink(a, a_think);
108 setorigin(a, start + movenode_stepup);
109 a.pos1 = trace_endpos;
110 //start - movenode_maxdrop
113 LOG_TRACE("I cant walk on air!");
117 start = trace_endpos;
119 // Find the direcion, without Z
123 vector direction = normalize(e - s);
125 float distance = vlen(start - end);
126 int steps = rint(distance / movenode_stepsize);
128 vector last_point = start;
129 for(int i = 1; i < steps; ++i)
131 point = last_point + (direction * movenode_stepsize);
132 traceline(point + movenode_stepup,point - movenode_maxdrop,MOVE_WORLDONLY,this);
133 if(trace_fraction == 1.0)
136 last_point = trace_endpos;
139 point = last_point + (direction * movenode_stepsize);
140 point.x = fsnap(point.x,pathlib_gridsize);
141 point.y = fsnap(point.y,pathlib_gridsize);
143 //dprint("end_x: ",ftos(end_x), " end_y: ",ftos(end_y),"\n");
144 //dprint("point_x:",ftos(point_x)," point_y:",ftos(point_y),"\n\n");
146 traceline(point + movenode_stepup, point - movenode_maxdrop,MOVE_WORLDONLY,this);
147 if(trace_fraction == 1.0)
150 last_point = trace_endpos;
152 tracebox(start + movenode_boxup, movenode_boxmin,movenode_boxmax, last_point + movenode_boxup, MOVE_WORLDONLY, this);
153 if(trace_fraction != 1.0)
156 pathlib_movenode_goodnode = true;