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
  • Try asking for help in the chatbox
  • need some more help


    Jordan2310
     Share

    Recommended Posts

    package Main;
    
    import org.dreambot.api.methods.container.impl.equipment.EquipmentSlot;
    import org.dreambot.api.methods.filter.Filter;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.skills.Skill;
    import org.dreambot.api.methods.skills.Skills;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.wrappers.interactive.NPC;
    
    @ScriptManifest(category = Category.COMBAT, name = "my script", author = "jordan", version = 1.0)
    public class Main extends AbstractScript {
        public static final String BRONZE_AXE = "Bronze axe";
        public static final String GOBLIN = "Goblin";
        public static final String GIANT_SPIDER = "Giant spider";
        public static final Filter<NPC> GOBLIN_FILTER = npc -> {
            if (npc == null) {
                return false;
            }
    
    
            return npc.getName().equals(GOBLIN) && !npc.isHealthBarVisible();
    
    
        };
    
    
        private final Area killArea = new Area(3243, 3241, 3259, 3231);
    
        @Override
        public int onLoop() {
            if (getLocalPlayer().isInCombat()) {
                //do nothing
            } else if (killArea.contains(getLocalPlayer())) {
                if (getEquipment().isSlotEmpty(EquipmentSlot.WEAPON.getSlot())) {
                    if (getInventory().contains(BRONZE_AXE)) {
                        getInventory().interact(BRONZE_AXE, "Wield");
                    } else {
                        stop();
                        return -1;
                    }
    
    
                } else {
                    Skills getSkills = null;
                    if (getSkills.getRealLevel(Skill.STRENGTH) >= 10) {
    
                    }
                    NPC goblin = getNpcs().closest(GOBLIN_FILTER);
                    if (goblin != null) {
    
                        }
                            goblin.interact("Attack");
                        if (getSkills.getRealLevel(Skill.STRENGTH) >= 20) {
    
                            goblin = getNpcs().closest(GIANT_SPIDER);
                            if (goblin != null) {
    
                                final boolean attack = goblin.interact("Attack");
                            }
                        }
                        }
    
                    }
                        getWalking().walk(killArea.getRandomTile());
            return 1000;
        }
                }

    is this script even close to being right im trying to make get to 10 str  and at 10 str change to giany spiders till 20 str and so on please help if you can 

    Link to comment
    Share on other sites

    Hi

    1) why are you implementing filters this way? ever heard of lambdas?

    This may help you: https://www.tutorialspoint.com/java8/java8_lambda_expressions.htm

    Ex of using lambdas: 

    getNpcs().closest(n->n!=null && n.getName().equals("Goblin") & n.hasAction("Attack"));

     

    2) This code is basically (With all respect to you man) trash, its hard to read through..

    } else {
                    Skills getSkills = null;
                    if (getSkills.getRealLevel(Skill.STRENGTH) >= 10) {
    
                    }
                    NPC goblin = getNpcs().closest(GOBLIN_FILTER);
                    if (goblin != null) {
    
                        }
                            goblin.interact("Attack");
                        if (getSkills.getRealLevel(Skill.STRENGTH) >= 20) {
    
                            goblin = getNpcs().closest(GIANT_SPIDER);
                            if (goblin != null) {
    
                                final boolean attack = goblin.interact("Attack");
                            }
                        }
                        }
    
                    }
                        getWalking().walk(killArea.getRandomTile());

     

    I'm gonna save you some time and write you what you should do:

    private void walkAndAttack() {
    	if(getSkills().getRealLevel(Skill.STRENGTH) < 10) {
     		if(GOBLIN_LOCATION_AREA.contains(getLocalPlayer()) {
          		if(!getLocalPlayer().isInCombat()) attack(Goblin); 
            } else {
              if(getWalking().shouldWalk(7)) getWalking().walk(GOBLIN_LOCATION_AREA.getRandomTile());
            }    
        } else if(getSkills().getRealLevel(Skill.STRENGTH) < 20) {
     		if(SPIDER_LOCATION_AREA.contains(getLocalPlayer()) {
          		if(!getLocalPlayer().isInCombat()) attack(Spider); 
            } else {
              if(getWalking().shouldWalk(7)) getWalking().walk(SPIDER_LOCATION_AREA.getRandomTile());
            }    
    	}
    }
      
    private void attack(String npc) {
      NPC npc_to_attack = getNpcs().closest(n->n!=null && n.getName().equals(npc) && !n.isInCombat());
      if(npc_to_attack != null) {
       	  if(npc_to_attack.interact("Attack")) sleepUntil(()->getLocalPlayer().isInCombat(),3000);
      }
    }

    This code that I wrote is basically what you need and  can be improved a lot. Learn java man 😛

    Edited by Defiled
    Forgot to add the player combat check, added..
    Link to comment
    Share on other sites

    10 hours ago, Defiled said:

    Hi

    1) why are you implementing filters this way? ever heard of lambdas?

    This may help you: https://www.tutorialspoint.com/java8/java8_lambda_expressions.htm

    Ex of using lambdas: 

    getNpcs().closest(n->n!=null && n.getName().equals("Goblin") & n.hasAction("Attack"));

     

    2) This code is basically (With all respect to you man) trash, its hard to read through..

    } else {
                    Skills getSkills = null;
                    if (getSkills.getRealLevel(Skill.STRENGTH) >= 10) {
    
                    }
                    NPC goblin = getNpcs().closest(GOBLIN_FILTER);
                    if (goblin != null) {
    
                        }
                            goblin.interact("Attack");
                        if (getSkills.getRealLevel(Skill.STRENGTH) >= 20) {
    
                            goblin = getNpcs().closest(GIANT_SPIDER);
                            if (goblin != null) {
    
                                final boolean attack = goblin.interact("Attack");
                            }
                        }
                        }
    
                    }
                        getWalking().walk(killArea.getRandomTile());

     

    I'm gonna save you some time and write you what you should do:

    private void walkAndAttack() {
    	if(getSkills().getRealLevel(Skill.STRENGTH) < 10) {
     		if(GOBLIN_LOCATION_AREA.contains(getLocalPlayer()) {
          		attack(Goblin); 
            } else {
              if(getWalking().shouldWalk(7)) getWalking().walk(GOBLIN_LOCATION_AREA.getRandomTile());
            }    
        } else if(getSkills().getRealLevel(Skill.STRENGTH) < 20) {
     		if(SPIDER_LOCATION_AREA.contains(getLocalPlayer()) {
          		attack(Spider); 
            } else {
              if(getWalking().shouldWalk(7)) getWalking().walk(SPIDER_LOCATION_AREA.getRandomTile());
            }    
    	}
    }
      
    private void attack(String npc) {
      NPC npc_to_attack = getNpcs().closest(n->n!=null && n.getName().equals(npc) && !n.isInCombat());
      if(npc_to_attack != null) {
       	  if(npc_to_attack.interact("Attack")) sleepUntil(()->getLocalPlayer().isInCombat(),3000);
      }
    }

    This code that I wrote is basically what you need and  can be improved a lot. Learn java man 😛

    I am leaning java I’m doing a online course I just really wont to get this script up and running for me so I can leave this running why I’m doing the courses but thanks you again for your help it really mean a lot that you have took the time to write that bit of code for me 

    Link to comment
    Share on other sites

    3 minutes ago, Jordan2310 said:

    I am leaning java I’m doing a online course I just really wont to get this script up and running for me so I can leave this running why I’m doing the courses but thanks you again for your help it really mean a lot that you have took the time to write that bit of code for me 

    Understandable, well good luck on your learning journey! I hope it'll be a blast! and yeah man no worries, anytime

    BTW, In the code I've forgot to check whether the player is in combat or not.. I'll add that in a sec! Sorry about that

    Edited by Defiled
    Link to comment
    Share on other sites

    11 minutes ago, Defiled said:

    Understandable, well good luck on your learning journey! I hope it'll be a blast! and yeah man no worries, anytime

    How much would it cost for you to write me a very basic script for my that gets me to 70 att str def or if you can do it for free that would be a big help you can say no I will totally understand sorry to be a pain 

    Link to comment
    Share on other sites

    6 minutes ago, Jordan2310 said:

    How much would it cost for you to write me a very basic script for my that gets me to 70 att str def or if you can do it for free that would be a big help you can say no I will totally understand sorry to be a pain 

    I'm sorry but I can't currently accept private scripts, also my time is really short currently due to uni exams.

    But if you have questions regarding scripting or whatever contact me via discord.. Defiledx1#0642

    Edited by Defiled
    Link to comment
    Share on other sites

    1 minute ago, Defiled said:

    I'm sorry but I'm unable currently of accepting private scripts, also my time is really short currently due to uni exams.

    No that’s fine though I would ask lol thanks you tho 

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • 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.