Advertisement
uhmm

AutoFishing

Aug 8th, 2022 (edited)
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 37.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Linq;
  5. using System.Threading;
  6. using System.Text;
  7. using Turbo.plugins.patrick.parameters;
  8. using Turbo.plugins.patrick.parameters.types;
  9. using Turbo.plugins.patrick.util.diablo;
  10. using Turbo.Plugins.Patrick.forms;
  11. using Turbo.plugins.patrick.util.input;
  12. using Turbo.plugins.patrick.util.logger;
  13. using Turbo.plugins.patrick.util.thud;
  14. using Turbo.Plugins;
  15. using Turbo.Plugins.Default;
  16.  
  17. namespace Turbo.plugins.patrick.hotkeys.actions.general {
  18.  
  19.     public class AutoFishing : BasePlugin, IAfterCollectHandler {
  20.         public AutoFishing() {
  21.             Enabled = true;
  22.         }
  23.  
  24.         public static bool Battlefields { get; set; } = true;
  25.         public static bool Festering { get; set; } = true;
  26.         public static bool Spire { get; set; } = false;
  27.         public static bool Desert { get; set; } = false;
  28.         public static bool DesolateSands { get; set; } = true;
  29.         public static bool FieldsOfMisery { get; set; } = true;
  30.         public static bool Graveyard { get; set; } = true;
  31.         public static bool SkipBadMobsets { get; set; } = false;
  32.        
  33.         // Edit these to mark them as good/bad mobsets for autofishing. Full info on http://warpath.eu
  34.         // under "Monster Sets", search by the index.
  35.         Dictionary<string, bool> GoodMobsets {get; set;} = new Dictionary<string, bool>{
  36.             {"Ghosts", true},                       // set #14
  37.             {"Ice Clan", true},                     // set #32
  38.             {"Slashers", true},                     // set #19
  39.             {"Swarms", true},                       // set #23
  40.             {"Transformers", true},                 // set #10
  41.             {"Zombie Grotesque", true},             // set #26
  42.            
  43.             {"Armored Destroyer", true},            // set #29
  44.             {"Bee Accursed", true},                 // set #25
  45.             {"Hellions", true},                     // set #22
  46.             {"Hulks", true},                        // set #09
  47.             {"Lacuni Phasebeast", true},            // set #13
  48.             {"Petting Zoo", true},                  // set #33
  49.             {"Small Spiders", true},                // set #20
  50.             {"Summoners", true},                    // set #02
  51.            
  52.             {"Anarch Exarch", false},               // set #24
  53.             {"Big Bogans", false},                  // set #21
  54.             {"Blue Fallen", false},                 // set #12
  55.             {"Boggen Trappers ", false},            // set #04
  56.             {"Dark Berserker", false},              // set #01
  57.             {"Frogs", false},                       // set #27
  58.             {"Red Fallen", false},                  // set #15
  59.             {"Red Spiders", false},                 // set #07
  60.            
  61.             {"Big Spiders", false},                 // set #08
  62.             {"Blazing Guardian", false},            // set #31
  63.             {"Lickers", false},                     // set #11
  64.             {"Lightning Snakes", false},            // set #18
  65.             {"Morlu Hell Witch", false},            // set #03
  66.             {"Oppressor Hell Witch", false},        // set #30
  67.             {"Red Archers", false},                 // set #17
  68.             {"Shamans", false},                     // set #28
  69.             {"Smoldering Construct", false},        // set #16
  70.             {"Spearmen", false},                    // set #05
  71.             {"Unburieds", false},                   // set #06
  72.         };
  73.        
  74.        
  75.         public static bool PlaySoundWhenDone { get; set; } = true;
  76.  
  77.         public static uint ActingInterval { get; set; } = 550;
  78.  
  79.         public static bool DebugPrints { get; set; } = true;
  80.  
  81.         public static bool ToggledOn { get; set; } = false;
  82.  
  83.        
  84.  
  85.         private enum FishingSteps {
  86.             ClickObelisk,
  87.             OpenGR,
  88.             DecideIfGRIsGood,
  89.             TalkToOrek,
  90.             CloseGR,
  91.             STEP_MAX,
  92.             STEP_INVALID,
  93.         }
  94.         private FishingSteps _currentStep = FishingSteps.STEP_INVALID;
  95.  
  96.         private uint _lastActed = 0;
  97.         private bool preloaded = false;
  98.  
  99.         private uint _timeoutInterval = 6000;
  100.  
  101.         private bool simpleLock = false;
  102.  
  103.         // When exiting a GR you can experience a weird bug in THUD and/or an unexpected state in the game.
  104.         // It will think you are still in a GR (according to IsInTown and SpecialArea) but the map name will be
  105.         // something weird like "DREADJUDGE'S REALM 1" or "ZHAR THE MAD'S REALM 1", and the current tile
  106.         // and the portals listed in Hud.Game.Portals will already be the town's portals, so obviously an exit
  107.         // was not found. I will detect this state by checking if one of the portals leads back to the GR.
  108.         private bool antiBugPortalFoundEarlierSignal = false;
  109.  
  110.         private void logthis(string message) {
  111.             if (DebugPrints) {
  112.                 Logger.info(message);
  113.             }
  114.         }
  115.  
  116.         private void moveMouseAndClick(float x, float y, bool shouldMoveMouse) {
  117.             if (x == 0 && y == 0) {
  118.                 return;
  119.             }
  120.             if (shouldMoveMouse) {
  121.                 InputSimulator.PostMouseMove((int)x, (int)y);
  122.             }
  123.             Thread.Sleep(30);
  124.             InputSimulator.PostMessageMouseClickLeft((int)x, (int)y);
  125.         }
  126.  
  127.         private void moveMouseAndClick(RectangleF rect, bool shouldMoveMouse) {
  128.             moveMouseAndClick((int)(rect.X + (rect.Width / 2)), (int)(rect.Y + (rect.Height / 2)), shouldMoveMouse);
  129.         }
  130.  
  131.         private void moveMouseAndClick(string uiPath, bool shouldMoveMouse) {
  132.             var rect = Hud.Render.GetOrRegisterAndGetUiElement(uiPath).Rectangle;
  133.             if (rect.X == 0 && rect.Y == 0) {
  134.                 rect = Hud.Render.GetOrRegisterAndGetUiElement(uiPath).Rectangle;
  135.                 if (rect.X == 0 && rect.Y == 0) {
  136.                 }
  137.                     logthis($"Couldn't get UI element for {uiPath}");
  138.             }
  139.             moveMouseAndClick(rect, shouldMoveMouse);
  140.         }
  141.  
  142.         // should return NEW TRISTRAM, GREATER RIFT 1, OREK'S DREAM 1, etc
  143.         IUiElement getAreaName() {
  144.             return Hud.Render.GetOrRegisterAndGetUiElement("Root.NormalLayer.minimap_dialog_backgroundScreen.minimap_dialog_pve.area_name");
  145.         }
  146.  
  147.         // the "Game Menu" button, located between the achievements button and the latency bar on the bottom.
  148.         // the 2nd dialogue option, useful for the "close gr" option when talking to Orek.
  149.         IUiElement getDialogueOption2Button() {
  150.             return Hud.Render.GetOrRegisterAndGetUiElement("Root.NormalLayer.interact_dialog_mainPage.interact_dialog_Background.stack.interact_button_2");
  151.         }
  152.  
  153.         private void preload() {
  154.             getAreaName();
  155.             getDialogueOption2Button();
  156.             Hud.Render.GetOrRegisterAndGetUiElement(UiPathConstants.Buttons.GAME_MENU);
  157.         }
  158.  
  159.         private bool isGRCurrentlyOpen() {
  160.             return Hud.Render.GreaterRiftBarUiElement.Visible;
  161.         }
  162.  
  163.         private bool isCurrentMapBattlefields() {
  164.             return Hud.Game.Me.Scene.SnoScene.Code.StartsWith("x1_pand_ext_120_edge");
  165.         }
  166.         private bool isCurrentMapFestering() {
  167.             return Hud.Game.Me.Scene.SnoScene.Code.StartsWith("px_festeringwoods_border");
  168.         }
  169.         private bool isCurrentMapSpire() {
  170.             return Hud.Game.Me.Scene.SnoScene.Code.StartsWith("a4dun_spire_corrupt");
  171.         }
  172.         private bool isCurrentMapDesert() {
  173.             return Hud.Game.Me.Scene.SnoScene.Code.StartsWith("px_desert_120_border");
  174.         }
  175.         private bool isCurrentMapDesolateSands() {
  176.             return Hud.Game.Me.Scene.SnoScene.Code.StartsWith("caout_boneyard");
  177.         }
  178.         private bool isCurrentMapFieldsOfMisery() {
  179.             return Hud.Game.Me.Scene.SnoScene.Code.StartsWith("px_tristramfields");
  180.         }
  181.         private bool isCurrentMapGraveyard() {
  182.             return Hud.Game.Me.Scene.SnoScene.Code.StartsWith("x1_westm_graveyard");
  183.         }
  184.  
  185.         private void tryClickingActor(ActorSnoEnum sno, string nameForDebug) {
  186.             bool found = false;
  187.             foreach (var actor in Hud.Game.Actors.ToList()) {
  188.                 if (actor.SnoActor != null && actor.SnoActor.Sno == sno) {
  189.                     logthis($"\tFound {nameForDebug}.");
  190.                     moveMouseAndClick(actor.ScreenCoordinate.X, actor.ScreenCoordinate.Y, true);
  191.                     found = true;
  192.                 }
  193.             }
  194.             if (!found) {
  195.                 logthis($"\tAutofishing Error - Didn't find {nameForDebug}.");
  196.                 ToggledOn = false;
  197.             }
  198.         }
  199.  
  200.         private bool isClickObeliskReady() {
  201.             return Hud.Game.IsInTown && !isGRCurrentlyOpen();
  202.         }
  203.  
  204.         private void executeClickObelisk() {
  205.             logthis("I will click the rift obelisk.");
  206.             tryClickingActor(ActorSnoEnum._x1_openworld_lootrunobelisk_b, "the Rift Obelisk");
  207.         }
  208.  
  209.         private bool isOpenGRReady() {
  210.             return Hud.Render.IsUiElementVisible(UiPathConstants.RiftObelisk.OBELISK_WINDOW);
  211.         }
  212.  
  213.         private void executeOpenGR() {
  214.             logthis("I will click \"start rift\".");
  215.             moveMouseAndClick(UiPathConstants.RiftObelisk.GREATER_RIFT_BUTTON, false);
  216.             moveMouseAndClick(UiPathConstants.RiftObelisk.ACCEPT_BUTTON, false);
  217.         }
  218.  
  219.         private bool isDecideIfGRIsGoodReady() {
  220.             return Hud.Game.SpecialArea == SpecialArea.GreaterRift;
  221.         }
  222.  
  223.         private void executeDecideIfGRIsGood() {
  224.             logthis("In greater rift. Should leave?");
  225.             bool shouldStay = false;
  226.  
  227.             if (shouldStay == false) {
  228.                 var text = getAreaName().ReadText(Encoding.ASCII, true);
  229.                 Logger.info($"\t\"Map Name\" = {text}");
  230.                 // Could be either OREK'S DREAM 1 or GREATER RIFT 1
  231.                 if (text.ToUpper().StartsWith("OREK")) {
  232.                     shouldStay = true;
  233.                 }
  234.                
  235.             }
  236.  
  237.             if (shouldStay == false) {
  238.                 if ((Battlefields && isCurrentMapBattlefields()) ||
  239.                     (Festering && isCurrentMapFestering()) ||
  240.                     (Spire && isCurrentMapSpire()) ||
  241.                     (Desert && isCurrentMapDesert()) ||
  242.                     (DesolateSands && isCurrentMapDesolateSands()) ||
  243.                     (FieldsOfMisery && isCurrentMapFieldsOfMisery()) ||
  244.                     (Graveyard && isCurrentMapGraveyard())
  245.                 ) {
  246.                     if (SkipBadMobsets) {
  247.                         var sets = ZysMobsetDetection.getMatchingMonsterSets(Hud);
  248.                         logthis ($"\tFound good map, checking mobset (found {sets.Count()} sets).");
  249.                         if (sets.Count == 0 || sets.Count == ZysMobsetDetection.MonsterSetList.Count) {
  250.                             logthis("\tDidn't find any mobs, will stay just in case.");
  251.                             shouldStay = true;
  252.                         } else if (sets.Count > 1) {
  253.                             logthis("\tFound more than one matching mobset.");
  254.                             shouldStay = GoodMobsets[sets.First().Name];
  255.                            
  256.                             bool ambiguous = false;
  257.                             foreach (var set in sets) {
  258.                                 if (GoodMobsets[set.Name] != shouldStay) {
  259.                                     logthis($"\tFound two possible sets with conflicting ____: {sets.First().Name} and {set.Name}.");
  260.                                     ambiguous = true;
  261.                                     shouldStay = true;
  262.                                     break;
  263.                                 }
  264.                             }
  265.                             if (ambiguous) {
  266.                                 logthis("\tWill stay due to ambiguity, just in case.");
  267.                                
  268.                             } else {
  269.                                 logthis($"\tAll possible monster sets are considered {(shouldStay ? "good" : "bad")}. Therefore I will {(shouldStay ? "stay" : "leave")}");
  270.                             }
  271.                         } else {
  272.                             var set = sets.First();
  273.                             logthis($"\tMobset is {set.Name}, which is considered {(GoodMobsets[set.Name] ? "Good" : "Bad")}.");
  274.                             shouldStay = GoodMobsets[set.Name];
  275.                         }
  276.                     } else {
  277.                         logthis("\tFound good map, disregarding mobset, will stay.");
  278.                         shouldStay = true;
  279.                     }
  280.                 } else {
  281.                     logthis($"\tIn bad map ({Hud.Game.Me.Scene.SnoScene.Code}), will leave.");
  282.                     shouldStay = false;
  283.                 }
  284.             }
  285.  
  286.            
  287.  
  288.             if (shouldStay) {
  289.                 logthis("Should stay, pausing the game.");
  290.                 if (PlaySoundWhenDone) {
  291.                     Hud.Sound.LoadSoundPlayer("notification_2.wav").Play();
  292.                 }
  293.                 moveMouseAndClick(UiPathConstants.Buttons.GAME_MENU, false);
  294.                 ToggledOn = false;
  295.             } else {
  296.                 logthis("Shouldn't stay, looking for portal out.");
  297.                 InputSimulator.PressKey(Settings.Keybinds[(int)ActionKey.Close]);
  298.                 var portals = Hud.Game.Portals.ToList()
  299.                     .Where(portal => portal.TargetArea.NameEnglish.Equals("Bastion's Keep Stronghold") ||
  300.                                         portal.TargetArea.NameEnglish.Equals("Hidden Camp") ||
  301.                                         portal.TargetArea.NameEnglish.Equals("New Tristram") ||
  302.                                         portal.TargetArea.NameEnglish.Equals("The Survivors' Enclave"))
  303.                     .OrderBy(portal => portal.CentralXyDistanceToMe);
  304.                 if (portals.Count() > 0) {
  305.                     var portal = portals.First();
  306.                     logthis($"\tFound a portal to {portal.TargetArea.NameEnglish} which is {portal.CentralXyDistanceToMe} yards away.");
  307.                     antiBugPortalFoundEarlierSignal = true;
  308.                     moveMouseAndClick(portal.FloorCoordinate.ToScreenCoordinate().X,
  309.                             portal.FloorCoordinate.ToScreenCoordinate().Y - 20, true);
  310.                 } else {
  311.                     // See comment above the declaration for antiBugPortalFoundEarlierSignal
  312.                     if (antiBugPortalFoundEarlierSignal) {
  313.                         logthis("\tGame is in transition state - skipping.");
  314.                     } else {
  315.                         logthis("\tAutofishing Error - Couldn't find a portal that leads out of the rift.");
  316.                         moveMouseAndClick(UiPathConstants.Buttons.GAME_MENU, false);
  317.                         ToggledOn = false;
  318.                     }
  319.                 }
  320.             }
  321.         }
  322.  
  323.         private bool isTalkToOrekReady() {
  324.             return Hud.Game.IsInTown && (_currentStep == FishingSteps.DecideIfGRIsGood || isGRCurrentlyOpen());
  325.         }
  326.  
  327.         private void executeTalkToOrek() {
  328.             logthis("I will talk to Orek.");
  329.             tryClickingActor(ActorSnoEnum._x1_lr_nephalem, "Orek");
  330.         }
  331.  
  332.         private bool isCloseGRReady() {
  333.             if (!Hud.Game.IsInTown) {
  334.                 return false;
  335.             }
  336.             var uiElement = getDialogueOption2Button();
  337.             if (!uiElement.Visible) {
  338.                 return false;
  339.             }
  340.             return true; // uiElement.ReadText(Encoding.ASCII, true).Equals("Close Greater Rift");
  341.         }
  342.  
  343.         private void executeCloseGR() {
  344.             logthis("I will tell Orek to close the GR.");
  345.             getDialogueOption2Button().Click();
  346.         }
  347.  
  348.         private void performAutoFishingStep() {
  349.             if (!preloaded) {
  350.                 preload();
  351.                 preloaded = true;
  352.             }
  353.  
  354.             uint currentTime = (uint)DateTimeOffset.Now.ToUnixTimeMilliseconds();
  355.  
  356.  
  357.             if (currentTime - _lastActed > _timeoutInterval) {
  358.                 logthis($"timed out - current time = {currentTime}, last acted = {_lastActed}");
  359.                 _currentStep = FishingSteps.STEP_INVALID;
  360.             }
  361.  
  362.  
  363.             bool movedStep = false;
  364.             if (_currentStep == FishingSteps.STEP_INVALID) {
  365.                 movedStep = true;
  366.                 logthis("Refreshing step state.");
  367.                 if (!Hud.Game.IsInTown) {
  368.                     logthis("\tAutoFishing error - not in town and don't know what to do.");
  369.                     ToggledOn = false;
  370.                     return;
  371.                 } else if (isGRCurrentlyOpen()) {
  372.                     _currentStep = FishingSteps.TalkToOrek;
  373.                 } else {
  374.                     _currentStep = FishingSteps.ClickObelisk;
  375.                 }
  376.             }
  377.  
  378.            
  379.  
  380.             try {
  381.                 if (_currentStep == FishingSteps.ClickObelisk) {
  382.                     if (isOpenGRReady()) {
  383.                         logthis($"Progressing to step OpenGR");
  384.                         _currentStep = FishingSteps.OpenGR;
  385.                         movedStep = true;
  386.                     }
  387.                 } else if (_currentStep == FishingSteps.OpenGR) {
  388.                     if (isDecideIfGRIsGoodReady()) {
  389.                         logthis($"Progressing to step DecideIfGRIsGood");
  390.                         _currentStep = FishingSteps.DecideIfGRIsGood;
  391.                         antiBugPortalFoundEarlierSignal = false;
  392.                         movedStep = true;
  393.                     }
  394.                 } else if (_currentStep == FishingSteps.DecideIfGRIsGood) {
  395.                     if (isTalkToOrekReady()) {
  396.                         logthis($"Progressing to step TalkToOrek");
  397.                         _currentStep = FishingSteps.TalkToOrek;
  398.                         movedStep = true;
  399.                     }
  400.                 } else if (_currentStep == FishingSteps.TalkToOrek) {
  401.                     if (isCloseGRReady()) {
  402.                         logthis($"Progressing to step CloseGR");
  403.                         _currentStep = FishingSteps.CloseGR;
  404.                         antiBugPortalFoundEarlierSignal = false; // redundant
  405.                         movedStep = true;
  406.                     }
  407.                 } else if (_currentStep == FishingSteps.CloseGR) {
  408.                     if (isClickObeliskReady()) {
  409.                         logthis($"Progressing to step ClickObelisk");
  410.                         _currentStep = FishingSteps.ClickObelisk;
  411.                         movedStep = true;
  412.                     }
  413.                 }
  414.             } catch (Exception e) {
  415.                 Logger.error("AutoFishing Error in state check: " + e.ToString());
  416.                 ToggledOn = false;
  417.                 return;
  418.             }
  419.  
  420.  
  421.             if (!movedStep && (currentTime - _lastActed < ActingInterval)) {
  422.                 // logthis($"Didn't move to next step and we're still waiting for timeout on current step.");
  423.                 return;
  424.             }
  425.  
  426.             // logthis($"Making an action at {currentTime} (currentStep = {_currentStep}, movedStep = {movedStep})");
  427.             try {
  428.                 if (_currentStep == FishingSteps.ClickObelisk) {
  429.                     if (isClickObeliskReady()) {
  430.                         executeClickObelisk();
  431.                         _lastActed = currentTime;
  432.                     }
  433.                 } else if (_currentStep == FishingSteps.OpenGR) {
  434.                     if (isOpenGRReady()) {
  435.                         executeOpenGR();
  436.                         _lastActed = currentTime;
  437.                     }
  438.                 } else if (_currentStep == FishingSteps.DecideIfGRIsGood) {
  439.                     if (isDecideIfGRIsGoodReady()) {
  440.                         executeDecideIfGRIsGood();
  441.                         _lastActed = currentTime;
  442.                     }
  443.                 } else if (_currentStep == FishingSteps.TalkToOrek) {
  444.                     if (isTalkToOrekReady()) {
  445.                         executeTalkToOrek();
  446.                         _lastActed = currentTime;
  447.                     }
  448.                 } else if (_currentStep == FishingSteps.CloseGR) {
  449.                     if (isCloseGRReady()) {
  450.                         executeCloseGR();
  451.                         _lastActed = currentTime;
  452.                     }
  453.                 }
  454.  
  455.             } catch (Exception e) {
  456.                 Logger.error("AutoFishing Error in step execution: " + e.ToString());
  457.                 ToggledOn = false;
  458.                 return;
  459.             }
  460.         }
  461.  
  462.         public void AfterCollect() {
  463.             if (!ToggledOn) {
  464.                 simpleLock = false;
  465.                 return;
  466.             }
  467.  
  468.             if (Hud.Game.IsLoading) {
  469.                 return;
  470.             }
  471.  
  472.             if (simpleLock) {
  473.                 return;
  474.             }
  475.             simpleLock = true;
  476.             performAutoFishingStep();
  477.             simpleLock = false;
  478.         }
  479.  
  480.         // Copied code from Zy's plugin, to make this plugin standalone.
  481.         private class ZysMobsetDetection {
  482.             public class MonsterSet
  483.             {
  484.                 public MonsterSet()
  485.                 {
  486.                     Index = 0;
  487.                     Name = "unknown";
  488.                 }
  489.                 public MonsterSet(uint Index_, string Name_, List<string> Monsters_)
  490.                 {
  491.                     Index = Index_;
  492.                     Name = Name_;
  493.                     Monsters = Monsters_;
  494.                 }
  495.  
  496.                 public uint Index { get; }
  497.                 public string Name { get; }
  498.                 public List<string> Monsters;
  499.             }
  500.  
  501.             public static List<MonsterSet> MonsterSetList = new List<MonsterSet>{
  502.                 new MonsterSet(01, "Dark Berserker", new List<string>
  503.                 { "Dark Berserker", "Dark Hellion", "Dark Skeletal Archer",  "Dark Summoner",  "Punisher",
  504.                     "Returned Executioner",  "Returned Shieldman",  "Revenant Soldier",  "Savage Fiend" ,  "Skeletal Beast" ,  "Skeleton" ,  "Tomb Guardian" }),
  505.  
  506.                 new MonsterSet(02, "Summoners", new List<string>
  507.                 { "Blazing Ghoul", "Corpse Worm", "Dark Skeletal Archer", "Deranged Cultist", "Dust Imp", "Grim Wraith", "Grotesque", "Hulking Phasebeast",
  508.                     "Quill Fiend", "Risen", "Skeletal Archer", "Skeletal Executioner", "Skeletal Shieldbearer", "Skeleton", "Tomb Guardian", "Unburied"}),
  509.  
  510.                 new MonsterSet(03, "Morlu Hell Witch", new List<string>
  511.                 { "Bile Crawler","Corrupted Angel", "Demonic Hellflyer", "Gloom Wraith", "Hell Witch", "Mallet Lord", "Morlu Incinerator", "Morlu Legionnaire"}),
  512.  
  513.                 new MonsterSet(04, "Boggen Trappers ", new List<string>
  514.                 { "Bogan Trapper", "Boggit", "Dark Moon Clan Impaler", "Dark Moon Clan Shaman", "Dark Moon Clan Warrior", "Fallen Hellhound", "Fallen Lunatic",
  515.                     "Fallen Slavelord", "Lacuni Slasher", "Lacuni Stalker", "Tusked Bogan"}),
  516.  
  517.                 new MonsterSet(05, "Spearman", new List<string>
  518.                 { "Blood Clan Sorcerer", "Blood Clan Spearman", "Blood Clan Warrior", "Colossal Golgor", "Death Maiden", "Fallen Soldier", "Herald of Pestilence",
  519.                     "Revenant Shield Guard", "Summoned Archer", "Summoned Shield Guard", "Tormented Stinger"}),
  520.  
  521.                 new MonsterSet(06, "Unburieds", new List<string>
  522.                 { "Carrion Bat", "Dark Moon Clan Shaman", "Darkmoth", "Ghoul", "Moon Clan Impaler", "Moon Clan Shaman", "Moon Clan Warrior", "Skeleton", "Unburied"}),
  523.  
  524.                 new MonsterSet(07, "Red Spiders", new List<string>
  525.                 { "Armored Destroyer", "Colossal Golgor", "Corrupted Angel", "Dark Hellion", "Disentombed Hulk", "Enslaved Nightmare", "Exarch", "Fiery Spiderling",
  526.                     "Lacuni Huntress", "Lacuni Stalker", "Mallet Lord", "Oppressor", "Revenant Soldier", "Scorching Creeper", "Summoned Archer", "Winged Assassin"}),
  527.  
  528.                 new MonsterSet(08, "Big Spiders", new List<string>
  529.                 { "Dark Hellion", "Darkmoth", "Death Maiden", "Moon Clan Shaman", "Stinging Swarm", "Stygian Crawler", "Summoned Archer", "Summoned Shield Guard",
  530.                     "Tormented Stinger", "Toxic Lurker", "Webspitter Spider"}),
  531.  
  532.                 new MonsterSet(09, "Hulks", new List<string>
  533.                 { "Dark Skeletal Archer", "Disentombed Hulk", "Dust Biter", "Dust Eater", "Dust Imp", "Enraged Phantom", "Frost Guardian", "Inferno Zombie", "Lacuni Stalker",
  534.                     "Murderous Fiend", "Ravenous Dead", "Retching Cadaver", "Revenant Shield Guard", "Sand Dweller", "Smoldering Construct", "Vicious Mangler"}),
  535.  
  536.                 new MonsterSet(10, "Transformers", new List<string>
  537.                 { "Dark Berserker", "Dark Cultist", "Dark Hellion", "Dark Summoner", "Dark Vessel", "Death Maiden", "Quill Fiend", "Revenant Archer", "Revenant Shield Guard", "Revenant Soldier",
  538.                     "Unburied", "Unholy Thrall"}),
  539.  
  540.                 new MonsterSet(11, "Lickers", new List<string>
  541.                 { "Abomination", "Brood Hatchling", "Copperfang Lurker", "Deathly Haunt", "Fallen Grunt", "Fallen Mongrel", "Fallen Overlord", "Fallen Prophet",
  542.                     "Noxious Guardian", "Soul Lasher", "Spellwinder"}),
  543.  
  544.                 new MonsterSet(12, "Blue Fallen", new List<string>
  545.                 { "Blazing Swordwielder", "Chilling Construct", "Demon Raider", "Exorcist", "Fallen Master", "Returned Executioner", "Reviled", "Skeletal Archer",
  546.                     "Skeletal Raider", "Spine Lasher", "Vengeful Summoner", "Vile Revenant"}),
  547.  
  548.                 new MonsterSet(13, "Lacuni Phasebeast", new List<string>
  549.                 { "Corpse Worm", "Grotesque", "Hungry Corpse", "Hungry Torso", "Imp", "Lacuni Huntress", "Ravenous Dead", "Retching Cadaver", "Returned", "Returned Archer",
  550.                     "Returned Executioner", "Returned Shieldman", "Returned Summoner", "Summoned Soldier", "Unholy Thrall", "Warping Horror"}),
  551.  
  552.                 new MonsterSet(14, "Ghosts", new List<string>
  553.                 { "Dark Zealot", "Enraged Phantom", "Ghastly Gravedigger", "Ghostly Murderer", "Horned Charger", "Moon Clan Ghost", "Pain Monger", "Shadow Vermin",
  554.                     "Summoned Archer", "Warping Horror", "Winged Assassin"}),
  555.  
  556.                 new MonsterSet(15, "Red Fallen", new List<string>
  557.                 { "Anarch", "Carrion Bat", "Death Maiden", "Fallen", "Fallen Hound", "Fallen Lunatic", "Fallen Overseer", "Fallen Shaman", "Scarab", "Skeletal Archer", "Summoned Archer",
  558.                     "Summoned Shield Guard", "Summoned Soldier"}),
  559.  
  560.                 new MonsterSet(16, "Smoldering Construct", new List<string>
  561.                 { "Accursed Hellion", "Dark Hellion", "Decayer", "Demon Trooper", "Enraged Phantom", "Foul Conjurer", "Quill Fiend", "Smoldering Construct", "Spewing Horror",
  562.                     "Stygian Crawler", "Voracious Zombie"}),
  563.  
  564.                 new MonsterSet(17, "Red Archers", new List<string>
  565.                 { "Betrayed", "Bile Crawler", "Canine Bones", "Corpse Raiser", "Corrupted Angel", "Darkmoth", "Death Maiden", "Exarch", "Exorcist", "Hellhide Tremor",
  566.                     "Hungering Bones", "Risen Bones", "Skeletal Ranger", "Spitting Bones", "Summoned Archer", "Summoned Shield Guard", "Tormented Stinger",
  567.                     "Vile Bat", "Winged Assassin"}),
  568.  
  569.                 new MonsterSet(18, "Lightning Snakes", new List<string>
  570.                 { "Blood Clan Mauler", "Blood Clan Sorcerer", "Canine Bones", "Corpse Raiser", "Corpse Worm", "Death Maiden", "Electric Eel", "Exarch", "Frenzied Lunatic",
  571.                     "Grotesque", "Hell Witch", "Hulking Phasebeast", "Hungering Bones", "Risen Bones", "Sand Wasp", "Scarab", "Serpent Magus", "Skeleton", "Spitting Bones",
  572.                     "Summoned Archer", "Summoned Shield Guard", "Terror Demon", "Vile Bat", "Writhing Deceiver"}),
  573.  
  574.                 new MonsterSet(19, "Slashers", new List<string>
  575.                 { "Accursed Hellion", "Blood Clan Impaler", "Blood Clan Mauler", "Bogan Trapper", "Fallen", "Fallen Shaman", "Foul Conjurer", "Herald of Pestilence",
  576.                     "Horror", "Lacuni Slasher", "Skeletal Raider", "Zap Worm"}),
  577.  
  578.                 new MonsterSet(20, "Small Spiders", new List<string>
  579.                 { "Arachnid Horror", "Bile Crawler", "Corpse Worm", "Exorcist", "Lacuni Huntress", "Moon Clan Impaler", "Spiderling"}),
  580.  
  581.                 new MonsterSet(21, "Big Bogans", new List<string>
  582.                 { "Armored Destroyer", "Bogan Trapper", "Boggit", "Demon Trooper", "Enslaved Nightmare", "Lacuni Huntress", "Maggot", "Maggot Brood", "Mallet Lord", "Moon Clan Impaler",
  583.                     "Moon Clan Warrior", "Oppressor", "Shrieking Terror", "Tusked Bogan", "Vile Bat"}),
  584.  
  585.                 new MonsterSet(22, "Hellions", new List<string>
  586.                 { "Accursed", "Accursed Hellion", "Barbed Lurker", "Blood Clan Impaler", "Blood Clan Mauler", "Crazed Cultist", "Dark Hellion", "Deranged Cultist", "Foul Conjurer",
  587.                     "Lacuni Huntress", "Lacuni Warrior", "Mallet Lord", "Pain Monger", "Savage Fiend", "Shadow of Death", "Vicious Mangler"}),
  588.  
  589.                 new MonsterSet(23, "Swarms", new List<string>
  590.                 { "Blood Clan Impaler", "Brood Hatchling", "Darkmoth", "Dune Stinger", "Great Horned Goliath", "Hellhide Tremor", "Scarab", "Stygian Crawler", "Vile Swarm",
  591.                     "Vile Temptress", "Webspitter Spider", "Winged Assassin"}),
  592.  
  593.                 new MonsterSet(24, "Anarch Exarch", new List<string>
  594.                 { "Anarch", "Death Maiden", "Demon Trooper", "Exarch", "Executioner", "Summoned Archer", "Summoned Shield Guard", "Summoned Soldier", "Winged Assassin"}),
  595.  
  596.                 new MonsterSet(25, "Bee Accursed", new List<string>
  597.                 { "Accursed", "Corpse Worm", "Dune Stinger", "Fallen Conjurer", "Fallen Cur", "Fallen Peon", "Grotesque", "Noxious Guardian", "Reviled"}),
  598.  
  599.                 new MonsterSet(26, "Zombie Grotesque", new List<string>
  600.                 { "Corpse Worm", "Dark Hellion", "Dark Summoner", "Decayer", "Grotesque", "Hungry Corpse", "Hungry Torso", "Imp", "Punisher", "Ravenous Dead", "Retching Cadaver",
  601.                     "Returned", "Returned Archer", "Returned Executioner", "Returned Shieldman", "Returned Summoner"}),
  602.  
  603.                 new MonsterSet(27, "Frogs", new List<string>
  604.                 { "Anarch", "Burrowing Leaper", "Dark Hellion", "Dark Skeletal Archer", "Enraged Phantom", "Hungry Corpse", "Hungry Torso", "Maniacal Golgor",
  605.                     "Returned Executioner", "Scavenger", "Shock Guardian", "Skeletal Archer", "Skeleton", "Tomb Guardian"}),
  606.  
  607.                 new MonsterSet(28, "Shamans", new List<string>
  608.                 { "Brood Hatchling", "Crazed Summoner", "Dark Conjurer", "Fallen", "Fallen Firemage", "Fallen Shaman", "Fallen Slavelord", "Frenzied Hellion",
  609.                     "Herald of Pestilence", "Quill Fiend", "Skeletal Ranger", "Soul Ripper", "Subjugator", "Unburied", "Vicious Ghoul", "Vicious Hellion"}),
  610.  
  611.                 new MonsterSet(29, "Armored Destroyer", new List<string>
  612.                 { "Anarch", "Armored Destroyer", "Blood Clan Warrior", "Canine Bones", "Corpse Raiser", "Demonic Hellflyer", "Demon Trooper", "Hungering Bones", "Morlu Incinerator",
  613.                     "Plague Carrier", "Risen Bones", "Sand Wasp", "Shade Stalker", "Skeletal Beast", "Spitting Bones", "Terror Demon", "Vile Bat", "Winged Assassin"}),
  614.  
  615.                 new MonsterSet(30, "Oppressor Hell Witch", new List<string>
  616.                 { "Blazing Ghoul", "Fallen Overseer", "Moon Clan Impaler", "Oppressor", "Subjugator", "Vile Temptress"}),
  617.  
  618.                 new MonsterSet(31, "Blazing Guardian", new List<string>
  619.                 { "Barbed Lurker", "Bile Crawler", "Blazing Guardian", "Dark Berserker", "Dark Hellion", "Grim Wraith", "Hulking Phasebeast", "Hungry Corpse", "Hungry Torso", "Inferno Zombie",
  620.                     "Murderous Fiend", "Returned Archer", "Skeletal Raider"}),
  621.  
  622.                 new MonsterSet(32, "Ice Clan", new List<string>
  623.                 { "Frost Maggot", "Glacial Colossus", "Ice Clan Impaler", "Ice Clan Shaman", "Ice Clan Warrior", "Ice Porcupine"}),
  624.  
  625.                 new MonsterSet(33, "Petting Zoo", new List<string>
  626.                 { "Arachnid Horror", "Bone Warrior", "Dark Berserker", "Dark Cultist", "Enraged Phantom", "Fallen Conjurer", "Horned Charger", "Oppressor", "Quill Fiend",
  627.                     "Savage Beast", "Scavenger", "Skeleton", "Tomb Guardian"})
  628.  
  629.                 };
  630.  
  631.                 public static List<MonsterSet> getMatchingMonsterSets(IController Hud) {
  632.                     HashSet<string> MonstersOnTheScreen = new HashSet<string>();
  633.  
  634.                     var monsters = Hud.Game.AliveMonsters.Where(m => (!m.IsElite));
  635.                     foreach (var monster in monsters)
  636.                     {
  637.                         if (monster.Rarity == ActorRarity.Normal)
  638.                         {
  639.                             MonstersOnTheScreen.Add(monster.SnoMonster.NameEnglish);
  640.                         }
  641.                     }
  642.  
  643.                     var BadMonsters = new List<string>
  644.                     { "Shock Tower", "Hell Bringer", "Blazing Swordwielder", "Bloated Corpse", "Spiderling"};
  645.  
  646.                     foreach (string monstername in BadMonsters)
  647.                     {
  648.                         if (MonstersOnTheScreen.Contains(monstername))
  649.                         {
  650.                             MonstersOnTheScreen.Remove(monstername);
  651.                         }
  652.                     }
  653.                     List<MonsterSet> MatchingMonsterSets = new List<MonsterSet>();
  654.                     foreach (MonsterSet monsterset in MonsterSetList)
  655.                     {
  656.                         MatchingMonsterSets.Add(new MonsterSet(monsterset.Index, monsterset.Name, monsterset.Monsters));
  657.                     }
  658.  
  659.  
  660.                     List<MonsterSet> RemoveList = new List<MonsterSet>();
  661.  
  662.                     foreach (string monster in MonstersOnTheScreen)
  663.                     {
  664.                         foreach (MonsterSet monsterset in MatchingMonsterSets)//see if the monster fits the monsterset
  665.                         {
  666.                             //if monster is not in the monsterset delete the monsterset
  667.                             if (!monsterset.Monsters.Contains(monster))
  668.                             {
  669.                                 RemoveList.Add(monsterset);
  670.                             }
  671.                         }
  672.                         foreach (MonsterSet monsterset in RemoveList)
  673.                         {
  674.                             MatchingMonsterSets.Remove(monsterset);
  675.                         }
  676.                     }
  677.  
  678.                     return MatchingMonsterSets;
  679.                 }
  680.  
  681.         }
  682.     }
  683.  
  684.     public class ToggleAutoFishing : AbstractHotkeyAction {
  685.         public override HotkeyType type => HotkeyType.General;
  686.  
  687.         public bool FieldsOfMisery { get; set; } = true;
  688.         public bool Festering { get; set; } = true;
  689.         public bool Graveyard { get; set; } = true;
  690.         public bool Battlefields { get; set; } = true;
  691.         public bool DesolateSands { get; set; } = false;
  692.         public bool Spire { get; set; } = false;
  693.         public bool Desert { get; set; } = false;
  694.        
  695.         public bool SkipBadMobsets { get; set; } = false;
  696.         public bool PlaySoundWhenDone { get; set; } = true;
  697.         public uint ActingInterval { get; set; } = 850;
  698.         public bool DebugPrints { get; set; } = false;
  699.  
  700.  
  701.         protected override string GetAttributes() => $@"Battlefields: {Battlefields}, Festering: {Festering}, Spire: {Spire},
  702.        Desert: {Desert}, DesolateSands: {DesolateSands}, FieldsOfMisery: {FieldsOfMisery}, Graveyard: {Graveyard},
  703.        SkipBadMobsets: {SkipBadMobsets}, PlaySoundWhenDone: {PlaySoundWhenDone}, ActingInterval: {ActingInterval}, DebugPrints: {DebugPrints}";
  704.  
  705.         public override List<AbstractParameter> GetParameters()
  706.         {
  707.             return new List<AbstractParameter>{
  708.                 SimpleParameter<bool>.of(nameof(Battlefields), x => Battlefields = x),
  709.                 SimpleParameter<bool>.of(nameof(Festering), x => Festering = x),
  710.                 SimpleParameter<bool>.of(nameof(Spire), x => Spire = x),
  711.                 SimpleParameter<bool>.of(nameof(Desert), x => Desert = x),
  712.                 SimpleParameter<bool>.of(nameof(DesolateSands), x => DesolateSands = x),
  713.                 SimpleParameter<bool>.of(nameof(FieldsOfMisery), x => FieldsOfMisery = x),
  714.                 SimpleParameter<bool>.of(nameof(Graveyard), x => Graveyard = x),
  715.                 SimpleParameter<bool>.of(nameof(SkipBadMobsets), x => SkipBadMobsets = x),
  716.                 SimpleParameter<bool>.of(nameof(PlaySoundWhenDone), x => PlaySoundWhenDone = x),
  717.                 SimpleParameter<int>.of(nameof(ActingInterval), x => ActingInterval = (uint)x),
  718.                 SimpleParameter<bool>.of(nameof(DebugPrints), x => DebugPrints = x),
  719.             };
  720.         }
  721.  
  722.         public override bool PreconditionSatisfied(IController hud)
  723.         {
  724.             return true;
  725.         }
  726.  
  727.         public override string tooltip => "Toggle AutoFishing on/off.";
  728.  
  729.         public override void Invoke(IController hud)
  730.         {
  731.             AutoFishing.ToggledOn = !AutoFishing.ToggledOn;
  732.             AutoFishing.Battlefields = Battlefields;
  733.             AutoFishing.Festering = Festering;
  734.             AutoFishing.Spire = Spire;
  735.             AutoFishing.Desert = Desert;
  736.             AutoFishing.DesolateSands = DesolateSands;
  737.             AutoFishing.FieldsOfMisery = FieldsOfMisery;
  738.             AutoFishing.Graveyard = Graveyard;
  739.             AutoFishing.SkipBadMobsets = SkipBadMobsets;
  740.             AutoFishing.PlaySoundWhenDone = PlaySoundWhenDone;
  741.             AutoFishing.ActingInterval = ActingInterval;
  742.             AutoFishing.DebugPrints = DebugPrints;
  743.  
  744.  
  745.             Logger.info($"Autofishing is now {AutoFishing.ToggledOn}");
  746.         }
  747.     }
  748. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement