From 44e9c267506ac3234fc280775675987c219dd280 Mon Sep 17 00:00:00 2001 From: Andrettin <6322423+Andrettin@users.noreply.github.com> Date: Thu, 7 Mar 2024 21:21:14 +0100 Subject: [PATCH] Affixes are now added to the unit's individual upgrades --- src/unit/unit.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/unit/unit.cpp b/src/unit/unit.cpp index e50a16d2a..4b5d1d98c 100644 --- a/src/unit/unit.cpp +++ b/src/unit/unit.cpp @@ -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(); } @@ -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(); } @@ -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(); } @@ -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(); }