From 51b7de4b986422f2e735fce2e31337742869e89f Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Fri, 5 Jan 2024 16:57:44 +0200 Subject: [PATCH] Fix double off-by-one bug with CREATURE_GROWTH bonus --- config/artifacts.json | 10 +++++----- docs/modders/Bonus/Bonus_Types.md | 2 +- lib/mapObjects/CGDwelling.cpp | 2 +- lib/mapObjects/CGTownInstance.cpp | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/config/artifacts.json b/config/artifacts.json index 4645b53bb..ae5501f30 100644 --- a/config/artifacts.json +++ b/config/artifacts.json @@ -1730,7 +1730,7 @@ "bonuses" : [ { "type" : "CREATURE_GROWTH", - "subtype" : "creatureLevel1", + "subtype" : "creatureLevel2", "val" : 5, "propagator": "VISITED_TOWN_AND_VISITOR" } @@ -1743,7 +1743,7 @@ "bonuses" : [ { "type" : "CREATURE_GROWTH", - "subtype" : "creatureLevel2", + "subtype" : "creatureLevel3", "val" : 4, "propagator": "VISITED_TOWN_AND_VISITOR" } @@ -1756,7 +1756,7 @@ "bonuses" : [ { "type" : "CREATURE_GROWTH", - "subtype" : "creatureLevel3", + "subtype" : "creatureLevel4", "val" : 3, "propagator": "VISITED_TOWN_AND_VISITOR" } @@ -1769,7 +1769,7 @@ "bonuses" : [ { "type" : "CREATURE_GROWTH", - "subtype" : "creatureLevel4", + "subtype" : "creatureLevel5", "val" : 2, "propagator": "VISITED_TOWN_AND_VISITOR" } @@ -1782,7 +1782,7 @@ "bonuses" : [ { "type" : "CREATURE_GROWTH", - "subtype" : "creatureLevel5", + "subtype" : "creatureLevel6", "val" : 1, "propagator": "VISITED_TOWN_AND_VISITOR" } diff --git a/docs/modders/Bonus/Bonus_Types.md b/docs/modders/Bonus/Bonus_Types.md index 6836066cc..3d6b616a4 100644 --- a/docs/modders/Bonus/Bonus_Types.md +++ b/docs/modders/Bonus/Bonus_Types.md @@ -244,7 +244,7 @@ Increased effect of spell affecting creature, ie. Aenain makes Disrupting Ray de "subtype" : "spell.disruptingRay", "type" : "SPECIAL_ADD_VALUE_ENCHANT" } -`````` +``` - subtype: affected spell identifier - additionalInfo: value to add diff --git a/lib/mapObjects/CGDwelling.cpp b/lib/mapObjects/CGDwelling.cpp index 88f3578c5..2276d8a0d 100644 --- a/lib/mapObjects/CGDwelling.cpp +++ b/lib/mapObjects/CGDwelling.cpp @@ -320,7 +320,7 @@ void CGDwelling::newTurn(CRandomGenerator & rand) const creaturesAccumulate = VLC->settings()->getBoolean(EGameSettings::DWELLINGS_ACCUMULATE_WHEN_NEUTRAL); const CCreature * cre =creatures[i].second[0].toCreature(); - TQuantity amount = cre->getGrowth() * (1 + cre->valOfBonuses(BonusType::CREATURE_GROWTH_PERCENT)/100) + cre->valOfBonuses(BonusType::CREATURE_GROWTH); + TQuantity amount = cre->getGrowth() * (1 + cre->valOfBonuses(BonusType::CREATURE_GROWTH_PERCENT)/100) + cre->valOfBonuses(BonusType::CREATURE_GROWTH, BonusCustomSubtype::creatureLevel(cre->getLevel())); if (creaturesAccumulate && ID != Obj::REFUGEE_CAMP) //camp should not try to accumulate different kinds of creatures sac.creatures[i].first += amount; else diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index 0f7c49bcf..70d83674a 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/lib/mapObjects/CGTownInstance.cpp @@ -164,7 +164,8 @@ GrowthInfo CGTownInstance::getGrowthInfo(int level) const } //other *-of-legion-like bonuses (%d to growth cumulative with grail) - TConstBonusListPtr bonuses = getBonuses(Selector::typeSubtype(BonusType::CREATURE_GROWTH, BonusCustomSubtype::creatureLevel(level))); + // Note: bonus uses 1-based levels (Pikeman is level 1), town list uses 0-based (Pikeman in 0-th creatures entry) + TConstBonusListPtr bonuses = getBonuses(Selector::typeSubtype(BonusType::CREATURE_GROWTH, BonusCustomSubtype::creatureLevel(level+1))); for(const auto & b : *bonuses) ret.entries.emplace_back(b->val, b->Description());