Guest User

Untitled

a guest
Dec 11th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. datablock audioDescription( audioSlightQuietClosest3D : audioClosest3D )
  2. {
  3. volume = 0.8;
  4. };
  5.  
  6. datablock audioProfile( quake3_hitsound )
  7. {
  8. filename = "./hitsound.wav";
  9. description = audioSlightQuietClosest3D;
  10. preload = true;
  11. };
  12.  
  13. package quake3_package
  14. {
  15. function armor::onNewDataBlock( %this, %obj )
  16. {
  17. parent::onNewDataBlock( %this, %obj );
  18.  
  19. if ( isObject( %cl = %obj.getControllingClient() ) )
  20. {
  21. %cl.sendQ3Update();
  22. }
  23. }
  24.  
  25. function gameConnection::setControlObject( %this, %obj )
  26. {
  27. parent::setControlObject( %this, %obj );
  28. %this.sendQ3Update();
  29. }
  30.  
  31. function player::setHealth( %this, %value, %cl )
  32. {
  33. if ( %this.getDataBlock().getName() $= "playerQuake3Armor" )
  34. {
  35. %this.health = mClamp( mFloatLength( %value, 0 ), -20, 200 );
  36.  
  37. if ( %this.health > 100 && !isEventPending( %this.decayQ3HealthTick ) )
  38. {
  39. %this.decayQ3HealthTick = %this.schedule( 1000, "decayQ3HealthTick" );
  40. }
  41. else if ( %this.health <= 0 )
  42. {
  43. %this.kill();
  44. }
  45. else if ( isObject( %cl = %this.getControllingClient() ) )
  46. {
  47. %cl.sendQ3Update();
  48. }
  49. }
  50. else
  51. {
  52. parent::setHealth( %this, %value, %cl );
  53. }
  54. }
  55.  
  56. function player::kill( %this, %cl )
  57. {
  58. if ( %this.getDataBlock().getName() $= "playerQuake3Armor" )
  59. {
  60. %this.health = 0;
  61. %this.armor = 0;
  62.  
  63. %this.damage( %this, %this.getHackPosition(), 1, $DamageType::Suicide );
  64. }
  65. else
  66. {
  67. parent::kill( %this, %cl );
  68. }
  69. }
  70. };
  71.  
  72. activatePackage( "quake3_package" );
  73.  
  74. function playerQuake3Armor::onAdd( %this, %obj )
  75. {
  76. %obj.health = 100;
  77. %obj.armor = 0;
  78.  
  79. if ( isObject( %cl = %obj.getControllingClient() ) )
  80. {
  81. %cl.sendQ3Update();
  82. }
  83. }
  84.  
  85. function playerQuake3Armor::onNewDataBlock( %this, %obj )
  86. {
  87. if ( !strLen( %obj.health ) )
  88. {
  89. %obj.health = 100;
  90. }
  91.  
  92. if ( !strLen( %obj.armor ) )
  93. {
  94. %obj.armor = 0;
  95. }
  96.  
  97. parent::onNewDataBlock( %this, %obj );
  98. }
  99.  
  100. function playerQuake3Armor::damage( %this, %obj, %src, %pos, %dmg, %type )
  101. {
  102. %dmg = mCeil( %dmg );
  103.  
  104. if ( %dmg <= 0 )
  105. {
  106. return;
  107. }
  108.  
  109. if ( isObject( %cl = %obj.getControllingClient() ) )
  110. {
  111. %cl.play2D( quake3_hitsound );
  112. }
  113.  
  114. if ( %obj.armor )
  115. {
  116. %part = mCeil( %dmg * ( 2 / 3 ) );
  117.  
  118. if ( %obj.armor >= %part )
  119. {
  120. %dmg -= %part;
  121. %obj.armor -= %part;
  122. }
  123. else
  124. {
  125. %dmg -= $armor;
  126. %obj.armor = 0;
  127. }
  128. }
  129.  
  130. %obj.health -= %dmg;
  131.  
  132. if ( %obj.health <= 0 )
  133. {
  134. %obj.spawnTime = 0;
  135.  
  136. // if ( %obj.health <= -20 )
  137. // {
  138. // kill with gib;
  139. // }
  140. // else
  141. // {
  142. parent::damage( %this, %obj, %src, %pos, %this.maxDamage, %type );
  143. // }
  144. }
  145. else
  146. {
  147. %obj.playPain();
  148. }
  149. }
  150.  
  151. function gameConnection::sendQ3Update( %this )
  152. {
  153. %obj = %this.getControlObject();
  154.  
  155. if ( isObject( %obj ) && ( %obj.getType() & $TypeMasks::PlayerObjectType ) && %obj.getDataBlock().isQ3A )
  156. {
  157. commandToClient( %this, 'Q3A_Health', %obj.health );
  158. commandToClient( %this, 'Q3A_Armor', %obj.armor );
  159. }
  160. else
  161. {
  162. commandToClient( %this, 'Q3A_Health', 0 );
  163. commandToClient( %this, 'Q3A_Armor', 0 );
  164. }
  165. }
  166.  
  167. function player::decayQ3HealthTick( %this )
  168. {
  169. cancel( %this.decayQ3HealthTick );
  170.  
  171. if ( %this.health > 100 )
  172. {
  173. %this.health -= 100;
  174.  
  175. if ( %this.health < 100 )
  176. {
  177. %this.health = 100;
  178. }
  179. }
  180. else
  181. {
  182. return;
  183. }
  184.  
  185. if ( isObject( %cl = %this.getControllingClient() ) )
  186. {
  187. %cl.sendQ3Update();
  188. }
  189.  
  190. %this.decayQ3HealthTick = %this.schedule( 1000, "decayQ3HealthTick" );
  191. }
  192.  
  193. // function q3a_deal_damage( %damage )
  194. // {
  195. // %damage = mCeil( %damage );
  196.  
  197. // if ( $armor )
  198. // {
  199. // %part = mCeil( %damage * ( 2 / 3 ) );
  200.  
  201. // if ( $armor >= %part )
  202. // {
  203. // %damage -= %part;
  204. // $armor -= %part;
  205. // }
  206. // else
  207. // {
  208. // %damage -= $armor;
  209. // $armor = 0;
  210. // }
  211. // }
  212.  
  213. // $health -= %damage;
  214.  
  215. // if ( $health <= 0 )
  216. // {
  217. // íf ( $health <= -20 )
  218. // {
  219. // kill with gib;
  220. // }
  221. // else
  222. // {
  223. // kill;
  224. // }
  225. // }
  226. // }
Add Comment
Please, Sign In to add comment