1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Yog will now only get Attack or Defence on leveling up

This commit is contained in:
Ivan Savenko
2024-01-31 00:18:10 +02:00
parent a9866bb5c6
commit ccea7fc1fb
2 changed files with 11 additions and 21 deletions

View File

@@ -13,6 +13,7 @@
#include <vcmi/ServerCallback.h>
#include <vcmi/spells/Spell.h>
#include <vstd/RNG.h>
#include "../CGeneralTextHandler.h"
#include "../ArtifactUtils.h"
@@ -1367,28 +1368,17 @@ std::vector<SecondarySkill> CGHeroInstance::getLevelUpProposedSecondarySkills(CR
PrimarySkill CGHeroInstance::nextPrimarySkill(CRandomGenerator & rand) const
{
assert(gainsLevel());
int randomValue = rand.nextInt(99);
int pom = 0;
int primarySkill = 0;
const auto isLowLevelHero = level < GameConstants::HERO_HIGH_LEVEL;
const auto & skillChances = isLowLevelHero ? type->heroClass->primarySkillLowLevel : type->heroClass->primarySkillHighLevel;
for(; primarySkill < GameConstants::PRIMARY_SKILLS; ++primarySkill)
if (isCampaignYog())
{
pom += skillChances[primarySkill];
if(randomValue < pom)
{
break;
}
// Yog can only receive Attack or Defence on level-up
std::vector<int> yogChances = { skillChances[0], skillChances[1]};
return static_cast<PrimarySkill>(RandomGeneratorUtil::nextItemWeighted(yogChances, rand));
}
if(primarySkill >= GameConstants::PRIMARY_SKILLS)
{
primarySkill = rand.nextInt(GameConstants::PRIMARY_SKILLS - 1);
logGlobal->error("Wrong values in primarySkill%sLevel for hero class %s", isLowLevelHero ? "Low" : "High", getClassNameTranslated());
randomValue = 100 / GameConstants::PRIMARY_SKILLS;
}
logGlobal->trace("The hero gets the primary skill %d with a probability of %d %%.", primarySkill, randomValue);
return static_cast<PrimarySkill>(primarySkill);
return static_cast<PrimarySkill>(RandomGeneratorUtil::nextItemWeighted(skillChances, rand));
}
std::optional<SecondarySkill> CGHeroInstance::nextSecondarySkill(CRandomGenerator & rand) const