static private Color inv_getColorOf(Point slot, LockedFastImage D3ScreenShot) { if (slot.X < 0 || slot.X > max_slot_x-1) throw new Exception("Invalid x parameter"); if (slot.Y < 0 || slot.Y > max_slot_y-1) throw new Exception("Invalid y parameter"); return D3ScreenShot[getMiddleCoordsOfSlot(slot)]; }
public int getNumberOfFreeInventorySlots(String module_name, bool random_sleep = true, int lowest_sleep = 100, int highest_sleep = 200) { if (!GameStateChecker.getInstance().current_game_state.ingame_flags.isinventoryOpen) { main.getInstance().writeToLog(module_name, "Can't right click on inventory. Inventory not open!"); return(-1); } LockedFastImage l = new LockedFastImage(Tools.D3ScreenShot()); int count = 0; for (int x = 0; x < 10; x++) { for (int y = 0; y < 6; y++) { Point slot = new Point(x, y); if (isFull(slot, l)) { count++; } } } return(slot_number - count); }
static public bool isInTown(LockedFastImage image = null) { Point pixel = new Point(258, 545); Point pixel2 = new Point(284, 546); Color c; if (image != null) { c = image[pixel]; } else { c = GetColorAt(pixel); } Color c2; if (image != null) { c2 = image[pixel2]; } else { c2 = GetColorAt(pixel2); } return(c.Name == PixelColors.getinstance().isInTown || isStashOpen(image) || c2.Name == PixelColors.getinstance().isInTown2); }
public int rightClickToAllFullPositions(String module_name, bool random_sleep = true, int lowest_sleep = 100, int highest_sleep = 200) { if (!GameStateChecker.getInstance().current_game_state.ingame_flags.isinventoryOpen) { main.getInstance().writeToLog(module_name, "Can't right click on inventory. Inventory not open!"); return(-1); } LockedFastImage l = new LockedFastImage(Tools.D3ScreenShot()); int clicks = 0; for (int x = 0; x < 10; x++) { for (int y = 0; y < 6; y++) { Point slot = new Point(x, y); if (isFull(slot, l)) { clicks++; rightClickOnSlot(slot, random_sleep, lowest_sleep, highest_sleep); } } } return(clicks); }
public GameState() { try { setFlags(); LockedFastImage image = new LockedFastImage(Tools.D3ScreenShot()); if (Tools.isCharScreen_RedEnterGameButton(image)) { game_state = GameStates.CharScreen_RedEnterGameButton; } else if (Tools.isCharScreen_GrayEnterGameButton(image)) { game_state = GameStates.CharScreen_GrayEnterGameButton; } else if (Tools.isDisconnectDienst(image)) { game_state = GameStates.DisconnectDienst; } else if (Tools.isInGame(image)) { game_state = GameStates.InGame; } else if (Tools.isLoadingScreen(image)) { game_state = GameStates.LoadingScreen; } else if (Tools.isLoginLoading(image)) { game_state = GameStates.LoginLoading; } else if (Tools.isloginScreen(image)) { game_state = GameStates.LoginScreen; } else { game_state = GameStates.Unknown; } if (game_state == GameStates.InGame) { setFlags(image); } image.Dispose(); } catch (Exception e) { game_state = GameStates.D3NotLoaded; } }
static private Color inv_getColorOf(Point slot, LockedFastImage D3ScreenShot) { if (slot.X < 0 || slot.X > max_slot_x - 1) { throw new Exception("Invalid x parameter"); } if (slot.Y < 0 || slot.Y > max_slot_y - 1) { throw new Exception("Invalid y parameter"); } return(D3ScreenShot[getMiddleCoordsOfSlot(slot)]); }
static public void writeEmtyInvColors() { LockedFastImage d3Shot = new LockedFastImage(Tools.D3ScreenShot()); String to_file = ""; for (int y = 0; y < max_slot_y; y++) { for (int x = 0; x < max_slot_x; x++) to_file += inv_getColorOf(new Point(x, y), d3Shot).Name + " "; to_file += Environment.NewLine; } System.IO.File.WriteAllText(file_name, to_file); }
static public bool isInGame(LockedFastImage image = null) { Point pixel = new Point(125, 598); Color c; if (image != null) { c = image[pixel]; } else { c = GetColorAt(pixel); } return(c.Name == PixelColors.getinstance().isInGame); }
static public void writeEmtyInvColors() { LockedFastImage d3Shot = new LockedFastImage(Tools.D3ScreenShot()); String to_file = ""; for (int y = 0; y < max_slot_y; y++) { for (int x = 0; x < max_slot_x; x++) { to_file += inv_getColorOf(new Point(x, y), d3Shot).Name + " "; } to_file += Environment.NewLine; } System.IO.File.WriteAllText(file_name, to_file); }
static public bool isStashOpen(LockedFastImage image = null) { Point pixel = new Point(167, 60); Color c; if (image != null) { c = image[pixel]; } else { c = GetColorAt(pixel); } return(c.Name == PixelColors.getinstance().isStashOpen); }
static public bool isCharScreen_GrayEnterGameButton(LockedFastImage image = null) { Point pixel = new Point(73, 262); Color c; if (image != null) { c = image[pixel]; } else { c = GetColorAt(pixel); } return(c.Name == PixelColors.getinstance().isCharScreen_GrayEnterGameButton); }
static public bool isLoginLoading(LockedFastImage image = null) { Point pixel = new Point(438, 401); Color c; if (image != null) { c = image[pixel]; } else { c = GetColorAt(pixel); } return(c.Name == PixelColors.getinstance().isLoginLoading); }
static public bool isDisconnectDienst(LockedFastImage image = null) { Point pixel = new Point(430, 381); Color c; if (image != null) { c = image[pixel]; } else { c = GetColorAt(pixel); } return(c.Name == PixelColors.getinstance().isDisconnectDienst); }
static public bool isloginScreen(LockedFastImage image = null) { Point pixel = new Point(278, 178); Color c; if (image != null) { c = image[pixel]; } else { c = GetColorAt(pixel); } return(c.Name == PixelColors.getinstance().isloginScreen); }
static public bool isDead(LockedFastImage image = null) { Point pixel = new Point(522, 502); Color c; if (image != null) { c = image[pixel]; } else { c = GetColorAt(pixel); } return(c.Name == PixelColors.getinstance().isDead); }
static public bool isNeedRep(LockedFastImage image = null) { Point pixel = new Point(585, 49); Color c; if (image != null) { c = image[pixel]; } else { c = GetColorAt(pixel); } return(c.Name == PixelColors.getinstance().isNeedRep1 || c.Name == PixelColors.getinstance().isNeedRep2); }
private void setFlags(LockedFastImage image = null) { if (image == null) { ingame_flags.inTown = false; ingame_flags.needRep = false; ingame_flags.isWPopen = false; ingame_flags.isDead = false; ingame_flags.isStashOpen = false; ingame_flags.isinventoryOpen = false; } else { ingame_flags.inTown = Tools.isInTown(image); ingame_flags.needRep = Tools.isNeedRep(image); ingame_flags.isWPopen = Tools.isWPopen(image); ingame_flags.isDead = Tools.isDead(image); ingame_flags.isStashOpen = Tools.isStashOpen(image); ingame_flags.isinventoryOpen = Tools.isInventoryOpen(image); } }
public GameState() { try { setFlags(); LockedFastImage image = new LockedFastImage(Tools.D3ScreenShot()); if (Tools.isCharScreen_RedEnterGameButton(image)) game_state = GameStates.CharScreen_RedEnterGameButton; else if (Tools.isCharScreen_GrayEnterGameButton(image)) game_state = GameStates.CharScreen_GrayEnterGameButton; else if (Tools.isDisconnectDienst(image)) game_state = GameStates.DisconnectDienst; else if (Tools.isInGame(image)) game_state = GameStates.InGame; else if (Tools.isLoadingScreen(image)) game_state = GameStates.LoadingScreen; else if (Tools.isLoginLoading(image)) game_state = GameStates.LoginLoading; else if (Tools.isloginScreen(image)) game_state = GameStates.LoginScreen; else game_state = GameStates.Unknown; if (game_state == GameStates.InGame) setFlags(image); image.Dispose(); } catch (Exception e) { game_state = GameStates.D3NotLoaded;} }
static public bool isInventoryOpen(LockedFastImage image = null) { Point pixel = new Point(672, 61); Color c; if (image != null) c = image[pixel]; else c = GetColorAt(pixel); return (c.Name == PixelColors.getinstance().isInventoryOpen); }
static public bool isNeedRep(LockedFastImage image = null) { Point pixel = new Point(585, 49); Color c; if (image != null) c = image[pixel]; else c = GetColorAt(pixel); return (c.Name == PixelColors.getinstance().isNeedRep1 || c.Name == PixelColors.getinstance().isNeedRep2); }
static public bool isDead(LockedFastImage image = null) { Point pixel = new Point(522, 502); Color c; if (image != null) c = image[pixel]; else c = GetColorAt(pixel); return (c.Name == PixelColors.getinstance().isDead); }
static public bool isCharScreen_GrayEnterGameButton(LockedFastImage image = null) { Point pixel = new Point(73, 262); Color c; if (image != null) c = image[pixel]; else c = GetColorAt(pixel); return (c.Name == PixelColors.getinstance().isCharScreen_GrayEnterGameButton); }
static public bool isInTown(LockedFastImage image = null) { Point pixel = new Point(258, 545); Point pixel2 = new Point(284, 546); Color c; if (image != null) c = image[pixel]; else c = GetColorAt(pixel); Color c2; if (image != null) c2 = image[pixel2]; else c2 = GetColorAt(pixel2); return (c.Name == PixelColors.getinstance().isInTown || isStashOpen(image) || c2.Name == PixelColors.getinstance().isInTown2); }
public bool isFull(Point slot, LockedFastImage D3Shot) { return !(inv_getColorOf(slot, D3Shot).Name == inventory_free_colors[slot.X, slot.Y].Name); }
static public bool isInGame(LockedFastImage image = null) { Point pixel = new Point(125, 598); Color c; if (image != null) c = image[pixel]; else c = GetColorAt(pixel); return (c.Name == PixelColors.getinstance().isInGame); }
static public bool isloginScreen(LockedFastImage image = null) { Point pixel = new Point(278, 178); Color c; if (image != null) c = image[pixel]; else c = GetColorAt(pixel); return (c.Name == PixelColors.getinstance().isloginScreen); }
public int getNumberOfFreeInventorySlots(String module_name, bool random_sleep = true, int lowest_sleep = 100, int highest_sleep = 200) { if (!GameStateChecker.getInstance().current_game_state.ingame_flags.isinventoryOpen) { main.getInstance().writeToLog(module_name, "Can't right click on inventory. Inventory not open!"); return -1; } LockedFastImage l = new LockedFastImage(Tools.D3ScreenShot()); int count = 0; for (int x = 0; x < 10; x++) for (int y = 0; y < 6; y++) { Point slot = new Point(x, y); if (isFull(slot, l)) count++; } return slot_number - count; }
static public List<Point> checkImageToD3(Bitmap imageToCheck, int number_of_results = 1, int x_speedUp = 1, int y_speedUp = 1, int begin_percent_x = 0, int end_percent_x = 100, int begin_percent_y = 0, int end_percent_y = 100, int fail = 0, LockedFastImage D3 = null ) { ImageChecker i; if (D3 != null) { i = new ImageChecker(D3, imageToCheck); } else { Bitmap b = D3ScreenShot(); if (b == null) return new List<Point>(); i = new ImageChecker(b, imageToCheck); } return i.bigContainsSmall(number_of_results, x_speedUp, y_speedUp, begin_percent_x, end_percent_x, begin_percent_y, end_percent_y, fail); }
public int readGoldFromInventory(String module_name, GameState gamestate) { try { if (!gamestate.ingame_flags.isinventoryOpen) { main.getInstance().writeToLog(module_name, "Can't read gold. Inventory not open!"); return -1; } LockedFastImage d3Shot = new LockedFastImage(Tools.D3ScreenShot()); List<GoldHelpClass> list = new List<GoldHelpClass>(); int number_fail = 10; //read 0 List<Point> p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_0.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) list.Add(new GoldHelpClass(tmp, 0)); //read 1 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_1.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) list.Add(new GoldHelpClass(tmp, 1)); //read 2 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_2.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) list.Add(new GoldHelpClass(tmp, 2)); //read 3 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_3.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) list.Add(new GoldHelpClass(tmp, 3)); //read 4 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_4.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) list.Add(new GoldHelpClass(tmp, 4)); //read 5 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_5.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) list.Add(new GoldHelpClass(tmp, 5)); //read 6 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_6.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) list.Add(new GoldHelpClass(tmp, 6)); //read 7 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_7.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) list.Add(new GoldHelpClass(tmp, 7)); //read 8 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_8.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) list.Add(new GoldHelpClass(tmp, 8)); //read 9 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_9.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) list.Add(new GoldHelpClass(tmp, 9)); return convertGoldHelpClassListToInt(list); } catch { return -1; } }
public bool isFull(Point slot, LockedFastImage D3Shot) { return(!(inv_getColorOf(slot, D3Shot).Name == inventory_free_colors[slot.X, slot.Y].Name)); }
public int readGoldFromInventory(String module_name, GameState gamestate) { try { if (!gamestate.ingame_flags.isinventoryOpen) { main.getInstance().writeToLog(module_name, "Can't read gold. Inventory not open!"); return(-1); } LockedFastImage d3Shot = new LockedFastImage(Tools.D3ScreenShot()); List <GoldHelpClass> list = new List <GoldHelpClass>(); int number_fail = 10; //read 0 List <Point> p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_0.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) { list.Add(new GoldHelpClass(tmp, 0)); } //read 1 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_1.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) { list.Add(new GoldHelpClass(tmp, 1)); } //read 2 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_2.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) { list.Add(new GoldHelpClass(tmp, 2)); } //read 3 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_3.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) { list.Add(new GoldHelpClass(tmp, 3)); } //read 4 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_4.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) { list.Add(new GoldHelpClass(tmp, 4)); } //read 5 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_5.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) { list.Add(new GoldHelpClass(tmp, 5)); } //read 6 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_6.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) { list.Add(new GoldHelpClass(tmp, 6)); } //read 7 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_7.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) { list.Add(new GoldHelpClass(tmp, 7)); } //read 8 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_8.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) { list.Add(new GoldHelpClass(tmp, 8)); } //read 9 p = Tools.checkImageToD3(new Bitmap(Image.FromFile("./config/Image/Common/gold_9.png")), 99, 1, 1, 68, 78, 48, 54, number_fail, d3Shot); foreach (Point tmp in p) { list.Add(new GoldHelpClass(tmp, 9)); } return(convertGoldHelpClassListToInt(list)); } catch { return(-1); } }
public int rightClickToAllFullPositions(String module_name, bool random_sleep = true, int lowest_sleep = 100, int highest_sleep = 200) { if (!GameStateChecker.getInstance().current_game_state.ingame_flags.isinventoryOpen) { main.getInstance().writeToLog(module_name, "Can't right click on inventory. Inventory not open!"); return -1; } LockedFastImage l = new LockedFastImage(Tools.D3ScreenShot()); int clicks = 0; for (int x = 0; x < 10; x++) for (int y = 0; y < 6; y++) { Point slot = new Point(x, y); if (isFull(slot, l)) { clicks++; rightClickOnSlot(slot, random_sleep, lowest_sleep, highest_sleep); } } return clicks; }
static public bool isDisconnectDienst(LockedFastImage image = null) { Point pixel = new Point(430, 381); Color c; if (image != null) c = image[pixel]; else c = GetColorAt(pixel); return (c.Name == PixelColors.getinstance().isDisconnectDienst); }
/// <summary> /// Constructor of the ImageChecker /// </summary> /// <param name="big_image">The image containing the small image.</param> /// <param name="small_image">The image located in the big image.</param> public ImageChecker(LockedFastImage big_image, Bitmap small_image) { this.big_image = big_image; this.small_image = new LockedFastImage(small_image); }
static public bool isLoginLoading(LockedFastImage image = null) { Point pixel = new Point(438, 401); Color c; if (image != null) c = image[pixel]; else c = GetColorAt(pixel); return (c.Name == PixelColors.getinstance().isLoginLoading); }
static public List <Point> checkImageToD3(Bitmap imageToCheck, int number_of_results = 1, int x_speedUp = 1, int y_speedUp = 1, int begin_percent_x = 0, int end_percent_x = 100, int begin_percent_y = 0, int end_percent_y = 100, int fail = 0, LockedFastImage D3 = null) { ImageChecker i; if (D3 != null) { i = new ImageChecker(D3, imageToCheck); } else { Bitmap b = D3ScreenShot(); if (b == null) { return(new List <Point>()); } i = new ImageChecker(b, imageToCheck); } return(i.bigContainsSmall(number_of_results, x_speedUp, y_speedUp, begin_percent_x, end_percent_x, begin_percent_y, end_percent_y, fail)); }