From b5612624fb51d496017a77b9f3257409b1b82e5b Mon Sep 17 00:00:00 2001 From: alexvins Date: Sun, 10 Mar 2013 16:16:43 +0000 Subject: [PATCH] fix clone immunity handling for 8+ level creatures, part of issue #1234. --- lib/CBattleCallback.cpp | 27 +++++++++++++++++++++------ lib/CBonusTypeHandler.cpp | 12 ++++++------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/lib/CBattleCallback.cpp b/lib/CBattleCallback.cpp index e5f6e35a3..a830d1f23 100644 --- a/lib/CBattleCallback.cpp +++ b/lib/CBattleCallback.cpp @@ -1483,14 +1483,29 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleIsImmune(const C switch (spell->id) //TODO: more general logic for new spells? { case SpellID::CLONE: - if (caster) //TODO: how about stacks casting Clone? { + //can't clone already cloned creature if (vstd::contains(subject->state, EBattleStackState::CLONED)) - return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; //can't clone already cloned creature - int maxLevel = (std::max(caster->getSpellSchoolLevel(spell), (ui8)1) + 4); - int creLevel = subject->getCreature()->level; - if (maxLevel < creLevel) //tier 1-5 for basic, 1-6 for advanced, 1-7 for expert - return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; + return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; + //TODO: how about stacks casting Clone? + //currently Clone casted by stack is assumed Expert level + ui8 schoolLevel; + if (caster) + { + schoolLevel = caster->getSpellSchoolLevel(spell); + } + else + { + schoolLevel = 3; + } + + if (schoolLevel < 3) + { + int maxLevel = (std::max(schoolLevel, (ui8)1) + 4); + int creLevel = subject->getCreature()->level; + if (maxLevel < creLevel) //tier 1-5 for basic, 1-6 for advanced, any level for expert + return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; + } } break; case SpellID::DISPEL_HELPFUL_SPELLS: diff --git a/lib/CBonusTypeHandler.cpp b/lib/CBonusTypeHandler.cpp index f347675f0..8c716a715 100644 --- a/lib/CBonusTypeHandler.cpp +++ b/lib/CBonusTypeHandler.cpp @@ -299,12 +299,12 @@ void CBonusTypeHandler::load(const JsonNode& config) if(it == bonusNameMap.end()) { //TODO: new bonus - CBonusType bt; - loadItem(node.second, bt); - - auto new_id = bonusTypes.size(); - - bonusTypes.push_back(bt); +// CBonusType bt; +// loadItem(node.second, bt); +// +// auto new_id = bonusTypes.size(); +// +// bonusTypes.push_back(bt); tlog2 << "Adding new bonuses not implemented (" << node.first << ")" << std::endl; }