Add ores and mine

This commit is contained in:
RedSparr0w
2019-10-14 14:54:32 +13:00
parent 0ec30babb7
commit 355ea71065
2 changed files with 68 additions and 11 deletions
+37
View File
@@ -0,0 +1,37 @@
package ParaScript.data.variables;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public enum Ores {
COPPER("Copper", new int[]{2090}),
TIN("Tin", new int[]{2094}),
COPPER_TIN("Copper & Tin", new int[]{2090, 2094}),
IRON ("Iron", new int[]{2092}),
COAL("Coal", new int[]{});
private String name;
private int[] ids;
Ores(String name, int[] ids) {
this.name = name;
this.ids = ids;
}
public static String[] toStringArray() {
List<Ores> enumList = Arrays.asList(Ores.values());
List<String> locationsArray = new ArrayList<>();
for (Ores obj : enumList) {
locationsArray.add(obj.name);
}
String[] simpleArray = new String[ locationsArray.size() ];
locationsArray.toArray( simpleArray );
return(simpleArray);
}
public int[] getIDs() {
return this.ids;
}
}
+31 -11
View File
@@ -1,6 +1,10 @@
package ParaScript.strategies; package ParaScript.strategies;
import ParaScript.data.Variables; import ParaScript.data.Variables;
import ParaScript.data.variables.Ores;
import ParaScript.data.variables.Trees;
import com.sun.deploy.util.ArrayUtil;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.framework.Strategy; import org.parabot.environment.scripts.framework.Strategy;
import org.rev317.min.api.methods.Inventory; import org.rev317.min.api.methods.Inventory;
import org.rev317.min.api.methods.Players; import org.rev317.min.api.methods.Players;
@@ -8,25 +12,41 @@ import org.rev317.min.api.methods.SceneObjects;
import org.rev317.min.api.wrappers.SceneObject; import org.rev317.min.api.wrappers.SceneObject;
public class Mine implements Strategy { public class Mine implements Strategy {
private SceneObject ore;
@Override @Override
public boolean activate() { public boolean activate() {
for (SceneObject i : SceneObjects.getNearest(100)) { ore = ore(); // set the local Variable
if (Variables.running if (Variables.running
&& i !=null && ore != null
&& i.distanceTo() <= 10 && (Variables.getStatus() == "none" || Variables.getStatus() == "mining")
&& !Players.getMyPlayer().isInCombat() && !Players.getMyPlayer().isInCombat()
&& Players.getMyPlayer().getAnimation() == -1 && Players.getMyPlayer().getAnimation() == -1
&& !Inventory.isFull()) { && !Inventory.isFull()) {
return true; Variables.setStatus("mining");
} return true;
} }
Variables.setStatus("none");
return false; return false;
} }
@Override @Override
public void execute() { public void execute() {
for (SceneObject i : SceneObjects.getNearest(100)) { try {
i.interact(SceneObjects.Option.MINE); ore.interact(SceneObjects.Option.MINE);
Time.sleep(1000);
Time.sleep(() -> Players.getMyPlayer().getAnimation() == -1, 3000);
} catch (Exception err){
System.out.println("Mining error: ¯\\_(ツ)_/¯");
} }
} }
private SceneObject ore(){
for(SceneObject tree : SceneObjects.getNearest(Ores.COPPER_TIN.getIDs())){
if(tree != null){
return ore;
}
}
return null;
}
} }