mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 15:20:52 +01:00
Fix giving handitems with bots
This commit is contained in:
parent
82ff5c0a08
commit
4ecba6723d
@ -96,8 +96,13 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
|
||||
List<Runnable> tasks = new ArrayList<>();
|
||||
tasks.add(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.itemId));
|
||||
tasks.add(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, 0));
|
||||
|
||||
Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, this.itemId));
|
||||
Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(bot.getRoomUnit(), habbo.getRoomUnit(), room, tasks, null));
|
||||
|
||||
List<Runnable> failedReach = new ArrayList<>();
|
||||
failedReach.add(() -> tasks.forEach(Runnable::run));
|
||||
|
||||
Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(bot.getRoomUnit(), habbo.getRoomUnit(), room, tasks, failedReach));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -47,9 +47,7 @@ public class RoomUnitWalkToRoomUnit implements Runnable {
|
||||
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.getGoal().equals(this.goalTile)) { // check that the action hasn't been cancelled by changing the goal
|
||||
if (this.walker.getCurrentLocation().distance(this.goalTile) <= this.minDistance) {
|
||||
for (Runnable r : this.targetReached) {
|
||||
Emulator.getThreading().run(r);
|
||||
@ -57,17 +55,6 @@ public class RoomUnitWalkToRoomUnit implements Runnable {
|
||||
WiredHandler.handle(WiredTriggerType.BOT_REACHED_AVTR, this.target, this.room, new Object[]{this.walker});
|
||||
}
|
||||
} else {
|
||||
List<RoomTile> tiles = this.room.getLayout().getTilesAround(this.target.getCurrentLocation());
|
||||
|
||||
for (RoomTile t : tiles) {
|
||||
if (t.equals(this.goalTile)) {
|
||||
Emulator.getThreading().run(this, 500);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.findNewLocation();
|
||||
|
||||
Emulator.getThreading().run(this, 500);
|
||||
}
|
||||
}
|
||||
@ -76,8 +63,15 @@ public class RoomUnitWalkToRoomUnit implements Runnable {
|
||||
private void findNewLocation() {
|
||||
this.goalTile = this.walker.getClosestAdjacentTile(this.target.getCurrentLocation().x, this.target.getCurrentLocation().y, true);
|
||||
|
||||
if (this.goalTile == null)
|
||||
if (this.goalTile == null) {
|
||||
if (this.failedReached != null) {
|
||||
for (Runnable r : this.failedReached) {
|
||||
Emulator.getThreading().run(r);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.walker.setGoalLocation(this.goalTile);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user