mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Do not allow rising of corpses below alive stack
This commit is contained in:
parent
beb9069f78
commit
1fab2e2e34
@ -89,20 +89,32 @@ void DemonSummon::apply(ServerCallback * server, const Mechanics * m, const Effe
|
||||
server->apply(&pack);
|
||||
}
|
||||
|
||||
bool DemonSummon::isValidTarget(const Mechanics * m, const battle::Unit * s) const
|
||||
bool DemonSummon::isValidTarget(const Mechanics * m, const battle::Unit * unit) const
|
||||
{
|
||||
if(!s->isDead())
|
||||
return false;
|
||||
if(!unit->isDead())
|
||||
{
|
||||
//check if alive unit blocks rising
|
||||
for(const BattleHex & hex : battle::Unit::getHexes(unit->getPosition(), unit->doubleWide(), unit->unitSide()))
|
||||
{
|
||||
auto blocking = m->battle()->battleGetUnitsIf([hex, unit](const battle::Unit * other)
|
||||
{
|
||||
return other->isValidTarget(false) && other->coversPos(hex) && other != unit;
|
||||
});
|
||||
|
||||
if (s->isGhost())
|
||||
if(!blocking.empty())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (unit->isGhost())
|
||||
return false;
|
||||
|
||||
const auto *creatureType = creature.toCreature(m->creatures());
|
||||
|
||||
if (s->getTotalHealth() < creatureType->getMaxHealth())
|
||||
if (unit->getTotalHealth() < creatureType->getMaxHealth())
|
||||
return false;
|
||||
|
||||
return m->isReceptive(s);
|
||||
return m->isReceptive(unit);
|
||||
}
|
||||
|
||||
void DemonSummon::serializeJsonUnitEffect(JsonSerializeFormat & handler)
|
||||
|
Loading…
Reference in New Issue
Block a user