/*

This script is triggeres by the timing bar GUI.
Its used to prevent characters who are inflicted with undeath from a wild surge
from healing when resting

2DruNk2FraG - 05-04-08

*/
effect SetRestDamage(object oTarget, int nInitialHP);

void main()
{	
	object oPC = OBJECT_SELF;//GetFirstPC();
	float fRadius = 50.0; 
	
	object oTarget = GetFirstObjectInShape(SHAPE_SPHERE,fRadius,GetLocation(oPC),FALSE,OBJECT_TYPE_CREATURE);
	
	while(GetIsObjectValid(oTarget))
	{
		if(GetIsResting(oTarget) == TRUE && GetLocalInt(oTarget,"nZombified") > 0) //&& has undead effect
		{
			int nInitialHP = GetCurrentHitPoints(oTarget);
						
			DelayCommand(5.1,ApplyEffectToObject(DURATION_TYPE_INSTANT,SetRestDamage(oTarget,nInitialHP),oTarget));
		}
	oTarget = GetNextObjectInShape(SHAPE_SPHERE,fRadius,GetLocation(oPC),FALSE,OBJECT_TYPE_CREATURE);
	}

}

effect SetRestDamage(object oTarget, int nInitialHP)
{
	int nHP = GetCurrentHitPoints(oTarget);
	int nDam = nHP - nInitialHP;
	effect eDam = EffectDamage(nDam,DAMAGE_TYPE_MAGICAL,DAMAGE_POWER_ENERGY,TRUE);
	return eDam;	
}