mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-31 12:22:36 +01:00
Added hotel.bot.butler.reachdistance config to ButlerBot. This will allow the bot to give an item without walking next to the player.
This commit is contained in:
parent
23ae60119b
commit
766a24c155
@ -99,20 +99,28 @@ public class ButlerBot extends Bot
|
||||
b.talk(Emulator.getTexts().getValue("bots.butler.given").replace("%key%", key).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername()));
|
||||
}
|
||||
});
|
||||
|
||||
List<Runnable> failedReached = new ArrayList();
|
||||
failedReached.add(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (b.getRoomUnit().getCurrentLocation().distance(serveEvent.habbo.getRoomUnit().getCurrentLocation()) <= Emulator.getConfig().getInt("hotel.bot.butler.servedistance")) {
|
||||
if (b.getRoomUnit().getCurrentLocation().distance(serveEvent.habbo.getRoomUnit().getCurrentLocation()) <= Emulator.getConfig().getInt("hotel.bot.butler.servedistance", 8)) {
|
||||
for (Runnable t : tasks) {
|
||||
t.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Emulator.getThreading().run(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), serveEvent.itemId));
|
||||
Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(this.getRoomUnit(), serveEvent.habbo.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), tasks, failedReached));
|
||||
|
||||
if (b.getRoomUnit().getCurrentLocation().distance(serveEvent.habbo.getRoomUnit().getCurrentLocation()) > Emulator.getConfig().getInt("hotel.bot.butler.reachdistance", 3)) {
|
||||
Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(this.getRoomUnit(), serveEvent.habbo.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), tasks, failedReached, Emulator.getConfig().getInt("hotel.bot.butler.reachdistance", 3)));
|
||||
}
|
||||
else {
|
||||
Emulator.getThreading().run(failedReached.get(0), 1000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||
|
||||
public class RoomUnitWalkToRoomUnit implements Runnable
|
||||
{
|
||||
private final int minDistance;
|
||||
private RoomUnit walker;
|
||||
private RoomUnit target;
|
||||
private Room room;
|
||||
@ -26,6 +27,17 @@ public class RoomUnitWalkToRoomUnit implements Runnable
|
||||
this.room = room;
|
||||
this.targetReached = targetReached;
|
||||
this.failedReached = failedReached;
|
||||
this.minDistance = 1;
|
||||
}
|
||||
|
||||
public RoomUnitWalkToRoomUnit(RoomUnit walker, RoomUnit target, Room room, List<Runnable> targetReached, List<Runnable> failedReached, int minDistance)
|
||||
{
|
||||
this.walker = walker;
|
||||
this.target = target;
|
||||
this.room = room;
|
||||
this.targetReached = targetReached;
|
||||
this.failedReached = failedReached;
|
||||
this.minDistance = minDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -36,10 +48,14 @@ public class RoomUnitWalkToRoomUnit implements Runnable
|
||||
this.findNewLocation();
|
||||
Emulator.getThreading().run(this, 500);
|
||||
}
|
||||
else if(this.walker.getGoal().equals(this.goalTile)) //Check if the goal is still the same. Chances are something is running the same task. If so we dump this task.
|
||||
|
||||
if(this.goalTile == null)
|
||||
return;
|
||||
|
||||
if(this.walker.getGoal().equals(this.goalTile)) //Check if the goal is still the same. Chances are something is running the same task. If so we dump this task.
|
||||
{
|
||||
//Check if arrived.
|
||||
if(this.walker.getCurrentLocation().equals(this.goalTile))
|
||||
if(this.walker.getCurrentLocation().distance(this.goalTile) <= this.minDistance)
|
||||
{
|
||||
for(Runnable r : this.targetReached)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user