1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

fix clone immunity handling for 8+ level creatures, part of issue #1234.

This commit is contained in:
alexvins 2013-03-10 16:16:43 +00:00
parent b413d80ccc
commit b5612624fb
2 changed files with 27 additions and 12 deletions

View File

@ -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:

View File

@ -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;
}