Dorkinator 64 Posted June 20, 2017 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; }
rokaHakor 171 Posted June 20, 2017 Why are you not scripter yet? xD you clearly know you're shit Scripters have to release scripts lol.
Banker 175 Posted June 20, 2017 Why are you not scripter yet? xD you clearly know you're shit Your* and yeah what roka said
Dinh 496 Posted June 20, 2017 Why are you not scripter yet? xD you clearly know you're shit and you clearly dont
Noidlox 11 Posted June 20, 2017 and you clearly dont Shots fired. And Dorkinator's priority is to get his Farm running again
Dorkinator 64 Author Posted June 20, 2017 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.