Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/Promotion.js
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | Promotion.prototype.Promote = function(promotedTemplateName) | ||||
cmpPromotedUnitPosition.SetHeightOffset(heightOffset); | cmpPromotedUnitPosition.SetHeightOffset(heightOffset); | ||||
var cmpCurrentUnitOwnership = Engine.QueryInterface(this.entity, IID_Ownership); | var cmpCurrentUnitOwnership = Engine.QueryInterface(this.entity, IID_Ownership); | ||||
var cmpPromotedUnitOwnership = Engine.QueryInterface(promotedUnitEntity, IID_Ownership); | var cmpPromotedUnitOwnership = Engine.QueryInterface(promotedUnitEntity, IID_Ownership); | ||||
cmpPromotedUnitOwnership.SetOwner(cmpCurrentUnitOwnership.GetOwner()); | cmpPromotedUnitOwnership.SetOwner(cmpCurrentUnitOwnership.GetOwner()); | ||||
// change promoted unit health to the same percent of hitpoints as unit had before promotion | // change promoted unit health to the same percent of hitpoints as unit had before promotion | ||||
var cmpPromotedUnitHealth = Engine.QueryInterface(promotedUnitEntity, IID_Health); | var cmpPromotedUnitHealth = Engine.QueryInterface(promotedUnitEntity, IID_Health); | ||||
var healthFraction = Math.max(0, Math.min(1, cmpCurrentUnitHealth.GetHitpoints() / cmpCurrentUnitHealth.GetMaxHitpoints())); | var healthFraction = Math.max(0, Math.min(1, cmpCurrentUnitHealth.GetHitpoints() / cmpCurrentUnitHealth.GetMaxHitpoints())); | ||||
fatherbushido: This satlin function is useless as Health.SetHitPoints already do such capping.
The change is… | |||||
var promotedUnitHitpoints = Math.round(cmpPromotedUnitHealth.GetMaxHitpoints() * healthFraction); | var promotedUnitHitpoints = cmpPromotedUnitHealth.GetMaxHitpoints() * healthFraction; | ||||
cmpPromotedUnitHealth.SetHitpoints(promotedUnitHitpoints); | cmpPromotedUnitHealth.SetHitpoints(promotedUnitHitpoints); | ||||
var cmpPromotedUnitPromotion = Engine.QueryInterface(promotedUnitEntity, IID_Promotion); | var cmpPromotedUnitPromotion = Engine.QueryInterface(promotedUnitEntity, IID_Promotion); | ||||
if (cmpPromotedUnitPromotion) | if (cmpPromotedUnitPromotion) | ||||
cmpPromotedUnitPromotion.IncreaseXp(this.currentXp); | cmpPromotedUnitPromotion.IncreaseXp(this.currentXp); | ||||
var cmpCurrentUnitResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer); | var cmpCurrentUnitResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer); | ||||
var cmpPromotedUnitResourceGatherer = Engine.QueryInterface(promotedUnitEntity, IID_ResourceGatherer); | var cmpPromotedUnitResourceGatherer = Engine.QueryInterface(promotedUnitEntity, IID_ResourceGatherer); | ||||
▲ Show 20 Lines • Show All 105 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
This satlin function is useless as Health.SetHitPoints already do such capping.
The change is not worth.
P46 is imo the good approach for all those things.