Fixed combat movement regression that occurred when fighting large NPCs

This commit is contained in:
Ceikry 2023-08-11 01:30:58 +00:00 committed by Ryan
parent 6a3e91f13c
commit 98a5b95407
5 changed files with 10 additions and 14 deletions

View file

@ -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) {

View file

@ -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) {

View file

@ -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() {

View file

@ -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
}

View file

@ -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) {