mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Yog will now only get Attack or Defence on leveling up
This commit is contained in:
parent
a9866bb5c6
commit
ccea7fc1fb
@ -282,12 +282,12 @@ CHeroClass * CHeroClassHandler::loadFromJson(const std::string & scope, const Js
|
|||||||
fillPrimarySkillData(node, heroClass, PrimarySkill::KNOWLEDGE);
|
fillPrimarySkillData(node, heroClass, PrimarySkill::KNOWLEDGE);
|
||||||
|
|
||||||
auto percentSumm = std::accumulate(heroClass->primarySkillLowLevel.begin(), heroClass->primarySkillLowLevel.end(), 0);
|
auto percentSumm = std::accumulate(heroClass->primarySkillLowLevel.begin(), heroClass->primarySkillLowLevel.end(), 0);
|
||||||
if(percentSumm != 100)
|
if(percentSumm <= 0)
|
||||||
logMod->error("Hero class %s has wrong lowLevelChance values: summ should be 100, but %d instead", heroClass->identifier, percentSumm);
|
logMod->error("Hero class %s has wrong lowLevelChance values: must be above zero!", heroClass->identifier, percentSumm);
|
||||||
|
|
||||||
percentSumm = std::accumulate(heroClass->primarySkillHighLevel.begin(), heroClass->primarySkillHighLevel.end(), 0);
|
percentSumm = std::accumulate(heroClass->primarySkillHighLevel.begin(), heroClass->primarySkillHighLevel.end(), 0);
|
||||||
if(percentSumm != 100)
|
if(percentSumm <= 0)
|
||||||
logMod->error("Hero class %s has wrong highLevelChance values: summ should be 100, but %d instead", heroClass->identifier, percentSumm);
|
logMod->error("Hero class %s has wrong highLevelChance values: must be above zero!", heroClass->identifier, percentSumm);
|
||||||
|
|
||||||
for(auto skillPair : node["secondarySkills"].Struct())
|
for(auto skillPair : node["secondarySkills"].Struct())
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <vcmi/ServerCallback.h>
|
#include <vcmi/ServerCallback.h>
|
||||||
#include <vcmi/spells/Spell.h>
|
#include <vcmi/spells/Spell.h>
|
||||||
|
#include <vstd/RNG.h>
|
||||||
|
|
||||||
#include "../CGeneralTextHandler.h"
|
#include "../CGeneralTextHandler.h"
|
||||||
#include "../ArtifactUtils.h"
|
#include "../ArtifactUtils.h"
|
||||||
@ -1367,28 +1368,17 @@ std::vector<SecondarySkill> CGHeroInstance::getLevelUpProposedSecondarySkills(CR
|
|||||||
PrimarySkill CGHeroInstance::nextPrimarySkill(CRandomGenerator & rand) const
|
PrimarySkill CGHeroInstance::nextPrimarySkill(CRandomGenerator & rand) const
|
||||||
{
|
{
|
||||||
assert(gainsLevel());
|
assert(gainsLevel());
|
||||||
int randomValue = rand.nextInt(99);
|
|
||||||
int pom = 0;
|
|
||||||
int primarySkill = 0;
|
|
||||||
const auto isLowLevelHero = level < GameConstants::HERO_HIGH_LEVEL;
|
const auto isLowLevelHero = level < GameConstants::HERO_HIGH_LEVEL;
|
||||||
const auto & skillChances = isLowLevelHero ? type->heroClass->primarySkillLowLevel : type->heroClass->primarySkillHighLevel;
|
const auto & skillChances = isLowLevelHero ? type->heroClass->primarySkillLowLevel : type->heroClass->primarySkillHighLevel;
|
||||||
|
|
||||||
for(; primarySkill < GameConstants::PRIMARY_SKILLS; ++primarySkill)
|
if (isCampaignYog())
|
||||||
{
|
{
|
||||||
pom += skillChances[primarySkill];
|
// Yog can only receive Attack or Defence on level-up
|
||||||
if(randomValue < pom)
|
std::vector<int> yogChances = { skillChances[0], skillChances[1]};
|
||||||
{
|
return static_cast<PrimarySkill>(RandomGeneratorUtil::nextItemWeighted(yogChances, rand));
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(primarySkill >= GameConstants::PRIMARY_SKILLS)
|
|
||||||
{
|
return static_cast<PrimarySkill>(RandomGeneratorUtil::nextItemWeighted(skillChances, rand));
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<SecondarySkill> CGHeroInstance::nextSecondarySkill(CRandomGenerator & rand) const
|
std::optional<SecondarySkill> CGHeroInstance::nextSecondarySkill(CRandomGenerator & rand) const
|
||||||
|
Loading…
Reference in New Issue
Block a user