mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-22 23:10:52 +01:00
Fixed ButlerBots, they now give drinks over a furniture if within a command difference.
This commit is contained in:
parent
0e92f9066a
commit
ca2e5ef500
@ -4,5 +4,6 @@ INSERT INTO `catalog_pages`(`id`, `parent_id`, `caption_save`, `caption`, `icon_
|
||||
SET @page_id = LAST_INSERT_ID();
|
||||
UPDATE catalog_items SET page_id = @page_id WHERE catalog_name LIKE '%guild_forum%';
|
||||
UPDATE items_base SET `interaction_type` = 'guild_furni' WHERE item_name LIKE '%guild_forum%';
|
||||
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.bot.butler.commanddistance', '5');
|
||||
|
||||
#END DATABASE UPDATE: 1.16.0 -> 2.0.0
|
@ -592,4 +592,18 @@ public class Bot implements Runnable
|
||||
{
|
||||
this.canWalk = canWalk;
|
||||
}
|
||||
|
||||
public void lookAt(Habbo habbo) {
|
||||
this.lookAt(habbo.getRoomUnit().getCurrentLocation());
|
||||
}
|
||||
|
||||
public void lookAt(RoomUnit roomUnit) {
|
||||
this.lookAt(roomUnit.getCurrentLocation());
|
||||
}
|
||||
|
||||
public void lookAt(RoomTile tile) {
|
||||
this.roomUnit.lookAtPoint(tile);
|
||||
this.roomUnit.statusUpdate(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ public class ButlerBot extends Bot
|
||||
{
|
||||
public static THashMap<THashSet<String>, Integer> serveItems = new THashMap<>();
|
||||
|
||||
|
||||
public ButlerBot(ResultSet set) throws SQLException
|
||||
{
|
||||
super(set);
|
||||
@ -67,50 +66,63 @@ public class ButlerBot extends Bot
|
||||
if(this.getRoomUnit().hasStatus(RoomUnitStatus.MOVE))
|
||||
return;
|
||||
|
||||
if (this.getRoomUnit().getCurrentLocation().distance(message.getHabbo().getRoomUnit().getCurrentLocation()) <= Emulator.getConfig().getInt("hotel.bot.butler.servedistance"))
|
||||
if(message.getUnfilteredMessage() != null)
|
||||
{
|
||||
for(Map.Entry<THashSet<String>, Integer> set : serveItems.entrySet())
|
||||
if (this.getRoomUnit().getCurrentLocation().distance(message.getHabbo().getRoomUnit().getCurrentLocation()) <= Emulator.getConfig().getInt("hotel.bot.butler.commanddistance"))
|
||||
if(message.getUnfilteredMessage() != null)
|
||||
{
|
||||
for(String s : set.getKey())
|
||||
for(Map.Entry<THashSet<String>, Integer> set : serveItems.entrySet())
|
||||
{
|
||||
if(message.getUnfilteredMessage().toLowerCase().contains(s))
|
||||
for(String s : set.getKey())
|
||||
{
|
||||
BotServerItemEvent serveEvent = new BotServerItemEvent(this, message.getHabbo(), set.getValue());
|
||||
if (Emulator.getPluginManager().fireEvent(serveEvent).isCancelled())
|
||||
if(message.getUnfilteredMessage().toLowerCase().contains(s))
|
||||
{
|
||||
BotServerItemEvent serveEvent = new BotServerItemEvent(this, message.getHabbo(), set.getValue());
|
||||
if (Emulator.getPluginManager().fireEvent(serveEvent).isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.getRoomUnit().canWalk())
|
||||
{
|
||||
final String key = s;
|
||||
final Bot b = this;
|
||||
b.lookAt(serveEvent.habbo);
|
||||
|
||||
final List<Runnable> tasks = new ArrayList();
|
||||
tasks.add(new RoomUnitGiveHanditem(serveEvent.habbo.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), serveEvent.itemId));
|
||||
tasks.add(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), 0));
|
||||
|
||||
tasks.add(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
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")) {
|
||||
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));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.getRoom().giveHandItem(serveEvent.habbo, serveEvent.itemId);
|
||||
this.talk(Emulator.getTexts().getValue("bots.butler.given").replace("%key%", s).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.getRoomUnit().canWalk())
|
||||
{
|
||||
final String key = s;
|
||||
final Bot b = this;
|
||||
|
||||
List<Runnable> tasks = new ArrayList<>();
|
||||
tasks.add(new RoomUnitGiveHanditem(serveEvent.habbo.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), serveEvent.itemId));
|
||||
tasks.add(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.habbo.getHabboInfo().getCurrentRoom(), 0));
|
||||
|
||||
tasks.add(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
b.talk(Emulator.getTexts().getValue("bots.butler.given").replace("%key%", key).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername()));
|
||||
}
|
||||
});
|
||||
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, null));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.getRoom().giveHandItem(serveEvent.habbo, serveEvent.itemId);
|
||||
this.talk(Emulator.getTexts().getValue("bots.butler.given").replace("%key%", s).replace("%username%", serveEvent.habbo.getHabboInfo().getUsername()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class RoomUnitWalkToRoomUnit implements Runnable
|
||||
|
||||
this.walker.setGoalLocation(this.goalTile);
|
||||
|
||||
if(this.walker.getPath() == null)
|
||||
if (this.walker.getPath().isEmpty())
|
||||
{
|
||||
for(Runnable r : this.failedReached)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user