@@ -25,8 +25,6 @@ import com.lambda.event.events.RotationEvent
2525import com.lambda.event.events.TickEvent
2626import com.lambda.event.listener.SafeListener.Companion.listen
2727import com.lambda.graphics.renderer.esp.builders.buildFilled
28- import com.lambda.graphics.renderer.esp.builders.buildLine
29- import com.lambda.graphics.renderer.esp.global.StaticESP
3028import com.lambda.interaction.request.rotation.Rotation
3129import com.lambda.interaction.request.rotation.Rotation.Companion.rotationTo
3230import com.lambda.interaction.request.rotation.RotationManager.onRotate
@@ -36,6 +34,7 @@ import com.lambda.module.tag.ModuleTag
3634import com.lambda.pathing.Path
3735import com.lambda.pathing.Pathing.findPathAStar
3836import com.lambda.pathing.Pathing.thetaStarClearance
37+ import com.lambda.pathing.PathingConfig
3938import com.lambda.pathing.PathingSettings
4039import com.lambda.pathing.goal.SimpleGoal
4140import com.lambda.threading.runConcurrent
@@ -44,7 +43,6 @@ import com.lambda.util.Formatting.string
4443import com.lambda.util.math.setAlpha
4544import com.lambda.util.player.MovementUtils.buildMovementInput
4645import com.lambda.util.player.MovementUtils.mergeFrom
47- import com.lambda.util.world.WorldUtils.isPathClear
4846import com.lambda.util.world.fastVectorOf
4947import com.lambda.util.world.toBlockPos
5048import com.lambda.util.world.toFastVec
@@ -69,8 +67,8 @@ object Pathfinder : Module(
6967 private val rotation = RotationSettings (this ) { page == Page .Rotation }
7068
7169 private val target = fastVectorOf(0 , 91 , - 4 )
72- private var longPath = Path ()
73- private var shortPath = Path ()
70+ private var coarsePath = Path ()
71+ private var refinedPath = Path ()
7472 private var currentTarget: Vec3d ? = null
7573 private var integralError = Vec3d .ZERO
7674 private var lastError = Vec3d .ZERO
@@ -81,8 +79,8 @@ object Pathfinder : Module(
8179 integralError = Vec3d .ZERO
8280 lastError = Vec3d .ZERO
8381 calculating = false
84- longPath = Path ()
85- shortPath = Path ()
82+ coarsePath = Path ()
83+ refinedPath = Path ()
8684 currentTarget = null
8785 }
8886
@@ -123,52 +121,60 @@ object Pathfinder : Module(
123121 }
124122
125123 listen<MovementEvent .Sprint > {
126- if (shortPath .moves.isEmpty()) return @listen
124+ if (refinedPath .moves.isEmpty()) return @listen
127125
128126 player.isSprinting = pathing.allowSprint
129127 it.sprint = pathing.allowSprint
130128 }
131129
132130 listen<RenderEvent .StaticESP > { event ->
133131// longPath.render(event.renderer, Color.YELLOW)
134- shortPath .render(event.renderer, Color .GREEN )
132+ refinedPath .render(event.renderer, Color .GREEN )
135133 event.renderer.buildFilled(Box (target.toBlockPos()), Color .PINK .setAlpha(0.25 ))
136134 }
137135 }
138136
139137 private fun SafeContext.updateTargetNode () {
140- shortPath .moves.firstOrNull()?.let { current ->
138+ refinedPath .moves.firstOrNull()?.let { current ->
141139 if (player.pos.distanceTo(current.bottomPos) < pathing.tolerance) {
142- shortPath .moves.removeFirst()
140+ refinedPath .moves.removeFirst()
143141 integralError = Vec3d .ZERO
144142 }
145- currentTarget = shortPath .moves.firstOrNull()?.bottomPos
143+ currentTarget = refinedPath .moves.firstOrNull()?.bottomPos
146144 } ? : run {
147145 currentTarget = null
148146 }
149147 }
150148
151149 private fun SafeContext.updatePaths () {
152- runConcurrent {
153- calculating = true
154- val long: Path
155- val aStar = measureTimeMillis {
156- long = findPathAStar(
157- player.blockPos.toFastVec(),
158- SimpleGoal (target),
159- pathing
160- )
150+ val goal = SimpleGoal (target)
151+ when (pathing.algorithm) {
152+ PathingConfig .PathingAlgorithm .A_STAR -> {
153+ runConcurrent {
154+ calculating = true
155+ val long: Path
156+ val aStar = measureTimeMillis {
157+ long = findPathAStar(player.blockPos.toFastVec(), goal, pathing)
158+ }
159+ val short: Path
160+ val thetaStar = measureTimeMillis {
161+ short = if (pathing.pathRefining) {
162+ thetaStarClearance(long, pathing)
163+ } else long
164+ }
165+ info(" A* (Length: ${long.length().string} Nodes: ${long.moves.size} T: $aStar ms) and Theta* (Length: ${short.length().string} Nodes: ${short.moves.size} T: $thetaStar ms)" )
166+ println (" Long: $long | Short: $short " )
167+ short.moves.removeFirstOrNull()
168+ coarsePath = long
169+ refinedPath = short
170+ // calculating = false
171+ }
161172 }
162- val short: Path
163- val thetaStar = measureTimeMillis {
164- short = thetaStarClearance(long, pathing)
173+ PathingConfig .PathingAlgorithm .D_STAR_LITE -> {
174+ runConcurrent {
175+ // 1. Build graph from goal to target
176+ }
165177 }
166- info(" A* (Length: ${long.length().string} Nodes: ${long.moves.size} T: $aStar ms) and Theta* (Length: ${short.length().string} Nodes: ${short.moves.size} T: $thetaStar ms)" )
167- println (" Long: $long | Short: $short " )
168- short.moves.removeFirstOrNull()
169- longPath = long
170- shortPath = short
171- // calculating = false
172178 }
173179 }
174180
0 commit comments