Advertisement
Guest User

Pug Prayer Altar V1.01

a guest
May 3rd, 2016
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.07 KB | None | 0 0
  1.  
  2. import java.awt.Graphics;
  3.  
  4. import org.dreambot.api.methods.Calculations;
  5. import org.dreambot.api.methods.container.impl.Inventory;
  6. import org.dreambot.api.methods.container.impl.bank.Bank;
  7. import org.dreambot.api.methods.interactive.GameObjects;
  8. import org.dreambot.api.methods.map.Area;
  9. import org.dreambot.api.script.AbstractScript;
  10. import org.dreambot.api.script.Category;
  11. import org.dreambot.api.script.ScriptManifest;
  12. import org.dreambot.api.wrappers.interactive.GameObject;
  13. import org.dreambot.api.wrappers.interactive.Player;
  14. import org.dreambot.api.wrappers.widgets.WidgetChild;
  15.  
  16. @ScriptManifest(author = "Pug", name = "Pug POH Altar", version = 1.01, description = "Gives bones to the god at the Gilded altar - V1.01", category = Category.PRAYER)
  17. public class PrayerAltar extends AbstractScript
  18. {
  19.     // change this to the persons name, who owns the house with the altar.
  20.     private String hostName = "w330 host";
  21.    
  22.     // change this to which type of bone you are using
  23.     private String bone = "Big bones";
  24.     private int bonesgiven;
  25.     private String statePrint = "WALK_TO_PORTAL";
  26.     private Area portalArea = new Area(2541,3099,2547,3095);
  27.     private Area bankArea = new Area(2610,3097,2613,3088);
  28.    
  29.     public enum State {
  30.         BANK, WALK_TO_PORTAL, ENTER_PORTAL, WALK_TO_ALTAR, GIVE_BONES, LEAVE_HOUSE, WALK_TO_BANK;
  31.  
  32.         @Override
  33.         public String toString() {
  34.             return name().substring(0, 1) + name().toLowerCase().replaceAll("_", " ").substring(1);
  35.         }
  36.     }
  37.    
  38.     public State currentState = State.WALK_TO_PORTAL;
  39.  
  40.     public void onStart()
  41.     {
  42.         log("starting script");
  43.     }
  44.    
  45.     @Override
  46.     public int onLoop()
  47.     {
  48.         if(getClient().isLoggedIn())
  49.         {
  50.             switch (currentState)
  51.             {
  52.             case BANK:
  53.                 bank();
  54.                 break;
  55.             case WALK_TO_PORTAL:
  56.                 walkToPortal();
  57.                 break;
  58.             case ENTER_PORTAL:
  59.                 enterPortal();
  60.                 break;
  61.             case WALK_TO_ALTAR:
  62.                 walkToAltar();
  63.                 break;
  64.             case GIVE_BONES:
  65.                 giveBones();
  66.                 break;
  67.             case LEAVE_HOUSE:
  68.                 leaveHouse();
  69.                 break;
  70.             case WALK_TO_BANK:
  71.                 walkToBank();
  72.                 break;
  73.             }
  74.         }
  75.         else
  76.         {
  77.             log("not logged in, wait");
  78.             sleep(5000);
  79.         }
  80.     return Calculations.random(150, 300);
  81.     }
  82.    
  83.     private void bank()
  84.     {
  85.         log("void bank");
  86.         statePrint = "BANK";
  87.         Player me = getLocalPlayer();
  88.         GameObjects objects = getGameObjects();
  89.         Inventory inv = getInventory();
  90.         Bank bank = getBank();
  91.         if(bank.isOpen())
  92.         {
  93.             if(bank.contains(bone))
  94.             {
  95.                 if(inv.contains(bone))
  96.                 {
  97.                     currentState = State.WALK_TO_PORTAL;
  98.                 }
  99.                 else
  100.                 {
  101.                     if(inv.isEmpty())
  102.                     {
  103.                         if(bank.withdrawAll(bone))
  104.                         {
  105.                             sleepUntil(() -> inv.contains(bone), 2000);
  106.                         }
  107.                     }
  108.                     if(!inv.isEmpty() && !inv.contains(bone))
  109.                     {
  110.                         bank.depositAllItems();
  111.                     }
  112.                 }
  113.             }
  114.             else
  115.             {
  116.                 stop();
  117.                 log("no bones left, stopping");
  118.             }
  119.         }
  120.         else
  121.         {
  122.             GameObject booth = objects.closest("Bank booth");
  123.             if(booth != null)
  124.             {
  125.                 if(booth.distance(me) <= 3)
  126.                 {
  127.                     if(booth.hasAction("Bank"))
  128.                     {
  129.                         int randRightClick = Calculations.random(1,100);
  130.                         if(randRightClick >= 98)
  131.                         {
  132.                             if(booth.interactForceRight("Bank"))
  133.                             {
  134.                                 sleepUntil(() -> bank.isOpen(), 2000);
  135.                             }
  136.                         }
  137.                         else
  138.                         {
  139.                             if(booth.interact("Bank"))
  140.                             {
  141.                                 sleepUntil(() -> bank.isOpen(), 2000);
  142.                             }
  143.                         }
  144.                     }
  145.                     else
  146.                     {
  147.                         log("banking action change #001");
  148.                     }
  149.                 }
  150.                 else
  151.                 {
  152.                     if(getWalking().walk(booth))
  153.                     {
  154.                         while(me.isMoving())
  155.                         {
  156.                             sleep(200,500);
  157.                         }
  158.                     }
  159.                    
  160.                 }
  161.             }
  162.             else
  163.             {
  164.                 log("booth is null #002");
  165.             }
  166.         }
  167.     }
  168.    
  169.     private void walkToPortal()
  170.     {
  171.         log("void walkToPortal");
  172.         statePrint = "WALK_TO_PORTAL";
  173.         Player me = getLocalPlayer();
  174.         if(portalArea.contains(me))
  175.         {
  176.             currentState = State.ENTER_PORTAL;
  177.         }
  178.         else
  179.         {
  180.             if(getWalking().walk(portalArea.getCenter()))
  181.             {
  182.                 sleep(663,1150);
  183.             }
  184.         }
  185.     }
  186.    
  187.     private void enterPortal()
  188.     {
  189.         log(" void enterPortal");
  190.         statePrint = "ENTER_PORTAL";
  191.         GameObjects objects = getGameObjects();
  192.         GameObject portal = objects.closest("Portal");
  193.         if(portal != null)
  194.         {
  195.             if(!getDialogues().inDialogue())
  196.             {
  197.                 if(portal.interact("Enter"))
  198.                 {
  199.                     sleepUntil(() -> getDialogues().inDialogue(), 2000);
  200.                 }
  201.             }
  202.             else
  203.             {
  204.                 if(getWidgets().getWidget(219) != null)
  205.                 {
  206.                     WidgetChild one = getWidgets().getChildWidget(219, 0).getChild(3);
  207.                     WidgetChild two = getWidgets().getChildWidget(162,32);
  208.                     if(one != null)
  209.                     {
  210.                         one.interact("Continue");
  211.                         sleep(721,934);
  212.                     }
  213.                     if(two != null)
  214.                     {
  215.                         getKeyboard().type(hostName);
  216.                         sleep(3421,3651);
  217.                         currentState = State.WALK_TO_ALTAR;
  218.                     }
  219.                 }
  220.             }
  221.         }
  222.     }
  223.    
  224.     private void walkToAltar()
  225.     {
  226.         log("void walkToAltar");
  227.         statePrint = "WALK_TO_ALTAR";
  228.         Player me = getLocalPlayer();
  229.         GameObjects objects = getGameObjects();
  230.         GameObject altar = objects.closest("Altar");
  231.         if(altar != null)
  232.         {
  233.             if(altar.distance(me) >= 3)
  234.             {
  235.                 if(getWalking().walk(altar))
  236.                 {
  237.                     sleep(663,1150);
  238.                 }
  239.             }
  240.             if(altar.distance(altar) <= 2)
  241.             {
  242.                 currentState = State.GIVE_BONES;
  243.             }
  244.         }
  245.     }
  246.    
  247.     private void giveBones()
  248.     {
  249.         log("void giveBones");
  250.         statePrint = "GIVE_BONES";
  251.         Player me = getLocalPlayer();
  252.         GameObjects objects = getGameObjects();
  253.         Inventory inv = getInventory();
  254.         GameObject altar = objects.closest("Altar");
  255.         if(altar != null)
  256.         {
  257.             if(inv.contains(bone))
  258.             {
  259.                 if(me.getAnimation() == -1)
  260.                 {
  261.                     inv.interact(bone, "Use");
  262.                     sleep(660,701);
  263.                     altar.interact("Use");
  264.                     sleep(1760,1980);
  265.                 }
  266.                 else
  267.                 {
  268.                     sleep(2000);
  269.                 }
  270.             }
  271.             else
  272.             {
  273.                 currentState = State.LEAVE_HOUSE;
  274.                 bonesgiven += 27;
  275.             }
  276.         }
  277.         else
  278.         {
  279.             log("altar null?");
  280.         }
  281.     }
  282.    
  283.     private void leaveHouse()
  284.     {
  285.         GameObjects objects = getGameObjects();
  286.         log("void leaveHouse");
  287.         statePrint = "LEAVE_HOUSE";
  288.         GameObject portal = objects.closest(4525);
  289.         if(portal != null)
  290.         {
  291.             log("portal != null");
  292.             if(portal.hasAction("Enter"))
  293.             {
  294.                 log("has action");
  295.                 if(portal.interact("Enter"))
  296.                 {
  297.                     log("entering");
  298.                     sleep(3000,3643);
  299.                     currentState = State.WALK_TO_BANK;
  300.                 }
  301.             }
  302.         }
  303.         else
  304.         {
  305.             log("portal null?");
  306.         }
  307.     }
  308.    
  309.     private void walkToBank()
  310.     {
  311.         log("void walkToBank");
  312.         statePrint = "WALK_TO_BANK";
  313.         Player me = getLocalPlayer();
  314.         if(bankArea.contains(me))
  315.         {
  316.             currentState = State.BANK;
  317.         }
  318.         else
  319.         {
  320.             if(getWalking().walk(bankArea.getCenter()))
  321.             {
  322.                 sleep(663,1150);
  323.             }
  324.         }
  325.     }
  326.    
  327.     public void onPaint(Graphics g)
  328.     {
  329.         g.drawString("Pug Prayer Altar - Version: " + getVersion(), 15, 40);
  330.         g.drawString("State: " + statePrint, 15, 60);
  331.         g.drawString("Bones given: " + bonesgiven, 15, 80);
  332.     }
  333. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement