package Ranged;
import org.osbot.rs07.antiban.AntiBan;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.Player;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import java.awt.*;
import java.util.concurrent.TimeUnit;
/**
* Created by Admin on 10/24/2015.
*/
@ScriptManifest(name="Varrock Skeleton Ranger",author="Acinate", info="Ranges Skeletons inside Varrock Sewer.", version=1.1, logo="")
public class Skeleton_Ranger extends Script {
Area RiverSpot = new Area(3253,9911,3255,9907);
Area RangeSpot = new Area(3253,9911,3253,9911);
Area Skeletons = new Area(3250,9918,3256,9914);
Area FarSkeletons = new Area(3249,9913,3246,9918);
Position SafeSpot = new Position(3253,9911,0);
Player[] randomPlayers = new Player[] {};
public boolean isSkeleton() {
NPC Skeleton = npcs.closest(Skeletons, "Skeleton");
if (Skeleton.isUnderAttack()) {
return true;
} else return false;
}
public long timeBegan;
public long timeRan;
private int startXP, currentXP, GainedXP, xpPerHour;
public void onStart() throws InterruptedException {
log("Thanks for choosing SkeletonZ!");
timeBegan = System.currentTimeMillis();
startXP = skills.getExperience(Skill.RANGED)
+ skills.getExperience(Skill.DEFENCE)
+ skills.getExperience(Skill.HITPOINTS);
}
private enum State { KILL, IDLE, HOP, SAFEMODE, DIA };
private State getState() {
if (dialogues.isPendingContinuation())
return State.DIA;
else if (!RiverSpot.contains(myPlayer()) && !myPlayer().isAnimating())
return State.SAFEMODE;
else if (RiverSpot.contains(myPlayer()) && !myPlayer().isAnimating())
return State.KILL;
else
return State.IDLE;
}
public int onLoop() throws InterruptedException {
switch(getState()) {
case DIA:
dialogues.clickContinue();
case KILL:
log("case KILL:");
NPC Skeleton = npcs.closest(Skeletons, "Skeleton");
NPC FarSkeleton = npcs.closest(FarSkeletons, "Skeleton");
if (RangeSpot.contains(myPlayer())) {
if (Skeleton != null && !myPlayer().isInteracting(Skeleton)) {
if (Skeleton.getAnimation() != 5491)
Skeleton.interact("Attack");
} else if (Skeleton == null && FarSkeleton != null) {
log("Attacking far Skeletons....");
FarSkeleton.interact("Attack");
localWalker.walk(RangeSpot, true);
sleep(random(1000,2000));
FarSkeleton.interact("Attack");
}
} else if(!RangeSpot.contains(myPlayer())) {
SafeSpot.interact(bot,"Walk here");
}
break;
case SAFEMODE:
log("case SAFEMODE:");
localWalker.walk(RiverSpot, true);
break;
case IDLE:
log("case IDLE:");
NPC Skele = npcs.closest(Skeletons, "Skeleton");
int SkeleHealth;
SkeleHealth = Skele.getHealth();
log(SkeleHealth);
int random = random(0, 10);
log(random);
while (myPlayer().isAnimating() && SkeleHealth > 0) {
if (random < 2)
tabs.getSkills().hoverSkill(Skill.RANGED);
else if (random == 3)
tabs.getSkills().hoverSkill(Skill.RANGED);
else if (random == 4)
tabs.getSkills().hoverSkill(Skill.HITPOINTS);
else if (random == 5)
{
log("Adjusting Camera");
if (isSkeleton() == true)
camera.toEntity(Skele);
}
else if (random > 5) {
mouse.moveRandomly();
if (random == 6)
sleep(random(2000, 3000));
else if (random == 7)
sleep(random(3000, 4000));
else if (random == 8)
sleep(random(4000, 5000));
else if (random >= 9)
sleep(random(5000, 6000));
}
}
NPC nextSkele = npcs.closest(Skeletons, "Skeleton");
if (isSkeleton() == false) {
log("Attacking next Skeleton..");
nextSkele.interact("Attack");
}
if (random % 3 == 0)
tabs.open(Tab.INVENTORY);
mouse.moveRandomly();
break;
}
return 1000;
}
public void onPaint(Graphics2D g) {
Graphics2D gr = g;
gr.setColor(Color.WHITE);
gr.setFont(new Font("Arial", Font.ROMAN_BASELINE, 14));
timeRan = System.currentTimeMillis() - timeBegan;
currentXP = skills.getExperience(Skill.RANGED)
+ skills.getExperience(Skill.DEFENCE)
+ skills.getExperience(Skill.HITPOINTS);
GainedXP = currentXP - startXP;
xpPerHour = (int)(GainedXP / ((System.currentTimeMillis() - timeBegan) / 3600000.0));
gr.drawString("Time Ran: " + ft(timeRan), 25, 297);
gr.drawString("XP Gained: " + GainedXP, 25, 312);
gr.drawString("XP Per hour:" + xpPerHour, 25, 327);
}
private String ft(long duration)
{
String res = "";
long days = TimeUnit.MILLISECONDS.toDays(duration);
long hours = TimeUnit.MILLISECONDS.toHours(duration)
- TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
- TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
.toHours(duration));
long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
- TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
.toMinutes(duration));
if (days == 0) {
res = (hours + ":" + minutes + ":" + seconds);
} else {
res = (days + ":" + hours + ":" + minutes + ":" + seconds);
}
return res;
}
}