Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _addon.name = 'THTest'
- _addon.author = 'Thorny'
- _addon.version = '1.00-w'
- _addon.commands = {'tht'} --No commands ported yet
- --addon.link = 'https://github.com/ThornyFFXI/'
- require('tables')
- config = require('config')
- texts = require('texts')
- local currentTarget = {}
- local globalProcCount = T{}
- local currentPlayerTH = 15
- local filePath
- local backupPath
- windower.register_event("load", function (...)
- local time = os.date('*t')
- local folderName = "logs"
- if not windower.dir_exists(windower.addon_path..folderName) then
- windower.create_dir(windower.addon_path..folderName)
- end
- local fileName = ('%04d%02d%02d_%02d%02d%02d.csv'):format(time.year, time.month, time.day, time.hour, time.min, time.sec)
- filePath = windower.addon_path..string.format('%s/%s', folderName, fileName)
- fileName = ('%04d%02d%02d_%02d%02d%02d_missed.csv'):format(time.year, time.month, time.day, time.hour, time.min, time.sec)
- backupPath = windower.addon_path..string.format('%s/%s', folderName, fileName)
- if (not windower.file_exists(filePath)) then
- local file = io.open(filePath, 'w')
- file:write('"Timestamp","Mob TH Level","Player TH Level","Proc Index","Proc Crit","First Hit Crit","First Hit Land","First Hit Damage"\n')
- file:close()
- end
- if (not windower.file_exists(backupPath)) then
- local file = io.open(filePath, 'w')
- file:write('"Timestamp","Mob TH Level","Player TH Level","Proc Index","Proc Crit","First Hit Crit","First Hit Land","First Hit Damage"\n')
- file:close()
- end
- end)
- windower.register_event('action', function(act)
- if act['actor_id'] == windower.ffxi.get_player()['id'] then
- if act['category'] == 1 then
- local target = act['targets'][1]
- if target then
- local targetId = target['id']
- if targetId ~= currentTarget.Id then
- currentTarget = {
- Id = targetId,
- TH = math.min(currentPlayerTH, 8),
- Name = windower.ffxi.get_mob_by_id(targetId)['name'],
- Index = windower.ffxi.get_mob_by_id(targetId)['index'],
- ProcCount = T{},
- }
- end
- local currentTH = currentTarget.TH
- local localProcCount = currentTarget.ProcCount
- if (localProcCount[currentTH] == nil) then
- localProcCount[currentTH] = { HitCount=1, ProcCount=0 }
- else
- localProcCount[currentTH].HitCount = localProcCount[currentTH].HitCount + 1
- end
- if (globalProcCount[currentTH] == nil) then
- globalProcCount[currentTH] = { HitCount=1, ProcCount=0 }
- else
- globalProcCount[currentTH].HitCount = globalProcCount[currentTH].HitCount + 1
- end
- local procIndex = 0
- local wasCrit = T{}
- local wasHit = T{}
- local hitDamage = T{}
- for index,action in ipairs(target.actions) do
- wasCrit[index] = (action.effect == 2)
- wasHit[index] = ((action.reaction ~= 1) and (action.effect ~= 2))
- hitDamage[index] = action.param
- if (action.has_add_effect) then
- if (action.add_effect_message == 603) then
- procIndex = index
- currentTarget.TH = action.add_effect_param
- localProcCount[currentTH].ProcCount = localProcCount[currentTH].ProcCount + 1
- globalProcCount[currentTH].ProcCount = globalProcCount[currentTH].ProcCount + 1
- end
- end
- end
- local procCrit = 0
- if (procIndex ~= 0) then
- procCrit = (wasCrit[procIndex] and 1 or 0)
- end
- local output = string.format('%u,%u,%u,%u,%u,%u,%u,%u\n',
- os.time(),
- currentTH,
- currentPlayerTH,
- procIndex,
- procCrit,
- wasCrit[1] and 1 or 0,
- wasHit[1] and 1 or 0,
- hitDamage[1])
- local file = io.open(filePath, 'a')
- if (file) then
- file:write(output)
- file:close()
- else
- file = io.open(backupPath, 'a')
- if file then
- file:write(output)
- file:close()
- else
- print(string.format('Failed to open file and backup file. Data Point:%s', output))
- end
- end
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement