Log in

View Full Version : Help with custom spellcaster



Gluben
03-25-2016, 09:23 AM
If I want a spellcaster to when I have ANY TARGET not just for a specific monster, how do I change this lua script?

local config = {
['Yeti'] = {strikes = {"Kura Flur", "Kura Min Flur"}, hppc = {1, 1}, dist = 1}
}

while (true) do
local targ = Creature.GetByID(Self.TargetID())
for name, var in pairs(config) do
if targ:Name() == name and targ:isAlive() and targ:DistanceFromSelf() <= var.dist then
for i=1, #var.strikes do
if (Self.CanCastSpell(var.strikes[i]) and targ:HealthPercent() >= var.hppc[1]) then
Self.Say(var.strikes[i])
elseif (targ:HealthPercent() >= var.hppc[2] and targ:HealthPercent() <= var.hppc[1] and Self.CanCastSpell(var.strikes[#var.strikes])) then
Self.Say(var.strikes[#var.strikes])
end
end
end
end
sleep(math.random(400,650))
end

Gluben
03-25-2016, 09:23 AM
I have also tried Anoyn's Spellcaster and it didnt work, just gave me errors. I have asked for help in his thread but getting this one to work would be very much appreciated!

Gluben
03-26-2016, 08:22 AM
Maybe anoyn you could help me with this? :) would appreciate it alot!

Jontor
03-26-2016, 11:51 AM
Try this:


-- name, distance format
local spells = {
["Kura Flur"] = 1,
["Kura Min Flur"] = 1
}

Module.New("", function()
local targetID = getSelfTargetID()

if (targetID <= 0) then
return
end

for spell, dist in pairs(spells) do
if (Creature.DistanceFromSelf(targetID) <= dist) then
if (Self.GetSpellCooldown(spell) == 0) then
Self.Say(spell)
end
end
end
end)

Gluben
03-26-2016, 12:06 PM
Try this:


-- name, distance format
local spells = {
["Kura Flur"] = 1,
["Kura Min Flur"] = 1
}

Module.New("", function()
local targetID = getSelfTargetID()

if (targetID <= 0) then
return
end

for spell, dist in pairs(spells) do
if (Creature.DistanceFromSelf(targetID) <= dist) then
if (Self.GetSpellCooldown(spell) == 0) then
Self.Say(spell)
end
end
end
end)

Works like a charm, thanks alot! :D
Doesn't look like it prioritizes the spells at the top though?

Jontor
03-26-2016, 12:12 PM
Works like a charm, thanks alot! :D
Doesn't look like it prioritizes the spells at the top though?

This is because pairs() are in random order, would need a small change:



local spells = {
{spell = "Kura Flur", dist = 1},
{spell = "Kura Min Flur", dist = 1}
}

Module.New("", function()
local targetID = getSelfTargetID()

if (targetID <= 0) then
return
end

for i = 1, #spells do
if (Creature.DistanceFromSelf(targetID) <= spells[i].dist) then
if (Self.GetSpellCooldown(spells[i].spell) == 0) then
Self.Say(spells[i].spell)
end
end
end
end)

Gluben
03-26-2016, 01:20 PM
This is because pairs() are in random order, would need a small change:



local spells = {
{spell = "Kura Flur", dist = 1},
{spell = "Kura Min Flur", dist = 1}
}

Module.New("", function()
local targetID = getSelfTargetID()

if (targetID <= 0) then
return
end

for i = 1, #spells do
if (Creature.DistanceFromSelf(targetID) <= spells[i].dist) then
if (Self.GetSpellCooldown(spells[i].spell) == 0) then
Self.Say(spells[i].spell)
end
end
end
end)

Thank you very much! :)

Gluben
03-26-2016, 10:17 PM
This is because pairs() are in random order, would need a small change:



local spells = {
{spell = "Kura Flur", dist = 1},
{spell = "Kura Min Flur", dist = 1}
}

Module.New("", function()
local targetID = getSelfTargetID()

if (targetID <= 0) then
return
end

for i = 1, #spells do
if (Creature.DistanceFromSelf(targetID) <= spells[i].dist) then
if (Self.GetSpellCooldown(spells[i].spell) == 0) then
Self.Say(spells[i].spell)
end
end
end
end)


This one works, but it spams so hard that the bot actually doesn't heal anymore. Is this solvable anyway? I mean its not even on same CD or anything :P I just cant heal

Sheradial
03-26-2016, 11:46 PM
This one works, but it spams so hard that the bot actually doesn't heal anymore. Is this solvable anyway? I mean its not even on same CD or anything :P I just cant heal

Healing spells and attack spells dont share the same cooldown.

Gluben
03-27-2016, 12:22 AM
Healing spells and attack spells dont share the same cooldown.

That's exactly what I wrote, still the bot does no longer cast my 'exura san' when this script is running.

Jontor
03-27-2016, 09:06 AM
That's exactly what I wrote, still the bot does no longer cast my 'exura san' when this script is running.

You can try running 2 different luas, can you tell me something more you'd need in this script?

Gluben
03-27-2016, 05:13 PM
You can try running 2 different luas, can you tell me something more you'd need in this script?

Some sort of delay or wait like in the first script(the one in my first post). Is that possible?

Jontor
03-27-2016, 05:36 PM
Some sort of delay or wait like in the first script(the one in my first post). Is that possible?

More important healing first, hp is in % and you can actually run it in the same lua as that spells shooter


local hSpells = {
{spell = "exura vita", hp = 50},
{spell = "exura gran", hp = 70}
}

Module.New("", function()
local percentHp = (getSelfHealth() / getSelfMaxHealth()) * 100

for i = 1, #hSpells do
if (percentHp <= hSpells[i].hp) then
if (Self.GetSpellCooldown(hSpells[i].spell) == 0) then
Self.Say(hSpells[i].spell)
end
end
end
end)

Gluben
03-27-2016, 09:00 PM
More important healing first, hp is in % and you can actually run it in the same lua as that spells shooter


local hSpells = {
{spell = "exura vita", hp = 50},
{spell = "exura gran", hp = 70}
}

Module.New("", function()
local percentHp = (getSelfHealth() / getSelfMaxHealth()) * 100

for i = 1, #hSpells do
if (percentHp <= hSpells[i].hp) then
if (Self.GetSpellCooldown(hSpells[i].spell) == 0) then
Self.Say(hSpells[i].spell)
end
end
end
end)


Again Thank you <3