Advertisement
Guest User

Untitled

a guest
Sep 29th, 2010
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. main()
  2. {
  3. precacheShellshock("flashbang_mp");
  4. }
  5.  
  6.  
  7. startMonitoringFlash()
  8. {
  9. self thread monitorFlash();
  10. }
  11.  
  12.  
  13. stopMonitoringFlash(disconnected)
  14. {
  15. self notify("stop_monitoring_flash");
  16. }
  17.  
  18.  
  19. flashRumbleLoop( duration )
  20. {
  21. self endon("stop_monitoring_flash");
  22.  
  23. self endon("flash_rumble_loop");
  24. self notify("flash_rumble_loop");
  25.  
  26. goalTime = getTime() + duration * 1000;
  27.  
  28. while ( getTime() < goalTime )
  29. {
  30. self PlayRumbleOnEntity( "damage_heavy" );
  31. wait( 0.05 );
  32. }
  33. }
  34.  
  35.  
  36. monitorFlash()
  37. {
  38. self endon("disconnect");
  39. self.flashEndTime = 0;
  40. while(1)
  41. {
  42. self waittill( "flashbang", origin, amount_distance, amount_angle, attacker );
  43.  
  44. if ( !isalive( self ) )
  45. continue;
  46.  
  47. if ( isDefined( self.usingRemote ) )
  48. continue;
  49.  
  50. hurtattacker = false;
  51. hurtvictim = true;
  52.  
  53. if ( amount_angle < 0.5 )
  54. amount_angle = 0.5;
  55. else if ( amount_angle > 0.8 )
  56. amount_angle = 1;
  57.  
  58. duration = amount_distance * amount_angle * 6;
  59.  
  60. if ( duration < 0.25 )
  61. continue;
  62.  
  63. rumbleduration = undefined;
  64. if ( duration > 2 )
  65. rumbleduration = 0.75;
  66. else
  67. rumbleduration = 0.25;
  68.  
  69. assert(isdefined(self.pers["team"]));
  70. if (level.teamBased && isdefined(attacker) && isdefined(attacker.pers["team"]) && attacker.pers["team"] == self.pers["team"] && attacker != self)
  71. {
  72. if(level.friendlyfire == 0) // no FF
  73. {
  74. continue;
  75. }
  76. else if(level.friendlyfire == 1) // FF
  77. {
  78. }
  79. else if(level.friendlyfire == 2) // reflect
  80. {
  81. duration = duration * .5;
  82. rumbleduration = rumbleduration * .5;
  83. hurtvictim = false;
  84. hurtattacker = true;
  85. }
  86. else if(level.friendlyfire == 3) // share
  87. {
  88. duration = duration * .5;
  89. rumbleduration = rumbleduration * .5;
  90. hurtattacker = true;
  91. }
  92. }
  93. else
  94. {
  95. attacker notify( "flash_hit" );
  96. }
  97.  
  98. if (hurtvictim)
  99. self thread applyFlash(duration, rumbleduration);
  100. if (hurtattacker)
  101. attacker thread applyFlash(duration, rumbleduration);
  102. }
  103. }
  104.  
  105. applyFlash(duration, rumbleduration)
  106. {
  107. // wait for the highest flash duration this frame,
  108. // and apply it in the following frame
  109.  
  110. if (!isdefined(self.flashDuration) || duration > self.flashDuration)
  111. self.flashDuration = duration;
  112. if (!isdefined(self.flashRumbleDuration) || rumbleduration > self.flashRumbleDuration)
  113. self.flashRumbleDuration = rumbleduration;
  114.  
  115. wait .05;
  116.  
  117. if (isdefined(self.flashDuration)) {
  118. self shellshock( "flashbang_mp", self.flashDuration ); // TODO: avoid shellshock overlap
  119. self.flashEndTime = getTime() + (self.flashDuration * 1000);
  120. }
  121. if (isdefined(self.flashRumbleDuration)) {
  122. self thread flashRumbleLoop( self.flashRumbleDuration ); //TODO: Non-hacky rumble.
  123. }
  124.  
  125. self.flashDuration = undefined;
  126. self.flashRumbleDuration = undefined;
  127. }
  128.  
  129.  
  130. isFlashbanged()
  131. {
  132. return isDefined( self.flashEndTime ) && gettime() < self.flashEndTime;
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement