Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. addSeparator("separator")
  2. addLabel("attacktext", "Attack Settings")
  3. addSeparator("separator")
  4. local toAttack = nil
  5. onMissle(function(missle)
  6. if not storage.attackLeader or storage.attackLeader:len() == 0 then
  7. return
  8. end
  9. local src = missle:getSource()
  10. if src.z ~= posz() then
  11. return
  12. end
  13. local from = g_map.getTile(src)
  14. local to = g_map.getTile(missle:getDestination())
  15. if not from or not to then
  16. return
  17. end
  18. local fromCreatures = from:getCreatures()
  19. local toCreatures = to:getCreatures()
  20. if #fromCreatures ~= 1 or #toCreatures ~= 1 then
  21. return
  22. end
  23. local c1 = fromCreatures[1]
  24. if c1:getName():lower() == storage.attackLeader:lower() then
  25. toAttack = toCreatures[1]
  26. end
  27. end)
  28. macro(50, "Attack leader's target", function()
  29. if toAttack and storage.attackLeader:len() > 0 and toAttack ~= g_game.getAttackingCreature() then
  30. g_game.attack(toAttack)
  31. toAttack = nil
  32. end
  33. end)
  34.  
  35. addLabel("leadertext", "Leader: ")
  36. addTextEdit("attackLeader", storage.attackLeader or "player name", function(widget, text)
  37. storage.attackLeader = text
  38. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement