3 * =============================================================================
4 * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 * =============================================================================
7 * This file is part of the SourceMod/SourcePawn SDK.
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.
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
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/>.
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>.
33 #if defined _tf2_stocks_included
36 #define _tf2_stocks_included
41 #define TF_CONDFLAG_NONE 0
42 #define TF_CONDFLAG_SLOWED (1 << 0)
43 #define TF_CONDFLAG_ZOOMED (1 << 1)
44 #define TF_CONDFLAG_DISGUISING (1 << 2)
45 #define TF_CONDFLAG_DISGUISED (1 << 3)
46 #define TF_CONDFLAG_CLOAKED (1 << 4)
47 #define TF_CONDFLAG_UBERCHARGED (1 << 5)
48 #define TF_CONDFLAG_TELEPORTGLOW (1 << 6)
49 #define TF_CONDFLAG_TAUNTING (1 << 7)
50 #define TF_CONDFLAG_UBERCHARGEFADE (1 << 8)
51 #define TF_CONDFLAG_CLOAKFLICKER (1 << 9)
52 #define TF_CONDFLAG_TELEPORTING (1 << 10)
53 #define TF_CONDFLAG_KRITZKRIEGED (1 << 11)
54 #define TF_CONDFLAG_DEADRINGERED (1 << 13)
55 #define TF_CONDFLAG_BONKED (1 << 14)
56 #define TF_CONDFLAG_DAZED (1 << 15)
57 #define TF_CONDFLAG_BUFFED (1 << 16)
58 #define TF_CONDFLAG_CHARGING (1 << 17)
59 #define TF_CONDFLAG_DEMOBUFF (1 << 18)
60 #define TF_CONDFLAG_CRITCOLA (1 << 19)
61 #define TF_CONDFLAG_INHEALRADIUS (1 << 20)
62 #define TF_CONDFLAG_HEALING (1 << 21)
63 #define TF_CONDFLAG_ONFIRE (1 << 22)
64 #define TF_CONDFLAG_OVERHEALED (1 << 23)
65 #define TF_CONDFLAG_JARATED (1 << 24)
66 #define TF_CONDFLAG_BLEEDING (1 << 25)
67 #define TF_CONDFLAG_DEFENSEBUFFED (1 << 26)
68 #define TF_CONDFLAG_MILKED (1 << 27)
69 #define TF_CONDFLAG_MEGAHEAL (1 << 28)
70 #define TF_CONDFLAG_REGENBUFFED (1 << 29)
71 #define TF_CONDFLAG_MARKEDFORDEATH (1 << 30)
73 #define TF_DEATHFLAG_KILLERDOMINATION (1 << 0)
74 #define TF_DEATHFLAG_ASSISTERDOMINATION (1 << 1)
75 #define TF_DEATHFLAG_KILLERREVENGE (1 << 2)
76 #define TF_DEATHFLAG_ASSISTERREVENGE (1 << 3)
77 #define TF_DEATHFLAG_FIRSTBLOOD (1 << 4)
78 #define TF_DEATHFLAG_DEADRINGER (1 << 5)
79 #define TF_DEATHFLAG_INTERRUPTED (1 << 6)
80 #define TF_DEATHFLAG_GIBBED (1 << 7)
81 #define TF_DEATHFLAG_PURGATORY (1 << 8)
83 // Custom kill identifiers for the customkill property on the player_death event
85 TF_CUSTOM_HEADSHOT = 1,
91 TF_CUSTOM_TAUNT_HADOUKEN,
92 TF_CUSTOM_BURNING_FLARE,
93 TF_CUSTOM_TAUNT_HIGH_NOON,
94 TF_CUSTOM_TAUNT_GRAND_SLAM,
95 TF_CUSTOM_PENETRATE_MY_TEAM,
96 TF_CUSTOM_PENETRATE_ALL_PLAYERS,
97 TF_CUSTOM_TAUNT_FENCING,
98 TF_CUSTOM_PENETRATE_HEADSHOT,
99 TF_CUSTOM_TAUNT_ARROW_STAB,
101 TF_CUSTOM_BURNING_ARROW,
102 TF_CUSTOM_FLYINGBURN,
103 TF_CUSTOM_PUMPKIN_BOMB,
104 TF_CUSTOM_DECAPITATION,
105 TF_CUSTOM_TAUNT_GRENADE,
107 TF_CUSTOM_CHARGE_IMPACT,
108 TF_CUSTOM_TAUNT_BARBARIAN_SWING,
109 TF_CUSTOM_AIR_STICKY_BURST,
110 TF_CUSTOM_DEFENSIVE_STICKY,
112 TF_CUSTOM_ROCKET_DIRECTHIT,
113 TF_CUSTOM_TAUNT_UBERSLICE,
114 TF_CUSTOM_PLAYER_SENTRY,
115 TF_CUSTOM_STANDARD_STICKY,
116 TF_CUSTOM_SHOTGUN_REVENGE_CRIT,
117 TF_CUSTOM_TAUNT_ENGINEER_SMASH,
119 TF_CUSTOM_GOLD_WRENCH,
120 TF_CUSTOM_CARRIED_BUILDING,
121 TF_CUSTOM_COMBO_PUNCH,
122 TF_CUSTOM_TAUNT_ENGINEER_ARM,
124 TF_CUSTOM_TRIGGER_HURT,
125 TF_CUSTOM_DECAPITATION_BOSS,
126 TF_CUSTOM_STICKBOMB_EXPLOSION,
127 TF_CUSTOM_AEGIS_ROUND,
128 TF_CUSTOM_FLARE_EXPLOSION,
129 TF_CUSTOM_BOOTS_STOMP,
131 TF_CUSTOM_PLASMA_CHARGED,
132 TF_CUSTOM_PLASMA_GIB,
133 TF_CUSTOM_PRACTICE_STICKY,
134 TF_CUSTOM_EYEBALL_ROCKET,
135 TF_CUSTOM_HEADSHOT_DECAPITATION,
136 TF_CUSTOM_TAUNT_ARMAGEDDON,
137 TF_CUSTOM_FLARE_PELLET,
139 TF_CUSTOM_CLEAVER_CRIT,
140 TF_CUSTOM_SAPPER_RECORDER_DEATH,
141 TF_CUSTOM_MERASMUS_PLAYER_BOMB,
142 TF_CUSTOM_MERASMUS_GRENADE,
143 TF_CUSTOM_MERASMUS_ZAP,
144 TF_CUSTOM_MERASMUS_DECAPITATION,
145 TF_CUSTOM_CANNONBALL_PUSH,
146 TF_CUSTOM_TAUNT_ALLCLASS_GUITAR_RIFF,
149 // Weapon codes as used in some events, such as player_death
150 // (not to be confused with Item Definition Indexes)
164 TF_WEAPON_SHOTGUN_PRIMARY,
165 TF_WEAPON_SHOTGUN_SOLDIER,
166 TF_WEAPON_SHOTGUN_HWG,
167 TF_WEAPON_SHOTGUN_PYRO,
168 TF_WEAPON_SCATTERGUN,
169 TF_WEAPON_SNIPERRIFLE,
172 TF_WEAPON_SYRINGEGUN_MEDIC,
174 TF_WEAPON_ROCKETLAUNCHER,
175 TF_WEAPON_GRENADELAUNCHER,
176 TF_WEAPON_PIPEBOMBLAUNCHER,
177 TF_WEAPON_FLAMETHROWER,
178 TF_WEAPON_GRENADE_NORMAL,
179 TF_WEAPON_GRENADE_CONCUSSION,
180 TF_WEAPON_GRENADE_NAIL,
181 TF_WEAPON_GRENADE_MIRV,
182 TF_WEAPON_GRENADE_MIRV_DEMOMAN,
183 TF_WEAPON_GRENADE_NAPALM,
184 TF_WEAPON_GRENADE_GAS,
185 TF_WEAPON_GRENADE_EMP,
186 TF_WEAPON_GRENADE_CALTROP,
187 TF_WEAPON_GRENADE_PIPEBOMB,
188 TF_WEAPON_GRENADE_SMOKE_BOMB,
189 TF_WEAPON_GRENADE_HEAL,
190 TF_WEAPON_GRENADE_STUNBALL,
191 TF_WEAPON_GRENADE_JAR,
192 TF_WEAPON_GRENADE_JAR_MILK,
194 TF_WEAPON_PISTOL_SCOUT,
198 TF_WEAPON_PDA_ENGINEER_BUILD,
199 TF_WEAPON_PDA_ENGINEER_DESTROY,
203 TF_WEAPON_GRENADE_MIRVBOMB,
204 TF_WEAPON_FLAMETHROWER_ROCKET,
205 TF_WEAPON_GRENADE_DEMOMAN,
206 TF_WEAPON_SENTRY_BULLET,
207 TF_WEAPON_SENTRY_ROCKET,
213 TF_WEAPON_COMPOUND_BOW,
215 TF_WEAPON_PUMPKIN_BOMB,
219 TF_WEAPON_LASER_POINTER,
220 TF_WEAPON_DISPENSER_GUN,
221 TF_WEAPON_SENTRY_REVENGE,
223 TF_WEAPON_HANDGUN_SCOUT_PRIMARY,
227 TF_WEAPON_HANDGUN_SCOUT_SEC,
228 TF_WEAPON_SODA_POPPER,
229 TF_WEAPON_SNIPERRIFLE_DECAP,
231 TF_WEAPON_PARTICLE_CANNON,
232 TF_WEAPON_MECHANICAL_ARM,
233 TF_WEAPON_DRG_POMSON,
234 TF_WEAPON_BAT_GIFTWRAP,
235 TF_WEAPON_GRENADE_ORNAMENT,
236 TF_WEAPON_RAYGUN_REVENGE,
237 TF_WEAPON_PEP_BRAWLER_BLASTER,
239 TF_WEAPON_GRENADE_CLEAVER,
240 TF_WEAPON_STICKY_BALL_LAUNCHER,
241 TF_WEAPON_GRENADE_STICKY_BALL,
242 TF_WEAPON_SHOTGUN_BUILDING_RESCUE,
245 TF_WEAPON_GRENADE_THROWABLE,
246 TF_WEAPON_PDA_SPY_BUILD,
247 TF_WEAPON_GRENADE_WATERBALLOON,
248 TF_WEAPON_HARVESTER_SAW,
250 TF_WEAPON_SPELLBOOK_PROJECTILE,
253 // TF2 Weapon Loadout Slots
256 TFWeaponSlot_Primary,
257 TFWeaponSlot_Secondary,
259 TFWeaponSlot_Grenade,
260 TFWeaponSlot_Building,
266 // Identifiers for the eventtype property on the teamplay_flag_event event
268 TF_FLAGEVENT_PICKEDUP = 1,
269 TF_FLAGEVENT_CAPTURED,
270 TF_FLAGEVENT_DEFENDED,
271 TF_FLAGEVENT_DROPPED,
272 TF_FLAGEVENT_RETURNED
280 TFResource_TotalScore,
283 TFResource_Dominations,
285 TFResource_BuildingsDestroyed,
286 TFResource_Headshots,
287 TFResource_Backstabs,
288 TFResource_HealPoints,
290 TFResource_Teleports,
291 TFResource_ResupplyPoints,
292 TFResource_KillAssists,
293 TFResource_MaxHealth,
294 TFResource_PlayerClass
297 static const String:TFResourceNames[TFResourceType][] =
307 "m_iBuildingsDestroyed",
320 * Get's a Clients current class.
322 * @param client Player's index.
323 * @return Current TFClassType of player.
324 * @error Invalid client index.
326 stock TFClassType:TF2_GetPlayerClass(client)
328 return TFClassType:GetEntProp(client, Prop_Send, "m_iClass");
332 * Set's a Clients class.
334 * Note: If setting player class in a player spawn hook weapons should be set to false.
336 * @param client Player's index.
337 * @param class TFClassType class symbol.
338 * @param weapons This paramater is ignored.
339 * @param persistent If true changes the players desired class so the change stays after death.
341 * @error Invalid client index.
343 stock TF2_SetPlayerClass(client, TFClassType:class, bool:weapons=true, bool:persistent=true)
345 SetEntProp(client, Prop_Send, "m_iClass", _:class);
349 SetEntProp(client, Prop_Send, "m_iDesiredPlayerClass", _:class);
354 * Retrieves client data from the resource entity
356 * @param client Player's index.
357 * @param type ResourceType constant
358 * @return Value or -1 on failure.
359 * @error Invalid client index, client not in game or failed to find resource entity.
361 #pragma deprecated Use GetPlayerResourceEntity and GetEntProp instead
362 stock TF2_GetPlayerResourceData(client, TFResourceType:type)
364 if (!IsClientConnected(client))
369 new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
376 new entity = TF2_GetResourceEntity();
383 return GetEntData(entity, offset + (client*4));
387 * Sets client data in the resource entity
389 * Note: The game overwrites these values every frame, so changing them will have very little effect.
391 * @param client Player's index.
392 * @param type ResourceType constant
393 * @param value Value to set.
394 * @return Value or -1 on failure.
395 * @error Invalid client index, client not in game or failed to find resource entity.
397 #pragma deprecated Use GetPlayerResourceEntity and SetEntProp instead
398 stock bool:TF2_SetPlayerResourceData(client, TFResourceType:type, any:value)
400 if (!IsClientConnected(client))
405 new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
412 new entity = TF2_GetResourceEntity();
419 SetEntData(entity, offset + (client*4), value);
425 * Removes all weapons from a client's weapon slot
427 * @param client Player's index.
428 * @param slot Slot index (0-5)
430 * @error Invalid client, invalid slot or lack of mod support
432 stock TF2_RemoveWeaponSlot(client, slot)
435 while ((weaponIndex = GetPlayerWeaponSlot(client, slot)) != -1)
437 RemovePlayerItem(client, weaponIndex);
438 AcceptEntityInput(weaponIndex, "Kill");
443 * Removes all weapons from a client
445 * @param client Player's index.
448 stock TF2_RemoveAllWeapons(client)
450 for (new i = 0; i <= 5; i++)
452 TF2_RemoveWeaponSlot(client, i);
457 * Gets a player's condition bits
459 * @param client Player's index.
460 * @return Player's condition bits
462 #pragma deprecated Use TF2_IsPlayerInCondition instead.
463 stock TF2_GetPlayerConditionFlags(client)
465 return GetEntProp(client, Prop_Send, "m_nPlayerCond")|GetEntProp(client, Prop_Send, "_condition_bits");
469 * Check whether or not a condition is set on a player
471 * @param client Player's index.
472 * @param cond TFCond constant
473 * @return True if set, false otherwise
475 stock bool:TF2_IsPlayerInCondition(client, TFCond:cond)
477 // Conditions are stored across two netprops now, one for each 32-bit segment.
480 new bit = 1 << _:cond;
481 if ((GetEntProp(client, Prop_Send, "m_nPlayerCond") & bit) == bit)
486 if ((GetEntProp(client, Prop_Send, "_condition_bits") & bit) == bit)
491 else if (_:cond < 64)
493 new bit = (1 << (_:cond - 32));
494 if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx") & bit) == bit)
501 new bit = (1 << (_:cond - 64));
502 if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx2") & bit) == bit)
512 * Gets an entity's object type.
514 * @param entity Entity index.
515 * @return Current TFObjectType of entity.
516 * @error Invalid entity index.
518 stock TFObjectType:TF2_GetObjectType(entity)
520 new offset = GetEntSendPropOffs(entity, "m_iObjectType");
524 ThrowError("Entity index %d is not an object", entity);
527 return TFObjectType:GetEntData(entity, offset);
531 * Gets an entity's object mode.
533 * @param entity Entity index.
534 * @return Current TFObjectMode of entity.
535 * @error Invalid entity index.
537 stock TFObjectMode:TF2_GetObjectMode(entity)
539 new offset = GetEntSendPropOffs(entity, "m_iObjectMode");
543 ThrowError("Entity index %d is not an object", entity);
546 return TFObjectMode:GetEntData(entity, offset);