Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.0 kB
5
Indexable
Never
local toAttack = nil
onMissle(function(missle)
  if not storage.attackLeader or storage.attackLeader:len() == 0 then
    return
  end
  local src = missle:getSource()
  if src.z ~= posz() then
    return
  end
  local from = g_map.getTile(src)
  local to = g_map.getTile(missle:getDestination())
  if not from or not to then
    return
  end
  local fromCreatures = from:getCreatures()
  local toCreatures = to:getCreatures()
  if #fromCreatures ~= 1 or #toCreatures ~= 1 then
    return
  end
  local c1 = fromCreatures[1]
  if c1:getName():lower() == storage.attackLeader:lower() then
    toAttack = toCreatures[1]
  end
end)
macro(50, "Attack leader's target", nil, function()
  if toAttack and storage.attackLeader:len() > 0 then 
    if not g_game.isAttacking() then
      g_game.attack(toAttack)
    end
    useWith(3155,toAttack)
    toAttack = nil
  end
end, parent)
addTextEdit("attackLeader", storage.attackLeader or "player name", function(widget, text)
  storage.attackLeader = text
end, parent)
Leave a Comment