Fix the missing health bug when an unit is promoted. Promotion component should not do the job of the Health component. Patch by Grugnas.

Accepted by FeXoR.
Differential Revision: https://code.wildfiregames.com/D409
This was SVN commit r19995.
This commit is contained in:
fatherbushido
2017-08-19 07:36:21 +00:00
parent bb58e7cb45
commit c312c35698
@@ -59,7 +59,7 @@ Promotion.prototype.Promote = function(promotedTemplateName)
// change promoted unit health to the same percent of hitpoints as unit had before promotion
var cmpPromotedUnitHealth = Engine.QueryInterface(promotedUnitEntity, IID_Health);
var healthFraction = Math.max(0, Math.min(1, cmpCurrentUnitHealth.GetHitpoints() / cmpCurrentUnitHealth.GetMaxHitpoints()));
var promotedUnitHitpoints = Math.round(cmpPromotedUnitHealth.GetMaxHitpoints() * healthFraction);
var promotedUnitHitpoints = cmpPromotedUnitHealth.GetMaxHitpoints() * healthFraction;
cmpPromotedUnitHealth.SetHitpoints(promotedUnitHitpoints);
var cmpPromotedUnitPromotion = Engine.QueryInterface(promotedUnitEntity, IID_Promotion);