Jump to content

PTY Botting

Members
  • Posts

    5
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by PTY Botting

  1. Incase someone else looking at this later

     

    On 3/8/2021 at 8:47 AM, Explv said:

    You're including the OSBot.jar in your script, instead of the compiled output.

    In the bottom right of your screen shot, where it says "Available Elements", you should be including "FirstBot2 compile output" (it should show up on the left side under the "Woodcutting_Script.jar". The "OSBot 2.6.20" should be on the right hand side (excluded from the compiled script)

     

  2. So much duplicated code, I think you need to try break it down more.

    There are 3 states

    • Alching
    • Buying
    • Exiting

    There are X Number of items which you are iterating in order

    Rune2h -> Rune Plate -> Rune Legs

    Heres is what I would try to do

    • Create an array which which holds the data for the item I wish to alch(Only name right now, but could hold things such as Times alched etc)
    • The initial state would be alching until no items
    • buy items (Trigger a flag saying bought items for current item once done)
    • alch until done
    • Switch the reference to the index of the array(Reset bought flag etc)
    • continue until x number of items done
    • reset index to 0, repeat.

     

    Using this way of having the current item stored in an array you can reduce duplicated code y taking a parameter into the method

    EG

    public void alchRpl8() throws InterruptedException {
    
    		if (getInventory().contains("Rune platebody")) {
    			if (!getPlayers().myPlayer().isAnimating()) {
    				magic.castSpell(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY);
    				Sleep.sleepUntil(() -> magic.isSpellSelected(), 5000);
    				getInventory().interact("cast", "Rune platebody");
    				runepl8 =+ 1;
    			}
    		}
    	}
    
    	

     

    could become

    public void alchItem(String itemName) throws InterruptedException {
    
    		if (getInventory().contains(itemName)) {
    			if (!getPlayers().myPlayer().isAnimating()) {
    				magic.castSpell(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY);
    				Sleep.sleepUntil(() -> magic.isSpellSelected(), 5000);
    				getInventory().interact("cast", itemName);
    			}
    		}
    	}
    
    	


    That way you don't need a separate method for each item you wish to alch
     

  3. On 3/2/2021 at 7:29 AM, Ricky Dactyl said:

    @mitsuki~
    not sure if you had this solved yet but I only just realised this section was a thing, here's what I've been using for my bots fresh from tutorial island.

     

    
    
    
    	public void setAttackStyle(String trainType) {
    	      int style = script.getConfigs().get(43);
    	      
    	      switch (trainType) {
    	        case "DEFENCE":
    	          if (style != 3) {
    	            while (!script.tabs.isOpen(Tab.ATTACK))
    	              script.getTabs().open(Tab.ATTACK); 
    //	            postStatus("CHANGING ATTACK STANCE TO DEFENCE");
    	            script.widgets.get(593, 17, 4).interact(new String[0]);
    	          } 
    	          break;
    	        case "ATTACK":
    	          if (style != 0) {
    	            while (!script.tabs.isOpen(Tab.ATTACK))
    	              script.getTabs().open(Tab.ATTACK); 
    //	            postStatus("CHANGING ATTACK STANCE TO ATTACK");
    	            script.widgets.get(593, 5, 4).interact(new String[0]);
    	          } 
    	          break;
    	        case "STRENGTH":
    	          if (style != 1) {
    	            while (!script.tabs.isOpen(Tab.ATTACK))
    	            script.getTabs().open(Tab.ATTACK); 
    //	            postStatus("CHANGING ATTACK STANCE TO STRENGTH");
    	            script.widgets.get(593, 9, 4).interact(new String[0]);
    	          }
    	          break;
    	      }
    	}

     

    You could simplify it to something like this (Although didn't test it), another step would be changing the traintype to an enum but yeah.

     

    	public void setAttackStyle(String trainType)
    	{
    		int style = script.getConfigs().get(43);
    		switch (trainType)
    		{
    			case "DEFENCE":
    				if (style != 3)
    				{
    					selectAttackStyle(17, 4);
    				}
    				break;
    			case "ATTACK":
    				if (style != 0)
    				{
    					selectAttackStyle(5, 4);
    				}
    				break;
    			case "STRENGTH":
    				if (style != 1)
    				{
    					selectAttackStyle(9, 4);
    				}
    				break;
    		}
    	}
    
    	private void selectAttackStyle(int childId, int subChildId)
    	{
    		if (!script.getTabs().open(Tab.ATTACK))
    		{
    			return;
    		}
    		RS2Widget widget = script.widgets.get(593, childId, subChildId);
    		if (widget != null && widget.isVisible())
    		{
    			widget.interact();
    		}
    	}

     

    • Like 2
×
×
  • Create New...