Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Minotaur Fighter script - questions

Featured Replies

package ProLaxMinotaurFighter;

import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import java.awt.*;

@ScriptManifest(
        version = 1.0,
        name = "ProLaxMinotaurFighter",
        author = "ProLax",
        info = "This is a Minotaur Fighter script.",
        logo = ""
)

public class ProLaxMinotaurFighter extends Script{
    private int currentLevelStr;
    private int beginningLevelStr;
    private int beginningXpStr;
    private int currentXpStr;
    private int xpGainedStr;

    private int currentLevelAtt;
    private int beginningLevelAtt;
    private int beginningXpAtt;
    private int currentXpAtt;
    private int xpGainedAtt;

    private int currentLevelHp;
    private int beginningLevelHp;
    private int beginningXpHp;
    private int currentXpHp;
    private int xpGainedHp;

    public void onStart(){
        log("The Minotaur fighter script started.");
        beginningLevelStr = skills.getStatic(Skill.STRENGTH);
        beginningXpStr = skills.getExperience(Skill.STRENGTH);

        beginningLevelAtt = skills.getStatic(Skill.ATTACK);
        beginningXpAtt = skills.getExperience(Skill.ATTACK);

        beginningLevelHp = skills.getStatic(Skill.HITPOINTS);
        beginningXpHp = skills.getExperience(Skill.HITPOINTS);
    }

    public int onLoop() throws InterruptedException {
        NPC minotaur = npcs.closest("Minotaur");

        if(!myPlayer().isAnimating() && !myPlayer().isMoving()) {
            if(minotaur != null) {
                if (minotaur.isVisible()) {
                    minotaur.interact("Attack");
                    sleep(random(300, 600));
                } else {
                    camera.toEntity(minotaur);
                }
            }
        } else {
            sleep(random(300, 600));
        }

        return(random(100, 300));

    }

    public void onPaint(Graphics2D g) {

        Graphics2D gr = g;

        gr.setColor(Color.cyan);

        gr.drawString("Prolax Minotaur killer", 10, 230);

        currentLevelAtt = skills.getStatic(Skill.ATTACK);
        gr.drawString("Starting Attack level: " + beginningLevelAtt + " ~ Current Attack level: " + currentLevelAtt, 10,245);

        currentXpAtt = skills.getExperience(Skill.ATTACK);
        xpGainedAtt = currentXpAtt - beginningXpAtt;
        gr.drawString("Attack XP gained: " + xpGainedAtt, 10, 260);

        currentLevelStr = skills.getStatic(Skill.STRENGTH);
        gr.drawString("Starting Strength level: " + beginningLevelStr + " ~ Current Strength level: " + currentLevelStr, 10,275);

        currentXpStr = skills.getExperience(Skill.STRENGTH);
        xpGainedStr = currentXpStr - beginningXpStr;
        gr.drawString("Strength XP gained: " + xpGainedStr, 10, 290);

        currentLevelHp = skills.getStatic(Skill.HITPOINTS);
        gr.drawString("Starting Hitpoints level: " + beginningLevelHp + " ~ Current Hitpoints level: " + currentLevelHp, 10,305);

        currentXpHp = skills.getExperience(Skill.HITPOINTS);
        xpGainedHp = currentXpHp - beginningXpHp;
        gr.drawString("Hitpoints XP gained: " + xpGainedHp, 10, 320);

    }

    public void onExit(){
        this.log("The Minotaur fighter script stopped.");
    }

}

Hi,

 

I started a Minotaur Fighter script. I have a few questions.

 

- Once my player is attacking a NPC, the script keeps clicking on the NPC?

- How can I include more antibans methods?

- How can I implement more camera turns?

 

Thanks,

ProLax

 

Edited by Prolax

  • Author
        if(!myPlayer().isAnimating() && !myPlayer().isMoving() && !myPlayer().isUnderAttack()) {
            if(minotaur != null && minotaur.exists()) {
                if (minotaur.isVisible()) {
                    minotaur.interact("Attack");
                    sleep(random(300, 600));
                } else {
                    camera.toEntity(minotaur);
                }
            }
        }

