mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-04-29 10:49:21 +02:00
Updaded modaldialog and bot (added anti push)
This commit is contained in:
parent
7d9a81d871
commit
d78af570ea
@ -34,6 +34,7 @@ Panels.AttackItem(attackTab)
|
||||
|
||||
Panels.AttackLeaderTarget(warTab)
|
||||
Panels.LimitFloor(warTab)
|
||||
Panels.AntiPush(warTab)
|
||||
|
||||
local waypoints = Panels.Waypoints(caveTab)
|
||||
local attacking = Panels.Attacking(caveTab)
|
||||
|
@ -779,15 +779,18 @@ Panel
|
||||
|
||||
local getMonsterConfig = function(monster)
|
||||
local name = monster:getName():lower()
|
||||
local hasConfig = false
|
||||
hasConfig = hasConfig or (monsters[name] ~= nil)
|
||||
if isConfigPassingConditions(monster, monsters[name]) then
|
||||
return monsters[name]
|
||||
end
|
||||
for i=1, 5 do
|
||||
hasConfig = hasConfig or (monsters[name .. i] ~= nil)
|
||||
if isConfigPassingConditions(monster, monsters[name .. i]) then
|
||||
return monsters[name .. i]
|
||||
end
|
||||
end
|
||||
if isConfigPassingConditions(monster, monsters["*"]) then
|
||||
if not hasConfig and isConfigPassingConditions(monster, monsters["*"]) then
|
||||
return monsters["*"]
|
||||
end
|
||||
return nil
|
||||
@ -1089,7 +1092,11 @@ Panel
|
||||
end
|
||||
end
|
||||
|
||||
target.ignoreByWaypoints = config.dontWalk
|
||||
if config.dontWalk then
|
||||
if goForLoot() then
|
||||
return
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -313,15 +313,15 @@ Panels.Eating = function(parent)
|
||||
widget:setOn(context.storage[panelName].enabled)
|
||||
end
|
||||
|
||||
if type(context.storage["autoEating" .. panelId]) ~= 'table' then
|
||||
context.storage["autoEating" .. panelId] = {3725, 0, 0, 0, 0}
|
||||
if type(context.storage[panelName].items) ~= 'table' then
|
||||
context.storage[panelName].items = {3725, 0, 0, 0, 0}
|
||||
end
|
||||
|
||||
for i=1,5 do
|
||||
ui.items:getChildByIndex(i).onItemChange = function(widget)
|
||||
context.storage["autoEating" .. panelId][i] = widget:getItemId()
|
||||
context.storage[panelName].items[i] = widget:getItemId()
|
||||
end
|
||||
ui.items:getChildByIndex(i):setItemId(context.storage["autoEating" .. panelId][i])
|
||||
ui.items:getChildByIndex(i):setItemId(context.storage[panelName].items[i])
|
||||
end
|
||||
|
||||
context.macro(15000, function()
|
||||
@ -329,16 +329,15 @@ Panels.Eating = function(parent)
|
||||
return
|
||||
end
|
||||
local candidates = {}
|
||||
for i, item in pairs(context.storage["autoEating" .. panelId]) do
|
||||
for i, item in pairs(context.storage[panelName].items) do
|
||||
if item >= 100 then
|
||||
table.insert(candidates, item)
|
||||
end
|
||||
end
|
||||
if #candidates == 0 then
|
||||
return
|
||||
end
|
||||
context.usewith(candidates[math.random(1, #candidates)], context.player)
|
||||
end
|
||||
context.use(candidates[math.random(1, #candidates)])
|
||||
end)
|
||||
end
|
||||
Panels.ManaItem = Panels.Mana
|
||||
|
||||
|
@ -63,3 +63,65 @@ Panels.LimitFloor = function(parent)
|
||||
switch:setOn(context.storage.limitFloor)
|
||||
end
|
||||
|
||||
Panels.AntiPush = function(parent)
|
||||
if not parent then
|
||||
parent = context.panel
|
||||
end
|
||||
|
||||
local panelName = "antiPushPanel"
|
||||
local ui = g_ui.createWidget("ItemsPanel", parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
if not context.storage[panelName] then
|
||||
context.storage[panelName] = {}
|
||||
end
|
||||
|
||||
ui.title:setText("Anti push")
|
||||
ui.title:setOn(context.storage[panelName].enabled)
|
||||
ui.title.onClick = function(widget)
|
||||
context.storage[panelName].enabled = not context.storage[panelName].enabled
|
||||
widget:setOn(context.storage[panelName].enabled)
|
||||
end
|
||||
|
||||
if type(context.storage[panelName].items) ~= 'table' then
|
||||
context.storage[panelName].items = {3031, 3035, 0, 0, 0}
|
||||
end
|
||||
|
||||
for i=1,5 do
|
||||
ui.items:getChildByIndex(i).onItemChange = function(widget)
|
||||
context.storage[panelName].items[i] = widget:getItemId()
|
||||
end
|
||||
ui.items:getChildByIndex(i):setItemId(context.storage[panelName].items[i])
|
||||
end
|
||||
|
||||
context.macro(100, function()
|
||||
if not context.storage[panelName].enabled then
|
||||
return
|
||||
end
|
||||
local tile = g_map.getTile(context.player:getPosition())
|
||||
if not tile then
|
||||
return
|
||||
end
|
||||
local topItem = tile:getTopUseThing()
|
||||
if topItem and topItem:isStackable() then
|
||||
topItem = topItem:getId()
|
||||
else
|
||||
topItem = 0
|
||||
end
|
||||
local candidates = {}
|
||||
for i, item in pairs(context.storage[panelName].items) do
|
||||
if item >= 100 and item ~= topItem and context.findItem(item) then
|
||||
table.insert(candidates, item)
|
||||
end
|
||||
end
|
||||
if #candidates == 0 then
|
||||
return
|
||||
end
|
||||
if type(context.storage[panelName].lastItem) ~= 'number' or context.storage[panelName].lastItem > #candidates then
|
||||
context.storage[panelName].lastItem = 1
|
||||
end
|
||||
local item = context.findItem(candidates[context.storage[panelName].lastItem])
|
||||
g_game.move(item, context.player:getPosition(), 1)
|
||||
context.storage[panelName].lastItem = context.storage[panelName].lastItem + 1
|
||||
end)
|
||||
end
|
||||
|
@ -578,7 +578,7 @@ Panel
|
||||
-- wait if attacking/following creature
|
||||
local attacking = g_game.getAttackingCreature()
|
||||
local following = g_game.getFollowingCreature()
|
||||
if (attacking and context.getCreatureById(attacking:getId())) or (following and context.getCreatureById(following:getId())) then
|
||||
if (attacking and context.getCreatureById(attacking:getId()) and not attacking.ignoreByWaypoints) or (following and context.getCreatureById(following:getId())) then
|
||||
executeNextMacroCall = false
|
||||
return
|
||||
end
|
||||
|
@ -37,6 +37,9 @@ function setupExtraHotkeys(combobox)
|
||||
nextChild = battlePanel:getFirstChild()
|
||||
end
|
||||
end
|
||||
if not breakNext then
|
||||
nextChild = battlePanel:getFirstChild()
|
||||
end
|
||||
if nextChild and nextChild.creature ~= attackedCreature then
|
||||
g_game.attack(nextChild.creature)
|
||||
end
|
||||
|
@ -1,4 +1,7 @@
|
||||
modalDialog = nil
|
||||
lastDialogChoices = 0
|
||||
lastDialogChoice = 0
|
||||
lastDialogAnswer = 0
|
||||
|
||||
function init()
|
||||
g_ui.importStyle('modaldialog')
|
||||
@ -53,7 +56,13 @@ function onModalDialog(id, title, message, buttons, enterButton, escapeButton, c
|
||||
labelHeight = label:getHeight()
|
||||
end
|
||||
end
|
||||
choiceList:focusNextChild()
|
||||
if #choices > 0 then
|
||||
if g_clock.millis() < lastDialogAnswer + 1000 and lastDialogChoices == #choices then
|
||||
choiceList:focusChild(choiceList:getChildByIndex(lastDialogChoice))
|
||||
else
|
||||
choiceList:focusChild(choiceList:getFirstChild())
|
||||
end
|
||||
end
|
||||
|
||||
local buttonsWidth = 0
|
||||
for i = 1, #buttons do
|
||||
@ -67,6 +76,8 @@ function onModalDialog(id, title, message, buttons, enterButton, escapeButton, c
|
||||
local choice = 0xFF
|
||||
if focusedChoice then
|
||||
choice = focusedChoice.choiceId
|
||||
lastDialogChoice = choiceList:getChildIndex(focusedChoice)
|
||||
lastDialogAnswer = g_clock.millis()
|
||||
end
|
||||
g_game.answerModalDialog(id, buttonId, choice)
|
||||
destroyDialog()
|
||||
@ -85,16 +96,20 @@ function onModalDialog(id, title, message, buttons, enterButton, escapeButton, c
|
||||
|
||||
local horizontalPadding = modalDialog:getPaddingLeft() + modalDialog:getPaddingRight()
|
||||
buttonsWidth = buttonsWidth + horizontalPadding
|
||||
|
||||
modalDialog:setWidth(math.min(modalDialog.maximumWidth, math.max(buttonsWidth, messageLabel:getWidth(), modalDialog.minimumWidth)))
|
||||
messageLabel:setWidth(math.min(modalDialog.maximumWidth, math.max(buttonsWidth, messageLabel:getWidth(), modalDialog.minimumWidth)) - horizontalPadding)
|
||||
modalDialog:setHeight(modalDialog:getHeight() + additionalHeight + messageLabel:getHeight() - 8)
|
||||
|
||||
local labelWidth = math.min(600, math.floor(message:len() * 1.5))
|
||||
modalDialog:setWidth(math.min(modalDialog.maximumWidth, math.max(buttonsWidth, labelWidth, modalDialog.minimumWidth)))
|
||||
messageLabel:setTextWrap(true)
|
||||
|
||||
modalDialog:setHeight(90 + additionalHeight + messageLabel:getHeight())
|
||||
|
||||
local enterFunc = function()
|
||||
local focusedChoice = choiceList:getFocusedChild()
|
||||
local choice = 0xFF
|
||||
if focusedChoice then
|
||||
choice = focusedChoice.choiceId
|
||||
lastDialogChoice = choiceList:getChildIndex(focusedChoice)
|
||||
lastDialogAnswer = g_clock.millis()
|
||||
end
|
||||
g_game.answerModalDialog(id, enterButton, choice)
|
||||
destroyDialog()
|
||||
@ -105,6 +120,8 @@ function onModalDialog(id, title, message, buttons, enterButton, escapeButton, c
|
||||
local choice = 0xFF
|
||||
if focusedChoice then
|
||||
choice = focusedChoice.choiceId
|
||||
lastDialogChoice = choiceList:getChildIndex(focusedChoice)
|
||||
lastDialogAnswer = g_clock.millis()
|
||||
end
|
||||
g_game.answerModalDialog(id, escapeButton, choice)
|
||||
destroyDialog()
|
||||
@ -114,4 +131,6 @@ function onModalDialog(id, title, message, buttons, enterButton, escapeButton, c
|
||||
|
||||
modalDialog.onEnter = enterFunc
|
||||
modalDialog.onEscape = escapeFunc
|
||||
|
||||
lastDialogChoices = #choices
|
||||
end
|
@ -40,7 +40,7 @@ ModalButton < Button
|
||||
ModalDialog < MainWindow
|
||||
id: modalDialog
|
||||
size: 280 97
|
||||
&minimumWidth: 200
|
||||
&minimumWidth: 300
|
||||
&maximumWidth: 600
|
||||
&minimumChoices: 4
|
||||
&maximumChoices: 10
|
||||
@ -49,6 +49,7 @@ ModalDialog < MainWindow
|
||||
id: messageLabel
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
text-align: left
|
||||
text-auto-resize: true
|
||||
text-wrap: true
|
||||
@ -59,6 +60,7 @@ ModalDialog < MainWindow
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: next.top
|
||||
margin-bottom: 5
|
||||
|
||||
Panel
|
||||
id: buttonsPanel
|
||||
|
Loading…
x
Reference in New Issue
Block a user