Chris

[Video Tutorial] Introduction To RSBot Scripting (IDE set-up & your first combat script) ~ Video 1

Recommended Posts

Chris   
2 hours ago, PingaP3te said:

Hey, Just followed the video and everything seems to be working alright, but when I rightclick the folder to compile it doesnt give me that option, instead it says "Build" or "Rebuild", clicking build (which I assume would compile it) creates a file in the \out\ folder but the script does not show up locally in RSBot once the client loads. Is there something I missed?

there could be many things but without seeing your set up there is no way to know what is not set correctly

Share this post


Link to post


Hi Chris,

 

Great video, loved it. Very informative. I see you are reasonably active still on this thread which is awesome!

Question for ya.

Warning:(66, 36) java: inCombat() in org.powerbot.script.rt4.Actor has been deprecated is coming up when i rebuild my script then inCombat has a line through it.

I tried putting @Deprecated above the method and this compiled it but doesn't attack.


Any ideas?

 

Thanks,

Share this post


Link to post
iDzn   
1 minute ago, Jamie Cox said:

Hi Chris,

 

Great video, loved it. Very informative. I see you are reasonably active still on this thread which is awesome!

Question for ya.

Warning:(66, 36) java: inCombat() in org.powerbot.script.rt4.Actor has been deprecated is coming up when i rebuild my script then inCombat has a line through it.

I tried putting @Deprecated above the method and this compiled it but doesn't attack.


Any ideas?

 

Thanks,

Means there's new code that supersedes it so to speak, inCombat() was replaced with healthBarVisible() as that's technically what inCombat was so its new method has a more relevant name. 

Share this post


Link to post
1 minute ago, iDzn said:

Means there's new code that supersedes it so to speak, inCombat() was replaced with healthBarVisible() as that's technically what inCombat was so its new method has a more relevant name. 

Thanks iDzn for the quick reply, will give this a go.

 

Cheers,

Jamie

Share this post


Link to post

i always find the topic just a tad late, does anyone know why i have an error message popping up saying "missing com.jagex.config setting, "i assume that i have something messed up in the VM options but i dont know what. im thinking that i need to set it the nxt client instead of the website.

 

Annnnddddd i fixed the issue it was in the VM option i didnt add a space between jav_config.ws and -javaagent:

shoot me now

Edited by William Reynolds

Share this post


Link to post

i swear i wont fix my own issue this time since i have no idea why its crashing other than i have this error

Error: client.init:1318 sun.reflect.NativeMethodAccessorImpl.invoke0 sun.reflect.NativeMethodAccessorImpl.invoke sun.reflect.DelegatingMethodAccessorImpl.invoke java.lang.reflect.Method.invoke Rs2Applet.a:52 Rs2Applet.init:1141 app.appletviewer.a jagexappletviewer.main:78 | java.lang.RuntimeException | 
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x5dad3066, pid=13864, tid=0x00003388
#
# JRE version: Java(TM) SE Runtime Environment (8.0_201-b09) (build 1.8.0_201-b09)
# Java VM: Java HotSpot(TM) Client VM (25.201-b09 mixed mode windows-x86 )
# Problematic frame:
# C  [jagdx.dll+0x3066]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\willi\desktop\rs3 helpful stuff\hs_err_pid13864.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
 

Share this post


Link to post
Chris   
8 hours ago, William Reynolds said:

i swear i wont fix my own issue this time since i have no idea why its crashing other than i have this error

Error: client.init:1318 sun.reflect.NativeMethodAccessorImpl.invoke0 sun.reflect.NativeMethodAccessorImpl.invoke sun.reflect.DelegatingMethodAccessorImpl.invoke java.lang.reflect.Method.invoke Rs2Applet.a:52 Rs2Applet.init:1141 app.appletviewer.a jagexappletviewer.main:78 | java.lang.RuntimeException | 
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x5dad3066, pid=13864, tid=0x00003388
#
# JRE version: Java(TM) SE Runtime Environment (8.0_201-b09) (build 1.8.0_201-b09)
# Java VM: Java HotSpot(TM) Client VM (25.201-b09 mixed mode windows-x86 )
# Problematic frame:
# C  [jagdx.dll+0x3066]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\willi\desktop\rs3 helpful stuff\hs_err_pid13864.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
 

the error is intentional, (sun.reflect..), the crash is not but I do not know why that happens

Share this post


Link to post
4 hours ago, Chris said:

the error is intentional, (sun.reflect..), the crash is not but I do not know why that happens

Any idea how to resolve it from crashing? Because it happens when loading through the IDE and outside of IDE when loading powerbot.

Share this post


Link to post
8 hours ago, Chris said:

the error is intentional, (sun.reflect..), the crash is not but I do not know why that happens

....... sort of figured it out, its the fact its a .jar file for Java. if I run a .exe regularly without it being a jar or java file i have no problems, however, I can't figure out how to run the .exe from IDE any ideas Chris?

 

Edited by William Reynolds

Share this post


Link to post

So the Script runs attacks, and Eats but it keeps wanting to attack every so often when im already "healthBarVisible()" and I cannot figure out why.

(its Attacking Cows atm was Experimenting if it was the Mob)

 

