This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 9984 for ps


Ignore:
Timestamp:
08/09/11 20:42:21 (13 years ago)
Author:
fcxSanya
Message:

Change promoted unit health to the same percent of hitpoints as unit had before promotion. Closes #922.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/binaries/data/mods/public/simulation/components/Promotion.js

    r9663 r9984  
    5252    cmpPromotedUnitOwnership.SetOwner(cmpCurrentUnitOwnership.GetOwner());
    5353
     54    // change promoted unit health to the same percent of hitpoints as unit had before promotion
     55    var cmpCurrentUnitHealth = Engine.QueryInterface(this.entity, IID_Health);
     56    var cmpPromotedUnitHealth = Engine.QueryInterface(promotedUnitEntity, IID_Health);
     57    var healthFraction = Math.max(0, Math.min(1, cmpCurrentUnitHealth.GetHitpoints() / cmpCurrentUnitHealth.GetMaxHitpoints()));
     58    var promotedUnitHitpoints = Math.round(cmpPromotedUnitHealth.GetMaxHitpoints() * healthFraction);
     59    cmpPromotedUnitHealth.SetHitpoints(promotedUnitHitpoints);
     60
    5461    var cmpPromotedUnitPromotion = Engine.QueryInterface(promotedUnitEntity, IID_Promotion);
    5562    if (cmpPromotedUnitPromotion)
Note: See TracChangeset for help on using the changeset viewer.