1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-05 13:04:54 +02:00

Disabled massive spells fore creatures as they are not fully supported yet.

* (WoG) commanders now cast spells properly.
This commit is contained in:
AlexVinS 2016-09-10 21:07:36 +03:00
parent 8eca149eb3
commit 4a9978c642
3 changed files with 10 additions and 6 deletions

View File

@ -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; 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) if(ti.massive || ti.type == CSpell::NO_TARGET)
spellSelMode = NO_LOCATION; spellSelMode = NO_LOCATION;
@ -1406,7 +1406,7 @@ void CBattleInterface::castThisSpell(SpellID spellID)
const CGHeroInstance * castingHero = (attackingHeroInstance->tempOwner == curInt->playerID) ? attackingHeroInstance : defendingHeroInstance; const CGHeroInstance * castingHero = (attackingHeroInstance->tempOwner == curInt->playerID) ? attackingHeroInstance : defendingHeroInstance;
assert(castingHero); // code below assumes non-null hero assert(castingHero); // code below assumes non-null hero
sp = spellID.toSpell(); 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 if (spellSelMode == NO_LOCATION) //user does not have to select location
{ {
@ -1589,6 +1589,7 @@ void CBattleInterface::activateStack()
else else
creatureSpellToCast = curInt->cb->battleGetRandomStackSpell(s, CBattleInfoCallback::RANDOM_AIMED); //faerie dragon can cast only one spell until their next move 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: what if creature can cast BOTH random genie spell and aimed spell?
//TODO: faerie dragon type spell should be selected by server
} }
else else
{ {
@ -1636,12 +1637,11 @@ void CBattleInterface::getPossibleActionsForStack(const CStack * stack)
if(creatureSpellToCast != -1) if(creatureSpellToCast != -1)
{ {
const CSpell * spell = SpellID(creatureSpellToCast).toSpell(); const CSpell * spell = SpellID(creatureSpellToCast).toSpell();
PossibleActions act = getCasterAction(spell, stack); PossibleActions act = getCasterAction(spell, stack, ECastingMode::CREATURE_ACTIVE_CASTING);
if(act == NO_LOCATION) if(act == NO_LOCATION)
logGlobal->error("NO_LOCATION action target is not yet supported for creatures"); logGlobal->error("NO_LOCATION action target is not yet supported for creatures");
else else
possibleActions.push_back(act); possibleActions.push_back(act);
} }
} }
if (stack->hasBonusOfType (Bonus::RANDOM_SPELLCASTER)) if (stack->hasBonusOfType (Bonus::RANDOM_SPELLCASTER))

View File

@ -259,7 +259,7 @@ private:
void redrawBackgroundWithHexes(const CStack * activeStack); void redrawBackgroundWithHexes(const CStack * activeStack);
/** End of battle screen blitting methods */ /** 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: public:
std::list<std::pair<CBattleAnimation *, bool> > pendingAnims; //currently displayed animations <anim, initialized> std::list<std::pair<CBattleAnimation *, bool> > pendingAnims; //currently displayed animations <anim, initialized>
void addNewAnim(CBattleAnimation * anim); //adds new anim to pendingAnims void addNewAnim(CBattleAnimation * anim); //adds new anim to pendingAnims

View File

@ -672,6 +672,10 @@ CSpell::TargetInfo::TargetInfo(const CSpell * spell, const int level, ECastingMo
{ {
alwaysHitDirectly = true; 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) void CSpell::TargetInfo::init(const CSpell * spell, const int level)