Jump to content

KlaAz0r

Members
  • Posts

    16
  • Joined

  • Last visited

  • Feedback

    0%

Profile Information

  • Gender
    Male

Recent Profile Visitors

683 profile views

KlaAz0r's Achievements

Newbie

Newbie (1/10)

0

Reputation

  1. figured that out, what I did was: if (BANK_AREA.contains(myPlayer().getPosition().getX(), myPlayer() .getPosition().getY(), 0) && inventory.isEmpty()) return State.WALKING_TO_UPPER_STAIRS; if (myPlayer().getPosition().getZ() == 1 && inventory.isEmpty()) return State.GOING_DOWN_STAIRS;
  2. Fixed the areas, but still seem to have a problem with walking, I get the bot to start walking when it is at the bank with an empty inventory but once it is at the stairs it stops localWalker.walkPath(fromBankToStairs); localWalker.waitUntilIdle(); Player player = myPlayer(); log(localWalker.toString()); if (UPPER_STAIRCASE_AREA.contains(myPlayer())) { log("we are at the stairs!"); objects.closest("Staircase").interact("Climb-down"); int z = player.getPosition().getZ(); if (z == 1) { objects.closest("Staircase").interact("Climb-down"); } } else { log("we are lost again.."); }
  3. So I got banking working, fighting and other things, but I come across a problem, walking to stairs and then going up them. localWalker.walkPath(fromBankToStairs); Player player = myPlayer(); int x = player.getPosition().getX(); int y = player.getPosition().getY(); if ((x > 3205) && (x < 3207) && (y > 3209) && (y < 3211)) { log("x : " + x + " y : " + y); log("we are at the stairs!"); objects.closest("Staircase").interact("Climb-down"); int z = player.getPosition().getZ(); if (z == 1) { objects.closest("Staircase").interact("Climb-down"); } } else { log("we are lost again.."); } What I did is walk to the stairs and if the player is near the stairs it should go down, but this does not working, does localWalker have a callback to see if the path is fully walked and then continue the script?
  4. case WALKING_TO_FIELDS: log("we should walk back to the fields!"); localWalker.walkPath(fromBankToStairs); Player player = myPlayer(); int x = player.getPosition().getX(); int y = player.getPosition().getY(); if ((x > 3205) && (x < 3207) && (y > 3209) && (y < 3211)) { log("x : " + x + " y : " + y); log("we are at the stairs!"); objects.closest("Staircase").interact("Climb-down"); int z = player.getPosition().getZ(); if (z == 1) { objects.closest("Staircase").interact("Climb-down"); } } else { log("we are lost again.."); } break; How do I walk to the stairs and wait till I am their before I interact with them? sometimes the script wants to go to the other stair
  5. Made an update! for now I am stuck on the point if we are in combat, should a use a State for that or just leave it?
  6. Thank you very much, I de-compiled a few scripts and discovered how the combat system works. Will work on this tomorrow and will post the final thing if it works
  7. Hey guys, today I started taking a look at script writing and I came across a few problems. My idea is to create a Lumbridge cow killer (just for learning) I get the idea of working in states en switches. But how do I make a path and walk stairs in them for example? path.WALK_TO_STAIR --> INTERACT.stairs --> path.WALK_TO_BANK or can I interact with objects in localWalker? the code below is just thrown together and not tested but I hope some one can tell me if this is going the right way UPDATE: So I worked out some things, the script checks if we are at the cow fields and then attacks the closest cow if it is not already in combat or the hit points are zero. but what should the script do while the player is in combat? package bot; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.model.Player; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(author = "KlaAz0r", info = "My first script", name = "Cow Killer", version = 0.01, logo = "") public class main extends Script { @Override public void onStart() { log("Welcome to Simple Cow killer"); } // all the states we can be in private enum State { GOING_DOWN_STAIRS, IDLE, IN_COMBAT, AT_COWS, ATTACKING_COW, AT_BANK, WALKING_FIELD_TO_STAIRS, GOING_UP_STAIRS, WALKING_TO_BANK, WALKING_BANK_TO_STAIRS, WALKING_STAIRS_TO_FIELDS, BANKING }; // check if the player is at the bank public boolean atBank() { Player player = myPlayer(); int x = player.getPosition().getX(); int y = player.getPosition().getY(); // NOT THE RIGHT COORDS YET! if ((x > 3426) && (x < 3431) && (y > 2889) && (y < 2894)) { return true; } return false; } // check if the player is at the fields public boolean atField() { Player player = myPlayer(); int x = player.getPosition().getX(); int y = player.getPosition().getY(); if ((x > 3253) && (x < 3265) && (y > 3255) && (y < 3298)) { log("x : " + x + " y : " + y); log("we are at the fields!"); return true; } log("x : " + x + " y : " + y); log("we are lost!"); return false; } // checking if we are in combat public boolean inCombat() { if (myPlayer().isUnderAttack()) { log("we are in combat"); return true; } log("we are not in combat"); return false; } // if a cow is near, we wil attack it public void killingCow() { NPC cow = npcs.closest("Cow"); if (cow != null && cow.getHealth() != 0 && cow.isAttackable() && cow.getName().contains("Cow")) { if (map.canReach(cow)) { log("attacking cow!"); cow.interact("Attack"); } } else { log("no cow found!"); } } // getting the state we are in private State getState() { // so if we are at the fields and are not in combat the state will be // ATTACKING_COW if (atField() && !inCombat()) return State.ATTACKING_COW; // if we are under attack the state will go to IN_COMBAT if (myPlayer().isUnderAttack()) return State.IN_COMBAT; // if we are at the fields and our inventory is full we should start // walking to the lumbridge stairs if (inventory.isFull() && atField()) return State.WALKING_FIELD_TO_STAIRS; // if we are at the bank and our inventory is still full we should start // banking if (atBank() && inventory.isFull()) return State.BANKING; // if we are at the bank and the inventory is empty we should start // making our way to the stairs again if (atBank() && inventory.isEmpty()) return State.WALKING_BANK_TO_STAIRS; // error state if nothing return State.IDLE; } // all the walking paths NYI private Position[] fieldToStairs = { new Position(3254, 3421, 0), new Position(3256, 3428, 0), new Position(3264, 3428, 0), new Position(3273, 3428, 0), new Position(3277, 3426, 0), new Position(3281, 3422, 0) }; private Position[] stairsToBank = { new Position(3254, 3421, 0), new Position(3256, 3428, 0), new Position(3264, 3428, 0), new Position(3273, 3428, 0), new Position(3277, 3426, 0), new Position(3281, 3422, 0) }; private Position[] bankToStairs = { new Position(3254, 3421, 0), new Position(3256, 3428, 0), new Position(3264, 3428, 0), new Position(3273, 3428, 0), new Position(3277, 3426, 0), new Position(3281, 3422, 0) }; private Position[] stairsToField = { new Position(3254, 3421, 0), new Position(3256, 3428, 0), new Position(3264, 3428, 0), new Position(3273, 3428, 0), new Position(3277, 3426, 0), new Position(3281, 3422, 0) }; @Override public int onLoop() throws InterruptedException { switch (getState()) { case IN_COMBAT: // what should happen here? break; case ATTACKING_COW: log("start killing a cow"); killingCow(); break; case WALKING_FIELD_TO_STAIRS: localWalker.walkPath(fieldToStairs); break; case GOING_UP_STAIRS: // interacting with stairs break; case GOING_DOWN_STAIRS: // interacting with stairs break; case WALKING_TO_BANK: break; case WALKING_BANK_TO_STAIRS: localWalker.walkPath(bankToStairs); break; case WALKING_STAIRS_TO_FIELDS: localWalker.walkPath(stairsToField); break; case BANKING: RS2Object bankBooth = objects.closest("Bank booth"); if (bankBooth != null) { if (bankBooth.interact("Bank")) { while (!bank.isOpen()) sleep(250); // deposting items bank.depositAll(); } } else { // error if the bank is not found log("error we could not find the bank?"); } break; default: break; } return random(200, 300); } @Override public void onExit() { log("Thanks for running my Cow killer!"); } @Override public void onPaint(Graphics2D g) { // NYI } }
  8. The script walks great to portals but sometimes it stands beside one and does nothing, it ignores most of the spinners. Maybe I am doing something wrong but it seems to have some problems.
×
×
  • Create New...