yompa93
05-02-2016, 02:27 PM
Here's a script with hotkeys binded to modules. If you activate for example manashield, the script will keep doing manashield when not manashielded.
https://i.gyazo.com/85a5cfd7806a114f82081496c987b31b.png
I am going to update the script so that you can change mana potions in the channel and other stuff i guess. :)
Added: possibility to change the mana potter in the channel.
Added: possibility to change between ring or spell for manashield in the channel.
Added: possibility to change which rune the rune shooter is using in the channel.
Added: Mana trainer with antipush.
Added: House mana trainer, in the same command as the old mana trainer.
Edited a few modules for the better.
Mana trainer:
To switch between the two kinds of trainers write these commands:
trainer, change, trainertype, shoptrainer or housetrainer
Shop mana trainer:
The shop mana trainer will buy potions, use potions and cast spells. Start the trainer next to the shop with the amount of cash you want to use. The mana trainer is not started on a hotkey, instead write "trainer" in the channel to see the choices/config.
House mana trainer:
The house trainer will use the same settings for spells/pots as the shop mana trainer. it will withdraw the chosen manas from the chosen container on the floor. You have to stand next to the backpack in any direction, but not on top of it, because you will drop flasks where you're standing.
-- Config
-- Targeted Rune Shooter
Rune = "sudden death rune" -- Which rune to use in the targeted rune shooter
-- Haster
HasteSpell = "utani gran hur" -- Which haste spell to use
-- ManaShield
ManaShieldMethod = "spell" -- Use ring/spell for manashield?
-- Mana Healer
mPots = "mana potion" -- Which mana potions to use.
BelowMana = 2000 -- Will use mana potions below this amount/percent of mana.
-- Healer
StrongHealingSpell = "exura vita"
HealthBelowStrong = 50 -- Health percentage to use the strong healing spell
MediumHealingSpell = "exura gran"
HealthBelowMedium = 85 -- Health percentage to use the medium healing spell
LightHealingSpell = "exura"
HealthBelowLight = 0 -- Health percentage to use the light healing spell
--Trainer Spells
TrainerPrio1 = "exevo gran mas vis"
TrainerPrio2 = "utana vid"
TrainerPrio3 = "exura vita"
--HouseTrainer
fromBackpack = "Blue Backpack" -- Backpack to open from the floor
toBackpack = "backpack" -- Main backpack, the backpack which
HouseTrainer = false
-- Hotkeys ------------------------------------------------------------
--[[ Set true only if you use it in the script or you wont be able to use the ingame hotkey on that particular button.
This is only needed if you commented out the Hotkeys.~ in the newest xb.~.lua in C:\Program Files (x86)\XenoBot
If you didnt comment it out in the data, you will loose the possibility to use all of the ingame hotkeys when running the script.]]--
Hotkeys.F1 = false
Hotkeys.F2 = true
Hotkeys.F3 = false
Hotkeys.F4 = true
Hotkeys.F5 = false
Hotkeys.F6 = true
Hotkeys.F7 = false
Hotkeys.F8 = false
Hotkeys.F9 = false
Hotkeys.F10 = true
Hotkeys.F12 = true
Hotkeys.PAGEUP = false
Hotkeys.PAGEDOWN = false
Hotkeys.INSERT = false
Hotkeys.DELETE = false
Hotkeys.END = false
Hotkeys.HOME = false
-- This is just to change the HUD to whichever key you're using, so it's easier to not forget which key does what.
TargetedruneshooterHUD = "F4"
HealerHUD = "F2"
ManaHealerHUD = "F6"
ManaShieldHUD = "F10"
HasteHUD = "F12"
-- Hotkeys function
function pressHandler(key, control, shift)
if key == Hotkeys.F4 then --hotkey for the Targeted rune shooter, change this by changing F4 to one of the available hotkeys above. remember to set F4 to false if you're not using it and the key you want to use to true.
if sd == 0 then
Module.Start('RuneShooter')
updateAF4 = "".. TargetedruneshooterHUD .." Targeted rune shooter: Activated"
updateDF4 = ""
HudUpdateF4()
print("Targeted rune shooter: Activated")
sd = 1
else
Module.Stop('RuneShooter')
updateAF4 = ""
updateDF4 = "".. TargetedruneshooterHUD .." Targeted rune shooter: Deactivated"
HudUpdateF4()
print("Targeted rune shooter: Deactivated")
sd = 0
end
elseif key == Hotkeys.F2 then --hotkey for the Healer, change this by changing F2 to one of the available hotkeys above. remember to set F2 to false if you're not using it and the key you want to use to true.
if Healer == 0 then
Module.Start('Healer')
updateAF2 = "".. HealerHUD .." Healer: Activated"
updateDF2 = ""
HudUpdateF2()
print("Healer: Activated")
Healer = 1
else
Module.Stop('Healer')
updateAF2 = ""
updateDF2 = "".. HealerHUD .." Healer: Deactivated"
HudUpdateF2()
print("Healer: Deactivated")
Healer = 0
end
elseif key == Hotkeys.F6 then --hotkey for the Mana Healer, change this by changing F6 to one of the available hotkeys above. remember to set F6 to false if you're not using it and the key you want to use to true.
if mHealer == 0 then
Module.Start('ManaHealer')
updateAF6 = "".. ManaHealerHUD .." Mana healer: Activated"
updateDF6 = ""
HudUpdateF6()
mHealer = 1
else
Module.Stop('ManaHealer')
updateAF6 = ""
updateDF6 = "".. ManaHealerHUD .." Mana healer: Deactivated"
HudUpdateF6()
mHealer = 0
end
elseif key == Hotkeys.F10 then --hotkey for ManaShield, change this by changing F10 to one of the available hotkeys above. remember to set F10 to false if you're not using it and the key you want to use to true.
if ms == 0 then
Module.Start('ManaShield')
updateAF10 = "".. ManaShieldHUD .." Magic Shield: Activated"
updateDF10 = ""
HudUpdateF10()
ms = 1
print("Magic Shield: Activated")
else
Module.Stop('ManaShield')
updateAF10 = ""
updateDF10 = "".. ManaShieldHUD .." Magic Shield: Deactivated"
HudUpdateF10()
ms = 0
print("Magic Shield: Deactivated")
end
elseif key == Hotkeys.F12 then --hotkey for the Haster, change this by changing F12 to one of the available hotkeys above. remember to set F12 to false if you're not using it and the key you want to use to true.
if h == 0 then
Module.Start('Haste')
updateAF12 = "".. HasteHUD .." Haste: Activated"
updateDF12 = ""
HudUpdateF12()
h = 1
print("Haste: Activated")
else
Module.Stop('Haste')
updateAF12 = ""
updateDF12 = "".. HasteHUD .." Haste: Deactivated"
HudUpdateF12()
h = 0
print("Haste: Deactivated")
end
end
end
-- Modules ------------------------------------------------------------
Module.New('ManaShield', function(mod)
if not Self.isManaShielded() and not Self.isInPz() and ManaShieldMethod == "spell" then
if Self.CanCastSpell("utamo vita") then
Self.Cast("utamo vita")
end
elseif not Self.isManaShielded() and not Self.isInPz() and ManaShieldMethod == "ring" then
if Self.ItemCount(3051) > 0 and Self.Ring().id ~= 3088 then
Self.Equip(3051, "ring")
end
elseif Self.isInPz() and Self.Ring().id == 3088 then
Self.Dequip("ring")
end
mod:Delay(200)
end, false)
ms = 0
Module.New('Haste', function(mod)
if not Self.isHasted() then
if Self.CanCastSpell(HasteSpell) then
Self.Cast(HasteSpell)
end
end
end, false)
h = 0
Module.New('RuneShooter', function(mod)
if Self.TargetID() ~= 0 then
Self.UseItemWithTarget(Rune)
end
mod:Delay(2250)
end, false)
sd = 0
Module.New('ManaHealer', function(mod)
if Self.ItemCount(mPots) > 0 then
if Self.Mana() < tonumber(BelowMana) then
Self.UseItemWithMe(mPots)
end
end
mod:Delay(1000)
end, false)
mHealer = 0
Module.New('Healer', function(module)
if HealthPercent() < tonumber(HealthBelowStrong) then
wait(200)
if Self.CanCastSpell(StrongHealingSpell) then
Self.Cast(StrongHealingSpell)
end
elseif HealthPercent() < tonumber(HealthBelowMedium) then
wait(200)
if Self.CanCastSpell(MediumHealingSpell) then
Self.Cast(MediumHealingSpell)
end
elseif HealthPercent() < tonumber(HealthBelowLight) then
wait(200)
if Self.CanCastSpell(LightHealingSpell) then
Self.Cast(LightHealingSpell)
end
module:Delay(100)
end
end, false)
Healer = 0
function HealthPercent()
return math.ceil((Self.Health()/Self.MaxHealth()*100))
end
Module.New('Check_Pos', function ()
s_pos = Self.Position()
Module.Start('AntiPush')
Module.Stop('Check_Pos')
end, false)
Module.New('AntiPush', function()
pos = Self.Position()
px = pos.x - s_pos.x
py = pos.y - s_pos.y
if px ~= 0 then
if px < 0 then
Self.Step("east")
elseif px > 0 then
Self.Step("west")
end
elseif py ~= 0 then
if py < 0 then
Self.Step("south")
elseif py > 0 then
Self.Step("north")
end
end
end, false)
-- Mana trainer vars
function TrainerPot()
if TrainerPotion == "mana potion" then
ratio = 2.7
PotionPrice = 50
elseif TrainerPotion == "strong mana potion" then
ratio = 2.9
PotionPrice = 80
elseif TrainerPotion == "great mana potion" then
ratio = 3.1
PotionPrice = 120
elseif TrainerPotion == "ultimate mana potion" then
ratio = 3.1
PotionPrice = 350
end
end
TrainerPotion = mPots
Supplying = false
fromBackpackID = Item.GetID(fromBackpack)
Module.New('TrainerMod', function(mod)
Module.Start('ManaHealer')
PotionID = Item.GetID(TrainerPotion)
ContTo = Container.New(toBackpack)
if not Supplying and (ContTo:CountItemsOfID(PotionID) > 0) then --using all of the mana potions
if Self.CanCastSpell(TrainerPrio1) then
Self.Cast(TrainerPrio1)
elseif (not Self.CanCastSpell(TrainerPrio1)) then
if Self.CanCastSpell(TrainerPrio2) then
Self.Cast(TrainerPrio2)
elseif (not Self.CanCastSpell(TrainerPrio2)) then
if Self.CanCastSpell(TrainerPrio3) then
Self.Cast(TrainerPrio3)
end
end
end
elseif HouseTrainer then
Module.Stop('ManaHealer')
if noMana then
Self.Logout()
end
Supplying = true
Self.DropFlasks(Self.Position().x, Self.Position().y, Self.Position().z)
Self.CloseContainers()
Self.OpenMainBackpack(true)
pos = Self.Position()
for y = -1, 1 do
for x = -1, 1 do
if Map.GetTopUseItem(pos.x+x, pos.y+y, pos.z).id == fromBackpackID then
Self.UseItemFromGround(pos.x + x, pos.y + y, pos.z)
wait(Self.Ping() + 300)
ManaBP = Container.New(fromBackpackID)
if ManaBP:isOpen() then
wait(Self.Ping() + 300)
else
return
end
end
end
end
while Self.Cap() > ratio*50 do
if ManaBP:CountItemsOfID(PotionID) == 0 then
local firstItem = ManaBP:GetItemData(ManaBP:ItemCount() - ManaBP:ItemCount())
if (Item.isContainer(firstItem.id)) then
ManaBP:UseItem(0, true)
wait(Self.Ping() + 300)
else
if not (Item.isContainer(firstItem.id)) then
noMana = true
Supplying = false
print("Out of pots, logging out after finishing the last round of pots.")
Self.CloseContainers()
Self.OpenMainBackpack(true)
break
end
end
else
for fromSpot = 0, ManaBP:ItemCount()-1 do
if (ManaBP:GetItemData(fromSpot).id == PotionID) then
if (ContTo:EmptySlots() > 0) then
ManaBP:MoveItemToContainer(fromSpot, ContTo, ContTo:ItemCapacity()-1, 50)
wait(500)
if Self.Cap() < ratio*50 then
Supplying = false
Self.CloseContainers()
Self.OpenMainBackpack(true)
break
end
end
end
end
end
end
elseif not HouseTrainer then
Self.SayToNpc({"hi", "trade"}, 100)
if Self.Money() > PotionPrice then
if (Self.Flasks() > 0) then
Self.ShopSellFlasks()
sleep(math.random(300,900))
elseif (Self.ItemCount(3031) > PotionPrice) then
CountGold = Self.ItemCount(3031) / PotionPrice
Self.ShopBuyItemsUpTo(PotionID, string.format('%i', CountGold))
sleep(math.random(300,900))
elseif (Self.Cap() > (ratio*10)) and (Self.Money() > PotionPrice) then
ManaToBuy = (Self.Cap()-20) / ratio
Self.ShopBuyItemsUpTo(PotionID, string.format('%i',ManaToBuy))
sleep(math.random(300,900))
end
else
Self.Logout()
end
end
mod:Delay(1200)
end, false)
-----------------------------------------------------------------------------------------------
local HUDData = {}
local data = {}
HUDData = data
local colorA = {r=225, g=22, b=22}
local colorD = {r=255, g=255, b=255}
data.updateAF4 = ""
data.updateDF4 = "".. TargetedruneshooterHUD .." Targeted rune shooter: Deactivated"
data.updateAF6 = ""
data.updateDF6 = "".. ManaHealerHUD .." Mana healer: Deactivated"
data.updateAF10 = ""
data.updateDF10 = "".. ManaShieldHUD .." Magic Shield: Deactivated"
data.updateAF12 = ""
data.updateDF12 = "".. HasteHUD .." Haste: Deactivated"
data.updateAF2 = ""
data.updateDF2 = "".. HealerHUD .." Healer: Deactivated"
data.labelS = HUD.CreateTextDisplay(116, 30, "Support", 255, 255, 255)
data.labelA = HUD.CreateTextDisplay(1575, 30, "Attack", 255, 255, 255)
data.labelA10 = HUD.CreateTextDisplay(66, 74, data.updateAF10, colorA.r, colorA.g, colorA.b)
data.labelD10 = HUD.CreateTextDisplay(66, 74, data.updateDF10, colorD.r, colorD.g, colorD.b)
data.labelA6 = HUD.CreateTextDisplay(66, 60, data.updateAF6, colorA.r, colorA.g, colorA.b)
data.labelD6 = HUD.CreateTextDisplay(66, 60, data.updateDF6, colorD.r, colorD.g, colorD.b)
data.labelA12 = HUD.CreateTextDisplay(66, 88, data.updateAF12, colorA.r, colorA.g, colorA.b)
data.labelD12 = HUD.CreateTextDisplay(66, 88, data.updateDF12, colorD.r, colorD.g, colorD.b)
data.labelA4 = HUD.CreateTextDisplay(1475, 46, data.updateAF4, colorA.r, colorA.g, colorA.b)
data.labelD4 = HUD.CreateTextDisplay(1475, 46, data.updateDF4, colorD.r, colorD.g, colorD.b)
data.labelA2 = HUD.CreateTextDisplay(66, 46, data.updateAF2, colorA.r, colorA.g, colorA.b)
data.labelD2 = HUD.CreateTextDisplay(66, 46, data.updateDF2, colorD.r, colorD.g, colorD.b)
function HudUpdateF2()
HUDData.labelA2:SetText(updateAF2)
HUDData.labelD2:SetText(updateDF2)
end
function HudUpdateF4()
HUDData.labelA4:SetText(updateAF4)
HUDData.labelD4:SetText(updateDF4)
end
function HudUpdateF6()
HUDData.labelA6:SetText(updateAF6)
HUDData.labelD6:SetText(updateDF6)
end
function HudUpdateF10()
HUDData.labelA10:SetText(updateAF10)
HUDData.labelD10:SetText(updateDF10)
end
function HudUpdateF12()
HUDData.labelA12:SetText(updateAF12)
HUDData.labelD12:SetText(updateDF12)
end
---------------------------------------------------------------------------------------------
-- Available hotkeys. If you enable for example F1 you cannot use F1, ctrl+F1 or shift+F1 in the hotkey menu ingame. That is the reason behind the checks.
if Hotkeys.F1 == true then
Hotkeys.F1 = 0x70
end
if Hotkeys.F2 == true then
Hotkeys.F2 = 0x71
end
if Hotkeys.F3 == true then
Hotkeys.F3 = 0x72
end
if Hotkeys.F4 == true then
Hotkeys.F4 = 0x73
end
if Hotkeys.F5 == true then
Hotkeys.F5 = 0x74
end
if Hotkeys.F6 == true then
Hotkeys.F6 = 0x75
end
if Hotkeys.F7 == true then
Hotkeys.F7 = 0x76
end
if Hotkeys.F8 == true then
Hotkeys.F8 = 0x77
end
if Hotkeys.F9 == true then
Hotkeys.F9 = 0x78
end
if Hotkeys.F10 == true then
Hotkeys.F10 = 0x79
end
if Hotkeys.F11 == true then
Hotkeys.F11 = 0x7A
end
if Hotkeys.F12 == true then
Hotkeys.F12 = 0x7B
end
if Hotkeys.PAGEUP == true then
Hotkeys.PAGEUP = 0x21
end
if Hotkeys.PAGEDOWN == true then
Hotkeys.PAGEDOWN = 0x22
end
if Hotkeys.INSERT == true then
Hotkeys.INSERT = 0x2D
end
if Hotkeys.DELETE == true then
Hotkeys.DELETE = 0x2E
end
if Hotkeys.END == true then
Hotkeys.END = 0x23
end
if Hotkeys.HOME == true then
Hotkeys.HOME = 0x24
end
Hotkeys.AddPressHandler(pressHandler)
Hotkeys.AddPressHandler(releaseHandler)
for name, value in pairs(Hotkeys) do
if (type(value) == "number") then
if (not Hotkeys.Register(value)) then
print("Failed to register hotkey %d", value)
end
end
end
-- Channel
HotkeyChannel = Channel.Open('Hotkey Config', onSpeak, onClose)
function ProcessDebugMessage(speaker, message)
HotkeyChannel:SendOrangeMessage(speaker, message)
end
ProcessDebugMessage('Hotkey Config', 'Welcome to the hotkey configuration channel.')
ProcessDebugMessage('Hotkey Config', 'Write "help" to see the commands.')
registerNativeEventListener(EVENT_SELF_CHANNELSPEE CH, 'onChannelSpeak')
onChannelSpeak = function(channel, message)
message = message:lower()
Latestmsg = message
if message == "help" then
HotkeyChannel:SendYellowMessage('Commands','\ndisp lay = View the configuration.\ntrainer = start/stop or change the mana trainer, and also view the config for the trainer.\nh1 = Change the config on the prio 1 healing spell.\nh2 = Change the config on the prio 2 healing spell.\nh3 = Change the config on the prio 3 healing spell.\nhs = Change the haste spell.\nmana = Change the configuration for the mana healer.\nms = Change between using ring and spell for manashield.\nrune = Change which rune the rune shooter is using.')
elseif message == "h1" then
msg = message
shs = 1
ProcessDebugMessage('Config', 'Please enter the prio 1 healing spell you want to use.')
cMessage = "will now be used as the prio 1 healing spell."
Module.Start('MessageReader')
wait (200)
elseif message == "h2" then
msg = message
mhs = 1
ProcessDebugMessage('Config', 'Please enter the prio 2 healing spell you want to use.')
cMessage = "will now be used as the prio 2 healing spell."
Module.Start('MessageReader')
wait (200)
elseif message == "h3" then
msg = message
lhs = 1
ProcessDebugMessage('Config', 'Please enter the prio 3 healing spell you want to use.')
cMessage = "will now be used as the prio 3 healing spell."
Module.Start('MessageReader')
wait (200)
elseif message == "hs" then
msg = message
hs = 1
ProcessDebugMessage('Config', 'Please enter which haste spell you want to use.')
cMessage = "will now be used to haste."
Module.Start('MessageReader')
wait (200)
elseif message == "mana" then
msg = message
mana = 1
ProcessDebugMessage('Config', 'Please enter which mana potion you want to use.')
Module.Start('MessageReader')
wait(200)
elseif message == "ms" then
msg = message
ms = 1
ProcessDebugMessage('Config', 'Please enter which how you want to use manashield. ring / spell')
cMessage = "will now be used to get manashielded."
Module.Start('MessageReader')
wait(200)
elseif message == "rune" then
msg = message
rune = 1
ProcessDebugMessage('Config', 'Please enter which rune you want to use in the rune shooter')
cMessage = "will now be used in the rune shooter."
Module.Start('MessageReader')
wait(200)
elseif message == "trainer" then
msg = message
trainer = 1
TrainerPotion = mPots
if HouseTrainer then
TrainerType = "HouseTrainer"
else
TrainerType = "ShopTrainer"
end
ProcessDebugMessage('Config', '\nDo you want to "start" or "stop" the trainer, or "change" the configuration? If you changed your mind and dont want to use the trainer write "stop" to be able to use other commands.')
HotkeyChannel:SendYellowMessage('Notice!',"\nIf you're using the regular mana trainer the main backpack must be open and contain money. Stand beside the shop in reach of the npc when starting the script!\nIf you are using the housetrainer you need to stand in reach of the backpack to open, but not on top of it, since the vials will be dropped where you are standing.")
if TrainerPotion == "ultimate mana potion" then
HotkeyChannel:SendYellowMessage('Current trainer config','\nMana pots: '.. TrainerPotion ..' (Not supported, use another potion!)\nSpell prio 1 = '.. TrainerPrio1 ..'\nSpell prio 2 = '.. TrainerPrio2 ..'\nSpell prio 3 = '.. TrainerPrio3 ..'')
else
HotkeyChannel:SendYellowMessage('Current trainer config','\nTrainer type = '.. TrainerType ..'\nMana pots: '.. TrainerPotion ..'\nSpell prio 1 = '.. TrainerPrio1 ..'\nSpell prio 2 = '.. TrainerPrio2 ..'\nSpell prio 3 = '.. TrainerPrio3 ..'')
end
Module.Start('MessageReader')
wait(200)
elseif message == "display" then
HotkeyChannel:SendYellowMessage('Current settings','\nMana Healer: Mana potions = '.. mPots ..' / Below '.. BelowMana ..' mana.\nHealing prio 1: Spell = '.. StrongHealingSpell ..' / Percentage to heal = '.. HealthBelowStrong ..'\nHealing prio 2: Spell = '.. MediumHealingSpell ..' / Percentage to heal = '.. HealthBelowMedium ..'\nHealing prio 3: Spell = '.. LightHealingSpell ..' / Percentage to heal = '.. HealthBelowLight ..'\nHaster: Spell = '.. HasteSpell ..'\nManaShield: Method = '.. ManaShieldMethod ..'\nRuneShooter: Rune = '.. Rune ..'')
end
end
MR = Module.New('MessageReader', function(mod)
if shs == 1 and Latestmsg ~= msg then
StrongHealingSpell = Latestmsg
HotkeyChannel:SendYellowMessage('Config', ''.. Latestmsg ..' ' ..cMessage.. '')
wait(100)
shs = 0
shv = 1
msg = Latestmsg
ProcessDebugMessage('Prio 1', 'At which percentage do you want to heal?')
Module.Start('MessageReader1')
Module.Stop('MessageReader')
elseif mhs == 1 and Latestmsg ~= msg then
MediumHealingSpell = Latestmsg
HotkeyChannel:SendYellowMessage('Config', ''.. Latestmsg ..' ' ..cMessage.. '')
wait(100)
mhs = 0
mhv = 1
msg = Latestmsg
ProcessDebugMessage('Prio 2', 'At which percentage do you want to heal?')
Module.Start('MessageReader1')
Module.Stop('MessageReader')
elseif lhs == 1 and Latestmsg ~= msg then
LightHealingSpell = Latestmsg
HotkeyChannel:SendYellowMessage('Config', ''.. Latestmsg ..' ' ..cMessage.. '')
wait(100)
lhs = 0
lhv = 1
msg = Latestmsg
ProcessDebugMessage('Prio 3', 'At which percentage do you want to heal?')
Module.Start('MessageReader1')
Module.Stop('MessageReader')
elseif hs == 1 and Latestmsg ~= msg then
HasteSpell = Latestmsg
HotkeyChannel:SendYellowMessage('Config', ''.. Latestmsg ..' ' ..cMessage.. '')
wait(100)
hs = 0
Module.Stop('MessageReader')
elseif ms == 1 and Latestmsg ~= msg then
ManaShieldMethod = Latestmsg
HotkeyChannel:SendYellowMessage('ManaShield', ''.. Latestmsg ..' ' ..cMessage.. '')
wait(100)
ms = 0
Module.Stop('MessageReader')
elseif trainer == 1 and Latestmsg ~= msg then
if Latestmsg == "start" or "change" or "stop" then
if Latestmsg == "start" then
if TrainerPotion == "ultimate mana potion" then
msg = Latestmsg
HotkeyChannel:SendYellowMessage('Trainer', 'The script does not support this potion!')
trainer = 0
else
if not HouseTrainer then
ProcessDebugMessage('Trainer', 'Do you want to use Anti-push? If so write "yes" when you are in position, else write "no"')
AntiCheck = 0
trainer = 0
else
TrainerPot()
Module.Start('TrainerMod')
HotkeyChannel:SendYellowMessage('Trainer', 'Trainer started.')
if mHealer == 0 then
updateAF6 = "".. ManaHealerHUD .." Mana healer: Activated"
updateDF6 = ""
HudUpdateF6()
Module.Start('ManaHealer')
mHealer = 1
end
Module.Stop('MessageReader')
end
end
elseif Latestmsg == "stop" then
Module.Stop('TrainerMod')
Module.Stop('AntiPush')
HotkeyChannel:SendYellowMessage('Trainer', 'Trainer stopped.')
trainer = 0
Module.Stop('MessageReader')
elseif Latestmsg == "change" then
msg = Latestmsg
ProcessDebugMessage('Config', 'Do you want to change "potion", "spells" or "trainertype"?')
Module.Start('MessageReader1')
Module.Stop('MessageReader')
end
end
elseif rune == 1 and Latestmsg ~= msg then
Rune = Latestmsg
HotkeyChannel:SendYellowMessage('RuneShooter', ''.. Latestmsg ..' ' ..cMessage.. '')
wait(100)
rune = 0
Module.Stop('MessageReader')
elseif mana == 1 and Latestmsg ~= msg then
mPots = Latestmsg
wait(100)
msg = Latestmsg
mana = 0
mv = 1
ProcessDebugMessage('Mana Healer', 'At which amount of mana do you want to use a potion?')
Module.Start('MessageReader1')
Module.Stop('MessageReader')
elseif AntiCheck == 0 and Latestmsg == "yes" then
Module.Start('Check_Pos')
TrainerPot()
Module.Start('TrainerMod')
HotkeyChannel:SendYellowMessage('Trainer', 'Trainer started.')
Module.Stop('MessageReader')
AntiCheck = 1
if mHealer == 0 then
updateAF6 = "".. ManaHealerHUD .." Mana healer: Activated"
updateDF6 = ""
HudUpdateF6()
Module.Start('ManaHealer')
mHealer = 1
end
elseif AntiCheck == 0 and Latestmsg == "no" then
TrainerPot()
Module.Start('TrainerMod')
HotkeyChannel:SendYellowMessage('Trainer', 'Trainer started.')
Module.Stop('MessageReader')
AntiCheck = 1
if mHealer == 0 then
updateAF6 = "".. ManaHealerHUD .." Mana healer: Activated"
updateDF6 = ""
HudUpdateF6()
Module.Start('ManaHealer')
mHealer = 1
end
end
end, false)
MR1 = Module.New('MessageReader1', function(mod)
if shv == 1 and Latestmsg ~= msg then
HealthBelowStrong = Latestmsg
wait(200)
HotkeyChannel:SendYellowMessage('Config', 'You will now use '.. StrongHealingSpell ..' at ' .. HealthBelowStrong .. ' percent')
shv = 0
Module.Stop('MessageReader1')
elseif mhv == 1 and Latestmsg ~= msg then
HealthBelowMedium = Latestmsg
wait(200)
HotkeyChannel:SendYellowMessage('Config', 'You will now use '.. MediumHealingSpell ..' at ' .. HealthBelowMedium .. ' percent')
mhv = 0
Module.Stop('MessageReader1')
elseif lhv == 1 and Latestmsg ~= msg then
HealthBelowLight = Latestmsg
wait(200)
HotkeyChannel:SendYellowMessage('Config', 'You will now use '.. LightHealingSpell ..' at ' .. HealthBelowLight .. ' percent')
lhv = 0
Module.Stop('MessageReader1')
elseif mv == 1 and Latestmsg ~= msg then
BelowMana = Latestmsg
wait(200)
HotkeyChannel:SendYellowMessage('Config', 'You will now use '.. mPots ..' below ' .. BelowMana .. ' mana')
mv = 0
Module.Stop('MessageReader1')
elseif trainer == 1 and Latestmsg == "potion" then
msg = Latestmsg
ProcessDebugMessage('Config', 'Which potion do you want to use in the trainer aswell as mana healer?')
trainer = 2
elseif trainer == 2 and Latestmsg ~= msg then
TrainerPotion = Latestmsg
mPots = Latestmsg
TrainerPot()
HotkeyChannel:SendYellowMessage('Config', 'You will now use '.. TrainerPotion ..' in the trainer and mana healer.')
msg = Latestmsg
trainer = 0
Module.Stop('MessageReader1')
elseif trainer == 1 and Latestmsg == "spells" then
ProcessDebugMessage('Config', 'Which spell do you want to use as the first priority?')
msg = Latestmsg
trainer = 3
elseif trainer == 1 and Latestmsg == "trainertype" then
ProcessDebugMessage('Config', 'Do you want to use the "housetrainer" or the "shoptrainer"?')
msg = Latestmsg
trainer = 10
elseif trainer == 10 and Latestmsg == "shoptrainer" then
msg = Latestmsg
HouseTrainer = false
HotkeyChannel:SendYellowMessage('Config', 'The trainer is now set to train next to the potion npc.')
trainer = 0
Module.Stop('MessageReader1')
elseif trainer == 10 and Latestmsg == "housetrainer" then
msg = Latestmsg
HouseTrainer = true
ProcessDebugMessage('Config', 'Which backpack do you want to withdraw potions from?')
trainer = 11
elseif trainer == 11 and Latestmsg ~= msg then
msg = Latestmsg
fromBackpack = Latestmsg
HotkeyChannel:SendYellowMessage('Config', 'The trainer will now withdraw manas from '.. fromBackpack ..'.')
ProcessDebugMessage('Config', 'What is the name of your main backpack?')
trainer = 12
elseif trainer == 12 and Latestmsg ~= msg then
msg = Latestmsg
fromBackpack = Latestmsg
HotkeyChannel:SendYellowMessage('Config', 'The trainer will now withdraw manas to '.. toBackpack ..'.')
ProcessDebugMessage('Config', 'To start the script or change it further, write "trainer" again.')
trainer = 0
Module.Stop('MessageReader1')
elseif trainer == 3 and Latestmsg ~= msg then
TrainerPrio1 = Latestmsg
HotkeyChannel:SendYellowMessage('Config', 'You will now use '.. TrainerPrio1 ..' as prio 1 in the trainer')
ProcessDebugMessage('Config', 'Which spell do you want to use as the second priority?')
msg = Latestmsg
trainer = 4
elseif trainer == 4 and Latestmsg ~= msg then
TrainerPrio2 = Latestmsg
HotkeyChannel:SendYellowMessage('Config', 'You will now use '.. TrainerPrio2 ..' as prio 2 in the trainer')
ProcessDebugMessage('Config', 'Which spell do you want to use as the third priority?')
msg = Latestmsg
trainer = 5
elseif trainer == 5 and Latestmsg ~= msg then
TrainerPrio3 = Latestmsg
HotkeyChannel:SendYellowMessage('Config', 'You will now use '.. TrainerPrio3 ..' as prio 3 in the trainer')
HotkeyChannel:SendYellowMessage('Config','Write "trainer" and then "start" to start the trainer.')
trainer = 0
Module.Stop('MessageReader1')
end
end, false)
To be able to use the hotkeys you are not using in this script, you need to comment out the hotkeys in the newest xb.~.lua in C:\prgram files (x86)\xenobot\data like so:
Hotkeys = {}
--Hotkeys.F1 = 0x70
--Hotkeys.F2 = 0x71
--Hotkeys.F3 = 0x72
--Hotkeys.F4 = 0x73
--Hotkeys.F5 = 0x74
--Hotkeys.F6 = 0x75
--Hotkeys.F7 = 0x76
--Hotkeys.F8 = 0x77
--Hotkeys.F9 = 0x78
--Hotkeys.F10 = 0x79
--Hotkeys.F11 = 0x7A
--Hotkeys.F12 = 0x7B
--Hotkeys.PAGEUP = 0x21
--Hotkeys.PAGEDOWN = 0x22
--Hotkeys.INSERT = 0x2D
--Hotkeys.DELETE = 0x2E
--Hotkeys.END = 0x23
--Hotkeys.HOME = 0x24
Hotkeys.__registeredPressHandler = false
Hotkeys.__registeredReleaseHandler = false
Hotkeys.__pressHandlers = {}
Hotkeys.__releaseHandlers = {}
And restart the client.
https://i.gyazo.com/85a5cfd7806a114f82081496c987b31b.png
I am going to update the script so that you can change mana potions in the channel and other stuff i guess. :)
Added: possibility to change the mana potter in the channel.
Added: possibility to change between ring or spell for manashield in the channel.
Added: possibility to change which rune the rune shooter is using in the channel.
Added: Mana trainer with antipush.
Added: House mana trainer, in the same command as the old mana trainer.
Edited a few modules for the better.
Mana trainer:
To switch between the two kinds of trainers write these commands:
trainer, change, trainertype, shoptrainer or housetrainer
Shop mana trainer:
The shop mana trainer will buy potions, use potions and cast spells. Start the trainer next to the shop with the amount of cash you want to use. The mana trainer is not started on a hotkey, instead write "trainer" in the channel to see the choices/config.
House mana trainer:
The house trainer will use the same settings for spells/pots as the shop mana trainer. it will withdraw the chosen manas from the chosen container on the floor. You have to stand next to the backpack in any direction, but not on top of it, because you will drop flasks where you're standing.
-- Config
-- Targeted Rune Shooter
Rune = "sudden death rune" -- Which rune to use in the targeted rune shooter
-- Haster
HasteSpell = "utani gran hur" -- Which haste spell to use
-- ManaShield
ManaShieldMethod = "spell" -- Use ring/spell for manashield?
-- Mana Healer
mPots = "mana potion" -- Which mana potions to use.
BelowMana = 2000 -- Will use mana potions below this amount/percent of mana.
-- Healer
StrongHealingSpell = "exura vita"
HealthBelowStrong = 50 -- Health percentage to use the strong healing spell
MediumHealingSpell = "exura gran"
HealthBelowMedium = 85 -- Health percentage to use the medium healing spell
LightHealingSpell = "exura"
HealthBelowLight = 0 -- Health percentage to use the light healing spell
--Trainer Spells
TrainerPrio1 = "exevo gran mas vis"
TrainerPrio2 = "utana vid"
TrainerPrio3 = "exura vita"
--HouseTrainer
fromBackpack = "Blue Backpack" -- Backpack to open from the floor
toBackpack = "backpack" -- Main backpack, the backpack which
HouseTrainer = false
-- Hotkeys ------------------------------------------------------------
--[[ Set true only if you use it in the script or you wont be able to use the ingame hotkey on that particular button.
This is only needed if you commented out the Hotkeys.~ in the newest xb.~.lua in C:\Program Files (x86)\XenoBot
If you didnt comment it out in the data, you will loose the possibility to use all of the ingame hotkeys when running the script.]]--
Hotkeys.F1 = false
Hotkeys.F2 = true
Hotkeys.F3 = false
Hotkeys.F4 = true
Hotkeys.F5 = false
Hotkeys.F6 = true
Hotkeys.F7 = false
Hotkeys.F8 = false
Hotkeys.F9 = false
Hotkeys.F10 = true
Hotkeys.F12 = true
Hotkeys.PAGEUP = false
Hotkeys.PAGEDOWN = false
Hotkeys.INSERT = false
Hotkeys.DELETE = false
Hotkeys.END = false
Hotkeys.HOME = false
-- This is just to change the HUD to whichever key you're using, so it's easier to not forget which key does what.
TargetedruneshooterHUD = "F4"
HealerHUD = "F2"
ManaHealerHUD = "F6"
ManaShieldHUD = "F10"
HasteHUD = "F12"
-- Hotkeys function
function pressHandler(key, control, shift)
if key == Hotkeys.F4 then --hotkey for the Targeted rune shooter, change this by changing F4 to one of the available hotkeys above. remember to set F4 to false if you're not using it and the key you want to use to true.
if sd == 0 then
Module.Start('RuneShooter')
updateAF4 = "".. TargetedruneshooterHUD .." Targeted rune shooter: Activated"
updateDF4 = ""
HudUpdateF4()
print("Targeted rune shooter: Activated")
sd = 1
else
Module.Stop('RuneShooter')
updateAF4 = ""
updateDF4 = "".. TargetedruneshooterHUD .." Targeted rune shooter: Deactivated"
HudUpdateF4()
print("Targeted rune shooter: Deactivated")
sd = 0
end
elseif key == Hotkeys.F2 then --hotkey for the Healer, change this by changing F2 to one of the available hotkeys above. remember to set F2 to false if you're not using it and the key you want to use to true.
if Healer == 0 then
Module.Start('Healer')
updateAF2 = "".. HealerHUD .." Healer: Activated"
updateDF2 = ""
HudUpdateF2()
print("Healer: Activated")
Healer = 1
else
Module.Stop('Healer')
updateAF2 = ""
updateDF2 = "".. HealerHUD .." Healer: Deactivated"
HudUpdateF2()
print("Healer: Deactivated")
Healer = 0
end
elseif key == Hotkeys.F6 then --hotkey for the Mana Healer, change this by changing F6 to one of the available hotkeys above. remember to set F6 to false if you're not using it and the key you want to use to true.
if mHealer == 0 then
Module.Start('ManaHealer')
updateAF6 = "".. ManaHealerHUD .." Mana healer: Activated"
updateDF6 = ""
HudUpdateF6()
mHealer = 1
else
Module.Stop('ManaHealer')
updateAF6 = ""
updateDF6 = "".. ManaHealerHUD .." Mana healer: Deactivated"
HudUpdateF6()
mHealer = 0
end
elseif key == Hotkeys.F10 then --hotkey for ManaShield, change this by changing F10 to one of the available hotkeys above. remember to set F10 to false if you're not using it and the key you want to use to true.
if ms == 0 then
Module.Start('ManaShield')
updateAF10 = "".. ManaShieldHUD .." Magic Shield: Activated"
updateDF10 = ""
HudUpdateF10()
ms = 1
print("Magic Shield: Activated")
else
Module.Stop('ManaShield')
updateAF10 = ""
updateDF10 = "".. ManaShieldHUD .." Magic Shield: Deactivated"
HudUpdateF10()
ms = 0
print("Magic Shield: Deactivated")
end
elseif key == Hotkeys.F12 then --hotkey for the Haster, change this by changing F12 to one of the available hotkeys above. remember to set F12 to false if you're not using it and the key you want to use to true.
if h == 0 then
Module.Start('Haste')
updateAF12 = "".. HasteHUD .." Haste: Activated"
updateDF12 = ""
HudUpdateF12()
h = 1
print("Haste: Activated")
else
Module.Stop('Haste')
updateAF12 = ""
updateDF12 = "".. HasteHUD .." Haste: Deactivated"
HudUpdateF12()
h = 0
print("Haste: Deactivated")
end
end
end
-- Modules ------------------------------------------------------------
Module.New('ManaShield', function(mod)
if not Self.isManaShielded() and not Self.isInPz() and ManaShieldMethod == "spell" then
if Self.CanCastSpell("utamo vita") then
Self.Cast("utamo vita")
end
elseif not Self.isManaShielded() and not Self.isInPz() and ManaShieldMethod == "ring" then
if Self.ItemCount(3051) > 0 and Self.Ring().id ~= 3088 then
Self.Equip(3051, "ring")
end
elseif Self.isInPz() and Self.Ring().id == 3088 then
Self.Dequip("ring")
end
mod:Delay(200)
end, false)
ms = 0
Module.New('Haste', function(mod)
if not Self.isHasted() then
if Self.CanCastSpell(HasteSpell) then
Self.Cast(HasteSpell)
end
end
end, false)
h = 0
Module.New('RuneShooter', function(mod)
if Self.TargetID() ~= 0 then
Self.UseItemWithTarget(Rune)
end
mod:Delay(2250)
end, false)
sd = 0
Module.New('ManaHealer', function(mod)
if Self.ItemCount(mPots) > 0 then
if Self.Mana() < tonumber(BelowMana) then
Self.UseItemWithMe(mPots)
end
end
mod:Delay(1000)
end, false)
mHealer = 0
Module.New('Healer', function(module)
if HealthPercent() < tonumber(HealthBelowStrong) then
wait(200)
if Self.CanCastSpell(StrongHealingSpell) then
Self.Cast(StrongHealingSpell)
end
elseif HealthPercent() < tonumber(HealthBelowMedium) then
wait(200)
if Self.CanCastSpell(MediumHealingSpell) then
Self.Cast(MediumHealingSpell)
end
elseif HealthPercent() < tonumber(HealthBelowLight) then
wait(200)
if Self.CanCastSpell(LightHealingSpell) then
Self.Cast(LightHealingSpell)
end
module:Delay(100)
end
end, false)
Healer = 0
function HealthPercent()
return math.ceil((Self.Health()/Self.MaxHealth()*100))
end
Module.New('Check_Pos', function ()
s_pos = Self.Position()
Module.Start('AntiPush')
Module.Stop('Check_Pos')
end, false)
Module.New('AntiPush', function()
pos = Self.Position()
px = pos.x - s_pos.x
py = pos.y - s_pos.y
if px ~= 0 then
if px < 0 then
Self.Step("east")
elseif px > 0 then
Self.Step("west")
end
elseif py ~= 0 then
if py < 0 then
Self.Step("south")
elseif py > 0 then
Self.Step("north")
end
end
end, false)
-- Mana trainer vars
function TrainerPot()
if TrainerPotion == "mana potion" then
ratio = 2.7
PotionPrice = 50
elseif TrainerPotion == "strong mana potion" then
ratio = 2.9
PotionPrice = 80
elseif TrainerPotion == "great mana potion" then
ratio = 3.1
PotionPrice = 120
elseif TrainerPotion == "ultimate mana potion" then
ratio = 3.1
PotionPrice = 350
end
end
TrainerPotion = mPots
Supplying = false
fromBackpackID = Item.GetID(fromBackpack)
Module.New('TrainerMod', function(mod)
Module.Start('ManaHealer')
PotionID = Item.GetID(TrainerPotion)
ContTo = Container.New(toBackpack)
if not Supplying and (ContTo:CountItemsOfID(PotionID) > 0) then --using all of the mana potions
if Self.CanCastSpell(TrainerPrio1) then
Self.Cast(TrainerPrio1)
elseif (not Self.CanCastSpell(TrainerPrio1)) then
if Self.CanCastSpell(TrainerPrio2) then
Self.Cast(TrainerPrio2)
elseif (not Self.CanCastSpell(TrainerPrio2)) then
if Self.CanCastSpell(TrainerPrio3) then
Self.Cast(TrainerPrio3)
end
end
end
elseif HouseTrainer then
Module.Stop('ManaHealer')
if noMana then
Self.Logout()
end
Supplying = true
Self.DropFlasks(Self.Position().x, Self.Position().y, Self.Position().z)
Self.CloseContainers()
Self.OpenMainBackpack(true)
pos = Self.Position()
for y = -1, 1 do
for x = -1, 1 do
if Map.GetTopUseItem(pos.x+x, pos.y+y, pos.z).id == fromBackpackID then
Self.UseItemFromGround(pos.x + x, pos.y + y, pos.z)
wait(Self.Ping() + 300)
ManaBP = Container.New(fromBackpackID)
if ManaBP:isOpen() then
wait(Self.Ping() + 300)
else
return
end
end
end
end
while Self.Cap() > ratio*50 do
if ManaBP:CountItemsOfID(PotionID) == 0 then
local firstItem = ManaBP:GetItemData(ManaBP:ItemCount() - ManaBP:ItemCount())
if (Item.isContainer(firstItem.id)) then
ManaBP:UseItem(0, true)
wait(Self.Ping() + 300)
else
if not (Item.isContainer(firstItem.id)) then
noMana = true
Supplying = false
print("Out of pots, logging out after finishing the last round of pots.")
Self.CloseContainers()
Self.OpenMainBackpack(true)
break
end
end
else
for fromSpot = 0, ManaBP:ItemCount()-1 do
if (ManaBP:GetItemData(fromSpot).id == PotionID) then
if (ContTo:EmptySlots() > 0) then
ManaBP:MoveItemToContainer(fromSpot, ContTo, ContTo:ItemCapacity()-1, 50)
wait(500)
if Self.Cap() < ratio*50 then
Supplying = false
Self.CloseContainers()
Self.OpenMainBackpack(true)
break
end
end
end
end
end
end
elseif not HouseTrainer then
Self.SayToNpc({"hi", "trade"}, 100)
if Self.Money() > PotionPrice then
if (Self.Flasks() > 0) then
Self.ShopSellFlasks()
sleep(math.random(300,900))
elseif (Self.ItemCount(3031) > PotionPrice) then
CountGold = Self.ItemCount(3031) / PotionPrice
Self.ShopBuyItemsUpTo(PotionID, string.format('%i', CountGold))
sleep(math.random(300,900))
elseif (Self.Cap() > (ratio*10)) and (Self.Money() > PotionPrice) then
ManaToBuy = (Self.Cap()-20) / ratio
Self.ShopBuyItemsUpTo(PotionID, string.format('%i',ManaToBuy))
sleep(math.random(300,900))
end
else
Self.Logout()
end
end
mod:Delay(1200)
end, false)
-----------------------------------------------------------------------------------------------
local HUDData = {}
local data = {}
HUDData = data
local colorA = {r=225, g=22, b=22}
local colorD = {r=255, g=255, b=255}
data.updateAF4 = ""
data.updateDF4 = "".. TargetedruneshooterHUD .." Targeted rune shooter: Deactivated"
data.updateAF6 = ""
data.updateDF6 = "".. ManaHealerHUD .." Mana healer: Deactivated"
data.updateAF10 = ""
data.updateDF10 = "".. ManaShieldHUD .." Magic Shield: Deactivated"
data.updateAF12 = ""
data.updateDF12 = "".. HasteHUD .." Haste: Deactivated"
data.updateAF2 = ""
data.updateDF2 = "".. HealerHUD .." Healer: Deactivated"
data.labelS = HUD.CreateTextDisplay(116, 30, "Support", 255, 255, 255)
data.labelA = HUD.CreateTextDisplay(1575, 30, "Attack", 255, 255, 255)
data.labelA10 = HUD.CreateTextDisplay(66, 74, data.updateAF10, colorA.r, colorA.g, colorA.b)
data.labelD10 = HUD.CreateTextDisplay(66, 74, data.updateDF10, colorD.r, colorD.g, colorD.b)
data.labelA6 = HUD.CreateTextDisplay(66, 60, data.updateAF6, colorA.r, colorA.g, colorA.b)
data.labelD6 = HUD.CreateTextDisplay(66, 60, data.updateDF6, colorD.r, colorD.g, colorD.b)
data.labelA12 = HUD.CreateTextDisplay(66, 88, data.updateAF12, colorA.r, colorA.g, colorA.b)
data.labelD12 = HUD.CreateTextDisplay(66, 88, data.updateDF12, colorD.r, colorD.g, colorD.b)
data.labelA4 = HUD.CreateTextDisplay(1475, 46, data.updateAF4, colorA.r, colorA.g, colorA.b)
data.labelD4 = HUD.CreateTextDisplay(1475, 46, data.updateDF4, colorD.r, colorD.g, colorD.b)
data.labelA2 = HUD.CreateTextDisplay(66, 46, data.updateAF2, colorA.r, colorA.g, colorA.b)
data.labelD2 = HUD.CreateTextDisplay(66, 46, data.updateDF2, colorD.r, colorD.g, colorD.b)
function HudUpdateF2()
HUDData.labelA2:SetText(updateAF2)
HUDData.labelD2:SetText(updateDF2)
end
function HudUpdateF4()
HUDData.labelA4:SetText(updateAF4)
HUDData.labelD4:SetText(updateDF4)
end
function HudUpdateF6()
HUDData.labelA6:SetText(updateAF6)
HUDData.labelD6:SetText(updateDF6)
end
function HudUpdateF10()
HUDData.labelA10:SetText(updateAF10)
HUDData.labelD10:SetText(updateDF10)
end
function HudUpdateF12()
HUDData.labelA12:SetText(updateAF12)
HUDData.labelD12:SetText(updateDF12)
end
---------------------------------------------------------------------------------------------
-- Available hotkeys. If you enable for example F1 you cannot use F1, ctrl+F1 or shift+F1 in the hotkey menu ingame. That is the reason behind the checks.
if Hotkeys.F1 == true then
Hotkeys.F1 = 0x70
end
if Hotkeys.F2 == true then
Hotkeys.F2 = 0x71
end
if Hotkeys.F3 == true then
Hotkeys.F3 = 0x72
end
if Hotkeys.F4 == true then
Hotkeys.F4 = 0x73
end
if Hotkeys.F5 == true then
Hotkeys.F5 = 0x74
end
if Hotkeys.F6 == true then
Hotkeys.F6 = 0x75
end
if Hotkeys.F7 == true then
Hotkeys.F7 = 0x76
end
if Hotkeys.F8 == true then
Hotkeys.F8 = 0x77
end
if Hotkeys.F9 == true then
Hotkeys.F9 = 0x78
end
if Hotkeys.F10 == true then
Hotkeys.F10 = 0x79
end
if Hotkeys.F11 == true then
Hotkeys.F11 = 0x7A
end
if Hotkeys.F12 == true then
Hotkeys.F12 = 0x7B
end
if Hotkeys.PAGEUP == true then
Hotkeys.PAGEUP = 0x21
end
if Hotkeys.PAGEDOWN == true then
Hotkeys.PAGEDOWN = 0x22
end
if Hotkeys.INSERT == true then
Hotkeys.INSERT = 0x2D
end
if Hotkeys.DELETE == true then
Hotkeys.DELETE = 0x2E
end
if Hotkeys.END == true then
Hotkeys.END = 0x23
end
if Hotkeys.HOME == true then
Hotkeys.HOME = 0x24
end
Hotkeys.AddPressHandler(pressHandler)
Hotkeys.AddPressHandler(releaseHandler)
for name, value in pairs(Hotkeys) do
if (type(value) == "number") then
if (not Hotkeys.Register(value)) then
print("Failed to register hotkey %d", value)
end
end
end
-- Channel
HotkeyChannel = Channel.Open('Hotkey Config', onSpeak, onClose)
function ProcessDebugMessage(speaker, message)
HotkeyChannel:SendOrangeMessage(speaker, message)
end
ProcessDebugMessage('Hotkey Config', 'Welcome to the hotkey configuration channel.')
ProcessDebugMessage('Hotkey Config', 'Write "help" to see the commands.')
registerNativeEventListener(EVENT_SELF_CHANNELSPEE CH, 'onChannelSpeak')
onChannelSpeak = function(channel, message)
message = message:lower()
Latestmsg = message
if message == "help" then
HotkeyChannel:SendYellowMessage('Commands','\ndisp lay = View the configuration.\ntrainer = start/stop or change the mana trainer, and also view the config for the trainer.\nh1 = Change the config on the prio 1 healing spell.\nh2 = Change the config on the prio 2 healing spell.\nh3 = Change the config on the prio 3 healing spell.\nhs = Change the haste spell.\nmana = Change the configuration for the mana healer.\nms = Change between using ring and spell for manashield.\nrune = Change which rune the rune shooter is using.')
elseif message == "h1" then
msg = message
shs = 1
ProcessDebugMessage('Config', 'Please enter the prio 1 healing spell you want to use.')
cMessage = "will now be used as the prio 1 healing spell."
Module.Start('MessageReader')
wait (200)
elseif message == "h2" then
msg = message
mhs = 1
ProcessDebugMessage('Config', 'Please enter the prio 2 healing spell you want to use.')
cMessage = "will now be used as the prio 2 healing spell."
Module.Start('MessageReader')
wait (200)
elseif message == "h3" then
msg = message
lhs = 1
ProcessDebugMessage('Config', 'Please enter the prio 3 healing spell you want to use.')
cMessage = "will now be used as the prio 3 healing spell."
Module.Start('MessageReader')
wait (200)
elseif message == "hs" then
msg = message
hs = 1
ProcessDebugMessage('Config', 'Please enter which haste spell you want to use.')
cMessage = "will now be used to haste."
Module.Start('MessageReader')
wait (200)
elseif message == "mana" then
msg = message
mana = 1
ProcessDebugMessage('Config', 'Please enter which mana potion you want to use.')
Module.Start('MessageReader')
wait(200)
elseif message == "ms" then
msg = message
ms = 1
ProcessDebugMessage('Config', 'Please enter which how you want to use manashield. ring / spell')
cMessage = "will now be used to get manashielded."
Module.Start('MessageReader')
wait(200)
elseif message == "rune" then
msg = message
rune = 1
ProcessDebugMessage('Config', 'Please enter which rune you want to use in the rune shooter')
cMessage = "will now be used in the rune shooter."
Module.Start('MessageReader')
wait(200)
elseif message == "trainer" then
msg = message
trainer = 1
TrainerPotion = mPots
if HouseTrainer then
TrainerType = "HouseTrainer"
else
TrainerType = "ShopTrainer"
end
ProcessDebugMessage('Config', '\nDo you want to "start" or "stop" the trainer, or "change" the configuration? If you changed your mind and dont want to use the trainer write "stop" to be able to use other commands.')
HotkeyChannel:SendYellowMessage('Notice!',"\nIf you're using the regular mana trainer the main backpack must be open and contain money. Stand beside the shop in reach of the npc when starting the script!\nIf you are using the housetrainer you need to stand in reach of the backpack to open, but not on top of it, since the vials will be dropped where you are standing.")
if TrainerPotion == "ultimate mana potion" then
HotkeyChannel:SendYellowMessage('Current trainer config','\nMana pots: '.. TrainerPotion ..' (Not supported, use another potion!)\nSpell prio 1 = '.. TrainerPrio1 ..'\nSpell prio 2 = '.. TrainerPrio2 ..'\nSpell prio 3 = '.. TrainerPrio3 ..'')
else
HotkeyChannel:SendYellowMessage('Current trainer config','\nTrainer type = '.. TrainerType ..'\nMana pots: '.. TrainerPotion ..'\nSpell prio 1 = '.. TrainerPrio1 ..'\nSpell prio 2 = '.. TrainerPrio2 ..'\nSpell prio 3 = '.. TrainerPrio3 ..'')
end
Module.Start('MessageReader')
wait(200)
elseif message == "display" then
HotkeyChannel:SendYellowMessage('Current settings','\nMana Healer: Mana potions = '.. mPots ..' / Below '.. BelowMana ..' mana.\nHealing prio 1: Spell = '.. StrongHealingSpell ..' / Percentage to heal = '.. HealthBelowStrong ..'\nHealing prio 2: Spell = '.. MediumHealingSpell ..' / Percentage to heal = '.. HealthBelowMedium ..'\nHealing prio 3: Spell = '.. LightHealingSpell ..' / Percentage to heal = '.. HealthBelowLight ..'\nHaster: Spell = '.. HasteSpell ..'\nManaShield: Method = '.. ManaShieldMethod ..'\nRuneShooter: Rune = '.. Rune ..'')
end
end
MR = Module.New('MessageReader', function(mod)
if shs == 1 and Latestmsg ~= msg then
StrongHealingSpell = Latestmsg
HotkeyChannel:SendYellowMessage('Config', ''.. Latestmsg ..' ' ..cMessage.. '')
wait(100)
shs = 0
shv = 1
msg = Latestmsg
ProcessDebugMessage('Prio 1', 'At which percentage do you want to heal?')
Module.Start('MessageReader1')
Module.Stop('MessageReader')
elseif mhs == 1 and Latestmsg ~= msg then
MediumHealingSpell = Latestmsg
HotkeyChannel:SendYellowMessage('Config', ''.. Latestmsg ..' ' ..cMessage.. '')
wait(100)
mhs = 0
mhv = 1
msg = Latestmsg
ProcessDebugMessage('Prio 2', 'At which percentage do you want to heal?')
Module.Start('MessageReader1')
Module.Stop('MessageReader')
elseif lhs == 1 and Latestmsg ~= msg then
LightHealingSpell = Latestmsg
HotkeyChannel:SendYellowMessage('Config', ''.. Latestmsg ..' ' ..cMessage.. '')
wait(100)
lhs = 0
lhv = 1
msg = Latestmsg
ProcessDebugMessage('Prio 3', 'At which percentage do you want to heal?')
Module.Start('MessageReader1')
Module.Stop('MessageReader')
elseif hs == 1 and Latestmsg ~= msg then
HasteSpell = Latestmsg
HotkeyChannel:SendYellowMessage('Config', ''.. Latestmsg ..' ' ..cMessage.. '')
wait(100)
hs = 0
Module.Stop('MessageReader')
elseif ms == 1 and Latestmsg ~= msg then
ManaShieldMethod = Latestmsg
HotkeyChannel:SendYellowMessage('ManaShield', ''.. Latestmsg ..' ' ..cMessage.. '')
wait(100)
ms = 0
Module.Stop('MessageReader')
elseif trainer == 1 and Latestmsg ~= msg then
if Latestmsg == "start" or "change" or "stop" then
if Latestmsg == "start" then
if TrainerPotion == "ultimate mana potion" then
msg = Latestmsg
HotkeyChannel:SendYellowMessage('Trainer', 'The script does not support this potion!')
trainer = 0
else
if not HouseTrainer then
ProcessDebugMessage('Trainer', 'Do you want to use Anti-push? If so write "yes" when you are in position, else write "no"')
AntiCheck = 0
trainer = 0
else
TrainerPot()
Module.Start('TrainerMod')
HotkeyChannel:SendYellowMessage('Trainer', 'Trainer started.')
if mHealer == 0 then
updateAF6 = "".. ManaHealerHUD .." Mana healer: Activated"
updateDF6 = ""
HudUpdateF6()
Module.Start('ManaHealer')
mHealer = 1
end
Module.Stop('MessageReader')
end
end
elseif Latestmsg == "stop" then
Module.Stop('TrainerMod')
Module.Stop('AntiPush')
HotkeyChannel:SendYellowMessage('Trainer', 'Trainer stopped.')
trainer = 0
Module.Stop('MessageReader')
elseif Latestmsg == "change" then
msg = Latestmsg
ProcessDebugMessage('Config', 'Do you want to change "potion", "spells" or "trainertype"?')
Module.Start('MessageReader1')
Module.Stop('MessageReader')
end
end
elseif rune == 1 and Latestmsg ~= msg then
Rune = Latestmsg
HotkeyChannel:SendYellowMessage('RuneShooter', ''.. Latestmsg ..' ' ..cMessage.. '')
wait(100)
rune = 0
Module.Stop('MessageReader')
elseif mana == 1 and Latestmsg ~= msg then
mPots = Latestmsg
wait(100)
msg = Latestmsg
mana = 0
mv = 1
ProcessDebugMessage('Mana Healer', 'At which amount of mana do you want to use a potion?')
Module.Start('MessageReader1')
Module.Stop('MessageReader')
elseif AntiCheck == 0 and Latestmsg == "yes" then
Module.Start('Check_Pos')
TrainerPot()
Module.Start('TrainerMod')
HotkeyChannel:SendYellowMessage('Trainer', 'Trainer started.')
Module.Stop('MessageReader')
AntiCheck = 1
if mHealer == 0 then
updateAF6 = "".. ManaHealerHUD .." Mana healer: Activated"
updateDF6 = ""
HudUpdateF6()
Module.Start('ManaHealer')
mHealer = 1
end
elseif AntiCheck == 0 and Latestmsg == "no" then
TrainerPot()
Module.Start('TrainerMod')
HotkeyChannel:SendYellowMessage('Trainer', 'Trainer started.')
Module.Stop('MessageReader')
AntiCheck = 1
if mHealer == 0 then
updateAF6 = "".. ManaHealerHUD .." Mana healer: Activated"
updateDF6 = ""
HudUpdateF6()
Module.Start('ManaHealer')
mHealer = 1
end
end
end, false)
MR1 = Module.New('MessageReader1', function(mod)
if shv == 1 and Latestmsg ~= msg then
HealthBelowStrong = Latestmsg
wait(200)
HotkeyChannel:SendYellowMessage('Config', 'You will now use '.. StrongHealingSpell ..' at ' .. HealthBelowStrong .. ' percent')
shv = 0
Module.Stop('MessageReader1')
elseif mhv == 1 and Latestmsg ~= msg then
HealthBelowMedium = Latestmsg
wait(200)
HotkeyChannel:SendYellowMessage('Config', 'You will now use '.. MediumHealingSpell ..' at ' .. HealthBelowMedium .. ' percent')
mhv = 0
Module.Stop('MessageReader1')
elseif lhv == 1 and Latestmsg ~= msg then
HealthBelowLight = Latestmsg
wait(200)
HotkeyChannel:SendYellowMessage('Config', 'You will now use '.. LightHealingSpell ..' at ' .. HealthBelowLight .. ' percent')
lhv = 0
Module.Stop('MessageReader1')
elseif mv == 1 and Latestmsg ~= msg then
BelowMana = Latestmsg
wait(200)
HotkeyChannel:SendYellowMessage('Config', 'You will now use '.. mPots ..' below ' .. BelowMana .. ' mana')
mv = 0
Module.Stop('MessageReader1')
elseif trainer == 1 and Latestmsg == "potion" then
msg = Latestmsg
ProcessDebugMessage('Config', 'Which potion do you want to use in the trainer aswell as mana healer?')
trainer = 2
elseif trainer == 2 and Latestmsg ~= msg then
TrainerPotion = Latestmsg
mPots = Latestmsg
TrainerPot()
HotkeyChannel:SendYellowMessage('Config', 'You will now use '.. TrainerPotion ..' in the trainer and mana healer.')
msg = Latestmsg
trainer = 0
Module.Stop('MessageReader1')
elseif trainer == 1 and Latestmsg == "spells" then
ProcessDebugMessage('Config', 'Which spell do you want to use as the first priority?')
msg = Latestmsg
trainer = 3
elseif trainer == 1 and Latestmsg == "trainertype" then
ProcessDebugMessage('Config', 'Do you want to use the "housetrainer" or the "shoptrainer"?')
msg = Latestmsg
trainer = 10
elseif trainer == 10 and Latestmsg == "shoptrainer" then
msg = Latestmsg
HouseTrainer = false
HotkeyChannel:SendYellowMessage('Config', 'The trainer is now set to train next to the potion npc.')
trainer = 0
Module.Stop('MessageReader1')
elseif trainer == 10 and Latestmsg == "housetrainer" then
msg = Latestmsg
HouseTrainer = true
ProcessDebugMessage('Config', 'Which backpack do you want to withdraw potions from?')
trainer = 11
elseif trainer == 11 and Latestmsg ~= msg then
msg = Latestmsg
fromBackpack = Latestmsg
HotkeyChannel:SendYellowMessage('Config', 'The trainer will now withdraw manas from '.. fromBackpack ..'.')
ProcessDebugMessage('Config', 'What is the name of your main backpack?')
trainer = 12
elseif trainer == 12 and Latestmsg ~= msg then
msg = Latestmsg
fromBackpack = Latestmsg
HotkeyChannel:SendYellowMessage('Config', 'The trainer will now withdraw manas to '.. toBackpack ..'.')
ProcessDebugMessage('Config', 'To start the script or change it further, write "trainer" again.')
trainer = 0
Module.Stop('MessageReader1')
elseif trainer == 3 and Latestmsg ~= msg then
TrainerPrio1 = Latestmsg
HotkeyChannel:SendYellowMessage('Config', 'You will now use '.. TrainerPrio1 ..' as prio 1 in the trainer')
ProcessDebugMessage('Config', 'Which spell do you want to use as the second priority?')
msg = Latestmsg
trainer = 4
elseif trainer == 4 and Latestmsg ~= msg then
TrainerPrio2 = Latestmsg
HotkeyChannel:SendYellowMessage('Config', 'You will now use '.. TrainerPrio2 ..' as prio 2 in the trainer')
ProcessDebugMessage('Config', 'Which spell do you want to use as the third priority?')
msg = Latestmsg
trainer = 5
elseif trainer == 5 and Latestmsg ~= msg then
TrainerPrio3 = Latestmsg
HotkeyChannel:SendYellowMessage('Config', 'You will now use '.. TrainerPrio3 ..' as prio 3 in the trainer')
HotkeyChannel:SendYellowMessage('Config','Write "trainer" and then "start" to start the trainer.')
trainer = 0
Module.Stop('MessageReader1')
end
end, false)
To be able to use the hotkeys you are not using in this script, you need to comment out the hotkeys in the newest xb.~.lua in C:\prgram files (x86)\xenobot\data like so:
Hotkeys = {}
--Hotkeys.F1 = 0x70
--Hotkeys.F2 = 0x71
--Hotkeys.F3 = 0x72
--Hotkeys.F4 = 0x73
--Hotkeys.F5 = 0x74
--Hotkeys.F6 = 0x75
--Hotkeys.F7 = 0x76
--Hotkeys.F8 = 0x77
--Hotkeys.F9 = 0x78
--Hotkeys.F10 = 0x79
--Hotkeys.F11 = 0x7A
--Hotkeys.F12 = 0x7B
--Hotkeys.PAGEUP = 0x21
--Hotkeys.PAGEDOWN = 0x22
--Hotkeys.INSERT = 0x2D
--Hotkeys.DELETE = 0x2E
--Hotkeys.END = 0x23
--Hotkeys.HOME = 0x24
Hotkeys.__registeredPressHandler = false
Hotkeys.__registeredReleaseHandler = false
Hotkeys.__pressHandlers = {}
Hotkeys.__releaseHandlers = {}
And restart the client.