Ok thanks for the answer. Could you explain why I need a global variable for minotaur? It's only used in OnLoop()

 

I edited my code, see above.

        if(!myPlayer().isAnimating() && !myPlayer().isMoving() && !myPlayer().isUnderAttack()) {
            if(minotaur != null && minotaur.exists()) {
                if (minotaur.isVisible()) {
                    minotaur.interact("Attack");
                    sleep(random(300, 600));
                } else {
                    camera.toEntity(minotaur);
                }
            }
        }

Ok thanks for the answer. Could you explain why I need a global variable for minotaur? It's only used in OnLoop()

 

I edited my code, see above.

 

 

To check if the minotaur has no health/is null.

if (minotaur == null || !minotaur.exists() || minotaur.getHealth() == 0) {
    minotaur = getNpcs().closest("Minotaur");
}

if (!myPlayer().isUnderAttack() && minotaur != null && !minotaur.isUnderAttack()) {
    if (!minotaur.isVisible()) getCamera().toEntity(minotaur);
    minotaur.interact("Attack");
}

Something like this would work.

 

  • Author

Thanks, looks a lot better. Still sometimes my player spamclicks the minotaur.

  • 1 month later...

To check if the minotaur has no health/is null.

if (minotaur == null || !minotaur.exists() || minotaur.getHealth() == 0) {
    minotaur = getNpcs().closest("Minotaur");
}

if (!myPlayer().isUnderAttack() && minotaur != null && !minotaur.isUnderAttack()) {
    if (!minotaur.isVisible()) getCamera().toEntity(minotaur);
    minotaur.interact("Attack");
}

Something like this would work.

 

I'm not understanding how the three conditions in the first if-statement work.

I'm new to this, but I thought == null and !exists() are the same thing? And if any of the conditions evaluate to true, why would you choose that Minotaur? It seems like it wouldn't be attackable in any of those cases

 

NPC cow = getNpcs().closest(NAME);
if (cow != null && cow.isAttackable() && cow.getHealth() > 0)
	if (cow.isVisible())
		cow.interact("Attack");
	else if (!cow.isVisible())
		camera.toEntity(cow);
		cow.interact("Attack");

This is how I've laid out my Cow killer script. Would this work?

I'm not understanding how the three conditions in the first if-statement work.

I'm new to this, but I thought == null and !exists() are the same thing? And if any of the conditions evaluate to true, why would you choose that Minotaur? It seems like it wouldn't be attackable in any of those cases

NPC cow = getNpcs().closest(NAME);if (cow != null && cow.isAttackable() && cow.getHealth() > 0)	if (cow.isVisible())		cow.interact("Attack");	else if (!cow.isVisible())		camera.toEntity(cow);		cow.interact("Attack");
This is how I've laid out my Cow killer script. Would this work?

If our NPC is evaluated to NULL, we can't run #exists() on it. If those conditions evaluate to true, our Minotaur is dead and thus we need a new one.

  • Author

    public int onLoop() throws InterruptedException {
        NPC minotaur = getNpcs().closest("Minotaur");
        if (!myPlayer().isUnderAttack() || !myPlayer().isAnimating()) {
            if (minotaur != null && minotaur.isAttackable() && minotaur.getHealth() > 0) {
                if (minotaur.isVisible()) {
                    minotaur.interact("Attack");
                } else if (!minotaur.isVisible()) {
                    camera.toEntity(minotaur);
                    minotaur.interact("Attack");
                }
            }
        }
        return (random(100, 300));
    }

Hi,

 

I still have the following problem, my player keeps spam clicking minotaurs, while it is already fighting a minotaur.

 

 

    public int onLoop() throws InterruptedException {
        NPC minotaur = getNpcs().closest("Minotaur");
        if(minotaur.exists() && !myPlayer().isUnderAttack()){
            if(!minotaur.isVisible()){
                camera.toEntity(minotaur);
            }
            minotaur.interact("attack");
            sleep(700);
        }
        return (random(100, 300));
    }

