You need to make a seperate function for a loop (this is mandatory), and from Armor::onAdd( %this, %obj ) function (call parent, put in package. Howto
here) call the loop.
In the loop, check if player is alive. If not, return; .
Also check the energy level. If it's <= 0, call function then return; (unless you want your function to be called at a constant rate)
If you don't know how to make a loop, here's how it should look like:
function player::yourLoop( %this )
{
cancel( %this.yourLoop );
code here
%this.yourLoop = %this.schedule( XX time in ms, FUNCTION NAME (put "yourLoop" in here you derp) );
}