Jump to content

Fighter


TFW

Recommended Posts

mDZdCJM.png

 

 

fights anything

eats any food

paint exp and time tracker

 

 

if you want something added let me know

 

downloads

https://www.mediafire.com/?8p9byab9r1o3lap

 

progry

g2I1qNT.png

 

HEgosBm.png

 

8yee8Pg.png

 

 

Source codes

/**
 * Created by TFW on 04/14/2016.
 */
@ScriptManifest(author = "TFW", info = "Fights anything", name = "TFW Fighter", version = 0.196, logo = "http://i.imgur.com/mDZdCJM.png")
public class Fighter extends Script {
    LinkedList<MousePathPoint> mousePath = new LinkedList<MousePathPoint>();
    private FighterGUI gui;
    private int r = 255;
    private int g = 0;
    private int b = 0;
    public String toAttack;
    public boolean eatFood;
    private long startTime;
    private NPC getNpcWhere;
    private Position startTile;

    @Override
    public void onStart() throws InterruptedException {
        this.startTile = myPlayer().getPosition();
        getExperienceTracker().startAll();
        startTime = System.currentTimeMillis();
        this.gui = new FighterGUI();
        gui.setVisible(true);
        while (gui.isVisible()){
            sleep(200);
        }
        this.toAttack = gui.getToAttack();
        this.eatFood = gui.isDoFood();
        log("NPC: " + toAttack);
        log("Eat Food: " + "[" + eatFood + "]");
        log("Starting Point: [" + startTile + "]");
        log("======================================================================");
        log("Welcome to [" + getName() + "] " + "by " + getAuthor() + ". You are currently running Version " + getVersion() + ".");
        log("======================================================================");
    }

    @Override
    public int onLoop() throws InterruptedException {
        getNpcWhere = getNpcs().closest(true, npc -> npc.getName().toLowerCase().equals(toAttack) && npc.isAttackable() && npc.getHealthPercent() > 0 && getMap().canReach(npc));

        if (myPlayer().getInteracting() == null && getNpcWhere != null && startTile.isOnMiniMap(getBot())){
            if (getNpcWhere.getPosition().distance(myPosition()) <= 7){
                InteractionEvent attackNpc = new InteractionEvent(getNpcWhere, "Attack"); //call interaction event
                attackNpc.setWalkTo(false); //turn off walking
                attackNpc.setOperateCamera(true); //enable camera
                execute(attackNpc);
                new ConditionalSleep(6000, 600) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return myPlayer().getInteracting() != null;
                    }
                }.sleep();
                getMouse().moveSlightly(random(500));
            } else {
                WalkingEvent walkToNpc = new WalkingEvent(getNpcWhere.getPosition()); //call the walking event
                walkToNpc.setBreakCondition(new Condition() {
                    @Override
                    public boolean evaluate() {
                        return getNpcWhere.getPosition().distance(myPosition()) <= 4;
                    }
                });
                execute(walkToNpc);
                log("Walking to " + getNpcWhere.getName() + " @ " + getNpcWhere.getPosition());
            }
        }

        if (myPlayer().getInteracting() != null && getCombat().isFighting() && !lowHealth()){
            new ConditionalSleep(20000, 600) {
                @Override
                public boolean condition() throws InterruptedException {
                    return myPlayer().getInteracting() == null || lowHealth();
                }
            }.sleep();
        }

        if (eatFood && lowHealth()){
            if (gotFood()){
                for (Item i : getInventory().getItems()) {
                    if (i != null && i.hasAction("Eat")) {
                        if (!getTabs().getOpen().equals(Tab.INVENTORY)) getTabs().open(Tab.INVENTORY);
                        i.interact("Eat");
                        new ConditionalSleep(3000, random(600, 1200)) {
                            @Override
                            public boolean condition() throws InterruptedException {
                                return myPlayer().getAnimation() == 829;
                            }
                        }.sleep();
                        break;
                    }
                }
            } else {
                //stop no food
                stop(false);
            }
        }

        return random(600, 900);
    }

    @Override
    public void onExit() {
        long runTime = System.currentTimeMillis() - startTime;
        log("======================================================================");
        log("Thank you for using [" + getName() + "] " + "by" + " [" + getAuthor() + "].");
        log("======================================================================");
        log("Time Ran: " + formatTime(runTime));
    }

    @Override
    public void onPaint(Graphics2D gfx) {
        long runTime = System.currentTimeMillis() - startTime;
        gfx.drawString("Runtime: "+formatTime(runTime), 15, 40);
        gfx.drawString("Attack: " + getExperienceTracker().getGainedXP(Skill.ATTACK), 15, 65);
        gfx.drawString("Strength: " + getExperienceTracker().getGainedXP(Skill.STRENGTH), 15, 80);
        gfx.drawString("Defence: " + getExperienceTracker().getGainedXP(Skill.DEFENCE), 15, 95);
        gfx.drawString("Range: " + getExperienceTracker().getGainedXP(Skill.RANGED), 15, 110);
        gfx.drawString("Magic: " + getExperienceTracker().getGainedXP(Skill.MAGIC), 15, 125);

        while (!mousePath.isEmpty() && mousePath.peek().isUp())
            mousePath.remove();
        Point clientCursor = mouse.getPosition();
        MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, 500);
        if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp))
            mousePath.add(mpp);
        MousePathPoint lastPoint = null;
        for (MousePathPoint a : mousePath) {
            if (lastPoint != null) {
                gfx.setColor(nextColor());
                gfx.drawLine(a.x, a.y, lastPoint.x, lastPoint.y);
            }
            lastPoint = a;
        }

        gfx.drawLine(clientCursor.x - 4, clientCursor.y, clientCursor.x + 4, clientCursor.y);
        gfx.drawLine(clientCursor.x, clientCursor.y - 4, clientCursor.x, clientCursor.y + 4);
    }

    /**
     * Methods
     */

    /** PAINT SHIT
     *
     */

    public void nextRGB() {
        if ( r == 255 && g < 255 && b == 0 )
        {
            g++;
        }
        if ( g == 255 && r > 0 && b == 0 )
        {
            r--;
        }
        if ( g == 255 && b < 255 && r == 0 )
        {
            b++;
        }
        if ( b == 255 && g > 0 && r == 0 )
        {
            g--;
        }
        if ( b == 255 && r < 255 && g == 0 )
        {
            r++;
        }
        if ( r == 255 && b > 0 && g == 0 )
        {
            b--;
        }
    }

    public Color nextColor() {
        nextRGB();
        return makeColor();
    }

    public Color makeColor() {
        return new Color(r, g, b);
    }


    public String formatTime(long ms){

        long s = ms / 1000, m = s / 60, h = m / 60;
        s %= 60; m %= 60; h %= 24;
        return String.format("%02d:%02d:%02d", h, m, s);
    }

    public boolean lowHealth(){
        return getSkills().getDynamic(Skill.HITPOINTS) <= (getSkills().getStatic(Skill.HITPOINTS) * 0.50);
    }

    public boolean gotFood() {
        return getInventory().contains(getEdible().getName());
    }

    public Item getEdible() {
        return getInventory().getItem(item -> item != null && item.hasAction("Eat"));
    }


}


Edited by TFW
  • Like 2
Link to comment
Share on other sites

i litteraly have one like that for myself lol laugh.png thought about releasing it as a jar, since i only really use it for slayer because my obby tank is sooooo slow with slayer (1 atk)

 

 

 

df68bc247c.png

 

Nice happy.png . I let it auto find food in the inventory tongue.png & just make user type in a name smile.png

Edited by TFW
Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...