mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
CGameHandler: obstacle trigger does not use CStack
This commit is contained in:
parent
22dd97ad18
commit
e946ddcfeb
@ -1506,7 +1506,7 @@ int CGameHandler::moveStack(int stack, BattleHex dest)
|
|||||||
{
|
{
|
||||||
if(stackIsMoving && start != curStack->getPosition())
|
if(stackIsMoving && start != curStack->getPosition())
|
||||||
{
|
{
|
||||||
stackIsMoving = handleDamageFromObstacle(curStack, stackIsMoving, passed);
|
stackIsMoving = handleDamageFromObstacle(curStack, passed);
|
||||||
passed.insert(curStack->getPosition());
|
passed.insert(curStack->getPosition());
|
||||||
if(curStack->doubleWide())
|
if(curStack->doubleWide())
|
||||||
passed.insert(curStack->occupiedHex());
|
passed.insert(curStack->occupiedHex());
|
||||||
@ -1544,7 +1544,7 @@ int CGameHandler::moveStack(int stack, BattleHex dest)
|
|||||||
passed.clear(); //Just empty passed, obstacles will handled automatically
|
passed.clear(); //Just empty passed, obstacles will handled automatically
|
||||||
}
|
}
|
||||||
//handling obstacle on the final field (separate, because it affects both flying and walking stacks)
|
//handling obstacle on the final field (separate, because it affects both flying and walking stacks)
|
||||||
handleDamageFromObstacle(curStack, false, passed);
|
handleDamageFromObstacle(curStack, passed);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -5219,7 +5219,7 @@ void CGameHandler::stackTurnTrigger(const CStack *st)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGameHandler::handleDamageFromObstacle(const CStack * curStack, bool stackIsMoving, const std::set<BattleHex> & passed)
|
bool CGameHandler::handleDamageFromObstacle(const battle::Unit * curStack, const std::set<BattleHex> & passed)
|
||||||
{
|
{
|
||||||
if(!curStack->alive())
|
if(!curStack->alive())
|
||||||
return false;
|
return false;
|
||||||
@ -5247,7 +5247,7 @@ 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;
|
const auto side = curStack->unitSide();
|
||||||
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->getSidePlayer(spellObstacle->casterSide), hero, *spellObstacle);
|
auto caster = spells::ObstacleCasterProxy(gs->curB->getSidePlayer(spellObstacle->casterSide), hero, *spellObstacle);
|
||||||
@ -5272,14 +5272,11 @@ bool CGameHandler::handleDamageFromObstacle(const CStack * curStack, bool stackI
|
|||||||
if(!curStack->alive())
|
if(!curStack->alive())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if((obstacle->stopsMovement() && stackIsMoving))
|
if(obstacle->stopsMovement())
|
||||||
movementStopped = true;
|
movementStopped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stackIsMoving)
|
|
||||||
return curStack->alive() && !movementStopped;
|
return curStack->alive() && !movementStopped;
|
||||||
|
|
||||||
return curStack->alive();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameHandler::handleTimeEvents()
|
void CGameHandler::handleTimeEvents()
|
||||||
|
@ -232,7 +232,7 @@ public:
|
|||||||
bool makeCustomAction(BattleAction &ba);
|
bool makeCustomAction(BattleAction &ba);
|
||||||
void stackEnchantedTrigger(const CStack * stack);
|
void stackEnchantedTrigger(const CStack * stack);
|
||||||
void stackTurnTrigger(const CStack *stack);
|
void stackTurnTrigger(const CStack *stack);
|
||||||
bool handleDamageFromObstacle(const CStack * curStack, bool stackIsMoving = false, const std::set<BattleHex> & passed = {}); //checks if obstacle is land mine and handles possible consequences
|
bool handleDamageFromObstacle(const battle::Unit * curStack, const std::set<BattleHex> & passed = {}); //checks if obstacle is land mine and handles possible consequences
|
||||||
|
|
||||||
void removeObstacle(const CObstacleInstance &obstacle);
|
void removeObstacle(const CObstacleInstance &obstacle);
|
||||||
bool queryReply( QueryID qid, const JsonNode & answer, PlayerColor player );
|
bool queryReply( QueryID qid, const JsonNode & answer, PlayerColor player );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user