Skip to content

Commit 430b463

Browse files
authored
Feat: KillAura DPS calculation (#200)
I don't want the KillAura to always switch to the axe if I have swap on, so this fixes that. It prefers the axe or the tool with the highest damage/hit if it is in the "Hit Damage" mode if you like the old behavior.
1 parent cbdd5ce commit 430b463

File tree

1 file changed

+14
-1
lines changed
  • src/main/kotlin/com/lambda/module/modules/combat

1 file changed

+14
-1
lines changed

src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package com.lambda.module.modules.combat
2020
import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
2121
import com.lambda.config.applyEdits
2222
import com.lambda.config.groups.Targeting
23+
import com.lambda.context.SafeContext
2324
import com.lambda.event.events.PlayerPacketEvent
2425
import com.lambda.event.events.TickEvent
2526
import com.lambda.event.listener.SafeListener.Companion.listen
@@ -31,13 +32,16 @@ import com.lambda.interaction.material.container.containers.MainHandContainer
3132
import com.lambda.module.Module
3233
import com.lambda.module.tag.ModuleTag
3334
import com.lambda.task.RootTask.run
35+
import com.lambda.threading.runSafe
3436
import com.lambda.threading.runSafeAutomated
3537
import com.lambda.util.NamedEnum
3638
import com.lambda.util.item.ItemStackUtils.attackDamage
39+
import com.lambda.util.item.ItemStackUtils.attackSpeed
3740
import com.lambda.util.item.ItemStackUtils.equal
3841
import com.lambda.util.math.random
3942
import com.lambda.util.player.SlotUtils.hotbarAndStorage
4043
import net.minecraft.entity.LivingEntity
44+
import net.minecraft.item.ItemStack
4145
import net.minecraft.util.Hand
4246

4347
object KillAura : Module(
@@ -48,6 +52,7 @@ object KillAura : Module(
4852
// Interact
4953
private val rotate by setting("Rotate", true).group(Group.General)
5054
private val swap by setting("Swap", true, "Swap to the item with the highest damage").group(Group.General)
55+
private val damageMode by setting("Damage Mode", DamageMode.DPS).group(Group.General)
5156
private val attackMode by setting("Attack Mode", AttackMode.Cooldown).group(Group.General)
5257
private val cooldownShrink by setting("Cooldown Offset", 0, 0..5, 1) { attackMode == AttackMode.Cooldown }.group(Group.General)
5358
private val hitDelay1 by setting("Hit Delay 1", 2.0, 0.0..20.0, 1.0) { attackMode == AttackMode.Delay }.group(Group.General)
@@ -76,6 +81,12 @@ object KillAura : Module(
7681
Delay
7782
}
7883

84+
@Suppress("unused")
85+
enum class DamageMode(override val displayName: String, val block: SafeContext.(ItemStack) -> Double) : NamedEnum {
86+
DPS("Damage Per Second", { player.attackDamage(stack = it) * player.attackSpeed(stack = it) }),
87+
Total("Hit Damage", { player.attackDamage(stack = it) })
88+
}
89+
7990
init {
8091
setDefaultAutomationConfig {
8192
applyEdits {
@@ -95,7 +106,9 @@ object KillAura : Module(
95106
listen<TickEvent.Pre> {
96107
target?.let { entity ->
97108
if (swap) {
98-
val selection = selectStack().sortByDescending { player.attackDamage(stack = it) }
109+
val selection = selectStack().sortByDescending {
110+
damageMode.block(this, it)
111+
}
99112

100113
if (!selection.bestItemMatch(player.hotbarAndStorage).equal(player.mainHandStack))
101114
selection.transfer(MainHandContainer)?.run()

0 commit comments

Comments
 (0)