1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/plugins/include/sdktools_trace.inc Sun Jul 06 04:49:55 2008 +0000
1.3 @@ -0,0 +1,367 @@
1.4 +/**
1.5 + * vim: set ts=4 :
1.6 + * =============================================================================
1.7 + * SourceMod (C)2004-2008 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
1.161 + * ending point, or the direction angle.
1.162 + * @param flags Trace flags.
1.163 + * @param rtype Method to calculate the ray direction.
1.164 + * @noreturn
1.165 + */
1.166 +native TR_TraceRay(const Float:pos[3],
1.167 + const Float:vec[3],
1.168 + flags,
1.169 + RayType:rtype);
1.170 +
1.171 +/**
1.172 + * Starts up a new trace hull using a global trace result.
1.173 + *
1.174 + * @param pos Starting position of the ray.
1.175 + * @param vec Ending position of the ray.
1.176 + * @param mins Hull minimum size.
1.177 + * @param maxs Hull maximum size.
1.178 + * @param flags Trace flags.
1.179 + * @noreturn
1.180 + */
1.181 +native TR_TraceHull(const Float:pos[3],
1.182 + const Float:vec[3],
1.183 + const Float:mins[3],
1.184 + const Float:maxs[3],
1.185 + flags);
1.186 +
1.187 +/**
1.188 + * Starts up a new trace ray using a global trace result and a customized
1.189 + * trace ray filter.
1.190 + *
1.191 + * Calling TR_Trace*Filter or TR_Trace*FilterEx from inside a filter
1.192 + * function is currently not allowed and may not work.
1.193 + *
1.194 + * @param pos Starting position of the ray.
1.195 + * @param vec Depending on RayType, it will be used as the ending
1.196 + * point, or the direction angle.
1.197 + * @param flags Trace flags.
1.198 + * @param rtype Method to calculate the ray direction.
1.199 + * @param filter Function to use as a filter.
1.200 + * @param data Arbitrary data value to pass through to the filter
1.201 + * function.
1.202 + * @noreturn
1.203 + */
1.204 +native TR_TraceRayFilter(const Float:pos[3],
1.205 + const Float:vec[3],
1.206 + flags,
1.207 + RayType:rtype,
1.208 + TraceEntityFilter:filter,
1.209 + any:data=0);
1.210 +
1.211 +/**
1.212 + * Starts up a new trace hull using a global trace result and a customized
1.213 + * trace ray filter.
1.214 + *
1.215 + * Calling TR_Trace*Filter or TR_Trace*FilterEx from inside a filter
1.216 + * function is currently not allowed and may not work.
1.217 + *
1.218 + * @param pos Starting position of the ray.
1.219 + * @param vec Depending on RayType, it will be used as the ending
1.220 + * point, or the direction angle.
1.221 + * @param mins Hull minimum size.
1.222 + * @param maxs Hull maximum size.
1.223 + * @param flags Trace flags.
1.224 + * @param filter Function to use as a filter.
1.225 + * @param data Arbitrary data value to pass through to the filter
1.226 + * function.
1.227 + * @noreturn
1.228 + */
1.229 +native TR_TraceHullFilter(const Float:pos[3],
1.230 + const Float:vec[3],
1.231 + const Float:mins[3],
1.232 + const Float:maxs[3],
1.233 + flags,
1.234 + TraceEntityFilter:filter,
1.235 + any:data=0);
1.236 +
1.237 +/**
1.238 + * Starts up a new trace ray using a new trace result.
1.239 + *
1.240 + * @param pos Starting position of the ray.
1.241 + * @param vec Depending on RayType, it will be used as the ending
1.242 + * point, or the direction angle.
1.243 + * @param flags Trace flags.
1.244 + * @param rtype Method to calculate the ray direction.
1.245 + * @return Ray trace handle, which must be closed via CloseHandle().
1.246 + */
1.247 +native Handle:TR_TraceRayEx(const Float:pos[3],
1.248 + const Float:vec[3],
1.249 + flags,
1.250 + RayType:rtype);
1.251 +
1.252 +/**
1.253 + * Starts up a new trace hull using a new trace result.
1.254 + *
1.255 + * @param pos Starting position of the ray.
1.256 + * @param vec Ending position of the ray.
1.257 + * @param mins Hull minimum size.
1.258 + * @param maxs Hull maximum size.
1.259 + * @param flags Trace flags.
1.260 + * @return Ray trace handle, which must be closed via CloseHandle().
1.261 + */
1.262 +native Handle:TR_TraceHullEx(const Float:pos[3],
1.263 + const Float:vec[3],
1.264 + const Float:mins[3],
1.265 + const Float:maxs[3],
1.266 + flags);
1.267 +
1.268 +/**
1.269 + * Starts up a new trace ray using a new trace result and a customized
1.270 + * trace ray filter.
1.271 + *
1.272 + * Calling TR_Trace*Filter or TR_TraceRay*Ex from inside a filter
1.273 + * function is currently not allowed and may not work.
1.274 + *
1.275 + * @param pos Starting position of the ray.
1.276 + * @param vec Depending on RayType, it will be used as the ending
1.277 + * point, or the direction angle.
1.278 + * @param flags Trace flags.
1.279 + * @param rtype Method to calculate the ray direction.
1.280 + * @param filter Function to use as a filter.
1.281 + * @param data Arbitrary data value to pass through to the filter function.
1.282 + * @return Ray trace handle, which must be closed via CloseHandle().
1.283 + */
1.284 +native Handle:TR_TraceRayFilterEx(const Float:pos[3],
1.285 + const Float:vec[3],
1.286 + flags,
1.287 + RayType:rtype,
1.288 + TraceEntityFilter:filter,
1.289 + any:data=0);
1.290 +
1.291 +/**
1.292 + * Starts up a new trace hull using a new trace result and a customized
1.293 + * trace ray filter.
1.294 + *
1.295 + * Calling TR_Trace*Filter or TR_Trace*FilterEx from inside a filter
1.296 + * function is currently not allowed and may not work.
1.297 + *
1.298 + * @param pos Starting position of the ray.
1.299 + * @param vec Ending position of the ray.
1.300 + * @param mins Hull minimum size.
1.301 + * @param maxs Hull maximum size.
1.302 + * @param flags Trace flags.
1.303 + * @param filter Function to use as a filter.
1.304 + * @param data Arbitrary data value to pass through to the filter function.
1.305 + * @return Ray trace handle, which must be closed via CloseHandle().
1.306 + */
1.307 +native Handle:TR_TraceHullFilterEx(const Float:pos[3],
1.308 + const Float:vec[3],
1.309 + const Float:mins[3],
1.310 + const Float:maxs[3],
1.311 + flags,
1.312 + TraceEntityFilter:filter,
1.313 + any:data=0);
1.314 +
1.315 +/**
1.316 + * Returns the time fraction from a trace result (1.0 means no collision).
1.317 + *
1.318 + * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
1.319 + * @return Time fraction value of the trace.
1.320 + * @error Invalid Handle.
1.321 + */
1.322 +native Float:TR_GetFraction(Handle:hndl=INVALID_HANDLE);
1.323 +
1.324 +/**
1.325 + * Returns the collision position of a trace result.
1.326 + *
1.327 + * @param pos Vector buffer to store data in.
1.328 + * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
1.329 + * @noreturn
1.330 + * @error Invalid Handle.
1.331 + */
1.332 +native TR_GetEndPosition(Float:pos[3], Handle:hndl=INVALID_HANDLE);
1.333 +
1.334 +/**
1.335 + * Returns the entity index that collided with the trace.
1.336 + *
1.337 + * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
1.338 + * @return Entity index or -1 for no collision.
1.339 + * @error Invalid Handle.
1.340 + */
1.341 +native TR_GetEntityIndex(Handle:hndl=INVALID_HANDLE);
1.342 +
1.343 +/**
1.344 + * Returns if there was any kind of collision along the trace ray.
1.345 + *
1.346 + * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
1.347 + * @return True if any collision found, otherwise false.
1.348 + * @error Invalid Handle.
1.349 + */
1.350 +native bool:TR_DidHit(Handle:hndl=INVALID_HANDLE);
1.351 +
1.352 +/**
1.353 + * Returns in which body hit group the trace collided if any.
1.354 + *
1.355 + * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
1.356 + * @return Body hit group.
1.357 + * @error Invalid Handle.
1.358 + */
1.359 +native TR_GetHitGroup(Handle:hndl=INVALID_HANDLE);
1.360 +
1.361 +/**
1.362 + * Find the normal vector to the collison plane of a trace.
1.363 + *
1.364 + * @param hndl A trace Handle, or INVALID_HANDLE to use a global trace result.
1.365 + * @param normal Vector buffer to store the vector normal to the collision plane
1.366 + * @noreturn
1.367 + * @error Invalid Handle
1.368 + */
1.369 +native TR_GetPlaneNormal(Handle:hndl, Float:normal[3]);
1.370 +