mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
CGameHandler: slightly rework obstacle caster
This commit is contained in:
parent
25956e3f37
commit
d5e2933bee
@ -5240,12 +5240,8 @@ bool CGameHandler::handleDamageFromObstacle(const CStack * curStack, bool stackI
|
|||||||
{
|
{
|
||||||
//helper info
|
//helper info
|
||||||
const SpellCreatedObstacle * spellObstacle = dynamic_cast<const SpellCreatedObstacle *>(obstacle.get());
|
const SpellCreatedObstacle * spellObstacle = dynamic_cast<const SpellCreatedObstacle *>(obstacle.get());
|
||||||
const ui8 side = curStack->side;
|
|
||||||
|
|
||||||
if(!spellObstacle)
|
if(spellObstacle)
|
||||||
COMPLAIN_RET("Invalid obstacle instance");
|
|
||||||
|
|
||||||
if(spellObstacle->triggersEffects())
|
|
||||||
{
|
{
|
||||||
auto revealObstacles = [&](const SpellCreatedObstacle & spellObstacle) -> void
|
auto revealObstacles = [&](const SpellCreatedObstacle & spellObstacle) -> void
|
||||||
{
|
{
|
||||||
@ -5263,11 +5259,12 @@ bool CGameHandler::handleDamageFromObstacle(const CStack * curStack, bool stackI
|
|||||||
changedObstacle.toInfo(bocp.changes.back(), operation);
|
changedObstacle.toInfo(bocp.changes.back(), operation);
|
||||||
sendAndApply(&bocp);
|
sendAndApply(&bocp);
|
||||||
};
|
};
|
||||||
|
const auto side = curStack->side;
|
||||||
auto shouldReveal = !spellObstacle->hidden || !gs->curB->battleIsObstacleVisibleForSide(*obstacle, (BattlePerspective::BattlePerspective)side);
|
auto shouldReveal = !spellObstacle->hidden || !gs->curB->battleIsObstacleVisibleForSide(*obstacle, (BattlePerspective::BattlePerspective)side);
|
||||||
const auto * hero = gs->curB->battleGetFightingHero(spellObstacle->casterSide);
|
const auto * hero = gs->curB->battleGetFightingHero(spellObstacle->casterSide);
|
||||||
auto caster = spells::ObstacleCasterProxy(gs->curB->sides.at(spellObstacle->casterSide).color, hero, *spellObstacle);
|
auto caster = spells::ObstacleCasterProxy(gs->curB->getSidePlayer(spellObstacle->casterSide), hero, *spellObstacle);
|
||||||
const auto * sp = SpellID(spellObstacle->ID).toSpell();
|
const auto * sp = SpellID(spellObstacle->ID).toSpell();
|
||||||
if(sp)
|
if(obstacle->triggersEffects() && sp)
|
||||||
{
|
{
|
||||||
auto cast = spells::BattleCast(gs->curB, &caster, spells::Mode::PASSIVE, sp);
|
auto cast = spells::BattleCast(gs->curB, &caster, spells::Mode::PASSIVE, sp);
|
||||||
spells::detail::ProblemImpl ignored;
|
spells::detail::ProblemImpl ignored;
|
||||||
|
Loading…
Reference in New Issue
Block a user