Fixed ButlerBots, they now give drinks over a furniture if within a command difference.

This commit is contained in:
KrewsOrg 2019-05-02 23:47:30 +01:00
parent 0e92f9066a
commit ca2e5ef500
4 changed files with 65 additions and 38 deletions

View File

@ -4,5 +4,6 @@ INSERT INTO `catalog_pages`(`id`, `parent_id`, `caption_save`, `caption`, `icon_
SET @page_id = LAST_INSERT_ID(); SET @page_id = LAST_INSERT_ID();
UPDATE catalog_items SET page_id = @page_id WHERE catalog_name LIKE '%guild_forum%'; 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%'; 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 #END DATABASE UPDATE: 1.16.0 -> 2.0.0

View File

@ -592,4 +592,18 @@ public class Bot implements Runnable
{ {
this.canWalk = canWalk; 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);
}
} }

View File

@ -22,7 +22,6 @@ public class ButlerBot extends Bot
{ {
public static THashMap<THashSet<String>, Integer> serveItems = new THashMap<>(); public static THashMap<THashSet<String>, Integer> serveItems = new THashMap<>();
public ButlerBot(ResultSet set) throws SQLException public ButlerBot(ResultSet set) throws SQLException
{ {
super(set); super(set);
@ -67,50 +66,63 @@ public class ButlerBot extends Bot
if(this.getRoomUnit().hasStatus(RoomUnitStatus.MOVE)) if(this.getRoomUnit().hasStatus(RoomUnitStatus.MOVE))
return; return;
if (this.getRoomUnit().getCurrentLocation().distance(message.getHabbo().getRoomUnit().getCurrentLocation()) <= Emulator.getConfig().getInt("hotel.bot.butler.servedistance")) if (this.getRoomUnit().getCurrentLocation().distance(message.getHabbo().getRoomUnit().getCurrentLocation()) <= Emulator.getConfig().getInt("hotel.bot.butler.commanddistance"))
if(message.getUnfilteredMessage() != null) if(message.getUnfilteredMessage() != null)
{
for(Map.Entry<THashSet<String>, Integer> set : serveItems.entrySet())
{ {
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(message.getUnfilteredMessage().toLowerCase().contains(s))
if (Emulator.getPluginManager().fireEvent(serveEvent).isCancelled())
{ {
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; 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;
} }
} }
} }
}
} }
} }

View File

@ -92,7 +92,7 @@ public class RoomUnitWalkToRoomUnit implements Runnable
this.walker.setGoalLocation(this.goalTile); this.walker.setGoalLocation(this.goalTile);
if(this.walker.getPath() == null) if (this.walker.getPath().isEmpty())
{ {
for(Runnable r : this.failedReached) for(Runnable r : this.failedReached)
{ {