mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-10-19 22:23:28 +02:00
Version 1.2 - more advanced bot, new hotkeys, bug fixes
This commit is contained in:
@@ -10,7 +10,7 @@ Panels.MonsterEditor = function(monster, config, callback, parent)
|
||||
local window = context.setupUI([[
|
||||
MainWindow
|
||||
id: monsterEditor
|
||||
size: 400 300
|
||||
size: 450 430
|
||||
!text: tr("Edit monster")
|
||||
|
||||
Label
|
||||
@@ -21,6 +21,14 @@ MainWindow
|
||||
text-align: center
|
||||
text: Use monster name * for any other monster not on the list
|
||||
|
||||
Label
|
||||
id: info2
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
text-align: center
|
||||
text: Add number (1-5) at the end of the name to create multiple configs
|
||||
|
||||
TextEdit
|
||||
id: name
|
||||
anchors.top: prev.bottom
|
||||
@@ -33,7 +41,7 @@ MainWindow
|
||||
Label
|
||||
anchors.verticalCenter: prev.verticalCenter
|
||||
anchors.left: parent.left
|
||||
text: Monster name:
|
||||
text: Target name:
|
||||
|
||||
Label
|
||||
id: priorityText
|
||||
@@ -75,6 +83,26 @@ MainWindow
|
||||
maximum: 10
|
||||
step: 1
|
||||
|
||||
Label
|
||||
id: maxDistanceText
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.horizontalCenter
|
||||
anchors.top: prev.bottom
|
||||
margin-right: 10
|
||||
margin-top: 10
|
||||
text: Max distance to target
|
||||
text-align: center
|
||||
|
||||
HorizontalScrollBar
|
||||
id: maxDistance
|
||||
anchors.left: prev.left
|
||||
anchors.right: prev.right
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 5
|
||||
minimum: 1
|
||||
maximum: 10
|
||||
step: 1
|
||||
|
||||
Label
|
||||
id: distanceText
|
||||
anchors.left: parent.left
|
||||
@@ -82,7 +110,7 @@ MainWindow
|
||||
anchors.top: prev.bottom
|
||||
margin-right: 10
|
||||
margin-top: 10
|
||||
text: Distance
|
||||
text: Keep distance
|
||||
text-align: center
|
||||
|
||||
HorizontalScrollBar
|
||||
@@ -134,6 +162,18 @@ MainWindow
|
||||
minimum: 0
|
||||
maximum: 100
|
||||
step: 1
|
||||
|
||||
Label
|
||||
id: attackSpellText
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.horizontalCenter
|
||||
anchors.top: prev.bottom
|
||||
margin-right: 10
|
||||
margin-top: 10
|
||||
text: Attack spell and attack rune are only used when you have more than 30% health
|
||||
text-align: center
|
||||
text-wrap: true
|
||||
text-auto-resize: true
|
||||
|
||||
BotSwitch
|
||||
id: attack
|
||||
@@ -148,7 +188,7 @@ MainWindow
|
||||
id: ignore
|
||||
anchors.left: prev.right
|
||||
anchors.top: name.bottom
|
||||
margin-left: 5
|
||||
margin-left: 18
|
||||
margin-top: 10
|
||||
width: 55
|
||||
text: Ignore
|
||||
@@ -157,7 +197,7 @@ MainWindow
|
||||
id: avoid
|
||||
anchors.left: prev.right
|
||||
anchors.top: name.bottom
|
||||
margin-left: 5
|
||||
margin-left: 18
|
||||
margin-top: 10
|
||||
width: 55
|
||||
text: Avoid
|
||||
@@ -187,7 +227,7 @@ MainWindow
|
||||
anchors.top: prev.bottom
|
||||
margin-left: 10
|
||||
margin-top: 10
|
||||
text: Chase when running away
|
||||
text: Chase when has low health
|
||||
|
||||
BotSwitch
|
||||
id: loot
|
||||
@@ -198,6 +238,56 @@ MainWindow
|
||||
margin-top: 10
|
||||
text: Loot corpse
|
||||
|
||||
BotSwitch
|
||||
id: monstersOnly
|
||||
anchors.left: parent.horizontalCenter
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
margin-left: 10
|
||||
margin-top: 10
|
||||
text: Only for monsters
|
||||
|
||||
BotSwitch
|
||||
id: dontWalk
|
||||
anchors.left: parent.horizontalCenter
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
margin-left: 10
|
||||
margin-top: 10
|
||||
text: Don't walk to target
|
||||
|
||||
Label
|
||||
id: attackSpellText
|
||||
anchors.left: parent.horizontalCenter
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
margin-left: 10
|
||||
margin-top: 10
|
||||
text: Attack Spell:
|
||||
text-align: center
|
||||
|
||||
TextEdit
|
||||
id: attackSpell
|
||||
anchors.left: prev.left
|
||||
anchors.right: prev.right
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 2
|
||||
|
||||
Label
|
||||
id: attackItemText
|
||||
anchors.left: parent.horizontalCenter
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 20
|
||||
margin-left: 20
|
||||
text: Attack rune:
|
||||
text-align: left
|
||||
|
||||
BotItem
|
||||
id: attackItem
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: prev.verticalCenter
|
||||
margin-right: 30
|
||||
|
||||
Button
|
||||
id: okButton
|
||||
!text: tr('Ok')
|
||||
@@ -212,7 +302,7 @@ MainWindow
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
width: 60
|
||||
]], g_ui.getRootWidget())
|
||||
]], g_ui.getRootWidget())
|
||||
|
||||
local destroy = function()
|
||||
window:destroy()
|
||||
@@ -222,6 +312,7 @@ MainWindow
|
||||
local config = {
|
||||
priority = window.priority:getValue(),
|
||||
danger = window.danger:getValue(),
|
||||
maxDistance = window.maxDistance:getValue(),
|
||||
distance = window.distance:getValue(),
|
||||
minHealth = window.minHealth:getValue(),
|
||||
maxHealth = window.maxHealth:getValue(),
|
||||
@@ -231,7 +322,11 @@ MainWindow
|
||||
keepDistance = window.keepDistance:isOn(),
|
||||
avoidAttacks = window.avoidAttacks:isOn(),
|
||||
chase = window.chase:isOn(),
|
||||
loot = window.loot:isOn()
|
||||
loot = window.loot:isOn(),
|
||||
monstersOnly = window.monstersOnly:isOn(),
|
||||
dontWalk = window.dontWalk:isOn(),
|
||||
attackItem = window.attackItem:getItemId(),
|
||||
attackSpell = window.attackSpell:getText()
|
||||
}
|
||||
destroy()
|
||||
callback(monster, config)
|
||||
@@ -249,8 +344,11 @@ MainWindow
|
||||
window.danger.onValueChange = function(scroll, value)
|
||||
window.dangerText:setText("Danger: " .. value)
|
||||
end
|
||||
window.maxDistance.onValueChange = function(scroll, value)
|
||||
window.maxDistanceText:setText("Max distance to target: " .. value)
|
||||
end
|
||||
window.distance.onValueChange = function(scroll, value)
|
||||
window.distanceText:setText("Distance: " .. value)
|
||||
window.distanceText:setText("Keep distance: " .. value)
|
||||
end
|
||||
window.minHealth.onValueChange = function(scroll, value)
|
||||
window.minHealthText:setText("Minimum health: " .. value .. "%")
|
||||
@@ -260,13 +358,17 @@ MainWindow
|
||||
end
|
||||
|
||||
window.priority:setValue(config.priority or 1)
|
||||
window.danger:setValue(config.danger or 1)
|
||||
window.danger:setValue(config.danger or 1)
|
||||
window.maxDistance:setValue(config.maxDistance or 6)
|
||||
window.distance:setValue(config.distance or 1)
|
||||
window.minHealth:setValue(1) -- to force onValueChange update
|
||||
window.maxHealth:setValue(1) -- to force onValueChange update
|
||||
window.minHealth:setValue(config.minHealth or 0)
|
||||
window.maxHealth:setValue(config.maxHealth or 100)
|
||||
|
||||
window.attackSpell:setText(config.attackSpell or "")
|
||||
window.attackItem:setItemId(config.attackItem or 0)
|
||||
|
||||
window.attack.onClick = function(widget)
|
||||
if widget:isOn() then
|
||||
return
|
||||
@@ -311,6 +413,12 @@ MainWindow
|
||||
window.loot.onClick = function(widget)
|
||||
widget:setOn(not widget:isOn())
|
||||
end
|
||||
window.monstersOnly.onClick = function(widget)
|
||||
widget:setOn(not widget:isOn())
|
||||
end
|
||||
window.dontWalk.onClick = function(widget)
|
||||
widget:setOn(not widget:isOn())
|
||||
end
|
||||
|
||||
window.keepDistance:setOn(config.keepDistance)
|
||||
window.avoidAttacks:setOn(config.avoidAttacks)
|
||||
@@ -319,6 +427,11 @@ MainWindow
|
||||
if config.loot == nil then
|
||||
window.loot:setOn(true)
|
||||
end
|
||||
window.monstersOnly:setOn(config.monstersOnly)
|
||||
if config.monstersOnly == nil then
|
||||
window.monstersOnly:setOn(true)
|
||||
end
|
||||
window.dontWalk:setOn(config.dontWalk)
|
||||
|
||||
window.name:setText(monster)
|
||||
|
||||
@@ -623,22 +736,17 @@ Panel
|
||||
refreshConfig()
|
||||
|
||||
-- processing
|
||||
|
||||
local getMonsterConfig = function(monster)
|
||||
if monsters[monster:getName():lower()] then
|
||||
return monsters[monster:getName():lower()]
|
||||
local isConfigPassingConditions = function(monster, config)
|
||||
if not config or type(config.priority) ~= 'number' or type(config.danger) ~= 'number' then
|
||||
return false
|
||||
end
|
||||
return monsters["*"]
|
||||
end
|
||||
|
||||
local calculatePriority = function(monster)
|
||||
local priority = 0
|
||||
local config = getMonsterConfig(monster)
|
||||
if not config or type(config.priority) ~= 'number' then
|
||||
return -1
|
||||
end
|
||||
if not config.attack then
|
||||
return -1
|
||||
return false
|
||||
end
|
||||
|
||||
if monster:isPlayer() and config.monstersOnly then
|
||||
return false
|
||||
end
|
||||
|
||||
local pos = context.player:getPosition()
|
||||
@@ -646,28 +754,64 @@ Panel
|
||||
local hp = monster:getHealthPercent()
|
||||
|
||||
if config.minHealth > hp or config.maxHealth < hp then
|
||||
return -1
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local maxDistance = 5
|
||||
if config.chase and hp < 20 then
|
||||
maxDistance = 7
|
||||
if type(config.maxDistance) == 'number' then
|
||||
maxDistance = config.maxDistance
|
||||
end
|
||||
if config.chase and hp < 25 then
|
||||
maxDistance = maxDistance + 2
|
||||
end
|
||||
|
||||
local distance = math.max(math.abs(pos.x-mpos.x), math.abs(pos.y-mpos.y))
|
||||
if distance > maxDistance then
|
||||
return -1
|
||||
return false
|
||||
end
|
||||
|
||||
local pathTo = context.findPath(context.player:getPosition(), {x=mpos.x, y=mpos.y, z=mpos.z}, maxDistance + 2, { ignoreNonPathable = true, precision=1, allowOnlyVisibleTiles = true })
|
||||
if not pathTo or #pathTo > maxDistance + 1 then
|
||||
return false
|
||||
end
|
||||
|
||||
local hasPath = false
|
||||
local pathTo = context.findPath(context.player:getPosition(), {x=mpos.x, y=mpos.y, z=mpos.z}, 10, { ignoreNonPathable = true, precision=1 })
|
||||
if pathTo then
|
||||
hasPath = true
|
||||
return true
|
||||
end
|
||||
|
||||
local getMonsterConfig = function(monster)
|
||||
local name = monster:getName():lower()
|
||||
if isConfigPassingConditions(monster, monsters[name]) then
|
||||
return monsters[name]
|
||||
end
|
||||
if distance > 2 and not hasPath then
|
||||
for i=1, 5 do
|
||||
if isConfigPassingConditions(monster, monsters[name .. i]) then
|
||||
return monsters[name .. i]
|
||||
end
|
||||
end
|
||||
if isConfigPassingConditions(monster, monsters["*"]) then
|
||||
return monsters["*"]
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local calculatePriority = function(monster)
|
||||
local priority = 0
|
||||
local config = getMonsterConfig(monster)
|
||||
if not config then
|
||||
return -1
|
||||
end
|
||||
|
||||
local pos = context.player:getPosition()
|
||||
local mpos = monster:getPosition()
|
||||
local hp = monster:getHealthPercent()
|
||||
local pathTo = context.findPath(context.player:getPosition(), {x=mpos.x, y=mpos.y, z=mpos.z}, 10, { ignoreNonPathable = true, ignoreLastCreature = true, precision=0, allowOnlyVisibleTiles = true })
|
||||
if not pathTo then
|
||||
pathTo = context.findPath(context.player:getPosition(), {x=mpos.x, y=mpos.y, z=mpos.z}, 10, { ignoreNonPathable = true, precision=1, allowOnlyVisibleTiles = true })
|
||||
if not pathTo then
|
||||
return -1
|
||||
end
|
||||
end
|
||||
local distance = #pathTo
|
||||
|
||||
if monster == g_game.getAttackingCreature() then
|
||||
priority = priority + 10
|
||||
end
|
||||
@@ -682,7 +826,7 @@ Panel
|
||||
priority = priority + 10
|
||||
end
|
||||
|
||||
if hp <= 20 and config.chase then
|
||||
if hp <= 25 and config.chase then
|
||||
priority = priority + 30
|
||||
end
|
||||
|
||||
@@ -718,6 +862,8 @@ Panel
|
||||
local lootTries = 0
|
||||
local openContainerRequest = 0
|
||||
local waitForLooting = 0
|
||||
local lastAttackSpell = 0
|
||||
local lastAttackRune = 0
|
||||
|
||||
local goForLoot = function()
|
||||
if #lootContainers == 0 or not context.storage.looting.enabled then
|
||||
@@ -842,7 +988,7 @@ Panel
|
||||
else
|
||||
container.autoLooting = (openContainerRequest + 3000 > context.now)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
context.macro(200, function()
|
||||
if not context.storage.attacking.enabled then
|
||||
@@ -864,7 +1010,7 @@ Panel
|
||||
if followingCandidate and followingCandidate:getId() == spec:getId() then
|
||||
following = spec
|
||||
end
|
||||
if spec:isMonster() then
|
||||
if spec:isMonster() or (spec:isPlayer() and not spec:isLocalPlayer()) then
|
||||
danger = danger + calculateMonsterDanger(spec)
|
||||
spec.attackingPriority = calculatePriority(spec)
|
||||
table.insert(monsters, spec)
|
||||
@@ -879,7 +1025,7 @@ Panel
|
||||
return
|
||||
end
|
||||
|
||||
if #monsters == 0 then
|
||||
if #monsters == 0 or context.isInProtectionZone() then
|
||||
goForLoot()
|
||||
return
|
||||
end
|
||||
@@ -892,28 +1038,50 @@ Panel
|
||||
if target.attackingPriority < 0 then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local pos = context.player:getPosition()
|
||||
local tpos = target:getPosition()
|
||||
local config = getMonsterConfig(target)
|
||||
local offsetX = pos.x - tpos.x
|
||||
local offsetY = pos.y - tpos.y
|
||||
|
||||
local justStartedAttack = false
|
||||
if target ~= attacking then
|
||||
g_game.attack(target)
|
||||
attacking = target
|
||||
lastAttack = context.now
|
||||
justStartedAttack = true
|
||||
end
|
||||
|
||||
-- proceed attack
|
||||
if lastAttack + 15000 < context.now then
|
||||
if not target:isPlayer() and lastAttack + 15000 < context.now then
|
||||
-- stop and attack again, just in case
|
||||
g_game.cancelAttack()
|
||||
g_game.attack(target)
|
||||
lastAttack = context.now
|
||||
return
|
||||
end
|
||||
|
||||
if not justStartedAttack and config.attackSpell and config.attackSpell:len() > 0 then
|
||||
if context.now > lastAttackSpell + 1000 and context.player:getHealthPercent() > 30 then
|
||||
if context.saySpell(config.attackSpell, 1500) then
|
||||
lastAttackRune = context.now
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not justStartedAttack and config.attackItem and config.attackItem >= 100 then
|
||||
if context.now > lastAttackRune + 1000 and context.player:getHealthPercent() > 30 then
|
||||
if context.useRune(config.attackItem, target, 1500) then
|
||||
lastAttackRune = context.now
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if modules.game_walking.lastManualWalk + 500 > context.now then
|
||||
return
|
||||
end
|
||||
|
||||
if danger < 8 then
|
||||
-- low danger, go for loot first
|
||||
if goForLoot() then
|
||||
@@ -921,10 +1089,14 @@ Panel
|
||||
end
|
||||
end
|
||||
|
||||
if config.dontWalk then
|
||||
return
|
||||
end
|
||||
|
||||
local distance = math.max(math.abs(offsetX), math.abs(offsetY))
|
||||
if config.keepDistance then
|
||||
local minDistance = config.distance
|
||||
if target:getHealthPercent() < 20 and config.chase and danger < 10 then
|
||||
if target:getHealthPercent() <= 25 and config.chase and danger < 10 then
|
||||
minDistance = 1
|
||||
end
|
||||
if (distance == minDistance or distance == minDistance + 1) then
|
||||
@@ -932,14 +1104,16 @@ Panel
|
||||
else
|
||||
local bestDist = 10
|
||||
local bestPos = pos
|
||||
if not context.autoWalk(tpos, 8, { minMargin=minDistance, maxMargin=minDistance + 1}) then
|
||||
if not context.autoWalk(tpos, 8, { ignoreNonPathable = true, minMargin=minDistance, maxMargin=minDistance + 1}) then
|
||||
if not context.autoWalk(tpos, 8, { ignoreNonPathable = true, ignoreCreatures = true, minMargin=minDistance, maxMargin=minDistance + 2}) then
|
||||
if not context.autoWalk(tpos, 10, { minMargin=minDistance, maxMargin=minDistance + 1, allowOnlyVisibleTiles = true}) then
|
||||
if not context.autoWalk(tpos, 10, { ignoreNonPathable = true, minMargin=minDistance, maxMargin=minDistance + 1, allowOnlyVisibleTiles = true}) then
|
||||
if not context.autoWalk(tpos, 10, { ignoreNonPathable = true, ignoreCreatures = true, minMargin=minDistance, maxMargin=minDistance + 2, allowOnlyVisibleTiles = true}) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
context.delay(300)
|
||||
if not target:isPlayer() then
|
||||
context.delay(300)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
@@ -961,14 +1135,16 @@ Panel
|
||||
end
|
||||
|
||||
if distance > 1 then
|
||||
if not context.autoWalk(tpos, 8, { precision = 1}) then
|
||||
if not context.autoWalk(tpos, 8, { ignoreNonPathable = true, precision = 1}) then
|
||||
if not context.autoWalk(tpos, 8, { ignoreNonPathable = true, precision = 2}) then
|
||||
if not context.autoWalk(tpos, 10, { precision = 1, allowOnlyVisibleTiles = true}) then
|
||||
if not context.autoWalk(tpos, 10, { ignoreNonPathable = true, precision = 1, allowOnlyVisibleTiles = true}) then
|
||||
if not context.autoWalk(tpos, 10, { ignoreNonPathable = true, precision = 2, allowOnlyVisibleTiles = true}) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
context.delay(300)
|
||||
if not target:isPlayer() then
|
||||
context.delay(300)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
@@ -1,402 +1,6 @@
|
||||
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)
|
||||
context.macro(500, "Auto ManaShield", nil, function()
|
||||
if not context.hasManaShield() then
|
||||
if context.saySpell("utamo vita", 500) then
|
||||
context.delay(5000)
|
||||
end
|
||||
end
|
||||
end, parent)
|
||||
end
|
||||
|
||||
Panels.AntiParalyze = function(parent)
|
||||
context.macro(500, "Anti Paralyze", nil, function()
|
||||
if context.isParalyzed() and context.storage.autoAntiParalyzeText:len() > 0 then
|
||||
if context.saySpell(context.storage.autoAntiParalyzeText, 750) then
|
||||
context.delay(1000)
|
||||
end
|
||||
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 = context.setupUI([[
|
||||
Panel
|
||||
height: 70
|
||||
margin-top: 2
|
||||
|
||||
Label
|
||||
id: info
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
text: Auto Healing
|
||||
text-align: center
|
||||
|
||||
Label
|
||||
id: label
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.bottom
|
||||
margin: 0 5 0 5
|
||||
text-align: center
|
||||
|
||||
HorizontalScrollBar
|
||||
id: scroll1
|
||||
anchors.left: label.left
|
||||
anchors.right: label.horizontalCenter
|
||||
anchors.top: label.bottom
|
||||
margin-top: 5
|
||||
margin-right: 2
|
||||
minimum: 0
|
||||
maximum: 100
|
||||
step: 1
|
||||
|
||||
HorizontalScrollBar
|
||||
id: scroll2
|
||||
anchors.left: label.horizontalCenter
|
||||
anchors.right: label.right
|
||||
anchors.top: label.bottom
|
||||
margin-top: 5
|
||||
margin-left: 2
|
||||
minimum: 0
|
||||
maximum: 100
|
||||
step: 1
|
||||
|
||||
BotTextEdit
|
||||
id: text
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: scroll1.bottom
|
||||
]], parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
ui.text.onTextChange = function(widget, text)
|
||||
context.storage["healthText" .. panelId] = text
|
||||
end
|
||||
ui.text:setText(context.storage["healthText" .. panelId] or "exura")
|
||||
|
||||
local updateText = function()
|
||||
ui.label:setText("" .. (context.storage["healthPercentMin" .. panelId] or "") .. "% <= hp <= " .. (context.storage["healthPercentMax" .. panelId] or "") .. "%")
|
||||
end
|
||||
|
||||
ui.scroll1.onValueChange = function(scroll, value)
|
||||
context.storage["healthPercentMin" .. panelId] = value
|
||||
updateText()
|
||||
end
|
||||
ui.scroll2.onValueChange = function(scroll, value)
|
||||
context.storage["healthPercentMax" .. panelId] = value
|
||||
updateText()
|
||||
end
|
||||
|
||||
ui.scroll1:setValue(context.storage["healthPercentMin" .. panelId] or 20)
|
||||
ui.scroll2:setValue(context.storage["healthPercentMax" .. panelId] or 60)
|
||||
|
||||
context.macro(25, function()
|
||||
if context.storage["healthText" .. panelId]:len() > 0 and context.storage["healthPercentMin" .. panelId] <= context.hppercent() and context.hppercent() <= context.storage["healthPercentMax" .. panelId] then
|
||||
if context.saySpell(context.storage["healthText" .. panelId], 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 = context.setupUI([[
|
||||
Panel
|
||||
height: 55
|
||||
margin-top: 2
|
||||
|
||||
Label
|
||||
id: info
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
text: Auto Healing
|
||||
text-align: center
|
||||
|
||||
BotItem
|
||||
id: item
|
||||
anchors.left: parent.left
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 3
|
||||
|
||||
Label
|
||||
id: label
|
||||
anchors.left: prev.right
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.top
|
||||
margin: 0 5 0 5
|
||||
text-align: center
|
||||
|
||||
HorizontalScrollBar
|
||||
id: scroll1
|
||||
anchors.left: label.left
|
||||
anchors.right: label.horizontalCenter
|
||||
anchors.top: label.bottom
|
||||
margin-top: 5
|
||||
margin-right: 2
|
||||
minimum: 0
|
||||
maximum: 100
|
||||
step: 1
|
||||
|
||||
HorizontalScrollBar
|
||||
id: scroll2
|
||||
anchors.left: label.horizontalCenter
|
||||
anchors.right: label.right
|
||||
anchors.top: label.bottom
|
||||
margin-top: 5
|
||||
margin-left: 2
|
||||
minimum: 0
|
||||
maximum: 100
|
||||
step: 1
|
||||
]], parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
ui.item.onItemChange = function(widget)
|
||||
context.storage["healthItem" .. panelId] = widget:getItemId()
|
||||
end
|
||||
ui.item:setItemId(context.storage["healthItem" .. panelId] or 266)
|
||||
|
||||
local updateText = function()
|
||||
ui.label:setText("" .. (context.storage["healthItemPercentMin" .. panelId] or "") .. "% <= hp <= " .. (context.storage["healthItemPercentMax" .. panelId] or "") .. "%")
|
||||
end
|
||||
|
||||
ui.scroll1.onValueChange = function(scroll, value)
|
||||
context.storage["healthItemPercentMin" .. panelId] = value
|
||||
updateText()
|
||||
end
|
||||
ui.scroll2.onValueChange = function(scroll, value)
|
||||
context.storage["healthItemPercentMax" .. panelId] = value
|
||||
updateText()
|
||||
end
|
||||
|
||||
ui.scroll1:setValue(context.storage["healthItemPercentMin" .. panelId] or 20)
|
||||
ui.scroll2:setValue(context.storage["healthItemPercentMax" .. panelId] or 60)
|
||||
|
||||
context.macro(25, function()
|
||||
if context.storage["healthItem" .. panelId] > 0 and context.storage["healthItemPercentMin" .. panelId] <= context.hppercent() and context.hppercent() <= context.storage["healthItemPercentMax" .. panelId] then
|
||||
context.useWith(context.storage["healthItem" .. panelId], context.player)
|
||||
context.delay(300)
|
||||
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 = context.setupUI([[
|
||||
Panel
|
||||
height: 55
|
||||
margin-top: 2
|
||||
|
||||
Label
|
||||
id: info
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
text: Auto Mana
|
||||
text-align: center
|
||||
|
||||
BotItem
|
||||
id: item
|
||||
anchors.left: parent.left
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 3
|
||||
|
||||
Label
|
||||
id: label
|
||||
anchors.left: prev.right
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.top
|
||||
margin: 0 5 0 5
|
||||
text-align: center
|
||||
|
||||
HorizontalScrollBar
|
||||
id: scroll1
|
||||
anchors.left: label.left
|
||||
anchors.right: label.horizontalCenter
|
||||
anchors.top: label.bottom
|
||||
margin-top: 5
|
||||
margin-right: 2
|
||||
minimum: 0
|
||||
maximum: 100
|
||||
step: 1
|
||||
|
||||
HorizontalScrollBar
|
||||
id: scroll2
|
||||
anchors.left: label.horizontalCenter
|
||||
anchors.right: label.right
|
||||
anchors.top: label.bottom
|
||||
margin-top: 5
|
||||
margin-left: 2
|
||||
minimum: 0
|
||||
maximum: 100
|
||||
step: 1
|
||||
]], parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
ui.item.onItemChange = function(widget)
|
||||
context.storage["manaItem" .. panelId] = widget:getItemId()
|
||||
end
|
||||
ui.item:setItemId(context.storage["manaItem" .. panelId] or 268)
|
||||
|
||||
local updateText = function()
|
||||
ui.label:setText("" .. (context.storage["manaItemPercentMin" .. panelId] or "") .. "% <= mana <= " .. (context.storage["manaItemPercentMax" .. panelId] or "") .. "%")
|
||||
end
|
||||
|
||||
ui.scroll1.onValueChange = function(scroll, value)
|
||||
context.storage["manaItemPercentMin" .. panelId] = value
|
||||
updateText()
|
||||
end
|
||||
ui.scroll2.onValueChange = function(scroll, value)
|
||||
context.storage["manaItemPercentMax" .. panelId] = value
|
||||
updateText()
|
||||
end
|
||||
|
||||
ui.scroll1:setValue(context.storage["manaItemPercentMin" .. panelId] or 20)
|
||||
ui.scroll2:setValue(context.storage["manaItemPercentMax" .. panelId] or 60)
|
||||
|
||||
context.macro(25, function()
|
||||
if context.storage["manaItem" .. panelId] > 0 and context.storage["manaItemPercentMin" .. panelId] <= context.manapercent() and context.manapercent() <= context.storage["manaItemPercentMax" .. panelId] then
|
||||
context.useWith(context.storage["manaItem" .. panelId], context.player)
|
||||
context.delay(300)
|
||||
end
|
||||
end)
|
||||
end
|
||||
Panels.ManaItem = Panels.Mana
|
||||
|
||||
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 = context.setupUI([[
|
||||
Panel
|
||||
height: 55
|
||||
margin-top: 2
|
||||
|
||||
Label
|
||||
id: info
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
text: Auto Eating
|
||||
text-align: center
|
||||
|
||||
BotItem
|
||||
id: item1
|
||||
anchors.left: parent.left
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 3
|
||||
margin-left: 10
|
||||
|
||||
BotItem
|
||||
id: item2
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: prev.top
|
||||
|
||||
BotItem
|
||||
id: item3
|
||||
anchors.right: parent.right
|
||||
anchors.top: prev.top
|
||||
margin-right: 10
|
||||
|
||||
]], parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
if not context.storage["autoEating" .. panelId] then
|
||||
context.storage["autoEating" .. panelId] = {}
|
||||
end
|
||||
|
||||
ui.item1.onItemChange = function(widget)
|
||||
context.storage["autoEating" .. panelId][1] = widget:getItemId()
|
||||
end
|
||||
ui.item1:setItemId(context.storage["autoEating" .. panelId][1] or 3725)
|
||||
|
||||
ui.item2.onItemChange = function(widget)
|
||||
context.storage["autoEating" .. panelId][2] = widget:getItemId()
|
||||
end
|
||||
ui.item2:setItemId(context.storage["autoEating" .. panelId][2] or 0)
|
||||
|
||||
ui.item3.onItemChange = function(widget)
|
||||
context.storage["autoEating" .. panelId][3] = widget:getItemId()
|
||||
end
|
||||
ui.item3:setItemId(context.storage["autoEating" .. panelId][3] or 0)
|
||||
|
||||
|
||||
context.macro(15000, function()
|
||||
local candidates = {}
|
||||
for i, item in pairs(context.storage["autoEating" .. panelId]) 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)
|
||||
end
|
||||
Panels.ManaItem = Panels.Mana
|
||||
|
||||
Panels.Turning = function(parent)
|
||||
context.macro(1000, "Turning / AntiIdle", nil, function()
|
||||
context.turn(math.random(1, 4))
|
||||
@@ -423,48 +27,31 @@ Panels.AttackItem = function(parent)
|
||||
parent = context.panel
|
||||
end
|
||||
|
||||
local panelName = "autoAttackItem"
|
||||
local panelId = 1
|
||||
while parent:getChildById(panelName .. panelId) do
|
||||
panelId = panelId + 1
|
||||
end
|
||||
panelName = panelName .. panelId
|
||||
|
||||
local ui = context.setupUI([[
|
||||
Panel
|
||||
height: 55
|
||||
margin-top: 2
|
||||
|
||||
Label
|
||||
id: info
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
text: Auto Attack Item
|
||||
text-align: center
|
||||
|
||||
BotItem
|
||||
id: item
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: prev.bottom
|
||||
margin-top: 3
|
||||
margin-left: 10
|
||||
]], parent)
|
||||
local panelName = "attackItem"
|
||||
local ui = g_ui.createWidget("ItemAndButtonPanel", parent)
|
||||
ui:setId(panelName)
|
||||
|
||||
if not context.storage["autoEating" .. panelId] then
|
||||
context.storage["autoEating" .. panelId] = {}
|
||||
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["autoAttackItem" .. panelId] = widget:getItemId()
|
||||
context.storage.attackItem.item = widget:getItemId()
|
||||
end
|
||||
ui.item:setItemId(context.storage["autoAttackItem" .. panelId] or 3155)
|
||||
ui.item:setItemId(context.storage.attackItem.item or 3155)
|
||||
|
||||
context.macro(500, "Auto attack with item", nil, function()
|
||||
context.macro(500, function()
|
||||
local target = g_game.getAttackingCreature()
|
||||
if target and context.getCreatureById(target:getId()) and context.storage["autoAttackItem" .. panelId] >= 100 then
|
||||
context.useWith(context.storage["autoAttackItem" .. panelId], target)
|
||||
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, parent)
|
||||
end)
|
||||
end
|
||||
|
344
modules/game_bot/panels/healing.lua
Normal file
344
modules/game_bot/panels/healing.lua
Normal file
@@ -0,0 +1,344 @@
|
||||
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)
|
||||
context.macro(100, "Auto Mana Shield", nil, function()
|
||||
if not context.hasManaShield() then
|
||||
context.saySpell("utamo vita", 200)
|
||||
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, 0)
|
||||
if not newItem then
|
||||
newItem = context.findItem(context.storage[panelName].item2, 0)
|
||||
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["autoEating" .. panelId]) ~= 'table' then
|
||||
context.storage["autoEating" .. panelId] = {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()
|
||||
end
|
||||
ui.items:getChildByIndex(i):setItemId(context.storage["autoEating" .. panelId][i])
|
||||
end
|
||||
|
||||
context.macro(15000, function()
|
||||
if not context.storage[panelName].enabled then
|
||||
return
|
||||
end
|
||||
local candidates = {}
|
||||
for i, item in pairs(context.storage["autoEating" .. panelId]) 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)
|
||||
end
|
||||
Panels.ManaItem = Panels.Mana
|
||||
|
@@ -82,7 +82,7 @@ Panel
|
||||
margin-top: 4
|
||||
text: Loot Containers
|
||||
|
||||
Panel
|
||||
ItemsRow
|
||||
id: containers
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
@@ -90,35 +90,6 @@ Panel
|
||||
height: 33
|
||||
margin-top: 2
|
||||
|
||||
BotItem
|
||||
id: item1
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
margin-left: 3
|
||||
|
||||
BotItem
|
||||
id: item2
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
margin-left: 2
|
||||
|
||||
BotItem
|
||||
id: item3
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
margin-left: 2
|
||||
|
||||
BotItem
|
||||
id: item4
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
margin-left: 2
|
||||
|
||||
BotItem
|
||||
id: item5
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
margin-left: 2
|
||||
|
||||
]], parent)
|
||||
|
||||
|
17
modules/game_bot/panels/tools.lua
Normal file
17
modules/game_bot/panels/tools.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
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
|
65
modules/game_bot/panels/war.lua
Normal file
65
modules/game_bot/panels/war.lua
Normal file
@@ -0,0 +1,65 @@
|
||||
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 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
|
||||
|
@@ -5,7 +5,7 @@ Panels.Waypoints = function(parent)
|
||||
local ui = context.setupUI([[
|
||||
Panel
|
||||
id: waypoints
|
||||
height: 203
|
||||
height: 223
|
||||
|
||||
BotLabel
|
||||
anchors.top: parent.top
|
||||
@@ -123,6 +123,31 @@ Panel
|
||||
width: 61
|
||||
height: 20
|
||||
|
||||
Button
|
||||
id: wNpc
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
text: Say NPC
|
||||
width: 61
|
||||
height: 20
|
||||
|
||||
Button
|
||||
id: wLabel
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
text: Label
|
||||
width: 61
|
||||
margin-top: 1
|
||||
height: 20
|
||||
|
||||
Button
|
||||
id: wFollow
|
||||
anchors.top: prev.top
|
||||
anchors.left: prev.right
|
||||
text: Follow
|
||||
width: 61
|
||||
height: 20
|
||||
|
||||
Button
|
||||
id: wFunction
|
||||
anchors.top: prev.top
|
||||
@@ -167,6 +192,10 @@ Panel
|
||||
return true
|
||||
elseif command == "say" then
|
||||
return true
|
||||
elseif command == "npc" then
|
||||
return true
|
||||
elseif command == "follow" then
|
||||
return true
|
||||
elseif command == "label" then
|
||||
return true
|
||||
elseif command == "gotolabel" then
|
||||
@@ -272,7 +301,15 @@ Panel
|
||||
return
|
||||
end
|
||||
context.storage.cavebot.enabled = not context.storage.cavebot.enabled
|
||||
refreshConfig()
|
||||
if autoRecording then
|
||||
refreshConfig()
|
||||
elseif context.storage.cavebot.enabled then
|
||||
ui.enableButton:setText("On")
|
||||
ui.enableButton:setColor('#00AA00FF')
|
||||
else
|
||||
ui.enableButton:setText("Off")
|
||||
ui.enableButton:setColor('#FF0000FF')
|
||||
end
|
||||
end
|
||||
ui.add.onClick = function()
|
||||
modules.game_textedit.multilineEditor("Waypoints editor", "name:Config name\nlabel:start\n", function(newText)
|
||||
@@ -425,6 +462,36 @@ Panel
|
||||
end)
|
||||
end
|
||||
|
||||
ui.wNpc.onClick = function()
|
||||
if not context.storage.cavebot.activeConfig or not context.storage.cavebot.configs[context.storage.cavebot.activeConfig] then
|
||||
return
|
||||
end
|
||||
modules.game_textedit.singlelineEditor("text", function(newText)
|
||||
context.storage.cavebot.configs[context.storage.cavebot.activeConfig] = context.storage.cavebot.configs[context.storage.cavebot.activeConfig] .. "\nnpc:" .. newText
|
||||
refreshConfig(true)
|
||||
end)
|
||||
end
|
||||
|
||||
ui.wLabel.onClick = function()
|
||||
if not context.storage.cavebot.activeConfig or not context.storage.cavebot.configs[context.storage.cavebot.activeConfig] then
|
||||
return
|
||||
end
|
||||
modules.game_textedit.singlelineEditor("label name", function(newText)
|
||||
context.storage.cavebot.configs[context.storage.cavebot.activeConfig] = context.storage.cavebot.configs[context.storage.cavebot.activeConfig] .. "\nlabel:" .. newText
|
||||
refreshConfig(true)
|
||||
end)
|
||||
end
|
||||
|
||||
ui.wFollow.onClick = function()
|
||||
if not context.storage.cavebot.activeConfig or not context.storage.cavebot.configs[context.storage.cavebot.activeConfig] then
|
||||
return
|
||||
end
|
||||
modules.game_textedit.singlelineEditor("creature name", function(newText)
|
||||
context.storage.cavebot.configs[context.storage.cavebot.activeConfig] = context.storage.cavebot.configs[context.storage.cavebot.activeConfig] .. "\nfollow:" .. newText
|
||||
refreshConfig(true)
|
||||
end)
|
||||
end
|
||||
|
||||
ui.wFunction.onClick = function()
|
||||
if not context.storage.cavebot.activeConfig or not context.storage.cavebot.configs[context.storage.cavebot.activeConfig] then
|
||||
return
|
||||
@@ -497,6 +564,10 @@ Panel
|
||||
if not context.storage.cavebot.enabled then
|
||||
return
|
||||
end
|
||||
|
||||
if modules.game_walking.lastManualWalk + 500 > context.now then
|
||||
return
|
||||
end
|
||||
|
||||
-- wait if walked or opened container recently
|
||||
if context.player:isWalking() or lastOpenedContainer + 1000 > context.now then
|
||||
@@ -539,12 +610,23 @@ Panel
|
||||
lastGotoSuccesful = true
|
||||
end
|
||||
|
||||
if command.command == "goto" then
|
||||
if command.command == "goto" or command.command == "follow" then
|
||||
local matches = regexMatch(command.text, [[([0-9]+)[^0-9]+([0-9]+)[^0-9]+([0-9]+)]])
|
||||
if #matches == 1 and #matches[1] == 4 then
|
||||
local position = {x=tonumber(matches[1][2]), y=tonumber(matches[1][3]), z=tonumber(matches[1][4])}
|
||||
local distance = context.getDistanceBetween(position, context.player:getPosition())
|
||||
if distance > 100 or position.z ~= context.player:getPosition().z then
|
||||
if (#matches == 1 and #matches[1] == 4) or command.command == "follow" then
|
||||
local position = nil
|
||||
if command.command == "follow" then
|
||||
local creature = context.getCreatureByName(command.text)
|
||||
if creature then
|
||||
position = creature:getPosition()
|
||||
end
|
||||
else
|
||||
position = {x=tonumber(matches[1][2]), y=tonumber(matches[1][3]), z=tonumber(matches[1][4])}
|
||||
end
|
||||
local distance = 0
|
||||
if position then
|
||||
distance = context.getDistanceBetween(position, context.player:getPosition())
|
||||
end
|
||||
if distance > 100 or not position or position.z ~= context.player:getPosition().z then
|
||||
lastGotoSuccesful = false
|
||||
elseif distance > 0 then
|
||||
if not context.findPath(context.player:getPosition(), position, 100, { ignoreNonPathable = true, precision = 1, ignoreCreatures = true }) then
|
||||
@@ -625,6 +707,8 @@ Panel
|
||||
waitTo = 0
|
||||
elseif command.command == "say" and lastGotoSuccesful then
|
||||
context.say(command.text)
|
||||
elseif command.command == "npc" and lastGotoSuccesful then
|
||||
context.sayNpc(command.text)
|
||||
elseif command.command == "function" and lastGotoSuccesful then
|
||||
usedGotoLabel = false
|
||||
local status, result = pcall(function()
|
||||
|
Reference in New Issue
Block a user