home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / quake / programs / heal / heal.qc next >
Encoding:
Text File  |  1996-08-26  |  1.6 KB  |  57 lines

  1. /* Heal
  2.    Adds health to an entity, usually by touching a health box.
  3.    Limits health to ".max_health", and stores overflow back into the box
  4.    so it can be reused.
  5.    If "ignore" is TRUE, max_health limits will not be used.
  6. */
  7.  
  8. float (entity ent, float amt, float ignore) Heal =
  9. {
  10.  local string s;
  11.  
  12.  if (ent.health <= 0)
  13.   return FALSE;                                 // Can't heal a dead entity
  14.  
  15.  if ((!ignore) && (ent.health >= other.max_health))
  16.   return FALSE;                                 // Health already at max
  17.  
  18.  amt=ceil(amt);                          
  19.  
  20.  ent.health=ent.health+amt;                     // Add healamount to health
  21.  
  22.  if ((!ignore) && (ent.health >= other.max_health))
  23.  {
  24.   self.healamount=ent.health-other.max_health;  // Overflow back into box
  25.   ent.health=other.max_health;                  // Bound health to max_health
  26.  }
  27.  else
  28.   self.healamount=0;
  29.  
  30.  if (ent.health > 250)
  31.   ent.health = 250;                               // Bound health to 250
  32.  
  33.  sprint(other, "You receive ");
  34.  s = ftos(amt-self.healamount);
  35.  sprint(other, s);
  36.  sprint(other, " health\n");
  37.  
  38.  return TRUE;
  39. };
  40.  
  41. void() SUB_healregen =
  42. {
  43.  self.model = self.mdl;          // restore original model
  44.  self.solid = SOLID_TRIGGER;     // allow it to be touched again
  45.  sound (self, CHAN_VOICE, "items/itembk2.wav", 1, ATTN_NORM);    // play respawn sound
  46.  setorigin (self, self.origin);
  47.  
  48.  if (self.spawnflags & H_ROTTEN)
  49.   self.healamount = 15;
  50.  else if (self.spawnflags & H_MEGA)
  51.   self.healamount = 100;
  52.  else
  53.   self.healamount = 25;
  54. };
  55.  
  56.  
  57.