Guest User

Runes Custom Timer

a guest
Sep 3rd, 2014
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.12 KB | None | 0 0
  1. --The base code used was taken from Byrth's BRD.Lua - Custom Timers
  2.  
  3. function get_sets()
  4.     timer_reg = {}
  5.     runecounter = 0
  6. end
  7.    
  8. function precast(spell)
  9.     rune_custome_timer_pc(spell)
  10. end
  11.  
  12. function midcast(spell)
  13. end
  14.  
  15. function buff_change(status,gain)
  16.     if gain then
  17.         --add_to_chat(100,'> > > Gain > '..status)
  18.     else
  19.         if runes:contains(status) then -- Need to work on this...
  20.             runecounter = runecounter -1
  21.             if runecounter < 0 then
  22.                 runecounter = 0
  23.             end
  24.         end
  25.         --add_to_chat(100,'> > Lost> '..status)
  26.     end
  27. end
  28.  
  29. function aftercast(spell,action)
  30.     rune_custome_timer_af(spell)
  31. end
  32.  
  33. function rune_custome_timer_pc(spell)
  34.     runes = S{ 'Ignis', 'Gelus', 'Flabra', 'Tellus', 'Sulpor', 'Unda', 'Lux', 'Tenebrae' }
  35.     if spell.type and spell.type == 'Rune' and not spell.interrupted then
  36.         runecounter = runecounter + 1
  37.         if runecounter > 3 then
  38.             runecounter = 1
  39.         end
  40.     end
  41.     runename = 'Rune: '..tostring(runecounter)
  42.    
  43.     if spell.name == "Swipe" and not spell.interrupted then
  44.         send_command('timers delete "Rune: 1"')
  45.         runecounter = 0
  46.     end
  47.    
  48.     if spell.name == "Lunge" or spell.name == "Gambit" and not spell.interrupted then
  49.         reset_timers()
  50.     end    
  51. end
  52.  
  53. function rune_custome_timer_af(spell)
  54.      if spell.type and spell.type == 'Rune' and spell.target and spell.target.type:upper() == 'SELF' and not spell.interrupted then
  55.         local t = os.time()
  56.         local tempreg = {}
  57.  
  58.         for i,v in pairs(timer_reg) do
  59.             if v < t then tempreg[i] = true end
  60.         end
  61.         for i,v in pairs(tempreg) do
  62.             timer_reg[i] = nil
  63.         end
  64.        
  65.         local dur = 300
  66.                 add_to_chat(100,'> > > '..runename)
  67.  
  68.         if timer_reg[runename] then
  69.                 send_command('timers delete "'..runename..'"')
  70.                 timer_reg[runename] = t + dur
  71.                 send_command('timers create "'..runename..'" '..dur..' down')
  72.         else
  73.             local maxrunes = 3
  74.             if maxrunes < table.length(timer_reg) then
  75.                 maxrunes = table.length(timer_reg)
  76.             end
  77.            
  78.             if table.length(timer_reg) < maxrunes then
  79.                 timer_reg[runename] = t+dur
  80.                 send_command('timers create "'..runename..'" '..dur..' down')
  81.             else
  82.                 local rep,reprune
  83.                 for i,v in pairs(timer_reg) do
  84.                     if t+dur > v then
  85.                         if not rep or rep > v then
  86.                             rep = v
  87.                             reprune = i
  88.                         end
  89.                     end
  90.                 end
  91.                 if reprune then
  92.                     timer_reg[reprune] = nil
  93.                     send_command('timers delete "'..reprune..'"')
  94.                     timer_reg[runename] = t+dur
  95.                     send_command('timers create "'..runename..'" '..dur..' down')
  96.                 end
  97.             end
  98.         end
  99.     end
  100. end
  101.  
  102. function reset_timers()
  103.   send_command('timers delete "Rune: 1"')
  104.   send_command('timers delete "Rune: 2"')
  105.   send_command('timers delete "Rune: 3"')
  106.   runecounter = 0
  107. end
  108.  
  109.  
  110. function self_command(cmd)
  111. end
Advertisement
Add Comment
Please, Sign In to add comment