I'll be posting any lua scripts i make here
I'll be posting any lua scripts i make here
Last edited by anoyn; 02-15-2016 at 01:18 AM.
Paladin/Mage Bow/X-Bow/Wand Spell CasterThis 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.
lua code:
-- 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
Last edited by anoyn; 01-23-2016 at 05:48 PM.
X-Log before Server SaveThis script will close the client at a random period before the server save.
It will only X-log when no creatures are no screen.
lua code:
-- 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)
Stealth/Energy Ring Equipper on X creaturesThis 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.
lua code:
-- 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,maxCreatureCheckDelay)
end)
Last edited by anoyn; 01-22-2016 at 04:25 AM.
Spell Caster while Manually PlayingThis 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)
lua code:
-- 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)
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
Last edited by garre93; 12-07-2015 at 01: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.