mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-10-19 22:23:28 +02:00
OTCv8 3.0 rev 2
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,57 +1,57 @@
|
||||
local context = G.botContext
|
||||
local Panels = context.Panels
|
||||
|
||||
Panels.Turning = function(parent)
|
||||
context.macro(1000, "Turning / AntiIdle", nil, function()
|
||||
context.turn(math.random(1, 4))
|
||||
end, parent)
|
||||
end
|
||||
Panels.AntiIdle = Panels.Turning
|
||||
|
||||
Panels.AttackSpell = function(parent)
|
||||
context.macro(500, "Auto attack spell", nil, function()
|
||||
local target = g_game.getAttackingCreature()
|
||||
if target and context.getCreatureById(target:getId()) and context.storage.autoAttackText:len() > 0 then
|
||||
if context.saySpell(context.storage.autoAttackText, 1000) then
|
||||
context.delay(1000)
|
||||
end
|
||||
end
|
||||
end, parent)
|
||||
context.addTextEdit("autoAttackText", context.storage.autoAttackText or "exori vis", function(widget, text)
|
||||
context.storage.autoAttackText = text
|
||||
end, parent)
|
||||
end
|
||||
|
||||
Panels.AttackItem = function(parent)
|
||||
if not parent then
|
||||
parent = context.panel
|
||||
end
|
||||
|
||||
local panelName = "attackItem"
|
||||
local ui = g_ui.createWidget("ItemAndButtonPanel", parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
ui.title:setText("Auto attack item")
|
||||
|
||||
if not context.storage.attackItem then
|
||||
context.storage.attackItem = {}
|
||||
end
|
||||
|
||||
ui.title:setOn(context.storage.attackItem.enabled)
|
||||
ui.title.onClick = function(widget)
|
||||
context.storage.attackItem.enabled = not context.storage.attackItem.enabled
|
||||
widget:setOn(context.storage.attackItem.enabled)
|
||||
end
|
||||
|
||||
ui.item.onItemChange = function(widget)
|
||||
context.storage.attackItem.item = widget:getItemId()
|
||||
end
|
||||
ui.item:setItemId(context.storage.attackItem.item or 3155)
|
||||
|
||||
context.macro(500, function()
|
||||
local target = g_game.getAttackingCreature()
|
||||
if context.storage.attackItem.enabled and target and context.getCreatureById(target:getId()) and context.storage.attackItem.item and context.storage.attackItem.item >= 100 then
|
||||
context.useWith(context.storage.attackItem.item, target)
|
||||
end
|
||||
end)
|
||||
end
|
||||
local context = G.botContext
|
||||
local Panels = context.Panels
|
||||
|
||||
Panels.Turning = function(parent)
|
||||
context.macro(1000, "Turning / AntiIdle", nil, function()
|
||||
context.turn(math.random(1, 4))
|
||||
end, parent)
|
||||
end
|
||||
Panels.AntiIdle = Panels.Turning
|
||||
|
||||
Panels.AttackSpell = function(parent)
|
||||
context.macro(500, "Auto attack spell", nil, function()
|
||||
local target = g_game.getAttackingCreature()
|
||||
if target and context.getCreatureById(target:getId()) and context.storage.autoAttackText:len() > 0 then
|
||||
if context.saySpell(context.storage.autoAttackText, 1000) then
|
||||
context.delay(1000)
|
||||
end
|
||||
end
|
||||
end, parent)
|
||||
context.addTextEdit("autoAttackText", context.storage.autoAttackText or "exori vis", function(widget, text)
|
||||
context.storage.autoAttackText = text
|
||||
end, parent)
|
||||
end
|
||||
|
||||
Panels.AttackItem = function(parent)
|
||||
if not parent then
|
||||
parent = context.panel
|
||||
end
|
||||
|
||||
local panelName = "attackItem"
|
||||
local ui = g_ui.createWidget("ItemAndButtonPanel", parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
ui.title:setText("Auto attack item")
|
||||
|
||||
if not context.storage.attackItem then
|
||||
context.storage.attackItem = {}
|
||||
end
|
||||
|
||||
ui.title:setOn(context.storage.attackItem.enabled)
|
||||
ui.title.onClick = function(widget)
|
||||
context.storage.attackItem.enabled = not context.storage.attackItem.enabled
|
||||
widget:setOn(context.storage.attackItem.enabled)
|
||||
end
|
||||
|
||||
ui.item.onItemChange = function(widget)
|
||||
context.storage.attackItem.item = widget:getItemId()
|
||||
end
|
||||
ui.item:setItemId(context.storage.attackItem.item or 3155)
|
||||
|
||||
context.macro(500, function()
|
||||
local target = g_game.getAttackingCreature()
|
||||
if context.storage.attackItem.enabled and target and context.getCreatureById(target:getId()) and context.storage.attackItem.item and context.storage.attackItem.item >= 100 then
|
||||
context.useWith(context.storage.attackItem.item, target)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
@@ -1,346 +1,346 @@
|
||||
local context = G.botContext
|
||||
local Panels = context.Panels
|
||||
|
||||
Panels.Haste = function(parent)
|
||||
context.macro(500, "Auto Haste", nil, function()
|
||||
if not context.hasHaste() and context.storage.autoHasteText:len() > 0 then
|
||||
if context.saySpell(context.storage.autoHasteText, 2500) then
|
||||
context.delay(5000)
|
||||
end
|
||||
end
|
||||
end, parent)
|
||||
context.addTextEdit("autoHasteText", context.storage.autoHasteText or "utani hur", function(widget, text)
|
||||
context.storage.autoHasteText = text
|
||||
end, parent)
|
||||
end
|
||||
|
||||
Panels.ManaShield = function(parent)
|
||||
local lastManaShield = 0
|
||||
context.macro(100, "Auto Mana Shield", nil, function()
|
||||
if not context.hasManaShield() or context.now > lastManaShield + 90000 then
|
||||
if context.saySpell("utamo vita", 200) then
|
||||
lastManaShield = context.now
|
||||
end
|
||||
end
|
||||
end, parent)
|
||||
end
|
||||
|
||||
Panels.AntiParalyze = function(parent)
|
||||
context.macro(100, "Anti Paralyze", nil, function()
|
||||
if context.isParalyzed() and context.storage.autoAntiParalyzeText:len() > 0 then
|
||||
context.saySpell(context.storage.autoAntiParalyzeText, 750)
|
||||
end
|
||||
end, parent)
|
||||
context.addTextEdit("autoAntiParalyzeText", context.storage.autoAntiParalyzeText or "utani hur", function(widget, text)
|
||||
context.storage.autoAntiParalyzeText = text
|
||||
end, parent)
|
||||
end
|
||||
|
||||
|
||||
Panels.Health = function(parent)
|
||||
if not parent then
|
||||
parent = context.panel
|
||||
end
|
||||
|
||||
local panelName = "autoHealthPanel"
|
||||
local panelId = 1
|
||||
while parent:getChildById(panelName .. panelId) do
|
||||
panelId = panelId + 1
|
||||
end
|
||||
panelName = panelName .. panelId
|
||||
|
||||
local ui = g_ui.createWidget("DualScrollPanel", parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
if not context.storage[panelName] then
|
||||
context.storage[panelName] = {
|
||||
item = 266,
|
||||
min = 20,
|
||||
max = 80,
|
||||
text = "exura"
|
||||
}
|
||||
end
|
||||
|
||||
ui.title:setOn(context.storage[panelName].enabled)
|
||||
ui.title.onClick = function(widget)
|
||||
context.storage[panelName].enabled = not context.storage[panelName].enabled
|
||||
widget:setOn(context.storage[panelName].enabled)
|
||||
end
|
||||
|
||||
ui.text.onTextChange = function(widget, text)
|
||||
context.storage[panelName].text = text
|
||||
end
|
||||
ui.text:setText(context.storage[panelName].text or "exura")
|
||||
|
||||
local updateText = function()
|
||||
ui.title:setText("" .. context.storage[panelName].min .. "% <= hp <= " .. context.storage[panelName].max .. "%")
|
||||
end
|
||||
|
||||
ui.scroll1.onValueChange = function(scroll, value)
|
||||
context.storage[panelName].min = value
|
||||
updateText()
|
||||
end
|
||||
ui.scroll2.onValueChange = function(scroll, value)
|
||||
context.storage[panelName].max = value
|
||||
updateText()
|
||||
end
|
||||
|
||||
ui.scroll1:setValue(context.storage[panelName].min)
|
||||
ui.scroll2:setValue(context.storage[panelName].max)
|
||||
|
||||
context.macro(25, function()
|
||||
if context.storage[panelName].enabled and context.storage[panelName].text:len() > 0 and context.storage[panelName].min <= context.hppercent() and context.hppercent() <= context.storage[panelName].max then
|
||||
if context.saySpell(context.storage[panelName].text, 500) then
|
||||
context.delay(200)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
Panels.HealthItem = function(parent)
|
||||
if not parent then
|
||||
parent = context.panel
|
||||
end
|
||||
|
||||
local panelName = "autoHealthItemPanel"
|
||||
local panelId = 1
|
||||
while parent:getChildById(panelName .. panelId) do
|
||||
panelId = panelId + 1
|
||||
end
|
||||
panelName = panelName .. panelId
|
||||
|
||||
local ui = g_ui.createWidget("DualScrollItemPanel", parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
if not context.storage[panelName] then
|
||||
context.storage[panelName] = {
|
||||
item = 266,
|
||||
min = 0,
|
||||
max = 60
|
||||
}
|
||||
end
|
||||
|
||||
ui.title:setOn(context.storage[panelName].enabled)
|
||||
ui.title.onClick = function(widget)
|
||||
context.storage[panelName].enabled = not context.storage[panelName].enabled
|
||||
widget:setOn(context.storage[panelName].enabled)
|
||||
end
|
||||
|
||||
ui.item.onItemChange = function(widget)
|
||||
context.storage[panelName].item = widget:getItemId()
|
||||
end
|
||||
ui.item:setItemId(context.storage[panelName].item)
|
||||
|
||||
local updateText = function()
|
||||
ui.title:setText("" .. (context.storage[panelName].min or "") .. "% <= hp <= " .. (context.storage[panelName].max or "") .. "%")
|
||||
end
|
||||
|
||||
ui.scroll1.onValueChange = function(scroll, value)
|
||||
context.storage[panelName].min = value
|
||||
updateText()
|
||||
end
|
||||
ui.scroll2.onValueChange = function(scroll, value)
|
||||
context.storage[panelName].max = value
|
||||
updateText()
|
||||
end
|
||||
|
||||
ui.scroll1:setValue(context.storage[panelName].min)
|
||||
ui.scroll2:setValue(context.storage[panelName].max)
|
||||
|
||||
context.macro(25, function()
|
||||
if context.storage[panelName].enabled and context.storage[panelName].item >= 100 and context.storage[panelName].min <= context.hppercent() and context.hppercent() <= context.storage[panelName].max then
|
||||
if context.useRune(context.storage[panelName].item, context.player, 500) then
|
||||
context.delay(300)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
Panels.Mana = function(parent)
|
||||
if not parent then
|
||||
parent = context.panel
|
||||
end
|
||||
|
||||
local panelName = "autoManaItemPanel"
|
||||
local panelId = 1
|
||||
while parent:getChildById(panelName .. panelId) do
|
||||
panelId = panelId + 1
|
||||
end
|
||||
panelName = panelName .. panelId
|
||||
|
||||
local ui = g_ui.createWidget("DualScrollItemPanel", parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
if not context.storage[panelName] then
|
||||
context.storage[panelName] = {
|
||||
item = 268,
|
||||
min = 0,
|
||||
max = 60
|
||||
}
|
||||
end
|
||||
|
||||
ui.title:setOn(context.storage[panelName].enabled)
|
||||
ui.title.onClick = function(widget)
|
||||
context.storage[panelName].enabled = not context.storage[panelName].enabled
|
||||
widget:setOn(context.storage[panelName].enabled)
|
||||
end
|
||||
|
||||
ui.item.onItemChange = function(widget)
|
||||
context.storage[panelName].item = widget:getItemId()
|
||||
end
|
||||
ui.item:setItemId(context.storage[panelName].item)
|
||||
|
||||
local updateText = function()
|
||||
ui.title:setText("" .. (context.storage[panelName].min or "") .. "% <= mana <= " .. (context.storage[panelName].max or "") .. "%")
|
||||
end
|
||||
|
||||
ui.scroll1.onValueChange = function(scroll, value)
|
||||
context.storage[panelName].min = value
|
||||
updateText()
|
||||
end
|
||||
ui.scroll2.onValueChange = function(scroll, value)
|
||||
context.storage[panelName].max = value
|
||||
updateText()
|
||||
end
|
||||
|
||||
ui.scroll1:setValue(context.storage[panelName].min)
|
||||
ui.scroll2:setValue(context.storage[panelName].max)
|
||||
|
||||
context.macro(25, function()
|
||||
if context.storage[panelName].enabled and context.storage[panelName].item >= 100 and context.storage[panelName].min <= context.manapercent() and context.manapercent() <= context.storage[panelName].max then
|
||||
if context.useRune(context.storage[panelName].item, context.player, 500) then
|
||||
context.delay(300)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
Panels.ManaItem = Panels.Mana
|
||||
|
||||
Panels.Equip = function(parent)
|
||||
if not parent then
|
||||
parent = context.panel
|
||||
end
|
||||
|
||||
local panelName = "autoEquipItem"
|
||||
local panelId = 1
|
||||
while parent:getChildById(panelName .. panelId) do
|
||||
panelId = panelId + 1
|
||||
end
|
||||
panelName = panelName .. panelId
|
||||
|
||||
local ui = g_ui.createWidget("TwoItemsAndSlotPanel", parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
if not context.storage[panelName] then
|
||||
context.storage[panelName] = {}
|
||||
if panelId == 1 then
|
||||
context.storage[panelName].item1 = 3052
|
||||
context.storage[panelName].item2 = 3089
|
||||
context.storage[panelName].slot = 9
|
||||
end
|
||||
end
|
||||
|
||||
ui.title:setText("Auto equip")
|
||||
ui.title:setOn(context.storage[panelName].enabled)
|
||||
ui.title.onClick = function(widget)
|
||||
context.storage[panelName].enabled = not context.storage[panelName].enabled
|
||||
widget:setOn(context.storage[panelName].enabled)
|
||||
end
|
||||
|
||||
ui.item1:setItemId(context.storage[panelName].item1 or 0)
|
||||
ui.item1.onItemChange = function(widget)
|
||||
context.storage[panelName].item1 = widget:getItemId()
|
||||
end
|
||||
|
||||
ui.item2:setItemId(context.storage[panelName].item2 or 0)
|
||||
ui.item2.onItemChange = function(widget)
|
||||
context.storage[panelName].item2 = widget:getItemId()
|
||||
end
|
||||
|
||||
if not context.storage[panelName].slot then
|
||||
context.storage[panelName].slot = 1
|
||||
end
|
||||
ui.slot:setCurrentIndex(context.storage[panelName].slot)
|
||||
ui.slot.onOptionChange = function(widget)
|
||||
context.storage[panelName].slot = widget.currentIndex
|
||||
end
|
||||
|
||||
context.macro(250, function()
|
||||
if context.storage[panelName].enabled and context.storage[panelName].slot > 0 then
|
||||
local item1 = context.storage[panelName].item1 or 0
|
||||
local item2 = context.storage[panelName].item2 or 0
|
||||
if item1 < 100 and item2 < 100 then
|
||||
return
|
||||
end
|
||||
local slotItem = context.getSlot(context.storage[panelName].slot)
|
||||
if slotItem and (slotItem:getId() == item1 or slotItem:getId() == item2) then
|
||||
return
|
||||
end
|
||||
local newItem = context.findItem(context.storage[panelName].item1)
|
||||
if not newItem then
|
||||
newItem = context.findItem(context.storage[panelName].item2)
|
||||
if not newItem then
|
||||
return
|
||||
end
|
||||
end
|
||||
g_game.move(newItem, {x=65535, y=context.storage[panelName].slot, z=0})
|
||||
context.delay(1000)
|
||||
end
|
||||
end)
|
||||
end
|
||||
Panels.AutoEquip = Panels.Equip
|
||||
|
||||
Panels.Eating = function(parent)
|
||||
if not parent then
|
||||
parent = context.panel
|
||||
end
|
||||
|
||||
local panelName = "autoEatingPanel"
|
||||
local panelId = 1
|
||||
while parent:getChildById(panelName .. panelId) do
|
||||
panelId = panelId + 1
|
||||
end
|
||||
panelName = panelName .. panelId
|
||||
|
||||
local ui = g_ui.createWidget("ItemsPanel", parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
if not context.storage[panelName] then
|
||||
context.storage[panelName] = {}
|
||||
end
|
||||
|
||||
ui.title:setText("Auto eating")
|
||||
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 = {3725, 0, 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(15000, function()
|
||||
if not context.storage[panelName].enabled then
|
||||
return
|
||||
end
|
||||
local candidates = {}
|
||||
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.use(candidates[math.random(1, #candidates)])
|
||||
end)
|
||||
end
|
||||
|
||||
local context = G.botContext
|
||||
local Panels = context.Panels
|
||||
|
||||
Panels.Haste = function(parent)
|
||||
context.macro(500, "Auto Haste", nil, function()
|
||||
if not context.hasHaste() and context.storage.autoHasteText:len() > 0 then
|
||||
if context.saySpell(context.storage.autoHasteText, 2500) then
|
||||
context.delay(5000)
|
||||
end
|
||||
end
|
||||
end, parent)
|
||||
context.addTextEdit("autoHasteText", context.storage.autoHasteText or "utani hur", function(widget, text)
|
||||
context.storage.autoHasteText = text
|
||||
end, parent)
|
||||
end
|
||||
|
||||
Panels.ManaShield = function(parent)
|
||||
local lastManaShield = 0
|
||||
context.macro(100, "Auto Mana Shield", nil, function()
|
||||
if not context.hasManaShield() or context.now > lastManaShield + 90000 then
|
||||
if context.saySpell("utamo vita", 200) then
|
||||
lastManaShield = context.now
|
||||
end
|
||||
end
|
||||
end, parent)
|
||||
end
|
||||
|
||||
Panels.AntiParalyze = function(parent)
|
||||
context.macro(100, "Anti Paralyze", nil, function()
|
||||
if context.isParalyzed() and context.storage.autoAntiParalyzeText:len() > 0 then
|
||||
context.saySpell(context.storage.autoAntiParalyzeText, 750)
|
||||
end
|
||||
end, parent)
|
||||
context.addTextEdit("autoAntiParalyzeText", context.storage.autoAntiParalyzeText or "utani hur", function(widget, text)
|
||||
context.storage.autoAntiParalyzeText = text
|
||||
end, parent)
|
||||
end
|
||||
|
||||
|
||||
Panels.Health = function(parent)
|
||||
if not parent then
|
||||
parent = context.panel
|
||||
end
|
||||
|
||||
local panelName = "autoHealthPanel"
|
||||
local panelId = 1
|
||||
while parent:getChildById(panelName .. panelId) do
|
||||
panelId = panelId + 1
|
||||
end
|
||||
panelName = panelName .. panelId
|
||||
|
||||
local ui = g_ui.createWidget("DualScrollPanel", parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
if not context.storage[panelName] then
|
||||
context.storage[panelName] = {
|
||||
item = 266,
|
||||
min = 20,
|
||||
max = 80,
|
||||
text = "exura"
|
||||
}
|
||||
end
|
||||
|
||||
ui.title:setOn(context.storage[panelName].enabled)
|
||||
ui.title.onClick = function(widget)
|
||||
context.storage[panelName].enabled = not context.storage[panelName].enabled
|
||||
widget:setOn(context.storage[panelName].enabled)
|
||||
end
|
||||
|
||||
ui.text.onTextChange = function(widget, text)
|
||||
context.storage[panelName].text = text
|
||||
end
|
||||
ui.text:setText(context.storage[panelName].text or "exura")
|
||||
|
||||
local updateText = function()
|
||||
ui.title:setText("" .. context.storage[panelName].min .. "% <= hp <= " .. context.storage[panelName].max .. "%")
|
||||
end
|
||||
|
||||
ui.scroll1.onValueChange = function(scroll, value)
|
||||
context.storage[panelName].min = value
|
||||
updateText()
|
||||
end
|
||||
ui.scroll2.onValueChange = function(scroll, value)
|
||||
context.storage[panelName].max = value
|
||||
updateText()
|
||||
end
|
||||
|
||||
ui.scroll1:setValue(context.storage[panelName].min)
|
||||
ui.scroll2:setValue(context.storage[panelName].max)
|
||||
|
||||
context.macro(25, function()
|
||||
if context.storage[panelName].enabled and context.storage[panelName].text:len() > 0 and context.storage[panelName].min <= context.hppercent() and context.hppercent() <= context.storage[panelName].max then
|
||||
if context.saySpell(context.storage[panelName].text, 500) then
|
||||
context.delay(200)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
Panels.HealthItem = function(parent)
|
||||
if not parent then
|
||||
parent = context.panel
|
||||
end
|
||||
|
||||
local panelName = "autoHealthItemPanel"
|
||||
local panelId = 1
|
||||
while parent:getChildById(panelName .. panelId) do
|
||||
panelId = panelId + 1
|
||||
end
|
||||
panelName = panelName .. panelId
|
||||
|
||||
local ui = g_ui.createWidget("DualScrollItemPanel", parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
if not context.storage[panelName] then
|
||||
context.storage[panelName] = {
|
||||
item = 266,
|
||||
min = 0,
|
||||
max = 60
|
||||
}
|
||||
end
|
||||
|
||||
ui.title:setOn(context.storage[panelName].enabled)
|
||||
ui.title.onClick = function(widget)
|
||||
context.storage[panelName].enabled = not context.storage[panelName].enabled
|
||||
widget:setOn(context.storage[panelName].enabled)
|
||||
end
|
||||
|
||||
ui.item.onItemChange = function(widget)
|
||||
context.storage[panelName].item = widget:getItemId()
|
||||
end
|
||||
ui.item:setItemId(context.storage[panelName].item)
|
||||
|
||||
local updateText = function()
|
||||
ui.title:setText("" .. (context.storage[panelName].min or "") .. "% <= hp <= " .. (context.storage[panelName].max or "") .. "%")
|
||||
end
|
||||
|
||||
ui.scroll1.onValueChange = function(scroll, value)
|
||||
context.storage[panelName].min = value
|
||||
updateText()
|
||||
end
|
||||
ui.scroll2.onValueChange = function(scroll, value)
|
||||
context.storage[panelName].max = value
|
||||
updateText()
|
||||
end
|
||||
|
||||
ui.scroll1:setValue(context.storage[panelName].min)
|
||||
ui.scroll2:setValue(context.storage[panelName].max)
|
||||
|
||||
context.macro(25, function()
|
||||
if context.storage[panelName].enabled and context.storage[panelName].item >= 100 and context.storage[panelName].min <= context.hppercent() and context.hppercent() <= context.storage[panelName].max then
|
||||
if context.useRune(context.storage[panelName].item, context.player, 500) then
|
||||
context.delay(300)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
Panels.Mana = function(parent)
|
||||
if not parent then
|
||||
parent = context.panel
|
||||
end
|
||||
|
||||
local panelName = "autoManaItemPanel"
|
||||
local panelId = 1
|
||||
while parent:getChildById(panelName .. panelId) do
|
||||
panelId = panelId + 1
|
||||
end
|
||||
panelName = panelName .. panelId
|
||||
|
||||
local ui = g_ui.createWidget("DualScrollItemPanel", parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
if not context.storage[panelName] then
|
||||
context.storage[panelName] = {
|
||||
item = 268,
|
||||
min = 0,
|
||||
max = 60
|
||||
}
|
||||
end
|
||||
|
||||
ui.title:setOn(context.storage[panelName].enabled)
|
||||
ui.title.onClick = function(widget)
|
||||
context.storage[panelName].enabled = not context.storage[panelName].enabled
|
||||
widget:setOn(context.storage[panelName].enabled)
|
||||
end
|
||||
|
||||
ui.item.onItemChange = function(widget)
|
||||
context.storage[panelName].item = widget:getItemId()
|
||||
end
|
||||
ui.item:setItemId(context.storage[panelName].item)
|
||||
|
||||
local updateText = function()
|
||||
ui.title:setText("" .. (context.storage[panelName].min or "") .. "% <= mana <= " .. (context.storage[panelName].max or "") .. "%")
|
||||
end
|
||||
|
||||
ui.scroll1.onValueChange = function(scroll, value)
|
||||
context.storage[panelName].min = value
|
||||
updateText()
|
||||
end
|
||||
ui.scroll2.onValueChange = function(scroll, value)
|
||||
context.storage[panelName].max = value
|
||||
updateText()
|
||||
end
|
||||
|
||||
ui.scroll1:setValue(context.storage[panelName].min)
|
||||
ui.scroll2:setValue(context.storage[panelName].max)
|
||||
|
||||
context.macro(25, function()
|
||||
if context.storage[panelName].enabled and context.storage[panelName].item >= 100 and context.storage[panelName].min <= context.manapercent() and context.manapercent() <= context.storage[panelName].max then
|
||||
if context.useRune(context.storage[panelName].item, context.player, 500) then
|
||||
context.delay(300)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
Panels.ManaItem = Panels.Mana
|
||||
|
||||
Panels.Equip = function(parent)
|
||||
if not parent then
|
||||
parent = context.panel
|
||||
end
|
||||
|
||||
local panelName = "autoEquipItem"
|
||||
local panelId = 1
|
||||
while parent:getChildById(panelName .. panelId) do
|
||||
panelId = panelId + 1
|
||||
end
|
||||
panelName = panelName .. panelId
|
||||
|
||||
local ui = g_ui.createWidget("TwoItemsAndSlotPanel", parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
if not context.storage[panelName] then
|
||||
context.storage[panelName] = {}
|
||||
if panelId == 1 then
|
||||
context.storage[panelName].item1 = 3052
|
||||
context.storage[panelName].item2 = 3089
|
||||
context.storage[panelName].slot = 9
|
||||
end
|
||||
end
|
||||
|
||||
ui.title:setText("Auto equip")
|
||||
ui.title:setOn(context.storage[panelName].enabled)
|
||||
ui.title.onClick = function(widget)
|
||||
context.storage[panelName].enabled = not context.storage[panelName].enabled
|
||||
widget:setOn(context.storage[panelName].enabled)
|
||||
end
|
||||
|
||||
ui.item1:setItemId(context.storage[panelName].item1 or 0)
|
||||
ui.item1.onItemChange = function(widget)
|
||||
context.storage[panelName].item1 = widget:getItemId()
|
||||
end
|
||||
|
||||
ui.item2:setItemId(context.storage[panelName].item2 or 0)
|
||||
ui.item2.onItemChange = function(widget)
|
||||
context.storage[panelName].item2 = widget:getItemId()
|
||||
end
|
||||
|
||||
if not context.storage[panelName].slot then
|
||||
context.storage[panelName].slot = 1
|
||||
end
|
||||
ui.slot:setCurrentIndex(context.storage[panelName].slot)
|
||||
ui.slot.onOptionChange = function(widget)
|
||||
context.storage[panelName].slot = widget.currentIndex
|
||||
end
|
||||
|
||||
context.macro(250, function()
|
||||
if context.storage[panelName].enabled and context.storage[panelName].slot > 0 then
|
||||
local item1 = context.storage[panelName].item1 or 0
|
||||
local item2 = context.storage[panelName].item2 or 0
|
||||
if item1 < 100 and item2 < 100 then
|
||||
return
|
||||
end
|
||||
local slotItem = context.getSlot(context.storage[panelName].slot)
|
||||
if slotItem and (slotItem:getId() == item1 or slotItem:getId() == item2) then
|
||||
return
|
||||
end
|
||||
local newItem = context.findItem(context.storage[panelName].item1)
|
||||
if not newItem then
|
||||
newItem = context.findItem(context.storage[panelName].item2)
|
||||
if not newItem then
|
||||
return
|
||||
end
|
||||
end
|
||||
g_game.move(newItem, {x=65535, y=context.storage[panelName].slot, z=0})
|
||||
context.delay(1000)
|
||||
end
|
||||
end)
|
||||
end
|
||||
Panels.AutoEquip = Panels.Equip
|
||||
|
||||
Panels.Eating = function(parent)
|
||||
if not parent then
|
||||
parent = context.panel
|
||||
end
|
||||
|
||||
local panelName = "autoEatingPanel"
|
||||
local panelId = 1
|
||||
while parent:getChildById(panelName .. panelId) do
|
||||
panelId = panelId + 1
|
||||
end
|
||||
panelName = panelName .. panelId
|
||||
|
||||
local ui = g_ui.createWidget("ItemsPanel", parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
if not context.storage[panelName] then
|
||||
context.storage[panelName] = {}
|
||||
end
|
||||
|
||||
ui.title:setText("Auto eating")
|
||||
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 = {3725, 0, 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(15000, function()
|
||||
if not context.storage[panelName].enabled then
|
||||
return
|
||||
end
|
||||
local candidates = {}
|
||||
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.use(candidates[math.random(1, #candidates)])
|
||||
end)
|
||||
end
|
||||
|
||||
|
@@ -1,431 +1,431 @@
|
||||
local context = G.botContext
|
||||
local Panels = context.Panels
|
||||
|
||||
Panels.Looting = function(parent)
|
||||
local ui = context.setupUI([[
|
||||
Panel
|
||||
id: looting
|
||||
height: 180
|
||||
|
||||
BotLabel
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
text: Looting
|
||||
|
||||
ComboBox
|
||||
id: config
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
margin-top: 5
|
||||
text-offset: 3 0
|
||||
width: 130
|
||||
|
||||
Button
|
||||
id: enableButton
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
anchors.right: parent.right
|
||||
margin-left: 5
|
||||
|
||||
Button
|
||||
margin-top: 1
|
||||
id: add
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
text: Add
|
||||
width: 60
|
||||
height: 17
|
||||
|
||||
Button
|
||||
id: edit
|
||||
anchors.top: prev.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: Edit
|
||||
width: 60
|
||||
height: 17
|
||||
|
||||
Button
|
||||
id: remove
|
||||
anchors.top: prev.top
|
||||
anchors.right: parent.right
|
||||
text: Remove
|
||||
width: 60
|
||||
height: 17
|
||||
|
||||
ScrollablePanel
|
||||
id: items
|
||||
anchors.top: prev.bottom
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
vertical-scrollbar: scrollBar
|
||||
margin-right: 5
|
||||
margin-top: 2
|
||||
height: 70
|
||||
layout:
|
||||
type: grid
|
||||
cell-size: 34 34
|
||||
flow: true
|
||||
|
||||
BotSmallScrollBar
|
||||
id: scrollBar
|
||||
anchors.top: prev.top
|
||||
anchors.bottom: prev.bottom
|
||||
anchors.right: parent.right
|
||||
step: 10
|
||||
pixels-scroll: true
|
||||
|
||||
BotLabel
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
margin-top: 4
|
||||
text: Loot Containers
|
||||
|
||||
ItemsRow
|
||||
id: containers
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: 33
|
||||
margin-top: 2
|
||||
|
||||
]], parent)
|
||||
|
||||
local lootContainers = { ui.containers.item1, ui.containers.item2, ui.containers.item3, ui.containers.item4, ui.containers.item5 }
|
||||
|
||||
if type(context.storage.looting) ~= "table" then
|
||||
context.storage.looting = {}
|
||||
end
|
||||
if type(context.storage.looting.configs) ~= "table" then
|
||||
context.storage.looting.configs = {}
|
||||
end
|
||||
|
||||
local getConfigName = function(config)
|
||||
local matches = regexMatch(config, [[name:\s*([^\n]*)$]])
|
||||
if matches[1] and matches[1][2] then
|
||||
return matches[1][2]:trim()
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local items = {}
|
||||
local itemsByKey = {}
|
||||
local containers = {}
|
||||
local commands = {}
|
||||
local refreshConfig = nil -- declared later
|
||||
|
||||
local createNewConfig = function(focusedWidget)
|
||||
if not context.storage.looting.activeConfig or not context.storage.looting.configs[context.storage.looting.activeConfig] then
|
||||
return
|
||||
end
|
||||
|
||||
local tmpItems = {}
|
||||
local tmpContainers = {}
|
||||
local focusIndex = 0
|
||||
|
||||
local newConfig = ""
|
||||
for i, text in ipairs(commands) do
|
||||
newConfig = newConfig .. text .. "\n"
|
||||
end
|
||||
for i=1,ui.items:getChildCount() do
|
||||
local widget = ui.items:getChildByIndex(i)
|
||||
if widget and widget:getItemId() >= 100 then
|
||||
if tmpItems[widget:getItemId()] == nil then
|
||||
tmpItems[widget:getItemId()] = 1
|
||||
newConfig = newConfig .. "\n" .. widget:getItemId()
|
||||
end
|
||||
end
|
||||
if widget == focusedWidget then
|
||||
focusIndex = i
|
||||
end
|
||||
end
|
||||
for i, widget in ipairs(lootContainers) do
|
||||
if widget:getItemId() >= 100 then
|
||||
if tmpContainers[widget:getItemId()] == nil then
|
||||
tmpContainers[widget:getItemId()] = 1 -- remove duplicates
|
||||
newConfig = newConfig .. "\ncontainer:" .. widget:getItemId()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context.storage.looting.configs[context.storage.looting.activeConfig] = newConfig
|
||||
refreshConfig(focusIndex)
|
||||
end
|
||||
|
||||
local parseConfig = function(config)
|
||||
items = {}
|
||||
itemsByKey = {}
|
||||
containers = {}
|
||||
commands = {}
|
||||
local matches = regexMatch(config, [[([^:^\n^\s]+)(:?)([^\n]*)]])
|
||||
for i=1,#matches do
|
||||
local command = matches[i][2]
|
||||
local validation = (matches[i][3] == ":")
|
||||
local text = matches[i][4]
|
||||
local commandAsNumber = tonumber(command)
|
||||
local textAsNumber = tonumber(text)
|
||||
if commandAsNumber and commandAsNumber >= 100 then
|
||||
table.insert(items, commandAsNumber)
|
||||
itemsByKey[commandAsNumber] = 1
|
||||
elseif command == "container" and validation and textAsNumber and textAsNumber >= 100 then
|
||||
containers[textAsNumber] = 1
|
||||
elseif validation then
|
||||
table.insert(commands, command .. ":" .. text)
|
||||
end
|
||||
end
|
||||
|
||||
local itemsToShow = #items + 2
|
||||
if itemsToShow % 5 ~= 0 then
|
||||
itemsToShow = itemsToShow + 5 - itemsToShow % 5
|
||||
end
|
||||
if itemsToShow < 10 then
|
||||
itemsToShow = 10
|
||||
end
|
||||
|
||||
for i=1,itemsToShow do
|
||||
local widget = g_ui.createWidget("BotItem", ui.items)
|
||||
local itemId = 0
|
||||
if i <= #items then
|
||||
itemId = items[i]
|
||||
end
|
||||
widget:setItemId(itemId)
|
||||
widget.onItemChange = createNewConfig
|
||||
end
|
||||
|
||||
for i, widget in ipairs(lootContainers) do
|
||||
widget:setItemId(0)
|
||||
end
|
||||
local containerIndex = 1
|
||||
for containerId, i in pairs(containers) do
|
||||
if lootContainers[containerIndex] then
|
||||
lootContainers[containerIndex]:setItemId(containerId)
|
||||
end
|
||||
containerIndex = containerIndex + 1
|
||||
end
|
||||
for i, widget in ipairs(lootContainers) do
|
||||
widget.onItemChange = createNewConfig
|
||||
end
|
||||
end
|
||||
|
||||
local ignoreOnOptionChange = true
|
||||
refreshConfig = function(focusIndex)
|
||||
ignoreOnOptionChange = true
|
||||
if context.storage.looting.enabled then
|
||||
ui.enableButton:setText("On")
|
||||
ui.enableButton:setColor('#00AA00FF')
|
||||
else
|
||||
ui.enableButton:setText("Off")
|
||||
ui.enableButton:setColor('#FF0000FF')
|
||||
end
|
||||
|
||||
ui.config:clear()
|
||||
for i, config in ipairs(context.storage.looting.configs) do
|
||||
local name = getConfigName(config)
|
||||
if not name then
|
||||
name = "Unnamed config"
|
||||
end
|
||||
ui.config:addOption(name)
|
||||
end
|
||||
|
||||
if (not context.storage.looting.activeConfig or context.storage.looting.activeConfig == 0) and #context.storage.looting.configs > 0 then
|
||||
context.storage.looting.activeConfig = 1
|
||||
end
|
||||
|
||||
ui.items:destroyChildren()
|
||||
for i, widget in ipairs(lootContainers) do
|
||||
widget.onItemChange = nil
|
||||
widget:setItemId(0)
|
||||
widget:setItemCount(0)
|
||||
end
|
||||
|
||||
if context.storage.looting.activeConfig and context.storage.looting.configs[context.storage.looting.activeConfig] then
|
||||
ui.config:setCurrentIndex(context.storage.looting.activeConfig)
|
||||
parseConfig(context.storage.looting.configs[context.storage.looting.activeConfig])
|
||||
end
|
||||
|
||||
context.saveConfig()
|
||||
if focusIndex and focusIndex > 0 and ui.items:getChildByIndex(focusIndex) then
|
||||
ui.items:focusChild(ui.items:getChildByIndex(focusIndex))
|
||||
end
|
||||
|
||||
ignoreOnOptionChange = false
|
||||
end
|
||||
|
||||
ui.config.onOptionChange = function(widget)
|
||||
if not ignoreOnOptionChange then
|
||||
context.storage.looting.activeConfig = widget.currentIndex
|
||||
refreshConfig()
|
||||
end
|
||||
end
|
||||
ui.enableButton.onClick = function()
|
||||
if not context.storage.looting.activeConfig or not context.storage.looting.configs[context.storage.looting.activeConfig] then
|
||||
return
|
||||
end
|
||||
context.storage.looting.enabled = not context.storage.looting.enabled
|
||||
refreshConfig()
|
||||
end
|
||||
ui.add.onClick = function()
|
||||
modules.client_textedit.multilineEditor("Looting editor", "name:Config name", function(newText)
|
||||
table.insert(context.storage.looting.configs, newText)
|
||||
context.storage.looting.activeConfig = #context.storage.looting.configs
|
||||
refreshConfig()
|
||||
end)
|
||||
end
|
||||
ui.edit.onClick = function()
|
||||
if not context.storage.looting.activeConfig or not context.storage.looting.configs[context.storage.looting.activeConfig] then
|
||||
return
|
||||
end
|
||||
modules.client_textedit.multilineEditor("Looting editor", context.storage.looting.configs[context.storage.looting.activeConfig], function(newText)
|
||||
context.storage.looting.configs[context.storage.looting.activeConfig] = newText
|
||||
refreshConfig()
|
||||
end)
|
||||
end
|
||||
ui.remove.onClick = function()
|
||||
if not context.storage.looting.activeConfig or not context.storage.looting.configs[context.storage.looting.activeConfig] then
|
||||
return
|
||||
end
|
||||
local questionWindow = nil
|
||||
local closeWindow = function()
|
||||
questionWindow:destroy()
|
||||
end
|
||||
local removeConfig = function()
|
||||
closeWindow()
|
||||
if not context.storage.looting.activeConfig or not context.storage.looting.configs[context.storage.looting.activeConfig] then
|
||||
return
|
||||
end
|
||||
context.storage.looting.enabled = false
|
||||
table.remove(context.storage.looting.configs, context.storage.looting.activeConfig)
|
||||
context.storage.looting.activeConfig = 0
|
||||
refreshConfig()
|
||||
end
|
||||
questionWindow = context.displayGeneralBox(tr('Remove config'), tr('Do you want to remove current looting config?'), {
|
||||
{ text=tr('Yes'), callback=removeConfig },
|
||||
{ text=tr('No'), callback=closeWindow },
|
||||
anchor=AnchorHorizontalCenter}, removeConfig, closeWindow)
|
||||
end
|
||||
refreshConfig()
|
||||
|
||||
context.onContainerOpen(function(container, prevContainer)
|
||||
if context.storage.attacking.enabled then
|
||||
return
|
||||
end
|
||||
if prevContainer then
|
||||
container.autoLooting = prevContainer.autoLooting
|
||||
else
|
||||
container.autoLooting = true
|
||||
end
|
||||
end)
|
||||
|
||||
context.macro(200, function()
|
||||
if not context.storage.looting.enabled then
|
||||
return
|
||||
end
|
||||
local candidates = {}
|
||||
local lootContainersCandidates = {}
|
||||
for containerId, container in pairs(g_game.getContainers()) do
|
||||
local containerItem = container:getContainerItem()
|
||||
if container.autoLooting and container:getItemsCount() > 0 and (not containerItem or containers[containerItem:getId()] == nil) then
|
||||
table.insert(candidates, container)
|
||||
elseif containerItem and containers[containerItem:getId()] ~= nil then
|
||||
table.insert(lootContainersCandidates, container)
|
||||
end
|
||||
end
|
||||
if #lootContainersCandidates == 0 then
|
||||
for slot = InventorySlotFirst, InventorySlotLast do
|
||||
local item = context.getInventoryItem(slot)
|
||||
if item and item:isContainer() and containers[item:getId()] ~= nil then
|
||||
table.insert(lootContainersCandidates, item)
|
||||
end
|
||||
end
|
||||
if #lootContainersCandidates > 0 then
|
||||
-- try to open inventory backpack
|
||||
local target = lootContainersCandidates[math.random(1,#lootContainersCandidates)]
|
||||
g_game.open(target, nil)
|
||||
context.delay(200)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if #candidates == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local container = candidates[math.random(1,#candidates)]
|
||||
local nextContainers = {}
|
||||
local foundItem = nil
|
||||
for i, item in ipairs(container:getItems()) do
|
||||
if item:isContainer() then
|
||||
table.insert(nextContainers, item)
|
||||
elseif itemsByKey[item:getId()] ~= nil then
|
||||
foundItem = item
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- found item to loot
|
||||
if foundItem then
|
||||
-- find backpack for it, first backpack with same items
|
||||
for i, container in ipairs(lootContainersCandidates) do
|
||||
if container:getItemsCount() < container:getCapacity() or foundItem:isStackable() then -- has space
|
||||
for j, item in ipairs(container:getItems()) do
|
||||
if item:getId() == foundItem:getId() then
|
||||
if foundItem:isStackable() then
|
||||
if item:getCount() ~= 100 then
|
||||
g_game.move(foundItem, container:getSlotPosition(j - 1), foundItem:getCount())
|
||||
return
|
||||
end
|
||||
else
|
||||
g_game.move(foundItem, container:getSlotPosition(container:getItemsCount()), foundItem:getCount())
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- now any backpack with empty slot
|
||||
for i, container in ipairs(lootContainersCandidates) do
|
||||
if container:getItemsCount() < container:getCapacity() then -- has space
|
||||
g_game.move(foundItem, container:getSlotPosition(container:getItemsCount()), foundItem:getCount())
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- can't find backpack, try to open new
|
||||
for i, container in ipairs(lootContainersCandidates) do
|
||||
local candidates = {}
|
||||
for j, item in ipairs(container:getItems()) do
|
||||
if item:isContainer() and containers[item:getId()] ~= nil then
|
||||
table.insert(candidates, item)
|
||||
end
|
||||
end
|
||||
if #candidates > 0 then
|
||||
g_game.open(candidates[math.random(1,#candidates)], container)
|
||||
return
|
||||
end
|
||||
-- full, close it
|
||||
g_game.close(container)
|
||||
return
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
-- open remaining containers
|
||||
if #nextContainers == 0 then
|
||||
return
|
||||
end
|
||||
local delay = 1
|
||||
for i=2,#nextContainers do
|
||||
-- if more than 1 container, open them in new window
|
||||
context.schedule(delay, function()
|
||||
g_game.open(nextContainers[i], nil)
|
||||
end)
|
||||
delay = delay + 250
|
||||
end
|
||||
context.schedule(delay, function()
|
||||
g_game.open(nextContainers[1], container)
|
||||
end)
|
||||
context.delay(150 + delay)
|
||||
end)
|
||||
end
|
||||
|
||||
local context = G.botContext
|
||||
local Panels = context.Panels
|
||||
|
||||
Panels.Looting = function(parent)
|
||||
local ui = context.setupUI([[
|
||||
Panel
|
||||
id: looting
|
||||
height: 180
|
||||
|
||||
BotLabel
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
text: Looting
|
||||
|
||||
ComboBox
|
||||
id: config
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
margin-top: 5
|
||||
text-offset: 3 0
|
||||
width: 130
|
||||
|
||||
Button
|
||||
id: enableButton
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
anchors.right: parent.right
|
||||
margin-left: 5
|
||||
|
||||
Button
|
||||
margin-top: 1
|
||||
id: add
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
text: Add
|
||||
width: 60
|
||||
height: 17
|
||||
|
||||
Button
|
||||
id: edit
|
||||
anchors.top: prev.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: Edit
|
||||
width: 60
|
||||
height: 17
|
||||
|
||||
Button
|
||||
id: remove
|
||||
anchors.top: prev.top
|
||||
anchors.right: parent.right
|
||||
text: Remove
|
||||
width: 60
|
||||
height: 17
|
||||
|
||||
ScrollablePanel
|
||||
id: items
|
||||
anchors.top: prev.bottom
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
vertical-scrollbar: scrollBar
|
||||
margin-right: 5
|
||||
margin-top: 2
|
||||
height: 70
|
||||
layout:
|
||||
type: grid
|
||||
cell-size: 34 34
|
||||
flow: true
|
||||
|
||||
BotSmallScrollBar
|
||||
id: scrollBar
|
||||
anchors.top: prev.top
|
||||
anchors.bottom: prev.bottom
|
||||
anchors.right: parent.right
|
||||
step: 10
|
||||
pixels-scroll: true
|
||||
|
||||
BotLabel
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
margin-top: 4
|
||||
text: Loot Containers
|
||||
|
||||
ItemsRow
|
||||
id: containers
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: 33
|
||||
margin-top: 2
|
||||
|
||||
]], parent)
|
||||
|
||||
local lootContainers = { ui.containers.item1, ui.containers.item2, ui.containers.item3, ui.containers.item4, ui.containers.item5 }
|
||||
|
||||
if type(context.storage.looting) ~= "table" then
|
||||
context.storage.looting = {}
|
||||
end
|
||||
if type(context.storage.looting.configs) ~= "table" then
|
||||
context.storage.looting.configs = {}
|
||||
end
|
||||
|
||||
local getConfigName = function(config)
|
||||
local matches = regexMatch(config, [[name:\s*([^\n]*)$]])
|
||||
if matches[1] and matches[1][2] then
|
||||
return matches[1][2]:trim()
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local items = {}
|
||||
local itemsByKey = {}
|
||||
local containers = {}
|
||||
local commands = {}
|
||||
local refreshConfig = nil -- declared later
|
||||
|
||||
local createNewConfig = function(focusedWidget)
|
||||
if not context.storage.looting.activeConfig or not context.storage.looting.configs[context.storage.looting.activeConfig] then
|
||||
return
|
||||
end
|
||||
|
||||
local tmpItems = {}
|
||||
local tmpContainers = {}
|
||||
local focusIndex = 0
|
||||
|
||||
local newConfig = ""
|
||||
for i, text in ipairs(commands) do
|
||||
newConfig = newConfig .. text .. "\n"
|
||||
end
|
||||
for i=1,ui.items:getChildCount() do
|
||||
local widget = ui.items:getChildByIndex(i)
|
||||
if widget and widget:getItemId() >= 100 then
|
||||
if tmpItems[widget:getItemId()] == nil then
|
||||
tmpItems[widget:getItemId()] = 1
|
||||
newConfig = newConfig .. "\n" .. widget:getItemId()
|
||||
end
|
||||
end
|
||||
if widget == focusedWidget then
|
||||
focusIndex = i
|
||||
end
|
||||
end
|
||||
for i, widget in ipairs(lootContainers) do
|
||||
if widget:getItemId() >= 100 then
|
||||
if tmpContainers[widget:getItemId()] == nil then
|
||||
tmpContainers[widget:getItemId()] = 1 -- remove duplicates
|
||||
newConfig = newConfig .. "\ncontainer:" .. widget:getItemId()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context.storage.looting.configs[context.storage.looting.activeConfig] = newConfig
|
||||
refreshConfig(focusIndex)
|
||||
end
|
||||
|
||||
local parseConfig = function(config)
|
||||
items = {}
|
||||
itemsByKey = {}
|
||||
containers = {}
|
||||
commands = {}
|
||||
local matches = regexMatch(config, [[([^:^\n^\s]+)(:?)([^\n]*)]])
|
||||
for i=1,#matches do
|
||||
local command = matches[i][2]
|
||||
local validation = (matches[i][3] == ":")
|
||||
local text = matches[i][4]
|
||||
local commandAsNumber = tonumber(command)
|
||||
local textAsNumber = tonumber(text)
|
||||
if commandAsNumber and commandAsNumber >= 100 then
|
||||
table.insert(items, commandAsNumber)
|
||||
itemsByKey[commandAsNumber] = 1
|
||||
elseif command == "container" and validation and textAsNumber and textAsNumber >= 100 then
|
||||
containers[textAsNumber] = 1
|
||||
elseif validation then
|
||||
table.insert(commands, command .. ":" .. text)
|
||||
end
|
||||
end
|
||||
|
||||
local itemsToShow = #items + 2
|
||||
if itemsToShow % 5 ~= 0 then
|
||||
itemsToShow = itemsToShow + 5 - itemsToShow % 5
|
||||
end
|
||||
if itemsToShow < 10 then
|
||||
itemsToShow = 10
|
||||
end
|
||||
|
||||
for i=1,itemsToShow do
|
||||
local widget = g_ui.createWidget("BotItem", ui.items)
|
||||
local itemId = 0
|
||||
if i <= #items then
|
||||
itemId = items[i]
|
||||
end
|
||||
widget:setItemId(itemId)
|
||||
widget.onItemChange = createNewConfig
|
||||
end
|
||||
|
||||
for i, widget in ipairs(lootContainers) do
|
||||
widget:setItemId(0)
|
||||
end
|
||||
local containerIndex = 1
|
||||
for containerId, i in pairs(containers) do
|
||||
if lootContainers[containerIndex] then
|
||||
lootContainers[containerIndex]:setItemId(containerId)
|
||||
end
|
||||
containerIndex = containerIndex + 1
|
||||
end
|
||||
for i, widget in ipairs(lootContainers) do
|
||||
widget.onItemChange = createNewConfig
|
||||
end
|
||||
end
|
||||
|
||||
local ignoreOnOptionChange = true
|
||||
refreshConfig = function(focusIndex)
|
||||
ignoreOnOptionChange = true
|
||||
if context.storage.looting.enabled then
|
||||
ui.enableButton:setText("On")
|
||||
ui.enableButton:setColor('#00AA00FF')
|
||||
else
|
||||
ui.enableButton:setText("Off")
|
||||
ui.enableButton:setColor('#FF0000FF')
|
||||
end
|
||||
|
||||
ui.config:clear()
|
||||
for i, config in ipairs(context.storage.looting.configs) do
|
||||
local name = getConfigName(config)
|
||||
if not name then
|
||||
name = "Unnamed config"
|
||||
end
|
||||
ui.config:addOption(name)
|
||||
end
|
||||
|
||||
if (not context.storage.looting.activeConfig or context.storage.looting.activeConfig == 0) and #context.storage.looting.configs > 0 then
|
||||
context.storage.looting.activeConfig = 1
|
||||
end
|
||||
|
||||
ui.items:destroyChildren()
|
||||
for i, widget in ipairs(lootContainers) do
|
||||
widget.onItemChange = nil
|
||||
widget:setItemId(0)
|
||||
widget:setItemCount(0)
|
||||
end
|
||||
|
||||
if context.storage.looting.activeConfig and context.storage.looting.configs[context.storage.looting.activeConfig] then
|
||||
ui.config:setCurrentIndex(context.storage.looting.activeConfig)
|
||||
parseConfig(context.storage.looting.configs[context.storage.looting.activeConfig])
|
||||
end
|
||||
|
||||
context.saveConfig()
|
||||
if focusIndex and focusIndex > 0 and ui.items:getChildByIndex(focusIndex) then
|
||||
ui.items:focusChild(ui.items:getChildByIndex(focusIndex))
|
||||
end
|
||||
|
||||
ignoreOnOptionChange = false
|
||||
end
|
||||
|
||||
ui.config.onOptionChange = function(widget)
|
||||
if not ignoreOnOptionChange then
|
||||
context.storage.looting.activeConfig = widget.currentIndex
|
||||
refreshConfig()
|
||||
end
|
||||
end
|
||||
ui.enableButton.onClick = function()
|
||||
if not context.storage.looting.activeConfig or not context.storage.looting.configs[context.storage.looting.activeConfig] then
|
||||
return
|
||||
end
|
||||
context.storage.looting.enabled = not context.storage.looting.enabled
|
||||
refreshConfig()
|
||||
end
|
||||
ui.add.onClick = function()
|
||||
modules.client_textedit.multilineEditor("Looting editor", "name:Config name", function(newText)
|
||||
table.insert(context.storage.looting.configs, newText)
|
||||
context.storage.looting.activeConfig = #context.storage.looting.configs
|
||||
refreshConfig()
|
||||
end)
|
||||
end
|
||||
ui.edit.onClick = function()
|
||||
if not context.storage.looting.activeConfig or not context.storage.looting.configs[context.storage.looting.activeConfig] then
|
||||
return
|
||||
end
|
||||
modules.client_textedit.multilineEditor("Looting editor", context.storage.looting.configs[context.storage.looting.activeConfig], function(newText)
|
||||
context.storage.looting.configs[context.storage.looting.activeConfig] = newText
|
||||
refreshConfig()
|
||||
end)
|
||||
end
|
||||
ui.remove.onClick = function()
|
||||
if not context.storage.looting.activeConfig or not context.storage.looting.configs[context.storage.looting.activeConfig] then
|
||||
return
|
||||
end
|
||||
local questionWindow = nil
|
||||
local closeWindow = function()
|
||||
questionWindow:destroy()
|
||||
end
|
||||
local removeConfig = function()
|
||||
closeWindow()
|
||||
if not context.storage.looting.activeConfig or not context.storage.looting.configs[context.storage.looting.activeConfig] then
|
||||
return
|
||||
end
|
||||
context.storage.looting.enabled = false
|
||||
table.remove(context.storage.looting.configs, context.storage.looting.activeConfig)
|
||||
context.storage.looting.activeConfig = 0
|
||||
refreshConfig()
|
||||
end
|
||||
questionWindow = context.displayGeneralBox(tr('Remove config'), tr('Do you want to remove current looting config?'), {
|
||||
{ text=tr('Yes'), callback=removeConfig },
|
||||
{ text=tr('No'), callback=closeWindow },
|
||||
anchor=AnchorHorizontalCenter}, removeConfig, closeWindow)
|
||||
end
|
||||
refreshConfig()
|
||||
|
||||
context.onContainerOpen(function(container, prevContainer)
|
||||
if context.storage.attacking.enabled then
|
||||
return
|
||||
end
|
||||
if prevContainer then
|
||||
container.autoLooting = prevContainer.autoLooting
|
||||
else
|
||||
container.autoLooting = true
|
||||
end
|
||||
end)
|
||||
|
||||
context.macro(200, function()
|
||||
if not context.storage.looting.enabled then
|
||||
return
|
||||
end
|
||||
local candidates = {}
|
||||
local lootContainersCandidates = {}
|
||||
for containerId, container in pairs(g_game.getContainers()) do
|
||||
local containerItem = container:getContainerItem()
|
||||
if container.autoLooting and container:getItemsCount() > 0 and (not containerItem or containers[containerItem:getId()] == nil) then
|
||||
table.insert(candidates, container)
|
||||
elseif containerItem and containers[containerItem:getId()] ~= nil then
|
||||
table.insert(lootContainersCandidates, container)
|
||||
end
|
||||
end
|
||||
if #lootContainersCandidates == 0 then
|
||||
for slot = InventorySlotFirst, InventorySlotLast do
|
||||
local item = context.getInventoryItem(slot)
|
||||
if item and item:isContainer() and containers[item:getId()] ~= nil then
|
||||
table.insert(lootContainersCandidates, item)
|
||||
end
|
||||
end
|
||||
if #lootContainersCandidates > 0 then
|
||||
-- try to open inventory backpack
|
||||
local target = lootContainersCandidates[math.random(1,#lootContainersCandidates)]
|
||||
g_game.open(target, nil)
|
||||
context.delay(200)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if #candidates == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local container = candidates[math.random(1,#candidates)]
|
||||
local nextContainers = {}
|
||||
local foundItem = nil
|
||||
for i, item in ipairs(container:getItems()) do
|
||||
if item:isContainer() then
|
||||
table.insert(nextContainers, item)
|
||||
elseif itemsByKey[item:getId()] ~= nil then
|
||||
foundItem = item
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- found item to loot
|
||||
if foundItem then
|
||||
-- find backpack for it, first backpack with same items
|
||||
for i, container in ipairs(lootContainersCandidates) do
|
||||
if container:getItemsCount() < container:getCapacity() or foundItem:isStackable() then -- has space
|
||||
for j, item in ipairs(container:getItems()) do
|
||||
if item:getId() == foundItem:getId() then
|
||||
if foundItem:isStackable() then
|
||||
if item:getCount() ~= 100 then
|
||||
g_game.move(foundItem, container:getSlotPosition(j - 1), foundItem:getCount())
|
||||
return
|
||||
end
|
||||
else
|
||||
g_game.move(foundItem, container:getSlotPosition(container:getItemsCount()), foundItem:getCount())
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- now any backpack with empty slot
|
||||
for i, container in ipairs(lootContainersCandidates) do
|
||||
if container:getItemsCount() < container:getCapacity() then -- has space
|
||||
g_game.move(foundItem, container:getSlotPosition(container:getItemsCount()), foundItem:getCount())
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- can't find backpack, try to open new
|
||||
for i, container in ipairs(lootContainersCandidates) do
|
||||
local candidates = {}
|
||||
for j, item in ipairs(container:getItems()) do
|
||||
if item:isContainer() and containers[item:getId()] ~= nil then
|
||||
table.insert(candidates, item)
|
||||
end
|
||||
end
|
||||
if #candidates > 0 then
|
||||
g_game.open(candidates[math.random(1,#candidates)], container)
|
||||
return
|
||||
end
|
||||
-- full, close it
|
||||
g_game.close(container)
|
||||
return
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
-- open remaining containers
|
||||
if #nextContainers == 0 then
|
||||
return
|
||||
end
|
||||
local delay = 1
|
||||
for i=2,#nextContainers do
|
||||
-- if more than 1 container, open them in new window
|
||||
context.schedule(delay, function()
|
||||
g_game.open(nextContainers[i], nil)
|
||||
end)
|
||||
delay = delay + 250
|
||||
end
|
||||
context.schedule(delay, function()
|
||||
g_game.open(nextContainers[1], container)
|
||||
end)
|
||||
context.delay(150 + delay)
|
||||
end)
|
||||
end
|
||||
|
||||
|
@@ -1,36 +1,36 @@
|
||||
local context = G.botContext
|
||||
local Panels = context.Panels
|
||||
|
||||
Panels.TradeMessage = function(parent)
|
||||
context.macro(60000, "Send message on trade", nil, function()
|
||||
local trade = context.getChannelId("advertising")
|
||||
if not trade then
|
||||
trade = context.getChannelId("trade")
|
||||
end
|
||||
if context.storage.autoTradeMessage:len() > 0 and trade then
|
||||
context.sayChannel(trade, context.storage.autoTradeMessage)
|
||||
end
|
||||
end, parent)
|
||||
context.addTextEdit("autoTradeMessage", context.storage.autoTradeMessage or "I'm using OTClientV8 - https://github.com/OTCv8/otclientv8", function(widget, text)
|
||||
context.storage.autoTradeMessage = text
|
||||
end, parent)
|
||||
end
|
||||
|
||||
Panels.AutoStackItems = function(parent)
|
||||
context.macro(500, "Auto stacking items", nil, function()
|
||||
local containers = context.getContainers()
|
||||
for i, container in pairs(containers) do
|
||||
local toStack = {}
|
||||
for j, item in ipairs(container:getItems()) do
|
||||
if item:isStackable() and item:getCount() ~= 100 then
|
||||
local otherItem = toStack[item:getId()]
|
||||
if otherItem then
|
||||
g_game.move(item, otherItem, item:getCount())
|
||||
return
|
||||
end
|
||||
toStack[item:getId()] = container:getSlotPosition(j - 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end, parent)
|
||||
local context = G.botContext
|
||||
local Panels = context.Panels
|
||||
|
||||
Panels.TradeMessage = function(parent)
|
||||
context.macro(60000, "Send message on trade", nil, function()
|
||||
local trade = context.getChannelId("advertising")
|
||||
if not trade then
|
||||
trade = context.getChannelId("trade")
|
||||
end
|
||||
if context.storage.autoTradeMessage:len() > 0 and trade then
|
||||
context.sayChannel(trade, context.storage.autoTradeMessage)
|
||||
end
|
||||
end, parent)
|
||||
context.addTextEdit("autoTradeMessage", context.storage.autoTradeMessage or "I'm using OTClientV8 - https://github.com/OTCv8/otclientv8", function(widget, text)
|
||||
context.storage.autoTradeMessage = text
|
||||
end, parent)
|
||||
end
|
||||
|
||||
Panels.AutoStackItems = function(parent)
|
||||
context.macro(500, "Auto stacking items", nil, function()
|
||||
local containers = context.getContainers()
|
||||
for i, container in pairs(containers) do
|
||||
local toStack = {}
|
||||
for j, item in ipairs(container:getItems()) do
|
||||
if item:isStackable() and item:getCount() ~= 100 then
|
||||
local otherItem = toStack[item:getId()]
|
||||
if otherItem then
|
||||
g_game.move(item, otherItem, item:getCount())
|
||||
return
|
||||
end
|
||||
toStack[item:getId()] = container:getSlotPosition(j - 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end, parent)
|
||||
end
|
@@ -1,127 +1,127 @@
|
||||
local context = G.botContext
|
||||
local Panels = context.Panels
|
||||
|
||||
Panels.AttackLeaderTarget = function(parent)
|
||||
local toAttack = nil
|
||||
context.onMissle(function(missle)
|
||||
if not context.storage.attackLeader or context.storage.attackLeader:len() == 0 then
|
||||
return
|
||||
end
|
||||
local src = missle:getSource()
|
||||
if src.z ~= context.posz() then
|
||||
return
|
||||
end
|
||||
local from = g_map.getTile(src)
|
||||
local to = g_map.getTile(missle:getDestination())
|
||||
if not from or not to then
|
||||
return
|
||||
end
|
||||
local fromCreatures = from:getCreatures()
|
||||
local toCreatures = to:getCreatures()
|
||||
if #fromCreatures ~= 1 or #toCreatures ~= 1 then
|
||||
return
|
||||
end
|
||||
local c1 = fromCreatures[1]
|
||||
if c1:getName():lower() == context.storage.attackLeader:lower() then
|
||||
toAttack = toCreatures[1]
|
||||
end
|
||||
end)
|
||||
context.macro(50, "Attack leader's target", nil, function()
|
||||
if toAttack and context.storage.attackLeader:len() > 0 and toAttack ~= g_game.getAttackingCreature() then
|
||||
g_game.attack(toAttack)
|
||||
toAttack = nil
|
||||
end
|
||||
end, parent)
|
||||
context.addTextEdit("attackLeader", context.storage.attackLeader or "player name", function(widget, text)
|
||||
context.storage.attackLeader = text
|
||||
end, parent)
|
||||
end
|
||||
|
||||
|
||||
Panels.LimitFloor = function(parent)
|
||||
context.onPlayerPositionChange(function(pos)
|
||||
if context.storage.limitFloor then
|
||||
local gameMapPanel = modules.game_interface.getMapPanel()
|
||||
if gameMapPanel then
|
||||
gameMapPanel:lockVisibleFloor(pos.z)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local switch = context.addSwitch("limitFloor", "Don't show higher floors", function(widget)
|
||||
widget:setOn(not widget:isOn())
|
||||
context.storage.limitFloor = widget:isOn()
|
||||
local gameMapPanel = modules.game_interface.getMapPanel()
|
||||
if gameMapPanel then
|
||||
if context.storage.limitFloor then
|
||||
gameMapPanel:lockVisibleFloor(context.posz())
|
||||
else
|
||||
gameMapPanel:unlockVisibleFloor()
|
||||
end
|
||||
end
|
||||
end, 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
|
||||
local context = G.botContext
|
||||
local Panels = context.Panels
|
||||
|
||||
Panels.AttackLeaderTarget = function(parent)
|
||||
local toAttack = nil
|
||||
context.onMissle(function(missle)
|
||||
if not context.storage.attackLeader or context.storage.attackLeader:len() == 0 then
|
||||
return
|
||||
end
|
||||
local src = missle:getSource()
|
||||
if src.z ~= context.posz() then
|
||||
return
|
||||
end
|
||||
local from = g_map.getTile(src)
|
||||
local to = g_map.getTile(missle:getDestination())
|
||||
if not from or not to then
|
||||
return
|
||||
end
|
||||
local fromCreatures = from:getCreatures()
|
||||
local toCreatures = to:getCreatures()
|
||||
if #fromCreatures ~= 1 or #toCreatures ~= 1 then
|
||||
return
|
||||
end
|
||||
local c1 = fromCreatures[1]
|
||||
if c1:getName():lower() == context.storage.attackLeader:lower() then
|
||||
toAttack = toCreatures[1]
|
||||
end
|
||||
end)
|
||||
context.macro(50, "Attack leader's target", nil, function()
|
||||
if toAttack and context.storage.attackLeader:len() > 0 and toAttack ~= g_game.getAttackingCreature() then
|
||||
g_game.attack(toAttack)
|
||||
toAttack = nil
|
||||
end
|
||||
end, parent)
|
||||
context.addTextEdit("attackLeader", context.storage.attackLeader or "player name", function(widget, text)
|
||||
context.storage.attackLeader = text
|
||||
end, parent)
|
||||
end
|
||||
|
||||
|
||||
Panels.LimitFloor = function(parent)
|
||||
context.onPlayerPositionChange(function(pos)
|
||||
if context.storage.limitFloor then
|
||||
local gameMapPanel = modules.game_interface.getMapPanel()
|
||||
if gameMapPanel then
|
||||
gameMapPanel:lockVisibleFloor(pos.z)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local switch = context.addSwitch("limitFloor", "Don't show higher floors", function(widget)
|
||||
widget:setOn(not widget:isOn())
|
||||
context.storage.limitFloor = widget:isOn()
|
||||
local gameMapPanel = modules.game_interface.getMapPanel()
|
||||
if gameMapPanel then
|
||||
if context.storage.limitFloor then
|
||||
gameMapPanel:lockVisibleFloor(context.posz())
|
||||
else
|
||||
gameMapPanel:unlockVisibleFloor()
|
||||
end
|
||||
end
|
||||
end, 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
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user