void Game::useWith(const ItemPtr& item, const ThingPtr& toThing)
{
if(!canPerformGameAction() || !item || !toThing)
return;
Position pos = item->getPosition();
if(!pos.isValid()) // virtual item
pos = Position(0xFFFF, 0, 0); // means that is an item in inventory
UIWidgetPtr clickedWidget = g_ui.getRootWidget()->recursiveGetChildByPos(g_window.getMousePosition(), false);
if (clickedWidget->getStyleName() == "BattleButton") {
if (toThing->isPlayer()) {
g_lua.callGlobalField("g_game", "onTextMessage", 19, "You are not allowed to shoot directly on players.");
} else {
m_protocolGame->sendUseItemWith(pos, item->getId(), item->getStackPos(), toThing->getPosition(), toThing->getId(), toThing->getStackPos());
}
} else {
m_protocolGame->sendUseItemWith(pos, item->getId(), item->getStackPos(), toThing->getPosition(), toThing->getId(), toThing->getStackPos());
}
}