I edited a bit.

 

 

    public int onLoop() throws InterruptedException {
        NPC minotaur = getNpcs().closest("Minotaur");
        if (!myPlayer().isUnderAttack() || !myPlayer().isAnimating()) {
            if (minotaur != null && minotaur.isAttackable() && minotaur.getHealth() > 0) {
                if (minotaur.isVisible()) {
                    minotaur.interact("Attack");
                } else if (!minotaur.isVisible()) {
                    camera.toEntity(minotaur);
                    minotaur.interact("Attack");
                }
            }
        }
        return (random(100, 300));
    }

Hi,

 

I still have the following problem, my player keeps spam clicking minotaurs, while it is already fighting a minotaur.

 

 

    public int onLoop() throws InterruptedException {
        NPC minotaur = getNpcs().closest("Minotaur");
        if(minotaur.exists() && !myPlayer().isUnderAttack()){
            if(!minotaur.isVisible()){
                camera.toEntity(minotaur);
            }
            minotaur.interact("attack");
            sleep(700);
        }
        return (random(100, 300));
    }

I edited a bit.

 

 

After you attack minotaur, set him into a global variable (say, npc)

private NPC npc;
public int onLoop() throws InterruptedException {
    if (npc == null || !npc.exists() || npc.getHealth() == 0) {
        //find new npc
        NPC minotaur = getNpcs().closest("Minotaur");
        //minotaur checks
        minotaur.interact("Attack");
        npc = minotaur;
    }
}

 

After you attack minotaur, set him into a global variable (say, npc)

private NPC npc;
public int onLoop() throws InterruptedException {
    if (npc == null || !npc.exists() || npc.getHealth() == 0) {
        //find new npc
        NPC minotaur = getNpcs().closest("Minotaur");
        //minotaur checks
        minotaur.interact("Attack");
        npc = minotaur;
    }
}

 

This is a nice and efficient approach, since it avoids filtering the NPCs redundantly in every cycle.

But be sure to not rely on an interaction completing successfully like it does in this particular example (failing to attack = stuck forever)

private NPC npc;
public int onLoop() throws InterruptedException {
    if (npc == null || !npc.exists() || npc.getHealth() == 0) {
        //find new npc
        NPC minotaur = getNpcs().closest("Minotaur");
        //minotaur checks
        npc = minotaur;
    } else if(myPlayer().getInteracting() != npc) {
        npc.interact("Attack");
    }
}

 

This is a nice and efficient approach, since it avoids filtering the NPCs redundantly in every cycle.

But be sure to not rely on an interaction completing successfully like it does in this particular example (failing to attack = stuck forever)

private NPC npc;
public int onLoop() throws InterruptedException {
    if (npc == null || !npc.exists() || npc.getHealth() == 0) {
        //find new npc
        NPC minotaur = getNpcs().closest("Minotaur");
        //minotaur checks
        npc = minotaur;
    } else if(myPlayer().getInteracting() != npc) {
        npc.interact("Attack");
    }
}

 

Alternatively..

npc = (minotaur.interact("Attack") ? minotaur : null);

 

  • Author

Thanks a lot, the attacking is now working perfect.

 

Next I'm going to implement looting and eating.

 

I've read that using states is not adviced, what should I use instead?

Thanks a lot, the attacking is now working perfect.

Next I'm going to implement looting and eating.

I've read that using states is not adviced, what should I use instead?

I'm on my phone here so forgive any typos.

You should look into something called a Node system, which is essentially an object oriented way of handling numerous tasks.

The idea is to have an abstract base class (let's call it Node) and have all of your nodes (eat, fight, loot) extend our Node class.

public abstract class Node
In the abstract node clasa there should also be two abstract methods (let's call them canProcess and process). Each of our nodes will override this method with our own code.

We can store each node in a List<Node> since they all extend our abstract Node class, and then call our abstract methods (canProcess and process) because they are defined in our Node class

In our onLoop, we want to see if we can process each node and then run it. You want do loop through every node, see if canProcess returns true, and if it does run process.

Hope this helped, I believe there is a tutorial somewhere in the forums for it :)

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.