Advertisement
Guest User

Untitled

a guest
Apr 29th, 2018
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.57 KB | None | 0 0
  1. _addon.name = 'Resist Tester'
  2. _addon.version = '0.1'
  3. _addon.author = 'Chiaia'
  4. _addon.commands = {'resist'}
  5.  
  6. packets = require('packets')
  7. require('logger')
  8. local self = windower.ffxi.get_mob_by_target('me').id
  9. local totalCount = 0
  10. local silenceCount = 0
  11. local resistedTypeOne = 0 --(Resisted!)
  12. local resistedTypeTwo = 0 --Regular Resist
  13. local run = false
  14. local percent = 0
  15.  
  16. windower.register_event('incoming chunk', function(id, data)
  17.      if run and (id == 0x028)then
  18.         local action = packets.parse('incoming', data)
  19.         local target  = action['Target 1 ID']
  20.         local message = action['Target 1 Action 1 Message']
  21.         local messageMod = action['Target 1 Action 1 _unknown'] --Message Modifier: 0 = Regular, Resist 2 = (Resist!)
  22.           if target == self and action.Category == 4 and action.Param == 59 then -- Target is me, Finished Casting and Spell is Silence
  23.             if message == 75 then --Don't log/count anything if No Effect
  24.                return
  25.             else
  26.                totalCount = totalCount + 1
  27.                if message == 236 then --Silence Landed
  28.                     silenceCount = silenceCount + 1
  29.                elseif message == 85 and messageMod == 2 then -- (Resisted!)
  30.                     resistedTypeOne = resistedTypeOne + 1
  31.                elseif message == 85 and messageMod == 0 then -- Regular Resist
  32.                     resistedTypeTwo = resistedTypeTwo + 1
  33.                else
  34.                     log("We have an error!")
  35.                end
  36.                     percent = (resistedTypeOne / totalCount) * 100
  37.                     log("(Resisted!): " ..resistedTypeOne.. " Reg Resist: " ..resistedTypeTwo.. " Silenced: " ..silenceCount..  " Total: " ..totalCount.."")
  38.                     log("Percent: "..percent.."%")
  39.             end
  40.           end
  41.      end
  42. end)
  43.  
  44. windower.register_event('addon command', function(command)
  45.     command = command and command:lower()
  46.     if S{'run'}:contains(command) then
  47.         if run then
  48.                run = false
  49.                log('No longer logging data.')
  50.           elseif not run then
  51.                run = true
  52.                log('Now resuming logging data.')
  53.           end
  54.     elseif S{'stats',}:contains(command) then
  55.                log("Stats: (Resisted!): " ..resistedTypeOne.. " Reg Resist: " ..resistedTypeTwo.. " Silenced: " ..silenceCount..  " Total: " ..totalCount.."")
  56.                log("Stats: Percent: "..percent.."%")
  57.      else
  58.                log('//resist run - To toggle on/off data logging')
  59.                log('//resist stats - To display current data')
  60.      end
  61. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement