DjWarmonger 14 years ago
parent
commit
825562a092
2 changed files with 31 additions and 23 deletions
  1. 1 1
      lib/BattleState.cpp
  2. 30 22
      server/CGameHandler.cpp

+ 1 - 1
lib/BattleState.cpp

@@ -1786,7 +1786,7 @@ SpellCasting::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInstance
 	const CStack * subject = getStackT(dest, false);
 	const CStack * subject = getStackT(dest, false);
 	if(subject)
 	if(subject)
 	{
 	{
-		if (spell->positiveness ==1 && subject->hasBonusOfType(Bonus::RECEPTIVE)) //accept all positive spells
+		if (spell->positiveness == 1 && subject->hasBonusOfType(Bonus::RECEPTIVE)) //accept all positive spells
 			return SpellCasting::OK;
 			return SpellCasting::OK;
 
 
 		if ((spell->id == 41 || spell->id == 42) && subject->hasBonusOfType(Bonus::UNDEAD)) //undeads are immune to bless & curse
 		if ((spell->id == 41 || spell->id == 42) && subject->hasBonusOfType(Bonus::UNDEAD)) //undeads are immune to bless & curse

+ 30 - 22
server/CGameHandler.cpp

@@ -3667,35 +3667,43 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
 			}
 			}
 
 
 			const CSpell *s = VLC->spellh->spells[ba.additionalInfo];
 			const CSpell *s = VLC->spellh->spells[ba.additionalInfo];
-			ui8 skill = h->getSpellSchoolLevel(s); //skill level
-
-			SpellCasting::ESpellCastProblem escp = gs->curB->battleCanCastThisSpell(h->tempOwner, s, SpellCasting::HERO_CASTING);
-			if(escp != SpellCasting::OK)
+			if (s->mainEffectAnim > -1) //TODO: special effects, like Clone
 			{
 			{
-				tlog2 << "Spell cannot be cast!\n";
-				tlog2 << "Problem : " << escp << std::endl;
-				return false;
-			}
+				ui8 skill = h->getSpellSchoolLevel(s); //skill level
 
 
-			StartAction start_action(ba);
-			sendAndApply(&start_action); //start spell casting
+				SpellCasting::ESpellCastProblem escp = gs->curB->battleCanCastThisSpell(h->tempOwner, s, SpellCasting::HERO_CASTING);
+				if(escp != SpellCasting::OK)
+				{
+					tlog2 << "Spell cannot be cast!\n";
+					tlog2 << "Problem : " << escp << std::endl;
+					return false;
+				}
 
 
-			handleSpellCasting (ba.additionalInfo, skill, ba.destinationTile, ba.side, h->tempOwner, h, secondHero, h->getPrimSkillLevel(2), SpellCasting::HERO_CASTING, NULL);
+				StartAction start_action(ba);
+				sendAndApply(&start_action); //start spell casting
 
 
-			sendAndApply(&end_action);
-			if( !gs->curB->getStack(gs->curB->activeStack, false)->alive() )
-			{
-				battleMadeAction.setn(true);
+				handleSpellCasting (ba.additionalInfo, skill, ba.destinationTile, ba.side, h->tempOwner, h, secondHero, h->getPrimSkillLevel(2), SpellCasting::HERO_CASTING, NULL);
+
+				sendAndApply(&end_action);
+				if( !gs->curB->getStack(gs->curB->activeStack, false)->alive() )
+				{
+					battleMadeAction.setn(true);
+				}
+				checkForBattleEnd(gs->curB->stacks);
+				if(battleResult.get())
+				{
+					battleMadeAction.setn(true);
+					//battle will be ended by startBattle function
+					//endBattle(gs->curB->tile, gs->curB->heroes[0], gs->curB->heroes[1]);
+				}
+
+				return true;
 			}
 			}
-			checkForBattleEnd(gs->curB->stacks);
-			if(battleResult.get())
+			else
 			{
 			{
-				battleMadeAction.setn(true);
-				//battle will be ended by startBattle function
-				//endBattle(gs->curB->tile, gs->curB->heroes[0], gs->curB->heroes[1]);
+				tlog2 << "Spell " << s->name << " is not yet supported!\n";
+				return false;
 			}
 			}
-
-			return true;
 		}
 		}
 	}
 	}
 	return false;
 	return false;