1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

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
This commit is contained in:
Konstantin 2023-02-15 22:01:38 +03:00
parent 9ffd18c914
commit 6e4372176a
4 changed files with 6 additions and 7 deletions

View File

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

View File

@ -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,8 +1068,7 @@ 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)
case Bonus::ROUGH_TERRAIN_DISCOUNT:
return bonusCache->pathfindingVal;
}

View File

@ -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 */

View File

@ -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;
}