1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-01 23:12:49 +02:00

vcmi: allow to configure army movement counter

It is not hardcoded now. MOVEMENT.TXT is still not read,
but ARMY_MOVEMENT updater parameters can be specified in json.
There is a 4 parameters:
1. Base - base value (firstly lowest speed is multiplied by it)
2. Divider - base value is integrally divided by it
3. Multiplier - result value will be multiplied by it
4. Max - maximum allowed movement from army.

Vanilla values is in defaultMods.json

Fixes: https://bugs.vcmi.eu/view.php?id=3209
This commit is contained in:
Konstantin
2023-03-11 23:09:16 +03:00
parent b91d7418dd
commit 0adffc824f
6 changed files with 70 additions and 16 deletions

View File

@@ -864,6 +864,24 @@ static TUpdaterPtr parseUpdater(const JsonNode & updaterJson)
updater->stepSize = static_cast<int>(param[1].Integer());
return updater;
}
else if (updaterJson["type"].String() == "ARMY_MOVEMENT")
{
std::shared_ptr<ArmyMovementUpdater> updater = std::make_shared<ArmyMovementUpdater>();
if(updaterJson["parameters"].isVector())
{
const auto & param = updaterJson["parameters"].Vector();
if(param.size() < 4)
logMod->warn("Invalid ARMY_MOVEMENT parameters, using default!");
else
{
updater->base = static_cast<si32>(param.at(0).Integer());
updater->divider = static_cast<si32>(param.at(1).Integer());
updater->multiplier = static_cast<si32>(param.at(2).Integer());
updater->max = static_cast<si32>(param.at(3).Integer());
}
return updater;
}
}
else
logMod->warn("Unknown updater type \"%s\"", updaterJson["type"].String());
break;