home *** CD-ROM | disk | FTP | other *** search
/ Qu-ake / Qu-ake.iso / qu_ke / patches / 004 / HOLO.QC < prev    next >
Encoding:
Text File  |  1996-10-24  |  4.4 KB  |  148 lines

  1. //====================================================================
  2. //
  3. // HOLOGRAPHIC SELF            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: holo.qc
  12. //--------------------------------------------------------------------
  13. // File: Weapons.qc
  14. // Procedure: ImpulseCommands
  15. // Location: in the beginning of the function
  16. // Added: CheckHoloCommand ();
  17. //--------------------------------------------------------------------
  18. // File: Client.qc
  19. // Procedure: SetChangeParms
  20. // Location: in "// remove items" between "IT_QUAD" and ")"
  21. // Added: | IT_HOLO
  22. //--------------------------------------------------------------------
  23. // File: Defs.qc
  24. // Declaration group: Item definitions
  25. // Location: after line float IT_QUAD = 4194304;
  26. // Added: float    IT_HOLO = 8388608;
  27. //--------------------------------------------------------------------
  28.  
  29.  
  30. float ACTIVATE_HOLO = 99;    // impulse constant
  31. float SEC = 10;            // number of seconds holo is on
  32. float COST = 10;        // number of power cells holo costs
  33. float CHANCE = 0.7;        // frequency of holo shooting (1.0 = continuous)
  34.  
  35.  
  36. //--------------------------------------------------------------------
  37. // When time expires holograph gets deactivated
  38. //--------------------------------------------------------------------
  39. void() RemoveHolo =
  40. {
  41.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  42.     WriteByte (MSG_BROADCAST, TE_TELEPORT);
  43.     WriteCoord (MSG_BROADCAST, self.origin_x);
  44.     WriteCoord (MSG_BROADCAST, self.origin_y);
  45.     WriteCoord (MSG_BROADCAST, self.origin_z);
  46.     sound (self, CHAN_BODY, "misc/r_tele1.wav", 1, ATTN_NORM);
  47.     SUB_Remove();
  48.     self.owner.items = self.owner.items - IT_HOLO;
  49.     sprint(self.owner,"holograph expired\n");
  50. };
  51.  
  52.  
  53. //--------------------------------------------------------------------
  54. // Frames for holograph self
  55. //--------------------------------------------------------------------
  56. void() holo_stand;        // prototype
  57.  
  58. void() holo_shoot1 = [103, holo_shoot2]
  59. {
  60.     sound (self ,CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
  61.     self.effects = self.effects | EF_MUZZLEFLASH;
  62. };  
  63.  
  64. void() holo_shoot2 = 
  65. {
  66.     self.frame = 104;
  67.     if (random() <= CHANCE)
  68.     {
  69.         sound (self ,CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
  70.         self.effects = self.effects | EF_MUZZLEFLASH;
  71.     }
  72.     self.nextthink = time + 0.1;
  73.     if (random() > CHANCE)
  74.         self.think = holo_stand;
  75.     else
  76.         self.think = holo_shoot1;
  77.     self.health = self.health - 0.2;
  78.     if (self.health <= 0)    
  79.         RemoveHolo();    
  80. };
  81.  
  82. void() holo_stand  = 
  83. {
  84.     self.frame = 105;
  85.     if (random() > CHANCE)
  86.         self.think = holo_stand;
  87.     else
  88.         self.think = holo_shoot1;
  89.     self.nextthink = time + 0.1;    
  90.     self.health = self.health - 0.1;
  91.     if (self.health <= 0)    
  92.         RemoveHolo();    
  93. };
  94.  
  95.  
  96.  
  97. //--------------------------------------------------------------------
  98. // Spawns holograph self
  99. //--------------------------------------------------------------------
  100. void(entity myself) ActivateHolo =
  101. {
  102.     local entity    newholo;
  103.  
  104.     newholo = spawn();
  105.     newholo.solid = SOLID_NOT;
  106.     newholo.movetype = MOVETYPE_TOSS;
  107.     setmodel (newholo, "progs/player.mdl");
  108.     setorigin (newholo, myself.origin);
  109.     setsize (newholo, VEC_HULL_MIN, VEC_HULL_MAX);
  110.     newholo.classname = "holo";
  111.     newholo.angles = myself.angles;
  112.     newholo.velocity = self.velocity + '0 0 200';
  113.     newholo.colormap = myself.colormap;
  114.     newholo.skin = myself.skin;
  115.     newholo.owner=myself;
  116.     newholo.health = SEC;
  117.     myself.currentammo = myself.ammo_cells = myself.ammo_cells - COST;
  118.     myself.items = myself.items | IT_HOLO;
  119.     stuffcmd (newholo.owner, "bf\n");
  120.     sprint(newholo.owner,"holograph activated\n");
  121.     newholo.nextthink = time;    
  122.     newholo.think = holo_stand;    
  123. };
  124.  
  125.  
  126.  
  127. //--------------------------------------------------------------------
  128. // Checks if holograph should be activated
  129. //--------------------------------------------------------------------
  130. void() CheckHoloCommand = 
  131. {
  132.     if (self.impulse != ACTIVATE_HOLO )
  133.         return;
  134.  
  135.     if ((self.items & IT_HOLO) == IT_HOLO)
  136.     {
  137.         sprint(self,"holograph active\n");
  138.         return;
  139.     }
  140.  
  141.     if (self.ammo_cells < COST)
  142.     {
  143.         sprint(self,"cells are low\n");
  144.         return;
  145.     }
  146.     
  147.     ActivateHolo (self);
  148. };