Suggestions
Smarter skull targeting
#12
This will target creatures with a black skull first, then other skulls and then lowest health found.
--[[
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, "Smart Skull Targeting", function()
if isInPz() then return end
local skulls = { [1] = true, [2] = true, [3] = true, [4] = true, [5] = true, [6] = true }
local target, lowest_health, max_distance, closest_distance = nil, 101, 6, 6
for _, spec in pairs(getSpectators()) do
local distance = getDistanceBetween(player:getPosition(), spec:getPosition())
if spec:isMonster() and distance <= max_distance then
local skull = spec:getSkull()
if skull == 5 then
target, closest_distance = spec, distance
break
elseif skulls[skull] and distance < closest_distance then
target, closest_distance = spec, distance
elseif not target and spec:getHealthPercent() < lowest_health then
lowest_health, target, closest_distance = spec:getHealthPercent(), spec, distance
end
end
end
if target and g_game.getAttackingCreature() ~= target then
g_game.attack(target)
end
end)
04 Oct 2024