MEGAHEALTH REDUX

Discuss programming in the QuakeC language.
Post Reply
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

MEGAHEALTH REDUX

Post by r00k »

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 :( )

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: Select all

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: Select all

	//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);
		}
	}
Post Reply