Jump to content

Making of a Combat script


Gearfighter

Recommended Posts

Hi Everyone,

 

My name is Gearfighter,

 

I am interested in making a script (to start off a Flesh Crawler script)

 

I have an understanding of some of the basics and i have looked at every tutorial i can find on this site, and any other site i could find.

 

I was just wondering if anyone wanted to help teach me how to make a basic script. Currently these are the problems i am running into.

 

 

  • Bot clicks regulary on NPC it is attacking (when i think that it should only be once)
  • If another NPC of the same name comes closer then the one im attacking the bot tries to switch to that npc, even though it is still under attack.

I think currently these are my first 2 issues that i am currently having. i will implement banking and walking at some stage, but i want to get the basic function of what the script is right first, and nice and clean as well.

 

If you can reply here, PM me or leave me a skype username so that i can get some help, that would be greatly appreieted. If you need any more information, dont hesitate to ask and i will try my best.

 

Cheers,

 

Gearfighter

Link to comment
Share on other sites

Bot clicks regulary on NPC it is attacking (when i think that it should only be once)
  • If another NPC of the same name comes closer then the one im attacking the bot tries to switch to that npc, even though it is still under attack.
If (myPlayer.isUnderAttack) {
//doNothing
} else {
//Attack NPC 
}

This will fix both your problems because it won't attack in combat. This is very basic, but should work for now. Of course you can add other things.

As Acerd said, It would be helpful if you post your PasteBin.

Edited by lg_juggles
Link to comment
Share on other sites

Hi Everyone,

 

My name is Gearfighter,

 

I am interested in making a script (to start off a Flesh Crawler script)

 

I have an understanding of some of the basics and i have looked at every tutorial i can find on this site, and any other site i could find.

 

I was just wondering if anyone wanted to help teach me how to make a basic script. Currently these are the problems i am running into.

 

 

  • Bot clicks regulary on NPC it is attacking (when i think that it should only be once)
  • If another NPC of the same name comes closer then the one im attacking the bot tries to switch to that npc, even though it is still under attack.

I think currently these are my first 2 issues that i am currently having. i will implement banking and walking at some stage, but i want to get the basic function of what the script is right first, and nice and clean as well.

 

If you can reply here, PM me or leave me a skype username so that i can get some help, that would be greatly appreieted. If you need any more information, dont hesitate to ask and i will try my best.

 

Cheers,

 

Gearfighter

The first one is (after your interaction? if so you need to sleep or conditonal sleep under the conditions that getCombat().isFighting() && myPlayer().isUnderAttack() 

 

2) you should always when finding a new npc and attacking check if !myPlayer().isUnderAttack() which simply means if our player isnt underattack (! means not in simple terms) 

 

(hopefully you get the gist and this works for you i hope)

 

also post the a small section of your npc finding and interaction code :P

Link to comment
Share on other sites

Here is my code (sorry i dont know how to pastebin right lol). Like i said this is very basic and i just want it to attack properly first before i throw anything else into the mix
 
 
import java.awt.Graphics2D;
 
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
 
@ScriptManifest(name = "Gearz Flesh Crawler Killer", author = "Alek", version = 1.0, info = "", logo = "")
public class GearzFleshCrawlerKiller extends Script {
 
@Override
public void onStart() {
log("Time to kill some Flesh Crawlers");
 
}
 
@Override
public void onExit() {
 
}
 
@Override
public int onLoop() throws InterruptedException {
NPC FleshCrawler = npcs.closest("Flesh Crawler");
myPlayer().getCombatTime(); myPlayer().isMoving(); {
if (FleshCrawler != null) {
if (FleshCrawler.isVisible()) {
FleshCrawler.interact("Attack");
sleep(random(600, 900));
 
} else {
camera.toEntity(FleshCrawler);
 
}
}
 
sleep(random(300, 600));
}
 
return (random(600, 900));
// The amount of time in milliseconds before the loop starts over
}
 
@Override
public void onPaint(Graphics2D g) {
// This is where you will put your code for paint(s)
 
}
 
}

Also another thing i just thought of is how do i make it so it doesnt attack mobs that are already under attack from someone else?

Link to comment
Share on other sites

***UPDATE****

 

http://pastebin.com/8XLQ1iFj

 

This is the new updated one i just worked out today.

 

Currently Fixes the multiple clicking on the npc while in combat problem.

 

Now just need to work on the attacking npcs currently under attack.

 

If you could just have a look at my coding and let me know if its ok or if it is able to be trimmed down/cleaned up that would be awesome.

 

Thankyou all for your help so much, looking to be a contributor here.

 

Cheers,

 

Gearfighter

Edited by Gearfighter
Link to comment
Share on other sites

***UPDATE****

 

http://pastebin.com/8XLQ1iFj

 

This is the new updated one i just worked out today.

 

Currently Fixes the multiple clicking on the npc while in combat problem.

 

Now just need to work on the attacking npcs currently under attack.

 

If you could just have a look at my coding and let me know if its ok or if it is able to be trimmed down/cleaned up that would be awesome.

 

Thankyou all for your help so much, looking to be a contributor here.

 

Cheers,

 

Gearfighter

import org.osbot.rs07.api.filter.Filter;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import java.awt.*;

@ScriptManifest(name = "Gearz Flesh Crawler Killer", author = "Gearfighter", version = 1.0, info = "", logo = "")
public class GearzFleshCrawlerKiller extends Script {

    @Override
    public void onStart() {
        log("Time to kill some Flesh Crawlers");

    }

    @Override
    public void onExit() {

    }

    @Override
    public int onLoop() throws InterruptedException {
        //NPC fleshCrawler = npcs.closest("Flesh Crawler");
        //try building a filter 
        NPC fleshCrawler = npcs.closest(new Filter<NPC>() {
            @Override
            public boolean match(NPC npc) {
                return npc.exists() && npc.getName().equals("Flesh Crawler") && npc.isAttackable() && npc.getHealthPercent() > 0;
            }
        });
        
        if (!getCombat().isFighting() || myPlayer().getInteracting() == null){
            if (fleshCrawler != null) {
                if (fleshCrawler.isVisible()) {
                    fleshCrawler.interact("Attack");
                }
            }
        }

        return random(600, 900); 
    }
    // The amount of time in milliseconds before the loop starts over


    @Override
    public void onPaint(Graphics2D g) {
        // This is where you will put your code for paint(s)

    }

}
Edited by Christopher
Link to comment
Share on other sites

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...