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

  1. /*========================================================================
  2.  
  3. Eject.qc - 8/14/96 Steve Bond (wedge)
  4.  
  5. ========================================================================*/
  6.  
  7.  
  8. void() shell_touch;
  9.  
  10. /*
  11. ===============
  12. eject_shell
  13.  
  14. Spews a spent shell casing from a shotgun
  15. ===============
  16. */
  17. void(vector org,vector dir) eject_shell =
  18. {
  19.         local float     flip;
  20.  
  21.         // Spawn one shell
  22.     newmis = spawn ();
  23.     newmis.owner = self;
  24.         newmis.movetype = MOVETYPE_BOUNCE;
  25.     newmis.solid = SOLID_BBOX;
  26.  
  27.     newmis.angles = vectoangles(dir);
  28.     
  29.         newmis.touch = shell_touch;
  30.         newmis.classname = "shellcasing";
  31.     newmis.think = SUB_Remove;
  32.         newmis.nextthink = time + 20;
  33.         setmodel (newmis, "progs/shelcase.mdl");
  34.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);               
  35.     setorigin (newmis, org);
  36.  
  37.         // pick a random number
  38.         flip = random();
  39.         
  40.  
  41.         // Based on that number, pick a velocity
  42.         if (flip < 0.2 )
  43.         newmis.velocity = '75 20 150';
  44.  
  45.         else if (flip < 0.4)
  46.         newmis.velocity = '50 50 80';
  47.  
  48.         else if (flip < 0.6)
  49.         newmis.velocity = '10 25 200';
  50.  
  51.         else if (flip < 0.8)
  52.         newmis.velocity = '75 50 100';
  53.  
  54.         else
  55.         newmis.velocity = '40 10 75';
  56.  
  57.         // pick a random number
  58.         flip = random();
  59.  
  60.         // based on that rate, pick a rate at which to spin
  61.         if (flip < 0.25)
  62.         newmis.avelocity = '300 300 300';
  63.  
  64.         else if (flip < 0.5)
  65.         newmis.avelocity = '150 300 100';
  66.  
  67.         else if (flip < 0.75)
  68.         newmis.avelocity = '200 100 0';
  69.  
  70.         else
  71.         newmis.avelocity = '400 200 100';
  72. };
  73.  
  74.  
  75.  
  76.  
  77. void() shell_touch =
  78. {
  79.      // DO NOT play the sound if we hit a door.
  80.      if (other.classname == "door")
  81.         return;
  82.  
  83.      sound (self, CHAN_WEAPON, "weapons/shellhit.wav", 1, ATTN_NORM);
  84. };
  85.  
  86.  
  87.