import com.speljohan.rsbot.script.Random;
import com.speljohan.rsbot.script.wrappers.RSNPC;
import com.speljohan.rsbot.script.wrappers.RSTile;
import java.awt.Point;
import java.util.List;
public class RuskisStrangePlant extends Random {
@Override
public double getVersion() {
return 1.0;
}
@Override
public String getAuthor() {
return "Ruski";
}
@Override
public String getName() {
return "RuskisStrangePlant";
}
@Override
public boolean activateCondition() {
RSNPC strangePlant = getNearestNPCByID(STRANGE_PLANT_ID);
if(strangePlant != null) {
RSTile strangePlantTile = strangePlant.getLocation();
if(distanceTo(strangePlantTile) == 1) {
currentPlant = strangePlant;
return true;
}
}
return false;
}
@Override
public int loop() {
if(currentPlant != null) {
if(!currentPlant.isValid() || getNearestNPCByID(STRANGE_PLANT_ID) == null) {
return -1;
}
if(currentPlant.getAnimation() == 348) {
return random(510, 1310);
}
if(currentPlant.getAnimation() == 350) {
return random(410, 810);
}
if(currentPlant.getAnimation() <= 0 && currentPlant.isValid()) {
clickNPC(currentPlant, "Pick");
return random(6100, 11000);
}
}
return -1;
}
private boolean clickNPC(RSNPC npc, String action) {
if (npc == null) {
return false;
}
RSTile tile = npc.getLocation();
if (!tile.isValid()) {
return false;
}
try {
Point screenLoc = npc.getScreenLocation();
if (distanceTo(tile) > 6 || !pointOnScreen(screenLoc)) {
turnToTile(tile);
}
if (distanceTo(tile) > 20) {
walkTileMM(tile);
return false;
}
for (int i = 0; i < 12; i++) {
screenLoc = npc.getScreenLocation();
if (!npc.isValid() || !pointOnScreen(screenLoc)) {
return false;
}
moveMouse(screenLoc, -15, 15);
if (getMenuItems().get(0).toLowerCase().contains(npc.getName().toLowerCase())) {
break;
}
if (getMouseLocation().equals(screenLoc)) {
break;
}
}
List<String> menuItems = getMenuItems();
if (menuItems.isEmpty()) {
return false;
}
for (int a = 0; a < menuItems.size(); a++) {
if (menuItems.get(a).toLowerCase().contains(npc.getName().toLowerCase())) {
if (menuItems.get(0).toLowerCase().contains(action.toLowerCase())) {
clickMouse(true);
return true;
} else {
clickMouse(false);
return atMenu(action);
}
}
}
} catch (Exception e) {
System.out.print("clickNPC(RSNPC, String) error: " + e);
return false;
}
return false;
}
private int ALIVE_ANIM = 348;
private int DEAD_ANIM = 350;
private int STRANGE_PLANT_ID = 407;
private RSNPC currentPlant;
}