Skip to content

Commit

Permalink
NEXTGEN: Added OnClick option (with DelayUntilStop suboption) to Aimb…
Browse files Browse the repository at this point in the history
…ot and KillAura. (#2095)
  • Loading branch information
mems01 committed Feb 14, 2024
1 parent a061b4d commit 44cd78c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
Expand Up @@ -18,11 +18,13 @@
*/
package net.ccbluex.liquidbounce.features.module.modules.combat

import net.ccbluex.liquidbounce.config.ToggleableConfigurable
import net.ccbluex.liquidbounce.event.events.SimulatedTickEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.utils.aiming.*
import net.ccbluex.liquidbounce.utils.client.Chronometer
import net.ccbluex.liquidbounce.utils.combat.PriorityEnum
import net.ccbluex.liquidbounce.utils.combat.TargetTracker
import net.ccbluex.liquidbounce.utils.entity.boxedDistanceTo
Expand All @@ -38,17 +40,36 @@ object ModuleAimbot : Module("Aimbot", Category.COMBAT) {

private val range by float("Range", 4.2f, 1f..8f)

private object OnClick : ToggleableConfigurable(this, "OnClick", false) {
val delayUntilStop by int("DelayUntilStop", 3, 0..10, "ticks")
}

init {
tree(OnClick)
}

private val targetTracker = tree(TargetTracker(PriorityEnum.DIRECTION))
private val pointTracker = tree(PointTracker())
private val rotationsConfigurable = tree(RotationsConfigurable(10f..30f))

private var targetRotation: Rotation? = null

private val clickTimer = Chronometer()

override fun disable() {
targetRotation = null
}

val tickHandler = handler<SimulatedTickEvent> { _ ->
if (mc.options.attackKey.isPressed) {
clickTimer.reset()
}

if (OnClick.enabled && (clickTimer.hasElapsed(OnClick.delayUntilStop * 50L)
|| !mc.options.attackKey.isPressed && ModuleAutoClicker.enabled)) {
return@handler
}

targetRotation = findNextTargetRotation()
targetRotation?.let {
RotationManager.aimAt(
Expand Down
Expand Up @@ -41,7 +41,6 @@ import net.ccbluex.liquidbounce.utils.aiming.*
import net.ccbluex.liquidbounce.utils.client.notification
import net.ccbluex.liquidbounce.utils.combat.*
import net.ccbluex.liquidbounce.utils.entity.boxedDistanceTo
import net.ccbluex.liquidbounce.utils.entity.squaredBoxedDistanceTo
import net.ccbluex.liquidbounce.utils.entity.wouldBlockHit
import net.ccbluex.liquidbounce.utils.item.InventoryTracker
import net.ccbluex.liquidbounce.utils.item.openInventorySilently
Expand Down Expand Up @@ -94,6 +93,8 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {
// Predict
private val pointTracker = tree(PointTracker())

private val onClick by boolean("OnClick", false)

init {
tree(FightBot)
}
Expand Down Expand Up @@ -141,6 +142,9 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {
}
}

private val canTargetEnemies
get() = !onClick || mc.options.attackKey.isPressed

private var renderTarget: Entity? = null

val renderHandler = handler<WorldRenderEvent> { event ->
Expand All @@ -152,6 +156,7 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {

private fun renderTarget(matrixStack: MatrixStack, partialTicks: Float) {
val target = targetTracker.lockedOnTarget ?: return

renderEnvironmentForWorld(matrixStack) {
targetRenderer.render(this, target, partialTicks)
}
Expand All @@ -162,7 +167,9 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {
val isInInventoryScreen =
InventoryTracker.isInventoryOpenServerSide || mc.currentScreen is GenericContainerScreen

if ((isInInventoryScreen && !ignoreOpenInventory) || player.isSpectator || player.isDead) {
val shouldCleanUpTracker = player.isSpectator || player.isDead || !canTargetEnemies

if (isInInventoryScreen && !ignoreOpenInventory || shouldCleanUpTracker) {
// Cleanup current target tracker
targetTracker.cleanup()
return@handler
Expand All @@ -189,13 +196,18 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {
AutoBlock.stopBlocking()

// Deal with fake swing when there is no target
if (FailSwing.enabled) {
if (FailSwing.enabled && canTargetEnemies) {
waitTicks(AutoBlock.tickOff)
dealWithFakeSwing(null)
}
return@repeatable
}

// Check if the module should (not) continue after the blocking state is updated
if (!canTargetEnemies) {
return@repeatable
}

// Check if our target is in range, otherwise deal with auto block
if (target.boxedDistanceTo(player) > range) {
if (AutoBlock.onScanRange) {
Expand Down Expand Up @@ -253,7 +265,7 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {
ModuleDebug.debugParameter(ModuleKillAura, "Rotation", rotation)
ModuleDebug.debugParameter(ModuleKillAura, "Target", chosenEntity.nameForScoreboard)

if(!isFacingEnemy) {
if (!isFacingEnemy) {
dealWithFakeSwing(chosenEntity)
return
}
Expand Down Expand Up @@ -330,6 +342,7 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {
val situation = when {
clickScheduler.goingToClick ||
clickScheduler.isClickOnNextTick(1) -> PointTracker.AimSituation.FOR_NEXT_TICK

else -> PointTracker.AimSituation.FOR_THE_FUTURE
}
ModuleDebug.debugParameter(ModuleKillAura, "AimSituation", situation)
Expand Down

0 comments on commit 44cd78c

Please sign in to comment.