mirror of https://github.com/kami-blue/client
[fix] OffhandGapple aura check
This commit is contained in:
parent
34e700b2ab
commit
ee7da9c8b9
|
@ -34,38 +34,38 @@ internal object AutoOffhand : Module(
|
||||||
description = "Manages item in your offhand",
|
description = "Manages item in your offhand",
|
||||||
category = Category.COMBAT
|
category = Category.COMBAT
|
||||||
) {
|
) {
|
||||||
private val type = setting("Type", Type.TOTEM)
|
private val type by setting("Type", Type.TOTEM)
|
||||||
|
|
||||||
// Totem
|
// Totem
|
||||||
private val hpThreshold = setting("HpThreshold", 5f, 1f..20f, 0.5f, { type.value == Type.TOTEM })
|
private val hpThreshold by setting("HpThreshold", 5f, 1f..20f, 0.5f, { type == Type.TOTEM })
|
||||||
private val bindTotem = setting("BindTotem", Bind(), { type.value == Type.TOTEM })
|
private val bindTotem by setting("BindTotem", Bind(), { type == Type.TOTEM })
|
||||||
private val checkDamage = setting("CheckDamage", true, { type.value == Type.TOTEM })
|
private val checkDamage by setting("CheckDamage", true, { type == Type.TOTEM })
|
||||||
private val mob = setting("Mob", true, { type.value == Type.TOTEM && checkDamage.value })
|
private val mob by setting("Mob", true, { type == Type.TOTEM && checkDamage })
|
||||||
private val player = setting("Player", true, { type.value == Type.TOTEM && checkDamage.value })
|
private val player by setting("Player", true, { type == Type.TOTEM && checkDamage })
|
||||||
private val crystal = setting("Crystal", true, { type.value == Type.TOTEM && checkDamage.value })
|
private val crystal by setting("Crystal", true, { type == Type.TOTEM && checkDamage })
|
||||||
private val falling = setting("Falling", true, { type.value == Type.TOTEM && checkDamage.value })
|
private val falling by setting("Falling", true, { type == Type.TOTEM && checkDamage })
|
||||||
|
|
||||||
// Gapple
|
// Gapple
|
||||||
private val offhandGapple = setting("OffhandGapple", false, { type.value == Type.GAPPLE })
|
private val offhandGapple by setting("OffhandGapple", false, { type == Type.GAPPLE })
|
||||||
private val bindGapple = setting("BindGapple", Bind(), { type.value == Type.GAPPLE && offhandGapple.value })
|
private val bindGapple by setting("BindGapple", Bind(), { type == Type.GAPPLE && offhandGapple })
|
||||||
private val checkAuraG = setting("CheckAuraG", true, { type.value == Type.GAPPLE && offhandGapple.value })
|
private val checkAuraG by setting("CheckAuraG", true, { type == Type.GAPPLE && offhandGapple })
|
||||||
private val checkWeaponG = setting("CheckWeaponG", false, { type.value == Type.GAPPLE && offhandGapple.value })
|
private val checkWeaponG by setting("CheckWeaponG", false, { type == Type.GAPPLE && offhandGapple })
|
||||||
private val checkCAGapple = setting("CheckCrystalAuraG", true, { type.value == Type.GAPPLE && offhandGapple.value && !offhandCrystal.value })
|
private val checkCAGapple by setting("CheckCrystalAuraG", true, { type == Type.GAPPLE && offhandGapple && !offhandCrystal })
|
||||||
|
|
||||||
// Strength
|
// Strength
|
||||||
private val offhandStrength = setting("OffhandStrength", false, { type.value == Type.STRENGTH })
|
private val offhandStrength by setting("OffhandStrength", false, { type == Type.STRENGTH })
|
||||||
private val bindStrength = setting("BindStrength", Bind(), { type.value == Type.STRENGTH && offhandStrength.value })
|
private val bindStrength by setting("BindStrength", Bind(), { type == Type.STRENGTH && offhandStrength })
|
||||||
private val checkAuraS = setting("CheckAuraS", true, { type.value == Type.STRENGTH && offhandStrength.value })
|
private val checkAuraS by setting("CheckAuraS", true, { type == Type.STRENGTH && offhandStrength })
|
||||||
private val checkWeaponS = setting("CheckWeaponS", false, { type.value == Type.STRENGTH && offhandStrength.value })
|
private val checkWeaponS by setting("CheckWeaponS", false, { type == Type.STRENGTH && offhandStrength })
|
||||||
|
|
||||||
// Crystal
|
// Crystal
|
||||||
private val offhandCrystal = setting("OffhandCrystal", false, { type.value == Type.CRYSTAL })
|
private val offhandCrystal by setting("OffhandCrystal", false, { type == Type.CRYSTAL })
|
||||||
private val bindCrystal = setting("BindCrystal", Bind(), { type.value == Type.CRYSTAL && offhandCrystal.value })
|
private val bindCrystal by setting("BindCrystal", Bind(), { type == Type.CRYSTAL && offhandCrystal })
|
||||||
private val checkCACrystal = setting("CheckCrystalAuraC", false, { type.value == Type.CRYSTAL && offhandCrystal.value })
|
private val checkCACrystal by setting("CheckCrystalAuraC", false, { type == Type.CRYSTAL && offhandCrystal })
|
||||||
|
|
||||||
// General
|
// General
|
||||||
private val priority = setting("Priority", Priority.HOTBAR)
|
private val priority by setting("Priority", Priority.HOTBAR)
|
||||||
private val switchMessage = setting("SwitchMessage", true)
|
private val switchMessage by setting("SwitchMessage", true)
|
||||||
|
|
||||||
private enum class Type(val filter: (ItemStack) -> Boolean) {
|
private enum class Type(val filter: (ItemStack) -> Boolean) {
|
||||||
TOTEM({ it.item.id == 449 }),
|
TOTEM({ it.item.id == 449 }),
|
||||||
|
@ -87,10 +87,10 @@ internal object AutoOffhand : Module(
|
||||||
safeListener<InputEvent.KeyInputEvent> {
|
safeListener<InputEvent.KeyInputEvent> {
|
||||||
val key = Keyboard.getEventKey()
|
val key = Keyboard.getEventKey()
|
||||||
when {
|
when {
|
||||||
bindTotem.value.isDown(key) -> switchToType(Type.TOTEM)
|
bindTotem.isDown(key) -> switchToType(Type.TOTEM)
|
||||||
bindGapple.value.isDown(key) -> switchToType(Type.GAPPLE)
|
bindGapple.isDown(key) -> switchToType(Type.GAPPLE)
|
||||||
bindStrength.value.isDown(key) -> switchToType(Type.STRENGTH)
|
bindStrength.isDown(key) -> switchToType(Type.STRENGTH)
|
||||||
bindCrystal.value.isDown(key) -> switchToType(Type.CRYSTAL)
|
bindCrystal.isDown(key) -> switchToType(Type.CRYSTAL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,11 @@ internal object AutoOffhand : Module(
|
||||||
}
|
}
|
||||||
|
|
||||||
safeListener<TickEvent.ClientTickEvent>(1100) {
|
safeListener<TickEvent.ClientTickEvent>(1100) {
|
||||||
if (player.isDead || !movingTimer.tick(200L, false)) return@safeListener // Delays 4 ticks by default
|
if (player.isDead) return@safeListener
|
||||||
|
|
||||||
|
updateDamage()
|
||||||
|
|
||||||
|
if (!movingTimer.tick(200L, false)) return@safeListener // Delays 4 ticks by default
|
||||||
|
|
||||||
if (!player.inventory.itemStack.isEmpty) { // If player is holding an in inventory
|
if (!player.inventory.itemStack.isEmpty) { // If player is holding an in inventory
|
||||||
if (mc.currentScreen is GuiContainer) {// If inventory is open (playing moving item)
|
if (mc.currentScreen is GuiContainer) {// If inventory is open (playing moving item)
|
||||||
|
@ -112,11 +116,10 @@ internal object AutoOffhand : Module(
|
||||||
} else { // If inventory is not open (ex. inventory desync)
|
} else { // If inventory is not open (ex. inventory desync)
|
||||||
removeHoldingItem()
|
removeHoldingItem()
|
||||||
}
|
}
|
||||||
} else { // If player is not holding an item in inventory
|
return@safeListener
|
||||||
switchToType(getType(), true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDamage()
|
switchToType(getType(), true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,37 +132,38 @@ internal object AutoOffhand : Module(
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun SafeClientEvent.checkTotem() = CombatUtils.getHealthSmart(player) < hpThreshold.value
|
private fun SafeClientEvent.checkTotem() = CombatUtils.getHealthSmart(player) < hpThreshold
|
||||||
|| (checkDamage.value && CombatUtils.getHealthSmart(player) - maxDamage < hpThreshold.value)
|
|| (checkDamage && CombatUtils.getHealthSmart(player) - maxDamage < hpThreshold)
|
||||||
|
|
||||||
private fun SafeClientEvent.checkGapple() = offhandGapple.value
|
private fun SafeClientEvent.checkGapple() = offhandGapple
|
||||||
&& (checkAuraS.value && CombatManager.isActiveAndTopPriority(KillAura)
|
&& (checkAuraG && CombatManager.isActiveAndTopPriority(KillAura)
|
||||||
|| checkWeaponG.value && player.heldItemMainhand.item.isWeapon
|
|| checkWeaponG && player.heldItemMainhand.item.isWeapon
|
||||||
|| (checkCAGapple.value && !offhandCrystal.value) && CombatManager.isOnTopPriority(CrystalAura))
|
|| (checkCAGapple && !offhandCrystal) && CombatManager.isOnTopPriority(CrystalAura))
|
||||||
|
|
||||||
private fun checkCrystal() = offhandCrystal.value
|
private fun checkCrystal() = offhandCrystal
|
||||||
&& checkCACrystal.value && CrystalAura.isEnabled && CombatManager.isOnTopPriority(CrystalAura)
|
&& checkCACrystal && CrystalAura.isEnabled && CombatManager.isOnTopPriority(CrystalAura)
|
||||||
|
|
||||||
private fun SafeClientEvent.checkStrength() = offhandStrength.value
|
private fun SafeClientEvent.checkStrength() = offhandStrength
|
||||||
&& !player.isPotionActive(MobEffects.STRENGTH)
|
&& !player.isPotionActive(MobEffects.STRENGTH)
|
||||||
&& (checkAuraG.value && CombatManager.isActiveAndTopPriority(KillAura)
|
&& player.inventoryContainer.inventory.any(Type.STRENGTH.filter)
|
||||||
|| checkWeaponS.value && player.heldItemMainhand.item.isWeapon)
|
&& (checkAuraS && CombatManager.isActiveAndTopPriority(KillAura)
|
||||||
|
|| checkWeaponS && player.heldItemMainhand.item.isWeapon)
|
||||||
|
|
||||||
private fun SafeClientEvent.switchToType(typeOriginal: Type?, alternativeType: Boolean = false) {
|
private fun SafeClientEvent.switchToType(typeOriginal: Type?, alternativeType: Boolean = false) {
|
||||||
// First check for whether player is holding the right item already or not
|
// First check for whether player is holding the right item already or not
|
||||||
if (typeOriginal != null && !checkOffhandItem(typeOriginal)) {
|
if (typeOriginal == null || checkOffhandItem(typeOriginal)) return
|
||||||
getItemSlot(typeOriginal)?.let { (slot, typeAlt) ->
|
|
||||||
// Second check is for case of when player ran out of the original type of item
|
|
||||||
if (!alternativeType && typeAlt != typeOriginal || checkOffhandItem(typeAlt)) return@let
|
|
||||||
|
|
||||||
transactionLog.clear()
|
getItemSlot(typeOriginal)?.let { (slot, typeAlt) ->
|
||||||
transactionLog.putAll(moveToSlot(slot.slotNumber, 45).associate { it to false })
|
// Second check is for case of when player ran out of the original type of item
|
||||||
|
if (!alternativeType && typeAlt != typeOriginal || checkOffhandItem(typeAlt)) return
|
||||||
|
|
||||||
playerController.updateController()
|
transactionLog.clear()
|
||||||
movingTimer.reset()
|
transactionLog.putAll(moveToSlot(slot.slotNumber, 45).associate { it to false })
|
||||||
|
|
||||||
if (switchMessage.value) MessageSendHelper.sendChatMessage("$chatName Offhand now has a ${typeAlt.toString().toLowerCase()}")
|
playerController.updateController()
|
||||||
}
|
movingTimer.reset()
|
||||||
|
|
||||||
|
if (switchMessage) MessageSendHelper.sendChatMessage("$chatName Offhand now has a ${typeAlt.toString().toLowerCase()}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +180,7 @@ internal object AutoOffhand : Module(
|
||||||
private fun SafeClientEvent.getSlot(type: Type): Slot? {
|
private fun SafeClientEvent.getSlot(type: Type): Slot? {
|
||||||
val slots = player.inventorySlots
|
val slots = player.inventorySlots
|
||||||
|
|
||||||
return if (priority.value == Priority.HOTBAR) {
|
return if (priority == Priority.HOTBAR) {
|
||||||
slots.lastOrNull { type.filter(it.stack) }
|
slots.lastOrNull { type.filter(it.stack) }
|
||||||
} else {
|
} else {
|
||||||
slots.firstOrNull { type.filter(it.stack) }
|
slots.firstOrNull { type.filter(it.stack) }
|
||||||
|
@ -185,27 +189,27 @@ internal object AutoOffhand : Module(
|
||||||
|
|
||||||
private fun SafeClientEvent.updateDamage() {
|
private fun SafeClientEvent.updateDamage() {
|
||||||
maxDamage = 0f
|
maxDamage = 0f
|
||||||
if (!checkDamage.value) return
|
if (!checkDamage) return
|
||||||
|
|
||||||
for (entity in world.loadedEntityList) {
|
for (entity in world.loadedEntityList) {
|
||||||
if (entity.name == player.name) continue
|
if (entity.name == player.name) continue
|
||||||
if (entity !is EntityMob && entity !is EntityPlayer && entity !is EntityEnderCrystal) continue
|
if (entity !is EntityMob && entity !is EntityPlayer && entity !is EntityEnderCrystal) continue
|
||||||
if (player.getDistance(entity) > 10f) continue
|
if (player.getDistance(entity) > 10f) continue
|
||||||
|
|
||||||
if (mob.value && entity is EntityMob) {
|
if (mob && entity is EntityMob) {
|
||||||
maxDamage = max(calcDamageFromMob(entity), maxDamage)
|
maxDamage = max(calcDamageFromMob(entity), maxDamage)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this@AutoOffhand.player.value && entity is EntityPlayer) {
|
if (this@AutoOffhand.player && entity is EntityPlayer) {
|
||||||
maxDamage = max(calcDamageFromPlayer(entity, true), maxDamage)
|
maxDamage = max(calcDamageFromPlayer(entity, true), maxDamage)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crystal.value && entity is EntityEnderCrystal) {
|
if (crystal && entity is EntityEnderCrystal) {
|
||||||
maxDamage = max(calcCrystalDamage(entity, player), maxDamage)
|
maxDamage = max(calcCrystalDamage(entity, player), maxDamage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (falling.value && nextFallDist > 3.0f) maxDamage = max(ceil(nextFallDist - 3.0f), maxDamage)
|
if (falling && nextFallDist > 3.0f) maxDamage = max(ceil(nextFallDist - 3.0f), maxDamage)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val SafeClientEvent.nextFallDist get() = player.fallDistance - player.motionY.toFloat()
|
private val SafeClientEvent.nextFallDist get() = player.fallDistance - player.motionY.toFloat()
|
||||||
|
|
Loading…
Reference in New Issue