Jump to content
Parabot - Bot for Ikov, DreamScape, SoulPlay, RuneWild, and more
  • 0
Deerkan

Isn't picking up items properly {Dreamscape}

Question

As the title says, it's not picking up items in the given radius, infact - it only picks an item up if it's directly on top of the item.

	        if (!Players.getMyPlayer().isInCombat()) {GroundItem[] loot = GroundItems.getNearest(12159, 12160, 12161, 12164, 990, 6200, 995, 80, 21004, 20235, 13836, 13834, 19314, 19315, 19316, 6202, 6204, 3881, 3885);
        for(int i = 0; i < loot.length; i++)
        {
            if (loot.length > 0 && loot[i] != null)
	        {
	            if (loot[i].distanceTo() <= 15)
	        { 
	           loot[i].interact(2);
	          Time.sleep(new SleepCondition() {
	              @Override
              public boolean isValid() {
                   return loot == null;
              }
          }, 1500);
	       }
	    }
        }
}   

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0
4 hours ago, Deerkan said:

As the title says, it's not picking up items in the given radius, infact - it only picks an item up if it's directly on top of the item.

 

	        if (!Players.getMyPlayer().isInCombat()) {GroundItem[] loot = GroundItems.getNearest(12159, 12160, 12161, 12164, 990, 6200, 995, 80, 21004, 20235, 13836, 13834, 19314, 19315, 19316, 6202, 6204, 3881, 3885);
        for(int i = 0; i < loot.length; i++)
        {
            if (loot.length > 0 && loot[i] != null)
	        {
	            if (loot[i].distanceTo() <= 15)
	        { 
	           loot[i].interact(2);
	          Time.sleep(new SleepCondition() {
	              @Override
              public boolean isValid() {
                   return loot == null;
              }
          }, 1500);
	       }
	    }
        }
}   

 

import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.SleepCondition;
import org.rev317.min.api.methods.GroundItems;
import org.rev317.min.api.methods.Inventory;
import org.rev317.min.api.wrappers.GroundItem;

public class HandleNests implements org.parabot.environment.scripts.framework.Strategy {
    private GroundItem[] groundItems;

    @Override
    public boolean activate() {
        return !Inventory.isFull()
                && (groundItems = GroundItems.getNearest(Constants.NEST_ID - 1)) != null
                && groundItems.length > 0;
    }

    @Override
    public void execute() {
        try {
            final int lastCount = Inventory.getCount(Constants.NEST_ID);
            groundItems[0].interact(GroundItems.Option.TAKE);
            Time.sleep(new SleepCondition() {
                @Override
                public boolean isValid() {
                    return Inventory.getCount(Constants.NEST_ID) > lastCount;
                }
            }, 1500);
        } catch (Exception ignored) {
        }
    }
}

Here's a snippet

Share this post


Link to post
Share on other sites
  • 0
2 hours ago, EmmaStone said:
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.SleepCondition;
import org.rev317.min.api.methods.GroundItems;
import org.rev317.min.api.methods.Inventory;
import org.rev317.min.api.wrappers.GroundItem;

public class HandleNests implements org.parabot.environment.scripts.framework.Strategy {
    private GroundItem[] groundItems;

    @Override
    public boolean activate() {
        return !Inventory.isFull()
                && (groundItems = GroundItems.getNearest(Constants.NEST_ID - 1)) != null
                && groundItems.length > 0;
    }

    @Override
    public void execute() {
        try {
            final int lastCount = Inventory.getCount(Constants.NEST_ID);
            groundItems[0].interact(GroundItems.Option.TAKE);
            Time.sleep(new SleepCondition() {
                @Override
                public boolean isValid() {
                    return Inventory.getCount(Constants.NEST_ID) > lastCount;
                }
            }, 1500);
        } catch (Exception ignored) {
        }
    }
}

Here's a snippet

Thank you. I seem to be getting a few errors when compiling. 

 

