Skip to content

Commit

Permalink
LEGACY: Super-KB WTap Improvement (CCBlueX#2683)
Browse files Browse the repository at this point in the history
Added targetDistance option, if the distance to enemy is less than the value set in targetDistance, the user will remain unsprinted. This should help user to combo enemy.
  • Loading branch information
EclipsesDev committed Mar 31, 2024
1 parent 6316b0c commit 58ee287
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import net.ccbluex.liquidbounce.features.module.ModuleCategory
import net.ccbluex.liquidbounce.utils.MovementUtils.isMoving
import net.ccbluex.liquidbounce.utils.PacketUtils.sendPacket
import net.ccbluex.liquidbounce.utils.PacketUtils.sendPackets
import net.ccbluex.liquidbounce.utils.extensions.getDistanceToEntityBox
import net.ccbluex.liquidbounce.utils.extensions.stopXZ
import net.ccbluex.liquidbounce.utils.timing.MSTimer
import net.ccbluex.liquidbounce.utils.timing.TimeUtils.randomDelay
Expand All @@ -21,6 +22,7 @@ import net.minecraft.entity.EntityLivingBase
import net.minecraft.network.play.client.C03PacketPlayer
import net.minecraft.network.play.client.C0BPacketEntityAction
import net.minecraft.network.play.client.C0BPacketEntityAction.Action.*
import kotlin.math.abs

object SuperKnockback : Module("SuperKnockback", ModuleCategory.COMBAT) {

Expand Down Expand Up @@ -50,6 +52,8 @@ object SuperKnockback : Module("SuperKnockback", ModuleCategory.COMBAT) {
override fun onChange(oldValue: Int, newValue: Int) = newValue.coerceAtMost(reSprintMaxTicks.get())
}

private val targetDistance by IntegerValue("TargetDistance", 3, 1..5) { mode == "WTap" }

private val stopTicks: IntegerValue = object : IntegerValue("PressBackTicks", 1, 1..5) {
override fun isSupported() = mode == "SprintTap2"

Expand Down Expand Up @@ -92,8 +96,8 @@ object SuperKnockback : Module("SuperKnockback", ModuleCategory.COMBAT) {
@EventTarget
fun onAttack(event: AttackEvent) {
val player = mc.thePlayer ?: return

if (event.targetEntity !is EntityLivingBase) return
val target = event.targetEntity as? EntityLivingBase ?: return
val distance = player.getDistanceToEntityBox(target)

if (event.targetEntity.hurtTime > hurtTime || !timer.hasTimePassed(delay) || (onlyGround && !player.onGround)) return

Expand Down Expand Up @@ -137,15 +141,17 @@ object SuperKnockback : Module("SuperKnockback", ModuleCategory.COMBAT) {
"WTap" -> {
// We want the player to be sprinting before we block inputs
if (player.isSprinting && player.serverSprintState && !blockInput && !startWaiting) {
blockInputTicks = randomDelay(minTicksUntilBlock.get(), maxTicksUntilBlock.get())
val delayMultiplier = 1.0 / (abs(targetDistance - distance) + 1)

blockInputTicks = (randomDelay(minTicksUntilBlock.get(), maxTicksUntilBlock.get()) * delayMultiplier).toInt()

blockInput = blockInputTicks == 0

if (!blockInput) {
startWaiting = true
}

allowInputTicks = randomDelay(reSprintMinTicks.get(), reSprintMaxTicks.get())
allowInputTicks = (randomDelay(reSprintMinTicks.get(), reSprintMaxTicks.get()) * delayMultiplier).toInt()
}
}

Expand Down

0 comments on commit 58ee287

Please sign in to comment.