1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Support for configuring minimal cost for moving between tiles

- Added `movementCostBase` parameter to game config that defines minimal
amount of movement points that will be spent when moving from one tile
on another while offroad (and cost of Fly / Town Portal spells)
- Added `BASE_TILE_MOVEMENT_COST` bonus type that allows modifying
`movementCostBase` on per-hero basis

Example usage for hota-like pathfinding skill
```json
"tileCostReduction" : {
	"type" : "BASE_TILE_MOVEMENT_COST",
	"val" : -15
}
```
This commit is contained in:
Ivan Savenko
2025-01-24 17:46:18 +00:00
parent b36f5e4026
commit ec970c7b22
18 changed files with 80 additions and 37 deletions

View File

@@ -73,25 +73,6 @@ void CGHeroPlaceholder::serializeJsonOptions(JsonSerializeFormat & handler)
handler.serializeInt("powerRank", powerRank.value());
}
ui32 CGHeroInstance::getTileMovementCost(const TerrainTile & dest, const TerrainTile & from, const TurnInfo * ti) const
{
int64_t ret = GameConstants::BASE_MOVEMENT_COST;
//if there is road both on dest and src tiles - use src road movement cost
if(dest.hasRoad() && from.hasRoad())
{
ret = from.getRoad()->movementCost;
}
else if(!ti->hasNoTerrainPenalty(from.getTerrainID())) //no special movement bonus
{
ret = VLC->terrainTypeHandler->getById(from.getTerrainID())->moveCost;
ret -= ti->getRoughTerrainDiscountValue();
if(ret < GameConstants::BASE_MOVEMENT_COST)
ret = GameConstants::BASE_MOVEMENT_COST;
}
return static_cast<ui32>(ret);
}
FactionID CGHeroInstance::getFactionID() const
{
return getHeroClass()->faction;

View File

@@ -218,9 +218,6 @@ public:
void setSecSkillLevel(const SecondarySkill & which, int val, bool abs); // abs == 0 - changes by value; 1 - sets to value
void levelUp(const std::vector<SecondarySkill> & skills);
/// returns base movement cost for movement between specific tiles. Does not accounts for diagonal movement or last tile exception
ui32 getTileMovementCost(const TerrainTile & dest, const TerrainTile & from, const TurnInfo * ti) const;
void setMovementPoints(int points);
int movementPointsRemaining() const;
int movementPointsLimit(bool onLand) const;