1
0
forked from mirrors/0ad

Use floats for health. Fix #1633

This was SVN commit r13507.
This commit is contained in:
alpha123
2013-06-29 00:43:08 +00:00
parent 4b3f4c0a1d
commit 37c8e77d8e
3 changed files with 6 additions and 6 deletions
@@ -54,7 +54,7 @@ function displaySingle(entState, template)
healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints));
unitHealthBar.size = healthSize;
var hitpoints = entState.hitpoints + " / " + entState.maxHitpoints;
var hitpoints = Math.ceil(entState.hitpoints) + " / " + entState.maxHitpoints;
getGUIObjectByName("healthStats").caption = hitpoints;
getGUIObjectByName("healthSection").hidden = false;
}
@@ -57,9 +57,9 @@ Armour.prototype.TakeDamage = function(hack, pierce, crush)
var adjPierce = pierce * Math.pow(0.9, armourStrengths.pierce);
var adjCrush = crush * Math.pow(0.9, armourStrengths.crush);
// Total is sum of individual damages, with minimum damage 1
// Round to nearest integer, since HP is integral
var total = Math.max(1, Math.round(adjHack + adjPierce + adjCrush));
// Total is sum of individual damages
// Don't bother rounding, since HP is no longer integral.
var total = Math.max(1, adjHack + adjPierce + adjCrush);
// Reduce health
var cmpHealth = Engine.QueryInterface(this.entity, IID_Health);
@@ -8,11 +8,11 @@ Health.prototype.Schema =
"<DeathType>corpse</DeathType>" +
"</a:example>" +
"<element name='Max' a:help='Maximum hitpoints'>" +
"<data type='positiveInteger'/>" +
"<data type='decimal'/>" +
"</element>" +
"<optional>" +
"<element name='Initial' a:help='Initial hitpoints. Default if unspecified is equal to Max'>" +
"<data type='positiveInteger'/>" +
"<data type='decimal'/>" +
"</element>" +
"</optional>" +
"<optional>" +