1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Added configurable animation for SPELL_LIKE_ATTACK

This commit is contained in:
AlexVinS
2014-11-28 00:36:14 +03:00
parent 943a5bf0d3
commit d94f15bdf4
10 changed files with 147 additions and 36 deletions

View File

@@ -794,11 +794,14 @@ void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CSt
}
const Bonus * bonus = att->getBonusLocalFirst(Selector::type(Bonus::SPELL_LIKE_ATTACK));
if (bonus && (bat.shot())) //TODO: make it work in meele?
{
bat.bsa.front().flags |= BattleStackAttacked::EFFECT;
bat.bsa.front().effect = VLC->spellh->objects.at(bonus->subtype)->mainEffectAnim; //hopefully it does not interfere with any other effect?
if (bonus && (bat.shot())) //TODO: make it work in melee?
{
//this is need for displaying hit animation
bat.flags |= BattleAttack::SPELL_LIKE;
bat.spellID = SpellID(bonus->subtype);
//TODO: should spell override creature`s projectile?
std::set<const CStack*> attackedCreatures = SpellID(bonus->subtype).toSpell()->getAffectedStacks(gs->curB, ECastingMode::SPELL_LIKE_ATTACK, att->owner, bonus->val, targetHex);
//TODO: get exact attacked hex for defender
@@ -810,6 +813,18 @@ void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CSt
applyBattleEffects(bat, att, stack, distance, true);
}
}
//now add effect info for all attacked stacks
for(BattleStackAttacked & bsa : bat.bsa)
{
if(bsa.attackerID == att->ID) //this is our attack and not f.e. fire shield
{
//this is need for displaying affect animation
bsa.flags |= BattleStackAttacked::SPELL_EFFECT;
bsa.spellID = SpellID(bonus->subtype);
}
}
}
}
void CGameHandler::applyBattleEffects(BattleAttack &bat, const CStack *att, const CStack *def, int distance, bool secondary) //helper function for prepareAttack