Jump to content

Programming preemptive interaction


WhatIfand

Recommended Posts

Disclaimer All pseudo code

(Wouldn't mind real code answers :) ) 

 

I'd love some help knowing how to program pre emptive mouse hovering and interaction. I haven't familiarized myself with the API, so I've just been considering the logic of these things.

Such as when the bot is running toward an area, and it has already clicked on the intractable object contained within the area it's running to. 

(and allows the player to run toward the object via interaction running)

if (myplayer.distance(areaOfObject) < 6){

object.interact;

}

or while fighting a monster, hovering the mouse over the next monster to attack.

This one i thought you may want to define 2 variables - one is closest npc and other is a 2nd closest npc?  Any thoughts on this?

if (closestMonster.gethealth(<30)){
getMouse.hover(secondMonster);
}

The only issue with the above is that the 2nd monster would be changing constantly (due to distance '.closest') unless theres a way to make a variable static based upon monster 1.

Like whoever is 2nd closest at that moment is assigned as a new variable (nextTarget).

Would also have to check their distance and status to ensure the bot doesnt attack something which is being attack by another player AFTER the assignment to the nextTarget variable.

-quite complex, i may be overthinking it. My initial reasoning for implementing these features was antiban, but upon enlightenment of its uselessness I think this functionality techniques would make things happen faster. Which would be very useful with a large scale gold farm.

Thanks guys.

As i typed 'thanks guys' I questioned : is there a single female on this website as a dev? Not to assume gender roles (lol) but lets be honest this is a pretty male nerd place to be.

Edited by WhatIfand
punctuation
Link to comment
Share on other sites

For breaking early based on distance, you'll want to use a WalkingEvent (or WebWalkingEvent) and set a break condition for the event. It could be something as simple as

Supplier<NPC> npcFinder = () -> getNpcs().closest(f -> f.getName().equals("NpcToFind") && f.getPosition() != null && f.getPosition().distance(myPosition()) <= 7 && getMap().canReach(f));
Condition breakCondition = new Condition() {
  @Override
    public boolean evaluate() {
    return npcFinder.get() != null;
  }
};
new WalkingEvent(myPos).setBreakCondition(breakCondition).execute();
NPC targetNpc = npcFinder.get();
if (targetNpc != null)
  if (targetNpc.interact())
  //Do stuff

This will break out of your walking event as soon as the NPC is able to be reached, and interact with it.

 

You'll use a similar concept for hovering the next monster to attack. In the execution of your combat-block, determine if the NPC you're fighting is about to die, and if so, find the next target and hover over it. You'll need to constantly validate that it's a valid target and isn't in combat with another player.

  • Like 2
Link to comment
Share on other sites

19 hours ago, NoxMerc said:

For breaking early based on distance, you'll want to use a WalkingEvent (or WebWalkingEvent) and set a break condition for the event. It could be something as simple as


Supplier<NPC> npcFinder = () -> getNpcs().closest(f -> f.getName().equals("NpcToFind") && f.getPosition() != null && f.getPosition().distance(myPosition()) <= 7 && getMap().canReach(f));
Condition breakCondition = new Condition() {
  @Override
    public boolean evaluate() {
    return npcFinder.get() != null;
  }
};
new WalkingEvent(myPos).setBreakCondition(breakCondition).execute();
NPC targetNpc = npcFinder.get();
if (targetNpc != null)
  if (targetNpc.interact())
  //Do stuff

This will break out of your walking event as soon as the NPC is able to be reached, and interact with it.

 

You'll use a similar concept for hovering the next monster to attack. In the execution of your combat-block, determine if the NPC you're fighting is about to die, and if so, find the next target and hover over it. You'll need to constantly validate that it's a valid target and isn't in combat with another player.

Simple enough. Appreciate the response man.

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