Skip to content

Commit

Permalink
feat(legacy): slightly improved tickbase (#3869)
Browse files Browse the repository at this point in the history
  • Loading branch information
EclipsesDev authored Sep 3, 2024
1 parent 9f77326 commit 9195452
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,16 @@ object TickBase : Module("TickBase", Category.COMBAT) {

if (event.state == EventState.POST && !duringTickModification && tickBuffer.isNotEmpty()) {
val nearbyEnemy = getNearestEntityInRange() ?: return
val currentDistance = player.positionVector.squareDistanceTo(nearbyEnemy.positionVector)
val currentDistance = player.positionVector.distanceTo(nearbyEnemy.positionVector)

val possibleTicks = tickBuffer
.mapIndexed { index, tick -> index to tick }
.filter { (_, tick) ->
tick.position.distanceTo(nearbyEnemy.positionVector) < currentDistance &&
tick.position.distanceTo(nearbyEnemy.positionVector) in minRangeToAttack.get()..maxRangeToAttack.get()
val tickDistance = tick.position.distanceTo(nearbyEnemy.positionVector)

tickDistance < currentDistance && tickDistance in minRangeToAttack.get().. maxRangeToAttack.get()
}
.filter { (_, tick) -> !tick.isCollidedHorizontally }
.filter { (_, tick) -> !forceGround || tick.onGround }

val criticalTick = possibleTicks
Expand All @@ -128,6 +130,7 @@ object TickBase : Module("TickBase", Category.COMBAT) {
if (bestTick == 0) return

if (RandomUtils.nextInt(endExclusive = 100) > change || (onlyOnKillAura && (!KillAura.state || KillAura.target == null))) {
ticksToSkip = 0
return
}

Expand Down Expand Up @@ -222,7 +225,8 @@ object TickBase : Module("TickBase", Category.COMBAT) {
simulatedPlayer.motionX,
simulatedPlayer.motionY,
simulatedPlayer.motionZ,
simulatedPlayer.onGround
simulatedPlayer.onGround,
simulatedPlayer.isCollidedHorizontally
)
}
}
Expand Down Expand Up @@ -290,6 +294,7 @@ object TickBase : Module("TickBase", Category.COMBAT) {
val motionY: Double,
val motionZ: Double,
val onGround: Boolean,
val isCollidedHorizontally: Boolean,
)

private fun getNearestEntityInRange(): EntityLivingBase? {
Expand Down

0 comments on commit 9195452

Please sign in to comment.