mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Remove stack instancies of removed stacks
This commit is contained in:
parent
349f16a359
commit
b024237e8a
@ -3854,12 +3854,13 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
|
|||||||
const CStack *summoner = gs->curB->battleGetStackByID(ba.stackNumber),
|
const CStack *summoner = gs->curB->battleGetStackByID(ba.stackNumber),
|
||||||
*destStack = gs->curB->battleGetStackByPos(ba.destinationTile, false);
|
*destStack = gs->curB->battleGetStackByPos(ba.destinationTile, false);
|
||||||
|
|
||||||
|
CreatureID summonedType(summoner->getBonusLocalFirst(Selector::type(Bonus::DAEMON_SUMMONING))->subtype);//in case summoner can summon more than one type of monsters... scream!
|
||||||
BattleStackAdded bsa;
|
BattleStackAdded bsa;
|
||||||
bsa.attacker = summoner->attackerOwned;
|
bsa.attacker = summoner->attackerOwned;
|
||||||
|
|
||||||
bsa.creID = CreatureID(summoner->getBonusLocalFirst(Selector::type(Bonus::DAEMON_SUMMONING))->subtype); //in case summoner can summon more than one type of monsters... scream!
|
bsa.creID = summonedType;
|
||||||
ui64 risedHp = summoner->count * summoner->valOfBonuses(Bonus::DAEMON_SUMMONING, bsa.creID.toEnum());
|
ui64 risedHp = summoner->count * summoner->valOfBonuses(Bonus::DAEMON_SUMMONING, bsa.creID.toEnum());
|
||||||
ui64 targetHealth = destStack->getCreature()->MaxHealth() * destStack->baseAmount;
|
ui64 targetHealth = destStack->getCreature()->MaxHealth() * destStack->baseAmount;//todo: ignore AGE effect
|
||||||
|
|
||||||
ui64 canRiseHp = std::min(targetHealth, risedHp);
|
ui64 canRiseHp = std::min(targetHealth, risedHp);
|
||||||
ui32 canRiseAmount = canRiseHp / VLC->creh->creatures.at(bsa.creID)->MaxHealth();
|
ui32 canRiseAmount = canRiseHp / VLC->creh->creatures.at(bsa.creID)->MaxHealth();
|
||||||
@ -5812,6 +5813,32 @@ CasualtiesAfterBattle::CasualtiesAfterBattle(const CArmedInstance *army, BattleI
|
|||||||
if(color == PlayerColor::UNFLAGGABLE)
|
if(color == PlayerColor::UNFLAGGABLE)
|
||||||
color = PlayerColor::NEUTRAL;
|
color = PlayerColor::NEUTRAL;
|
||||||
|
|
||||||
|
//1. Find removed stacks.
|
||||||
|
for(const auto & slotInfo : army->stacks)
|
||||||
|
{
|
||||||
|
const SlotID slot = slotInfo.first;
|
||||||
|
const CStackInstance * instance = slotInfo.second;
|
||||||
|
|
||||||
|
if(nullptr != instance)//just in case
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
for(const CStack * sta : bat->stacks)
|
||||||
|
{
|
||||||
|
if(sta->base == instance)
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//stack in this slot was removed == it is dead
|
||||||
|
if(!found)
|
||||||
|
{
|
||||||
|
StackLocation sl(army, slot);
|
||||||
|
newStackCounts.push_back(TStackAndItsNewCount(sl, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(CStack *st : bat->stacks)
|
for(CStack *st : bat->stacks)
|
||||||
{
|
{
|
||||||
if(vstd::contains(st->state, EBattleStackState::SUMMONED)) //don't take into account summoned stacks
|
if(vstd::contains(st->state, EBattleStackState::SUMMONED)) //don't take into account summoned stacks
|
||||||
|
Loading…
Reference in New Issue
Block a user