1414import net .runelite .client .plugins .microbot .util .grounditem .LootingParameters ;
1515import net .runelite .client .plugins .microbot .util .grounditem .Rs2GroundItem ;
1616import net .runelite .client .plugins .microbot .util .inventory .Rs2Inventory ;
17+ import net .runelite .client .plugins .microbot .util .magic .Rs2Magic ;
1718import net .runelite .client .plugins .microbot .util .npc .Rs2Npc ;
1819import net .runelite .client .plugins .microbot .util .npc .Rs2NpcModel ;
1920import net .runelite .client .plugins .microbot .util .player .Rs2Player ;
2021import net .runelite .client .plugins .microbot .util .prayer .Rs2Prayer ;
2122import net .runelite .client .plugins .microbot .util .prayer .Rs2PrayerEnum ;
2223import net .runelite .client .plugins .microbot .util .reflection .Rs2Reflection ;
24+ import net .runelite .client .plugins .microbot .util .tabs .Rs2Tab ;
2325import net .runelite .client .plugins .microbot .util .walker .Rs2Walker ;
26+ import net .runelite .client .plugins .microbot .util .widget .Rs2Widget ;
2427import net .runelite .client .plugins .microbot .zerozero .tormenteddemons .TormentedDemonConfig .CombatPotionType ;
2528import net .runelite .client .plugins .microbot .zerozero .tormenteddemons .TormentedDemonConfig .MODE ;
2629import net .runelite .client .plugins .microbot .zerozero .tormenteddemons .TormentedDemonConfig .RangingPotionType ;
@@ -38,25 +41,23 @@ public class TormentedDemonScript extends Script {
3841 private Rs2PrayerEnum currentDefensivePrayer = null ;
3942 private Rs2PrayerEnum currentOffensivePrayer = null ;
4043 private HeadIcon currentOverheadIcon = null ;
41- private Rs2NpcModel currentTarget ;
44+ public Rs2NpcModel currentTarget ;
4245 private boolean lootAttempted = false ;
4346 private String lastChatMessage = "" ;
4447 private boolean isRestocking = false ;
4548
46-
47- private static final int MAGIC_ATTACK_ANIMATION = 11388 ;
48- private static final int RANGE_ATTACK_ANIMATION = 11389 ;
49- private static final int MELEE_ATTACK_ANIMATION = 11392 ;
50-
5149 private static final WorldPoint SAFE_LOCATION = new WorldPoint (3150 , 3634 , 0 );
5250
53- private enum State { BANKING , TRAVEL_TO_TORMENTED , FIGHTING }
51+ private enum State {BANKING , TRAVEL_TO_TORMENTED , FIGHTING }
52+
5453 public static State BOT_STATUS = State .BANKING ;
5554
56- private enum TravelStep { LOCATION_ONE , CLIMB_FIRST_STAIRS , CLIMB_SECOND_STAIRS , CLIMB_THROUGH , LOCATION_THREE }
55+ private enum TravelStep {LOCATION_ONE , CLIMB_FIRST_STAIRS , CLIMB_SECOND_STAIRS , CLIMB_THROUGH , LOCATION_THREE }
56+
5757 private TravelStep travelStep = TravelStep .LOCATION_ONE ;
5858
59- private enum BankingStep { DRINK , BANK , LOAD_INVENTORY }
59+ private enum BankingStep {DRINK , BANK , LOAD_INVENTORY }
60+
6061 private BankingStep bankingStep = BankingStep .DRINK ;
6162
6263 public boolean run (TormentedDemonConfig config ) {
@@ -95,6 +96,9 @@ public boolean run(TormentedDemonConfig config) {
9596
9697
9798 private void handleTravel (TormentedDemonConfig config ) {
99+ if (Rs2Bank .isOpen ()) {
100+ Rs2Bank .closeBank ();
101+ }
98102 WorldPoint targetLocationOne = new WorldPoint (4062 , 4558 , 0 );
99103 WorldPoint targetFinalLocation = new WorldPoint (4073 , 4432 , 0 );
100104 WorldPoint playerLocation = Microbot .getClient ().getLocalPlayer ().getWorldLocation ();
@@ -203,6 +207,7 @@ private void handleBanking(TormentedDemonConfig config) {
203207 break ;
204208 }
205209 }
210+
206211 private void handleFighting (TormentedDemonConfig config ) {
207212 if (currentTarget == null || currentTarget .isDead ()) {
208213 disableAllPrayers ();
@@ -217,6 +222,9 @@ private void handleFighting(TormentedDemonConfig config) {
217222 }
218223
219224 currentTarget = findNewTarget (config );
225+ if (currentTarget .getInteracting () != Microbot .getClient ().getLocalPlayer ()) {
226+ currentTarget = findNewTarget (config );
227+ }
220228 if (currentTarget != null ) {
221229 currentOverheadIcon = Rs2Reflection .getHeadIcon (currentTarget );
222230 if (currentOverheadIcon == null ) {
@@ -245,6 +253,7 @@ private void handleFighting(TormentedDemonConfig config) {
245253 }
246254
247255 if (currentTarget != null && !currentTarget .isDead ()) {
256+
248257 Rs2Player .eatAt (config .minEatPercent ());
249258 Rs2Player .drinkPrayerPotionAt (config .minPrayerPercent ());
250259
@@ -257,7 +266,7 @@ private void handleFighting(TormentedDemonConfig config) {
257266
258267 if (attackSuccessful ) {
259268 Rs2Player .waitForAnimation ();
260- sleepUntil (() -> Rs2Player .getInteracting () != null && ((Rs2NpcModel ) Rs2Player .getInteracting ()).getIndex () == currentTarget .getIndex (), 3000 );
269+ sleepUntil (() -> Rs2Player .getInteracting () != null && ((Rs2NpcModel ) Rs2Player .getInteracting ()).getIndex () == currentTarget .getIndex (), 3000 );
261270 } else {
262271 logOnceToChat ("Attack failed for target: " + (currentTarget != null ? currentTarget .getName () : "null" ));
263272 currentTarget = null ;
@@ -279,23 +288,6 @@ private void handleFighting(TormentedDemonConfig config) {
279288
280289 if (currentTarget == null ) return ;
281290
282- int npcAnimation = currentTarget .getAnimation ();
283- if (config .enableDefensivePrayer ()) {
284- System .out .println (npcAnimation );
285- Rs2PrayerEnum newDefensivePrayer = null ;
286- if (npcAnimation == MAGIC_ATTACK_ANIMATION ) {
287- newDefensivePrayer = Rs2PrayerEnum .PROTECT_MAGIC ;
288- } else if (npcAnimation == RANGE_ATTACK_ANIMATION ) {
289- newDefensivePrayer = Rs2PrayerEnum .PROTECT_RANGE ;
290- } else if (npcAnimation == MELEE_ATTACK_ANIMATION ) {
291- newDefensivePrayer = Rs2PrayerEnum .PROTECT_MELEE ;
292- }
293- if (newDefensivePrayer != null && newDefensivePrayer != currentDefensivePrayer ) {
294- logOnceToChat ("Changing defensive prayer to " + newDefensivePrayer );
295- switchDefensivePrayer (newDefensivePrayer );
296- }
297- }
298-
299291 if (config .enableOffensivePrayer ()) {
300292 activateOffensivePrayer (config );
301293 }
@@ -312,14 +304,19 @@ private void switchDefensivePrayer(Rs2PrayerEnum newDefensivePrayer) {
312304
313305 private void activateOffensivePrayer (TormentedDemonConfig config ) {
314306 Rs2PrayerEnum newOffensivePrayer = null ;
315- if (config .useMagicStyle () && isGearEquipped (parseGear (config .magicGear ()))) {
307+ if (config .useMagicStyle () && isGearEquipped (parseGear (config .magicGear ())) && Rs2Player . getBoostedSkillLevel ( Skill . PRAYER ) >= 77 ) {
316308 newOffensivePrayer = Rs2PrayerEnum .AUGURY ;
317- } else if (config .useRangeStyle () && isGearEquipped (parseGear (config .rangeGear ()))) {
318- newOffensivePrayer = Rs2PrayerEnum .RIGOUR ;
319- } else if (config .useMeleeStyle () && isGearEquipped (parseGear (config .meleeGear ()))) {
309+ } else if (config .useMagicStyle () && isGearEquipped (parseGear (config .magicGear ()))) {
310+ newOffensivePrayer = Rs2PrayerEnum .MYSTIC_LORE ;
311+ } else if (config .useMeleeStyle () && isGearEquipped (parseGear (config .meleeGear ())) && Rs2Player . getBoostedSkillLevel ( Skill . PRAYER ) >= 70 ) {
320312 newOffensivePrayer = Rs2PrayerEnum .PIETY ;
313+ } else if (config .useMeleeStyle () && isGearEquipped (parseGear (config .meleeGear ()))) {
314+ newOffensivePrayer = Rs2PrayerEnum .ULTIMATE_STRENGTH ;
315+ } else if (config .useRangeStyle () && isGearEquipped (parseGear (config .rangeGear ())) && Rs2Player .getBoostedSkillLevel (Skill .PRAYER ) >= 70 ) {
316+ newOffensivePrayer = Rs2PrayerEnum .RIGOUR ;
317+ } else if (config .useRangeStyle () && isGearEquipped (parseGear (config .rangeGear ()))) {
318+ newOffensivePrayer = Rs2PrayerEnum .HAWK_EYE ;
321319 }
322-
323320 if (newOffensivePrayer != null && newOffensivePrayer != currentOffensivePrayer ) {
324321 logOnceToChat ("Changing offensive prayer to " + newOffensivePrayer );
325322 switchOffensivePrayer (newOffensivePrayer );
@@ -421,7 +418,7 @@ private boolean shouldRetreat(TormentedDemonConfig config) {
421418 boolean noPrayerPotions = Rs2Inventory .items ().stream ()
422419 .noneMatch (item -> item != null && item .getName () != null && item .getName ().toLowerCase ().contains ("prayer potion" ));
423420
424- return (noFood && currentHealth <= config .healthThreshold ()) || (noPrayerPotions && currentPrayer < 10 );
421+ return (noFood || currentHealth <= config .healthThreshold ()) || (noPrayerPotions && currentPrayer < 10 );
425422 }
426423
427424 public void disableAllPrayers () {
@@ -589,7 +586,4 @@ public void shutdown() {
589586 }
590587 logOnceToChat ("Shutting down Tormented Demon script" );
591588 }
592-
593-
594-
595589}
0 commit comments