Foodstuff heals the Clonk over time.

shapetextures
Armin 2015-10-27 19:10:13 +01:00 committed by David Dormagen
parent 9a9ab3059d
commit cb4dbc3609
2 changed files with 30 additions and 1 deletions

View File

@ -188,7 +188,7 @@ public func Eat(object food)
{
if(GetProcedure() == "WALK")
{
DoEnergy(food->NutritionalValue());
Heal(food->NutritionalValue());
food->RemoveObject();
Sound("Munch?");
SetAction("Eat");

View File

@ -0,0 +1,29 @@
/**
Heal.c
Function to heal livings over time.
Author: Armin
*/
/**
Heals the object over time for /amount/ HP.
Calling the function multiple times results in faster healing (as opposed to longer healing).
*/
global func Heal(int amount)
{
// Add effect.
var fx = this->AddEffect("HealingOverTime", this, 1, 36);
fx.healing_amount = amount;
fx.done = 0;
return fx;
}
global func FxHealingOverTimeTimer(object target, effect fx)
{
// Stop healing the Clonk if he reached full health.
if (target->GetEnergy() >= target.MaxEnergy/1000 || fx.done >= fx.healing_amount)
return -1;
target->DoEnergy(1);
fx.done++;
return FX_OK;
}