Automatically add best (strong) strike spells to cavebot targeter
I wrote a script that can automatically add strike spells to a targetlist.
I hate it when I have an extensive creaturelist and have to add all the strike spells manually, thought I would share.
-- Add best strike spells for each creature in targetlist
local elementToSpell = {{'fire', 'Flame'}, {'energy', 'Energy'}, {'earth', 'Earth'}, {'ice', 'Ice'},}
local useStrongStrike = false
local bestStrike = nil
-- If you use strong spells: Damage difference in percent between strike and strong spell to not use
-- e.g. If creature is weak to energy (110%) and you're a druid (no energy)
-- And the strong spell you can cast would be earth damage, creature has (85%)
-- Then for any value higher than 25 it will not use the strong spell
local damagePercentDiff = 20
foreach settingsentry e 'Targeting/Creatures' do
setsetting(e, 'Setting1/FirstSpell', "No Spell")
setsetting(e, 'Setting1/SecondSpell', "No Spell")
local creatureInfo = creatureinfo(getsetting(e, 'Name'))
if creatureInfo.hp > 0 then
bestStrike = getbestspell(creatureInfo.name).name
if useStrongStrike then
local bestStrongElement = bestelement(creatureInfo.name, true)
local bestElement = bestelement(creatureInfo.name, false)
for _,i in pairs(elementToSpell) do
if i[1] == bestStrongElement then
if creatureInfo[bestElement..'mod']-damagePercentDiff <= creatureInfo[bestStrongElement..'mod'] then
setsetting(e, 'Setting1/FirstSpell', "Strong " .. i[2] .. " Strike")
end
end
end
if getsetting(e, 'Setting1/FirstSpell') ~= "No Spell" then
setsetting(e, 'Setting1/SecondSpell', bestStrike)
else
setsetting(e, 'Setting1/FirstSpell', bestStrike)
end
else
setsetting(e, 'Setting1/FirstSpell', bestStrike)
end
end
end
This keeps into account when names such as Category A or Others are used in the targetlist, it will just set the spells to "No Spell".
I made a parameter that looks for damage difference between strong/weak strike spells, I will probably update the math behind that one soon, this is really basic at the moment, didn't feel like write an extensive code.
01-08-2015, 11:36 AM
Borges
@Heronas Thanks for share, just need add other elements like death, holy, physical
btw good job.
01-08-2015, 04:19 PM
albino
Sometimes I hunt using bot to heal, but attacking manually, and it's bad to press 10000 strike hotkeys. So I edited your script and I'm using it as a hotkey when "Delete" is pressed.
If someone wants to give it a try:
local elementToSpell = {
{'fire', 'Flame', 'flam'},
{'energy', 'Energy', 'vis'},
{'earth', 'Earth', 'tera'},
{'ice', 'Ice', 'frigo'},
-- {'physical', 'Physical', 'moe ico'}, --not used
-- {'death', 'Death', 'mort'}, --not used
}
local useStrongStrike = false
local bestStrike = nil
local creatureInfo = creatureinfo($attacked.name)
-- If you use strong spells: Damage difference in percent between strike and strong spell to not use
-- e.g. If creature is weak to energy (110%) and you're a druid (no energy)
-- And the strong spell you can cast would be earth damage, creature has (85%)
-- Then for any value higher than 25 it will not use the strong spell
local damagePercentDiff = 20
if creatureInfo.hp > 0 then
bestStrike = getbestspell(creatureInfo.name).name
if useStrongStrike then
local bestStrongElement = bestelement(creatureInfo.name, true)
local bestElement = bestelement(creatureInfo.name, false)
for _,i in pairs(elementToSpell) do
if i[1] == bestStrongElement then
if creatureInfo[bestElement..'mod']-damagePercentDiff <= creatureInfo[bestStrongElement..'mod'] then
cast('exori gran ' .. i[3])
end
end
end
else
if bestStrike == "Flame Strike" and cancastspell('exori flam', $attacked) then
cast('exori flam')
elseif bestStrike == "Energy Strike" and cancastspell('exori vis', $attacked) then
cast('exori vis')
elseif bestStrike == "Terra Strike" and cancastspell('exori tera', $attacked) then
cast('exori tera')
elseif bestStrike == "Ice Strike" and cancastspell('exori frigo', $attacked) then
cast('exori frigo')
elseif bestStrike == "Physical Strike" and cancastspell('exori moe ico', $attacked) then
cast('exori moe ico')
elseif bestStrike == "Death Strike" and cancastspell('exori mort', $attacked) then
cast('exori mort')
end
end
end
01-08-2015, 06:14 PM
Heronas
@albino
I highly recommend not using that, simply because this function is way too complicated for what you want.
This does almost the same thing, except that the strong strike determination is a little different (I don't like it).
init start
local useStrongStrikes = true
local exhaustTime = 0
local strongExhaustTime = 0
init end
auto(100, 200)
if $attacked.id ~= 0 then
local creatureName = $attacked.name
if $attacked.isshootable then
if useStrongStrikes and $timems >= strongExhaustTime then
caststrongstrike(0) strongExhaustTime = $timems+6000
elseif $timems >= exhaustTime then
caststrike(0) exhaustTime = $timems+1000
end
end
end
Or if you want to go fancy and use synchronised spells (works as fast as targeter).
init start
local useStrongStrikes = true
local strongExhaustTime = 0
init end
auto(100, 200)
foreach newprojectile p do
wait(25, 75)
if (p.fromx-$posx <= 1 and p.fromy-$posy <= 1) and $attacked.id ~=0 then
if $timems >= strongExhaustTime and useStrongStrikes then
caststrongstrike(0) strongExhaustTime = $timems+6000
else
caststrike(0)
end
end
end
01-08-2015, 06:19 PM
Heronas
Quote:
Originally Posted by borges
@Heronas Thanks for share, just need add other elements like death, holy, physical
btw good job.
I am using Lucas Terra's library for this, if I want to add holy spells I would have to rewrite that library code just like I did with a wand swapper I made, that makes noone happy.
And as for the death and physical strikes, it already uses them, the
elementToSpell
variable is only used for the strong strike determination.
Probably should make my variables a bit more trivial next time.
01-08-2015, 11:15 PM
albino
Quote:
Originally Posted by Heronas
@albino
I highly recommend not using that, simply because this function is way too complicated for what you want.
This does almost the same thing, except that the strong strike determination is a little different (I don't like it).
init start
local useStrongStrikes = true
local exhaustTime = 0
local strongExhaustTime = 0
init end
auto(100, 200)
if $attacked.id ~= 0 then
local creatureName = $attacked.name
if $attacked.isshootable then
if useStrongStrikes and $timems >= strongExhaustTime then
caststrongstrike(0) strongExhaustTime = $timems+6000
elseif $timems >= exhaustTime then
caststrike(0) exhaustTime = $timems+1000
end
end
end
Or if you want to go fancy and use synchronised spells (works as fast as targeter).
init start
local useStrongStrikes = true
local strongExhaustTime = 0
init end
auto(100, 200)
foreach newprojectile p do
wait(25, 75)
if (p.fromx-$posx <= 1 and p.fromy-$posy <= 1) and $attacked.id ~=0 then
if $timems >= strongExhaustTime and useStrongStrikes then
caststrongstrike(0) strongExhaustTime = $timems+6000
else
caststrike(0)
end
end
end
:eek: didn't know about that caststrike()
makes it a lot easier :) thank you