Jump to content
Booleans YAY

initiating combat

Recommended Posts

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");

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

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.

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