Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Object validation code/bitshifting/bitmasking


    Dorkinator

    Recommended Posts

    Posted

    This code is used for validation of weather or not an object can be interacted with. It's also a pretty good example of how bit shifting/masking work. The getAdjacent tile method is also a good introduction for getting a walkable tile from an unwalkable one.

     

    	public static final int W_N = 2;
    	public static final int W_SE = 16;
    	public static final int BLOCKED4 = 262144;
    	public static final int W_W = 128;
    	public static final int W_E = 8;
    	public static final int W_NE = 4;
    	public static final int W_SW = 16777216;
    	public static final int W_NW = 1;
    	public static final int W_S = 32;
    	public static final int BLOCKED2 = 2097152;
    	public static final int BLOCKED = 256;
    	public static final int WATER = 19398912;
    	public static final int WALKABLE = WATER | BLOCKED | BLOCKED2 | BLOCKED4 | BLOCKED;
    
    
    	public Tile normalizeTile(GameObject o){
    		int UID = o.getIndex();
    		return new Tile((UID & 0x7f) + c.getClient().getBaseX(), ((UID >> 7) & 0x7f) + c.getClient().getBaseY(), o.getPlane());
    	}
    
    	public ArrayList<Tile> getAjacentTiles(GameObject o){
    		ArrayList<Tile> out = new ArrayList<>();
    		int objWidth = o.getWidth();
    		Tile t = normalizeTile(o);
    		if (t != null) {
    			int x = -1;
    			int y = -1;
    			int dx = 0;
    			int dy = 1;
    			for (int i2 = 0; i2 < objWidth * 4; i2++) {
    				if ((dy > 0 && y >= objWidth - 1) || (dx > 0 && x >= objWidth-1) || (dy < 0 && y <= 0)) {
    					x += dx;
    					y += dy;
    					int tmp = dy;
    					dy = -dx;
    					dx = tmp;
    				}
    				x += dx;
    				y += dy;
    				out.add(new Tile(t.getX() + x, t.getY() + y, t.getZ()));
    			}
    		}
    		return out;
    	}
    
    	public boolean canInteractFrom(int width, Tile obj, Tile pos){
    		TileReference tRef = pos.getTileReference();
    		if(tRef != null) {
    			if (obj.getY() + width - 1 < pos.getY()) {
    				if ((tRef.getFlags() & (WALKABLE | W_N)) == 0) {
    					return true;
    				}
    				return false;
    			} else if (obj.getX() + width - 1 > pos.getX()) {
    				if ((tRef.getFlags() & (WALKABLE | W_E)) == 0) {
    					return true;
    				}
    				return false;
    			} else if (obj.getY() > pos.getY()) {
    				if ((tRef.getFlags() & (WALKABLE | W_S)) == 0) {
    					return true;
    				}
    				return false;
    			} else if (obj.getX() < pos.getX()) {
    				if ((tRef.getFlags() & (WALKABLE | W_W)) == 0) {
    					return true;
    				}
    				return false;
    			}
    		}
    		return false;
    	}
    
    	public boolean canInteractWith(GameObject o){
    		for(Tile i:getAjacentTiles(o)){
    			if(canInteractFrom(o.getWidth(), normalizeTile(o), i)){
    				if(c.getMap().canReach(i)){
    					return true;
    				}
    			}
    		}
    		return false;
    	}
    Posted

    Why is TileFlags obfuscated? And why you don't use CollisionMap?

    Posted

    Why are you not scripter yet? xD you clearly know you're shit

     

    Scripters have to release scripts lol.

    Posted

    Why are you not scripter yet? xD you clearly know you're shit

     

    Your*

     

    and yeah what roka said

    Posted

    Why are you not scripter yet? xD you clearly know you're shit

    and you clearly dont

    Posted

    and you clearly dont

    Shots fired.

     

    And Dorkinator's priority is to get his Farm running again

    Posted

    Shots fired.

     

    And Dorkinator's priority is to get his Farm running again

    Yeah I have 2 scripts that are ported and ready for release, my farms almost completely fixes.

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.