plugins/include/sdktools_trace.inc
changeset 1859 76e8977e1193
parent 1855 7871fb255eb5
child 1860 6bf7b6d49686
     1.1 --- a/plugins/include/sdktools_trace.inc	Wed Jan 23 03:18:36 2008 +0000
     1.2 +++ b/plugins/include/sdktools_trace.inc	Wed Jan 23 17:05:50 2008 +0000
     1.3 @@ -1,261 +1,271 @@
     1.4 -/**
     1.5 - * vim: set ts=4 :
     1.6 - * =============================================================================
     1.7 - * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     1.8 - * =============================================================================
     1.9 - *
    1.10 - * This file is part of the SourceMod/SourcePawn SDK.
    1.11 - *
    1.12 - * This program is free software; you can redistribute it and/or modify it under
    1.13 - * the terms of the GNU General Public License, version 3.0, as published by the
    1.14 - * Free Software Foundation.
    1.15 - * 
    1.16 - * This program is distributed in the hope that it will be useful, but WITHOUT
    1.17 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.18 - * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.19 - * details.
    1.20 - *
    1.21 - * You should have received a copy of the GNU General Public License along with
    1.22 - * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.23 - *
    1.24 - * As a special exception, AlliedModders LLC gives you permission to link the
    1.25 - * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.26 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.27 - * by the Valve Corporation.  You must obey the GNU General Public License in
    1.28 - * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.29 - * this exception to all derivative works.  AlliedModders LLC defines further
    1.30 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.31 - * or <http://www.sourcemod.net/license.php>.
    1.32 - *
    1.33 - * Version: $Id$
    1.34 - */
    1.35 -
    1.36 -#if defined _sdktools_trace_included
    1.37 - #endinput
    1.38 -#endif
    1.39 -#define _sdktools_trace_included
    1.40 -
    1.41 -#define	CONTENTS_EMPTY			0		/**< No contents. */
    1.42 -#define	CONTENTS_SOLID			0x1		/**< an eye is never valid in a solid . */
    1.43 -#define	CONTENTS_WINDOW			0x2		/**< translucent, but not watery (glass). */
    1.44 -#define	CONTENTS_AUX			0x4
    1.45 -#define	CONTENTS_GRATE			0x8		/**< alpha-tested "grate" textures.  Bullets/sight pass through, but solids don't. */
    1.46 -#define	CONTENTS_SLIME			0x10
    1.47 -#define	CONTENTS_WATER			0x20
    1.48 -#define	CONTENTS_MIST			0x40
    1.49 -#define CONTENTS_OPAQUE			0x80		/**< things that cannot be seen through (may be non-solid though). */
    1.50 -#define	LAST_VISIBLE_CONTENTS	0x80
    1.51 -#define ALL_VISIBLE_CONTENTS 	(LAST_VISIBLE_CONTENTS | (LAST_VISIBLE_CONTENTS-1))
    1.52 -#define CONTENTS_TESTFOGVOLUME	0x100
    1.53 -#define CONTENTS_UNUSED5		0x200
    1.54 -#define CONTENTS_UNUSED6		0x4000
    1.55 -#define CONTENTS_TEAM1			0x800		/**< per team contents used to differentiate collisions. */
    1.56 -#define CONTENTS_TEAM2			0x1000		/**< between players and objects on different teams. */
    1.57 -#define CONTENTS_IGNORE_NODRAW_OPAQUE	0x2000		/**< ignore CONTENTS_OPAQUE on surfaces that have SURF_NODRAW. */
    1.58 -#define CONTENTS_MOVEABLE		0x4000		/**< hits entities which are MOVETYPE_PUSH (doors, plats, etc) */
    1.59 -#define	CONTENTS_AREAPORTAL		0x8000		/**< remaining contents are non-visible, and don't eat brushes. */
    1.60 -#define	CONTENTS_PLAYERCLIP		0x10000
    1.61 -#define	CONTENTS_MONSTERCLIP	0x20000
    1.62 -
    1.63 -/**
    1.64 - * @section currents can be added to any other contents, and may be mixed
    1.65 - */
    1.66 -#define	CONTENTS_CURRENT_0		0x40000
    1.67 -#define	CONTENTS_CURRENT_90		0x80000
    1.68 -#define	CONTENTS_CURRENT_180	0x100000
    1.69 -#define	CONTENTS_CURRENT_270	0x200000
    1.70 -#define	CONTENTS_CURRENT_UP		0x400000
    1.71 -#define	CONTENTS_CURRENT_DOWN	0x800000
    1.72 -
    1.73 -/**
    1.74 - * @endsection
    1.75 - */
    1.76 -
    1.77 -#define	CONTENTS_ORIGIN			0x1000000	/**< removed before bsping an entity. */
    1.78 -#define	CONTENTS_MONSTER		0x2000000	/**< should never be on a brush, only in game. */
    1.79 -#define	CONTENTS_DEBRIS			0x4000000
    1.80 -#define	CONTENTS_DETAIL			0x8000000	/**< brushes to be added after vis leafs. */
    1.81 -#define	CONTENTS_TRANSLUCENT	0x10000000	/**< auto set if any surface has trans. */
    1.82 -#define	CONTENTS_LADDER			0x20000000
    1.83 -#define CONTENTS_HITBOX			0x40000000	/**< use accurate hitboxes on trace. */
    1.84 -
    1.85 -/**
    1.86 - * @section Trace masks.
    1.87 - */
    1.88 -#define	MASK_ALL				(0xFFFFFFFF)
    1.89 -#define	MASK_SOLID				(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) 			/**< everything that is normally solid */
    1.90 -#define	MASK_PLAYERSOLID		(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) 	/**< everything that blocks player movement */
    1.91 -#define	MASK_NPCSOLID			(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) /**< blocks npc movement */
    1.92 -#define	MASK_WATER				(CONTENTS_WATER|CONTENTS_MOVEABLE|CONTENTS_SLIME) 							/**< water physics in these contents */
    1.93 -#define	MASK_OPAQUE				(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_OPAQUE) 							/**< everything that blocks line of sight for AI, lighting, etc */
    1.94 -#define MASK_OPAQUE_AND_NPCS	(MASK_OPAQUE|CONTENTS_MONSTER)										/**< everything that blocks line of sight for AI, lighting, etc, but with monsters added. */
    1.95 -#define	MASK_VISIBLE			(MASK_OPAQUE|CONTENTS_IGNORE_NODRAW_OPAQUE) 								/**< everything that blocks line of sight for players */
    1.96 -#define MASK_VISIBLE_AND_NPCS	(MASK_OPAQUE_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE) 							/**< everything that blocks line of sight for players, but with monsters added. */
    1.97 -#define	MASK_SHOT				(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_HITBOX) 	/**< bullets see these as solid */
    1.98 -#define MASK_SHOT_HULL			(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_GRATE) 	/**< non-raycasted weapons see this as solid (includes grates) */
    1.99 -#define MASK_SHOT_PORTAL		(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW) 							/**< hits solids (not grates) and passes through everything else */
   1.100 -#define MASK_SOLID_BRUSHONLY	(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_GRATE) 					/**< everything normally solid, except monsters (world+brush only) */
   1.101 -#define MASK_PLAYERSOLID_BRUSHONLY	(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_PLAYERCLIP|CONTENTS_GRATE) 			/**< everything normally solid for player movement, except monsters (world+brush only) */
   1.102 -#define MASK_NPCSOLID_BRUSHONLY	(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE) 			/**< everything normally solid for npc movement, except monsters (world+brush only) */
   1.103 -#define MASK_NPCWORLDSTATIC		(CONTENTS_SOLID|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE) 					/**< just the world, used for route rebuilding */
   1.104 -#define MASK_SPLITAREAPORTAL	(CONTENTS_WATER|CONTENTS_SLIME) 									/**< These are things that can split areaportals */
   1.105 -
   1.106 -/**
   1.107 - * @endsection
   1.108 - */
   1.109 -
   1.110 -enum RayType
   1.111 -{
   1.112 -	RayType_EndPoint,	/**< The trace ray will go from the start position to the end position. */
   1.113 -	RayType_Infinite	/**< The trace ray will go from the start position to infinity using a direction vector. */
   1.114 -};
   1.115 -
   1.116 -funcenum TraceEntityFilter
   1.117 -{
   1.118 -	/**
   1.119 -	 * Called on entity filtering.
   1.120 -	 *
   1.121 -	 * @param entity		Entity index.
   1.122 - 	 * @param contentsMask	Contents Mask.
   1.123 - 	 * @return				True to allow the current entity to be hit, otherwise false.
   1.124 - 	 */
   1.125 -	bool:public(entity, contentsMask),
   1.126 -	
   1.127 -	/**
   1.128 -	 * Called on entity filtering.
   1.129 -	 *
   1.130 -	 * @param entity		Entity index.
   1.131 - 	 * @param contentsMask	Contents Mask.
   1.132 - 	 * @param data			Data value, if used.
   1.133 - 	 * @return				True to allow the current entity to be hit, otherwise false.
   1.134 - 	 */
   1.135 -	bool:public(entity, contentsMask, any:data),
   1.136 -};
   1.137 -
   1.138 -/**
   1.139 - * Get the contents mask and the entity index at the given position.
   1.140 - *
   1.141 - * @param pos			World position to test.
   1.142 - * @param entindex		Entity index found at the given position (by reference).
   1.143 - * @return				Contents mask.
   1.144 - */
   1.145 -native TR_GetPointContents(const Float:pos[3], &entindex=-1);
   1.146 -
   1.147 -/**
   1.148 - * Get the point contents testing only the given entity index.
   1.149 - *
   1.150 - * @param entindex		Entity index to test.
   1.151 - * @param pos			World position.
   1.152 - * @return				Contents mask.
   1.153 - */
   1.154 -native TR_GetPointContentsEnt(entindex, const Float:pos[3]);
   1.155 -
   1.156 -/**
   1.157 - * Starts up a new trace ray using a global trace result.
   1.158 - *
   1.159 - * @param pos			Starting position of the ray.
   1.160 - * @param vec			Depending on RayType, it will be used as the ending point, or the direction angle.
   1.161 - * @param flags			Trace flags.
   1.162 - * @param rtype			Method to calculate the ray direction.
   1.163 - * @noreturn
   1.164 - */
   1.165 -native TR_TraceRay(const Float:pos[3], const Float:vec[3], flags, RayType:rtype);
   1.166 -
   1.167 -/**
   1.168 - * Starts up a new trace ray using a global trace result and a customized trace ray filter.
   1.169 - *
   1.170 - * Calling TR_TraceRayFilter or TR_TraceRayFilterEx from inside a filter function is 
   1.171 - * currently not allowed and may not work.
   1.172 - *
   1.173 - * @param pos			Starting position of the ray.
   1.174 - * @param vec			Depending on RayType, it will be used as the ending point, or the direction angle.
   1.175 - * @param flags			Trace flags.
   1.176 - * @param rtype			Method to calculate the ray direction.
   1.177 - * @param filter		Function to use as a filter.
   1.178 - * @param data			Arbitrary data value to pass through to the filter function.
   1.179 - * @noreturn
   1.180 - */
   1.181 -native TR_TraceRayFilter(const Float:pos[3],
   1.182 -						 const Float:vec[3],
   1.183 -						 flags,
   1.184 -						 RayType:rtype,
   1.185 -						 TraceEntityFilter:filter,
   1.186 -						 any:data=0);
   1.187 -
   1.188 -/**
   1.189 - * Starts up a new trace ray using a new trace result.
   1.190 - *
   1.191 - * @param pos			Starting position of the ray.
   1.192 - * @param vec			Depending on RayType, it will be used as the ending point, or the direction angle.
   1.193 - * @param flags			Trace flags.
   1.194 - * @param rtype			Method to calculate the ray direction.
   1.195 - * @return				Ray trace handle, which must be closed via CloseHandle().
   1.196 - */
   1.197 -native Handle:TR_TraceRayEx(const Float:pos[3], const Float:vec[3], flags, RayType:rtype);
   1.198 -
   1.199 -/**
   1.200 - * Starts up a new trace ray using a new trace result and a customized trace ray filter.
   1.201 - *
   1.202 - * Calling TR_TraceRayFilter or TR_TraceRayFilterEx from inside a filter function is 
   1.203 - * currently not allowed and may not work.
   1.204 - *
   1.205 - * @param pos			Starting position of the ray.
   1.206 - * @param vec			Depending on RayType, it will be used as the ending point, or the direction angle.
   1.207 - * @param flags			Trace flags.
   1.208 - * @param rtype			Method to calculate the ray direction.
   1.209 - * @param filter		Function to use as a filter.
   1.210 - * @param data			Arbitrary data value to pass through to the filter function.
   1.211 - * @return				Ray trace handle, which must be closed via CloseHandle().
   1.212 - */
   1.213 -native Handle:TR_TraceRayFilterEx(const Float:pos[3], 
   1.214 -								  const Float:vec[3],
   1.215 -								  flags, 
   1.216 -								  RayType:rtype, 
   1.217 -								  TraceEntityFilter:filter,
   1.218 -								  any:data=0);
   1.219 -
   1.220 -/**
   1.221 - * Returns the time fraction from a trace result (1.0 means no collision).
   1.222 - *
   1.223 - * @param hndl			A trace Handle, or INVALID_HANDLE to use a global trace result.
   1.224 - * @return				Time fraction value of the trace.
   1.225 - * @error				Invalid Handle.
   1.226 - */
   1.227 -native Float:TR_GetFraction(Handle:hndl=INVALID_HANDLE);
   1.228 -
   1.229 -/**
   1.230 - * Returns the collision position of a trace result.
   1.231 - *
   1.232 - * @param pos			Vector buffer to store data in.
   1.233 - * @param hndl			A trace Handle, or INVALID_HANDLE to use a global trace result.
   1.234 - * @noreturn
   1.235 - * @error				Invalid Handle.
   1.236 - */
   1.237 -native TR_GetEndPosition(Float:pos[3], Handle:hndl=INVALID_HANDLE);
   1.238 -
   1.239 -/**
   1.240 - * Returns the entity index that collided with the trace.
   1.241 - *
   1.242 - * @param hndl			A trace Handle, or INVALID_HANDLE to use a global trace result.
   1.243 - * @return				Entity index or -1 for no collision.
   1.244 - * @error				Invalid Handle.
   1.245 - */
   1.246 -native TR_GetEntityIndex(Handle:hndl=INVALID_HANDLE);
   1.247 -
   1.248 -/**
   1.249 - * Returns if there was any kind of collision along the trace ray.
   1.250 - *
   1.251 - * @param hndl			A trace Handle, or INVALID_HANDLE to use a global trace result.
   1.252 - * @return				True if any collision found, otherwise false.
   1.253 - * @error				Invalid Handle.
   1.254 - */
   1.255 -native bool:TR_DidHit(Handle:hndl=INVALID_HANDLE);
   1.256 -
   1.257 -/**
   1.258 - * Returns in which body hit group the trace collided if any.
   1.259 - *
   1.260 - * @param hndl			A trace Handle, or INVALID_HANDLE to use a global trace result.
   1.261 - * @return				Body hit group.
   1.262 - * @error				Invalid Handle.
   1.263 - */
   1.264 -native TR_GetHitGroup(Handle:hndl=INVALID_HANDLE);
   1.265 +/**
   1.266 + * vim: set ts=4 :
   1.267 + * =============================================================================
   1.268 + * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
   1.269 + * =============================================================================
   1.270 + *
   1.271 + * This file is part of the SourceMod/SourcePawn SDK.
   1.272 + *
   1.273 + * This program is free software; you can redistribute it and/or modify it under
   1.274 + * the terms of the GNU General Public License, version 3.0, as published by the
   1.275 + * Free Software Foundation.
   1.276 + * 
   1.277 + * This program is distributed in the hope that it will be useful, but WITHOUT
   1.278 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   1.279 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   1.280 + * details.
   1.281 + *
   1.282 + * You should have received a copy of the GNU General Public License along with
   1.283 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   1.284 + *
   1.285 + * As a special exception, AlliedModders LLC gives you permission to link the
   1.286 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   1.287 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   1.288 + * by the Valve Corporation.  You must obey the GNU General Public License in
   1.289 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   1.290 + * this exception to all derivative works.  AlliedModders LLC defines further
   1.291 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   1.292 + * or <http://www.sourcemod.net/license.php>.
   1.293 + *
   1.294 + * Version: $Id$
   1.295 + */
   1.296 +
   1.297 +#if defined _sdktools_trace_included
   1.298 + #endinput
   1.299 +#endif
   1.300 +#define _sdktools_trace_included
   1.301 +
   1.302 +#define	CONTENTS_EMPTY			0		/**< No contents. */
   1.303 +#define	CONTENTS_SOLID			0x1		/**< an eye is never valid in a solid . */
   1.304 +#define	CONTENTS_WINDOW			0x2		/**< translucent, but not watery (glass). */
   1.305 +#define	CONTENTS_AUX			0x4
   1.306 +#define	CONTENTS_GRATE			0x8		/**< alpha-tested "grate" textures.  Bullets/sight pass through, but solids don't. */
   1.307 +#define	CONTENTS_SLIME			0x10
   1.308 +#define	CONTENTS_WATER			0x20
   1.309 +#define	CONTENTS_MIST			0x40
   1.310 +#define CONTENTS_OPAQUE			0x80		/**< things that cannot be seen through (may be non-solid though). */
   1.311 +#define	LAST_VISIBLE_CONTENTS	0x80
   1.312 +#define ALL_VISIBLE_CONTENTS 	(LAST_VISIBLE_CONTENTS | (LAST_VISIBLE_CONTENTS-1))
   1.313 +#define CONTENTS_TESTFOGVOLUME	0x100
   1.314 +#define CONTENTS_UNUSED5		0x200
   1.315 +#define CONTENTS_UNUSED6		0x4000
   1.316 +#define CONTENTS_TEAM1			0x800		/**< per team contents used to differentiate collisions. */
   1.317 +#define CONTENTS_TEAM2			0x1000		/**< between players and objects on different teams. */
   1.318 +#define CONTENTS_IGNORE_NODRAW_OPAQUE	0x2000		/**< ignore CONTENTS_OPAQUE on surfaces that have SURF_NODRAW. */
   1.319 +#define CONTENTS_MOVEABLE		0x4000		/**< hits entities which are MOVETYPE_PUSH (doors, plats, etc) */
   1.320 +#define	CONTENTS_AREAPORTAL		0x8000		/**< remaining contents are non-visible, and don't eat brushes. */
   1.321 +#define	CONTENTS_PLAYERCLIP		0x10000
   1.322 +#define	CONTENTS_MONSTERCLIP	0x20000
   1.323 +
   1.324 +/**
   1.325 + * @section currents can be added to any other contents, and may be mixed
   1.326 + */
   1.327 +#define	CONTENTS_CURRENT_0		0x40000
   1.328 +#define	CONTENTS_CURRENT_90		0x80000
   1.329 +#define	CONTENTS_CURRENT_180	0x100000
   1.330 +#define	CONTENTS_CURRENT_270	0x200000
   1.331 +#define	CONTENTS_CURRENT_UP		0x400000
   1.332 +#define	CONTENTS_CURRENT_DOWN	0x800000
   1.333 +
   1.334 +/**
   1.335 + * @endsection
   1.336 + */
   1.337 +
   1.338 +#define	CONTENTS_ORIGIN			0x1000000	/**< removed before bsping an entity. */
   1.339 +#define	CONTENTS_MONSTER		0x2000000	/**< should never be on a brush, only in game. */
   1.340 +#define	CONTENTS_DEBRIS			0x4000000
   1.341 +#define	CONTENTS_DETAIL			0x8000000	/**< brushes to be added after vis leafs. */
   1.342 +#define	CONTENTS_TRANSLUCENT	0x10000000	/**< auto set if any surface has trans. */
   1.343 +#define	CONTENTS_LADDER			0x20000000
   1.344 +#define CONTENTS_HITBOX			0x40000000	/**< use accurate hitboxes on trace. */
   1.345 +
   1.346 +/**
   1.347 + * @section Trace masks.
   1.348 + */
   1.349 +#define	MASK_ALL				(0xFFFFFFFF)
   1.350 +#define	MASK_SOLID				(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) 			/**< everything that is normally solid */
   1.351 +#define	MASK_PLAYERSOLID		(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) 	/**< everything that blocks player movement */
   1.352 +#define	MASK_NPCSOLID			(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) /**< blocks npc movement */
   1.353 +#define	MASK_WATER				(CONTENTS_WATER|CONTENTS_MOVEABLE|CONTENTS_SLIME) 							/**< water physics in these contents */
   1.354 +#define	MASK_OPAQUE				(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_OPAQUE) 							/**< everything that blocks line of sight for AI, lighting, etc */
   1.355 +#define MASK_OPAQUE_AND_NPCS	(MASK_OPAQUE|CONTENTS_MONSTER)										/**< everything that blocks line of sight for AI, lighting, etc, but with monsters added. */
   1.356 +#define	MASK_VISIBLE			(MASK_OPAQUE|CONTENTS_IGNORE_NODRAW_OPAQUE) 								/**< everything that blocks line of sight for players */
   1.357 +#define MASK_VISIBLE_AND_NPCS	(MASK_OPAQUE_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE) 							/**< everything that blocks line of sight for players, but with monsters added. */
   1.358 +#define	MASK_SHOT				(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_HITBOX) 	/**< bullets see these as solid */
   1.359 +#define MASK_SHOT_HULL			(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_GRATE) 	/**< non-raycasted weapons see this as solid (includes grates) */
   1.360 +#define MASK_SHOT_PORTAL		(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW) 							/**< hits solids (not grates) and passes through everything else */
   1.361 +#define MASK_SOLID_BRUSHONLY	(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_GRATE) 					/**< everything normally solid, except monsters (world+brush only) */
   1.362 +#define MASK_PLAYERSOLID_BRUSHONLY	(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_PLAYERCLIP|CONTENTS_GRATE) 			/**< everything normally solid for player movement, except monsters (world+brush only) */
   1.363 +#define MASK_NPCSOLID_BRUSHONLY	(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE) 			/**< everything normally solid for npc movement, except monsters (world+brush only) */
   1.364 +#define MASK_NPCWORLDSTATIC		(CONTENTS_SOLID|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE) 					/**< just the world, used for route rebuilding */
   1.365 +#define MASK_SPLITAREAPORTAL	(CONTENTS_WATER|CONTENTS_SLIME) 									/**< These are things that can split areaportals */
   1.366 +
   1.367 +/**
   1.368 + * @endsection
   1.369 + */
   1.370 +
   1.371 +enum RayType
   1.372 +{
   1.373 +	RayType_EndPoint,	/**< The trace ray will go from the start position to the end position. */
   1.374 +	RayType_Infinite	/**< The trace ray will go from the start position to infinity using a direction vector. */
   1.375 +};
   1.376 +
   1.377 +funcenum TraceEntityFilter
   1.378 +{
   1.379 +	/**
   1.380 +	 * Called on entity filtering.
   1.381 +	 *
   1.382 +	 * @param entity		Entity index.
   1.383 + 	 * @param contentsMask	Contents Mask.
   1.384 + 	 * @return				True to allow the current entity to be hit, otherwise false.
   1.385 + 	 */
   1.386 +	bool:public(entity, contentsMask),
   1.387 +	
   1.388 +	/**
   1.389 +	 * Called on entity filtering.
   1.390 +	 *
   1.391 +	 * @param entity		Entity index.
   1.392 + 	 * @param contentsMask	Contents Mask.
   1.393 + 	 * @param data			Data value, if used.
   1.394 + 	 * @return				True to allow the current entity to be hit, otherwise false.
   1.395 + 	 */
   1.396 +	bool:public(entity, contentsMask, any:data),
   1.397 +};
   1.398 +
   1.399 +/**
   1.400 + * Get the contents mask and the entity index at the given position.
   1.401 + *
   1.402 + * @param pos			World position to test.
   1.403 + * @param entindex		Entity index found at the given position (by reference).
   1.404 + * @return				Contents mask.
   1.405 + */
   1.406 +native TR_GetPointContents(const Float:pos[3], &entindex=-1);
   1.407 +
   1.408 +/**
   1.409 + * Get the point contents testing only the given entity index.
   1.410 + *
   1.411 + * @param entindex		Entity index to test.
   1.412 + * @param pos			World position.
   1.413 + * @return				Contents mask.
   1.414 + */
   1.415 +native TR_GetPointContentsEnt(entindex, const Float:pos[3]);
   1.416 +
   1.417 +/**
   1.418 + * Starts up a new trace ray using a global trace result.
   1.419 + *
   1.420 + * @param pos			Starting position of the ray.
   1.421 + * @param vec			Depending on RayType, it will be used as the ending point, or the direction angle.
   1.422 + * @param flags			Trace flags.
   1.423 + * @param rtype			Method to calculate the ray direction.
   1.424 + * @noreturn
   1.425 + */
   1.426 +native TR_TraceRay(const Float:pos[3], const Float:vec[3], flags, RayType:rtype);
   1.427 +
   1.428 +/**
   1.429 + * Starts up a new trace ray using a global trace result and a customized trace ray filter.
   1.430 + *
   1.431 + * Calling TR_TraceRayFilter or TR_TraceRayFilterEx from inside a filter function is 
   1.432 + * currently not allowed and may not work.
   1.433 + *
   1.434 + * @param pos			Starting position of the ray.
   1.435 + * @param vec			Depending on RayType, it will be used as the ending point, or the direction angle.
   1.436 + * @param flags			Trace flags.
   1.437 + * @param rtype			Method to calculate the ray direction.
   1.438 + * @param filter		Function to use as a filter.
   1.439 + * @param data			Arbitrary data value to pass through to the filter function.
   1.440 + * @noreturn
   1.441 + */
   1.442 +native TR_TraceRayFilter(const Float:pos[3],
   1.443 +						 const Float:vec[3],
   1.444 +						 flags,
   1.445 +						 RayType:rtype,
   1.446 +						 TraceEntityFilter:filter,
   1.447 +						 any:data=0);
   1.448 +
   1.449 +/**
   1.450 + * Starts up a new trace ray using a new trace result.
   1.451 + *
   1.452 + * @param pos			Starting position of the ray.
   1.453 + * @param vec			Depending on RayType, it will be used as the ending point, or the direction angle.
   1.454 + * @param flags			Trace flags.
   1.455 + * @param rtype			Method to calculate the ray direction.
   1.456 + * @return				Ray trace handle, which must be closed via CloseHandle().
   1.457 + */
   1.458 +native Handle:TR_TraceRayEx(const Float:pos[3], const Float:vec[3], flags, RayType:rtype);
   1.459 +
   1.460 +/**
   1.461 + * Starts up a new trace ray using a new trace result and a customized trace ray filter.
   1.462 + *
   1.463 + * Calling TR_TraceRayFilter or TR_TraceRayFilterEx from inside a filter function is 
   1.464 + * currently not allowed and may not work.
   1.465 + *
   1.466 + * @param pos			Starting position of the ray.
   1.467 + * @param vec			Depending on RayType, it will be used as the ending point, or the direction angle.
   1.468 + * @param flags			Trace flags.
   1.469 + * @param rtype			Method to calculate the ray direction.
   1.470 + * @param filter		Function to use as a filter.
   1.471 + * @param data			Arbitrary data value to pass through to the filter function.
   1.472 + * @return				Ray trace handle, which must be closed via CloseHandle().
   1.473 + */
   1.474 +native Handle:TR_TraceRayFilterEx(const Float:pos[3], 
   1.475 +								  const Float:vec[3],
   1.476 +								  flags, 
   1.477 +								  RayType:rtype, 
   1.478 +								  TraceEntityFilter:filter,
   1.479 +								  any:data=0);
   1.480 +
   1.481 +/**
   1.482 + * Returns the time fraction from a trace result (1.0 means no collision).
   1.483 + *
   1.484 + * @param hndl			A trace Handle, or INVALID_HANDLE to use a global trace result.
   1.485 + * @return				Time fraction value of the trace.
   1.486 + * @error				Invalid Handle.
   1.487 + */
   1.488 +native Float:TR_GetFraction(Handle:hndl=INVALID_HANDLE);
   1.489 +
   1.490 +/**
   1.491 + * Returns the collision position of a trace result.
   1.492 + *
   1.493 + * @param pos			Vector buffer to store data in.
   1.494 + * @param hndl			A trace Handle, or INVALID_HANDLE to use a global trace result.
   1.495 + * @noreturn
   1.496 + * @error				Invalid Handle.
   1.497 + */
   1.498 +native TR_GetEndPosition(Float:pos[3], Handle:hndl=INVALID_HANDLE);
   1.499 +
   1.500 +/**
   1.501 + * Returns the entity index that collided with the trace.
   1.502 + *
   1.503 + * @param hndl			A trace Handle, or INVALID_HANDLE to use a global trace result.
   1.504 + * @return				Entity index or -1 for no collision.
   1.505 + * @error				Invalid Handle.
   1.506 + */
   1.507 +native TR_GetEntityIndex(Handle:hndl=INVALID_HANDLE);
   1.508 +
   1.509 +/**
   1.510 + * Returns if there was any kind of collision along the trace ray.
   1.511 + *
   1.512 + * @param hndl			A trace Handle, or INVALID_HANDLE to use a global trace result.
   1.513 + * @return				True if any collision found, otherwise false.
   1.514 + * @error				Invalid Handle.
   1.515 + */
   1.516 +native bool:TR_DidHit(Handle:hndl=INVALID_HANDLE);
   1.517 +
   1.518 +/**
   1.519 + * Returns in which body hit group the trace collided if any.
   1.520 + *
   1.521 + * @param hndl			A trace Handle, or INVALID_HANDLE to use a global trace result.
   1.522 + * @return				Body hit group.
   1.523 + * @error				Invalid Handle.
   1.524 + */
   1.525 +native TR_GetHitGroup(Handle:hndl=INVALID_HANDLE);
   1.526 +
   1.527 +/**
   1.528 + * Find the normal vector to the collison plane of a trace.
   1.529 + *
   1.530 + * @param hndl		A trace Handle, or INVALID_HANDLE to use a global trace result.
   1.531 + * @param normal	Vector buffer to store the vector normal to the collision plane
   1.532 + * @noreturn
   1.533 + * @error			Invalid Handle
   1.534 + */
   1.535 +native TR_GetPlaneNormal(Handle:hndl=INVALID_HANDLE, Float:normal[3]);