@@ -34,38 +34,39 @@ object AutoOffhand : Module(
34
34
description = " Manages item in your offhand" ,
35
35
category = Category .COMBAT
36
36
) {
37
+ // General
38
+ private val switchMessage by setting(" Switch Message" , true )
39
+ private val priority by setting(" Priority" , Priority .HOTBAR )
40
+ private val conditional by setting(" Conditional" , false )
37
41
private val type by setting(" Type" , Type .TOTEM )
38
42
39
43
// Totem
40
- private val hpThreshold by setting(" Hp Threshold " , 5f , 1f .. 36f , 0.5f , { type == Type .TOTEM })
44
+ private val offhandTotem by setting(" Offhand Totem " , true , { type == Type .TOTEM })
41
45
private val bindTotem by setting(" Bind Totem" , Bind (), { type == Type .TOTEM })
42
- private val checkDamage by setting(" Check Damage" , true , { type == Type .TOTEM })
43
- private val mob by setting(" Mob" , true , { type == Type .TOTEM && checkDamage })
44
- private val player by setting(" Player" , true , { type == Type .TOTEM && checkDamage })
45
- private val crystal by setting(" Crystal" , true , { type == Type .TOTEM && checkDamage })
46
- private val falling by setting(" Falling" , true , { type == Type .TOTEM && checkDamage })
46
+ private val hpThreshold by setting(" Hp Threshold" , 5f , 1f .. 36f , 0.5f , { type == Type .TOTEM && offhandTotem && conditional })
47
+ private val checkDamage by setting(" Check Damage" , true , { type == Type .TOTEM && offhandTotem && conditional })
48
+ private val mob by setting(" Mob" , true , { type == Type .TOTEM && offhandTotem && checkDamage && conditional })
49
+ private val player by setting(" Player" , true , { type == Type .TOTEM && offhandTotem && checkDamage && conditional })
50
+ private val crystal by setting(" Crystal" , true , { type == Type .TOTEM && offhandTotem && checkDamage && conditional })
51
+ private val falling by setting(" Falling" , true , { type == Type .TOTEM && offhandTotem && checkDamage && conditional })
47
52
48
53
// Gapple
49
54
private val offhandGapple by setting(" Offhand Gapple" , false , { type == Type .GAPPLE })
50
- private val bindGapple by setting(" Bind Gapple" , Bind (), { type == Type .GAPPLE && offhandGapple })
51
- private val checkAuraG by setting(" Check Aura G" , true , { type == Type .GAPPLE && offhandGapple })
52
- private val checkWeaponG by setting(" Check Weapon G" , false , { type == Type .GAPPLE && offhandGapple })
53
- private val checkCAGapple by setting(" Check CrystalAura G" , true , { type == Type .GAPPLE && offhandGapple && ! offhandCrystal })
55
+ private val bindGapple by setting(" Bind Gapple" , Bind (), { type == Type .GAPPLE })
56
+ private val checkAuraG by setting(" Check Aura G" , true , { type == Type .GAPPLE && offhandGapple && conditional })
57
+ private val checkWeaponG by setting(" Check Weapon G" , false , { type == Type .GAPPLE && offhandGapple && conditional })
58
+ private val checkCAGapple by setting(" Check CrystalAura G" , true , { type == Type .GAPPLE && offhandGapple && ! offhandCrystal && conditional })
54
59
55
60
// Strength
56
61
private val offhandStrength by setting(" Offhand Strength" , false , { type == Type .STRENGTH })
57
- private val bindStrength by setting(" Bind Strength" , Bind (), { type == Type .STRENGTH && offhandStrength })
58
- private val checkAuraS by setting(" Check Aura S" , true , { type == Type .STRENGTH && offhandStrength })
59
- private val checkWeaponS by setting(" Check Weapon S" , false , { type == Type .STRENGTH && offhandStrength })
62
+ private val bindStrength by setting(" Bind Strength" , Bind (), { type == Type .STRENGTH })
63
+ private val checkAuraS by setting(" Check Aura S" , true , { type == Type .STRENGTH && offhandStrength && conditional })
64
+ private val checkWeaponS by setting(" Check Weapon S" , false , { type == Type .STRENGTH && offhandStrength && conditional })
60
65
61
66
// Crystal
62
67
private val offhandCrystal by setting(" Offhand Crystal" , false , { type == Type .CRYSTAL })
63
- private val bindCrystal by setting(" Bind Crystal" , Bind (), { type == Type .CRYSTAL && offhandCrystal })
64
- private val checkCACrystal by setting(" Check Crystal Aura C" , false , { type == Type .CRYSTAL && offhandCrystal })
65
-
66
- // General
67
- private val priority by setting(" Priority" , Priority .HOTBAR )
68
- private val switchMessage by setting(" Switch Message" , true )
68
+ private val bindCrystal by setting(" Bind Crystal" , Bind (), { type == Type .CRYSTAL })
69
+ private val checkCACrystal by setting(" Check Crystal Aura C" , false , { type == Type .CRYSTAL && offhandCrystal && conditional })
69
70
70
71
// Represents the remaining number of items of type AutoOffhandType in the inventory
71
72
private var hudInfo = " "
@@ -100,7 +101,7 @@ object AutoOffhand : Module(
100
101
101
102
updateDamage()
102
103
103
- switchToType(getType(), true )
104
+ if (player.heldItemOffhand.isEmpty) switchToType(getType())
104
105
105
106
hudInfo = player.allSlots.countByStack { type.filter(it) }.toString()
106
107
}
@@ -113,26 +114,27 @@ object AutoOffhand : Module(
113
114
checkStrength() -> Type .STRENGTH
114
115
checkGapple() -> Type .GAPPLE
115
116
checkCrystal() -> Type .CRYSTAL
116
- player.heldItemOffhand.isEmpty -> Type .TOTEM
117
117
else -> null
118
118
}
119
119
120
- private fun SafeClientEvent.checkTotem () = player.scaledHealth < hpThreshold
121
- || (checkDamage && player.scaledHealth - maxDamage < hpThreshold)
120
+ private fun SafeClientEvent.checkTotem () = offhandTotem
121
+ && (! conditional || (player.scaledHealth < hpThreshold
122
+ || (checkDamage && player.scaledHealth - maxDamage < hpThreshold)))
122
123
123
124
private fun SafeClientEvent.checkGapple () = offhandGapple
124
- && (checkAuraG && CombatManager .isActiveAndTopPriority(KillAura )
125
+ && (! conditional || (( checkAuraG && CombatManager .isActiveAndTopPriority(KillAura )
125
126
|| checkWeaponG && player.heldItemMainhand.item.isWeapon
126
- || (checkCAGapple && ! offhandCrystal) && CombatManager .isOnTopPriority(CrystalAura ))
127
+ || (checkCAGapple && ! offhandCrystal) && CombatManager .isOnTopPriority(CrystalAura ))))
127
128
128
129
private fun checkCrystal () = offhandCrystal
129
- && checkCACrystal && CrystalAura .isEnabled && CombatManager .isOnTopPriority(CrystalAura )
130
+ && (! conditional || (checkCACrystal && CrystalAura .isEnabled
131
+ && CombatManager .isOnTopPriority(CrystalAura )))
130
132
131
133
private fun SafeClientEvent.checkStrength () = offhandStrength
132
- && ! player.isPotionActive(MobEffects .STRENGTH )
134
+ && ( ! conditional || ( ! player.isPotionActive(MobEffects .STRENGTH )
133
135
&& player.inventoryContainer.inventory.any(Type .STRENGTH .filter)
134
136
&& (checkAuraS && CombatManager .isActiveAndTopPriority(KillAura )
135
- || checkWeaponS && player.heldItemMainhand.item.isWeapon)
137
+ || checkWeaponS && player.heldItemMainhand.item.isWeapon)))
136
138
137
139
private fun SafeClientEvent.switchToType (typeOriginal : Type ? , alternativeType : Boolean = false) {
138
140
// First check for whether player is holding the right item already or not
@@ -155,9 +157,7 @@ object AutoOffhand : Module(
155
157
getSlot(type)?.to(type)
156
158
? : if (attempts > 1 ) {
157
159
getItemSlot(type.next(), attempts - 1 )
158
- } else {
159
- null
160
- }
160
+ } else null
161
161
162
162
private fun SafeClientEvent.getSlot (type : Type ): Slot ? {
163
163
return player.offhandSlot.takeIf (filter(type))
@@ -175,9 +175,7 @@ object AutoOffhand : Module(
175
175
private fun List<Slot>.findItemByType (type : Type ) =
176
176
find(filter(type))
177
177
178
- private fun filter (type : Type ) = { it: Slot ->
179
- type.filter(it.stack)
180
- }
178
+ private fun filter (type : Type ) = { it: Slot -> type.filter(it.stack) }
181
179
182
180
private fun SafeClientEvent.updateDamage () {
183
181
maxDamage = 0f
@@ -189,12 +187,8 @@ object AutoOffhand : Module(
189
187
if (player.getDistance(entity) > 10.0f ) continue
190
188
191
189
when {
192
- mob && entity is EntityMob -> {
193
- maxDamage = max(calcDamageFromMob(entity), maxDamage)
194
- }
195
- this @AutoOffhand.player && entity is EntityPlayer -> {
196
- maxDamage = max(calcDamageFromPlayer(entity, true ), maxDamage)
197
- }
190
+ mob && entity is EntityMob -> maxDamage = max(calcDamageFromMob(entity), maxDamage)
191
+ this @AutoOffhand.player && entity is EntityPlayer -> maxDamage = max(calcDamageFromPlayer(entity, true ), maxDamage)
198
192
crystal && entity is EntityEnderCrystal -> {
199
193
val damage = CombatManager .crystalMap[entity] ? : continue
200
194
maxDamage = max(damage.selfDamage, maxDamage)
0 commit comments