From 4a9978c6423f1682bf3af36ed6f58747968ac455 Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Sat, 10 Sep 2016 21:07:36 +0300 Subject: [PATCH] Disabled massive spells fore creatures as they are not fully supported yet. * (WoG) commanders now cast spells properly. --- client/battle/CBattleInterface.cpp | 10 +++++----- client/battle/CBattleInterface.h | 2 +- lib/spells/CSpellHandler.cpp | 4 ++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/client/battle/CBattleInterface.cpp b/client/battle/CBattleInterface.cpp index e6840048d..88a238e3a 100644 --- a/client/battle/CBattleInterface.cpp +++ b/client/battle/CBattleInterface.cpp @@ -1366,11 +1366,11 @@ void CBattleInterface::battleStacksEffectsSet(const SetStackEffect & sse) } } -CBattleInterface::PossibleActions CBattleInterface::getCasterAction(const CSpell * spell, const ISpellCaster * caster) const +CBattleInterface::PossibleActions CBattleInterface::getCasterAction(const CSpell * spell, const ISpellCaster * caster, ECastingMode::ECastingMode mode) const { PossibleActions spellSelMode = ANY_LOCATION; - const CSpell::TargetInfo ti(spell, caster->getSpellSchoolLevel(spell)); + const CSpell::TargetInfo ti(spell, caster->getSpellSchoolLevel(spell), mode); if(ti.massive || ti.type == CSpell::NO_TARGET) spellSelMode = NO_LOCATION; @@ -1406,7 +1406,7 @@ void CBattleInterface::castThisSpell(SpellID spellID) const CGHeroInstance * castingHero = (attackingHeroInstance->tempOwner == curInt->playerID) ? attackingHeroInstance : defendingHeroInstance; assert(castingHero); // code below assumes non-null hero sp = spellID.toSpell(); - PossibleActions spellSelMode = getCasterAction(sp, castingHero); + PossibleActions spellSelMode = getCasterAction(sp, castingHero, ECastingMode::HERO_CASTING); if (spellSelMode == NO_LOCATION) //user does not have to select location { @@ -1589,6 +1589,7 @@ void CBattleInterface::activateStack() else creatureSpellToCast = curInt->cb->battleGetRandomStackSpell(s, CBattleInfoCallback::RANDOM_AIMED); //faerie dragon can cast only one spell until their next move //TODO: what if creature can cast BOTH random genie spell and aimed spell? + //TODO: faerie dragon type spell should be selected by server } else { @@ -1636,12 +1637,11 @@ void CBattleInterface::getPossibleActionsForStack(const CStack * stack) if(creatureSpellToCast != -1) { const CSpell * spell = SpellID(creatureSpellToCast).toSpell(); - PossibleActions act = getCasterAction(spell, stack); + PossibleActions act = getCasterAction(spell, stack, ECastingMode::CREATURE_ACTIVE_CASTING); if(act == NO_LOCATION) logGlobal->error("NO_LOCATION action target is not yet supported for creatures"); else possibleActions.push_back(act); - } } if (stack->hasBonusOfType (Bonus::RANDOM_SPELLCASTER)) diff --git a/client/battle/CBattleInterface.h b/client/battle/CBattleInterface.h index 803350ee8..7a700d202 100644 --- a/client/battle/CBattleInterface.h +++ b/client/battle/CBattleInterface.h @@ -259,7 +259,7 @@ private: void redrawBackgroundWithHexes(const CStack * activeStack); /** End of battle screen blitting methods */ - PossibleActions getCasterAction(const CSpell * spell, const ISpellCaster * caster) const; + PossibleActions getCasterAction(const CSpell * spell, const ISpellCaster * caster, ECastingMode::ECastingMode mode) const; public: std::list > pendingAnims; //currently displayed animations void addNewAnim(CBattleAnimation * anim); //adds new anim to pendingAnims diff --git a/lib/spells/CSpellHandler.cpp b/lib/spells/CSpellHandler.cpp index f85594c79..16c601c3e 100644 --- a/lib/spells/CSpellHandler.cpp +++ b/lib/spells/CSpellHandler.cpp @@ -672,6 +672,10 @@ CSpell::TargetInfo::TargetInfo(const CSpell * spell, const int level, ECastingMo { alwaysHitDirectly = true; } + else if(mode == ECastingMode::CREATURE_ACTIVE_CASTING) + { + massive = false;//FIXME: find better solution for Commander spells + } } void CSpell::TargetInfo::init(const CSpell * spell, const int level)