Inside3D!
     

Megahealth rotting - rot 1 hp/second w/o fixed respawn delay

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



Joined: 12 Jan 2007
Posts: 414
Location: Brazil

PostPosted: Sun Nov 16, 2008 2:02 am    Post subject: Megahealth rotting - rot 1 hp/second w/o fixed respawn delay Reply with quote

Guys, I figured out a new way to rot down megahealth in just 1 hp per second and maintain the originality of respawning only if your health is 100 or less.
There are many other ways to do it, but sadly they don't keep the originality of the player rotting down to 100 health and only respawn 20 seconds AFTER the player's megahealth is fully rotten.

I tested the QIP method, but the respawn delay was fixed (always 125 seconds). The megahealth may respawn much earlier if you take damage and your health rapidly goes to 100 or less, then it may be a loooong wait.

Code:

// Megahealth = rot down the player's super health
   if (self.healtype == 2 && !(other.items & IT_SUPERHEALTH))
   {   // if the player health is 100 or less, act normally
      other.items = other.items | IT_SUPERHEALTH;
      self.nextthink = time;   // think every frame to make it more precise
      self.frags = time + 5;   // rot down after 5 seconds
      self.think = item_megahealth_rot;
      self.owner = other;
   }
   else if (self.healtype == 2 && other.items & IT_SUPERHEALTH)
   {   // if the player health is more than 100, don't rot twice as fast but always check respawn delay
      self.nextthink = time;
      self.think = item_megahealth_check;
      self.owner = other;
   }
   else
   {
      if (deathmatch != 2)      // deathmatch 2 is the silly old rules
      {
         if (deathmatch)
            self.nextthink = time + 20;
         self.think = SUB_regen;
      }
   }


I made it think every frame to make it more precise, but it works the same as original, takes 5 seconds to rot down if you pick up the 1st megahealth, and rots 1 hp/second without rotting twice or more as fast if you pick up 2 or more megahealths.

Originally, you pick up a megahealth, then it rots down, when your health is 100 or less, it takes 20 seconds to respawn. BUT, if you pick up two megahealths, it'll rot down twice as fast. I think a certain number of players don't like that behavior.

So as you can see above, I added two different checks for the same healtype, if you don't have the megahealth (health <= 100), it'll wait 5 seconds and will rot down normally. If you already have a megahealth and picked up another one, it'll keep rotting down, but won't rot down twice as fast. The new function item_megahelth_check() checks every frame if the player's health is more than 100, if that's true, it'll keep thinking and checking over and over again until your health is 100 or less, then it waits 20 seconds and then respawn. I made both megahealth_rot() and megahealth_check() to think every frame to make it more precise.

Changed item_megahealth_rot(), and the new item_megahealth_check():

Code:

void() item_megahealth_rot =
{
   other = self.owner;
   
   if (other.health > other.max_health)
   {
      if (self.frags < time)
      {
         if (self.t_width < time)
         {
            other.health = other.health - 1;
            self.t_width = time + 1;
         }
      }
      self.nextthink = time;
      return;
   }

// it is possible for a player to die and respawn between rots, so don't
// just blindly subtract the flag off
   other.items = other.items - (other.items & IT_SUPERHEALTH);
   
   if (deathmatch != 2)      // deathmatch 2 is the silly old rules
   {
      if (deathmatch)
         self.nextthink = time + 20;
      self.think = SUB_regen;
   }
};

void() item_megahealth_check =
{
   other = self.owner;
   
   if (other.health > other.max_health)
   {   // act similarly to the function above, but don't rot down twice as fast, just check the player's health
      self.nextthink = time;
      return;
   }
   
   if (deathmatch != 2)      // deathmatch 2 is the silly old rules
   {
      if (deathmatch)
         self.nextthink = time + 20;
      self.think = SUB_regen;
   }
};



I did a test on dm3, I picked up both megahealths from the center and the pent area. I waited it rot down without damaging myself, and when my health hit 100, both megahealths respawned at the same time. Pretty much like the original stuff, but without rotting twice as fast.

Hope you like it, if you want to use just replace the old codes with the new ones. Smile
_________________
There's no signature here. Stop looking for one.


Last edited by Orion on Mon Nov 17, 2008 3:10 pm; edited 1 time in total
Back to top
View user's profile Send private message
CocoT



Joined: 14 Dec 2004
Posts: 599
Location: Belly-Gum

PostPosted: Sun Nov 16, 2008 2:29 am    Post subject: Reply with quote

Cool stuff! Thanks, Orion Wink
_________________
http://www.planetcocot.net/
Back to top
View user's profile Send private message Send e-mail Visit poster's website
redrum



Joined: 28 Mar 2007
Posts: 367
Location: Long Island, New York

PostPosted: Mon Nov 17, 2008 3:02 am    Post subject: Reply with quote

Quote:
Hope you like it, if you want to use just replace the new codes with the old ones.


It might work better though if you replaced the OLD codes with the NEW ones! Wink
Keep up the good work!
_________________
Welcome to the Overlook Hotel 69.113.123.178:27500
Back to top
View user's profile Send private message Send e-mail
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Mon Nov 17, 2008 7:26 am    Post subject: Reply with quote

Hmm I'll have to see how much different it is
http://forums.inside3d.com/viewtopic.php?t=1141
Very Happy
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