Index: ps/trunk/binaries/data/mods/public/simulation/components/Promotion.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/Promotion.js +++ ps/trunk/binaries/data/mods/public/simulation/components/Promotion.js @@ -33,7 +33,10 @@ // If the unit is dead, don't promote it let cmpHealth = Engine.QueryInterface(this.entity, IID_Health); if (cmpHealth && cmpHealth.GetHitpoints() == 0) + { + this.promotedUnitEntity = INVALID_ENTITY; return; + } // Save the entity id. this.promotedUnitEntity = ChangeEntityTemplate(this.entity, promotedTemplateName); Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Promotion.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Promotion.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_Promotion.js @@ -63,4 +63,15 @@ TS_ASSERT_EQUALS(cmpPromotion.entity, 62); TS_ASSERT_EQUALS(cmpPromotion.template.Entity, "end"); TS_ASSERT_EQUALS(cmpPromotion.GetCurrentXp(), 200); + +cmpPromotion = ConstructComponent(ENT_ID, "Promotion", { + "Entity": "template_b", + "RequiredXp": 1000 +}); + +let cmpHealth = AddMock(ENT_ID, IID_Health, { + "GetHitpoints": () => 0, +}); + +cmpPromotion.IncreaseXp(1000); })();