1
0
forked from 0ad/0ad

Allows garrison heal rate of "0" (disables healing).

This was SVN commit r11296.
This commit is contained in:
historic_bruno 2012-03-10 04:08:15 +00:00
parent 39844eaadc
commit 4b7a5ac814

View File

@ -14,7 +14,7 @@ GarrisonHolder.prototype.Schema =
"<ref name='nonNegativeDecimal'/>" + "<ref name='nonNegativeDecimal'/>" +
"</element>" + "</element>" +
"<element name='BuffHeal' a:help='Number of hit points that will be restored to this holder&apos;s garrisoned units each second'>" + "<element name='BuffHeal' a:help='Number of hit points that will be restored to this holder&apos;s garrisoned units each second'>" +
"<data type='positiveInteger'/>" + "<data type='nonNegativeInteger'/>" +
"</element>" + "</element>" +
"<element name='LoadingRange' a:help='The maximum distance from this holder at which entities are allowed to garrison. Should be about 2.0 for land entities and preferably greater for ships'>" + "<element name='LoadingRange' a:help='The maximum distance from this holder at which entities are allowed to garrison. Should be about 2.0 for land entities and preferably greater for ships'>" +
"<ref name='nonNegativeDecimal'/>" + "<ref name='nonNegativeDecimal'/>" +
@ -123,7 +123,7 @@ GarrisonHolder.prototype.Garrison = function(entity)
if (this.GetCapacity() < this.spaceOccupied + 1) if (this.GetCapacity() < this.spaceOccupied + 1)
return false; return false;
if (!this.timer) if (!this.timer && this.healRate > 0)
{ {
var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
this.timer = cmpTimer.SetTimeout(this.entity, IID_GarrisonHolder, "HealTimeout", 1000, {}); this.timer = cmpTimer.SetTimeout(this.entity, IID_GarrisonHolder, "HealTimeout", 1000, {});
@ -298,7 +298,7 @@ GarrisonHolder.prototype.HasEnoughHealth = function()
var cmpHealth = Engine.QueryInterface(this.entity, IID_Health) var cmpHealth = Engine.QueryInterface(this.entity, IID_Health)
var hitpoints = cmpHealth.GetHitpoints(); var hitpoints = cmpHealth.GetHitpoints();
var maxHitpoints = cmpHealth.GetMaxHitpoints(); var maxHitpoints = cmpHealth.GetMaxHitpoints();
var ejectHitpoints = parseInt(parseFloat(this.template.EjectHealth) * maxHitpoints); var ejectHitpoints = Math.floor((+this.template.EjectHealth) * maxHitpoints);
return hitpoints > ejectHitpoints; return hitpoints > ejectHitpoints;
}; };