plugins/include/tf2.inc
author Nicholas Hastings <skamonkey@gmail.com>
Fri Oct 01 10:46:21 2010 -0400 (2010-10-01)
changeset 3128 337f190aaf4b
parent 3125 5788be8f69bd
child 3147 b6db3d09eb79
permissions -rw-r--r--
Fixed/updated TF2_DisguisePlayer (bug 4641, r=fyren).
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
     5  * =============================================================================
     6  *
     7  * This file is part of the SourceMod/SourcePawn SDK.
     8  *
     9  * This program is free software; you can redistribute it and/or modify it under
    10  * the terms of the GNU General Public License, version 3.0, as published by the
    11  * Free Software Foundation.
    12  * 
    13  * This program is distributed in the hope that it will be useful, but WITHOUT
    14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    15  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    16  * details.
    17  *
    18  * You should have received a copy of the GNU General Public License along with
    19  * this program.  If not, see <http://www.gnu.org/licenses/>.
    20  *
    21  * As a special exception, AlliedModders LLC gives you permission to link the
    22  * code of this program (as well as its derivative works) to "Half-Life 2," the
    23  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    24  * by the Valve Corporation.  You must obey the GNU General Public License in
    25  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    26  * this exception to all derivative works.  AlliedModders LLC defines further
    27  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    28  * or <http://www.sourcemod.net/license.php>.
    29  *
    30  * Version: $Id$
    31  */
    32 
    33 #if defined _tf2_included
    34  #endinput
    35 #endif
    36 #define _tf2_included
    37 
    38 #define TF_STUNFLAG_SLOWDOWN        (1 << 0)	// activates slowdown modifier
    39 #define TF_STUNFLAG_BONKSTUCK       (1 << 1)	// bonk sound, stuck
    40 #define TF_STUNFLAG_LIMITMOVEMENT   (1 << 2)	// disable forward/backward movement
    41 #define TF_STUNFLAG_CHEERSOUND      (1 << 3)	// cheering sound
    42 #define TF_STUNFLAG_NOSOUNDOREFFECT (1 << 5)	// no sound or particle
    43 #define TF_STUNFLAG_THIRDPERSON     (1 << 6)	// panic animation
    44 #define TF_STUNFLAG_GHOSTEFFECT     (1 << 7)	// ghost particles
    45 
    46 #define TF_STUNFLAGS_LOSERSTATE     TF_STUNFLAG_SLOWDOWN|TF_STUNFLAG_NOSOUNDOREFFECT|TF_STUNFLAG_THIRDPERSON
    47 #define TF_STUNFLAGS_GHOSTSCARE     TF_STUNFLAG_GHOSTEFFECT|TF_STUNFLAG_THIRDPERSON
    48 #define TF_STUNFLAGS_SMALLBONK      TF_STUNFLAG_THIRDPERSON|TF_STUNFLAG_SLOWDOWN
    49 #define TF_STUNFLAGS_NORMALBONK     TF_STUNFLAG_BONKSTUCK
    50 #define TF_STUNFLAGS_BIGBONK        TF_STUNFLAG_CHEERSOUND|TF_STUNFLAG_BONKSTUCK
    51 
    52 enum TFClassType
    53 {
    54 	TFClass_Unknown = 0,
    55 	TFClass_Scout,
    56 	TFClass_Sniper,
    57 	TFClass_Soldier,
    58 	TFClass_DemoMan,
    59 	TFClass_Medic,
    60 	TFClass_Heavy,
    61 	TFClass_Pyro,
    62 	TFClass_Spy,
    63 	TFClass_Engineer
    64 };
    65 
    66 enum TFTeam
    67 {
    68 	TFTeam_Unassigned = 0,
    69 	TFTeam_Spectator = 1,
    70 	TFTeam_Red = 2,
    71 	TFTeam_Blue = 3	
    72 };
    73 
    74 enum TFCond
    75 {
    76 	TFCond_Slowed = 0,
    77 	TFCond_Zoomed,
    78 	TFCond_Disguising,
    79 	TFCond_Disguised,
    80 	TFCond_Cloaked,
    81 	TFCond_Ubercharged,
    82 	TFCond_TeleportedGlow,
    83 	TFCond_Taunting,
    84 	TFCond_UberchargeFading,
    85 	TFCond_Unknown1,
    86 	TFCond_Teleporting,
    87 	TFCond_Kritzkrieged,
    88 	TFCond_Unknown2,
    89 	TFCond_DeadRingered,
    90 	TFCond_Bonked,
    91 	TFCond_Dazed,
    92 	TFCond_Buffed,
    93 	TFCond_Charging,
    94 	TFCond_DemoBuff,
    95 	TFCond_CritCola,
    96 	TFCond_Healing,
    97 	
    98 	TFCond_OnFire = 22,
    99 	TFCond_Overhealed,
   100 	TFCond_Jarated,
   101 	TFCond_Bleeding,
   102 	TFCond_DefenseBuffed,
   103 	TFCond_Milked
   104 };
   105 
   106 enum TFHoliday
   107 {
   108 	TFHoliday_None = 1,
   109 	TFHoliday_Halloween,
   110 	TFHoliday_Birthday
   111 };
   112 
   113 enum TFObjectType
   114 {
   115 	TFObject_CartDispenser = 0,
   116 	TFObject_Dispenser = 0,
   117 	TFObject_Teleporter = 1,
   118 	TFObject_Sentry = 2,
   119 	TFObject_Sapper = 3
   120 };
   121 
   122 enum TFObjectMode
   123 {
   124 	TFObjectMode_None = 0,
   125 	TFObjectMode_Entrance = 0,
   126 	TFObjectMode_Exit = 1
   127 };
   128 
   129 /**
   130  * Sets a client on fire for 10 seconds.
   131  *
   132  * @param client		Player's index.
   133  * @noreturn
   134  * @error				Invalid client index, client not in game, or no mod support.
   135  */
   136 native TF2_IgnitePlayer(client, target);
   137 
   138 /**
   139  * Respawns a client
   140  *
   141  * @param client		Player's index.
   142  * @noreturn
   143  * @error				Invalid client index, client not in game, or no mod support.
   144  */
   145 native TF2_RespawnPlayer(client);
   146 
   147 /**
   148  * Regenerates a client's health and ammunition
   149  *
   150  * @param client		Player's index.
   151  * @noreturn
   152  * @error				Invalid client index, client not in game, or no mod support.
   153  */
   154 native TF2_RegeneratePlayer(client);
   155 
   156 /**
   157  * Adds a condition to a player
   158  *
   159  * @param client		Player's index.
   160  * @param condition		Integer identifier of condition to apply.
   161  * @param duration		Duration of condition (does not apply to all conditions).
   162  * @noreturn
   163  * @error				Invalid client index, client not in game, or no mod support.
   164  */
   165 native TF2_AddCondition(client, TFCond:condition, Float:duration);
   166 
   167 /**
   168  * Removes a condition from a player
   169  *
   170  * @param client		Player's index.
   171  * @param condition		Integer identifier of condition to remove.
   172  * @noreturn
   173  * @error				Invalid client index, client not in game, or no mod support.
   174  */
   175 native TF2_RemoveCondition(client, TFCond:condition);
   176 
   177 /**
   178  * Enables/disables PowerPlay mode on a player.
   179  *
   180  * @param client		Player's index.
   181  * @param enabled		Whether to enable or disable PowerPlay on player.
   182  * @noreturn
   183  * @error				Invalid client index, client not in game, or no mod support.
   184  */
   185 native TF2_SetPlayerPowerPlay(client, bool:enabled);
   186 
   187 /**
   188  * Disguises a client to the given model and team. Only has an effect on spies.
   189  *
   190  * Note: This only starts the disguise process and a delay occurs before the spy is fully disguised
   191  *
   192  * @param client		Player's index.
   193  * @param team			Team to disguise the player as (only TFTeam_Red and TFTeam_Blue have an effect)
   194  * @param class			TFClassType class to disguise the player as
   195  * @param target		Specific target player to disguise as (0 for any)
   196  * @noreturn
   197  * @error				Invalid client index, client not in game, or no mod support.
   198  */
   199 native TF2_DisguisePlayer(client, TFTeam:team, TFClassType:class, target=0);
   200 
   201 /**
   202  * Removes the current disguise from a client. Only has an effect on spies.
   203  *
   204  * @param client		Player's index.
   205  * @noreturn
   206  * @error				Invalid client index, client not in game, or no mod support.
   207  */
   208 native TF2_RemovePlayerDisguise(client);
   209 
   210 /**
   211  * Stuns a client
   212  *
   213  * @param client		Player's index.
   214  * @param float			Duration of stun.
   215  * @param float			Slowdown percent (as decimal, 0.00-1.00)
   216  *						(ignored if TF_STUNFLAG_SLOWDOWN is not set.
   217  * @param int			Stun flags.
   218  * @param attacker		Attacker's index (0 is allowed for world).
   219  * @noreturn
   220  */
   221 native TF2_StunPlayer(client, Float:duration, Float:slowdown=0.0, stunflags, attacker=0);
   222 
   223 /**
   224  * Induces the bleed effect on a client
   225  *
   226  * @param client		Player's index.
   227  * @param victim		Victim's index.
   228  * @param float			Duration of bleeding (in seconds).
   229  * @noreturn
   230  */
   231 native TF2_MakeBleed(client, victim, Float:duration);
   232 
   233 /**
   234  * Retrieves the entity index of the CPlayerResource entity
   235  *
   236  * @return				The current resource entity index.
   237  */
   238 native TF2_GetResourceEntity();
   239 
   240 /**
   241  * Finds the TFClassType for a given class name.
   242  *
   243  * @param classname		A classname string such as "sniper" or "demoman"
   244  * @return				A TFClassType constant.
   245  */
   246 native TFClassType:TF2_GetClass(const String:classname[]);
   247 
   248 /**
   249  * Called on weapon fire to decide if the current shot should be critical.
   250  * Return Plugin_Continue to let the original calculation or return a higher
   251  * action to override the decision with the value of 'result'
   252  *
   253  * @note Since critical shots are also calculated client side any changes made with
   254  *		 this will not show for the shooter. Projectile weapons such as the rocketlauncher
   255  *		 and demoman weapons will show a critical bullet but no critical sound effect.
   256  *		 Bullet hits should appear as expected.
   257  *
   258  * @param client		Client Index.
   259  * @param weapon		Weapon entity Index.
   260  * @param weaponname	Classname of the weapon.
   261  * @param result		Buffer param for the result of the decision.
   262  */
   263 forward Action:TF2_CalcIsAttackCritical(client, weapon, String:weaponname[], &bool:result);
   264 
   265 /**
   266  * Called when the game checks to see if the current day is one of its tracked holidays
   267  *
   268  * @note Change the value of holiday and return Plugin_Changed to override.
   269  *       Return Plugin_Continue for no change.
   270  *
   271  * @param holiday		Current Holiday
   272  */
   273 forward Action:TF2_OnGetHoliday(&TFHoliday:holiday);
   274 
   275 /**
   276  * Do not edit below this line!
   277  */
   278 public Extension:__ext_tf2 = 
   279 {
   280 	name = "TF2 Tools",
   281 	file = "game.tf2.ext",
   282 	autoload = 0,
   283 #if defined REQUIRE_EXTENSIONS
   284 	required = 1,
   285 #else
   286 	required = 0,
   287 #endif
   288 };
   289 
   290 #if !defined REQUIRE_EXTENSIONS
   291 public __ext_tf2_SetNTVOptional()
   292 {
   293 	MarkNativeAsOptional("TF2_IgnitePlayer");
   294 	MarkNativeAsOptional("TF2_RespawnPlayer");
   295 	MarkNativeAsOptional("TF2_RegeneratePlayer");
   296 	MarkNativeAsOptional("TF2_AddCondition");
   297 	MarkNativeAsOptional("TF2_RemoveCondition");
   298 	MarkNativeAsOptional("TF2_SetPlayerPowerPlay");
   299 	MarkNativeAsOptional("TF2_DisguisePlayer");
   300 	MarkNativeAsOptional("TF2_RemovePlayerDisguise");
   301 	MarkNativeAsOptional("TF2_StunPlayer");
   302 	MarkNativeAsOptional("TF2_MakeBleed");
   303 	MarkNativeAsOptional("TF2_GetResourceEntity");
   304 	MarkNativeAsOptional("TF2_GetClass");
   305 }
   306 #endif