Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.ikovps.slayer.strategies;
- import org.parabot.environment.api.utils.Filter;
- import org.parabot.environment.api.utils.Time;
- import org.parabot.environment.scripts.framework.SleepCondition;
- import org.parabot.environment.scripts.framework.Strategy;
- import org.rev317.min.api.methods.Npcs;
- import org.rev317.min.api.methods.Players;
- import org.rev317.min.api.wrappers.Npc;
- import com.ikovps.slayer.data.Variables;
- import com.ikovps.slayer.util.Equipment;
- import com.ikovps.slayer.util.Utils;
- /**
- * A class that attacks assigned Slayer monsters.
- *
- * @author Masood && El Maestro
- *
- */
- public class HandleCombat implements Strategy {
- private Npc monsterToFight = null;
- @Override
- public boolean activate() {
- if (Variables.getTask().atTask() && (!Variables.getTask().isDone() || Variables.getTask().isDone())) {
- return !Utils.isFighting() || Utils.canSpecial() && !Utils.isSpecActivated() || !Utils.canSpecial()
- && Equipment.WEAPON.isWearing(Variables.getSpecialWeapon());
- }
- return false;
- }
- @Override
- public void execute() {
- Variables.setStatus("Completing task...");
- if (Variables.getTask().getPrayer() != null && !Variables.getTask().getPrayer().isActivated()) {
- Variables.getTask().getPrayer().toggle();
- }
- if (!Utils.retaliateIsToggled()) {
- Utils.toggleRetaliate();
- }
- if (Variables.isSpecialAttack()) {
- if (Utils.canSpecial() && !Utils.isSpecActivated()) {
- Utils.handleSpecialAttack();
- } else if (!Utils.canSpecial() && Equipment.WEAPON.isWearing(Variables.getSpecialWeapon())) {
- Equipment.WEAPON.equip(Variables.getPrimaryWeapon());
- }
- }
- if (!Utils.isFighting()) {
- final Npc[] monsters = Npcs.getNearest(slayerMonsterFilter);
- if (monsters.length > 0)
- monsterToFight = monsters[0];
- if (monsterToFight != null) {
- monsterToFight.interact(1);
- }
- }
- Time.sleep(new SleepCondition() {
- @Override
- public boolean isValid() {
- return monsterToFight == null || Utils.isFighting() || Utils.canSpecial() && !Utils.isSpecActivated()
- || !Utils.canSpecial() && Equipment.WEAPON.isWearing(Variables.getSpecialWeapon());
- }
- }, 4000);
- }
- private final Filter<Npc> slayerMonsterFilter = new Filter<Npc>() {
- @Override
- public boolean accept(Npc n) {
- for (int target : Variables.getTask().getNpcIds())
- if (n != null && n.getDef().getId() == target && !n.isInCombat() && n.getInteractingCharacter() == null)
- return true;
- return false;
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement