Created
August 24, 2011 03:52
-
-
Save Zalgo2462/1167270 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.rsbot.script.Script; | |
import org.rsbot.script.ScriptManifest; | |
import org.rsbot.script.internal.event.PaintListener; | |
import org.rsbot.script.methods.*; | |
import org.rsbot.script.wrappers.Area; | |
import org.rsbot.script.wrappers.Tile; | |
import java.awt.*; | |
import java.util.*; | |
@ScriptManifest(name = "Collisions", authors = {"Zalgo"}, description = "Detects collision flags and paints them on the screen.") | |
public class CollisionFlags extends Script implements PaintListener { | |
public enum Flag { | |
// WALL_NORTHWEST(0x1), | |
// WALL_NORTH(0x2), | |
// WALL_NORTHEAST(0x4), | |
// WALL_EAST(0x8), | |
// WALL_SOUTHEAST(0x10), | |
// WALL_SOUTH(0x20), | |
// WALL_SOUTHWEST(0x40), | |
// WALL_WEST(0x80), | |
// | |
// OBJECT_TILE(0x100), | |
WALL_BLOCK_NORTHWEST(0x200), | |
WALL_BLOCK_NORTH(0x400), | |
WALL_BLOCK_NORTHEAST(0x800), | |
WALL_BLOCK_EAST(0x1000), | |
WALL_BLOCK_SOUTHEAST(0x2000), | |
WALL_BLOCK_SOUTH(0x4000), | |
WALL_BLOCK_SOUTHWEST(0x8000), | |
WALL_BLOCK_WEST(0x10000), | |
OBJECT_BLOCK(0x20000), | |
DECORATION_BLOCK(0x40000), | |
WALL_ALLOW_RANGE_NORTHWEST(0x400000), | |
WALL_ALLOW_RANGE_NORTH(0x800000), | |
WALL_ALLOW_RANGE_NORTHEAST(0x1000000), | |
WALL_ALLOW_RANGE_EAST(0x2000000), | |
WALL_ALLOW_RANGE_SOUTHEAST(0x4000000), | |
WALL_ALLOW_RANGE_SOUTH(0x8000000), | |
WALL_ALLOW_RANGE_SOUTHWEST(0x10000000), | |
WALL_ALLOW_RANGE_WEST(0x20000000), | |
OBJECT_ALLOW_RANGE(0x40000000), | |
WATER(0x1280100), | |
NULL(0); | |
private int flag; | |
Flag(int flag){ | |
this.flag = flag; | |
} | |
public int getFlag() { | |
return this.flag; | |
} | |
public String toString() { | |
return this.name(); | |
} | |
} | |
@Override | |
protected int loop() { | |
return 10000; | |
} | |
public void onRepaint(Graphics graphics) { | |
try { | |
Area highlightArea = new Area( | |
Players.getLocal().getLocation().getX() - 10, Players.getLocal().getLocation().getY() - 10, | |
Players.getLocal().getLocation().getX() + 10, Players.getLocal().getLocation().getY() + 10); | |
for(Tile tile : highlightArea.getTileArray()) { | |
tile.draw(graphics, getColorsMap().get(getFlag(tile)), 0); | |
} | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
private Flag getFlag(Tile tile) { | |
Tile offset = Walking.getCollisionOffset(Game.getPlane()); | |
int[][] flags = Walking.getCollisionFlags(Game.getPlane()); | |
int tileFlag = flags[tile.getX() - (Game.getBaseX() + offset.getX())][tile.getY() - (Game.getBaseY() + offset.getY())]; | |
for(int iii = 0; iii < Flag.values().length; iii++) { | |
int flag = Flag.values()[iii].getFlag(); | |
if((flag & tileFlag) != 0) { | |
return Flag.values()[iii]; | |
} | |
} | |
return Flag.NULL; | |
} | |
private HashMap<Flag, Color> getColorsMap() { | |
HashMap<Flag, Color> map = new HashMap<Flag, Color>(); | |
map.put(Flag.DECORATION_BLOCK, Color.BLACK); | |
map.put(Flag.WALL_ALLOW_RANGE_EAST, Color.BLUE); | |
map.put(Flag.WALL_ALLOW_RANGE_NORTH, Color.BLUE); | |
map.put(Flag.WALL_ALLOW_RANGE_SOUTH, Color.BLUE); | |
map.put(Flag.WALL_ALLOW_RANGE_WEST, Color.BLUE); | |
map.put(Flag.WALL_ALLOW_RANGE_NORTHEAST, Color.BLUE); | |
map.put(Flag.WALL_ALLOW_RANGE_NORTHWEST, Color.BLUE); | |
map.put(Flag.WALL_ALLOW_RANGE_SOUTHEAST, Color.BLUE); | |
map.put(Flag.WALL_ALLOW_RANGE_SOUTHWEST, Color.BLUE); | |
map.put(Flag.OBJECT_ALLOW_RANGE, Color.GREEN); | |
map.put(Flag.OBJECT_BLOCK, Color.MAGENTA); | |
map.put(Flag.WALL_BLOCK_EAST, Color.RED); | |
map.put(Flag.WALL_BLOCK_NORTH, Color.RED); | |
map.put(Flag.WALL_BLOCK_SOUTH, Color.RED); | |
map.put(Flag.WALL_BLOCK_WEST, Color.RED); | |
map.put(Flag.WALL_BLOCK_NORTHEAST, Color.RED); | |
map.put(Flag.WALL_BLOCK_NORTHWEST, Color.RED); | |
map.put(Flag.WALL_BLOCK_SOUTHEAST, Color.RED); | |
map.put(Flag.WALL_BLOCK_SOUTHWEST, Color.RED); | |
map.put(Flag.WATER, Color.CYAN); | |
map.put(Flag.NULL, Color.WHITE); | |
return map; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment