mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Reworked and fixed selection of secondary skills:
- Fixed off-by-one error when checking for obligatory skills - If both wisdom and magic school must be offered in the same slot, magic school will be correctly offered on next levelup - Obligatory skill can now be proposed for upgrade - Obligatory skills are now offered using hero class weight instead of simple random - If hero has multiple skills not available to his class game will select random skill instead of first one - Moved storage of random seed to server instead of mutable member
This commit is contained in:
@@ -187,25 +187,21 @@ void CGameHandler::levelUpHero(const CGHeroInstance * hero)
|
||||
sps.val = 1;
|
||||
sendAndApply(&sps);
|
||||
|
||||
PrepareHeroLevelUp pre;
|
||||
pre.heroId = hero->id;
|
||||
sendAndApply(&pre);
|
||||
|
||||
HeroLevelUp hlu;
|
||||
hlu.player = hero->tempOwner;
|
||||
hlu.heroId = hero->id;
|
||||
hlu.primskill = primarySkill;
|
||||
hlu.skills = pre.skills;
|
||||
hlu.skills = hero->getLevelUpProposedSecondarySkills(heroPool->getHeroSkillsRandomGenerator(hero->getHeroType()));
|
||||
|
||||
if (hlu.skills.size() == 0)
|
||||
{
|
||||
sendAndApply(&hlu);
|
||||
levelUpHero(hero);
|
||||
}
|
||||
else if (hlu.skills.size() == 1)
|
||||
else if (hlu.skills.size() == 1 || !hero->getOwner().isValidPlayer())
|
||||
{
|
||||
sendAndApply(&hlu);
|
||||
levelUpHero(hero, pre.skills.front());
|
||||
levelUpHero(hero, hlu.skills.front());
|
||||
}
|
||||
else if (hlu.skills.size() > 1)
|
||||
{
|
||||
@@ -551,6 +547,9 @@ void CGameHandler::init(StartInfo *si, Load::ProgressAccumulator & progressTrack
|
||||
for (auto & elem : gs->players)
|
||||
turnOrder->addPlayer(elem.first);
|
||||
|
||||
for (auto & elem : gs->map->allHeroes)
|
||||
heroPool->getHeroSkillsRandomGenerator(elem->getHeroType()); // init RMG seed
|
||||
|
||||
reinitScripting();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user