Signup Now
Results 1 to 2 of 2
  1. #1
    Moderator Josh's Avatar
    Join Date
    Dec 2013
    Posts
    1,395
    Reputation
    183
    Rep Power
    24

    Attack nearest creature

    Attack nearest creature until dead:
    function getNearestCreature()
    local nearestCreatureID = 0
    local nearestCreatureDist = 10
    foreach creature m 'ms' do
    if m.dist < nearestCreatureDist then
    nearestCreatureID = m.id
    nearestCreatureDist = m.dist
    end
    end
    return nearestCreatureID
    end


    auto(1000)
    if $target == 0 then
    attack(getNearestCreature())
    end


    Attack nearest creature until a nearer one comes along:
    function getNearestCreature()    local nearestCreatureID = 0
    local nearestCreatureDist = 10
    foreach creature m 'ms' do
    if m.dist < nearestCreatureDist then
    nearestCreatureID = m.id
    nearestCreatureDist = m.dist
    end
    end
    return nearestCreatureID
    end




    auto(1000)
    if $target.id ~= getcreature(getNearestCreature()).id then
    attack(getNearestCreature())
    end


    Didn't test it, but it looks about right.
    @ratrider
    Last edited by Josh; 05-17-2016 at 08:00 AM.

  2. #2
    Moderator mistgun's Avatar
    Join Date
    Dec 2013
    Location
    Lodz, Poland
    Posts
    1,821
    Reputation
    220
    Rep Power
    26
    hmm i wonder why making such things? proximity in targeting is the way

 

 

Posting Permissions

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