3 #include <common/weapons/_all.qh>
4 #include <common/stats.qh>
5 #include <server/miscfunctions.qh>
8 bool location_isok(vector point, bool waterok, bool air_isok)
10 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)
13 int pc = pointcontents(point);
14 int pc2 = pointcontents(point - '0 0 1');
16 if(pc == CONTENT_EMPTY && pc2 == CONTENT_SOLID)
18 if(pc == CONTENT_EMPTY && pc2 == CONTENT_WATER && waterok)
20 if(pc == CONTENT_EMPTY && pc2 == CONTENT_EMPTY && air_isok)
22 if(pc == CONTENT_WATER && waterok)
27 entity pathlib_nodeatpoint(vector where)
29 ++pathlib_searched_cnt;
31 where.x = fsnap(where.x,pathlib_gridsize);
32 where.y = fsnap(where.y,pathlib_gridsize);
34 entity found = NULL; // TODO: using FOREACH_ENTITY_RADIUS here causes mutex loop warnings, this may need a proper fix!
35 IL_EACH(g_pathlib_nodes, it.is_path_node && vdist(it.origin - where, <, pathlib_gridsize * 0.5),
44 bool tile_check_cross(entity this, vector where)
47 vector f = PLIB_FORWARD * tile_check_size;
48 vector r = PLIB_RIGHT * tile_check_size;
53 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
54 if (!location_isok(trace_endpos, 1, 0))
59 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
60 if (!location_isok(trace_endpos, 1, 0))
65 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
66 if (!location_isok(trace_endpos, 1 ,0))
71 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
72 if (!location_isok(trace_endpos, 1, 0))
78 bool tile_check_plus(entity this, vector where)
82 vector f = PLIB_FORWARD * tile_check_size;
83 vector r = PLIB_RIGHT * tile_check_size;
87 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
88 if (!location_isok(trace_endpos,1,0))
94 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
95 if (!location_isok(trace_endpos,1,0))
100 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
101 if (!location_isok(trace_endpos,1,0))
106 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
107 if (!location_isok(trace_endpos,1,0))
113 float tile_check_plus2(entity this, vector where)
118 vector f = PLIB_FORWARD * pathlib_gridsize;
119 vector r = PLIB_RIGHT * pathlib_gridsize;
121 //#define pathlib_node_edgeflag_left 2
122 //#define pathlib_node_edgeflag_right 4
123 //#define pathlib_node_edgeflag_forward 8
124 //#define pathlib_node_edgeflag_back 16
128 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
129 if (location_isok(trace_endpos,1,0))
132 e |= pathlib_node_edgeflag_forward;
138 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
139 if (location_isok(trace_endpos,1,0))
142 e |= pathlib_node_edgeflag_left;
148 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
149 if (location_isok(trace_endpos,1,0))
152 e |= pathlib_node_edgeflag_right;
157 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
158 if (location_isok(trace_endpos,1,0))
161 e |= pathlib_node_edgeflag_back;
166 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
167 if (location_isok(trace_endpos, 1, 0))
170 e |= pathlib_node_edgeflag_forwardright;
175 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
176 if (location_isok(trace_endpos, 1, 0))
179 e |= pathlib_node_edgeflag_forwardleft;
184 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
185 if (location_isok(trace_endpos, 1 ,0))
188 e |= pathlib_node_edgeflag_backright;
193 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
194 if (location_isok(trace_endpos, 1, 0))
197 e |= pathlib_node_edgeflag_backleft;
202 e = pathlib_node_edgeflag_none;
207 bool tile_check_star(entity this, vector where)
209 if(tile_check_plus(this, where))
210 return tile_check_cross(this, where);