mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
parent
e13dc872e0
commit
99352a7220
@ -1201,7 +1201,7 @@ bool CStack::isMeleeAttackPossible(const CStack * attacker, const CStack * defen
|
||||
|
||||
}
|
||||
|
||||
bool CStack::ableToRetaliate() const
|
||||
bool CStack::ableToRetaliate() const //FIXME: crash after clone is killed
|
||||
{
|
||||
return alive()
|
||||
&& (counterAttacks > 0 || hasBonusOfType(Bonus::UNLIMITED_RETALIATIONS))
|
||||
|
@ -264,6 +264,10 @@ public:
|
||||
{
|
||||
return vstd::contains(state,EBattleStackState::ALIVE);
|
||||
}
|
||||
bool idDeadClone() const //determines if stack is alive
|
||||
{
|
||||
return vstd::contains(state,EBattleStackState::DEAD_CLONE);
|
||||
}
|
||||
bool isValidTarget(bool allowDead = false) const; //alive non-turret stacks (can be attacked or be object of magic effect)
|
||||
};
|
||||
|
||||
|
@ -429,7 +429,7 @@ namespace EMarketMode
|
||||
|
||||
namespace EBattleStackState
|
||||
{
|
||||
enum EBattleStackState{ALIVE = 180, SUMMONED, CLONED, HAD_MORALE, WAITING, MOVED, DEFENDING, FEAR,
|
||||
enum EBattleStackState{ALIVE = 180, SUMMONED, CLONED, DEAD_CLONE, HAD_MORALE, WAITING, MOVED, DEFENDING, FEAR,
|
||||
DRAINED_MANA /*remember to drain mana only once per turn*/};
|
||||
}
|
||||
|
||||
|
@ -1185,9 +1185,9 @@ DLL_LINKAGE void BattleStackAttacked::applyGs( CGameState *gs )
|
||||
}
|
||||
if (cloneKilled())
|
||||
{
|
||||
BattleStacksRemoved bsr; //remove body
|
||||
bsr.stackIDs.insert(at->ID);
|
||||
bsr.applyGs(gs);
|
||||
//"hide" killed creatures instead so we keep info about it
|
||||
at->state.insert(EBattleStackState::DEAD_CLONE);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3433,7 +3433,8 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
||||
}
|
||||
|
||||
//counterattack
|
||||
if (!stack->hasBonusOfType(Bonus::BLOCKS_RETALIATION)
|
||||
if (stackAtEnd
|
||||
&& !stack->hasBonusOfType(Bonus::BLOCKS_RETALIATION)
|
||||
&& stackAtEnd->ableToRetaliate()
|
||||
&& stack->alive()) //attacker may have died (fire shield)
|
||||
{
|
||||
@ -3451,6 +3452,7 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
||||
moveStack(ba.stackNumber, startingPos);
|
||||
//NOTE: curStack->ID == ba.stackNumber (rev 1431)
|
||||
}
|
||||
|
||||
sendAndApply(&end_action);
|
||||
break;
|
||||
}
|
||||
@ -3773,7 +3775,6 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
||||
|
||||
handleSpellCasting(spellID, spellLvl, destination, casterSide, stack->owner, nullptr, secHero, 0, ECastingMode::CREATURE_ACTIVE_CASTING, stack);
|
||||
}
|
||||
|
||||
sendAndApply(&end_action);
|
||||
break;
|
||||
}
|
||||
@ -5895,7 +5896,21 @@ void CGameHandler::runBattle()
|
||||
|
||||
const BattleInfo & curB = *gs->curB;
|
||||
|
||||
//remove clones after all mechanics and animations are handled!
|
||||
std::set <const CStack*> stacksToRemove;
|
||||
for (auto stack : curB.stacks)
|
||||
{
|
||||
if (stack->idDeadClone())
|
||||
stacksToRemove.insert(stack);
|
||||
}
|
||||
for (auto stack : stacksToRemove)
|
||||
{
|
||||
BattleStacksRemoved bsr;
|
||||
bsr.stackIDs.insert(stack->ID);
|
||||
sendAndApply(&bsr);
|
||||
}
|
||||
//stack loop
|
||||
|
||||
const CStack *next;
|
||||
while(!battleResult.get() && (next = curB.getNextStack()) && next->willMove())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user