diff --git a/data/images/ui/checkbox_round.png b/data/images/ui/checkbox_round.png index e45bae8..71672a7 100644 Binary files a/data/images/ui/checkbox_round.png and b/data/images/ui/checkbox_round.png differ diff --git a/data/styles/40-outfitwindow.otui b/data/styles/40-outfitwindow.otui new file mode 100644 index 0000000..0e47d10 --- /dev/null +++ b/data/styles/40-outfitwindow.otui @@ -0,0 +1,476 @@ +PartCheckBoxes < Panel + height: 18 + + ButtonBox + id: head + font: cipsoftFont + !text: tr('Head') + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + checked: true + width: 62 + height: 18 + + ButtonBox + id: primary + font: cipsoftFont + !text: tr('Primary') + anchors.verticalCenter: prev.verticalCenter + anchors.left: prev.right + width: 62 + height: 18 + + ButtonBox + id: secondary + font: cipsoftFont + !text: tr('Secondary') + anchors.verticalCenter: prev.verticalCenter + anchors.left: prev.right + width: 62 + height: 18 + + ButtonBox + id: detail + font: cipsoftFont + !text: tr('Detail') + anchors.verticalCenter: prev.verticalCenter + anchors.left: prev.right + width: 62 + height: 18 + + ButtonBox + id: randomizeButton + font: cipsoftFont + !text: tr('Randomize') + !tooltip: tr('Randomize characters outfit') + anchors.verticalCenter: prev.verticalCenter + anchors.left: prev.right + width: 62 + height: 18 + @onClick: modules.game_outfit.randomize() + +AppearanceCategory < Panel + height: 20 + + $!first: + margin-top: 2 + + CheckBox + id: checkBox + image-source: /images/ui/checkbox_round + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + margin-left: 5 + width: 90 + text: Outfit: + @onClick: modules.game_outfit.onOptionChange(self:getParent():getId(), self:isChecked(), self) + + FlatLabel + id: description + anchors.verticalCenter: prev.verticalCenter + anchors.left: prev.right + anchors.right: parent.right + margin-right: 5 + text-align: center + text: - + +WindowPanel < Panel + image-source: /images/ui/window + image-border: 6 + image-border-top: 27 + padding: 5 + padding-top: 8 + +OptionsCheckBox < Panel + image-source: /images/ui/panel_flat + image-border: 1 + padding: 2 + padding-left: 7 + height: 22 + + CheckBox + id: check + anchors.centerIn: parent + anchors.left: parent.left + anchors.right: parent.right + text-align: left + @onCheckChange: modules.game_outfit.onOptionChange(self:getParent():getId(), self:isChecked(), self) + + $!first: + margin-top: 3 + +PreviewCreaturePanel < FlatPanel + padding: 3 + + Button + id: rotateLeft + anchors.left: parent.left + anchors.bottom: parent.bottom + size: 20 20 + text: < + @onClick: modules.game_outfit.rotatePreview(self:getId()) + + Button + id: rotateRight + anchors.right: parent.right + anchors.bottom: parent.bottom + size: 20 20 + text: > + @onClick: modules.game_outfit.rotatePreview(self:getId()) + + UICreature + id: creature + size: 100 100 + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + +ConfigurePanel < WindowPanel + width: 150 + padding: 3 + + Label + id: title + margin-top: 5 + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + font: verdana-11px-rounded + text: Configure + + Panel + id: options + anchors.fill: parent + anchors.top: prev.bottom + margin-top: 1 + padding: 5 + layout: verticalBox + +SmallPreviewTile < UICheckBox + padding: 5 + @onClick: modules.game_outfit.onElementSelect(self) + image-source: /images/ui/button + image-color: #dfdfdf + image-clip: 0 0 22 23 + image-border: 10 + opacity: 1.0 + + $pressed: + image-clip: 0 46 22 23 + + $hover: + opacity: 0.75 + + UICreature + id: creature + size: 60 60 + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + phantom: true + creature-fixed-size: true + + UIWidget + id: item + anchors.fill: prev + phantom: true + + Label + id: title + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + text-align: center + font: verdana-11px-rounded + + $checked: + border-width: 1 + border-color: #ffffff + + $!checked: + border-width: 0 + +LargePreviewTile < UICheckBox + padding: 15 15 2 15 + @onClick: modules.game_outfit.onElementSelect(self) + image-source: /images/ui/button + image-color: #dfdfdf + image-clip: 0 0 22 23 + image-border: 10 + opacity: 1.0 + + $pressed: + image-clip: 0 46 22 23 + + UICreature + id: outfit + size: 60 60 + anchors.left: parent.left + margin-left: 10 + anchors.top: parent.top + phantom: true + + UICreature + id: mount + size: 60 60 + anchors.right: parent.right + margin-right: 10 + anchors.top: parent.top + phantom: true + + Label + id: title + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + text-align: center + font: verdana-11px-rounded + + $checked: + border-width: 1 + border-color: #ffffff + + $!checked: + border-width: 0 + +FilterPanel < WindowPanel + size: 242 56 + padding-left: 10 + padding-right: 10 + padding-bottom: 8 + + Label + id: title + anchors.left: parent.left + anchors.right: parent.right + text-align: center + anchors.top: parent.top + font: verdana-11px-rounded + text: Filter outfits + + Button + id: clear + anchors.right: parent.right + anchors.bottom: parent.bottom + size: 20 20 + text: X + @onClick: modules.game_outfit.clearFilterText() + + TextEdit + id: filterWindow + anchors.right: prev.left + anchors.left: parent.left + anchors.bottom: parent.bottom + height: 20 + placeholder: Type to search + placehoder-color: black + @onTextChange: modules.game_outfit.onFilterList(self:getText()) + +PresetPanel < WindowPanel + size: 242 47 + padding-left: 2 + padding-bottom: 2 + + Label + id: title + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + font: verdana-11px-rounded + text: Manage Presets + + Button + id: new + size: 45 18 + font: cipsoftFont + text: New + anchors.left: parent.left + anchors.bottom: parent.bottom + margin-bottom: 6 + margin-left: 25 + @onClick: modules.game_outfit.onPresetButtonPress(self:getId()) + + Button + id: rename + size: 45 18 + font: cipsoftFont + text: Rename + anchors.left: prev.right + margin-left: 3 + anchors.verticalCenter: prev.verticalCenter + @onClick: modules.game_outfit.onPresetButtonPress(self:getId()) + + + Button + id: save + size: 45 18 + font: cipsoftFont + text: Save + anchors.left: prev.right + margin-left: 3 + anchors.verticalCenter: prev.verticalCenter + @onClick: modules.game_outfit.onPresetButtonPress(self:getId()) + + Button + id: delete + size: 45 18 + font: cipsoftFont + text: Delete + anchors.left: prev.right + margin-left: 3 + anchors.verticalCenter: prev.verticalCenter + @onClick: modules.game_outfit.onPresetButtonPress(self:getId()) + +PreviewPanel < WindowPanel + size: 477 205 + + Label + id: title + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + font: verdana-11px-rounded + text: Preview Selection + + FlatPanel + id: options + anchors.top: parent.top + anchors.left: parent.left + anchors.bottom: parent.bottom + margin: 3 + margin-top: 19 + padding: 5 + width: 120 + layout: verticalBox + + Label + font: verdana-11px-rounded + text-align: center + text: Show: + + PreviewCreaturePanel + id: creaturePanel + margin: 3 + margin-top: 19 + anchors.fill: parent + anchors.left: prev.right + +AppearancePanel < WindowPanel + layout: + type: verticalBox + fit-children: true + + Panel + id: categories + margin-top: 20 + layout: + type: verticalBox + fit-children: true + + PartCheckBoxes + id: parts + margin-top: 3 + margin-left: 7 + + Panel + id: colorBoxPanel + padding: 2 2 2 5 + layout: + type: grid + cell-size: 14 14 + cell-spacing: 2 + num-columns: 19 + num-lines: 7 + fit-children: true + +ListBox < ScrollableFlatPanel + width: 242 + padding-top: 6 + padding-left: 6 + padding-bottom: 6 + layout: + type: grid + num-columns: 2 + cell-size: 106 100 + cell-spacing: 6 + flow: true + +OutfitWindow < MainWindow + size: 760 519 + padding-top: 35 + !text: tr('Customize Character') + + FilterPanel + id: search + anchors.top: parent.top + anchors.right: parent.right + + PresetPanel + id: preset + anchors.fill: prev + visible: false + + ListBox + id: list + anchors.top: prev.bottom + margin-top: 5 + anchors.right: parent.right + anchors.bottom: bottomSep.top + margin-bottom: 5 + vertical-scrollbar: scrollBar + + VerticalScrollBar + id: scrollBar + anchors.top: list.top + anchors.bottom: list.bottom + anchors.right: list.right + step: 14 + pixels-scroll: true + + PreviewPanel + id: preview + anchors.top: parent.top + anchors.left: parent.left + + ConfigurePanel + id: config + anchors.top: prev.bottom + margin-top: 5 + anchors.bottom: bottomSep.top + margin-bottom: 5 + anchors.left: parent.left + + AppearancePanel + id: appearance + anchors.left: prev.right + anchors.top: preview.bottom + anchors.right: preview.right + margin: 5 0 5 5 + + Label + anchors.top: prev.top + margin-top: 8 + anchors.horizontalCenter: prev.horizontalCenter + font: verdana-11px-rounded + text: Change Appearance + + HorizontalSeparator + id: bottomSep + anchors.right: parent.right + anchors.left: parent.left + anchors.bottom: closeButton.top + margin-bottom: 8 + + Button + id: closeButton + !text: tr('Cancel') + font: cipsoftFont + anchors.right: parent.right + anchors.bottom: parent.bottom + size: 45 21 + @onClick: modules.game_outfit.destroy() + + Button + id: okButton + !text: tr('Ok') + font: cipsoftFont + anchors.right: prev.left + margin-right: 7 + anchors.bottom: parent.bottom + size: 45 21 + @onClick: modules.game_outfit.accept() \ No newline at end of file diff --git a/layouts/retro/styles/40-outfitwindow.otui b/layouts/retro/styles/40-outfitwindow.otui new file mode 100644 index 0000000..9bc120e --- /dev/null +++ b/layouts/retro/styles/40-outfitwindow.otui @@ -0,0 +1,467 @@ +PartCheckBoxes < Panel + height: 18 + + ButtonBox + id: head + font: cipsoftFont + !text: tr('Head') + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + checked: true + width: 62 + height: 18 + + ButtonBox + id: primary + font: cipsoftFont + !text: tr('Primary') + anchors.verticalCenter: prev.verticalCenter + anchors.left: prev.right + width: 62 + height: 18 + + ButtonBox + id: secondary + font: cipsoftFont + !text: tr('Secondary') + anchors.verticalCenter: prev.verticalCenter + anchors.left: prev.right + width: 62 + height: 18 + + ButtonBox + id: detail + font: cipsoftFont + !text: tr('Detail') + anchors.verticalCenter: prev.verticalCenter + anchors.left: prev.right + width: 62 + height: 18 + + ButtonBox + id: randomizeButton + font: cipsoftFont + !text: tr('Randomize') + !tooltip: tr('Randomize characters outfit') + anchors.verticalCenter: prev.verticalCenter + anchors.left: prev.right + width: 62 + height: 18 + @onClick: modules.game_outfit.randomize() + +AppearanceCategory < Panel + height: 20 + + $!first: + margin-top: 2 + + CheckBox + id: checkBox + image-source: /images/ui/checkbox_round + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + margin-left: 5 + width: 90 + text: Outfit: + @onClick: modules.game_outfit.onOptionChange(self:getParent():getId(), self:isChecked(), self) + + FlatLabel + id: description + anchors.verticalCenter: prev.verticalCenter + anchors.left: prev.right + anchors.right: parent.right + margin-right: 5 + text-align: center + text: - + +WindowPanel < Panel + image-source: /images/ui/window + padding-top: 3 + padding-left: 7 + padding-bottom: 7 + padding-right: 7 + image-border: 4 + image-border-top: 17 + +OptionsCheckBox < Panel + image-source: /images/ui/panel_flat + image-border: 1 + padding: 2 + padding-left: 7 + height: 22 + + CheckBox + id: check + anchors.centerIn: parent + anchors.left: parent.left + anchors.right: parent.right + text-align: left + @onCheckChange: modules.game_outfit.onOptionChange(self:getParent():getId(), self:isChecked(), self) + + $!first: + margin-top: 3 + +PreviewCreaturePanel < FlatPanel + padding: 3 + + Button + id: rotateLeft + anchors.left: parent.left + anchors.bottom: parent.bottom + size: 20 20 + text: < + @onClick: modules.game_outfit.rotatePreview(self:getId()) + + Button + id: rotateRight + anchors.right: parent.right + anchors.bottom: parent.bottom + size: 20 20 + text: > + @onClick: modules.game_outfit.rotatePreview(self:getId()) + + UICreature + id: creature + size: 100 100 + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + +ConfigurePanel < WindowPanel + width: 150 + padding: 3 + + Label + id: title + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + font: verdana-11px-rounded + text: Configure + + Panel + id: options + anchors.fill: parent + anchors.top: prev.bottom + margin-top: 1 + padding: 5 + layout: verticalBox + +SmallPreviewTile < UICheckBox + padding: 5 + image-source: /images/ui/button + @onClick: modules.game_outfit.onElementSelect(self) + image-clip: 0 0 22 23 + image-border: 3 + + $pressed: + image-clip: 0 46 22 23 + + UICreature + id: creature + size: 60 60 + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + phantom: true + creature-fixed-size: true + + UIWidget + id: item + anchors.fill: prev + phantom: true + + Label + id: title + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + text-align: center + font: verdana-11px-rounded + + $checked: + border-width: 1 + border-color: #ffffff + + $!checked: + border-width: 0 + +LargePreviewTile < UICheckBox + padding: 15 + padding-bottom: 2 + image-source: /images/ui/button + @onClick: modules.game_outfit.onElementSelect(self) + image-clip: 0 0 22 23 + image-border: 3 + + $pressed: + image-clip: 0 46 22 23 + + UICreature + id: outfit + size: 60 60 + anchors.left: parent.left + margin-left: 10 + anchors.top: parent.top + phantom: true + + UICreature + id: mount + size: 60 60 + anchors.right: parent.right + margin-right: 10 + anchors.top: parent.top + phantom: true + + Label + id: title + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + text-align: center + font: verdana-11px-rounded + + $checked: + border-width: 1 + border-color: #ffffff + + $!checked: + border-width: 0 + +FilterPanel < WindowPanel + size: 242 47 + + Label + id: title + anchors.left: parent.left + anchors.right: parent.right + text-align: center + anchors.top: parent.top + font: verdana-11px-rounded + text: Filter outfits + + Button + id: clear + anchors.right: parent.right + anchors.bottom: parent.bottom + size: 20 20 + text: X + @onClick: modules.game_outfit.clearFilterText() + + TextEdit + id: filterWindow + anchors.right: prev.left + anchors.left: parent.left + anchors.bottom: parent.bottom + height: 20 + placeholder: Type to search + @onTextChange: modules.game_outfit.onFilterList(self:getText()) + +PresetPanel < WindowPanel + size: 242 47 + padding-left: 2 + padding-bottom: 2 + + Label + id: title + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + font: verdana-11px-rounded + text: Manage Presets + + Button + id: new + size: 45 18 + font: cipsoftFont + text: New + anchors.left: parent.left + anchors.bottom: parent.bottom + margin-bottom: 6 + margin-left: 25 + @onClick: modules.game_outfit.onPresetButtonPress(self:getId()) + + Button + id: rename + size: 45 18 + font: cipsoftFont + text: Rename + anchors.left: prev.right + margin-left: 3 + anchors.verticalCenter: prev.verticalCenter + @onClick: modules.game_outfit.onPresetButtonPress(self:getId()) + + + Button + id: save + size: 45 18 + font: cipsoftFont + text: Save + anchors.left: prev.right + margin-left: 3 + anchors.verticalCenter: prev.verticalCenter + @onClick: modules.game_outfit.onPresetButtonPress(self:getId()) + + Button + id: delete + size: 45 18 + font: cipsoftFont + text: Delete + anchors.left: prev.right + margin-left: 3 + anchors.verticalCenter: prev.verticalCenter + @onClick: modules.game_outfit.onPresetButtonPress(self:getId()) + +PreviewPanel < WindowPanel + size: 477 205 + + Label + id: title + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + font: verdana-11px-rounded + text: Preview Selection + + FlatPanel + id: options + anchors.top: parent.top + anchors.left: parent.left + anchors.bottom: parent.bottom + margin: 3 + margin-top: 19 + padding: 5 + width: 120 + layout: verticalBox + + Label + font: verdana-11px-rounded + text-align: center + text: Show: + + PreviewCreaturePanel + id: creaturePanel + margin: 3 + margin-top: 19 + anchors.fill: parent + anchors.left: prev.right + +AppearancePanel < WindowPanel + layout: + type: verticalBox + fit-children: true + + Panel + id: categories + margin-top: 20 + layout: + type: verticalBox + fit-children: true + + PartCheckBoxes + id: parts + margin-top: 10 + + FlatPanel + id: colorBoxPanel + margin-top: 2 + padding: 2 + layout: + type: grid + cell-size: 14 14 + cell-spacing: 2 + num-columns: 19 + num-lines: 7 + fit-children: true + +ListBox < ScrollableFlatPanel + width: 242 + padding-top: 6 + padding-left: 6 + padding-bottom: 6 + layout: + type: grid + num-columns: 2 + cell-size: 106 100 + cell-spacing: 6 + flow: true + +OutfitWindow < MainWindow + size: 755 519 + padding-top: 27 + !text: tr('Customize Character') + + FilterPanel + id: search + anchors.top: parent.top + anchors.right: parent.right + + PresetPanel + id: preset + anchors.fill: prev + visible: false + + ListBox + id: list + anchors.top: prev.bottom + margin-top: 5 + anchors.right: parent.right + anchors.bottom: bottomSep.top + margin-bottom: 5 + vertical-scrollbar: scrollBar + + VerticalScrollBar + id: scrollBar + anchors.top: list.top + anchors.bottom: list.bottom + anchors.right: list.right + step: 14 + pixels-scroll: true + + PreviewPanel + id: preview + anchors.top: parent.top + anchors.left: parent.left + + ConfigurePanel + id: config + anchors.top: prev.bottom + margin-top: 5 + anchors.bottom: bottomSep.top + margin-bottom: 5 + anchors.left: parent.left + + AppearancePanel + id: appearance + anchors.left: prev.right + anchors.top: preview.bottom + anchors.right: list.left + margin: 5 + + Label + anchors.top: prev.top + margin-top: 3 + anchors.horizontalCenter: prev.horizontalCenter + font: verdana-11px-rounded + text: Change Appearance + + HorizontalSeparator + id: bottomSep + anchors.right: parent.right + anchors.left: parent.left + anchors.bottom: closeButton.top + margin-bottom: 8 + + Button + id: closeButton + !text: tr('Cancel') + font: cipsoftFont + anchors.right: parent.right + anchors.bottom: parent.bottom + size: 45 21 + @onClick: modules.game_outfit.destroy() + + Button + id: okButton + !text: tr('Ok') + font: cipsoftFont + anchors.right: prev.left + margin-right: 7 + anchors.bottom: parent.bottom + size: 45 21 + @onClick: modules.game_outfit.accept() \ No newline at end of file diff --git a/modules/game_actionbar/actionbar.lua b/modules/game_actionbar/actionbar.lua index 783dd6d..d2b8135 100644 --- a/modules/game_actionbar/actionbar.lua +++ b/modules/game_actionbar/actionbar.lua @@ -1,4 +1,3 @@ ----@diagnostic disable: undefined-global bottomActionPanel1 = nil bottomActionPanel2 = nil bottomActionPanel3 = nil @@ -235,8 +234,6 @@ function setupAction(action) local chatMode = not modules.game_walking.wsadWalking if not lockKeyboard or not chatMode then - print('lock', lockKeyboard) - print('chatMode', chatMode) executeAction(action, ticks) end end diff --git a/modules/game_actionbar/actionbar.otui b/modules/game_actionbar/actionbar.otui index 43c1ce0..31a6c2e 100644 --- a/modules/game_actionbar/actionbar.otui +++ b/modules/game_actionbar/actionbar.otui @@ -1,17 +1,9 @@ ActionButton < Panel font: cipsoftFont - anchors.top: parent.top - anchors.bottom: parent.bottom width: 40 padding: 1 1 1 1 margin-left: 1 draggable: true - - $first: - anchors.left: parent.left - - $!first: - anchors.left: prev.right Item id: item @@ -91,6 +83,7 @@ Panel anchors.right: next.left margin-right: 3 clipping: true + layout: horizontalBox TabButton id: nextButton diff --git a/modules/game_actionbar/sideactionbar.otui b/modules/game_actionbar/sideactionbar.otui index 23cb19e..c21010e 100644 --- a/modules/game_actionbar/sideactionbar.otui +++ b/modules/game_actionbar/sideactionbar.otui @@ -1,18 +1,13 @@ SideActionButton < Panel font: cipsoftFont - anchors.left: parent.left - anchors.right: parent.right height: 40 padding: 1 1 1 1 - margin-top: 1 - draggable: true $first: - anchors.top: parent.top - margin-top: -3 + margin-top: -4 $!first: - anchors.top: prev.bottom + margin-top: -1 Item id: item @@ -92,6 +87,7 @@ Panel anchors.bottom: next.top margin-top: 3 clipping: true + layout: verticalBox TabButton id: nextButton diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/antiRs.lua b/modules/game_bot/default_configs/vBot_4.41/vBot/antiRs.lua deleted file mode 100644 index 41f5a3f..0000000 --- a/modules/game_bot/default_configs/vBot_4.41/vBot/antiRs.lua +++ /dev/null @@ -1,14 +0,0 @@ -setDefaultTab("Tools") -local m = macro(1000, "AntiRS & Msg", function() end) - -local frags = 0 -onTextMessage(function(mode, text) - if not m.isOn() then return end - if not text:find("Warning! The murder of") then return end - say("Don't bother, I have anti-rs and shit EQ. Don't waste our time.") - frags = frags + 1 - if killsToRs() < 6 or frags > 1 then - g_game.stop() - modules.game_interface.forceExit() - end -end) \ No newline at end of file diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/lib/CaveBot.lua b/modules/game_bot/default_configs/vBot_4.41/vBot/lib/CaveBot.lua deleted file mode 100644 index e69de29..0000000 diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/lib/Container.lua b/modules/game_bot/default_configs/vBot_4.41/vBot/lib/Container.lua deleted file mode 100644 index 2cfdf21..0000000 --- a/modules/game_bot/default_configs/vBot_4.41/vBot/lib/Container.lua +++ /dev/null @@ -1,159 +0,0 @@ -Container = {} - ---- returns all open containers --- @return table -function Container:getAll() return getContainers() end - ---- gets first open container --- @return userdata -function Container:getFirst() return getContainers()[1] end - ---- gets last open container --- @return userdata -function Container:getLast() return getContainers()[#getContainers()] end - --- returns open containers count --- @return number -function Container:getOpenContainersCount() return #getContainers() end - ---- returns given container item id --- @param container is userdata --- @return number -function Container:getItemId() end - ---- closes all open container windows --- @return void -function Container:closeAllContainers() - for i, container in ipairs(Container:getContainers()) do - container:close() - end -end - ---- checks if container has any free slots --- @param container is userdata --- @return boolean -function Container:isFull(container) - return container:getCapacity() > #container:getItems() -end - ---- returns free slots count in given container --- @param container is userdata --- @return number -function Container:getFreeSlots(container) - return #container:getItems() - container:getCapacity() -end - ---- returns first free slot position --- @param container is userdata --- @return table -function Container:getFreeSlotPosition(container) - return container:getSlotPosition(container:getItems()) -end - ---- opens given container parent --- @param container is userdata --- @return void -function Container:openParent(container) g_game.openParent(container) end - ---- finds open container object based on the id --- @param itemId is number --- @return userdata -function Container:getContainerByItemId(itemId) - - for i, container in ipairs(getContainers()) do - local cId = container:getContainerItem():getId() - if cId == itemId then return container end - end - -end - ---- finds open container object based on the name --- @param name is string --- @return userdata -function Container:getContainerByName(name) - name = name:lower():trim() - - for i, container in ipairs(getContainers()) do - local cName = container:getName():lower() - if cName == name then return container end - end - -end - ---- checks if given container is declared as loot container in TargetBot --- @param container is userdata / integer / string --- @returns boolean -function Container:isLootContainer(container) - local id - - if type(container) == "number" then - id = container - elseif type(container) == "string" then - id = Container:getContainerByName(container) - id = id and id:getContainerItem():getId() - elseif type(container) == "userdata" then - id = container:getContainerItem():getId() - end - - if not id then return false end - - if table.find(vBot.lootConainers, id) then - return true - else - return false - end -end - ---- returns the amount of open loot containers --- @return amount -function Container:getOpenLootContainersCount() - local amount = 0 - - for i, container in ipairs(getContainers()) do - amount = Container:isLootContainer(container) and amount + 1 or amount - end - - return amount -end - ---- opens child container with the same id inside given one --- @param container is userdata --- @param newWindow is boolean --- @return void -function Container:openChild(container, newWindow) - local parentId = container:getContaierItem():getId() - - for i, item in ipairs(container:getItems()) do - local id = item:getId() - - if id == parentId then - return g_game.open(item, newWindow and container or nil) - end - end -end - --- returns all items inside given container --- @param container is userdata --- @return table -function Container:getItems(container) return container:getItems() end - ---- checks if given container helds item with given id --- @param container is userdata --- @param id is number --- @return boolean -function Container:hasItem(container, id) - local isInsideContainer = false - - for i, item in ipairs(container:getItems()) do - if item:getId() == id then - isInsideContainer = true - break - end - end - - return isInsideContainer -end - -function Container:reOpenAllContainers() - -- TODO, extract function from containers.lua -end \ No newline at end of file diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/lib/Map.lua b/modules/game_bot/default_configs/vBot_4.41/vBot/lib/Map.lua deleted file mode 100644 index e69de29..0000000 diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/lib/Player.lua b/modules/game_bot/default_configs/vBot_4.41/vBot/lib/Player.lua deleted file mode 100644 index 39508e5..0000000 --- a/modules/game_bot/default_configs/vBot_4.41/vBot/lib/Player.lua +++ /dev/null @@ -1,100 +0,0 @@ -Player = {} - ---- opens main backpack --- @return void -function Player:openMain() - local back = getBack() - - if back then g_game.open(back) end -end - ---- opens purse/store inbox slot --- @return void -function Player:openPurse() - local purse = getPurse() - - if item then use(purse) end -end - ---- player says certain phrase or sequence --- @param text is string or table --- @param npc is boolean --- @return void -function Player:speak(text, npc, wait) - if type(text) == "string" then - if npc then - return NPC.say(text) - else - return say(text) - end - end - - -- text is table, therefore sequence - local talkDelay = 0 - local globalDelay = storage.extras.talkDelay - - for i, string in ipairs(text) do - - schedule(talkDelay, function() - - if npc then - return NPC.say(string) - else - return say(string) - end - - end) - - talkDelay = talkDelay + globalDelay - end - if wait then delay( talkDelay + globalDelay ) end -end - - -function Player:getId() - return player:getId() -end - -function Player:getName() - return player:getName() -end - -function Player:getTarget() - return g_game.getAttackingCreature() -end - -function Player:getTargetName() - return Player:getTarget():getName() -end - -function Player:getTargetPosition() - return Player:getTarget():getPosition() -end - -function Player:getDistanceFromTarget() - return getDistanceBetween(Player:getPosition(), Player:getTargetPosition()) -end - -function Player:getPosition() - return player:getPosition() -end - -function Player:getLookDirection() - return player:getDirection() -end - -function Player:getLookPosition(range) - local dir = Player:getLookDirection() - local pos = Player:getPosition() - local n = range or 1 - if (dir == NORTH) then - pos.y = pos.y - n - elseif (dir == SOUTH) then - pos.y = pos.y + n - elseif (dir == WEST) then - pos.x = pos.x - n - elseif (dir == EAST) then - pos.x = pos.x + n - end - return pos -end \ No newline at end of file diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/lib/Spectators.lua b/modules/game_bot/default_configs/vBot_4.41/vBot/lib/Spectators.lua deleted file mode 100644 index e69de29..0000000 diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/quiver_manager.lua b/modules/game_bot/default_configs/vBot_4.41/vBot/quiver_manager.lua deleted file mode 100644 index b032f91..0000000 --- a/modules/game_bot/default_configs/vBot_4.41/vBot/quiver_manager.lua +++ /dev/null @@ -1,111 +0,0 @@ -setDefaultTab("Tools") -function quiverManager() - local panelName = "quiverManager" - - local ui = setupUI([[ -Panel - height: 33 - margin-top: 2 - - BotItem - id: BoltsID - anchors.left: parent.left - anchors.top: parent.top - - BotItem - id: ArrowsID - anchors.left: prev.right - anchors.verticalCenter: prev.verticalCenter - - BotSwitch - id: BoltsSwitch - anchors.top: parent.top - anchors.bottom: prev.verticalCenter - anchors.right: parent.right - text: Sort Bolts - - BotSwitch - id: ArrowsSwitch - anchors.top: prev.bottom - anchors.bottom: ArrowsID.bottom - anchors.right: parent.right - text: Sort Arrows - - ]] - ) - ui:setId(panelName) - - if not storage[panelName] then - storage[panelName] = { - arrowsId = 35848, - boltsId = 35849, - bolts = false, - arrows = false - } - end - - local config = storage[panelName] - - ui.BoltsSwitch:setOn(config.bolts) - ui.BoltsSwitch.onClick = function(widget) - config.bolts = not config.bolts - widget:setOn(config.bolts) - end - ui.ArrowsSwitch:setOn(config.arrows) - ui.ArrowsSwitch.onClick = function(widget) - config.arrows = not config.arrows - widget:setOn(config.arrows) - end - ui.BoltsID:setItemId(config.boltsId) - ui.BoltsID.onItemChange = function(widget) - config.boltsId = widget:getItemId() - end - ui.ArrowsID:setItemId(config.arrowsId) - ui.ArrowsID.onItemChange = function(widget) - config.arrowsId = widget:getItemId() - end - - local arrows = {16143, 763, 761, 7365, 3448, 762, 21470, 7364, 14251, 3447, 3449, 15793, 25757, 774, 35901} - local bolts = {6528, 7363, 3450, 16141, 25758, 14252, 3446, 16142, 35902} - - macro(100, function() - local dArrow - local dBolt - for _, c in pairs(getContainers()) do - if not containerIsFull(c) then - if c:getContainerItem():getId() == config.arrowsId and config.arrows then - dArrow = c - elseif c:getContainerItem():getId() == config.boltsId and config.bolts then - dBolt = c - end - end - end - for _, c in pairs(getContainers()) do - if c:getName():lower():find("backpack") or c:getName():lower():find("bag") or c:getName():lower():find("chess") then - for _, i in pairs(c:getItems()) do - -- arrows - if dArrow and config.arrows then - if table.find(arrows, i:getId()) and c ~= dArrow then - return g_game.move(i, dArrow:getSlotPosition(dArrow:getItemsCount()), i:getCount()) - end - end - -- bolts - if dBolt and config.bolts then - if table.find(bolts, i:getId()) and c ~= dBolt then - return g_game.move(i, dBolt:getSlotPosition(dBolt:getItemsCount()), i:getCount()) - end - end - end - end - end - delay(900) - end) -end - -addSeparator() -if voc() == 2 or voc() == 12 then - UI.Label("[[ Quiver Manager ]]") - addSeparator() - quiverManager() - addSeparator() -end diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/version.txt b/modules/game_bot/default_configs/vBot_4.41/vBot/version.txt deleted file mode 100644 index cb83bc1..0000000 --- a/modules/game_bot/default_configs/vBot_4.41/vBot/version.txt +++ /dev/null @@ -1 +0,0 @@ -4.41 \ No newline at end of file diff --git a/modules/game_bot/default_configs/vBot_4.41/_Loader.lua b/modules/game_bot/default_configs/vBot_4.5/_Loader.lua similarity index 98% rename from modules/game_bot/default_configs/vBot_4.41/_Loader.lua rename to modules/game_bot/default_configs/vBot_4.5/_Loader.lua index bb90908..972b0b7 100644 --- a/modules/game_bot/default_configs/vBot_4.41/_Loader.lua +++ b/modules/game_bot/default_configs/vBot_4.5/_Loader.lua @@ -37,6 +37,7 @@ local luaFiles = { "Dropper", "Containers", "quiver_manager", + "quiver_label", "tools", "antiRs", "depot_withdraw", diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/actions.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/actions.lua similarity index 83% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/actions.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/actions.lua index 668ee59..42e4d59 100644 --- a/modules/game_bot/default_configs/vBot_4.41/cavebot/actions.lua +++ b/modules/game_bot/default_configs/vBot_4.5/cavebot/actions.lua @@ -1,7 +1,39 @@ CaveBot.Actions = {} vBot.lastLabel = "" +local oldTibia = g_game.getClientVersion() < 960 + + +-- antistuck f() +local nextPos = nil +local function modPos(dir) + local y = 0 + local x = 0 + + if dir == 0 then + y = -1 + elseif dir == 1 then + x = 1 + elseif dir == 2 then + y = 1 + elseif dir == 3 then + x = -1 + elseif dir == 4 then + y = -1 + x = 1 + elseif dir == 5 then + y = 1 + x = 1 + elseif dir == 6 then + y = 1 + x = -1 + elseif dir == 7 then + y = -1 + x = -1 + end + + return {x, y} +end -local antiTrapTriggered = false -- it adds an action widget to list CaveBot.addAction = function(action, value, focus) action = action:lower() @@ -176,27 +208,37 @@ CaveBot.registerAction("goto", "green", function(value, retries, prev) -- check if there's a path to destination but consider Creatures (attack only if trapped) local path2 = findPath(playerPos, pos, maxDist, { ignoreNonPathable = true, precision = 1 }) if not path2 then - local target = {} -- c = creature, d = distance - for i, spec in pairs(getSpectators()) do - local hppc = spec:getHealthPercent() - if spec:isMonster() and (hppc and hppc > 0) then - local path = findPath(playerPos, spec:getPosition(), 7, { ignoreNonPathable = true, precision = 1 }) - if path then - local dist = getDistanceBetween(pos, spec:getPosition()) - if not target.d or target.d > dist then - target = {c=spec, d=dist} + local foundMonster = false + for i, dir in ipairs(path) do + local dirs = modPos(dir) + 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 + local creature = tile:getCreatures()[1] + 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(), 20, { ignoreNonPathable = true, precision = 1 }) + if path then + foundMonster = true + attack(creature) + g_game.setChaseMode(1) + CaveBot.setOff() + CaveBot.delay(1000) + schedule(1000, function() CaveBot.setOn() end) + end + end end - end end end - if target.c then - if target.c ~= getTarget() then - attack(target.c) - end - g_game.setChaseMode(1) - CaveBot.setOff() - schedule(1000, function() CaveBot.setOn() end) - else + + nextPos = nil -- reset path + if not foundMonster then + foundMonster = false return false -- no other way end end diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/bank.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/bank.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/bank.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/bank.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/buy_supplies.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/buy_supplies.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/buy_supplies.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/buy_supplies.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/cavebot.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/cavebot.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/cavebot.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/cavebot.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/cavebot.otui b/modules/game_bot/default_configs/vBot_4.5/cavebot/cavebot.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/cavebot.otui rename to modules/game_bot/default_configs/vBot_4.5/cavebot/cavebot.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/clear_tile.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/clear_tile.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/clear_tile.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/clear_tile.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/config.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/config.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/config.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/config.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/config.otui b/modules/game_bot/default_configs/vBot_4.5/cavebot/config.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/config.otui rename to modules/game_bot/default_configs/vBot_4.5/cavebot/config.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/d_withdraw.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/d_withdraw.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/d_withdraw.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/d_withdraw.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/depositor.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/depositor.lua similarity index 99% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/depositor.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/depositor.lua index 8f2bb85..eb2d038 100644 --- a/modules/game_bot/default_configs/vBot_4.41/cavebot/depositor.lua +++ b/modules/game_bot/default_configs/vBot_4.5/cavebot/depositor.lua @@ -125,6 +125,7 @@ CaveBot.Extensions.Depositor.setup = function() end -- we gucci + resetCache() return true end) diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/doors.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/doors.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/doors.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/doors.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/editor.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/editor.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/editor.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/editor.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/editor.otui b/modules/game_bot/default_configs/vBot_4.5/cavebot/editor.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/editor.otui rename to modules/game_bot/default_configs/vBot_4.5/cavebot/editor.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/example_functions.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/example_functions.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/example_functions.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/example_functions.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/extension_template.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/extension_template.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/extension_template.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/extension_template.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/imbuing.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/imbuing.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/imbuing.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/imbuing.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/inbox_withdraw.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/inbox_withdraw.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/inbox_withdraw.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/inbox_withdraw.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/lure.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/lure.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/lure.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/lure.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/minimap.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/minimap.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/minimap.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/minimap.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/pos_check.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/pos_check.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/pos_check.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/pos_check.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/recorder.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/recorder.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/recorder.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/recorder.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/sell_all.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/sell_all.lua similarity index 79% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/sell_all.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/sell_all.lua index 3b79bec..579f6cb 100644 --- a/modules/game_bot/default_configs/vBot_4.41/cavebot/sell_all.lua +++ b/modules/game_bot/default_configs/vBot_4.5/cavebot/sell_all.lua @@ -5,15 +5,16 @@ CaveBot.Extensions.SellAll.setup = function() CaveBot.registerAction("SellAll", "#C300FF", function(value, retries) local val = string.split(value, ",") local wait - if #val > 2 then - warn("CaveBot[SellAll]: incorrect sell all value!") - return false + + -- table formatting + for i, v in ipairs(val) do + v = v:trim() + v = tonumber(v) or v + val[i] = v end - if #val == 2 then + if table.find(val, "yes", true) then wait = true - else - wait = false end local npcName = val[1] @@ -46,8 +47,8 @@ CaveBot.Extensions.SellAll.setup = function() sellAllCap = freecap() end - NPC.sellAll(wait) - if #val == 2 then + modules.game_npctrade.sellAll(wait, val) + if wait then print("CaveBot[SellAll]: Sold All with delay") else print("CaveBot[SellAll]: Sold All without delay") @@ -59,7 +60,6 @@ CaveBot.Extensions.SellAll.setup = function() CaveBot.Editor.registerAction("sellall", "sell all", { value="NPC", title="Sell All", - description="Insert NPC name, and 'yes' if sell with delay ", - validation=[[^[^,]+(?:, yes$|, Yes$|, YES$|$)]] + description="NPC Name, 'yes' if sell with delay, exceptions: id separated by comma", }) end \ No newline at end of file diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/supply_check.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/supply_check.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/supply_check.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/supply_check.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/tasker.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/tasker.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/tasker.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/tasker.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/travel.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/travel.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/travel.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/travel.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/walking.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/walking.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/walking.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/walking.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/cavebot/withdraw.lua b/modules/game_bot/default_configs/vBot_4.5/cavebot/withdraw.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/cavebot/withdraw.lua rename to modules/game_bot/default_configs/vBot_4.5/cavebot/withdraw.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/targetbot/creature.lua b/modules/game_bot/default_configs/vBot_4.5/targetbot/creature.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/targetbot/creature.lua rename to modules/game_bot/default_configs/vBot_4.5/targetbot/creature.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/targetbot/creature_attack.lua b/modules/game_bot/default_configs/vBot_4.5/targetbot/creature_attack.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/targetbot/creature_attack.lua rename to modules/game_bot/default_configs/vBot_4.5/targetbot/creature_attack.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/targetbot/creature_editor.lua b/modules/game_bot/default_configs/vBot_4.5/targetbot/creature_editor.lua similarity index 98% rename from modules/game_bot/default_configs/vBot_4.41/targetbot/creature_editor.lua rename to modules/game_bot/default_configs/vBot_4.5/targetbot/creature_editor.lua index cc4c289..37d6d00 100644 --- a/modules/game_bot/default_configs/vBot_4.41/targetbot/creature_editor.lua +++ b/modules/game_bot/default_configs/vBot_4.5/targetbot/creature_editor.lua @@ -102,4 +102,5 @@ TargetBot.Creature.edit = function(config, callback) -- callback = function(newC addCheckBox("diamondArrows", "D-Arrows priority", false) addCheckBox("rePosition", "rePosition to better tile", false) addCheckBox("closeLure", "Close Pulling Monsters", false) + addCheckBox("rpSafe", "RP PVP SAFE - (DA)", false) end diff --git a/modules/game_bot/default_configs/vBot_4.41/targetbot/creature_editor.otui b/modules/game_bot/default_configs/vBot_4.5/targetbot/creature_editor.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/targetbot/creature_editor.otui rename to modules/game_bot/default_configs/vBot_4.5/targetbot/creature_editor.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/targetbot/creature_priority.lua b/modules/game_bot/default_configs/vBot_4.5/targetbot/creature_priority.lua similarity index 69% rename from modules/game_bot/default_configs/vBot_4.41/targetbot/creature_priority.lua rename to modules/game_bot/default_configs/vBot_4.5/targetbot/creature_priority.lua index 266e69a..813d3a6 100644 --- a/modules/game_bot/default_configs/vBot_4.41/targetbot/creature_priority.lua +++ b/modules/game_bot/default_configs/vBot_4.5/targetbot/creature_priority.lua @@ -1,14 +1,20 @@ TargetBot.Creature.calculatePriority = function(creature, config, path) -- config is based on creature_editor local priority = 0 + local currentTarget = g_game.getAttackingCreature() -- extra priority if it's current target - if g_game.getAttackingCreature() == creature then + if currentTarget == creature then priority = priority + 1 end - -- check if distance is fine, if not then attack only if already attacked + -- check if distance is ok if #path > config.maxDistance then + if config.rpSafe then + if currentTarget == creature then + g_game.cancelAttackAndFollow() -- if not, stop attack (pvp safe) + end + end return priority end @@ -27,6 +33,15 @@ TargetBot.Creature.calculatePriority = function(creature, config, path) if config.diamondArrows then local mobCount = getCreaturesInArea(creature:getPosition(), diamondArrowArea, 2) priority = priority + (mobCount * 4) + + if config.rpSafe then + if getCreaturesInArea(creature:getPosition(), largeRuneArea, 3) > 0 then + if currentTarget == creature then + g_game.cancelAttackAndFollow() + end + return 0 -- pvp safe + end + end end -- extra priority for low health diff --git a/modules/game_bot/default_configs/vBot_4.41/targetbot/looting.lua b/modules/game_bot/default_configs/vBot_4.5/targetbot/looting.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/targetbot/looting.lua rename to modules/game_bot/default_configs/vBot_4.5/targetbot/looting.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/targetbot/looting.otui b/modules/game_bot/default_configs/vBot_4.5/targetbot/looting.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/targetbot/looting.otui rename to modules/game_bot/default_configs/vBot_4.5/targetbot/looting.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/targetbot/target.lua b/modules/game_bot/default_configs/vBot_4.5/targetbot/target.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/targetbot/target.lua rename to modules/game_bot/default_configs/vBot_4.5/targetbot/target.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/targetbot/target.otui b/modules/game_bot/default_configs/vBot_4.5/targetbot/target.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/targetbot/target.otui rename to modules/game_bot/default_configs/vBot_4.5/targetbot/target.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/targetbot/walking.lua b/modules/game_bot/default_configs/vBot_4.5/targetbot/walking.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/targetbot/walking.lua rename to modules/game_bot/default_configs/vBot_4.5/targetbot/walking.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/AttackBot.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/AttackBot.lua similarity index 99% rename from modules/game_bot/default_configs/vBot_4.41/vBot/AttackBot.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/AttackBot.lua index 755ed1c..18a9831 100644 --- a/modules/game_bot/default_configs/vBot_4.41/vBot/AttackBot.lua +++ b/modules/game_bot/default_configs/vBot_4.5/vBot/AttackBot.lua @@ -135,14 +135,14 @@ local spellPatterns = { {-- adjacent [[ 111 - 101 + 111 111 ]], -- adjacent SAFE [[ 11111 11111 - 11011 + 11111 11111 11111 ]] diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/AttackBot.otui b/modules/game_bot/default_configs/vBot_4.5/vBot/AttackBot.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/AttackBot.otui rename to modules/game_bot/default_configs/vBot_4.5/vBot/AttackBot.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/BotServer.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/BotServer.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/BotServer.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/BotServer.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/BotServer.otui b/modules/game_bot/default_configs/vBot_4.5/vBot/BotServer.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/BotServer.otui rename to modules/game_bot/default_configs/vBot_4.5/vBot/BotServer.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/Conditions.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/Conditions.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/Conditions.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/Conditions.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/Conditions.otui b/modules/game_bot/default_configs/vBot_4.5/vBot/Conditions.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/Conditions.otui rename to modules/game_bot/default_configs/vBot_4.5/vBot/Conditions.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/Containers.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/Containers.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/Containers.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/Containers.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/Dropper.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/Dropper.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/Dropper.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/Dropper.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/Equipper.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/Equipper.lua similarity index 99% rename from modules/game_bot/default_configs/vBot_4.41/vBot/Equipper.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/Equipper.lua index ea8ec1a..a9442bc 100644 --- a/modules/game_bot/default_configs/vBot_4.41/vBot/Equipper.lua +++ b/modules/game_bot/default_configs/vBot_4.5/vBot/Equipper.lua @@ -51,7 +51,8 @@ local conditions = { -- always add new conditions at the bottom "Player is in protection zone", -- nothing 11 "Players around is more than:", -- spinbox 12 "Players around is less than:", -- spinbox 13 - "TargetBot Danger is Above:" -- spinbox 14 + "TargetBot Danger is Above:", -- spinbox 14 + "Blacklist player in range (sqm)" -- spinbox 15 } local conditionNumber = 1 @@ -577,6 +578,8 @@ local function interpreteCondition(n, v) return getPlayers() < v elseif n == 14 then return TargetBot.Danger() > v and TargetBot.isOn() + elseif n == 15 then + return isBlackListedPlayerInRange(v) end end diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/HealBot.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/HealBot.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/HealBot.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/HealBot.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/HealBot.otui b/modules/game_bot/default_configs/vBot_4.5/vBot/HealBot.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/HealBot.otui rename to modules/game_bot/default_configs/vBot_4.5/vBot/HealBot.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/Sio.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/Sio.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/Sio.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/Sio.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/alarms.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/alarms.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/alarms.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/alarms.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/alarms.otui b/modules/game_bot/default_configs/vBot_4.5/vBot/alarms.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/alarms.otui rename to modules/game_bot/default_configs/vBot_4.5/vBot/alarms.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/analyzer.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/analyzer.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/analyzer.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/analyzer.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/analyzer.otui b/modules/game_bot/default_configs/vBot_4.5/vBot/analyzer.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/analyzer.otui rename to modules/game_bot/default_configs/vBot_4.5/vBot/analyzer.otui diff --git a/modules/game_bot/default_configs/vBot_4.5/vBot/antiRs.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/antiRs.lua new file mode 100644 index 0000000..02160ac --- /dev/null +++ b/modules/game_bot/default_configs/vBot_4.5/vBot/antiRs.lua @@ -0,0 +1,33 @@ +setDefaultTab("Tools") +g_game.cancelAttackAndFollow() + +local frags = 0 +local unequip = false +local m = macro(50, "AntiRS & Msg", function() end) + +function safeExit() + CaveBot.setOff() + TargetBot.setOff() + g_game.cancelAttackAndFollow() + g_game.cancelAttackAndFollow() + g_game.cancelAttackAndFollow() + modules.game_interface.forceExit() +end + +onTextMessage(function(mode, text) + if not m.isOn() then return end + if not text:find("Warning! The murder of") then return end + frags = frags + 1 + if killsToRs() < 6 or frags > 1 then + EquipManager.setOff() + schedule(100, function() + local id = getLeft() and getLeft():getId() + + if id and not unequip then + unequip = true + g_game.equipItemId(id) + end + safeExit() + end) + end +end) \ No newline at end of file diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/cast_food.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/cast_food.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/cast_food.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/cast_food.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/cavebot.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/cavebot.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/cavebot.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/cavebot.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/cavebot_control_panel.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/cavebot_control_panel.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/cavebot_control_panel.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/cavebot_control_panel.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/combo.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/combo.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/combo.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/combo.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/combo.otui b/modules/game_bot/default_configs/vBot_4.5/vBot/combo.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/combo.otui rename to modules/game_bot/default_configs/vBot_4.5/vBot/combo.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/configs.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/configs.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/configs.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/configs.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/depositer_config.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/depositer_config.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/depositer_config.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/depositer_config.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/depositer_config.otui b/modules/game_bot/default_configs/vBot_4.5/vBot/depositer_config.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/depositer_config.otui rename to modules/game_bot/default_configs/vBot_4.5/vBot/depositer_config.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/depot_withdraw.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/depot_withdraw.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/depot_withdraw.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/depot_withdraw.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/eat_food.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/eat_food.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/eat_food.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/eat_food.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/equip.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/equip.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/equip.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/equip.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/equipper.otui b/modules/game_bot/default_configs/vBot_4.5/vBot/equipper.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/equipper.otui rename to modules/game_bot/default_configs/vBot_4.5/vBot/equipper.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/exeta.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/exeta.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/exeta.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/exeta.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/extras.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/extras.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/extras.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/extras.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/extras.otui b/modules/game_bot/default_configs/vBot_4.5/vBot/extras.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/extras.otui rename to modules/game_bot/default_configs/vBot_4.5/vBot/extras.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/hold_target.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/hold_target.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/hold_target.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/hold_target.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/ingame_editor.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/ingame_editor.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/ingame_editor.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/ingame_editor.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/items.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/items.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/items.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/items.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/main.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/main.lua similarity index 97% rename from modules/game_bot/default_configs/vBot_4.41/vBot/main.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/main.lua index 20b0b74..4d21b6c 100644 --- a/modules/game_bot/default_configs/vBot_4.41/vBot/main.lua +++ b/modules/game_bot/default_configs/vBot_4.5/vBot/main.lua @@ -1,4 +1,4 @@ -local version = "4.41" +local version = "4.5" local currentVersion local available = false diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/new_cavebot_lib.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/new_cavebot_lib.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/new_cavebot_lib.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/new_cavebot_lib.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/new_healer.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/new_healer.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/new_healer.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/new_healer.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/new_healer.otui b/modules/game_bot/default_configs/vBot_4.5/vBot/new_healer.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/new_healer.otui rename to modules/game_bot/default_configs/vBot_4.5/vBot/new_healer.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/npc_talk.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/npc_talk.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/npc_talk.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/npc_talk.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/playerlist.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/playerlist.lua similarity index 73% rename from modules/game_bot/default_configs/vBot_4.41/vBot/playerlist.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/playerlist.lua index aad85fe..ea7d2b6 100644 --- a/modules/game_bot/default_configs/vBot_4.41/vBot/playerlist.lua +++ b/modules/game_bot/default_configs/vBot_4.5/vBot/playerlist.lua @@ -183,6 +183,26 @@ if rootWidget then clearCachedPlayers() refreshStatus() end + label.onMouseRelease = function(widget, mousePos, mouseButton) + if mouseButton == 2 then + local child = rootWidget:recursiveGetChildByPos(mousePos) + if child == widget then + local menu = g_ui.createWidget('PopupMenu') + menu:setId("blzMenu") + menu:setGameMenu(true) + menu:addOption('Check Player', function() + local name = widget:getText():gsub(" ", "_") + local link = "https://www.gunzodus.net/character/show/" + g_platform.openUrl(link..name) + end, "") + menu:addOption('Copy Name', function() + g_window.setClipboardText(widget:getText()) + end, "") + menu:display(mousePos) + return true + end + end + end end local tabButton = TabBar.buttonsPanel:getChildren()[v] @@ -215,6 +235,26 @@ if rootWidget then table.remove(playerList, table.find(playerList, name)) label:destroy() end + label.onMouseRelease = function(widget, mousePos, mouseButton) + if mouseButton == 2 then + local child = rootWidget:recursiveGetChildByPos(mousePos) + if child == widget then + local menu = g_ui.createWidget('PopupMenu') + menu:setId("blzMenu") + menu:setGameMenu(true) + menu:addOption('Check Player', function() + local name = widget:getText():gsub(" ", "_") + local link = "https://www.gunzodus.net/character/show/" + g_platform.openUrl(link..name) + end, "") + menu:addOption('Copy Name', function() + g_window.setClipboardText(widget:getText()) + end, "") + menu:display(mousePos) + return true + end + end + end nameTab:setText("") else warn("vBot[PlayerList]: Player ".. name .." is already added!") @@ -245,6 +285,26 @@ if rootWidget then table.remove(playerList, table.find(playerList, name)) label:destroy() end + label.onMouseRelease = function(widget, mousePos, mouseButton) + if mouseButton == 2 then + local child = rootWidget:recursiveGetChildByPos(mousePos) + if child == widget then + local menu = g_ui.createWidget('PopupMenu') + menu:setId("blzMenu") + menu:setGameMenu(true) + menu:addOption('Check Player', function() + local name = widget:getText():gsub(" ", "_") + local link = "https://www.gunzodus.net/character/show/" + g_platform.openUrl(link..name) + end, "") + menu:addOption('Copy Name', function() + g_window.setClipboardText(widget:getText()) + end, "") + menu:display(mousePos) + return true + end + end + end end end @@ -263,10 +323,10 @@ 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 +onPlayerPositionChange(function(x,y) + if x.z ~= y.z then + schedule(20, function() + refreshStatus() + end) + end +end) \ No newline at end of file diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/playerlist.otui b/modules/game_bot/default_configs/vBot_4.5/vBot/playerlist.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/playerlist.otui rename to modules/game_bot/default_configs/vBot_4.5/vBot/playerlist.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/pushmax.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/pushmax.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/pushmax.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/pushmax.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/pushmax.otui b/modules/game_bot/default_configs/vBot_4.5/vBot/pushmax.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/pushmax.otui rename to modules/game_bot/default_configs/vBot_4.5/vBot/pushmax.otui diff --git a/modules/game_bot/default_configs/vBot_4.5/vBot/quiver_label.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/quiver_label.lua new file mode 100644 index 0000000..671d726 --- /dev/null +++ b/modules/game_bot/default_configs/vBot_4.5/vBot/quiver_label.lua @@ -0,0 +1,58 @@ +local quiverSlot = modules.game_inventory.inventoryWindow:recursiveGetChildById('slot5') +local label = quiverSlot.count + +label = label or g_ui.loadUIFromString([[ +Label + id: count + color: #bfbfbf + font: verdana-11px-rounded + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + text-align: right + margin-right: 3 + margin-left: 3 + text: +]], quiverSlot) + + +function getQuiverAmount() + -- old tibia + if g_game.getClientVersion() < 1000 then return end + + + local isQuiverEquipped = getRight() and getRight():isContainer() or false + local quiver = isQuiverEquipped and getContainerByItem(getRight():getId()) + local count = 0 + + if quiver then + for i, item in ipairs(quiver:getItems()) do + count = count + item:getCount() + end + else + return label:setText("") + end + + return label:setText(count) +end +getQuiverAmount() + +onContainerOpen(function(container, previousContainer) + getQuiverAmount() +end) + +onContainerClose(function(container) + getQuiverAmount() +end) + +onAddItem(function(container, slot, item, oldItem) + getQuiverAmount() +end) + +onRemoveItem(function(container, slot, item) + getQuiverAmount() +end) + +onContainerUpdateItem(function(container, slot, item, oldItem) + getQuiverAmount() +end) \ No newline at end of file diff --git a/modules/game_bot/default_configs/vBot_4.5/vBot/quiver_manager.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/quiver_manager.lua new file mode 100644 index 0000000..8c629cd --- /dev/null +++ b/modules/game_bot/default_configs/vBot_4.5/vBot/quiver_manager.lua @@ -0,0 +1,90 @@ +if voc() == 2 or voc() == 12 then + local bows = { 3350, 31581, 27455, 8027, 20082, 36664, 7438, 28718, 36665, 14246, 19362, 35518, 34150, 29417, 9378, 16164, 22866, 12733, 8029, 20083, 20084, 8026, 8028, 34088} + local xbows = { 30393, 3349, 27456, 20085, 16163, 5947, 8021, 14247, 22867, 8023, 22711, 19356, 20086, 20087, 34089} + local arrows = { 16143, 763, 761, 7365, 3448, 762, 21470, 7364, 14251, 3447, 3449, 15793, 25757, 774, 35901 } + local bolts = { 6528, 7363, 3450, 16141, 25758, 14252, 3446, 16142, 35902 } + local hold = false + + onContainerOpen(function(container, previousContainer) + hold = false + end) + + onContainerClose(function(container) + hold = false + end) + + onAddItem(function(container, slot, item, oldItem) + hold = false + end) + + onRemoveItem(function(container, slot, item) + hold = false + end) + + onContainerUpdateItem(function(container, slot, item, oldItem) + hold = false + end) + + + + local function manageQuiver(isBowEquipped, quiverContainer) + local ammo = isBowEquipped and arrows or bolts + local dest = nil + local containers = getContainers() + for i, container in ipairs(containers) do + if container ~= quiverContainer and not containerIsFull(container) then + if container:getName():lower():find("backpack") or container:getName():lower():find("bag") or container:getName():lower():find("chess") then + dest = container + end + end + end + + -- clearing + if dest then + for i, item in ipairs(quiverContainer:getItems()) do + if not table.find(ammo, item:getId()) then + local pos = dest:getSlotPosition(dest:getItemsCount()) + return g_game.move(item, pos, item:getCount()) + end + end + end + + if not containerIsFull(quiverContainer) then + for i, container in ipairs(containers) do + if container ~= quiverContainer then + for j, item in ipairs(container:getItems()) do + if table.find(ammo, item:getId()) then + local pos = quiverContainer:getSlotPosition(quiverContainer:getItemsCount()) + return g_game.move(item, pos, item:getCount()) + end + end + end + end + end + return true + end + + UI.Separator() + macro(100, "Quiver Manager", function() + if hold then return end -- do nothing if nothing to do + local hand = getLeft() and getLeft():getId() + local quiverEquipped = getRight() and getRight():isContainer() + + if not hand then return end + if not quiverEquipped then return end + + local quiverContainer = getContainerByItem(getRight():getId()) + if not quiverContainer then return end + + local isBowEquipped = getLeft() and table.find(bows, hand) and true or false + if not isBowEquipped then + if not table.find(xbows, hand) then + return -- neither bow and xbow is equipped + end + end + + if manageQuiver(isBowEquipped, quiverContainer) then -- if true then it didn't do anything + hold = true + end + end) +end \ No newline at end of file diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/siolist.otui b/modules/game_bot/default_configs/vBot_4.5/vBot/siolist.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/siolist.otui rename to modules/game_bot/default_configs/vBot_4.5/vBot/siolist.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/spy_level.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/spy_level.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/spy_level.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/spy_level.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/supplies.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/supplies.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/supplies.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/supplies.lua diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/supplies.otui b/modules/game_bot/default_configs/vBot_4.5/vBot/supplies.otui similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/supplies.otui rename to modules/game_bot/default_configs/vBot_4.5/vBot/supplies.otui diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/tools.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/tools.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/tools.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/tools.lua diff --git a/modules/game_bot/default_configs/vBot_4.5/vBot/version.txt b/modules/game_bot/default_configs/vBot_4.5/vBot/version.txt new file mode 100644 index 0000000..958d30d --- /dev/null +++ b/modules/game_bot/default_configs/vBot_4.5/vBot/version.txt @@ -0,0 +1 @@ +4.5 \ No newline at end of file diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/vlib.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/vlib.lua similarity index 99% rename from modules/game_bot/default_configs/vBot_4.41/vBot/vlib.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/vlib.lua index bf1fc55..d92c57f 100644 --- a/modules/game_bot/default_configs/vBot_4.41/vBot/vlib.lua +++ b/modules/game_bot/default_configs/vBot_4.5/vBot/vlib.lua @@ -428,8 +428,7 @@ function isFriend(c) if not p then return false end if p:isLocalPlayer() then return true end if p:isPlayer() then - if ((p:getShield() >= 3 and p:getShield() <= 10) or p:getEmblem() == - 1) then + if p:isPartyMember() then CachedFriends[c] = true CachedFriends[p] = true return true @@ -658,8 +657,7 @@ function getPlayers(range, multifloor) for _, spec in pairs(getSpectators(multifloor)) do specs = not spec:isLocalPlayer() and spec:isPlayer() and distanceFromPlayer(spec:getPosition()) <= range and - not ((spec:getShield() >= 3 and spec:getShield() <= 10) or - spec:getEmblem() == 1) and specs + 1 or specs; + not (spec:isPartyMember() or spec:getEmblem() == 1) and specs + 1 or specs; end return specs; end diff --git a/modules/game_bot/default_configs/vBot_4.41/vBot/xeno_menu.lua b/modules/game_bot/default_configs/vBot_4.5/vBot/xeno_menu.lua similarity index 100% rename from modules/game_bot/default_configs/vBot_4.41/vBot/xeno_menu.lua rename to modules/game_bot/default_configs/vBot_4.5/vBot/xeno_menu.lua diff --git a/modules/game_npctrade/npctrade.lua b/modules/game_npctrade/npctrade.lua index 0562489..d271ffe 100644 --- a/modules/game_npctrade/npctrade.lua +++ b/modules/game_npctrade/npctrade.lua @@ -557,20 +557,29 @@ function getMaxAmount() return 100 end -function sellAll(delayed) +function sellAll(delayed, exceptions) + -- backward support + if type(delayed) == "table" then + exceptions = delayed + delayed = false + end + exceptions = exceptions or {} removeEvent(sellAllWithDelayEvent) local queue = {} for _,entry in ipairs(tradeItems[SELL]) do - local sellQuantity = getSellQuantity(entry.ptr) - while sellQuantity > 0 do - local maxAmount = math.min(sellQuantity, getMaxAmount()) - if delayed then - g_game.sellItem(entry.ptr, maxAmount, ignoreEquipped:isChecked()) - sellAllWithDelayEvent = scheduleEvent(function() sellAll(true) end, 1100) - return + local id = entry.ptr:getId() + if not table.find(exceptions, id) then + local sellQuantity = getSellQuantity(entry.ptr) + while sellQuantity > 0 do + local maxAmount = math.min(sellQuantity, getMaxAmount()) + if delayed then + g_game.sellItem(entry.ptr, maxAmount, ignoreEquipped:isChecked()) + sellAllWithDelayEvent = scheduleEvent(function() sellAll(true) end, 1100) + return + end + table.insert(queue, {entry.ptr, maxAmount, ignoreEquipped:isChecked()}) + sellQuantity = sellQuantity - maxAmount end - table.insert(queue, {entry.ptr, maxAmount, ignoreEquipped:isChecked()}) - sellQuantity = sellQuantity - maxAmount end end for _, entry in ipairs(queue) do diff --git a/modules/game_outfit/outfit.lua b/modules/game_outfit/outfit.lua index 4031017..34843fd 100644 --- a/modules/game_outfit/outfit.lua +++ b/modules/game_outfit/outfit.lua @@ -1,29 +1,78 @@ -ADDON_SETS = { - [1] = {1}, - [2] = {2}, - [3] = {1, 2}, - [4] = {3}, - [5] = {1, 3}, - [6] = {2, 3}, - [7] = {1, 2, 3} -} +local loadLocalShaders = false +appearanceOptions = {} +configOptions = {} +previewOptions = {} +previewDir = 2 +filterText = "" +currentCategory = "outfit" outfitWindow = nil -outfit = nil -outfits = nil outfitCreatureBox = nil -currentOutfit = 1 - -addons = nil currentColorBox = nil currentClotheButtonBox = nil colorBoxes = {} +dataTables = { + outfits = {}, + mounts = {}, + auras = {}, + wings = {}, + shaders = {}, + manaBar = {}, + healthBar = {} +} -mount = nil -mounts = nil -mountCreatureBox = nil -currentMount = 1 -ignoreNextOutfitWindow = 0 +math.randomseed(os.time()) + +-- take local shaders, won't work if server does not support it +localShaders = {} +local shaderFiles = g_resources.listDirectoryFiles("/data/shaders/", true, false) +for i, file in ipairs(shaderFiles) do + local name = file:split(".")[1]:trim():lower() + name = name:gsub("/data/shaders//","") + name = name:gsub("_fragment","") + name = name:gsub("_vertex","") + if name:find("outfit") and not table.find(localShaders, name) then + table.insert(localShaders, name) + end +end + +function setupTables() + configOptions = { + + { id="addon1", text="Addon 1", checked=false, enabled=g_game.getClientVersion()>=780 }, + { id="addon2", text="Addon 2", checked=false, enabled=g_game.getClientVersion()>=780 }, + { id="mount", text="Mount", checked=false, enabled=g_game.getFeature(GamePlayerMounts) }, + { id="wings", text="Wings", checked=false, enabled=g_game.getFeature(GameWingsAndAura) }, + { id="aura", text="Aura", checked=false, enabled=g_game.getFeature(GameWingsAndAura) }, + { id="shader", text="Shaders", checked=false, enabled=g_game.getFeature(GameOutfitShaders) or loadLocalShaders and #localShaders > 0 }, + { id="healtbar", text="Health Bars", checked=false, enabled=g_game.getFeature(GameHealthInfoBackground) }, + { id="manabar", text="Mana Bars", checked=false, enabled=g_game.getFeature(GameHealthInfoBackground) }, + + } + appearanceOptions = { + + { id="presetCat", text="Preset", enabled=true }, + { id="outfitCat", text="Outfit", enabled=true }, + { id="mountCat", text="Mount", enabled=g_game.getFeature(GamePlayerMounts) }, + { id="wingsCat", text="Wings", enabled=g_game.getFeature(GameWingsAndAura) }, + { id="auraCat", text="Aura", enabled=g_game.getFeature(GameWingsAndAura) }, + { id="shaderCat", text="Shader", enabled=g_game.getFeature(GameOutfitShaders) or loadLocalShaders and #localShaders > 0 }, + { id="healtbarCat", text="Health Bars", enabled=g_game.getFeature(GameHealthInfoBackground) }, + { id="manabarCat", text="Mana Bars", enabled=g_game.getFeature(GameHealthInfoBackground) }, + + } + previewOptions = { + + { id="move", text="Movement", checked=false, enabled=true }, + { id="showOutfit", text="Outfit", checked=true, enabled=true }, + { id="showMount", text="Mount", checked=false, enabled=g_game.getFeature(GamePlayerMounts) }, + { id="showWings", text="Wings", checked=false, enabled=g_game.getFeature(GameWingsAndAura) }, + { id="showAura", text="Aura", checked=false, enabled=g_game.getFeature(GameWingsAndAura) }, + { id="showShader", text="Shader", checked=false, enabled=g_game.getFeature(GameOutfitShaders) or loadLocalShaders and #localShaders > 0 }, + + } + +end function init() connect( @@ -46,287 +95,422 @@ function terminate() destroy() end -function updateMount() - if table.empty(mounts) or not mount then - return - end - local nameMountWidget = outfitWindow:getChildById("mountName") - nameMountWidget:setText(mounts[currentMount][2]) +function onFilterList(text) + if not outfitWindow then return end + filterText = text:lower() - mount.type = mounts[currentMount][1] - mountCreature:setOutfit(mount) + refreshVisiblePreviews() end -function setupSelector(widget, id, outfit, list) - widget:setId(id) - if id == "healthBar" or id == "manaBar" then - widget.title:setText(id == "healthBar" and "Health Bar" or "Mana Bar") - table.insert(list, 1, {0, "-"}) - else - widget.title:setText(id:gsub("^%l", string.upper)) - if id ~= "type" or #list == 0 then - table.insert(list, 1, {0, "-"}) - end - end +function clearFilterText() + if not outfitWindow then return end - local pos = 1 - for i, o in pairs(list) do - if (id == "shader" and outfit[id] == o[2]) or outfit[id] == o[1] then - pos = i - end - end - if list[pos] then - widget.outfit = list[pos] - if id == "shader" then - widget.creature:setOutfit( - { - shader = list[pos][2] - } - ) - elseif id == "healthBar" then - if pos ~= 1 then - widget.bar:setImageSource(g_healthBars.getHealthBarPath(pos - 1)) - else - widget.bar:setImageSource("") - end - widget.bar.selected = pos - 1 - elseif id == "manaBar" then - if pos ~= 1 then - widget.bar:setImageSource(g_healthBars.getManaBarPath(pos - 1)) - else - widget.bar:setImageSource("") - end - widget.bar.selected = pos - 1 - else - widget.creature:setOutfit( - { - type = list[pos][1] - } - ) - end - widget.label:setText(list[pos][2]) - end - - widget.prevButton.onClick = function() - if pos == 1 then - pos = #list - else - pos = pos - 1 - end - if id == "healthBar" or id == "manaBar" then - if id == "healthBar" then - if pos ~= 1 then - widget.bar:setImageSource(g_healthBars.getHealthBarPath(pos - 1)) - else - widget.bar:setImageSource("") - end - elseif id == "manaBar" then - if pos ~= 1 then - widget.bar:setImageSource(g_healthBars.getManaBarPath(pos - 1)) - else - widget.bar:setImageSource("") - end - end - widget.bar.selected = pos - 1 - widget.label:setText(list[pos][2]) - else - local outfit = widget.creature:getOutfit() - if id == "shader" then - outfit.shader = list[pos][2] - else - outfit.type = list[pos][1] - end - widget.outfit = list[pos] - widget.creature:setOutfit(outfit) - widget.label:setText(list[pos][2]) - updateOutfit() - end - end - - widget.nextButton.onClick = function() - if pos == #list then - pos = 1 - else - pos = pos + 1 - end - if id == "healthBar" or id == "manaBar" then - if id == "healthBar" then - if pos ~= 1 then - widget.bar:setImageSource(g_healthBars.getHealthBarPath(pos - 1)) - else - widget.bar:setImageSource("") - end - elseif id == "manaBar" then - if pos ~= 1 then - widget.bar:setImageSource(g_healthBars.getManaBarPath(pos - 1)) - else - widget.bar:setImageSource("") - end - end - widget.bar.selected = pos - 1 - widget.label:setText(list[pos][2]) - else - local outfit = widget.creature:getOutfit() - if id == "shader" then - outfit.shader = list[pos][2] - else - outfit.type = list[pos][1] - end - widget.outfit = list[pos] - widget.creature:setOutfit(outfit) - widget.label:setText(list[pos][2]) - updateOutfit() - end - end - return widget + outfitWindow.search.filterWindow:setText('') end -function create(currentOutfit, outfitList, mountList, wingList, auraList, shaderList, hpBarList, manaBarList) - if ignoreNextOutfitWindow and g_clock.millis() < ignoreNextOutfitWindow + 1000 then - return - end - if outfitWindow and not outfitWindow:isHidden() then - return - end +function onPresetButtonPress(key) + local widget - destroy() - - outfitWindow = g_ui.displayUI("outfitwindow") - - setupSelector(outfitWindow.type, "type", currentOutfit, outfitList) - - local outfit = outfitWindow.type.creature:getOutfit() - outfit.head = currentOutfit.head - outfit.body = currentOutfit.body - outfit.legs = currentOutfit.legs - outfit.feet = currentOutfit.feet - outfitWindow.type.creature:setOutfit(outfit) - - if g_game.getFeature(GamePlayerMounts) then - setupSelector(g_ui.createWidget("OutfitSelectorPanel", outfitWindow.extensions), "mount", currentOutfit, mountList) - end - if g_game.getFeature(GameWingsAndAura) then - setupSelector(g_ui.createWidget("OutfitSelectorPanel", outfitWindow.extensions), "wings", currentOutfit, wingList) - setupSelector(g_ui.createWidget("OutfitSelectorPanel", outfitWindow.extensions), "aura", currentOutfit, auraList) - end - if g_game.getFeature(GameOutfitShaders) then - setupSelector(g_ui.createWidget("OutfitSelectorPanel", outfitWindow.extensions), "shader", currentOutfit, shaderList) - end - - if g_game.getFeature(GameHealthInfoBackground) then - setupSelector(g_ui.createWidget("BarSelectorPanel", outfitWindow.extensions), "healthBar", currentOutfit, hpBarList) - setupSelector(g_ui.createWidget("BarSelectorPanel", outfitWindow.extensions), "manaBar", currentOutfit, manaBarList) - end - - if not outfitWindow.extensions:getFirstChild() then - outfitWindow:setHeight(outfitWindow:getHeight() - 128) - end - - for j = 0, 6 do - for i = 0, 18 do - local colorBox = g_ui.createWidget("ColorBox", outfitWindow.colorBoxPanel) - local outfitColor = getOutfitColor(j * 19 + i) - colorBox:setImageColor(outfitColor) - colorBox:setId("colorBox" .. j * 19 + i) - colorBox.colorId = j * 19 + i - - if j * 19 + i == currentOutfit.head then - currentColorBox = colorBox - colorBox:setChecked(true) + for i, child in ipairs(outfitWindow.list:getChildren()) do + if child.catalog == "preset" then + if child:isChecked() then + widget = child + break end - colorBox.onCheckChange = onColorCheckChange - colorBoxes[#colorBoxes + 1] = colorBox end end - -- set addons - addons = { - [1] = {widget = outfitWindow:getChildById("addon1"), value = 1}, - [2] = {widget = outfitWindow:getChildById("addon2"), value = 2}, - [3] = {widget = outfitWindow:getChildById("addon3"), value = 4} + if key == "delete" then + if widget then + widget:destroy() + end + + elseif key == "new" then + local outfit = getOutfitFromCurrentChecks(1) + outfit.mount = 0 + local mount = getOutfitFromCurrentChecks().mount + local name = "new preset" + + local widget = g_ui.createWidget("LargePreviewTile", outfitWindow.list) + widget.catalog = "preset" + widget:setId("preset."..outfit.type..name) + widget.outfit:setOutfit(outfit) + if mount then + widget.mount:setOutfit({ + type = mount + }) + end + widget.title:setText(name) + + + elseif key == "rename" then + if widget then + modules.client_textedit.show(widget.title, {title="Rename Preset", placeholder=widget.title:getText()}) + end + + + elseif key == "save" then + if widget then + local data = getOutfitFromCurrentChecks() + local outfit = data.outfit + local mount = data.mount + + widget.outfit:setOutfit(outfit) + if mount then + widget.mount:setOutfit(mount) + end + save() + end + end +end + +function onOptionChange(key, checked, widget) + if not outfitWindow then return end + local creature = outfitWindow.preview.creaturePanel.creature + + if key:find("show") or key:find("addon") then + refreshPreview() + end + + if key:find("Cat") then + currentCategory = string.sub(key, 1, key:len()-3) + + -- set filter window title + outfitWindow.search.title:setText("Filter "..currentCategory.."s") + + if key == "presetCat" then + outfitWindow.list:getLayout():setNumColumns(1) + outfitWindow.list:getLayout():setCellSize({height = 100, width = 217}) + outfitWindow.search:setVisible(false) + outfitWindow.preset:setVisible(true) + else + outfitWindow.list:getLayout():setNumColumns(2) + outfitWindow.list:getLayout():setCellSize({height = 100, width = 106}) + outfitWindow.search:setVisible(true) + outfitWindow.preset:setVisible(false) + end + + -- set correct checks + for i, child in ipairs(widget:getParent():getParent():getChildren()) do + child.checkBox:setChecked(widget==child.checkBox) + end + + refreshVisiblePreviews() + + + elseif key == "move" then + creature:setAnimate(checked) + + + elseif key == "showOutfit" or key == "showMount" then + local options = outfitWindow.preview.options + local showOutfit = options.showOutfit + local showMount = options.showMount + showOutfit = showOutfit and showOutfit.check:isChecked() + showMount = showMount and showMount.check:isChecked() + + if not showMount and not showOutfit then + options.move.check:setChecked(false) + creature:setAnimate(false) + options.move:disable() + else + options.move:enable() + end + + end + + +end + +function refreshVisiblePreviews() + if not outfitWindow then return end + + for i, child in ipairs(outfitWindow.list:getChildren()) do + local id = child:getId() + local catalog = string.split(id, ".")[1] + local name = string.split(id, ".")[2] + local show = catalog == currentCategory and name:find(filterText) + child:setVisible(show) + end +end + +function getOutfitFromCurrentChecks(returnVal) + returnVal = returnVal or 0 + + -- 0 - return raw table + -- 1 - return combined outfit according to configure checks + -- 2 - return combined outfit according to preview checks + if not outfitWindow then return end + + local data = { + cleanOutfit = {}, -- outfit.type & colors + mount = 0, -- outfit.mount + addons = 0, -- outfit.addons + shader = "", -- outfit.shader + wings = 0, -- outfit.wings + aura = 0, -- outfit.aura + healthbar = "", -- outfit.healthbar + manabar = "" -- outfit.manabar } - for _, addon in pairs(addons) do - addon.widget.onCheckChange = function(self) - onAddonCheckChange(self, addon.value) + local combinedOutfit + local previewOutfit + local options = outfitWindow.config.options + local addon1 = options.addon1 + local addon2 = options.addon2 + addon1 = addon1 and addon1.check:isChecked() + addon2 = addon2 and addon2.check:isChecked() + local showAddons = addon1 and addon2 and 3 or addon2 and 2 or addon1 and 1 or 0 + local showMount = g_game.getFeature(GamePlayerMounts) and options.mount and options.mount.check:isChecked() + local showShader = (g_game.getFeature(GameOutfitShaders) or #localShaders > 0) and options.shader and options.shader.check:isChecked() + local showHealthBar = g_game.getFeature(GameHealthInfoBackground) and options.healthbar and options.healthbar:isChecked() + local showManaBar = g_game.getFeature(GameHealthInfoBackground) and options.manabar and options.manabar:isChecked() + local showAura = g_game.getFeature(GameWingsAndAura) and options.aura and options.aura:isChecked() + local showWings = g_game.getFeature(GameWingsAndAura) and options.wings and options.wings:isChecked() + + for i, child in ipairs(outfitWindow.list:getChildren()) do + if child:isChecked() and child.catalog ~= "preset" then + local catalog = child.catalog + local outfit = child.creature:getOutfit() + if catalog == "outfit" then -- get type and colors + data.cleanOutfit = outfit + elseif catalog == "mount" then + data[catalog] = outfit.type + elseif catalog == "shader" then + data[catalog] = child.shader + elseif catalog == "wings" then + data[catalog] = outfit.type + elseif catalog == "aura" then + data[catalog] = outfit.aura + elseif catalog == "healthbar" then + local id = string.split(child:getId(), " ")[2] + data[catalog] = id + elseif catalog == "manabar" then + local id = string.split(child:getId(), " ")[2] + data[catalog] = id + end end end + data.addons = showAddons - if currentOutfit.addons and currentOutfit.addons > 0 then - for _, i in pairs(ADDON_SETS[currentOutfit.addons]) do - addons[i].widget:setChecked(true) - end + if returnVal == 1 then + combinedOutfit = data.cleanOutfit + combinedOutfit.addons = showAddons + combinedOutfit.mount = showMount and data.mount > 0 and data.mount or nil + combinedOutfit.shader = showShader and data.shader:len() > 0 and data.shader or nil + combinedOutfit.wings = showWings and data.wings > 0 and data.wings or nil + combinedOutfit.aura = showAura and data.aura > 0 and data.aura or nil + combinedOutfit.healthbar = showHealthBar and data.healthbar:len() > 0 and data.healthbar or nil + combinedOutfit.manabar = showManaBar and data.manabar:len() > 0 and data.manabar or nil + elseif returnVal == 2 then + previewOutfit = data.cleanOutfit + previewOutfit.addons = showAddons + previewOutfit.mount = data.mount > 0 and data.mount or nil + previewOutfit.shader = data.shader:len() > 0 and data.shader or nil + previewOutfit.wings = data.wings > 0 and data.wings or nil + previewOutfit.aura = data.aura > 0 and data.aura or nil + previewOutfit.healthbar = data.healthbar:len() > 0 and data.healthbar or nil + previewOutfit.manabar = data.manabar:len() > 0 and data.manabar or nil end - -- hook outfit sections - currentClotheButtonBox = outfitWindow.head - outfitWindow.head.onCheckChange = onClotheCheckChange - outfitWindow.primary.onCheckChange = onClotheCheckChange - outfitWindow.secondary.onCheckChange = onClotheCheckChange - outfitWindow.detail.onCheckChange = onClotheCheckChange - - updateOutfit() -end - -function destroy() - if outfitWindow then - outfitWindow:destroy() - outfitWindow = nil - currentColorBox = nil - currentClotheButtonBox = nil - colorBoxes = {} - addons = {} + -- TODO: test & most likely fix all custom features (wings, auras, shaders, bars) + if returnVal == 0 then + return data -- raw + elseif returnVal == 1 then + return combinedOutfit -- combined @ configure + else + return previewOutfit -- combined @ preview end end function randomize() local outfitTemplate = { - outfitWindow.head, - outfitWindow.primary, - outfitWindow.secondary, - outfitWindow.detail + outfitWindow.appearance.parts.head, + outfitWindow.appearance.parts.primary, + outfitWindow.appearance.parts.secondary, + outfitWindow.appearance.parts.detail } for i = 1, #outfitTemplate do + local n = math.random(#colorBoxes) + outfitTemplate[i]:setChecked(true) - colorBoxes[math.random(1, #colorBoxes)]:setChecked(true) + colorBoxes[n]:setChecked(true) outfitTemplate[i]:setChecked(false) end outfitTemplate[1]:setChecked(true) end -function accept() - local outfit = outfitWindow.type.creature:getOutfit() - for i, child in pairs(outfitWindow.extensions:getChildren()) do - if child:getId() == "healthBar" or child:getId() == "manaBar" then - outfit[child:getId()] = child.bar.selected - else - if child.creature:getCreature() then - if child:getId() == "shader" then - outfit[child:getId()] = child.creature:getOutfit().shader - else - outfit[child:getId()] = child.creature:getOutfit().type - end - end +function onElementSelect(widget) + if not outfitWindow then return end + local catalog = string.split(widget:getId(), ".")[1] + + -- apply correct check + for i, child in ipairs(widget:getParent():getChildren()) do + -- there can be few items checked, but only one per catalog + if child.catalog == widget.catalog then + child:setChecked(widget==child) end end - g_game.changeOutfit(outfit) - destroy() + if catalog == "outfit" then + local outfit = widget.creature:getOutfit() + local addons = outfit.addons + + local addon1 = outfitWindow.config.options.addon1.check + local addon2 = outfitWindow.config.options.addon2.check + + addon1:setChecked(addons == 1 or addons == 3) + addon2:setChecked(addons > 1) + + addon1:setEnabled(addons == 1 or addons == 3) + addon2:setEnabled(addons > 1) + + + refreshPreview() + setCategoryDescription(catalog, outfit.type) + elseif catalog == "mount" then + local outfit = widget.creature:getOutfit() + + refreshPreview() + setCategoryDescription(catalog, outfit.type) + + elseif catalog == "preset" then + local outfit = widget.outfit:getOutfit().type + local mount = widget.mount:getOutfit().type + + for i, child in ipairs(outfitWindow.list:getChildren()) do + if child.catalog == "outfit" then + if child.creature:getOutfit().type == outfit then + onElementSelect(child) + end + end + if child.catalog == "mount" then + if child.creature:getOutfit().type == mount then + onElementSelect(child) + end + end + end + + setCategoryDescription(catalog, widget.title:getText()) + refreshPreview() + + elseif catalog == "shader" then + local shader = widget.creature:getOutfit().shader + + setCategoryDescription(catalog, widget.title:getText()) + refreshPreview() + + elseif catalog == "healthbar" then + + + + elseif catalog == "manabar" then + + + elseif catalog == "wings" then + + + end end -function onAddonCheckChange(addon, value) - local outfit = outfitWindow.type.creature:getOutfit() - if addon:isChecked() then - outfit.addons = outfit.addons + value +function refreshPreview() + if not outfitWindow then return end + local creature = outfitWindow.preview.creaturePanel.creature + local options = outfitWindow.preview.options + + local outfit = getOutfitFromCurrentChecks(2) + + + local showOutfit = options.showOutfit and options.showOutfit.check:isChecked() + local showMount = g_game.getFeature(GamePlayerMounts) and options.showMount and options.showMount.check:isChecked() + local showShader = (g_game.getFeature(GameOutfitShaders) or #localShaders > 0) and options.showShader and options.showShader.check:isChecked() + local showWings = g_game.getFeature(GameWingsAndAura) and options.showWings and options.showWings.check:isChecked() + local showAura = g_game.getFeature(GameWingsAndAura) and options.showAura and options.showAura.check:isChecked() + + if showOutfit then + outfit.mount = not showMount and 0 or outfit.mount + -- those things can only be displaed when showOutfit + outfit.shader = not showShader and "" or outfit.shader + outfit.wings = not showWings and 0 or outfit.wings + outfit.aura = not showAura and 0 or outfit.aura + elseif showMount then + outfit = {type = outfit.mount} else - outfit.addons = outfit.addons - value + return creature:setOutfit({}) + end + + creature:setOutfit(outfit) +end + +function rotatePreview(side) + if not outfitWindow then return end + local creature = outfitWindow.preview.creaturePanel.creature + previewDir = side == "rotateLeft" and (previewDir + 1) or (previewDir - 1) + previewDir = previewDir % 4 + + creature:setDirection(previewDir) +end + +function setCategoryDescription(id, key) + if not outfitWindow then return end + + -- id can be widgetId so extract id + local type = string.split(id, ".")[1] -- ie. outfit + local tableKey = type.."s" -- ie. outfits + local newId = type.."Cat" -- ie. outfitCat + local table = dataTables[tableKey] + local widget = outfitWindow.appearance.categories[newId] + + widget = widget and widget.description + + if id == "preset" or id == "shader" then + return widget:setText(key) + end + + -- something went wrong + if not table or not widget then return end + + for i, data in ipairs(table) do + if data[1] == key then + return widget:setText(data[2]) + end + end + + widget:setText('-') +end + +function onClotheCheckChange(clotheButtonBox) + if not outfitWindow then return end + local outfit = outfitWindow.preview.creaturePanel.creature:getOutfit() + if clotheButtonBox == currentClotheButtonBox then + clotheButtonBox.onCheckChange = nil + clotheButtonBox:setChecked(true) + clotheButtonBox.onCheckChange = onClotheCheckChange + else + currentClotheButtonBox.onCheckChange = nil + currentClotheButtonBox:setChecked(false) + currentClotheButtonBox.onCheckChange = onClotheCheckChange + + currentClotheButtonBox = clotheButtonBox + + local colorId = 0 + if currentClotheButtonBox:getId() == "head" then + colorId = outfit.head + elseif currentClotheButtonBox:getId() == "primary" then + colorId = outfit.body + elseif currentClotheButtonBox:getId() == "secondary" then + colorId = outfit.legs + elseif currentClotheButtonBox:getId() == "detail" then + colorId = outfit.feet + end + outfitWindow.appearance.colorBoxPanel["colorBox" .. colorId]:setChecked(true) end - outfitWindow.type.creature:setOutfit(outfit) end function onColorCheckChange(colorBox) - local outfit = outfitWindow.type.creature:getOutfit() + if not outfitWindow then return end + local outfit = outfitWindow.preview.creaturePanel.creature:getOutfit() if colorBox == currentColorBox then colorBox.onCheckChange = nil colorBox:setChecked(true) @@ -349,67 +533,423 @@ function onColorCheckChange(colorBox) elseif currentClotheButtonBox:getId() == "detail" then outfit.feet = currentColorBox.colorId end - outfitWindow.type.creature:setOutfit(outfit) + outfitWindow.preview.creaturePanel.creature:setOutfit(outfit) + updateOutfits() + refreshPreview() end end -function onClotheCheckChange(clotheButtonBox) - local outfit = outfitWindow.type.creature:getOutfit() - if clotheButtonBox == currentClotheButtonBox then - clotheButtonBox.onCheckChange = nil - clotheButtonBox:setChecked(true) - clotheButtonBox.onCheckChange = onClotheCheckChange - else - currentClotheButtonBox.onCheckChange = nil - currentClotheButtonBox:setChecked(false) - currentClotheButtonBox.onCheckChange = onClotheCheckChange +function updateOutfits() + if not outfitWindow then return end + local outfit = outfitWindow.preview.creaturePanel.creature:getOutfit() - currentClotheButtonBox = clotheButtonBox - local colorId = 0 - if currentClotheButtonBox:getId() == "head" then - colorId = outfit.head - elseif currentClotheButtonBox:getId() == "primary" then - colorId = outfit.body - elseif currentClotheButtonBox:getId() == "secondary" then - colorId = outfit.legs - elseif currentClotheButtonBox:getId() == "detail" then - colorId = outfit.feet + for i, child in ipairs(outfitWindow.list:getChildren()) do + if child.catalog == "outfit" then + local previewOutfit = child.creature:getOutfit() + previewOutfit.head = outfit.head + previewOutfit.body = outfit.body + previewOutfit.legs = outfit.legs + previewOutfit.feet = outfit.feet + + child.creature:setOutfit(previewOutfit) end - outfitWindow:recursiveGetChildById("colorBox" .. colorId):setChecked(true) end end -function updateOutfit() - local currentSelection = outfitWindow.type.outfit - if not currentSelection then +function create(currentOutfit, outfitList, mountList, wingList, auraList, shaderList, hpBarList, manaBarList) + if outfitWindow and not outfitWindow:isHidden() then return end - local outfit = outfitWindow.type.creature:getOutfit() - local availableAddons = currentSelection[3] - local prevAddons = {} - for k, addon in pairs(addons) do - prevAddons[k] = addon.widget:isChecked() - addon.widget:setChecked(false) - addon.widget:setEnabled(false) - end - outfit.addons = 0 - outfitWindow.type.creature:setOutfit(outfit) + load() + destroy() + setupTables() - local shader = outfitWindow.extensions:getChildById("shader") - if shader then - outfit.shader = shader.creature:getOutfit().shader - if outfit.shader == "-" then - outfit.shader = "" - end - shader.creature:setOutfit(outfit) + -- use local shaders if server doesnt send any + shaderList = #shaderList > 0 and shaderList or loadLocalShaders and localShaders or {} + + outfitWindow = g_ui.displayUI("outfitwindow") + dataTables = { + outfits = outfitList, + mounts = mountList, + wings = wingList, + auras = auraList, + shaders = shaderList, + hpBars = hpBarList, + manaBars = manaBarList + } + + outfitWindow.appearance.onGeometryChange = function(widget, old, new) + local filterHeight = outfitWindow.search:getHeight() -- to detect layout used, 56 for default 47 for retro + local diff = 239 + filterHeight + local height = new.height + outfitWindow:setHeight(height + diff) end - if availableAddons > 0 then - for _, i in pairs(ADDON_SETS[availableAddons]) do - addons[i].widget:setEnabled(true) - addons[i].widget:setChecked(true) + local creature = outfitWindow.preview.creaturePanel.creature + local outfitType = currentOutfit.type + local mountType = currentOutfit.mount + local clearOutfit = currentOutfit + local currentAddons = currentOutfit.addons + + local availableAddons + for i, outfit in ipairs(outfitList) do + if outfit[1] == outfitType then + availableAddons = outfit[3] end end + + clearOutfit.mount = 0 + creature:setOutfit(clearOutfit) + + previewDir = 2 + + -- outfits + for i, outfit in ipairs(outfitList) do + local id = outfit[1] + local name = outfit[2] + local addons = outfit[3] + local outfit = currentOutfit + outfit.type = id + outfit.addons = addons + + local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list) + widget:setId("outfit."..name:lower().." "..id) + widget.title:setText(name) + outfit.mount = 0 + widget.creature:setOutfit(outfit) + widget.catalog = "outfit" + end + + -- mounts + for i, mount in ipairs(mountList) do + local id = mount[1] + local name = mount[2] + local mountOufit = { + type = id + } + + local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list) + widget:setId("mount."..name:lower().." "..id) + widget.title:setText(name) + widget.creature:setOutfit(mountOufit) + widget.catalog = "mount" + end + + -- wings + for i, wings in ipairs(wingList) do + local id = wings[1] + local name = wings[2] + local wingsOufit = { + type = id + } + + local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list) + widget:setId("wings."..name:lower().." "..id) + widget.title:setText(name) + widget.creature:setOutfit(wingsOufit) + widget.catalog = "wings" + end + + -- auras + for i, aura in ipairs(auraList) do + local id = aura[1] + local name = aura[2] + local auraOufit = { + type = id + } + + local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list) + widget:setId("aura."..name:lower().." "..id) + widget.title:setText(name) + widget.creature:setOutfit(auraOufit) + widget.catalog = "aura" + end + + -- shaders + for i, shader in ipairs(shaderList) do + if type(shader) ~= "table" then + shader = {i, shader} + end + local id = shader[1] + local name = shader[2] + local shaderOutfit = currentOutfit + shaderOutfit.shader = name + shaderOutfit.type = outfitType + + local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list) + widget:setId("shader."..name:lower().." "..id) + widget.title:setText(name) + widget.creature:setOutfit(shaderOutfit) + widget.catalog = "shader" + widget.shader = shaderOutfit.shader + end + + if g_game.getFeature(GameHealthInfoBackground) then + table.insert(hpBarList, 1, {0, "-"}) + table.insert(manaBarList, 1, {0, "-"}) + end + + -- hpbar + for i, bar in ipairs(hpBarList) do + local id = bar[1] + local name = bar[2] + local path = g_healthBars.getHealthBarPath(id) + + local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list) + widget:setId("healthbar."..name:lower().." "..id) + widget.item:setImageSource(i > 1 and path or "") + widget.title:setText(i > i and name or "Standard") + widget.catalog = "healthbar" + end + + -- hpbar + for i, bar in ipairs(manaBarList) do + local id = bar[1] + local name = bar[2] + local path = g_healthBars.getHealthBarPath(id) + + local widget = g_ui.createWidget("SmallPreviewTile", outfitWindow.list) + widget:setId("manabar."..name:lower().." "..id) + widget.item:setImageSource(i > 1 and path or "") + widget.title:setText(i > i and name or "Standard") + widget.catalog = "manabar" + end + + + -- check current outfit + for i, child in ipairs(outfitWindow.list:getChildren()) do + local catalog = child.catalog + local outfit = child.creature:getOutfit() + + if catalog == "outfit" then + if outfit.type == outfitType then + child:setChecked(true) + outfitWindow.list:moveChildToIndex(child, 1) + end + elseif catalog == "mount" then + if outfit.type == mountType then + child:setChecked(true) + outfitWindow.list:moveChildToIndex(child, 1) + child:setVisible(false) + end + elseif catalog == "shader" then + if outfit.shader == currentOutfit.shader then + child:setChecked(true) + outfitWindow.list:moveChildToIndex(child, 1) + child:setVisible(false) + end + elseif catalog == "wings" then + if outfit.wings == currentOutfit.wings then + child:setChecked(true) + outfitWindow.list:moveChildToIndex(child, 1) + child:setVisible(false) + end + elseif catalog == "aura" then + if outfit.aura == currentOutfit.aura then + child:setChecked(true) + outfitWindow.list:moveChildToIndex(child, 1) + child:setVisible(false) + end + elseif catalog == "manabar" then + if child:getId():find(outfit.manabar) then + child:setChecked(true) + outfitWindow.list:moveChildToIndex(child, 1) + child:setVisible(false) + end + elseif catalog == "healthbar" then + if child:getId():find(outfit.healthbar) then + child:setChecked(true) + outfitWindow.list:moveChildToIndex(child, 1) + child:setVisible(false) + end + end + end + + -- color box + for j = 0, 6 do + for i = 0, 18 do + local colorBox = g_ui.createWidget("ColorBox", outfitWindow.appearance.colorBoxPanel) + local outfitColor = getOutfitColor(j * 19 + i) + colorBox:setImageColor(outfitColor) + colorBox:setId("colorBox" .. j * 19 + i) + colorBox.colorId = j * 19 + i + + if j * 19 + i == currentOutfit.head then + currentColorBox = colorBox + colorBox:setChecked(true) + end + colorBox.onCheckChange = onColorCheckChange + colorBoxes[#colorBoxes + 1] = colorBox + end + end + + -- hook outfit sections + currentClotheButtonBox = outfitWindow.appearance.parts.head + outfitWindow.appearance.parts.head.onCheckChange = onClotheCheckChange + outfitWindow.appearance.parts.primary.onCheckChange = onClotheCheckChange + outfitWindow.appearance.parts.secondary.onCheckChange = onClotheCheckChange + outfitWindow.appearance.parts.detail.onCheckChange = onClotheCheckChange + + -- previewOptions + for i, settings in ipairs(previewOptions) do + if settings.enabled then + local widget = g_ui.createWidget("OptionsCheckBox", outfitWindow.preview.options) + widget:setId(settings.id) + widget:setText(settings.text) + widget.check:setChecked(settings.checked) + + if i > 1 then + local catalog = string.sub(settings.id, 5):lower() + local data = dataTables[catalog.."s"] + + -- if there's no options for certain category disable widget + if not data or #data == 0 then + widget.check:setChecked(false) + widget.check:setEnabled(false) + widget:setEnabled(false) + widget.check:setColor('#808080') + end + end + end + end + + -- config options + for i, settings in ipairs(configOptions) do + if settings.enabled then + local widget = g_ui.createWidget("OptionsCheckBox", outfitWindow.config.options) + widget:setId(settings.id) + widget:setText(settings.text) + widget:setChecked(settings.checked) + end + end + + -- appearance options + for i, settings in ipairs(appearanceOptions) do + if settings.enabled then + local widget = g_ui.createWidget("AppearanceCategory", outfitWindow.appearance.categories) + widget:setId(settings.id) + widget.checkBox:setText(settings.text) + widget.checkBox:setChecked(i==2) + end + end + + setCategoryDescription("outfit", outfitType) + setCategoryDescription("mount", mountType) + + local addon1 = outfitWindow.config.options.addon1.check + local addon2 = outfitWindow.config.options.addon2.check + local mount = g_game.getFeature(GamePlayerMounts) and outfitWindow.config.options.mount.check + + if #mountList == 0 and g_game.getFeature(GamePlayerMounts) then + mount:disable() + end + + addon1:setChecked(currentAddons == 1 or currentAddons == 3) + addon2:setChecked(currentAddons > 1) + + addon1:setEnabled(availableAddons > 0) + addon2:setEnabled(availableAddons > 1) + + + for i, setting in ipairs(settings) do + local outfit = setting.outfit + local mount = setting.mount + local name = setting.name + + local widget = g_ui.createWidget("LargePreviewTile", outfitWindow.list) + widget.catalog = "preset" + widget:setId("preset."..outfit.type..name) + widget.outfit:setOutfit(outfit) + if mount then + widget.mount:setOutfit(mount) + end + widget.title:setText(name) + end + + refreshVisiblePreviews() + refreshPreview() +end + +function destroy() + if outfitWindow then + filterText = "" + currentCategory = "outfit" + + outfitWindow:destroy() + outfitWindow = nil + end +end + +function accept() + local player = g_game.getLocalPlayer() + if outfitWindow then + save() + filterText = "" + currentCategory = "outfit" + + if g_game.getFeature(GamePlayerMounts) then + local mount = outfitWindow.config.options.mount.check:isChecked() + + if not player:isMounted() and mount then + player:mount() + end + end + + g_game.changeOutfit(getOutfitFromCurrentChecks(1)) + outfitWindow:destroy() + outfitWindow = nil + end +end + +-- json +function save() + local settings = {} + + for i, child in ipairs(outfitWindow.list:getChildren()) do + if child.catalog == "preset" then + local data = { + outfit = child.outfit:getOutfit(), + mount = child.mount:getOutfit(), + name = child.title:getText() + } + + table.insert(settings, data) + end + end + + local file = "/settings/outfits.json" + + local status, result = pcall(function() return json.encode(settings, 2) end) + if not status then + return onError( + "Error while saving top bar settings. Data won't be saved. Details: " .. + result) + end + + if result:len() > 100 * 1024 * 1024 then + return onError( + "Something went wrong, file is above 100MB, won't be saved") + end + + g_resources.writeFileContents(file, result) +end + +function load() + local file = "/settings/outfits.json" + + if g_resources.fileExists(file) then + local status, result = pcall(function() + return json.decode(g_resources.readFileContents(file)) + end) + if not status then + return onError( + "Error while reading top bar settings file. To fix this problem you can delete storage.json. Details: " .. + result) + end + settings = result + else + settings = {} + end end diff --git a/modules/game_outfit/outfit.otmod b/modules/game_outfit/outfit.otmod index 284d076..dfaba8d 100644 --- a/modules/game_outfit/outfit.otmod +++ b/modules/game_outfit/outfit.otmod @@ -1,9 +1,9 @@ Module name: game_outfit description: Change local player outfit - author: baxnie, edubart - website: https://github.com/edubart/otclient + author: Vithrax + discord: Vithrax#5814 sandboxed: true scripts: [ outfit ] @onLoad: init() - @onUnload: terminate() + @onUnload: terminate() \ No newline at end of file diff --git a/modules/game_outfit/outfitwindow.otui b/modules/game_outfit/outfitwindow.otui index a7e4810..9ce9537 100644 --- a/modules/game_outfit/outfitwindow.otui +++ b/modules/game_outfit/outfitwindow.otui @@ -1,219 +1,3 @@ -NextOutfitButton < NextButton -PrevOutfitButton < PreviousButton -NextMountButton < NextButton -PrevMountButton < PreviousButton - -OutfitSelectorPanel < Panel - size: 125 120 - - Label - id: title - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - text-align: center - - UICreature - id: creature - size: 100 80 - anchors.top: prev.bottom - anchors.horizontalCenter: parent.horizontalCenter - margin-top: 1 - - PreviousButton - id: prevButton - anchors.left: parent.left - anchors.bottom: parent.bottom - - NextButton - id: nextButton - anchors.right: parent.right - anchors.bottom: parent.bottom - - Label - id: label - text: Outfit name - text-align: center - anchors.left: prevButton.right - anchors.right: nextButton.left - anchors.top: prevButton.top - anchors.bottom: parent.bottom - margin-left: 2 - margin-right: 2 - image-source: /images/ui/panel_flat - image-border: 2 - text: - - -BarSelectorPanel < Panel - size: 125 120 - - Label - id: title - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - text-align: center - - UIWidget - id: bar - anchors.centerIn: parent - - PreviousButton - id: prevButton - anchors.left: parent.left - anchors.bottom: parent.bottom - - NextButton - id: nextButton - anchors.right: parent.right - anchors.bottom: parent.bottom - - Label - id: label - text: - - text-align: center - anchors.left: prevButton.right - anchors.right: nextButton.left - anchors.top: prevButton.top - anchors.bottom: parent.bottom - margin-left: 2 - margin-right: 2 - image-source: /images/ui/panel_flat - image-border: 2 - -MainWindow - !text: tr('Select Outfit') - size: 560 330 - +OutfitWindow @onEnter: modules.game_outfit.accept() - @onEscape: modules.game_outfit.destroy() - - // Creature Boxes - - Panel - id: line1 - anchors.top: outfit.bottom - anchors.left: parent.left - anchors.right: parent.right - backgroud: red - layout: - type: horizontalBox - spacing: 3 - - OutfitSelectorPanel - id: type - anchors.left: parent.left - anchors.top: parent.top - - CheckBox - id: addon1 - width: 80 - anchors.top: type.bottom - anchors.left: type.left - !text: tr('Addon 1') - margin-left: 2 - margin-top: 5 - enabled: false - - CheckBox - id: addon2 - width: 80 - anchors.top: prev.top - anchors.left: prev.right - !text: tr('Addon 2') - enabled: false - - CheckBox - id: addon3 - width: 80 - anchors.top: prev.top - anchors.left: prev.right - !text: tr('Addon 3') - enabled: false - - ButtonBox - id: head - !text: tr('Head') - anchors.top: type.top - anchors.left: type.right - margin-left: 5 - checked: true - width: 76 - - ButtonBox - id: primary - !text: tr('Primary') - anchors.top: prev.bottom - anchors.left: prev.left - margin-top: 2 - width: 76 - - ButtonBox - id: secondary - !text: tr('Secondary') - anchors.top: prev.bottom - anchors.left: prev.left - margin-top: 2 - width: 76 - - ButtonBox - id: detail - !text: tr('Detail') - anchors.top: prev.bottom - anchors.left: prev.left - margin-top: 2 - width: 76 - - ButtonBox - id: randomizeButton - !text: tr('Randomize') - anchors.top: prev.bottom - !tooltip: tr('Randomize characters outfit') - anchors.left: prev.left - margin-top: 2 - width: 76 - @onClick: modules.game_outfit.randomize() - - Panel - id: colorBoxPanel - anchors.top: head.top - anchors.left: head.right - anchors.right: parent.right - anchors.bottom: type.bottom - margin-left: 5 - margin-top: 2 - layout: - type: grid - cell-size: 15 15 - cell-spacing: 2 - num-columns: 19 - num-lines: 7 - - Panel - id: extensions - height: 120 - margin-top: 5 - anchors.top: addon1.bottom - anchors.horizontalCenter: parent.horizontalCenter - backgroud: red - layout: - type: horizontalBox - fit-children: true - spacing: 8 - - Button - id: outfitOkButton - !text: tr('Ok') - width: 64 - anchors.right: next.left - anchors.bottom: parent.bottom - margin-right: 16 - @onClick: modules.game_outfit.accept() - - Button - id: outfitCancelButton - !text: tr('Cancel') - width: 64 - anchors.right: parent.right - anchors.bottom: parent.bottom - @onClick: modules.game_outfit.destroy() + @onEscape: self:hide() \ No newline at end of file diff --git a/modules/game_topbar/topbar.lua b/modules/game_topbar/topbar.lua index 7a13249..da73010 100644 --- a/modules/game_topbar/topbar.lua +++ b/modules/game_topbar/topbar.lua @@ -226,6 +226,7 @@ end function toggleIcon(bitChanged) local content = states + if not content then return end local icon = content:getChildById(Icons[bitChanged].id) if icon then @@ -245,6 +246,7 @@ function loadIcon(bitChanged) end function onHealthChange(localPlayer, health, maxHealth) + if not healthBar then return end if health > maxHealth then maxHealth = health end local healthPercent = (health / maxHealth) * 100 @@ -268,6 +270,7 @@ function onHealthChange(localPlayer, health, maxHealth) end function onManaChange(localPlayer, mana, maxMana) + if not manaBar then return end if mana > maxMana then maxMana = mana end local manaPercent = (mana / maxMana) * 100 @@ -278,6 +281,7 @@ function onManaChange(localPlayer, mana, maxMana) end function onLevelChange(localPlayer, value, percent) + if not topBar then return end local experienceBar = topBar.Experience.progress local levelLabel = topBar.Experience.level experienceBar:setTooltip(tr(experienceTooltip, 100-percent, value + 1)) @@ -374,6 +378,7 @@ function setupSkills() end function toggleSkillPanel(id) + if not topBar then return end local panel = topBar.skills[id] panel = panel or topBar.Experience if not panel then return end @@ -384,6 +389,7 @@ function toggleSkillPanel(id) end function setSkillValue(id, value) + if not topBar then return end local panel = topBar.skills[id] if not panel then return end @@ -391,6 +397,7 @@ function setSkillValue(id, value) end function setSkillPercent(id, percent, tooltip) + if not topBar then return end local panel = topBar.skills[id] if not panel then return end @@ -398,6 +405,7 @@ function setSkillPercent(id, percent, tooltip) end function setSkillBase(id, value, baseValue) + if not topBar then return end local panel = topBar.skills[id] if not panel then return end diff --git a/otclient_dx.exe b/otclient_dx.exe index ee3793a..e8533ac 100644 Binary files a/otclient_dx.exe and b/otclient_dx.exe differ diff --git a/otclient_gl.exe b/otclient_gl.exe index 51f09d1..8db9be7 100644 Binary files a/otclient_gl.exe and b/otclient_gl.exe differ diff --git a/otclientv8.apk b/otclientv8.apk index 7927b24..4407fbf 100644 Binary files a/otclientv8.apk and b/otclientv8.apk differ