home *** CD-ROM | disk | FTP | other *** search
/ Qu-ake / Qu-ake.iso / qu_ke / patches / 004 / SHELLS.QC < prev   
Encoding:
Text File  |  1996-10-24  |  3.1 KB  |  82 lines

  1. //====================================================================
  2. //
  3. // SHOTGUN SHELLS            by: Perecli Manole AKA Bort
  4. //
  5. //====================================================================
  6. // Aside from this new file, the following are the modifications
  7. // done to id's original source files:
  8. //--------------------------------------------------------------------
  9. // File: Progs.src
  10. // Location: before the "weapons.qc" line
  11. // Added: shells.qc
  12. //--------------------------------------------------------------------
  13. // File: Weapons.qc
  14. // Procedure: W_Precache
  15. // Location: end of procedure
  16. // Added: precache_sound ("weapons/shellhit.wav"); // shotgun shells
  17. //--------------------------------------------------------------------
  18. // File: World.qc
  19. // Procedure: worldspawn
  20. // Location: at the end of all precache model definitions
  21. // Added: precache_model ("progs/shell.mdl");
  22. //--------------------------------------------------------------------
  23. // File: Weapons.qc
  24. // Procedure: W_FireShotgun 
  25. // Location: before "FireBullets (6, dir, '0.04 0.04 0');" line
  26. // Added: SpawnShell(); 
  27. //--------------------------------------------------------------------
  28. // File: Weapons.qc
  29. // Procedure: W_FireSuperShotgun
  30. // Location: before "FireBullets (14, dir, '0.14 0.08 0');" line
  31. // Added: SpawnShell(); SpawnShell(); 
  32. //--------------------------------------------------------------------
  33.  
  34.  
  35. float () crandom;   // prototype
  36.  
  37.  
  38. //--------------------------------------------------------------------
  39. // Plays hit sound when shell hits hard surface if not stuck in loop
  40. //--------------------------------------------------------------------
  41. void() ShellHit =
  42. {
  43.     if (self.ltime <= (time - 0.2))   // prevent sound if last shell hit sound occured within last 2 frames
  44.         sound (self, CHAN_WEAPON, "weapons/shellhit.wav", 1, ATTN_NORM);
  45.     self.ltime = time;                // marks time of current touch trigger activation
  46. };
  47.  
  48.  
  49. //--------------------------------------------------------------------
  50. // Displays shell and defines its dynamic manifestation
  51. //--------------------------------------------------------------------
  52. void() DropShell = 
  53. {
  54.     self.movetype = MOVETYPE_BOUNCE;
  55.     self.solid = SOLID_BBOX;
  56.     setmodel (self, "progs/shell.mdl");
  57.     setsize (self, VEC_ORIGIN, VEC_ORIGIN);   
  58.     makevectors (self.owner.v_angle);
  59.     setorigin (self, self.owner.origin + v_forward * 10 - v_right*10);    
  60.     self.velocity = v_forward*30 + crandom()*v_forward*30 + v_up*220 + crandom()*v_up*10 - v_right*50 + crandom()*v_right*20;
  61.     self.avelocity_x = crandom()*500;
  62.     self.avelocity_y = crandom()*500;
  63.     self.avelocity_z = crandom()*500;
  64.     self.touch = ShellHit;
  65.     self.nextthink = time + 15;
  66.     self.think = SUB_Remove;
  67.     self.ltime = time - 1;
  68. };
  69.  
  70.  
  71. //--------------------------------------------------------------------
  72. // Spawns new shell entity but doesn't display it until reload time
  73. //--------------------------------------------------------------------
  74. void() SpawnShell=
  75. {
  76.     local entity shell;
  77.  
  78.     shell = spawn ();
  79.     shell.owner = self;
  80.     shell.nextthink = time + 0.4;         // delay shells until reload
  81.     shell.think = DropShell;
  82. };