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.AttackLeaderTarget(warTab)
|
||||||
Panels.LimitFloor(warTab)
|
Panels.LimitFloor(warTab)
|
||||||
|
Panels.AntiPush(warTab)
|
||||||
|
|
||||||
local waypoints = Panels.Waypoints(caveTab)
|
local waypoints = Panels.Waypoints(caveTab)
|
||||||
local attacking = Panels.Attacking(caveTab)
|
local attacking = Panels.Attacking(caveTab)
|
||||||
|
@ -779,15 +779,18 @@ Panel
|
|||||||
|
|
||||||
local getMonsterConfig = function(monster)
|
local getMonsterConfig = function(monster)
|
||||||
local name = monster:getName():lower()
|
local name = monster:getName():lower()
|
||||||
|
local hasConfig = false
|
||||||
|
hasConfig = hasConfig or (monsters[name] ~= nil)
|
||||||
if isConfigPassingConditions(monster, monsters[name]) then
|
if isConfigPassingConditions(monster, monsters[name]) then
|
||||||
return monsters[name]
|
return monsters[name]
|
||||||
end
|
end
|
||||||
for i=1, 5 do
|
for i=1, 5 do
|
||||||
|
hasConfig = hasConfig or (monsters[name .. i] ~= nil)
|
||||||
if isConfigPassingConditions(monster, monsters[name .. i]) then
|
if isConfigPassingConditions(monster, monsters[name .. i]) then
|
||||||
return monsters[name .. i]
|
return monsters[name .. i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if isConfigPassingConditions(monster, monsters["*"]) then
|
if not hasConfig and isConfigPassingConditions(monster, monsters["*"]) then
|
||||||
return monsters["*"]
|
return monsters["*"]
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
@ -1089,7 +1092,11 @@ Panel
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
target.ignoreByWaypoints = config.dontWalk
|
||||||
if config.dontWalk then
|
if config.dontWalk then
|
||||||
|
if goForLoot() then
|
||||||
|
return
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -313,15 +313,15 @@ Panels.Eating = function(parent)
|
|||||||
widget:setOn(context.storage[panelName].enabled)
|
widget:setOn(context.storage[panelName].enabled)
|
||||||
end
|
end
|
||||||
|
|
||||||
if type(context.storage["autoEating" .. panelId]) ~= 'table' then
|
if type(context.storage[panelName].items) ~= 'table' then
|
||||||
context.storage["autoEating" .. panelId] = {3725, 0, 0, 0, 0}
|
context.storage[panelName].items = {3725, 0, 0, 0, 0}
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1,5 do
|
for i=1,5 do
|
||||||
ui.items:getChildByIndex(i).onItemChange = function(widget)
|
ui.items:getChildByIndex(i).onItemChange = function(widget)
|
||||||
context.storage["autoEating" .. panelId][i] = widget:getItemId()
|
context.storage[panelName].items[i] = widget:getItemId()
|
||||||
end
|
end
|
||||||
ui.items:getChildByIndex(i):setItemId(context.storage["autoEating" .. panelId][i])
|
ui.items:getChildByIndex(i):setItemId(context.storage[panelName].items[i])
|
||||||
end
|
end
|
||||||
|
|
||||||
context.macro(15000, function()
|
context.macro(15000, function()
|
||||||
@ -329,16 +329,15 @@ Panels.Eating = function(parent)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local candidates = {}
|
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
|
if item >= 100 then
|
||||||
table.insert(candidates, item)
|
table.insert(candidates, item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #candidates == 0 then
|
if #candidates == 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
context.usewith(candidates[math.random(1, #candidates)], context.player)
|
context.use(candidates[math.random(1, #candidates)])
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
Panels.ManaItem = Panels.Mana
|
|
||||||
|
|
||||||
|
@ -63,3 +63,65 @@ Panels.LimitFloor = function(parent)
|
|||||||
switch:setOn(context.storage.limitFloor)
|
switch:setOn(context.storage.limitFloor)
|
||||||
end
|
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
|
-- wait if attacking/following creature
|
||||||
local attacking = g_game.getAttackingCreature()
|
local attacking = g_game.getAttackingCreature()
|
||||||
local following = g_game.getFollowingCreature()
|
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
|
executeNextMacroCall = false
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -37,6 +37,9 @@ function setupExtraHotkeys(combobox)
|
|||||||
nextChild = battlePanel:getFirstChild()
|
nextChild = battlePanel:getFirstChild()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if not breakNext then
|
||||||
|
nextChild = battlePanel:getFirstChild()
|
||||||
|
end
|
||||||
if nextChild and nextChild.creature ~= attackedCreature then
|
if nextChild and nextChild.creature ~= attackedCreature then
|
||||||
g_game.attack(nextChild.creature)
|
g_game.attack(nextChild.creature)
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
modalDialog = nil
|
modalDialog = nil
|
||||||
|
lastDialogChoices = 0
|
||||||
|
lastDialogChoice = 0
|
||||||
|
lastDialogAnswer = 0
|
||||||
|
|
||||||
function init()
|
function init()
|
||||||
g_ui.importStyle('modaldialog')
|
g_ui.importStyle('modaldialog')
|
||||||
@ -53,7 +56,13 @@ function onModalDialog(id, title, message, buttons, enterButton, escapeButton, c
|
|||||||
labelHeight = label:getHeight()
|
labelHeight = label:getHeight()
|
||||||
end
|
end
|
||||||
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
|
local buttonsWidth = 0
|
||||||
for i = 1, #buttons do
|
for i = 1, #buttons do
|
||||||
@ -67,6 +76,8 @@ function onModalDialog(id, title, message, buttons, enterButton, escapeButton, c
|
|||||||
local choice = 0xFF
|
local choice = 0xFF
|
||||||
if focusedChoice then
|
if focusedChoice then
|
||||||
choice = focusedChoice.choiceId
|
choice = focusedChoice.choiceId
|
||||||
|
lastDialogChoice = choiceList:getChildIndex(focusedChoice)
|
||||||
|
lastDialogAnswer = g_clock.millis()
|
||||||
end
|
end
|
||||||
g_game.answerModalDialog(id, buttonId, choice)
|
g_game.answerModalDialog(id, buttonId, choice)
|
||||||
destroyDialog()
|
destroyDialog()
|
||||||
@ -85,16 +96,20 @@ function onModalDialog(id, title, message, buttons, enterButton, escapeButton, c
|
|||||||
|
|
||||||
local horizontalPadding = modalDialog:getPaddingLeft() + modalDialog:getPaddingRight()
|
local horizontalPadding = modalDialog:getPaddingLeft() + modalDialog:getPaddingRight()
|
||||||
buttonsWidth = buttonsWidth + horizontalPadding
|
buttonsWidth = buttonsWidth + horizontalPadding
|
||||||
|
|
||||||
modalDialog:setWidth(math.min(modalDialog.maximumWidth, math.max(buttonsWidth, messageLabel:getWidth(), modalDialog.minimumWidth)))
|
local labelWidth = math.min(600, math.floor(message:len() * 1.5))
|
||||||
messageLabel:setWidth(math.min(modalDialog.maximumWidth, math.max(buttonsWidth, messageLabel:getWidth(), modalDialog.minimumWidth)) - horizontalPadding)
|
modalDialog:setWidth(math.min(modalDialog.maximumWidth, math.max(buttonsWidth, labelWidth, modalDialog.minimumWidth)))
|
||||||
modalDialog:setHeight(modalDialog:getHeight() + additionalHeight + messageLabel:getHeight() - 8)
|
messageLabel:setTextWrap(true)
|
||||||
|
|
||||||
|
modalDialog:setHeight(90 + additionalHeight + messageLabel:getHeight())
|
||||||
|
|
||||||
local enterFunc = function()
|
local enterFunc = function()
|
||||||
local focusedChoice = choiceList:getFocusedChild()
|
local focusedChoice = choiceList:getFocusedChild()
|
||||||
local choice = 0xFF
|
local choice = 0xFF
|
||||||
if focusedChoice then
|
if focusedChoice then
|
||||||
choice = focusedChoice.choiceId
|
choice = focusedChoice.choiceId
|
||||||
|
lastDialogChoice = choiceList:getChildIndex(focusedChoice)
|
||||||
|
lastDialogAnswer = g_clock.millis()
|
||||||
end
|
end
|
||||||
g_game.answerModalDialog(id, enterButton, choice)
|
g_game.answerModalDialog(id, enterButton, choice)
|
||||||
destroyDialog()
|
destroyDialog()
|
||||||
@ -105,6 +120,8 @@ function onModalDialog(id, title, message, buttons, enterButton, escapeButton, c
|
|||||||
local choice = 0xFF
|
local choice = 0xFF
|
||||||
if focusedChoice then
|
if focusedChoice then
|
||||||
choice = focusedChoice.choiceId
|
choice = focusedChoice.choiceId
|
||||||
|
lastDialogChoice = choiceList:getChildIndex(focusedChoice)
|
||||||
|
lastDialogAnswer = g_clock.millis()
|
||||||
end
|
end
|
||||||
g_game.answerModalDialog(id, escapeButton, choice)
|
g_game.answerModalDialog(id, escapeButton, choice)
|
||||||
destroyDialog()
|
destroyDialog()
|
||||||
@ -114,4 +131,6 @@ function onModalDialog(id, title, message, buttons, enterButton, escapeButton, c
|
|||||||
|
|
||||||
modalDialog.onEnter = enterFunc
|
modalDialog.onEnter = enterFunc
|
||||||
modalDialog.onEscape = escapeFunc
|
modalDialog.onEscape = escapeFunc
|
||||||
|
|
||||||
|
lastDialogChoices = #choices
|
||||||
end
|
end
|
@ -40,7 +40,7 @@ ModalButton < Button
|
|||||||
ModalDialog < MainWindow
|
ModalDialog < MainWindow
|
||||||
id: modalDialog
|
id: modalDialog
|
||||||
size: 280 97
|
size: 280 97
|
||||||
&minimumWidth: 200
|
&minimumWidth: 300
|
||||||
&maximumWidth: 600
|
&maximumWidth: 600
|
||||||
&minimumChoices: 4
|
&minimumChoices: 4
|
||||||
&maximumChoices: 10
|
&maximumChoices: 10
|
||||||
@ -49,6 +49,7 @@ ModalDialog < MainWindow
|
|||||||
id: messageLabel
|
id: messageLabel
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
text-align: left
|
text-align: left
|
||||||
text-auto-resize: true
|
text-auto-resize: true
|
||||||
text-wrap: true
|
text-wrap: true
|
||||||
@ -59,6 +60,7 @@ ModalDialog < MainWindow
|
|||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: next.top
|
anchors.bottom: next.top
|
||||||
|
margin-bottom: 5
|
||||||
|
|
||||||
Panel
|
Panel
|
||||||
id: buttonsPanel
|
id: buttonsPanel
|
||||||
|
Loading…
x
Reference in New Issue
Block a user