Skip to content

Commit

Permalink
added aimmode option to KillAura
Browse files Browse the repository at this point in the history
AimMode:
- Normal
- Flick
- OnTick
  • Loading branch information
1zun4 committed Jan 14, 2024
1 parent e7022ac commit 9bffaca
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 37 deletions.
5 changes: 2 additions & 3 deletions config/detekt/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<CurrentIssues>
<ID>ComplexCondition:ModuleAutoWeapon.kt$ModuleAutoWeapon$stack.isNothing() || (!player.isCreative &amp;&amp; stack.damage >= (stack.maxDamage - 2) &amp;&amp; ignoreDurability) || (stack.getEnchantment( KNOCKBACK ) != 0 &amp;&amp; ignoreKnockback)</ID>
<ID>ComplexCondition:ModuleBlink.kt$ModuleBlink$packet is PlayerMoveC2SPacket || packet is PlayerInteractBlockC2SPacket || packet is HandSwingC2SPacket || packet is PlayerActionC2SPacket || packet is PlayerInteractEntityC2SPacket</ID>
<ID>ComplexCondition:ModuleRegen.kt$ModuleRegen$(!noAir &amp;&amp; player.isOnGround) &amp;&amp; !player.abilities.creativeMode &amp;&amp; player.health > 0 &amp;&amp; player.health &lt; health</ID>
<ID>ComplexCondition:ModuleTrajectories.kt$ModuleTrajectories$!it.isSpectator &amp;&amp; it.isAlive &amp;&amp; (it.canHit() || player != mc.player &amp;&amp; it == mc.player)</ID>
<ID>ComplexCondition:ModuleVelocity.kt$ModuleVelocity$(packet is EntityVelocityUpdateS2CPacket &amp;&amp; packet.id == player.id || packet is ExplosionS2CPacket) &amp;&amp; it.original &amp;&amp; Delayed.enabled</ID>
<ID>ComplexCondition:SimulatedArrow.kt$SimulatedArrow$!it.isSpectator &amp;&amp; it.isAlive &amp;&amp; (it.canHit() || arrowEntity != mc.player &amp;&amp; it == arrowEntity)</ID>
Expand All @@ -15,12 +14,13 @@
<ID>CyclomaticComplexMethod:FallingPlayer.kt$FallingPlayer$fun findCollision(ticks: Int): CollisionResult?</ID>
<ID>CyclomaticComplexMethod:FontRenderer.kt$FontRenderer$override fun getStringWidth( text: String, shadow: Boolean ): Float</ID>
<ID>CyclomaticComplexMethod:FontRenderer.kt$FontRenderer$private fun drawInternal( text: String, x0: Float, y0: Float, defaultColor: Color4b, shadow: Boolean, obfuscatedSeed: Long, z: Float, scale: Float ): Float</ID>
<ID>CyclomaticComplexMethod:ModuleKillAura.kt$ModuleKillAura$internal suspend fun Sequence&lt;*>.prepareAttackEnvironment(rotation: Rotation? = null, attack: () -> Unit)</ID>
<ID>CyclomaticComplexMethod:ModuleKillAura.kt$ModuleKillAura$private fun updateEnemySelection()</ID>
<ID>CyclomaticComplexMethod:ModuleTrajectories.kt$ModuleTrajectories$private fun drawTrajectoryForProjectile( motion: Vec3d, trajectoryInfo: TrajectoryInfo, pos: Vec3d, player: Entity, interpolatedOffset: Vec3, color: Color4b, matrixStack: MatrixStack ): HitResult?</ID>
<ID>CyclomaticComplexMethod:RotationsUtil.kt$RotationManager$fun update()</ID>
<ID>CyclomaticComplexMethod:Value.kt$Value$open fun setByString(string: String)</ID>
<ID>DestructuringDeclarationWithTooManyEntries:ModuleAimbot.kt$ModuleAimbot$val (fromPoint, toPoint, box, cutOffBox) = pointTracker.gatherPoint(target, true)</ID>
<ID>DestructuringDeclarationWithTooManyEntries:ModuleKillAura.kt$ModuleKillAura$val (eyes, nextPoint, box, cutOffBox) = pointTracker.gatherPoint( target, clickScheduler.isClickOnNextTick(1) )</ID>
<ID>DestructuringDeclarationWithTooManyEntries:ModuleKillAura.kt$ModuleKillAura$val (eyes, nextPoint, box, cutOffBox) = pointTracker.gatherPoint( entity, clickScheduler.goingToClick || clickScheduler.isClickOnNextTick(1) )</ID>
<ID>EmptyCatchBlock:ModuleMobOwners.kt$ModuleMobOwners${ }</ID>
<ID>EmptyFunctionBlock:ModuleDisabler.kt$ModuleDisabler.VulcanMovement${ }</ID>
<ID>EmptyFunctionBlock:ModuleStorageESP.kt$ModuleStorageESP.StorageScanner${}</ID>
Expand Down Expand Up @@ -96,7 +96,6 @@
<ID>MaxLineLength:ModuleNameProtect.kt$ModuleNameProtect.NameProtectOrderedText$if</ID>
<ID>MaxLineLength:ModuleNameProtect.kt$ModuleNameProtect.NameProtectOrderedText$originalChar.style</ID>
<ID>MaxLineLength:ModuleNoWeb.kt$ModuleNoWeb$notification("Compatibility error", "NoWeb is incompatible with AvoidHazards", NotificationEvent.Severity.ERROR)</ID>
<ID>MaxLineLength:ModuleRegen.kt$ModuleRegen$if</ID>
<ID>MaxLineLength:ModuleScaffold.kt$ModuleScaffold$if (AdvancedRotation.enabled) AdvancedRotation.xRange.toDouble() else AdvancedRotation.DEFAULT_XZ_RANGE.toDouble()</ID>
<ID>MaxLineLength:ModuleScaffold.kt$ModuleScaffold$if (AdvancedRotation.enabled) AdvancedRotation.yRange.toDouble() else AdvancedRotation.DEFAULT_Y_RANGE.toDouble()</ID>
<ID>MaxLineLength:ModuleScaffold.kt$ModuleScaffold$if (AdvancedRotation.enabled) AdvancedRotation.zRange.toDouble() else AdvancedRotation.DEFAULT_XZ_RANGE.toDouble()</ID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import net.ccbluex.liquidbounce.features.module.modules.combat.killaura.features
import net.ccbluex.liquidbounce.features.module.modules.combat.killaura.features.NotifyWhenFail.renderFailedHits
import net.ccbluex.liquidbounce.render.renderEnvironmentForWorld
import net.ccbluex.liquidbounce.utils.aiming.*
import net.ccbluex.liquidbounce.utils.client.chat
import net.ccbluex.liquidbounce.utils.combat.*
import net.ccbluex.liquidbounce.utils.entity.boxedDistanceTo
import net.ccbluex.liquidbounce.utils.entity.squaredBoxedDistanceTo
Expand All @@ -47,12 +46,14 @@ import net.ccbluex.liquidbounce.utils.render.WorldTargetRenderer
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.entity.Entity
import net.minecraft.entity.LivingEntity
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.AxeItem
import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket
import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket
import net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket.Full
import net.minecraft.util.Hand
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
Expand Down Expand Up @@ -86,7 +87,7 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {

// Rotation
private val rotations = tree(RotationsConfigurable(40f..60f))
private val flick by boolean("Flick", false)
private val aimMode by enumChoice("AimMode", AimMode.NORMAL, AimMode.values())

// Target rendering
private val targetRenderer = tree(WorldTargetRenderer(this))
Expand Down Expand Up @@ -173,7 +174,7 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {
return@repeatable
}

if (target == null) {
if (target == null || target !is LivingEntity) {
AutoBlock.stopBlocking()

// Deal with fake swing when there is no target
Expand Down Expand Up @@ -202,7 +203,18 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {
}

// Determine if we should attack the target or someone else
val rotation = RotationManager.serverRotation
val rotation = if (aimMode == AimMode.ON_TICK) {
val rangeSquared = range * range
val scanRange = if (targetTracker.maxDistanceSquared > rangeSquared) {
((range + scanExtraRange) * (range + scanExtraRange)).toDouble()
} else {
rangeSquared.toDouble()
}

getSpot(target, scanRange)?.rotation ?: RotationManager.serverRotation
} else {
RotationManager.serverRotation
}
val chosenEntity: Entity

if (raycast != TRACE_NONE) {
Expand All @@ -223,25 +235,23 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {
chosenEntity = target
}

// Are we actually facing the choosen entity?
if (!facingEnemy(
toEntity = chosenEntity, rotation = rotation, range = range.toDouble(),
wallsRange = wallRange.toDouble()
)
) {
mightAttack(chosenEntity, rotation)
}

private suspend fun Sequence<*>.mightAttack(chosenEntity: Entity, rotation: Rotation) {
// Are we actually facing the [chosenEntity]
if (aimMode != AimMode.ON_TICK && !facingEnemy(toEntity = chosenEntity, rotation = rotation,
range = range.toDouble(),
wallsRange = wallRange.toDouble())) {
dealWithFakeSwing(chosenEntity)
return@repeatable
return
}

mightAttack(chosenEntity)
}

private suspend fun Sequence<*>.mightAttack(chosenEntity: Entity) {
// Attack enemy according to the attack scheduler
if (clickScheduler.goingToClick && checkIfReadyToAttack(chosenEntity)) {
AutoBlock.makeSeemBlock()

prepareAttackEnvironment {
prepareAttackEnvironment(rotation) {
clickScheduler.clicks {
// On each click, we check if we are still ready to attack
if (!checkIfReadyToAttack(chosenEntity)) {
Expand Down Expand Up @@ -297,20 +307,7 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {
continue
}

val (eyes, nextPoint, box, cutOffBox) = pointTracker.gatherPoint(
target,
clickScheduler.isClickOnNextTick(1)
)
val rotationPreference = LeastDifferencePreference(RotationManager.serverRotation, nextPoint)

// find best spot
val spot = raytraceBox(
eyes, cutOffBox, range = sqrt(scanRange),
wallsRange = wallRange.toDouble(), rotationPreference = rotationPreference
) ?: raytraceBox(
eyes, box, range = sqrt(scanRange),
wallsRange = wallRange.toDouble(), rotationPreference = rotationPreference
) ?: continue
val spot = getSpot(target, scanRange) ?: continue

renderTarget = target

Expand All @@ -319,7 +316,12 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {

// aim at target
val ticks = rotations.howLongItTakes(spot.rotation)
if (flick && !clickScheduler.isClickOnNextTick(ticks.coerceAtLeast(1))) {
if (aimMode == AimMode.FLICK && !clickScheduler.isClickOnNextTick(ticks.coerceAtLeast(1))) {
break
}

// On Tick can only be used if the distance is not too far compared to the turn speed
if (aimMode == AimMode.ON_TICK && ticks <= 1) {
break
}

Expand Down Expand Up @@ -347,6 +349,25 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {
}
}

private fun getSpot(entity: LivingEntity, scanRange: Double): VecRotation? {
val (eyes, nextPoint, box, cutOffBox) = pointTracker.gatherPoint(
entity,
clickScheduler.goingToClick || clickScheduler.isClickOnNextTick(1)
)
val rotationPreference = LeastDifferencePreference(RotationManager.serverRotation, nextPoint)

// find best spot
val spot = raytraceBox(
eyes, cutOffBox, range = sqrt(scanRange),
wallsRange = wallRange.toDouble(), rotationPreference = rotationPreference
) ?: raytraceBox(
eyes, box, range = sqrt(scanRange),
wallsRange = wallRange.toDouble(), rotationPreference = rotationPreference
) ?: return null

return spot
}

private fun checkIfReadyToAttack(choosenEntity: Entity): Boolean {
val critical = !ModuleCriticals.shouldWaitForCrit() || choosenEntity.velocity.lengthSquared() > 0.25 * 0.25
val shielding = attackShielding || choosenEntity !is PlayerEntity || player.mainHandStack.item is AxeItem ||
Expand All @@ -364,7 +385,7 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {
* This means, we make sure we are not blocking, we are not using another item,
* and we are not in an inventory screen depending on the configuration.
*/
internal suspend fun Sequence<*>.prepareAttackEnvironment(attack: () -> Unit) {
internal suspend fun Sequence<*>.prepareAttackEnvironment(rotation: Rotation? = null, attack: () -> Unit) {
val isInInventoryScreen =
InventoryTracker.isInventoryOpenServerSide || mc.currentScreen is GenericContainerScreen

Expand All @@ -391,8 +412,16 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {
return // return if it's not allowed to attack while the player is using another item that's not a shield
}

if (aimMode == AimMode.ON_TICK && rotation != null) {
network.sendPacket(Full(player.x, player.y, player.z, rotation.yaw, rotation.pitch, player.isOnGround))
}

attack()

if (aimMode == AimMode.ON_TICK && rotation != null) {
network.sendPacket(Full(player.x, player.y, player.z, player.yaw, player.pitch, player.isOnGround))
}

if (simulateInventoryClosing && isInInventoryScreen) {
openInventorySilently()
}
Expand All @@ -408,6 +437,10 @@ object ModuleKillAura : Module("KillAura", Category.COMBAT) {
}
}

enum class AimMode(override val choiceName: String) : NamedChoice {
NORMAL("Normal"), FLICK("Flick"), ON_TICK("OnTick")
}

enum class RaycastMode(override val choiceName: String) : NamedChoice {
TRACE_NONE("None"), TRACE_ONLYENEMY("Enemy"), TRACE_ALL("All")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import net.ccbluex.liquidbounce.event.Listenable
import net.ccbluex.liquidbounce.event.events.MovementInputEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.utils.client.mc
import net.ccbluex.liquidbounce.utils.client.player
import net.ccbluex.liquidbounce.utils.entity.SimulatedPlayer
import net.ccbluex.liquidbounce.utils.entity.box
import net.ccbluex.liquidbounce.utils.entity.eyes
Expand Down Expand Up @@ -146,8 +147,6 @@ class PointTracker : Configurable("PointTracker"), Listenable {
* @param entity The entity we want to track.
*/
fun gatherPoint(entity: LivingEntity, requiredOnTick: Boolean): Point {
val player = mc.player!!

// Predicted target position of the enemy
val targetPrediction = entity.pos.subtract(entity.prevPos)
.multiply(BASE_PREDICT + timeEnemyOffset.toDouble())
Expand Down

0 comments on commit 9bffaca

Please sign in to comment.