1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-09 01:06:07 +02:00

Fix commander levelups

- Fixes commander not receiving experience if stack experience is off
- Fixes commander not leveling up when hero fill his secondary skills
This commit is contained in:
Ivan Savenko
2025-05-14 21:51:32 +03:00
parent f7d08a7288
commit b09152d62a
2 changed files with 4 additions and 12 deletions

View File

@ -781,12 +781,7 @@ void CStackInstance::giveTotalStackExperience(TExpType experienceToGive)
if (!canGainExperience())
return;
int level = std::clamp(getLevel(), 1, 7);
TExpType maxAmountPerUnit = LIBRARY->creh->expRanks[level].back();
TExpType maxExperience = maxAmountPerUnit * getCount();
TExpType maxExperienceToGain = maxExperience - totalExperience;
TExpType actualGainedExperience = std::min(maxExperienceToGain, experienceToGive);
totalExperience += actualGainedExperience;
totalExperience += experienceToGive;
}
TExpType CStackInstance::getTotalExperience() const
@ -1064,7 +1059,7 @@ void CCommanderInstance::setAlive (bool Alive)
bool CCommanderInstance::canGainExperience() const
{
return alive && CStackInstance::canGainExperience();
return alive;
}
int CCommanderInstance::getExpRank() const