Page 1 of 6 123 ... LastLast
Results 1 to 10 of 55
Like Tree1Likes

Thread: Free gunning assist/bot

  1. #1
    Junior Member
    vincent is offline

    Posts
    16

    Free gunning assist/bot

    Releasing this as I am moving away from this game to other things, and this is the only bot I havn't sold to anyone.

    https://www.dropbox.com/s/4uhrwf3356...nning.rar?dl=1

    This is not a fully automated bot, it will simply place the arrows when the correct piece is next to a cannon and your cursor is already next to it.
    Only tested on max speed, you probably have to change your keybinds to place an arrow to include the X key (I dont think that's a default atleast) or edit it in the source code.

    I abandoned this project because I achieved #1 ult with it (Could only get to respected before) and havn't had a need to make it fully automatic.

    Source code is included
    Last edited by vincent; 04-28-2016 at 12:01 PM.
    ninjasZX likes this.

  2. #2
    Junior Member
    rekabdivad is offline

    Posts
    18
    lol chrome flagged it

  3. #3
    Senior Member
    Atothek is offline

    Posts
    278
    i would be careful download that

  4. #4
    Junior Member
    coolmoo is offline

    Posts
    13
    I will open it in my sandbox and test for you as Virustotal didnt find anything

  5. #5
    Junior Member
    vincent is offline

    Posts
    16
    I guess it must be because of 'suspicious' file extensions... (.bat) All source code is included, you can recompile it and can grab the official JNA jars if you think I tampered with those
    Last edited by vincent; 01-25-2016 at 06:49 PM.

  6. #6
    Captain Medals
    Mehfailz x3 is offline

    Posts
    2,227
    Removed the link.

    I will put it back in once Sticky verifies the bot.

    Until then: be careful
    Who do you think you are?



  7. #7
    Junior Member
    vincent is offline

    Posts
    16
    Quote Originally Posted by Mehfailz x3 View Post
    Removed the link.

    I will put it back in once Sticky verifies the bot.

    Until then: be careful
    Alright fair enough, I don't really like the idea that only a handful have access to it though, can I atleast keep up the source code as a harmless block of text?
    Spoiler: code
    Code:
    package bot;
    
    import java.awt.AWTException;
    import java.awt.Point;
    import java.awt.Robot;
    import java.awt.event.KeyEvent;
    import java.awt.image.BufferedImage;
    import java.io.IOException;
    import java.util.HashSet;
    import java.util.Set;
    
    import com.sun.jna.Memory;
    import com.sun.jna.Native;
    import com.sun.jna.Pointer;
    import com.sun.jna.platform.win32.GDI32;
    import com.sun.jna.platform.win32.User32;
    import com.sun.jna.platform.win32.WinDef.HBITMAP;
    import com.sun.jna.platform.win32.WinDef.HDC;
    import com.sun.jna.platform.win32.WinDef.HWND;
    import com.sun.jna.platform.win32.WinGDI;
    import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
    import com.sun.jna.platform.win32.WinNT.HANDLE;
    import com.sun.jna.platform.win32.WinUser.WNDENUMPROC;
    
    public class Gunnery {
    	
    	private static final int WASHING = -3482887;
    	private static final int DIRTY = -8242668;
    	private static final int LOADED = -64765;
    	private static final int BARREL = -4406049;
    	private static final int BUCKET = -14143168;
    	private static final int POWDER = -11136758;
    	private static final int WAD = -3753816;
    	private static final int SHOT = -11447196;
    	private static final int CRATE = -6258851;
    	private static final int CRATE_STONES = -8553865;
    	private static final int CRATE_FLOWERS = -2228224;
    	
    	private static final int startH = 107;
    	private static final int startW = 17;
    	
    	public static HWND current = null;
    	public static Robot robot;
    	public static int TILE_SIZE = 32;
    	public static int TILES = 13;
    	public static int BOARD_SIZE = TILES * TILE_SIZE;
    	
    	public static Set cannons = new HashSet<>();
    	@SuppressWarnings("unchecked")
    	public static Set[][] board = new HashSet[TILES][TILES];
    	public static void main(String[] args) throws IOException, InterruptedException, AWTException {
    		robot = new Robot();
    		while (true) {
    			User32.INSTANCE.EnumWindows(new WNDENUMPROC() {
    				@Override
    				public boolean callback(HWND hWnd, Pointer arg1) {
    					char[] windowText = new char[512];
    					User32.INSTANCE.GetWindowText(hWnd, windowText, 512);
    					String wText = Native.toString(windowText);
    					if (wText.startsWith("Puzzle Pirates - ")) {
    						current = hWnd;
    						processImage(capture(hWnd));
    					}
    					return true;
    				}
    			}, null);
    			Thread.sleep(5);
    		}
    	}
    	
    	public static class Cannon {
    		public final int fillX;
    		public final int fillY;
    		
    		public boolean needsBucket = false;
    		public boolean hasPowder = false;
    		public boolean hasWad = false;
    		public boolean loaded = false;
    		
    		public Cannon(int fillX, int fillY) {
    			this.fillX = fillX;
    			this.fillY = fillY;
    		}
    		
    		public void fill() {
    			if (fillX == 0) {
    				right();
    			} else {
    				left();
    			}
    		}
    	}
    	
    	public static Cannon getCannonByFillCoords(int fillX, int fillY) {
    		for (Cannon c : cannons) {
    			if (c.fillX == fillX && c.fillY == fillY) {
    				return c;
    			}
    		}
    		return null;
    	}
    	
    	public static Cannon getCannon(int x, int y) {
    		if (x >= 1 && x <= 3) {
    			return getCannonByFillCoords(0, y);
    		} else if (x >= 9 && x <= 11) {
    			return getCannonByFillCoords(12, y);
    		}
    		return null;
    	}
    	
    	public static void processImage(RGBAImage image) {
    		for (int x = 0; x < TILES; x++) {
    			for (int y = 0; y < TILES; y++) {
    				board[x][y] = new HashSet<>();
    			}
    		}
    		cannons.clear();
    		cannons.add(new Cannon(0, 3));
    		cannons.add(new Cannon(0, 9));
    		cannons.add(new Cannon(12, 3));
    		cannons.add(new Cannon(12, 9));
    		//TODO: We actually only need to screenshot/scan near the cannon where the cursor is, but we are probably going to make it fully automatic later and a full board scan will come in handy then
    		for (int x = 0; x < BOARD_SIZE; x++) {
    			for (int y = 0; y < BOARD_SIZE; y++) {
    				int piece = image.getRGB(x, y) | 0xff000000; //Alpha band
    				int bx = x / 32;
    				int by = y / 32;
    				switch (piece) {
    					case CRATE_STONES:
    					case CRATE_FLOWERS:
    					case CRATE:
    					case POWDER:
    					case WAD:
    					case SHOT:
    					case BUCKET:
    					case BARREL:
    					case LOADED:
    					case DIRTY:
    					case WASHING:
    						break;
    					default:
    						continue;
    				}
    				Cannon cannon = getCannon(bx, by);
    				if (cannon != null) {
    					if (piece == LOADED) {
    						cannon.loaded = true;
    					} else if (piece == SHOT) {
    						cannon.needsBucket = true;
    					} else if (piece == POWDER) {
    						cannon.hasPowder = true;
    					} else if (piece == WAD) {
    						cannon.hasWad = true;
    						if (x == 3 || x == 11) {
    							cannon.needsBucket = true;
    						}
    					} else if (piece == DIRTY) {
    						cannon.needsBucket = true;
    					}
    				}
    				board[bx][by].add(piece);
    			}
    		}
    		Point cursor = GetCursorPosInWindow();
    		if (cursor == null)
    			return;
    		int x = (cursor.x - startW) / TILE_SIZE;
    		int y = (cursor.y - startH) / TILE_SIZE;
    		Cannon c = getCannonByFillCoords(x, y);
    		if (c != null) {
    			if (c.loaded)
    				return;
    			if (c.needsBucket) {
    				if (board[x][y].contains(BUCKET)) {
    					c.fill();
    				}
    			} else if (c.hasWad) {
    				if (board[x][y].contains(SHOT)) {
    					c.fill();
    					
    				}
    			} else if (c.hasPowder) {
    				if (board[x][y].contains(WAD)) {
    					c.fill();
    					
    				}
    			} else {
    				if (board[x][y].contains(POWDER)) {
    					c.fill();
    				}
    			}
    		}
    	}
    	
    	public static Point GetCursorPosInWindow() {
    		long[] lpPoint = new long[1];
    		User32Extra.INSTANCE.GetCursorPos(lpPoint);
    		return User32Extra.INSTANCE.ScreenToClient(current, lpPoint) ? new Point((int) (lpPoint[0] & 0xffffffffL), (int) (lpPoint[0] >>> 32)) : null;
    	}
    	
    	static void left() {
    		//TODO: More human keypresses, there should be about a 40ms delay between press & release, and the next press can come before the last release
    		press(KeyEvent.VK_A);
    		press(KeyEvent.VK_X);
    		sleep(100);
    		press(KeyEvent.VK_D);
    		press(KeyEvent.VK_X);
    	}
    	
    	static void right() {
    		press(KeyEvent.VK_D);
    		press(KeyEvent.VK_X);
    		sleep(100);
    		press(KeyEvent.VK_A);
    		press(KeyEvent.VK_X);
    	}
    	
    	static void press(int code) {
    		if (!current.equals(User32.INSTANCE.GetForegroundWindow())) {
    			return;
    		}
    		robot.keyPress(code);
    		robot.keyRelease(code);
    	}
    	
    	public static void sleep(long millis) {
    		try {
    			Thread.sleep(millis);
    		} catch (InterruptedException e) {
    		}
    	}
    	
    	public static final class RGBAImage {
    		private final int w;
    		private final int[] buffer;
    		
    		public RGBAImage(BufferedImage image) {
    			//Convenience method for testing with saved images
    			this.w = image.getWidth();
    			this.buffer = new int[image.getHeight() * image.getWidth()];
    			for (int x = 0; x < image.getWidth(); x++) {
    				for (int y = 0; y < image.getHeight(); y++) {
    					buffer[x + y * w] = image.getRGB(x, y);
    				}
    			}
    		}
    		
    		public RGBAImage(Memory memory, int w, int h) {
    			this.w = w;
    			//Faster than using BufferedImage because that copies pixel by pixel and converts color model
    			this.buffer = memory.getIntArray(0, w * h);
    		}
    		
    		public final int getRGB(int x, int y) {
    			return buffer[x + y * w];
    		}
    		
    	}
    	
    	public static RGBAImage capture(HWND hWnd) {
    		HDC hdcWindow = User32.INSTANCE.GetDC(hWnd);
    		HDC hdcMemDC = GDI32.INSTANCE.CreateCompatibleDC(hdcWindow);
    		
    		HBITMAP hBitmap = GDI32.INSTANCE.CreateCompatibleBitmap(hdcWindow, BOARD_SIZE, BOARD_SIZE);
    		
    		HANDLE hOld = GDI32.INSTANCE.SelectObject(hdcMemDC, hBitmap);
    		GDI32Extra.INSTANCE.BitBlt(hdcMemDC, 0, 0, BOARD_SIZE, BOARD_SIZE, hdcWindow, startW, startH, WinGDIExtra.SRCCOPY);
    		
    		GDI32.INSTANCE.SelectObject(hdcMemDC, hOld);
    		GDI32.INSTANCE.DeleteDC(hdcMemDC);
    		
    		BITMAPINFO bmi = new BITMAPINFO();
    		bmi.bmiHeader.biWidth = BOARD_SIZE;
    		bmi.bmiHeader.biHeight = -BOARD_SIZE;
    		bmi.bmiHeader.biPlanes = 1;
    		bmi.bmiHeader.biBitCount = 32;
    		bmi.bmiHeader.biCompression = WinGDI.BI_RGB;
    		
    		Memory buffer = new Memory(BOARD_SIZE * BOARD_SIZE * 4);
    		GDI32.INSTANCE.GetDIBits(hdcWindow, hBitmap, 0, BOARD_SIZE, buffer, bmi, WinGDI.DIB_RGB_COLORS);
    		
    		RGBAImage image = new RGBAImage(buffer, BOARD_SIZE, BOARD_SIZE);
    		
    		GDI32.INSTANCE.DeleteObject(hBitmap);
    		User32.INSTANCE.ReleaseDC(hWnd, hdcWindow);
    		return image;
    	}
    }
    
    
    package bot;
    
    import com.sun.jna.Native;
    import com.sun.jna.platform.win32.GDI32;
    import com.sun.jna.platform.win32.WinDef.DWORD;
    import com.sun.jna.platform.win32.WinDef.HDC;
    import com.sun.jna.win32.W32APIOptions;
    
    public interface GDI32Extra extends GDI32 {
    
        GDI32Extra INSTANCE = (GDI32Extra) Native.loadLibrary("gdi32", GDI32Extra.class, W32APIOptions.DEFAULT_OPTIONS);
    
        public boolean BitBlt(HDC hObject, int nXDest, int nYDest, int nWidth, int nHeight, HDC hObjectSource, int nXSrc, int nYSrc, DWORD dwRop);
    
    }
    
    package bot;
    
    import com.sun.jna.Native;
    import com.sun.jna.platform.win32.User32;
    import com.sun.jna.win32.W32APIOptions;
    
    public interface User32Extra extends User32 {
    	
    	User32Extra INSTANCE = (User32Extra) Native.loadLibrary("user32", User32Extra.class, W32APIOptions.DEFAULT_OPTIONS);
    	
    	public HDC GetWindowDC(HWND hWnd);
    	
    	public boolean GetClientRect(HWND hWnd, RECT rect);
    	
    	public boolean GetCursorPos(long[] lpPoint);
    	
    
    	HWND WindowFromPoint(long point);
    	
    	public boolean ScreenToClient(HWND hWnd, long[] lpPoint);
    	
    
    }
    
    
    package bot;
    
    
    import com.sun.jna.platform.win32.WinDef.DWORD;
    import com.sun.jna.platform.win32.WinGDI;
    
    public interface WinGDIExtra extends WinGDI {
    
        public DWORD SRCCOPY = new DWORD(0x00CC0020);
    
    }


    Also the chrome warning seems to purely come due to uppit... So please put up a mirror instead once its verified

    Goodbye
    Last edited by vincent; 01-25-2016 at 07:40 PM.

  8. #8
    Captain Medals
    Mehfailz x3 is offline

    Posts
    2,227
    Alright, looks legit.

    @vincent: You should upload it as a .rar , the problem might disappear that way.
    Who do you think you are?



  9. #9
    Junior Member
    vincent is offline

    Posts
    16
    Quote Originally Posted by Mehfailz x3 View Post
    Alright, looks legit.

    @vincent: You should upload it as a .rar , the problem might disappear that way.
    It already was a .rar, but Chrome seemed fine with the exact same file on other sites, but it doesn't seem to complain about uppit either now. Does anyone else get warnings?

  10. #10
    Senior Member
    Atothek is offline

    Posts
    278
    Downloaded, unzipped, the bot file opens the command screen and does nothing, and both java files don't open...

Page 1 of 6 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •