From b09d82d5cc1ca45f04d73dc0d529d1c4a6b9915d Mon Sep 17 00:00:00 2001 From: dam <27978131-real_damighty@users.noreply.gitlab.com> Date: Tue, 23 Jun 2026 21:18:59 +0300 Subject: [PATCH] Small fixes --- .../entity/combat/CombatMovementPlanner.kt | 3 - .../game/node/entity/combat/CombatPulse.kt | 15 ++--- .../game/node/entity/combat/CombatReach.kt | 63 +++---------------- .../node/entity/combat/MeleeSwingHandler.kt | 1 - .../src/main/core/worker/MajorUpdateWorker.kt | 13 +--- 5 files changed, 14 insertions(+), 81 deletions(-) diff --git a/Server/src/main/core/game/node/entity/combat/CombatMovementPlanner.kt b/Server/src/main/core/game/node/entity/combat/CombatMovementPlanner.kt index 29cedfeab..a29b03438 100644 --- a/Server/src/main/core/game/node/entity/combat/CombatMovementPlanner.kt +++ b/Server/src/main/core/game/node/entity/combat/CombatMovementPlanner.kt @@ -70,9 +70,6 @@ object CombatMovementPlanner { } val firstPoint = first ?: return emptyList() val steps = movementStepsThisTick(target, firstPoint, second).coerceAtMost(maxSteps) - if (steps <= 0) { - return emptyList() - } val predicted = ArrayList(steps) predicted.add(Location.create(firstPoint.x, firstPoint.y, target.location.z)) if (steps > 1 && second != null) { diff --git a/Server/src/main/core/game/node/entity/combat/CombatPulse.kt b/Server/src/main/core/game/node/entity/combat/CombatPulse.kt index e9dce99dd..ab8889466 100644 --- a/Server/src/main/core/game/node/entity/combat/CombatPulse.kt +++ b/Server/src/main/core/game/node/entity/combat/CombatPulse.kt @@ -221,7 +221,9 @@ class CombatPulse( } val type = canInteract() if (type == InteractionType.STILL_INTERACT) { - if (shouldMaintainMeleePressure()) { + if (style == CombatStyle.MELEE && !attacker.locks.isMovementLocked && + CombatMovementIntents.shouldMaintainMeleePressure(attacker, target) + ) { CombatMovementIntents.request(attacker, target) } return true @@ -233,15 +235,6 @@ class CombatPulse( return type == InteractionType.MOVE_INTERACT } - private fun shouldMaintainMeleePressure(): Boolean { - val attacker = entity ?: return false - val target = victim ?: return false - if (style != CombatStyle.MELEE || attacker.locks.isMovementLocked) { - return false - } - return CombatMovementIntents.shouldMaintainMeleePressure(attacker, target) - } - /** * Sets the combat style. */ @@ -323,7 +316,7 @@ class CombatPulse( if (!isAttacking) entity.pulseManager.run(this) - if (victim is Entity && style == CombatStyle.MELEE) { + if (style == CombatStyle.MELEE) { CombatMovementIntents.trackActiveMelee(entity, victim) } } diff --git a/Server/src/main/core/game/node/entity/combat/CombatReach.kt b/Server/src/main/core/game/node/entity/combat/CombatReach.kt index 76191b5d5..65891b95d 100644 --- a/Server/src/main/core/game/node/entity/combat/CombatReach.kt +++ b/Server/src/main/core/game/node/entity/combat/CombatReach.kt @@ -46,63 +46,14 @@ object CombatReach { val y = victim.location.y val size = entity.size() if (distance == 1) { + val victimSize = victim.size() + fun adjacent(ex: Int, ey: Int): Boolean = + Pathfinder.isStandingIn(ex, ey, 1, 1, x, y, victimSize, victimSize) for (i in 0 until size) { - if ( - Pathfinder.isStandingIn( - e.x - 1, - e.y + i, - 1, - 1, - x, - y, - victim.size(), - victim.size(), - ) - ) { - return true - } - if ( - Pathfinder.isStandingIn( - e.x + size, - e.y + i, - 1, - 1, - x, - y, - victim.size(), - victim.size(), - ) - ) { - return true - } - if ( - Pathfinder.isStandingIn( - e.x + i, - e.y - 1, - 1, - 1, - x, - y, - victim.size(), - victim.size(), - ) - ) { - return true - } - if ( - Pathfinder.isStandingIn( - e.x + i, - e.y + size, - 1, - 1, - x, - y, - victim.size(), - victim.size(), - ) - ) { - return true - } + if (adjacent(e.x - 1, e.y + i)) return true + if (adjacent(e.x + size, e.y + i)) return true + if (adjacent(e.x + i, e.y - 1)) return true + if (adjacent(e.x + i, e.y + size)) return true } return victim.getSwingHandler(false).type == CombatStyle.MELEE && e.withinDistance( 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 ded768d6b..b0455a28b 100644 --- a/Server/src/main/core/game/node/entity/combat/MeleeSwingHandler.kt +++ b/Server/src/main/core/game/node/entity/combat/MeleeSwingHandler.kt @@ -20,7 +20,6 @@ import core.game.world.map.Location import core.game.world.map.RegionManager import core.game.world.map.path.RsmodPathfinder import org.rs09.consts.Items -import org.rs09.consts.NPCs import kotlin.math.floor /** diff --git a/Server/src/main/core/worker/MajorUpdateWorker.kt b/Server/src/main/core/worker/MajorUpdateWorker.kt index b38415e3a..e9e43ba23 100644 --- a/Server/src/main/core/worker/MajorUpdateWorker.kt +++ b/Server/src/main/core/worker/MajorUpdateWorker.kt @@ -21,6 +21,7 @@ import java.lang.Long.max import java.text.SimpleDateFormat import java.util.* import kotlin.system.exitProcess +import kotlin.system.measureTimeMillis /** * Handles the running of pulses and writing of masks, etc @@ -119,10 +120,10 @@ class MajorUpdateWorker { GameWorld.Pulser.updateAll() } GameWorld.tickListeners.forEach { it.tick() } - val meleePressureTime = measureMillis { + val meleePressureTime = measureTimeMillis { CombatMovementIntents.requestActiveMeleePressure() } - val movementResolveTime = measureMillis { + val movementResolveTime = measureTimeMillis { CombatMovementIntents.resolve() } notifyIfCombatMovementTooLong(meleePressureTime, movementResolveTime) @@ -146,14 +147,6 @@ class MajorUpdateWorker { } } - private fun measureMillis(logic: () -> Unit): Long { - val startTime = System.currentTimeMillis() - - logic() - - return System.currentTimeMillis() - startTime - } - private fun notifyIfCombatMovementTooLong(meleePressureTime: Long, movementResolveTime: Long) { val totalTime = meleePressureTime + movementResolveTime val resolveSummary = CombatMovementIntents.lastResolveSummary()