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

Implement STACK_EXPERIENCE_GAIN_PERCENT bonus

Suggested on Discord

- implements STACK_EXPERIENCE_GAIN_PERCENT that modifies stack
experience received by units after combat
- removed "EXPERIENCE" primary skill. Changes to experience are now
applied through separate netpack
This commit is contained in:
Ivan Savenko
2025-06-02 21:21:20 +03:00
parent 4fda657296
commit 139f41c9b2
24 changed files with 167 additions and 65 deletions

View File

@@ -1451,35 +1451,34 @@ std::vector<SecondarySkill> CGHeroInstance::getLevelupSkillCandidates(IGameRando
return skills;
}
void CGHeroInstance::setPrimarySkill(PrimarySkill primarySkill, si64 value, ChangeValueMode mode)
{
if(primarySkill < PrimarySkill::EXPERIENCE)
{
auto skill = getLocalBonus(Selector::type()(BonusType::PRIMARY_SKILL)
.And(Selector::subtype()(BonusSubtypeID(primarySkill)))
.And(Selector::sourceType()(BonusSource::HERO_BASE_SKILL)));
assert(skill);
auto skill = getLocalBonus(Selector::type()(BonusType::PRIMARY_SKILL)
.And(Selector::subtype()(BonusSubtypeID(primarySkill)))
.And(Selector::sourceType()(BonusSource::HERO_BASE_SKILL)));
assert(skill);
if(mode == ChangeValueMode::ABSOLUTE)
{
skill->val = static_cast<si32>(value);
}
else
{
skill->val += static_cast<si32>(value);
}
nodeHasChanged();
}
else if(primarySkill == PrimarySkill::EXPERIENCE)
if(mode == ChangeValueMode::ABSOLUTE)
{
if(mode == ChangeValueMode::ABSOLUTE)
{
exp = value;
}
else
{
exp += value;
}
skill->val = static_cast<si32>(value);
}
else
{
skill->val += static_cast<si32>(value);
}
nodeHasChanged();
}
void CGHeroInstance::setExperience(si64 value, ChangeValueMode mode)
{
if(mode == ChangeValueMode::ABSOLUTE)
{
exp = value;
}
else
{
exp += value;
}
}