1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-29 21:56:54 +02:00

Improvement for multiple-hex effects.

TODO: Attacker must know exact attacked tile, not only the stack.
This commit is contained in:
DjWarmonger 2011-07-03 05:55:57 +00:00
parent 4592ddb74e
commit 57a36e77f3
4 changed files with 38 additions and 4 deletions

@ -792,7 +792,7 @@ void CPlayerInterface::battleStacksAttacked(const std::vector<BattleStackAttacke
const CStack *attacker = cb->battleGetStackByID(i->attackerID, false);
if(i->isEffect() && i->effect != 12) //and not armageddon
{
if (defender != NULL)
if (defender && !i->isSecondary())
battleInt->displayEffect(i->effect, defender->position);
}
SStackAttackedInfo to_put = {defender, i->damageAmount, i->killedAmount, attacker, LOCPLINT->curAction->actionType==7, i->killed()};

@ -2276,6 +2276,35 @@ THex CStack::occupiedHex() const
}
}
std::vector<THex> CStack::getHexes() const
{
std::vector<THex> hexes;
hexes.push_back(THex(position));
if (doubleWide())
{
if (attackerOwned)
hexes.push_back(THex(position - 1));
else
hexes.push_back(THex(position + 1));
}
return hexes;
}
bool CStack::coversPos(ui16 pos) const
{
if (pos == position)
return true;
if (doubleWide())
{
if (attackerOwned)
return (pos == position - 1);
else
return (pos == position + 1);
}
else
return false;
}
std::vector<si32> CStack::activeSpells() const
{
std::vector<si32> ret;

@ -183,6 +183,8 @@ public:
bool doubleWide() const;
THex occupiedHex() const; //returns number of occupied hex (not the position) if stack is double wide; otherwise -1
std::vector<THex> getHexes() const; //up to two occupied hexes, starting from front
bool coversPos(ui16 position) const; //checks also if unit is double-wide
void prepareAttacked(BattleStackAttacked &bsa) const; //requires bsa.damageAmout filled

@ -551,6 +551,7 @@ void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CSt
BattleStackAttacked bss = *bsa; // copy some parameters, such as attacker
std::set<CStack*> attackedCreatures = gs->curB->getAttackedCreatures(VLC->spellh->spells[bonus->subtype], bonus->val, att->owner, def->position);
//TODO: get exact attacked hex for defender
BOOST_FOREACH(CStack * stack, attackedCreatures)
{
@ -3492,9 +3493,11 @@ void CGameHandler::handleSpellCasting( int spellID, int spellLvl, int destinatio
continue;
BattleStackAttacked bsa;
//TODO: display effect only upon primary target of area spell
bsa.flags |= BattleStackAttacked::EFFECT;
bsa.effect = spell->mainEffectAnim;
if (destination > -1 && (*it)->coversPos(destination)) //display effect only upon primary target of area spell
{
bsa.flags |= BattleStackAttacked::EFFECT;
bsa.effect = spell->mainEffectAnim;
}
bsa.damageAmount = gs->curB->calculateSpellDmg(spell, caster, *it, spellLvl, usedSpellPower);
bsa.stackAttacked = (*it)->ID;
bsa.attackerID = -1;