randalthor7

Dreambot - Chicken Fighter

Aug 15th, 2015
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. import org.dreambot.api.methods.Calculations;
  2. import org.dreambot.api.methods.filter.Filter;
  3. import org.dreambot.api.script.AbstractScript;
  4. import org.dreambot.api.script.ScriptManifest;
  5. import org.dreambot.api.script.Category;
  6. import org.dreambot.api.wrappers.interactive.NPC;
  7. import org.dreambot.api.wrappers.items.GroundItem;
  8. import org.dreambot.api.methods.skills.SkillTracker;
  9. import org.dreambot.api.methods.skills.Skill;
  10.  
  11.  
  12. @ScriptManifest(author = "Rand", name = "ChickenFighter", version = 1.0, description = "AttacksChickens", category = Category.COMBAT)
  13. public class main extends AbstractScript {
  14. public static int runEnergy = 0;
  15. public SkillTracker skills = new SkillTracker(getClient());
  16.  
  17. public void onStart() {
  18. log("Welcome to ChickenFighter 1.0");
  19. log("Loots feathers, toggles run, avoids unreachable targets");
  20. skills.start();
  21. }
  22.  
  23. public void onExit() {
  24. log("Thank you for using ChickenFighter 1.0");
  25. log("you gained " + skills.getGainedExperience(Skill.ATTACK) + ", " + skills.getGainedExperience(Skill.STRENGTH)
  26. + ", " + skills.getGainedExperience(Skill.DEFENCE) + ", " + skills.getGainedExperience(Skill.HITPOINTS) +
  27. " attack, strength, defense, and hitpoints xp");
  28. }
  29.  
  30. @Override
  31. public int onLoop() {
  32. runAntiban();
  33. if (!getLocalPlayer().isInCombat()) { //player is not fighting currently
  34. if (Calculations.random(3) > 2) { //chooses to pickup feather 1/4 of the time
  35. pickupFeather();
  36. }
  37. NPC chicken = getNpcs().closest(new Filter<NPC>() { //finds closest chicken not in combat that is reachable
  38. @Override
  39. public boolean match(NPC npc) {
  40. return npc != null && npc.getName().equals("Chicken") && npc.getActions().length > 0 && !npc.isInCombat() && getMap().canReach(npc);
  41. }
  42. }); //closing parentheses for filter object that was created
  43. if (chicken != null)
  44. chicken.interact("Attack"); //attack closest chicken that matches filter
  45. }
  46. return Calculations.random(500, 600);
  47. }
  48.  
  49. //enable run randomly based on global variable
  50. public void runAntiban() {
  51. if((getWalking().getRunEnergy() > runEnergy) && !getWalking().isRunEnabled()) {
  52. getWalking().toggleRun();
  53. runEnergy = Calculations.random(0, 90);
  54. }
  55. }
  56.  
  57. //picks up closest feathers
  58. public void pickupFeather() {
  59. GroundItem feather = getGroundItems().closest(new Filter<GroundItem>() {
  60. @Override
  61. public boolean match (GroundItem target) {
  62. return target.getName().equals("Feather") && getMap().canReach(target);
  63. }
  64. });
  65. if(feather != null) {
  66. if (Calculations.random(2) > 0) { //do 2/3 of the time
  67. feather.interact("Take");
  68. } else {
  69. feather.interactForceRight("Take"); //do 1/3 of the time
  70. }
  71. }
  72. }
  73. }
Add Comment
Please, Sign In to add comment