[code]/tmp/jc_19437/thugKilla2.java:41: error: cannot find symbol
                && (groundItems = GroundItems.getNearest(Constants.NEST_ID - 12159, 12160, 12161, 12164, 990, 6200, 995, 80, 21004, 20235, 13836, 13834, 19314, 19315, 19316, 6202, 6204, 3881, 3885)) != null
                                                         ^
  symbol:   variable Constants
  location: class thugKilla2.HandleNests
/tmp/jc_19437/thugKilla2.java:48: error: cannot find symbol
            final int lastCount = Inventory.getCount(Constants.NEST_ID);
                                                     ^
  symbol:   variable Constants
  location: class thugKilla2.HandleNests
/tmp/jc_19437/thugKilla2.java:49: error: cannot find symbol
            groundItems[0].interact(GroundItems.Option.TAKE);
                                               ^
  symbol:   variable Option
  location: class GroundItems
/tmp/jc_19437/thugKilla2.java:53: error: cannot find symbol
                    return Inventory.getCount(Constants.NEST_ID) > lastCount;
                                              ^
  symbol: variable Constants
4 errors[/code]

So they are all basically saying that it doesn't understand the variable? I'm using the Latest Minified 317 API as Jar2 if that helps us solve the problem any quicker.

Here's the full script, maybe I'm missing something entirely.. I'm not tech savvy in the slightest but i'm trying to understand so I can at the very least make basic scripts I want on my own.

import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.Category;
import org.parabot.environment.scripts.ScriptManifest;
import org.parabot.environment.scripts.Script;
import org.parabot.environment.scripts.framework.SleepCondition;
import org.parabot.environment.scripts.framework.Strategy;
import org.rev317.min.api.methods.GroundItems;
import org.rev317.min.api.methods.Npcs;
import org.rev317.min.api.methods.Players;
import org.rev317.min.api.methods.Inventory;
import org.rev317.min.api.wrappers.GroundItem;
import org.rev317.min.api.wrappers.Npc;
import java.awt.Graphics;
import java.awt.Image;
import java.util.ArrayList;
    
@ScriptManifest(author = "Deerkan", category = Category.COMBAT, description = "Kills thugs", name = "thugKilla2", servers = { "Dreamscape" }, version = 1)
public class thugKilla2 extends Script {
        private final ArrayList<Strategy> strategies = new ArrayList<Strategy>();
    Image _i;
        @Override
    public boolean onExecute() {
        strategies.add(new Attack());
        strategies.add(new HandleNests()); //added this? it didn't seem to make a difference either way
        provide(strategies);
        return true;
    }
        @Override
    public void onFinish() {
        }
    
    public void paint(Graphics g) {
        g.drawRect(0, 40, 100, 200);
    }
    public class HandleNests implements Strategy {
    private GroundItem[] groundItems;
	    @Override
    public boolean activate() {
        return !Inventory.isFull()
                && (groundItems = GroundItems.getNearest(Constants.NEST_ID - 12159, 12160, 12161, 12164, 990, 6200, 995, 80, 21004, 20235, 13836, 13834, 19314, 19315, 19316, 6202, 6204, 3881, 3885)) != null
                && groundItems.length > 0;
    }
	    @Override
    public void execute() {
        try {
            final int lastCount = Inventory.getCount(Constants.NEST_ID);
            groundItems[0].interact(GroundItems.Option.TAKE);
            Time.sleep(new SleepCondition() {
                @Override
                public boolean isValid() {
                    return Inventory.getCount(Constants.NEST_ID) > lastCount;
                }
            }, 1500);
        } catch (Exception ignored) {
        }
    }
}
    public class Attack implements Strategy {
        
        @Override
        public boolean activate() {                                    
            return  !Players.getMyPlayer().isInCombat();
      }
            @SuppressWarnings("deprecation")
        @Override
        public void execute() {
            Npc enemy = Npcs.getClosest(95);
            if (enemy != null && !enemy.isInCombat() == true) {
Time.sleep(new SleepCondition() {
                @Override
                public boolean isValid() {
                   return Players.getMyPlayer().isInCombat();
                }
            }, 1500);
            }
        }
    }
  }

I appreciate any further assistance!

Edited by Deerkan

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...