1
0
forked from 0ad/0ad

Entity heal update.

This was SVN commit r3129.
This commit is contained in:
pyrolink 2005-11-13 06:43:04 +00:00
parent 2ddf20374c
commit 139698ec1d
2 changed files with 47 additions and 0 deletions

View File

@ -5,6 +5,7 @@
<Event On="Attack" Function="entity_event_attack" />
<Event On="Gather" Function="entity_event_gather" />
<Event On="Heal" Function="entity_event_heal" />
<Event On="TakesDamage" Function="entity_event_takesdamage" />
<Event On="TargetChanged" Function="entity_event_targetchanged" />
<Event On="PrepareOrder" Function="entity_event_prepareorder" />

View File

@ -108,6 +108,52 @@ function entity_event_gather( evt )
}
}
// ====================================================================
function entity_event_heal( evt )
{
if ( evt.target.player != this.player )
{
console.write( "You have a traitor!" );
return;
}
//Make sure we have enough resources
if ( this.player.resource["Food"] - evt.target.actions.heal.cost * evt.target.traits.creation.cost.food < 0 )
{
console.write( "Not enough food for healing." );
return;
}
if ( this.player.resource["Wood"] - evt.target.actions.heal.cost * evt.target.traits.creation.cost.wood < 0 )
{
console.write( "Not enough wood for healing." );
return;
}
if ( this.player.resource["Stone"] - evt.target.actions.heal.cost * evt.target.traits.creation.cost.stone < 0 )
{
console.write( "Not enough stone for healing." );
return;
}
if ( this.player.resource["Ore"] - evt.target.actions.heal.cost * evt.target.traits.creation.cost.ore < 0 )
{
console.write( "Not enough ore for healing." );
return;
}
evt.target.traits.health.curr += this.actions.heal.speed;
console.write( this.traits.id.specific + "has performed a miracle!" );
if (evt.target.traits.health.curr >= evt.target.traits.health.max)
{
evt.target.traits.health.curr = evt.target.traits.health.max;
}
this.player.resource["Food"] -= evt.target.actions.heal.cost * evt.target.traits.creation.cost.food;
this.player.resource["Wood"] -= evt.target.actions.heal.cost * evt.target.traits.creation.cost.wood;
this.player.resource["Stone"] -= evt.target.actions.heal.cost * evt.target.traits.creation.cost.stone;
this.player.resource["Ore"] -= evt.target.actions.heal.cost * evt.target.traits.creation.cost.ore;
}
// ====================================================================
function entity_event_takesdamage( evt )