From 8e5032d48aeb1ba6a9f3cbf6ce166f80130cb509 Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Tue, 28 Nov 2023 13:04:29 -0300 Subject: [PATCH] improve: remove unnecessary spaces from mod/ folder --- init.lua | 2 +- mods/client_profiles/profiles.lua | 6 +- mods/client_profiles/profiles.otmod | 2 +- mods/client_textedit/textedit.otui | 9 +- mods/game_bot/bot.lua | 185 ++++++------ mods/game_bot/bot.otui | 22 +- .../cavebot_1.3/cavebot/actions.lua | 48 +-- .../cavebot_1.3/cavebot/cavebot.lua | 32 +- .../cavebot_1.3/cavebot/cavebot.otui | 17 +- .../cavebot_1.3/cavebot/config.lua | 16 +- .../cavebot_1.3/cavebot/config.otui | 14 +- .../cavebot_1.3/cavebot/depositer.lua | 2 +- .../cavebot_1.3/cavebot/editor.lua | 28 +- .../cavebot_1.3/cavebot/editor.otui | 5 +- .../cavebot_1.3/cavebot/example_functions.lua | 6 +- .../cavebot/extension_template.lua | 2 +- .../cavebot_1.3/cavebot/recorder.lua | 10 +- .../cavebot_1.3/cavebot/supply.lua | 2 +- .../cavebot_1.3/cavebot/supply.otui | 8 +- .../cavebot_1.3/cavebot/walking.lua | 16 +- .../default_configs/cavebot_1.3/hp.lua | 24 +- .../default_configs/cavebot_1.3/main.lua | 3 - .../cavebot_1.3/mwall_timer.lua | 6 +- .../cavebot_1.3/targetbot/creature.lua | 5 +- .../cavebot_1.3/targetbot/creature_attack.lua | 6 +- .../cavebot_1.3/targetbot/creature_editor.lua | 2 +- .../targetbot/creature_editor.otui | 13 +- .../targetbot/creature_priority.lua | 4 +- .../cavebot_1.3/targetbot/looting.lua | 6 +- .../cavebot_1.3/targetbot/looting.otui | 10 +- .../cavebot_1.3/targetbot/target.lua | 15 +- .../cavebot_1.3/targetbot/target.otui | 8 +- .../cavebot_1.3/targetbot/walking.lua | 2 +- .../default_configs/cavebot_1.3/tools.lua | 10 +- .../vBot_4.8/cavebot/actions.lua | 60 ++-- .../default_configs/vBot_4.8/cavebot/bank.lua | 7 +- .../vBot_4.8/cavebot/buy_supplies.lua | 14 +- .../vBot_4.8/cavebot/cavebot.lua | 42 +-- .../vBot_4.8/cavebot/cavebot.otui | 17 +- .../vBot_4.8/cavebot/clear_tile.lua | 6 +- .../vBot_4.8/cavebot/config.lua | 16 +- .../vBot_4.8/cavebot/config.otui | 14 +- .../vBot_4.8/cavebot/d_withdraw.lua | 11 +- .../vBot_4.8/cavebot/depositor.lua | 8 +- .../vBot_4.8/cavebot/doors.lua | 6 +- .../vBot_4.8/cavebot/editor.lua | 35 ++- .../vBot_4.8/cavebot/editor.otui | 5 +- .../vBot_4.8/cavebot/example_functions.lua | 6 +- .../vBot_4.8/cavebot/extension_template.lua | 2 +- .../vBot_4.8/cavebot/imbuing.lua | 8 +- .../vBot_4.8/cavebot/inbox_withdraw.lua | 4 +- .../default_configs/vBot_4.8/cavebot/lure.lua | 2 +- .../vBot_4.8/cavebot/minimap.lua | 2 +- .../vBot_4.8/cavebot/pos_check.lua | 2 +- .../vBot_4.8/cavebot/recorder.lua | 10 +- .../vBot_4.8/cavebot/sell_all.lua | 10 +- .../vBot_4.8/cavebot/stand_lure.lua | 12 +- .../vBot_4.8/cavebot/tasker.lua | 10 +- .../vBot_4.8/cavebot/travel.lua | 6 +- .../vBot_4.8/cavebot/walking.lua | 16 +- .../vBot_4.8/cavebot/withdraw.lua | 4 +- .../vBot_4.8/targetbot/creature.lua | 3 +- .../vBot_4.8/targetbot/creature_attack.lua | 12 +- .../vBot_4.8/targetbot/creature_editor.lua | 2 +- .../vBot_4.8/targetbot/creature_editor.otui | 12 +- .../vBot_4.8/targetbot/creature_priority.lua | 4 +- .../vBot_4.8/targetbot/looting.lua | 8 +- .../vBot_4.8/targetbot/looting.otui | 12 +- .../vBot_4.8/targetbot/target.lua | 15 +- .../vBot_4.8/targetbot/target.otui | 8 +- .../vBot_4.8/targetbot/walking.lua | 2 +- .../vBot_4.8/vBot/AttackBot.lua | 50 ++-- .../vBot_4.8/vBot/AttackBot.otui | 36 +-- .../vBot_4.8/vBot/BotServer.lua | 16 +- .../vBot_4.8/vBot/BotServer.otui | 17 +- .../vBot_4.8/vBot/Conditions.lua | 31 +- .../vBot_4.8/vBot/Conditions.otui | 28 +- .../vBot_4.8/vBot/Containers.lua | 4 +- .../default_configs/vBot_4.8/vBot/Dropper.lua | 14 +- .../vBot_4.8/vBot/Equipper.lua | 28 +- .../default_configs/vBot_4.8/vBot/HealBot.lua | 45 ++- .../vBot_4.8/vBot/HealBot.otui | 34 +-- .../default_configs/vBot_4.8/vBot/Sio.lua | 28 +- .../default_configs/vBot_4.8/vBot/alarms.lua | 21 +- .../default_configs/vBot_4.8/vBot/alarms.otui | 6 +- .../vBot_4.8/vBot/analyzer.lua | 133 ++++----- .../vBot_4.8/vBot/analyzer.otui | 39 ++- .../default_configs/vBot_4.8/vBot/antiRs.lua | 2 +- .../vBot_4.8/vBot/cast_food.lua | 2 +- .../vBot_4.8/vBot/cavebot_control_panel.lua | 6 +- .../default_configs/vBot_4.8/vBot/combo.lua | 33 +- .../default_configs/vBot_4.8/vBot/combo.otui | 64 ++-- .../default_configs/vBot_4.8/vBot/configs.lua | 26 +- .../vBot_4.8/vBot/depositer_config.lua | 18 +- .../vBot_4.8/vBot/depositer_config.otui | 2 +- .../vBot_4.8/vBot/depot_withdraw.lua | 11 +- .../vBot_4.8/vBot/eat_food.lua | 2 +- .../default_configs/vBot_4.8/vBot/equip.lua | 4 +- .../vBot_4.8/vBot/equipper.otui | 17 +- .../default_configs/vBot_4.8/vBot/exeta.lua | 4 +- .../default_configs/vBot_4.8/vBot/extras.lua | 8 - .../default_configs/vBot_4.8/vBot/extras.otui | 10 +- .../vBot_4.8/vBot/hold_target.lua | 4 +- .../vBot_4.8/vBot/ingame_editor.lua | 10 +- .../default_configs/vBot_4.8/vBot/main.lua | 8 +- .../vBot_4.8/vBot/new_cavebot_lib.lua | 19 +- .../vBot_4.8/vBot/new_healer.lua | 26 +- .../vBot_4.8/vBot/new_healer.otui | 42 +-- .../vBot_4.8/vBot/npc_talk.lua | 2 +- .../vBot_4.8/vBot/playerlist.lua | 19 +- .../vBot_4.8/vBot/playerlist.otui | 2 +- .../default_configs/vBot_4.8/vBot/pushmax.lua | 9 +- .../vBot_4.8/vBot/pushmax.otui | 6 +- .../vBot_4.8/vBot/quiver_label.lua | 5 +- .../vBot_4.8/vBot/quiver_manager.lua | 6 +- .../vBot_4.8/vBot/siolist.otui | 14 +- .../vBot_4.8/vBot/spy_level.lua | 2 +- .../vBot_4.8/vBot/supplies.lua | 2 +- .../vBot_4.8/vBot/supplies.otui | 12 +- .../default_configs/vBot_4.8/vBot/tools.lua | 6 +- .../default_configs/vBot_4.8/vBot/vlib.lua | 12 +- .../vBot_4.8/vBot/xeno_menu.lua | 26 +- mods/game_bot/edit.otui | 32 +- mods/game_bot/executor.lua | 56 ++-- mods/game_bot/functions/callbacks.lua | 22 +- mods/game_bot/functions/icon.lua | 32 +- mods/game_bot/functions/main.lua | 28 +- mods/game_bot/functions/map.lua | 25 +- mods/game_bot/functions/npc.lua | 8 +- mods/game_bot/functions/player_conditions.lua | 2 +- mods/game_bot/functions/player_inventory.lua | 2 +- mods/game_bot/functions/server.lua | 2 +- mods/game_bot/functions/test.lua | 2 +- mods/game_bot/functions/tools.lua | 2 +- mods/game_bot/functions/ui.lua | 8 +- mods/game_bot/functions/ui_elements.lua | 23 +- mods/game_bot/functions/ui_legacy.lua | 18 +- mods/game_bot/functions/ui_windows.lua | 2 +- mods/game_bot/panels/attacking.lua | 2 - mods/game_bot/panels/healing.lua | 80 +++-- mods/game_bot/panels/looting.lua | 43 ++- mods/game_bot/panels/tools.lua | 6 +- mods/game_bot/panels/war.lua | 24 +- mods/game_bot/panels/waypoints.lua | 2 - mods/game_bot/ui/basic.otui | 14 +- mods/game_bot/ui/config.otui | 10 +- mods/game_bot/ui/container.otui | 2 +- mods/game_bot/ui/icons.otui | 6 +- mods/game_bot/ui/panels.otui | 51 ++-- mods/game_buttons/buttons.otui | 1 - mods/game_itemselector/itemselector.lua | 12 +- mods/game_itemselector/itemselector.otui | 4 +- modules/game_battle/battle.lua | 40 +-- modules/game_features/features.lua | 3 +- modules/gamelib/ui/uiitem.lua | 12 +- src/client/creature.cpp | 20 +- src/client/creatures.h | 2 +- src/client/declarations.h | 5 +- src/client/item.cpp | 8 +- src/client/item.h | 2 +- src/client/lightview.cpp | 49 ++- src/client/lightview.h | 1 + src/client/luafunctions.cpp | 2 - src/client/map.cpp | 72 +++-- src/client/map.h | 10 +- src/client/mapview.cpp | 281 ++++++++---------- src/client/mapview.h | 23 +- src/client/minimap.h | 2 +- src/client/protocolgameparse.cpp | 6 +- src/client/thing.h | 13 - src/client/tile.cpp | 28 +- src/client/tile.h | 4 +- src/client/uimap.cpp | 44 ++- src/client/uimap.h | 7 +- src/framework/core/adaptativeframecounter.cpp | 10 +- src/framework/core/adaptativeframecounter.h | 21 +- src/framework/core/application.h | 2 +- src/framework/core/asyncdispatcher.cpp | 20 +- src/framework/core/eventdispatcher.cpp | 19 +- src/framework/core/graphicalapplication.cpp | 98 +++--- src/framework/core/graphicalapplication.h | 15 +- src/framework/core/resourcemanager.cpp | 10 +- src/framework/core/resourcemanager.h | 6 +- src/framework/graphics/drawpool.cpp | 57 ++-- src/framework/graphics/drawpool.h | 58 ++-- src/framework/graphics/drawpoolmanager.cpp | 159 +++++----- src/framework/graphics/drawpoolmanager.h | 12 +- src/framework/graphics/framebuffer.h | 4 +- src/framework/graphics/graphics.cpp | 5 +- src/framework/graphics/painter.cpp | 2 +- src/framework/graphics/painter.h | 2 +- src/framework/graphics/shaderprogram.cpp | 3 - src/framework/graphics/shaderprogram.h | 2 - src/framework/graphics/texturemanager.h | 2 +- src/framework/luaengine/luavaluecasts.h | 70 ----- src/framework/net/protocolhttp.h | 14 +- src/framework/pch.h | 2 - src/framework/platform/platform.cpp | 4 +- src/framework/platform/platform.h | 4 +- src/framework/platform/win32window.cpp | 6 +- src/framework/sound/soundmanager.h | 6 +- src/framework/ui/uianchorlayout.h | 2 +- src/framework/ui/uimanager.cpp | 8 +- src/framework/ui/uiwidget.cpp | 4 +- src/gitinfo.h | 2 +- vc17/otclient.vcxproj | 5 +- 206 files changed, 1731 insertions(+), 1988 deletions(-) diff --git a/init.lua b/init.lua index e398b2bc0b..5f57a19ac6 100644 --- a/init.lua +++ b/init.lua @@ -8,7 +8,7 @@ Services = { g_app.setName("OTClient - Redemption"); g_app.setCompactName("otclient"); -g_app.setOrganizationName("otcr"); +g_app.setOrganizationName("otbr"); g_app.hasUpdater = function() return (Services.updater and Services.updater ~= "" and g_modules.getModule("updater")) diff --git a/mods/client_profiles/profiles.lua b/mods/client_profiles/profiles.lua index eb38948fff..12d5878ffb 100644 --- a/mods/client_profiles/profiles.lua +++ b/mods/client_profiles/profiles.lua @@ -49,7 +49,7 @@ end function setProfileOption(index) local currentProfile = g_settings.getNumber('profile') - currentProfile = tostring(currentProfile) + currentProfile = tostring(currentProfile) index = tostring(index) if currentProfile ~= index then @@ -114,7 +114,7 @@ function onProfileChange(offline) local currentProfile = g_settings.getNumber('profile') local index = g_game.getCharacterName() - + if index then settings[index] = currentProfile save() @@ -157,4 +157,4 @@ function save() "Something went wrong, file is above 100MB, won't be saved") end g_resources.writeFileContents(file, result) -end \ No newline at end of file +end diff --git a/mods/client_profiles/profiles.otmod b/mods/client_profiles/profiles.otmod index a43d72eec6..260e0c7760 100644 --- a/mods/client_profiles/profiles.otmod +++ b/mods/client_profiles/profiles.otmod @@ -8,4 +8,4 @@ Module scripts: [ profiles ] sandboxed: true @onLoad: init() - @onUnload: terminate() \ No newline at end of file + @onUnload: terminate() diff --git a/mods/client_textedit/textedit.otui b/mods/client_textedit/textedit.otui index 86d77aa199..483d5a47ed 100644 --- a/mods/client_textedit/textedit.otui +++ b/mods/client_textedit/textedit.otui @@ -23,7 +23,7 @@ TextEditWindow < MainWindow layout: type: verticalBox fit-children: true - + Label id: description text-align: center @@ -31,7 +31,7 @@ TextEditWindow < MainWindow visible: false text-wrap: true text-auto-resize: true - + ComboBox id: examples margin-bottom: 5 @@ -42,7 +42,7 @@ SinglelineTextEditWindow < TextEditWindow TextEdit id: text - + TextEditButtons MultilineTextEditWindow < TextEditWindow @@ -70,6 +70,5 @@ MultilineTextEditWindow < TextEditWindow anchors.right: parent.right pixels-scroll: true step: 10 - - TextEditButtons + TextEditButtons diff --git a/mods/game_bot/bot.lua b/mods/game_bot/bot.lua index ad7339b0fc..eb0ef84a8b 100644 --- a/mods/game_bot/bot.lua +++ b/mods/game_bot/bot.lua @@ -21,20 +21,20 @@ local configManagerUrl = "http://otclient.ovh/configs.php" function init() dofile("executor") - + g_ui.importStyle("ui/basic.otui") g_ui.importStyle("ui/panels.otui") g_ui.importStyle("ui/config.otui") g_ui.importStyle("ui/icons.otui") g_ui.importStyle("ui/container.otui") - - connect(g_game, { - onGameStart = online, - onGameEnd = offline, + + connect(g_game, { + onGameStart = online, + onGameEnd = offline, }) - - initCallbacks() - + + initCallbacks() + botButton = modules.client_topmenu.addRightGameToggleButton('botButton', tr('Bot'), '/images/topbuttons/bot', toggle, false, 99999) botButton:setOn(false) botButton:hide() @@ -46,13 +46,13 @@ function init() configList = contentsPanel.config enableButton = contentsPanel.enableButton statusLabel = contentsPanel.statusLabel - botMessages = contentsPanel.messages + botMessages = contentsPanel.messages botTabs = contentsPanel.botTabs - botTabs:setContentWidget(contentsPanel.botPanel) - + botTabs:setContentWidget(contentsPanel.botPanel) + editWindow = g_ui.displayUI('edit') editWindow:hide() - + if g_game.isOnline() then clear() online() @@ -63,16 +63,16 @@ function terminate() save() clear() - disconnect(g_game, { - onGameStart = online, - onGameEnd = offline, + disconnect(g_game, { + onGameStart = online, + onGameEnd = offline, }) - + terminateCallbacks() editWindow:destroy() botWindow:destroy() - botButton:destroy() + botButton:destroy() end function clear() @@ -82,12 +82,12 @@ function clear() -- optimization, callback is not used when not needed g_game.enableTileThingLuaCallback(false) - botTabs:clearTabs() + botTabs:clearTabs() botTabs:setOn(false) - + botMessages:destroyChildren() botMessages:updateLayout() - + for i, socket in pairs(botWebSockets) do g_http.cancel(socket) botWebSockets[i] = nil @@ -110,23 +110,22 @@ function clear() end end end - + local gameMapPanel = modules.game_interface.getMapPanel() if gameMapPanel then - gameMapPanel:unlockVisibleFloor() + gameMapPanel:unlockVisibleFloor() end - + if g_sounds then g_sounds.getChannel(SoundChannels.Bot):stop() - end + end end - function refresh() if not g_game.isOnline() then return end save() clear() - + -- create bot dir if not g_resources.directoryExists("/bot") then g_resources.makeDir("/bot") @@ -134,16 +133,16 @@ function refresh() return onError("Can't create bot directory in " .. g_resources.getWriteDir()) end end - + -- get list of configs createDefaultConfigs() - local configs = g_resources.listDirectoryFiles("/bot", false, false) - + local configs = g_resources.listDirectoryFiles("/bot", false, false) + -- clean configList.onOptionChange = nil enableButton.onClick = nil - configList:clearOptions() - + configList:clearOptions() + -- select active config based on settings local settings = g_settings.getNode('bot') or {} local index = g_game.getCharacterName() .. "_" .. g_game.getClientVersion() @@ -152,10 +151,10 @@ function refresh() enabled=false, config="" } - end - + end + -- init list and buttons - for i=1,#configs do + for i=1,#configs do configList:addOption(configs[i]) end configList:setCurrentOption(settings[index].config) @@ -163,34 +162,34 @@ function refresh() settings[index].config = configList:getCurrentOption().text settings[index].enabled = false end - + enableButton:setOn(settings[index].enabled) - + configList.onOptionChange = function(widget) settings[index].config = widget:getCurrentOption().text g_settings.setNode('bot', settings) g_settings.save() refresh() end - + enableButton.onClick = function(widget) settings[index].enabled = not settings[index].enabled g_settings.setNode('bot', settings) g_settings.save() - refresh() + refresh() end - + if not g_game.isOnline() or not settings[index].enabled then statusLabel:setOn(true) statusLabel:setText("Status: disabled\nPress off button to enable") return end - + local configName = settings[index].config -- storage botStorage = {} - + local path = "/bot/" .. configName .. "/storage/" if not g_resources.directoryExists(path) then g_resources.makeDir(path) @@ -198,8 +197,8 @@ function refresh() botStorageFile = path.."profile_" .. g_settings.getNumber('profile') .. ".json" if g_resources.fileExists(botStorageFile) then - local status, result = pcall(function() - return json.decode(g_resources.readFileContents(botStorageFile)) + local status, result = pcall(function() + return json.decode(g_resources.readFileContents(botStorageFile)) end) if not status then return onError("Error while reading storage (" .. botStorageFile .. "). To fix this problem you can delete storage.json. Details: " .. result) @@ -208,13 +207,13 @@ function refresh() end -- run script - local status, result = pcall(function() + local status, result = pcall(function() return executeBot(configName, botStorage, botTabs, message, save, refresh, botWebSockets) end ) if not status then return onError(result) end - + statusLabel:setOn(false) botExecutor = result check() @@ -224,24 +223,24 @@ function save() if not botExecutor then return end - + local settings = g_settings.getNode('bot') or {} local index = g_game.getCharacterName() .. "_" .. g_game.getClientVersion() if settings[index] == nil then return end - - local status, result = pcall(function() - return json.encode(botStorage, 2) + + local status, result = pcall(function() + return json.encode(botStorage, 2) end) if not status then return onError("Error while saving bot storage. Storage won't be saved. Details: " .. result) end - + if result:len() > 100 * 1024 * 1024 then return onError("Storage file is too big, above 100MB, it won't be saved") end - + g_resources.writeFileContents(botStorageFile, result) end @@ -280,13 +279,13 @@ function onError(message) end function edit() - local configs = g_resources.listDirectoryFiles("/bot", false, false) - editWindow.manager.upload.config:clearOptions() - for i=1,#configs do + local configs = g_resources.listDirectoryFiles("/bot", false, false) + editWindow.manager.upload.config:clearOptions() + for i=1,#configs do editWindow.manager.upload.config:addOption(configs[i]) end editWindow.manager.download.config:setText("") - + editWindow:show() editWindow:focus() editWindow:raise() @@ -317,7 +316,7 @@ function createDefaultConfigs() local contents = g_resources.fileExists(file) and g_resources.readFileContents(file) or "" if contents:len() > 0 then g_resources.writeFileContents("/bot/" .. config_name .. "/" .. baseName .. "/" .. baseName2, contents) - end + end end else local contents = g_resources.fileExists(file) and g_resources.readFileContents(file) or "" @@ -339,24 +338,24 @@ function uploadConfig() if archive:len() > 1024 * 1024 then return displayErrorBox(tr("Config upload failed"), tr("Config %s is too big, maximum size is 1024KB. Now it has %s KB.", config, math.floor(archive:len() / 1024))) end - + local infoBox = displayInfoBox(tr("Uploading config"), tr("Uploading config %s. Please wait.", config)) - + HTTP.postJSON(configManagerUrl .. "?config=" .. config:gsub("%s+", "_"), archive, function(data, err) if infoBox then infoBox:destroy() end - if err or data["error"] then + if err or data["error"] then return displayErrorBox(tr("Config upload failed"), tr("Error while upload config %s:\n%s", config, err or data["error"])) end displayInfoBox(tr("Succesful config upload"), tr("Config %s has been uploaded.\n%s", config, data["message"])) - end) + end) end function downloadConfig() local hash = editWindow.manager.download.config:getText() if hash:len() == 0 then - return displayErrorBox(tr("Config download error"), tr("Enter correct config hash")) + return displayErrorBox(tr("Config download error"), tr("Enter correct config hash")) end local infoBox = displayInfoBox(tr("Downloading config"), tr("Downloading config with hash %s. Please wait.", hash)) HTTP.download(configManagerUrl .. "?hash=" .. hash, hash .. ".zip", function(path, checksum, err) @@ -364,7 +363,7 @@ function downloadConfig() infoBox:destroy() end if err then - return displayErrorBox(tr("Config download error"), tr("Config with hash %s cannot be downloaded", hash)) + return displayErrorBox(tr("Config download error"), tr("Config with hash %s cannot be downloaded", hash)) end modules.client_textedit.show("", { title="Enter name for downloaded config", @@ -408,7 +407,7 @@ function decompressConfig(configName, archive) if not g_resources.directoryExists("/bot/" .. configName) then return onError("Can't create /bot/" .. configName .. " directory in " .. g_resources.getWriteDir()) end - + for file, contents in pairs(files) do local split = file:split("/") split[#split] = nil -- remove file name @@ -435,15 +434,15 @@ function message(category, msg) widget:setColor("red") g_logger.error("[BOT] " .. msg) elseif category == 'warn' then - widget:setText(msg) + widget:setText(msg) widget:setColor("yellow") g_logger.warning("[BOT] " .. msg) elseif category == 'info' then - widget:setText(msg) + widget:setText(msg) widget:setColor("white") g_logger.info("[BOT] " .. msg) end - + if botMessages:getChildCount() > 5 then botMessages:getFirstChild():destroy() end @@ -456,15 +455,15 @@ function check() end checkEvent = scheduleEvent(check, 10) - - local status, result = pcall(function() - return botExecutor.script() + + local status, result = pcall(function() + return botExecutor.script() end) - if not status then + if not status then botExecutor = nil -- critical return onError(result) - end - + end + -- remove old messages local widget = botMessages:getFirstChild() if widget and widget.added + 5000 < g_clock.millis() then @@ -477,10 +476,10 @@ function initCallbacks() connect(rootWidget, { onKeyDown = botKeyDown, onKeyUp = botKeyUp, - onKeyPress = botKeyPress + onKeyPress = botKeyPress }) - connect(g_game, { + connect(g_game, { onTalk = botOnTalk, onTextMessage = botOnTextMessage, onLoginAdvice = botOnLoginAdvice, @@ -499,10 +498,10 @@ function initCallbacks() onSpellCooldown = botSpellCooldown, onSpellGroupCooldown = botGroupSpellCooldown }) - + connect(Tile, { onAddThing = botAddThing, - onRemoveThing = botRemoveThing + onRemoveThing = botRemoveThing }) connect(Creature, { @@ -513,7 +512,7 @@ function initCallbacks() onTurn = botCreatureTurn, onWalk = botCreatureWalk, }) - + connect(LocalPlayer, { onPositionChange = botCreaturePositionChange, onHealthPercentChange = botCraetureHealthPercentChange, @@ -523,7 +522,7 @@ function initCallbacks() onStatesChange = botStatesChange, onInventoryChange = botInventoryChange }) - + connect(Container, { onOpen = botContainerOpen, onClose = botContainerClose, @@ -531,8 +530,8 @@ function initCallbacks() onAddItem = botContainerAddItem, onRemoveItem = botContainerRemoveItem, }) - - connect(g_map, { + + connect(g_map, { onMissle = botOnMissle, onAnimatedText = botOnAnimatedText, onStaticText = botOnStaticText @@ -543,10 +542,10 @@ function terminateCallbacks() disconnect(rootWidget, { onKeyDown = botKeyDown, onKeyUp = botKeyUp, - onKeyPress = botKeyPress + onKeyPress = botKeyPress }) - - disconnect(g_game, { + + disconnect(g_game, { onTalk = botOnTalk, onTextMessage = botOnTextMessage, onLoginAdvice = botOnLoginAdvice, @@ -563,10 +562,10 @@ function terminateCallbacks() onSpellCooldown = botSpellCooldown, onSpellGroupCooldown = botGroupSpellCooldown }) - + disconnect(Tile, { onAddThing = botAddThing, - onRemoveThing = botRemoveThing + onRemoveThing = botRemoveThing }) disconnect(Creature, { @@ -576,8 +575,8 @@ function terminateCallbacks() onHealthPercentChange = botCraetureHealthPercentChange, onTurn = botCreatureTurn, onWalk = botCreatureWalk, - }) - + }) + disconnect(LocalPlayer, { onPositionChange = botCreaturePositionChange, onHealthPercentChange = botCraetureHealthPercentChange, @@ -587,16 +586,16 @@ function terminateCallbacks() onStatesChange = botStatesChange, onInventoryChange = botInventoryChange }) - + disconnect(Container, { onOpen = botContainerOpen, onClose = botContainerClose, onUpdateItem = botContainerUpdateItem, - onAddItem = botContainerAddItem, + onAddItem = botContainerAddItem, onRemoveItem = botContainerRemoveItem }) - - disconnect(g_map, { + + disconnect(g_map, { onMissle = botOnMissle, onAnimatedText = botOnAnimatedText, onStaticText = botOnStaticText @@ -605,7 +604,7 @@ end function safeBotCall(func) local status, result = pcall(func) - if not status then + if not status then onError(result) end end @@ -796,4 +795,4 @@ end function botInventoryChange(player, slot, item, oldItem) if botExecutor == nil then return false end safeBotCall(function() botExecutor.callbacks.onInventoryChange(player, slot, item, oldItem) end) -end \ No newline at end of file +end diff --git a/mods/game_bot/bot.otui b/mods/game_bot/bot.otui index 50bc0a594f..2096ae4b23 100644 --- a/mods/game_bot/bot.otui +++ b/mods/game_bot/bot.otui @@ -3,7 +3,7 @@ BotTabBar < TabBar margin-left: 1 margin-right: 1 height: 20 - + $on: visible: true margin-top: 2 @@ -29,7 +29,7 @@ MiniWindow &save: true &autoOpen: 10 - MiniWindowContents + MiniWindowContents ComboBox id: config &menuScroll: true @@ -43,7 +43,7 @@ MiniWindow margin-left: 2 margin-right: 75 text-offset: 3 0 - + Button id: editConfig anchors.top: prev.top @@ -61,15 +61,15 @@ MiniWindow anchors.right: parent.right margin-left: 3 margin-right: 2 - + $on: text: On color: #00AA00 - + $!on: text: Off color: #FF0000 - + Label id: statusLabel anchors.top: prev.bottom @@ -81,14 +81,14 @@ MiniWindow !text: tr('Status: waiting') margin-left: 3 margin-right: 3 - + $on: margin-top: 3 - + $!on: text: margin-top: -13 - + HorizontalSeparator anchors.left: parent.left anchors.right: parent.right @@ -113,14 +113,14 @@ MiniWindow margin-top: 5 margin-left: 2 margin-right: 2 - + BotTabBar id: botTabs anchors.top: prev.bottom anchors.left: parent.left anchors.right: parent.right margin-right: -20 - + Panel id: botPanel margin-top: 2 diff --git a/mods/game_bot/default_configs/cavebot_1.3/cavebot/actions.lua b/mods/game_bot/default_configs/cavebot_1.3/cavebot/actions.lua index 64d728819f..8a35b45a04 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/cavebot/actions.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/cavebot/actions.lua @@ -41,11 +41,11 @@ CaveBot.editAction = function(widget, action, value) if not raction then return error("Invalid cavebot action: " .. action) end - + if not widget.action or not widget.value then - return error("Invalid cavebot action widget, has missing action or value") + return error("Invalid cavebot action widget, has missing action or value") end - + widget:setText(action .. ":" .. value:split("\n")[1]) widget.action = action widget.value = value @@ -63,7 +63,7 @@ prev is a true when previuos action was executed succesfully, false otherwise it must return true if executed correctly, false otherwise it can also return string "retry", then the function will be called again in 20 ms ]]-- -CaveBot.registerAction = function(action, color, callback) +CaveBot.registerAction = function(action, color, callback) action = action:lower() if CaveBot.Actions[action] then return error("Duplicated acction: " .. action) @@ -79,12 +79,12 @@ CaveBot.registerAction("label", "yellow", function(value, retries, prev) end) CaveBot.registerAction("gotolabel", "#FFFF55", function(value, retries, prev) - return CaveBot.gotoLabel(value) + return CaveBot.gotoLabel(value) end) CaveBot.registerAction("delay", "#AAAAAA", function(value, retries, prev) if retries == 0 then - CaveBot.delay(tonumber(value)) + CaveBot.delay(tonumber(value)) return "retry" end return true @@ -96,13 +96,13 @@ CaveBot.registerAction("function", "red", function(value, retries, prev) for extension, callbacks in pairs(CaveBot.Extensions) do prefix = prefix .. "local " .. extension .. " = CaveBot.Extensions." .. extension .. "\n" end - local status, result = pcall(function() + local status, result = pcall(function() return assert(load(prefix .. value, "cavebot_function"))() end) if not status then error("Error in cavebot function:\n" .. result) return false - end + end return result end) @@ -112,7 +112,7 @@ CaveBot.registerAction("goto", "green", function(value, retries, prev) error("Invalid cavebot goto action value. It should be position (x,y,z), is: " .. value) return false end - + if CaveBot.Config.get("mapClick") then if retries >= 5 then return false -- tried 5 times, can't get there @@ -120,23 +120,23 @@ CaveBot.registerAction("goto", "green", function(value, retries, prev) else if retries >= 100 then return false -- tried 100 times, can't get there - end + end end local precision = tonumber(pos[1][5]) - pos = {x=tonumber(pos[1][2]), y=tonumber(pos[1][3]), z=tonumber(pos[1][4])} + pos = {x=tonumber(pos[1][2]), y=tonumber(pos[1][3]), z=tonumber(pos[1][4])} local playerPos = player:getPosition() - if pos.z ~= playerPos.z then + if pos.z ~= playerPos.z then return false -- different floor end - + if math.abs(pos.x-playerPos.x) + math.abs(pos.y-playerPos.y) > 40 then return false -- too far way end local minimapColor = g_map.getMinimapColor(pos) local stairs = (minimapColor >= 210 and minimapColor <= 213) - + if stairs then if math.abs(pos.x-playerPos.x) == 0 and math.abs(pos.y-playerPos.y) <= 0 then return true -- already at position @@ -149,17 +149,17 @@ CaveBot.registerAction("goto", "green", function(value, retries, prev) if not path then return false -- there's no way end - + -- try to find path, don't ignore creatures, don't ignore fields if not CaveBot.Config.get("ignoreFields") and CaveBot.walkTo(pos, 40) then return "retry" end - + -- try to find path, don't ignore creatures, ignore fields if CaveBot.walkTo(pos, 40, { ignoreNonPathable = true }) then return "retry" end - + if retries >= 3 then -- try to lower precision, find something close to final position local precison = retries - 1 @@ -168,13 +168,13 @@ CaveBot.registerAction("goto", "green", function(value, retries, prev) end if CaveBot.walkTo(pos, 50, { ignoreNonPathable = true, precision = precison }) then return "retry" - end + end end - + if not CaveBot.Config.get("mapClick") and retries >= 5 then return false end - + if CaveBot.Config.get("skipBlocked") then return false end @@ -196,9 +196,9 @@ CaveBot.registerAction("use", "#FFB272", function(value, retries, prev) return true end - pos = {x=tonumber(pos[1][2]), y=tonumber(pos[1][3]), z=tonumber(pos[1][4])} + pos = {x=tonumber(pos[1][2]), y=tonumber(pos[1][3]), z=tonumber(pos[1][4])} local playerPos = player:getPosition() - if pos.z ~= playerPos.z then + if pos.z ~= playerPos.z then return false -- different floor end @@ -233,9 +233,9 @@ CaveBot.registerAction("usewith", "#EEB292", function(value, retries, prev) end local itemid = tonumber(pos[1][2]) - pos = {x=tonumber(pos[1][3]), y=tonumber(pos[1][4]), z=tonumber(pos[1][5])} + pos = {x=tonumber(pos[1][3]), y=tonumber(pos[1][4]), z=tonumber(pos[1][5])} local playerPos = player:getPosition() - if pos.z ~= playerPos.z then + if pos.z ~= playerPos.z then return false -- different floor end diff --git a/mods/game_bot/default_configs/cavebot_1.3/cavebot/cavebot.lua b/mods/game_bot/default_configs/cavebot_1.3/cavebot/cavebot.lua index a00ee716fb..1ac2d1fd8a 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/cavebot/cavebot.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/cavebot/cavebot.lua @@ -28,18 +28,18 @@ cavebotMacro = macro(20, function() CaveBot.resetWalking() return -- target bot or looting is working, wait end - + if CaveBot.doWalking() then return -- executing walking end - + local actions = ui.list:getChildCount() if actions == 0 then return end local currentAction = ui.list:getFocusedChild() if not currentAction then currentAction = ui.list:getFirstChild() end - local action = CaveBot.Actions[currentAction.action] + local action = CaveBot.Actions[currentAction.action] local value = currentAction.value local retry = false if action then @@ -59,15 +59,15 @@ cavebotMacro = macro(20, function() end else error("Error while executing cavebot action (" .. currentAction.action .. "):\n" .. result) - end + end else error("Invalid cavebot action: " .. currentAction.action) end - + if retry then return end - + if currentAction ~= ui.list:getFocusedChild() then -- focused child can change durring action, get it again and reset state currentAction = ui.list:getFocusedChild() or ui.list:getFirstChild() @@ -87,13 +87,13 @@ config = Config.setup("cavebot_configs", configWidget, "cfg", function(name, ena if enabled and CaveBot.Recorder.isOn() then CaveBot.Recorder.disable() CaveBot.setOff() - return + return end local currentActionIndex = ui.list:getChildIndex(ui.list:getFocusedChild()) ui.list:destroyChildren() if not data then return cavebotMacro.setOff() end - + local cavebotConfig = nil for k,v in ipairs(data) do if type(v) == "table" and #v == 2 then @@ -126,17 +126,17 @@ config = Config.setup("cavebot_configs", configWidget, "cfg", function(name, ena end CaveBot.Config.onConfigChange(name, enabled, cavebotConfig) - + actionRetries = 0 CaveBot.resetWalking() prevActionResult = true cavebotMacro.setOn(enabled) cavebotMacro.delay = nil - if lastConfig == name then + if lastConfig == name then -- restore focused child on the action list ui.list:focusChild(ui.list:getChildByIndex(currentActionIndex)) end - lastConfig = name + lastConfig = name end) -- ui callbacks @@ -172,14 +172,14 @@ CaveBot.isOff = function() end CaveBot.setOn = function(val) - if val == false then + if val == false then return CaveBot.setOff(true) end config.setOn() end CaveBot.setOff = function(val) - if val == false then + if val == false then return CaveBot.setOn(true) end config.setOff() @@ -192,7 +192,7 @@ end CaveBot.gotoLabel = function(label) label = label:lower() for index, child in ipairs(ui.list:getChildren()) do - if child.action == "label" and child.value:lower() == label then + if child.action == "label" and child.value:lower() == label then ui.list:focusChild(child) return true end @@ -205,11 +205,11 @@ CaveBot.save = function() for index, child in ipairs(ui.list:getChildren()) do table.insert(data, {child.action, child.value}) end - + if CaveBot.Config then table.insert(data, {"config", json.encode(CaveBot.Config.save())}) end - + local extension_data = {} for extension, callbacks in pairs(CaveBot.Extensions) do if callbacks.onSave then diff --git a/mods/game_bot/default_configs/cavebot_1.3/cavebot/cavebot.otui b/mods/game_bot/default_configs/cavebot_1.3/cavebot/cavebot.otui index b92ed05fb9..f27857bd98 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/cavebot/cavebot.otui +++ b/mods/game_bot/default_configs/cavebot_1.3/cavebot/cavebot.otui @@ -6,7 +6,6 @@ CaveBotAction < Label $focus: background-color: #00000055 - CaveBotPanel < Panel layout: type: verticalBox @@ -15,7 +14,7 @@ CaveBotPanel < Panel HorizontalSeparator margin-top: 2 margin-bottom: 5 - + Panel id: listPanel height: 100 @@ -28,7 +27,7 @@ CaveBotPanel < Panel margin-right: 15 focusable: false auto-focus: first - + VerticalScrollBar id: listScrollbar anchors.top: parent.top @@ -36,23 +35,23 @@ CaveBotPanel < Panel anchors.right: parent.right pixels-scroll: true step: 10 - + BotSwitch id: showEditor margin-top: 2 - + $on: text: Hide waypoints editor - + $!on: text: Show waypoints editor BotSwitch id: showConfig margin-top: 2 - + $on: text: Hide config - + $!on: - text: Show config \ No newline at end of file + text: Show config diff --git a/mods/game_bot/default_configs/cavebot_1.3/cavebot/config.lua b/mods/game_bot/default_configs/cavebot_1.3/cavebot/config.lua index 549f663c2d..78d2c2d39c 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/cavebot/config.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/cavebot/config.lua @@ -8,13 +8,13 @@ CaveBot.Config.setup = function() CaveBot.Config.ui = UI.createWidget("CaveBotConfigPanel") local ui = CaveBot.Config.ui local add = CaveBot.Config.add - + add("ping", "Server ping", 100) add("walkDelay", "Walk delay", 10) add("mapClick", "Use map click", false) add("mapClickDelay", "Map click delay", 100) - add("ignoreFields", "Ignore fields", false) - add("skipBlocked", "Skip blocked path", false) + add("ignoreFields", "Ignore fields", false) + add("skipBlocked", "Skip blocked path", false) add("useDelay", "Delay after use", 400) end @@ -46,7 +46,7 @@ CaveBot.Config.add = function(id, title, defaultValue) if CaveBot.Config.values[id] then return error("Duplicated config key: " .. id) end - + local panel local setter -- sets value if type(defaultValue) == "number" then @@ -76,11 +76,11 @@ CaveBot.Config.add = function(id, title, defaultValue) CaveBot.save() end else - return error("Invalid default value of config for key " .. id .. ", should be number or boolean") + return error("Invalid default value of config for key " .. id .. ", should be number or boolean") end - + panel.title:setText(tr(title) .. ":") - + CaveBot.Config.value_setters[id] = setter CaveBot.Config.values[id] = defaultValue CaveBot.Config.default_values[id] = defaultValue @@ -91,4 +91,4 @@ CaveBot.Config.get = function(id) return error("Invalid CaveBot.Config.get, id: " .. id) end return CaveBot.Config.values[id] -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/cavebot_1.3/cavebot/config.otui b/mods/game_bot/default_configs/cavebot_1.3/cavebot/config.otui index 21d479dd60..cd07947c21 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/cavebot/config.otui +++ b/mods/game_bot/default_configs/cavebot_1.3/cavebot/config.otui @@ -1,11 +1,11 @@ CaveBotConfigPanel < Panel id: cavebotEditor visible: false - + layout: type: verticalBox fit-children: true - + HorizontalSeparator margin-top: 5 @@ -17,7 +17,7 @@ CaveBotConfigPanel < Panel CaveBotConfigNumberValuePanel < Panel height: 20 margin-top: 5 - + BotTextEdit id: value anchors.right: parent.right @@ -35,7 +35,7 @@ CaveBotConfigNumberValuePanel < Panel CaveBotConfigBooleanValuePanel < Panel height: 20 margin-top: 5 - + BotSwitch id: value anchors.right: parent.right @@ -43,10 +43,10 @@ CaveBotConfigBooleanValuePanel < Panel anchors.bottom: parent.bottom margin-right: 5 width: 50 - + $on: text: On - + $!on: text: Off @@ -54,4 +54,4 @@ CaveBotConfigBooleanValuePanel < Panel id: title anchors.left: parent.left anchors.verticalCenter: prev.verticalCenter - margin-left: 5 \ No newline at end of file + margin-left: 5 diff --git a/mods/game_bot/default_configs/cavebot_1.3/cavebot/depositer.lua b/mods/game_bot/default_configs/cavebot_1.3/cavebot/depositer.lua index d397c47e7d..32ef3e96a5 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/cavebot/depositer.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/cavebot/depositer.lua @@ -11,7 +11,7 @@ end -- called when cavebot config changes, configData is a table but it can be nil CaveBot.Extensions.Depositer.onConfigChange = function(configName, isEnabled, configData) if not configData then return end - + end -- called when cavebot is saving config, should return table or nil diff --git a/mods/game_bot/default_configs/cavebot_1.3/cavebot/editor.lua b/mods/game_bot/default_configs/cavebot_1.3/cavebot/editor.lua index 1fb4e766d8..205e47dd74 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/cavebot/editor.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/cavebot/editor.lua @@ -19,13 +19,13 @@ CaveBot.Editor.registerAction = function(action, text, params) CaveBot.Editor.Actions[action] = params color = raction.color end - + local button = UI.createWidget('CaveBotEditorButton', CaveBot.Editor.ui.buttons) button:setText(text) if color then button:setColor(color) end - button.onClick = function() + button.onClick = function() if type(params) == 'function' then params() return @@ -79,12 +79,12 @@ CaveBot.Editor.setup = function() action:destroy() CaveBot.save() end) - + registerAction("label", { value="labelName", title="Label", description="Add label", - multiline=false + multiline=false }) registerAction("delay", { value="500", @@ -97,7 +97,7 @@ CaveBot.Editor.setup = function() value="labelName", title="Go to label", description="Go to label", - multiline=false + multiline=false }) registerAction("goto", "go to", { value=function() return posx() .. "," .. posy() .. "," .. posz() end, @@ -110,8 +110,8 @@ CaveBot.Editor.setup = function() value=function() return posx() .. "," .. posy() .. "," .. posz() end, title="Use", description="Use item from position (x,y,z) or from inventory (itemId)", - multiline=false - }) + multiline=false + }) registerAction("usewith", "use with", { value=function() return "itemId," .. posx() .. "," .. posy() .. "," .. posz() end, title="Use with", @@ -123,8 +123,8 @@ CaveBot.Editor.setup = function() value="text", title="Say", description="Enter text to say", - multiline=false - }) + multiline=false + }) registerAction("function", { title="Edit bot function", multiline=true, @@ -132,7 +132,7 @@ CaveBot.Editor.setup = function() examples=CaveBot.Editor.ExampleFunctions, width=650 }) - + ui.autoRecording.onClick = function() if ui.autoRecording:isOn() then CaveBot.Recorder.disable() @@ -140,12 +140,12 @@ CaveBot.Editor.setup = function() CaveBot.Recorder.enable() end end - + -- callbacks onPlayerPositionChange(function(pos) - ui.pos:setText("Position: " .. pos.x .. ", " .. pos.y .. ", " .. pos.z) + ui.pos:setText("Position: " .. pos.x .. ", " .. pos.y .. ", " .. pos.z) end) - ui.pos:setText("Position: " .. posx() .. ", " .. posy() .. ", " .. posz()) + ui.pos:setText("Position: " .. posx() .. ", " .. posy() .. ", " .. posz()) end CaveBot.Editor.show = function() @@ -170,5 +170,5 @@ CaveBot.Editor.edit = function(action, value, callback) -- callback = function(a UI.EditorWindow(value, params, function(newText) callback(action, newText) - end) + end) end diff --git a/mods/game_bot/default_configs/cavebot_1.3/cavebot/editor.otui b/mods/game_bot/default_configs/cavebot_1.3/cavebot/editor.otui index d11288c64d..77d63e8fa9 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/cavebot/editor.otui +++ b/mods/game_bot/default_configs/cavebot_1.3/cavebot/editor.otui @@ -1,18 +1,17 @@ CaveBotEditorButton < Button - CaveBotEditorPanel < Panel id: cavebotEditor visible: false layout: type: verticalBox fit-children: true - + Label id: pos text-align: center text: - - + Panel id: buttons margin-top: 2 diff --git a/mods/game_bot/default_configs/cavebot_1.3/cavebot/example_functions.lua b/mods/game_bot/default_configs/cavebot_1.3/cavebot/example_functions.lua index 556129c11d..0f891150d6 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/cavebot/example_functions.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/cavebot/example_functions.lua @@ -23,8 +23,8 @@ return true addExampleFunction("buy 200 mana potion from npc Eryn", [[ --buy 200 mana potions local npc = getCreatureByName("Eryn") -if not npc then - return false +if not npc then + return false end if retries > 10 then return false @@ -87,4 +87,4 @@ addExampleFunction("Logout", [[ g_game.safeLogout() delay(1000) return "retry" -]]) \ No newline at end of file +]]) diff --git a/mods/game_bot/default_configs/cavebot_1.3/cavebot/extension_template.lua b/mods/game_bot/default_configs/cavebot_1.3/cavebot/extension_template.lua index d015f11beb..6e595cd6b8 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/cavebot/extension_template.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/cavebot/extension_template.lua @@ -28,7 +28,7 @@ CaveBot.Extensions.Example.setup = function() title="Say hello", description="Says hello x times", validation="[0-9]{1,5}" -- regex, optional - }) + }) end -- called when cavebot config changes, configData is a table but it can also be nil diff --git a/mods/game_bot/default_configs/cavebot_1.3/cavebot/recorder.lua b/mods/game_bot/default_configs/cavebot_1.3/cavebot/recorder.lua index 27206ba14b..e7f8712092 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/cavebot/recorder.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/cavebot/recorder.lua @@ -11,7 +11,7 @@ local function setup() end onPlayerPositionChange(function(newPos, oldPos) - if CaveBot.isOn() or not isEnabled then return end + if CaveBot.isOn() or not isEnabled then return end if not lastPos then -- first step addPosition(oldPos) @@ -23,15 +23,15 @@ local function setup() addPosition(newPos) end end) - + onUse(function(pos, itemId, stackPos, subType) if CaveBot.isOn() or not isEnabled then return end - if pos.x ~= 0xFFFF then + if pos.x ~= 0xFFFF then lastPos = pos CaveBot.addAction("use", pos.x .. "," .. pos.y .. "," .. pos.z, true) end end) - + onUseWith(function(pos, itemId, target, subType) if CaveBot.isOn() or not isEnabled then return end if not target:isItem() then return end @@ -62,4 +62,4 @@ CaveBot.Recorder.disable = function() end CaveBot.Editor.ui.autoRecording:setOn(false) CaveBot.save() -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/cavebot_1.3/cavebot/supply.lua b/mods/game_bot/default_configs/cavebot_1.3/cavebot/supply.lua index b3cd4ca207..be3a33ccd5 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/cavebot/supply.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/cavebot/supply.lua @@ -14,7 +14,7 @@ end -- called when cavebot config changes, configData is a table but it can be nil CaveBot.Extensions.Supply.onConfigChange = function(configName, isEnabled, configData) if not configData then return end - + end -- called when cavebot is saving config, should return table or nil diff --git a/mods/game_bot/default_configs/cavebot_1.3/cavebot/supply.otui b/mods/game_bot/default_configs/cavebot_1.3/cavebot/supply.otui index 83c76ac794..233cf2e148 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/cavebot/supply.otui +++ b/mods/game_bot/default_configs/cavebot_1.3/cavebot/supply.otui @@ -1,13 +1,13 @@ SupplyItem < Panel height: 34 - + BotItem id: item - size: 32 32 + size: 32 32 anchors.left: parent.left anchors.top: parent.top margin-top: 1 - + Panel id: fields anchors.top: parent.top @@ -16,7 +16,7 @@ SupplyItem < Panel anchors.right: parent.right margin-left: 2 margin-right: 2 - + Label id: minLabel anchors.top: parent.top diff --git a/mods/game_bot/default_configs/cavebot_1.3/cavebot/walking.lua b/mods/game_bot/default_configs/cavebot_1.3/cavebot/walking.lua index c8a713366b..38e16b01e2 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/cavebot/walking.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/cavebot/walking.lua @@ -28,13 +28,13 @@ CaveBot.doWalking = function() CaveBot.delay(CaveBot.Config.get("walkDelay") + player:getStepDuration(false, dir)) return true end - return false + return false end -- called when player position has been changed (step has been confirmed by server) onPlayerPositionChange(function(newPos, oldPos) if not oldPos or not newPos then return end - + local dirs = {{NorthWest, North, NorthEast}, {West, 8, East}, {SouthWest, South, SouthEast}} local dir = dirs[newPos.y - oldPos.y + 2] if dir then @@ -50,7 +50,7 @@ onPlayerPositionChange(function(newPos, oldPos) CaveBot.delay(CaveBot.Config.get("ping") + player:getStepDuration(false, dir) + 150) return end - + if expectedDirs[1] ~= dir then if CaveBot.Config.get("mapClick") then CaveBot.delay(CaveBot.Config.get("walkDelay") + player:getStepDuration(false, dir)) @@ -59,8 +59,8 @@ onPlayerPositionChange(function(newPos, oldPos) end return end - - table.remove(expectedDirs, 1) + + table.remove(expectedDirs, 1) if CaveBot.Config.get("mapClick") and #expectedDirs > 0 then CaveBot.delay(CaveBot.Config.get("mapClickDelay") + player:getStepDuration(false, dir)) end @@ -72,7 +72,7 @@ CaveBot.walkTo = function(dest, maxDist, params) return false end local dir = path[1] - + if CaveBot.Config.get("mapClick") then local ret = autoWalk(path) if ret then @@ -82,9 +82,9 @@ CaveBot.walkTo = function(dest, maxDist, params) end return ret end - + g_game.walk(dir, false) - isWalking = true + isWalking = true walkPath = path walkPathIter = 2 expectedDirs = { dir } diff --git a/mods/game_bot/default_configs/cavebot_1.3/hp.lua b/mods/game_bot/default_configs/cavebot_1.3/hp.lua index 88b44d1b46..661e140068 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/hp.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/hp.lua @@ -21,7 +21,7 @@ for _, healingInfo in ipairs({storage.healing1, storage.healing2}) do local healingmacro = macro(20, function() local hp = player:getHealthPercent() if healingInfo.max >= hp and hp >= healingInfo.min then - if TargetBot then + if TargetBot then TargetBot.saySpell(healingInfo.text) -- sync spell with targetbot if available else say(healingInfo.text) @@ -30,7 +30,7 @@ for _, healingInfo in ipairs({storage.healing1, storage.healing2}) do end) healingmacro.setOn(healingInfo.on) - UI.DualScrollPanel(healingInfo, function(widget, newParams) + UI.DualScrollPanel(healingInfo, function(widget, newParams) healingInfo = newParams healingmacro.setOn(healingInfo.on) end) @@ -57,7 +57,7 @@ for i, healingInfo in ipairs({storage.hpitem1, storage.hpitem2, storage.manaitem local healingmacro = macro(20, function() local hp = i <= 2 and player:getHealthPercent() or math.min(100, math.floor(100 * (player:getMana() / player:getMaxMana()))) if healingInfo.max >= hp and hp >= healingInfo.min then - if TargetBot then + if TargetBot then TargetBot.useItem(healingInfo.item, healingInfo.subType, player) -- sync spell with targetbot if available else local thing = g_things.getThingType(healingInfo.item) @@ -71,7 +71,7 @@ for i, healingInfo in ipairs({storage.hpitem1, storage.hpitem2, storage.manaitem end) healingmacro.setOn(healingInfo.on) - UI.DualScrollItemPanel(healingInfo, function(widget, newParams) + UI.DualScrollItemPanel(healingInfo, function(widget, newParams) healingInfo = newParams healingmacro.setOn(healingInfo.on and healingInfo.item > 100) end) @@ -89,9 +89,9 @@ UI.TextEdit(storage.manaShield or "utamo vita", function(widget, newText) end) local lastManaShield = 0 -macro(20, "mana shield", function() +macro(20, "mana shield", function() if hasManaShield() or lastManaShield + 90000 > now then return end - if TargetBot then + if TargetBot then TargetBot.saySpell(storage.manaShield) -- sync spell with targetbot if available else say(storage.manaShield) @@ -103,9 +103,9 @@ UI.TextEdit(storage.hasteSpell or "utani hur", function(widget, newText) storage.hasteSpell = newText end) -macro(500, "haste", function() +macro(500, "haste", function() if hasHaste() then return end - if TargetBot then + if TargetBot then TargetBot.saySpell(storage.hasteSpell) -- sync spell with targetbot if available else say(storage.hasteSpell) @@ -117,9 +117,9 @@ UI.TextEdit(storage.antiParalyze or "utani hur", function(widget, newText) storage.antiParalyze = newText end) -macro(100, "anti paralyze", function() +macro(100, "anti paralyze", function() if not isParalyzed() then return end - if TargetBot then + if TargetBot then TargetBot.saySpell(storage.antiParalyze) -- sync spell with targetbot if available else say(storage.antiParalyze) @@ -181,7 +181,7 @@ macro(250, function() for __, item in ipairs(container:getItems()) do if item:getId() == autoEquip.item1 or item:getId() == autoEquip.item2 then g_game.move(item, {x=65535, y=autoEquip.slot, z=0}, item:getCount()) - delay(1000) -- don't call it too often + delay(1000) -- don't call it too often return end end @@ -189,4 +189,4 @@ macro(250, function() end end end -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/cavebot_1.3/main.lua b/mods/game_bot/default_configs/cavebot_1.3/main.lua index 57b7ca6ead..93ae8178b6 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/main.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/main.lua @@ -4,9 +4,6 @@ VERSION = "1.3" UI.Label("Config version: " .. VERSION) UI.Separator() - - - UI.Separator() UI.Button("Discord", function() diff --git a/mods/game_bot/default_configs/cavebot_1.3/mwall_timer.lua b/mods/game_bot/default_configs/cavebot_1.3/mwall_timer.lua index 6dc1ec48b0..919ab2f329 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/mwall_timer.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/mwall_timer.lua @@ -21,9 +21,9 @@ onAddThing(function(tile, thing) else return end - + local pos = tile:getPosition().x .. "," .. tile:getPosition().y .. "," .. tile:getPosition().z - if not activeTimers[pos] or activeTimers[pos] < now then + if not activeTimers[pos] or activeTimers[pos] < now then activeTimers[pos] = now + timer end tile:setTimer(activeTimers[pos] - now) @@ -37,5 +37,5 @@ onRemoveThing(function(tile, thing) local pos = tile:getPosition().x .. "," .. tile:getPosition().y .. "," .. tile:getPosition().z activeTimers[pos] = nil tile:setTimer(0) - end + end end) diff --git a/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature.lua b/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature.lua index d4dd545959..22d30e1fcc 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature.lua @@ -1,4 +1,3 @@ - TargetBot.Creature = {} TargetBot.Creature.configsCache = {} TargetBot.Creature.cached = 0 @@ -25,7 +24,7 @@ TargetBot.Creature.addConfig = function(config, focus) if config.regex:len() > 0 then config.regex = config.regex .. "|" end - config.regex = config.regex .. "^" .. part:trim():lower():gsub("%*", ".*"):gsub("%?", ".?") .. "$" + config.regex = config.regex .. "^" .. part:trim():lower():gsub("%*", ".*"):gsub("%?", ".?") .. "$" end end @@ -64,7 +63,7 @@ TargetBot.Creature.getConfigs = function(creature) table.insert(configs, config.value) end end - if TargetBot.Creature.cached > 1000 then + if TargetBot.Creature.cached > 1000 then TargetBot.Creature.resetConfigsCache() -- too big cache size, reset end TargetBot.Creature.configsCache[name] = configs -- add to cache diff --git a/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature_attack.lua b/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature_attack.lua index 048c07c65b..98e1ac4651 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature_attack.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature_attack.lua @@ -5,7 +5,7 @@ TargetBot.Creature.attack = function(params, targets, isLooting) -- params {conf local config = params.config local creature = params.creature - + if g_game.getAttackingCreature() ~= creature then g_game.attack(creature) end @@ -66,7 +66,7 @@ end TargetBot.Creature.walk = function(creature, config, targets) local cpos = creature:getPosition() local pos = player:getPosition() - + local isTrapped = true local pos = player:getPosition() local dirs = {{-1,1}, {0,1}, {1,1}, {-1, 0}, {1, 0}, {-1, -1}, {0, -1}, {1, -1}} @@ -76,7 +76,7 @@ TargetBot.Creature.walk = function(creature, config, targets) isTrapped = false end end - + -- luring if TargetBot.canLure() and (config.lure or config.lureCavebot) and not (config.chase and creature:getHealthPercent() < 30) and not isTrapped then local monsters = 0 diff --git a/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature_editor.lua b/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature_editor.lua index 8d92db0b9b..5689057041 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature_editor.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature_editor.lua @@ -68,7 +68,7 @@ TargetBot.Creature.edit = function(config, callback) -- callback = function(newC if newConfig.regex:len() > 0 then newConfig.regex = newConfig.regex .. "|" end - newConfig.regex = newConfig.regex .. "^" .. part:trim():lower():gsub("%*", ".*"):gsub("%?", ".?") .. "$" + newConfig.regex = newConfig.regex .. "^" .. part:trim():lower():gsub("%*", ".*"):gsub("%?", ".?") .. "$" end editor:destroy() diff --git a/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature_editor.otui b/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature_editor.otui index 24f3da6146..df2f8ca574 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature_editor.otui +++ b/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature_editor.otui @@ -8,7 +8,7 @@ TargetBotCreatureEditorScrollBar < Panel anchors.right: parent.right anchors.top: parent.top text-align: center - + HorizontalScrollBar id: scroll anchors.left: parent.left @@ -29,7 +29,7 @@ TargetBotCreatureEditorTextEdit < Panel anchors.right: parent.right anchors.top: parent.top text-align: center - + TextEdit id: textEdit anchors.left: parent.left @@ -56,7 +56,6 @@ TargetBotCreatureEditorItem < Panel anchors.top: parent.top anchors.right: parent.right - TargetBotCreatureEditorCheckBox < BotSwitch height: 20 margin-top: 7 @@ -65,7 +64,7 @@ TargetBotCreatureEditorWindow < MainWindow text: TargetBot creature editor width: 500 height: 630 - + $mobile: height: 300 @@ -82,7 +81,7 @@ TargetBotCreatureEditorWindow < MainWindow anchors.top: prev.bottom text-align: center !text: tr('You can also enter multiple targets, separate them by ,') - + TextEdit id: name anchors.top: prev.bottom @@ -115,7 +114,7 @@ TargetBotCreatureEditorWindow < MainWindow anchors.bottom: help.top vertical-scrollbar: contentScroll margin-bottom: 10 - + Panel id: left anchors.top: parent.top @@ -139,7 +138,7 @@ TargetBotCreatureEditorWindow < MainWindow layout: type: verticalBox fit-children: true - + Button id: help !text: tr('Help & Tutorials') diff --git a/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature_priority.lua b/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature_priority.lua index dcc2f81fed..d19fc7f343 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature_priority.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/targetbot/creature_priority.lua @@ -14,7 +14,7 @@ TargetBot.Creature.calculatePriority = function(creature, config, path) -- add config priority priority = priority + config.priority - + -- extra priority for close distance local path_length = #path if path_length == 1 then @@ -37,4 +37,4 @@ TargetBot.Creature.calculatePriority = function(creature, config, path) end return priority -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/cavebot_1.3/targetbot/looting.lua b/mods/game_bot/default_configs/cavebot_1.3/targetbot/looting.lua index 451450fc73..21298c8f8f 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/targetbot/looting.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/targetbot/looting.lua @@ -11,7 +11,7 @@ local dontSave = false TargetBot.Looting.setup = function() ui = UI.createWidget("TargetBotLootingPanel") UI.Container(TargetBot.Looting.onItemsUpdate, true, nil, ui.items) - UI.Container(TargetBot.Looting.onContainersUpdate, true, nil, ui.containers) + UI.Container(TargetBot.Looting.onContainersUpdate, true, nil, ui.containers) ui.everyItem.onClick = function() ui.everyItem:setOn(not ui.everyItem:isOn()) TargetBot.save() @@ -241,11 +241,11 @@ TargetBot.Looting.lootContainer = function(lootContainers, container) return end end - + -- looting finished, remove container from list container.lootContainer = false g_game.close(container) - table.remove(TargetBot.Looting.list, 1) + table.remove(TargetBot.Looting.list, 1) end TargetBot.Looting.lootItem = function(lootContainers, item) diff --git a/mods/game_bot/default_configs/cavebot_1.3/targetbot/looting.otui b/mods/game_bot/default_configs/cavebot_1.3/targetbot/looting.otui index 97cb351d15..dde8b2e252 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/targetbot/looting.otui +++ b/mods/game_bot/default_configs/cavebot_1.3/targetbot/looting.otui @@ -9,12 +9,12 @@ TargetBotLootingPanel < Panel Label margin-top: 5 text: Items to loot - text-align: center + text-align: center BotContainer id: items margin-top: 3 - + BotSwitch id: everyItem !text: tr("Loot every item") @@ -29,12 +29,12 @@ TargetBotLootingPanel < Panel id: containers margin-top: 3 height: 45 - + Panel id: maxDangerPanel height: 20 margin-top: 5 - + BotTextEdit id: value anchors.right: parent.right @@ -53,7 +53,7 @@ TargetBotLootingPanel < Panel id: minCapacityPanel height: 20 margin-top: 3 - + BotTextEdit id: value anchors.right: parent.right diff --git a/mods/game_bot/default_configs/cavebot_1.3/targetbot/target.lua b/mods/game_bot/default_configs/cavebot_1.3/targetbot/target.lua index adcd20e01d..9bf04f6ead 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/targetbot/target.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/targetbot/target.lua @@ -71,7 +71,7 @@ targetbotMacro = macro(100, function() if highestPriorityParams and not isInPz() then ui.target.right:setText(highestPriorityParams.creature:getName()) ui.config.right:setText(highestPriorityParams.config.name) - TargetBot.Creature.attack(highestPriorityParams, targets, looting) + TargetBot.Creature.attack(highestPriorityParams, targets, looting) if lootingStatus:len() > 0 then TargetBot.setStatus("Attack & " .. lootingStatus) elseif cavebotAllowance > now then @@ -79,7 +79,7 @@ targetbotMacro = macro(100, function() else TargetBot.setStatus("Attacking") if not lureEnabled then - TargetBot.setStatus("Attacking (luring off)") + TargetBot.setStatus("Attacking (luring off)") end end TargetBot.walk() @@ -104,7 +104,7 @@ end) config = Config.setup("targetbot_configs", configWidget, "json", function(name, enabled, data) if not data then ui.status.right:setText("Off") - return targetbotMacro.setOff() + return targetbotMacro.setOff() end TargetBot.Creature.resetConfigs() for _, value in ipairs(data["targeting"] or {}) do @@ -173,14 +173,14 @@ TargetBot.isOff = function() end TargetBot.setOn = function(val) - if val == false then + if val == false then return TargetBot.setOff(true) end config.setOn() end TargetBot.setOff = function(val) - if val == false then + if val == false then return TargetBot.setOn(true) end config.setOff() @@ -211,7 +211,6 @@ TargetBot.enableLuring = function() lureEnabled = true end - -- attacks local lastSpell = 0 local lastAttackSpell = 0 @@ -272,7 +271,7 @@ TargetBot.useAttackItem = function(item, subType, target, delay) if g_game.getClientVersion() < 780 then local tmpItem = g_game.findPlayerItem(item, subType) if not tmpItem then return end - g_game.useWith(tmpItem, target, subType) -- using item from bp + g_game.useWith(tmpItem, target, subType) -- using item from bp else g_game.useInventoryItemWith(item, target, subType) -- hotkey end @@ -282,4 +281,4 @@ end TargetBot.canLure = function() return lureEnabled -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/cavebot_1.3/targetbot/target.otui b/mods/game_bot/default_configs/cavebot_1.3/targetbot/target.otui index 6e0e4eafa5..2b91f01912 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/targetbot/target.otui +++ b/mods/game_bot/default_configs/cavebot_1.3/targetbot/target.otui @@ -52,7 +52,7 @@ TargetBotPanel < Panel margin-right: 15 focusable: false auto-focus: first - + VerticalScrollBar id: listScrollbar anchors.top: parent.top @@ -60,7 +60,7 @@ TargetBotPanel < Panel anchors.right: parent.right pixels-scroll: true step: 10 - + BotSwitch id: configButton @onClick: | @@ -73,7 +73,7 @@ TargetBotPanel < Panel $!on: text: Show target editor - + Panel id: editor visible: false @@ -109,7 +109,7 @@ TargetBotPanel < Panel anchors.right: parent.right text: Remove width: 56 - + BotSwitch id: debug text: Show target priority diff --git a/mods/game_bot/default_configs/cavebot_1.3/targetbot/walking.lua b/mods/game_bot/default_configs/cavebot_1.3/targetbot/walking.lua index b256d6acf4..f4da77ea4c 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/targetbot/walking.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/targetbot/walking.lua @@ -17,7 +17,7 @@ TargetBot.walk = function() local dist = math.max(math.abs(pos.x-dest.x), math.abs(pos.y-dest.y)) if params.precision and params.precision >= dist then return end if params.marginMin and params.marginMax then - if dist >= params.marginMin and dist <= params.marginMax then + if dist >= params.marginMin and dist <= params.marginMax then return end end diff --git a/mods/game_bot/default_configs/cavebot_1.3/tools.lua b/mods/game_bot/default_configs/cavebot_1.3/tools.lua index 7621ab0138..629a9ca36e 100644 --- a/mods/game_bot/default_configs/cavebot_1.3/tools.lua +++ b/mods/game_bot/default_configs/cavebot_1.3/tools.lua @@ -22,7 +22,7 @@ for _, scripts in ipairs({storage.ingame_macros, storage.ingame_hotkeys}) do local status, result = pcall(function() assert(load(scripts, "ingame_editor"))() end) - if not status then + if not status then error("Ingame edior error:\n" .. result) end end @@ -44,7 +44,7 @@ macro(1000, "Exchange money", function() if item:getCount() == 100 then for m, moneyId in ipairs(moneyIds) do if item:getId() == moneyId then - return g_game.use(item) + return g_game.use(item) end end end @@ -124,7 +124,7 @@ local manatrainmacro = macro(1000, function() end) manatrainmacro.setOn(storage.manaTrain.on) -UI.DualScrollPanel(storage.manaTrain, function(widget, newParams) +UI.DualScrollPanel(storage.manaTrain, function(widget, newParams) storage.manaTrain = newParams manatrainmacro.setOn(storage.manaTrain.on) end) @@ -136,11 +136,11 @@ macro(60000, "Send message on trade", function() if not trade then trade = getChannelId("trade") end - if trade and storage.autoTradeMessage:len() > 0 then + if trade and storage.autoTradeMessage:len() > 0 then sayChannel(trade, storage.autoTradeMessage) end end) -UI.TextEdit(storage.autoTradeMessage or "I'm using OTClientV8!", function(widget, text) +UI.TextEdit(storage.autoTradeMessage or "I'm using OTClientV8!", function(widget, text) storage.autoTradeMessage = text end) diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/actions.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/actions.lua index 5e9818b87a..ba4ed7d48a 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/actions.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/actions.lua @@ -2,7 +2,6 @@ CaveBot.Actions = {} vBot.lastLabel = "" local oldTibia = g_game.getClientVersion() < 960 local nextTile = nil - local noPath = 0 -- antistuck f() @@ -97,7 +96,7 @@ local function breakFurniture(destPos) useWith(3197, thing) return true end - + return false end @@ -126,7 +125,7 @@ local function pathfinder() local profile = CaveBot.getCurrentProfile() local config = getConfigFromName() local newProfile = profile == '#Unibase' and config or '#Unibase' - + CaveBot.setCurrentProfile(newProfile) end end @@ -175,11 +174,11 @@ CaveBot.editAction = function(widget, action, value) if not raction then return warn("Invalid cavebot action: " .. action) end - + if not widget.action or not widget.value then - return warn("Invalid cavebot action widget, has missing action or value") + return warn("Invalid cavebot action widget, has missing action or value") end - + widget:setText(action .. ":" .. value:split("\n")[1]) widget.action = action widget.value = value @@ -197,7 +196,7 @@ prev is a true when previuos action was executed succesfully, false otherwise it must return true if executed correctly, false otherwise it can also return string "retry", then the function will be called again in 20 ms ]]-- -CaveBot.registerAction = function(action, color, callback) +CaveBot.registerAction = function(action, color, callback) action = action:lower() if CaveBot.Actions[action] then return warn("Duplicated acction: " .. action) @@ -214,7 +213,7 @@ CaveBot.registerAction("label", "yellow", function(value, retries, prev) end) CaveBot.registerAction("gotolabel", "#FFFF55", function(value, retries, prev) - return CaveBot.gotoLabel(value) + return CaveBot.gotoLabel(value) end) CaveBot.registerAction("delay", "#AAAAAA", function(value, retries, prev) @@ -237,7 +236,7 @@ CaveBot.registerAction("delay", "#AAAAAA", function(value, retries, prev) end final = final or val - CaveBot.delay(final) + CaveBot.delay(final) return "retry" end return true @@ -267,13 +266,13 @@ CaveBot.registerAction("function", "red", function(value, retries, prev) for extension, callbacks in pairs(CaveBot.Extensions) do prefix = prefix .. "local " .. extension .. " = CaveBot.Extensions." .. extension .. "\n" end - local status, result = pcall(function() + local status, result = pcall(function() return assert(load(prefix .. value, "cavebot_function"))() end) if not status then warn("warn in cavebot function:\n" .. result) return false - end + end return result end) @@ -287,7 +286,7 @@ CaveBot.registerAction("goto", "green", function(value, retries, prev) -- reset pathfinder nextPosF = nil nextPos = nil - + if CaveBot.Config.get("mapClick") then if retries >= 5 then noPath = noPath + 1 @@ -299,20 +298,20 @@ CaveBot.registerAction("goto", "green", function(value, retries, prev) noPath = noPath + 1 pathfinder() return false -- tried 100 times, can't get there - end + end end local precision = tonumber(pos[1][5]) - pos = {x=tonumber(pos[1][2]), y=tonumber(pos[1][3]), z=tonumber(pos[1][4])} + pos = {x=tonumber(pos[1][2]), y=tonumber(pos[1][3]), z=tonumber(pos[1][4])} local playerPos = player:getPosition() - if pos.z ~= playerPos.z then + if pos.z ~= playerPos.z then noPath = noPath + 1 pathfinder() return false -- different floor end local maxDist = storage.extras.gotoMaxDistance or 40 - + if math.abs(pos.x-playerPos.x) + math.abs(pos.y-playerPos.y) > maxDist then noPath = noPath + 1 pathfinder() @@ -321,7 +320,7 @@ CaveBot.registerAction("goto", "green", function(value, retries, prev) local minimapColor = g_map.getMinimapColor(pos) local stairs = (minimapColor >= 210 and minimapColor <= 213) - + if stairs then if math.abs(pos.x-playerPos.x) == 0 and math.abs(pos.y-playerPos.y) <= 0 then noPath = 0 @@ -353,7 +352,7 @@ CaveBot.registerAction("goto", "green", function(value, retries, prev) nextPos = nextPos or playerPos nextPos.x = nextPos.x + dirs[1] nextPos.y = nextPos.y + dirs[2] - + local tile = g_map.getTile(nextPos) if tile then if tile:hasCreature() then @@ -361,7 +360,7 @@ CaveBot.registerAction("goto", "green", function(value, retries, prev) local hppc = creature:getHealthPercent() if creature:isMonster() and (hppc and hppc > 0) and (oldTibia or creature:getType() < 3) then -- real blocking creature can not meet those conditions - ie. it could be player, so just in case check if the next creature is reachable - local path = findPath(playerPos, creature:getPosition(), 7, { ignoreNonPathable = true, precision = 1 }) + local path = findPath(playerPos, creature:getPosition(), 7, { ignoreNonPathable = true, precision = 1 }) if path then foundMonster = true if g_game.getAttackingCreature() ~= creature then @@ -386,17 +385,17 @@ CaveBot.registerAction("goto", "green", function(value, retries, prev) return false -- no other way end end - + -- try to find path, don't ignore creatures, don't ignore fields if not CaveBot.Config.get("ignoreFields") and CaveBot.walkTo(pos, 40) then return "retry" end - + -- try to find path, don't ignore creatures, ignore fields if CaveBot.walkTo(pos, maxDist, { ignoreNonPathable = true, allowUnseen = true, allowOnlyVisibleTiles = false }) then return "retry" end - + if retries >= 3 then -- try to lower precision, find something close to final position local precison = retries - 1 @@ -405,15 +404,15 @@ CaveBot.registerAction("goto", "green", function(value, retries, prev) end if CaveBot.walkTo(pos, 50, { ignoreNonPathable = true, precision = precison, allowUnseen = true, allowOnlyVisibleTiles = false }) then return "retry" - end + end end - + if not CaveBot.Config.get("mapClick") and retries >= 5 then noPath = noPath + 1 pathfinder() return false end - + if CaveBot.Config.get("skipBlocked") then noPath = noPath + 1 pathfinder() @@ -437,9 +436,9 @@ CaveBot.registerAction("use", "#FFB272", function(value, retries, prev) return true end - pos = {x=tonumber(pos[1][2]), y=tonumber(pos[1][3]), z=tonumber(pos[1][4])} + pos = {x=tonumber(pos[1][2]), y=tonumber(pos[1][3]), z=tonumber(pos[1][4])} local playerPos = player:getPosition() - if pos.z ~= playerPos.z then + if pos.z ~= playerPos.z then return false -- different floor end @@ -474,9 +473,9 @@ CaveBot.registerAction("usewith", "#EEB292", function(value, retries, prev) end local itemid = tonumber(pos[1][2]) - pos = {x=tonumber(pos[1][3]), y=tonumber(pos[1][4]), z=tonumber(pos[1][5])} + pos = {x=tonumber(pos[1][3]), y=tonumber(pos[1][4]), z=tonumber(pos[1][5])} local playerPos = player:getPosition() - if pos.z ~= playerPos.z then + if pos.z ~= playerPos.z then return false -- different floor end @@ -503,7 +502,8 @@ CaveBot.registerAction("say", "#FF55FF", function(value, retries, prev) say(value) return true end) + CaveBot.registerAction("npcsay", "#FF55FF", function(value, retries, prev) NPC.say(value) return true -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/bank.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/bank.lua index 6bdee75893..d8e3dfecb1 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/bank.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/bank.lua @@ -43,9 +43,9 @@ CaveBot.Extensions.Bank.setup = function() end local npc = getCreatureByName(npcName) - if not npc then + if not npc then print("CaveBot[Bank]: NPC not found, skipping") - return false + return false end if not CaveBot.ReachNPC(npcName) then @@ -84,9 +84,8 @@ CaveBot.Extensions.Bank.setup = function() }) end - onTalk(function(name, level, mode, text, channelId, pos) if mode == 51 and text:find("Your account balance is") then balance = getFirstNumberInText(text) end -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/buy_supplies.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/buy_supplies.lua index 1620ccc0e4..29b7c29259 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/buy_supplies.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/buy_supplies.lua @@ -6,21 +6,21 @@ CaveBot.Extensions.BuySupplies.setup = function() local val = string.split(value, ",") local waitVal - if #val == 0 or #val > 2 then + if #val == 0 or #val > 2 then warn("CaveBot[BuySupplies]: incorrect BuySupplies value") - return false + return false elseif #val == 2 then waitVal = tonumber(val[2]:trim()) end local npcName = val[1]:trim() local npc = getCreatureByName(npcName) - if not npc then + if not npc then print("CaveBot[BuySupplies]: NPC not found") - return false + return false end - - if not waitVal and #val == 2 then + + if not waitVal and #val == 2 then warn("CaveBot[BuySupplies]: incorrect delay values!") elseif waitVal and #val == 2 then delay(waitVal) @@ -73,4 +73,4 @@ CaveBot.Extensions.BuySupplies.setup = function() title="Buy Supplies", description="NPC Name, delay(in ms, optional)", }) -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/cavebot.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/cavebot.lua index 6da44598c7..0f57dfe39c 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/cavebot.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/cavebot.lua @@ -28,18 +28,18 @@ cavebotMacro = macro(20, function() CaveBot.resetWalking() return -- target bot or looting is working, wait end - + if CaveBot.doWalking() then return -- executing walking3 end - + local actions = ui.list:getChildCount() if actions == 0 then return end local currentAction = ui.list:getFocusedChild() if not currentAction then currentAction = ui.list:getFirstChild() end - local action = CaveBot.Actions[currentAction.action] + local action = CaveBot.Actions[currentAction.action] local value = currentAction.value local retry = false if action then @@ -59,15 +59,15 @@ cavebotMacro = macro(20, function() end else warn("warn while executing cavebot action (" .. currentAction.action .. "):\n" .. result) - end + end else warn("Invalid cavebot action: " .. currentAction.action) end - + if retry then return end - + if currentAction ~= ui.list:getFocusedChild() then -- focused child can change durring action, get it again and reset state currentAction = ui.list:getFocusedChild() or ui.list:getFirstChild() @@ -87,13 +87,13 @@ config = Config.setup("cavebot_configs", configWidget, "cfg", function(name, ena if enabled and CaveBot.Recorder.isOn() then CaveBot.Recorder.disable() CaveBot.setOff() - return + return end local currentActionIndex = ui.list:getChildIndex(ui.list:getFocusedChild()) ui.list:destroyChildren() if not data then return cavebotMacro.setOff() end - + local cavebotConfig = nil for k,v in ipairs(data) do if type(v) == "table" and #v == 2 then @@ -126,17 +126,17 @@ config = Config.setup("cavebot_configs", configWidget, "cfg", function(name, ena end CaveBot.Config.onConfigChange(name, enabled, cavebotConfig) - + actionRetries = 0 CaveBot.resetWalking() prevActionResult = true cavebotMacro.setOn(enabled) cavebotMacro.delay = nil - if lastConfig == name then + if lastConfig == name then -- restore focused child on the action list ui.list:focusChild(ui.list:getChildByIndex(currentActionIndex)) end - lastConfig = name + lastConfig = name end) -- ui callbacks @@ -172,14 +172,14 @@ CaveBot.isOff = function() end CaveBot.setOn = function(val) - if val == false then + if val == false then return CaveBot.setOff(true) end config.setOn() end CaveBot.setOff = function(val) - if val == false then + if val == false then return CaveBot.setOn(true) end config.setOff() @@ -205,7 +205,7 @@ CaveBot.gotoNextWaypointInRange = function() if string.starts(text, "goto:") then local re = regexMatch(text, [[(?:goto:)([^,]+),([^,]+),([^,]+)]]) local pos = {x = tonumber(re[1][2]), y = tonumber(re[1][3]), z = tonumber(re[1][4])} - + if posz() == pos.z then local maxDist = storage.extras.gotoMaxDistance if distanceFromPlayer(pos) <= maxDist then @@ -318,7 +318,7 @@ CaveBot.getFirstWaypointBeforeLabel = function(label) for i=1,#actions do if index - 1 < 1 then - -- did not found any waypoint in range before label + -- did not found any waypoint in range before label return false end @@ -355,7 +355,7 @@ CaveBot.getPreviousLabel = function() for i=1,#actions do if index - i < 1 then - -- did not found any waypoint in range before label + -- did not found any waypoint in range before label return false end @@ -381,7 +381,7 @@ CaveBot.getNextLabel = function() for i=1,#actions do if index + i > #actions then - -- did not found any waypoint in range before label + -- did not found any waypoint in range before label return false end @@ -411,7 +411,7 @@ end CaveBot.gotoLabel = function(label) label = label:lower() for index, child in ipairs(ui.list:getChildren()) do - if child.action == "label" and child.value:lower() == label then + if child.action == "label" and child.value:lower() == label then ui.list:focusChild(child) return true end @@ -424,11 +424,11 @@ CaveBot.save = function() for index, child in ipairs(ui.list:getChildren()) do table.insert(data, {child.action, child.value}) end - + if CaveBot.Config then table.insert(data, {"config", json.encode(CaveBot.Config.save())}) end - + local extension_data = {} for extension, callbacks in pairs(CaveBot.Extensions) do if callbacks.onSave then @@ -444,4 +444,4 @@ end CaveBotList = function() return ui.list -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/cavebot.otui b/mods/game_bot/default_configs/vBot_4.8/cavebot/cavebot.otui index b92ed05fb9..f27857bd98 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/cavebot.otui +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/cavebot.otui @@ -6,7 +6,6 @@ CaveBotAction < Label $focus: background-color: #00000055 - CaveBotPanel < Panel layout: type: verticalBox @@ -15,7 +14,7 @@ CaveBotPanel < Panel HorizontalSeparator margin-top: 2 margin-bottom: 5 - + Panel id: listPanel height: 100 @@ -28,7 +27,7 @@ CaveBotPanel < Panel margin-right: 15 focusable: false auto-focus: first - + VerticalScrollBar id: listScrollbar anchors.top: parent.top @@ -36,23 +35,23 @@ CaveBotPanel < Panel anchors.right: parent.right pixels-scroll: true step: 10 - + BotSwitch id: showEditor margin-top: 2 - + $on: text: Hide waypoints editor - + $!on: text: Show waypoints editor BotSwitch id: showConfig margin-top: 2 - + $on: text: Hide config - + $!on: - text: Show config \ No newline at end of file + text: Show config diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/clear_tile.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/clear_tile.lua index 73a252fb10..2a46f84b9a 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/clear_tile.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/clear_tile.lua @@ -8,7 +8,6 @@ CaveBot.Extensions.ClearTile.setup = function() local stand = false local pPos = player:getPosition() - for i, value in ipairs(data) do value = value:lower():trim() if value == "stand" then @@ -18,7 +17,6 @@ CaveBot.Extensions.ClearTile.setup = function() end end - if not #pos == 3 then warn("CaveBot[ClearTile]: invalid value. It should be position (x,y,z), is: " .. value) return false @@ -77,7 +75,7 @@ CaveBot.Extensions.ClearTile.setup = function() print("CaveBot[ClearTile]: moving item... " .. item:getId().. " from tile") g_game.move(item, pPos, item:getCount()) return "retry" - end + end end -- player @@ -125,4 +123,4 @@ CaveBot.Extensions.ClearTile.setup = function() description="tile position (x,y,z), doors/stand - optional", multiline=false }) -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/config.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/config.lua index e398111d6b..0cb4f68dde 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/config.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/config.lua @@ -8,13 +8,13 @@ CaveBot.Config.setup = function() CaveBot.Config.ui = UI.createWidget("CaveBotConfigPanel") local ui = CaveBot.Config.ui local add = CaveBot.Config.add - + add("ping", "Server ping", 100) add("walkDelay", "Walk delay", 10) add("mapClick", "Use map click", false) add("mapClickDelay", "Map click delay", 100) - add("ignoreFields", "Ignore fields", false) - add("skipBlocked", "Skip blocked path", false) + add("ignoreFields", "Ignore fields", false) + add("skipBlocked", "Skip blocked path", false) add("useDelay", "Delay after use", 400) end @@ -46,7 +46,7 @@ CaveBot.Config.add = function(id, title, defaultValue) if CaveBot.Config.values[id] then return warn("Duplicated config key: " .. id) end - + local panel local setter -- sets value if type(defaultValue) == "number" then @@ -78,11 +78,11 @@ CaveBot.Config.add = function(id, title, defaultValue) CaveBot.save() end else - return warn("Invalid default value of config for key " .. id .. ", should be number or boolean") + return warn("Invalid default value of config for key " .. id .. ", should be number or boolean") end - + panel.title:setText(tr(title) .. ":") - + CaveBot.Config.value_setters[id] = setter CaveBot.Config.values[id] = defaultValue CaveBot.Config.default_values[id] = defaultValue @@ -108,4 +108,4 @@ CaveBot.Config.set = function(id, value) panel.value:setText(value, true) CaveBot.save() end -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/config.otui b/mods/game_bot/default_configs/vBot_4.8/cavebot/config.otui index 21d479dd60..cd07947c21 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/config.otui +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/config.otui @@ -1,11 +1,11 @@ CaveBotConfigPanel < Panel id: cavebotEditor visible: false - + layout: type: verticalBox fit-children: true - + HorizontalSeparator margin-top: 5 @@ -17,7 +17,7 @@ CaveBotConfigPanel < Panel CaveBotConfigNumberValuePanel < Panel height: 20 margin-top: 5 - + BotTextEdit id: value anchors.right: parent.right @@ -35,7 +35,7 @@ CaveBotConfigNumberValuePanel < Panel CaveBotConfigBooleanValuePanel < Panel height: 20 margin-top: 5 - + BotSwitch id: value anchors.right: parent.right @@ -43,10 +43,10 @@ CaveBotConfigBooleanValuePanel < Panel anchors.bottom: parent.bottom margin-right: 5 width: 50 - + $on: text: On - + $!on: text: Off @@ -54,4 +54,4 @@ CaveBotConfigBooleanValuePanel < Panel id: title anchors.left: parent.left anchors.verticalCenter: prev.verticalCenter - margin-left: 5 \ No newline at end of file + margin-left: 5 diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/d_withdraw.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/d_withdraw.lua index 888ed1b074..044af3dec6 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/d_withdraw.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/d_withdraw.lua @@ -5,7 +5,7 @@ CaveBot.Extensions.DWithdraw.setup = function() local capLimit local data = string.split(value, ",") if retries > 600 then - print("CaveBot[DepotWithdraw]: actions limit reached, proceeding") + print("CaveBot[DepotWithdraw]: actions limit reached, proceeding") return false end local destContainer @@ -24,7 +24,6 @@ CaveBot.Extensions.DWithdraw.setup = function() capLimit = tonumber(data[4]:trim()) end - -- cap check if freecap() < (capLimit or 200) then for i, container in ipairs(getContainers()) do @@ -32,8 +31,8 @@ CaveBot.Extensions.DWithdraw.setup = function() g_game.close(container) end end - print("CaveBot[DepotWithdraw]: cap limit reached, proceeding") - return false + print("CaveBot[DepotWithdraw]: cap limit reached, proceeding") + return false end -- containers @@ -46,7 +45,7 @@ CaveBot.Extensions.DWithdraw.setup = function() end end - if not destContainer then + if not destContainer then print("CaveBot[DepotWithdraw]: container not found!") return false end @@ -102,4 +101,4 @@ CaveBot.Extensions.DWithdraw.setup = function() title="Loot Withdraw", description="insert index, destination container name and it's ID", }) -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/depositor.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/depositor.lua index eb2d03801f..8eb0e42ea9 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/depositor.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/depositor.lua @@ -91,13 +91,13 @@ CaveBot.Extensions.Depositor.setup = function() end -- next check retries - if retries > 400 then + if retries > 400 then print("CaveBot[Depositor]: Depositor actions limit reached, proceeding") resetCache() - return true + return true end - -- reaching and opening depot + -- reaching and opening depot if not CaveBot.ReachAndOpenDepot() then return "retry" end @@ -135,4 +135,4 @@ CaveBot.Extensions.Depositor.setup = function() description=description, validation="(yes|Yes|YES|no|No|NO)" }) -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/doors.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/doors.lua index f53992b1b5..98839cd219 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/doors.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/doors.lua @@ -17,7 +17,7 @@ CaveBot.Extensions.OpenDoors.setup = function() return false -- tried 5 times, can't open end - pos = {x=tonumber(pos[1]), y=tonumber(pos[2]), z=tonumber(pos[3])} + pos = {x=tonumber(pos[1]), y=tonumber(pos[2]), z=tonumber(pos[3])} local doorTile if not doorTile then @@ -31,7 +31,7 @@ CaveBot.Extensions.OpenDoors.setup = function() if not doorTile then return false end - + if not doorTile:isWalkable() then if not key then use(doorTile:getTopUseThing()) @@ -55,4 +55,4 @@ CaveBot.Extensions.OpenDoors.setup = function() multiline=false, validation=[[\d{1,5},\d{1,5},\d{1,2}(?:,\d{1,5}$|$)]] }) -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/editor.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/editor.lua index cefaf2604a..342475b114 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/editor.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/editor.lua @@ -19,13 +19,13 @@ CaveBot.Editor.registerAction = function(action, text, params) CaveBot.Editor.Actions[action] = params color = raction.color end - + local button = UI.createWidget('CaveBotEditorButton', CaveBot.Editor.ui.buttons) button:setText(text) if color then button:setColor(color) end - button.onClick = function() + button.onClick = function() if type(params) == 'function' then params() return @@ -79,12 +79,12 @@ CaveBot.Editor.setup = function() action:destroy() CaveBot.save() end) - + registerAction("label", { value="labelName", title="Label", description="Add label", - multiline=false + multiline=false }) registerAction("delay", { value="500", @@ -97,7 +97,7 @@ CaveBot.Editor.setup = function() value="labelName", title="Go to label", description="Go to label", - multiline=false + multiline=false }) registerAction("goto", "go to", { value=function() return posx() .. "," .. posy() .. "," .. posz() end, @@ -110,8 +110,8 @@ CaveBot.Editor.setup = function() value=function() return posx() .. "," .. posy() .. "," .. posz() end, title="Use", description="Use item from position (x,y,z) or from inventory (itemId)", - multiline=false - }) + multiline=false + }) registerAction("usewith", "use with", { value=function() return "itemId," .. posx() .. "," .. posy() .. "," .. posz() end, title="Use with", @@ -123,20 +123,20 @@ CaveBot.Editor.setup = function() value="text", title="Say", description="Enter text to say", - multiline=false - }) + multiline=false + }) registerAction("follow", { value="NPC name", title="Follow Creature", description="insert creature name to follow", - multiline=false + multiline=false }) registerAction("npcsay", { value="text", title="NPC Say", description="Enter text to NPC say", - multiline=false - }) + multiline=false + }) registerAction("function", { title="Edit bot function", multiline=true, @@ -144,7 +144,7 @@ CaveBot.Editor.setup = function() examples=CaveBot.Editor.ExampleFunctions, width=650 }) - + ui.autoRecording.onClick = function() if ui.autoRecording:isOn() then CaveBot.Recorder.disable() @@ -152,19 +152,18 @@ CaveBot.Editor.setup = function() CaveBot.Recorder.enable() end end - + -- callbacks onPlayerPositionChange(function(pos) - ui.pos:setText("Position: " .. pos.x .. ", " .. pos.y .. ", " .. pos.z) + ui.pos:setText("Position: " .. pos.x .. ", " .. pos.y .. ", " .. pos.z) end) - ui.pos:setText("Position: " .. posx() .. ", " .. posy() .. ", " .. posz()) + ui.pos:setText("Position: " .. posx() .. ", " .. posy() .. ", " .. posz()) end CaveBot.Editor.show = function() CaveBot.Editor.ui:show() end - CaveBot.Editor.hide = function() CaveBot.Editor.ui:hide() end @@ -182,5 +181,5 @@ CaveBot.Editor.edit = function(action, value, callback) -- callback = function(a UI.EditorWindow(value, params, function(newText) callback(action, newText) - end) + end) end diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/editor.otui b/mods/game_bot/default_configs/vBot_4.8/cavebot/editor.otui index d11288c64d..77d63e8fa9 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/editor.otui +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/editor.otui @@ -1,18 +1,17 @@ CaveBotEditorButton < Button - CaveBotEditorPanel < Panel id: cavebotEditor visible: false layout: type: verticalBox fit-children: true - + Label id: pos text-align: center text: - - + Panel id: buttons margin-top: 2 diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/example_functions.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/example_functions.lua index 99252e805c..deb091da89 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/example_functions.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/example_functions.lua @@ -41,8 +41,8 @@ addExampleFunction("Check for stamina and imbues", [[ addExampleFunction("buy 200 mana potion from npc Eryn", [[ --buy 200 mana potions local npc = getCreatureByName("Eryn") -if not npc then - return false +if not npc then + return false end if retries > 10 then return false @@ -111,4 +111,4 @@ addExampleFunction("Close Loot Containers", [[ CaveBot.CloseAllLootContainers() delay(3000) return true -]]) \ No newline at end of file +]]) diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/extension_template.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/extension_template.lua index d015f11beb..6e595cd6b8 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/extension_template.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/extension_template.lua @@ -28,7 +28,7 @@ CaveBot.Extensions.Example.setup = function() title="Say hello", description="Says hello x times", validation="[0-9]{1,5}" -- regex, optional - }) + }) end -- called when cavebot config changes, configData is a table but it can also be nil diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/imbuing.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/imbuing.lua index 64012a7f97..231caed2f9 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/imbuing.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/imbuing.lua @@ -36,7 +36,7 @@ CaveBot.Extensions.Imbuing.setup = function() EquipManager.setOff() if value == 'name' then - local imbuData = AutoImbueTable[player:getName()] + local imbuData = AutoImbueTable[player:getName()] for id, imbues in pairs(imbuData) do table.insert(ids, id) end @@ -49,7 +49,7 @@ CaveBot.Extensions.Imbuing.setup = function() end end end - + -- all items imbued, can proceed if currentIndex > #ids then warn("CaveBot[Imbuing] used shrine on all items, proceeding") @@ -78,7 +78,7 @@ CaveBot.Extensions.Imbuing.setup = function() currentId = ids[currentIndex] item = findItem(currentId) - + -- maybe equipped? try to take off if not item then -- did try before, still not found so item is unavailable @@ -116,4 +116,4 @@ CaveBot.Extensions.Imbuing.setup = function() title="Auto Imbuing", description="insert below item ids to be imbued, separated by comma\nor 'name' to load from file", }) -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/inbox_withdraw.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/inbox_withdraw.lua index d5fc02b483..c0ccc1bb7f 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/inbox_withdraw.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/inbox_withdraw.lua @@ -53,7 +53,7 @@ CaveBot.Extensions.InWithdraw.setup = function() local destination for i, container in pairs(getContainers()) do if container:getCapacity() > #container:getItems() and not string.find(container:getName():lower(), "quiver") and not string.find(container:getName():lower(), "depot") and not string.find(container:getName():lower(), "loot") and not string.find(container:getName():lower(), "inbox") then - destination = container + destination = container end end @@ -88,4 +88,4 @@ CaveBot.Extensions.InWithdraw.setup = function() title="Withdraw Items", description="insert item id and amount", }) -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/lure.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/lure.lua index 0cb5c54053..e36dd3f796 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/lure.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/lure.lua @@ -26,4 +26,4 @@ CaveBot.Extensions.Lure.setup = function() multiline=false, validation=[[(start|stop|toggle)$]] }) -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/minimap.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/minimap.lua index 5ace5ee471..8d36d50389 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/minimap.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/minimap.lua @@ -23,4 +23,4 @@ minimap.onMouseRelease = function(widget,pos,button) return true end return false -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/pos_check.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/pos_check.lua index 361ddb6da2..29156d59ae 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/pos_check.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/pos_check.lua @@ -44,4 +44,4 @@ CaveBot.Extensions.PosCheck.setup = function() description="label name, accepted dist from coordinates, x, y, z", multiline=false, }) -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/recorder.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/recorder.lua index 14248f378b..7ceba06725 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/recorder.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/recorder.lua @@ -15,7 +15,7 @@ local function setup() end onPlayerPositionChange(function(newPos, oldPos) - if CaveBot.isOn() or not isEnabled then return end + if CaveBot.isOn() or not isEnabled then return end if not lastPos then -- first step addPosition(oldPos) @@ -27,15 +27,15 @@ local function setup() addPosition(newPos) end end) - + onUse(function(pos, itemId, stackPos, subType) if CaveBot.isOn() or not isEnabled then return end - if pos.x ~= 0xFFFF then + if pos.x ~= 0xFFFF then lastPos = pos CaveBot.addAction("use", pos.x .. "," .. pos.y .. "," .. pos.z, true) end end) - + onUseWith(function(pos, itemId, target, subType) if CaveBot.isOn() or not isEnabled then return end if not target:isItem() then return end @@ -66,4 +66,4 @@ CaveBot.Recorder.disable = function() end CaveBot.Editor.ui.autoRecording:setOn(false) CaveBot.save() -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/sell_all.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/sell_all.lua index c3d40f3e11..305fe6e381 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/sell_all.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/sell_all.lua @@ -19,9 +19,9 @@ CaveBot.Extensions.SellAll.setup = function() local npcName = val[1] local npc = getCreatureByName(npcName) - if not npc then + if not npc then print("CaveBot[SellAll]: NPC not found! skipping") - return false + return false end if retries > 10 then @@ -30,7 +30,7 @@ CaveBot.Extensions.SellAll.setup = function() end if freecap() == sellAllCap then - sellAllCap = 0 + sellAllCap = 0 print("CaveBot[SellAll]: Sold everything, proceeding") return true end @@ -57,7 +57,7 @@ CaveBot.Extensions.SellAll.setup = function() end table.dump(val) - + modules.game_npctrade.sellAll(wait, val) if wait then print("CaveBot[SellAll]: Sold All with delay") @@ -73,4 +73,4 @@ CaveBot.Extensions.SellAll.setup = function() title="Sell All", description="NPC Name, 'yes' if sell with delay, exceptions: id separated by comma", }) -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/stand_lure.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/stand_lure.lua index 7230bdd999..9b0c1db872 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/stand_lure.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/stand_lure.lua @@ -92,7 +92,7 @@ CaveBot.Extensions.StandLure.setup = function() if not pathWithoutMonsters then reset() warn("[Rush Lure] No possible path to reach position, skipping.") - return false -- spot is unreachable + return false -- spot is unreachable elseif pathWithoutMonsters and not pathWithMonsters then local foundMonster = false for i, dir in ipairs(pathWithoutMonsters) do @@ -101,7 +101,7 @@ CaveBot.Extensions.StandLure.setup = function() nextPos.x = nextPos.x + dirs[1] nextPos.y = nextPos.y + dirs[2] - + local tile = g_map.getTile(nextPos) if tile then if tile:hasCreature() then @@ -109,7 +109,7 @@ CaveBot.Extensions.StandLure.setup = function() local hppc = creature:getHealthPercent() if creature:isMonster() and (hppc and hppc > 0) and (oldTibia or creature:getType() < 3) then -- real blocking creature can not meet those conditions - ie. it could be player, so just in case check if the next creature is reachable - local path = findPath(playerPos, creature:getPosition(), 7, { ignoreNonPathable = true, precision = 1 }) + local path = findPath(playerPos, creature:getPosition(), 7, { ignoreNonPathable = true, precision = 1 }) if path then creature:setMarked('#00FF00') if g_game.getAttackingCreature() ~= creature then @@ -124,7 +124,7 @@ CaveBot.Extensions.StandLure.setup = function() end end end - + if not g_game.getAttackingCreature() then reset() warn("[Rush Lure] No path, no blocking monster, skipping.") @@ -178,9 +178,9 @@ schedule(5, function() -- delay because cavebot.lua is loaded after this file elseif enable == false then TargetBot.setOff() end - + enable = nil -- reset next = false end end}) -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/tasker.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/tasker.lua index 959515e62c..4972f30198 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/tasker.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/tasker.lua @@ -77,7 +77,7 @@ CaveBot.Extensions.Tasker.setup = function() dataValidationFailed() end end - + -- let's cover markers now if marker == 1 then -- starting task CaveBot.Conversation("hi", "task", taskName, "yes") @@ -133,17 +133,17 @@ CaveBot.Extensions.Tasker.setup = function() - task name in gryzzly adams: medusae - monster count: 500 - monster name to track: medusa - - optional, monster name 2: - 2. check status, + - optional, monster name 2: + 2. check status, to be used on refill to decide whether to go back or spawn or go give task back parameters: - scenario for extension: 2 - label if task in progress: skipTask - - label if task done: taskDone + - label if task done: taskDone 3. report task, parameters: - scenario for extension: 3 - + Strong suggestion, almost mandatory - USE POS CHECK to verify position! this module will only check if there is ANY npc in range! when begin remove all the text and leave just a single string of parameters diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/travel.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/travel.lua index 8e9d21e5b6..6dc55ae814 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/travel.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/travel.lua @@ -17,9 +17,9 @@ CaveBot.Extensions.Travel.setup = function() end local npc = getCreatureByName(npcName) - if not npc then + if not npc then print("CaveBot[Travel]: NPC not found, can't travel") - return false + return false end if not CaveBot.ReachNPC(npcName) then @@ -37,4 +37,4 @@ CaveBot.Extensions.Travel.setup = function() title="Travel", description="NPC name, City name, delay in ms(default is 200ms)", }) -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/walking.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/walking.lua index c8a713366b..38e16b01e2 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/walking.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/walking.lua @@ -28,13 +28,13 @@ CaveBot.doWalking = function() CaveBot.delay(CaveBot.Config.get("walkDelay") + player:getStepDuration(false, dir)) return true end - return false + return false end -- called when player position has been changed (step has been confirmed by server) onPlayerPositionChange(function(newPos, oldPos) if not oldPos or not newPos then return end - + local dirs = {{NorthWest, North, NorthEast}, {West, 8, East}, {SouthWest, South, SouthEast}} local dir = dirs[newPos.y - oldPos.y + 2] if dir then @@ -50,7 +50,7 @@ onPlayerPositionChange(function(newPos, oldPos) CaveBot.delay(CaveBot.Config.get("ping") + player:getStepDuration(false, dir) + 150) return end - + if expectedDirs[1] ~= dir then if CaveBot.Config.get("mapClick") then CaveBot.delay(CaveBot.Config.get("walkDelay") + player:getStepDuration(false, dir)) @@ -59,8 +59,8 @@ onPlayerPositionChange(function(newPos, oldPos) end return end - - table.remove(expectedDirs, 1) + + table.remove(expectedDirs, 1) if CaveBot.Config.get("mapClick") and #expectedDirs > 0 then CaveBot.delay(CaveBot.Config.get("mapClickDelay") + player:getStepDuration(false, dir)) end @@ -72,7 +72,7 @@ CaveBot.walkTo = function(dest, maxDist, params) return false end local dir = path[1] - + if CaveBot.Config.get("mapClick") then local ret = autoWalk(path) if ret then @@ -82,9 +82,9 @@ CaveBot.walkTo = function(dest, maxDist, params) end return ret end - + g_game.walk(dir, false) - isWalking = true + isWalking = true walkPath = path walkPathIter = 2 expectedDirs = { dir } diff --git a/mods/game_bot/default_configs/vBot_4.8/cavebot/withdraw.lua b/mods/game_bot/default_configs/vBot_4.8/cavebot/withdraw.lua index da29053277..a1a83bcd58 100644 --- a/mods/game_bot/default_configs/vBot_4.8/cavebot/withdraw.lua +++ b/mods/game_bot/default_configs/vBot_4.8/cavebot/withdraw.lua @@ -16,7 +16,7 @@ CaveBot.Extensions.Withdraw.setup = function() -- validation for correct values if not id or not amount then - print("CaveBot[Withdraw]: incorrect id or amount! skipping") + print("CaveBot[Withdraw]: incorrect id or amount! skipping") return false end @@ -53,4 +53,4 @@ CaveBot.Extensions.Withdraw.setup = function() title="Withdraw Items", description="index/inbox, item id and amount", }) -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/targetbot/creature.lua b/mods/game_bot/default_configs/vBot_4.8/targetbot/creature.lua index 225bcec141..22d30e1fcc 100644 --- a/mods/game_bot/default_configs/vBot_4.8/targetbot/creature.lua +++ b/mods/game_bot/default_configs/vBot_4.8/targetbot/creature.lua @@ -1,4 +1,3 @@ - TargetBot.Creature = {} TargetBot.Creature.configsCache = {} TargetBot.Creature.cached = 0 @@ -64,7 +63,7 @@ TargetBot.Creature.getConfigs = function(creature) table.insert(configs, config.value) end end - if TargetBot.Creature.cached > 1000 then + if TargetBot.Creature.cached > 1000 then TargetBot.Creature.resetConfigsCache() -- too big cache size, reset end TargetBot.Creature.configsCache[name] = configs -- add to cache diff --git a/mods/game_bot/default_configs/vBot_4.8/targetbot/creature_attack.lua b/mods/game_bot/default_configs/vBot_4.8/targetbot/creature_attack.lua index 4c31644c8d..636e9429fc 100644 --- a/mods/game_bot/default_configs/vBot_4.8/targetbot/creature_attack.lua +++ b/mods/game_bot/default_configs/vBot_4.8/targetbot/creature_attack.lua @@ -1,5 +1,5 @@ local targetBotLure = false -local targetCount = 0 +local targetCount = 0 local delayValue = 0 local lureMax = 0 local anchorPosition = nil @@ -54,7 +54,7 @@ TargetBot.Creature.attack = function(params, targets, isLooting) -- params {conf local config = params.config local creature = params.creature - + if g_game.getAttackingCreature() ~= creature then g_game.attack(creature) end @@ -115,7 +115,7 @@ end TargetBot.Creature.walk = function(creature, config, targets) local cpos = creature:getPosition() local pos = player:getPosition() - + local isTrapped = true local pos = player:getPosition() local dirs = {{-1,1}, {0,1}, {1,1}, {-1, 0}, {1, 0}, {-1, -1}, {0, -1}, {1, -1}} @@ -213,9 +213,9 @@ TargetBot.Creature.walk = function(creature, config, targets) elseif diffx == -1 and diffy == 1 then candidates = {{x=pos.x-1, y=pos.y, z=pos.z}, {x=pos.x, y=pos.y-1, z=pos.z}} elseif diffx == -1 and diffy == -1 then - candidates = {{x=pos.x, y=pos.y-1, z=pos.z}, {x=pos.x-1, y=pos.y, z=pos.z}} + candidates = {{x=pos.x, y=pos.y-1, z=pos.z}, {x=pos.x-1, y=pos.y, z=pos.z}} elseif diffx == 1 and diffy == -1 then - candidates = {{x=pos.x, y=pos.y-1, z=pos.z}, {x=pos.x+1, y=pos.y, z=pos.z}} + candidates = {{x=pos.x, y=pos.y-1, z=pos.z}, {x=pos.x+1, y=pos.y, z=pos.z}} else local dir = player:getDirection() if diffx == 1 and dir ~= 1 then turn(1) @@ -242,4 +242,4 @@ onPlayerPositionChange(function(newPos, oldPos) if targetCount < (delayFrom or lureMax/2) or not target() then return end CaveBot.delay(delayValue or 0) -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/targetbot/creature_editor.lua b/mods/game_bot/default_configs/vBot_4.8/targetbot/creature_editor.lua index 37d6d0014b..6e14f57b96 100644 --- a/mods/game_bot/default_configs/vBot_4.8/targetbot/creature_editor.lua +++ b/mods/game_bot/default_configs/vBot_4.8/targetbot/creature_editor.lua @@ -68,7 +68,7 @@ TargetBot.Creature.edit = function(config, callback) -- callback = function(newC if newConfig.regex:len() > 0 then newConfig.regex = newConfig.regex .. "|" end - newConfig.regex = newConfig.regex .. "^" .. part:trim():lower():gsub("%*", ".*"):gsub("%?", ".?") .. "$" + newConfig.regex = newConfig.regex .. "^" .. part:trim():lower():gsub("%*", ".*"):gsub("%?", ".?") .. "$" end editor:destroy() diff --git a/mods/game_bot/default_configs/vBot_4.8/targetbot/creature_editor.otui b/mods/game_bot/default_configs/vBot_4.8/targetbot/creature_editor.otui index 9570f8774f..6b63a684b2 100644 --- a/mods/game_bot/default_configs/vBot_4.8/targetbot/creature_editor.otui +++ b/mods/game_bot/default_configs/vBot_4.8/targetbot/creature_editor.otui @@ -8,7 +8,7 @@ TargetBotCreatureEditorScrollBar < Panel anchors.right: parent.right anchors.top: parent.top text-align: center - + HorizontalScrollBar id: scroll anchors.left: parent.left @@ -29,7 +29,7 @@ TargetBotCreatureEditorTextEdit < Panel anchors.right: parent.right anchors.top: parent.top text-align: center - + TextEdit id: textEdit anchors.left: parent.left @@ -65,7 +65,7 @@ TargetBotCreatureEditorWindow < MainWindow text: TargetBot creature editor width: 500 height: 425 - + $mobile: height: 300 @@ -82,7 +82,7 @@ TargetBotCreatureEditorWindow < MainWindow anchors.top: prev.bottom text-align: center !text: tr('You can also enter multiple targets, separate them by ,') - + TextEdit id: name anchors.top: prev.bottom @@ -115,7 +115,7 @@ TargetBotCreatureEditorWindow < MainWindow anchors.bottom: help.top vertical-scrollbar: contentScroll margin-bottom: 10 - + Panel id: left anchors.top: parent.top @@ -139,7 +139,7 @@ TargetBotCreatureEditorWindow < MainWindow layout: type: verticalBox fit-children: true - + Button id: help !text: tr('Help & Tutorials') diff --git a/mods/game_bot/default_configs/vBot_4.8/targetbot/creature_priority.lua b/mods/game_bot/default_configs/vBot_4.8/targetbot/creature_priority.lua index 813d3a620b..9639987328 100644 --- a/mods/game_bot/default_configs/vBot_4.8/targetbot/creature_priority.lua +++ b/mods/game_bot/default_configs/vBot_4.8/targetbot/creature_priority.lua @@ -20,7 +20,7 @@ TargetBot.Creature.calculatePriority = function(creature, config, path) -- add config priority priority = priority + config.priority - + -- extra priority for close distance local path_length = #path if path_length == 1 then @@ -58,4 +58,4 @@ TargetBot.Creature.calculatePriority = function(creature, config, path) end return priority -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/targetbot/looting.lua b/mods/game_bot/default_configs/vBot_4.8/targetbot/looting.lua index 9e41528b97..c4816a1de0 100644 --- a/mods/game_bot/default_configs/vBot_4.8/targetbot/looting.lua +++ b/mods/game_bot/default_configs/vBot_4.8/targetbot/looting.lua @@ -11,7 +11,7 @@ local dontSave = false TargetBot.Looting.setup = function() ui = UI.createWidget("TargetBotLootingPanel") UI.Container(TargetBot.Looting.onItemsUpdate, true, nil, ui.items) - UI.Container(TargetBot.Looting.onContainersUpdate, true, nil, ui.containers) + UI.Container(TargetBot.Looting.onContainersUpdate, true, nil, ui.containers) ui.everyItem.onClick = function() ui.everyItem:setOn(not ui.everyItem:isOn()) TargetBot.save() @@ -250,11 +250,11 @@ TargetBot.Looting.lootContainer = function(lootContainers, container) return end end - + -- looting finished, remove container from list container.lootContainer = false g_game.close(container) - table.remove(TargetBot.Looting.list, storage.extras.lootLast and #TargetBot.Looting.list or 1) + table.remove(TargetBot.Looting.list, storage.extras.lootLast and #TargetBot.Looting.list or 1) end onTextMessage(function(mode, text) @@ -313,7 +313,7 @@ onCreatureDisappear(function(creature) if not findPath(player:getPosition(), mpos, 6, {ignoreNonPathable=true, ignoreCreatures=true, ignoreCost=true}) then return end table.insert(TargetBot.Looting.list, {pos=mpos, creature=name, container=container:getId(), added=now, tries=0}) - table.sort(TargetBot.Looting.list, function(a,b) + table.sort(TargetBot.Looting.list, function(a,b) a.dist = distanceFromPlayer(a.pos) b.dist = distanceFromPlayer(b.pos) diff --git a/mods/game_bot/default_configs/vBot_4.8/targetbot/looting.otui b/mods/game_bot/default_configs/vBot_4.8/targetbot/looting.otui index aa973e3805..34a4d35ad4 100644 --- a/mods/game_bot/default_configs/vBot_4.8/targetbot/looting.otui +++ b/mods/game_bot/default_configs/vBot_4.8/targetbot/looting.otui @@ -9,12 +9,12 @@ TargetBotLootingPanel < Panel Label margin-top: 5 text: Items to loot - text-align: center + text-align: center BotContainer id: items margin-top: 3 - + BotSwitch id: everyItem !text: tr("Loot every item") @@ -29,12 +29,12 @@ TargetBotLootingPanel < Panel id: containers margin-top: 3 height: 45 - + Panel id: maxDangerPanel height: 20 margin-top: 5 - + BotTextEdit id: value anchors.right: parent.right @@ -53,7 +53,7 @@ TargetBotLootingPanel < Panel id: minCapacityPanel height: 20 margin-top: 3 - + BotTextEdit id: value anchors.right: parent.right @@ -66,4 +66,4 @@ TargetBotLootingPanel < Panel anchors.left: parent.left anchors.verticalCenter: prev.verticalCenter text: Min. capacity: - margin-left: 5 \ No newline at end of file + margin-left: 5 diff --git a/mods/game_bot/default_configs/vBot_4.8/targetbot/target.lua b/mods/game_bot/default_configs/vBot_4.8/targetbot/target.lua index 8bfb499702..ce1722fedc 100644 --- a/mods/game_bot/default_configs/vBot_4.8/targetbot/target.lua +++ b/mods/game_bot/default_configs/vBot_4.8/targetbot/target.lua @@ -88,7 +88,7 @@ targetbotMacro = macro(100, function() if highestPriorityParams and not isInPz() then ui.target.right:setText(highestPriorityParams.creature:getName()) ui.config.right:setText(highestPriorityParams.config.name) - TargetBot.Creature.attack(highestPriorityParams, targets, looting) + TargetBot.Creature.attack(highestPriorityParams, targets, looting) if lootingStatus:len() > 0 then TargetBot.setStatus("Attack & " .. lootingStatus) elseif cavebotAllowance > now then @@ -96,7 +96,7 @@ targetbotMacro = macro(100, function() else TargetBot.setStatus("Attacking") if not lureEnabled then - TargetBot.setStatus("Attacking (luring off)") + TargetBot.setStatus("Attacking (luring off)") end end TargetBot.walk() @@ -121,7 +121,7 @@ end) config = Config.setup("targetbot_configs", configWidget, "json", function(name, enabled, data) if not data then ui.status.right:setText("Off") - return targetbotMacro.setOff() + return targetbotMacro.setOff() end TargetBot.Creature.resetConfigs() for _, value in ipairs(data["targeting"] or {}) do @@ -194,14 +194,14 @@ TargetBot.isOff = function() end TargetBot.setOn = function(val) - if val == false then + if val == false then return TargetBot.setOff(true) end config.setOn() end TargetBot.setOff = function(val) - if val == false then + if val == false then return TargetBot.setOn(true) end config.setOff() @@ -254,7 +254,6 @@ TargetBot.lootStatus = function() return looterStatus end - -- attacks local lastSpell = 0 local lastAttackSpell = 0 @@ -315,7 +314,7 @@ TargetBot.useAttackItem = function(item, subType, target, delay) if g_game.getClientVersion() < 780 then local tmpItem = g_game.findPlayerItem(item, subType) if not tmpItem then return end - g_game.useWith(tmpItem, target, subType) -- using item from bp + g_game.useWith(tmpItem, target, subType) -- using item from bp else g_game.useInventoryItemWith(item, target, subType) -- hotkey end @@ -325,4 +324,4 @@ end TargetBot.canLure = function() return lureEnabled -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/targetbot/target.otui b/mods/game_bot/default_configs/vBot_4.8/targetbot/target.otui index 6e0e4eafa5..2b91f01912 100644 --- a/mods/game_bot/default_configs/vBot_4.8/targetbot/target.otui +++ b/mods/game_bot/default_configs/vBot_4.8/targetbot/target.otui @@ -52,7 +52,7 @@ TargetBotPanel < Panel margin-right: 15 focusable: false auto-focus: first - + VerticalScrollBar id: listScrollbar anchors.top: parent.top @@ -60,7 +60,7 @@ TargetBotPanel < Panel anchors.right: parent.right pixels-scroll: true step: 10 - + BotSwitch id: configButton @onClick: | @@ -73,7 +73,7 @@ TargetBotPanel < Panel $!on: text: Show target editor - + Panel id: editor visible: false @@ -109,7 +109,7 @@ TargetBotPanel < Panel anchors.right: parent.right text: Remove width: 56 - + BotSwitch id: debug text: Show target priority diff --git a/mods/game_bot/default_configs/vBot_4.8/targetbot/walking.lua b/mods/game_bot/default_configs/vBot_4.8/targetbot/walking.lua index b256d6acf4..f4da77ea4c 100644 --- a/mods/game_bot/default_configs/vBot_4.8/targetbot/walking.lua +++ b/mods/game_bot/default_configs/vBot_4.8/targetbot/walking.lua @@ -17,7 +17,7 @@ TargetBot.walk = function() local dist = math.max(math.abs(pos.x-dest.x), math.abs(pos.y-dest.y)) if params.precision and params.precision >= dist then return end if params.marginMin and params.marginMax then - if dist >= params.marginMin and dist <= params.marginMax then + if dist >= params.marginMin and dist <= params.marginMax then return end end diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/AttackBot.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/AttackBot.lua index 2fe7ee12f0..93c40840ff 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/AttackBot.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/AttackBot.lua @@ -55,12 +55,12 @@ local patterns = { -- absolute { "Adjacent (exori, exori gran)", - "3x3 Wave (vis hur, tera hur)", + "3x3 Wave (vis hur, tera hur)", "Small Area (mas san, exori mas)", "Medium Area (mas flam, mas frigo)", "Large Area (mas vis, mas tera)", - "Short Beam (vis lux)", - "Large Beam (gran vis lux)", + "Short Beam (vis lux)", + "Large Beam (gran vis lux)", "Sweep (exori min)", -- 8 "Small Wave (gran frigo hur)", "Big Wave (flam hur, frigo hur)", @@ -72,9 +72,9 @@ local patterns = { local spellPatterns = { {}, -- blank, wont be used -- Area Runes, - { + { { -- cross - [[ + [[ 010 111 010 @@ -504,7 +504,7 @@ local posW = ek and [[ ]] -- AttackBotConfig --- create blank profiles +-- create blank profiles if not AttackBotConfig[panelName] or not AttackBotConfig[panelName][1] or #AttackBotConfig[panelName] ~= 5 then AttackBotConfig[panelName] = { [1] = { @@ -584,8 +584,8 @@ if not AttackBotConfig[panelName] or not AttackBotConfig[panelName][1] or #Attac }, } end - -if not AttackBotConfig.currentBotProfile or AttackBotConfig.currentBotProfile == 0 or AttackBotConfig.currentBotProfile > 5 then + +if not AttackBotConfig.currentBotProfile or AttackBotConfig.currentBotProfile == 0 or AttackBotConfig.currentBotProfile > 5 then AttackBotConfig.currentBotProfile = 1 end @@ -600,7 +600,7 @@ end setActiveProfile() if not currentSettings.AntiRsRange then - currentSettings.AntiRsRange = 5 + currentSettings.AntiRsRange = 5 end local setProfileName = function() @@ -613,7 +613,7 @@ ui.title.onClick = function(widget) widget:setOn(currentSettings.enabled) vBotConfigSave("atk") end - + ui.settings.onClick = function(widget) mainWindow:show() mainWindow:raise() @@ -687,7 +687,7 @@ end end panel.nextCategory.onClick = function() if category == #categories then - category = 1 + category = 1 else category = category + 1 end @@ -708,7 +708,7 @@ end panel.previousRange.onClick = function() local t = patterns[patternCategory] if pattern == 1 then - pattern = #t + pattern = #t else pattern = pattern - 1 end @@ -717,7 +717,7 @@ end panel.nextRange.onClick = function() local t = patterns[patternCategory] if pattern == #t then - pattern = 1 + pattern = 1 else pattern = pattern + 1 end @@ -782,7 +782,6 @@ end end end - -- refreshing values function refreshAttacks() if not currentSettings.attackTable then return end @@ -928,7 +927,6 @@ end currentSettings.AntiRsRange = value end - -- window elements mainWindow.closeButton.onClick = function() showSettings = false @@ -1009,31 +1007,31 @@ end -- public functions AttackBot = {} -- global table - + AttackBot.isOn = function() return currentSettings.enabled end - + AttackBot.isOff = function() return not currentSettings.enabled end - + AttackBot.setOff = function() currentSettings.enabled = false ui.title:setOn(currentSettings.enabled) vBotConfigSave("atk") end - + AttackBot.setOn = function() currentSettings.enabled = true ui.title:setOn(currentSettings.enabled) vBotConfigSave("atk") end - + AttackBot.getActiveProfile = function() return AttackBotConfig.currentBotProfile -- returns number 1-5 end - + AttackBot.setActiveProfile = function(n) if not n or not tonumber(n) or n < 1 or n > 5 then return error("[AttackBot] wrong profile parameter! should be 1 to 5 is " .. n) @@ -1049,7 +1047,6 @@ end mainWindow:focus() end - -- otui covered, now support functions function getPattern(category, pattern, safe) safe = safe and 2 or 1 @@ -1057,7 +1054,6 @@ function getPattern(category, pattern, safe) return spellPatterns[category][pattern][safe] end - function getMonstersInArea(category, posOrCreature, pattern, minHp, maxHp, safePattern, monsterNamesTable) -- monsterNamesTable can be nil local monsters = 0 @@ -1074,7 +1070,7 @@ function getMonstersInArea(category, posOrCreature, pattern, minHp, maxHp, safeP return 0 end end - end + end if category == 1 or category == 3 or category == 4 then if category == 1 or category == 3 then @@ -1128,7 +1124,7 @@ function executeAttackBotAction(categoryOrPos, idOrFormula, cooldown) cooldown = cooldown or 0 if categoryOrPos == 4 or categoryOrPos == 5 or categoryOrPos == 1 then cast(idOrFormula, cooldown) - elseif categoryOrPos == 3 then + elseif categoryOrPos == 3 then useWith(idOrFormula, target()) end end @@ -1200,7 +1196,7 @@ macro(100, function() local entry = child.params local attackData = entry.itemId > 100 and entry.itemId or entry.spell if entry.enabled and manapercent() >= entry.mana then - if (type(attackData) == "string" and canCast(entry.spell, not currentSettings.ignoreMana, not currentSettings.Cooldown)) or (entry.itemId > 100 and (not currentSettings.Visible or findItem(entry.itemId))) then + if (type(attackData) == "string" and canCast(entry.spell, not currentSettings.ignoreMana, not currentSettings.Cooldown)) or (entry.itemId > 100 and (not currentSettings.Visible or findItem(entry.itemId))) then -- first PVP scenario if currentSettings.pvpMode and target():getHealthPercent() >= entry.minHp and target():getHealthPercent() <= entry.maxHp and target():canShoot() then if entry.category == 2 then @@ -1251,4 +1247,4 @@ macro(100, function() end end end -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/AttackBot.otui b/mods/game_bot/default_configs/vBot_4.8/vBot/AttackBot.otui index f6329f474c..fb4ef83b08 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/AttackBot.otui +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/AttackBot.otui @@ -78,7 +78,7 @@ AttackBotBotPanel < Panel text: 2 margin-left: 4 size: 17 17 - + Button id: 3 anchors.verticalCenter: prev.verticalCenter @@ -93,8 +93,8 @@ AttackBotBotPanel < Panel anchors.left: prev.right text: 4 margin-left: 4 - size: 17 17 - + size: 17 17 + Button id: 5 anchors.verticalCenter: prev.verticalCenter @@ -102,7 +102,7 @@ AttackBotBotPanel < Panel text: 5 margin-left: 4 size: 17 17 - + Label id: name anchors.verticalCenter: prev.verticalCenter @@ -263,7 +263,7 @@ AttackBotPanel < Panel text-align: center text: Mana%: font: verdana-11px-rounded - + SpinBox id: manaPercent anchors.verticalCenter: prev.verticalCenter @@ -280,7 +280,7 @@ AttackBotPanel < Panel anchors.left: prev.right margin-left: 7 anchors.verticalCenter: prev.verticalCenter - text: Creatures: + text: Creatures: font: verdana-11px-rounded SpinBox @@ -306,7 +306,7 @@ AttackBotPanel < Panel anchors.left: prev.right margin-left: 7 anchors.verticalCenter: prev.verticalCenter - text: HP: + text: HP: font: verdana-11px-rounded SpinBox @@ -325,7 +325,7 @@ AttackBotPanel < Panel anchors.left: prev.right margin-left: 4 anchors.verticalCenter: prev.verticalCenter - text: - + text: - font: verdana-11px-rounded SpinBox @@ -344,7 +344,7 @@ AttackBotPanel < Panel anchors.left: prev.right margin-left: 7 anchors.verticalCenter: prev.verticalCenter - text: CD: + text: CD: font: verdana-11px-rounded SpinBox @@ -380,7 +380,7 @@ AttackBotPanel < Panel text: Move Down text-align: center font: cipsoftFont - + Button id: addEntry anchors.right: parent.right @@ -449,7 +449,7 @@ SettingsPanel < Panel text-align: center text: Reset Settings - CheckBox + CheckBox id: IgnoreMana anchors.top: parent.top anchors.left: parent.left @@ -477,7 +477,7 @@ SettingsPanel < Panel width: 30 minimum: 1 maximum: 10 - focusable: true + focusable: true margin-left: 5 CheckBox @@ -546,7 +546,7 @@ SettingsPanel < Panel width: 50 minimum: 1 maximum: 10 - focusable: true + focusable: true margin-left: 5 AttackBotWindow < MainWindow @@ -565,7 +565,7 @@ AttackBotWindow < MainWindow !text: tr('More important methods come first (Example: Exori gran above Exori)') text-align: left font: verdana-11px-rounded - color: #aeaeae + color: #aeaeae SettingsPanel id: settingsPanel @@ -589,7 +589,7 @@ AttackBotWindow < MainWindow margin-top: 10 anchors.left: parent.left margin-left: 2 - visible: false + visible: false Label id: shooterLabel @@ -599,11 +599,11 @@ AttackBotWindow < MainWindow text: Spell Shooter color: #fe4400 font: verdana-11px-rounded - visible: false + visible: false HorizontalSeparator anchors.left: parent.left - anchors.right: parent.right + anchors.right: parent.right anchors.bottom: closeButton.top margin-bottom: 10 @@ -621,4 +621,4 @@ AttackBotWindow < MainWindow anchors.verticalCenter: prev.verticalCenter size: 50 21 font: cipsoftFont - text: Settings \ No newline at end of file + text: Settings diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/BotServer.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/BotServer.lua index e6feb433cc..87efc3ff62 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/BotServer.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/BotServer.lua @@ -45,7 +45,6 @@ if rootWidget then botServerWindow = UI.createWindow('BotServerWindow') botServerWindow:hide() - botServerWindow.enabled:setOn(config.enabled) botServerWindow.enabled.onClick = function() config.enabled = not config.enabled @@ -56,7 +55,7 @@ if rootWidget then botServerWindow.Data.ServerStatus:setText("CONNECTING...") ui.botServer:setColor('#FFF380') botServerWindow.Data.ServerStatus:setColor('#FFF380') - else + else if BotServer._websocket then BotServer.terminate() end @@ -64,7 +63,7 @@ if rootWidget then ui.botServer:setColor('#E3242B') botServerWindow.Data.ServerStatus:setColor('#E3242B') botServerWindow.Data.Participants:setText("-") - botServerWindow.Data.Members:setTooltip('') + botServerWindow.Data.Members:setTooltip('') ServerMembers = {} serverCount = {} end @@ -122,7 +121,7 @@ function initBotServerListenFunctions() -- list BotServer.listen("list", function(name, data) - serverCount = regexMatch(json.encode(data), regex) + serverCount = regexMatch(json.encode(data), regex) ServerMembers = json.encode(data) end) @@ -159,12 +158,12 @@ function initBotServerListenFunctions() if config.broadcasts then broadcastMessage(name..": "..message) end - end) + end) end initBotServerListenFunctions() function updateStatusText() - if BotServer._websocket then + if BotServer._websocket then botServerWindow.Data.ServerStatus:setText("CONNECTED") botServerWindow.Data.ServerStatus:setColor('#03AC13') ui.botServer:setColor('#03AC13') @@ -182,7 +181,7 @@ function updateStatusText() text = text .. "\n" .. re[i][2] end end - botServerWindow.Data.Members:setTooltip(text) + botServerWindow.Data.Members:setTooltip(text) end end else @@ -211,7 +210,6 @@ botServerWindow.closeButton.onClick = function(widget) botServerWindow:hide() end - onAddThing(function(tile, thing) if config.mwallInfo and BotServer._websocket then if thing:isItem() and thing:getId() == 2129 then @@ -241,4 +239,4 @@ if config.vocation and BotServer._websocket then BotServer.send("voc", "yes") end -addSeparator() \ No newline at end of file +addSeparator() diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/BotServer.otui b/mods/game_bot/default_configs/vBot_4.8/vBot/BotServer.otui index 5ca327e563..887e5e49d9 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/BotServer.otui +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/BotServer.otui @@ -7,7 +7,7 @@ BotServerData < Panel Label id: label anchors.top: parent.top - anchors.left: parent.left + anchors.left: parent.left anchors.right: parent.right text-align: center !text: tr("BotServer Data") @@ -47,7 +47,7 @@ BotServerData < Panel margin-left: 6 margin-bottom: 4 text-align: center - text: Status: + text: Status: Label id: ServerStatus @@ -56,7 +56,7 @@ BotServerData < Panel margin-left: 10 width: 150 margin-bottom: 4 - text-align: left + text-align: left Label id: Participants @@ -73,7 +73,7 @@ BotServerData < Panel anchors.bottom: parent.bottom size: 80 21 text-align: center - text: Members: + text: Members: FeaturePanel < Panel size: 340 150 @@ -87,7 +87,7 @@ FeaturePanel < Panel anchors.horizontalCenter: parent.horizontalCenter text-align: center text: Features - + HorizontalSeparator id: sep anchors.top: prev.bottom @@ -135,7 +135,6 @@ FeaturePanel < Panel margin-left: 5 text: Broadcasts - TextEdit id: broadcastText anchors.bottom: parent.bottom @@ -176,7 +175,7 @@ BotServerWindow < MainWindow anchors.right: parent.right anchors.left: parent.left anchors.bottom: closeButton.top - margin-bottom: 8 + margin-bottom: 8 Button id: closeButton @@ -194,9 +193,9 @@ BotServerWindow < MainWindow anchors.left: parent.left margin-left: 5 height: 21 - + $!on: text: BotServer: OFF $on: - text: BotServer: ON \ No newline at end of file + text: BotServer: ON diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/Conditions.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/Conditions.lua index d9846d0bce..86d35f002a 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/Conditions.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/Conditions.lua @@ -20,7 +20,7 @@ Panel margin-left: 3 height: 17 text: Setup - + ]]) ui:setId(panelName) @@ -63,20 +63,17 @@ Panel widget:setOn(config.enabled) vBotConfigSave("heal") end - + ui.conditionList.onClick = function(widget) conditionsWindow:show() conditionsWindow:raise() conditionsWindow:focus() end - - local rootWidget = g_ui.getRootWidget() if rootWidget then conditionsWindow = UI.createWindow('ConditionsWindow', rootWidget) conditionsWindow:hide() - conditionsWindow.onVisibilityChange = function(widget, visible) if not visible then @@ -123,22 +120,22 @@ Panel conditionsWindow.Hold.HasteSpell:setText(config.hasteSpell) conditionsWindow.Hold.HasteSpell.onTextChange = function(widget, text) config.hasteSpell = text - end - + end + conditionsWindow.Hold.HasteCost:setText(config.hasteCost) conditionsWindow.Hold.HasteCost.onTextChange = function(widget, text) config.hasteCost = tonumber(text) end - + conditionsWindow.Hold.UtamoCost:setText(config.utamoCost) conditionsWindow.Hold.UtamoCost.onTextChange = function(widget, text) config.utamoCost = tonumber(text) - end - + end + conditionsWindow.Hold.UtanaCost:setText(config.utanaCost) conditionsWindow.Hold.UtanaCost.onTextChange = function(widget, text) config.utanaCost = tonumber(text) - end + end conditionsWindow.Hold.UturaCost:setText(config.uturaCost) conditionsWindow.Hold.UturaCost.onTextChange = function(widget, text) @@ -157,7 +154,7 @@ Panel config.curePoison = not config.curePoison widget:setChecked(config.curePoison) end - + conditionsWindow.Cure.CureCurse:setChecked(config.cureCurse) conditionsWindow.Cure.CureCurse.onClick = function(widget) config.cureCurse = not config.cureCurse @@ -241,11 +238,11 @@ Panel macro(500, function() if not config.enabled or modules.game_cooldown.isGroupCooldownIconActive(2) then return end if hppercent() > 95 then - if config.curePoison and mana() >= config.poisonCost and isPoisioned() then say("exana pox") - elseif config.cureCurse and mana() >= config.curseCost and isCursed() then say("exana mort") + if config.curePoison and mana() >= config.poisonCost and isPoisioned() then say("exana pox") + elseif config.cureCurse and mana() >= config.curseCost and isCursed() then say("exana mort") elseif config.cureBleed and mana() >= config.bleedCost and isBleeding() then say("exana kor") - elseif config.cureBurn and mana() >= config.burnCost and isBurning() then say("exana flam") - elseif config.cureElectrify and mana() >= config.electrifyCost and isEnergized() then say("exana vis") + elseif config.cureBurn and mana() >= config.burnCost and isBurning() then say("exana flam") + elseif config.cureElectrify and mana() >= config.electrifyCost and isEnergized() then say("exana vis") end end if (not config.ignoreInPz or not isInPz()) and config.holdUtura and mana() >= config.uturaCost and canCast(config.uturaType) and hppercent() < 90 then say(config.uturaType) @@ -259,4 +256,4 @@ Panel elseif ((not config.ignoreInPz or not isInPz()) and standTime() < 5000 and config.holdHaste and mana() >= config.hasteCost and not hasHaste() and not getSpellCoolDown(config.hasteSpell) and (not target() or not config.stopHaste or TargetBot.isCaveBotActionAllowed())) and standTime() < 3000 then say(config.hasteSpell) elseif config.cureParalyse and mana() >= config.paralyseCost and isParalyzed() and not getSpellCoolDown(config.paralyseSpell) then say(config.paralyseSpell) end - end) \ No newline at end of file + end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/Conditions.otui b/mods/game_bot/default_configs/vBot_4.8/vBot/Conditions.otui index ee8d43bec6..b76034e9da 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/Conditions.otui +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/Conditions.otui @@ -3,7 +3,7 @@ UturaComboBoxPopupMenuButton < ComboBoxPopupMenuButton UturaComboBox < ComboBox @onSetup: | self:addOption("Utura") - self:addOption("Utura Gran") + self:addOption("Utura Gran") CureConditions < Panel id: Cure @@ -104,7 +104,7 @@ CureConditions < Panel id: CureBleed anchors.verticalCenter: prev.verticalCenter anchors.right: parent.right - margin-right: 10 + margin-right: 10 Label id: label4 @@ -175,7 +175,7 @@ CureConditions < Panel margin-top: 10 text: Paralyse color: #ffaa00 - font: verdana-11px-rounded + font: verdana-11px-rounded Label id: label66 @@ -213,7 +213,7 @@ CureConditions < Panel anchors.verticalCenter: prev.verticalCenter anchors.left: prev.right margin-left: 10 - width: 100 + width: 100 font: verdana-11px-rounded HoldConditions < Panel @@ -231,7 +231,7 @@ HoldConditions < Panel margin-left: 5 text: Haste color: #ffaa00 - font: verdana-11px-rounded + font: verdana-11px-rounded Label id: label11 @@ -332,7 +332,7 @@ HoldConditions < Panel id: HoldUtamo anchors.verticalCenter: prev.verticalCenter anchors.right: parent.right - margin-right: 10 + margin-right: 10 Label id: label5 @@ -340,8 +340,8 @@ HoldConditions < Panel anchors.top: label4.bottom margin-top: 10 text: Recovery - color: #ffaa00 - font: verdana-11px-rounded + color: #ffaa00 + font: verdana-11px-rounded Label id: label55 @@ -401,7 +401,7 @@ HoldConditions < Panel anchors.horizontalCenter: IgnoreInPz.horizontalCenter anchors.top: IgnoreInPz.bottom margin-top: 8 - + Label anchors.verticalCenter: prev.verticalCenter anchors.left: prev.right @@ -425,7 +425,7 @@ ConditionsWindow < MainWindow id: label anchors.top: parent.top anchors.left: parent.left - text: Cure Conditions + text: Cure Conditions color: #88e3dd margin-left: 10 font: verdana-11px-rounded @@ -440,17 +440,17 @@ ConditionsWindow < MainWindow id: label anchors.top: parent.top anchors.right: parent.right - text: Hold Conditions + text: Hold Conditions color: #88e3dd margin-right: 100 - font: verdana-11px-rounded + font: verdana-11px-rounded HorizontalSeparator id: separator anchors.right: parent.right anchors.left: parent.left anchors.bottom: closeButton.top - margin-bottom: 8 + margin-bottom: 8 Button id: closeButton @@ -460,4 +460,4 @@ ConditionsWindow < MainWindow anchors.bottom: parent.bottom size: 45 21 margin-top: 15 - margin-right: 5 \ No newline at end of file + margin-right: 5 diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/Containers.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/Containers.lua index 827d0a585d..475ae82f27 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/Containers.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/Containers.lua @@ -330,7 +330,6 @@ end local lstBPs - local openContainer = function(id) local t = {getRight(), getLeft(), getAmmo()} -- if more slots needed then add them here for i=1,#t do @@ -654,7 +653,6 @@ local mainLoop = macro(150, function(macro) macro:setOff() end) - onContainerOpen(function(container, previousContainer) mainLoop:setOn() end) @@ -671,4 +669,4 @@ onContainerClose(function(container) if not container.lootContainer then mainLoop:setOn() end -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/Dropper.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/Dropper.lua index 96674b9823..dad5f0db1f 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/Dropper.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/Dropper.lua @@ -25,7 +25,7 @@ Panel local edit = setupUI([[ Panel height: 150 - + Label anchors.top: parent.top anchors.left: parent.left @@ -69,7 +69,7 @@ Panel anchors.top: prev.bottom anchors.left: parent.left anchors.right: parent.right - height: 32 + height: 32 ]]) edit:hide() @@ -102,22 +102,22 @@ end UI.Container(function() config.trashItems = edit.TrashItems:getItems() - end, true, nil, edit.TrashItems) + end, true, nil, edit.TrashItems) edit.TrashItems:setItems(config.trashItems) UI.Container(function() config.useItems = edit.UseItems:getItems() - end, true, nil, edit.UseItems) + end, true, nil, edit.UseItems) edit.UseItems:setItems(config.useItems) UI.Container(function() config.capItems = edit.CapItems:getItems() - end, true, nil, edit.CapItems) + end, true, nil, edit.CapItems) edit.CapItems:setItems(config.capItems) local function properTable(t) local r = {} - + for _, entry in pairs(t) do table.insert(r, entry.id) end @@ -143,4 +143,4 @@ macro(200, function() end end -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/Equipper.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/Equipper.lua index cc3c782997..16a872ab42 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/Equipper.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/Equipper.lua @@ -81,7 +81,7 @@ local slotWidgets = {eqPanel.head, eqPanel.body, eqPanel.legs, eqPanel.feet, eqP local function setCondition(first, n) local widget - local spinBox + local spinBox local textEdit if first then @@ -260,7 +260,7 @@ listPanel.up.onClick = function(widget) end listPanel.down.onClick = function(widget) - local focused = listPanel.list:getFocusedChild() + local focused = listPanel.list:getFocusedChild() local n = listPanel.list:getChildIndex(focused) local t = config.rules @@ -277,12 +277,12 @@ eqPanel.cloneEq.onClick = function(widget) eqPanel.head:setItemId(getHead() and getHead():getId() or 0) eqPanel.body:setItemId(getBody() and getBody():getId() or 0) eqPanel.legs:setItemId(getLeg() and getLeg():getId() or 0) - eqPanel.feet:setItemId(getFeet() and getFeet():getId() or 0) - eqPanel.neck:setItemId(getNeck() and getNeck():getId() or 0) + eqPanel.feet:setItemId(getFeet() and getFeet():getId() or 0) + eqPanel.neck:setItemId(getNeck() and getNeck():getId() or 0) eqPanel["left-hand"]:setItemId(getLeft() and getLeft():getId() or 0) eqPanel["right-hand"]:setItemId(getRight() and getRight():getId() or 0) - eqPanel.finger:setItemId(getFinger() and getFinger():getId() or 0) - eqPanel.ammo:setItemId(getAmmo() and getAmmo():getId() or 0) + eqPanel.finger:setItemId(getFinger() and getFinger():getId() or 0) + eqPanel.ammo:setItemId(getAmmo() and getAmmo():getId() or 0) end eqPanel.default.onClick = resetFields @@ -355,7 +355,7 @@ local function setupPreview(display, data) widget:setItemId(0) else widget:setChecked(false) - widget:setItemId(value) + widget:setItemId(value) end end end @@ -501,7 +501,7 @@ inputPanel.add.onClick = function(widget) end local ruleData = { - name = profileName, + name = profileName, data = t, enabled = true, visible = true, @@ -562,7 +562,7 @@ bossPanel.add.onClick = function() widget.remove.onClick = function() table.remove(config.bosses, table.find(config.bosses, name)) widget:destroy() - end + end table.insert(config.bosses, name) bossPanel.name:setText('') @@ -685,7 +685,6 @@ local function equipItem(id, slot) slot = 5 end - if g_game.getClientVersion() >= 910 then -- new tibia return g_game.equipItemId(id) @@ -696,7 +695,6 @@ local function equipItem(id, slot) end end - local function markChild(child) if mainWindow:isVisible() then for i, child in ipairs(listPanel.list:getChildren()) do @@ -708,7 +706,6 @@ local function markChild(child) end end - local missingItem = false local lastRule = false local correctEq = false @@ -736,14 +733,13 @@ EquipManager = macro(50, function() -- reset executed rule - -- first check unequip if unequipItem(rule.data) == true then delay(200) return end - -- equiploop + -- equiploop for slot, item in ipairs(rule.data) do if type(item) == "number" and item > 100 then if not isEquipped(item) then @@ -768,8 +764,6 @@ EquipManager = macro(50, function() -- even if nothing was done, exit function to hold rule return end - - end end -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/HealBot.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/HealBot.lua index 530f429e33..770a4e72bb 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/HealBot.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/HealBot.lua @@ -43,7 +43,7 @@ Panel text: 2 margin-left: 4 size: 17 17 - + Button id: 3 anchors.verticalCenter: prev.verticalCenter @@ -58,8 +58,8 @@ Panel anchors.left: prev.right text: 4 margin-left: 4 - size: 17 17 - + size: 17 17 + Button id: 5 anchors.verticalCenter: prev.verticalCenter @@ -67,7 +67,7 @@ Panel text: 5 margin-left: 4 size: 17 17 - + Label id: name anchors.verticalCenter: prev.verticalCenter @@ -146,7 +146,7 @@ if not HealBotConfig[healPanelName] or not HealBotConfig[healPanelName][1] or #H } end -if not HealBotConfig.currentHealBotProfile or HealBotConfig.currentHealBotProfile == 0 or HealBotConfig.currentHealBotProfile > 5 then +if not HealBotConfig.currentHealBotProfile or HealBotConfig.currentHealBotProfile == 0 or HealBotConfig.currentHealBotProfile > 5 then HealBotConfig.currentHealBotProfile = 1 end @@ -344,7 +344,7 @@ if rootWidget then end healWindow.healer.spells.addSpell.onClick = function(widget) - + local spellFormula = healWindow.healer.spells.spellFormula:getText():trim() local manaCost = tonumber(healWindow.healer.spells.manaCost:getText()) local spellTrigger = tonumber(healWindow.healer.spells.spellValue:getText()) @@ -353,19 +353,19 @@ if rootWidget then local source local equasion - if not manaCost then - warn("HealBot: incorrect mana cost value!") + if not manaCost then + warn("HealBot: incorrect mana cost value!") healWindow.healer.spells.spellFormula:setText('') healWindow.healer.spells.spellValue:setText('') - healWindow.healer.spells.manaCost:setText('') - return + healWindow.healer.spells.manaCost:setText('') + return end - if not spellTrigger then - warn("HealBot: incorrect condition value!") + if not spellTrigger then + warn("HealBot: incorrect condition value!") healWindow.healer.spells.spellFormula:setText('') healWindow.healer.spells.spellValue:setText('') healWindow.healer.spells.manaCost:setText('') - return + return end if spellSource == "Current Mana" then @@ -379,7 +379,7 @@ if rootWidget then else source = "burst" end - + if spellEquasion == "Above" then equasion = ">" elseif spellEquasion == "Below" then @@ -400,7 +400,7 @@ if rootWidget then end healWindow.healer.items.addItem.onClick = function(widget) - + local id = healWindow.healer.items.itemId:getItemId() local trigger = tonumber(healWindow.healer.items.itemValue:getText()) local src = healWindow.healer.items.itemSource:getCurrentOption().text @@ -426,7 +426,7 @@ if rootWidget then else source = "burst" end - + if eq == "Above" then equasion = ">" elseif eq == "Below" then @@ -498,7 +498,6 @@ if rootWidget then loadSettings() end - -- public functions HealBot = {} -- global table @@ -594,7 +593,7 @@ macro(100, function() elseif entry.sign == "<" and mana() <= entry.value then say(entry.spell) return - end + end elseif entry.origin == "burst" then if entry.sign == "=" and burstDamageValue() == entry.value then say(entry.spell) @@ -605,7 +604,7 @@ macro(100, function() elseif entry.sign == "<" and burstDamageValue() <= entry.value then say(entry.spell) return - end + end end else somethingIsOnCooldown = true @@ -613,7 +612,7 @@ macro(100, function() end end if not somethingIsOnCooldown then - standBySpells = true + standBySpells = true end end) @@ -682,7 +681,7 @@ macro(100, function() elseif entry.sign == "<" and mana() <= entry.value then g_game.useInventoryItemWith(entry.item, player) return - end + end elseif entry.origin == "burst" then if entry.sign == "=" and burstDamageValue() == entry.value then g_game.useInventoryItemWith(entry.item, player) @@ -693,7 +692,7 @@ macro(100, function() elseif entry.sign == "<" and burstDamageValue() <= entry.value then g_game.useInventoryItemWith(entry.item, player) return - end + end end end end @@ -709,4 +708,4 @@ end) onManaChange(function(player, mana, maxMana, oldMana, oldMaxMana) standByItems = false standBySpells = false -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/HealBot.otui b/mods/game_bot/default_configs/vBot_4.8/vBot/HealBot.otui index fb8cb03d7e..17affcc9cd 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/HealBot.otui +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/HealBot.otui @@ -48,7 +48,7 @@ SpellEntry < Label margin-right: 15 text-offset: 1 0 width: 15 - height: 15 + height: 15 ItemEntry < Label background-color: alpha @@ -84,7 +84,7 @@ ItemEntry < Label margin-right: 15 text-offset: 1 0 width: 15 - height: 15 + height: 15 SpellHealing < FlatPanel size: 490 130 @@ -120,13 +120,13 @@ SpellHealing < FlatPanel anchors.top: whenSpell.bottom text: Is margin-top: 9 - margin-left: 7 + margin-left: 7 font: verdana-11px-rounded SpellConditionBox id: spellCondition anchors.left: spellSource.left - anchors.top: spellSource.bottom + anchors.top: spellSource.bottom marin-top: 15 width: 80 font: verdana-11px-rounded @@ -143,7 +143,7 @@ SpellHealing < FlatPanel id: castSpell anchors.left: isSpell.left anchors.top: isSpell.bottom - text: Cast + text: Cast margin-top: 9 font: verdana-11px-rounded @@ -166,7 +166,7 @@ SpellHealing < FlatPanel id: manaCost anchors.left: spellFormula.left anchors.top: spellFormula.bottom - width: 40 + width: 40 font: verdana-11px-rounded TextList @@ -176,7 +176,7 @@ SpellHealing < FlatPanel anchors.top: parent.top padding: 1 padding-top: 2 - width: 270 + width: 270 margin-bottom: 7 margin-left: 7 margin-top: 10 @@ -214,7 +214,7 @@ SpellHealing < FlatPanel margin-right: 5 text: Move Down size: 55 17 - font: cipsoftFont + font: cipsoftFont ItemHealing < FlatPanel size: 490 120 @@ -250,13 +250,13 @@ ItemHealing < FlatPanel anchors.top: whenItem.bottom text: Is margin-top: 9 - margin-left: 7 + margin-left: 7 font: verdana-11px-rounded SpellConditionBox id: itemCondition anchors.left: itemSource.left - anchors.top: itemSource.bottom + anchors.top: itemSource.bottom marin-top: 15 width: 80 font: verdana-11px-rounded @@ -273,7 +273,7 @@ ItemHealing < FlatPanel id: useItem anchors.left: isItem.left anchors.top: isItem.bottom - text: Use + text: Use margin-top: 15 font: verdana-11px-rounded @@ -289,7 +289,7 @@ ItemHealing < FlatPanel anchors.top: parent.top padding: 1 padding-top: 2 - width: 270 + width: 270 margin-top: 10 margin-bottom: 7 margin-left: 8 @@ -362,7 +362,7 @@ HealBotSettingsPanel < Panel text: Additional Settings text-align: center font: verdana-11px-rounded - + HorizontalSeparator SettingCheckBox @@ -431,7 +431,7 @@ HealBotSettingsPanel < Panel anchors.top: prev.bottom margin-top: 3 anchors.left: parent.left - anchors.right: parent.right + anchors.right: parent.right Button id: ResetSettings @@ -454,7 +454,7 @@ HealWindow < MainWindow !text: tr('More important methods come first (Example: Exura gran above Exura)') text-align: left font: verdana-11px-rounded - color: #aeaeae + color: #aeaeae HealerPanel id: healer @@ -472,7 +472,7 @@ HealWindow < MainWindow anchors.right: parent.right anchors.left: parent.left anchors.bottom: closeButton.top - margin-bottom: 8 + margin-bottom: 8 Button id: closeButton @@ -489,4 +489,4 @@ HealWindow < MainWindow font: cipsoftFont anchors.left: parent.left anchors.bottom: parent.bottom - size: 45 21 \ No newline at end of file + size: 45 21 diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/Sio.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/Sio.lua index ade2c0dfdc..6d68c55ca7 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/Sio.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/Sio.lua @@ -20,7 +20,7 @@ Panel margin-left: 3 height: 17 text: Setup - + ]], parent) ui:setId(panelName) @@ -74,42 +74,42 @@ Panel config.customSpell = not config.customSpell widget:setOn(config.customSpell) end - sioListWindow.item:setOn(config.itemHeal) + sioListWindow.item:setOn(config.itemHeal) sioListWindow.item.onClick = function(widget) config.itemHeal = not config.itemHeal widget:setOn(config.itemHeal) end - sioListWindow.exuraSio:setOn(config.exuraSio) + sioListWindow.exuraSio:setOn(config.exuraSio) sioListWindow.exuraSio.onClick = function(widget) config.exuraSio = not config.exuraSio widget:setOn(config.exuraSio) - end - sioListWindow.exuraGranSio:setOn(config.exuraGranSio) + end + sioListWindow.exuraGranSio:setOn(config.exuraGranSio) sioListWindow.exuraGranSio.onClick = function(widget) config.exuraGranSio = not config.exuraGranSio widget:setOn(config.exuraGranSio) end - sioListWindow.exuraMasRes:setOn(config.exuraMasRes) + sioListWindow.exuraMasRes:setOn(config.exuraMasRes) sioListWindow.exuraMasRes.onClick = function(widget) config.exuraMasRes = not config.exuraMasRes widget:setOn(config.exuraMasRes) end - sioListWindow.vocation.ED:setOn(config.healEd) + sioListWindow.vocation.ED:setOn(config.healEd) sioListWindow.vocation.ED.onClick = function(widget) config.healEd = not config.healEd widget:setOn(config.healEd) end - sioListWindow.vocation.MS:setOn(config.healMs) + sioListWindow.vocation.MS:setOn(config.healMs) sioListWindow.vocation.MS.onClick = function(widget) config.healMs = not config.healMs widget:setOn(config.healMs) end - sioListWindow.vocation.EK:setOn(config.healEk) + sioListWindow.vocation.EK:setOn(config.healEk) sioListWindow.vocation.EK.onClick = function(widget) config.healEk = not config.healEk widget:setOn(config.healEk) end - sioListWindow.vocation.RP:setOn(config.healRp) + sioListWindow.vocation.RP:setOn(config.healRp) sioListWindow.vocation.RP.onClick = function(widget) config.healRp = not config.healRp widget:setOn(config.healRp) @@ -120,7 +120,7 @@ Panel sioListWindow.manaInfo:setText("Minimum Mana >= " .. config.minMana .. "%") end local updateFriendHpText = function() - sioListWindow.friendHp:setText("Heal Friend Below " .. config.minFriendHp .. "% hp") + sioListWindow.friendHp:setText("Heal Friend Below " .. config.minFriendHp .. "% hp") end local updateDistanceText = function() sioListWindow.distText:setText("Max Distance: " .. config.distance) @@ -167,7 +167,7 @@ Panel local voc = vBot.BotServerMembers[name] if not voc then return true end - + if voc == 11 then voc = 1 elseif voc == 12 then voc = 2 elseif voc == 13 then voc = 3 @@ -246,7 +246,7 @@ Panel end end end - end + end end) -addSeparator() \ No newline at end of file +addSeparator() diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/alarms.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/alarms.lua index 928beb6aa2..80c95409e9 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/alarms.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/alarms.lua @@ -44,20 +44,19 @@ ui.alerts.onClick = function() window:focus() end -local widgets = +local widgets = { - "AlarmCheckBox", - "AlarmCheckBoxAndSpinBox", + "AlarmCheckBox", + "AlarmCheckBoxAndSpinBox", "AlarmCheckBoxAndTextEdit" } -local parents = +local parents = { - window.list, + window.list, window.settingsList } - -- type addAlarm = function(id, title, defaultValue, alarmType, parent, tooltip) local widget = UI.createWidget(widgets[alarmType], parents[parent]) @@ -126,7 +125,7 @@ local function alarm(file, windowText) lastCall = now + 4000 -- alarm.ogg length is 6s end - + if modules.game_bot.g_app.getOs() == "windows" and config.flashClient.enabled then g_window.flash() end @@ -176,7 +175,7 @@ onTalk(function(name, level, mode, text, channelId, pos) end) -- health & mana -macro(100, function() +macro(100, function() if not config.enabled then return end if config.lowHealth.enabled then if hppercent() < config.lowHealth.value then @@ -197,7 +196,7 @@ macro(100, function() return alarm("/sounds/magnum.ogg", "Creature Detected!") end - if spec:isPlayer() then + if spec:isPlayer() then if spec:isTimedSquareVisible() and config.playerAttack.enabled then return alarm("/sounds/Player_Attack.ogg", "Player Attack!") end @@ -209,7 +208,7 @@ macro(100, function() if config.creatureName.enabled then local name = spec:getName():lower() local fragments = string.split(config.creatureName.value, ",") - + for i=1,#fragments do local frag = fragments[i]:trim():lower() @@ -220,4 +219,4 @@ macro(100, function() end end end -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/alarms.otui b/mods/game_bot/default_configs/vBot_4.8/vBot/alarms.otui index ea8faa61e0..03b03d19ef 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/alarms.otui +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/alarms.otui @@ -85,7 +85,7 @@ AlarmsWindow < MainWindow margin-top: 10 padding: 5 padding-left: 10 - layout: + layout: type: verticalBox fit-children: true @@ -122,7 +122,7 @@ AlarmsWindow < MainWindow maximum: 600 margin-left: 3 margin-right: 3 - background: #ffffff88 + background: #ffffff88 Button id: closeButton @@ -132,4 +132,4 @@ AlarmsWindow < MainWindow anchors.bottom: parent.bottom size: 45 21 margin-right: 5 - @onClick: self:getParent():hide() \ No newline at end of file + @onClick: self:getParent():hide() diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/analyzer.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/analyzer.lua index 74859f161e..2942ecb0fa 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/analyzer.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/analyzer.lua @@ -7,7 +7,7 @@ - Lee#7725 Thanks for ideas, graphics, functions, design tips! - + br, Vithrax ]] @@ -75,14 +75,14 @@ storage.analyzers.outfits = storage.analyzers.outfits or {} local trackedLoot = storage.analyzers.trackedLoot --destroy old windows -local windowsTable = {"MainAnalyzerWindow", - "HuntingAnalyzerWindow", - "LootAnalyzerWindow", - "SupplyAnalyzerWindow", - "ImpactAnalyzerWindow", - "XPAnalyzerWindow", - "PartyAnalyzerWindow", - "DropTracker", +local windowsTable = {"MainAnalyzerWindow", + "HuntingAnalyzerWindow", + "LootAnalyzerWindow", + "SupplyAnalyzerWindow", + "ImpactAnalyzerWindow", + "XPAnalyzerWindow", + "PartyAnalyzerWindow", + "DropTracker", "CaveBotStats", "BossTracker" } @@ -331,7 +331,6 @@ label:setColor('#ED7117') local suppliesByRefill = UI.createWidget("AnalyzerItemsPanel", statsWindow.contentsPanel) UI.Separator(statsWindow.contentsPanel) - --huntig local sessionTimeLabel = UI.DualLabel("Session:", "00:00h", {}, huntingWindow.contentsPanel).right local xpGainLabel = UI.DualLabel("XP Gain:", "0", {}, huntingWindow.contentsPanel).right @@ -348,7 +347,6 @@ local killedList = UI.createWidget("AnalyzerListPanel", huntingWindow.contentsPa UI.DualLabel("Looted items:", "", {maxWidth = 200}, huntingWindow.contentsPanel) local lootList = UI.createWidget("AnalyzerListPanel", huntingWindow.contentsPanel) - --party UI.Button("Copy to Clipboard", function() clipboardData() end, partyHuntWindow.contentsPanel) UI.Button("Reset Sessions", function() @@ -410,14 +408,14 @@ local function createTrackedItems() trackedLoot[tostring(id)] = 0 drops:setText("Loot Drops: 0") end - + for i, child in pairs(dropLoot:getChildren()) do child:setTooltip("Double click to reset or clear item to remove.") end item.onItemChange = function(widget) local id = widget:getItemId() - if id == 0 then + if id == 0 then trackedLoot[widget:getParent():getId()] = nil if tonumber(widget:getParent():getId()) then widget:getParent():destroy() @@ -427,7 +425,7 @@ local function createTrackedItems() widget:getParent():setId("blank") name:setText("Set Item to start track.") drops:setText("Loot Drops: 0") - return + return end -- only amount have changed, ignore @@ -438,9 +436,9 @@ local function createTrackedItems() warn("vBot[Drop Tracker]: Item already added!") name:setText("Set Item to start track.") widget:setItemId(0) - return + return end - + widget:setImageSource('') drops:setText("Loot Drops: 0") name:setText(itemName) @@ -473,7 +471,7 @@ UI.Button("Add item to track drops", function() item.onItemChange = function(widget) local id = widget:getItemId() - if id == 0 then + if id == 0 then trackedLoot[widget:getParent():getId()] = nil if tonumber(widget:getParent():getId()) then widget:getParent():destroy() @@ -483,7 +481,7 @@ UI.Button("Add item to track drops", function() widget:getParent():setId("blank") name:setText("Set Item to start track.") drops:setText("Loot Drops: 0") - return + return end -- only amount have changed, ignore @@ -494,7 +492,7 @@ UI.Button("Add item to track drops", function() warn("vBot[Drop Tracker]: Item already added!") name:setText("Set Item to start track.") widget:setItemId(0) - return + return end widget:setImageSource('') @@ -509,7 +507,6 @@ end, dropTrackerWindow.contentsPanel) UI.Separator(dropTrackerWindow.contentsPanel) createTrackedItems() - --loot local lootInLootAnalyzerLabel = UI.DualLabel("Gold Value:", "0", {}, lootWindow.contentsPanel).right local lootHourInLootAnalyzerLabel = UI.DualLabel("Per Hour:", "0", {}, lootWindow.contentsPanel).right @@ -522,9 +519,6 @@ local lootGraph = UI.createWidget("AnalyzerGraph", lootWindow.contentsPanel) lootGraph:setTitle("Loot/h") drawGraph(lootGraph, 0) - - - --supplies local suppliesInSuppliesAnalyzerLabel = UI.DualLabel("Gold Value:", "0", {}, supplyWindow.contentsPanel).right local suppliesHourInSuppliesAnalyzerLabel = UI.DualLabel("Per Hour:", "0", {}, supplyWindow.contentsPanel).right @@ -535,10 +529,7 @@ UI.Separator(supplyWindow.contentsPanel) --//graph local supplyGraph = UI.createWidget("AnalyzerGraph", supplyWindow.contentsPanel) supplyGraph:setTitle("Waste/h") - drawGraph(supplyGraph, 0) - - - + drawGraph(supplyGraph, 0) -- impact @@ -552,9 +543,9 @@ UI.Separator(impactWindow.contentsPanel) local dmgGraph = UI.createWidget("AnalyzerGraph", impactWindow.contentsPanel) dmgGraph:setTitle("DPS") drawGraph(dmgGraph, 0) - - ---- distribution + + +--- distribution UI.Separator(impactWindow.contentsPanel) local title2 = UI.DualLabel("Damage Distribution", "", {maxWidth = 150}, impactWindow.contentsPanel).left title2:setColor('#FABD02') @@ -570,7 +561,6 @@ top3.left:setWidth(135) top4.left:setWidth(135) top5.left:setWidth(135) - --- healing UI.Separator(impactWindow.contentsPanel) local title3 = UI.DualLabel("Healing", "", {}, impactWindow.contentsPanel).left @@ -582,13 +572,7 @@ UI.Separator(impactWindow.contentsPanel) --//graph local healGraph = UI.createWidget("AnalyzerGraph", impactWindow.contentsPanel) healGraph:setTitle("HPS") - drawGraph(healGraph, 0) - - - - - - + drawGraph(healGraph, 0) --xp local xpGrainInXpLabel = UI.DualLabel("XP Gain:", "0", {}, xpWindow.contentsPanel).right @@ -601,10 +585,6 @@ UI.Separator(xpWindow.contentsPanel) local xpGraph = UI.createWidget("AnalyzerGraph", xpWindow.contentsPanel) xpGraph:setTitle("XP/h") drawGraph(xpGraph, 0) - - - - --############################################# --############################################# UI DONE @@ -623,7 +603,7 @@ local data = {} local function getColor(v) if v >= 10000000 then -- 10kk, red - return "#FF0000" + return "#FF0000" elseif v >= 5000000 then -- 5kk, orange return "#FFA500" elseif v >= 1000000 then -- 1kk, yellow @@ -758,14 +738,14 @@ local function sendData() local outfit = player:getOutfit() outfit.mount = 0 local t = { - totalDmg, - totalHeal, - balance, - hppercent(), - manapercent(), - outfit, - player:isPartyLeader(), - lootWorth, + totalDmg, + totalHeal, + balance, + hppercent(), + manapercent(), + outfit, + player:isPartyLeader(), + lootWorth, wasteWorth, modules.game_skills.skillsWindow.contentsPanel.stamina.value:getText(), format_thousand(expGained()), @@ -792,14 +772,14 @@ if BotServer._websocket then resetAnalyzerSessionData() else membersData[name] = { - damage = message[1], - heal = message[2], - balance = message[3], - hp = message[4], - mana = message[5], - outfit = message[6], - leader = message[7], - loot = message[8], + damage = message[1], + heal = message[2], + balance = message[3], + hp = message[4], + mana = message[5], + outfit = message[6], + leader = message[7], + loot = message[8], waste = message[9], stamina = message[10], expGained = message[11], @@ -813,7 +793,6 @@ if BotServer._websocket then widget:setId(widgetName) widget.lastUpdate = now - local t = membersData[name] widget.name:setText(name) widget.name:setColor("white") @@ -865,7 +844,6 @@ if BotServer._websocket then end) end - function hightlightText(widget, color, duration) for i=0,duration do schedule(i * 250, function() @@ -905,7 +883,7 @@ onTextMessage(function(mode, text) -- add timestamp, creature part and color it as white add(t, os.date('%H:%M') .. ' ' .. split[1]..": ", "#FFFFFF", true) - add(messageT, split[1]..": ", "#FFFFFF", true) + add(messageT, split[1]..": ", "#FFFFFF", true) -- main part if re ~= 0 then @@ -961,7 +939,7 @@ onTextMessage(function(mode, text) if modules.game_textmessage.messagesPanel.centerTextMessagePanel.highCenterLabel:getText() == text then modules.game_textmessage.messagesPanel.centerTextMessagePanel.highCenterLabel:setColoredText(messageT) - schedule(math.max(#text * 50, 2000), function() + schedule(math.max(#text * 50, 2000), function() modules.game_textmessage.messagesPanel.centerTextMessagePanel.highCenterLabel:setVisible(false) end) end @@ -1054,7 +1032,6 @@ mainWindow.contentsPanel.Settings.onClick = function() settingsWindow:raise() settingsWindow:focus() end - -- extras window settingsWindow.closeButton.onClick = function() @@ -1075,7 +1052,6 @@ local function getFrame(v) end end - displayCondition = function(menuPosition, lookThing, useThing, creatureThing) if lookThing and not lookThing:isCreature() and not lookThing:isNotMoveable() and lookThing:isPickupable() then return true @@ -1106,11 +1082,11 @@ local function setFrames() if id == 0 or not hovered then return interface.removeMenuHook('analyzer') end - interface.addMenuHook('analyzer', 'Price:', function() end, displayCondition, price) + interface.addMenuHook('analyzer', 'Price:', function() end, displayCondition, price) end end - end -end + end +end setFrames() onContainerOpen(function(container, previousContainer) @@ -1230,7 +1206,7 @@ local valueInSeconds = function(t) return math.ceil(d/((now-time)/1000)) end -local regex = "You lose ([0-9]*) hitpoints due to an attack by ([a-z]*) ([a-z A-z-]*)" +local regex = "You lose ([0-9]*) hitpoints due to an attack by ([a-z]*) ([a-z A-z-]*)" onTextMessage(function(mode, text) local value = getFirstNumberInText(text) if mode == 21 then -- damage dealt @@ -1389,12 +1365,12 @@ function refreshWaste() suppliesByRefill:destroyChildren() suppliesByRound:destroyChildren() - local parents = {supplyItems, suppliesByRound, suppliesByRefill} + local parents = {supplyItems, suppliesByRound, suppliesByRefill} for k,v in pairs(usedItems) do for i=1,#parents do - local amount = i == 1 and v.count or - i == 2 and v.count/(vBot.CaveBotData.rounds + 1) or + local amount = i == 1 and v.count or + i == 2 and v.count/(vBot.CaveBotData.rounds + 1) or i == 3 and v.count/(vBot.CaveBotData.refills + 1) amount = math.floor(amount) local label1 = UI.createWidget("AnalyzerLootItem", parents[i]) @@ -1418,7 +1394,7 @@ local lastCap = freecap() onAddItem(function(container, slot, item, oldItem) if not table.find(containers, container:getContainerItem():getId()) then return end if isInPz() then return end - if slot > 0 then return end + if slot > 0 then return end if freecap() >= lastCap then return end local name = item:getId() local tmpname = item:getId() == 3031 and "gold coin" or item:getId() == 3035 and "platinum coin" or item:getId() == 3043 and "crystal coin" or item:getMarketData().name @@ -1436,9 +1412,9 @@ end) onContainerUpdateItem(function(container, slot, item, oldItem) if not table.find(containers, container:getContainerItem():getId()) then return end if not oldItem then return end - if isInPz() then return end + if isInPz() then return end if freecap() == lastCap then return end - + local tmpname = item:getId() == 3031 and "gold coin" or item:getId() == 3035 and "platinum coin" or item:getId() == 3043 and "crystal coin" or item:getMarketData().name local amount = item:getCount() - oldItem:getCount() if amount < 0 then @@ -1664,7 +1640,6 @@ macro(500, function() lootInLootAnalyzerLabel:setText(format_thousand(lootWorth)) lootHourInLootAnalyzerLabel:setText(format_thousand(lootHour())) - --supply window suppliesInSuppliesAnalyzerLabel:setText(format_thousand(wasteWorth)) suppliesHourInSuppliesAnalyzerLabel:setText(format_thousand(wasteHour())) @@ -1695,7 +1670,6 @@ macro(500, function() nextLevelLabel:setText(timeToLevel()) progressBar:setPercent(modules.game_skills.skillsWindow.contentsPanel.level.percent:getPercent()) - --stats totalRounds:setText(vBot.CaveBotData.rounds) avRoundTime:setText(niceTimeFormat(avgTable(vBot.CaveBotData.time),true)) @@ -1768,19 +1742,16 @@ end Analyzer.getTotalProfit = function() local lootWorth, wasteWorth, balance = bottingStats() - return lootWorth end Analyzer.getTotalWaste = function() local lootWorth, wasteWorth, balance = bottingStats() - return wasteWorth end Analyzer.getBalance = function() local lootWorth, wasteWorth, balance = bottingStats() - return balance end @@ -1823,4 +1794,4 @@ Analyzer.getCaveBotStats = function() roundSupplies = round, -- { [id] = amount, [id2] = amount ...} refillSupplies = refill -- { [id] = amount, [id2] = amount ...} } -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/analyzer.otui b/mods/game_bot/default_configs/vBot_4.8/vBot/analyzer.otui index 216d9583cb..761a9b4c99 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/analyzer.otui +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/analyzer.otui @@ -33,7 +33,6 @@ BossCreaturePanel < Panel font: verdana-11px-rounded text: 19h 20min - SearchPanel < TextEdit placeholder: Type to search margin-top: 1 @@ -78,13 +77,12 @@ TrackerItem < Panel margin-top: 3 anchors.bottom: Item.bottom anchors.left: prev.left - anchors.right: parent.right + anchors.right: parent.right font: verdana-11px-rounded text-align:left text: Loot Drops: 0 color: #CCCCCC - DualLabel < Label height: 15 text-offset: 4 0 @@ -122,7 +120,7 @@ MemberWidget < Panel anchors.right: parent.right text: Player Name font: verdana-11px-rounded - text-align: left + text-align: left ProgressBar id: health @@ -132,7 +130,7 @@ MemberWidget < Panel margin-top: 2 height: 7 background-color: #00c000 - phantom: false + phantom: false ProgressBar id: mana @@ -157,7 +155,7 @@ MemberWidget < Panel anchors.left: parent.left anchors.right: parent.right margin-top: 2 - text: Damage: + text: Damage: DualLabel id: healing @@ -165,7 +163,7 @@ MemberWidget < Panel anchors.left: parent.left anchors.right: parent.right margin-top: 2 - text: Healing: + text: Healing: AnalyzerPriceLabel < Label background-color: alpha @@ -191,7 +189,6 @@ AnalyzerListPanel < Panel type: verticalBox fit-children: true - ListLabel < Label height: 15 font: verdana-11px-rounded @@ -212,7 +209,7 @@ AnalyzerLootItem < UIItem height: 37 margin-left: 1 virtual: true - background-color: alpha + background-color: alpha Label id: count @@ -276,8 +273,8 @@ MainAnalyzerWindow < MiniWindow AnalyzerButton id: SupplyAnalyzer - text: Supply Analyzer - + text: Supply Analyzer + AnalyzerButton id: ImpactAnalyzer text: Impact Analyzer @@ -315,7 +312,7 @@ MainAnalyzerWindow < MiniWindow text: Reset Session color: #FF0000 -HuntingAnalyzer < MiniWindow +HuntingAnalyzer < MiniWindow id: HuntingAnalyzerWindow text: Hunt Analyzer icon: /images/topbuttons/analyzers @@ -325,7 +322,7 @@ HuntingAnalyzer < MiniWindow layout: verticalBox LootAnalyzer < MiniWindow - id: LootAnalyzerWindow + id: LootAnalyzerWindow text: Loot Analyzer icon: /images/topbuttons/analyzers @@ -334,7 +331,7 @@ LootAnalyzer < MiniWindow layout: verticalBox SupplyAnalyzer < MiniWindow - id: SupplyAnalyzerWindow + id: SupplyAnalyzerWindow text: Supply Analyzer icon: /images/topbuttons/analyzers @@ -343,7 +340,7 @@ SupplyAnalyzer < MiniWindow layout: verticalBox ImpactAnalyzer < MiniWindow - id: ImpactAnalyzerWindow + id: ImpactAnalyzerWindow text: Impact Analyzer icon: /images/topbuttons/analyzers @@ -352,7 +349,7 @@ ImpactAnalyzer < MiniWindow layout: verticalBox XPAnalyzer < MiniWindow - id: XPAnalyzerWindow + id: XPAnalyzerWindow text: XP Analyzer height: 150 icon: /images/topbuttons/analyzers @@ -462,7 +459,7 @@ FeaturesWindow < MainWindow anchors.verticalCenter: prev.verticalCenter anchors.right: CustomPrices.right text: Add - font: verdana-11px-rounded + font: verdana-11px-rounded HorizontalSeparator anchors.left: ID.right @@ -485,7 +482,7 @@ FeaturesWindow < MainWindow anchors.top: prev.top margin-top: 20 text: Loot Channel - font: verdana-11px-rounded + font: verdana-11px-rounded BotSwitch id: RarityFrames @@ -495,13 +492,13 @@ FeaturesWindow < MainWindow anchors.top: secondSeparator.top margin-top: 20 text: Rarity Frames - font: verdana-11px-rounded + font: verdana-11px-rounded HorizontalSeparator anchors.right: parent.right anchors.left: parent.left anchors.bottom: closeButton.top - margin-bottom: 8 + margin-bottom: 8 Button id: closeButton @@ -511,4 +508,4 @@ FeaturesWindow < MainWindow anchors.bottom: parent.bottom size: 45 21 margin-top: 15 - margin-right: 5 \ No newline at end of file + margin-right: 5 diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/antiRs.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/antiRs.lua index 02160acc9a..32480be44e 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/antiRs.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/antiRs.lua @@ -30,4 +30,4 @@ onTextMessage(function(mode, text) safeExit() end) end -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/cast_food.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/cast_food.lua index 187738d830..1bdd1042d3 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/cast_food.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/cast_food.lua @@ -19,4 +19,4 @@ if voc() ~= 1 and voc() ~= 11 then cast("exevo pan", 5000) end end) -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/cavebot_control_panel.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/cavebot_control_panel.lua index 765a640de0..69ab85348f 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/cavebot_control_panel.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/cavebot_control_panel.lua @@ -8,7 +8,7 @@ CaveBotControlPanel < Panel fit-children: true HorizontalSeparator - + Label text-align: center text: CaveBot Control Panel @@ -16,7 +16,7 @@ CaveBotControlPanel < Panel margin-top: 3 HorizontalSeparator - + Panel id: buttons margin-top: 2 @@ -60,4 +60,4 @@ end, panel.buttons) local backOffline = UI.Button("Offline", function(widget) storage.caveBot.backOffline = true print("[CaveBot] Going back to city on next supply check and going to label 'toOfflineTraining' on depositer action.") -end, panel.buttons) \ No newline at end of file +end, panel.buttons) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/combo.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/combo.lua index b97c118497..d3fc3d8789 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/combo.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/combo.lua @@ -100,7 +100,7 @@ if rootWidget then comboWindow.server.targetServerLeaderToggle.onClick = function(widget) config.serverLeaderTarget = not config.serverLeaderTarget widget:setOn(config.serverLeaderTarget) - end + end -- buttons comboWindow.closeButton.onClick = function(widget) @@ -136,38 +136,38 @@ if rootWidget then comboWindow.trigger.onCastToggle.onClick = function(widget) config.onCastEnabled = not config.onCastEnabled widget:setChecked(config.onCastEnabled) - end + end comboWindow.actions.followLeaderToggle:setChecked(config.followLeaderEnabled) comboWindow.actions.followLeaderToggle.onClick = function(widget) config.followLeaderEnabled = not config.followLeaderEnabled widget:setChecked(config.followLeaderEnabled) end - + comboWindow.actions.attackLeaderTargetToggle:setChecked(config.attackLeaderTargetEnabled) comboWindow.actions.attackLeaderTargetToggle.onClick = function(widget) config.attackLeaderTargetEnabled = not config.attackLeaderTargetEnabled widget:setChecked(config.attackLeaderTargetEnabled) - end - + end + comboWindow.actions.attackSpellToggle:setChecked(config.attackSpellEnabled) comboWindow.actions.attackSpellToggle.onClick = function(widget) config.attackSpellEnabled = not config.attackSpellEnabled widget:setChecked(config.attackSpellEnabled) end - + comboWindow.actions.attackItemToggle:setChecked(config.attackItemEnabled) comboWindow.actions.attackItemToggle.onClick = function(widget) config.attackItemEnabled = not config.attackItemEnabled widget:setChecked(config.attackItemEnabled) end - + -- text edits comboWindow.trigger.onSayLeader:setText(config.sayLeader) comboWindow.trigger.onSayLeader.onTextChange = function(widget, text) config.sayLeader = text end - + comboWindow.trigger.onShootLeader:setText(config.shootLeader) comboWindow.trigger.onShootLeader.onTextChange = function(widget, text) config.shootLeader = text @@ -182,7 +182,7 @@ if rootWidget then comboWindow.trigger.onSayPhrase.onTextChange = function(widget, text) config.sayPhrase = text end - + comboWindow.actions.attackSpell:setText(config.spell) comboWindow.actions.attackSpell.onTextChange = function(widget, text) config.spell = text @@ -191,7 +191,7 @@ if rootWidget then comboWindow.server.botServerLeader:setText(config.serverLeader) comboWindow.server.botServerLeader.onTextChange = function(widget, text) config.serverLeader = text - end + end end -- bot server @@ -215,8 +215,8 @@ macro(10, function() end) comboWindow.server.partyButton.onClick = function(widget) - if config.serverEnabled and config.enabled then - if config.serverLeader:len() > 0 and storage.BotServerChannel:len() > 0 then + if config.serverEnabled and config.enabled then + if config.serverLeader:len() > 0 and storage.BotServerChannel:len() > 0 then talkPrivate(config.serverLeader, "request invite " .. storage.BotServerChannel) else error("Request failed. Lack of data.") @@ -266,7 +266,7 @@ onTalk(function(name, level, mode, text, channelId, pos) end end end - -- [[ End of Frosty's Code ]] -- + -- [[ End of Frosty's Code ]] -- if config.enabled and config.enabled then if name:lower() == config.sayLeader:lower() and string.find(text, config.sayPhrase) and config.onSayEnabled then startCombo = true @@ -302,7 +302,7 @@ onTalk(function(name, level, mode, text, channelId, pos) end) onMissle(function(missle) - if config.enabled and config.onShootEnabled then + if config.enabled and config.onShootEnabled then if not config.shootLeader or config.shootLeader:len() == 0 then return end @@ -329,7 +329,7 @@ onMissle(function(missle) end if config.attackSpellEnabled and config.spell:len() > 1 then say(config.spell) - end + end end end end) @@ -349,7 +349,6 @@ macro(10, function() end end) - local toFollow local toFollowPos = {} @@ -440,4 +439,4 @@ if BotServer._websocket and config.enabled and config.serverEnabled then useWith(config.item, tile:getTopUseThing()) end end) -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/combo.otui b/mods/game_bot/default_configs/vBot_4.8/vBot/combo.otui index b89013acc8..fcf21f38b9 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/combo.otui +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/combo.otui @@ -3,14 +3,14 @@ AttackComboBoxPopupMenuButton < ComboBoxPopupMenuButton AttackComboBox < ComboBox @onSetup: | self:addOption("LEADER TARGET") - self:addOption("COMMAND TARGET") + self:addOption("COMMAND TARGET") FollowComboBoxPopupMenu < ComboBoxPopupMenu FollowComboBoxPopupMenuButton < ComboBoxPopupMenuButton FollowComboBox < ComboBox @onSetup: | self:addOption("LEADER TARGET") - self:addOption("SERVER LEADER TARGET") + self:addOption("SERVER LEADER TARGET") self:addOption("LEADER") self:addOption("SERVER LEADER") @@ -35,7 +35,7 @@ ComboTrigger < Panel anchors.left: triggerLabel1.right anchors.top: triggerLabel1.top text: Leader: - margin-left: 35 + margin-left: 35 TextEdit id: onSayLeader @@ -75,14 +75,14 @@ ComboTrigger < Panel anchors.top: triggerLabel1.bottom text: On Shoot margin-top: 5 - color: #ffaa00 + color: #ffaa00 Label id: leaderLabel1 anchors.left: triggerLabel2.right anchors.top: triggerLabel2.top text: Leader: - margin-left: 24 + margin-left: 24 TextEdit id: onShootLeader @@ -92,7 +92,7 @@ ComboTrigger < Panel anchors.right: onSayPhrase.right margin-left: 5 width: 120 - font: cipsoftFont + font: cipsoftFont CheckBox id: onShootToggle @@ -107,14 +107,14 @@ ComboTrigger < Panel anchors.top: triggerLabel2.bottom text: On Cast margin-top: 5 - color: #ffaa00 + color: #ffaa00 Label id: leaderLabel2 anchors.left: triggerLabel3.right anchors.top: triggerLabel3.top text: Leader: - margin-left: 32 + margin-left: 32 TextEdit id: onCastLeader @@ -124,14 +124,14 @@ ComboTrigger < Panel anchors.right: onSayPhrase.right margin-left: 5 width: 120 - font: cipsoftFont + font: cipsoftFont CheckBox id: onCastToggle anchors.left: onCastLeader.right anchors.top: onCastLeader.top margin-top: 1 - margin-left: 5 + margin-left: 5 ComboActions < Panel id: actions @@ -148,23 +148,23 @@ ComboActions < Panel margin-top: 5 margin-left: 3 height: 15 - color: #ffaa00 + color: #ffaa00 FollowComboBox id: followLeader anchors.left: prev.right - anchors.top: prev.top - margin-left: 7 + anchors.top: prev.top + margin-left: 7 height: 15 width: 145 - font: cipsoftFont + font: cipsoftFont CheckBox id: followLeaderToggle anchors.left: followLeader.right anchors.top: followLeader.top margin-top: 2 - margin-left: 5 + margin-left: 5 Label id: label2 @@ -177,8 +177,8 @@ ComboActions < Panel AttackComboBox id: attackLeaderTarget anchors.left: prev.right - anchors.top: prev.top - margin-left: 5 + anchors.top: prev.top + margin-left: 5 height: 15 width: 145 font: cipsoftFont @@ -201,9 +201,9 @@ ComboActions < Panel TextEdit id: attackSpell anchors.left: prev.right - anchors.top: prev.top + anchors.top: prev.top anchors.right: attackLeaderTarget.right - margin-left: 17 + margin-left: 17 height: 15 width: 145 font: cipsoftFont @@ -213,7 +213,7 @@ ComboActions < Panel anchors.left: attackSpell.right anchors.top: attackSpell.top margin-top: 2 - margin-left: 5 + margin-left: 5 Label id: label4 @@ -231,7 +231,7 @@ ComboActions < Panel CheckBox id: attackItemToggle - anchors.left: prev.right + anchors.left: prev.right anchors.verticalCenter: prev.verticalCenter margin-left: 5 @@ -246,12 +246,12 @@ ComboActions < Panel text-wrap: true multiline: true -BotServer < Panel +BotServer < Panel id: server image-source: /images/ui/panel_flat image-border: 6 padding: 3 - size: 220 100 + size: 220 100 Label id: labelX @@ -259,9 +259,9 @@ BotServer < Panel anchors.top: parent.top text: Leader: height: 15 - color: #ffaa00 + color: #ffaa00 margin-left: 3 - margin-top: 5 + margin-top: 5 TextEdit id: botServerLeader @@ -312,7 +312,7 @@ BotServer < Panel height: 30 margin-left: 3 margin-right: 3 - text: Triggers + text: Triggers ComboWindow < MainWindow !text: tr('Combo Options') @@ -333,7 +333,7 @@ ComboWindow < MainWindow text: Combo Trigger color: #ff7700 - ComboActions + ComboActions id: actions anchors.top: trigger.bottom anchors.left: trigger.left @@ -346,13 +346,13 @@ ComboWindow < MainWindow margin-left: 10 margin-top: 85 text: Combo Actions - color: #ff7700 + color: #ff7700 - BotServer + BotServer id: server anchors.top: actions.top anchors.left: actions.right - margin-left: 10 + margin-left: 10 Label id: title @@ -368,7 +368,7 @@ ComboWindow < MainWindow anchors.right: parent.right anchors.left: parent.left anchors.bottom: closeButton.top - margin-bottom: 8 + margin-bottom: 8 Button id: closeButton @@ -388,4 +388,4 @@ ComboWindow < MainWindow anchors.top: closeButton.top margin-right: 10 size: 45 21 - @onClick: g_platform.openUrl("http://bot.otclient.ovh/books/scripts/page/combobot") \ No newline at end of file + @onClick: g_platform.openUrl("http://bot.otclient.ovh/books/scripts/page/combobot") diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/configs.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/configs.lua index 45cd29af73..ed4d08e052 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/configs.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/configs.lua @@ -1,6 +1,6 @@ ---[[ +--[[ Configs for modules - Based on Kondrah storage method + Based on Kondrah storage method --]] local configName = modules.game_bot.contentsPanel.config:getCurrentOption().text @@ -29,8 +29,8 @@ local suppliesFile = "/bot/" .. configName .. "/vBot_configs/profile_".. profile --healbot if g_resources.fileExists(healBotFile) then - local status, result = pcall(function() - return json.decode(g_resources.readFileContents(healBotFile)) + local status, result = pcall(function() + return json.decode(g_resources.readFileContents(healBotFile)) end) if not status then return onError("Error while reading config file (" .. healBotFile .. "). To fix this problem you can delete HealBot.json. Details: " .. result) @@ -40,8 +40,8 @@ end --attackbot if g_resources.fileExists(attackBotFile) then - local status, result = pcall(function() - return json.decode(g_resources.readFileContents(attackBotFile)) + local status, result = pcall(function() + return json.decode(g_resources.readFileContents(attackBotFile)) end) if not status then return onError("Error while reading config file (" .. attackBotFile .. "). To fix this problem you can delete HealBot.json. Details: " .. result) @@ -51,8 +51,8 @@ end --supplies if g_resources.fileExists(suppliesFile) then - local status, result = pcall(function() - return json.decode(g_resources.readFileContents(suppliesFile)) + local status, result = pcall(function() + return json.decode(g_resources.readFileContents(suppliesFile)) end) if not status then return onError("Error while reading config file (" .. suppliesFile .. "). To fix this problem you can delete HealBot.json. Details: " .. result) @@ -65,7 +65,7 @@ function vBotConfigSave(file) --- heal --- atk --- supply - local configFile + local configFile local configTable if not file then return end file = file:lower() @@ -82,16 +82,16 @@ function vBotConfigSave(file) return end - local status, result = pcall(function() - return json.encode(configTable, 2) + local status, result = pcall(function() + return json.encode(configTable, 2) end) if not status then return onError("Error while saving config. it won't be saved. Details: " .. result) end - + if result:len() > 100 * 1024 * 1024 then return onError("config file is too big, above 100MB, it won't be saved") end g_resources.writeFileContents(configFile, result) -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/depositer_config.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/depositer_config.lua index a869c771bc..59a018b594 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/depositer_config.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/depositer_config.lua @@ -2,7 +2,7 @@ setDefaultTab("Cave") local panelName = "specialDeposit" local depositerPanel -UI.Button("Stashing Settings", function() +UI.Button("Stashing Settings", function() depositerPanel:show() depositerPanel:raise() depositerPanel:focus() @@ -26,7 +26,7 @@ end depositerPanel:setHeight(config.height or 380) depositerPanel.onGeometryChange = function(widget, old, new) - if old.height == 0 then return end + if old.height == 0 then return end config.height = new.height end @@ -70,14 +70,14 @@ local function refreshEntries() panel.name:setText(Item.create(entry.id):getMarketData().name) if entry.index == 0 then local window = modules.client_textedit.show(panel.slot, { - title = "Set depot for "..panel.name:getText(), + title = "Set depot for "..panel.name:getText(), description = "Select depot to which item should be stashed, choose between 3 and 17", validation = [[^([3-9]|1[0-7])$]] }) window.text:setText(entry.index) - schedule(50, function() + schedule(50, function() window:raise() - window:focus() + window:focus() end) end end @@ -88,14 +88,14 @@ local function refreshEntries() panel.slot:setTooltip("Click to set stashing destination.") panel.slot.onClick = function(widget) local window = modules.client_textedit.show(widget, { - title = "Set depot for "..panel.name:getText(), + title = "Set depot for "..panel.name:getText(), description = "Select depot to which item should be stashed, choose between 3 and 17", validation = [[^([3-9]|1[0-7])$]] }) window.text:setText(entry.index) - schedule(50, function() + schedule(50, function() window:raise() - window:focus() + window:focus() end) end panel.slot.onTextChange = function(widget, text) @@ -133,4 +133,4 @@ local sellContainer = UI.Container(function(widget, items) storage.cavebotSell = items end, true) sellContainer:setHeight(35) -sellContainer:setItems(storage.cavebotSell) \ No newline at end of file +sellContainer:setItems(storage.cavebotSell) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/depositer_config.otui b/mods/game_bot/default_configs/vBot_4.8/vBot/depositer_config.otui index eb3ab6bec7..31eaf43205 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/depositer_config.otui +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/depositer_config.otui @@ -95,4 +95,4 @@ DepositerPanel < MainWindow anchors.right: parent.right anchors.bottom: parent.bottom size: 45 21 - margin-right: 5 \ No newline at end of file + margin-right: 5 diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/depot_withdraw.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/depot_withdraw.lua index 8323f714ec..4255005a03 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/depot_withdraw.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/depot_withdraw.lua @@ -24,7 +24,7 @@ function reopenLootContainer() end macro(50, "Depot Withdraw", function() - + -- set the containers if not potionsContainer or not runesContainer or not ammoContainer then for i, container in pairs(getContainers()) do @@ -34,7 +34,7 @@ macro(50, "Depot Withdraw", function() depotContainer = container elseif string.find(container:getName(), "your inbox") then mailContainer = container - end + end end end @@ -47,10 +47,9 @@ macro(50, "Depot Withdraw", function() end end - if playerContainer and freecap() >= 200 then local time = 500 - if depotContainer then + if depotContainer then for i, container in pairs(getContainers()) do if string.find(container:getName(), "Depot") then for j, item in pairs(container:getItems()) do @@ -61,7 +60,7 @@ if playerContainer and freecap() >= 200 then end end - if mailContainer then + if mailContainer then for i, container in pairs(getContainers()) do if string.find(container:getName(), "your inbox") then for j, item in pairs(container:getItems()) do @@ -73,4 +72,4 @@ if playerContainer and freecap() >= 200 then end end -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/eat_food.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/eat_food.lua index ad8edb5f12..ccea249c98 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/eat_food.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/eat_food.lua @@ -45,4 +45,4 @@ macro(500, "Eat Food", function() end end end) -UI.Separator() \ No newline at end of file +UI.Separator() diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/equip.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/equip.lua index b0c2f80343..278dff8fbe 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/equip.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/equip.lua @@ -25,7 +25,7 @@ macro(250, function() for __, item in ipairs(container:getItems()) do if item:getId() == autoEquip.item1 or item:getId() == autoEquip.item2 then g_game.move(item, {x=65535, y=autoEquip.slot, z=0}, item:getCount()) - delay(1000) -- don't call it too often + delay(1000) -- don't call it too often return end end @@ -33,4 +33,4 @@ macro(250, function() end end end -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/equipper.otui b/mods/game_bot/default_configs/vBot_4.8/vBot/equipper.otui index d61db7e6a6..fa031e6ff9 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/equipper.otui +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/equipper.otui @@ -62,7 +62,7 @@ Rule < UIWidget focusable: true height: 16 text-align: left - font: verdana-11px-rounded + font: verdana-11px-rounded CheckBox id: enabled @@ -99,7 +99,6 @@ Rule < UIWidget tooltip: Items must be visible anchors.verticalCenter: parent.verticalCenter - ConditionPanel < Panel height: 58 @@ -144,8 +143,6 @@ ConditionPanel < Panel width: 200 text-align: center - - ListPanel < FlatPanel size: 270 300 padding-left: 10 @@ -170,7 +167,7 @@ ListPanel < FlatPanel !text: tr('More important methods come first.') text-align: left font: verdana-11px-rounded - color: #aeaeae + color: #aeaeae TextList id: list @@ -240,7 +237,7 @@ InputPanel < FlatPanel anchors.right: parent.right anchors.top: prev.bottom margin-top: 4 - + ConditionPanel id: condition anchors.left: parent.left @@ -492,7 +489,7 @@ EquipWindow < MainWindow margin-bottom: 5 anchors.left: prev.right margin-left: 10 - + Profile id: profileName anchors.top: parent.top @@ -520,7 +517,7 @@ EquipWindow < MainWindow anchors.right: parent.right anchors.left: parent.left anchors.bottom: closeButton.top - margin-bottom: 8 + margin-bottom: 8 Button id: closeButton @@ -528,7 +525,7 @@ EquipWindow < MainWindow font: cipsoftFont anchors.right: parent.right anchors.bottom: parent.bottom - size: 45 21 + size: 45 21 Button id: bossList @@ -536,4 +533,4 @@ EquipWindow < MainWindow font: cipsoftFont anchors.left: parent.left anchors.bottom: parent.bottom - size: 65 21 \ No newline at end of file + size: 65 21 diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/exeta.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/exeta.lua index 324bad93b4..e4a7eadfb7 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/exeta.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/exeta.lua @@ -6,7 +6,7 @@ if voc == 1 or voc == 11 then local lastCast = now onCreatureHealthPercentChange(function(creature, healthPercent) if m.isOff() then return end - if healthPercent > 15 then return end + if healthPercent > 15 then return end if CaveBot.isOff() or TargetBot.isOff() then return end if modules.game_cooldown.isGroupCooldownIconActive(3) then return end if creature:getPosition() and getDistanceBetween(pos(),creature:getPosition()) > 1 then return end @@ -24,4 +24,4 @@ if voc == 1 or voc == 11 then end end) UI.Separator() -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/extras.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/extras.lua index 6eb961396d..209b210ade 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/extras.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/extras.lua @@ -233,7 +233,6 @@ if true then end end - addCheckBox("timers", "MW & WG Timers", true, rightPanel, "Show times for Magic Walls and Wild Growths.") if true then local activeTimers = {} @@ -272,7 +271,6 @@ if true then end) end - addCheckBox("antiKick", "Anti - Kick", true, rightPanel, "Turn every 10 minutes to prevent kick.") if true then macro(600 * 1000, function() @@ -283,7 +281,6 @@ if true then end) end - addCheckBox("stake", "Skin Monsters", false, leftPanel, "Automatically skin & stake corpses when cavebot is enabled") if true then local knifeBodies = { 4286, 4272, 4173, 4011, 4025, 4047, 4052, 4057, 4062, 4112, 4212, 4321, 4324, 4327, 10352, 10356, @@ -315,7 +312,6 @@ if true then end) end - addCheckBox("oberon", "Auto Reply Oberon", true, rightPanel, "Auto reply to Grand Master Oberon talk minigame.") if true then onTalk(function(name, level, mode, text, channelId, pos) @@ -344,7 +340,6 @@ if true then end) end - addCheckBox("autoOpenDoors", "Auto Open Doors", true, rightPanel, "Open doors when trying to step on them.") if true then local doorsIds = { 5007, 8265, 1629, 1632, 5129, 6252, 6249, 7715, 7712, 7714, @@ -392,7 +387,6 @@ if true then end) end - addCheckBox("bless", "Buy bless at login", true, rightPanel, "Say !bless at login.") if true then local blessed = false @@ -419,7 +413,6 @@ if true then end end - addCheckBox("reUse", "Keep Crosshair", false, rightPanel, "Keep crosshair after using with item") if true then local excluded = { 268, 237, 238, 23373, 266, 236, 239, 7643, 23375, 7642, 23374, 5908, 5942 } @@ -436,7 +429,6 @@ if true then end) end - addCheckBox("suppliesControl", "TargetBot off if low supply", false, leftPanel, "Turn off TargetBot if either one of supply amount is below 50% of minimum.") if true then diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/extras.otui b/mods/game_bot/default_configs/vBot_4.8/vBot/extras.otui index de551d9a5d..d34e9ab546 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/extras.otui +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/extras.otui @@ -8,7 +8,7 @@ ExtrasScrollBar < Panel anchors.right: parent.right anchors.top: parent.top text-align: center - + HorizontalScrollBar id: scroll anchors.left: parent.left @@ -29,7 +29,7 @@ ExtrasTextEdit < Panel anchors.right: parent.right anchors.top: parent.top text-align: center - + TextEdit id: textEdit anchors.left: parent.left @@ -101,7 +101,7 @@ ExtrasWindow < MainWindow anchors.bottom: separator.top vertical-scrollbar: contentScroll margin-bottom: 10 - + Panel id: left anchors.top: parent.top @@ -146,7 +146,7 @@ ExtrasWindow < MainWindow maximum: 600 margin-left: 3 margin-right: 3 - background: #ffffff88 + background: #ffffff88 Button id: closeButton @@ -155,4 +155,4 @@ ExtrasWindow < MainWindow anchors.right: parent.right anchors.bottom: parent.bottom size: 45 21 - margin-right: 5 \ No newline at end of file + margin-right: 5 diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/hold_target.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/hold_target.lua index 484bf85cbd..5c93c5edaa 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/hold_target.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/hold_target.lua @@ -21,10 +21,10 @@ macro(100, "Hold Target", function() for i, spec in ipairs(getSpectators()) do local sameFloor = spec:getPosition().z == posz() local oldTarget = spec:getId() == targetID - + if sameFloor and oldTarget then attack(spec) end end end -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/ingame_editor.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/ingame_editor.lua index 1217b82b1a..46528fc305 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/ingame_editor.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/ingame_editor.lua @@ -6,18 +6,18 @@ UI.Button("Ingame script editor", function(newText) reload() end) end) - + UI.Separator() - + for _, scripts in pairs({storage.ingame_hotkeys}) do if type(scripts) == "string" and scripts:len() > 3 then local status, result = pcall(function() assert(load(scripts, "ingame_editor"))() end) - if not status then + if not status then error("Ingame edior error:\n" .. result) end end end - - UI.Separator() \ No newline at end of file + + UI.Separator() diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/main.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/main.lua index 4f01c3dcfa..2bf45d63f0 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/main.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/main.lua @@ -8,7 +8,7 @@ storage.checkVersion = storage.checkVersion or 0 if os.time() > storage.checkVersion + (12 * 60 * 60) then storage.checkVersion = os.time() - + HTTP.get("https://raw.githubusercontent.com/Vithrax/vBot/main/vBot/version.txt", function(data, err) if err then warn("[vBot updater]: Unable to check version:\n" .. err) @@ -29,12 +29,12 @@ schedule(5000, function() if not available then return end if currentVersion ~= version then - + UI.Separator() UI.Label("New vBot is available for download! v"..currentVersion) UI.Button("Go to vBot GitHub Page", function() g_platform.openUrl("https://github.com/Vithrax/vBot") end) UI.Separator() - + end -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/new_cavebot_lib.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/new_cavebot_lib.lua index 3434a999f9..a1a23dcfd3 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/new_cavebot_lib.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/new_cavebot_lib.lua @@ -24,7 +24,7 @@ local LOCKER_ACCESSTILE_MODIFIERS = { local function CaveBotConfigParse() local name = storage["_configs"]["targetbot_configs"]["selected"] - if not name then + if not name then return warn("[vBot] Please create a new TargetBot config and reset bot") end local file = configDir .. "/targetbot_configs/" .. name .. ".json" @@ -87,7 +87,6 @@ function CaveBot.GetLootItems() return returnTable end - --- Checks whether player has any visible items to be stashed -- @return boolean function CaveBot.HasLootItems() @@ -234,7 +233,7 @@ end -- @return void(acion) or boolean function CaveBot.ReachNPC(name) name = name:lower() - + local npc = nil for i, spec in pairs(getSpectators()) do if spec:isNpc() and spec:getName():lower() == name then @@ -409,8 +408,8 @@ end -- Combined for shorthand usage. -- @return boolean whether succeed to reach and open depot function CaveBot.ReachAndOpenDepot() - if CaveBot.ReachDepot() and CaveBot.OpenDepotChest() then - return true + if CaveBot.ReachDepot() and CaveBot.OpenDepotChest() then + return true end return false end @@ -419,8 +418,8 @@ end -- Combined for shorthand usage. -- @return boolean whether succeed to reach and open depot function CaveBot.ReachAndOpenInbox() - if CaveBot.ReachDepot() and CaveBot.OpenInbox() then - return true + if CaveBot.ReachDepot() and CaveBot.OpenInbox() then + return true end return false end @@ -472,8 +471,8 @@ function CaveBot.WithdrawItem(id, amount, fromDepot, destination) end end - if itemCount >= amount then - return true + if itemCount >= amount then + return true end local toMove = amount - itemCount @@ -515,4 +514,4 @@ end -- @return void function CaveBot.Travel(destination) return CaveBot.Conversation("hi", destination, "yes") -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/new_healer.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/new_healer.lua index ca799c9b0a..cb95ca83f5 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/new_healer.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/new_healer.lua @@ -20,7 +20,7 @@ Panel margin-left: 3 height: 17 text: Setup - + ]]) ui:setId(panelName) @@ -125,17 +125,17 @@ customList.addPanel.add.onClick = function() name = name .. " " .. capitalFistLetter(word) end - if not health then + if not health then clearFields() return warn("[Friend Healer] Please enter health percent value!") end - if name:len() == 0 or name:lower() == "friend name" then + if name:len() == 0 or name:lower() == "friend name" then clearFields() return warn("[Friend Healer] Please enter friend name to be added!") end - if config.customPlayers[name] or config.customPlayers[name:lower()] then + if config.customPlayers[name] or config.customPlayers[name:lower()] then clearFields() return warn("[Friend Healer] Player already added to custom list.") else @@ -274,8 +274,6 @@ for i, setting in ipairs(config.settings) do end end - - -- priority and toggles local function setCrementalButtons() for i, child in ipairs(priority.list:getChildren()) do @@ -316,14 +314,14 @@ for i, action in ipairs(config.priorities) do action.enabled = not action.enabled widget:setColor(action.enabled and "#98BF64" or "#dfdfdf") widget.enabled:setChecked(action.enabled) - validate(widget, 1) + validate(widget, 1) end if action.custom then widget.onDoubleClick = function() local window = modules.client_textedit.show(widget, {title = "Custom Spell", description = "Enter below formula for a custom healing spell"}) - schedule(50, function() + schedule(50, function() window:raise() - window:focus() + window:focus() end) end widget.onTextChange = function(widget,text) @@ -377,13 +375,13 @@ local function friendHealerAction(spec, targetsInRange) end local function isCandidate(spec) - if spec:isLocalPlayer() or not spec:isPlayer() then - return nil + if spec:isLocalPlayer() or not spec:isPlayer() then + return nil end if not spec:canShoot() then return false end - + local curHp = spec:getHealthPercent() if curHp == 100 or (config.customPlayers[name] and curHp > config.customPlayers[name]) then return false @@ -428,7 +426,7 @@ macro(100, function() local healTarget = {creature=nil, hp=100} local inMasResRange = 0 - -- check basic + -- check basic if hppercent() <= minHp or manapercent() <= minMp then return end -- get all spectators @@ -453,4 +451,4 @@ macro(100, function() if healTarget.creature then return friendHealerAction(healTarget.creature, inMasResRange) end -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/new_healer.otui b/mods/game_bot/default_configs/vBot_4.8/vBot/new_healer.otui index 2eb55cc4de..9caf95bf4c 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/new_healer.otui +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/new_healer.otui @@ -1,5 +1,5 @@ CategoryCheckBox < CheckBox - font: verdana-11px-rounded + font: verdana-11px-rounded margin-top: 3 $checked: @@ -14,7 +14,7 @@ HealScroll < Panel anchors.top: parent.top text-align: center text: test - + HorizontalScrollBar id: scroll anchors.left: parent.left @@ -45,7 +45,7 @@ ToolTipLabel < UIWidget font: verdana-11px-rounded color: #dfdfdf height: 14 - text-align: center + text-align: center HealerPlayerEntry < Label background-color: alpha @@ -57,7 +57,7 @@ HealerPlayerEntry < Label $focus: background-color: #00000055 - + Button id: remove anchors.right: parent.right @@ -85,8 +85,8 @@ PriorityEntry < ToolTipLabel anchors.verticalCenter: parent.verticalCenter size: 15 15 margin-top: 2 - margin-left: 3 - + margin-left: 3 + Button id: increment anchors.right: parent.right @@ -114,7 +114,7 @@ TargetSettings < Panel Label anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top - font: verdana-11px-rounded + font: verdana-11px-rounded text: Heal Target Settings Groups @@ -156,7 +156,7 @@ Groups < FlatPanel anchors.right: parent.right anchors.bottom: parent.bottom padding: 2 - layout: + layout: type: verticalBox CategoryCheckBox @@ -174,7 +174,7 @@ Groups < FlatPanel CategoryCheckBox id: botserver text: BotServer Members - + Vocations < FlatPanel size: 100 90 padding: 3 @@ -184,7 +184,7 @@ Vocations < FlatPanel id: title anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top - font: verdana-11px-rounded + font: verdana-11px-rounded text: Vocations HorizontalSeparator @@ -202,7 +202,7 @@ Vocations < FlatPanel anchors.bottom: parent.bottom padding: 2 - layout: + layout: type: verticalBox CategoryCheckBox @@ -232,7 +232,7 @@ Priority < Panel id: title anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top - font: verdana-11px-rounded + font: verdana-11px-rounded text: Priority & Toggles TextList @@ -252,7 +252,7 @@ AddPlayer < FlatPanel anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right - font: verdana-11px-rounded + font: verdana-11px-rounded text: Add Player to Custom List text-align: center text-wrap: true @@ -279,7 +279,7 @@ AddPlayer < FlatPanel anchors.verticalCenter: prev.verticalCenter anchors.left: prev.right margin-left: 3 - font: verdana-11px-rounded + font: verdana-11px-rounded text: %HP - heal if below TextEdit @@ -288,7 +288,7 @@ AddPlayer < FlatPanel margin-top: 5 anchors.left: health.left anchors.right: parent.right - font: verdana-11px-rounded + font: verdana-11px-rounded text-align: center text: friend name @@ -298,7 +298,7 @@ AddPlayer < FlatPanel anchors.right: parent.right anchors.top: prev.bottom margin-top: 5 - font: verdana-11px-rounded + font: verdana-11px-rounded text: Add Player PlayerList < Panel @@ -328,7 +328,7 @@ CustomList < Panel ToolTipLabel anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top - font: verdana-11px-rounded + font: verdana-11px-rounded text: Custom Player List tooltip: Double click on the list below to add new player. @@ -353,7 +353,7 @@ Conditions < Panel Label anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top - font: verdana-11px-rounded + font: verdana-11px-rounded text: Player Conditions Panel @@ -362,7 +362,7 @@ Conditions < Panel margin-top: 16 padding: 5 padding-top: 3 - layout: + layout: type: grid cell-size: 128 31 cell-spacing: 5 @@ -401,7 +401,7 @@ FriendHealer < MainWindow anchors.right: parent.right anchors.left: parent.left anchors.bottom: closeButton.top - margin-bottom: 8 + margin-bottom: 8 Button id: closeButton @@ -410,4 +410,4 @@ FriendHealer < MainWindow anchors.right: parent.right anchors.bottom: parent.bottom size: 45 21 - @onClick: self:getParent():hide() \ No newline at end of file + @onClick: self:getParent():hide() diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/npc_talk.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/npc_talk.lua index 4ed5cf4e04..f1ac60e15c 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/npc_talk.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/npc_talk.lua @@ -2,4 +2,4 @@ onAttackingCreatureChange(function(creature, OldCreature) if creature and creature:isNpc() and distanceFromPlayer(creature:getPosition()) <= 3 then CaveBot.Conversation("hi", "trade") end -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/playerlist.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/playerlist.lua index 948928d69d..03f2b62165 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/playerlist.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/playerlist.lua @@ -15,8 +15,6 @@ local link = "https://www.gunzodus.net/character/show/" local spacing = "_" - - -- do not edit below setDefaultTab("Main") local tabs = {"Friends", "Enemies", "BlackList"} @@ -59,7 +57,7 @@ local refreshStatus = function() specOutfit.feet = 88 if storage.BOTserver.outfit then local voc = vBot.BotServerMembers[spec:getName()] - specOutfit.addons = 3 + specOutfit.addons = 3 if voc == 1 then specOutfit.type = 131 elseif voc == 2 then @@ -89,10 +87,10 @@ refreshStatus() local checkStatus = function(creature) if not creature:isPlayer() or creature:isLocalPlayer() then return end - + local specName = creature:getName() local specOutfit = creature:getOutfit() - + if isFriend(specName) then if config.highlight then creature:setMarked('#0000FF') @@ -104,7 +102,7 @@ local checkStatus = function(creature) specOutfit.feet = 88 if storage.BOTserver.outfit then local voc = vBot.BotServerMembers[creature:getName()] - specOutfit.addons = 3 + specOutfit.addons = 3 if voc == 1 then specOutfit.type = 131 elseif voc == 2 then @@ -131,13 +129,12 @@ local checkStatus = function(creature) end end - rootWidget = g_ui.getRootWidget() if rootWidget then local ListWindow = UI.createWindow('PlayerListWindow', rootWidget) ListWindow:hide() - UI.Button("Player Lists", function() + UI.Button("Player Lists", function() ListWindow:show() ListWindow:raise() ListWindow:focus() @@ -229,7 +226,7 @@ if rootWidget then tabButton.onStyleApply = function(widget) if TabBar:getCurrentTab() == widget then widget:setColor(colors[v]) - end + end end -- callbacks @@ -341,11 +338,11 @@ end) onCreatureAppear(function(creature) checkStatus(creature) end) - + onPlayerPositionChange(function(x,y) if x.z ~= y.z then schedule(20, function() refreshStatus() end) end -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/playerlist.otui b/mods/game_bot/default_configs/vBot_4.8/vBot/playerlist.otui index a4f0d92a5b..b5fb0b678c 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/playerlist.otui +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/playerlist.otui @@ -148,4 +148,4 @@ PlayerListWindow < MainWindow size: 45 21 margin-top: 15 margin-right: 5 - @onClick: self:getParent():hide() \ No newline at end of file + @onClick: self:getParent():hide() diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/pushmax.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/pushmax.lua index 0f63447005..2e269fac11 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/pushmax.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/pushmax.lua @@ -84,12 +84,11 @@ if rootWidget then pushWindow.hotkey:setText(config.pushMaxKey) end - -- variables for config local fieldTable = {2118, 105, 2122} local cleanTile = nil --- scripts +-- scripts local targetTile local pushTarget @@ -251,9 +250,9 @@ macro(50, function() local tilePos = targetTile:getPosition() local targetPos = pushTarget:getPosition() if not isOk(tilePos,targetPos) then return end - + local tileOfTarget = g_map.getTile(targetPos) - + if not targetTile:isWalkable() then local topThing = targetTile:getTopUseThing():getId() if topThing == 2129 or topThing == 2130 or topThing == customMwall then @@ -284,4 +283,4 @@ macro(50, function() g_game.move(pushTarget,tilePos) delay(2000) end -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/pushmax.otui b/mods/game_bot/default_configs/vBot_4.8/vBot/pushmax.otui index 875a4f8b4f..097d714a68 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/pushmax.otui +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/pushmax.otui @@ -36,7 +36,7 @@ PushMaxWindow < MainWindow anchors.left: parent.left text-align: center text: VS AntiPush - margin-top: 5 + margin-top: 5 BotItem id: runeId @@ -72,7 +72,7 @@ PushMaxWindow < MainWindow anchors.right: parent.right anchors.left: parent.left anchors.bottom: closeButton.top - margin-bottom: 8 + margin-bottom: 8 Button id: closeButton @@ -82,4 +82,4 @@ PushMaxWindow < MainWindow anchors.bottom: parent.bottom size: 45 21 margin-top: 15 - margin-right: 5 \ No newline at end of file + margin-right: 5 diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/quiver_label.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/quiver_label.lua index 671d726831..cbe19e26cf 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/quiver_label.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/quiver_label.lua @@ -15,7 +15,6 @@ Label text: ]], quiverSlot) - function getQuiverAmount() -- old tibia if g_game.getClientVersion() < 1000 then return end @@ -44,7 +43,7 @@ end) onContainerClose(function(container) getQuiverAmount() end) - + onAddItem(function(container, slot, item, oldItem) getQuiverAmount() end) @@ -55,4 +54,4 @@ end) onContainerUpdateItem(function(container, slot, item, oldItem) getQuiverAmount() -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/quiver_manager.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/quiver_manager.lua index 368bd8cda6..8edc8f8520 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/quiver_manager.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/quiver_manager.lua @@ -12,7 +12,7 @@ if voc() == 2 or voc() == 12 then onContainerClose(function(container) hold = false end) - + onAddItem(function(container, slot, item, oldItem) hold = false end) @@ -25,8 +25,6 @@ if voc() == 2 or voc() == 12 then hold = false end) - - local function manageQuiver(isBowEquipped, quiverContainer) local ammo = isBowEquipped and arrows or bolts local dest = nil @@ -88,4 +86,4 @@ if voc() == 2 or voc() == 12 then hold = true end end) -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/siolist.otui b/mods/game_bot/default_configs/vBot_4.8/vBot/siolist.otui index e9920753fa..303eb03752 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/siolist.otui +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/siolist.otui @@ -39,8 +39,6 @@ VocationPanel < Panel anchors.right: parent.right text: Paladins - - SioListWindow < MainWindow !text: tr('Healer Options') size: 220 360 @@ -105,7 +103,7 @@ SioListWindow < MainWindow anchors.right: parent.right anchors.bottom: prev.verticalCenter text-align: center - text: Item Healing + text: Item Healing margin-left: 2 BotLabel @@ -125,7 +123,7 @@ SioListWindow < MainWindow margin-top: 3 minimum: 1 maximum: 10 - step: 1 + step: 1 HorizontalSeparator anchors.top: prev.bottom @@ -167,11 +165,11 @@ SioListWindow < MainWindow margin-top: 2 minimum: 1 maximum: 100 - step: 1 + step: 1 VocationPanel id: vocation - anchors.top: prev.bottom + anchors.top: prev.bottom margin-top: 6 HorizontalSeparator @@ -179,7 +177,7 @@ SioListWindow < MainWindow anchors.right: parent.right anchors.left: parent.left anchors.bottom: closeButton.top - margin-bottom: 8 + margin-bottom: 8 Button id: closeButton @@ -189,4 +187,4 @@ SioListWindow < MainWindow anchors.bottom: parent.bottom size: 45 21 margin-top: 15 - margin-right: 5 \ No newline at end of file + margin-right: 5 diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/spy_level.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/spy_level.lua index f225d7699d..f34b8da2fb 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/spy_level.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/spy_level.lua @@ -21,4 +21,4 @@ onKeyPress(function(keys) lockedLevel = lockedLevel - 1 modules.game_interface.getMapPanel():lockVisibleFloor(lockedLevel) end -end) \ No newline at end of file +end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/supplies.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/supplies.lua index d5fbd4d3ef..97b40202f3 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/supplies.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/supplies.lua @@ -470,4 +470,4 @@ Supplies.getFullData = function() } return data -end \ No newline at end of file +end diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/supplies.otui b/mods/game_bot/default_configs/vBot_4.8/vBot/supplies.otui index 9576c88bec..e048956577 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/supplies.otui +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/supplies.otui @@ -43,7 +43,7 @@ ItemPanel < Panel id: min anchors.left: prev.right anchors.bottom: parent.bottom - + SupplySpinBox id: max anchors.left: prev.right @@ -53,7 +53,7 @@ ItemPanel < Panel id: avg anchors.left: prev.right anchors.bottom: parent.bottom - width: 50 + width: 50 UIWidget anchors.left: min.left @@ -120,7 +120,7 @@ SuppliesWindow < MainWindow margin-top: 5 margin-left: 10 text: No Soft - tooltip: Go refill if there's no more active soft boots. + tooltip: Go refill if there's no more active soft boots. BotSwitch id: capSwitch @@ -180,7 +180,7 @@ SuppliesWindow < MainWindow anchors.right: prev.right anchors.bottom: bottomSep.top margin-bottom: 25 - + BotButton id: newProfile anchors.left: prev.left @@ -222,7 +222,7 @@ SuppliesWindow < MainWindow anchors.right: parent.right anchors.bottom: parent.bottom size: 45 21 - margin-top: 15 + margin-top: 15 tooltip: Close supplies window and save settings. @onClick: self:getParent():hide() @@ -241,4 +241,4 @@ SuppliesWindow < MainWindow margin-right: 3 text: - width: 50 - tooltip: decrease all max supplies amount by average \ No newline at end of file + tooltip: decrease all max supplies amount by average diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/tools.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/tools.lua index 6105692f9d..271cc6f68d 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/tools.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/tools.lua @@ -13,7 +13,7 @@ macro(1000, "Exchange money", function() if item:getCount() == 100 then for m, moneyId in ipairs(storage.moneyItems) do if item:getId() == moneyId.id then - return g_game.use(item) + return g_game.use(item) end end end @@ -35,11 +35,11 @@ macro(60000, "Send message on trade", function() if not trade then trade = getChannelId("trade") end - if trade and storage.autoTradeMessage:len() > 0 then + if trade and storage.autoTradeMessage:len() > 0 then sayChannel(trade, storage.autoTradeMessage) end end) -UI.TextEdit(storage.autoTradeMessage or "I'm using OTClientV8!", function(widget, text) +UI.TextEdit(storage.autoTradeMessage or "I'm using OTClientV8!", function(widget, text) storage.autoTradeMessage = text end) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/vlib.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/vlib.lua index c93bb144c5..6ddb711432 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/vlib.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/vlib.lua @@ -14,7 +14,7 @@ function logInfo(text) text = tostring(text) local start = timestamp.." [vBot]: " - return modules.client_terminal.addLine(start..text, "orange") + return modules.client_terminal.addLine(start..text, "orange") end -- scripts / functions @@ -30,7 +30,7 @@ function relogOnCharacter(charName) local characters = g_ui.getRootWidget().charactersWindow.characters for index, child in ipairs(characters:getChildren()) do local name = child:getChildren()[1]:getText() - + if name:lower():find(charName:lower()) then child:focus() schedule(100, modules.client_entergame.CharacterList.doLogin) @@ -109,7 +109,7 @@ function getFirstNumberInText(text) end -- function to search if item of given ID can be found on certain tile --- first argument is always ID +-- first argument is always ID -- the rest of aguments can be: -- - tile -- - position @@ -242,7 +242,7 @@ end) -- [[ canCast and cast functions ]] -- -- callback connected to cast and canCast function --- detects if a given spell was in fact casted based on player's text messages +-- detects if a given spell was in fact casted based on player's text messages -- Cast text and message text must match -- checks only spells inserted in SpellCastTable by function cast SpellCastTable = {} @@ -402,7 +402,7 @@ onUseWith(function(pos, itemId, target, subType) if pos.x < 65000 then isUsingTime = now + 1000 end end) --- returns first word in string +-- returns first word in string function string.starts(String, Start) return string.sub(String, 1, string.len(Start)) == Start end @@ -764,7 +764,7 @@ function itemAmount(id) end -- self explanatory --- a is item to use on +-- a is item to use on -- b is item to use a on function useOnInvertoryItem(a, b) local item = findItem(b) diff --git a/mods/game_bot/default_configs/vBot_4.8/vBot/xeno_menu.lua b/mods/game_bot/default_configs/vBot_4.8/vBot/xeno_menu.lua index 2583500579..f3d1a38b9b 100644 --- a/mods/game_bot/default_configs/vBot_4.8/vBot/xeno_menu.lua +++ b/mods/game_bot/default_configs/vBot_4.8/vBot/xeno_menu.lua @@ -9,22 +9,22 @@ modules.game_interface.gameRootPanel.onMouseRelease = function(widget, mousePos, menu:addOption('HealBot', HealBot.show, "OTCv8") menu:addOption('Conditions', Conditions.show, "OTCv8") menu:addSeparator() - menu:addOption('CaveBot', function() - if CaveBot.isOn() then - CaveBot.setOff() - else - CaveBot.setOn() - end + menu:addOption('CaveBot', function() + if CaveBot.isOn() then + CaveBot.setOff() + else + CaveBot.setOn() + end end, CaveBot.isOn() and "ON " or "OFF ") - menu:addOption('TargetBot', function() - if TargetBot.isOn() then - TargetBot.setOff() - else - TargetBot.setOn() - end + menu:addOption('TargetBot', function() + if TargetBot.isOn() then + TargetBot.setOff() + else + TargetBot.setOn() + end end, TargetBot.isOn() and "ON " or "OFF ") menu:display(mousePos) return true end end -end \ No newline at end of file +end diff --git a/mods/game_bot/edit.otui b/mods/game_bot/edit.otui index e45ad6eae6..f15713830f 100644 --- a/mods/game_bot/edit.otui +++ b/mods/game_bot/edit.otui @@ -12,7 +12,7 @@ MainWindow anchors.left: parent.left anchors.right: parent.right height: 152 - + Label anchors.top: parent.top anchors.left: parent.left @@ -21,14 +21,14 @@ MainWindow text-align: center text-wrap: true !text: tr("Config Manager\nYou can use config manager to share configs between different machines, especially smartphones. After you configure your config, you can upload it, then you'll get unique hash code which you can use on diffent machinge (for eg. mobile phone) to download it.") - + HorizontalSeparator anchors.top: prev.bottom anchors.left: parent.left anchors.right: parent.right margin-top: 3 height: 2 - + Panel id: upload anchors.top: prev.bottom @@ -65,7 +65,7 @@ MainWindow margin-left: 20 margin-right: 20 text-offset: 3 0 - + Button id: submit anchors.top: prev.bottom @@ -76,12 +76,12 @@ MainWindow margin-left: 40 margin-right: 40 @onClick: modules.game_bot.uploadConfig() - + Panel id: download anchors.top: prev.top anchors.left: parent.horizontalCenter - anchors.right: parent.right + anchors.right: parent.right anchors.bottom: parent.bottom Label @@ -111,7 +111,7 @@ MainWindow margin-top: 4 margin-left: 20 margin-right: 20 - + Button id: submit anchors.top: prev.bottom @@ -121,19 +121,19 @@ MainWindow margin-top: 4 margin-left: 40 margin-right: 40 - @onClick: modules.game_bot.downloadConfig() - + @onClick: modules.game_bot.downloadConfig() + HorizontalSeparator anchors.top: prev.bottom anchors.left: parent.left anchors.right: parent.right margin-top: 3 height: 2 - + Panel anchors.top: prev.bottom anchors.left: parent.left - anchors.right: parent.right + anchors.right: parent.right margin-top: 5 height: 330 $mobile: @@ -217,7 +217,7 @@ MainWindow !text: tr('Tutorials') anchors.bottom: parent.bottom anchors.left: prev.right - margin-left: 5 + margin-left: 5 width: 80 @onClick: g_platform.openUrl("http://otclient.ovh/bot.php?tutorials") @@ -225,7 +225,7 @@ MainWindow !text: tr('Scripts') anchors.bottom: parent.bottom anchors.left: prev.right - margin-left: 5 + margin-left: 5 width: 80 @onClick: g_platform.openUrl("http://otclient.ovh/bot.php?scripts") @@ -233,7 +233,7 @@ MainWindow !text: tr('Forum') anchors.bottom: parent.bottom anchors.left: prev.right - margin-left: 5 + margin-left: 5 width: 80 @onClick: g_platform.openUrl("http://otclient.ovh/bot.php?forum") @@ -241,10 +241,10 @@ MainWindow !text: tr('Discord') anchors.bottom: parent.bottom anchors.left: prev.right - margin-left: 5 + margin-left: 5 width: 80 @onClick: g_platform.openUrl("http://otclient.ovh/bot.php?discord") - + Button id: cancelButton !text: tr('Close') diff --git a/mods/game_bot/executor.lua b/mods/game_bot/executor.lua index 0ca87a93ad..e9f0c8f7c6 100644 --- a/mods/game_bot/executor.lua +++ b/mods/game_bot/executor.lua @@ -1,6 +1,6 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, reloadCallback, websockets) -- load lua and otui files - local configFiles = g_resources.listDirectoryFiles("/bot/" .. config, true, false) + local configFiles = g_resources.listDirectoryFiles("/bot/" .. config, true, false) local luaFiles = {} local uiFiles = {} for i, file in ipairs(configFiles) do @@ -12,11 +12,11 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo table.insert(uiFiles, file) end end - + if #luaFiles == 0 then return error("Config (/bot/" .. config .. ") doesn't have lua files") end - + -- init bot variables local context = {} context.configDir = "/bot/".. config @@ -25,7 +25,7 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo context.panel = context.mainTab context.saveConfig = saveConfigCallback context.reload = reloadCallback - + context.storage = storage if context.storage._macros == nil then context.storage._macros = {} -- active macros @@ -75,7 +75,7 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo onRemoveItem = {}, onInventoryChange = {} } - + -- basic functions & classes context.print = print context.bit32 = bit32 @@ -110,7 +110,7 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo end context.isMobile = g_app.isMobile context.getVersion = g_app.getVersion - + -- classes context.g_resources = g_resources context.g_game = g_game @@ -143,7 +143,7 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo context.info = function(text) return msgCallback("info", tostring(text)) end context.warn = function(text) return msgCallback("warn", tostring(text)) end context.error = function(text) return msgCallback("error", tostring(text)) end - context.warning = context.warn + context.warning = context.warn -- init context context.now = g_clock.millis() @@ -169,10 +169,10 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo end return { - script = function() + script = function() context.now = g_clock.millis() context.time = g_clock.millis() - + for i, macro in ipairs(context._macros) do if macro.lastExecution + macro.timeout <= context.now and macro.enabled then local status, result = pcall(function() @@ -185,7 +185,7 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo end end end - + while #context._scheduler > 0 and context._scheduler[1].execution <= g_clock.millis() do local status, result = pcall(function() context._scheduler[1].callback() @@ -208,7 +208,7 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo if hotkey then if hotkey.single then if hotkey.callback() then - hotkey.lastExecution = context.now + hotkey.lastExecution = context.now end end if hotkey.switch then @@ -222,7 +222,7 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo onKeyUp = function(keyCode, keyboardModifiers) local keyDesc = determineKeyComboDesc(keyCode, keyboardModifiers) local hotkey = context._hotkeys[keyDesc] - if hotkey then + if hotkey then if hotkey.switch then hotkey.switch:setOn(false) end @@ -236,7 +236,7 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo local hotkey = context._hotkeys[keyDesc] if hotkey and not hotkey.single then if hotkey.callback() then - hotkey.lastExecution = context.now + hotkey.lastExecution = context.now end end for i, callback in ipairs(context._callbacks.onKeyPress) do @@ -262,21 +262,21 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo for i, callback in ipairs(context._callbacks.onLoginAdvice) do callback(message) end - end, + end, onAddThing = function(tile, thing) for i, callback in ipairs(context._callbacks.onAddThing) do callback(tile, thing) - end + end end, onRemoveThing = function(tile, thing) for i, callback in ipairs(context._callbacks.onRemoveThing) do callback(tile, thing) - end + end end, onCreatureAppear = function(creature) for i, callback in ipairs(context._callbacks.onCreatureAppear) do callback(creature) - end + end end, onCreatureDisappear = function(creature) for i, callback in ipairs(context._callbacks.onCreatureDisappear) do @@ -286,17 +286,17 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo onCreaturePositionChange = function(creature, newPos, oldPos) for i, callback in ipairs(context._callbacks.onCreaturePositionChange) do callback(creature, newPos, oldPos) - end + end end, onCreatureHealthPercentChange = function(creature, healthPercent) for i, callback in ipairs(context._callbacks.onCreatureHealthPercentChange) do callback(creature, healthPercent) - end + end end, onUse = function(pos, itemId, stackPos, subType) for i, callback in ipairs(context._callbacks.onUse) do callback(pos, itemId, stackPos, subType) - end + end end, onUseWith = function(pos, itemId, target, subType) for i, callback in ipairs(context._callbacks.onUseWith) do @@ -336,32 +336,32 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo onChannelList = function(channels) for i, callback in ipairs(context._callbacks.onChannelList) do callback(channels) - end + end end, onOpenChannel = function(channelId, channelName) for i, callback in ipairs(context._callbacks.onOpenChannel) do callback(channels) - end + end end, onCloseChannel = function(channelId) for i, callback in ipairs(context._callbacks.onCloseChannel) do callback(channelId) - end + end end, onChannelEvent = function(channelId, name, event) for i, callback in ipairs(context._callbacks.onChannelEvent) do callback(channelId, name, event) - end + end end, onTurn = function(creature, direction) for i, callback in ipairs(context._callbacks.onTurn) do callback(creature, direction) - end + end end, onWalk = function(creature, oldPos, newPos) for i, callback in ipairs(context._callbacks.onWalk) do callback(creature, oldPos, newPos) - end + end end, onModalDialog = function(id, title, message, buttons, enterButton, escapeButton, choices, priority) for i, callback in ipairs(context._callbacks.onModalDialog) do @@ -418,6 +418,6 @@ function executeBot(config, storage, tabs, msgCallback, saveConfigCallback, relo callback(player, slot, item, oldItem) end end - } + } } -end \ No newline at end of file +end diff --git a/mods/game_bot/functions/callbacks.lua b/mods/game_bot/functions/callbacks.lua index aeefcf4c60..ecb88352e3 100644 --- a/mods/game_bot/functions/callbacks.lua +++ b/mods/game_bot/functions/callbacks.lua @@ -14,12 +14,12 @@ context.callback = function(callbackType, callback) if info then desc = info.short_src .. ":" .. info.currentline end - + local callbackData = {} table.insert(context._callbacks[callbackType], function(...) if not callbackData.delay or callbackData.delay < context.now then local prevExecution = context._currentExecution - context._currentExecution = callbackData + context._currentExecution = callbackData local start = g_clock.realMillis() callback(...) local executionTime = g_clock.realMillis() - start @@ -46,42 +46,42 @@ context.callback = function(callbackType, callback) end -- onKeyDown(callback) -- callback = function(keys) -context.onKeyDown = function(callback) +context.onKeyDown = function(callback) return context.callback("onKeyDown", callback) end -- onKeyPress(callback) -- callback = function(keys) -context.onKeyPress = function(callback) +context.onKeyPress = function(callback) return context.callback("onKeyPress", callback) end -- onKeyUp(callback) -- callback = function(keys) -context.onKeyUp = function(callback) +context.onKeyUp = function(callback) return context.callback("onKeyUp", callback) end -- onTalk(callback) -- callback = function(name, level, mode, text, channelId, pos) -context.onTalk = function(callback) +context.onTalk = function(callback) return context.callback("onTalk", callback) end -- onTextMessage(callback) -- callback = function(mode, text) -context.onTextMessage = function(callback) +context.onTextMessage = function(callback) return context.callback("onTextMessage", callback) end -- onLoginAdvice(callback) -- callback = function(message) -context.onLoginAdvice = function(callback) +context.onLoginAdvice = function(callback) return context.callback("onLoginAdvice", callback) end -- onAddThing(callback) -- callback = function(tile, thing) -context.onAddThing = function(callback) +context.onAddThing = function(callback) return context.callback("onAddThing", callback) end -- onRemoveThing(callback) -- callback = function(tile, thing) -context.onRemoveThing = function(callback) +context.onRemoveThing = function(callback) return context.callback("onRemoveThing", callback) end @@ -268,4 +268,4 @@ context.onPlayerInventoryChange = function(callback) callback(slot, item, oldItem) end end) -end \ No newline at end of file +end diff --git a/mods/game_bot/functions/icon.lua b/mods/game_bot/functions/icon.lua index dcd48a2d82..a72338b7bf 100644 --- a/mods/game_bot/functions/icon.lua +++ b/mods/game_bot/functions/icon.lua @@ -28,7 +28,7 @@ context.addIcon = function(id, options, callback) if type(context.storage._icons[id]) ~= "table" then context.storage._icons[id] = {} end - local config = context.storage._icons[id] + local config = context.storage._icons[id] local widget = g_ui.createWidget("BotIcon", panel) widget.botWidget = true widget.botIcon = true @@ -53,7 +53,7 @@ context.addIcon = function(id, options, callback) widget.item:setShowCount(false) end end - + if options.outfit then widget.creature:setOutfit(options.outfit) end @@ -67,7 +67,7 @@ context.addIcon = function(id, options, callback) end widget.status:setOn(config.enabled) end - + if options.text then if options.switchable ~= false then widget.status:hide() @@ -77,9 +77,9 @@ context.addIcon = function(id, options, callback) widget.text:setColor('red') end end - widget.text:setText(options.text) + widget.text:setText(options.text) end - + widget.setOn = function(val) widget.status:setOn(val) if widget.status:isOn() then @@ -87,9 +87,9 @@ context.addIcon = function(id, options, callback) else widget.text:setColor('red') end - config.enabled = widget.status:isOn() + config.enabled = widget.status:isOn() end - + widget.onClick = function(widget) if options.switchable ~= false then widget.setOn(not widget.status:isOn()) @@ -98,10 +98,10 @@ context.addIcon = function(id, options, callback) return end end - + callback(widget, widget.status:isOn()) end - + if options.hotkey then widget.hotkey:setText(options.hotkey) context.hotkey(options.hotkey, "", function() @@ -136,7 +136,7 @@ context.addIcon = function(id, options, callback) local y = widget:getY() - parentRect.y local width = parentRect.width - widget:getWidth() local height = parentRect.height - widget:getHeight() - + config.x = math.min(1, math.max(0, x / width)) config.y = math.min(1, math.max(0, y / height)) @@ -159,18 +159,18 @@ context.addIcon = function(id, options, callback) end if options.phantom ~= true then - widget.onMouseRelease = function() - return true + widget.onMouseRelease = function() + return true end end - - if options.switchable ~= false then + + if options.switchable ~= false then if type(callback) == 'table' then callback.setOn(config.enabled) callback.icon = widget else - callback(widget, widget.status:isOn()) + callback(widget, widget.status:isOn()) end end return widget -end \ No newline at end of file +end diff --git a/mods/game_bot/functions/main.lua b/mods/game_bot/functions/main.lua index 211ee0c625..744f8b9812 100644 --- a/mods/game_bot/functions/main.lua +++ b/mods/game_bot/functions/main.lua @@ -17,7 +17,7 @@ context.macro = function(timeout, name, hotkey, callback, parent) elseif type(hotkey) == 'function' then parent = callback callback = hotkey - hotkey = "" + hotkey = "" elseif type(callback) ~= 'function' then error("Invalid callback for macro: " .. tostring(callback)) end @@ -29,22 +29,22 @@ context.macro = function(timeout, name, hotkey, callback, parent) end if not parent then parent = context.panel - end + end if hotkey:len() > 0 then hotkey = retranslateKeyComboDesc(hotkey) end - + -- min timeout is 50, to avoid lags if timeout < 50 then timeout = 50 end - + table.insert(context._macros, { enabled = false, name = name, timeout = timeout, lastExecution = context.now + math.random(0, 100), - hotkey = hotkey, + hotkey = hotkey, }) local macro = context._macros[#context._macros] @@ -87,7 +87,7 @@ context.macro = function(timeout, name, hotkey, callback, parent) macro.icon.setOn(false) end end - + if name:len() > 0 then -- creature switch local text = name @@ -103,13 +103,13 @@ context.macro = function(timeout, name, hotkey, callback, parent) else macro.enabled = true -- unnamed macros are enabled by default end - + local desc = "lua" local info = debug.getinfo(2, "Sl") if info then desc = info.short_src .. ":" .. info.currentline end - + macro.callback = function(macro) if not macro.delay or macro.delay < context.now then context._currentExecution = macro @@ -119,7 +119,7 @@ context.macro = function(timeout, name, hotkey, callback, parent) if executionTime > 100 then context.warning("Slow macro (" .. executionTime .. "ms): " .. macro.name .. " - " .. desc) end - context._currentExecution = nil + context._currentExecution = nil return true end end @@ -156,7 +156,7 @@ context.hotkey = function(keys, name, callback, parent, single) switch = switch, single = single } - + local desc = "lua" local info = debug.getinfo(2, "Sl") if info then @@ -166,7 +166,7 @@ context.hotkey = function(keys, name, callback, parent, single) local hotkeyData = context._hotkeys[keys] hotkeyData.callback = function() if not hotkeyData.delay or hotkeyData.delay < context.now then - context._currentExecution = hotkeyData + context._currentExecution = hotkeyData local start = g_clock.realMillis() callback() local executionTime = g_clock.realMillis() - start @@ -189,8 +189,8 @@ context.singlehotkey = function(keys, name, callback, parent) callback = name name = "" end - return context.hotkey(keys, name, callback, parent, true) -end + return context.hotkey(keys, name, callback, parent, true) +end -- schedule(timeout, callback) context.schedule = function(timeout, callback) @@ -208,4 +208,4 @@ context.delay = function(duration) return context.error("Invalid usage of delay function, it should be used inside callbacks") end context._currentExecution.delay = context.now + duration -end \ No newline at end of file +end diff --git a/mods/game_bot/functions/map.lua b/mods/game_bot/functions/map.lua index 1e27c92c55..79c69de4de 100644 --- a/mods/game_bot/functions/map.lua +++ b/mods/game_bot/functions/map.lua @@ -24,11 +24,11 @@ context.getSpectators = function(param1, param2) direction = param1:getDirection() param1 = param2 end - + if type(param1) == 'string' then - return g_map.getSpectatorsByPattern(pos, param1, direction) + return g_map.getSpectatorsByPattern(pos, param1, direction) end - + local multifloor = false if type(param1) == 'boolean' and param1 == true then multifloor = true @@ -97,7 +97,7 @@ context.findAllPaths = function(start, maxDist, params) if value == nil or value == false then params[key] = 0 elseif value == true then - params[key] = 1 + params[key] = 1 end end if type(params['maxDistanceFrom']) == 'table' then @@ -120,7 +120,7 @@ context.translateAllPathsToPath = function(paths, destPos) if type(destPos) ~= 'string' then destPosStr = destPos.x .. "," .. destPos.y .. "," .. destPos.z end - + while destPosStr:len() > 0 do local node = paths[destPosStr] if not node then @@ -140,7 +140,6 @@ context.translateAllPathsToPath = function(paths, destPos) end context.translateEveryPathToPath = context.translateAllPathsToPath - context.findPath = function(startPos, destPos, maxDist, params) --[[ Available params: @@ -173,7 +172,7 @@ context.findPath = function(startPos, destPos, maxDist, params) local marginMax = params.marginMax or params.maxMargin if type(marginMin) == 'number' and type(marginMax) == 'number' then local bestCandidate = nil - local bestCandidatePos = nil + local bestCandidatePos = nil for x = -marginMax, marginMax do for y = -marginMax, marginMax do if math.abs(x) >= marginMin or math.abs(y) >= marginMin then @@ -182,17 +181,17 @@ context.findPath = function(startPos, destPos, maxDist, params) if node and (not bestCandidate or bestCandidate[1] > node[1]) then bestCandidate = node bestCandidatePos = dest - end + end end end end if bestCandidate then - return context.translateAllPathsToPath(paths, bestCandidatePos) + return context.translateAllPathsToPath(paths, bestCandidatePos) end return end - if not paths[destPosStr] then + if not paths[destPosStr] then local precision = params.precision if type(precision) == 'number' then for p = 1, precision do @@ -209,19 +208,19 @@ context.findPath = function(startPos, destPos, maxDist, params) end end if bestCandidate then - return context.translateAllPathsToPath(paths, bestCandidatePos) + return context.translateAllPathsToPath(paths, bestCandidatePos) end end end return nil end - + return context.translateAllPathsToPath(paths, destPos) end context.getPath = context.findPath -- also works as autoWalk(dirs) where dirs is a list eg.: {1,2,3,0,1,1,2,} -context.autoWalk = function(destination, maxDist, params) +context.autoWalk = function(destination, maxDist, params) if type(destination) == "table" and table.isList(destination) and not maxDist and not params then g_game.autoWalk(destination, {x=0,y=0,z=0}) return true diff --git a/mods/game_bot/functions/npc.lua b/mods/game_bot/functions/npc.lua index b650f4c5d5..9822952019 100644 --- a/mods/game_bot/functions/npc.lua +++ b/mods/game_bot/functions/npc.lua @@ -4,7 +4,7 @@ context.NPC = {} context.NPC.talk = function(text) if g_game.getClientVersion() >= 810 then - g_game.talkChannel(11, 0, text) + g_game.talkChannel(11, 0, text) else return context.say(text) end @@ -29,7 +29,7 @@ context.NPC.getSellItems = function() name = item.name, subType = item.ptr:getSubType(), weight = item.weight / 100, - price = item.price + price = item.price }) end return items @@ -46,7 +46,7 @@ context.NPC.getBuyItems = function() name = item.name, subType = item.ptr:getSubType(), weight = item.weight / 100, - price = item.price + price = item.price }) end return items @@ -127,4 +127,4 @@ end context.NPC.close = context.NPC.closeTrade context.NPC.finish = context.NPC.closeTrade context.NPC.endTrade = context.NPC.closeTrade -context.NPC.finishTrade = context.NPC.closeTrade \ No newline at end of file +context.NPC.finishTrade = context.NPC.closeTrade diff --git a/mods/game_bot/functions/player_conditions.lua b/mods/game_bot/functions/player_conditions.lua index b87ceacdc5..e0b2abae04 100644 --- a/mods/game_bot/functions/player_conditions.lua +++ b/mods/game_bot/functions/player_conditions.lua @@ -2,7 +2,7 @@ local context = G.botContext for i, state in ipairs(PlayerStates) do context[state] = state -end +end context.hasCondition = function(condition) return bit.band(context.player:getStates(), condition) > 0 end diff --git a/mods/game_bot/functions/player_inventory.lua b/mods/game_bot/functions/player_inventory.lua index 9ea8c4c9fd..62e39ce185 100644 --- a/mods/game_bot/functions/player_inventory.lua +++ b/mods/game_bot/functions/player_inventory.lua @@ -42,4 +42,4 @@ context.moveToSlot = function(item, slot, count) count = item:getCount() end return g_game.move(item, {x=65535, y=slot, z=0}, count) -end \ No newline at end of file +end diff --git a/mods/game_bot/functions/server.lua b/mods/game_bot/functions/server.lua index f620fc5668..a99da082e9 100644 --- a/mods/game_bot/functions/server.lua +++ b/mods/game_bot/functions/server.lua @@ -60,7 +60,7 @@ context.BotServer.init = function(name, channel) context.BotServer._websocket = nil context.BotServer.ping = 0 context.BotServer.init(name, channel) - end + end }, context.BotServer.timeout) context._websockets[context.BotServer._websocket.id] = 1 context.BotServer._websocket.send({type="init", name=name, channel=channel, lastMessage=context.BotServer._lastMessageId}) diff --git a/mods/game_bot/functions/test.lua b/mods/game_bot/functions/test.lua index 9d6afcf098..1e06afef5f 100644 --- a/mods/game_bot/functions/test.lua +++ b/mods/game_bot/functions/test.lua @@ -1,3 +1,3 @@ local context = G.botContext -context.test = function() return context.info("test") end \ No newline at end of file +context.test = function() return context.info("test") end diff --git a/mods/game_bot/functions/tools.lua b/mods/game_bot/functions/tools.lua index bebae760d7..a956dc66cf 100644 --- a/mods/game_bot/functions/tools.lua +++ b/mods/game_bot/functions/tools.lua @@ -16,4 +16,4 @@ context.screenshot = context.doScreenshot context.getVersion = function() return g_app.getVersion() -end \ No newline at end of file +end diff --git a/mods/game_bot/functions/ui.lua b/mods/game_bot/functions/ui.lua index fe020dbc77..905c716fc6 100644 --- a/mods/game_bot/functions/ui.lua +++ b/mods/game_bot/functions/ui.lua @@ -5,7 +5,7 @@ end local UI = context.UI UI.createWidget = function(name, parent) - if parent == nil then + if parent == nil then parent = context.panel end local widget = g_ui.createWidget(name, parent) @@ -14,7 +14,7 @@ UI.createWidget = function(name, parent) end UI.createMiniWindow = function(name, parent) - if parent == nil then + if parent == nil then parent = modules.game_interface.getRightPanel() end local widget = g_ui.createWidget(name, parent) @@ -25,9 +25,9 @@ end UI.createWindow = function(name) local widget = g_ui.createWidget(name, g_ui.getRootWidget()) - widget.botWidget = true + widget.botWidget = true widget:show() widget:raise() widget:focus() return widget -end \ No newline at end of file +end diff --git a/mods/game_bot/functions/ui_elements.lua b/mods/game_bot/functions/ui_elements.lua index 79bbd4af42..808f9141ca 100644 --- a/mods/game_bot/functions/ui_elements.lua +++ b/mods/game_bot/functions/ui_elements.lua @@ -11,7 +11,6 @@ UI.Button = function(text, callback, parent) return widget end - UI.Config = function(parent) return UI.createWidget("BotConfig", parent) end @@ -62,7 +61,7 @@ UI.Container = function(callback, unique, parent, widget) for i = 1, itemsToShow do local widget = g_ui.createWidget("BotItem", widget.items) if type(items[i]) == 'number' then - items[i] = { id = items[i], count = 1 } + items[i] = {id=items[i], count=1} end if type(items[i]) == 'table' then widget:setItem(Item.create(items[i].id, items[i].count)) @@ -80,7 +79,7 @@ UI.Container = function(callback, unique, parent, widget) for i, child in ipairs(widget.items:getChildren()) do if child:getItemId() >= 100 then if not duplicates[child:getItemId()] or not unique then - table.insert(items, { id = child:getItemId(), count = child:getItemCount() }) + table.insert(items, {id=child:getItemId(), count=child:getItemCountOrSubType()}) duplicates[child:getItemId()] = true end end @@ -125,7 +124,7 @@ UI.DualScrollPanel = function(params, callback, parent) -- callback = function(w end end - local update = function(dontSignal) + local update = function(dontSignal) widget.title:setText("" .. params.min .. "% <= " .. params.title .. " <= " .. params.max .. "%") if callback and not dontSignal then callback(widget, params) @@ -181,7 +180,7 @@ UI.DualScrollItemPanel = function(params, callback, parent) -- callback = functi end end - local update = function(dontSignal) + local update = function(dontSignal) widget.title:setText("" .. params.min .. "% <= " .. params.title .. " <= " .. params.max .. "%") if callback and not dontSignal then callback(widget, params) @@ -294,7 +293,7 @@ UI.DualLabel = function(left, right, params, parent) widget.right:setText(right) widget:setHeight(params.height) if widget.left:getWidth() > params.maxWidth then - widget.left:setWidth(params.maxWidth) + widget.left:setWidth(params.maxWidth) end return widget end @@ -325,7 +324,7 @@ UI.LabelAndTextEdit = function(params, callback, parent) widget.right.onTextChange = function(widget, text) params.right = text if callback then - callback(widget, params) + callback(widget, params) end end @@ -371,20 +370,20 @@ UI.SwitchAndButton = function(params, callbackSwitch, callbackButton, callback, params.on = not params.on widget.left:setOn(params.on) if callback then - callback(widget, params) + callback(widget, params) end if callbackSwitch then - callbackSwitch() + callbackSwitch() else - warn("callback not set!") + warn("callback not set!") end end widget.right.onClick = function() if callbackButton then - callbackButton() + callbackButton() else - warn("callback not set!") + warn("callback not set!") end end diff --git a/mods/game_bot/functions/ui_legacy.lua b/mods/game_bot/functions/ui_legacy.lua index 2fece4c5d1..095bf0940e 100644 --- a/mods/game_bot/functions/ui_legacy.lua +++ b/mods/game_bot/functions/ui_legacy.lua @@ -4,14 +4,14 @@ local context = G.botContext -- IT'S ONLY HERE FOR BACKWARD COMPATIBILITY, MAY BE REMOVED IN THE FUTURE context.createWidget = function(name, parent) - if parent == nil then + if parent == nil then parent = context.panel end g_ui.createWidget(name, parent) end context.setupUI = function(otml, parent) - if parent == nil then + if parent == nil then parent = context.panel end local widget = g_ui.loadUIFromString(otml, parent) @@ -34,7 +34,7 @@ context.addTab = function(name) if tab then -- return existing tab return tab.tabPanel.content end - + local smallTabs = #(context.tabs.tabs) >= 5 local newTab = context.tabs:addTab(name, g_ui.createWidget('BotPanel')).tabPanel.content context.tabs:setOn(true) @@ -43,7 +43,7 @@ context.addTab = function(name) tab:setFont('small-9px') end end - + return newTab end context.getTab = context.addTab @@ -72,7 +72,7 @@ context.addButton = function(id, text, onClickCallback, parent) button:setId(id) button:setText(text) button.onClick = onClickCallback - return button + return button end context.addLabel = function(id, text, parent) @@ -82,7 +82,7 @@ context.addLabel = function(id, text, parent) local label = g_ui.createWidget('BotLabel', parent) label:setId(id) label:setText(text) - return label + return label end context.addTextEdit = function(id, text, onTextChangeCallback, parent) @@ -93,7 +93,7 @@ context.addTextEdit = function(id, text, onTextChangeCallback, parent) widget:setId(id) widget.onTextChange = onTextChangeCallback widget:setText(text) - return widget + return widget end context.addSeparator = function(id, parent) @@ -102,7 +102,7 @@ context.addSeparator = function(id, parent) end local separator = g_ui.createWidget('BotSeparator', parent) separator:setId(id) - return separator + return separator end context._addMacroSwitch = function(name, keys, parent) @@ -132,4 +132,4 @@ context._addHotkeySwitch = function(name, keys, parent) local switch = context.addSwitch("hotkey_" .. #context._hotkeys, text, nil, parent) switch:setOn(false) return switch -end \ No newline at end of file +end diff --git a/mods/game_bot/functions/ui_windows.lua b/mods/game_bot/functions/ui_windows.lua index a0c0a4c3db..75c1bf1bf5 100644 --- a/mods/game_bot/functions/ui_windows.lua +++ b/mods/game_bot/functions/ui_windows.lua @@ -46,4 +46,4 @@ UI.ConfirmationWindow = function(title, question, callback) anchor=AnchorHorizontalCenter}, onConfirm, closeWindow) window.botWidget = true return window -end \ No newline at end of file +end diff --git a/mods/game_bot/panels/attacking.lua b/mods/game_bot/panels/attacking.lua index 34b1ac8503..8de2a3a2ef 100644 --- a/mods/game_bot/panels/attacking.lua +++ b/mods/game_bot/panels/attacking.lua @@ -664,7 +664,6 @@ Panel ignoreOnOptionChange = false end - ui.config.onOptionChange = function(widget) if not ignoreOnOptionChange then context.storage.attacking.activeConfig = widget.currentIndex @@ -721,7 +720,6 @@ Panel }, removeConfig, closeWindow) end - ui.mAdd.onClick = function() if not context.storage.attacking.activeConfig or not context.storage.attacking.configs[context.storage.attacking.activeConfig] then return diff --git a/mods/game_bot/panels/healing.lua b/mods/game_bot/panels/healing.lua index fe4171d07c..82d023d6d3 100644 --- a/mods/game_bot/panels/healing.lua +++ b/mods/game_bot/panels/healing.lua @@ -9,7 +9,7 @@ Panels.Haste = function(parent) end end end, parent) - context.addTextEdit("autoHasteText", context.storage.autoHasteText or "utani hur", function(widget, text) + context.addTextEdit("autoHasteText", context.storage.autoHasteText or "utani hur", function(widget, text) context.storage.autoHasteText = text end, parent) end @@ -31,27 +31,26 @@ Panels.AntiParalyze = function(parent) context.saySpell(context.storage.autoAntiParalyzeText, 750) end end, parent) - context.addTextEdit("autoAntiParalyzeText", context.storage.autoAntiParalyzeText or "utani hur", function(widget, text) + context.addTextEdit("autoAntiParalyzeText", context.storage.autoAntiParalyzeText or "utani hur", function(widget, text) context.storage.autoAntiParalyzeText = text end, parent) end - Panels.Health = function(parent) if not parent then parent = context.panel end - + local panelName = "autoHealthPanel" local panelId = 1 while parent:getChildById(panelName .. panelId) do panelId = panelId + 1 end panelName = panelName .. panelId - + local ui = g_ui.createWidget("DualScrollPanel", parent) ui:setId(panelName) - + if not context.storage[panelName] then context.storage[panelName] = { item = 266, @@ -68,14 +67,14 @@ Panels.Health = function(parent) end ui.text.onTextChange = function(widget, text) - context.storage[panelName].text = text + context.storage[panelName].text = text end ui.text:setText(context.storage[panelName].text or "exura") - + local updateText = function() - ui.title:setText("" .. context.storage[panelName].min .. "% <= hp <= " .. context.storage[panelName].max .. "%") + ui.title:setText("" .. context.storage[panelName].min .. "% <= hp <= " .. context.storage[panelName].max .. "%") end - + ui.scroll1.onValueChange = function(scroll, value) context.storage[panelName].min = value updateText() @@ -87,7 +86,7 @@ Panels.Health = function(parent) ui.scroll1:setValue(context.storage[panelName].min) ui.scroll2:setValue(context.storage[panelName].max) - + context.macro(25, function() if context.storage[panelName].enabled and context.storage[panelName].text:len() > 0 and context.storage[panelName].min <= context.hppercent() and context.hppercent() <= context.storage[panelName].max then if context.saySpell(context.storage[panelName].text, 500) then @@ -101,17 +100,17 @@ Panels.HealthItem = function(parent) if not parent then parent = context.panel end - + local panelName = "autoHealthItemPanel" local panelId = 1 while parent:getChildById(panelName .. panelId) do panelId = panelId + 1 end panelName = panelName .. panelId - + local ui = g_ui.createWidget("DualScrollItemPanel", parent) ui:setId(panelName) - + if not context.storage[panelName] then context.storage[panelName] = { item = 266, @@ -130,11 +129,11 @@ Panels.HealthItem = function(parent) context.storage[panelName].item = widget:getItemId() end ui.item:setItemId(context.storage[panelName].item) - + local updateText = function() - ui.title:setText("" .. (context.storage[panelName].min or "") .. "% <= hp <= " .. (context.storage[panelName].max or "") .. "%") + ui.title:setText("" .. (context.storage[panelName].min or "") .. "% <= hp <= " .. (context.storage[panelName].max or "") .. "%") end - + ui.scroll1.onValueChange = function(scroll, value) context.storage[panelName].min = value updateText() @@ -146,7 +145,7 @@ Panels.HealthItem = function(parent) ui.scroll1:setValue(context.storage[panelName].min) ui.scroll2:setValue(context.storage[panelName].max) - + context.macro(25, function() if context.storage[panelName].enabled and context.storage[panelName].item >= 100 and context.storage[panelName].min <= context.hppercent() and context.hppercent() <= context.storage[panelName].max then if context.useRune(context.storage[panelName].item, context.player, 500) then @@ -160,17 +159,17 @@ Panels.Mana = function(parent) if not parent then parent = context.panel end - + local panelName = "autoManaItemPanel" local panelId = 1 while parent:getChildById(panelName .. panelId) do panelId = panelId + 1 end panelName = panelName .. panelId - + local ui = g_ui.createWidget("DualScrollItemPanel", parent) ui:setId(panelName) - + if not context.storage[panelName] then context.storage[panelName] = { item = 268, @@ -189,11 +188,11 @@ Panels.Mana = function(parent) context.storage[panelName].item = widget:getItemId() end ui.item:setItemId(context.storage[panelName].item) - + local updateText = function() - ui.title:setText("" .. (context.storage[panelName].min or "") .. "% <= mana <= " .. (context.storage[panelName].max or "") .. "%") + ui.title:setText("" .. (context.storage[panelName].min or "") .. "% <= mana <= " .. (context.storage[panelName].max or "") .. "%") end - + ui.scroll1.onValueChange = function(scroll, value) context.storage[panelName].min = value updateText() @@ -205,7 +204,7 @@ Panels.Mana = function(parent) ui.scroll1:setValue(context.storage[panelName].min) ui.scroll2:setValue(context.storage[panelName].max) - + context.macro(25, function() if context.storage[panelName].enabled and context.storage[panelName].item >= 100 and context.storage[panelName].min <= context.manapercent() and context.manapercent() <= context.storage[panelName].max then if context.useRune(context.storage[panelName].item, context.player, 500) then @@ -220,17 +219,17 @@ Panels.Equip = function(parent) if not parent then parent = context.panel end - + local panelName = "autoEquipItem" local panelId = 1 while parent:getChildById(panelName .. panelId) do panelId = panelId + 1 end panelName = panelName .. panelId - + local ui = g_ui.createWidget("TwoItemsAndSlotPanel", parent) ui:setId(panelName) - + if not context.storage[panelName] then context.storage[panelName] = {} if panelId == 1 then @@ -239,24 +238,24 @@ Panels.Equip = function(parent) context.storage[panelName].slot = 9 end end - + ui.title:setText("Auto equip") ui.title:setOn(context.storage[panelName].enabled) ui.title.onClick = function(widget) context.storage[panelName].enabled = not context.storage[panelName].enabled widget:setOn(context.storage[panelName].enabled) end - + ui.item1:setItemId(context.storage[panelName].item1 or 0) ui.item1.onItemChange = function(widget) context.storage[panelName].item1 = widget:getItemId() end - + ui.item2:setItemId(context.storage[panelName].item2 or 0) ui.item2.onItemChange = function(widget) context.storage[panelName].item2 = widget:getItemId() end - + if not context.storage[panelName].slot then context.storage[panelName].slot = 1 end @@ -264,7 +263,7 @@ Panels.Equip = function(parent) ui.slot.onOptionChange = function(widget) context.storage[panelName].slot = widget.currentIndex end - + context.macro(250, function() if context.storage[panelName].enabled and context.storage[panelName].slot > 0 then local item1 = context.storage[panelName].item1 or 0 @@ -294,14 +293,14 @@ Panels.Eating = function(parent) if not parent then parent = context.panel end - + local panelName = "autoEatingPanel" local panelId = 1 while parent:getChildById(panelName .. panelId) do panelId = panelId + 1 end panelName = panelName .. panelId - + local ui = g_ui.createWidget("ItemsPanel", parent) ui:setId(panelName) @@ -315,7 +314,7 @@ Panels.Eating = function(parent) context.storage[panelName].enabled = not context.storage[panelName].enabled widget:setOn(context.storage[panelName].enabled) end - + if type(context.storage[panelName].items) ~= 'table' then context.storage[panelName].items = {3725, 0, 0, 0, 0} end @@ -324,10 +323,10 @@ Panels.Eating = function(parent) ui.items:getChildByIndex(i).onItemChange = function(widget) context.storage[panelName].items[i] = widget:getItemId() end - ui.items:getChildByIndex(i):setItemId(context.storage[panelName].items[i]) + ui.items:getChildByIndex(i):setItemId(context.storage[panelName].items[i]) end - - context.macro(15000, function() + + context.macro(15000, function() if not context.storage[panelName].enabled then return end @@ -339,8 +338,7 @@ Panels.Eating = function(parent) end if #candidates == 0 then return - end + end context.use(candidates[math.random(1, #candidates)]) end) end - diff --git a/mods/game_bot/panels/looting.lua b/mods/game_bot/panels/looting.lua index cf2785a73f..036f9955e9 100644 --- a/mods/game_bot/panels/looting.lua +++ b/mods/game_bot/panels/looting.lua @@ -6,7 +6,7 @@ Panels.Looting = function(parent) Panel id: looting height: 180 - + BotLabel anchors.top: parent.top anchors.left: parent.left @@ -27,7 +27,7 @@ Panel anchors.left: prev.right anchors.right: parent.right margin-left: 5 - + Button margin-top: 1 id: add @@ -52,7 +52,7 @@ Panel text: Remove width: 60 height: 17 - + ScrollablePanel id: items anchors.top: prev.bottom @@ -89,16 +89,16 @@ Panel anchors.right: parent.right height: 33 margin-top: 2 - + ]], parent) - + local lootContainers = { ui.containers.item1, ui.containers.item2, ui.containers.item3, ui.containers.item4, ui.containers.item5 } if type(context.storage.looting) ~= "table" then context.storage.looting = {} end if type(context.storage.looting.configs) ~= "table" then - context.storage.looting.configs = {} + context.storage.looting.configs = {} end local getConfigName = function(config) @@ -119,7 +119,7 @@ Panel if not context.storage.looting.activeConfig or not context.storage.looting.configs[context.storage.looting.activeConfig] then return end - + local tmpItems = {} local tmpContainers = {} local focusIndex = 0 @@ -144,15 +144,15 @@ Panel if widget:getItemId() >= 100 then if tmpContainers[widget:getItemId()] == nil then tmpContainers[widget:getItemId()] = 1 -- remove duplicates - newConfig = newConfig .. "\ncontainer:" .. widget:getItemId() + newConfig = newConfig .. "\ncontainer:" .. widget:getItemId() end end end - + context.storage.looting.configs[context.storage.looting.activeConfig] = newConfig refreshConfig(focusIndex) end - + local parseConfig = function(config) items = {} itemsByKey = {} @@ -182,7 +182,7 @@ Panel if itemsToShow < 10 then itemsToShow = 10 end - + for i=1,itemsToShow do local widget = g_ui.createWidget("BotItem", ui.items) local itemId = 0 @@ -192,7 +192,7 @@ Panel widget:setItemId(itemId) widget.onItemChange = createNewConfig end - + for i, widget in ipairs(lootContainers) do widget:setItemId(0) end @@ -207,7 +207,7 @@ Panel widget.onItemChange = createNewConfig end end - + local ignoreOnOptionChange = true refreshConfig = function(focusIndex) ignoreOnOptionChange = true @@ -218,7 +218,7 @@ Panel ui.enableButton:setText("Off") ui.enableButton:setColor('#FF0000FF') end - + ui.config:clear() for i, config in ipairs(context.storage.looting.configs) do local name = getConfigName(config) @@ -227,28 +227,28 @@ Panel end ui.config:addOption(name) end - + if (not context.storage.looting.activeConfig or context.storage.looting.activeConfig == 0) and #context.storage.looting.configs > 0 then context.storage.looting.activeConfig = 1 end - + ui.items:destroyChildren() for i, widget in ipairs(lootContainers) do widget.onItemChange = nil widget:setItemId(0) widget:setItemCount(0) end - + if context.storage.looting.activeConfig and context.storage.looting.configs[context.storage.looting.activeConfig] then ui.config:setCurrentIndex(context.storage.looting.activeConfig) parseConfig(context.storage.looting.configs[context.storage.looting.activeConfig]) end - + context.saveConfig() if focusIndex and focusIndex > 0 and ui.items:getChildByIndex(focusIndex) then ui.items:focusChild(ui.items:getChildByIndex(focusIndex)) end - + ignoreOnOptionChange = false end @@ -362,7 +362,7 @@ Panel break end end - + -- found item to loot if foundItem then -- find backpack for it, first backpack with same items @@ -415,7 +415,7 @@ Panel return end local delay = 1 - for i=2,#nextContainers do + for i=2,#nextContainers do -- if more than 1 container, open them in new window context.schedule(delay, function() g_game.open(nextContainers[i], nil) @@ -428,4 +428,3 @@ Panel context.delay(150 + delay) end) end - diff --git a/mods/game_bot/panels/tools.lua b/mods/game_bot/panels/tools.lua index 1094b6e6e7..206cc6460a 100644 --- a/mods/game_bot/panels/tools.lua +++ b/mods/game_bot/panels/tools.lua @@ -7,11 +7,11 @@ Panels.TradeMessage = function(parent) if not trade then trade = context.getChannelId("trade") end - if context.storage.autoTradeMessage:len() > 0 and trade then + if context.storage.autoTradeMessage:len() > 0 and trade then context.sayChannel(trade, context.storage.autoTradeMessage) end end, parent) - context.addTextEdit("autoTradeMessage", context.storage.autoTradeMessage or "I'm using OTClientV8 - https://github.com/OTCv8/otclientv8", function(widget, text) + context.addTextEdit("autoTradeMessage", context.storage.autoTradeMessage or "I'm using OTClientV8 - https://github.com/OTCv8/otclientv8", function(widget, text) context.storage.autoTradeMessage = text end, parent) end @@ -33,4 +33,4 @@ Panels.AutoStackItems = function(parent) end end end, parent) -end \ No newline at end of file +end diff --git a/mods/game_bot/panels/war.lua b/mods/game_bot/panels/war.lua index 44cf767f45..2451c3c383 100644 --- a/mods/game_bot/panels/war.lua +++ b/mods/game_bot/panels/war.lua @@ -27,18 +27,18 @@ Panels.AttackLeaderTarget = function(parent) end end) context.macro(50, "Attack leader's target", nil, function() - if toAttack and context.storage.attackLeader:len() > 0 and toAttack ~= g_game.getAttackingCreature() then + if toAttack and context.storage.attackLeader:len() > 0 and toAttack ~= g_game.getAttackingCreature() then g_game.attack(toAttack) toAttack = nil end end, parent) - context.addTextEdit("attackLeader", context.storage.attackLeader or "player name", function(widget, text) + context.addTextEdit("attackLeader", context.storage.attackLeader or "player name", function(widget, text) context.storage.attackLeader = text - end, parent) + end, parent) end -Panels.LimitFloor = function(parent) +Panels.LimitFloor = function(parent) context.onPlayerPositionChange(function(pos) if context.storage.limitFloor then local gameMapPanel = modules.game_interface.getMapPanel() @@ -56,7 +56,7 @@ Panels.LimitFloor = function(parent) if context.storage.limitFloor then gameMapPanel:lockVisibleFloor(context.posz()) else - gameMapPanel:unlockVisibleFloor() + gameMapPanel:unlockVisibleFloor() end end end, parent) @@ -67,8 +67,8 @@ Panels.AntiPush = function(parent) if not parent then parent = context.panel end - - local panelName = "antiPushPanel" + + local panelName = "antiPushPanel" local ui = g_ui.createWidget("ItemsPanel", parent) ui:setId(panelName) @@ -82,7 +82,7 @@ Panels.AntiPush = function(parent) context.storage[panelName].enabled = not context.storage[panelName].enabled widget:setOn(context.storage[panelName].enabled) end - + if type(context.storage[panelName].items) ~= 'table' then context.storage[panelName].items = {3031, 3035, 0, 0, 0} end @@ -91,10 +91,10 @@ Panels.AntiPush = function(parent) ui.items:getChildByIndex(i).onItemChange = function(widget) context.storage[panelName].items[i] = widget:getItemId() end - ui.items:getChildByIndex(i):setItemId(context.storage[panelName].items[i]) + ui.items:getChildByIndex(i):setItemId(context.storage[panelName].items[i]) end - - context.macro(100, function() + + context.macro(100, function() if not context.storage[panelName].enabled then return end @@ -106,7 +106,7 @@ Panels.AntiPush = function(parent) if topItem and topItem:isStackable() then topItem = topItem:getId() else - topItem = 0 + topItem = 0 end local candidates = {} for i, item in pairs(context.storage[panelName].items) do diff --git a/mods/game_bot/panels/waypoints.lua b/mods/game_bot/panels/waypoints.lua index ac29ef99a1..b66c699619 100644 --- a/mods/game_bot/panels/waypoints.lua +++ b/mods/game_bot/panels/waypoints.lua @@ -289,7 +289,6 @@ Panel ignoreOnOptionChange = false end - ui.config.onOptionChange = function(widget) if not ignoreOnOptionChange then context.storage.cavebot.activeConfig = widget.currentIndex @@ -595,7 +594,6 @@ Panel end end) - context.macro(250, function() if not context.storage.cavebot.enabled then return diff --git a/mods/game_bot/ui/basic.otui b/mods/game_bot/ui/basic.otui index 56d9e036b7..d1c003040e 100644 --- a/mods/game_bot/ui/basic.otui +++ b/mods/game_bot/ui/basic.otui @@ -15,26 +15,26 @@ SmallBotSwitch < Button image-color: green $!on: image-color: red - + BotLabel < Label margin-top: 2 height: 15 text-auto-resize: true text-align: center text-wrap: true - + BotItem < Item virtual: true &selectable: true &editable: true -BotTextEdit < TextEdit +BotTextEdit < TextEdit @onClick: modules.client_textedit.show(self) text-align: center multiline: false focusable: false height: 20 - + BotSeparator < HorizontalSeparator margin-top: 5 margin-bottom: 3 @@ -60,7 +60,7 @@ BotPanel < Panel anchors.top: parent.top anchors.bottom: parent.bottom anchors.right: parent.right - + CaveBotLabel < Label background-color: alpha text-offset: 2 0 @@ -68,7 +68,7 @@ CaveBotLabel < Label $focus: background-color: #00000055 - + SlotComboBoxPopupMenu < ComboBoxPopupMenu SlotComboBoxPopupMenuButton < ComboBoxPopupMenuButton SlotComboBox < ComboBox @@ -84,5 +84,3 @@ SlotComboBox < ComboBox self:addOption("Finger") self:addOption("Ammo") self:addOption("Purse") - - diff --git a/mods/game_bot/ui/config.otui b/mods/game_bot/ui/config.otui index baa541d1cc..64a21308a3 100644 --- a/mods/game_bot/ui/config.otui +++ b/mods/game_bot/ui/config.otui @@ -20,11 +20,11 @@ BotConfig < Panel anchors.top: prev.top anchors.left: prev.right anchors.right: parent.right - margin-left: 5 + margin-left: 5 $on: text: On color: #00AA00 - + $!on: text: Off color: #FF0000 @@ -38,7 +38,7 @@ BotConfig < Panel width: 56 height: 18 text-offet: 0 2 - + Button id: edit anchors.top: prev.top @@ -47,7 +47,7 @@ BotConfig < Panel width: 56 height: 18 text-offet: 0 2 - + Button id: remove anchors.top: prev.top @@ -55,4 +55,4 @@ BotConfig < Panel text: Remove width: 56 height: 18 - text-offet: 0 2 \ No newline at end of file + text-offet: 0 2 diff --git a/mods/game_bot/ui/container.otui b/mods/game_bot/ui/container.otui index acb04a1a06..1f75b9caa7 100644 --- a/mods/game_bot/ui/container.otui +++ b/mods/game_bot/ui/container.otui @@ -1,6 +1,6 @@ BotContainer < Panel height: 68 - + ScrollablePanel id: items anchors.fill: parent diff --git a/mods/game_bot/ui/icons.otui b/mods/game_bot/ui/icons.otui index 655c66cb0e..c810e88e5d 100644 --- a/mods/game_bot/ui/icons.otui +++ b/mods/game_bot/ui/icons.otui @@ -22,7 +22,7 @@ BotIcon < UIWidget margin-top: 0 size: 48 48 phantom: true - + UIWidget id: status anchors.top: parent.top @@ -39,7 +39,7 @@ BotIcon < UIWidget $!on: text: OFF background: red - + UIWidget id: hotkey anchors.top: parent.top @@ -49,7 +49,7 @@ BotIcon < UIWidget color: white phantom: true text-align: right - + UIWidget id: text anchors.bottom: parent.bottom diff --git a/mods/game_bot/ui/panels.otui b/mods/game_bot/ui/panels.otui index bb0e8df14f..a4659af945 100644 --- a/mods/game_bot/ui/panels.otui +++ b/mods/game_bot/ui/panels.otui @@ -1,14 +1,14 @@ DualScrollPanel < Panel height: 51 margin-top: 3 - + SmallBotSwitch id: title anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top text-align: center - + HorizontalScrollBar id: scroll1 anchors.left: title.left @@ -20,7 +20,7 @@ DualScrollPanel < Panel maximum: 100 step: 1 &disableScroll: true - + HorizontalScrollBar id: scroll2 anchors.left: title.horizontalCenter @@ -31,7 +31,7 @@ DualScrollPanel < Panel maximum: 100 step: 1 &disableScroll: true - + BotTextEdit id: text anchors.left: parent.left @@ -44,7 +44,7 @@ DualScrollPanel < Panel SingleScrollItemPanel < Panel height: 45 margin-top: 2 - + BotItem id: item anchors.left: parent.left @@ -55,10 +55,10 @@ SingleScrollItemPanel < Panel id: title anchors.left: prev.right anchors.right: parent.right - anchors.top: prev.top + anchors.top: prev.top margin-left: 2 text-align: center - + HorizontalScrollBar id: scroll anchors.left: title.left @@ -73,7 +73,7 @@ SingleScrollItemPanel < Panel DualScrollItemPanel < Panel height: 33 margin-top: 3 - + BotItem id: item anchors.left: parent.left @@ -84,10 +84,10 @@ DualScrollItemPanel < Panel id: title anchors.left: prev.right anchors.right: parent.right - anchors.top: prev.top + anchors.top: prev.top margin-left: 2 text-align: center - + HorizontalScrollBar id: scroll1 anchors.left: title.left @@ -99,7 +99,7 @@ DualScrollItemPanel < Panel maximum: 100 step: 1 &disableScroll: true - + HorizontalScrollBar id: scroll2 anchors.left: title.horizontalCenter @@ -110,11 +110,11 @@ DualScrollItemPanel < Panel maximum: 100 step: 1 &disableScroll: true - + ItemsRow < Panel height: 33 margin-top: 2 - + BotItem id: item1 anchors.top: parent.top @@ -143,7 +143,7 @@ ItemsRow < Panel anchors.top: prev.top anchors.left: prev.right margin-left: 2 - + ItemsPanel < Panel height: 55 @@ -153,22 +153,21 @@ ItemsPanel < Panel anchors.right: parent.right anchors.top: parent.top text-align: center - + ItemsRow id: items anchors.left: parent.left anchors.right: parent.right anchors.top: prev.bottom - - + ItemAndButtonPanel < Panel height: 40 - + BotItem id: item anchors.left: parent.left anchors.top: parent.top - + BotSwitch id: title anchors.left: prev.right @@ -176,16 +175,16 @@ ItemAndButtonPanel < Panel anchors.verticalCenter: prev.verticalCenter text-align: center margin-left: 2 - margin-top: 0 - + margin-top: 0 + ItemAndSlotPanel < Panel height: 40 - + BotItem id: item anchors.left: parent.left anchors.top: parent.top - + SmallBotSwitch id: title anchors.left: prev.right @@ -207,7 +206,7 @@ ItemAndSlotPanel < Panel TwoItemsAndSlotPanel < Panel height: 35 margin-top: 4 - + BotItem id: item1 anchors.left: parent.left @@ -219,7 +218,7 @@ TwoItemsAndSlotPanel < Panel anchors.left: prev.right anchors.top: prev.top margin-left: 1 - + SmallBotSwitch id: title anchors.left: prev.right @@ -307,4 +306,4 @@ SwitchAndButtonPanel < Panel anchors.left: parent.left anchors.right: prev.left margin-right: 3 - text-align: center \ No newline at end of file + text-align: center diff --git a/mods/game_buttons/buttons.otui b/mods/game_buttons/buttons.otui index 963a541a85..bee29fe4ab 100644 --- a/mods/game_buttons/buttons.otui +++ b/mods/game_buttons/buttons.otui @@ -3,4 +3,3 @@ GameButtonsWindow &save: true !text: tr("Buttons") icon: /images/topbuttons/buttons - diff --git a/mods/game_itemselector/itemselector.lua b/mods/game_itemselector/itemselector.lua index 33f9437310..7a961f2ab4 100644 --- a/mods/game_itemselector/itemselector.lua +++ b/mods/game_itemselector/itemselector.lua @@ -27,7 +27,7 @@ function show(itemWidget) destroyWindow() end local window = g_ui.createWidget('ItemSelectorWindow', rootWidget) - + local destroy = function() window:destroy() if window == activeWindow then @@ -43,27 +43,27 @@ function show(itemWidget) window.item:setItemCount(0) doneFunc() end - + window.clearButton.onClick = clearFunc window.okButton.onClick = doneFunc window.cancelButton.onClick = destroy window.onEnter = doneFunc window.onEscape = destroy - + window.item:setItem(Item.create(itemWidget:getItemId(), itemWidget:getItemCount())) - + window.itemId:setValue(itemWidget:getItemId()) if itemWidget:getItemCount() > 1 then window.itemCount:setValue(itemWidget:getItemCount()) end - + window.itemId.onValueChange = function(widget, value) window.item:setItemId(value) end window.itemCount.onValueChange = function(widget, value) window.item:setItemCount(value) end - + activeWindow = window activeWindow:raise() activeWindow:focus() diff --git a/mods/game_itemselector/itemselector.otui b/mods/game_itemselector/itemselector.otui index 0e114c62ab..b7c6aec462 100644 --- a/mods/game_itemselector/itemselector.otui +++ b/mods/game_itemselector/itemselector.otui @@ -2,7 +2,7 @@ ItemSelectorWindow < MainWindow id: itemSelector size: 260 120 !text: tr("Select item") - + Item id: item virtual: true @@ -55,7 +55,7 @@ ItemSelectorWindow < MainWindow anchors.bottom: parent.bottom anchors.left: parent.left width: 60 - + Button id: okButton !text: tr('Ok') diff --git a/modules/game_battle/battle.lua b/modules/game_battle/battle.lua index eea017d726..834c91f6c7 100644 --- a/modules/game_battle/battle.lua +++ b/modules/game_battle/battle.lua @@ -1,5 +1,5 @@ -- Global Tables -local binaryTree = {} -- BST +local binaryTree = {} -- BST local battleButtons = {} -- map of creature id -- Global variables that will inherit from init @@ -64,7 +64,7 @@ end function init() -- Initiating the module (load) g_ui.importStyle('battlebutton') battleButton = modules.client_topmenu.addRightGameToggleButton('battleButton', tr('Battle') .. ' (Ctrl+B)', - '/images/topbuttons/battle', toggle) + '/images/topbuttons/battle', toggle) battleButton:setOn(true) battleWindow = g_ui.loadUI('battle') @@ -88,14 +88,14 @@ function init() -- Initiating the module (load) end -- Adding Filter options - local options = { 'hidePlayers', 'hideNPCs', 'hideMonsters', 'hideSkulls', 'hideParty' } + local options = {'hidePlayers', 'hideNPCs', 'hideMonsters', 'hideSkulls', 'hideParty'} for i, v in ipairs(options) do hideButtons[v] = battleWindow:recursiveGetChildById(v) end -- Adding SortType and SortOrder options - local sortTypeOptions = { 'Name', 'Distance', 'Age', 'Health' } - local sortOrderOptions = { 'Asc.', 'Desc.' } + local sortTypeOptions = {'Name', 'Distance', 'Age', 'Health'} + local sortOrderOptions = {'Asc.', 'Desc.'} local sortTypeBox = battleWindow:recursiveGetChildById('sortTypeBox') for i, v in ipairs(sortTypeOptions) do @@ -134,6 +134,7 @@ end -- Binary Search, Insertion and Resort functions local function debugTables(sortType) -- Print both battlebutton and binarytree tables + local function getInfo(v, sortType) local returnedInfo = v.id if sortType then @@ -463,14 +464,10 @@ end local function canBeSeen(creature) return creature and creature:canBeSeen() and creature:getPosition() and - modules.game_interface.getMapPanel():isInRange(creature:getPosition()) + modules.game_interface.getMapPanel():isInRange(creature:getPosition()) end local function getDistanceBetween(p1, p2) -- Calculate distance - if p2 == nil then - p2 = { x = 0, y = 0 } - end - local xd = math.abs(p1.x - p2.x); local yd = math.abs(p1.y - p2.y); @@ -625,8 +622,8 @@ function removeCreature(creature, all) -- Remove a single creature or all msg = msg .. p end assert(index ~= nil, - 'Not able to remove creature: id ' .. creatureId .. ' not found in binary search using ' .. sortType .. - ' to find value ' .. msg .. '.') + 'Not able to remove creature: id ' .. creatureId .. ' not found in binary search using ' .. sortType .. + ' to find value ' .. msg .. '.') end end return false @@ -691,8 +688,10 @@ function attackNext(previous) if battleButton.isTarget then foundTarget = true + elseif foundTarget and not nextElement then nextElement = battleButton + elseif not foundTarget then prevElement = battleButton end @@ -713,6 +712,7 @@ function attackNext(previous) g_game.attack(firstElement.creature) end end + elseif firstElement then g_game.attack(firstElement.creature) else @@ -896,9 +896,9 @@ function onCreaturePositionChange(creature, newPos, oldPos) -- Update battleButt correctBattleButtons() else assert(index ~= nil, - 'Not able to update Position Change. Creature: ' .. creature:getName() .. ' id ' .. - creatureId .. ' not found in binary search using ' .. sortType .. - ' to find value ' .. oldDistance .. '.\n') + 'Not able to update Position Change. Creature: ' .. creature:getName() .. ' id ' .. + creatureId .. ' not found in binary search using ' .. sortType .. + ' to find value ' .. oldDistance .. '.\n') end end end @@ -952,10 +952,11 @@ function onCreatureHealthPercentChange(creature, healthPercent, oldHealthPercent correctBattleButtons() else assert(index ~= nil, - 'Not able to update HealthPercent Change. Creature: id ' .. creatureId .. - ' not found in binary search using ' .. sortType .. ' to find value ' .. oldHealthPercent .. - '.') + 'Not able to update HealthPercent Change. Creature: id ' .. creatureId .. + ' not found in binary search using ' .. sortType .. ' to find value ' .. oldHealthPercent .. + '.') end + end battleButton:setLifeBarPercent(healthPercent) end @@ -985,7 +986,7 @@ function onBattleButtonMouseRelease(self, mousePosition, mouseButton) -- Interac end if ((g_mouse.isPressed(MouseLeftButton) and mouseButton == MouseRightButton) or - (g_mouse.isPressed(MouseRightButton) and mouseButton == MouseLeftButton)) then + (g_mouse.isPressed(MouseRightButton) and mouseButton == MouseLeftButton)) then mouseWidget.cancelNextRelease = true g_game.look(self.creature, true) return true @@ -1079,4 +1080,5 @@ function terminate() -- Terminating the Module (unload) onGameStart = onGameStart }) disconnecting() + end diff --git a/modules/game_features/features.lua b/modules/game_features/features.lua index a7e0236c82..49fce13987 100644 --- a/modules/game_features/features.lua +++ b/modules/game_features/features.lua @@ -1,8 +1,7 @@ controller = Controller:new() controller:registerEvents(g_game, { onClientVersionChange = function(version) - -- g_game.enableFeature(GameKeepUnawareTiles) - g_game.enableFeature(GameFormatCreatureName) + g_game.enableFeature(GameFormatCreatureName); if version >= 750 then g_game.enableFeature(GameSoul); diff --git a/modules/gamelib/ui/uiitem.lua b/modules/gamelib/ui/uiitem.lua index dc503f70ef..05ab126e22 100644 --- a/modules/gamelib/ui/uiitem.lua +++ b/modules/gamelib/ui/uiitem.lua @@ -24,7 +24,7 @@ function UIItem:onDrop(widget, mousePos, forced) local item = widget.currentDragThing if not item or not item:isItem() then return false end - + if self.selectable then if item:isPickupable() then self:setItem(Item.create(item:getId(), item:getCountOrSubType())) @@ -60,7 +60,7 @@ end function UIItem:onHoverChange(hovered) UIWidget.onHoverChange(self, hovered) - + if self:isVirtual() or not self:isDraggable() then return end local draggingWidget = g_ui.getDraggingWidget() @@ -89,8 +89,8 @@ function UIItem:onMouseRelease(mousePosition, mouseButton) if not item or not self:containsPoint(mousePosition) then return false end if modules.client_options.getOption('classicControl') and not g_app.isMobile() and - ((g_mouse.isPressed(MouseLeftButton) and mouseButton == MouseRightButton) or - (g_mouse.isPressed(MouseRightButton) and mouseButton == MouseLeftButton)) then + ((g_mouse.isPressed(MouseLeftButton) and mouseButton == MouseRightButton) or + (g_mouse.isPressed(MouseRightButton) and mouseButton == MouseLeftButton)) then g_game.look(item) self.cancelNextRelease = true return true @@ -105,7 +105,7 @@ function UIItem:canAcceptDrop(widget, mousePos) if not widget or not widget.currentDragThing then return false end local children = rootWidget:recursiveGetChildrenByPos(mousePos) - for i = 1, #children do + for i=1,#children do local child = children[i] if child == self then return true @@ -134,4 +134,4 @@ function UIItem:onItemChange() tooltip = self:getItem():getTooltip() end self:setTooltip(tooltip) -end +end \ No newline at end of file diff --git a/src/client/creature.cpp b/src/client/creature.cpp index f361467549..b278ecd4ec 100644 --- a/src/client/creature.cpp +++ b/src/client/creature.cpp @@ -82,8 +82,6 @@ void Creature::draw(const Point& dest, bool drawThings, LightView* lightView) if (isMarked()) internalDraw(_dest, nullptr, getMarkedColor()); - else if (isHighlighted()) - internalDraw(_dest, nullptr, getHighlightColor()); } if (lightView) { @@ -117,9 +115,6 @@ void Creature::draw(const Rect& destRect, uint8_t size) internalDraw(p); if (isMarked()) internalDraw(p, nullptr, getMarkedColor()); - else if (isHighlighted()) - internalDraw(p, nullptr, getHighlightColor()); - } g_drawPool.releaseFrameBuffer(destRect); } @@ -239,8 +234,9 @@ void Creature::drawInformation(const MapPosInfo& mapRect, const Point& dest, boo void Creature::internalDraw(Point dest, LightView* lightView, const Color& color) { - bool replaceColorShader = color != Color::white; - if (replaceColorShader) + bool isMarked = color != Color::white; + + if (isMarked) g_drawPool.setShaderProgram(g_painter->getReplaceColorShader()); else drawAttachedEffect(dest, lightView, false); // On Bottom @@ -251,7 +247,7 @@ void Creature::internalDraw(Point dest, LightView* lightView, const Color& color if (m_outfit.hasMount()) { dest -= m_mountType->getDisplacement() * g_drawPool.getScaleFactor(); - if (!replaceColorShader && m_mountShader) + if (!isMarked && m_mountShader) g_drawPool.setShaderProgram(m_mountShader, true, m_mountShaderAction); m_mountType->draw(dest, 0, m_numPatternX, 0, 0, getCurrentAnimationPhase(true), color); @@ -266,7 +262,7 @@ void Creature::internalDraw(Point dest, LightView* lightView, const Color& color const auto& datType = getThingType(); const int animationPhase = getCurrentAnimationPhase(); - if (!replaceColorShader && m_shader) + if (!isMarked && m_shader) g_drawPool.setShaderProgram(m_shader, true, m_shaderAction); // yPattern => creature addon @@ -277,7 +273,7 @@ void Creature::internalDraw(Point dest, LightView* lightView, const Color& color datType->draw(dest, 0, m_numPatternX, yPattern, m_numPatternZ, animationPhase, color); - if (m_drawOutfitColor && !replaceColorShader && getLayers() > 1) { + if (m_drawOutfitColor && !isMarked && getLayers() > 1) { g_drawPool.setCompositionMode(CompositionMode::MULTIPLY); datType->draw(dest, SpriteMaskYellow, m_numPatternX, yPattern, m_numPatternZ, animationPhase, m_outfit.getHeadColor()); datType->draw(dest, SpriteMaskRed, m_numPatternX, yPattern, m_numPatternZ, animationPhase, m_outfit.getBodyColor()); @@ -307,13 +303,13 @@ void Creature::internalDraw(Point dest, LightView* lightView, const Color& color if (m_outfit.isEffect()) animationPhase = std::min(animationPhase + 1, animationPhases); - if (!replaceColorShader && m_shader) + if (!isMarked && m_shader) g_drawPool.setShaderProgram(m_shader, true, m_shaderAction); m_thingType->draw(dest - (getDisplacement() * g_drawPool.getScaleFactor()), 0, 0, 0, 0, animationPhase, color); } } - if (replaceColorShader) + if (isMarked) g_drawPool.resetShaderProgram(); else drawAttachedEffect(dest, lightView, true); // On Top diff --git a/src/client/creatures.h b/src/client/creatures.h index b23802dc17..018bdce6e3 100644 --- a/src/client/creatures.h +++ b/src/client/creatures.h @@ -130,7 +130,7 @@ class CreatureManager private: std::vector m_creatures; - std::unordered_map m_spawns; + stdext::map m_spawns; bool m_loaded{ false }; bool m_spawnLoaded{ false }; CreatureTypePtr m_nullCreature; diff --git a/src/client/declarations.h b/src/client/declarations.h index d0295209e5..62230a4271 100644 --- a/src/client/declarations.h +++ b/src/client/declarations.h @@ -84,8 +84,8 @@ using SpawnPtr = std::shared_ptr; using HouseList = std::list; using TownList = std::list; -using CreatureMap = std::unordered_map; -using SpawnMap = std::unordered_map; +using CreatureMap = stdext::map; +using SpawnMap = stdext::map; #endif using ThingList = std::vector; @@ -95,6 +95,7 @@ using ItemTypeList = std::vector; using TileList = std::list; using ItemVector = std::vector; +using ItemMap = stdext::map; using TileMap = stdext::map; // net diff --git a/src/client/item.cpp b/src/client/item.cpp index aa9030d183..2d97e90532 100644 --- a/src/client/item.cpp +++ b/src/client/item.cpp @@ -57,13 +57,11 @@ void Item::draw(const Point& dest, bool drawThings, LightView* lightView) if (isMarked()) internalDraw(animationPhase, dest, getMarkedColor(), drawThings, true); - else if (isHighlighted()) - internalDraw(animationPhase, dest, getHighlightColor(), drawThings, true); } -void Item::internalDraw(int animationPhase, const Point& dest, const Color& color, bool drawThings, bool replaceColorShader, LightView* lightView) +void Item::internalDraw(int animationPhase, const Point& dest, const Color& color, bool drawThings, bool isMarked, LightView* lightView) { - if (replaceColorShader) + if (isMarked) g_drawPool.setShaderProgram(g_painter->getReplaceColorShader(), true); else { drawAttachedEffect(dest, lightView, false); // On Bottom @@ -74,7 +72,7 @@ void Item::internalDraw(int animationPhase, const Point& dest, const Color& colo getThingType()->draw(dest, 0, m_numPatternX, m_numPatternY, m_numPatternZ, animationPhase, color, drawThings, lightView, m_drawConductor); g_drawPool.resetShaderProgram(); - if (!replaceColorShader) + if (!isMarked) drawAttachedEffect(dest, lightView, true); // On Top drawAttachedParticlesEffect(dest); diff --git a/src/client/item.h b/src/client/item.h index 36295ff6ea..12d8693b5c 100644 --- a/src/client/item.h +++ b/src/client/item.h @@ -147,7 +147,7 @@ class Item : public Thing #endif private: - void internalDraw(int animationPhase, const Point& dest, const Color& color, bool drawThings, bool replaceColorShader, LightView* lightView = nullptr); + void internalDraw(int animationPhase, const Point& dest, const Color& color, bool drawThings, bool isMarked, LightView* lightView = nullptr); void setConductor(); uint16_t m_countOrSubType{ 0 }; diff --git a/src/client/lightview.cpp b/src/client/lightview.cpp index 63a11f6ec8..e8d135c9f2 100644 --- a/src/client/lightview.cpp +++ b/src/client/lightview.cpp @@ -34,13 +34,26 @@ LightView::LightView(const Size& size, const uint16_t tileSize) : m_pool(g_drawP m_texture = std::make_shared(size); m_texture->setSmooth(true); }); + + g_drawPool.use(DrawPoolType::LIGHT); + g_drawPool.addAction([this] { + { + std::scoped_lock l(m_pool->getMutex()); + m_texture->updatePixels(m_pixels.data()); + } + g_painter->resetColor(); + g_painter->resetTransformMatrix(); + g_painter->setTexture(m_texture.get()); + g_painter->setCompositionMode(CompositionMode::MULTIPLY); + g_painter->drawCoords(m_coords); + }); } void LightView::resize(const Size& size, const uint16_t tileSize) { if (!m_texture || m_mapSize == size && m_tileSize == tileSize) return; - std::scoped_lock l(m_pool->getMutex(), m_pool->getMutexPreDraw()); + std::scoped_lock l(m_pool->getMutex()); m_mapSize = size; m_tileSize = tileSize; @@ -58,10 +71,10 @@ void LightView::resize(const Size& size, const uint16_t tileSize) { void LightView::addLightSource(const Point& pos, const Light& light, float brightness) { - if (!isDark() || light.intensity == 0) + if (light.intensity == 0) return; - auto& lightData = m_lightData[0]; + auto& lightData = m_lightData[m_currentLightData]; if (!lightData.lights.empty()) { auto& prevLight = lightData.lights.back(); @@ -82,7 +95,7 @@ void LightView::addLightSource(const Point& pos, const Light& light, float brigh void LightView::resetShade(const Point& pos) { - auto& lightData = m_lightData[0]; + auto& lightData = m_lightData[m_currentLightData]; size_t index = (pos.y / m_tileSize) * m_mapSize.width() + (pos.x / m_tileSize); if (index >= lightData.tiles.size()) return; @@ -91,34 +104,20 @@ void LightView::resetShade(const Point& pos) void LightView::draw(const Rect& dest, const Rect& src) { + updateCoords(dest, src); + if (m_updatedHash != m_hash) { m_hash = m_updatedHash; m_updatedHash = 0; - std::scoped_lock l(m_pool->getMutexPreDraw()); - std::swap(m_lightData[0], m_lightData[1]); + std::scoped_lock l(m_pool->getMutex()); + if (++m_currentLightData > 1) m_currentLightData = 0; g_asyncDispatcher.dispatch([this] { updatePixels(); }); } - g_drawPool.preDraw(DrawPoolType::LIGHT, [this, &dest, &src] { - g_drawPool.addAction([=, this] { - { - std::scoped_lock l(m_pool->getMutexPreDraw()); - m_texture->updatePixels(m_pixels.data()); - } - - updateCoords(dest, src); - g_painter->setCompositionMode(CompositionMode::MULTIPLY); - g_painter->resetTransformMatrix(); - g_painter->resetColor(); - g_painter->setTexture(m_texture.get()); - g_painter->drawCoords(m_coords); - }); - }); - - auto& lightData = m_lightData[0]; + auto& lightData = m_lightData[m_currentLightData]; lightData.lights.clear(); lightData.tiles.assign(m_mapSize.area(), {}); } @@ -140,9 +139,9 @@ void LightView::updateCoords(const Rect& dest, const Rect& src) { } void LightView::updatePixels() { - std::scoped_lock l(m_pool->getMutexPreDraw()); + std::scoped_lock l(m_pool->getMutex()); - const auto& lightData = m_lightData[1]; + const auto& lightData = m_lightData[m_currentLightData ? 0 : 1]; const size_t lightSize = lightData.lights.size(); diff --git a/src/client/lightview.h b/src/client/lightview.h index 3fe527e343..fb7ae444c8 100644 --- a/src/client/lightview.h +++ b/src/client/lightview.h @@ -82,5 +82,6 @@ class LightView : public LuaObject CoordsBuffer m_coords; TexturePtr m_texture; LightData m_lightData[2]; + std::atomic_uint8_t m_currentLightData{ 0 }; std::vector m_pixels; }; diff --git a/src/client/luafunctions.cpp b/src/client/luafunctions.cpp index 58b9bf6d97..2a5989bfcc 100644 --- a/src/client/luafunctions.cpp +++ b/src/client/luafunctions.cpp @@ -460,8 +460,6 @@ void Client::registerLuaFunctions() g_lua.bindClassMemberFunction("isLyingCorpse", &Thing::isLyingCorpse); g_lua.bindClassMemberFunction("getDefaultAction", &Thing::getDefaultAction); g_lua.bindClassMemberFunction("getClassification", &Thing::getClassification); - g_lua.bindClassMemberFunction("setHighlight", &Thing::lua_setHighlight); - g_lua.bindClassMemberFunction("isHighlighted", &Thing::isHighlighted); #ifdef FRAMEWORK_EDITOR g_lua.registerClass(); diff --git a/src/client/map.cpp b/src/client/map.cpp index 1aa80a192a..a6202b8c4b 100644 --- a/src/client/map.cpp +++ b/src/client/map.cpp @@ -152,55 +152,51 @@ void Map::addStaticText(const StaticTextPtr& txt, const Position& pos) { if (!g_app.isDrawingTexts()) return; - g_textDispatcher.addEvent([=, this] { - for (const auto& other : m_staticTexts) { - // try to combine messages - if (other->getPosition() == pos && other->addMessage(txt->getName(), txt->getMessageMode(), txt->getFirstMessage())) { - return; - } + for (const auto& other : m_staticTexts) { + // try to combine messages + if (other->getPosition() == pos && other->addMessage(txt->getName(), txt->getMessageMode(), txt->getFirstMessage())) { + return; } + } - txt->setPosition(pos); - m_staticTexts.emplace_back(txt); - }); + txt->setPosition(pos); + m_staticTexts.emplace_back(txt); } void Map::addAnimatedText(const AnimatedTextPtr& txt, const Position& pos) { if (!g_app.isDrawingTexts()) return; - g_textDispatcher.addEvent([=, this] { - // this code will stack animated texts of the same color - AnimatedTextPtr prevAnimatedText; - - bool merged = false; - for (const auto& other : m_animatedTexts) { - if (other->getPosition() == pos) { - prevAnimatedText = other; - if (other->merge(txt)) { - merged = true; - break; - } + // this code will stack animated texts of the same color + AnimatedTextPtr prevAnimatedText; + + bool merged = false; + for (const auto& other : m_animatedTexts) { + if (other->getPosition() == pos) { + prevAnimatedText = other; + if (other->merge(txt)) { + merged = true; + break; } } + } - if (!merged) { - if (prevAnimatedText) { - Point offset = prevAnimatedText->getOffset(); - if (const float t = prevAnimatedText->getTimer().ticksElapsed(); - t < g_gameConfig.getAnimatedTextDuration() / 4.0) { // didnt move 12 pixels - const int32_t y = 12 - 48 * t / static_cast(g_gameConfig.getAnimatedTextDuration()); - offset += Point(0, y); - } - offset.y = std::min(offset.y, 12); - txt->setOffset(offset); + if (!merged) { + if (prevAnimatedText) { + Point offset = prevAnimatedText->getOffset(); + if (const float t = prevAnimatedText->getTimer().ticksElapsed(); + t < g_gameConfig.getAnimatedTextDuration() / 4.0) { // didnt move 12 pixels + const int32_t y = 12 - 48 * t / static_cast(g_gameConfig.getAnimatedTextDuration()); + offset += Point(0, y); } - m_animatedTexts.emplace_back(txt); + offset.y = std::min(offset.y, 12); + txt->setOffset(offset); } + m_animatedTexts.emplace_back(txt); + } - txt->setPosition(pos); - txt->onAppear(); - }); + txt->setPosition(pos); + txt->onAppear(); } ThingPtr Map::getThing(const Position& pos, int16_t stackPos) @@ -1127,7 +1123,7 @@ bool Map::isSightClear(const Position& fromPos, const Position& toPos) } #ifndef BOT_PROTECTION -std::map> Map::findEveryPath(const Position& start, int maxDistance, const std::map& params) +stdext::map> Map::findEveryPath(const Position& start, int maxDistance, const stdext::map& params) { // using Dijkstra's algorithm struct LessNode @@ -1138,7 +1134,7 @@ std::map> Map::findEveryPath } }; - std::map::const_iterator it; + stdext::map::const_iterator it; it = params.find("ignoreLastCreature"); bool ignoreLastCreature = it != params.end() && it->second != "0" && it->second != ""; it = params.find("ignoreCreatures"); @@ -1180,7 +1176,7 @@ std::map> Map::findEveryPath } } - std::map> ret; + stdext::map> ret; std::unordered_map nodes; std::priority_queue, LessNode> searchList; diff --git a/src/client/map.h b/src/client/map.h index 4131fe873f..2b9600a2d8 100644 --- a/src/client/map.h +++ b/src/client/map.h @@ -291,7 +291,7 @@ class Map bool isDrawingFloatingEffects() { return m_floatingEffect; } #ifndef BOT_PROTECTION - std::map> findEveryPath(const Position& start, int maxDistance, const std::map& params); + stdext::map> findEveryPath(const Position& start, int maxDistance, const stdext::map& params); std::vector getSpectatorsByPattern(const Position& centerPos, const std::string& pattern, Otc::Direction direction); #endif @@ -302,7 +302,7 @@ class Map struct FloorData { std::vector missiles; - std::unordered_map tileBlocks; + stdext::map tileBlocks; }; void removeUnawareThings(); @@ -315,11 +315,11 @@ class Map std::vector m_staticTexts; std::vector m_mapViews; - std::unordered_map m_knownCreatures; + stdext::map m_knownCreatures; #ifdef FRAMEWORK_EDITOR - std::unordered_map m_waypoints; - std::unordered_map m_zoneColors; + stdext::map m_waypoints; + stdext::map m_zoneColors; std::string m_houseFile; std::string m_spawnFile; diff --git a/src/client/mapview.cpp b/src/client/mapview.cpp index 500dccfb1a..4c7e610de3 100644 --- a/src/client/mapview.cpp +++ b/src/client/mapview.cpp @@ -46,63 +46,59 @@ MapView::MapView() : m_pool(g_drawPool.get(DrawPoolType::MAP)), m_lightView(std: { m_floors.resize(g_gameConfig.getMapMaxZ() + 1); - setVisibleDimension(Size(15, 11)); -} - -MapView::~MapView() -{ -#ifndef NDEBUG - assert(!g_app.isTerminated()); -#endif - m_lightView = nullptr; -} - -void MapView::registerEvents() { - g_drawPool.addAction([this, camera = m_posInfo.camera, srcRect = m_posInfo.srcRect] { - m_pool->onBeforeDraw([=, this] { - float fadeOpacity = 1.f; - if (!m_shaderSwitchDone && m_fadeOutTime > 0) { - fadeOpacity = 1.f - (m_fadeTimer.timeElapsed() / m_fadeOutTime); - if (fadeOpacity < 0.f) { - m_shader = m_nextShader; - m_nextShader = nullptr; - m_shaderSwitchDone = true; - m_fadeTimer.restart(); - } + m_pool->onBeforeDraw([this] { + float fadeOpacity = 1.f; + if (!m_shaderSwitchDone && m_fadeOutTime > 0) { + fadeOpacity = 1.f - (m_fadeTimer.timeElapsed() / m_fadeOutTime); + if (fadeOpacity < 0.f) { + m_shader = m_nextShader; + m_nextShader = nullptr; + m_shaderSwitchDone = true; + m_fadeTimer.restart(); } + } - if (m_shaderSwitchDone && m_shader && m_fadeInTime > 0) - fadeOpacity = std::min(m_fadeTimer.timeElapsed() / m_fadeInTime, 1.f); + if (m_shaderSwitchDone && m_shader && m_fadeInTime > 0) + fadeOpacity = std::min(m_fadeTimer.timeElapsed() / m_fadeInTime, 1.f); - if (m_shader) { - const auto& center = srcRect.center(); - const auto& globalCoord = Point(camera.x - m_drawDimension.width() / 2, -(camera.y - m_drawDimension.height() / 2)) * m_tileSize; + if (m_shader) { + const auto& center = m_posInfo.srcRect.center(); + const auto& globalCoord = Point(m_posInfo.camera.x - m_drawDimension.width() / 2, -(m_posInfo.camera.y - m_drawDimension.height() / 2)) * m_tileSize; - m_shader->bind(); - m_shader->setUniformValue(ShaderManager::MAP_CENTER_COORD, center.x / static_cast(m_rectDimension.width()), 1.f - center.y / static_cast(m_rectDimension.height())); - m_shader->setUniformValue(ShaderManager::MAP_GLOBAL_COORD, globalCoord.x / static_cast(m_rectDimension.height()), globalCoord.y / static_cast(m_rectDimension.height())); - m_shader->setUniformValue(ShaderManager::MAP_ZOOM, m_pool->getScaleFactor()); + m_shader->bind(); + m_shader->setUniformValue(ShaderManager::MAP_CENTER_COORD, center.x / static_cast(m_rectDimension.width()), 1.f - center.y / static_cast(m_rectDimension.height())); + m_shader->setUniformValue(ShaderManager::MAP_GLOBAL_COORD, globalCoord.x / static_cast(m_rectDimension.height()), globalCoord.y / static_cast(m_rectDimension.height())); + m_shader->setUniformValue(ShaderManager::MAP_ZOOM, m_pool->getScaleFactor()); - Point last = transformPositionTo2D(camera, m_shaderPosition); - //Reverse vertical axis. - last.y = -last.y; + Point last = transformPositionTo2D(m_posInfo.camera, m_shaderPosition); + //Reverse vertical axis. + last.y = -last.y; - m_shader->setUniformValue(ShaderManager::MAP_WALKOFFSET, last.x / static_cast(m_rectDimension.width()), last.y / static_cast(m_rectDimension.height())); + m_shader->setUniformValue(ShaderManager::MAP_WALKOFFSET, last.x / static_cast(m_rectDimension.width()), last.y / static_cast(m_rectDimension.height())); - g_painter->setShaderProgram(m_shader); - } + g_painter->setShaderProgram(m_shader); + } - g_painter->setOpacity(fadeOpacity); - }); + g_painter->setOpacity(fadeOpacity); + }); - m_pool->onAfterDraw([] { - g_painter->resetShaderProgram(); - g_painter->resetOpacity(); - }); + m_pool->onAfterDraw([] { + g_painter->resetShaderProgram(); + g_painter->resetOpacity(); }); + + setVisibleDimension(Size(15, 11)); } -void MapView::draw(const Rect& rect) +MapView::~MapView() +{ +#ifndef NDEBUG + assert(!g_app.isTerminated()); +#endif + m_lightView = nullptr; +} + +void MapView::draw() { // update visible tiles cache when needed if (m_updateVisibleTiles) @@ -129,92 +125,91 @@ void MapView::draw(const Rect& rect) void MapView::drawFloor() { - const auto& cameraPosition = m_posInfo.camera; - const auto& lightView = isDrawingLights() ? m_lightView.get() : nullptr; + g_drawPool.use(DrawPoolType::MAP, m_posInfo.rect, m_posInfo.srcRect, Color::black); + { + const auto& cameraPosition = m_posInfo.camera; + const auto& lightView = isDrawingLights() ? m_lightView.get() : nullptr; - uint32_t flags = Otc::DrawThings; - if (lightView) flags |= Otc::DrawLights; - if (m_drawNames) { flags |= Otc::DrawNames; } - if (m_drawHealthBars) { flags |= Otc::DrawBars; } - if (m_drawManaBar) { flags |= Otc::DrawManaBar; } + uint32_t flags = Otc::DrawThings; + if (lightView) flags |= Otc::DrawLights; + if (m_drawNames) { flags |= Otc::DrawNames; } + if (m_drawHealthBars) { flags |= Otc::DrawBars; } + if (m_drawManaBar) { flags |= Otc::DrawManaBar; } - for (int_fast8_t z = m_floorMax; z >= m_floorMin; --z) { - const float fadeLevel = getFadeLevel(z); - if (fadeLevel == 0.f) break; - if (fadeLevel < .99f) - g_drawPool.setOpacity(fadeLevel); + for (int_fast8_t z = m_floorMax; z >= m_floorMin; --z) { + const float fadeLevel = getFadeLevel(z); + if (fadeLevel == 0.f) break; + if (fadeLevel < .99f) + g_drawPool.setOpacity(fadeLevel); - Position _camera = cameraPosition; - const bool alwaysTransparent = m_floorViewMode == ALWAYS_WITH_TRANSPARENCY && z < m_cachedFirstVisibleFloor && _camera.coveredUp(cameraPosition.z - z); + Position _camera = cameraPosition; + const bool alwaysTransparent = m_floorViewMode == ALWAYS_WITH_TRANSPARENCY && z < m_cachedFirstVisibleFloor && _camera.coveredUp(cameraPosition.z - z); - const auto& map = m_floors[z].cachedVisibleTiles; + const auto& map = m_floors[z].cachedVisibleTiles; - if (m_fadeType != FadeType::OUT$ || fadeLevel == 1.f) { - for (const auto& tile : map.shades) { - if (alwaysTransparent && tile->getPosition().isInRange(_camera, g_gameConfig.getTileTransparentFloorViewRange(), g_gameConfig.getTileTransparentFloorViewRange(), true)) - continue; + if (m_fadeType != FadeType::OUT$ || fadeLevel == 1.f) { + for (const auto& tile : map.shades) { + if (alwaysTransparent && tile->getPosition().isInRange(_camera, g_gameConfig.getTileTransparentFloorViewRange(), g_gameConfig.getTileTransparentFloorViewRange(), true)) + continue; - m_lightView->resetShade(transformPositionTo2D(tile->getPosition(), cameraPosition)); + m_lightView->resetShade(transformPositionTo2D(tile->getPosition(), cameraPosition)); + } } - } - for (const auto& tile : map.tiles) { - uint32_t tileFlags = flags; + for (const auto& tile : map.tiles) { + uint32_t tileFlags = flags; - if (!m_drawViewportEdge && !tile->canRender(tileFlags, cameraPosition, m_viewport)) - continue; + if (!m_drawViewportEdge && !tile->canRender(tileFlags, cameraPosition, m_viewport)) + continue; - bool isCovered = false; - if (tile->hasCreature()) { - isCovered = tile->isCovered(m_cachedFirstVisibleFloor); - } + bool isCovered = false; + if (tile->hasCreature()) { + isCovered = tile->isCovered(m_cachedFirstVisibleFloor); + } - if (alwaysTransparent) { - const bool inRange = tile->getPosition().isInRange(_camera, g_gameConfig.getTileTransparentFloorViewRange(), g_gameConfig.getTileTransparentFloorViewRange(), true); - isCovered = isCovered && !inRange; + if (alwaysTransparent) { + const bool inRange = tile->getPosition().isInRange(_camera, g_gameConfig.getTileTransparentFloorViewRange(), g_gameConfig.getTileTransparentFloorViewRange(), true); + isCovered = isCovered && !inRange; - g_drawPool.setOpacity(inRange ? .16 : .7); - } + g_drawPool.setOpacity(inRange ? .16 : .7); + } - tile->draw(transformPositionTo2D(tile->getPosition(), cameraPosition), m_posInfo, tileFlags, isCovered, lightView); + tile->draw(transformPositionTo2D(tile->getPosition(), cameraPosition), m_posInfo, tileFlags, isCovered, lightView); - if (alwaysTransparent) - g_drawPool.resetOpacity(); - } + if (alwaysTransparent) + g_drawPool.resetOpacity(); + } - for (const auto& missile : g_map.getFloorMissiles(z)) - missile->draw(transformPositionTo2D(missile->getPosition(), cameraPosition), true, lightView); + for (const auto& missile : g_map.getFloorMissiles(z)) + missile->draw(transformPositionTo2D(missile->getPosition(), cameraPosition), true, lightView); - if (m_shadowFloorIntensity > 0 && z == cameraPosition.z + 1) { - g_drawPool.setOpacity(m_shadowFloorIntensity, true); - g_drawPool.addFilledRect(m_rectDimension, Color::black, m_shadowConductor); - } + if (m_shadowFloorIntensity > 0 && z == cameraPosition.z + 1) { + g_drawPool.setOpacity(m_shadowFloorIntensity, true); + g_drawPool.addFilledRect(m_rectDimension, Color::black, m_shadowConductor); + } - if (canFloorFade()) - g_drawPool.resetOpacity(); + if (canFloorFade()) + g_drawPool.resetOpacity(); - g_drawPool.flush(); - } + g_drawPool.flush(); + } - if (m_posInfo.rect.contains(g_window.getMousePosition())) { - if (m_crosshairTexture && m_mousePosition.isValid()) { - const auto& point = transformPositionTo2D(m_mousePosition, cameraPosition); - const auto& crosshairRect = Rect(point, m_tileSize, m_tileSize); - g_drawPool.addTexturedRect(crosshairRect, m_crosshairTexture); + if (m_posInfo.rect.contains(g_window.getMousePosition())) { + if (m_crosshairTexture && m_mousePosition.isValid()) { + const auto& point = transformPositionTo2D(m_mousePosition, cameraPosition); + const auto& crosshairRect = Rect(point, m_tileSize, m_tileSize); + g_drawPool.addTexturedRect(crosshairRect, m_crosshairTexture); + } + } else if (m_lastHighlightTile) { + m_mousePosition = {}; // Invalidate mousePosition + destroyHighlightTile(); } - } else if (m_lastHighlightTile) { - m_mousePosition = {}; // Invalidate mousePosition - destroyHighlightTile(); } } -void MapView::drawForeground(const Rect& rect) +void MapView::drawText() { - const auto& camera = getCameraPosition(); - const auto& srcRect = calcFramebufferSource(rect.size()); - const auto& drawOffset = srcRect.topLeft(); - const auto& horizontalStretchFactor = rect.width() / static_cast(srcRect.width()); - const auto& verticalStretchFactor = rect.height() / static_cast(srcRect.height()); + g_drawPool.use(DrawPoolType::TEXT); g_drawPool.scale(g_app.getStaticTextScale()); for (const auto& staticText : g_map.getStaticTexts()) { @@ -222,43 +217,28 @@ void MapView::drawForeground(const Rect& rect) continue; const auto& pos = staticText->getPosition(); - if (pos.z != camera.z && staticText->getMessageMode() == Otc::MessageNone) + if (pos.z != m_posInfo.camera.z && staticText->getMessageMode() == Otc::MessageNone) continue; - Point p = transformPositionTo2D(pos, camera) - drawOffset; - p.x *= horizontalStretchFactor; - p.y *= verticalStretchFactor; - p += rect.topLeft(); - staticText->drawText(p.scale(g_app.getStaticTextScale()), rect); + Point p = transformPositionTo2D(pos, m_posInfo.camera) - m_posInfo.drawOffset; + p.x *= m_posInfo.horizontalStretchFactor; + p.y *= m_posInfo.verticalStretchFactor; + p += m_posInfo.rect.topLeft(); + staticText->drawText(p.scale(g_app.getStaticTextScale()), m_posInfo.rect); } g_drawPool.scale(g_app.getAnimatedTextScale()); for (const auto& animatedText : g_map.getAnimatedTexts()) { const auto& pos = animatedText->getPosition(); - if (pos.z != camera.z) + if (pos.z != m_posInfo.camera.z) continue; - auto p = transformPositionTo2D(pos, camera) - drawOffset; - p.x *= horizontalStretchFactor; - p.y *= verticalStretchFactor; - p += rect.topLeft(); - animatedText->drawText(p, rect); - } - - g_drawPool.scale(1.f); - for (const auto& tile : m_foregroundTiles) { - const auto& dest = transformPositionTo2D(tile->getPosition(), camera); -#ifndef BOT_PROTECTION - Point p = dest - drawOffset; - p.x *= horizontalStretchFactor; - p.y *= verticalStretchFactor; - p += rect.topLeft(); - p.y += 5; - - tile->drawTexts(p); -#endif - tile->drawWidget(dest, rect); + auto p = transformPositionTo2D(pos, m_posInfo.camera) - m_posInfo.drawOffset; + p.x *= m_posInfo.horizontalStretchFactor; + p.y *= m_posInfo.verticalStretchFactor; + p += m_posInfo.rect.topLeft(); + animatedText->drawText(p, m_posInfo.rect); } } @@ -430,7 +410,6 @@ void MapView::updateGeometry(const Size& visibleDimension) m_lightView->resize(lightSize, tileSize); } - g_mainDispatcher.addEvent([this, bufferSize]() { m_pool->getFrameBuffer()->resize(bufferSize); }); @@ -477,15 +456,15 @@ void MapView::updateLight() void MapView::onTileUpdate(const Position& pos, const ThingPtr& thing, const Otc::Operation op) { - if (thing && thing->isOpaque() && op == Otc::OPERATION_REMOVE) - m_resetCoveredCache = true; - - if (op == Otc::OPERATION_CLEAN) { - if (m_lastHighlightTile && m_lastHighlightTile->getPosition() == pos) - m_lastHighlightTile = nullptr; + if (m_lastHighlightTile && m_lastHighlightTile->getPosition() == pos && op == Otc::OPERATION_CLEAN) + m_lastHighlightTile = nullptr; - requestUpdateVisibleTiles(); + if (thing) { + if (thing->isOpaque() && op == Otc::OPERATION_REMOVE) + m_resetCoveredCache = true; } + + requestUpdateVisibleTiles(); } void MapView::onFadeInFinished() @@ -569,7 +548,8 @@ void MapView::setAntiAliasingMode(const AntialiasingMode mode) m_antiAliasingMode = mode; g_mainDispatcher.addEvent([=, this]() { - m_pool->getFrameBuffer()->setSmooth(mode != ANTIALIASING_DISABLED); + g_drawPool.get(DrawPoolType::MAP)->getFrameBuffer() + ->setSmooth(mode != ANTIALIASING_DISABLED); }); updateGeometry(m_visibleDimension); @@ -884,19 +864,4 @@ void MapView::destroyHighlightTile() { m_lastHighlightTile->unselect(); m_lastHighlightTile = nullptr; } -} - -void MapView::addForegroundTile(const TilePtr& tile) { - std::scoped_lock l(g_drawPool.get(DrawPoolType::FOREGROUND_MAP)->getMutex()); - - if (std::find(m_foregroundTiles.begin(), m_foregroundTiles.end(), tile) == m_foregroundTiles.end()) - m_foregroundTiles.emplace_back(tile); -} -void MapView::removeForegroundTile(const TilePtr& tile) { - std::scoped_lock l(g_drawPool.get(DrawPoolType::FOREGROUND_MAP)->getMutex()); - const auto it = std::find(m_foregroundTiles.begin(), m_foregroundTiles.end(), tile); - if (it == m_foregroundTiles.end()) - return; - - m_foregroundTiles.erase(it); } \ No newline at end of file diff --git a/src/client/mapview.h b/src/client/mapview.h index c02c1680cb..02a29c6f7f 100644 --- a/src/client/mapview.h +++ b/src/client/mapview.h @@ -88,8 +88,8 @@ class MapView : public LuaObject MapView(); ~MapView() override; - void draw(const Rect& rect); - void drawForeground(const Rect& rect); + void draw(); + void drawText(); // floor visibility related uint8_t getLockedFirstVisibleFloor() const { return m_lockedFirstVisibleFloor; } @@ -181,9 +181,6 @@ class MapView : public LuaObject PainterShaderProgramPtr getNextShader() { return m_nextShader; } bool isSwitchingShader() { return !m_shaderSwitchDone; } - void addForegroundTile(const TilePtr& tile); - void removeForegroundTile(const TilePtr& tile); - protected: void onGlobalLightChange(const Light& light); void onFloorChange(uint8_t floor, uint8_t previousFloor); @@ -223,25 +220,24 @@ class MapView : public LuaObject TexturePtr texture; }; - void updateHighlightTile(const Position& mousePos); - void destroyHighlightTile(); - - void updateLight(); - void updateViewportDirectionCache(); void updateGeometry(const Size& visibleDimension); void updateVisibleTiles(); void updateRect(const Rect& rect); - void updateViewport(const Otc::Direction dir = Otc::InvalidDirection) { m_viewport = m_viewPortDirection[dir]; } void requestUpdateVisibleTiles() { m_updateVisibleTiles = true; } void requestUpdateMapPosInfo() { m_updateMapPosInfo = true; } - void registerEvents(); - uint8_t calcFirstVisibleFloor(bool checkLimitsFloorsView) const; uint8_t calcLastVisibleFloor() const; + void updateLight(); + void updateViewportDirectionCache(); void drawFloor(); + void updateHighlightTile(const Position& mousePos); + void destroyHighlightTile(); + + void updateViewport(const Otc::Direction dir = Otc::InvalidDirection) { m_viewport = m_viewPortDirection[dir]; } + bool canFloorFade() const { return m_floorViewMode == FADE && m_floorFading; } float getFadeLevel(uint8_t z) const @@ -318,7 +314,6 @@ class MapView : public LuaObject AntialiasingMode m_antiAliasingMode{ AntialiasingMode::ANTIALIASING_DISABLED }; std::vector m_floors; - std::vector m_foregroundTiles; PainterShaderProgramPtr m_shader; PainterShaderProgramPtr m_nextShader; diff --git a/src/client/minimap.h b/src/client/minimap.h index dbd2c3340a..dde0bbd3cc 100644 --- a/src/client/minimap.h +++ b/src/client/minimap.h @@ -128,7 +128,7 @@ class Minimap }; } uint32_t getBlockIndex(const Position& pos) { return ((pos.y / MMBLOCK_SIZE) * (65536 / MMBLOCK_SIZE)) + (pos.x / MMBLOCK_SIZE); } - std::vector> m_tileBlocks; + std::vector> m_tileBlocks; std::mutex m_lock; }; diff --git a/src/client/protocolgameparse.cpp b/src/client/protocolgameparse.cpp index f6183389cd..d8205ef23b 100644 --- a/src/client/protocolgameparse.cpp +++ b/src/client/protocolgameparse.cpp @@ -3585,7 +3585,7 @@ void ProtocolGame::parseImbuementWindow(const InputMessagePtr& msg) } const uint8_t slot = msg->getU8(); // slot id - std::unordered_map> activeSlots; + stdext::map> activeSlots; for (uint8_t i = 0; i < slot; i++) { const uint8_t firstByte = msg->getU8(); if (firstByte == 0x01) { @@ -3658,7 +3658,7 @@ void ProtocolGame::parseMarketEnterOld(const InputMessagePtr& msg) const uint8_t offers = msg->getU8(); const uint16_t itemsSent = msg->getU16(); - std::unordered_map depotItems; + stdext::map depotItems; for (int_fast32_t i = 0; i < itemsSent; i++) { const uint16_t itemId = msg->getU16(); const uint16_t count = msg->getU16(); @@ -3678,7 +3678,7 @@ void ProtocolGame::parseMarketDetail(const InputMessagePtr& msg) } } - std::unordered_map descriptions; + stdext::map descriptions; Otc::MarketItemDescription lastAttribute = Otc::ITEM_DESC_WEIGHT; if (g_game.getClientVersion() >= 1200) lastAttribute = Otc::ITEM_DESC_IMBUINGSLOTS; diff --git a/src/client/thing.h b/src/client/thing.h index 07aac984e2..780c2f976b 100644 --- a/src/client/thing.h +++ b/src/client/thing.h @@ -184,17 +184,6 @@ class Thing : public AttachableObject bool isMarked() { return m_markedColor != Color::white; } void setMarked(const Color& color) { if (m_markedColor != color) m_markedColor = color; } - const Color& getHighlightColor() { - if (m_highlightColor == Color::white) - return Color::white; - - m_highlightColor.setAlpha(0.1f + std::abs(500 - g_clock.millis() % 1000) / 1000.0f); - return m_highlightColor; - } - - bool isHighlighted() { return m_highlightColor != Color::white; } - void setHighlight(const Color& color) { if (m_highlightColor != color) m_highlightColor = color; } - bool isHided() { return isOwnerHidden(); } void onStartAttachEffect(const AttachedEffectPtr& effect) override; void onDispatcherAttachEffect(const AttachedEffectPtr& effect) override; @@ -220,7 +209,6 @@ class Thing : public AttachableObject DrawConductor m_drawConductor{ false, DrawOrder::THIRD }; Color m_markedColor{ Color::white }; - Color m_highlightColor{ Color::white }; // Shader PainterShaderProgramPtr m_shader; @@ -228,7 +216,6 @@ class Thing : public AttachableObject private: void lua_setMarked(std::string_view color) { setMarked(Color(color)); } - void lua_setHighlight(std::string_view color) { setHighlight(Color(color)); } bool m_canDraw{ true }; diff --git a/src/client/tile.cpp b/src/client/tile.cpp index 6df583fb31..37d8bf4760 100644 --- a/src/client/tile.cpp +++ b/src/client/tile.cpp @@ -146,12 +146,12 @@ void Tile::updateWidget(const Point& dest, const MapPosInfo& mapRect) m_widget->setRect(rect); } -void Tile::drawWidget(const Point& dest, const Rect& rect) +void Tile::drawWidget(const Point& dest, const MapPosInfo& mapRect) { if (!m_widget) return; - m_widget->draw(rect, DrawPoolType::FOREGROUND); + m_widget->draw(mapRect.rect, DrawPoolType::FOREGROUND); } void Tile::setWidget(const UIWidgetPtr& widget) { @@ -160,7 +160,7 @@ void Tile::setWidget(const UIWidgetPtr& widget) { m_widget = widget; m_widget->setClipping(true); g_dispatcher.scheduleEvent([tile = static_self_cast()] { - g_ui.getMapWidget()->getMapView()->addForegroundTile(tile); + g_ui.getMapWidget()->addTile(tile); }, g_game.getServerBeat()); } @@ -181,7 +181,7 @@ void Tile::clean() #endif )) { g_dispatcher.scheduleEvent([tile = static_self_cast()] { - g_ui.getMapWidget()->getMapView()->removeForegroundTile(tile); + g_ui.getMapWidget()->removeTile(tile); }, g_game.getServerBeat()); } @@ -849,18 +849,24 @@ bool Tile::canRender(uint32_t& flags, const Position& cameraPosition, const Awar } #ifndef BOT_PROTECTION -void Tile::drawTexts(Point dest) +void Tile::drawTexts(const Point& dest, const MapPosInfo& mapRect) { + Point p = dest - mapRect.drawOffset; + p.x *= mapRect.horizontalStretchFactor; + p.y *= mapRect.verticalStretchFactor; + p += mapRect.rect.topLeft(); + p.y += 5; + if (m_timerText && g_clock.millis() < m_timer) { if (m_text && m_text->hasText()) - dest.y -= 8; + p.y -= 8; m_timerText->setText(stdext::format("%.01f", (m_timer - g_clock.millis()) / 1000.)); - m_timerText->drawText(dest, Rect(dest.x - 64, dest.y - 64, 128, 128)); - dest.y += 16; + m_timerText->drawText(p, Rect(p.x - 64, p.y - 64, 128, 128)); + p.y += 16; } if (m_text && m_text->hasText()) { - m_text->drawText(dest, Rect(dest.x - 64, dest.y - 64, 128, 128)); + m_text->drawText(p, Rect(p.x - 64, p.y - 64, 128, 128)); } } @@ -869,7 +875,7 @@ void Tile::setText(const std::string& text, Color color) if (!m_text) { m_text = std::make_shared(); g_dispatcher.scheduleEvent([tile = static_self_cast()] { - g_ui.getMapWidget()->getMapView()->addForegroundTile(tile); + g_ui.getMapWidget()->addTile(tile); }, g_game.getServerBeat()); } @@ -892,7 +898,7 @@ void Tile::setTimer(int time, Color color) if (!m_timerText) { m_timerText = std::make_shared(); g_dispatcher.scheduleEvent([tile = static_self_cast()] { - g_ui.getMapWidget()->getMapView()->addForegroundTile(tile); + g_ui.getMapWidget()->addTile(tile); }, g_game.getServerBeat()); } diff --git a/src/client/tile.h b/src/client/tile.h index 0a24310d8f..72dd2a5487 100644 --- a/src/client/tile.h +++ b/src/client/tile.h @@ -119,7 +119,7 @@ class Tile : public AttachableObject ThingPtr getTopMultiUseThing(); bool hasWidget() const { return m_widget != nullptr; } - void drawWidget(const Point& dest, const Rect& rect); + void drawWidget(const Point& dest, const MapPosInfo& mapRect); void setWidget(const UIWidgetPtr& widget); UIWidgetPtr getWidget() { return m_widget; } void removeWidget(); @@ -212,7 +212,7 @@ class Tile : public AttachableObject bool checkForDetachableThing(); #ifndef BOT_PROTECTION - void drawTexts(Point dest); + void drawTexts(const Point& dest, const MapPosInfo& mapRect); void setText(const std::string& text, Color color); std::string getText(); void setTimer(int time, Color color); diff --git a/src/client/uimap.cpp b/src/client/uimap.cpp index 06dca2cb80..e1ce9cc723 100644 --- a/src/client/uimap.cpp +++ b/src/client/uimap.cpp @@ -21,7 +21,6 @@ */ #include "uimap.h" -#include #include #include #include @@ -61,19 +60,25 @@ void UIMap::drawSelf(DrawPoolType drawPane) return; } - const auto& mapRect = g_app.isScaled() ? Rect(0, 0, g_graphics.getViewportSize()) : m_mapRect; + if (m_mapView && drawPane == DrawPoolType::FOREGROUND_TILE) { + g_drawPool.use(DrawPoolType::FOREGROUND_TILE); + for (const auto& tile : m_tiles) { + const auto& dest = m_mapView->transformPositionTo2D(tile->getPosition(), m_mapView->getCameraPosition()); +#ifndef BOT_PROTECTION + tile->drawTexts(dest, m_mapView->m_posInfo); +#endif + tile->drawWidget(dest, m_mapView->m_posInfo); + } + return; + } + + const auto& mapSize = g_app.isScaled() ? Rect(0, 0, g_graphics.getViewportSize()) : m_mapRect; + m_mapView->updateRect(mapSize); if (drawPane == DrawPoolType::MAP) { - m_mapView->updateRect(mapRect); - g_drawPool.preDraw(drawPane, [this, &mapRect] { - m_mapView->registerEvents(); - m_mapView->draw(mapRect); - }, m_mapView->m_posInfo.rect, m_mapView->m_posInfo.srcRect, Color::black); - } else if (drawPane == DrawPoolType::FOREGROUND_MAP) { - g_textDispatcher.poll(); - g_drawPool.preDraw(drawPane, [this, &mapRect] { - m_mapView->drawForeground(mapRect); - }); + m_mapView->draw(); + } else if (drawPane == DrawPoolType::TEXT) { + m_mapView->drawText(); } } @@ -207,4 +212,19 @@ void UIMap::updateMapSize() updateVisibleDimension(); } +void UIMap::addTile(const TilePtr& tile) { + std::scoped_lock l(g_drawPool.get(DrawPoolType::FOREGROUND)->getMutex()); + + if (std::ranges::find(m_tiles, tile) == m_tiles.end()) + m_tiles.emplace_back(tile); +} +void UIMap::removeTile(const TilePtr& tile) { + std::scoped_lock l(g_drawPool.get(DrawPoolType::FOREGROUND)->getMutex()); + const auto it = std::find(m_tiles.begin(), m_tiles.end(), tile); + if (it == m_tiles.end()) + return; + + m_tiles.erase(it); +} + /* vim: set ts=4 sw=4 et: */ \ No newline at end of file diff --git a/src/client/uimap.h b/src/client/uimap.h index 8da6672145..4f7e9a9ce9 100644 --- a/src/client/uimap.h +++ b/src/client/uimap.h @@ -93,9 +93,11 @@ class UIMap : public UIWidget void setDrawHighlightTarget(const bool enable) { m_mapView->setDrawHighlightTarget(enable); } void setAntiAliasingMode(const MapView::AntialiasingMode mode) { m_mapView->setAntiAliasingMode(mode); } void setFloorFading(const uint16_t v) { m_mapView->setFloorFading(v); } - MapViewPtr getMapView() const { return m_mapView; } + + void addTile(const TilePtr& tile); + void removeTile(const TilePtr& tile); void clearTiles() { - m_mapView->m_foregroundTiles.clear(); + m_tiles.clear(); } protected: @@ -107,6 +109,7 @@ class UIMap : public UIWidget void updateVisibleDimension(); void updateMapSize(); + std::vector m_tiles; MapViewPtr m_mapView; Rect m_mapRect; diff --git a/src/framework/core/adaptativeframecounter.cpp b/src/framework/core/adaptativeframecounter.cpp index f4c09f357c..1e761aa8cd 100644 --- a/src/framework/core/adaptativeframecounter.cpp +++ b/src/framework/core/adaptativeframecounter.cpp @@ -24,9 +24,9 @@ #include #include -bool AdaptativeFrameCounter::update() +void AdaptativeFrameCounter::update() { - const auto maxFps = m_targetFps == 0 ? m_maxFps : std::clamp(m_targetFps, 1, std::max(m_maxFps, m_targetFps)); + const uint8_t maxFps = m_targetFps == 0 ? m_maxFps : std::clamp(m_targetFps, 1, std::max(m_maxFps, m_targetFps)); if (maxFps > 0) { const int32_t sleepPeriod = (getMaxPeriod(maxFps) - 1000) - m_timer.elapsed_micros(); if (sleepPeriod > 0) stdext::microsleep(sleepPeriod); @@ -37,15 +37,15 @@ bool AdaptativeFrameCounter::update() ++m_fpsCount; if (m_fps == m_fpsCount) - return false; + return; const uint32_t tickCount = stdext::millis(); if (tickCount - m_interval <= 1000) - return false; + return; m_fps = m_fpsCount; m_fpsCount = 0; m_interval = tickCount; - return true; + g_dispatcher.addEvent([this] { g_lua.callGlobalField("g_app", "onFps", getFps()); }); } \ No newline at end of file diff --git a/src/framework/core/adaptativeframecounter.h b/src/framework/core/adaptativeframecounter.h index 82ba747c2d..e4fa40876c 100644 --- a/src/framework/core/adaptativeframecounter.h +++ b/src/framework/core/adaptativeframecounter.h @@ -33,31 +33,22 @@ class AdaptativeFrameCounter AdaptativeFrameCounter() : m_interval(stdext::millis()) { } void init() { m_timer.restart(); } - bool update(); + void update(); uint16_t getFps() const { return m_fps; } - uint16_t getMaxFps() const { return m_maxFps; } - uint16_t getTargetFps() const { return m_targetFps; } + uint8_t getMaxFps() const { return m_maxFps; } + uint8_t getTargetFps() const { return m_targetFps; } void setMaxFps(const uint16_t max) { m_maxFps = max; } - void setTargetFps(const uint16_t target) { if (m_targetFps != target) m_targetFps = target; } + void setTargetFps(const uint16_t target) { m_targetFps = target; } void resetTargetFps() { m_targetFps = 0; } - float getPercent() const { - const float maxFps = std::clamp(m_targetFps, 1, std::max(m_maxFps, m_targetFps)); - return ((maxFps - m_fps) / maxFps) * 100.f; - } - - float getFpsPercent(float percent) const { - return getFps() * (percent / 100); - } - private: uint32_t getMaxPeriod(uint16_t fps) const { return 1000000u / fps; } - uint16_t m_maxFps{}; - uint16_t m_targetFps{ 60u }; + uint8_t m_maxFps{}; + uint8_t m_targetFps{ 60u }; uint16_t m_fps{}; uint16_t m_fpsCount{}; diff --git a/src/framework/core/application.h b/src/framework/core/application.h index 88d4eba1ec..f8c280f45f 100644 --- a/src/framework/core/application.h +++ b/src/framework/core/application.h @@ -67,7 +67,7 @@ class Application std::string m_charset{ "cp1252" }; std::string m_organizationName{ "otbr" }; std::string m_appName{ "OTClient - Redemption" }; - std::string m_appCompactName{ "otcr" }; + std::string m_appCompactName{ "otclient" }; std::string m_startupOptions; std::vector m_startupArgs; diff --git a/src/framework/core/asyncdispatcher.cpp b/src/framework/core/asyncdispatcher.cpp index 87c259f550..e662a098aa 100644 --- a/src/framework/core/asyncdispatcher.cpp +++ b/src/framework/core/asyncdispatcher.cpp @@ -26,20 +26,11 @@ AsyncDispatcher g_asyncDispatcher; void AsyncDispatcher::init(uint8_t maxThreads) { - /* - * -1 = Graphic - * 1 = Map and (Connection, Particle and Sound) Pool - * 2 = Foreground UI - * 3 = Foreground MAP - * 4 = Extra, ex: pathfinder and lighting system - */ - const uint8_t minThreads = 4; - if (maxThreads == 0) maxThreads = 6; - // 2 = Min Threads - int_fast8_t threads = std::clamp(std::thread::hardware_concurrency() - 1, minThreads, maxThreads); + // -2 = Main Thread and Map Thread + int_fast8_t threads = std::clamp(std::thread::hardware_concurrency() - 2, 1, maxThreads); while (--threads >= 0) m_threads.emplace_back([this] { m_ioService.run(); }); } @@ -54,8 +45,9 @@ void AsyncDispatcher::stop() m_ioService.stop(); - for (auto& thread : m_threads) { - if (thread.joinable()) - thread.join(); + for (std::size_t i = 0; i < m_threads.size(); i++) { + if (m_threads[i].joinable()) { + m_threads[i].join(); + } } }; \ No newline at end of file diff --git a/src/framework/core/eventdispatcher.cpp b/src/framework/core/eventdispatcher.cpp index 3b2928efa1..698fa24bd5 100644 --- a/src/framework/core/eventdispatcher.cpp +++ b/src/framework/core/eventdispatcher.cpp @@ -51,8 +51,8 @@ void EventDispatcher::shutdown() void EventDispatcher::poll() { - executeEvents(); executeScheduledEvents(); + executeEvents(); mergeEvents(); } @@ -63,9 +63,12 @@ ScheduledEventPtr EventDispatcher::scheduleEvent(const std::function& ca assert(delay >= 0); + const auto& scheduledEvent = std::make_shared(callback, delay, 1); const auto& thread = getThreadTask(); std::scoped_lock lock(thread->mutex); - return thread->scheduledEventList.emplace_back(std::make_shared(callback, delay, 1)); + + thread->scheduledEventList.emplace_back(scheduledEvent); + return scheduledEvent; } ScheduledEventPtr EventDispatcher::cycleEvent(const std::function& callback, int delay) @@ -75,9 +78,12 @@ ScheduledEventPtr EventDispatcher::cycleEvent(const std::function& callb assert(delay > 0); + const auto& scheduledEvent = std::make_shared(callback, delay, 0); const auto& thread = getThreadTask(); std::scoped_lock lock(thread->mutex); - return thread->scheduledEventList.emplace_back(std::make_shared(callback, delay, 0)); + + thread->scheduledEventList.emplace_back(scheduledEvent); + return scheduledEvent; } EventPtr EventDispatcher::addEvent(const std::function& callback) @@ -90,9 +96,13 @@ EventPtr EventDispatcher::addEvent(const std::function& callback) return std::make_shared(nullptr); } + const auto& event = std::make_shared(callback); + const auto& thread = getThreadTask(); std::scoped_lock lock(thread->mutex); - return thread->events.emplace_back(std::make_shared(callback)); + thread->events.emplace_back(event); + + return event; } void EventDispatcher::executeEvents() { @@ -103,6 +113,7 @@ void EventDispatcher::executeEvents() { for (const auto& event : m_eventList) { event->execute(); } + m_eventList.clear(); } diff --git a/src/framework/core/graphicalapplication.cpp b/src/framework/core/graphicalapplication.cpp index 0c978e0cf3..fbae7ee5c4 100644 --- a/src/framework/core/graphicalapplication.cpp +++ b/src/framework/core/graphicalapplication.cpp @@ -82,8 +82,7 @@ void GraphicalApplication::init(std::vector& args, uint8_t asyncDis g_sounds.init(); #endif - m_mapProcessFrameCounter.init(); - m_graphicFrameCounter.init(); + m_frameCounter.init(); } void GraphicalApplication::deinit() @@ -135,51 +134,13 @@ void GraphicalApplication::run() g_lua.callGlobalField("g_app", "onRun"); - std::condition_variable foregroundUICondition, foregroundMapCondition; + const auto& foreground = g_drawPool.get(DrawPoolType::FOREGROUND); + const auto& foreground_tile = g_drawPool.get(DrawPoolType::FOREGROUND_TILE); + const auto& txt = g_drawPool.get(DrawPoolType::TEXT); + const auto& map = g_drawPool.get(DrawPoolType::MAP); - const auto& FPS = [&] { - m_mapProcessFrameCounter.setTargetFps(g_window.vsyncEnabled() || getMaxFps() || getTargetFps() ? 500u : 999u); - return m_graphicFrameCounter.getFps(); - }; - - const auto& drawForeground = [&] { - const auto& foregroundUI = g_drawPool.get(DrawPoolType::FOREGROUND); - const auto& foregroundMap = g_drawPool.get(DrawPoolType::FOREGROUND_MAP); - - if (foregroundUI->canRepaint()) { - if (g_game.isOnline()) - foregroundUICondition.notify_one(); - else - g_ui.render(DrawPoolType::FOREGROUND); - } - - if (g_game.isOnline() && foregroundMap->canRepaint()) - foregroundMapCondition.notify_one(); - }; - - // THREAD - FOREGROUND UI - g_asyncDispatcher.dispatch([this, &condition = foregroundUICondition] { - const auto& pool = g_drawPool.get(DrawPoolType::FOREGROUND); - std::unique_lock lock(pool->getMutexPreDraw()); - condition.wait(lock, [this]() -> bool { - g_ui.render(DrawPoolType::FOREGROUND); - return m_stopping; - }); - }); - - // THREAD - FOREGROUND MAP - g_asyncDispatcher.dispatch([this, &condition = foregroundMapCondition] { - const auto& pool = g_drawPool.get(DrawPoolType::FOREGROUND_MAP); - std::unique_lock lock(pool->getMutexPreDraw()); - condition.wait(lock, [this]() -> bool { - if (g_ui.m_mapWidget) - g_ui.m_mapWidget->drawSelf(DrawPoolType::FOREGROUND_MAP); - return m_stopping; - }); - }); - - // THREAD - POOL & MAP - g_asyncDispatcher.dispatch([&] { + // clang c++20 dont support jthread + std::thread t1([&]() { g_eventThreadId = std::this_thread::get_id(); while (!m_stopping) { poll(); @@ -189,20 +150,42 @@ void GraphicalApplication::run() continue; } - drawForeground(); + /*if (g_drawPool.isDrawing()) { + stdext::millisleep(1); + continue; + }*/ + + if (foreground->canRepaint()) { + g_asyncDispatcher.dispatch([this, &foreground] { + std::scoped_lock l(foreground->getMutex()); + g_ui.render(DrawPoolType::FOREGROUND); + }); + } if (g_game.isOnline()) { if (!g_ui.m_mapWidget) g_ui.m_mapWidget = g_ui.getRootWidget()->recursiveGetChildById("gameMapPanel")->static_self_cast(); - g_ui.m_mapWidget->drawSelf(DrawPoolType::MAP); + if (txt->canRepaint() || foreground_tile->canRepaint()) { + g_asyncDispatcher.dispatch([this, &txt] { + std::scoped_lock l(txt->getMutex()); + g_textDispatcher.poll(); + + if (g_ui.m_mapWidget) { + g_ui.m_mapWidget->drawSelf(DrawPoolType::TEXT); + g_ui.m_mapWidget->drawSelf(DrawPoolType::FOREGROUND_TILE); + } + }); + } + + { + std::scoped_lock l(map->getMutex()); + g_ui.m_mapWidget->drawSelf(DrawPoolType::MAP); + } } else g_ui.m_mapWidget = nullptr; - m_mapProcessFrameCounter.update(); + stdext::millisleep(1); } - - foregroundUICondition.notify_one(); - foregroundMapCondition.notify_one(); }); m_running = true; @@ -218,14 +201,11 @@ void GraphicalApplication::run() // update screen pixels g_window.swapBuffers(); - - if (m_graphicFrameCounter.update()) { - g_dispatcher.addEvent([this, fps = FPS()] { - g_lua.callGlobalField("g_app", "onFps", fps); - }); - } + m_frameCounter.update(); } + t1.join(); + m_stopping = false; m_running = false; } @@ -275,7 +255,7 @@ void GraphicalApplication::resize(const Size& size) if (USE_FRAMEBUFFER) { g_drawPool.get(DrawPoolType::CREATURE_INFORMATION)->setFramebuffer(size); - g_drawPool.get(DrawPoolType::FOREGROUND_MAP)->setFramebuffer(size); + g_drawPool.get(DrawPoolType::TEXT)->setFramebuffer(size); } }); } diff --git a/src/framework/core/graphicalapplication.h b/src/framework/core/graphicalapplication.h index 6ca438527a..5cce89c3bc 100644 --- a/src/framework/core/graphicalapplication.h +++ b/src/framework/core/graphicalapplication.h @@ -41,14 +41,14 @@ class GraphicalApplication : public Application void mainPoll(); void close() override; - void setMaxFps(uint16_t maxFps) { m_graphicFrameCounter.setMaxFps(maxFps); } - void setTargetFps(uint16_t targetFps) { m_graphicFrameCounter.setTargetFps(targetFps); } + void setMaxFps(uint16_t maxFps) { m_frameCounter.setMaxFps(maxFps); } + void setTargetFps(uint16_t targetFps) { m_frameCounter.setTargetFps(targetFps); } - uint16_t getFps() { return m_graphicFrameCounter.getFps(); } - uint8_t getMaxFps() { return m_graphicFrameCounter.getMaxFps(); } - uint8_t getTargetFps() { return m_graphicFrameCounter.getTargetFps(); } + uint16_t getFps() { return m_frameCounter.getFps(); } + uint8_t getMaxFps() { return m_frameCounter.getMaxFps(); } + uint8_t getTargetFps() { return m_frameCounter.getTargetFps(); } - void resetTargetFps() { m_graphicFrameCounter.resetTargetFps(); } + void resetTargetFps() { m_frameCounter.resetTargetFps(); } bool isOnInputEvent() { return m_onInputEvent; } bool mustOptimize() { @@ -112,8 +112,7 @@ class GraphicalApplication : public Application float m_animatedTextScale{ PlatformWindow::DEFAULT_DISPLAY_DENSITY }; float m_staticTextScale{ PlatformWindow::DEFAULT_DISPLAY_DENSITY }; - AdaptativeFrameCounter m_mapProcessFrameCounter; - AdaptativeFrameCounter m_graphicFrameCounter; + AdaptativeFrameCounter m_frameCounter; }; extern GraphicalApplication g_app; diff --git a/src/framework/core/resourcemanager.cpp b/src/framework/core/resourcemanager.cpp index ca7901a18a..902ce4268f 100644 --- a/src/framework/core/resourcemanager.cpp +++ b/src/framework/core/resourcemanager.cpp @@ -564,9 +564,9 @@ std::string ResourceManager::fileChecksum(const std::string& path) { return checksum; } -std::unordered_map ResourceManager::filesChecksums() +stdext::map ResourceManager::filesChecksums() { - std::unordered_map ret; + stdext::map ret; auto files = listDirectoryFiles("/", true, false, true); for (auto it = files.rbegin(); it != files.rend(); ++it) { const auto& filePath = *it; @@ -723,10 +723,10 @@ bool ResourceManager::launchCorrect(std::vector& args) { // curentl #endif } -std::string ResourceManager::createArchive(const std::unordered_map& files) { return ""; } +std::string ResourceManager::createArchive(const stdext::map& files) { return ""; } -std::unordered_map ResourceManager::decompressArchive(std::string dataOrPath) +stdext::map ResourceManager::decompressArchive(std::string dataOrPath) { - std::unordered_map ret; + stdext::map ret; return ret; } \ No newline at end of file diff --git a/src/framework/core/resourcemanager.h b/src/framework/core/resourcemanager.h index 5eea6509f2..eb304dfcb9 100644 --- a/src/framework/core/resourcemanager.h +++ b/src/framework/core/resourcemanager.h @@ -85,13 +85,13 @@ class ResourceManager void save_string_into_file(const std::string& contents, const std::string& name); std::string fileChecksum(const std::string& path); - std::unordered_map filesChecksums(); + stdext::map filesChecksums(); std::string selfChecksum(); void updateFiles(const std::set& files); void updateExecutable(std::string fileName); bool launchCorrect(std::vector& args); - std::string createArchive(const std::unordered_map& files); - std::unordered_map decompressArchive(std::string dataOrPath); + std::string createArchive(const stdext::map& files); + stdext::map decompressArchive(std::string dataOrPath); std::string getBinaryPath() { return m_binaryPath.string(); } diff --git a/src/framework/graphics/drawpool.cpp b/src/framework/graphics/drawpool.cpp index 84dc1bf172..ca63e3f2c9 100644 --- a/src/framework/graphics/drawpool.cpp +++ b/src/framework/graphics/drawpool.cpp @@ -40,7 +40,7 @@ DrawPool* DrawPool::create(const DrawPoolType type) } else { pool->m_alwaysGroupDrawings = true; // CREATURE_INFORMATION & TEXT - if (type == DrawPoolType::FOREGROUND_MAP) { + if (type == DrawPoolType::TEXT || type == DrawPoolType::FOREGROUND_TILE) { pool->setFPS(FPS60); } } @@ -49,7 +49,7 @@ DrawPool* DrawPool::create(const DrawPoolType type) return pool; } -void DrawPool::add(const Color& color, const TexturePtr& texture, DrawPool::DrawMethod&& method, +void DrawPool::add(const Color& color, const TexturePtr& texture, DrawPool::DrawMethod& method, DrawMode drawMode, const DrawConductor& conductor, const CoordsBufferPtr& coordsBuffer) { updateHash(method, texture, color); @@ -63,8 +63,8 @@ void DrawPool::add(const Color& color, const TexturePtr& texture, DrawPool::Draw if (m_alwaysGroupDrawings || conductor.agroup) { auto& coords = m_coords.try_emplace(m_state.hash, nullptr).first->second; if (!coords) { - auto state = getState(texture, color); - coords = m_objects[order].emplace_back(std::move(state)).coords.get(); + auto state = getState(method, texture, color); + coords = m_objects[m_depthLevel][order].emplace_back(state).coords.get(); } if (coordsBuffer) @@ -74,12 +74,12 @@ void DrawPool::add(const Color& color, const TexturePtr& texture, DrawPool::Draw } else { bool addNewObj = true; - auto& list = m_objects[order]; + auto& list = m_objects[m_depthLevel][order]; if (!list.empty()) { auto& prevObj = list.back(); - if (prevObj.state == m_state) { + if (prevObj.state.hash == m_state.hash) { if (!prevObj.coords) - prevObj.addMethod(std::move(method)); + prevObj.addMethod(method); else if (coordsBuffer) prevObj.coords->append(coordsBuffer.get()); else @@ -90,11 +90,11 @@ void DrawPool::add(const Color& color, const TexturePtr& texture, DrawPool::Draw } if (addNewObj) { - auto state = getState(texture, color); + auto state = getState(method, texture, color); if (coordsBuffer) { - list.emplace_back(std::move(state)).coords->append(coordsBuffer.get()); + list.emplace_back(state).coords->append(coordsBuffer.get()); } else - list.emplace_back(drawMode, std::move(state), std::move(method)); + list.emplace_back(drawMode, state, method); } } @@ -143,38 +143,38 @@ void DrawPool::updateHash(const DrawPool::DrawMethod& method, const TexturePtr& { // State Hash m_state.hash = 0; - if (m_bindedFramebuffers) - stdext::hash_combine(m_state.hash, m_lastFramebufferId); - if (m_state.blendEquation != BlendEquation::ADD) stdext::hash_combine(m_state.hash, m_state.blendEquation); + if (m_state.clipRect.isValid()) + stdext::hash_union(m_state.hash, m_state.clipRect.hash()); + if (m_state.compositionMode != CompositionMode::NORMAL) stdext::hash_combine(m_state.hash, m_state.compositionMode); if (m_state.opacity < 1.f) stdext::hash_combine(m_state.hash, m_state.opacity); - if (m_state.clipRect.isValid()) - stdext::hash_union(m_state.hash, m_state.clipRect.hash()); - if (m_state.shaderProgram) - stdext::hash_union(m_state.hash, m_state.shaderProgram->hash()); + stdext::hash_combine(m_state.hash, m_state.shaderProgram->getProgramId()); if (m_state.transformMatrix != DEFAULT_MATRIX3) stdext::hash_union(m_state.hash, m_state.transformMatrix.hash()); + if (m_bindedFramebuffers) + stdext::hash_combine(m_state.hash, m_lastFramebufferId); + if (color != Color::white) stdext::hash_union(m_state.hash, color.hash()); if (texture) stdext::hash_union(m_state.hash, texture->hash()); - } - if (hasFrameBuffer()) { // Pool Hash - if (m_state.hash) + if (hasFrameBuffer()) stdext::hash_union(m_status.second, m_state.hash); + } + if (hasFrameBuffer()) { // Method Hash if (method.type == DrawPool::DrawMethodType::TRIANGLE) { if (!method.a.isNull()) stdext::hash_union(m_status.second, method.a.hash()); if (!method.b.isNull()) stdext::hash_union(m_status.second, method.b.hash()); @@ -188,7 +188,7 @@ void DrawPool::updateHash(const DrawPool::DrawMethod& method, const TexturePtr& } } -DrawPool::PoolState DrawPool::getState(const TexturePtr& texture, const Color& color) +DrawPool::PoolState DrawPool::getState(const DrawPool::DrawMethod& method, const TexturePtr& texture, const Color& color) { return PoolState{ std::move(m_state.transformMatrix), m_state.opacity, @@ -243,12 +243,14 @@ void DrawPool::setShaderProgram(const PainterShaderProgramPtr& shaderProgram, bo void DrawPool::resetState() { - for (auto& objs : m_objects) - objs.clear(); - m_objectsFlushed.clear(); - m_coords.clear(); + for (auto& objs : m_objects) { + for (auto& order : objs) + order.clear(); + } + m_coords.clear(); m_state = {}; + m_depthLevel = 0; m_status.second = 0; m_lastFramebufferId = 0; m_shaderRefreshDelay = 0; @@ -257,9 +259,6 @@ void DrawPool::resetState() bool DrawPool::canRepaint(const bool autoUpdateStatus) { - if (!hasFrameBuffer()) - return true; - uint16_t refreshDelay = m_refreshDelay; if (m_shaderRefreshDelay > 0 && (m_refreshDelay == 0 || m_shaderRefreshDelay < m_refreshDelay)) refreshDelay = m_shaderRefreshDelay; @@ -365,7 +364,7 @@ void DrawPool::removeFramebuffer() { void DrawPool::addAction(const std::function& action) { const uint8_t order = m_type == DrawPoolType::MAP ? DrawOrder::THIRD : DrawOrder::FIRST; - m_objects[order].emplace_back(action); + m_objects[m_depthLevel][order].emplace_back(action); } void DrawPool::bindFrameBuffer(const Size& size) diff --git a/src/framework/graphics/drawpool.h b/src/framework/graphics/drawpool.h index d3b79605bd..0f3371bb7f 100644 --- a/src/framework/graphics/drawpool.h +++ b/src/framework/graphics/drawpool.h @@ -29,18 +29,20 @@ #include "texture.h" #include "framework/core/timer.h" #include -#include #include "../stdext/storage.h" +#define MAX_DRAW_DEPTH 15 + enum class DrawPoolType : uint8_t { MAP, CREATURE_INFORMATION, LIGHT, - FOREGROUND_MAP, + TEXT, + FOREGROUND_TILE, FOREGROUND, - LAST + UNKNOW }; enum DrawOrder : uint8_t @@ -94,11 +96,10 @@ class DrawPool void setFramebuffer(const Size& size); void removeFramebuffer(); - void onBeforeDraw(std::function&& f) { m_beforeDraw = std::move(f); } - void onAfterDraw(std::function&& f) { m_afterDraw = std::move(f); } + void onBeforeDraw(std::function f) { m_beforeDraw = std::move(f); } + void onAfterDraw(std::function f) { m_afterDraw = std::move(f); } - std::mutex& getMutex() { return m_mutexDraw; } - std::mutex& getMutexPreDraw() { return m_mutexPreDraw; } + std::mutex& getMutex() { return m_mutex; } protected: @@ -139,11 +140,11 @@ class DrawPool struct DrawObject { DrawObject(std::function action) : action(std::move(action)) {} - DrawObject(PoolState&& state) : state(std::move(state)), coords(std::make_unique()) {} - DrawObject(const DrawMode drawMode, PoolState&& state, DrawMethod&& method) : + DrawObject(PoolState& state) : state(std::move(state)), coords(std::make_unique()) {} + DrawObject(const DrawMode drawMode, PoolState& state, DrawMethod& method) : drawMode(drawMode), state(std::move(state)) { methods.emplace_back(std::move(method)); } - void addMethod(DrawMethod&& method) + void addMethod(DrawMethod& method) { drawMode = DrawMode::TRIANGLES; methods.emplace_back(std::move(method)); @@ -179,7 +180,7 @@ class DrawPool STATE_BLEND_EQUATION = 1 << 4, }; - void add(const Color& color, const TexturePtr& texture, DrawPool::DrawMethod&& method, + void add(const Color& color, const TexturePtr& texture, DrawPool::DrawMethod& method, DrawMode drawMode = DrawMode::TRIANGLES, const DrawConductor& conductor = DEFAULT_DRAW_CONDUCTOR, const CoordsBufferPtr& coordsBuffer = nullptr); @@ -190,7 +191,7 @@ class DrawPool inline void setFPS(uint16_t fps) { m_refreshDelay = fps; } void updateHash(const DrawPool::DrawMethod& method, const TexturePtr& texture, const Color& color); - PoolState getState(const TexturePtr& texture, const Color& color); + PoolState getState(const DrawPool::DrawMethod& method, const TexturePtr& texture, const Color& color); float getOpacity() const { return m_state.opacity; } Rect getClipRect() { return m_state.clipRect; } @@ -219,25 +220,8 @@ class DrawPool void flush() { m_coords.clear(); - for (auto& objs : m_objects) { - m_objectsFlushed.insert(m_objectsFlushed.end(), make_move_iterator(objs.begin()), make_move_iterator(objs.end())); - objs.clear(); - } - } - - void release(bool draw = true) { - m_objectsDraw.clear(); - if (draw) { - if (!m_objectsFlushed.empty()) - m_objectsDraw.insert(m_objectsDraw.end(), make_move_iterator(m_objectsFlushed.begin()), make_move_iterator(m_objectsFlushed.end())); - - for (auto& objs : m_objects) { - m_objectsDraw.insert(m_objectsDraw.end(), make_move_iterator(objs.begin()), make_move_iterator(objs.end())); - objs.clear(); - } - } - - m_objectsFlushed.clear(); + if (m_depthLevel < MAX_DRAW_DEPTH) + ++m_depthLevel; } bool canRepaint(bool autoUpdateStatus); @@ -248,6 +232,7 @@ class DrawPool bool m_alwaysGroupDrawings{ false }; int_fast8_t m_bindedFramebuffers{ -1 }; + uint8_t m_depthLevel{ 0 }; uint16_t m_refreshDelay{ 0 }, m_shaderRefreshDelay{ 0 }; uint32_t m_onlyOnceStateFlag{ 0 }; @@ -255,7 +240,7 @@ class DrawPool PoolState m_state, m_oldState; - DrawPoolType m_type{ DrawPoolType::LAST }; + DrawPoolType m_type{ DrawPoolType::UNKNOW }; Timer m_refreshTimer; @@ -263,10 +248,7 @@ class DrawPool std::vector m_transformMatrixStack; std::vector m_temporaryFramebuffers; - - std::vector m_objects[static_cast(DrawOrder::LAST)]; - std::vector m_objectsFlushed; - std::vector m_objectsDraw; + std::vector m_objects[MAX_DRAW_DEPTH + 1][static_cast(DrawOrder::LAST)]; stdext::map m_coords; @@ -278,9 +260,7 @@ class DrawPool std::function m_beforeDraw; std::function m_afterDraw; - std::atomic_bool m_repaint{ false }; - std::mutex m_mutexDraw; - std::mutex m_mutexPreDraw; + std::mutex m_mutex; friend class DrawPoolManager; }; diff --git a/src/framework/graphics/drawpoolmanager.cpp b/src/framework/graphics/drawpoolmanager.cpp index ff097f8145..e750eebb47 100644 --- a/src/framework/graphics/drawpoolmanager.cpp +++ b/src/framework/graphics/drawpoolmanager.cpp @@ -33,7 +33,7 @@ void DrawPoolManager::init(uint16_t spriteSize) m_spriteSize = spriteSize; // Create Pools - for (int8_t i = -1; ++i < static_cast(DrawPoolType::LAST);) { + for (int8_t i = -1; ++i <= static_cast(DrawPoolType::UNKNOW);) { m_pools[i] = DrawPool::create(static_cast(i)); } } @@ -41,7 +41,7 @@ void DrawPoolManager::init(uint16_t spriteSize) void DrawPoolManager::terminate() const { // Destroy Pools - for (int_fast8_t i = -1; ++i < static_cast(DrawPoolType::LAST);) { + for (int_fast8_t i = -1; ++i <= static_cast(DrawPoolType::UNKNOW);) { delete m_pools[i]; } } @@ -57,16 +57,62 @@ void DrawPoolManager::draw() g_painter->setResolution(m_size, m_transformMatrix); } - for (auto pool : m_pools) { - if (pool->getType() == DrawPoolType::CREATURE_INFORMATION) - continue; + // m_drawing = true; - std::scoped_lock l(pool->m_mutexDraw); - drawPool(pool); - - if (pool->getType() == DrawPoolType::MAP) + const auto& map = get(DrawPoolType::MAP); { + std::scoped_lock l(map->m_mutex); + if (drawPool(map)) { drawPool(get(DrawPoolType::CREATURE_INFORMATION)); + drawPool(get(DrawPoolType::LIGHT)); + } } + + const auto& text = get(DrawPoolType::TEXT); { + std::scoped_lock l(text->m_mutex); + drawPool(text); + drawPool(get(DrawPoolType::FOREGROUND_TILE)); + } + + const auto& foreground = get(DrawPoolType::FOREGROUND); { + std::scoped_lock l(foreground->m_mutex); + drawPool(foreground); + } + + // m_drawing = false; +} + +bool DrawPoolManager::drawPool(DrawPool* pool) { + if (!pool->isEnabled()) + return false; + + if (!pool->hasFrameBuffer()) { + for (const auto& obj : pool->m_objects[0][DrawOrder::FIRST]) { + drawObject(obj); + } + return true; + } + + if (!pool->m_framebuffer->canDraw()) + return false; + + if (pool->canRepaint(true)) { + pool->m_framebuffer->bind(); + for (int_fast8_t i = -1; ++i <= pool->m_depthLevel;) { + for (const auto& order : pool->m_objects[i]) + for (const auto& obj : order) + drawObject(obj); + } + + pool->m_framebuffer->release(); + } + + g_painter->resetState(); + + if (pool->m_beforeDraw) pool->m_beforeDraw(); + pool->m_framebuffer->draw(); + if (pool->m_afterDraw) pool->m_afterDraw(); + + return true; } void DrawPoolManager::drawObject(const DrawPool::DrawObject& obj) @@ -89,7 +135,8 @@ void DrawPoolManager::drawObject(const DrawPool::DrawObject& obj) void DrawPoolManager::addTexturedCoordsBuffer(const TexturePtr& texture, const CoordsBufferPtr& coords, const Color& color) const { - getCurrentPool()->add(color, texture, DrawPool::DrawMethod{}, DrawMode::TRIANGLE_STRIP, DEFAULT_DRAW_CONDUCTOR, coords); + DrawPool::DrawMethod method; + getCurrentPool()->add(color, texture, method, DrawMode::TRIANGLE_STRIP, DEFAULT_DRAW_CONDUCTOR, coords); } void DrawPoolManager::addTexturedRect(const Rect& dest, const TexturePtr& texture, const Rect& src, const Color& color, const DrawConductor& condutor) const @@ -97,10 +144,12 @@ void DrawPoolManager::addTexturedRect(const Rect& dest, const TexturePtr& textur if (dest.isEmpty() || src.isEmpty()) return; - getCurrentPool()->add(color, texture, DrawPool::DrawMethod{ + DrawPool::DrawMethod method{ .type = DrawPool::DrawMethodType::RECT, .dest = dest, .src = src - }, DrawMode::TRIANGLE_STRIP, condutor); + }; + + getCurrentPool()->add(color, texture, method, DrawMode::TRIANGLE_STRIP, condutor); } void DrawPoolManager::addUpsideDownTexturedRect(const Rect& dest, const TexturePtr& texture, const Rect& src, const Color& color) const @@ -108,7 +157,9 @@ void DrawPoolManager::addUpsideDownTexturedRect(const Rect& dest, const TextureP if (dest.isEmpty() || src.isEmpty()) return; - getCurrentPool()->add(color, texture, DrawPool::DrawMethod{ DrawPool::DrawMethodType::UPSIDEDOWN_RECT, dest, src }, DrawMode::TRIANGLE_STRIP); + DrawPool::DrawMethod method{ DrawPool::DrawMethodType::UPSIDEDOWN_RECT, dest, src }; + + getCurrentPool()->add(color, texture, method, DrawMode::TRIANGLE_STRIP); } void DrawPoolManager::addTexturedRepeatedRect(const Rect& dest, const TexturePtr& texture, const Rect& src, const Color& color) const @@ -116,7 +167,9 @@ void DrawPoolManager::addTexturedRepeatedRect(const Rect& dest, const TexturePtr if (dest.isEmpty() || src.isEmpty()) return; - getCurrentPool()->add(color, texture, DrawPool::DrawMethod{ DrawPool::DrawMethodType::REPEATED_RECT, dest, src }); + DrawPool::DrawMethod method{ DrawPool::DrawMethodType::REPEATED_RECT, dest, src }; + + getCurrentPool()->add(color, texture, method); } void DrawPoolManager::addFilledRect(const Rect& dest, const Color& color, const DrawConductor& condutor) const @@ -124,7 +177,9 @@ void DrawPoolManager::addFilledRect(const Rect& dest, const Color& color, const if (dest.isEmpty()) return; - getCurrentPool()->add(color, nullptr, DrawPool::DrawMethod{ DrawPool::DrawMethodType::RECT, dest }, DrawMode::TRIANGLES, condutor); + DrawPool::DrawMethod method{ DrawPool::DrawMethodType::RECT, dest }; + + getCurrentPool()->add(color, nullptr, method, DrawMode::TRIANGLES, condutor); } void DrawPoolManager::addFilledTriangle(const Point& a, const Point& b, const Point& c, const Color& color) const @@ -132,12 +187,9 @@ void DrawPoolManager::addFilledTriangle(const Point& a, const Point& b, const Po if (a == b || a == c || b == c) return; - getCurrentPool()->add(color, nullptr, DrawPool::DrawMethod{ - .type = DrawPool::DrawMethodType::TRIANGLE, - .a = a, - .b = b, - .c = c - }); + DrawPool::DrawMethod method{ .type = DrawPool::DrawMethodType::TRIANGLE, .a = a, .b = b, .c = c }; + + getCurrentPool()->add(color, nullptr, method); } void DrawPoolManager::addBoundingRect(const Rect& dest, const Color& color, uint16_t innerLineWidth) const @@ -145,69 +197,30 @@ void DrawPoolManager::addBoundingRect(const Rect& dest, const Color& color, uint if (dest.isEmpty() || innerLineWidth == 0) return; - getCurrentPool()->add(color, nullptr, DrawPool::DrawMethod{ + DrawPool::DrawMethod method{ .type = DrawPool::DrawMethodType::BOUNDING_RECT, .dest = dest, .intValue = innerLineWidth - }); + }; + + getCurrentPool()->add(color, nullptr, method); } -void DrawPoolManager::preDraw(const DrawPoolType type, const std::function& f, const Rect& dest, const Rect& src, const Color& colorClear) +void DrawPoolManager::use(const DrawPoolType type, const Rect& dest, const Rect& src, const Color& colorClear) { select(type); - const auto pool = getCurrentPool(); - - if (pool->hasFrameBuffer() && pool->m_repaint.load()) - return; - - pool->resetState(); - - // when the selected pool is MAP, reset the creature information state. - if (type == DrawPoolType::MAP) { - get(DrawPoolType::CREATURE_INFORMATION)->resetState(); - } - - if (f) f(); - std::scoped_lock l(pool->m_mutexDraw); + auto* currentPoll = getCurrentPool(); - pool->setEnable(true); - if (pool->hasFrameBuffer()) - pool->m_framebuffer->prepare(dest, src, colorClear); + currentPoll->setEnable(true); + currentPoll->resetState(); - pool->release(pool->m_repaint = pool->canRepaint(true)); + if (currentPoll->hasFrameBuffer()) { + currentPoll->m_framebuffer->prepare(dest, src, colorClear); - if (type == DrawPoolType::MAP) { - get(DrawPoolType::CREATURE_INFORMATION)->release(); - } -} - -void DrawPoolManager::drawPool(DrawPool* pool) { - if (!pool->isEnabled()) - return; - - if (!pool->hasFrameBuffer()) { - for (const auto& obj : pool->m_objectsDraw) { - drawObject(obj); + // when the selected pool is MAP, reset the creature information state. + if (type == DrawPoolType::MAP) { + get(DrawPoolType::CREATURE_INFORMATION)->resetState(); } - return; - } - - if (!pool->m_framebuffer->canDraw()) - return; - - if (pool->m_repaint) { - pool->m_repaint.store(false); - - pool->m_framebuffer->bind(); - for (const auto& obj : pool->m_objectsDraw) - drawObject(obj); - pool->m_framebuffer->release(); } - - g_painter->resetState(); - - if (pool->m_beforeDraw) pool->m_beforeDraw(); - pool->m_framebuffer->draw(); - if (pool->m_afterDraw) pool->m_afterDraw(); } \ No newline at end of file diff --git a/src/framework/graphics/drawpoolmanager.h b/src/framework/graphics/drawpoolmanager.h index d305d76d48..03a99517eb 100644 --- a/src/framework/graphics/drawpoolmanager.h +++ b/src/framework/graphics/drawpoolmanager.h @@ -33,8 +33,8 @@ class DrawPoolManager DrawPool* get(const DrawPoolType type) const { return m_pools[static_cast(type)]; } void select(DrawPoolType type); - void preDraw(const DrawPoolType type, const std::function& f) { return preDraw(type, f, {}, {}); } - void preDraw(DrawPoolType type, const std::function& f, const Rect& dest, const Rect& src, const Color& colorClear = Color::alpha); + void use(const DrawPoolType type) { use(type, {}, {}); } + void use(DrawPoolType type, const Rect& dest, const Rect& src, const Color& colorClear = Color::alpha); void addTexturedPoint(const TexturePtr& texture, const Point& point, const Color& color = Color::white) const { addTexturedRect(Rect(point, texture->getSize()), texture, color); } @@ -93,6 +93,8 @@ class DrawPoolManager DrawPoolType getCurrentType() const { return getCurrentPool()->m_type; } + bool isDrawing() const { return m_drawing; } + private: DrawPool* getCurrentPool() const; @@ -101,10 +103,12 @@ class DrawPoolManager void terminate() const; void drawObject(const DrawPool::DrawObject& obj); - void drawPool(DrawPool* pool); + bool drawPool(DrawPool* pool); + + std::atomic_bool m_drawing{ false }; CoordsBuffer m_coordsBuffer; - std::array(DrawPoolType::LAST)> m_pools{}; + std::array(DrawPoolType::UNKNOW) + 1> m_pools{}; Size m_size; Matrix3 m_transformMatrix; diff --git a/src/framework/graphics/framebuffer.h b/src/framework/graphics/framebuffer.h index 31026796b5..85782bba92 100644 --- a/src/framework/graphics/framebuffer.h +++ b/src/framework/graphics/framebuffer.h @@ -41,9 +41,7 @@ class FrameBuffer bool resize(const Size& size); bool isValid() const { return m_texture != nullptr; } - bool canDraw() const { - return m_texture && m_coordsBuffer.getVertexCount() > 0; - } + bool canDraw() const { return m_coordsBuffer.getVertexCount() > 0; } TexturePtr getTexture() const { return m_texture; } Size getSize() const { return m_texture->getSize(); } diff --git a/src/framework/graphics/graphics.cpp b/src/framework/graphics/graphics.cpp index d4cd7c58b0..2417e581cb 100644 --- a/src/framework/graphics/graphics.cpp +++ b/src/framework/graphics/graphics.cpp @@ -77,7 +77,7 @@ void Graphics::init() m_ok = true; - g_painter = std::make_unique(); + g_painter = new Painter; g_textures.init(); } @@ -87,6 +87,9 @@ void Graphics::terminate() g_fonts.terminate(); g_textures.terminate(); + delete g_painter; + g_painter = nullptr; + m_ok = false; } diff --git a/src/framework/graphics/painter.cpp b/src/framework/graphics/painter.cpp index 3c22d6ba8b..72db5beb51 100644 --- a/src/framework/graphics/painter.cpp +++ b/src/framework/graphics/painter.cpp @@ -27,7 +27,7 @@ #include "shader/shadersources.h" -std::unique_ptr g_painter = nullptr; +Painter* g_painter = nullptr; /** * Painter using OpenGL 2.0 programmable rendering pipeline, diff --git a/src/framework/graphics/painter.h b/src/framework/graphics/painter.h index 3917fcfcc6..120966e9d5 100644 --- a/src/framework/graphics/painter.h +++ b/src/framework/graphics/painter.h @@ -142,4 +142,4 @@ class Painter PainterShaderProgramPtr m_drawReplaceColorProgram; }; -extern std::unique_ptr g_painter; +extern Painter* g_painter; diff --git a/src/framework/graphics/shaderprogram.cpp b/src/framework/graphics/shaderprogram.cpp index 248c19d18d..863fe63335 100644 --- a/src/framework/graphics/shaderprogram.cpp +++ b/src/framework/graphics/shaderprogram.cpp @@ -24,7 +24,6 @@ #include "graphics.h" #include -#include uint32_t ShaderProgram::m_currentProgram = 0; @@ -49,7 +48,6 @@ bool ShaderProgram::addShader(const ShaderPtr& shader) glAttachShader(m_programId, shader->getShaderId()); m_linked = false; m_shaders.emplace_back(shader); - m_hash = stdext::hash_int(m_programId); return true; } @@ -82,7 +80,6 @@ void ShaderProgram::removeShader(const ShaderPtr& shader) glDetachShader(m_programId, shader->getShaderId()); m_shaders.erase(it); m_linked = false; - m_hash = 0; } void ShaderProgram::removeAllShaders() diff --git a/src/framework/graphics/shaderprogram.h b/src/framework/graphics/shaderprogram.h index d64cc8c188..75442ad2fb 100644 --- a/src/framework/graphics/shaderprogram.h +++ b/src/framework/graphics/shaderprogram.h @@ -109,13 +109,11 @@ class ShaderProgram : public LuaObject bool isLinked() const { return m_linked; } uint32_t getProgramId() const { return m_programId; } - size_t hash() const { return m_hash; } ShaderList getShaders() { return m_shaders; } private: bool m_linked{ false }; uint32_t m_programId; - size_t m_hash{ 0 }; static uint32_t m_currentProgram; ShaderList m_shaders; std::array m_uniformLocations{ }; diff --git a/src/framework/graphics/texturemanager.h b/src/framework/graphics/texturemanager.h index 69bcfed14b..cf193654ba 100644 --- a/src/framework/graphics/texturemanager.h +++ b/src/framework/graphics/texturemanager.h @@ -41,7 +41,7 @@ class TextureManager TexturePtr loadTexture(std::stringstream& file); private: - std::unordered_map m_textures; + stdext::map m_textures; std::vector m_animatedTextures; TexturePtr m_emptyTexture; ScheduledEventPtr m_liveReloadEvent; diff --git a/src/framework/luaengine/luavaluecasts.h b/src/framework/luaengine/luavaluecasts.h index 2769829d14..629f49f95a 100644 --- a/src/framework/luaengine/luavaluecasts.h +++ b/src/framework/luaengine/luavaluecasts.h @@ -205,18 +205,6 @@ int push_luavalue(const stdext::map& map); template bool luavalue_cast(int index, stdext::map& map); -template -int push_luavalue(const std::map& map); - -template -bool luavalue_cast(int index, std::map& map); - -template -int push_luavalue(const std::unordered_map& map); - -template -bool luavalue_cast(int index, std::unordered_map& map); - // pair template bool luavalue_cast(int index, std::pair& pair); @@ -499,64 +487,6 @@ bool luavalue_cast(int index, stdext::map& map) return false; } -template -int push_luavalue(const std::map& map) -{ - g_lua.newTable(); - for (const auto& [key, value] : map) { - push_internal_luavalue(key); - push_internal_luavalue(value); - g_lua.rawSet(); - } - return 1; -} - -template -bool luavalue_cast(int index, std::map& map) -{ - if (g_lua.isTable(index)) { - g_lua.pushNil(); - while (g_lua.next(index < 0 ? index - 1 : index)) { - K key; - V value; - if (luavalue_cast(-1, value) && luavalue_cast(-2, key)) - map[key] = value; - g_lua.pop(); - } - return true; - } - return false; -} - -template -int push_luavalue(const std::unordered_map& map) -{ - g_lua.newTable(); - for (const auto& [key, value] : map) { - push_internal_luavalue(key); - push_internal_luavalue(value); - g_lua.rawSet(); - } - return 1; -} - -template -bool luavalue_cast(int index, std::unordered_map& map) -{ - if (g_lua.isTable(index)) { - g_lua.pushNil(); - while (g_lua.next(index < 0 ? index - 1 : index)) { - K key; - V value; - if (luavalue_cast(-1, value) && luavalue_cast(-2, key)) - map[key] = value; - g_lua.pop(); - } - return true; - } - return false; -} - template bool luavalue_cast(int index, std::pair& pair) { diff --git a/src/framework/net/protocolhttp.h b/src/framework/net/protocolhttp.h index db77bcf78a..516ac9cafe 100644 --- a/src/framework/net/protocolhttp.h +++ b/src/framework/net/protocolhttp.h @@ -65,7 +65,7 @@ class HttpSession : public std::enable_shared_from_this HttpSession(asio::io_service& service, const std::string& url, const std::string& agent, const bool& enable_time_out_on_read_write, - const std::unordered_map& custom_header, + const stdext::map& custom_header, int timeout, bool isJson, bool checkContentLength, const HttpResult_ptr& result, HttpResult_cb callback) : m_service(service), m_url(url), @@ -93,7 +93,7 @@ class HttpSession : public std::enable_shared_from_this std::string m_url; std::string m_agent; bool m_enable_time_out_on_read_write; - std::unordered_map m_custom_header; + stdext::map m_custom_header; int m_timeout; bool m_isJson; bool m_checkContentLength; @@ -204,7 +204,7 @@ class Http bool wsClose(int operationId); bool cancel(int id); - const std::unordered_map& downloads() const { return m_downloads; } + const stdext::map& downloads() const { return m_downloads; } void clearDownloads() { m_downloads.clear(); } @@ -231,11 +231,11 @@ class Http std::thread m_thread; asio::io_context m_ios{}; asio::executor_work_guard m_guard; - std::unordered_map m_operations; - std::unordered_map> m_websockets; - std::unordered_map m_downloads; + stdext::map m_operations; + stdext::map> m_websockets; + stdext::map m_downloads; std::string m_userAgent = "Mozilla/5.0"; - std::unordered_map m_custom_header; + stdext::map m_custom_header; }; extern Http g_http; diff --git a/src/framework/pch.h b/src/framework/pch.h index 8717263ccb..6e61fa8878 100644 --- a/src/framework/pch.h +++ b/src/framework/pch.h @@ -46,8 +46,6 @@ #include #include #include -#include -#include #include #include diff --git a/src/framework/platform/platform.cpp b/src/framework/platform/platform.cpp index 8b36360354..35501505eb 100644 --- a/src/framework/platform/platform.cpp +++ b/src/framework/platform/platform.cpp @@ -24,13 +24,13 @@ Platform g_platform; -std::unordered_map Platform::m_deviceShortNames = { +stdext::map Platform::m_deviceShortNames = { {Platform::Desktop, "desktop"}, {Platform::Mobile, "mobile"}, {Platform::Console, "console"}, }; -std::unordered_map Platform::m_osShortNames = { +stdext::map Platform::m_osShortNames = { {Platform::Windows, "windows"}, {Platform::Linux, "linux"}, {Platform::macOS, "macos"}, diff --git a/src/framework/platform/platform.h b/src/framework/platform/platform.h index 53bdd94935..5b274838a5 100644 --- a/src/framework/platform/platform.h +++ b/src/framework/platform/platform.h @@ -90,8 +90,8 @@ class Platform private: Device m_device{ Device(Desktop, Windows) }; - static std::unordered_map m_deviceShortNames; - static std::unordered_map m_osShortNames; + static stdext::map m_deviceShortNames; + static stdext::map m_osShortNames; }; extern Platform g_platform; diff --git a/src/framework/platform/win32window.cpp b/src/framework/platform/win32window.cpp index 5402edd18c..f7b6a29a94 100644 --- a/src/framework/platform/win32window.cpp +++ b/src/framework/platform/win32window.cpp @@ -25,7 +25,6 @@ #include "win32window.h" #include #include -#include #include #include #include @@ -937,9 +936,8 @@ void WIN32Window::setFullscreen(bool fullscreen) void WIN32Window::setVerticalSync(bool enable) { - m_vsync = enable; - - g_mainDispatcher.addEvent([this, enable] { + g_mainDispatcher.addEvent([&, enable] { + m_vsync = enable; #ifdef OPENGL_ES eglSwapInterval(m_eglDisplay, enable); #else diff --git a/src/framework/sound/soundmanager.h b/src/framework/sound/soundmanager.h index 9e4dd5dfe7..e8396c587b 100644 --- a/src/framework/sound/soundmanager.h +++ b/src/framework/sound/soundmanager.h @@ -58,9 +58,9 @@ class SoundManager ALCdevice* m_device{}; ALCcontext* m_context{}; - std::unordered_map> m_streamFiles; - std::unordered_map m_buffers; - std::unordered_map m_channels; + stdext::map> m_streamFiles; + stdext::map m_buffers; + stdext::map m_channels; std::vector m_sources; bool m_audioEnabled{ true }; diff --git a/src/framework/ui/uianchorlayout.h b/src/framework/ui/uianchorlayout.h index d0f0dce63d..1dbc9aad95 100644 --- a/src/framework/ui/uianchorlayout.h +++ b/src/framework/ui/uianchorlayout.h @@ -83,5 +83,5 @@ class UIAnchorLayout : public UILayout protected: bool internalUpdate() override; virtual bool updateWidget(const UIWidgetPtr& widget, const UIAnchorGroupPtr& anchorGroup, UIWidgetPtr first = nullptr); - std::unordered_map m_anchorsGroups; + stdext::map m_anchorsGroups; }; diff --git a/src/framework/ui/uimanager.cpp b/src/framework/ui/uimanager.cpp index abde91c634..f515e1796f 100644 --- a/src/framework/ui/uimanager.cpp +++ b/src/framework/ui/uimanager.cpp @@ -59,12 +59,8 @@ void UIManager::terminate() void UIManager::render(DrawPoolType drawPane) const { - if (drawPane == DrawPoolType::FOREGROUND) { - g_drawPool.preDraw(DrawPoolType::FOREGROUND, [this, drawPane] { - m_rootWidget->draw(m_rootWidget->getRect(), drawPane); - }, { 0,0, g_graphics.getViewportSize() }, {}); - return; - } + if (drawPane == DrawPoolType::FOREGROUND) + g_drawPool.use(DrawPoolType::FOREGROUND, { 0,0, g_graphics.getViewportSize() }, {}); m_rootWidget->draw(m_rootWidget->getRect(), drawPane); } diff --git a/src/framework/ui/uiwidget.cpp b/src/framework/ui/uiwidget.cpp index 50d6e814ed..450d4f4cb4 100644 --- a/src/framework/ui/uiwidget.cpp +++ b/src/framework/ui/uiwidget.cpp @@ -1918,7 +1918,7 @@ void UIWidget::move(int x, int y) { self->m_rect = {}; // force update self->setRect(rect); self->setProp(PropUpdatingMove, false); - }, 8); + }, 13); } m_rect = { x, y, getSize() }; @@ -1935,4 +1935,4 @@ void UIWidget::setShader(const std::string_view name) { }); } -void UIWidget::repaint() { g_app.repaint(); } \ No newline at end of file +void UIWidget::repaint() { g_app.repaint(); } diff --git a/src/gitinfo.h b/src/gitinfo.h index db0f2f9f02..e03e28d0a8 100644 --- a/src/gitinfo.h +++ b/src/gitinfo.h @@ -1,3 +1,3 @@ #define GIT_BRANCH desenv -#define GIT_VERSION 3.x +#define GIT_VERSION 1.0 #define GIT_COMMITS 0 diff --git a/vc17/otclient.vcxproj b/vc17/otclient.vcxproj index 149b23df86..f793966979 100644 --- a/vc17/otclient.vcxproj +++ b/vc17/otclient.vcxproj @@ -29,13 +29,13 @@ Application true v143 - true + false Application true v143 - true + false Application @@ -142,7 +142,6 @@ cmd /c "start ../vcpkg_installed\$(VcpkgTriplet)\$(VcpkgTriplet)\tools\protobuf\ $(VcpkgRoot)\installed\$(VcpkgTriplet)\include\luajit;%(AdditionalIncludeDirectories) stdcpp20 4244;4251;4996;%(DisableSpecificWarnings) - true true