Jump to content

Accurate Interaction


Beau

Recommended Posts

You are completely wrong about everything you have just said. If you actually understood the code, then you would know how it works.

Test it out...

1. The mouse left clicks if the entity is the first on top, otherwise, it will right click and selected the interaction.

2. It returns true because the mouse has to continue actions until the interaction is over. It's returned false if the entity basically can't be interacted with.

Edited by Beau
Link to comment
Share on other sites

You are completely wrong about everything you have just said. If you actually understood the code, then you would know how it works.

Test it out...

1. The mouse left clicks if the entity is the first on top, otherwise, it will right click and selected the interaction.

2. It returns true because the mouse has to continue actions until the interaction is over. It's returned false if the entity basically can't be interacted with.

1) Ok lets say I want to interact with something but the action I want is the second action on the list. It won't work and will continue to select the first one because all it's doing is clicking. Something along the lines of this, but not exactly of course, would work better:

if (Arrays.asList(object.getDefinition().getActions()).get(0).equalsIgnoreCase(action)) {
			return sI.client.moveMouseTo(new RectangleDestination(boundingBox.x+5, boundingBox.y+5, boundingBox.width-10, boundingBox.height-10), false, true, false);
		}

2) Because getting stuck in a loop is fantastic...? I don't see how it could be considering there's not a single loop besides the option grabber in your entire snippet.

 

Lastly, just because you may say select this option doesn't mean the method will execute correctly. You should be returning the value returned by the mouse methods.

Edited by Swizzbeat
Link to comment
Share on other sites

1) Ok lets say I want to interact with something but the action I want is the second action on the list. It won't work and will continue to select the first one because all it's doing is clicking. Something along the lines of this, but not exactly of course, would work better:

if (Arrays.asList(object.getDefinition().getActions()).get(0).equalsIgnoreCase(action)) {
			return sI.client.moveMouseTo(new RectangleDestination(boundingBox.x+5, boundingBox.y+5, boundingBox.width-10, boundingBox.height-10), false, true, false);
		}
2) Because getting stuck in a loop is fantastic...? I don't see how it could be considering there's not a single loop besides the option grabber in your entire snippet.

 

Lastly, just because you may say select this option doesn't mean the method will execute correctly. You should be returning the value returned by the mouse methods.

Are you not reading the code correctly? I'm not just getting the first option...

int slot = getMenuBoxSlot(e, interaction);

if (entities.size() == 1)

Neither of those specify that I'm getting the first option. It works fine when selecting the options past the first.

I updated the interaction with while loops and removed the sleep timers.

ALSO: You should not criticize my work unless you can do better. So, you show what you can do?

Edited by Beau
Link to comment
Share on other sites

Are you not reading the code correctly? I'm not just getting the first option...

int slot = getMenuBoxSlot(e, interaction);

if (entities.size() == 1)

Neither of those specify that I'm getting the first option. It works fine when selecting the options past the first.

I updated the interaction with while loops and removed the sleep timers.

ALSO: You should not criticize my work unless you can do better. So, you show what you can do?

I was trying to help you, don't act like a know it all when you just had a static sleep timer of 500-1500 please.

 

1) I'm not sure why you still think you're doing it right, but this:

 

2950fb51d2ecd38f4eb36b686fa697f2.png

 

NEVER GETS ANY OPTION. All it does is click, and that's assuming there's one thing on the cursor (you're not even checking that that's the correct entity, just that there's one there).

 

2) Your while loop just assures that the mouse gets moved to the bounding box. This could be good I guess, but it's kind of redundant when you could just return false if a menu is not open when you go to interact with it.

 

3) Fine if you're going to act like that I will:

public boolean interactNPC(NPC npc, String action) throws InterruptedException {
	if (npc != null && npc.getDefinition().getActions() != null) {
		Rectangle boundingBox = npc.getMouseDestination().getBoundingBox();
		if (Arrays.asList(npc.getDefinition().getActions()).get(0).equalsIgnoreCase(action)) {
			client.moveMouseTo(new RectangleDestination(boundingBox.x+5, boundingBox.y+5, boundingBox.width-10, boundingBox.height-10), false, false, false);
			if (client.getEntitiesOnCursor().get(0).getName().equalsIgnoreCase(npc.getName())) {
				client.clickMouse(false);
				return true;
			}
			else {
				client.moveMouseTo(new RectangleDestination(boundingBox.x+5, boundingBox.y+5, boundingBox.width-10, boundingBox.height-10), false, true, true);
				return selectMenuOption(action);
			}
		}
		else {
			client.moveMouseTo(new RectangleDestination(boundingBox.x+5, boundingBox.y+5, boundingBox.width-10, boundingBox.height-10), false, true, true);
			return selectMenuOption(action);
		}
	}
	return false;
}
	
