@@ -34,38 +34,39 @@ object AutoOffhand : Module(
3434 description = " Manages item in your offhand" ,
3535 category = Category .COMBAT
3636) {
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 )
3741 private val type by setting(" Type" , Type .TOTEM )
3842
3943 // 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 })
4145 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 })
4752
4853 // Gapple
4954 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 })
5459
5560 // Strength
5661 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 })
6065
6166 // Crystal
6267 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 })
6970
7071 // Represents the remaining number of items of type AutoOffhandType in the inventory
7172 private var hudInfo = " "
@@ -100,7 +101,7 @@ object AutoOffhand : Module(
100101
101102 updateDamage()
102103
103- switchToType(getType(), true )
104+ if (player.heldItemOffhand.isEmpty) switchToType(getType())
104105
105106 hudInfo = player.allSlots.countByStack { type.filter(it) }.toString()
106107 }
@@ -113,26 +114,27 @@ object AutoOffhand : Module(
113114 checkStrength() -> Type .STRENGTH
114115 checkGapple() -> Type .GAPPLE
115116 checkCrystal() -> Type .CRYSTAL
116- player.heldItemOffhand.isEmpty -> Type .TOTEM
117117 else -> null
118118 }
119119
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)))
122123
123124 private fun SafeClientEvent.checkGapple () = offhandGapple
124- && (checkAuraG && CombatManager .isActiveAndTopPriority(KillAura )
125+ && (! conditional || (( checkAuraG && CombatManager .isActiveAndTopPriority(KillAura )
125126 || checkWeaponG && player.heldItemMainhand.item.isWeapon
126- || (checkCAGapple && ! offhandCrystal) && CombatManager .isOnTopPriority(CrystalAura ))
127+ || (checkCAGapple && ! offhandCrystal) && CombatManager .isOnTopPriority(CrystalAura ))))
127128
128129 private fun checkCrystal () = offhandCrystal
129- && checkCACrystal && CrystalAura .isEnabled && CombatManager .isOnTopPriority(CrystalAura )
130+ && (! conditional || (checkCACrystal && CrystalAura .isEnabled
131+ && CombatManager .isOnTopPriority(CrystalAura )))
130132
131133 private fun SafeClientEvent.checkStrength () = offhandStrength
132- && ! player.isPotionActive(MobEffects .STRENGTH )
134+ && ( ! conditional || ( ! player.isPotionActive(MobEffects .STRENGTH )
133135 && player.inventoryContainer.inventory.any(Type .STRENGTH .filter)
134136 && (checkAuraS && CombatManager .isActiveAndTopPriority(KillAura )
135- || checkWeaponS && player.heldItemMainhand.item.isWeapon)
137+ || checkWeaponS && player.heldItemMainhand.item.isWeapon)))
136138
137139 private fun SafeClientEvent.switchToType (typeOriginal : Type ? , alternativeType : Boolean = false) {
138140 // First check for whether player is holding the right item already or not
@@ -155,9 +157,7 @@ object AutoOffhand : Module(
155157 getSlot(type)?.to(type)
156158 ? : if (attempts > 1 ) {
157159 getItemSlot(type.next(), attempts - 1 )
158- } else {
159- null
160- }
160+ } else null
161161
162162 private fun SafeClientEvent.getSlot (type : Type ): Slot ? {
163163 return player.offhandSlot.takeIf (filter(type))
@@ -175,9 +175,7 @@ object AutoOffhand : Module(
175175 private fun List<Slot>.findItemByType (type : Type ) =
176176 find(filter(type))
177177
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) }
181179
182180 private fun SafeClientEvent.updateDamage () {
183181 maxDamage = 0f
@@ -189,12 +187,8 @@ object AutoOffhand : Module(
189187 if (player.getDistance(entity) > 10.0f ) continue
190188
191189 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)
198192 crystal && entity is EntityEnderCrystal -> {
199193 val damage = CombatManager .crystalMap[entity] ? : continue
200194 maxDamage = max(damage.selfDamage, maxDamage)
0 commit comments