Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.4 kB
3
Indexable
Never
package TestScript.Tasks;

import TestScript.RezzCW;
import org.powbot.api.Condition;
import org.powbot.api.Random;
import org.powbot.api.rt4.*;
import utils.Task;

public class Attack extends Task {
    RezzCW main;

    public Attack(RezzCW main) {
        super();
        super.name = "EnterPortal";
        this.main = main;
    }

    @Override
    public boolean activate() {
        return main.desired.contains(Players.local())
                && Players.local().interacting().name().equals("")
                && ! Players.local().healthBarVisible()
                && Players.stream().name(main.name1,
                main.name2,
                main.name3,
                main.name4,
                main.name5,
                main.name6,
                main.name7,
                main.name8,
                main.name9,
                main.name10).within(main.danger).filter(p -> p.interacting().equals(Actor.getNil()) && ! p.healthBarVisible()).isNotEmpty();
    }

    @Override
    public void execute() {
        if(Random.nextInt(0,10)==1){
            Condition.sleep(Random.nextInt(5,35)*1000);
        }
        Player p = Players.stream().name(main.name1,
                main.name2,
                main.name3,
                main.name4,
                main.name5,
                main.name6,
                main.name7,
                main.name8,
                main.name9,
                main.name10).within(main.danger).filter(player -> player.interacting().equals(Actor.getNil())
                && ! player.healthBarVisible()).nearest().first();
        if (p != Player.getNil()) {
            if (p.inViewport()) {
                if (main.danger.contains(p)) {
                    p.interact("Attack", p.name());
                    Condition.wait(() -> Players.local().interacting().name().equals(p.name()), 50, 15);
                    if (Combat.specialPercentage() >= 50) {
                        Combat.specialAttack(true);
                        Condition.wait(() -> Players.local().interacting().name().equals(p.name()), 1000, 15);
                    }

                    if (Combat.specialPercentage() <= 40) {
                        Combat.specialAttack(false);
                    }

                        }

                }


            } else {
                Camera.turnTo(p);
            }
        }
    }