Your browser does not support JavaScript or its disabled!
Please turn it on, or be aware that some features on this website will not work correctly.
2.1K
Smarter skull targeting #12
This will target creatures with a black skull first, then other skulls and then lowest health found.
1.32kb | 40 lines.
 --[[
  Script made by Lee (Discord: l33_) - www.trainorcreations.com
  If you want to support my work, feel free to donate at https://trainorcreations.com/donate
  PS. Stop ripping off my work and selling it as your own.
 ]]--
macro(100, "Smarter skull targeting", function()
    if isInPz() then return end
    local skulls_array = { 1,2, 3, 4, 5, 6 }
    local skull_black = 5
    local skull_found = false

    local distance = 6
    local lowest_health = 101
    local tNpc = nil

    for _, spec in pairs(getSpectators()) do
        if spec:isMonster() then
            if getDistanceBetween(player:getPosition(), spec:getPosition()) <= distance then
                local pSkull = spec:getSkull()
                if table.find(skulls_array, pSkull) then
					tNpc = spec
                    skull_found = true
                    if pSkull == skull_black then
                        break
                    end
                else
                    if spec:getHealthPercent() < lowest_health and not skull_found then
                        lowest_health = spec:getHealthPercent()
                        tNpc = spec
                    end
                end
            end
        end
    end

    if tNpc and tNpc:isMonster() then
        if getDistanceBetween(player:getPosition(), tNpc:getPosition()) <= distance then
            if (g_game.getAttackingCreature() ~= tNpc) then
                if skull_found or tNpc:getHealthPercent() <= lowest_health then
                    g_game.attack(tNpc)
                end
            end
        end
    end
end)

01 Jan 2020
Ads