1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Handle HYPNOTIZE effect in case of FEAR and ENCHANTED effects

This commit is contained in:
AlexVinS 2016-09-29 22:26:28 +03:00
parent 83b3c700dd
commit 9097ffbd8a
3 changed files with 20 additions and 4 deletions

View File

@ -494,6 +494,15 @@ const CGHeroInstance * CBattleInfoEssentials::battleGetOwnerHero(const CStack *
return getBattle()->sides.at(playerToSide(battleGetOwner(stack))).hero;
}
bool CBattleInfoEssentials::battleMatchOwner(const CStack * attacker, const CStack * defender, const boost::logic::tribool positivness /* = false*/) const
{
RETURN_IF_NOT_BATTLE(false);
if(boost::logic::indeterminate(positivness))
return true;
else
return (battleGetOwner(attacker) == battleGetOwner(defender)) == positivness;
}
si8 CBattleInfoCallback::battleHasWallPenalty( const CStack * stack, BattleHex destHex ) const
{
return battleHasWallPenalty(stack, stack->position, destHex);

View File

@ -214,8 +214,15 @@ public:
const CStack * battleGetStackByID(int ID, bool onlyAlive = true) const; //returns stack info by given ID
bool battleIsObstacleVisibleForSide(const CObstacleInstance & coi, BattlePerspective::BattlePerspective side) const;
PlayerColor battleGetOwner(const CStack * stack) const; //returns player that controls given stack; mind control included
const CGHeroInstance * battleGetOwnerHero(const CStack * stack) const; //returns hero that controls given stack; nullptr if none; mind control included
///returns player that controls given stack; mind control included
PlayerColor battleGetOwner(const CStack * stack) const;
///returns hero that controls given stack; nullptr if none; mind control included
const CGHeroInstance * battleGetOwnerHero(const CStack * stack) const;
///check that stacks are controlled by same|other player(s) depending on positiveness
///mind control included
bool battleMatchOwner(const CStack * attacker, const CStack * defender, const boost::logic::tribool positivness = false) const;
};
struct DLL_LINKAGE BattleAttackInfo

View File

@ -4556,7 +4556,7 @@ void CGameHandler::stackTurnTrigger(const CStack * st)
bool fearsomeCreature = false;
for(CStack * stack : gs->curB->stacks)
{
if (stack->owner != st->owner && stack->alive() && stack->hasBonusOfType(Bonus::FEAR))
if(battleMatchOwner(st, stack) && stack->alive() && stack->hasBonusOfType(Bonus::FEAR))
{
fearsomeCreature = true;
break;
@ -4614,7 +4614,7 @@ void CGameHandler::stackTurnTrigger(const CStack * st)
{
for (auto s : gs->curB->battleGetAllStacks())
{
if (st->owner == s->owner && s->isValidTarget()) //all allied
if(battleMatchOwner(st, s, true) && s->isValidTarget()) //all allied
sse.stacks.push_back (s->ID);
}
}