Pineapple pizza maker

Discussion in 'Archives' started by perc, Feb 21, 2009.

Pineapple pizza maker
  1. Unread #1 - Feb 21, 2009 at 1:36 AM
  2. perc
    Joined:
    Feb 1, 2007
    Posts:
    830
    Referrals:
    1
    Sythe Gold:
    0

    perc Apprentice

    Pineapple pizza maker

    it would withdraw 14 pineapple chunks and 14 plain pizzas, then use the chunks on the pizza or the other way around and click make -x 14 or make all pineapple pizzas then bank. there is something like this.. but i dont know whats wrong with it.


    Code:
    import java.awt.*;
    import java.util.*;
    import java.awt.event.*;
    import com.speljohan.rsbot.script.*;
    import com.speljohan.rsbot.bot.*;
    import com.speljohan.rsbot.script.wrappers.*;
    import com.speljohan.rsbot.event.listeners.*;
    import com.speljohan.rsbot.event.events.*;
    import com.speljohan.rsbot.event.events.ServerMessageEvent;
    import com.speljohan.rsbot.event.listeners.ServerMessageListener;
    
    public class PizzaMaker extends Script implements ServerMessageListener,PaintListener {
    
    	public long startTime = System.currentTimeMillis();
        public int[] bankBooth = new int[] {11402, 35647, 36831};
    	public int startCook = 0;
    	public int pizzacount = 0;
    	public int startlvl = 0;
    	public int pizzasmade = 0;	
    	public int pizza = 0;
    	public int plainpizza = 2289;
    	public int topping = 0;
    	public int fails = 0;
    	public int number = 1;
    	int pizzasleft;
    	public  String TOPPING;
    	boolean making = false;
    
    	int randomInt;
        int GambleInt;
        long lastCheck = 0;
        long timer = System.currentTimeMillis();
        int checkTime;	
    	
    	public boolean onStart(Map<String,String> args) {
    	        if (args.get("pizza").equals("anchovies")) {
    	pizza = 2297;
    	topping = 319;
    	TOPPING = "Anchovies";
            }
            if (args.get("pizza").equals("pinapple")) {
    	pizza = 2301;
    	topping = 2118;
    	TOPPING = "Pinapple";
            }
    		        if (args.get("pizza").equals("meat")) {
    	pizza = 2293;
    	topping = 2142;
    	TOPPING = "Meat";
            }
    	                 number = Integer.parseInt(args.get("number"));	
    		Bot.getEventManager().addListener(PaintListener.class, this);    	
    		return true;
    	}
    	
    	public int loop() {	
    		if (RSInterface.getInterface( INTERFACE_BANK ).isValid() && inventoryContains(plainpizza) && 
    		inventoryContains(topping) ||  inventoryContains(plainpizza) && inventoryContains(topping) )
    				{
    			MakePizza();
    				}
    				
    			
    		else {
    		openTab(TAB_INVENTORY);
    		Bank();
    		}
    			return random (500,1000);
    	
    	}
    	public void serverMessageRecieved(ServerMessageEvent e) {
    		if (e.getMessage().contains("pizza")) {
    			making = true;	
    		}
    	}
    		public void usePizza()	{
    		atInventoryItem(topping, "Use");
    		wait(random(129,260));
    		atInventoryItem(plainpizza, "Use");
    		wait(random(129,260));
    		}
    		public void MakePizza()  {
    		
    		if(RSInterface.getInterface( INTERFACE_BANK ).isValid()) {
    		closeBank();
    		}
    			
    		if (!isBusy() && (!RSInterface.getInterface(309).isValid()) && (making == false) )   {		
    		wait(random(1029,1560));
    		log("Got plainpizzas and " + TOPPING + " lets make pizza");
    		usePizza();
    		}
    		if (inventoryContains(topping))	{
    		making = false;
    		wait(random(800,1000));
    		}
    		
    		
    		if ( RSInterface.getInterface(309).isValid()  )   {
    		for(int i = 0; i < 4; i++) {
    		// at problem with running again after random.
    	            	atInterface(309, 6, "Make All");
    	                wait( random(1000, 1500) );
    	                atMenu("Make All");
    	        		wait( random(800, 1300) );	
    				antiban();					
    						}
    	            }
    				
    		            if (number <= 0){
                                log("Done what you asked for");
                                stopAllScripts();
                }
    		if (isBusy()) {
    		
    		wait(random(800,1000));	
    		}		
    
    		}
    		// credits WarXperiment
    			public void turnCamera() {
        	char[] LR = new char[] { KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT };
        	char[] UD = new char[] { KeyEvent.VK_UP, KeyEvent.VK_DOWN };
        	char[] LRUD = new char[] { KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT,
        							 KeyEvent.VK_UP, KeyEvent.VK_DOWN };
        	int random2 = random(0,2);
        	int random1 = random(0,2);
        	int random4 = random(0,4);
        	
        	if(random(0,3) == 0) {
            	Bot.getInputManager().pressKey(LR[random1]);
            	try { Thread.sleep(random(100, 400)); } catch (Exception e) {}
            	Bot.getInputManager().pressKey(UD[random2]);
            	try { Thread.sleep(random(300, 600)); } catch (Exception e) {}
            	Bot.getInputManager().releaseKey(UD[random2]);
            	try { Thread.sleep(random(100, 400)); } catch (Exception e) {}
            	Bot.getInputManager().releaseKey(LR[random1]);        		
        	} else {
        		Bot.getInputManager().pressKey(LRUD[random4]);
        		if(random4>1) {
        			try { Thread.sleep(random(300, 600)); } catch (Exception e) {}
        		} else {
        			try { Thread.sleep(random(500, 900)); } catch (Exception e) {}
        		}
        		Bot.getInputManager().releaseKey(LRUD[random4]);
        	}
        }
    
    	
    		public void antiban() {
    		 GambleInt = random(1, 20);
    		if (GambleInt == 1) {
    			turnCamera();
    		}
    
    		if (GambleInt == 2) {
    			int xA = random(0, 750);
    			int yA = random(0, 500);
    			moveMouse(xA, yA);
    			turnCamera();
    		}
    		
    		if (GambleInt == 3) {
    			if (getCurrentTab() != TAB_INVENTORY) {
    				openTab(TAB_INVENTORY);
    				turnCamera();
    			}
    		}
    
    		if (GambleInt == 4) {
    			clickCharacter(getNearestPlayerByLevel(1,130) , "Cancel");
    			wait(random(500, 1750));
    		}
    
    		if ((System.currentTimeMillis() - lastCheck) >= checkTime) {
    			lastCheck = System.currentTimeMillis();
    			checkTime = random(300000, 600000);
    			turnCamera();
    		        openTab(random(0, 13));
    			turnCamera();
    		}
    		
    		
    		if (GambleInt == 5) {
    	    	        turnCamera();
    			int xA = random(0, 750);
    			int yA = random(0, 500);
    			moveMouse(xA, yA);
    		}
    		
    		if (GambleInt == 6) 
    			turnCamera();
    			
    		if (GambleInt == 7) 
    			openTab(random(0, 13));
    			
    		if (GambleInt == 8) 
    			moveMouse(random(0,450), random(0,450));
    		}
    		public boolean isBusy() { //thanks to alowaniak, Xhamolk and darkmaxxie
    		   boolean flag = false;
    		   for(int i = 0; i < 4; i++) {
    		      if(getMyPlayer().getAnimation() != -1) {
    		         flag = true;
    		         break;
    		      }
    		      wait(random(200, 250));
    		   }
    		   return flag;
    		}
    	
    		public void Bank()  { //ben's code.
    		
    		RSObject Bank = findObject(bankBooth);
    		/*if (distanceTo(new RSTile (3254, 3420)) > 5 || Bank == null) {
    			runEnable();
    			randomPath2().walkToEnd();
    		}*/
    		if(!RSInterface.getInterface( INTERFACE_BANK ).isValid() && (!isBusy()) || Bank != null && (!isBusy())) {
    				atObject(Bank, "Use-Quickly");
    					wait(random(625,1545));
    		}
    			if (RSInterface.getInterface( INTERFACE_BANK ).isValid() && inventoryContains(pizza)) {
    			pizzasmade = pizzasmade + getInventoryCount(pizza);
    			number = number - getInventoryCount(pizza);
    			wait(random(229,360));
    			making = false;
    			
    				bank.depositAllExcept();
    					wait(random(300,500));
    			}
    
    
    			if (RSInterface.getInterface( INTERFACE_BANK ).isValid() && !inventoryContains(topping)){
    				clickMouse(55, 107, 14, 14, false);
    				if (pizzasmade > 13) {
    				wait(random(250,500));
    				atMenu("Withdraw-14");
    				wait (random(500,1000));
    				log("Withdraws 14 " + TOPPING);
    				}
    				else {
    				wait(random(250,500));
    				atMenu("Withdraw-X");
    				wait (random(700,1200));
    				sendText("14", true);
    				log("Withdraws 14 " + TOPPING);
    				
    				wait(random(1000,1500));
    				}
    
    				if(!inventoryContains(plainpizza, topping)){
    					fails++;
    				    wait(random(400,600));
    					if (fails == 10 || pizzasmade == 986){
    						log("Must be out of Plain Pizzas or " + TOPPING);
    						log("Stops script.");
    						stopAllScripts();
    					}
    				}
    			}
    			if(inventoryContains(pizza)){
    				fails = 0;
    				 wait(random(400,600));
    		}
    
    			if (RSInterface.getInterface( INTERFACE_BANK ).isValid() && !inventoryContains(plainpizza)){
    				clickMouse(98, 108, 10, 12, false);
    				wait(random(250,500));
    				atMenu("Withdraw-14");
    				log("Withdraws 14 Plain Pizzas");
    				wait (random(500,1000));
    			}	
    		}
    	
    	public void onRepaint(Graphics g) { //stole this from endoskeleton, and rewrite, allcredits to him.
    		if (isLoggedIn()) {
    			//only setup stats a startup.
    			if (startlvl == 0) {
    			startlvl = skills.getCurrentSkillLevel(STAT_COOKING);
    				}
    			if (startTime == 0) {
    	    	startTime = System.currentTimeMillis();
    				}
    			if (startCook == 0) {
    			startCook = skills.getCurrentSkillExp(STAT_COOKING);
    				}
    			//runtime
    			long millis = System.currentTimeMillis() - startTime;
    			long hours = millis / (1000 * 60 * 60);
    			millis -= hours * (1000 * 60 * 60);
    			long minutes = millis / (1000 * 60);
    			millis -= minutes * (1000 * 60);
    			long seconds = millis / 1000;
    		//setup current xp
    		int cookEarnt = skills.getCurrentSkillExp(STAT_COOKING) - startCook;
    		int LevelChange = skills.getCurrentSkillLevel(STAT_COOKING) - startlvl;
    		//calc xp per sec
    		float XPperSec = 0;
    			if ((minutes > 0 || hours > 0 || seconds > 0) && cookEarnt > 0) {
    				XPperSec = ((float) cookEarnt)/(float)(seconds + (minutes*60) + (hours*60*60));
    			}
    			float XPperMin = XPperSec*60;
    			float XPperHour = XPperMin*60;
    			float timeTillLvl = 9999;
    			float secsTillLvl = (int) timeTillLvl;
    			float minsTillLvl = (int) timeTillLvl;
    			float hoursTillLvl = (int) timeTillLvl;
    			//calc xp per hour
    			if (XPperSec > 0) {
    				secsTillLvl = skills.getXPToNextLevel(STAT_COOKING)/XPperSec ;
    				}
    			if (XPperMin > 0) {
    				minsTillLvl = skills.getXPToNextLevel(STAT_COOKING)/XPperMin ;
    				}
    			if (XPperHour > 0) {
    				hoursTillLvl = skills.getXPToNextLevel(STAT_COOKING)/XPperHour ;
    				}
    			secsTillLvl -= (int) minsTillLvl*60;
    			minsTillLvl -= (int) hoursTillLvl*60;
    			if (minsTillLvl < 0) minsTillLvl = 0;
    			//setup color
                g.setColor(new Color(0, 0, 0, 100));
                g.fill3DRect(332, 246, 184, 87, true);
    			g.setColor(Color.white);
    			//draw on screen
    			g.drawString("Runtime: " + hours + "h " + minutes
    					+ "m " + seconds + "s.", 335, 258);
                g.drawString("Cooking levels gained: " +LevelChange, 335, 270);
                g.drawString("Cooking EXP gained: " +(skills.getCurrentSkillExp(STAT_COOKING) - startCook), 335, 282);
    			g.drawString("EXP per hour: " +(int)XPperHour, 335, 294);
    			g.drawString("Time to level: " + (int)hoursTillLvl + "h " + (int)minsTillLvl
    			+ "m " + (int)secsTillLvl + "s", 335, 306);
    			g.drawString("Pizzas made: " +((int)pizzasmade), 335, 318);
    			g.drawString("Pizzas left to be made: " +((int)number), 335, 330);
    		
    					
    		}
    	}
    	
    	public void onFinish() {
    		Bot.getEventManager().removeListener(PaintListener.class, this);
    	}
    	public double getVersion() {
    		return 1.4;
    	}	
    	public String getName(){
    		return "Pizza Maker";
    	}
    	
    	public String getAuthor(){
    		return "Skjoldborg";
    	}
    
    	public String getScriptCategory() {
    		return "Skjoldborg Scripts - SS";
    	}
    	
    	public String getScriptDescription() {
    		String html = "";
    		html += "<html>";
    		html += "<body>";
    		html += "<font color=red>";
    		html += "<h2>" + getName() + " v" + getVersion() + "</h2><br>";
    		html += "<b>Author:</b> " + getAuthor() + "([email protected]) <b><br/>\n";
    		html += "Number of Pizzas to be made:<br> <input type=\"text\" name=\"number\"><br>";
            html += "<br><b>Anchovie pizza:<input type=\"radio\" name=\"pizza\" value=\"anchovies\" checked=\"checked\"></b>" ;
            html += "<b>Pinapple pizza:<input type=\"radio\" name=\"pizza\" value=\"pinapple\"></b>" ;
            html += "<b>Meat pizza:<input type=\"radio\" name=\"pizza\" value=\"meat\"></b><br><br><br>" ;
                    html += "</font>";
    		html += "<b>Instructions:</b> Start it at either Lumbridge Bank, Alkharid Bank, both West and East Varrock Bank. <br>";
    		html += "<b>Setup a new tab --- http://img511.imageshack.us/img511/8595/setuppizzamakeryi2.png <br></b>";
    		html += "<b>Version 1.4: </b><br>";
    		html += "<b>Now got Antiban(1.4) and how many pizzas do you want to make (1.3)</b><br> ";
    	html += "<b>Changes & Credits:  See the forum !!</b><br>";
    		html += "</body>\n";
    		html += "</html\n";
    		
    		return html;
    	}
    
    }
     
< Trading My Hybrid for a Pure! | Untitled Poem I Wrote. It's funny IMO, youll like it. read it. >

Users viewing this thread
1 guest


 
 
Adblock breaks this site