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<>();
|
List<Runnable> tasks = new ArrayList<>();
|
||||||
tasks.add(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.itemId));
|
tasks.add(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.itemId));
|
||||||
tasks.add(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, 0));
|
tasks.add(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, 0));
|
||||||
|
|
||||||
Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, this.itemId));
|
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;
|
return true;
|
||||||
|
@ -47,9 +47,7 @@ public class RoomUnitWalkToRoomUnit implements Runnable {
|
|||||||
if (this.goalTile == null)
|
if (this.goalTile == null)
|
||||||
return;
|
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.
|
if (this.walker.getGoal().equals(this.goalTile)) { // check that the action hasn't been cancelled by changing the goal
|
||||||
{
|
|
||||||
//Check if arrived.
|
|
||||||
if (this.walker.getCurrentLocation().distance(this.goalTile) <= this.minDistance) {
|
if (this.walker.getCurrentLocation().distance(this.goalTile) <= this.minDistance) {
|
||||||
for (Runnable r : this.targetReached) {
|
for (Runnable r : this.targetReached) {
|
||||||
Emulator.getThreading().run(r);
|
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});
|
WiredHandler.handle(WiredTriggerType.BOT_REACHED_AVTR, this.target, this.room, new Object[]{this.walker});
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
Emulator.getThreading().run(this, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,8 +63,15 @@ public class RoomUnitWalkToRoomUnit implements Runnable {
|
|||||||
private void findNewLocation() {
|
private void findNewLocation() {
|
||||||
this.goalTile = this.walker.getClosestAdjacentTile(this.target.getCurrentLocation().x, this.target.getCurrentLocation().y, true);
|
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.walker.setGoalLocation(this.goalTile);
|
this.walker.setGoalLocation(this.goalTile);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user