Advertisement
Guest User

help

a guest
May 1st, 2011
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.59 KB | None | 0 0
  1. #include maps\mp\_utility;
  2.  
  3. init()
  4. {
  5. level.healthOverlayCutoff = 0.55;
  6.  
  7. regenTime = 5;
  8. regenTime = maps\mp\gametypes\_tweakables::getTweakableValue( "player", "healthregentime" );
  9.  
  10. level.playerHealth_RegularRegenDelay = regenTime * 1000;
  11.  
  12. level.healthRegenDisabled = (level.playerHealth_RegularRegenDelay <= 0);
  13.  
  14. level thread onPlayerConnect();
  15. }
  16.  
  17. onPlayerConnect()
  18. {
  19. for(;;)
  20. {
  21. level waittill("connected", player);
  22.  
  23. player thread onPlayerSpawned();
  24. }
  25. }
  26.  
  27.  
  28. onPlayerSpawned()
  29. {
  30. self endon("disconnect");
  31.  
  32. for(;;)
  33. {
  34. self waittill("spawned_player");
  35. //self thread playerHealthRegen();
  36.  
  37. self thread showTempDamage();
  38. }
  39. }
  40.  
  41.  
  42. showTempDamage()
  43. {
  44. self endon ( "death" );
  45. self endon ( "disconnect" );
  46. /#
  47. setDevDvar( "scr_damage_wait", 0 );
  48. setDevDvar( "scr_damage_fadein", 0.25 );
  49. setDevDvar( "scr_damage_fadeout", 0.5 );
  50. setDevDvar( "scr_damage_holdtime", 0.5 );
  51. setDevDvar( "scr_damage_numfades", 5 );
  52.  
  53. for ( ;; )
  54. {
  55. while ( getDvarFloat( "scr_damage_wait" ) <= 0 )
  56. wait ( 1.0 );
  57.  
  58. wait ( getDvarFloat( "scr_damage_wait" ) );
  59.  
  60. for ( i = 0; i < getDvarInt( "scr_damage_numfades" ); i++ )
  61. {
  62. self VisionSetNakedForPlayer( "mp_crash_damage", getDvarFloat( "scr_damage_fadein" ) * (getDvarInt( "scr_damage_numfades" ) - i) );
  63. wait ( getDvarFloat( "scr_damage_fadein" ) + getDvarFloat( "scr_damage_holdtime" ) );
  64. self VisionSetNakedForPlayer( "mp_crash", getDvarFloat( "scr_damage_fadeout" ) * getDvarInt( "scr_damage_numfades" ) );
  65. wait ( getDvarFloat( "scr_damage_fadeout" ) );
  66. }
  67.  
  68. }
  69. #/
  70. }
  71.  
  72. playerHealthRegen()
  73. {
  74. self endon ( "death" );
  75. self endon ( "disconnect" );
  76. self endon ( "joined_team" );
  77. self endon ( "joined_spectators" );
  78.  
  79. if ( self.health <= 0 )
  80. {
  81. assert( !isalive( self ) );
  82. return;
  83. }
  84.  
  85. oldhealth = self.maxhealth;
  86.  
  87. regenRate = 0.1;
  88. veryHurt = false;
  89.  
  90. self.breathingStopTime = -10000;
  91.  
  92. thread playerBreathingSound( self.maxhealth * 0.35 );
  93.  
  94. lastSoundTime_Recover = 0;
  95. hurtTime = 0;
  96. newHealth = 0;
  97.  
  98. for (;;)
  99. {
  100. wait ( 0.05 );
  101. if ( isDefined( level.hostMigrationTimer ) )
  102. {
  103. timePassed = maps\mp\gametypes\_hostmigration::waitTillHostMigrationDone();
  104.  
  105. hurtTime += timePassed;
  106. lastSoundTime_Recover += timePassed;
  107. }
  108.  
  109. if ( self.health == self.maxhealth || ( level.dieHardMode && isDefined( self.healthClamped ) && self.health >= self.healthClamped ) ) // runs every frame
  110. {
  111. oldHealth = self.maxhealth;
  112. veryHurt = false;
  113. self.atBrinkOfDeath = false;
  114. continue;
  115. }
  116.  
  117. if ( self.health <= 0 ) // player dead
  118. return;
  119.  
  120. curTime = getTime();
  121.  
  122. ratio = self.health / self.maxHealth;
  123.  
  124. if ( ratio <= level.healthOverlayCutoff )
  125. {
  126. if ( !veryHurt )
  127. hurtTime = curTime;
  128.  
  129. veryHurt = true;
  130. self.atBrinkOfDeath = true;
  131. }
  132.  
  133. if ( self.health >= oldhealth )
  134. {
  135. if ( curTime - hurtTime < level.playerHealth_RegularRegenDelay )
  136. continue;
  137.  
  138. if ( level.healthRegenDisabled )
  139. {
  140. wait ( 3.0 );
  141. self.maxHealth = int( max( self.health, 2 ) );
  142. self.health = self.maxHealth;
  143.  
  144. continue;
  145. }
  146.  
  147. if ( curTime - lastSoundTime_Recover > level.playerHealth_RegularRegenDelay )
  148. {
  149. lastSoundTime_Recover = curTime;
  150. if ( !level.gameEnded )
  151. self playLocalSound("breathing_better");
  152. }
  153.  
  154. if ( veryHurt )
  155. {
  156. newHealth = ratio;
  157. if ( curTime > hurtTime + 3000 )
  158. newHealth += regenRate;
  159. }
  160. else
  161. {
  162. newHealth = 1;
  163. }
  164.  
  165. if ( newHealth >= 1.0 )
  166. {
  167. if ( veryHurt )
  168. self maps\mp\gametypes\_missions::healthRegenerated();
  169.  
  170. self maps\mp\gametypes\_damage::resetAttackerList();
  171. newHealth = 1.0;
  172. }
  173.  
  174. if (newHealth <= 0)
  175. {
  176. // Player is dead
  177. return;
  178. }
  179.  
  180. self setNormalHealth (newHealth);
  181. oldHealth = self.health;
  182. continue;
  183. }
  184.  
  185. // first time damaged
  186. oldHealth = self.health;
  187. hurtTime = curTime;
  188. self.breathingStopTime = hurtTime + 6000;
  189. }
  190. }
  191.  
  192. playerBreathingSound( healthcap )
  193. {
  194. level endon ( "game_ended" );
  195. self endon ( "death" );
  196. self endon ( "disconnect" );
  197. self endon ( "joined_team" );
  198. self endon ( "joined_spectators" );
  199.  
  200. wait ( 2 );
  201.  
  202. for (;;)
  203. {
  204. wait ( 0.2 );
  205.  
  206. if ( self.health <= 0 )
  207. return;
  208.  
  209. // Player still has a lot of health so no breathing sound
  210. if ( self.health >= healthcap )
  211. continue;
  212.  
  213. if ( level.healthRegenDisabled && gettime() > self.breathingStopTime )
  214. continue;
  215.  
  216. self playLocalSound( "breathing_hurt" );
  217.  
  218. wait ( .784 );
  219. wait ( 0.1 + randomfloat (0.8) );
  220. }
  221. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement