1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

+smart target, +hit animation

This commit is contained in:
AlexVinS 2015-03-18 17:48:32 +03:00
parent a1ea551a85
commit 9600446cf9
10 changed files with 29 additions and 11 deletions

View File

@ -1188,7 +1188,7 @@ void CBattleInterface::hexLclicked(int whichOne)
void CBattleInterface::stackIsCatapulting(const CatapultAttack & ca)
{
if(ca.attacker != -1) //no shooting animation for spells like earthquake
if(ca.attacker != -1)
{
const CStack * stack = curInt->cb->battleGetStackByID(ca.attacker);
for(auto attackInfo : ca.attackedParts)
@ -1196,6 +1196,16 @@ void CBattleInterface::stackIsCatapulting(const CatapultAttack & ca)
addNewAnim(new CShootingAnimation(this, stack, attackInfo.destinationTile, nullptr, true, attackInfo.damageDealt));
}
}
else
{
//no attacker stack, assume spell-related (earthquake) - only hit animation
for(auto attackInfo : ca.attackedParts)
{
Point destPos = CClickableHex::getXYUnitAnim(attackInfo.destinationTile, nullptr, this) + Point(99, 120);
addNewAnim(new CSpellEffectAnimation(this, "SGEXPL.DEF", destPos.x, destPos.y));
}
}
waitForAnims();

View File

@ -86,6 +86,7 @@
},
"levels" : {
"base":{
"targetModifier":{"smart":true},
"range" : "X"
}
},

View File

@ -1599,7 +1599,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
if(!spell->combatSpell)
return ESpellCastProblem::ADVMAP_SPELL_INSTEAD_OF_BATTLE_SPELL;
const ESpellCastProblem::ESpellCastProblem specificProblem = spell->canBeCasted(this);
const ESpellCastProblem::ESpellCastProblem specificProblem = spell->canBeCasted(this, player);
if(specificProblem != ESpellCastProblem::OK)
return specificProblem;

View File

@ -196,7 +196,7 @@ void EarthquakeMechanics::applyBattleEffects(const SpellCastEnvironment * env, B
attackInfo.damageDealt = 1;
attackInfo.attackedPart = target;
attackInfo.destinationTile = BattleHex::INVALID;
attackInfo.destinationTile = parameters.cb->wallPartToBattleHex(target);
ca.attackedParts.push_back(attackInfo);
@ -236,7 +236,7 @@ void EarthquakeMechanics::applyBattleEffects(const SpellCastEnvironment * env, B
env->sendAndApply(&ca);
}
ESpellCastProblem::ESpellCastProblem EarthquakeMechanics::canBeCasted(const CBattleInfoCallback * cb) const
ESpellCastProblem::ESpellCastProblem EarthquakeMechanics::canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const
{
if(nullptr == cb->battleGetDefendedTown())
{
@ -248,6 +248,13 @@ ESpellCastProblem::ESpellCastProblem EarthquakeMechanics::canBeCasted(const CBat
return ESpellCastProblem::NO_APPROPRIATE_TARGET;
}
if(owner->getTargetInfo(0).smart) //TODO: use real spell level
{
//if spell targeting is smart, then only attacker can use it
if(cb->playerToSide(player) != 0)
return ESpellCastProblem::NO_APPROPRIATE_TARGET;
}
return ESpellCastProblem::OK;
}

View File

@ -48,7 +48,7 @@ class DLL_LINKAGE EarthquakeMechanics : public DefaultSpellMechanics
{
public:
EarthquakeMechanics(CSpell * s): DefaultSpellMechanics(s){};
ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb) const override;
ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const override;
protected:
void applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const override;
};

View File

@ -712,7 +712,7 @@ std::set<const CStack *> DefaultSpellMechanics::getAffectedStacks(SpellTargeting
return attackedCres;
}
ESpellCastProblem::ESpellCastProblem DefaultSpellMechanics::canBeCasted(const CBattleInfoCallback * cb) const
ESpellCastProblem::ESpellCastProblem DefaultSpellMechanics::canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const
{
//no problems by default, this method is for spell-specific problems
return ESpellCastProblem::OK;

View File

@ -33,7 +33,7 @@ public:
std::vector<BattleHex> rangeInHexes(BattleHex centralHex, ui8 schoolLvl, ui8 side, bool * outDroppedHexes = nullptr) const override;
std::set<const CStack *> getAffectedStacks(SpellTargetingContext & ctx) const override;
ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb) const override;
ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const override;
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const CGHeroInstance * caster, const CStack * obj) const override;

View File

@ -234,9 +234,9 @@ ui32 CSpell::calculateDamage(const CGHeroInstance * caster, const CStack * affec
return ret;
}
ESpellCastProblem::ESpellCastProblem CSpell::canBeCasted(const CBattleInfoCallback * cb) const
ESpellCastProblem::ESpellCastProblem CSpell::canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const
{
return mechanics->canBeCasted(cb);
return mechanics->canBeCasted(cb, player);
}
std::vector<BattleHex> CSpell::rangeInHexes(BattleHex centralHex, ui8 schoolLvl, ui8 side, bool *outDroppedHexes) const

View File

@ -302,7 +302,7 @@ public:
///internal interface (for callbacks)
///Checks general but spell-specific problems for all casting modes. Use only during battle.
ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb) const;
ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const;
///checks for creature immunity / anything that prevent casting *at given target* - doesn't take into account general problems such as not having spellbook or mana points etc.
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const CGHeroInstance * caster, const CStack * obj) const;

View File

@ -39,7 +39,7 @@ public:
virtual std::vector<BattleHex> rangeInHexes(BattleHex centralHex, ui8 schoolLvl, ui8 side, bool * outDroppedHexes = nullptr) const = 0;
virtual std::set<const CStack *> getAffectedStacks(SpellTargetingContext & ctx) const = 0;
virtual ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb) const = 0;
virtual ESpellCastProblem::ESpellCastProblem canBeCasted(const CBattleInfoCallback * cb, PlayerColor player) const = 0;
virtual ESpellCastProblem::ESpellCastProblem isImmuneByStack(const CGHeroInstance * caster, const CStack * obj) const = 0;