1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00
This commit is contained in:
AlexVinS 2016-09-29 23:14:22 +03:00
parent 9097ffbd8a
commit 72461c5c2e
4 changed files with 20 additions and 4 deletions

View File

@ -478,7 +478,6 @@ EGateState CBattleInfoEssentials::battleGetGateState() const
return getBattle()->si.gateState;
}
PlayerColor CBattleInfoEssentials::battleGetOwner(const CStack * stack) const
{
RETURN_IF_NOT_BATTLE(PlayerColor::CANNOT_DETERMINE);
@ -499,6 +498,8 @@ bool CBattleInfoEssentials::battleMatchOwner(const CStack * attacker, const CSta
RETURN_IF_NOT_BATTLE(false);
if(boost::logic::indeterminate(positivness))
return true;
else if(defender->owner != battleGetOwner(defender))
return true;//mind controlled unit is attackable for both sides
else
return (battleGetOwner(attacker) == battleGetOwner(defender)) == positivness;
}
@ -856,7 +857,7 @@ bool CBattleInfoCallback::battleCanAttack(const CStack * stack, const CStack * t
if (!stack || !target)
return false;
if (stack->owner == target->owner)
if(!battleMatchOwner(stack, target))
return false;
auto &id = stack->getCreature()->idNumber;
@ -888,7 +889,7 @@ bool CBattleInfoCallback::battleCanShoot(const CStack * stack, BattleHex dest) c
return false;
if(stack->hasBonusOfType(Bonus::SHOOTER)//it's shooter
&& stack->owner != dst->owner
&& battleMatchOwner(stack, dst)
&& dst->alive()
&& (!battleIsStackBlocked(stack) || stack->hasBonusOfType(Bonus::FREE_SHOOTING))
&& stack->shots

View File

@ -267,6 +267,19 @@ bool CSpell::isNeutral() const
return positiveness == NEUTRAL;
}
boost::logic::tribool CSpell::getPositiveness() const
{
switch (positiveness)
{
case CSpell::POSITIVE:
return true;
case CSpell::NEGATIVE:
return false;
default:
return boost::logic::indeterminate;
}
}
bool CSpell::isRisingSpell() const
{
return isRising;

View File

@ -204,6 +204,8 @@ public:
bool isNegative() const;
bool isNeutral() const;
boost::logic::tribool getPositiveness() const;
bool isDamageSpell() const;
bool isRisingSpell() const;
bool isOffensiveSpell() const;

View File

@ -5726,7 +5726,7 @@ void CGameHandler::runBattle()
continue;
}
const CGHeroInstance * curOwner = gs->curB->battleGetOwnerHero(next);
const CGHeroInstance * curOwner = battleGetOwnerHero(next);
if( (next->position < 0 || next->getCreature()->idNumber == CreatureID::BALLISTA) //arrow turret or ballista
&& (!curOwner || curOwner->getSecSkillLevel(SecondarySkill::ARTILLERY) == 0)) //hero has no artillery