Wanted to introduce myself, you can call me skid.
I think I found my new hobby! I am sitting here enjoying some nice scotch watching my script kill cows.
This weekend I finally gave in to all these ads about being able to play runescape on mobile. Having played runescape extensively in middle school I couldn't help but give in to the nostalgia and played through tutorial island on my phone.
After a while I said hell I will just play a bit and started playing on my computer. Then I thought, well hell why not play multiple accounts at a time to keep my mind stimulated. Fast forward and I am playing four accounts at once while listening to podcast. I thought again, why not automate this so I started googling and came across this community. A little reading of OSBot's API and lurking this forum for code examples and I was on my way!
Full disclosure, I have been a self-taught software engineer for the last three years or so and just started picking up Java as part of a new job so it didn't take a lot to come up with something that worked. What's the best way to get involved around here? I love the OSBot and just bought VIP so I can start running multiple bots at a time. I'd love to read some of people's more advanced scripts that they don't mind having open-sourced.
Here's my first script! It went through a few revisions. I am still trying to understand how to best organize code around OSBot's API.
public class CowKiller {
private MethodProvider B;
private String[] advesaryStrings = { "Cow", "Cow calf" };
public CowKiller(MethodProvider B) {
this.B = B;
}
public void execute() throws InterruptedException {
while(lifeSafe()) {
if (B.getSettings().getRunEnergy() > 20) {
run();
}
NPC advesary = getAdvesary();
attack(advesary);
}
run();
B.getWalking().walk(Banks.LUMBRIDGE_LOWER);
}
private void attack(NPC advesary) throws InterruptedException {
B.log("Attacking advesary!!!!!!!!!!!!!!");
while(attackCondition(advesary) && lifeSafe()) {
B.log("attacking the cow");
advesary.interact("Attack");
B.sleep(B.random(1000, 5000));
}
}
private NPC getAdvesary() {
return B.getNpcs().closest(npc -> attackable(npc));
}
private boolean attackable(NPC advesary) {
return wantedAdvesary(advesary) &&
advesary.getInteracting() == null &&
!advesary.isUnderAttack() &&
!advesary.isHitBarVisible() &&
B.getMap().canReach(advesary);
}
private boolean lifeSafe() {
return B.skills.getDynamic(Skill.HITPOINTS) > 10;
}
private boolean attackCondition(NPC advesary) {
return advesary.exists() && advesary.isAttackable();
}
private void run() {
B.getSettings().setRunning(true);
}
private boolean wantedAdvesary(NPC advesary) {
for (String advesaryString : advesaryStrings) {
if (advesary.getName().equals(advesaryString)) {
return true;
}
}
return false;
}
}
I think that's enough for an introduction, cheers!