home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / quake / programs / sgqcver3 / player.qc < prev    next >
Encoding:
Text File  |  1996-08-25  |  26.0 KB  |  838 lines

  1. void() W_FireChain;
  2. void() W_ThrowAxe;
  3. void() MakeSolidHead;
  4. void() bubble_bob;
  5. void() feign;
  6. void(entity me) hologram_explode;
  7. /*
  8. ==============================================================================
  9.  
  10. PLAYER
  11.  
  12. ==============================================================================
  13. */
  14.  
  15. $cd /raid/quake/id1/models/player_4
  16. $origin 0 -6 24
  17. $base base        
  18. $skin skin
  19.  
  20. //
  21. // running
  22. //
  23. $frame axrun1 axrun2 axrun3 axrun4 axrun5 axrun6
  24.  
  25. $frame rockrun1 rockrun2 rockrun3 rockrun4 rockrun5 rockrun6
  26.  
  27. //
  28. // standing
  29. //
  30. $frame stand1 stand2 stand3 stand4 stand5
  31.  
  32. $frame axstnd1 axstnd2 axstnd3 axstnd4 axstnd5 axstnd6
  33. $frame axstnd7 axstnd8 axstnd9 axstnd10 axstnd11 axstnd12
  34.  
  35.  
  36. //
  37. // pain
  38. //
  39. $frame axpain1 axpain2 axpain3 axpain4 axpain5 axpain6
  40.  
  41. $frame pain1 pain2 pain3 pain4 pain5 pain6
  42.  
  43.  
  44. //
  45. // death
  46. //
  47.  
  48. $frame axdeth1 axdeth2 axdeth3 axdeth4 axdeth5 axdeth6
  49. $frame axdeth7 axdeth8 axdeth9
  50.  
  51. $frame deatha1 deatha2 deatha3 deatha4 deatha5 deatha6 deatha7 deatha8
  52. $frame deatha9 deatha10 deatha11
  53.  
  54. $frame deathb1 deathb2 deathb3 deathb4 deathb5 deathb6 deathb7 deathb8
  55. $frame deathb9
  56.  
  57. $frame deathc1 deathc2 deathc3 deathc4 deathc5 deathc6 deathc7 deathc8
  58. $frame deathc9 deathc10 deathc11 deathc12 deathc13 deathc14 deathc15
  59.  
  60. $frame deathd1 deathd2 deathd3 deathd4 deathd5 deathd6 deathd7
  61. $frame deathd8 deathd9
  62.  
  63. $frame deathe1 deathe2 deathe3 deathe4 deathe5 deathe6 deathe7
  64. $frame deathe8 deathe9
  65.  
  66. //
  67. // attacks
  68. //
  69. $frame nailatt1 nailatt2
  70.  
  71. $frame light1 light2
  72.  
  73. $frame rockatt1 rockatt2 rockatt3 rockatt4 rockatt5 rockatt6
  74.  
  75. $frame shotatt1 shotatt2 shotatt3 shotatt4 shotatt5 shotatt6
  76.  
  77. $frame axatt1 axatt2 axatt3 axatt4 axatt5 axatt6
  78.  
  79. $frame axattb1 axattb2 axattb3 axattb4 axattb5 axattb6
  80.  
  81. $frame axattc1 axattc2 axattc3 axattc4 axattc5 axattc6
  82.  
  83. $frame axattd1 axattd2 axattd3 axattd4 axattd5 axattd6
  84.  
  85.  
  86. /*
  87. ==============================================================================
  88. PLAYER
  89. ==============================================================================
  90. */
  91.  
  92. void() player_run;
  93.  
  94. void()    player_stand1 =[    $axstnd1,    player_stand1    ]
  95. {
  96.     self.weaponframe=0;
  97.     if (self.velocity_x || self.velocity_y)
  98.     {
  99.         self.walkframe=0;
  100.         player_run();
  101.         return;
  102.     }
  103.  
  104.     if (self.weapon == IT_AXE || self.weapon == IT_THROWING_AXE)
  105.     {
  106.         if (self.walkframe >= 12)
  107.             self.walkframe = 0;
  108.         self.frame = $axstnd1 + self.walkframe;
  109.     }
  110.     else
  111.     {
  112.         if (self.walkframe >= 5)
  113.             self.walkframe = 0;
  114.         self.frame = $stand1 + self.walkframe;
  115.     }
  116.     self.walkframe = self.walkframe + 1;    
  117. };
  118.  
  119. void()    player_run =[    $rockrun1,    player_run    ]
  120. {
  121.     self.weaponframe=0;
  122.     if (!self.velocity_x && !self.velocity_y)
  123.     {
  124.         self.walkframe=0;
  125.         player_stand1();
  126.         return;
  127.     }
  128.  
  129.     if (self.weapon == IT_AXE || self.weapon == IT_THROWING_AXE)
  130.     {
  131.         if (self.walkframe == 6)
  132.             self.walkframe = 0;
  133.         self.frame = $axrun1 + self.walkframe;
  134.     }
  135.     else
  136.     {
  137.         if (self.walkframe == 6)
  138.             self.walkframe = 0;
  139.         self.frame = self.frame + self.walkframe;
  140.     }
  141.         if (self.walkframe == 1)
  142.         {
  143.                 if (checkbottom(self) == TRUE)
  144.                 {
  145.                         if (self.waterlevel == 0)
  146.                                 sound (self, CHAN_AUTO, "player/step.wav", 1, ATTN_NORM);
  147.                 }
  148.         }
  149.     self.walkframe = self.walkframe + 1;
  150. };
  151.  
  152.  
  153. void()    player_shot1 =    [$shotatt1, player_shot2    ] {self.weaponframe=1;
  154. self.effects = self.effects | EF_MUZZLEFLASH;};
  155. void()    player_shot2 =    [$shotatt2, player_shot3    ] {self.weaponframe=2;};
  156. void()    player_shot3 =    [$shotatt3, player_shot4    ] {self.weaponframe=3;};
  157. void()    player_shot4 =    [$shotatt4, player_shot5    ] {self.weaponframe=4;};
  158. void()    player_shot5 =    [$shotatt5, player_shot6    ] {self.weaponframe=5;};
  159. void()    player_shot6 =    [$shotatt6, player_run    ] {self.weaponframe=6;};
  160.  
  161. void()  player_tax1 =   [$axatt1, player_tax2   ] {self.weaponframe=1;};
  162. void()  player_tax2 =   [$axatt2, player_tax3   ] {self.weaponframe=2;};
  163. void()  player_tax3 =   [$axatt3, player_tax4   ] {self.weaponframe=3;W_ThrowAxe();};
  164. void()  player_tax4 =   [$axatt4, player_run    ] {self.weaponframe=4;};
  165.  
  166. void()    player_axe1 =    [$axatt1, player_axe2    ] {self.weaponframe=1;};
  167. void()    player_axe2 =    [$axatt2, player_axe3    ] {self.weaponframe=2;};
  168. void()    player_axe3 =    [$axatt3, player_axe4    ] {self.weaponframe=3;W_FireAxe();};
  169. void()    player_axe4 =    [$axatt4, player_run    ] {self.weaponframe=4;};
  170.  
  171. void()    player_axeb1 =    [$axattb1, player_axeb2    ] {self.weaponframe=5;};
  172. void()    player_axeb2 =    [$axattb2, player_axeb3    ] {self.weaponframe=6;};
  173. void()    player_axeb3 =    [$axattb3, player_axeb4    ] {self.weaponframe=7;W_FireAxe();};
  174. void()    player_axeb4 =    [$axattb4, player_run    ] {self.weaponframe=8;};
  175.  
  176. void()    player_axec1 =    [$axattc1, player_axec2    ] {self.weaponframe=1;};
  177. void()    player_axec2 =    [$axattc2, player_axec3    ] {self.weaponframe=2;};
  178. void()    player_axec3 =    [$axattc3, player_axec4    ] {self.weaponframe=3;W_FireAxe();};
  179. void()    player_axec4 =    [$axattc4, player_run    ] {self.weaponframe=4;};
  180.  
  181. void()    player_axed1 =    [$axattd1, player_axed2    ] {self.weaponframe=5;};
  182. void()    player_axed2 =    [$axattd2, player_axed3    ] {self.weaponframe=6;};
  183. void()    player_axed3 =    [$axattd3, player_axed4    ] {self.weaponframe=7;W_FireAxe();};
  184. void()    player_axed4 =    [$axattd4, player_run    ] {self.weaponframe=8;};
  185.  
  186. void()  player_chain5=  [$axattd4, player_run    ] {self.weaponframe=5;};
  187. void()  player_chain4=  [$deathc4, player_chain4 ]
  188. {
  189.         self.weaponframe=4;
  190.         if (!self.hook_out)
  191.         {
  192.                 player_chain5();
  193.                 return;
  194.         }
  195.         if (vlen(self.velocity) < 750)
  196.         {
  197.                 player_chain3();
  198.                 return;
  199.         }
  200. };
  201. void()  player_chain3=  [$axattd3, player_chain3 ]
  202. {
  203.         self.weaponframe=3;
  204.         if (!self.hook_out)
  205.         {
  206.                 player_chain5();
  207.                 return;
  208.         }
  209.         if (vlen(self.velocity) >= 750)
  210.         {
  211.                 player_chain4();
  212.                 return;
  213.         }
  214. };
  215. void()  player_chain2=  [$axattd2, player_chain3 ] {self.weaponframe=3;W_FireChain();};
  216. void()  player_chain1=  [$axattd1, player_chain2 ] {self.weaponframe=2;};
  217.  
  218. void()  player_feigna1    =       [       $deatha1,       player_feigna2    ] {};
  219. void()  player_feigna2    =       [       $deatha2,       player_feigna3    ] {};
  220. void()  player_feigna3    =       [       $deatha3,       player_feigna4    ] {};
  221. void()  player_feigna4    =       [       $deatha4,       player_feigna5    ] {};
  222. void()  player_feigna5    =       [       $deatha5,       player_feigna6    ] {};
  223. void()  player_feigna6    =       [       $deatha6,       player_feigna7    ] {};
  224. void()  player_feigna7    =       [       $deatha7,       player_feigna8    ] {};
  225. void()  player_feigna8    =       [       $deatha8,       player_feigna9    ] {};
  226. void()  player_feigna9    =       [       $deatha9,       player_feigna10   ] {};
  227. void()  player_feigna10   =       [       $deatha10,      player_feigna11   ] {};
  228. void()  player_feigna11   =       [       $deatha11,      player_feigna11   ] {};
  229.  
  230. void() player_upa1 = [$deathd9, player_upa2] {self.view_ofs = '0 0 4';};
  231. void() player_upa2 = [$deathd8, player_upa3] {self.view_ofs = '0 0 6';};
  232. void() player_upa3 = [$deathd7, player_upa4] {self.view_ofs = '0 0 8';};
  233. void() player_upa4 = [$deathd6, player_upa5] {self.view_ofs = '0 0 10';};
  234. void() player_upa5 = [$deathd5, player_upa6] {self.view_ofs = '0 0 12';};
  235. void() player_upa6 = [$deathd4, player_upa7] {self.view_ofs = '0 0 14';};
  236. void() player_upa7 = [$deathd3, player_upa8] {self.view_ofs = '0 0 16';};
  237. void() player_upa8 = [$deathd2, player_upa9] {self.view_ofs = '0 0 18';};
  238. void() player_upa9 = [$deathd1, player_upa9] {player_stand1 ();};
  239.  
  240. void() player_upax1 = [$axdeth9, player_upax2] {self.view_ofs = '0 0 4';};
  241. void() player_upax2 = [$axdeth8, player_upax3] {self.view_ofs = '0 0 6';};
  242. void() player_upax3 = [$axdeth7, player_upax4] {self.view_ofs = '0 0 8';};
  243. void() player_upax4 = [$axdeth6, player_upax5] {self.view_ofs = '0 0 10';};
  244. void() player_upax5 = [$axdeth5, player_upax6] {self.view_ofs = '0 0 12';};
  245. void() player_upax6 = [$axdeth4, player_upax7] {self.view_ofs = '0 0 14';};
  246. void() player_upax7 = [$axdeth3, player_upax8] {self.view_ofs = '0 0 16';};
  247. void() player_upax8 = [$axdeth2, player_upax9] {self.view_ofs = '0 0 18';};
  248. void() player_upax9 = [$axdeth1, player_upax9] {player_stand1 ();};
  249.  
  250. void() player_up =
  251. {
  252.         self.flags = self.flags - (self.flags & FL_ISFEIGN);
  253.         self.movetype = MOVETYPE_WALK;
  254.         self.weaponmodel = self.oldweaponmodel;
  255.         self.weapon = self.oldweapon;
  256.         self.oldweapon = 0;
  257.         if (self.weapon == IT_AXE || self.weapon == IT_THROWING_AXE || self.weapon == IT_MORNINGSTAR)
  258.                 player_upax1 ();
  259.     else
  260.                 player_upa1 ();
  261.         setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
  262.         self.view_ofs = '0 0 22';
  263.     self.th_pain = player_pain;
  264. };
  265.  
  266. void() player_axfall1 = [$axdeth1, player_axfall2] {self.view_ofs = '0 0 18';};
  267. void() player_axfall2 = [$axdeth2, player_axfall3] {self.view_ofs = '0 0 16';};
  268. void() player_axfall3 = [$axdeth3, player_axfall4] {self.view_ofs = '0 0 14';};
  269. void() player_axfall4 = [$axdeth4, player_axfall5] {self.view_ofs = '0 0 12';};
  270. void() player_axfall5 = [$axdeth5, player_axfall6] {self.view_ofs = '0 0 10';};
  271. void() player_axfall6 = [$axdeth6, player_axfall7] {self.view_ofs = '0 0 8';};
  272. void() player_axfall7 = [$axdeth7, player_axfall8] {self.view_ofs = '0 0 6';};
  273. void() player_axfall8 = [$axdeth8, player_axfall9] {self.view_ofs = '0 0 4';};
  274. void() player_axfall9 = [$axdeth9, player_axfall9]
  275. {
  276.         self.nextthink = time + 0.3;
  277.         self.think = player_up;
  278. };
  279.  
  280. void()  player_fall1 =  [$deathd1,  player_fall2]  {self.view_ofs = '0 0 18';};
  281. void()  player_fall2 =  [$deathd2,  player_fall3]  {self.view_ofs = '0 0 16';};
  282. void()  player_fall3 =  [$deathd3,  player_fall4]  {self.view_ofs = '0 0 14';};
  283. void()  player_fall4 =  [$deathd4,  player_fall5]  {self.view_ofs = '0 0 12';};
  284. void()  player_fall5 =  [$deathd5,  player_fall6]  {self.view_ofs = '0 0 10';};
  285. void()  player_fall6 =  [$deathd6,  player_fall7]  {self.view_ofs = '0 0 8';};
  286. void()  player_fall7 =  [$deathd7,  player_fall8]  {self.view_ofs = '0 0 6';};
  287. void()  player_fall8 =  [$deathd8,  player_fall9]  {self.view_ofs = '0 0 4';};
  288. void()  player_fall9 =  [$deathd9,  player_fall9]
  289. {
  290.         self.nextthink = time + 0.3;
  291.         self.think = player_up;
  292. };
  293.  
  294. void() player_fall =
  295. {
  296.         if ( !(sg_mods & FL_FALL) )
  297.                 return;
  298.         if (self.invisible_finished > time)
  299.                 return;         // eyes don't have pain frames
  300.         if (self.flags & FL_ISFEIGN)       // experimental
  301.                 return;
  302.         self.flags = self.flags | FL_ISFEIGN;
  303.         self.oldweapon = self.weapon;   
  304.         self.weapon = 0;
  305.         self.oldweaponmodel = self.weaponmodel;
  306.         self.weaponmodel = "";
  307.         self.movetype = MOVETYPE_TOSS;
  308.         if (self.oldweapon == IT_AXE || self.oldweapon == IT_THROWING_AXE || self.weapon == IT_MORNINGSTAR)
  309.         player_axfall1 ();
  310.     else
  311.         player_fall1 ();
  312.         setsize (self , '-16 -16 -4' , '16 16 4');
  313.         self.view_ofs = '0 0 2';
  314. };
  315.  
  316. void() player_nail1   =[$nailatt1, player_nail2  ] 
  317. {
  318.     self.effects = self.effects | EF_MUZZLEFLASH;
  319.  
  320.     if (!self.button0)
  321.         {player_run ();return;}
  322.     self.weaponframe = self.weaponframe + 1;
  323.     if (self.weaponframe == 9)
  324.         self.weaponframe = 1;
  325.     SuperDamageSound();
  326.     W_FireSpikes (4);
  327.     self.attack_finished = time + 0.2;
  328. };
  329. void() player_nail2   =[$nailatt2, player_nail1  ]
  330. {
  331.     self.effects = self.effects | EF_MUZZLEFLASH;
  332.  
  333.     if (!self.button0)
  334.         {player_run ();return;}
  335.     self.weaponframe = self.weaponframe + 1;
  336.     if (self.weaponframe == 9)
  337.         self.weaponframe = 1;
  338.     SuperDamageSound();
  339.     W_FireSpikes (-4);
  340.     self.attack_finished = time + 0.2;
  341. };
  342.  
  343. //============================================================================
  344.  
  345. void() player_light1   =[$light1, player_light2  ] 
  346. {
  347.     self.effects = self.effects | EF_MUZZLEFLASH;
  348.  
  349.     if (!self.button0)
  350.         {player_run ();return;}
  351.     self.weaponframe = self.weaponframe + 1;
  352.     if (self.weaponframe == 5)
  353.         self.weaponframe = 1;
  354.     SuperDamageSound();
  355.     W_FireLightning();
  356.     self.attack_finished = time + 0.2;
  357. };
  358. void() player_light2   =[$light2, player_light1  ]
  359. {
  360.     self.effects = self.effects | EF_MUZZLEFLASH;
  361.  
  362.     if (!self.button0)
  363.         {player_run ();return;}
  364.     self.weaponframe = self.weaponframe + 1;
  365.     if (self.weaponframe == 5)
  366.         self.weaponframe = 1;
  367.     SuperDamageSound();
  368.     W_FireLightning();
  369.     self.attack_finished = time + 0.2;
  370. };
  371.  
  372. //============================================================================
  373.  
  374.  
  375. void() player_rocket1   =[$rockatt1, player_rocket2  ] {self.weaponframe=1;
  376. self.effects = self.effects | EF_MUZZLEFLASH;};
  377. void() player_rocket2   =[$rockatt2, player_rocket3  ] {self.weaponframe=2;};
  378. void() player_rocket3   =[$rockatt3, player_rocket4  ] {self.weaponframe=3;};
  379. void() player_rocket4   =[$rockatt4, player_rocket5  ] {self.weaponframe=4;};
  380. void() player_rocket5   =[$rockatt5, player_rocket6  ] {self.weaponframe=5;};
  381. void() player_rocket6   =[$rockatt6, player_run  ] {self.weaponframe=6;};
  382. void(float num_bubbles) DeathBubbles;
  383.  
  384. void() PainSound =
  385. {
  386. local float        rs;
  387. local float             which_hit;
  388.     if (self.health < 0)
  389.         return;
  390.  
  391.     if (damage_attacker.classname == "teledeath")
  392.     {
  393.         sound (self, CHAN_VOICE, "player/teledth1.wav", 1, ATTN_NONE);
  394.         return;
  395.     }
  396.  
  397. // water pain sounds
  398.     if (self.watertype == CONTENT_WATER && self.waterlevel == 3)
  399.     {
  400.         DeathBubbles(1);
  401.         if (random() > 0.5)
  402.             sound (self, CHAN_VOICE, "player/drown1.wav", 1, ATTN_NORM);
  403.         else
  404.             sound (self, CHAN_VOICE, "player/drown2.wav", 1, ATTN_NORM);
  405.         return;
  406.     }
  407.  
  408. // slime pain sounds
  409.     if (self.watertype == CONTENT_SLIME)
  410.     {
  411. // FIX ME    put in some steam here
  412.         if (random() > 0.5)
  413.             sound (self, CHAN_VOICE, "player/lburn1.wav", 1, ATTN_NORM);
  414.         else
  415.             sound (self, CHAN_VOICE, "player/lburn2.wav", 1, ATTN_NORM);
  416.         return;
  417.     }
  418.  
  419.     if (self.watertype == CONTENT_LAVA)
  420.     {
  421.         if (random() > 0.5)
  422.             sound (self, CHAN_VOICE, "player/lburn1.wav", 1, ATTN_NORM);
  423.         else
  424.             sound (self, CHAN_VOICE, "player/lburn2.wav", 1, ATTN_NORM);
  425.         return;
  426.     }
  427.  
  428.     if (self.pain_finished > time)
  429.     {
  430.         self.axhitme = 0;
  431.         return;
  432.     }
  433.     self.pain_finished = time + 0.5;
  434.  
  435. // don't make multiple pain sounds right after each other
  436.  
  437. // ax pain sound
  438.     if (self.axhitme == 1)
  439.     {
  440.         self.axhitme = 0;
  441.                 which_hit = random();
  442.                 if (which_hit < 0.33)
  443.                         sound (self, CHAN_VOICE, "weapons/taxhit1.wav", 1, ATTN_NORM);
  444.                 else if (which_hit < 0.66)
  445.                         sound (self, CHAN_VOICE, "weapons/taxhit2.wav", 1, ATTN_NORM);
  446.                 else
  447.                         sound (self, CHAN_VOICE, "weapons/taxhit3.wav", 1, ATTN_NORM);
  448.         return;
  449.     }
  450.     
  451.  
  452.     rs = rint((random() * 5) + 1);
  453.  
  454.     self.noise = "";
  455.     if (rs == 1)
  456.         self.noise = "player/pain1.wav";
  457.     else if (rs == 2)
  458.         self.noise = "player/pain2.wav";
  459.     else if (rs == 3)
  460.         self.noise = "player/pain3.wav";
  461.     else if (rs == 4)
  462.         self.noise = "player/pain4.wav";
  463.     else if (rs == 5)
  464.         self.noise = "player/pain5.wav";
  465.     else
  466.         self.noise = "player/pain6.wav";
  467.  
  468.     sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
  469.     return;
  470. };
  471.  
  472. void()    player_pain1 =    [    $pain1,    player_pain2    ] {PainSound();self.weaponframe=0;};
  473. void()    player_pain2 =    [    $pain2,    player_pain3    ] {};
  474. void()    player_pain3 =    [    $pain3,    player_pain4    ] {};
  475. void()    player_pain4 =    [    $pain4,    player_pain5    ] {};
  476. void()    player_pain5 =    [    $pain5,    player_pain6    ] {};
  477. void()    player_pain6 =    [    $pain6,    player_run    ] {};
  478.  
  479. void()    player_axpain1 =    [    $axpain1,    player_axpain2    ] {PainSound();self.weaponframe=0;};
  480. void()    player_axpain2 =    [    $axpain2,    player_axpain3    ] {};
  481. void()    player_axpain3 =    [    $axpain3,    player_axpain4    ] {};
  482. void()    player_axpain4 =    [    $axpain4,    player_axpain5    ] {};
  483. void()    player_axpain5 =    [    $axpain5,    player_axpain6    ] {};
  484. void()    player_axpain6 =    [    $axpain6,    player_run    ] {};
  485.  
  486. void() player_pain =
  487. {
  488.     if (self.weaponframe)
  489.         return;
  490.  
  491.     if (self.invisible_finished > time)
  492.         return;        // eyes don't have pain frames
  493.  
  494.         if (self.flags & FL_ISFEIGN)       // experimental
  495.                 return;
  496.  
  497.         if (self.weapon == IT_AXE || self.weapon == IT_THROWING_AXE || self.weapon == IT_MORNINGSTAR)
  498.         player_axpain1 ();
  499.     else
  500.         player_pain1 ();
  501. };
  502.  
  503. void() player_diea1;
  504. void() player_dieb1;
  505. void() player_diec1;
  506. void() player_died1;
  507. void() player_diee1;
  508. void() player_die_ax1;
  509.  
  510. void() DeathBubblesSpawn =
  511. {
  512. local entity    bubble;
  513.     if (self.owner.waterlevel != 3)
  514.         return;
  515.     bubble = spawn();
  516.     setmodel (bubble, "progs/s_bubble.spr");
  517.     setorigin (bubble, self.owner.origin + '0 0 24');
  518.     bubble.movetype = MOVETYPE_NOCLIP;
  519.     bubble.solid = SOLID_NOT;
  520.     bubble.velocity = '0 0 15';
  521.     bubble.nextthink = time + 0.5;
  522.     bubble.think = bubble_bob;
  523.     bubble.classname = "bubble";
  524.     bubble.frame = 0;
  525.     bubble.cnt = 0;
  526.     setsize (bubble, '-8 -8 -8', '8 8 8');
  527.     self.nextthink = time + 0.1;
  528.     self.think = DeathBubblesSpawn;
  529.     self.air_finished = self.air_finished + 1;
  530.     if (self.air_finished >= self.bubble_count)
  531.         remove(self);
  532. };
  533.  
  534. void(float num_bubbles) DeathBubbles =
  535. {
  536. local entity    bubble_spawner;
  537.     
  538.     bubble_spawner = spawn();
  539.     setorigin (bubble_spawner, self.origin);
  540.     bubble_spawner.movetype = MOVETYPE_NONE;
  541.     bubble_spawner.solid = SOLID_NOT;
  542.     bubble_spawner.nextthink = time + 0.1;
  543.     bubble_spawner.think = DeathBubblesSpawn;
  544.     bubble_spawner.air_finished = 0;
  545.     bubble_spawner.owner = self;
  546.     bubble_spawner.bubble_count = num_bubbles;
  547.     return;
  548. };
  549.  
  550.  
  551. void() DeathSound =
  552. {
  553. local float        rs;
  554.  
  555.     // water death sounds
  556.     if (self.waterlevel == 3)
  557.     {
  558.         DeathBubbles(20);
  559.         sound (self, CHAN_VOICE, "player/h2odeath.wav", 1, ATTN_NONE);
  560.         return;
  561.     }
  562.     
  563.     rs = rint ((random() * 4) + 1);
  564.     if (rs == 1)
  565.         self.noise = "player/death1.wav";
  566.     if (rs == 2)
  567.         self.noise = "player/death2.wav";
  568.     if (rs == 3)
  569.         self.noise = "player/death3.wav";
  570.     if (rs == 4)
  571.         self.noise = "player/death4.wav";
  572.     if (rs == 5)
  573.         self.noise = "player/death5.wav";
  574.  
  575.     sound (self, CHAN_VOICE, self.noise, 1, ATTN_NONE);
  576.     return;
  577. };
  578.  
  579.  
  580. void() PlayerDead =
  581. {
  582.     self.nextthink = -1;
  583. // allow respawn after a certain time
  584.     self.deadflag = DEAD_DEAD;
  585. };
  586.  
  587. vector(float dm) VelocityForDamage =
  588. {
  589.     local vector v;
  590.  
  591.     v_x = 100 * crandom();
  592.     v_y = 100 * crandom();
  593.     v_z = 200 + 100 * random();
  594.  
  595.     if (dm > -50)
  596.     {
  597. //        dprint ("level 1\n");
  598.         v = v * 0.7;
  599.     }
  600.     else if (dm > -200)
  601.     {
  602. //        dprint ("level 3\n");
  603.         v = v * 2;
  604.     }
  605.     else
  606.         v = v * 10;
  607.  
  608.     return v;
  609. };
  610.  
  611. void() FakeBackpackTouch =
  612. {
  613.         if (other.classname != "player")        // Monsters won't pick up
  614.                 return;
  615.         if (other.health <= 0)                  // Dead people won't pick up
  616.                 return;
  617.         sprint (other, "Hmmmm, empty...\n");
  618.         sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);    // backpack touch sound
  619.         stuffcmd (other, "bf\n");       // flashes the screen
  620.     remove(self);
  621.     
  622. };
  623.  
  624. void(string gibname, float dm) ThrowGib =
  625. {
  626.     local    entity new;
  627.  
  628.     new = spawn();
  629.     new.origin = self.origin;
  630.     setmodel (new, gibname);
  631.     setsize (new, '0 0 0', '0 0 0');
  632.     new.velocity = VelocityForDamage (dm);
  633.     new.movetype = MOVETYPE_BOUNCE;
  634.     new.solid = SOLID_NOT;
  635.     new.avelocity_x = random()*600;
  636.     new.avelocity_y = random()*600;
  637.     new.avelocity_z = random()*600;
  638.     new.think = SUB_Remove;
  639.     new.ltime = time;
  640.     new.nextthink = time + 10 + random()*10;
  641.     new.frame = 0;
  642.     new.flags = 0;
  643. };
  644.  
  645. void(string gibname, float dm) ThrowHeadPlayer =
  646. {
  647.         setmodel (self, gibname);
  648.         self.frame = 0;
  649.         self.nextthink = -1;
  650.         self.movetype = MOVETYPE_BOUNCE;
  651.     self.takedamage = DAMAGE_NO;
  652.     self.solid = SOLID_NOT;
  653.     self.view_ofs = '0 0 8';
  654.     setsize (self, '-16 -16 0', '16 16 56');
  655.     self.velocity = VelocityForDamage (dm);
  656.     self.origin_z = self.origin_z - 24;
  657.     self.flags = self.flags - (self.flags & FL_ONGROUND);
  658.     self.avelocity = crandom() * '0 600 0';
  659. };
  660.  
  661. void(string gibname, float dm) ThrowHead =
  662. {    
  663.         setmodel (self, gibname);
  664.         MakeSolidHead();    //Does just what you think it would.
  665.         self.frame = 0;
  666.         self.skin = self.skin;
  667.         self.nextthink = -1;
  668.         self.view_ofs = '0 0 8';
  669.         self.velocity = VelocityForDamage (dm);
  670.         self.origin_z = self.origin_z - 24;
  671.         self.flags = self.flags - (self.flags & FL_ONGROUND);
  672.         self.avelocity = crandom() * '0 600 0';
  673. };
  674.  
  675.  
  676. void() GibPlayer =
  677. {
  678.         ThrowHeadPlayer ("progs/h_player.mdl", self.health);
  679.     ThrowGib ("progs/gib1.mdl", self.health);
  680.     ThrowGib ("progs/gib2.mdl", self.health);
  681.     ThrowGib ("progs/gib3.mdl", self.health);
  682.     self.deadflag = DEAD_DEAD;
  683.     if (damage_attacker.classname == "teledeath")
  684.     {
  685.         sound (self, CHAN_VOICE, "player/teledth1.wav", 1, ATTN_NONE);
  686.         return;
  687.     }
  688.     if (damage_attacker.classname == "teledeath2")
  689.     {
  690.         sound (self, CHAN_VOICE, "player/teledth1.wav", 1, ATTN_NONE);
  691.         return;
  692.     }
  693.     if (random() < 0.5)
  694.         sound (self, CHAN_VOICE, "player/gib.wav", 1, ATTN_NONE);
  695.     else
  696.         sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NONE);
  697. };
  698.  
  699. void() PlayerDie =
  700. {
  701.     local    float    i;
  702.  
  703.         if (self.flags & FL_ISFEIGN)       // experimental
  704.                feign();
  705.     self.items = self.items - (self.items & IT_INVISIBILITY);
  706.     self.invisible_finished = 0;    // don't die as eyes
  707.     self.invincible_finished = 0;
  708.     self.super_damage_finished = 0;
  709.     self.radsuit_finished = 0;
  710.     self.modelindex = modelindex_player;    // don't use eyes
  711.     if (deathmatch || coop)
  712.         DropBackpack();
  713.     
  714.     self.weaponmodel="";
  715.     self.view_ofs = '0 0 -8';
  716.     self.deadflag = DEAD_DYING;
  717.     self.solid = SOLID_NOT;
  718.     self.flags = self.flags - (self.flags & FL_ONGROUND);
  719.         self.movetype = MOVETYPE_TOSS;
  720.     if (self.velocity_z < 10)
  721.         self.velocity_z = self.velocity_z + random()*300;
  722.         DetPipeBombs();
  723.         if (self.holo >= 1)
  724.            hologram_explode(self.myhologram);
  725.  
  726.     if (self.health < -40)
  727.     {
  728.         GibPlayer ();
  729.         return;
  730.     }
  731.  
  732.     DeathSound();
  733.          
  734.     self.angles_x = 0;
  735.     self.angles_z = 0;
  736.     
  737.         if (self.weapon == IT_AXE || self.weapon == IT_THROWING_AXE || self.weapon == IT_MORNINGSTAR)
  738.     {
  739.         player_die_ax1 ();
  740.         return;
  741.     }
  742.     
  743.     i = cvar("temp1");
  744.     if (!i)
  745.         i = 1 + floor(random()*6);
  746.     
  747.     if (i == 1)
  748.         player_diea1();
  749.     else if (i == 2)
  750.         player_dieb1();
  751.     else if (i == 3)
  752.         player_diec1();
  753.     else if (i == 4)
  754.         player_died1();
  755.     else
  756.         player_diee1();
  757. };
  758.  
  759. void() set_suicide_frame =
  760. {
  761.     if (self.model != "progs/player.mdl")
  762.         return;    // allready gibbed
  763.     self.frame = $deatha11;
  764.     self.solid = SOLID_NOT;
  765.     self.movetype = MOVETYPE_TOSS;
  766.     self.deadflag = DEAD_DEAD;
  767.     self.nextthink = -1;
  768. };
  769.  
  770.  
  771. void()    player_diea1    =    [    $deatha1,    player_diea2    ] {};
  772. void()    player_diea2    =    [    $deatha2,    player_diea3    ] {};
  773. void()    player_diea3    =    [    $deatha3,    player_diea4    ] {};
  774. void()    player_diea4    =    [    $deatha4,    player_diea5    ] {};
  775. void()    player_diea5    =    [    $deatha5,    player_diea6    ] {};
  776. void()    player_diea6    =    [    $deatha6,    player_diea7    ] {};
  777. void()    player_diea7    =    [    $deatha7,    player_diea8    ] {};
  778. void()    player_diea8    =    [    $deatha8,    player_diea9    ] {};
  779. void()    player_diea9    =    [    $deatha9,    player_diea10    ] {};
  780. void()    player_diea10    =    [    $deatha10,    player_diea11    ] {};
  781. void()    player_diea11    =    [    $deatha11,    player_diea11 ] {PlayerDead();};
  782.  
  783. void()    player_dieb1    =    [    $deathb1,    player_dieb2    ] {};
  784. void()    player_dieb2    =    [    $deathb2,    player_dieb3    ] {};
  785. void()    player_dieb3    =    [    $deathb3,    player_dieb4    ] {};
  786. void()    player_dieb4    =    [    $deathb4,    player_dieb5    ] {};
  787. void()    player_dieb5    =    [    $deathb5,    player_dieb6    ] {};
  788. void()    player_dieb6    =    [    $deathb6,    player_dieb7    ] {};
  789. void()    player_dieb7    =    [    $deathb7,    player_dieb8    ] {};
  790. void()    player_dieb8    =    [    $deathb8,    player_dieb9    ] {};
  791. void()    player_dieb9    =    [    $deathb9,    player_dieb9    ] {PlayerDead();};
  792.  
  793. void()    player_diec1    =    [    $deathc1,    player_diec2    ] {};
  794. void()    player_diec2    =    [    $deathc2,    player_diec3    ] {};
  795. void()    player_diec3    =    [    $deathc3,    player_diec4    ] {};
  796. void()    player_diec4    =    [    $deathc4,    player_diec5    ] {};
  797. void()    player_diec5    =    [    $deathc5,    player_diec6    ] {};
  798. void()    player_diec6    =    [    $deathc6,    player_diec7    ] {};
  799. void()    player_diec7    =    [    $deathc7,    player_diec8    ] {};
  800. void()    player_diec8    =    [    $deathc8,    player_diec9    ] {};
  801. void()    player_diec9    =    [    $deathc9,    player_diec10    ] {};
  802. void()    player_diec10    =    [    $deathc10,    player_diec11    ] {};
  803. void()    player_diec11    =    [    $deathc11,    player_diec12    ] {};
  804. void()    player_diec12    =    [    $deathc12,    player_diec13    ] {};
  805. void()    player_diec13    =    [    $deathc13,    player_diec14    ] {};
  806. void()    player_diec14    =    [    $deathc14,    player_diec15    ] {};
  807. void()    player_diec15    =    [    $deathc15,    player_diec15 ] {PlayerDead();};
  808.  
  809. void()    player_died1    =    [    $deathd1,    player_died2    ] {};
  810. void()    player_died2    =    [    $deathd2,    player_died3    ] {};
  811. void()    player_died3    =    [    $deathd3,    player_died4    ] {};
  812. void()    player_died4    =    [    $deathd4,    player_died5    ] {};
  813. void()    player_died5    =    [    $deathd5,    player_died6    ] {};
  814. void()    player_died6    =    [    $deathd6,    player_died7    ] {};
  815. void()    player_died7    =    [    $deathd7,    player_died8    ] {};
  816. void()    player_died8    =    [    $deathd8,    player_died9    ] {};
  817. void()    player_died9    =    [    $deathd9,    player_died9    ] {PlayerDead();};
  818.  
  819. void()    player_diee1    =    [    $deathe1,    player_diee2    ] {};
  820. void()    player_diee2    =    [    $deathe2,    player_diee3    ] {};
  821. void()    player_diee3    =    [    $deathe3,    player_diee4    ] {};
  822. void()    player_diee4    =    [    $deathe4,    player_diee5    ] {};
  823. void()    player_diee5    =    [    $deathe5,    player_diee6    ] {};
  824. void()    player_diee6    =    [    $deathe6,    player_diee7    ] {};
  825. void()    player_diee7    =    [    $deathe7,    player_diee8    ] {};
  826. void()    player_diee8    =    [    $deathe8,    player_diee9    ] {};
  827. void()    player_diee9    =    [    $deathe9,    player_diee9    ] {PlayerDead();};
  828.  
  829. void()    player_die_ax1    =    [    $axdeth1,    player_die_ax2    ] {};
  830. void()    player_die_ax2    =    [    $axdeth2,    player_die_ax3    ] {};
  831. void()    player_die_ax3    =    [    $axdeth3,    player_die_ax4    ] {};
  832. void()    player_die_ax4    =    [    $axdeth4,    player_die_ax5    ] {};
  833. void()    player_die_ax5    =    [    $axdeth5,    player_die_ax6    ] {};
  834. void()    player_die_ax6    =    [    $axdeth6,    player_die_ax7    ] {};
  835. void()    player_die_ax7    =    [    $axdeth7,    player_die_ax8    ] {};
  836. void()    player_die_ax8    =    [    $axdeth8,    player_die_ax9    ] {};
  837. void()    player_die_ax9    =    [    $axdeth9,    player_die_ax9    ] {PlayerDead();};
  838.