Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bot item ondrop and analyzer loot channel #887

Merged
merged 6 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions mods/game_bot/default_configs/vBot_4.8/vBot/analyzer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -723,11 +723,10 @@ local expPerHour = function(calculation)
end

local function add(t, text, color, last)
table.insert(t, text)
table.insert(t, color)
local coloredText = "{" .. text .. ", " .. color .. "}"
table.insert(t, coloredText)
if not last then
table.insert(t, ", ")
table.insert(t, "#FFFFFF")
table.insert(t, "{, , #FFFFFF}")
end
end

Expand Down Expand Up @@ -958,7 +957,8 @@ onTextMessage(function(mode, text)
local panel = console.consoleTabBar:getTabPanel(tab)
local consoleBuffer = panel:getChildById('consoleBuffer')
local message = consoleBuffer:getLastChild()
message:setColoredText(t)
message:setColoredText(table.concat(t))

end)

local function niceFormat(v)
Expand Down
18 changes: 16 additions & 2 deletions modules/game_interface/widgets/uiitem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ function UIItem:onDrop(widget, mousePos)
if not(toPos) and self:getParent() and self:getParent().slotPosition then
toPos = self:getParent().slotPosition
end

if not g_game.isEnabledBotProtection() and self.selectable then
if item:isPickupable() then
self:setItem(Item.create(item:getId(), item:getCountOrSubType()))
return true
end
return false
end
if not itemPos or not toPos then
local pressedWidget = g_ui.getPressedWidget()
local rootWidget = g_ui.getRootWidget()
Expand Down Expand Up @@ -170,8 +178,14 @@ function UIItem:onMouseRelease(mousePosition, mouseButton)
end

function UIItem:canAcceptDrop(widget, mousePos)
if self:isVirtual() or not self:isDraggable() then
return false
if not g_game.isEnabledBotProtection() then
if not self.selectable and (self:isVirtual() or not self:isDraggable()) then
return false
end
else
if self:isVirtual() or not self:isDraggable() then
return false
end
end
if not widget or not widget.currentDragThing then
return false
Expand Down
8 changes: 4 additions & 4 deletions src/client/uiitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,23 @@ void UIItem::setItemId(int id)
m_item->setId(id);
else
m_item = Item::create(id);
#ifdef BOT_PROTECTION
#ifndef BOT_PROTECTION
callLuaField("onItemChange");
#endif
}

void UIItem::setItemCount(int count)
{
if (m_item) m_item->setCount(count);
#ifdef BOT_PROTECTION
#ifndef BOT_PROTECTION
callLuaField("onItemChange");
#endif
}

void UIItem::setItemSubType(int subType)
{
if (m_item) m_item->setSubType(subType);
#ifdef BOT_PROTECTION
#ifndef BOT_PROTECTION
callLuaField("onItemChange");
#endif
}
Expand All @@ -99,7 +99,7 @@ void UIItem::setItem(const ItemPtr& item)
{
m_item = item;

#ifdef BOT_PROTECTION
#ifndef BOT_PROTECTION
callLuaField("onItemChange");
#endif
}
Expand Down
Loading