PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/plugins/include/l4d2.inc

https://bitbucket.org/ProdigySim/l4d2ext
Pascal | 392 lines | 339 code | 31 blank | 22 comment | 24 complexity | 8d5228ec92983a793981dc6c73a42f71 MD5 | raw file
  1. /**
  2. * vim: set ts=4 :
  3. * =============================================================================
  4. * SourceMod Left 4 Dead 2 Extension
  5. * Copyright (C) 2004-2011 AlliedModders LLC. All rights reserved.
  6. * Copyright (C) 2010-2011 Michael Busby
  7. * Copyright (C) 2010-2011 "AtomicStryker".
  8. * Copyright (C) 2009-2010 Igor "Downtown1" Smirnov.
  9. * =============================================================================
  10. *
  11. * This program is free software; you can redistribute it and/or modify it under
  12. * the terms of the GNU General Public License, version 3.0, as published by the
  13. * Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful, but WITHOUT
  16. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  17. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  18. * details.
  19. *
  20. * You should have received a copy of the GNU General Public License along with
  21. * this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. * As a special exception, AlliedModders LLC gives you permission to link the
  24. * code of this program (as well as its derivative works) to "Half-Life 2," the
  25. * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
  26. * by the Valve Corporation. You must obey the GNU General Public License in
  27. * all respects for all other code used. Additionally, AlliedModders LLC grants
  28. * this exception to all derivative works. AlliedModders LLC defines further
  29. * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
  30. * or <http://www.sourcemod.net/license.php>.
  31. *
  32. * Version: $Id$
  33. */
  34. #if defined _l4d2_included
  35. #endinput
  36. #endif
  37. #define _l4d2_included
  38. #include <l4d2_timers>
  39. #include <l4d2_weapons>
  40. /**
  41. * @brief Called whenever ZombieManager::SpawnTank(Vector&,QAngle&) is invoked
  42. * @remarks Not invoked if z_spawn tank is used and it gives a ghosted/dead player tank
  43. *
  44. * @param vector Vector coordinate where tank is spawned
  45. * @param qangle QAngle where tank will be facing
  46. * @return Pl_Handled to block tank from spawning, Pl_Continue otherwise.
  47. */
  48. forward Action:L4D2_OnSpawnTank(const Float:vector[3], const Float:qangle[3]);
  49. /**
  50. * @brief Called whenever ZombieManager::SpawnWitch(Vector&,QAngle&) is invoked
  51. *
  52. * @param vector Vector coordinate where witch is spawned
  53. * @param qangle QAngle where witch will be facing
  54. * @return Pl_Handled to block witch from spawning, Pl_Continue otherwise.
  55. */
  56. forward Action:L4D2_OnSpawnWitch(const Float:vector[3], const Float:qangle[3]);
  57. /**
  58. * @brief Called whenever CTerrorGameRules::ClearTeamScores(bool) is invoked
  59. * @remarks This resets the map score at the beginning of a map, and by checking
  60. * the campaign scores on a small timer you can see if they were reset as well.
  61. *
  62. * @param newCampaign if true then this is a new campaign, if false a new chapter
  63. * @return Pl_Handled to block scores from being cleared, Pl_Continue otherwise.
  64. */
  65. forward Action:L4D2_OnClearTeamScores(bool:newCampaign);
  66. /**
  67. * @brief Called whenever CTerrorGameRules::SetCampaignScores(int,int) is invoked
  68. * @remarks The campaign scores are updated after the 2nd round is completed
  69. *
  70. * @param scoreA score of logical team A
  71. * @param scoreB score of logical team B
  72. * @return Pl_Handled to block campaign scores from being set, Pl_Continue otherwise.
  73. */
  74. forward Action:L4D2_OnSetCampaignScores(&scoreA, &scoreB);
  75. /**
  76. * @brief Called whenever CDirector::OnFirstSurvivorLeftSafeArea is invoked
  77. * @remarks A versus round is started when survivors leave the safe room, or force started
  78. * after 90 seconds regardless.
  79. *
  80. * @param client the survivor that left the safe area first
  81. *
  82. * @return Pl_Handled to block round from being started, Pl_Continue otherwise.
  83. */
  84. forward Action:L4D2_OnFirstSurvivorLeftSafeArea(client);
  85. /**
  86. * @brief Called whenever CDirector::GetScriptValue(const char*, int) is invoked
  87. * @remarks A script value is map specific
  88. *
  89. * @param key the script's key name
  90. * @param retVal what to override the return value with
  91. *
  92. * @return Pl_Handled to override return value, Pl_Continue otherwise.
  93. */
  94. forward Action:L4D2_OnGetScriptValueInt(const String:key[], &retVal);
  95. /**
  96. * @brief Called whenever CTerrorPlayer::OnEnterGhostState(CTerrorPlayer*) is invoked
  97. * @remarks This happens when a player enters ghost mode (or in finales auto-materialized)
  98. *
  99. * @param client the client that has entered ghost mode
  100. */
  101. forward L4D2_OnEnterGhostState(client);
  102. /**
  103. * @brief Called whenever CDirector::TryOfferingTankBot is invoked
  104. * @remarks Is used for displaying the "X gets Tank" window and transferring Tank control
  105. *
  106. * @return Pl_Handled to block window from showing and to keep Tank Bot, Pl_Continue otherwise
  107. */
  108. forward Action:L4D2_OnTryOfferingTankBot(tank_index, &bool:enterStasis);
  109. /**
  110. * @brief Called whenever CDirector::OnMobRushStart(void) is invoked
  111. * @remarks called on random hordes, mini- and finale hordes, and boomer hordes, causes Zombies to attack
  112. * Not called on "z_spawn mob", hook the console command and check arguments to catch plugin mobs
  113. * This function is used to reset the Director's natural horde timer
  114. *
  115. * @return Pl_Handled to block, Pl_Continue otherwise
  116. */
  117. forward Action:L4D2_OnMobRushStart();
  118. /**
  119. * @brief Called whenever ZombieManager::SpawnITMob(int) is invoked
  120. * @remarks called on boomer hordes, increases Zombie Spawn Queue
  121. *
  122. * @param amount Amount of Zombies to add to Queue
  123. *
  124. * @return Pl_Handled to block, Pl_Continue otherwise
  125. */
  126. forward Action:L4D2_OnSpawnITMob(&amount);
  127. /**
  128. * @brief Called whenever ZombieManager::SpawnMob(int) is invoked
  129. * @remarks called on natural hordes & z_spawn mob, increases Zombie Spawn
  130. * Queue, triggers player OnMobSpawned (vocalizations), sets horde
  131. * direction, and plays horde music.
  132. *
  133. * @param amount Amount of Zombies to add to Queue
  134. *
  135. * @return Pl_Handled to block, Pl_Continue otherwise
  136. */
  137. forward Action:L4D2_OnSpawnMob(&amount);
  138. /**
  139. * @brief Called whenever CTerrorPlayer::OnShovedBySurvivor(CTerrorPlayer, Vector&) is invoked
  140. * @remarks L4D2 only uses this on Special Infected
  141. *
  142. * @param client the client that did the shoving
  143. * @param victim the client that was shoved (CAUTION: retrieved from function pointer, dont meddle with it)
  144. * @param vector Vector Angle of Shoveforce
  145. *
  146. * @return Pl_Handled to block melee effect (staggering), Pl_Continue otherwise.
  147. */
  148. forward Action:L4D2_OnShovedBySurvivor(client, victim, const Float:vector[3]);
  149. /**
  150. * @brief Called whenever CTerrorPlayer::GetCrouchTopSpeed() is invoked
  151. *
  152. * @param target the client that its being called on (not changible)
  153. * @param retVal what to override the return value with
  154. *
  155. * @return Pl_Handled to override return value, Pl_Continue otherwise.
  156. */
  157. forward Action:L4D2_OnGetCrouchTopSpeed(target, &Float:retVal);
  158. /**
  159. * @brief Called whenever CTerrorPlayer::GetRunTopSpeed() is invoked
  160. *
  161. * @param target the client that its being called on (not changible)
  162. * @param retVal what to override the return value with
  163. *
  164. * @return Pl_Handled to override return value, Pl_Continue otherwise.
  165. */
  166. forward Action:L4D2_OnGetRunTopSpeed(target, &Float:retVal);
  167. /**
  168. * @brief Called whenever CTerrorPlayer::GetWalkTopSpeed() is invoked
  169. *
  170. * @param target the client that its being called on (not changible)
  171. * @param retVal what to override the return value with
  172. *
  173. * @return Pl_Handled to override return value, Pl_Continue otherwise.
  174. */
  175. forward Action:L4D2_OnGetWalkTopSpeed(target, &Float:retVal);
  176. /**
  177. * @brief Called whenever CTerrorGameRules::HasConfigurableDifficultySetting() is invoked
  178. * @remarks used to deny/allow difficulty changes in different game modes
  179. *
  180. * @param retVal what to override the return value with. 1 to allow difficulty configuration, 0 to deny.
  181. *
  182. * @return Pl_Handled to override return value, Pl_Continue otherwise.
  183. */
  184. forward Action:L4D2_OnHasConfigurableDifficulty(&retVal);
  185. /**
  186. * @brief Called whenever CTerrorGameRules::GetSurvivorSet(void) is invoked
  187. *
  188. * @param retVal what to override the return value with
  189. *
  190. * @return Pl_Handled to override return value, Pl_Continue otherwise.
  191. */
  192. forward Action:L4D2_OnGetSurvivorSet(&retVal);
  193. /**
  194. * @brief Called whenever CTerrorGameRules::FastGetSurvivorSet(void) is invoked
  195. *
  196. * @param retVal what to override the return value with
  197. *
  198. * @return Pl_Handled to override return value, Pl_Continue otherwise.
  199. */
  200. forward Action:L4D2_OnFastGetSurvivorSet(&retVal);
  201. /**
  202. * @brief Called whenever CDirectorVersusMode::GetMissionVersusBossSpawning() is invoked
  203. * @remarks Passed values are from the map's Mission Keyvalues. If those keyvalues don't exist, they are from cvar and other globals
  204. *
  205. * @param spawn_pos_min Minimum spawn position (percent of flow distance) for bosses
  206. * @param spawn_pos_max Maximum spawn position (perfect of flow distance) for bosses
  207. * @param tank_chance Chance for a tank to spawn on this map
  208. * @param witch_chance Chance for a witch to spawn on this map
  209. *
  210. * @return Pl_Handled to block reading map data, Pl_Changed to use overwritten values from plugin, Pl_Continue to continue to read from mission data.
  211. */
  212. forward Action:L4D2_OnGetMissionVSBossSpawning(&Float:spawn_pos_min, &Float:spawn_pos_max, &Float:tank_chance, &Float:witch_chance);
  213. /**
  214. * @brief Called whenever CThrow::ActivateAbility(void) is invoked
  215. * @remarks Called when a tank throws a rock. Blocking this call will
  216. * keep the tank from throwing a rock.
  217. *
  218. * @return Pl_Handled to block, Pl_Continue otherwise
  219. */
  220. forward Action:L4D2_OnCThrowActivate();
  221. /**
  222. * @brief Called whenever InfectedShoved::OnShoved(Infected *, CBaseEntity *) is invoked
  223. * @remarks Called when common Infected are about to get shoved
  224. *
  225. * @return Pl_Handled to block, Pl_Continue otherwise
  226. */
  227. forward Action:L4D2_OnInfectedShoved(infected, entity);
  228. /**
  229. * @brief Called whenever CTerrorMeleeWeapon::StartMeleeSwing(CTerrorPlayer *, bool) is invoked
  230. * @remarks Called when a player uses his melee Weapons primary attack. This is before the game
  231. * reads the melee weapon data (model etc) and decides if he CAN attack at all.
  232. *
  233. * @return Pl_Handled to block, Pl_Continue otherwise
  234. */
  235. forward Action:L4D2_OnStartMeleeSwing(client, bool:boolean);
  236. /**
  237. * @brief Get the team scores for the current map
  238. * @remarks The campaign scores are not set until the end of round 2,
  239. * use L4D2_GetCampaignScores to get them earlier.
  240. *
  241. * @deprecated This function can be called through SDKTools using CTerrorGameRules,
  242. * and so you should switch off to using SDKTools instead of this native.
  243. *
  244. * @param logical_team 0 for A, 1 for B
  245. * @param campaign_score true to get campaign score instead of map score
  246. * @return the logical team's map score
  247. * or -1 if the team hasn't played the round yet,
  248. * or the team's campaign score if campaign_score = true
  249. */
  250. native L4D2_GetTeamScore(logical_team, campaign_score=false);
  251. /**
  252. * @brief Restarts the setup timer (when in scavenge mode)
  253. * @remarks If game has already started, the setup timer will show,
  254. * but it still won't go back into setup.
  255. */
  256. native L4D2_ScavengeBeginRoundSetupTime();
  257. /**
  258. * @brief Restarts the round, switching the map if necessary
  259. * @remarks Set the map to the current map to restart the round
  260. *
  261. * @param map the mapname it should go to after the round restarts
  262. * @return 1 always
  263. */
  264. native L4D2_RestartScenarioFromVote(const String:map[]);
  265. /**
  266. * @brief Removes lobby reservation from a server
  267. * @remarks Sets the reservation cookie to 0,
  268. * it is safe to call this even if it's unreserved.
  269. */
  270. native L4D2_LobbyUnreserve();
  271. /**
  272. * @brief Gets the max versus completion score for the map
  273. * @remarks Requires GameRules to be initialized--map must be loaded
  274. * Seems to be updated before OnMapStart
  275. *
  276. *
  277. * @return The map's max completion distance (map distance score)
  278. */
  279. native L4D2_GetVersusMaxCompletionScore();
  280. /**
  281. * @brief Sets the max versus completion score for the map
  282. * @remarks Requires GameRules to be initialized--map must be loaded
  283. * Seems to be updated before OnMapStart and checked on round_start
  284. *
  285. * @param score The versus max completion score to set for the round
  286. */
  287. native L4D2_SetVersusMaxCompletionScore(score);
  288. /**
  289. * @brief Tells if the Mission (map) is the final map of the campaign
  290. *
  291. * @return true if the map is the last map of the campaign (finale)
  292. */
  293. native bool:L4D2_IsMissionFinalMap();
  294. /**
  295. * @brief Resets the natural mob (horde) timer
  296. * @remarks Requires the Director to be available--map must be started
  297. *
  298. * @noreturn
  299. */
  300. native L4D2_ResetMobTimer();
  301. /**
  302. * @brief Notifies the CGameRulesProxy that the game state has been changed
  303. * @remarks Use this function before changing networked members of GameRules,
  304. * like with L4D2_SetVersusMaxCompletionScore()
  305. *
  306. * @noreturn
  307. */
  308. native L4D2_NotifyNetworkStateChanged();
  309. /**
  310. * @brief Trigger's a target player's stagger behavior
  311. * @remarks Works on any CTerrorPlayer--survivor or infected.
  312. *
  313. * @param target Player to stagger
  314. * @param source_ent Source of the stagger (another player, etc)
  315. * @param source_vector Source location of the stagger. If NULL_VECTOR, origins of source_ent is used.
  316. * @noreturn
  317. */
  318. native L4D2_StaggerPlayer(target, source_ent, Float:source_vector[3]);
  319. /**
  320. * @brief Get the remaining spawn time for an SI
  321. * @remarks This is meant for Special infected in ghost mode in versus.
  322. *
  323. * @return Time (seconds) until the SI will spawn.
  324. */
  325. native Float:L4D2_GetPlayerSpawnTime(player);
  326. /*
  327. Makes the extension required by the plugins, undefine REQUIRE_EXTENSIONS
  328. if you want to use it optionally before including this .inc file
  329. */
  330. public Extension:__ext_l4d2 =
  331. {
  332. name = "L4D2 Tools",
  333. file = "game.l4d2.ext",
  334. autoload = 0,
  335. #if defined REQUIRE_EXTENSIONS
  336. required = 1,
  337. #else
  338. required = 0,
  339. #endif
  340. };
  341. #if !defined REQUIRE_EXTENSIONS
  342. public __ext_l4d2_SetNTVOptional()
  343. {
  344. MarkNativeAsOptional("L4D2_GetTeamScore");
  345. MarkNativeAsOptional("L4D2_ScavengeBeginRoundSetupTime");
  346. MarkNativeAsOptional("L4D2_RestartScenarioFromVote");
  347. MarkNativeAsOptional("L4D2_LobbyUnreserve");
  348. MarkNativeAsOptional("L4D2_GetVersusMaxCompletionScore");
  349. MarkNativeAsOptional("L4D2_SetVersusMaxCompletionScore");
  350. MarkNativeAsOptional("L4D2_IsMissionFinalMap");
  351. MarkNativeAsOptional("L4D2_ResetMobTimer");
  352. MarkNativeAsOptional("L4D2_NotifyNetworkStateChanged");
  353. MarkNativeAsOptional("L4D2_StaggerPlayer");
  354. MarkNativeAsOptional("L4D2_GetPlayerSpawnTime");
  355. }
  356. #endif