Jump to content

initiating combat


Recommended Posts

Posted
1 minute ago, Booleans YAY said:

I said the interactions didn't work. I made over 14 scripts but never really combat related so I dont know what's going on or what to specificly conclude in writing a combat script for this situation.

it should work?

unless ur doing something wrong

Npc cow = getNpcs().closest("Cow"):

if (cow != null) cow.interact("Attack");

Posted
1 hour ago, Chris said:

it should work?

unless ur doing something wrong

Npc cow = getNpcs().closest("Cow"):

if (cow != null) cow.interact("Attack");

            NPC chicken = getNpcs().closest(2820);
            if (chicken != null && chicken.isAttackable()) {
                chicken.interact("Attack");
            }

the chicken id is same relevancy use as the name itself, I tried both name and ID.

also everything you see there was tried with and without pieces being shown.

Posted (edited)
8 hours ago, Booleans YAY said:

            NPC chicken = getNpcs().closest(2820);
            if (chicken != null && chicken.isAttackable()) {
                chicken.interact("Attack");
            }

the chicken id is same relevancy use as the name itself, I tried both name and ID.

also everything you see there was tried with and without pieces being shown.

What if the closest chicken is not attackable? Your script will just sit there and do nothing.

It should be something more like:

NPC chicken = getNpcs().closest(npc -> npc.getName().equals("Chicken") && npc.isAttackable());
if (chicken != null && chicken.interact("Attack")) {
    new ConditionalSleep(5000) {
        @Override
        public boolean condition() {
            return !chicken.isAttackable() || myPlayer().isInteracting(chicken);
        }
    }.sleep();
}

If that doesn't work it is something else in your script that is broken.

Edited by Explv
  • Like 1
Posted (edited)

I had the right code (besides the conditional sleeper) just my botstate enum check wasn't properly set to what it needed to be, fixed it though.

Thanks for inputs, i'm sure this'll help more people than just myself in future.

 

3 hours ago, Explv said:

What if the closest chicken is not attackable? Your script will just sit there and do nothing.

It should be something more like:


NPC chicken = getNpcs().closest(npc -> npc.getName().equals("Chicken") && npc.isAttackable());
if (chicken != null && chicken.interact("Attack")) {
    new ConditionalSleep(5000) {
        @Override
        public boolean condition() {
            return !chicken.isAttackable() || myPlayer().isInteracting(chicken);
        }
    }.sleep();
}

If that doesn't work it is something else in your script that is broken.

Should be this instead cause yours will attack multiple npcs at once within seconds timed.

if (!myPlayer().isUnderAttack() &&  chicken != null && chicken.interact("Attack")) {

 

Edited by Booleans YAY
quoting explv
Posted
1 hour ago, Booleans YAY said:

I had the right code (besides the conditional sleeper) just my botstate enum check wasn't properly set to what it needed to be, fixed it though.

Thanks for inputs, i'm sure this'll help more people than just myself in future.

 

Should be this instead cause yours will attack multiple npcs at once within seconds timed.


if (!myPlayer().isUnderAttack() &&  chicken != null && chicken.interact("Attack")) {

 

 

Well yes, obviously you will need to check your player isn't already attacking a chicken. I just didn't think it was necessary to write out the entire script

Posted
2 minutes ago, Explv said:

 

Well yes, obviously you will need to check your player isn't already attacking a chicken. I just didn't think it was necessary to write out the entire script

Well I mean you did write out all of that but not include a few key strokes in the if statement, regardless minor miss oh well. Appreciated the support.

Posted
2 minutes ago, Booleans YAY said:

Well I mean you did write out all of that but not include a few key strokes in the if statement, regardless minor miss oh well. Appreciated the support.

Doesn't make sense to put it in the if statement though. It should be before you retrieve the closest chicken. Why look for a chicken if you aren't going to attack it?

Posted
39 minutes ago, Explv said:

Doesn't make sense to put it in the if statement though. It should be before you retrieve the closest chicken. Why look for a chicken if you aren't going to attack it?

cuz he uses booleans 2 attak chickenz bruh. First u gots 2 look 4 em den boolean em in closer cuz tis faster den filterz u kno? boolenz bro dey r the futere.

 

 

sry boolean but he gave you a snippet to help get you in a good direction, you don't have to follow it if you don't want but ya

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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