Advertisement
Guest User

Untitled

a guest
Apr 20th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. package com.ikovps.slayer.strategies;
  2.  
  3. import org.parabot.environment.api.utils.Filter;
  4. import org.parabot.environment.api.utils.Time;
  5. import org.parabot.environment.scripts.framework.SleepCondition;
  6. import org.parabot.environment.scripts.framework.Strategy;
  7. import org.rev317.min.api.methods.Npcs;
  8. import org.rev317.min.api.methods.Players;
  9. import org.rev317.min.api.wrappers.Npc;
  10.  
  11. import com.ikovps.slayer.data.Variables;
  12. import com.ikovps.slayer.util.Equipment;
  13. import com.ikovps.slayer.util.Utils;
  14.  
  15. /**
  16. * A class that attacks assigned Slayer monsters.
  17. *
  18. * @author Masood && El Maestro
  19. *
  20. */
  21. public class HandleCombat implements Strategy {
  22. private Npc monsterToFight = null;
  23.  
  24. @Override
  25. public boolean activate() {
  26. if (Variables.getTask().atTask() && (!Variables.getTask().isDone() || Variables.getTask().isDone())) {
  27. return !Utils.isFighting() || Utils.canSpecial() && !Utils.isSpecActivated() || !Utils.canSpecial()
  28. && Equipment.WEAPON.isWearing(Variables.getSpecialWeapon());
  29. }
  30. return false;
  31. }
  32.  
  33. @Override
  34. public void execute() {
  35. Variables.setStatus("Completing task...");
  36. if (Variables.getTask().getPrayer() != null && !Variables.getTask().getPrayer().isActivated()) {
  37. Variables.getTask().getPrayer().toggle();
  38. }
  39. if (!Utils.retaliateIsToggled()) {
  40. Utils.toggleRetaliate();
  41. }
  42. if (Variables.isSpecialAttack()) {
  43. if (Utils.canSpecial() && !Utils.isSpecActivated()) {
  44. Utils.handleSpecialAttack();
  45. } else if (!Utils.canSpecial() && Equipment.WEAPON.isWearing(Variables.getSpecialWeapon())) {
  46. Equipment.WEAPON.equip(Variables.getPrimaryWeapon());
  47. }
  48. }
  49. if (!Utils.isFighting()) {
  50. final Npc[] monsters = Npcs.getNearest(slayerMonsterFilter);
  51. if (monsters.length > 0)
  52. monsterToFight = monsters[0];
  53.  
  54. if (monsterToFight != null) {
  55. monsterToFight.interact(1);
  56. }
  57. }
  58. Time.sleep(new SleepCondition() {
  59. @Override
  60. public boolean isValid() {
  61. return monsterToFight == null || Utils.isFighting() || Utils.canSpecial() && !Utils.isSpecActivated()
  62. || !Utils.canSpecial() && Equipment.WEAPON.isWearing(Variables.getSpecialWeapon());
  63. }
  64. }, 4000);
  65. }
  66.  
  67. private final Filter<Npc> slayerMonsterFilter = new Filter<Npc>() {
  68. @Override
  69. public boolean accept(Npc n) {
  70. for (int target : Variables.getTask().getNpcIds())
  71. if (n != null && n.getDef().getId() == target && !n.isInCombat() && n.getInteractingCharacter() == null)
  72. return true;
  73. return false;
  74. }
  75.  
  76. };
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement