mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-04 23:17:41 +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:
parent
f7d08a7288
commit
b09152d62a
@ -781,12 +781,7 @@ void CStackInstance::giveTotalStackExperience(TExpType experienceToGive)
|
|||||||
if (!canGainExperience())
|
if (!canGainExperience())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int level = std::clamp(getLevel(), 1, 7);
|
totalExperience += experienceToGive;
|
||||||
TExpType maxAmountPerUnit = LIBRARY->creh->expRanks[level].back();
|
|
||||||
TExpType maxExperience = maxAmountPerUnit * getCount();
|
|
||||||
TExpType maxExperienceToGain = maxExperience - totalExperience;
|
|
||||||
TExpType actualGainedExperience = std::min(maxExperienceToGain, experienceToGive);
|
|
||||||
totalExperience += actualGainedExperience;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TExpType CStackInstance::getTotalExperience() const
|
TExpType CStackInstance::getTotalExperience() const
|
||||||
@ -1064,7 +1059,7 @@ void CCommanderInstance::setAlive (bool Alive)
|
|||||||
|
|
||||||
bool CCommanderInstance::canGainExperience() const
|
bool CCommanderInstance::canGainExperience() const
|
||||||
{
|
{
|
||||||
return alive && CStackInstance::canGainExperience();
|
return alive;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CCommanderInstance::getExpRank() const
|
int CCommanderInstance::getExpRank() const
|
||||||
|
@ -149,6 +149,8 @@ void CGameHandler::levelUpHero(const CGHeroInstance * hero)
|
|||||||
// required exp for at least 1 lvl-up hasn't been reached
|
// required exp for at least 1 lvl-up hasn't been reached
|
||||||
if (!hero->gainsLevel())
|
if (!hero->gainsLevel())
|
||||||
{
|
{
|
||||||
|
if (hero->getCommander() && hero->getCommander()->gainsLevel())
|
||||||
|
levelUpCommander(hero->getCommander());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,11 +340,6 @@ void CGameHandler::expGiven(const CGHeroInstance *hero)
|
|||||||
levelUpHero(hero);
|
levelUpHero(hero);
|
||||||
else if (hero->getCommander() && hero->getCommander()->gainsLevel())
|
else if (hero->getCommander() && hero->getCommander()->gainsLevel())
|
||||||
levelUpCommander(hero->getCommander());
|
levelUpCommander(hero->getCommander());
|
||||||
|
|
||||||
//if (hero->commander && hero->level > hero->commander->level && hero->commander->gainsLevel())
|
|
||||||
// levelUpCommander(hero->commander);
|
|
||||||
// else
|
|
||||||
// levelUpHero(hero);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameHandler::giveExperience(const CGHeroInstance * hero, TExpType amountToGain)
|
void CGameHandler::giveExperience(const CGHeroInstance * hero, TExpType amountToGain)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user