diff --git a/src/map/entities/battleentity.cpp b/src/map/entities/battleentity.cpp index acd6d9e1242..f98e6f5e8a2 100644 --- a/src/map/entities/battleentity.cpp +++ b/src/map/entities/battleentity.cpp @@ -255,27 +255,31 @@ uint8 CBattleEntity::GetSpeed() return std::clamp(outputSpeed, std::numeric_limits::min(), std::numeric_limits::max()); } - // Flee, KIs, Gear penalties, Bolters Roll. - float additiveMods = static_cast(getMod(Mod::MOVE_SPEED_STACKABLE)) / 100.0f; + // KIs, Gear penalties, Bolters Roll. + float additiveMods = static_cast(getMod(Mod::MOVE_SPEED_STACKABLE)); - // Quickening and Mazurka. Only highest applies. + // Quickening and Mazurka. Only highest applies. Additive. Mod modToUse = getMod(Mod::MOVE_SPEED_QUICKENING) > getMod(Mod::MOVE_SPEED_MAZURKA) ? Mod::MOVE_SPEED_QUICKENING : Mod::MOVE_SPEED_MAZURKA; - float effectBonus = static_cast(getMod(modToUse)) / 100.0f; + float effectAdditiveBonus = static_cast(getMod(modToUse)); - // Positive movement speed from gear. Only highest applies. - float gearBonus = 0.0f; + // Flee. + float fleeFactor = std::clamp(1.0f + static_cast(getMod(Mod::MOVE_SPEED_FLEE)) / 100.0f, 1.0f, 2.0f); + + // Positive movement speed from gear. Only highest applies. Multiplicative to base speed. + float gearBonus = 1.0f; if (objtype == TYPE_PC) { - gearBonus = static_cast(getMaxGearMod(Mod::MOVE_SPEED_GEAR_BONUS)) / 100.0f; + gearBonus = std::clamp(1.0f + static_cast(getMaxGearMod(Mod::MOVE_SPEED_GEAR_BONUS)) / 100.0f, 1.0f, 1.25f); } // Gravity and Curse. They seem additive to each other and the sum seems to be multiplicative. - float weightPenalties = static_cast(getMod(Mod::MOVE_SPEED_WEIGHT_PENALTY)) / 100.0f; + float weightPenalties = std::clamp(1.0f - static_cast(getMod(Mod::MOVE_SPEED_WEIGHT_PENALTY)) / 100.0f, 0.1f, 1.0f); // We have all the modifiers needed. Calculate final speed. - float modifiedSpeed = static_cast(baseSpeed) * std::clamp(1.0f + additiveMods + effectBonus, 0.1f, 1.6f) * (1.0f + gearBonus) * std::clamp(1.0f - weightPenalties, 0.1f, 1.0f); + // Final speed = (base speed + addtive bonuses/penalties) * flee * positive bonus from gear * weight penalties + float modifiedSpeed = static_cast(baseSpeed + additiveMods + effectAdditiveBonus) * fleeFactor * gearBonus * weightPenalties; outputSpeed = static_cast(modifiedSpeed);