diff --git a/src/map/entities/battleentity.cpp b/src/map/entities/battleentity.cpp index e48e73196a9..302dd16b795 100644 --- a/src/map/entities/battleentity.cpp +++ b/src/map/entities/battleentity.cpp @@ -256,32 +256,34 @@ uint8 CBattleEntity::GetSpeed() } // Gear penalties, Bolters Roll. - float additiveMods = static_cast(getMod(Mod::MOVE_SPEED_STACKABLE)); + uint8 additiveMods = static_cast(getMod(Mod::MOVE_SPEED_STACKABLE)); // Quickening and Mazurka. They share a cap. Additive. - float effectAdditiveBonus = std::clamp(getMod(Mod::MOVE_SPEED_QUICKENING) + getMod(Mod::MOVE_SPEED_MAZURKA), 0.0f, 10.0f); + uint8 effectAdditiveBonus = std::clamp(getMod(Mod::MOVE_SPEED_QUICKENING) + getMod(Mod::MOVE_SPEED_MAZURKA), 0, 10); // 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 and from Atmas. Only highest applies. Multiplicative to base speed. - float gearBonus = 1.0f; + float gearFactor = 1.0f; if (objtype == TYPE_PC) { - gearBonus = std::clamp(1.0f + static_cast(getMaxGearMod(Mod::MOVE_SPEED_GEAR_BONUS)) / 100.0f, 1.0f, 1.25f); + gearFactor = 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 = std::clamp(1.0f - static_cast(getMod(Mod::MOVE_SPEED_WEIGHT_PENALTY)) / 100.0f, 0.1f, 1.0f); + float weightFactor = 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. - // 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); - - // Set cap. + // This MUST BE DONE IN THIS ORDER. Using uint8 data type, we use that to floor. + outputSpeed = baseSpeed + additiveMods + effectAdditiveBonus; + outputSpeed = outputSpeed * fleeFactor; + outputSpeed = outputSpeed * gearFactor; + outputSpeed = outputSpeed * weightFactor; + // outputSpeed = outputSpeed * cheerFactor; + + // Set cap (Default 80). outputSpeed = std::clamp(outputSpeed, 0, 80 + settings::get("map.SPEED_MOD")); // Speed cap can be bypassed. Ex. Feast of swords. GM speed.