/*-- Stem Needle --*/

local full;

protected func Initialize()
{
	full = false;
}

func Hit()
{
	Sound("LightMetalHit?");
}

func ControlUse(object clonk,int x, int y)
{
	if(full == false && clonk->GetEnergy() > 25){
		Log("Clonk donated blood.");
		SetGraphics("1");
		clonk->DoEnergy(-25);
		full = true;
		//Do regen effect
		AddEffect("NeedleRegen", clonk, 1, 1, clonk);
	}
	else if(full == true && clonk->GetEnergy() < 50 && GetEffect("NeedleRegen",clonk) == nil && GetEffect("NeedleHeal",clonk) == nil){
		Log("Clonk used needle to heal.");
		SetGraphics("");
		full = false;
		//Do heal effect
		AddEffect("NeedleHeal", clonk, 1, 1, clonk);
	}
	
	return 1;
}

global func FxNeedleRegenTimer(object target, proplist effect, int timer)
{
	var interval = 108;
	//timed regen
	if(timer % interval == 0 && target->GetEnergy() < 50) target->DoEnergy(1);
	if(timer > (25 * interval)) return -1;
}

global func FxNeedleHealTimer(object target, proplist effect, int timer)
{
	var interval = 36;
	//timed heal
	if(timer % interval == 0 && target->GetEnergy() < 50) target->DoEnergy(1);
	if(timer > (25 * interval)) return -1;
}
		
public func IsInventorIngredient() { return true; }

local Collectible = 1;
local Name = "$Name$";
local Description = "$Description$";
local Rebuy = true;
