Skip to content

Commit

Permalink
feat(legacy): A bit of a more realistic speed change for the Relative…
Browse files Browse the repository at this point in the history
… Smoother Rotation mode. (CCBlueX#3561)
  • Loading branch information
mems01 committed Jul 29, 2024
1 parent 2a4e9dd commit df98180
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ object Aimbot : Module("Aimbot", Category.COMBAT, hideModule = false) {
searchCenter(boundingBox,
outborder = false,
random = false,
useSpots = false,
predict = true,
lookRange = range,
attackRange = if (Reach.handleEvents()) Reach.combatReach else 3f,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
package net.ccbluex.liquidbounce.features.module.modules.combat

import net.ccbluex.liquidbounce.event.*
import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.features.module.modules.misc.AntiBot.isBot
import net.ccbluex.liquidbounce.features.module.modules.misc.Teams
import net.ccbluex.liquidbounce.features.module.modules.player.Blink
Expand Down Expand Up @@ -81,11 +81,27 @@ object Backtrack : Module("Backtrack", Category.COMBAT, hideModule = false) {
private val smart by BoolValue("Smart", true) { mode == "Modern" }

// ESP
val espMode by ListValue("ESP-Mode", arrayOf("None", "Box", "Player"), "Box", subjective = true) { mode == "Modern" }
val espMode by ListValue("ESP-Mode",
arrayOf("None", "Box", "Player"),
"Box",
subjective = true
) { mode == "Modern" }
private val rainbow by BoolValue("Rainbow", true, subjective = true) { mode == "Modern" && espMode == "Box" }
private val red by IntegerValue("R", 0, 0..255, subjective = true) { !rainbow && mode == "Modern" && espMode == "Box" }
private val green by IntegerValue("G", 255, 0..255, subjective = true) { !rainbow && mode == "Modern" && espMode == "Box" }
private val blue by IntegerValue("B", 0, 0..255, subjective = true) { !rainbow && mode == "Modern" && espMode == "Box" }
private val red by IntegerValue("R",
0,
0..255,
subjective = true
) { !rainbow && mode == "Modern" && espMode == "Box" }
private val green by IntegerValue("G",
255,
0..255,
subjective = true
) { !rainbow && mode == "Modern" && espMode == "Box" }
private val blue by IntegerValue("B",
0,
0..255,
subjective = true
) { !rainbow && mode == "Modern" && espMode == "Box" }

private val packetQueue = LinkedHashMap<Packet<*>, Long>()
private val positions = mutableListOf<Pair<Vec3, Long>>()
Expand Down Expand Up @@ -168,9 +184,15 @@ object Backtrack : Module("Backtrack", Category.COMBAT, hideModule = false) {

"modern" -> {
// Prevent cancelling packets when not needed
if (packetQueue.isEmpty() || !shouldBacktrack())
if (packetQueue.isEmpty() && !shouldBacktrack())
return

// Flush if packetQueue is not empty when not needed
if (packetQueue.isNotEmpty() && !shouldBacktrack()) {
clearPackets()
return
}

when (packet) {
// Ignore server related packets
is C00Handshake, is C00PacketServerQuery, is S02PacketChat ->
Expand Down Expand Up @@ -463,14 +485,14 @@ object Backtrack : Module("Backtrack", Category.COMBAT, hideModule = false) {
if (!packetQueue.isEmpty()) {
delayForNextBacktrack = System.currentTimeMillis() + nextBacktrackDelay
}

synchronized(packetQueue) {
if (handlePackets)
PacketUtils.queuedPackets.addAll(packetQueue.keys)

packetQueue.clear()
}

positions.clear()
shouldRender = false
ignoreWholeTick = true
Expand Down Expand Up @@ -608,8 +630,8 @@ object Backtrack : Module("Backtrack", Category.COMBAT, hideModule = false) {

fun shouldBacktrack() =
System.currentTimeMillis() >= delayForNextBacktrack && target?.let {
!it.isDead && isEnemy(it) && (mc.thePlayer?.ticksExisted ?: 0) > 20 && !ignoreWholeTick
} ?: false
isEnemy(it) && (mc.thePlayer?.ticksExisted ?: 0) > 20 && !ignoreWholeTick
} ?: false

private fun reset() {
target = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,12 @@ object KillAura : Module("KillAura", Category.COMBAT, Keyboard.KEY_R, hideModule

private val simulateShortStop by BoolValue("SimulateShortStop", false) { !noRotation }
private val randomizeRotations by BoolValue("RandomizeRotations", true) { !noRotation }
private val useSpotsToRandomize by BoolValue("UseSpotsToRandomize", false) { randomizeRotations && !noRotation }
private val outborder by BoolValue("Outborder", false) { !noRotation }

private val highestBodyPointToTargetValue: ListValue = object : ListValue("HighestBodyPointToTarget", arrayOf("Head", "Body", "Feet"), "Head") {
private val highestBodyPointToTargetValue: ListValue = object : ListValue("HighestBodyPointToTarget",
arrayOf("Head", "Body", "Feet"),
"Head"
) {
override fun isSupported() = !noRotation

override fun onChange(oldValue: String, newValue: String): String {
Expand All @@ -272,7 +274,10 @@ object KillAura : Module("KillAura", Category.COMBAT, Keyboard.KEY_R, hideModule
}
private val highestBodyPointToTarget by highestBodyPointToTargetValue

private val lowestBodyPointToTargetValue: ListValue = object : ListValue("LowestBodyPointToTarget", arrayOf("Head", "Body", "Feet"), "Feet") {
private val lowestBodyPointToTargetValue: ListValue = object : ListValue("LowestBodyPointToTarget",
arrayOf("Head", "Body", "Feet"),
"Feet"
) {
override fun isSupported() = !noRotation

override fun onChange(oldValue: String, newValue: String): String {
Expand Down Expand Up @@ -915,7 +920,6 @@ object KillAura : Module("KillAura", Category.COMBAT, Keyboard.KEY_R, hideModule
boundingBox,
outborder && !attackTimer.hasTimePassed(attackDelay / 2),
randomizeRotations,
useSpots = useSpotsToRandomize,
predict = false,
lookRange = range + scanRange,
attackRange = range,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ object TimerRange : Module("TimerRange", Category.COMBAT, hideModule = false) {

player.setPosAndPrevPos(simPlayer.pos)

val distance = searchCenter(boundingBox,
val distance = searchCenter(
boundingBox,
outborder = false,
random = false,
useSpots = false,
predict = true,
lookRange = if (timerBoostMode == "Normal") rangeValue else randomRange,
attackRange = if (Reach.handleEvents()) Reach.combatReach else 3f,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ object Scaffold : Module("Scaffold", Category.WORLD, Keyboard.KEY_I, hideModule

// Turn Speed
val startRotatingSlow by BoolValue("StartRotatingSlow", false) { rotationMode != "Off" }
val curvePitchRotation by BoolValue("CurvePitchRotation", false) { rotationMode != "Off" }
val slowDownOnDirectionChange by BoolValue("SlowDownOnDirectionChange", false) { rotationMode != "Off" }
val useStraightLinePath by BoolValue("UseStraightLinePath", true) { rotationMode != "Off" }
val maxHorizontalSpeedValue = object : FloatValue("MaxHorizontalSpeed", 180f, 1f..180f) {
Expand Down
19 changes: 3 additions & 16 deletions src/main/java/net/ccbluex/liquidbounce/utils/RotationUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import net.ccbluex.liquidbounce.utils.misc.RandomUtils.nextFloat
import net.minecraft.entity.Entity
import net.minecraft.network.play.client.C03PacketPlayer
import net.minecraft.util.*
import java.security.SecureRandom
import kotlin.math.*

object RotationUtils : MinecraftInstance(), Listenable {
Expand Down Expand Up @@ -186,7 +185,7 @@ object RotationUtils : MinecraftInstance(), Listenable {
* @return center
*/
fun searchCenter(
bb: AxisAlignedBB, outborder: Boolean, random: Boolean, useSpots: Boolean, predict: Boolean,
bb: AxisAlignedBB, outborder: Boolean, random: Boolean, predict: Boolean,
lookRange: Float, attackRange: Float, throughWallsRange: Float = 0f,
bodyPoints: List<String> = listOf("Head", "Feet"),
): Rotation? {
Expand All @@ -203,37 +202,25 @@ object RotationUtils : MinecraftInstance(), Listenable {

val eyes = mc.thePlayer.eyes

val isInsideEnemy = bb.isVecInside(eyes)

var currRotation = currentRotation ?: mc.thePlayer.rotation

var attackRotation: Pair<Rotation, Float>? = null
var lookRotation: Pair<Rotation, Float>? = null

if (random && !useSpots) {
if (random) {
currRotation += Rotation(
if (Math.random() > 0.25) nextFloat(-10f, 10f) else 0f,
if (Math.random() > 0.25) nextFloat(-10f, 10f) else 0f
)
}

val oldYawDiff = getAngleDifference(serverRotation.yaw, lastServerRotation.yaw)
val yawSign = if (oldYawDiff == 0f) 1f else oldYawDiff.sign
val chanceToRandomize = Math.random() > 0.75
val threshold = nextFloat(10f, 25f)
val signToFollow = if (Math.random() > 0.5) yawSign else -yawSign

for (x in 0.0..1.0) {
for (y in min..max) {
for (z in 0.0..1.0) {
val vec = bb.lerpWith(x, y, z)

val rotation = toRotation(vec, predict).fixedSensitivity()
val yawAngleDiff = getAngleDifference(rotation.yaw, currRotation.yaw)

if (!(!random || !useSpots || chanceToRandomize && getRotationDifference(rotation, currRotation) > threshold && yawAngleDiff.sign == signToFollow))
continue

// Calculate actual hit vec after applying fixed sensitivity to rotation
val gcdVec = bb.calculateIntercept(eyes,
eyes + getVectorForRotation(rotation) * lookRange.toDouble()
Expand Down Expand Up @@ -476,7 +463,7 @@ object RotationUtils : MinecraftInstance(), Listenable {
}

private fun computeFactor(rotationDifference: Float, turnSpeed: Float): Float {
return (rotationDifference / 180 * turnSpeed).coerceIn(0f, 180f)
return (rotationDifference / nextFloat(120f, 150f) * turnSpeed).coerceIn(0f, 180f)
}

/**
Expand Down

0 comments on commit df98180

Please sign in to comment.