Bot scripting simplification!

This commit is contained in:
dginovker 2019-06-09 10:58:58 -04:00
parent 0d31085a36
commit 4f6a431f65
5 changed files with 7 additions and 35 deletions

View file

@ -143,26 +143,6 @@ public class AIPlayer extends Player {
this.setAttribute("dead", true);
}
public void runScript(Script script)
{
if (!this.getPulseManager().hasPulseRunning())
{
getPulseManager().run(new Pulse() {
@Override
public boolean pulse() {
return false;
}
@Override
public boolean update() {
super.update();
script.runLoop();
return true;
}
});
}
}
/**
* Gets the UID.
* @return the UID.

View file

@ -27,8 +27,11 @@ public class GeneralBotCreator {
AIPlayer.deregister(bot.getUid());
return true;
}
bot.runScript(botScript);
System.out.println("Running script");
if (!bot.getPulseManager().hasPulseRunning())
{
botScript.runLoop();
}
return false;
}
});

View file

@ -26,12 +26,8 @@ public class ScriptAPI {
double minDistance = Double.MAX_VALUE;
for (Node e : RegionManager.forId(me.getLocation().getRegionId()).getPlanes()[me.getLocation().getZ()].getEntities())
{
if (e != null && e.getName().equals(entityName) && distance(me, e) < minDistance && Pathfinder.find(me, e).isSuccessful())
if (e != null && e.getName().equals(entityName) && distance(me, e) < minDistance && Pathfinder.find(me, e, false, Pathfinder.SMART).isSuccessful())
{
/*if (entity != null)
{
System.out.println("I'm at " + me.getLocation() + ". " + e.getLocation() + distance(me, e) + " is closer to me than " + entity.getLocation() + distance(me, entity));
}*/
entity = e;
minDistance = distance(me, e);
}

View file

@ -8,13 +8,6 @@ public class ManThiever extends Script {
public void runLoop() {
Node man = scriptAPI.getNearestEntity(me, "Man");
System.out.println("Current pulse: " + me.getPulseManager().getCurrent());
System.out.println("Is moving pulse? " + me.getPulseManager().isMovingPulse());
if (!me.getPulseManager().isMovingPulse())
{
man.getInteraction().handle(me, man.getInteraction().get(2));
}
/*scriptAPI.walk(me, man);
new ThievingOptionPlugin().handle(me, man, "pickpocket");*/
man.getInteraction().handle(me, man.getInteraction().get(2));
}
}