Guest User

Untitled

a guest
Aug 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.77 KB | None | 0 0
  1. import org.rsbot.script.Script;
  2. import org.rsbot.script.wrappers.RSTile;
  3. import org.rsbot.script.wrappers.RSArea;
  4.  
  5.  
  6. public class TehXmasHillGiantKiller extends Script{
  7.  
  8. private String status = "Starting Up...";
  9.  
  10. public boolean onStart(){
  11. return true;
  12. }
  13. public void onFinish(){
  14.  
  15. }
  16.  
  17. // Enums for handling states.
  18. // This is handled in the loop, this is Action states, we want to do somthing in every specific state.
  19. private enum State {
  20. GO_BANK, BANK_ITEMS, GO_DUNGEON, ATTACK_GIANTS, UNK_0
  21. }
  22.  
  23. // Location states are useful no matter what, we allways want script to know
  24. // what todo if we are at places we should not be, places we are and yeah.
  25. // All places should have a condition in getState() connected to the Location.
  26. private enum LocationState {
  27. AT_BANK, AT_DUNGEON, UNK_1
  28. }
  29.  
  30. // Tiles, used in location handler and walking and such.
  31. RSTile bankTile = new RSTile(0000,0000);
  32. RSTile ladderTile = new RSTile(0000,0000);
  33.  
  34.  
  35.  
  36. public int loop(){
  37. State stateSelector = getState();
  38.  
  39. switch(stateSelector){
  40. case GO_BANK:
  41. // Walking method to walk to bank. Example: walking.walkPathMM(....) ...
  42. break;
  43. case BANK_ITEMS:
  44. // Banking code, to bank items. Example: bank.open() etc...
  45. break;
  46. case GO_DUNGEON:
  47. // Walking method to walk to mine. Example: walking.walkPathMM(....) ...
  48. break;
  49. case ATTACK_GIANTS:
  50. // Mining specific code. objects.getNearest(...) ... and etc....
  51. break;
  52. }
  53. return random(200,300);
  54. }
  55.  
  56. /*
  57. * State handler. Should be pretty Ok. It checks what we want to do! Can,
  58. * but should not return UNK_0. Peec.
  59. * State handler is very important, here you should use conditions , if conditions and switches but dont handle walking and actions here.
  60. */
  61. private State getState() {
  62.  
  63. // When getting action states, we would most sincerly like to know our current location to determine what to do!
  64. LocationState currentLoc = getCurrentLocation();
  65.  
  66. // Bank state if full inventory. inventory.isFull() is the best for this check of banking.
  67. // Normally very good for defining if we need to go bank! Should be used
  68. // in most scripts =)
  69. if (inventory.isFull()) {
  70. // Now, we want to do difrent actions based on what locations we are @....
  71. switch (currentLoc) {
  72. // If we are @ bank, lets just use BANK_ITEMS
  73. case AT_BANK:
  74. return State.BANK_ITEMS;
  75. // But if we are @ mine or other places... Lets just walk to bank!
  76. case AT_DUNGEON:
  77. case UNK_1: // This is if we dont really know where we are.
  78. return State.GO_BANK;
  79.  
  80. }
  81. // We do not have full inventory below. Lets create states for it.
  82. } else {
  83. // Now, we want to do difrent actions based on what locations we are @....
  84. switch (currentLoc) {
  85. // If we are @bank or any other place, lets just walk to Mine! GO_MINE
  86. case AT_BANK:
  87. case UNK_1:// This is if we dont really know where we are.
  88. return State.GO_DUNGEON;
  89. // However, if we are @ Mine, lets just MINE_ROCKS.
  90. case AT_DUNGEON:
  91. return State.ATTACK_GIANTS;
  92. }
  93. }
  94.  
  95. // This should not be possible, but if it is , its a bug! I dont like
  96. // bugs so we better create handeleres for unknown states too!
  97. status = "Unknown state.";
  98. return State.UNK_0;
  99. }
  100. /*
  101. * Location state handler. Finds out where we are. But can return UNK_1 wich
  102. * means, it doesnt know where we are. Peec.
  103. */
  104. private LocationState getCurrentLocation() {
  105. RSArea Dungeon = new RSArea(new RSTile(2884, 4837), new RSTile(2901,
  106. 4859));
  107. /*
  108. * Here we handle diferent locations. You can also work with preferably RSArea and other things for
  109. * checking the current location!
  110. * UNK_1, thats a state for: We dont really know where we are.
  111. */
  112.  
  113. // If @ bank
  114. if (calc.distanceBetween(bankTile, getMyPlayer().getLocation()) <= 3) {
  115. return LocationState.AT_BANK;
  116. }
  117.  
  118. // If @ mine
  119. if (Dungeon.contains(getMyPlayer().getLocation())) {
  120. return LocationState.AT_DUNGEON;
  121. }
  122.  
  123. // We dont really know the current location, handleres for this state
  124. // should be handled in the loop or less preferably in getState()
  125. return LocationState.UNK_1;
  126. }
  127.  
  128.  
  129. }
Add Comment
Please, Sign In to add comment