mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user