ソースを参照

vcmi: skill-agnostic pathfinding

For now, works exactly as in VCMI and H3.
I think we should add some BONUS_TERRAIN_DISCOUNT_PERCENT bonus
to discount by percent, like written in pathfinding description
Konstantin 2 年 前
コミット
6e4372176a
4 ファイル変更6 行追加7 行削除
  1. 1 2
      config/skills.json
  2. 3 4
      lib/CPathfinder.cpp
  3. 1 0
      lib/HeroBonus.h
  4. 1 1
      lib/mapObjects/CGHeroInstance.cpp

+ 1 - 2
config/skills.json

@@ -4,8 +4,7 @@
 		"base" : {
 			"effects" : {
 				"main" : {
-					"subtype" : "skill.pathfinding",
-					"type" : "SECONDARY_SKILL_PREMY",
+					"type" : "ROUGH_TERRAIN_DISCOUNT",
 					"valueType" : "BASE_NUMBER"
 				}
 			}

+ 3 - 4
lib/CPathfinder.cpp

@@ -1011,7 +1011,7 @@ TurnInfo::BonusCache::BonusCache(TConstBonusListPtr bl)
 	flyingMovementVal = bl->valOfBonuses(Selector::type()(Bonus::FLYING_MOVEMENT));
 	waterWalking = static_cast<bool>(bl->getFirst(Selector::type()(Bonus::WATER_WALKING)));
 	waterWalkingVal = bl->valOfBonuses(Selector::type()(Bonus::WATER_WALKING));
-	pathfindingVal = bl->valOfBonuses(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::PATHFINDING));
+	pathfindingVal = bl->valOfBonuses(Selector::type()(Bonus::ROUGH_TERRAIN_DISCOUNT));
 }
 
 TurnInfo::TurnInfo(const CGHeroInstance * Hero, const int turn)
@@ -1068,9 +1068,8 @@ int TurnInfo::valOfBonuses(Bonus::BonusType type, int subtype) const
 		return bonusCache->flyingMovementVal;
 	case Bonus::WATER_WALKING:
 		return bonusCache->waterWalkingVal;
-	case Bonus::SECONDARY_SKILL_PREMY:
-		if (subtype == SecondarySkill::PATHFINDING)
-			return bonusCache->pathfindingVal;
+	case Bonus::ROUGH_TERRAIN_DISCOUNT:
+		return bonusCache->pathfindingVal;
 	}
 
 	return bonuses->valOfBonuses(Selector::type()(type).And(Selector::subtype()(subtype)));

+ 1 - 0
lib/HeroBonus.h

@@ -336,6 +336,7 @@ public:
 	BONUS_NAME(LEARN_BATTLE_SPELL_LEVEL_LIMIT) /*skill-agnostic eagle eye limit, subtype - school (-1 for all), others TODO*/\
 	BONUS_NAME(PERCENTAGE_DAMAGE_BOOST) /*skill-agnostic archery and offence, subtype is 0 for offence and 1 for archery*/\
 	BONUS_NAME(LEARN_MEETING_SPELL_LIMIT) /*skill-agnostic scholar, subtype is -1 for all, TODO for others (> 0)*/\
+	BONUS_NAME(ROUGH_TERRAIN_DISCOUNT) /*skill-agnostic pathfinding*/\
 	/* end of list */
 
 

+ 1 - 1
lib/mapObjects/CGHeroInstance.cpp

@@ -76,7 +76,7 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile & dest, const TerrainTile & f
 	{
 
 		ret = VLC->heroh->terrCosts[from.terType->getId()];
-		ret -= ti->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::PATHFINDING);
+		ret -= ti->valOfBonuses(Bonus::ROUGH_TERRAIN_DISCOUNT);
 		if(ret < GameConstants::BASE_MOVEMENT_COST)
 			ret = GameConstants::BASE_MOVEMENT_COST;
 	}