forked from 2009Scape/Server
Bot scripting simplification!
This commit is contained in:
parent
0d31085a36
commit
4f6a431f65
5 changed files with 7 additions and 35 deletions
Binary file not shown.
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue