XenoBot Forums - Powered by vBulletin

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Help with custom spellcaster

  1. #1

    Join Date
    Feb 2014
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Help with custom spellcaster

    If I want a spellcaster to when I have ANY TARGET not just for a specific monster, how do I change this lua script?

    lua code:
    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

  2. #2

    Join Date
    Feb 2014
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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!

  3. #3

    Join Date
    Feb 2014
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Maybe @anoyn you could help me with this? would appreciate it alot!

  4. #4
    Senior Member Jontor's Avatar
    Join Date
    Sep 2014
    Posts
    446
    Mentioned
    51 Post(s)
    Tagged
    1 Thread(s)
    Try this:
    Code:
    -- 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)

  5. #5

    Join Date
    Feb 2014
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jontor View Post
    Try this:
    Code:
    -- 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!
    Doesn't look like it prioritizes the spells at the top though?

  6. #6
    Senior Member Jontor's Avatar
    Join Date
    Sep 2014
    Posts
    446
    Mentioned
    51 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Gluben View Post
    Works like a charm, thanks alot!
    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:

    Code:
    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)

  7. #7

    Join Date
    Feb 2014
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jontor View Post
    This is because pairs() are in random order, would need a small change:

    Code:
    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!

  8. #8

    Join Date
    Feb 2014
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jontor View Post
    This is because pairs() are in random order, would need a small change:

    Code:
    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

  9. #9
    Lifetime Subscriber Sheradial's Avatar
    Join Date
    Apr 2015
    Posts
    165
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Gluben View Post
    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.


  10. #10

    Join Date
    Feb 2014
    Posts
    24
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Sheradial View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •