3 #include <common/weapons/_all.qh>
4 #include <common/stats.qh>
7 bool location_isok(vector point, bool waterok, bool air_isok)
9 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)
12 int pc = pointcontents(point);
13 int pc2 = pointcontents(point - '0 0 1');
15 if(pc == CONTENT_EMPTY && pc2 == CONTENT_SOLID)
17 if(pc == CONTENT_EMPTY && pc2 == CONTENT_WATER && waterok)
19 if(pc == CONTENT_EMPTY && pc2 == CONTENT_EMPTY && air_isok)
21 if(pc == CONTENT_WATER && waterok)
26 entity pathlib_nodeatpoint(vector where)
28 ++pathlib_searched_cnt;
30 where.x = fsnap(where.x,pathlib_gridsize);
31 where.y = fsnap(where.y,pathlib_gridsize);
33 entity found = NULL; // TODO: using FOREACH_ENTITY_RADIUS here causes mutex loop warnings, this may need a proper fix!
34 IL_EACH(g_pathlib_nodes, it.is_path_node && vdist(it.origin - where, <, pathlib_gridsize * 0.5),
43 bool tile_check_cross(entity this, vector where)
46 vector f = PLIB_FORWARD * tile_check_size;
47 vector r = PLIB_RIGHT * tile_check_size;
52 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
53 if (!location_isok(trace_endpos, 1, 0))
58 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
59 if (!location_isok(trace_endpos, 1, 0))
64 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
65 if (!location_isok(trace_endpos, 1 ,0))
70 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
71 if (!location_isok(trace_endpos, 1, 0))
77 bool tile_check_plus(entity this, vector where)
81 vector f = PLIB_FORWARD * tile_check_size;
82 vector r = PLIB_RIGHT * tile_check_size;
86 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
87 if (!location_isok(trace_endpos,1,0))
93 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
94 if (!location_isok(trace_endpos,1,0))
99 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
100 if (!location_isok(trace_endpos,1,0))
105 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
106 if (!location_isok(trace_endpos,1,0))
112 float tile_check_plus2(entity this, vector where)
117 vector f = PLIB_FORWARD * pathlib_gridsize;
118 vector r = PLIB_RIGHT * pathlib_gridsize;
120 //#define pathlib_node_edgeflag_left 2
121 //#define pathlib_node_edgeflag_right 4
122 //#define pathlib_node_edgeflag_forward 8
123 //#define pathlib_node_edgeflag_back 16
127 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
128 if (location_isok(trace_endpos,1,0))
131 e |= pathlib_node_edgeflag_forward;
137 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
138 if (location_isok(trace_endpos,1,0))
141 e |= pathlib_node_edgeflag_left;
147 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
148 if (location_isok(trace_endpos,1,0))
151 e |= pathlib_node_edgeflag_right;
156 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
157 if (location_isok(trace_endpos,1,0))
160 e |= pathlib_node_edgeflag_back;
165 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
166 if (location_isok(trace_endpos, 1, 0))
169 e |= pathlib_node_edgeflag_forwardright;
174 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
175 if (location_isok(trace_endpos, 1, 0))
178 e |= pathlib_node_edgeflag_forwardleft;
183 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
184 if (location_isok(trace_endpos, 1 ,0))
187 e |= pathlib_node_edgeflag_backright;
192 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
193 if (location_isok(trace_endpos, 1, 0))
196 e |= pathlib_node_edgeflag_backleft;
201 e = pathlib_node_edgeflag_none;
206 bool tile_check_star(entity this, vector where)
208 if(tile_check_plus(this, where))
209 return tile_check_cross(this, where);