Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Basic Zamorak Monk killing script


    beefsteak

    Recommended Posts

    Hey guys, absolute noob scripter here. I had one working script with DB2, but now with DB3 I'm totally lost. Trying to get a basic state machine going, to kill Zammy Monks, loot any robes, then after clearing the room, looting the wine if its there, and then hop a world. 

    At the moment, I basically have nothing because I cant get past a syntax error with my private String state; 
    Once I can get it to recognize the different states I think I'll be able to figure out the rest by copying from other peoples scripts (like this one)

    Any and all tips appreciated, please destroy me verbally



     

    import java.awt.Graphics2D;
    
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.script.impl.TaskScript; //Remove based on above
    import org.dreambot.api.utilities.Timer;
    import org.dreambot.api.wrappers.interactive.GameObject;
    import org.dreambot.api.Client;
    import org.dreambot.api.input.Mouse;
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.MethodProvider;
    import org.dreambot.api.methods.combat.Combat;
    import org.dreambot.api.methods.container.impl.Inventory;
    import org.dreambot.api.methods.container.impl.bank.Bank;
    import org.dreambot.api.methods.container.impl.equipment.Equipment;
    import org.dreambot.api.methods.dialogues.Dialogues;
    import org.dreambot.api.methods.grandexchange.GrandExchange;
    import org.dreambot.api.methods.input.Camera;
    import org.dreambot.api.methods.input.Keyboard;
    import org.dreambot.api.methods.interactive.GameObjects;
    import org.dreambot.api.methods.interactive.NPCs;
    import org.dreambot.api.methods.interactive.Players;
    import org.dreambot.api.methods.item.GroundItems;
    import org.dreambot.api.methods.magic.Magic;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.map.Map;
    import org.dreambot.api.methods.prayer.Prayers;
    import org.dreambot.api.methods.quest.Quests;
    import org.dreambot.api.methods.settings.PlayerSettings;
    import org.dreambot.api.methods.skills.Skills;
    import org.dreambot.api.methods.tabs.Tabs;
    import org.dreambot.api.methods.trade.Trade;
    import org.dreambot.api.methods.walking.impl.Walking;
    import org.dreambot.api.methods.widget.Widgets;
    import org.dreambot.api.methods.worldhopper.WorldHopper;
    
    @ScriptManifest(author = "Beefsteak", description = "Kills Zammy Monks.", name = "Heinous Monks", category = Category.COMBAT, version = 0.1)
    
    public class ZMonks extends AbstractScript {
    
    	public void onStart() {
        	
    		log("Welcome to Heinous Monkeys");
    		startTime = new Timer(); 
    		
        }
    	
    	
    	private Timer startTime;  
        
    	Area BANK = new Area(2943, 3369, 2949, 3368);
    	Area MONKS = new Area(2929, 3512, 2941, 3518);
    
        public enum State {
        	IDLE("Idle"),
        	FIGHTING("Fighting"),
        	BANKING("Banking"), 
        	
        	private State state; 
        	State(String state) {
                this.state = state;
            }
            public String getState() {
                return state;
            }   
            public void onPaint(Graphics2D g) {
                g.drawString("State: " + state.getState(),12,77);
            }
        }
        	
    @Override
    public int onLoop() {
    	  
    		 state = getState();
    		  
    		  switch (state) {
    	  
    		    case BANKING:
    		    	log("Banking");
    		    	if (Inventory.isFull() && !Players.localPlayer().isInCombat()) {
    		    		Walking.walkOnScreen(BANK.getRandomTile());
    		        	}
    					GameObject depositbox = GameObjects.closest("Bank deposit box");
    					if (depositbox != null && getInventory().isFull()) {
    						depositbox.interact("Deposit");
    						sleepUntil(() -> getDepositBox().isOpen(),
    								randomNum(8000, 10000));
    						sleep(randomNum(300, 500));			
    							getDepositBox().depositAllExcept("Trout");
    							sleep(randomNum(300, 500));	
    						getDepositBox().close();
    					Walking.walkOnScreen(MONKS.getRandomTile());
    					sleepUntil(() -> Players.localPlayer().isMoving(), randomNum(1000, 2000));
    					
    					break;
    							
    		    case FIGHTING:
    		    	log("Fighting");
    		    	NPCs zmonk = NPCs.closest(q -> q != null && q.getName().equals("Monk of Zamorak") && !q.isInCombat() && q.hasAction("Attack"));
    		    	if (MONKS.getArea().contains(Players.localPlayer())) {
    		    		if (zmonk != null) {
    		    			if (!zmonk.isInteractedWith() && !Players.localPlayer().isInCombat()) {
    		    				zmonk.interact("Attack");
    		    				Mouse.moveMouseOutsideScreen();
    		    			}
    		    		}
    		    } else {
                        sleepWhile(() -> Players.localPlayer().isAnimating(), () -> Players.localPlayer().isAnimating(),5000,5);
    		    }
    		    	
      return Calculations.random(1000,1200);
      
    		  }
    }	    
    		      


                    
                
                  
     

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.