From 98a5b95407ddba07e41e074a9fd7901223dacba9 Mon Sep 17 00:00:00 2001 From: Ceikry Date: Fri, 11 Aug 2023 01:30:58 +0000 Subject: [PATCH] Fixed combat movement regression that occurred when fighting large NPCs --- Server/src/main/content/global/skill/AttackListener.kt | 1 + .../main/core/game/interaction/InteractionListeners.kt | 8 -------- .../src/main/core/game/interaction/MovementPulse.java | 10 +++++----- .../main/core/game/node/entity/combat/CombatPulse.kt | 4 +++- Server/src/test/kotlin/content/ListenerTests.kt | 1 + 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Server/src/main/content/global/skill/AttackListener.kt b/Server/src/main/content/global/skill/AttackListener.kt index 78b21386f..cba5a7e0e 100644 --- a/Server/src/main/content/global/skill/AttackListener.kt +++ b/Server/src/main/content/global/skill/AttackListener.kt @@ -6,6 +6,7 @@ import core.game.interaction.IntType class AttackListener : InteractionListener { override fun defineListeners() { + flagInstant() on(IntType.NPC, "attack"){ player, npc -> //Makes sure player uses correct attack styles for lumbridge dummies if (npc.id == 4474 && player.getSwingHandler(false).type != CombatStyle.MAGIC) { diff --git a/Server/src/main/core/game/interaction/InteractionListeners.kt b/Server/src/main/core/game/interaction/InteractionListeners.kt index c85e0a61b..1527942c1 100644 --- a/Server/src/main/core/game/interaction/InteractionListeners.kt +++ b/Server/src/main/core/game/interaction/InteractionListeners.kt @@ -255,14 +255,6 @@ object InteractionListeners { val destOverride = getOverride(type.ordinal, id, option) ?: getOverride(type.ordinal,node.id) ?: getOverride(type.ordinal,option.toLowerCase()) - - if(option.toLowerCase() == "attack") //Attack needs special handling >.> - { - player.dispatch(InteractionEvent(node, option.toLowerCase())) - method.invoke(player, node) - return true - } - if(type != IntType.ITEM && !isInstant(method)) { if(player.locks.isMovementLocked) return false player.pulseManager.run(object : MovementPulse(player, node, flag, destOverride) { diff --git a/Server/src/main/core/game/interaction/MovementPulse.java b/Server/src/main/core/game/interaction/MovementPulse.java index 1cb0bd664..3339645da 100644 --- a/Server/src/main/core/game/interaction/MovementPulse.java +++ b/Server/src/main/core/game/interaction/MovementPulse.java @@ -286,7 +286,7 @@ public abstract class MovementPulse extends Pulse { else if (loc == destination.getLocation()) loc = null; } - if (destination instanceof NPC) + if (destination instanceof NPC && mover.getProperties().getCombatPulse().getVictim() != destination) loc = checkForEntityPathInterrupt(loc != null ? loc : destination.getLocation()); if (interactLocation == null) @@ -335,10 +335,10 @@ public abstract class MovementPulse extends Pulse { previousLoc = loc; } last = destination.getLocation(); - if (mover instanceof Player && mover.getAttribute("draw-intersect", false)) { - clearHintIcon((Player) mover); - registerHintIcon((Player) mover, interactLocation, 5); - } + if (mover instanceof Player && mover.getAttribute("draw-intersect", false)) { + clearHintIcon((Player) mover); + registerHintIcon((Player) mover, interactLocation, 5); + } } private boolean checkAllowMovement() { 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 99078ad34..dc9101134 100644 --- a/Server/src/main/core/game/node/entity/combat/CombatPulse.kt +++ b/Server/src/main/core/game/node/entity/combat/CombatPulse.kt @@ -17,6 +17,7 @@ import core.game.world.GameWorld import core.game.world.update.flag.context.Animation import core.tools.RandomFunction import core.api.* +import core.game.interaction.DestinationFlag import core.game.system.timer.impl.* /** @@ -352,6 +353,7 @@ class CombatPulse( override fun start() { super.start() entity!!.face(victim) + entity.walkingQueue.reset() } override fun stop() { @@ -466,7 +468,7 @@ class CombatPulse( } init { - movement = object : MovementPulse(entity, null) { + movement = object : MovementPulse(entity, null, DestinationFlag.ENTITY) { override fun pulse(): Boolean { return false } diff --git a/Server/src/test/kotlin/content/ListenerTests.kt b/Server/src/test/kotlin/content/ListenerTests.kt index e7709522d..b6316eda5 100644 --- a/Server/src/test/kotlin/content/ListenerTests.kt +++ b/Server/src/test/kotlin/content/ListenerTests.kt @@ -9,6 +9,7 @@ import core.game.interaction.IntType import core.game.interaction.InteractionListeners class ListenerTests : InteractionListener { + init {TestUtils.preTestSetup()} @Test fun doubleDefinedListenerShouldThrowIllegalStateException() { on(0, IntType.ITEM, "touch") { _, _ -> return@on true} Assertions.assertThrows(IllegalStateException::class.java) {