Skip to content

Commit

Permalink
Affixes are now added to the unit's individual upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrettin committed Mar 7, 2024
1 parent 24d73ed commit 44e9c26
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/unit/unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1992,9 +1992,8 @@ void CUnit::ApplyAuraEffect(const int aura_index)
void CUnit::SetPrefix(const CUpgrade *prefix)
{
if (Prefix != nullptr) {
for (const auto &modifier : Prefix->get_modifiers()) {
RemoveIndividualUpgradeModifier(*this, modifier.get());
}
IndividualUpgradeLost(*this, this->Prefix);

this->Variable[MAGICLEVEL_INDEX].Value -= Prefix->get_magic_level();
this->Variable[MAGICLEVEL_INDEX].Max -= Prefix->get_magic_level();
}
Expand All @@ -2004,10 +2003,10 @@ void CUnit::SetPrefix(const CUpgrade *prefix)
this->Container->get_character()->save();
}
Prefix = prefix;

if (Prefix != nullptr) {
for (const auto &modifier : Prefix->get_modifiers()) {
ApplyIndividualUpgradeModifier(*this, modifier.get());
}
IndividualUpgradeAcquire(*this, this->Prefix);

this->Variable[MAGICLEVEL_INDEX].Value += Prefix->get_magic_level();
this->Variable[MAGICLEVEL_INDEX].Max += Prefix->get_magic_level();
}
Expand All @@ -2018,9 +2017,8 @@ void CUnit::SetPrefix(const CUpgrade *prefix)
void CUnit::SetSuffix(const CUpgrade *suffix)
{
if (Suffix != nullptr) {
for (const auto &modifier : Suffix->get_modifiers()) {
RemoveIndividualUpgradeModifier(*this, modifier.get());
}
IndividualUpgradeLost(*this, this->Suffix);

this->Variable[MAGICLEVEL_INDEX].Value -= Suffix->get_magic_level();
this->Variable[MAGICLEVEL_INDEX].Max -= Suffix->get_magic_level();
}
Expand All @@ -2031,9 +2029,8 @@ void CUnit::SetSuffix(const CUpgrade *suffix)
}
Suffix = suffix;
if (Suffix != nullptr) {
for (const auto &modifier : Suffix->get_modifiers()) {
ApplyIndividualUpgradeModifier(*this, modifier.get());
}
IndividualUpgradeAcquire(*this, this->Suffix);

this->Variable[MAGICLEVEL_INDEX].Value += Suffix->get_magic_level();
this->Variable[MAGICLEVEL_INDEX].Max += Suffix->get_magic_level();
}
Expand Down

0 comments on commit 44e9c26

Please sign in to comment.