Sfoglia il codice sorgente

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

alexvins 12 anni fa
parent
commit
b5612624fb
2 ha cambiato i file con 27 aggiunte e 12 eliminazioni
  1. 21 6
      lib/CBattleCallback.cpp
  2. 6 6
      lib/CBonusTypeHandler.cpp

+ 21 - 6
lib/CBattleCallback.cpp

@@ -1483,14 +1483,29 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleIsImmune(const C
 		switch (spell->id) //TODO: more general logic for new spells?
 		switch (spell->id) //TODO: more general logic for new spells?
 		{
 		{
 		case SpellID::CLONE:
 		case SpellID::CLONE:
-			if (caster) //TODO: how about stacks casting Clone?
 			{
 			{
+				//can't clone already cloned creature
 				if (vstd::contains(subject->state, EBattleStackState::CLONED))
 				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;
 			break;
 		case SpellID::DISPEL_HELPFUL_SPELLS:
 		case SpellID::DISPEL_HELPFUL_SPELLS:

+ 6 - 6
lib/CBonusTypeHandler.cpp

@@ -299,12 +299,12 @@ void CBonusTypeHandler::load(const JsonNode& config)
 		if(it == bonusNameMap.end())
 		if(it == bonusNameMap.end())
 		{
 		{
 			//TODO: new bonus
 			//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;
 			tlog2 << "Adding new bonuses not implemented (" << node.first << ")" << std::endl;
 		}
 		}