فهرست منبع

Shackles of War implementation uses bonus system propagation instead of looking into enemy hero. Silences some warnings.

Michał W. Urbańczyk 13 سال پیش
والد
کامیت
38b6435ee4
3فایلهای تغییر یافته به همراه5 افزوده شده و 7 حذف شده
  1. 1 1
      lib/CArtHandler.cpp
  2. 3 5
      lib/CBattleCallback.cpp
  3. 1 1
      lib/HeroBonus.h

+ 1 - 1
lib/CArtHandler.cpp

@@ -779,7 +779,7 @@ void CArtHandler::addBonuses()
 	giveArtBonus(123,Bonus::SPELL,3,1, Bonus::INDEPENDENT_MAX); 
 
 	giveArtBonus(124, Bonus::SPELLS_OF_LEVEL,3,1); //Spellbinder's Hat
-	giveArtBonus(125, Bonus::ENEMY_CANT_ESCAPE,0); //Shackles of War
+	giveArtBonus(125, Bonus::BATTLE_NO_FLEEING,0, 0, battleWidePropagator); //Shackles of War
 	giveArtBonus(126, Bonus::BLOCK_ALL_MAGIC, 0, -1, battleWidePropagator);//Orb of Inhibition
 
 	//vial of dragon blood

+ 3 - 5
lib/CBattleCallback.cpp

@@ -307,16 +307,14 @@ bool CBattleInfoEssentials::battleCanFlee(int player) const
 {
 	RETURN_IF_NOT_BATTLE(false);
 	ui8 mySide = playerToSide(player);
-	const CGHeroInstance *myHero = battleGetFightingHero(mySide),
-		*enemyHero = battleGetFightingHero(!mySide);
+	const CGHeroInstance *myHero = battleGetFightingHero(mySide);
 
 	//current player have no hero
 	if(!myHero)
 		return false;
 
-	//TODo use bonus system
-	//ie. one of heroes is wearing shakles of war
-	if(NBonus::hasOfType(enemyHero, Bonus::ENEMY_CANT_ESCAPE) || NBonus::hasOfType(myHero, Bonus::ENEMY_CANT_ESCAPE))
+	//eg. one of heroes is wearing shakles of war
+	if(myHero->hasBonusOfType(Bonus::BATTLE_NO_FLEEING))
 		return false;
 
 	//we are besieged defender

+ 1 - 1
lib/HeroBonus.h

@@ -69,7 +69,7 @@ typedef boost::function<bool(const Bonus*)> CSelector;
 	BONUS_NAME(WHIRLPOOL_PROTECTION) /*hero won't lose army when teleporting through whirlpool*/  \
 	BONUS_NAME(SPELL) /*hero knows spell, val - skill level (0 - 3), subtype - spell id*/  \
 	BONUS_NAME(SPELLS_OF_LEVEL) /*hero knows all spells of given level, val - skill level; subtype - level*/  \
-	BONUS_NAME(ENEMY_CANT_ESCAPE) /*for shackles of war*/ \
+	BONUS_NAME(BATTLE_NO_FLEEING) /*for shackles of war*/ \
 	BONUS_NAME(MAGIC_SCHOOL_SKILL) /* //eg. for magic plains terrain, subtype: school of magic (0 - all, 1 - fire, 2 - air, 4 - water, 8 - earth), value - level*/ \
 	BONUS_NAME(FREE_SHOOTING) /*stacks can shoot even if otherwise blocked (sharpshooter's bow effect)*/ \
 	BONUS_NAME(OPENING_BATTLE_SPELL) /*casts a spell at expert level at beginning of battle, val - spell power, subtype - spell id*/ \