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
  • How do I correctly loot the loot from my NPC?


    Krugiztar

    Recommended Posts

    So I've been working on this combat script for a while, it works like charm and I decided to add a loot feature.

    The things is it keeps messing up alot.

    I tried making it attack then loot, but then it attacked and ran straight for a loot somewhere close.

    And i've tried a bunch of other things and this is what I want to do.

     

    Attack my NPC, WAIT until my npc is DEAD and then check for loot on those tiles that my enemy was standing at.

     

    Here are some things I have so far (I have some more but this will get you the gist of the script)

    NPC cows= getNpcs().closest("Cows");
    Area fightingArea = new Area(cows.getTile());
    
    if (cown.getInteractingCharacter() == null){
    cown.interact("Attack");
    sleepUntil(() -> getLocalPlayer().getInteractingCharacter() != null, 4253);
    }
    
    while (getLocalPlayer().getInteractingCharacter() != null){
    sleepUntil(() -> cows.getInteractingCharacter() == null, 9000);
    }
    
    if (getLocalPlayer().getInteractingCharacter() != null){
    if (fightingArea.contains(cowHides) || fightingArea.contains(bones) || fightingArea.contains(meat)) {
    cowHides.interact("Take");
    sleepUntil(() -> getInventory().count("Cowhide") > InvCowHide, 5621);
    
    bones.interact("Take");
    sleepUntil(() -> getInventory().count("Bones") > InvBones, 5621);
    
    beef.interact("Take");
    sleepUntil(() -> getInventory().count("Raw beef") > invBeef, 5621);
    }
    }

    Do you guys see what the issue is?

    Never done a script like this before so thats why its confusing.

    Really appriciate all the help! :D

     

    Link to comment
    Share on other sites

    If you don't get any other help soon, PM me and I'd be happy to walk you through this. I spotted a couple issues with your code but I would write it much differently and don't want to blind side you with a wall of code  :)

    Link to comment
    Share on other sites

    I'm learning too. But I think this is the reason your player runs away in combat. And the player should only loot when something is interacting with it.

    if (getLocalPlayer().getInteractingCharacter() != null){
    if (fightingArea.contains(cowHides) || fightingArea.contains(bones) || fightingArea.contains(meat)) {
    cowHides.interact("Take");
    sleepUntil(() -> getInventory().count("Cowhide") > InvCowHide, 5621);
    if (getLocalPlayer().getInteractingCharacter() != null)

    It will only loot if getLocalPlayer is interacting with something. If you made it 

    if (getLocalPlayer().getInteractingCharacter() == null)

    I think it would work.

     

     

    Edited because I hit post too early.

    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.