Share Pastebin
Guest
Public paste!

runemysteries.java

By: a guest | Mar 16th, 2010 | Syntax: None | Size: 18.76 KB | Hits: 165 | Expires: Never
Copy text to clipboard
  1. import java.text.*;
  2. import java.awt.Color;
  3. import java.awt.Graphics;
  4. import java.awt.Point;
  5. import java.util.Map;
  6.  
  7. import org.rsbot.bot.Bot;
  8. import org.rsbot.bot.input.CanvasWrapper;
  9. import org.rsbot.bot.input.Mouse;
  10. import org.rsbot.event.listeners.PaintListener;
  11. import org.rsbot.script.Script;
  12. import org.rsbot.script.ScriptManifest;
  13. import org.rsbot.script.wrappers.RSItemTile;
  14. import org.rsbot.script.wrappers.RSTile;
  15. import org.rsbot.script.wrappers.RSInterface;
  16. import org.rsbot.script.wrappers.RSNPC;
  17. import org.rsbot.script.wrappers.RSObject;
  18. import org.rsbot.script.Constants;
  19. import org.rsbot.script.wrappers.RSArea;
  20.  
  21. //YES, I IMPORTED CONSTANTS FOR 1 SINGLE FUCKING CONSTANT.
  22.  
  23. @ScriptManifest(authors = { "Coco" }, category = "@QUESTAN", name = "RUNE MYSTERIES", version = 1.0, description = "<html><body>" +
  24.  "<h2>Rune Mysteries solver</h2>by Coco<br><hr><p>" +
  25. " <select name='initialstate'>" +
  26. "<option>Walking to duke</option" +
  27. "<option>Talking Duke</option>" +
  28. "<option>Walking to lumby</option>" +
  29. "<option>walking to draynor</option>" +
  30. "<option>getting to serdidor</option>" +
  31. "<option>talking to serdidor</option>" +
  32. "<option>lumby to varrock</option>" +
  33. "<option>talking to aubury</option>" +
  34. "<option>back to draynor</option>" +
  35. "<option>to serdidor again</option>" +
  36. "<option>talking serdidor again</option>" +
  37. "</select> <br></body></html>")
  38.  
  39.  
  40. public class runemysteries extends Script implements PaintListener {
  41.        
  42.         private RSObject closedDoor;
  43.  
  44.         // duke
  45.         private RSTile toDukeStairs[] = new RSTile[] { new RSTile(3222,3218),new RSTile(3214,3216),new RSTile(3213,3210),new RSTile(3206,3210) };
  46.         private RSTile dukeToLumby[] = reversePath(toDukeStairs);
  47.         private RSObject stairDukeO;
  48.         private final int stairDuke = 36773;
  49.         private final int Duke =741;
  50.         private RSNPC duke;
  51.         private final int closedDukedoor = 36844;
  52.        
  53.         private final RSTile outsideduke = new RSTile (3207, 3222);
  54.         private final RSTile insideduke = new RSTile (3208, 3222);
  55.         private final int floorduke =1;
  56.         private final RSArea room = new RSArea(new RSTile(3208, 3218), new RSTile(3212, 3225));
  57.         private final RSTile nearStairDukeNorth = new RSTile (3205, 3228);
  58.        
  59.         //  /duke
  60.         // wizard tower
  61.  
  62.         private final int wizardEntranceDoorID = 11993;
  63.         //same as stair divison, should use attile? maybe getNearestObjectByID will solve it..
  64.         private final int stairToBasementID = 2147;
  65.         private final int stairFromBasementID = 32015;
  66.         private final int doorToSerdidorID =33060;
  67.         private final RSTile doorToSerdidorT = new RSTile(3108, 9570);
  68.         private final int serdidorID = 300;
  69.         private final RSArea serdidorRoom = new RSArea(new RSTile(3096, 9566), new RSTile(3107,9574));
  70.         private RSTile lumbyToDraynor[]= new RSTile[] { new RSTile(3222,3219),new RSTile(3232,3220),new RSTile(3230, 3230),new RSTile(3225,3235),new RSTile(3213,3238),
  71.         new RSTile(3200,3238),new RSTile(3188,3235),new RSTile(3177,3231),new RSTile(3165,3232),new RSTile(3155,3230),new RSTile(3143,3229),new RSTile(3130,3225),
  72.         new RSTile(3119,3220),new RSTile(3114,3210),new RSTile(3114,3197),new RSTile(3114,3188),new RSTile(3114,3176),new RSTile(3109,3167)};
  73.        
  74.         //ends up BEFORE THE DOOR
  75.        
  76.         private RSTile LumbyToVarrock[] = new RSTile[] { new RSTile(3220, 3219), new RSTile(3235, 3223), new RSTile(3248, 3226), new RSTile(3259, 3227),
  77.         new RSTile(3259, 3241), new RSTile(3251, 3252), new RSTile(3249, 3266), new RSTile(3242, 3276), new RSTile(3237, 3286), new RSTile(3237, 3300),
  78.         new RSTile(3238, 3302), new RSTile(3238, 3316), new RSTile(3238, 3328), new RSTile(3239, 3335), new RSTile(3230, 3337), new RSTile(3225, 3343),
  79.         new RSTile(3225, 3354), new RSTile(3217, 3394), new RSTile(3225, 3354), new RSTile(3220, 3359), new RSTile(3216, 3364), new RSTile(3212, 3368),
  80.         new RSTile(3211, 3374), new RSTile(3209, 3382), new RSTile(3211, 3388), new RSTile(3211, 3394), new RSTile(3210, 3404), new RSTile(3221, 3410),
  81.         new RSTile(3234, 3406), new RSTile(3247, 3401), new RSTile(3253, 3398), new RSTile(3293, 3406), new RSTile(3253, 3398) };
  82.        
  83.         private RSTile varrockToDraynor[] = new RSTile[]{ new RSTile(3253, 3398), new RSTile(3243, 3403),new RSTile(3243, 3414), new RSTile(3236, 3428), new RSTile(3224, 3430),
  84.         new RSTile(3217, 3429), new RSTile(3203, 3429), new RSTile(3202, 3430), new RSTile(3162, 3454), new RSTile(3202, 3430), new RSTile(3192, 3429),
  85.         new RSTile(3184, 3429), new RSTile(3171, 3429), new RSTile(3161, 3424), new RSTile(3150, 3424), new RSTile(3138, 3422), new RSTile(3127, 3421),
  86.         new RSTile(3116, 3421), new RSTile(3107, 3421), new RSTile(3102, 3421), new RSTile(3096, 3414), new RSTile(3098, 3407), new RSTile(3099, 3400),
  87.         new RSTile(3100, 3393), new RSTile(3099, 3388), new RSTile(3108, 3387), new RSTile(3120, 3385), new RSTile(3123, 3381), new RSTile(3126, 3378),
  88.         new RSTile(3129, 3377), new RSTile(3135, 3368), new RSTile(3136, 3358), new RSTile(3135, 3353), new RSTile(3135, 3349), new RSTile(3135, 3340),
  89.         new RSTile(3146, 3337), new RSTile(3145, 3326), new RSTile(3145, 3314), new RSTile(3145, 3302), new RSTile(3138, 3292), new RSTile(3135, 3281),
  90.         new RSTile(3134, 3268), new RSTile(3134, 3259), new RSTile(3135, 3255), new RSTile(3134, 3252), new RSTile(3136, 3242), new RSTile(3136, 3236),
  91.         new RSTile(3136, 3230), new RSTile(3131, 3224), new RSTile(3125, 3221), new RSTile(3122, 3218), new RSTile(3118, 3213), new RSTile(3122, 3218),
  92.         new RSTile(3118, 3213), new RSTile(3113, 3207), new RSTile(3113, 3193), new RSTile(3112, 3182), new RSTile(3112, 3178), new RSTile(3111, 3170),
  93.         new RSTile(3109, 3167)};
  94.         // /wizard tower
  95.        
  96.         // aubury
  97.         private final int auburyClosedID =24381;
  98.         private final int auburyID = 553;
  99.        
  100.         private int state = 0;
  101.         private final int walkingToDuke=0,talkingDuke = 1, walkingToLumby=2, walkingToDraynor=3, gettingToSerdidor=4, talkingToSerdidor=5,
  102.         lumbyToVarrock=6, talkingToAubury=7, backToDraynor=8, toSerdidorAgain=9,talkingSerdidorAgain=10;
  103.  
  104.         @Override
  105.         public int loop() {
  106.                 if (!isRunning() && getEnergy() > 50) setRun(true);
  107.                
  108.                 switch (state) {
  109.                         case walkingToDuke:
  110.                                 if(getPlane() == 0) {
  111.                                         if (distanceTo(toDukeStairs[toDukeStairs.length -1]) > 5) {
  112.                                                 walk(toDukeStairs);
  113.                                                 return 1000;
  114.                                         }
  115.                                         stairDukeO = getNearestObjectByID(stairDuke);
  116.                                         if (stairDukeO !=null) {
  117.                                                 atObject(stairDukeO, "Climb-up");
  118.                                                 return 1000;
  119.                                         }
  120.                                 } else {
  121.                                         duke =getNearestNPCByID(Duke);
  122.                                         if (room.contains(duke.getLocation()) && !room.contains(getMyPlayer().getLocation()) ||
  123.                                                 !room.contains(duke.getLocation()) && room.contains(getMyPlayer().getLocation())) {
  124.                                                 //duke is inthe room (and i am not)
  125.                                                 //OR I am in the room, the duke walked out
  126.                                                 closedDoor = getNearestObjectByID(closedDukedoor);
  127.                                                 if (closedDoor !=null) { //and some noob closed the door
  128.                                                         atDoor(closedDukedoor, 'E'); // open
  129.                                                         return 700;
  130.                                                 }
  131.                                         }
  132.                                         if (distanceTo(duke.getLocation()) > 5) {
  133.                                                 walkTileMM(duke.getLocation(),0,0); //to duke
  134.                                                 return (500);
  135.                                         }
  136.                                 }
  137.                                 if(duke !=null){
  138.                                         if (distanceTo(duke.getLocation()) <= 5) state++;
  139.                                 }
  140.                                 break;
  141.                         case talkingDuke:
  142.                                 manageTalkingDuke();
  143.                                 break;
  144.                         case walkingToLumby:
  145.                                 //check door
  146.                                 closedDoor = getNearestObjectByID(closedDukedoor);
  147.                                 if (closedDoor !=null && room.contains(getMyPlayer().getLocation())) { //and some noob closed the door
  148.                                         atDoor(closedDukedoor, 'E'); // open
  149.                                         return 700;
  150.                                 }
  151.                                                
  152.                                 if(getPlane() == 1) {
  153.                                         if (distanceTo(new RSTile(3205,3209)) > 5) {
  154.                                                 walkTileMM(new RSTile(3205,3209),0,0);
  155.                                                 return 1000;
  156.                                         }
  157.                                         RSObject stairs = getNearestObjectByID(36774);
  158.                                         if (stairs!= null) { //bug here :D
  159.                                                 atObject(stairs, "Climb-down");
  160.                                                 return 1000;
  161.                                         }
  162.                                 } else {
  163.                                         if (distanceTo(dukeToLumby[dukeToLumby.length -1]) > 5) {
  164.                                                 walk(dukeToLumby);
  165.                                                 return 1000;
  166.                                         }
  167.                                 }
  168.                                         if (distanceTo(dukeToLumby[dukeToLumby.length -1]) <= 5) state++;
  169.                                        
  170.                                 break;
  171.                         case walkingToDraynor:
  172.                                 if (distanceTo(lumbyToDraynor[lumbyToDraynor.length -1]) > 5) {
  173.                                         walk(lumbyToDraynor);
  174.                                         return 1000;
  175.                                 }
  176.                                 state++;
  177.                                 break;
  178.                         case gettingToSerdidor:
  179.                                 if (distanceTo(new RSTile(3109,3167)) <= 20) {
  180.                                         RSObject entrancedoor = getNearestObjectByID(wizardEntranceDoorID);
  181.                                         if (entrancedoor != null && distanceBetween(entrancedoor.getLocation(), new RSTile(3111,3163)) > 1) {
  182.                                                 if (tileOnScreen(entrancedoor.getLocation())) {
  183.                                                         if (distanceBetween(entrancedoor.getLocation(), new RSTile(3107,3162)) < 2) { //to trapdoor
  184.                                                                 atDoorTiles(new RSTile(3107,3161), new RSTile(3107,3162));
  185.                                                         } else { //main door
  186.                                                                 atDoorTiles(new RSTile(3109,3166), new RSTile(3109,3167));
  187.                                                         }
  188.                                                 } else {
  189.                                                         walkTileMM(entrancedoor.getLocation(),0,0);
  190.                                                 }
  191.                                                 return 1000;
  192.                                         }
  193.                                         RSObject stairstobasement =getNearestObjectByID(stairToBasementID);
  194.                                         if (stairstobasement!=null) {
  195.                                                 if (tileOnScreen(stairstobasement.getLocation())) {
  196.                                                         atObject(stairstobasement, "Climb-down");
  197.                                                 } else {
  198.                                                         walkTileMM(stairstobasement.getLocation(),0,0);
  199.                                                 }
  200.                                                 return 1000;
  201.                                         }
  202.                                 } else {
  203.                                         RSNPC serdidor =getNearestNPCByID(serdidorID);
  204.                                         if (serdidorRoom.contains(serdidor.getLocation()) && !serdidorRoom.contains(getMyPlayer().getLocation()) ||
  205.                                                 !serdidorRoom.contains(serdidor.getLocation()) && serdidorRoom.contains(getMyPlayer().getLocation())) {
  206.                                                 RSObject closedDoors = getNearestObjectByID(doorToSerdidorID);
  207.                                                 if (closedDoors != null && !serdidorRoom.contains(getMyPlayer().getLocation())) { // in the room and door is closed, should be in the next state
  208.                                                         //if (distanceBetween(closedDoors.getLocation(),new RSTile(3107,9570)) <= 3) {
  209.                                                                 if (tileOnScreen(closedDoors.getLocation()) ) { //trying to get in to serdidor
  210.                                                                         atDoorTiles(new RSTile(3108,9570), new RSTile(3107,9570));
  211.                                                                         return 100;
  212.                                                                 } else {
  213.                                                                         walkTileMM(closedDoors.getLocation(),0,0);
  214.                                                                         return 1000;
  215.                                                                 }
  216.                                                         //}
  217.                                                 }
  218.                                         }
  219.                                         if (distanceTo(serdidor.getLocation()) > 5) {
  220.                                                 walkTileMM(serdidor.getLocation(),0,0); //to duke
  221.                                                 return (500);
  222.                                         }
  223.                                         if (distanceTo(serdidor.getLocation()) <= 5 && serdidorRoom.contains(getMyPlayer().getLocation())) state++;
  224.                                 }
  225.                                 break;
  226.                         case talkingToSerdidor:
  227.                                 manageTalkingSerdidor();
  228.                                 break;
  229.                         case lumbyToVarrock:
  230.                                 if (distanceTo(LumbyToVarrock[LumbyToVarrock.length -1]) > 5) {
  231.                                         walk(LumbyToVarrock);
  232.                                         return 1000;
  233.                                 }
  234.                                 state++;
  235.                                 break;
  236.                         case talkingToAubury:
  237.                                 manageTalkingAubury();
  238.                                 break;
  239.                         case backToDraynor:
  240.                                 if (distanceTo(varrockToDraynor[varrockToDraynor.length -1]) > 5) {
  241.                                         walk(varrockToDraynor);
  242.                                         return 1000;
  243.                                 }
  244.                                 state++;
  245.                                 //MISSCLICK OUT OF THE PALACE STATE 1
  246.                                 break;
  247.                         case toSerdidorAgain:
  248.                                 if (distanceTo(new RSTile(3109,3167)) <= 20) {
  249.                                         RSObject entrancedoor = getNearestObjectByID(wizardEntranceDoorID);
  250.                                         if (entrancedoor != null && distanceBetween(entrancedoor.getLocation(), new RSTile(3111,3163)) > 1) {
  251.                                                 if (tileOnScreen(entrancedoor.getLocation())) {
  252.                                                         if (distanceBetween(entrancedoor.getLocation(), new RSTile(3107,3162)) < 2) { //to trapdoor
  253.                                                                 atDoorTiles(new RSTile(3107,3161), new RSTile(3107,3162));
  254.                                                         } else { //main door
  255.                                                                 atDoorTiles(new RSTile(3109,3166), new RSTile(3109,3167));
  256.                                                         }
  257.                                                 } else {
  258.                                                         walkTileMM(entrancedoor.getLocation(),0,0);
  259.                                                 }
  260.                                                 return 1000;
  261.                                         }
  262.                                         RSObject stairstobasement =getNearestObjectByID(stairToBasementID);
  263.                                         if (stairstobasement!=null) {
  264.                                                 if (tileOnScreen(stairstobasement.getLocation())) {
  265.                                                         atObject(stairstobasement, "Climb-down");
  266.                                                 } else {
  267.                                                         walkTileMM(stairstobasement.getLocation(),0,0);
  268.                                                 }
  269.                                                 return 1000;
  270.                                         }
  271.                                 } else {
  272.                                         RSNPC serdidor =getNearestNPCByID(serdidorID);
  273.                                         if (serdidor == null) {
  274.                                         state--;
  275.                                         return 1000;
  276.                                         }
  277.                                         if (serdidorRoom.contains(serdidor.getLocation()) && !serdidorRoom.contains(getMyPlayer().getLocation()) ||
  278.                                                 !serdidorRoom.contains(serdidor.getLocation()) && serdidorRoom.contains(getMyPlayer().getLocation())) {
  279.                                                 RSObject closedDoors = getNearestObjectByID(doorToSerdidorID);
  280.                                                 if (closedDoors != null && !serdidorRoom.contains(getMyPlayer().getLocation())) { // in the room and door is closed, should be in the next state
  281.                                                         //if (distanceBetween(closedDoors.getLocation(),new RSTile(3107,9570)) <= 3) {
  282.                                                                 if (tileOnScreen(closedDoors.getLocation()) ) { //trying to get in to serdidor
  283.                                                                         atDoorTiles(new RSTile(3108,9570), new RSTile(3107,9570));
  284.                                                                         return 100;
  285.                                                                 } else {
  286.                                                                         walkTileMM(closedDoors.getLocation(),0,0);
  287.                                                                         return 1000;
  288.                                                                 }
  289.                                                         //}
  290.                                                 }
  291.                                         }
  292.                                         if (distanceTo(serdidor.getLocation()) > 5) {
  293.                                                 walkTileMM(serdidor.getLocation(),0,0); //to duke
  294.                                                 return (500);
  295.                                         }
  296.                                         if (distanceTo(serdidor.getLocation()) <= 5 && serdidorRoom.contains(getMyPlayer().getLocation())) state++;
  297.                                 }
  298.                                 break;
  299.                         case talkingSerdidorAgain:
  300.                                 manageTalkingSerdidorAgain();
  301.                                 break;
  302.                        
  303.                        
  304.                         //if tally, quest complete :D
  305.                 }
  306.                 return 150;
  307.         }
  308. //bug climbing down (duke-> lumby)
  309.  
  310.         private void manageTalkingDuke() {
  311.                 duke = getNearestNPCByID(Duke);
  312.                 closedDoor = getNearestObjectByID(closedDukedoor);
  313.                 if (getPlane() != floorduke)  {
  314.                        
  315.                         return;
  316.                 }
  317.                 if (duke == null) {
  318.                 //      state = bankToDuke;
  319.                         wait(600);
  320.                         return;
  321.                 }
  322.  
  323.                 if (canContinue()) {
  324.                         clickContinue();
  325.                         wait(450);
  326.                         return ;
  327.                 }
  328.                
  329.                 if (getInterface(228).isValid()) {
  330.                         atInterface(getInterface(228).getChild(2), "Continue"); //have you any quests for me?
  331.                         return;
  332.                 }
  333.                 if (getInterface(178).isValid()) {
  334.                         atInterface(getInterface(178).getChild(62), "Yes"); //YES (accept quest)
  335.                         return;
  336.                 }
  337.                 if (getInventoryCount(15361) > 0) state++;
  338.                 if (!tileOnScreen(duke.getLocation())) {
  339.                         walkTileMM(duke.getLocation(),0,0);
  340.                 } else {
  341.                         atNPC(duke, "Talk-to");
  342.                 }
  343.                 wait(600);
  344.                 return;
  345.                
  346.         }
  347.         private void manageTalkingSerdidor() {
  348.                
  349.                 if (getInventoryCount(290) > 0) {//the package
  350.                         if (distanceTo(new RSTile(3223, 3219)) < 10) {
  351.                                 state++;
  352.                         } else {
  353.                                 castSpell(Constants.SPELL_HOME_TELEPORT);
  354.                                 wait(3000);
  355.                                 while (getMyPlayer().getAnimation() != -1) wait(30);
  356.                         }
  357.                         return;
  358.                 }
  359.                
  360.                 //get plane, distance to
  361.                 RSObject closedDoors = getNearestObjectByID(doorToSerdidorID);
  362.                 if (closedDoors != null && !serdidorRoom.contains(getMyPlayer().getLocation())) { // in the room and door is closed, should be in the next state
  363.                         if (distanceBetween(closedDoors.getLocation(),new RSTile(3107,9570)) <= 5) {
  364.                                 if (tileOnScreen(closedDoors.getLocation()) ) { //trying to get in to serdidor
  365.                                         atDoorTiles(new RSTile(3108,9570), new RSTile(3107,9570));
  366.                                         return;
  367.                                 } else {
  368.                                         walkTileMM(closedDoors.getLocation(),0,0);
  369.                                         wait(1000);
  370.                                         return;
  371.                                 }
  372.                         }
  373.                 }
  374.                 if (canContinue()) {
  375.                         clickContinue();
  376.                         wait(450);
  377.                         return ;
  378.                 }
  379.                 if (getInterface(230).isValid()) {
  380.                         atInterface(getInterface(230).getChild(4), "Continue");
  381.                         return;
  382.                 }
  383.                 if (getInterface(228).isValid()) {
  384.                         atInterface(getInterface(228).getChild(2), "Continue");
  385.                         return;
  386.                 }
  387.                
  388.                 RSNPC serdidor = getNearestNPCByID(serdidorID);
  389.                 if (!tileOnScreen(serdidor.getLocation())) {
  390.                         walkTileMM(serdidor.getLocation(),0,0);
  391.                         wait(1000);
  392.                         return;
  393.                 }
  394.                 atNPC(serdidor, "Talk-to");
  395.                
  396.                 wait(500);
  397.                
  398.         }
  399.         private void manageTalkingAubury() {
  400.                 if (getInventoryCount(291) > 0) state++; //notes -> go to serdidor
  401.                 if (canContinue()) {
  402.                         clickContinue();
  403.                         wait(450);
  404.                         return ;
  405.                 }
  406.                 if (getInterface(230).isValid()) {
  407.                         atInterface(getInterface(230).getChild(4), "Continue");
  408.                         return;
  409.                 }//ive been sent
  410.                 if (getInventoryCount(291) > 0) state++; //notes -> go to serdidor
  411.                 RSNPC aubury = getNearestNPCByID(auburyID);
  412.                 if (aubury != null) atNPC(aubury, "Talk-to");
  413.                
  414.         }
  415.        
  416.         private void manageTalkingSerdidorAgain() {
  417.                 if (getInventoryCount(1438) > 0) {//TALISMAN
  418.                         log("QUEST COMPLETED!");
  419.                         stopScript();
  420.                         return;
  421.                 }
  422.                
  423.                 RSObject closedDoors = getNearestObjectByID(doorToSerdidorID);
  424.                 if (closedDoors != null && !serdidorRoom.contains(getMyPlayer().getLocation())) { // in the room and door is closed, should be in the next state
  425.                         if (tileOnScreen(closedDoors.getLocation()) && distanceBetween(closedDoors.getLocation(),new RSTile(3107,9570)) <= 2  ) { //trying to get in to serdidor
  426.                                 atDoorTiles(new RSTile(3108,9570), new RSTile(3107,9570));
  427.                                 return;
  428.                         } else if(!tileOnScreen(closedDoors.getLocation())) {
  429.                                 walkTileMM(closedDoors.getLocation(),0,0);
  430.                                 wait(1000);
  431.                                 return;
  432.                         }
  433.                 }
  434.                
  435.                 if (canContinue()) {
  436.                         clickContinue();
  437.                         wait(450);
  438.                         return ;
  439.                 }
  440.                
  441.                 RSNPC serdidor = getNearestNPCByID(serdidorID);
  442.                 atNPC(serdidor, "Talk-to");
  443.                 wait(500);
  444.         }
  445.         public void getStartupState() {
  446.                 return;        
  447.         }
  448.         public void onRepaint(final Graphics g) {
  449.                 if (!isLoggedIn()) return;
  450.                 g.drawString("State: " + stringstate(state), 560,450);
  451.  
  452.                
  453.         }
  454.         public String stringstate(int a) {
  455.                 switch (a) {
  456.                         case 0: return "Walking to duke";
  457.                         case 1: return "Talking Duke";
  458.                         case 2: return "Walking to lumby";
  459.                         case 3: return "walking to draynor";
  460.                         case 4: return "getting to serdidor";
  461.                         case 5: return "talking to serdidor";
  462.                         case 6: return "lumby to varrock";
  463.                         case 7: return "talking to aubury";            
  464.                         case 8: return "back to draynor";
  465.                         case 9: return "to serdidor again";
  466.                         case 10: return "talking serdidor again";
  467.                 }
  468.                 return ("huh? this is wierd");
  469.         }
  470.         public double redondear( double numero, int decimales ) {
  471.                 return Math.round(numero*Math.pow(10,decimales))/Math.pow(10,decimales);
  472.         }  
  473.         @Override
  474.         public boolean onStart(final Map<String, String> args) {
  475.                 setCameraAltitude(true);
  476.                 if (args.get("initialstate").equals("Walking to duke")) state = 0;
  477.         if (args.get("initialstate").equals("Talking Duke")) state = 1;
  478.                 if (args.get("initialstate").equals("Walking to lumby")) state = 2;
  479.                 if (args.get("initialstate").equals("walking to draynor")) state = 3;
  480.                 if (args.get("initialstate").equals("getting to serdidor")) state = 4;
  481.                 if (args.get("initialstate").equals("talking to serdidor")) state = 5;
  482.                 if (args.get("initialstate").equals("lumby to varrock")) state = 6;
  483.                 if (args.get("initialstate").equals("talking to aubury")) state = 7;
  484.                 if (args.get("initialstate").equals("back to draynor")) state = 8;
  485.                 if (args.get("initialstate").equals("to serdidor again")) state = 9;
  486.                 if (args.get("initialstate").equals("talking serdidor again")) state = 10;
  487.                
  488.                 log("starting at state = " + state);
  489.                 return true;
  490.         }
  491.         public void onFinish() {
  492.                
  493.                
  494.         }
  495.         private void walk(RSTile path[]) {
  496.                 if (!getMyPlayer().isMoving() || distanceTo(getDestination()) <= random(4, 7)) walkPathMM(path, 0,0);
  497.         }
  498. }