Advertisement
Guest User

Untitled

a guest
Sep 29th, 2010
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.94 KB | None | 0 0
  1. // Callback Setup
  2. // This script provides the hooks from code into script for the gametype callback functions.
  3.  
  4. //=============================================================================
  5. // Code Callback functions
  6.  
  7. /*================
  8. Called by code after the level's main script function has run.
  9. ================*/
  10. CodeCallback_StartGameType()
  11. {
  12. if( getDvar( "r_reflectionProbeGenerate" ) == "1" )
  13. level waittill( "eternity" );
  14.  
  15. // If the gametype has not beed started, run the startup
  16. if(!isDefined(level.gametypestarted) || !level.gametypestarted)
  17. {
  18. [[level.callbackStartGameType]]();
  19.  
  20. level.gametypestarted = true; // so we know that the gametype has been started up
  21. }
  22. }
  23.  
  24.  
  25. /*================
  26. Called when a player begins connecting to the server.
  27. Called again for every map change or tournement restart.
  28.  
  29. Return undefined if the client should be allowed, otherwise return
  30. a string with the reason for denial.
  31.  
  32. Otherwise, the client will be sent the current gamestate
  33. and will eventually get to ClientBegin.
  34.  
  35. firstTime will be qtrue the very first time a client connects
  36. to the server machine, but qfalse on map changes and tournement
  37. restarts.
  38. ================*/
  39. CodeCallback_PlayerConnect()
  40. {
  41. if( getDvar( "r_reflectionProbeGenerate" ) == "1" )
  42. level waittill( "eternity" );
  43.  
  44. self endon("disconnect");
  45. [[level.callbackPlayerConnect]]();
  46. }
  47.  
  48. /*================
  49. Called when a player drops from the server.
  50. Will not be called between levels.
  51. self is the player that is disconnecting.
  52. ================*/
  53. CodeCallback_PlayerDisconnect()
  54. {
  55. self notify("disconnect");
  56. [[level.callbackPlayerDisconnect]]();
  57. }
  58.  
  59. /*================
  60. Called when a player has taken damage.
  61. self is the player that took damage.
  62. ================*/
  63. CodeCallback_PlayerDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset)
  64. {
  65. self endon("disconnect");
  66. [[level.callbackPlayerDamage]](eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset);
  67. }
  68.  
  69. /*================
  70. Called when a player has been killed.
  71. self is the player that was killed.
  72. ================*/
  73. CodeCallback_PlayerKilled(eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration)
  74. {
  75. self endon("disconnect");
  76. [[level.callbackPlayerKilled]](eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration);
  77. }
  78.  
  79.  
  80. /*================
  81. Called when a vehicle has taken damage.
  82. self is the vehicle that took damage.
  83. ================*/
  84. CodeCallback_VehicleDamage( inflictor, attacker, damage, dFlags, meansOfDeath, weapon, point, dir, hitLoc, timeOffset, modelIndex, partName )
  85. {
  86. if ( isDefined( self.damageCallback ) )
  87. self [[self.damageCallback]]( inflictor, attacker, damage, dFlags, meansOfDeath, weapon, point, dir, hitLoc, timeOffset, modelIndex, partName );
  88. else
  89. self Vehicle_FinishDamage( inflictor, attacker, damage, dFlags, meansOfDeath, weapon, point, dir, hitLoc, timeOffset, modelIndex, partName );
  90. }
  91.  
  92.  
  93. /*================
  94. Called when code is forcibly ending the game.
  95. e.g. we suck as host.
  96. ================*/
  97. CodeCallback_CodeEndGame()
  98. {
  99. self endon("disconnect");
  100. [[level.callbackCodeEndGame]]();
  101. }
  102.  
  103.  
  104. /*================
  105. Called when a player has been killed, but has last stand perk.
  106. self is the player that was killed.
  107. ================*/
  108. CodeCallback_PlayerLastStand(eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration )
  109. {
  110. self endon("disconnect");
  111. [[level.callbackPlayerLastStand]](eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration );
  112. }
  113.  
  114.  
  115. /*================
  116. Called when a player reconnects to the server
  117. following a host migration.
  118. ================*/
  119. CodeCallback_PlayerMigrated()
  120. {
  121. self endon("disconnect");
  122. [[level.callbackPlayerMigrated]]();
  123. }
  124.  
  125.  
  126. /*================
  127. Called once when a host migration has occured.
  128. ================*/
  129. CodeCallback_HostMigration()
  130. {
  131. [[level.callbackHostMigration]]();
  132. }
  133.  
  134.  
  135.  
  136. //=============================================================================
  137.  
  138. // Damage flags used in the playerDamage callback
  139. SetupDamageFlags()
  140. {
  141. // code-defined:
  142. level.iDFLAGS_RADIUS = 1; // damage was indirect
  143. level.iDFLAGS_NO_ARMOR = 2; // armor does not protect from this damage
  144. level.iDFLAGS_NO_KNOCKBACK = 4; // do not affect velocity, just view angles
  145. level.iDFLAGS_PENETRATION = 8; // damage occurred after one or more penetrations
  146. level.iDFLAGS_STUN = 16; // non-lethal
  147. level.iDFLAGS_SHIELD_EXPLOSIVE_IMPACT = 32; // missile impacted on the front of the victim's shield
  148. level.iDFLAGS_SHIELD_EXPLOSIVE_IMPACT_HUGE = 64; // ...and was from a projectile with "Big Explosion" checked on.
  149. level.iDFLAGS_SHIELD_EXPLOSIVE_SPLASH = 128; // explosive splash, somewhat deflected by the victim's shield
  150.  
  151. // script-defined:
  152. level.iDFLAGS_NO_TEAM_PROTECTION = 256;
  153. level.iDFLAGS_NO_PROTECTION = 512;
  154. level.iDFLAGS_PASSTHRU = 1024;
  155. }
  156.  
  157.  
  158. /*================
  159. Setup any misc callbacks stuff like defines and default callbacks
  160. ================*/
  161. SetupCallbacks()
  162. {
  163. SetDefaultCallbacks();
  164. SetupDamageFlags();
  165. }
  166.  
  167.  
  168. /*================
  169. Called from the gametype script to store off the default callback functions.
  170. This allows the callbacks to be overridden by level script, but not lost.
  171. ================*/
  172. SetDefaultCallbacks()
  173. {
  174. level.callbackStartGameType = maps\mp\gametypes\_gamelogic::Callback_StartGameType;
  175. level.callbackPlayerConnect = maps\mp\gametypes\_playerlogic::Callback_PlayerConnect;
  176. level.callbackPlayerDisconnect = maps\mp\gametypes\_playerlogic::Callback_PlayerDisconnect;
  177. level.callbackPlayerDamage = maps\mp\gametypes\_damage::Callback_PlayerDamage;
  178. level.callbackPlayerKilled = maps\mp\gametypes\_damage::Callback_PlayerKilled;
  179. level.callbackCodeEndGame = maps\mp\gametypes\_gamelogic::Callback_CodeEndGame;
  180. level.callbackPlayerLastStand = maps\mp\gametypes\_damage::Callback_PlayerLastStand;
  181. level.callbackPlayerMigrated = maps\mp\gametypes\_playerlogic::Callback_PlayerMigrated;
  182. level.callbackHostMigration = maps\mp\gametypes\_hostmigration::Callback_HostMigration;
  183. }
  184.  
  185.  
  186. /*================
  187. Called when a gametype is not supported.
  188. ================*/
  189. AbortLevel()
  190. {
  191. println("Aborting level - gametype is not supported");
  192.  
  193. level.callbackStartGameType = ::callbackVoid;
  194. level.callbackPlayerConnect = ::callbackVoid;
  195. level.callbackPlayerDisconnect = ::callbackVoid;
  196. level.callbackPlayerDamage = ::callbackVoid;
  197. level.callbackPlayerKilled = ::callbackVoid;
  198. level.callbackCodeEndGame = ::callbackVoid;
  199. level.callbackPlayerLastStand = ::callbackVoid;
  200. level.callbackPlayerMigrated = ::callbackVoid;
  201. level.callbackHostMigration = ::callbackVoid;
  202.  
  203. setdvar("g_gametype", "dm");
  204.  
  205. exitLevel(false);
  206. }
  207.  
  208.  
  209. /*================
  210. ================*/
  211. callbackVoid()
  212. {
  213. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement