Inside3D!
     

MEGAHEALTH REDUX

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Tue Sep 09, 2008 5:42 am    Post subject: MEGAHEALTH REDUX Reply with quote

Megahealth fix redux... to preserve id's original intent...

a.> Health subtracts 1 per second
b.> respawns 125 seconds after u take
or
c.> respawn 20 seconds after u get below 100h (this part Maddes left out, and some hardcore DM players were pissed off about it Sad )

if u have multiple megahealths then it wont multiply on the depletion AND if you die or your health drops below(or equals) 100 then it all megahealths that you had WILL respawn in 20 seconds.

ITEMS.QC:

Code:

void(entity player, entity mega) MakeHealthRot =
{
   local entity rot;
   rot = spawn ();
   rot.classname = "health_rot";
   rot.nextthink = time + 5;
   rot.think = item_megahealth_rot;
   rot.owner = mega;   
   rot.enemy = player;
   rot.enemy.rotthink = time + 5;//delay
};

void () health_touch =
{
   local float   donttake;
   local string    s;

   if ((other.classname != "player"))
   {
      return;
   }
   if ((self.healtype == H_MEGA))
   {
      if ((other.health >= 250))
      {
         donttake = 1;
      }
      if (!T_Heal (other, self.healamount, H_ROTTEN))
      {
         donttake = 1;
      }
   }
   else
   {
      if (!T_Heal (other, self.healamount, 0))
      {
         donttake = 1;
      }
   }
   
   if (donttake == 0)
   {
      sprint (other, "You receive ");
      s = ftos (self.healamount);
      sprint (other, s);
      sprint (other, " health\n");
      sound (other, CHAN_ITEM, self.noise, H_ROTTEN, ATTN_NORM);
      stuffcmd (other, "bf\n");
      self.model = string_null;
      self.solid = SOLID_NOT;
      self.owner = other;
   
      //MEGAHEALTH FIX
      if (self.healtype == H_MEGA)
      {
         MakeHealthRot(other,self);// create rot entity R00k: fixed
   
         other.items = other.items | IT_SUPERHEALTH;
   
         //Set this megahealth's respawn to default 125 seconds.
         if (deathmatch != 2)   // deathmatch 2 is silly old rules
         {
            self.nextthink = time + self.healamount + 25;   // delay (5) + health + respawn wait (20)
            self.think = SUB_regen;
         }
      }
      else
      {
         if ((deathmatch != 2))
         {
            self.nextthink = (time + 20);
            self.think = SUB_regen;
         }
      }
   }
   activator = other;
   SUB_UseTargets ();
};


void () item_megahealth_rot =
{
   other = self.enemy;
   
   if (other.health > other.max_health)
   {
      self.think = item_megahealth_rot;
      self.nextthink = (time + 1);
      return;
   }

   //R00k: must still respawn mega 20 seconds AFTER other.health < other.max_health
   if (deathmatch != 2)
   {
      self.owner.nextthink = (time + 20);
      self.owner.think = SUB_regen;
   }

   remove(self);
};


CLIENT.QC:
in
void () CheckPowerups =

Code:

   //Multiple megahealth rot fix
   if ((self.items & IT_SUPERHEALTH) && (time > self.rotthink))
   {
      if (self.health > self.max_health)
      {
         if (self.invincible_finished < time)
         {
            self.health = (self.health - 1.00);
            self.rotthink = (time + 1.00);
         }
      }
      else
      {
         self.items = self.items - (self.items & IT_SUPERHEALTH);
      }
   }
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group