8 vector pathlib_wateroutnode(entity this, vector start, vector end, float doedge)
12 pathlib_movenode_goodnode = 0;
14 end.x = fsnap(end.x, pathlib_gridsize);
15 end.y = fsnap(end.y, pathlib_gridsize);
17 traceline(end + ('0 0 0.25' * pathlib_gridsize),end - ('0 0 1' * pathlib_gridsize),MOVE_WORLDONLY,this);
20 if (!(pointcontents(end - '0 0 1') == CONTENT_SOLID))
23 for(surface = start ; surface.z < (end.z + 32); ++surface.z)
25 if(pointcontents(surface) == CONTENT_EMPTY)
29 if(pointcontents(surface + '0 0 1') != CONTENT_EMPTY)
32 tracebox(start + '0 0 64', movenode_boxmin,movenode_boxmax, end + '0 0 64', MOVE_WORLDONLY, this);
33 if(trace_fraction == 1)
34 pathlib_movenode_goodnode = 1;
36 if(fabs(surface.z - end.z) > 32)
37 pathlib_movenode_goodnode = 0;
42 vector pathlib_swimnode(entity this, vector start, vector end, float doedge)
44 pathlib_movenode_goodnode = 0;
46 if(pointcontents(start) != CONTENT_WATER)
49 end.x = fsnap(end.x, pathlib_gridsize);
50 end.y = fsnap(end.y, pathlib_gridsize);
52 if(pointcontents(end) == CONTENT_EMPTY)
53 return pathlib_wateroutnode(this, start, end, doedge);
55 tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, this);
56 if(trace_fraction == 1)
57 pathlib_movenode_goodnode = 1;
62 vector pathlib_flynode(entity this, vector start, vector end, float doedge)
64 pathlib_movenode_goodnode = 0;
66 end.x = fsnap(end.x, pathlib_gridsize);
67 end.y = fsnap(end.y, pathlib_gridsize);
69 tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, this);
70 if(trace_fraction == 1)
71 pathlib_movenode_goodnode = 1;
76 void a_think(entity this)
78 te_lightning1(this,this.origin, this.pos1);
82 this.nextthink = time + 0.2;
85 vector pathlib_walknode(entity this, vector start, vector end, float doedge)
87 vector direction,point,last_point,s,e;
88 float steps, distance, i;
90 LOG_TRACE("Walking node from ", vtos(start), " to ", vtos(end), "\n");
92 pathlib_movenode_goodnode = 0;
94 end.x = fsnap(end.x,pathlib_gridsize);
95 end.y = fsnap(end.y,pathlib_gridsize);
96 start.x = fsnap(start.x,pathlib_gridsize);
97 start.y = fsnap(start.y,pathlib_gridsize);
100 traceline(start + movenode_stepup, start - movenode_maxdrop, MOVE_WORLDONLY, this);
101 if(trace_fraction == 1.0)
105 setthink(a, a_think);
107 setorigin(a, start + movenode_stepup);
108 a.pos1 = trace_endpos;
109 //start - movenode_maxdrop
112 LOG_TRACE("I cant walk on air!\n");
116 start = trace_endpos;
118 // Find the direcion, without Z
121 direction = normalize(e - s);
123 distance = vlen(start - end);
124 steps = rint(distance / movenode_stepsize);
127 for(i = 1; i < steps; ++i)
129 point = last_point + (direction * movenode_stepsize);
130 traceline(point + movenode_stepup,point - movenode_maxdrop,MOVE_WORLDONLY,this);
131 if(trace_fraction == 1.0)
134 last_point = trace_endpos;
137 point = last_point + (direction * movenode_stepsize);
138 point.x = fsnap(point.x,pathlib_gridsize);
139 point.y = fsnap(point.y,pathlib_gridsize);
141 //dprint("end_x: ",ftos(end_x), " end_y: ",ftos(end_y),"\n");
142 //dprint("point_x:",ftos(point_x)," point_y:",ftos(point_y),"\n\n");
144 traceline(point + movenode_stepup, point - movenode_maxdrop,MOVE_WORLDONLY,this);
145 if(trace_fraction == 1.0)
148 last_point = trace_endpos;
150 tracebox(start + movenode_boxup, movenode_boxmin,movenode_boxmax, last_point + movenode_boxup, MOVE_WORLDONLY, this);
151 if(trace_fraction != 1.0)
154 pathlib_movenode_goodnode = 1;