plugins/include/sdktools_trace.inc
author David Anderson <dvander@alliedmods.net>
Tue Aug 14 01:00:42 2007 +0000 (2007-08-14)
changeset 1324 9d1983bf06c7
parent 1075 6ebd28ffd880
child 1330 ab94316bb52b
permissions -rw-r--r--
added SQL_CheckConfig() so sql admin plugins can default back
     1 /**
     2  * vim: set ts=4 :
     3  * ===============================================================
     4  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     5  * ===============================================================
     6  *
     7  *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
     8  * or modified under the Terms and Conditions of its License Agreement, which is found 
     9  * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
    10  * may change at any time.  To view the latest information, see:
    11  *   http://www.sourcemod.net/license.php
    12  *
    13  * Version: $Id$
    14  */
    15 
    16 #if defined _sdktools_trace_included
    17  #endinput
    18 #endif
    19 #define _sdktools_trace_included
    20 
    21 #define	CONTENTS_EMPTY			0		/**< No contents. */
    22 #define	CONTENTS_SOLID			0x1		/**< an eye is never valid in a solid . */
    23 #define	CONTENTS_WINDOW			0x2		/**< translucent, but not watery (glass). */
    24 #define	CONTENTS_AUX			0x4
    25 #define	CONTENTS_GRATE			0x8		/**< alpha-tested "grate" textures.  Bullets/sight pass through, but solids don't. */
    26 #define	CONTENTS_SLIME			0x10
    27 #define	CONTENTS_WATER			0x20
    28 #define	CONTENTS_MIST			0x40
    29 #define CONTENTS_OPAQUE			0x80		/**< things that cannot be seen through (may be non-solid though). */
    30 #define	LAST_VISIBLE_CONTENTS		0x80
    31 #define ALL_VISIBLE_CONTENTS 		(LAST_VISIBLE_CONTENTS | (LAST_VISIBLE_CONTENTS-1))
    32 #define CONTENTS_TESTFOGVOLUME		0x100
    33 #define CONTENTS_UNUSED5		0x200
    34 #define CONTENTS_UNUSED6		0x4000
    35 #define CONTENTS_TEAM1			0x800		/**< per team contents used to differentiate collisions. */
    36 #define CONTENTS_TEAM2			0x1000		/**< between players and objects on different teams. */
    37 #define CONTENTS_IGNORE_NODRAW_OPAQUE	0x2000		/**< ignore CONTENTS_OPAQUE on surfaces that have SURF_NODRAW. */
    38 #define CONTENTS_MOVEABLE		0x4000		/**< hits entities which are MOVETYPE_PUSH (doors, plats, etc) */
    39 #define	CONTENTS_AREAPORTAL		0x8000		/**< remaining contents are non-visible, and don't eat brushes. */
    40 #define	CONTENTS_PLAYERCLIP		0x10000
    41 #define	CONTENTS_MONSTERCLIP		0x20000
    42 
    43 /**
    44  * @section currents can be added to any other contents, and may be mixed
    45  */
    46 #define	CONTENTS_CURRENT_0		0x40000
    47 #define	CONTENTS_CURRENT_90		0x80000
    48 #define	CONTENTS_CURRENT_180		0x100000
    49 #define	CONTENTS_CURRENT_270		0x200000
    50 #define	CONTENTS_CURRENT_UP		0x400000
    51 #define	CONTENTS_CURRENT_DOWN		0x800000
    52 
    53 /**
    54  * @endsection
    55  */
    56 
    57 #define	CONTENTS_ORIGIN			0x1000000	/**< removed before bsping an entity. */
    58 #define	CONTENTS_MONSTER		0x2000000	/**< should never be on a brush, only in game. */
    59 #define	CONTENTS_DEBRIS			0x4000000
    60 #define	CONTENTS_DETAIL			0x8000000	/**< brushes to be added after vis leafs. */
    61 #define	CONTENTS_TRANSLUCENT		0x10000000	/**< auto set if any surface has trans. */
    62 #define	CONTENTS_LADDER			0x20000000
    63 #define CONTENTS_HITBOX			0x40000000	/**< use accurate hitboxes on trace. */
    64 
    65 /**
    66  * @section Trace masks.
    67  */
    68 #define	MASK_ALL			(0xFFFFFFFF)
    69 #define	MASK_SOLID			(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) 			/**< everything that is normally solid */
    70 #define	MASK_PLAYERSOLID		(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) 	/**< everything that blocks player movement */
    71 #define	MASK_NPCSOLID			(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) /**< blocks npc movement */
    72 #define	MASK_WATER			(CONTENTS_WATER|CONTENTS_MOVEABLE|CONTENTS_SLIME) 							/**< water physics in these contents */
    73 #define	MASK_OPAQUE			(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_OPAQUE) 							/**< everything that blocks line of sight for AI, lighting, etc */
    74 #define MASK_OPAQUE_AND_NPCS		(MASK_OPAQUE|CONTENTS_MONSTER)										/**< everything that blocks line of sight for AI, lighting, etc, but with monsters added. */
    75 #define	MASK_VISIBLE			(MASK_OPAQUE|CONTENTS_IGNORE_NODRAW_OPAQUE) 								/**< everything that blocks line of sight for players */
    76 #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. */
    77 #define	MASK_SHOT			(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_HITBOX) 	/**< bullets see these as solid */
    78 #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) */
    79 #define MASK_SHOT_PORTAL		(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW) 							/**< hits solids (not grates) and passes through everything else */
    80 #define MASK_SOLID_BRUSHONLY		(CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_GRATE) 					/**< everything normally solid, except monsters (world+brush only) */
    81 #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) */
    82 #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) */
    83 #define MASK_NPCWORLDSTATIC		(CONTENTS_SOLID|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE) 					/**< just the world, used for route rebuilding */
    84 #define MASK_SPLITAREAPORTAL		(CONTENTS_WATER|CONTENTS_SLIME) 									/**< These are things that can split areaportals */
    85 
    86 /**
    87  * @endsection
    88  */
    89 
    90 enum RayType
    91 {
    92 	RayType_EndPoint,	/**< The trace ray will go from the start position to the end position. */
    93 	RayType_Infinite	/**< The trace ray will go from the start position to infinity using a direction vector. */
    94 };
    95 
    96 /**
    97  * Called on entity filtering.
    98  *
    99  * @param entity		Entity index.
   100  * @param contentsMask		Contents Mask.
   101  * @return			True to allow the current entity to be hit, otherwise false.
   102  */
   103 functag TraceEntityFilter bool:public(entity, contentsMask);
   104 
   105 /**
   106  * Get the contents mask and the entity index at the given position.
   107  *
   108  * @param pos			World position to test.
   109  * @param entindex		Entity index found at the given position (by reference).
   110  * @return			Contents mask.
   111  */
   112 native TR_GetPointContents(const Float:pos[3], &entindex=-1);
   113 
   114 /**
   115  * Get the point contents testing only the given entity index.
   116  *
   117  * @param entindex		Entity index to test.
   118  * @param pos			World position.
   119  * @return			Contents mask.
   120  */
   121 native TR_GetPointContentsEnt(entindex, const Float:pos[3]);
   122 
   123 /**
   124  * Starts up a new trace ray using a global trace result.
   125  *
   126  * @param pos			Starting position of the ray.
   127  * @param vec			Depending on RayType, it will be used as the ending point, or the direction angle.
   128  * @param flags			Trace flags.
   129  * @param rtype			Method to calculate the ray direction.
   130  * @noreturn
   131  */
   132 native TR_TraceRay(const Float:pos[3], const Float:vec[3], flags, RayType:rtype);
   133 
   134 /**
   135  * Starts up a new trace ray using a global trace result and a customized trace ray filter.
   136  *
   137  * @param pos			Starting position of the ray.
   138  * @param vec			Depending on RayType, it will be used as the ending point, or the direction angle.
   139  * @param flags			Trace flags.
   140  * @param rtype			Method to calculate the ray direction.
   141  * @param filter		Function to use as a filter.
   142  * @noreturn
   143  */
   144 native TR_TraceRayFilter(const Float:pos[3], const Float:vec[3], flags, RayType:rtype, TraceEntityFilter:filter);
   145 
   146 /**
   147  * Starts up a new trace ray using a new trace result.
   148  *
   149  * @param pos			Starting position of the ray.
   150  * @param vec			Depending on RayType, it will be used as the ending point, or the direction angle.
   151  * @param flags			Trace flags.
   152  * @param rtype			Method to calculate the ray direction.
   153  * @return			Ray trace handle.
   154  * @note Traces are closed with CloseHandle().
   155  */
   156 native Handle:TR_TraceRayEx(const Float:pos[3], const Float:vec[3], flags, RayType:rtype);
   157 
   158 /**
   159  * Starts up a new trace ray using a new trace result and a customized trace ray filter.
   160  *
   161  * @param pos			Starting position of the ray.
   162  * @param vec			Depending on RayType, it will be used as the ending point, or the direction angle.
   163  * @param flags			Trace flags.
   164  * @param rtype			Method to calculate the ray direction.
   165  * @param filter		Function to use as a filter.
   166  * @return			Ray trace handle.
   167  * @note Traces are closed with CloseHandle().
   168  */
   169 native Handle:TR_TraceRayFilterEx(const Float:pos[3], const Float:vec[3], flags, RayType:rtype, TraceEntityFilter:filter);
   170 
   171 /**
   172  * Returns the time fraction from a trace result (1.0 means no collision).
   173  *
   174  * @param hndl			A trace Handle, or INVALID_HANDLE to use a global trace result.
   175  * @return			Time fraction value of the trace.
   176  * @error			Invalid Handle.
   177  */
   178 native Float:TR_GetFraction(Handle:hndl=INVALID_HANDLE);
   179 
   180 /**
   181  * Returns the collision position of a trace result.
   182  *
   183  * @param pos			Vector buffer to store data in.
   184  * @param hndl			A trace Handle, or INVALID_HANDLE to use a global trace result.
   185  * @noreturn
   186  * @error			Invalid Handle.
   187  */
   188 native TR_GetEndPosition(Float:pos[3], Handle:hndl=INVALID_HANDLE);
   189 
   190 /**
   191  * Returns the entity index that collided with the trace.
   192  *
   193  * @param hndl			A trace Handle, or INVALID_HANDLE to use a global trace result.
   194  * @return			Entity index or -1 for no collision.
   195  * @error			Invalid Handle.
   196  */
   197 native TR_GetEntityIndex(Handle:hndl=INVALID_HANDLE);
   198 
   199 /**
   200  * Returns if there was any kind of collision along the trace ray.
   201  *
   202  * @param hndl			A trace Handle, or INVALID_HANDLE to use a global trace result.
   203  * @return			True if any collision found, otherwise false.
   204  * @error			Invalid Handle.
   205  */
   206 native bool:TR_DidHit(Handle:hndl=INVALID_HANDLE);
   207 
   208 /**
   209  * Returns in which body hit group the trace collided if any.
   210  *
   211  * @param hndl			A trace Handle, or INVALID_HANDLE to use a global trace result.
   212  * @return			Body hit group.
   213  * @error			Invalid Handle.
   214  */
   215 native TR_GetHitGroup(Handle:hndl=INVALID_HANDLE);