From 8231534a69e662061ac5f29772e60bd48d988188 Mon Sep 17 00:00:00 2001 From: MowFord <131182600+MowFord@users.noreply.github.com> Date: Sat, 4 May 2024 20:14:16 -0500 Subject: [PATCH] Convert map setting MOB_SPEED_MOD to percent This fixes underflow for slow mobs and negative mobspeedmod --- settings/default/map.lua | 2 +- src/map/ai/helpers/pathfind.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/settings/default/map.lua b/settings/default/map.lua index cc343bb1288..7e9b402e330 100644 --- a/settings/default/map.lua +++ b/settings/default/map.lua @@ -112,7 +112,7 @@ xi.settings.map = -- Note retail treats the mounted speed as double what it actually is. MOUNT_SPEED_MOD = 0, - -- Modifier to apply to agro'd monster speed. 0 is the retail accurate default. Negative numbers will reduce it. + -- This is an integer percentage. Modifier to apply to agro'd monster speed (i.e. while engaged in combat). 0 is the retail accurate default. Negative numbers will reduce ALL mobs's speed. MOB_SPEED_MOD = 0, -- Allows you to manipulate the constant multiplier in the skill-up rate formulas, having a potent effect on skill-up rates. diff --git a/src/map/ai/helpers/pathfind.cpp b/src/map/ai/helpers/pathfind.cpp index 8eecf7fc6ae..8d0f3515f8f 100644 --- a/src/map/ai/helpers/pathfind.cpp +++ b/src/map/ai/helpers/pathfind.cpp @@ -580,7 +580,13 @@ float CPathFind::GetRealSpeed() } else if (m_POwner->animation == ANIMATION_ATTACK) { - realSpeed = realSpeed + settings::get("map.MOB_SPEED_MOD"); + auto speedMod = settings::get("map.MOB_SPEED_MOD"); + if (speedMod < -90) + { + speedMod = -90; + } + + realSpeed *= 1.0f + speedMod / 100.0f; } }