package Scripts;

import org.powerbot.script.Condition;
import org.powerbot.script.Filter;
import org.powerbot.script.PollingScript;
import org.powerbot.script.Script;
import org.powerbot.script.rt4.ClientContext;
import org.powerbot.script.rt4.Item;
import org.powerbot.script.rt4.Npc;

import java.util.concurrent.Callable;


@Script.Manifest(name="First Script", description = "Killing Gobs", properties = "author= Hayden; topic=999; client=4;")

public class Firstscript extends PollingScript<ClientContext> {

    final static int GOBLIN_IDS[] = {2805,2804,2806,2809,2808};
    final static int FOOD_ID = 315;

    @Override
    public void start() {
    }

    @Override
    public void stop() {

    }

    @Override
    public void poll() {

        if(hasFood()){
            if(needsHeal()){
                heal();
            } else if(shouldAttack()) {
                attack();
            }
    }

}

    public boolean needsHeal(){
        return ctx.combat.health() <6;
    }

    public boolean shouldAttack(){
        return !ctx.players.local().healthBarVisible();
    }


    public boolean hasFood(){
            return ctx.inventory.select().id(FOOD_ID).count() > 0;
    }


    public void attack(){
        final Npc goblinToAttack = ctx.npcs.select().id(GOBLIN_IDS).select(new Filter<Npc>(){

            @Override
            public boolean accept(Npc npc) {
                return !npc.healthBarVisible();
            }
        }).nearest().poll();

        goblinToAttack.interact("Attack");


        Condition.wait(new Callable<Boolean>() {
            @Override
            public Boolean call() throws Exception {
                return ctx.players.local().healthBarVisible();
            }
        },200, 20);
    }

    public void heal (){
        Item foodToEat = ctx.inventory.select().id(FOOD_ID).poll();

        foodToEat.interact("Eat");

        final int startingHealth = ctx.combat.health();

        Condition.wait(new Callable<Boolean>() {
            @Override
            public Boolean call() throws Exception {
                final int currentHealth = ctx.combat.health();
                return currentHealth != startingHealth;
            }
        },150, 20);

    }


}

Share this post


Link to post
Chris   
On 3/29/2019 at 9:28 AM, Zerolerms said:

So the Script runs attacks, and Eats but it keeps wanting to attack every so often when im already "healthBarVisible()" and I cannot figure out why.

(its Attacking Cows atm was Experimenting if it was the Mob)

 

package Scripts;

import org.powerbot.script.Condition;
import org.powerbot.script.Filter;
import org.powerbot.script.PollingScript;
import org.powerbot.script.Script;
import org.powerbot.script.rt4.ClientContext;
import org.powerbot.script.rt4.Item;
import org.powerbot.script.rt4.Npc;

import java.util.concurrent.Callable;


@Script.Manifest(name="First Script", description = "Killing Gobs", properties = "author= Hayden; topic=999; client=4;")

public class Firstscript extends PollingScript<ClientContext> {

    final static int GOBLIN_IDS[] = {2805,2804,2806,2809,2808};
    final static int FOOD_ID = 315;

    @Override
    public void start() {
    }

    @Override
    public void stop() {

    }

    @Override
    public void poll() {

        if(hasFood()){
            if(needsHeal()){
                heal();
            } else if(shouldAttack()) {
                attack();
            }
    }

}

    public boolean needsHeal(){
        return ctx.combat.health() <6;
    }

    public boolean shouldAttack(){
        return !ctx.players.local().healthBarVisible();
    }


    public boolean hasFood(){
            return ctx.inventory.select().id(FOOD_ID).count() > 0;
    }


    public void attack(){
        final Npc goblinToAttack = ctx.npcs.select().id(GOBLIN_IDS).select(new Filter<Npc>(){

            @Override
            public boolean accept(Npc npc) {
                return !npc.healthBarVisible();
            }
        }).nearest().poll();

        goblinToAttack.interact("Attack");


        Condition.wait(new Callable<Boolean>() {
            @Override
            public Boolean call() throws Exception {
                return ctx.players.local().healthBarVisible();
            }
        },200, 20);
    }

    public void heal (){
        Item foodToEat = ctx.inventory.select().id(FOOD_ID).poll();

        foodToEat.interact("Eat");

        final int startingHealth = ctx.combat.health();

        Condition.wait(new Callable<Boolean>() {
            @Override
            public Boolean call() throws Exception {
                final int currentHealth = ctx.combat.health();
                return currentHealth != startingHealth;
            }
        },150, 20);

    }


}

health bar may be flickering, there are some checks you can do that are better than healthbarvisible

Share this post


Link to post
DRocks   

Sorry for being off topic but this is awesome and I'm wondering, Chris, are you the Chris who started AutoHotkey community ?

Asking because I noticed you had AutoHotkey installed while I was watching the tutorial video.

 

EDIT: BTW: What a good tutorial! I have NEVER used Intellij. Never Scripted with java. Came back to runescape yesterday. And after following your steps it really ran the launcher on first try. Good job on the video and thank you this is VERY instructive and fun.

Edited by DRocks

Share this post


Link to post

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.

Loading...