Advertisement
ppgab

Untitled

May 23rd, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.04 KB | None | 0 0
  1. -- How the caster config works :
  2. --[[
  3.     Options:
  4.         words - words of spell to cast
  5.         creatures - table of creatures to consider, if you disclude this it will consider all
  6.         count - amount of creatures in order to cast
  7.         range - distance from self to consider creatures
  8.         padding - for pvpsafe, if enabled each spell must have a padding setting, distance from self players must be in order to cast
  9.         needTarget - for spells that require a target, no need for a count or padding if this is enabled
  10. ]]--
  11.  
  12.  
  13. -- user config:
  14.  
  15. ExoriHur        = true
  16. Exori           = true
  17. ExoriGran       = true
  18. ExoriIco        = true
  19. ExoriGranIco    = true
  20.  
  21. Creatures       = {'Creature 1', 'Creature 2', 'Creature 3'} -- All names must be in 'CamelCase'
  22.  
  23.  
  24.  
  25.  
  26. -- the caster module:
  27.  
  28. local Attacks = {}
  29.  
  30. spellCaster = Module.New('Caster', function(module)
  31.     for _, data in ipairs(Attacks) do
  32.         if (not PvPSafe) or (Self.isAreaPvPSafe(data.padding,true,true)) then
  33.             if data.needTarget then
  34.                 local target = Creature.New(Self.TargetID())
  35.                 if (data.creatures and table.find(data.creatures, target:Name(), false)) or (not data.creatures) then
  36.                     if target:DistanceFromSelf() <= data.range and Self.CanCastSpell(data.words) then
  37.                         Self.Say(data.words)
  38.                     end
  39.                 end
  40.             else
  41.                 local count, mob = 0, Self.GetTargets(data.range)
  42.                 if data.creatures then
  43.                     for i = 1, #mob do
  44.                         if mob[i]:isOnScreen() and table.find(data.creatures, mob[i]:Name(), false) then
  45.                             count = count + 1
  46.                         end
  47.                     end
  48.                 else
  49.                     count = #mob
  50.                 end
  51.                 if count >= data.count and Self.CanCastSpell(data.words) then
  52.                     Self.Say(data.words)
  53.                 end
  54.             end
  55.         end
  56.     end
  57. end,false)
  58.  
  59. -- Creating the config table based on user configuration:
  60.     local n = 1
  61.    
  62.     if Exori then
  63.         Attacks[n] = {words = 'exori', creatures = Creatures, count = 2, range = 1}
  64.         n = n + 1 -- since we already added Attacks[1] let's add Attacks[2] in the next
  65.     end
  66.     if ExoriGran then
  67.         Attacks[n] = {words = 'exori gran', creatures = Creatures, count = 3, range = 1}
  68.         n = n + 1
  69.     end
  70.     if ExoriGranIco then
  71.         Attacks[n] = {words = 'exori gran ico', creatures = Creatures, count = 1, range = 1, needTarget = true}
  72.         n = n + 1
  73.     end
  74.     if ExoriIco then
  75.         Attacks[n] = {words = 'exori ico', creatures = Creatures, count = 1, range = 1, needTarget = true}
  76.         n = n + 1
  77.     end
  78.     if ExoriHur then
  79.             Attacks[n] = {words = 'exori hur', creatures = Creatures, count = 1, range = 4, needTarget = true}
  80.             n = n+1
  81.     end
  82.  
  83. if (Exori or ExoriGran or ExoriGranIco or ExoriIco or ExoriHur) then
  84.     spellCaster:Start() -- starting the module
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement