Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.abyssCrafterV2;
- import org.tribot.api.Clicking;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.interfaces.Positionable;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.GameTab.TABS;
- import org.tribot.api2007.Skills.SKILLS;
- import org.tribot.api.types.generic.Condition;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Camera;
- import org.tribot.api2007.Equipment;
- import org.tribot.api2007.GameTab;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.NPCs;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.PathFinding;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSNPC;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- public class DezUtils {
- public static boolean characterCanDie() {
- return Player.getRSPlayer().getHealth() < getHealthPercentage(.75);
- }
- public static int getHealthPercentage(double percentageBelow) {
- return (int) (Skills.getActualLevel(SKILLS.HITPOINTS)
- - (Skills.getActualLevel(SKILLS.HITPOINTS)
- * (Skills.getActualLevel(SKILLS.HITPOINTS) * percentageBelow)));
- }
- public static boolean interactObject(String name, int dist) {
- RSObject[] obj = Objects.findNearest(dist, name);
- if (!Player.isMoving() && obj.length > 0 && obj[0].hover()) {
- if (Timing.waitUptext(name, General.random(700, 1100))) {
- if (obj[0] != null && obj[0].click()) {
- General.sleep(1100, 1600);
- return true;
- }
- }
- else {
- fixCam();
- }
- }
- return false;
- }
- public static boolean interactObject(RSObject obj, String option) {
- if (!Player.isMoving() && obj != null) {
- if (obj.hover() && Timing.waitUptext(obj.getDefinition().getName(), General.random(700, 1100))) {
- if (obj != null && obj.click(option)) {
- General.sleep(1100, 1600);
- return true;
- }
- }
- else {
- fixCam();
- }
- }
- return false;
- }
- public static boolean interactObject(RSObject obj) {
- if (!Player.isMoving() && obj != null) {
- if (obj.hover() && Timing.waitUptext(obj.getDefinition().getName(), General.random(700, 1100))) {
- if (obj != null && obj.click()) {
- General.sleep(1100, 1600);
- return true;
- }
- }
- else {
- fixCam();
- }
- }
- return false;
- }
- public static boolean interactObject(RSObject obj, int min, int max) {
- if (!Player.isMoving() && obj != null) {
- if (obj.hover() && Timing.waitUptext(obj.getDefinition().getName(), General.random(700, 1100))) {
- if (obj != null && obj.click()) {
- General.sleep(min, max);
- return true;
- }
- }
- else {
- fixCam();
- }
- }
- return false;
- }
- public static boolean interactObject(Positionable tile) {
- RSObject[] obj = Objects.getAt(tile);
- if (!Player.isMoving() && obj.length > 0){
- if(obj[0].hover() && Timing.waitUptext(obj[0].getDefinition().getName(), General.random(700, 1100))) {
- if (obj[0] != null && obj[0].click()) {
- General.sleep(1100, 1600);
- return true;
- }
- else {
- fixCam();
- }
- }
- }
- return false;
- }
- public static boolean interactNpc(String name, String option) {
- RSNPC[] npc = NPCs.find(name);
- if (!Player.isMoving() && npc.length > 0) {
- if (npc[0].hover() && Timing.waitUptext(npc[0].getDefinition().getName(), General.random(700, 1100))) {
- if (npc[0] != null && option != null ? npc[0].click(option) : npc[0].click()) {
- General.sleep(1100, 1600);
- return true;
- }
- }
- else {
- fixCam();
- }
- }
- return false;
- }
- public static boolean interactNpc(RSNPC npc, String option) {
- if (!Player.isMoving() && npc != null && npc.hover()){
- if (Timing.waitUptext(npc.getDefinition().getName(), General.random(700, 1100))) {
- if (npc != null && npc.click(option)) {
- General.sleep(1100, 1600);
- return true;
- }
- }
- else {
- fixCam();
- }
- }
- return false;
- }
- public static void fixCam() {
- Camera.setCameraRotation(Camera.getCameraRotation() + General.random(-5, 5));
- }
- public static boolean withdrawItem(final String name, String deposit, int amt, boolean killBot){
- if (!Banking.isBankScreenOpen()) {
- if (Banking.openBank()) {
- Timing.waitCondition(new Condition(){
- @Override
- public boolean active() {
- return Banking.isBankScreenOpen();
- }
- }, General.random(3000, 5000));
- }
- }
- else if (Banking.find(name).length > 0 && Banking.find(name)[0] != null) {
- if (Inventory.isFull()) {
- if (deposit != null && Banking.deposit(1, deposit)) {
- General.sleep(1200, 1400);
- }
- }
- else if (Banking.withdraw(amt, name)) {
- return Timing.waitCondition(new Condition() {
- @Override
- public boolean active() {
- return Inventory.find(name).length > 0;
- }
- }, General.random(1200, 1600));
- }
- }
- else {
- Main.running = false;
- }
- return false;
- }
- public static boolean toObject(final RSObject obj) {
- if (obj != null && PathFinding.aStarWalk(obj)) {
- return Timing.waitCondition(new Condition(){
- @Override
- public boolean active() {
- return obj.isOnScreen();
- }
- }, General.random(2000, 3500));
- }
- return false;
- }
- public static boolean toNpc(final RSNPC npc) {
- if (npc != null && PathFinding.aStarWalk(npc)) {
- return Timing.waitCondition(new Condition(){
- @Override
- public boolean active() {
- return npc.isOnScreen();
- }
- }, General.random(2000, 3500));
- }
- return false;
- }
- public static void takePath(Positionable[] tile) {
- if (Walking.walkPath(tile, new Condition(){
- @Override
- public boolean active() {
- return !Player.isMoving() || characterCanDie();
- }
- }, 2300)) {
- General.sleep(1400, 2400);
- }
- }
- public static void takePath(Positionable tile) {
- if (WebWalking.walkTo(tile, new Condition(){
- @Override
- public boolean active() {
- return !Player.isMoving() || characterCanDie();
- }
- }, 2300)) {
- General.sleep(1400, 2400);
- }
- }
- public static boolean useJewlery(String destination, String... names) {
- RSItem[] item = Equipment.find(names);
- final RSTile origin = Player.getPosition();
- if (item.length > 0 && GameTab.open(TABS.EQUIPMENT)) {
- if (Clicking.click(destination, item[0])) {
- return Timing.waitCondition(new Condition(){
- @Override
- public boolean active() {
- return !Player.getPosition().equals(origin);
- }
- }, General.random(7000, 9000));
- }
- }
- return false;
- }
- public static void useTeleportTab() {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement