diff --git a/modules/addon_terminal/commands.lua b/modules/addon_terminal/commands.lua index 37c83f6d..6a5bd03c 100644 --- a/modules/addon_terminal/commands.lua +++ b/modules/addon_terminal/commands.lua @@ -22,7 +22,8 @@ end function debugContainersItems() function UIItem:onHoverChange(hovered) if hovered then - ToolTip.display(self:getItem():getId()) + local item = self:getItem() + if item then ToolTip.display(item:getId()) end else ToolTip.hide() end diff --git a/modules/core_widgets/uipopupmenu.lua b/modules/core_widgets/uipopupmenu.lua index 5b560424..8ba2ae41 100644 --- a/modules/core_widgets/uipopupmenu.lua +++ b/modules/core_widgets/uipopupmenu.lua @@ -18,12 +18,15 @@ function UIPopupMenu:display(pos) end displayUI(self, {x = pos.x, y = pos.y}) - self:bindRectToParent() self:grabMouse() self:grabKeyboard() table.insert(displayedMenuList, self) end +function UIPopupMenu:onGeometryChange() + self:bindRectToParent() +end + function UIPopupMenu:addOption(optionName, optionCallback) local optionWidget = createWidget(self:getStyleName() .. 'Button', self) local lastOptionWidget = self:getLastChild() diff --git a/src/otclient/core/game.cpp b/src/otclient/core/game.cpp index 2321636a..0481cbaa 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/core/game.cpp @@ -274,6 +274,14 @@ void Game::useHotkey(int itemId, const ThingPtr& toThing) m_protocolGame->sendUseItemEx(Position(0xFFFF, 0, 0), itemId, 0, toThing->getPos(), toThing->getId(), getThingStackpos(toThing)); } +void Game::useOnCreature(const ThingPtr& thing, const CreaturePtr& creature) +{ + if(!m_online || !thing || !checkBotProtection()) + return; + + m_protocolGame->sendUseOnCreature(thing->getPos(), thing->getId(), getThingStackpos(thing), creature->getId()); +} + void Game::attack(const CreaturePtr& creature) { if(!m_online || !creature || !checkBotProtection()) diff --git a/src/otclient/core/game.h b/src/otclient/core/game.h index 878fc222..ebdd6961 100644 --- a/src/otclient/core/game.h +++ b/src/otclient/core/game.h @@ -65,6 +65,7 @@ public: void use(const ThingPtr& thing); void useWith(const ThingPtr& fromThing, const ThingPtr& toThing); void useHotkey(int itemId, const ThingPtr& toThing); + void useOnCreature(const ThingPtr& thing, const CreaturePtr& creature); // attack/follow related void attack(const CreaturePtr& creature); diff --git a/src/otclient/luafunctions.cpp b/src/otclient/luafunctions.cpp index f0df3b01..c094936b 100644 --- a/src/otclient/luafunctions.cpp +++ b/src/otclient/luafunctions.cpp @@ -198,6 +198,7 @@ void OTClient::registerLuaFunctions() g_lua.bindClassStaticFunction("use", std::bind(&Game::use, &g_game, _1)); g_lua.bindClassStaticFunction("useWith", std::bind(&Game::useWith, &g_game, _1, _2)); g_lua.bindClassStaticFunction("useHotkey", std::bind(&Game::useHotkey, &g_game, _1, _2)); + g_lua.bindClassStaticFunction("useOnCreature", std::bind(&Game::useOnCreature, &g_game, _1, _2)); g_lua.bindClassStaticFunction("walk", std::bind(&Game::walk, &g_game, _1)); g_lua.bindClassStaticFunction("forceWalk", std::bind(&Game::forceWalk, &g_game, _1)); g_lua.bindClassStaticFunction("attack", std::bind(&Game::attack, &g_game, _1)); diff --git a/src/otclient/net/protocolgame.h b/src/otclient/net/protocolgame.h index cd207c9f..38e5f1e5 100644 --- a/src/otclient/net/protocolgame.h +++ b/src/otclient/net/protocolgame.h @@ -66,7 +66,7 @@ public: void sendRejectTrade(); void sendUseItem(const Position& position, int itemId, int stackpos, int index); void sendUseItemEx(const Position& fromPos, int fromThingId, int fromStackpos, const Position& toPos, int toThingId, int toStackpos); - void sendUseItemCreature(const Position& pos, int thingId, int stackpos, uint creatureId); + void sendUseOnCreature(const Position& pos, int thingId, int stackpos, uint creatureId); void sendRotateItem(const Position& pos, int thingId, int stackpos); void sendCloseContainer(int containerId); void sendUpContainer(int containerId); diff --git a/src/otclient/net/protocolgamesend.cpp b/src/otclient/net/protocolgamesend.cpp index 5c5e66f0..8f1b493f 100644 --- a/src/otclient/net/protocolgamesend.cpp +++ b/src/otclient/net/protocolgamesend.cpp @@ -275,7 +275,7 @@ void ProtocolGame::sendUseItemEx(const Position& fromPos, int fromThingId, int f send(oMsg); } -void ProtocolGame::sendUseItemCreature(const Position& pos, int thingId, int stackpos, uint creatureId) +void ProtocolGame::sendUseOnCreature(const Position& pos, int thingId, int stackpos, uint creatureId) { OutputMessage oMsg; oMsg.addU8(Proto::ClientUseOnCreature);