Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.dreambot.api.methods.Calculations;
- import org.dreambot.api.methods.filter.Filter;
- import org.dreambot.api.script.AbstractScript;
- import org.dreambot.api.script.ScriptManifest;
- import org.dreambot.api.script.Category;
- import org.dreambot.api.wrappers.interactive.NPC;
- import org.dreambot.api.wrappers.items.GroundItem;
- import org.dreambot.api.methods.skills.SkillTracker;
- import org.dreambot.api.methods.skills.Skill;
- @ScriptManifest(author = "Rand", name = "ChickenFighter", version = 1.0, description = "AttacksChickens", category = Category.COMBAT)
- public class main extends AbstractScript {
- public static int runEnergy = 0;
- public SkillTracker skills = new SkillTracker(getClient());
- public void onStart() {
- log("Welcome to ChickenFighter 1.0");
- log("Loots feathers, toggles run, avoids unreachable targets");
- skills.start();
- }
- public void onExit() {
- log("Thank you for using ChickenFighter 1.0");
- log("you gained " + skills.getGainedExperience(Skill.ATTACK) + ", " + skills.getGainedExperience(Skill.STRENGTH)
- + ", " + skills.getGainedExperience(Skill.DEFENCE) + ", " + skills.getGainedExperience(Skill.HITPOINTS) +
- " attack, strength, defense, and hitpoints xp");
- }
- @Override
- public int onLoop() {
- runAntiban();
- if (!getLocalPlayer().isInCombat()) { //player is not fighting currently
- if (Calculations.random(3) > 2) { //chooses to pickup feather 1/4 of the time
- pickupFeather();
- }
- NPC chicken = getNpcs().closest(new Filter<NPC>() { //finds closest chicken not in combat that is reachable
- @Override
- public boolean match(NPC npc) {
- return npc != null && npc.getName().equals("Chicken") && npc.getActions().length > 0 && !npc.isInCombat() && getMap().canReach(npc);
- }
- }); //closing parentheses for filter object that was created
- if (chicken != null)
- chicken.interact("Attack"); //attack closest chicken that matches filter
- }
- return Calculations.random(500, 600);
- }
- //enable run randomly based on global variable
- public void runAntiban() {
- if((getWalking().getRunEnergy() > runEnergy) && !getWalking().isRunEnabled()) {
- getWalking().toggleRun();
- runEnergy = Calculations.random(0, 90);
- }
- }
- //picks up closest feathers
- public void pickupFeather() {
- GroundItem feather = getGroundItems().closest(new Filter<GroundItem>() {
- @Override
- public boolean match (GroundItem target) {
- return target.getName().equals("Feather") && getMap().canReach(target);
- }
- });
- if(feather != null) {
- if (Calculations.random(2) > 0) { //do 2/3 of the time
- feather.interact("Take");
- } else {
- feather.interactForceRight("Take"); //do 1/3 of the time
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment