mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-28 05:45:10 -06:00
Small fixes
This commit is contained in:
parent
5857cba851
commit
b09d82d5cc
5 changed files with 14 additions and 81 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue