Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.tools;
- import org.tribot.api.DynamicClicking;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.input.Mouse;
- import org.tribot.api2007.ChooseOption;
- import org.tribot.api2007.Game;
- import org.tribot.api2007.GameTab;
- import org.tribot.api2007.NPCs;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Projection;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.GameTab.TABS;
- import org.tribot.api2007.types.RSModel;
- import org.tribot.api2007.types.RSNPC;
- import org.tribot.api2007.types.RSTile;
- public class Fighting {
- @SuppressWarnings("unused")
- private static void SwitchStyle(int style) {
- GameTab.open(TABS.COMBAT);
- if (style == 1) {
- Mouse.click(General.random(594, 615), General.random(266, 282), 1);
- General.sleep(300, 600);
- }
- if (style == 2) {
- Mouse.click(General.random(671, 701), General.random(266, 282), 1);
- General.sleep(300, 600);
- }
- if (style == 3) {
- Mouse.click(General.random(594, 615), General.random(316, 332), 1);
- General.sleep(300, 600);
- }
- if (style == 4) {
- Mouse.click(General.random(671, 701), General.random(316, 332), 1);
- General.sleep(300, 600);
- }
- }
- // Attacks specified monster
- public static boolean AttackMonster(int[] chickens) {
- // Creates an array of all nearby monsters
- RSNPC[] monsters = NPCs.findNearest(chickens);
- // Goes for closest monster that isn't null or in combat
- for (RSNPC monster : monsters) {
- if (monster != null && monster.isValid() && !monster.isInCombat()) {
- // Gets the model (more accurate clicking)
- RSModel model = monster.getModel();
- // Clicks on the monster model to attack it if not null
- if (model != null && DynamicClicking.clickRSModel(model, "Attack")) {
- General.sleep(500, 1000);
- long t = System.currentTimeMillis();
- while (Timing.timeFromMark(t) < General.random(1500, 2000)) {
- if (Player.getRSPlayer().isInCombat()) {
- System.out.println("Succesfully attacked monster!");
- General.sleep(2000, 3000);
- return true;
- } else if (Player.isMoving()) {
- t = System.currentTimeMillis();
- }
- General.sleep(50, 100);
- }
- break;
- }
- }
- }
- return false;
- }
- /** Checks if we are in combat */
- public static boolean IsInCombat() {
- int startHpXp = Skills.getXP(Skills.SKILLS.HITPOINTS);
- long t = System.currentTimeMillis();
- while (Timing.timeFromMark(t) < General.random(800, 1200)) {
- if (Player.getRSPlayer().isInCombat() || Skills.getXP(Skills.SKILLS.HITPOINTS) > startHpXp) {
- return true;
- }
- General.sleep(40, 80);
- }
- return false;
- }
- public static boolean ClickNPC(RSNPC npc, String option) {
- // Mouse.setSpeed(General.random(100,120));
- RSTile loc = null;
- if (npc != null && npc.isOnScreen()) {
- loc = npc.getPosition();
- Mouse.move(Projection.tileToScreen(loc, 10));
- if (Game.isUptext(option)) {
- Mouse.click(1);
- return true;
- } else {
- Mouse.click(3);
- if (ChooseOption.isOpen()) {
- ChooseOption.select(option);
- }
- }
- }
- return false;
- }
- }
Add Comment
Please, Sign In to add comment