Advertisement
OSBotMerccy

Untitled

Jul 6th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.96 KB | None | 0 0
  1. package com.merccy.Shop;
  2. import java.awt.Rectangle;
  3.  
  4. import org.osbot.script.Script;
  5. import org.osbot.script.mouse.RectangleDestination;
  6.  
  7.  
  8. public class ShopItem {
  9.    
  10.     private Script scr;
  11.     public int slotID;
  12.     private int parentID;
  13.     private int childID;
  14.    
  15.     private int startWidth = 80;
  16.     private int startHeight = 70;
  17.     private int itemWidth = 30;
  18.     private int itemHeight = 30;
  19.     private int spaceWidth = 17;
  20.     private int spaceHeight = 17;
  21.     private int rowAmount = 8;
  22.    
  23.     public Rectangle slot;
  24.     public String name;
  25.     public int id;
  26.     public int amount;
  27.    
  28.     public ShopItem(Script s, int slotID){
  29.     this.scr = s;
  30.     this.slotID = slotID;
  31.     this.slot = this.getRectForSlot(this.slotID);
  32.     }
  33.    
  34.     public ShopItem(Script s, int slotID, int p, int c){
  35.     this.scr = s;
  36.     this.slotID = slotID;
  37.     this.parentID = p;
  38.     this.childID = c;
  39.     this.slot = this.getRectForSlot(this.slotID);
  40.     }
  41.    
  42.     public int getAmount(){
  43.     return this.amount;
  44.     }
  45.    
  46.     public String getName(){
  47.     return this.name;
  48.     }
  49.    
  50.     public int getID(){
  51.     return this.id;
  52.     }
  53.    
  54.     public int getSlotID(){
  55.     return this.slotID;
  56.     }
  57.    
  58.     public boolean value() throws InterruptedException{
  59.     this.scr.client.moveMouseTo(new RectangleDestination(this.slot), true, true, true);
  60.     this.scr.sleep(250);
  61.     return this.scr.selectOption(null, new RectangleDestination(this.slot), "Value");
  62.     }
  63.    
  64.     public boolean buy1() throws InterruptedException{
  65.     this.scr.client.moveMouseTo(new RectangleDestination(this.slot), true, true, true);
  66.     this.scr.sleep(250);
  67.     return this.scr.selectOption(null, new RectangleDestination(this.slot), "Buy 1");
  68.     }
  69.    
  70.     public boolean buy5() throws InterruptedException{
  71.     this.scr.client.moveMouseTo(new RectangleDestination(this.slot), true, true, true);
  72.     this.scr.sleep(250);
  73.     return this.scr.selectOption(null, new RectangleDestination(this.slot), "Buy 5");
  74.     }
  75.    
  76.     public boolean buy10() throws InterruptedException{
  77.     this.scr.client.moveMouseTo(new RectangleDestination(this.slot), true, true, true);
  78.     this.scr.sleep(250);
  79.     return this.scr.selectOption(null, new RectangleDestination(this.slot), "Buy 10");
  80.     }
  81.    
  82.     private Rectangle getRectForSlot(int slotId) {
  83.     return new Rectangle(this.calcWidth(slotId), this.calcHeight(slotId),
  84.         this.itemWidth, this.itemHeight);
  85.     }
  86.  
  87.     private int calcWidth(int slotId) {
  88.     int mod = slotId % 8;
  89.     if (mod == 0){
  90.         mod = 8;
  91.     }
  92.     int column = mod - 1;
  93.     int totalwidth = this.startWidth;
  94.     for (int i = 1; i <= column; i++) {
  95.         totalwidth += this.itemWidth;
  96.         totalwidth += this.spaceWidth;
  97.     }
  98.     return totalwidth;
  99.     }
  100.  
  101.     private int calcHeight(int slotId) {
  102.     int row = (int) Math.ceil(slotId / 8D) - 1;
  103.     int totalheight = this.startHeight;
  104.     for (int i = 1; i <= row; i++) {
  105.         totalheight += this.spaceHeight;
  106.         totalheight += this.itemHeight;
  107.     }
  108.     return totalheight;
  109.     }
  110.    
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement