Small fixes

This commit is contained in:
dam 2026-06-23 21:18:59 +03:00
parent 5857cba851
commit b09d82d5cc
No known key found for this signature in database
GPG key ID: 4AF4E722399663FB
5 changed files with 14 additions and 81 deletions

View file

@ -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<Location>(steps)
predicted.add(Location.create(firstPoint.x, firstPoint.y, target.location.z))
if (steps > 1 && second != null) {

View file

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

View file

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

View file

@ -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
/**

View file

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