Browse Source

Implement NO_TERRAIN_PENALTY bonus

Penalty of specified terrain type is ignored if hero have this bonus
ArseniyShestakov 10 years ago
parent
commit
52a52dcfd9
3 changed files with 7 additions and 3 deletions
  1. 5 0
      config/bonuses.json
  2. 1 0
      lib/HeroBonus.h
  3. 1 3
      lib/mapObjects/CGHeroInstance.cpp

+ 5 - 0
config/bonuses.json

@@ -368,6 +368,11 @@
 			"icon":  "zvs/Lib1.res/E_OBST"
 		}
 	},
+	
+	"NO_TERRAIN_PENALTY":
+	{
+		"hidden": true
+	},
 
 	"NON_LIVING":
 	{

+ 1 - 0
lib/HeroBonus.h

@@ -215,6 +215,7 @@ public:
 	BONUS_NAME(ADDITIONAL_UNITS) /*val of units with id = subtype will be added to hero's army at the beginning of battle */\
 	BONUS_NAME(SPOILS_OF_WAR) /*val * 10^-6 * gained exp resources of subtype will be given to hero after battle*/\
 	BONUS_NAME(BLOCK)\
+	BONUS_NAME(NO_TERRAIN_PENALTY) /* subtype - terrain type */\
 	BONUS_NAME(DISGUISED) /* subtype - spell level */\
 	BONUS_NAME(VISIONS) /* subtype - spell level */
 	

+ 1 - 3
lib/mapObjects/CGHeroInstance.cpp

@@ -83,8 +83,6 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainTile &fro
 	}
 	else
 	{
-		//FIXME: in H3 presence of Nomad in army will remove terrain penalty for sand. Bonus not implemented in VCMI
-
 		// NOTE: in H3 neutral stacks will ignore terrain penalty only if placed as topmost stack(s) in hero army.
 		// This is clearly bug in H3 however intended behaviour is not clear.
 		// Current VCMI behaviour will ignore neutrals in calculations so army in VCMI
@@ -101,7 +99,7 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainTile &fro
 				break;
 			}
 		}
-		if (!nativeArmy)
+		if(!nativeArmy && !hasBonusOfType(Bonus::NO_TERRAIN_PENALTY, from.terType))
         {
             ret = VLC->heroh->terrCosts[from.terType];
             ret-=getSecSkillLevel(SecondarySkill::PATHFINDING)*25;