1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +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

@@ -188,19 +188,17 @@ int CGHeroInstance::maxMovePoints(bool onLand) const
return maxMovePointsCached(onLand, &ti);
}
int CGHeroInstance::getArmyMovementBonus() const
int CGHeroInstance::getLowestCreatureSpeed() const
{
return armyMovementVal;
return lowestCreatureSpeed;
}
void CGHeroInstance::updateArmyMovementBonus(bool onLand, const TurnInfo * ti) const
{
int armySpeed = lowestSpeed(this) * 20 / 3;
auto base = armySpeed * 10; // separate *10 is intentional to receive same rounding as in h3
if(armyMovementVal != vstd::abetween(base, 200, 700)) // army modifier speed is limited by these values
auto realLowestSpeed = lowestSpeed(this);
if(lowestCreatureSpeed != realLowestSpeed)
{
armyMovementVal = base;
lowestCreatureSpeed = realLowestSpeed;
ti->updateHeroBonuses(Bonus::MOVEMENT, Selector::subtype()(!!onLand).And(Selector::sourceTypeSel(Bonus::ARMY)));
}
}
@@ -208,7 +206,7 @@ void CGHeroInstance::updateArmyMovementBonus(bool onLand, const TurnInfo * ti) c
int CGHeroInstance::maxMovePointsCached(bool onLand, const TurnInfo * ti) const
{
updateArmyMovementBonus(onLand, ti);
return ti->valOfBonuses(Bonus::MOVEMENT, !!onLand);;
return ti->valOfBonuses(Bonus::MOVEMENT, !!onLand);
}
CGHeroInstance::CGHeroInstance():
@@ -222,7 +220,7 @@ CGHeroInstance::CGHeroInstance():
level(1),
exp(UNINITIALIZED_EXPERIENCE),
sex(std::numeric_limits<ui8>::max()),
armyMovementVal(0)
lowestCreatureSpeed(0)
{
setNodeType(HERO);
ID = Obj::HERO;