PDA

View Full Version : Anoyn's Scripts



anoyn
12-06-2015, 06:49 AM
I'll be posting any lua scripts i make here



Scripts


Paladin/Mage Bow/X-Bow/Wand Spell Caster (http://forums.xenobot.net/showthread.php?39731-Anoyn-s-Scripts&p=461236&viewfull=1#post461236)


X-Log before Server Save (http://forums.xenobot.net/showthread.php?39731-Anoyn-s-Scripts&p=461358&viewfull=1#post461358)


Stealth/Energy Ring Equipper on X creatures (http://forums.xenobot.net/showthread.php?39731-Anoyn-s-Scripts&p=461360&viewfull=1#post461360)

anoyn
12-06-2015, 06:56 AM
Paladin/Mage Bow/X-Bow/Wand Spell Caster
This script replaces the built in magic shooter.
It casts spells after a Bow/Crossbow/wand hit to avoid exhaust.
It only works with bow, XBow and wands.
It does not support area spells.
It supports range limited spells.
It supports spells for specific creatures.



-- Paladin/Mage single target spell shooter
-- THIS ONLY WORKS WITH ARROWS, BOLTS and WANDS/RODS
--Version 2.1
--[[ Made by
___ .__ __. ______ ____ ____ .__ __.
/ \ | \ | | / __ \ \ \ / / | \ | |
/ ^ \ | \| | | | | | \ \/ / | \| |
/ /_\ \ | . ` | | | | | \_ _/ | . ` |
/ _____ \ | |\ | | `--' | | | | |\ |
/__/ \__\ |__| \__| \______/ |__| |__| \__|

]]


--------------------------------------------
--[[ ------------ CONFIG -------------- ]]--
--------------------------------------------
--if the spell does not have a range, dont give the spell a range
--if you want to use a spell on any creature, dont give the spell onCreatures
--attack can be either a spell or rune ID
--spells you want to cast first should be at the top
spells = {
--{ attack = "exori san", range = 4 },
{ attack = "exori flam", range = 3, onCreatures = { "Kongra", "Rat" } }, -- This will cast exori flam on a Kongra or Rat if they are within a range of 3
{ attack = 3155, range = 3, onCreatures = { "Sibang" } },
-- { attack = "exori gran con" },
-- { attack = "exori con" },
{ attack = "exori vis", range = 3 }
}

--How long do you want to wait between your arrow and casting spell? (If OT, set to 0)
delayToCastMin = 150 -- 150ms
delayToCastMax = 300 -- 300ms

--IF you are playing a wierd OT that messes with player HP, you can override what vocation you are here
overrideVocation = nil -- "Paladin", "Mage"

--------------------------------------------
--[[ ----- Script -- No need to edit ---- ]]
--------------------------------------------

function VocationDetection() --Aristeus
if overrideVocation ~= nil and (overrideVocation ~= "Knight" or overrideVocation ~= "Paladin" or overrideVocation ~= "Mage") then
print("Overiding Vocation to " .. overrideVocation)
Vocation = overrideVocation
else
local HealthLevel = (Self.MaxHealth() - 185) / (Self.Level() - 8)
if (HealthLevel == 15) then
Vocation = "Knight"
print('Vocation: Knight')
end
if (HealthLevel == 10) then
Vocation = "Paladin"
print('Vocation: Paladin')
end
if (HealthLevel == 5) then
Vocation = "Mage"
print('Vocation: Mage')
end
print("Vocation " .. Vocation .. " detected.")
end
end
VocationDetection()

lastAmmoCount = Self.Ammo().count
function checkIfCanCastSpell(targetID)
--Check if spell has limited range
for i = 1, #spells do
local castThisSpell = true
local creature = Creature.New(targetID)
if creature ~= nil then
if spells[i]['range'] ~= nil then
if not( Self.DistanceFromPosition(creature:Position().x, creature:Position().y, creature:Position().z) <= spells[i]['range'] ) then
castThisSpell = false
end
end
--Check current target
if castThisSpell and spells[i]['onCreatures'] ~= nil then
if not table.contains( spells[i]['onCreatures'], creature:Name() ) then
castThisSpell = false
end
end

if castThisSpell then
attack(spells[i]['attack'], targetID)
break
end
end
end
end

function attack(attackValue, targetID)
wait(delayToCastMin,delayToCastMax)
if tonumber(attackValue) then
Self.UseItemWithCreature(attackValue, targetID)
else
Self.Cast(attackValue)
end
end

if Vocation == "Paladin" then
Module.New('boltChecker', function(boltChecker)
ammo = Self.Ammo()
local targetID = Self.TargetID()
if ammo.count > lastAmmoCount then
lastAmmoCount = ammo.count
elseif targetID ~= 0 and ammo.id ~= 0 and ammo.count < lastAmmoCount then
lastAmmoCount = ammo.count
checkIfCanCastSpell(targetID)
end
end)
elseif Vocation == "Mage" then
BattleMessageProxy.OnReceive("BattleProxy", function(proxy, text)
if( string.find(text, " due to your")) then
local targetID = Self.TargetID()
if targetID ~= 0 then
checkIfCanCastSpell(targetID)
end
end
end)
else
print("Vocation " .. Vocation .. " not supported")
end

anoyn
12-06-2015, 11:43 PM
X-Log before Server Save
This script will close the client at a random period before the server save.
It will only X-log when no creatures are no screen.


-- Xlog at server save
--Version 1.0
--[[ Made by
___ .__ __. ______ ____ ____ .__ __.
/ \ | \ | | / __ \ \ \ / / | \ | |
/ ^ \ | \| | | | | | \ \/ / | \| |
/ /_\ \ | . ` | | | | | \_ _/ | . ` |
/ _____ \ | |\ | | `--' | | | | |\ |
/__/ \__\ |__| \__| \______/ |__| |__| \__|

]]
-----CONFIG------
--the hour before the server save (server save is at 3 AM for my computer)
local sshour = "02"

-- the script will logout sometime between the two times
local ssEarlyLogout = 10
local ssLateLogout = 40


-----SCRIPT------
local ssmin = tostring(math.random(ssEarlyLogout,ssLateLogout))

Module.New('xLogSS', function(xLogSS)
if ((os.date("%H") == sshour) and (os.date("%M") >= ssmin)) then
--Check to see if there are creatures on screen
PlayersOnScreen = Self.GetSpectators()
creatureOnScreen = false
for i = 1, #PlayersOnScreen do
if not PlayersOnScreen[i]:isPlayer() then
creatureOnScreen = true
break
end
end

--If there are no creatures on screen
if not creatureOnScreen then
os.exit()
end
end
xLogSS:Delay(10000)
end)

anoyn
12-07-2015, 12:06 AM
Stealth/Energy Ring Equipper on X creatures
This script will equip a stealth ring based on creatures on screen within a certain range.
Creatures can have varying danger levels
If the total danger is above the limit. The ring will be equipped.


-- Stealth Ring Equipper
--Version 1.0
--[[ Made by
___ .__ __. ______ ____ ____ .__ __.
/ \ | \ | | / __ \ \ \ / / | \ | |
/ ^ \ | \| | | | | | \ \/ / | \| |
/ /_\ \ | . ` | | | | | \_ _/ | . ` |
/ _____ \ | |\ | | `--' | | | | |\ |
/__/ \__\ |__| \__| \______/ |__| |__| \__|

]]
--------------------------------------------
--[[ ------------ CONFIG -------------- ]]--
--------------------------------------------
local distanceToCheckCreatures = 2 -- Check creatures within this range
local dangerToEquip = 3 -- if danger is higher than this number, equip ring

local monsterList = {
{ name = "Cyclops Smith", danger = 3 },
{ name = "Cyclops Drone", danger = 2 },
{ name = "Cyclops", danger = 1 }
}

-- 3049, 3086 = stealth ring/steath ring equipped
local RingID = 3049 -- ID of ring in backpack to equip
local RingIDWhenEquipped = 3086 -- The ID when ring is equipped

--How often should creature checks be made in milliseconds
local minCreatureCheckDelay = 400
local maxCreatureCheckDelay = 1200

--------------------------------------------
--[[ ----- Script -- No need to edit ---- ]]
--------------------------------------------
function getDangerLevel( dist )
local currentDanger = 0
local targets = Self.GetTargets( dist )
for i = 1, #targets do
local targetName = targets[i]:Name()

for i = 1, #monsterList do
if monsterList[i]['name'] == targetName then
currentDanger = currentDanger + monsterList[i]['danger']
end
end
end
return currentDanger
end

function stealthring()
local dangerAmount = getDangerLevel( distanceToCheckCreatures )
--print("Danger level = " .. dangerAmount )
if dangerAmount >= dangerToEquip and Self.Ring().id ~= RingIDWhenEquipped and Self.ItemCount(RingID) >= 1 then
Self.Equip(RingID, "ring")
elseif dangerAmount < dangerToEquip and Self.Ring().id == RingIDWhenEquipped then
Self.Dequip("ring")
end
end

Module('stealth', function(stealth)
stealthring()
stealth:Delay(minCreatureCheckDelay,maxCreatureChe ckDelay)
end)

anoyn
12-07-2015, 12:22 AM
Spell Caster while Manually Playing
This script will cast spells in order when you are attacking a creature.
To be used if you are too lazy to cast spells yourself while manually playing.
Can be enabled and disabled with a hotkey. (Default end)


-- Automatic spell caster for manual targeting
-- Version 1.0
--[[ Made by
___ .__ __. ______ ____ ____ .__ __.
/ \ | \ | | / __ \ \ \ / / | \ | |
/ ^ \ | \| | | | | | \ \/ / | \| |
/ /_\ \ | . ` | | | | | \_ _/ | . ` |
/ _____ \ | |\ | | `--' | | | | |\ |
/__/ \__\ |__| \__| \______/ |__| |__| \__|

]]
--------------------------------------------
--[[ ------------ CONFIG -------------- ]]--
--------------------------------------------
--Spells to cast in order from strongest to weakest
strikeSpells = {
"exori max frigo",
"exori gran frigo",
"exori frigo"
}

--Square range you can shoot your spells
castRange = 3

--will only cast if mana percent is this or above
manaPercentToCast = 10

--Whether you want automatic casts to be on when you start the script
castingSpells = true

enableHotkey = 35 -- 35 = END, 36 = HOME

--------------------------------------------
--[[ ----- Script -- No need to edit ---- ]]
--------------------------------------------
Module.New('saySpell', function(saySpell)
if( castingSpells ) then
local curTargetID = Self.TargetID()
if( curTargetID ~= 0 ) then
local enemyPos = Creature.New(curTargetID):Position()
local manaPercent = math.floor(( Self.Mana() * 100 ) / Self.MaxMana())
if( Self.DistanceFromPosition(enemyPos.x, enemyPos.y, enemyPos.z) <= castRange and
Self.Position().z == enemyPos.z and manaPercent >= manaPercentToCast ) then
for spellIndex = 1, #strikeSpells do
if( Self.CanCastSpell(strikeSpells[spellIndex] ) ) then
Self.Cast(strikeSpells[spellIndex] )
break
end
end
end
end
end
end)

if not Hotkeys.Register(enableHotkey) then
print("Could not enable hotkey, check that enableHotkey (" .. enableHotkey .. ") is valid.")
end

function pressHandler(key, control, shift)
if( castingSpells ) then
print("Pausing Spell Caster")
castingSpells = false
else
print("Starting Spell Caster")
castingSpells = true
end
end
Hotkeys.AddPressHandler(pressHandler)

garre93
12-07-2015, 01:06 AM
Paladin Bow/X-Bow Spell Caster
This script replaces the built in magic shooter.
It casts spells after a Bow/Crossbow hit to avoid exhaust.
It only works with bow and XBow.
It does not support area spells.
It supports range limited spells.


-- Paladin single target spell shooter
-- THIS ONLY WORKS WITH ARROWS AND BOLTS
--Version 1.0
--[[ Made by
___ .__ __. ______ ____ ____ .__ __.
/ \ | \ | | / __ \ \ \ / / | \ | |
/ ^ \ | \| | | | | | \ \/ / | \| |
/ /_\ \ | . ` | | | | | \_ _/ | . ` |
/ _____ \ | |\ | | `--' | | | | |\ |
/__/ \__\ |__| \__| \______/ |__| |__| \__|

]]

--------------------------------------------
--[[ ------------ CONFIG -------------- ]]--
--------------------------------------------
--if the spell does not have a range, dont give the spell a range
--spells you want to cast first should be at the top
spells = {
--{ words = "exori san", range = 4 },
{ words = "exori gran con" },
{ words = "exori con" }
}

--How long do you want to wait between your arrow and casting spell? (If OT, set to 0)
delayToCastMin = 30 -- 30ms
delayToCastMax = 300 -- 300ms


--------------------------------------------
--[[ ----- Script -- No need to edit ---- ]]
--------------------------------------------
lastAmmoCount = Self.Ammo().count
function checkIfCanCastSpell(targetID)
--Check if spell has limited range
for i = 1, #spells do
if spells[i]['range'] ~= nil then
local creature = Creature.New(targetID)
if( creature ~= nil and Self.DistanceFromPosition(creature:Position().x, creature:Position().y, creature:Position().z) <= spells[i]['range'] ) then
if Self.CanCastSpell(spells[i]['words']) then
castSpell(spells[i]['words'])
break
end
end
else
if Self.CanCastSpell(spells[i].words) then
castSpell(spells[i]['words'])
break
end
end
end
end

function castSpell(words)
lastAmmoCount = ammo.count
wait(delayToCastMin,delayToCastMax)
Self.Cast(words)
end

Module.New('boltChecker', function(boltChecker)
ammo = Self.Ammo()
local targetID = Self.TargetID()
if targetID ~= 0 and ammo.id ~= 0 and ammo.count < lastAmmoCount then
checkIfCanCastSpell(targetID)
end
end)


SERIOUSLY! THIS IS THE BEST THING THAT COULD HAVE HAPPEN! It works like a charm, really you are a lifesaver, BIG CREDS to you! Would have payed for this to happen lol.

Update: Ive tried it now and it worked flawlessly for some time, then it just stopped working at all and i had to reload the script to make it work again (no error message) It could be at the time my bot autorefill to 100 arrows from 25-35 but not sure
Update 2: Yes it is when the bot reloads the arrows confirmed

anoyn
12-07-2015, 01:42 AM
SERIOUSLY! THIS IS THE BEST THING THAT COULD HAVE HAPPEN! It works like a charm, really you are a lifesaver, BIG CREDS to you! Would have payed for this to happen lol.

Update: Ive tried it now and it worked flawlessly for some time, then it just stopped working at all and i had to reload the script to make it work again (no error message) It could be at the time my bot autorefill to 100 arrows from 25-35 but not sure
Update 2: Yes it is when the bot reloads the arrows confirmed

Glad to hear you like it!

Issue should be fixed with version 1.1.

garre93
12-07-2015, 02:21 AM
Glad to hear you like it!

Issue should be fixed with version 1.1.

Cool! Really looked forward to something like this, and great it getting fixed also, then its perfect!

Update: Yes its perfect ;) thanks!!

Kociii
12-07-2015, 02:35 AM
Paladin Bow/X-Bow Spell Caster
This script replaces the built in magic shooter.
It casts spells after a Bow/Crossbow hit to avoid exhaust.
It only works with bow and XBow.
It does not support area spells.
It supports range limited spells.


-- Paladin single target spell shooter
-- THIS ONLY WORKS WITH ARROWS AND BOLTS
--Version 1.1
--[[ Made by
___ .__ __. ______ ____ ____ .__ __.
/ \ | \ | | / __ \ \ \ / / | \ | |
/ ^ \ | \| | | | | | \ \/ / | \| |
/ /_\ \ | . ` | | | | | \_ _/ | . ` |
/ _____ \ | |\ | | `--' | | | | |\ |
/__/ \__\ |__| \__| \______/ |__| |__| \__|

]]

--------------------------------------------
--[[ ------------ CONFIG -------------- ]]--
--------------------------------------------
--if the spell does not have a range, dont give the spell a range
--spells you want to cast first should be at the top
spells = {
--{ words = "exori san", range = 4 },
{ words = "exori gran con" },
{ words = "exori con" }
}

--How long do you want to wait between your arrow and casting spell? (If OT, set to 0)
delayToCastMin = 30 -- 30ms
delayToCastMax = 300 -- 300ms


--------------------------------------------
--[[ ----- Script -- No need to edit ---- ]]
--------------------------------------------
lastAmmoCount = Self.Ammo().count
function checkIfCanCastSpell(targetID)
--Check if spell has limited range
for i = 1, #spells do
if spells[i]['range'] ~= nil then
local creature = Creature.New(targetID)
if( creature ~= nil and Self.DistanceFromPosition(creature:Position().x, creature:Position().y, creature:Position().z) <= spells[i]['range'] ) then
if Self.CanCastSpell(spells[i]['words']) then
castSpell(spells[i]['words'])
break
end
end
else
if Self.CanCastSpell(spells[i].words) then
castSpell(spells[i]['words'])
break
end
end
end
end

function castSpell(words)
lastAmmoCount = ammo.count
wait(delayToCastMin,delayToCastMax)
Self.Cast(words)
end

Module.New('boltChecker', function(boltChecker)
ammo = Self.Ammo()
local targetID = Self.TargetID()
if ammo.count > lastAmmoCount then
lastAmmoCount = ammo.count
elseif targetID ~= 0 and ammo.id ~= 0 and ammo.count < lastAmmoCount then
checkIfCanCastSpell(targetID)
end
end)


Nice work. I will give it a go later. Just checking, will you be adding area attacker and such later on? But this script isen't working with Exori Hur and that right?

anoyn
12-07-2015, 05:25 AM
Nice work. I will give it a go later. Just checking, will you be adding area attacker and such later on? But this script isen't working with Exori Hur and that right?

I may add an area spell shooter later, but its not a high priority right now.


The script works by casting when you use a arrow/bolt. For spears and knights it does not work since you cant count if you lost your weapon.

You could have it cast after a battle proxy message, but then it wouldnt cast if you missed the creature, so therefore on paladin/knight but perfect for mages.

I'm not sure if there is enough interest for a mage version which uses a battle proxy message to time wands and spells together.

garre93
12-07-2015, 05:35 AM
I may add an area spell shooter later, but its not a high priority right now.


The script works by casting when you use a arrow/bolt. For spears and knights it does not work since you cant count if you lost your weapon.

You could have it cast after a battle proxy message, but then it wouldnt cast if you missed the creature, so therefore on paladin/knight but perfect for mages.

I'm not sure if there is enough interest for a mage version which uses a battle proxy message to time wands and spells together.

I would use it :)

shadowart
12-07-2015, 09:08 PM
That Paladin shooter is really sweet. Too bad you don't get a battle message from missing with a throwing weapon.

anoyn
12-08-2015, 03:03 AM
That Paladin shooter is really sweet. Too bad you don't get a battle message from missing with a throwing weapon.

༼ つ ◕_◕ ༽つ Give sprite effect proxy ༼ つ ◕_◕ ༽つ

HjugO
12-08-2015, 10:04 AM
༼ つ ◕_◕ ༽つ Give sprite effect proxy ༼ つ ◕_◕ ༽つ
You can get around this. (。◕‿‿◕。)

Bollo
12-08-2015, 11:59 AM
Paladin Bow/X-Bow Spell Caster
This script replaces the built in magic shooter.
It casts spells after a Bow/Crossbow hit to avoid exhaust.
It only works with bow and XBow.
It does not support area spells.
It supports range limited spells.


-- Paladin single target spell shooter
-- THIS ONLY WORKS WITH ARROWS AND BOLTS
--Version 1.1
--[[ Made by
___ .__ __. ______ ____ ____ .__ __.
/ \ | \ | | / __ \ \ \ / / | \ | |
/ ^ \ | \| | | | | | \ \/ / | \| |
/ /_\ \ | . ` | | | | | \_ _/ | . ` |
/ _____ \ | |\ | | `--' | | | | |\ |
/__/ \__\ |__| \__| \______/ |__| |__| \__|

]]

--------------------------------------------
--[[ ------------ CONFIG -------------- ]]--
--------------------------------------------
--if the spell does not have a range, dont give the spell a range
--spells you want to cast first should be at the top
spells = {
--{ words = "exori san", range = 4 },
{ words = "exori gran con" },
{ words = "exori con" }
}

--How long do you want to wait between your arrow and casting spell? (If OT, set to 0)
delayToCastMin = 30 -- 30ms
delayToCastMax = 300 -- 300ms


--------------------------------------------
--[[ ----- Script -- No need to edit ---- ]]
--------------------------------------------
lastAmmoCount = Self.Ammo().count
function checkIfCanCastSpell(targetID)
--Check if spell has limited range
for i = 1, #spells do
if spells[i]['range'] ~= nil then
local creature = Creature.New(targetID)
if( creature ~= nil and Self.DistanceFromPosition(creature:Position().x, creature:Position().y, creature:Position().z) <= spells[i]['range'] ) then
if Self.CanCastSpell(spells[i]['words']) then
castSpell(spells[i]['words'])
break
end
end
else
if Self.CanCastSpell(spells[i].words) then
castSpell(spells[i]['words'])
break
end
end
end
end

function castSpell(words)
lastAmmoCount = ammo.count
wait(delayToCastMin,delayToCastMax)
Self.Cast(words)
end

Module.New('boltChecker', function(boltChecker)
ammo = Self.Ammo()
local targetID = Self.TargetID()
if ammo.count > lastAmmoCount then
lastAmmoCount = ammo.count
elseif targetID ~= 0 and ammo.id ~= 0 and ammo.count < lastAmmoCount then
checkIfCanCastSpell(targetID)
end
end)


Cheers man, will check this out, looks promising!

Great work, keep it up! =)

Bollo
12-13-2015, 01:08 PM
I may add an area spell shooter later, but its not a high priority right now.


The script works by casting when you use a arrow/bolt. For spears and knights it does not work since you cant count if you lost your weapon.

You could have it cast after a battle proxy message, but then it wouldnt cast if you missed the creature, so therefore on paladin/knight but perfect for mages.

I'm not sure if there is enough interest for a mage version which uses a battle proxy message to time wands and spells together.

Would be highly apreciated man if you could add mas san aswell! Also, if there would be a possibility to add that it shoots the spells on specific creatures.
Like for example if you want to shoot only exori san on some and exori con on others if they are immune or so on.

zajcu
12-30-2015, 01:04 AM
I would like to see mage version with runes and wave spells ;)

anoyn
12-30-2015, 04:15 AM
Updated Paladin/Mage Bow/X-Bow/Wand Spell Caster (v2.0)

Now supports

Mages using wand
Spells for specific creatures
Attacking with runes

Tirell
01-02-2016, 12:44 AM
Can u make script for unrust items?:>

Hik
01-21-2016, 06:13 PM
hi bro
please i wanna simple function
i wanna function that use pick on (x,y,z) till it get 3 corlas (boxes) then leave i will make wp and use this boxes on (x,y,z) thx
if u wanna see the vido for function here
http://www.youtube.com/watch?v=EOar1W7O9mk

dean015
02-14-2016, 04:16 AM
anoyn

really nice script but since i started using it occasionally tibia client stops responding and ends up crashing, sometimes even when no creeps on screen

iv never had tibia client crash befor but its happend twice using this script
anyone else having this problem?
thanks

billdahlberg
02-14-2016, 10:41 PM
Im kinda new at this, sorry. But where do i put in the file to make it run?

dean015
02-15-2016, 12:08 AM
Im kinda new at this, sorry. But where do i put in the file to make it run?

xenobot/scripts

anoyn
02-15-2016, 01:09 AM
anoyn

really nice script but since i started using it occasionally tibia client stops responding and ends up crashing, sometimes even when no creeps on screen

iv never had tibia client crash befor but its happend twice using this script
anyone else having this problem?
thanks

I've never had a script crash tibia, I've only crashed when changing screen resolution or running 20mcs at 100% cpu usage.

dean015
02-15-2016, 01:13 AM
I've never had a script crash tibia, I've only crashed when changing screen resolution or running 20mcs at 100% cpu usage.

maybe its just my shitty laptop is it even possible for a script to crash the tibia client? since when it crashes xenobot is still running fine

thanks for the reply

anoyn
02-15-2016, 01:22 AM
maybe its just my shitty laptop is it even possible for a script to crash the tibia client? since when it crashes xenobot is still running fine

thanks for the reply

I'm not sure, if its a big problem make a thread about it. I haven't had the issue myself

neinrar
02-22-2016, 04:02 PM
Im getting error stuck :/

anoyn
02-22-2016, 06:54 PM
Im getting error stuck :/

What script and what does the error say?

l4z
02-27-2016, 05:53 PM
Is this script fixing anything on new xenobot?
Gona test it.

edit:
Imo definitly recomended to use but..
What about this "cloud" "you are exhasted" isn't it bannable after longer time of botting?

Gluben
03-25-2016, 06:30 AM
Spell Caster while Manually Playing
This script will cast spells in order when you are attacking a creature.
To be used if you are too lazy to cast spells yourself while manually playing.
Can be enabled and disabled with a hotkey. (Default end)


-- Automatic spell caster for manual targeting
-- Version 1.0
--[[ Made by
___ .__ __. ______ ____ ____ .__ __.
/ \ | \ | | / __ \ \ \ / / | \ | |
/ ^ \ | \| | | | | | \ \/ / | \| |
/ /_\ \ | . ` | | | | | \_ _/ | . ` |
/ _____ \ | |\ | | `--' | | | | |\ |
/__/ \__\ |__| \__| \______/ |__| |__| \__|

]]
--------------------------------------------
--[[ ------------ CONFIG -------------- ]]--
--------------------------------------------
--Spells to cast in order from strongest to weakest
strikeSpells = {
"exori max frigo",
"exori gran frigo",
"exori frigo"
}

--Square range you can shoot your spells
castRange = 3

--will only cast if mana percent is this or above
manaPercentToCast = 10

--Whether you want automatic casts to be on when you start the script
castingSpells = true

enableHotkey = 35 -- 35 = END, 36 = HOME

--------------------------------------------
--[[ ----- Script -- No need to edit ---- ]]
--------------------------------------------
Module.New('saySpell', function(saySpell)
if( castingSpells ) then
local curTargetID = Self.TargetID()
if( curTargetID ~= 0 ) then
local enemyPos = Creature.New(curTargetID):Position()
local manaPercent = math.floor(( Self.Mana() * 100 ) / Self.MaxMana())
if( Self.DistanceFromPosition(enemyPos.x, enemyPos.y, enemyPos.z) <= castRange and
Self.Position().z == enemyPos.z and manaPercent >= manaPercentToCast ) then
for spellIndex = 1, #strikeSpells do
if( Self.CanCastSpell(strikeSpells[spellIndex] ) ) then
Self.Cast(strikeSpells[spellIndex] )
break
end
end
end
end
end
end)

if not Hotkeys.Register(enableHotkey) then
print("Could not enable hotkey, check that enableHotkey (" .. enableHotkey .. ") is valid.")
end

function pressHandler(key, control, shift)
if( castingSpells ) then
print("Pausing Spell Caster")
castingSpells = false
else
print("Starting Spell Caster")
castingSpells = true
end
end
Hotkeys.AddPressHandler(pressHandler)


Just give s me an error when trying to use this script?

07:30 XenoScript Error:
Script: spells.lua
Line #: 55
Error: attempt to index global 'Hotkeys' (a nil value)
This is an error with user-input and should not be reported as a bug with XenoBot.

anoyn
03-25-2016, 03:37 PM
Just give s me an error when trying to use this script?

07:30 XenoScript Error:
Script: spells.lua
Line #: 55
Error: attempt to index global 'Hotkeys' (a nil value)
This is an error with user-input and should not be reported as a bug with XenoBot.

Hotkeys only work with newer tibia client versions. I don't remember the version they were added with.

Just remove all lines below and including "if not Hotkeys.Register(enableHotkey) then".
That will remove hotkeys

ganth1
06-11-2016, 09:59 AM
nvm...