Sfoglia il codice sorgente

Passive cast can be blocked by spell level limit.

AlexVinS 9 anni fa
parent
commit
ef34d21941
2 ha cambiato i file con 8 aggiunte e 2 eliminazioni
  1. 3 1
      lib/CBattleCallback.cpp
  2. 5 1
      server/CGameHandler.cpp

+ 3 - 1
lib/CBattleCallback.cpp

@@ -1666,7 +1666,9 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
 	if(specificProblem != ESpellCastProblem::OK)
 		return specificProblem;
 
-	if(battleMaxSpellLevel(side) < spell->level) //effect like Recanter's Cloak or Orb of Inhibition
+	//effect like Recanter's Cloak. Blocks also passive casting.
+	//TODO: check creature abilities to block
+	if(battleMaxSpellLevel(side) < spell->level)
 		return ESpellCastProblem::SPELL_LEVEL_LIMIT_EXCEEDED;
 
 	return ESpellCastProblem::OK;

+ 5 - 1
server/CGameHandler.cpp

@@ -5578,13 +5578,17 @@ void CGameHandler::runBattle()
 	for(int i = 0; i < 2; ++i)
 	{
 		auto h = gs->curB->battleGetFightingHero(i);
-		if(h && h->hasBonusOfType(Bonus::OPENING_BATTLE_SPELL))
+		if(h)
 		{
 			TBonusListPtr bl = h->getBonuses(Selector::type(Bonus::OPENING_BATTLE_SPELL));
 
 			for (Bonus *b : *bl)
 			{
 				const CSpell * spell = SpellID(b->subtype).toSpell();
+
+				if(ESpellCastProblem::OK != gs->curB->battleCanCastThisSpell(h, spell, ECastingMode::PASSIVE_CASTING))
+					continue;
+
 				BattleSpellCastParameters parameters(gs->curB, h, spell);
 				parameters.spellLvl = 3;
 				parameters.effectLevel = 3;