Fix for maxHP upgrades

Fixed the calculation of HP if value is given in percent.
This commit is contained in:
titiger 2021-01-02 20:27:51 +01:00
parent 0f4bc361c6
commit 75651f3b2e
2 changed files with 4 additions and 4 deletions

View File

@ -3578,7 +3578,7 @@ void Unit::applyUpgrade(const UpgradeType *upgradeType){
checkItemInVault(&this->hp,this->hp);
int original_hp = this->hp;
this->hp += upgradeType->getMaxHp();
this->hp += totalUpgrade.getMaxHp();
this->hp = max(0,this->hp);
if(original_hp != this->hp) {
//printf("File: %s line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__);

View File

@ -304,11 +304,11 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree,
startHpType= stPercentage;
}
// No start value set; use max HP before upgrades
// No start value is set; use 100% of the current Max
if(!parametersNode->getChild("max-hp")->hasAttribute("start-value") &&
!parametersNode->getChild("max-hp")->hasAttribute("start-percentage")) {
startHpValue= parametersNode->getChild("max-hp")->getAttribute("value")->getIntValue();
startHpType= stValue;
startHpPercentage=100;
startHpType= stPercentage;
}
addItemToVault(&(this->startHpPercentage),this->startHpPercentage);