diff options
Diffstat (limited to 'Data/BuiltIn/Libraries/lua-addons/addons/digger')
3 files changed, 310 insertions, 0 deletions
diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/digger/README b/Data/BuiltIn/Libraries/lua-addons/addons/digger/README new file mode 100644 index 0000000..d79b4ed --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/digger/README @@ -0,0 +1,23 @@ +This script is a Chocobo digging addon to be used with Windower for +Final Fantasy XI. + +You can report issues, get the latest version, and view the source at: + https://github.com/svanheulen/digger-windower-addon + +*********************************************************************** +I stopped playing FFXI (in February 2015) so I may not be able to help +with bugs but I'll try... So long as you can give me more information +then "it doesn't work" +*********************************************************************** + +This addon requires the Timers plugin to display your "recast" timer for +digging. It will also display statistics about your dig accuracy, +fatigue and remaining greens after each dig. The fatigue tracking will +also work properly with the Blue Racing Silks bonus. + +The available commands are: + digger rank <crafting rank> + Sets your digging rank. Accepts rank name (like "Artisan") or + area delay (like "A25"). + digger stats [clear] + Displays or clears digging accuracy statistics. diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/digger/digger.lua b/Data/BuiltIn/Libraries/lua-addons/addons/digger/digger.lua new file mode 100644 index 0000000..90d4acd --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/digger/digger.lua @@ -0,0 +1,226 @@ +--[[ +Copyright (c) 2014, Seth VanHeulen +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--]] + +-- addon information + +_addon.name = 'digger' +_addon.version = '2.2.0' +_addon.command = 'digger' +_addon.author = 'Seth VanHeulen (Acacia@Odin)' + +-- modules + +config = require('config') +require('pack') + +-- default settings + +defaults = {} +defaults.delay = {} +defaults.delay.area = 60 +defaults.delay.lag = 3 +defaults.delay.dig = 15 +defaults.fatigue = {} +defaults.fatigue.date = os.date('!%Y-%m-%d', os.time() + 32400) +defaults.fatigue.items = 0 +defaults.fatigue.diff = 0 +defaults.fatigue.free = 0 +defaults.accuracy = {} +defaults.accuracy.failed = 0 +defaults.accuracy.total = 0 + +settings = config.load(defaults) + +-- load message constants + +require('messages') + +-- buff helper function + +function get_chocobo_buff() + for _,buff_id in pairs(windower.ffxi.get_player().buffs) do + if buff_id == 252 then + return true + end + end + return false +end + +-- inventory helper function + +function get_gysahl_count() + local count = 0 + for _,item in pairs(windower.ffxi.get_items(0)) do + if type(item) == 'table' and item.id == 4545 and item.status == 0 then + count = count + item.count + end + end + return count +end + +-- stats helper functions + +function update_day() + local today = os.date('!%Y-%m-%d', os.time() + 32400) + if settings.fatigue.date ~= today then + settings.fatigue.date = today + settings.fatigue.items = 0 + settings.fatigue.free = 0 + settings.fatigue.diff = settings.accuracy.failed - settings.accuracy.total + end +end + +function display_stats() + local accuracy = 0 + local successful = settings.accuracy.total - settings.accuracy.failed + if settings.accuracy.total > 0 then + accuracy = (successful / settings.accuracy.total) * 100 + end + windower.add_to_chat(207, 'dig accuracy: %d%% (%d/%d), fatigue today: %d, items today: %d gysahl greens remaining: %d':format(accuracy, successful, settings.accuracy.total, successful - settings.fatigue.free + settings.fatigue.diff, settings.fatigue.items, get_gysahl_count())) +end + +function update_stats(mode) + update_day() + if mode == 3 then + settings.fatigue.free = settings.fatigue.free + 1 + elseif mode == 2 then + settings.fatigue.items = settings.fatigue.items + 1 + display_stats() + elseif mode == 1 then + settings.accuracy.total = settings.accuracy.total + 1 + else + settings.accuracy.failed = settings.accuracy.failed + 1 + display_stats() + end + settings:save() +end + +-- event callback functions + +function check_zone_change(new_zone_id, old_zone_id) + if messages[new_zone_id] then + windower.send_command('timers c "Chocobo Area Delay" %d down':format(settings.delay.area + settings.delay.lag)) + else + windower.send_command('timers d "Chocobo Area Delay"') + end + windower.send_command('timers d "Chocobo Dig Delay"') +end + +function check_incoming_chunk(id, original, modified, injected, blocked) + local zone_id = windower.ffxi.get_info().zone + if messages[zone_id] then + if id == 0x2A then + local message_id = original:unpack('H', 27) % 0x8000 + if (messages[zone_id].full == message_id or messages[zone_id].success == message_id or messages[zone_id].points == message_id or messages[zone_id].standing == message_id or messages[zone_id].notes == message_id or messages[zone_id].bayld == message_id) and get_chocobo_buff() then + update_stats(2) + elseif messages[zone_id].ease == message_id then + update_stats(3) + end + elseif id == 0x2F and windower.ffxi.get_player().id == original:unpack('I', 5) then + if settings.delay.dig > 0 then + windower.send_command('timers c "Chocobo Dig Delay" %d down':format(settings.delay.dig)) + end + update_stats(1) + elseif id == 0x36 then + local message_id = original:unpack('H', 11) % 0x8000 + if messages[zone_id].fail == message_id then + update_stats(0) + end + end + end +end + +function digger_command(...) + local arg = {...} + if #arg == 1 and arg[1]:lower() == 'stats' then + update_day() + display_stats() + elseif #arg == 2 and arg[1]:lower() == 'stats' and arg[2]:lower() == 'clear' then + update_day() + settings.fatigue.diff = settings.accuracy.total - settings.accuracy.failed + settings.fatigue.diff + settings.accuracy.failed = 0 + settings.accuracy.total = 0 + settings:save() + windower.add_to_chat(204, 'reset dig accuracy statistics') + elseif #arg == 2 and arg[1]:lower() == 'rank' then + local rank = arg[2]:lower() + if rank == 'amateur' or rank == 'a60' then + settings.delay.area = 60 + settings.delay.dig = 15 + elseif rank == 'recruit' or rank == 'a55' then + settings.delay.area = 55 + settings.delay.dig = 10 + elseif rank == 'initiate' or rank == 'a50' then + settings.delay.area = 50 + settings.delay.dig = 5 + elseif rank == 'novice' or rank == 'a45' then + settings.delay.area = 45 + settings.delay.dig = 0 + elseif rank == 'apprentice' or rank == 'a40' then + settings.delay.area = 40 + settings.delay.dig = 0 + elseif rank == 'journeyman' or rank == 'a35' then + settings.delay.area = 35 + settings.delay.dig = 0 + elseif rank == 'craftsman' or rank == 'a30' then + settings.delay.area = 30 + settings.delay.dig = 0 + elseif rank == 'artisan' or rank == 'a25' then + settings.delay.area = 25 + settings.delay.dig = 0 + elseif rank == 'adept' or rank == 'a20' then + settings.delay.area = 20 + settings.delay.dig = 0 + elseif rank == 'veteran' or rank == 'a15' then + settings.delay.area = 15 + settings.delay.dig = 0 + elseif rank == 'expert' or rank == 'a10' then + settings.delay.area = 10 + settings.delay.dig = 0 + else + windower.add_to_chat(167, 'invalid digging rank') + return + end + windower.add_to_chat(204, 'digging rank: %s, area delay: %d seconds, dig delay: %d seconds':format(rank, settings.delay.area, settings.delay.dig)) + settings:save() + else + windower.add_to_chat(167, 'usage:') + windower.add_to_chat(167, ' digger rank <crafting rank>') + windower.add_to_chat(167, ' digger stats [clear]') + end +end + +-- register event callbacks + +windower.register_event('zone change', check_zone_change) +windower.register_event('incoming chunk', check_incoming_chunk) +windower.register_event('addon command', digger_command) diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/digger/messages.lua b/Data/BuiltIn/Libraries/lua-addons/addons/digger/messages.lua new file mode 100644 index 0000000..8da59e0 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/digger/messages.lua @@ -0,0 +1,61 @@ +messages = {} +messages[2] = {bayld=7368, ease=7360, fail=7285, full=7283, notes=7367, points=7365, standing=7366, success=6388} +messages[4] = {bayld=7362, ease=7354, fail=7279, full=7277, notes=7361, points=7359, standing=7360, success=6388} +messages[5] = {bayld=7319, ease=7311, fail=7236, full=7234, notes=7318, points=7316, standing=7317, success=6401} +messages[7] = {bayld=7313, ease=7305, fail=7230, full=7228, notes=7312, points=7310, standing=7311, success=6388} +messages[24] = {bayld=7649, ease=7641, fail=7566, full=7564, notes=7648, points=7646, standing=7647, success=6388} +messages[25] = {bayld=7169, ease=7161, fail=7086, full=7084, notes=7168, points=7166, standing=7167, success=6388} +messages[51] = {bayld=7147, ease=7139, fail=7064, full=7062, notes=7146, points=7144, standing=7145, success=6388} +messages[52] = {bayld=7147, ease=7139, fail=7064, full=7062, notes=7146, points=7144, standing=7145, success=6388} +messages[61] = {bayld=7147, ease=7139, fail=7064, full=7062, notes=7146, points=7144, standing=7145, success=6388} +messages[79] = {bayld=7147, ease=7139, fail=7064, full=7062, notes=7146, points=7144, standing=7145, success=6388} +messages[81] = {bayld=7828, ease=7820, fail=7745, full=7743, notes=7827, points=7825, standing=7826, success=6388} +messages[82] = {bayld=7460, ease=7452, fail=7377, full=7375, notes=7459, points=7457, standing=7458, success=6388} +messages[83] = {bayld=7147, ease=7139, fail=7064, full=7062, notes=7146, points=7144, standing=7145, success=6388} +messages[84] = {bayld=7167, ease=7159, fail=7084, full=7082, notes=7166, points=7164, standing=7165, success=6388} +messages[88] = {bayld=7453, ease=7445, fail=7370, full=7368, notes=7452, points=7450, standing=7451, success=6388} +messages[89] = {bayld=7147, ease=7139, fail=7064, full=7062, notes=7146, points=7144, standing=7145, success=6388} +messages[90] = {bayld=7244, ease=7236, fail=7161, full=7159, notes=7243, points=7241, standing=7242, success=6388} +messages[91] = {bayld=7167, ease=7159, fail=7084, full=7082, notes=7166, points=7164, standing=7165, success=6388} +messages[95] = {bayld=7174, ease=7166, fail=7091, full=7089, notes=7173, points=7171, standing=7172, success=6388} +messages[96] = {bayld=7147, ease=7139, fail=7064, full=7062, notes=7146, points=7144, standing=7145, success=6388} +messages[97] = {bayld=7705, ease=7697, fail=7622, full=7620, notes=7704, points=7702, standing=7703, success=6388} +messages[98] = {bayld=7705, ease=7697, fail=7622, full=7620, notes=7704, points=7702, standing=7703, success=6388} +messages[100] = {bayld=7328, ease=7320, fail=7245, full=7243, notes=7327, points=7325, standing=7326, success=6410} +messages[101] = {bayld=7328, ease=7320, fail=7245, full=7243, notes=7327, points=7325, standing=7326, success=6410} +messages[102] = {bayld=7310, ease=7302, fail=7227, full=7225, notes=7309, points=7307, standing=7308, success=6388} +messages[103] = {bayld=7328, ease=7320, fail=7245, full=7243, notes=7327, points=7325, standing=7326, success=6410} +messages[104] = {bayld=7802, ease=7794, fail=7719, full=7717, notes=7801, points=7799, standing=7800, success=6410} +messages[105] = {bayld=7328, ease=7320, fail=7245, full=7243, notes=7327, points=7325, standing=7326, success=6410} +messages[106] = {bayld=7328, ease=7320, fail=7245, full=7243, notes=7327, points=7325, standing=7326, success=6569} +messages[107] = {bayld=7328, ease=7320, fail=7245, full=7243, notes=7327, points=7325, standing=7326, success=6410} +messages[108] = {bayld=7310, ease=7302, fail=7227, full=7225, notes=7309, points=7307, standing=7308, success=6388} +messages[109] = {bayld=7328, ease=7320, fail=7245, full=7243, notes=7327, points=7325, standing=7326, success=6410} +messages[110] = {bayld=7328, ease=7320, fail=7245, full=7243, notes=7327, points=7325, standing=7326, success=6410} +messages[111] = {bayld=7328, ease=7320, fail=7245, full=7243, notes=7327, points=7325, standing=7326, success=6569} +messages[112] = {bayld=7345, ease=7337, fail=7262, full=7260, notes=7344, points=7342, standing=7343, success=6401} +messages[113] = {bayld=7648, ease=7640, fail=7565, full=7563, notes=7647, points=7645, standing=7646, success=6388} +messages[114] = {bayld=7648, ease=7640, fail=7565, full=7563, notes=7647, points=7645, standing=7646, success=6388} +messages[115] = {bayld=7147, ease=7139, fail=7064, full=7062, notes=7146, points=7144, standing=7145, success=6388} +messages[116] = {bayld=7306, ease=7298, fail=7223, full=7221, notes=7305, points=7303, standing=7304, success=6388} +messages[117] = {bayld=7328, ease=7320, fail=7245, full=7243, notes=7327, points=7325, standing=7326, success=6569} +messages[118] = {bayld=7347, ease=7339, fail=7264, full=7262, notes=7346, points=7344, standing=7345, success=6423} +messages[119] = {bayld=7328, ease=7320, fail=7245, full=7243, notes=7327, points=7325, standing=7326, success=6410} +messages[120] = {bayld=7336, ease=7328, fail=7253, full=7251, notes=7335, points=7333, standing=7334, success=6410} +messages[121] = {bayld=7648, ease=7640, fail=7565, full=7563, notes=7647, points=7645, standing=7646, success=6388} +messages[122] = {bayld=7306, ease=7298, fail=7223, full=7221, notes=7305, points=7303, standing=7304, success=6388} +messages[123] = {bayld=7648, ease=7640, fail=7565, full=7563, notes=7647, points=7645, standing=7646, success=6388} +messages[124] = {bayld=7648, ease=7640, fail=7565, full=7563, notes=7647, points=7645, standing=7646, success=6388} +messages[125] = {bayld=7306, ease=7298, fail=7223, full=7221, notes=7305, points=7303, standing=7304, success=6388} +messages[126] = {bayld=7306, ease=7298, fail=7223, full=7221, notes=7305, points=7303, standing=7304, success=6388} +messages[127] = {bayld=7306, ease=7298, fail=7223, full=7221, notes=7305, points=7303, standing=7304, success=6388} +messages[128] = {bayld=7306, ease=7298, fail=7223, full=7221, notes=7305, points=7303, standing=7304, success=6388} +messages[136] = {bayld=7147, ease=7139, fail=7064, full=7062, notes=7146, points=7144, standing=7145, success=6388} +messages[137] = {bayld=7669, ease=7661, fail=7586, full=7584, notes=7668, points=7666, standing=7667, success=6388} +messages[260] = {bayld=7147, ease=7139, fail=7064, full=7062, notes=7146, points=7144, standing=7145, success=6388} +messages[261] = {bayld=7147, ease=7139, fail=7064, full=7062, notes=7146, points=7144, standing=7145, success=6388} +messages[262] = {bayld=7147, ease=7139, fail=7064, full=7062, notes=7146, points=7144, standing=7145, success=6388} +messages[263] = {bayld=7147, ease=7139, fail=7064, full=7062, notes=7146, points=7144, standing=7145, success=6388} +messages[265] = {bayld=7147, ease=7139, fail=7064, full=7062, notes=7146, points=7144, standing=7145, success=6388} +messages[266] = {bayld=7147, ease=7139, fail=7064, full=7062, notes=7146, points=7144, standing=7145, success=6388} +messages[267] = {bayld=7147, ease=7139, fail=7064, full=7062, notes=7146, points=7144, standing=7145, success=6388} |