From e046f46ed2595ddff511314d159ef6a129308c29 Mon Sep 17 00:00:00 2001 From: randy Date: Mon, 18 Aug 2025 08:29:34 -0600 Subject: [PATCH] Slower melee weapons now do a minimum damage on successful hits to compensate for the lower dps. The minimum damage is 10% of the max hit for each tick below scimitar speeds (rounded down). This leads to a maximum dps increase of 10% for 5 tick weapons, 22% for 6 tick, and 40% for 7 tick. Usually less though, due to the rounding. Also added the formula to the ::calcmaxhit command so players can see the minimum hit in game. --- .../core/game/node/entity/combat/MeleeSwingHandler.kt | 9 ++++++++- .../core/game/system/command/sets/MiscCommandSet.kt | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Server/src/main/core/game/node/entity/combat/MeleeSwingHandler.kt b/Server/src/main/core/game/node/entity/combat/MeleeSwingHandler.kt index 90c30e728..c70d760f9 100644 --- a/Server/src/main/core/game/node/entity/combat/MeleeSwingHandler.kt +++ b/Server/src/main/core/game/node/entity/combat/MeleeSwingHandler.kt @@ -73,7 +73,14 @@ open class MeleeSwingHandler (vararg flags: SwingHandlerFlag) if (entity is NPC && state.armourEffect == ArmourSet.VERAC && victim.hasProtectionPrayer(CombatStyle.MELEE)) max = max * 2 / 3 } state.maximumHit = max - hit = RandomFunction.random(max + 1) + + // Snowscape: Give slower weapons a minimum damage on hit to compensate for their lower DPS + // While the exact math varies due to enemy defence, this brings the average time to kill for slow weapons closer to the scimitar + // This formula is copied to MiscCommandSet.kt for the ::calcmaxhit command. + var speedMod = (entity.getProperties().getAttackSpeed() - 4) + var min = floor(speedMod * 0.1 * max).toInt() + + hit = RandomFunction.random(min, max + 1) } state.estimatedHit = hit if(victim != null) { diff --git a/Server/src/main/core/game/system/command/sets/MiscCommandSet.kt b/Server/src/main/core/game/system/command/sets/MiscCommandSet.kt index b959495bd..f62d8e87b 100644 --- a/Server/src/main/core/game/system/command/sets/MiscCommandSet.kt +++ b/Server/src/main/core/game/system/command/sets/MiscCommandSet.kt @@ -35,6 +35,9 @@ import java.awt.HeadlessException import java.awt.Toolkit import java.awt.datatransfer.StringSelection +import core.game.node.entity.combat.CombatStyle +import kotlin.math.floor + @Initializable class MiscCommandSet : CommandSet(Privilege.ADMIN){ override fun defineCommands() { @@ -126,6 +129,13 @@ class MiscCommandSet : CommandSet(Privilege.ADMIN){ val swingHandler = player.getSwingHandler(false) val hit = swingHandler.calculateHit(player, player, 1.0) notify(player, "max hit: ${hit} (${(swingHandler as Object).getClass().getName()})") + + // Snowescape: calculate the min damage on hit for melee attacks (see MeleeSwingHandler.swing() for the custom minimum damage). + if (swingHandler.type == CombatStyle.MELEE) { + val speedMod = (player.getProperties().getAttackSpeed() - 4) + val min = floor(speedMod * 0.1 * hit).toInt() + notify(player, "min hit: ${min} (on successful hits)") + } } /**