public boolean selectMenuOption(String action) throws InterruptedException {
	if (client.isMenuOpen()) {
		List<Option> options = client.getMenu();
		for (int i= 0; i < options.size(); i++) {
			if (options.get(i).action.equalsIgnoreCase(action)) {
				return client.moveMouseTo(new RectangleDestination(client.getMenuX(), client.getMenuY()+19+(i*15), client.getMenuWidth(), 15), false, true, false);
			}
		}
	}
	return false;
}

Of course I could do more checking, but that can easily be accomplished by checking the boolean returned when the scripter calls the method.

Edited by Swizzbeat
Link to comment
Share on other sites

The first time I had a check if the entitiy was inside of the list and it was the only one in there. I didn't notice that I had removed it. I'm not acting like a no-it-all.... You were wrong about your statements until I changed it.

Now, let mr criticize yours, just so we're even...

1. You only have support for NPCs.

2. You're pulling the first action off the NPC instead of checking for all of the actions with the specified interaction name.

3. In your selectedMenuOption, you're only picking out the specified interaction, and not the entity with the option.

Now, let me explain why everything is screwed up, and why I had everything the way it was before.

1. I was trying to make it like you suggested and forgot about a few things.

2. I was checking if the size() was 1 because I had already set the mouse to move to the entity, and if he was the only one, then it would click the entity, other wise, it would right click and selected an option.

Lets get brief on the "NEVER GETS ANY OPTION":

1. As I explained before...The size() check is if the entity is the only one of the list, which is wrong way to do so, but I will change it.

This will move the mouse to the entity -> client.moveMouse(e.getMouseDestination(), false);

This will check if there is only one entity if (entities.size() == 1)

If not then it will select an option -> (THE ESLE STATEMENT)

EDIT:

I have changed the check to this

if (entities.get(0) != null && entities.get(0).equals(e)) {

Link to comment
Share on other sites

The first time I had a check if the entitiy was inside of the list and it was the only one in there. I didn't notice that I had removed it. I'm not acting like a no-it-all.... You were wrong about your statements until I changed it.

Now, let mr criticize yours, just so we're even...

1. You only have support for NPCs.

2. You're pulling the first action off the NPC instead of checking for all of the actions with the specified interaction name.

3. In your selectedMenuOption, you're only picking out the specified interaction, and not the entity with the option.

Now, let me explain why everything is screwed up, and why I had everything the way it was before.

1. I was trying to make it like you suggested and forgot about a few things.

2. I was checking if the size() was 1 because I had already set the mouse to move to the entity, and if he was the only one, then it would click the entity, other wise, it would right click and selected an option.

Lets get brief on the "NEVER GETS ANY OPTION":

1. As I explained before...The size() check is if the entity is the only one of the list, which is wrong way to do so, but I will change it.

This will move the mouse to the entity -> client.moveMouse(e.getMouseDestination(), false);

This will check if there is only one entity if (entities.size() == 1)

If not then it will select an option -> (THE ESLE STATEMENT)

EDIT:

I have changed the check to this

if (entities.get(0) != null && entities.get(0).equals(e)) {

1) The getDefintion() method is not found in the Entity class, but in the corresponding subclasses. Unfortunately this means that we need to create a whole separate method, unless I'm overlooking something, for each subclass as we cannot cast the Entity because we don't know what type will get passed to the method.

 

2) I'm only checking for the first action because if it is that means all the script has to do is click on it instead of opening a menu. If the action is not the first on the list it will continue on to the else statement.

 

3) It doesn't matter what NPC I have to interact with because my moveMouseTo right clicks the NPC I need, all this method does is look for the correct interaction on the menu.

 

I'm sorry if I came off like I was trying to be a dick, because I'm not, just attempting to provide you with some constructive feedback :)

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