home *** CD-ROM | disk | FTP | other *** search
- /* Heal
- Adds health to an entity, usually by touching a health box.
- Limits health to ".max_health", and stores overflow back into the box
- so it can be reused.
- If "ignore" is TRUE, max_health limits will not be used.
- */
-
- float (entity ent, float amt, float ignore) Heal =
- {
- local string s;
-
- if (ent.health <= 0)
- return FALSE; // Can't heal a dead entity
-
- if ((!ignore) && (ent.health >= other.max_health))
- return FALSE; // Health already at max
-
- amt=ceil(amt);
-
- ent.health=ent.health+amt; // Add healamount to health
-
- if ((!ignore) && (ent.health >= other.max_health))
- {
- self.healamount=ent.health-other.max_health; // Overflow back into box
- ent.health=other.max_health; // Bound health to max_health
- }
- else
- self.healamount=0;
-
- if (ent.health > 250)
- ent.health = 250; // Bound health to 250
-
- sprint(other, "You receive ");
- s = ftos(amt-self.healamount);
- sprint(other, s);
- sprint(other, " health\n");
-
- return TRUE;
- };
-
- void() SUB_healregen =
- {
- self.model = self.mdl; // restore original model
- self.solid = SOLID_TRIGGER; // allow it to be touched again
- sound (self, CHAN_VOICE, "items/itembk2.wav", 1, ATTN_NORM); // play respawn sound
- setorigin (self, self.origin);
-
- if (self.spawnflags & H_ROTTEN)
- self.healamount = 15;
- else if (self.spawnflags & H_MEGA)
- self.healamount = 100;
- else
- self.healamount = 25;
- };
-
-
-