Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.rsbot.script.Script;
- import org.rsbot.script.wrappers.RSTile;
- import org.rsbot.script.wrappers.RSArea;
- public class TehXmasHillGiantKiller extends Script{
- private String status = "Starting Up...";
- public boolean onStart(){
- return true;
- }
- public void onFinish(){
- }
- // Enums for handling states.
- // This is handled in the loop, this is Action states, we want to do somthing in every specific state.
- private enum State {
- GO_BANK, BANK_ITEMS, GO_DUNGEON, ATTACK_GIANTS, UNK_0
- }
- // Location states are useful no matter what, we allways want script to know
- // what todo if we are at places we should not be, places we are and yeah.
- // All places should have a condition in getState() connected to the Location.
- private enum LocationState {
- AT_BANK, AT_DUNGEON, UNK_1
- }
- // Tiles, used in location handler and walking and such.
- RSTile bankTile = new RSTile(0000,0000);
- RSTile ladderTile = new RSTile(0000,0000);
- public int loop(){
- State stateSelector = getState();
- switch(stateSelector){
- case GO_BANK:
- // Walking method to walk to bank. Example: walking.walkPathMM(....) ...
- break;
- case BANK_ITEMS:
- // Banking code, to bank items. Example: bank.open() etc...
- break;
- case GO_DUNGEON:
- // Walking method to walk to mine. Example: walking.walkPathMM(....) ...
- break;
- case ATTACK_GIANTS:
- // Mining specific code. objects.getNearest(...) ... and etc....
- break;
- }
- return random(200,300);
- }
- /*
- * State handler. Should be pretty Ok. It checks what we want to do! Can,
- * but should not return UNK_0. Peec.
- * State handler is very important, here you should use conditions , if conditions and switches but dont handle walking and actions here.
- */
- private State getState() {
- // When getting action states, we would most sincerly like to know our current location to determine what to do!
- LocationState currentLoc = getCurrentLocation();
- // Bank state if full inventory. inventory.isFull() is the best for this check of banking.
- // Normally very good for defining if we need to go bank! Should be used
- // in most scripts =)
- if (inventory.isFull()) {
- // Now, we want to do difrent actions based on what locations we are @....
- switch (currentLoc) {
- // If we are @ bank, lets just use BANK_ITEMS
- case AT_BANK:
- return State.BANK_ITEMS;
- // But if we are @ mine or other places... Lets just walk to bank!
- case AT_DUNGEON:
- case UNK_1: // This is if we dont really know where we are.
- return State.GO_BANK;
- }
- // We do not have full inventory below. Lets create states for it.
- } else {
- // Now, we want to do difrent actions based on what locations we are @....
- switch (currentLoc) {
- // If we are @bank or any other place, lets just walk to Mine! GO_MINE
- case AT_BANK:
- case UNK_1:// This is if we dont really know where we are.
- return State.GO_DUNGEON;
- // However, if we are @ Mine, lets just MINE_ROCKS.
- case AT_DUNGEON:
- return State.ATTACK_GIANTS;
- }
- }
- // This should not be possible, but if it is , its a bug! I dont like
- // bugs so we better create handeleres for unknown states too!
- status = "Unknown state.";
- return State.UNK_0;
- }
- /*
- * Location state handler. Finds out where we are. But can return UNK_1 wich
- * means, it doesnt know where we are. Peec.
- */
- private LocationState getCurrentLocation() {
- RSArea Dungeon = new RSArea(new RSTile(2884, 4837), new RSTile(2901,
- 4859));
- /*
- * Here we handle diferent locations. You can also work with preferably RSArea and other things for
- * checking the current location!
- * UNK_1, thats a state for: We dont really know where we are.
- */
- // If @ bank
- if (calc.distanceBetween(bankTile, getMyPlayer().getLocation()) <= 3) {
- return LocationState.AT_BANK;
- }
- // If @ mine
- if (Dungeon.contains(getMyPlayer().getLocation())) {
- return LocationState.AT_DUNGEON;
- }
- // We dont really know the current location, handleres for this state
- // should be handled in the loop or less preferably in getState()
- return LocationState.UNK_1;
- }
- }
Add Comment
Please, Sign In to add comment