|
|
@@ -13,6 +13,8 @@
|
|
|
#include "../CStack.h"
|
|
|
#include "BattleInfo.h"
|
|
|
#include "CObstacleInstance.h"
|
|
|
+#include "GameLibrary.h"
|
|
|
+#include "IGameSettings.h"
|
|
|
|
|
|
#include "../constants/EntityIdentifiers.h"
|
|
|
#include "../entities/building/TownFortifications.h"
|
|
|
@@ -230,6 +232,12 @@ BattleSide CBattleInfoEssentials::battleGetTacticsSide() const
|
|
|
return getBattle()->getTacticsSide();
|
|
|
}
|
|
|
|
|
|
+int32_t CBattleInfoEssentials::battleGetRound() const
|
|
|
+{
|
|
|
+ RETURN_IF_NOT_BATTLE(-1);
|
|
|
+ return getBattle()->getRound();
|
|
|
+}
|
|
|
+
|
|
|
const CGHeroInstance * CBattleInfoEssentials::battleGetFightingHero(BattleSide side) const
|
|
|
{
|
|
|
RETURN_IF_NOT_BATTLE(nullptr);
|
|
|
@@ -295,14 +303,19 @@ bool CBattleInfoEssentials::battleCanFlee(const PlayerColor & player) const
|
|
|
|
|
|
const CGHeroInstance * myHero = battleGetFightingHero(side);
|
|
|
|
|
|
- //current player have no hero
|
|
|
+ //current player has no hero
|
|
|
if(!myHero)
|
|
|
return false;
|
|
|
|
|
|
- //eg. one of heroes is wearing shakles of war
|
|
|
+ //eg. one of heroes is wearing shackles of war
|
|
|
if(myHero->hasBonusOfType(BonusType::BATTLE_NO_FLEEING) && battleHasHero(otherSide(side)))
|
|
|
return false;
|
|
|
|
|
|
+ //with hit & run disabled - cannot flee after casting spell in 1st turn as attacker
|
|
|
+ if(LIBRARY->engineSettings()->getBoolean(EGameSettings::COMBAT_NO_SPELL_HIT_AND_RUN)
|
|
|
+ && side == BattleSide::ATTACKER && getBattle()->getRound() == 1 && battleHasHero(otherSide(side)) && getBattle()->getCastSpells(side) >= 1)
|
|
|
+ return false;
|
|
|
+
|
|
|
//we are besieged defender
|
|
|
if(side == BattleSide::DEFENDER && getBattle()->getDefendedTown() != nullptr)
|
|
|
{
|