Advertisement
Cavitt

Auto Area Attack

Apr 25th, 2012
4,746
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2.         Instructions:
  3.                 Attacks are prioritized least to greatest.
  4.  
  5.                 Required parameters:
  6.                         words = spell words or rune id
  7.                         min = minimum monster amount to trigger spell/rune
  8.                         distance = the max range of the attack
  9.  
  10.                 Optional parameters:
  11.                         max = the max monsters the spell will attack
  12.                         mana = the minimum mana you want to have before casting
  13.                         padding = the extra sqm's to check for players PAST the attack distance (default is 0)
  14.                         needsTarget = the attack needs a target (exori hur, etc)
  15.                         needsDirection = spells most effective when facing target (exori min)
  16.                         multiFloor = check for players above/below (stairhop skulling)
  17.                         ignoreParty = ignore player checks for party members
  18.                         whiteList = table of players to ignore
  19.                         targetList = table of monsters to attack, to attack all do not specify this option
  20.  
  21. ]]
  22.  
  23.  
  24. attack = {}
  25. attack[1] = {words="exori gran", min=5, distance=1, padding=2, multiFloor=true, ignoreParty=false, whiteList={"Syntax", "DarkstaR"}}
  26. attack[2] = {words="exori min", min=3, mana=100, needsDirection=true, distance=1, padding=2, multiFloor=true, ignoreParty=true, targetList={"Dragon"}}
  27. attack[3] = {words="exori", min=2, distance=1, padding=2, multiFloor=true, ignoreParty=true}
  28. attack[4] = {words="exori hur", min=1, max=1, needsTarget=true, distance=1, padding=0, multiFloor=false, ignoreParty=true}
  29. attack[5] = {words=3191, min=3, distance=3, padding=2, multiFloor=true, ignoreParty=true} -- gfb rune
  30.  
  31.  
  32. function getTargetCount(distance, padding, multiFloor, ignoreParty, whiteList, targetList)
  33.         local n = 0
  34.         padding = padding or 0
  35.         whiteList = whiteList or {}
  36.         targetList = targetList or {}
  37.         for i = CREATURES_LOW, CREATURES_HIGH do
  38.                 local cid = Creature.GetFromIndex(i)
  39.                 local checkPad = cid:isPlayer() and padding or 0
  40.                 if(cid:isValid() and cid:isVisible() and cid:isAlive() and cid:DistanceFromSelf() <= (distance + checkPad) and not cid:isSelf())then
  41.                         if(getSelfPosition().z == cid:Position().z or (multiFloor and cid:isPlayer()))then
  42.                                 if(cid:isPlayer() and (not cid:isPartyMember() or not ignoreParty) and not table.find(whiteList, cid:Name(), false))then
  43.                                         return 0
  44.                                 elseif(cid:isMonster() and (table.find(targetList, cid:Name(), false) or #targetList<1))then
  45.                                         n = n + 1
  46.                                 end
  47.                         end
  48.                 end
  49.         end
  50.         return n
  51. end
  52.  
  53. function main()
  54.         for i = 1, #attack do
  55.                 local atk = attack[i]
  56.                 local count = getTargetCount(atk.distance, atk.padding, atk.multiFloor, atk.ignoreParty, atk.whiteList, atk.targetList)
  57.                 if(count > 0)then
  58.                         if(count >= atk.min and count <= ((atk.max == nil) and count or atk.max))then
  59.                                 if(type(atk.words) == 'number')then
  60.                                         Self.UseItemWithMe(atk.words)
  61.                                         wait(900, 1200)
  62.                                 elseif(Self.CanCastSpell(atk.words) and (not atk.mana or Self.Mana() >= atk.mana))then
  63.                                         local target = Creature.GetByID(Self.TargetID())
  64.                                         if(atk.needsTarget or atk.needsDirection)then
  65.                                                 if(target:isOnScreen() and target:isVisible() and target:isAlive())then
  66.                                                         if(target:DistanceFromSelf() <= atk.distance)then
  67.                                                                 if(atk.needsDirection)then
  68.                                                                         local pos, toPos = getSelfPosition(), target:Position()
  69.                                                                         local dir = pos.x > toPos.x and WEST or pos.x < toPos.x and EAST or pos.y > toPos.y and NORTH or SOUTH
  70.                                                                         Self.Turn(dir)
  71.                                                                         wait(100, 200)
  72.                                                                 else
  73.                                                                         Self.Say(atk.words)
  74.                                                                 end
  75.                                                         end
  76.                                                 end
  77.                                         end
  78.                                         if(not atk.needsTarget)then
  79.                                                 Self.Say(atk.words)
  80.                                         end
  81.                                         wait(600, 1000)
  82.                                 end
  83.                         end
  84.                 end
  85.         end
  86. end
  87.  
  88. print([[
  89. Name: Auto Area Attack
  90. Description: Shoots area spells/rune on certain conditions
  91. Author: Cavitt Glover (Syntax)
  92. Version: 5.0.00 (updated 11.26.2012)]])
  93. wait(2000)
  94.  
  95. registerEventListener(TIMER_TICK, "main")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement