From 9e9849b7419ea4caa7f6e46c97bd18cd3afe5220 Mon Sep 17 00:00:00 2001 From: Dydzio Date: Sat, 23 Dec 2023 20:16:29 +0100 Subject: [PATCH 1/3] Fix commander ability accumulation, change commander ability bonus --- lib/bonuses/BonusSelector.cpp | 7 +++++++ lib/bonuses/BonusSelector.h | 1 + lib/bonuses/CBonusSystemNode.cpp | 2 +- server/CGameHandler.cpp | 4 ++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/bonuses/BonusSelector.cpp b/lib/bonuses/BonusSelector.cpp index 1d57e8e13..1c75f1f4e 100644 --- a/lib/bonuses/BonusSelector.cpp +++ b/lib/bonuses/BonusSelector.cpp @@ -82,6 +82,13 @@ namespace Selector return CSelectFieldEqual(&Bonus::valType)(valType); } + CSelector DLL_LINKAGE typeSubtypeValueType(BonusType Type, BonusSubtypeID Subtype, BonusValueType valType) + { + return type()(Type) + .And(subtype()(Subtype)) + .And(valueType(valType)); + } + DLL_LINKAGE CSelector all([](const Bonus * b){return true;}); DLL_LINKAGE CSelector none([](const Bonus * b){return false;}); } diff --git a/lib/bonuses/BonusSelector.h b/lib/bonuses/BonusSelector.h index 4e2ebbc74..14fe31c92 100644 --- a/lib/bonuses/BonusSelector.h +++ b/lib/bonuses/BonusSelector.h @@ -139,6 +139,7 @@ namespace Selector CSelector DLL_LINKAGE source(BonusSource source, BonusSourceID sourceID); CSelector DLL_LINKAGE sourceTypeSel(BonusSource source); CSelector DLL_LINKAGE valueType(BonusValueType valType); + CSelector DLL_LINKAGE typeSubtypeValueType(BonusType Type, BonusSubtypeID Subtype, BonusValueType valType); /** * Selects all bonuses diff --git a/lib/bonuses/CBonusSystemNode.cpp b/lib/bonuses/CBonusSystemNode.cpp index 4de398409..8306e3ae1 100644 --- a/lib/bonuses/CBonusSystemNode.cpp +++ b/lib/bonuses/CBonusSystemNode.cpp @@ -356,7 +356,7 @@ void CBonusSystemNode::addNewBonus(const std::shared_ptr& b) void CBonusSystemNode::accumulateBonus(const std::shared_ptr& b) { - auto bonus = exportedBonuses.getFirst(Selector::typeSubtype(b->type, b->subtype)); //only local bonuses are interesting //TODO: what about value type? + auto bonus = exportedBonuses.getFirst(Selector::typeSubtypeValueType(b->type, b->subtype, b->valType)); //only local bonuses are interesting if(bonus) bonus->val += b->val; else diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 68bccfaf6..2312460da 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -253,11 +253,11 @@ void CGameHandler::levelUpCommander (const CCommanderInstance * c, int skill) break; case ECommander::HEALTH: scp.accumulatedBonus.type = BonusType::STACK_HEALTH; - scp.accumulatedBonus.valType = BonusValueType::PERCENT_TO_BASE; + scp.accumulatedBonus.valType = BonusValueType::PERCENT_TO_ALL; break; case ECommander::DAMAGE: scp.accumulatedBonus.type = BonusType::CREATURE_DAMAGE; - scp.accumulatedBonus.valType = BonusValueType::PERCENT_TO_BASE; + scp.accumulatedBonus.valType = BonusValueType::PERCENT_TO_ALL; break; case ECommander::SPEED: scp.accumulatedBonus.type = BonusType::STACKS_SPEED; From 6fd4b2bdddc1ba7c67c6db80417219c339445dd9 Mon Sep 17 00:00:00 2001 From: Dydzio Date: Sat, 23 Dec 2023 20:33:15 +0100 Subject: [PATCH 2/3] Fix commander bonus from damage ability --- server/CGameHandler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 2312460da..b6bd1cdd8 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -257,6 +257,7 @@ void CGameHandler::levelUpCommander (const CCommanderInstance * c, int skill) break; case ECommander::DAMAGE: scp.accumulatedBonus.type = BonusType::CREATURE_DAMAGE; + scp.accumulatedBonus.subtype = BonusCustomSubtype::creatureDamageBoth; scp.accumulatedBonus.valType = BonusValueType::PERCENT_TO_ALL; break; case ECommander::SPEED: From 2e976dc0f186e79cdd4f73d6c41b43bbded6930f Mon Sep 17 00:00:00 2001 From: Dydzio Date: Sat, 23 Dec 2023 20:35:40 +0100 Subject: [PATCH 3/3] Add TODO comment for possible minor logic deviation from WoG --- server/CGameHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index b6bd1cdd8..fa0d8f1a3 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -253,7 +253,7 @@ void CGameHandler::levelUpCommander (const CCommanderInstance * c, int skill) break; case ECommander::HEALTH: scp.accumulatedBonus.type = BonusType::STACK_HEALTH; - scp.accumulatedBonus.valType = BonusValueType::PERCENT_TO_ALL; + scp.accumulatedBonus.valType = BonusValueType::PERCENT_TO_ALL; //TODO: check how it accumulates in original WoG with artifacts such as vial of life blood, elixir of life etc. break; case ECommander::DAMAGE: scp.accumulatedBonus.type = BonusType::CREATURE_DAMAGE;