diff options
Diffstat (limited to 'Data/BuiltIn/Libraries/lua-addons/addons/ohShi')
7 files changed, 726 insertions, 0 deletions
diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/Readme.md b/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/Readme.md new file mode 100644 index 0000000..679684b --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/Readme.md @@ -0,0 +1,39 @@ +**Author:** Ricky Gall +**Version:** 2.55 +**Description:** +Replacement for yarnregex for Windower 4 I made for a friend. Uses the chat log so filters must be off. At least until i figure out another way to do it. Keeps track of various event related things. Such as, VW proc messages, mob casting, mob tp moves, TH procs and cor rolls, as well as others. Digi of shiva created the icon and was the driving force behind testing/giving me the idea to do this. Digi also created the default mob list/danger list and chose the name. + +**Abbreviation:** //ohShi + +**Commands:** + 1. help - Brings up this menu. + 2. showrolls | selfrolls - Show corsair rolls in tracker | only own rolls. + 3. staggeronly - Only show voidwatch stagger notices. + 4. track(on/off) <abyssea/dangerous/legion/meebles/other/voidwatch> (name) - Begin or stop tracking (type (default: other)) of mob (name). + 5. spell/ws(on/off) <name> - Start or stop watching for <name> spell|ws. +**The following commands all correspond to the tracker:** + 6. fonttype <name> - change to (name) font + 7. fontsize <size> - change to (size) font + 8. pos <x> <y> - change boxes x/y coordinates (can click/drag as well) + 9. bgcolor <r> <g> <b> - change background color (r: red) (g: green) (b: blue) + 10. txtcolor <r> <g> <b> - change text color (r: red) (g: green) (b: blue) + 11. duration <time> - Changes the duration things stay in tracker. + 12. settings - shows current textbox settings + 13. show/hide - toggles visibility of the tracker so you can make changes. + +**Changes:** +* v2.55 + * Added vagary weakness tracking +* v2.5 + * Complete overhaul. + * Added ability to click/drag the text box + * Add selfrolls command (if this is on only your rolls will show) + * Due to the overhaul, all of your settings (except your moblist) will be reset to default. +* v2.1 + * On load/help command announce addon version +* v2.0 + * Fixed issue with nil value on ws or blue magic cast from player + * Fixed magic messages due to the spell resources being different + * Added confirmation and boxflash on settings change + * Settings file updated. moblist.xml deprecated + diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/data/settings.xml b/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/data/settings.xml new file mode 100644 index 0000000..8baab64 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/data/settings.xml @@ -0,0 +1,42 @@ +<?xml version="1.1" ?> +<settings> + <global> + <bg> + <alpha>255</alpha> + <blue>0</blue> + <green>0</green> + <red>0</red> + </bg> + <dangerwords> + <spells>Aeroga IV, Aeroja, Blizzaga IV, Blizzaja, Breakga, Death, Firaga IV, Firaja, Kaustra, Meteor, Stonega IV, Stoneja, Thundaga IV, Thundaja</spells> + <weaponskills>Arm Cannon, Astral Flow, Ballistic Kick, Beastruction, Chainspell, Danse Macabre, Divesting Gale, Eradicator, Extreme Purgitation, Frog Chorus, Frog Song, Fulmination, Gates of Hades, Geirrothr, Gorge, Mandible Massacre, Nerve Gas, Oblivion's Mantle, Pawn's Penumbra, Raksha Stance, Rancid Reflux, Slimy Proposal, Thundris Shriek, Yama's Judgment, Zantetsuken</weaponskills> + </dangerwords> + <duration>10</duration> + <moblist> + <abyssea>Alfard, Carabosse, Glavoid, Isgebind, Orthrus</abyssea> + <dangerous>Apademak, Provenance Watcher</dangerous> + <legion>Lofty, Mired, Paramount, Soaring, Veiled</legion> + <meebles>Dreyruk, Goldwing, Grannus, Izyx, Melisseus, Samursk, Silagilith, Surtr, Svaha, Umagrhk</meebles> + <other>Bloodthirsty, Cerberus, Dvergr, Enraged, Hydra, Khimaira, Khrysokhimaira, Odin, Tiamat</other> + <voidwatch>Aello, Agathos, Akvan, Asb, Belphoebe, Bismarck, Botulus Rex, Celaeno, Cherufe, Gasha, Gaunab, Giltine, Goji, Gugalanna, Hahava, Ig-Alima, Kaggen, Kalasutrax, Kholomodumo, Mellonia, Morta, Ocythoe, Pil, Provenance Watcher, Qilin, Rukh, Sarbaz, Shah, Taweret, Uptala, Wazir</voidwatch> + </moblist> + <padding>0</padding> + <pos> + <x>400</x> + <y>300</y> + </pos> + <selfrolls>false</selfrolls> + <showrolls>true</showrolls> + <staggeronly>false</staggeronly> + <text> + <alpha>255</alpha> + <blue>255</blue> + <content /> + <font>Consolas</font> + <green>255</green> + <red>255</red> + <size>10</size> + </text> + <visible>false</visible> + </global> +</settings> diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/data/warning.png b/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/data/warning.png Binary files differnew file mode 100644 index 0000000..23c294d --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/data/warning.png diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/default_settings.lua b/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/default_settings.lua new file mode 100644 index 0000000..7e19ca5 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/default_settings.lua @@ -0,0 +1,81 @@ +--[[ +Copyright (c) 2013, Ricky Gall +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of <addon name> 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 <your name> 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. +]] + +--Declaring default settings +defaults = T{} +--Addon settings +defaults.staggeronly = false +defaults.showrolls = true +defaults.selfrolls = false +defaults.duration = 10 + +--Textbox settings +defaults.bg = {} +defaults.bg.alpha = 100 +defaults.bg.red = 0 +defaults.bg.blue = 0 +defaults.bg.green = 0 +defaults.pos = {} +defaults.pos.x = 400 +defaults.pos.y = 300 +defaults.text = {} +defaults.text.red = 255 +defaults.text.green = 255 +defaults.text.blue = 255 +defaults.text.font = 'Consolas' +defaults.text.size = 10 + +--Moblist defaults +defaults.moblist = T{} +defaults.moblist['voidwatch'] = S{"Qilin", "Celaeno", "Morta", "Bismarck", "Ig-Alima", "Kalasutrax", "Ocythoe", "Gaunab", "Hahava", "Cherufe", "Botulus Rex", "Taweret", "Agathos", "Goji", "Gugalanna", "Gasha", "Giltine", "Mellonia", "Kaggen", "Akvan", "Pil", "Belphoebe", "Kholomodumo", "Aello", "Uptala", "Sarbaz", "Shah", "Wazir", "Asb", "Rukh", "Provenance Watcher"} +defaults.moblist['abyssea'] = S{"Alfard", "Orthrus", "Carabosse", "Glavoid", "Isgebind"} +defaults.moblist['legion'] = S{"Veiled", "Lofty", "Soaring", "Mired", "Paramount"} +defaults.moblist['meebles'] = S{"Goldwing", "Silagilith", "Surtr", "Dreyruk", "Samursk", "Umagrhk", "Izyx", "Grannus", "Svaha", "Melisseus"} +defaults.moblist['other'] = S{"Tiamat", "Khimaira", "Khrysokhimaira", "Cerberus", "Dvergr", "Bloodthirsty", "Hydra", "Enraged", "Odin"} +defaults.moblist['dangerous'] = S{"Provenance Watcher", "Apademak"} +defaults.dangerwords = T{} +defaults.dangerwords['weaponskills'] = S{"Zantetsuken", "Geirrothr", "Astral Flow", "Chainspell", "Beastruction", "Mandible Massacre", "Oblivion's Mantle", "Divesting Gale", "Frog Song", "Frog Chorus", "Danse Macabre", "Raksha Stance", "Yama's Judgment", "Ballistic Kick", "Eradicator", "Arm Cannon", "Gorge", "Extreme Purgitation", "Slimy Proposal", "Rancid Reflux", "Pawn's Penumbra", "Gates of Hades", "Fulmination", "Nerve Gas", "Thundris Shriek"} +defaults.dangerwords['spells'] = S{"Death", "Meteor", "Kaustra", "Breakga", "Thundaga IV", "Thundaja", "Firaga IV", "Firaja", "Aeroga IV", "Aeroja", "Blizzaga IV", "Blizzaja", "Stonega IV", "Stoneja"} + +--Fill settings from either defaults table or settings.xml +settings = config.load(defaults) +ohShi_tb = texts.new(settings) + +--create tables to be used throughout the addon +tracking = T{} +prims = S{} +--[[ keeping in case the function below doesn't work. +trusts = S{'Kupipi','Excenmille','Naji','Ayame','Zeid','Curilla', + 'NanaaMihgo','Trion','Shantotto','Volker','Ajido-Marujido', + 'MihliAliapoh','Valaineral','Joachim','Lion','Prishe','Ulmia', + 'Ironeater','Gadalar','NajaSalaheem','Cherukiki','Nashmeira', + 'Zazarg','Ingrid','LhekoHabhoka','Ovjang','Mnejing','Sakura', + 'Luzaf','Najelith', 'Maat','Gessho','Aldo','Moogle','Fablinix', + 'D.Shantotto','Elvira','Noillurie','LhuMhakaracca','FerreousCoffin', + 'StarSibyl','Mumor'}]] + trusts = S(res.spells:type('Trust'):map(string.gsub-{' ', ''} .. table.get-{'name'})) diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/helper_functions.lua b/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/helper_functions.lua new file mode 100644 index 0000000..e08fb21 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/helper_functions.lua @@ -0,0 +1,146 @@ +--[[ +Copyright (c) 2013, Ricky Gall +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of <addon name> 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 <your name> 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. +]] + +--This function checks the string sent to it against your mob list +--returns true if it's found and false if not. +function mCheck(str) + for category,_ in pairs(settings.moblist) do + for name,_ in pairs(settings.moblist[category]) do + if str:lower():contains(name:lower()) then + return true + end + end + end + return false +end + +--This function checks the string sent to it against your mob list +--returns true if it's found and false if not. +function mDanger(str) + for name,_ in pairs(settings.moblist.dangerous) do + if str:lower():contains(name:lower()) then + return true + end + end + return false +end + +--This function checks the string sent to it against your danger list +--returns true if it's found and false if not. +function dCheck(typ, sid) + --log('DEBUG TYP: '..typ..' ID: '..sid) + sid = tonumber(sid) + if typ == 'spell' then + if settings.dangerwords.spells:find(string.imatch-{res.spells[sid].english .. '$'}) then + return true + end + elseif sid <= 255 then + if settings.dangerwords.weaponskills:find(string.imatch-{res.weapon_skills[sid].english .. '$'}) then + return true + end + else + if settings.dangerwords.weaponskills:find(string.imatch-{res.monster_abilities[sid].english .. '$'}) then + return true + end + end + + return false +end + +--Check if the actor is actually an npc rather than a player +function isMob(id) + if not trusts:contains(windower.ffxi.get_mob_by_id(id)['name']) then + return windower.ffxi.get_mob_by_id(id)['is_npc'] + end + return false +end + +--This function is used to parse the windower resources +--to fill tables with ability/spell names/ids. +--Created by Byrth +function parse_resources(lines_file) + local ignore_fields = S{'german','french','japanese','index','recast','fr','frl','de','del','jp','jpl'} + local completed_table = {} + local counter = 0 + for i in ipairs(lines_file) do + local str = tostring(lines_file[i]) + local g,h,typ,key = string.find(str,'<(%w+) id="(%d+)" ') + if typ == 's' then + g,h,key = string.find(str,'index="(%d+)" ') + end + if key ~=nil then + completed_table[tonumber(key)]={} + local q = 1 + while q <= str:len() do + local a,b,ind,val = string.find(str,'(%w+)="([^"]+)"',q) + if ind~=nil then + if not ignore_fields[ind] then + if val == "true" or val == "false" then + completed_table[tonumber(key)][ind] = str2bool(val) + else + completed_table[tonumber(key)][ind] = val:gsub('"','\42'):gsub(''','\39') + end + end + q = b+1 + else + q = str:len()+1 + end + end + local k,v,english = string.find(str,'>([^<]+)</') + if english~=nil then + completed_table[tonumber(key)]['english']=english + end + end + end + + return completed_table +end + +--This function was made by Byrth. It's used to split strings +--at a specific character and store them in a table +function split(msg, match) + if msg == nil then return '' end + local length = msg:len() + local splitarr = {} + local u = 1 + while u <= length do + local nextanch = msg:find(match,u) + if nextanch ~= nil then + splitarr[#splitarr+1] = msg:sub(u,nextanch-match:len()) + if nextanch~=length then + u = nextanch+match:len() + else + u = length + end + else + splitarr[#splitarr+1] = msg:sub(u,length) + u = length+1 + end + end + return splitarr +end diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/ohShi.lua b/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/ohShi.lua new file mode 100644 index 0000000..567b15f --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/ohShi.lua @@ -0,0 +1,273 @@ +--[[ +Copyright (c) 2013, Ricky Gall +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of <addon name> 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 <your name> 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.name = 'OhShi' +_addon.version = '2.55' +_addon.author = 'Nitrous (Shiva)' +_addon.command = 'ohshi' + +--Requiring libraries used in this addon +--These should be saved in addons/libs +require('logger') +require('tables') +require('strings') +require('sets') +config = require('config') +files = require('files') +chat = require('chat') +texts = require('texts') +res = require('resources') +require('default_settings') +require('text_handling') +require('helper_functions') + +--This function is called when the addon loads. Defines aliases and +--registers functions, as well as filling the resource tables. +windower.register_event('load', initText) + +--Used when the addon is unloaded to save settings. +windower.register_event('unload',function() + settings:update(ohShi_tb._settings) + settings:save('all') +end) + +function saveSettings() + addText('OhShi Settings Updated') + settings:save('all') +end + +--This function is used to process addon commands +--like //ohshi help and the like. +windower.register_event('addon command', function(...) + local args = T{...} + if args[1] == nil then args[1] = 'help' end + if args[1] ~= nil then + local comm = table.remove(args,1):lower() + + if S{'showrolls','selfrolls'}:contains(comm) then + settings[comm] = not settings[comm] + settings.staggeronly = false + if comm == 'selfrolls' and not settings.showrolls then + settings.showrolls = true + elseif comm == 'showrolls' and settings.selfrolls then + settings.selfrolls = false + end + print('OhShi Showrolls:', settings.showrolls) + print('OhShi Selfrolls:', settings.selfrolls) + settings:save('all') + elseif comm == "staggeronly" then + settings.staggeronly = not settings.sstaggeronly + print('OhShi Stagger Only mode:', settings.staggeronly) + elseif comm == 'duration' then + if tonumber(args[1]) then + settings.duration = tonumber(args[1]) + print('OhShi Duration:',settings.duration) + saveSettings() + end + elseif S{'trackon','trackoff'}:contains(comm) then + local typ = '' + if S{'abyssea','dangerous','legion','meebles','other','voidwatch'}:contains(args[1]) then + typ = table.remove(args,1):lower() + else + typ = 'other' + end + local list = args:concat(' '):capitalize() + if comm == 'trackon' then + if not settings.moblist[typ]:find(string.imatch-{list}) then + settings.moblist[typ]:add(list) + notice(list..' added to '..typ..' table.') + end + else + if settings.moblist[typ]:find(string.imatch-{list}) then + settings.moblist[typ]:remove(settings.moblist[typ]:find(string.imatch-{list})) + notice(list..' removed from '..typ..' table.') + end + end + settings:save('all') + elseif S{'spellon','spelloff','wson','wsoff'}:contains(comm) then + local typ = '' + if S{'spellon','spelloff'}:contains(comm) then + typ = 'spells' + else + typ = 'weaponskills' + end + local list = args:concat(' '):capitalize() + if comm:find('on$') then + if not settings.dangerwords[typ]:find(string.imatch-{list..'$'}) then + settings.dangerwords[typ]:add(list) + notice(list..' added to '..typ..' table.') + end + else + if settings.dangerwords[typ]:find(string.imatch-{list..'$'}) then + settings.dangerwords[typ]:remove(settings.dangerwords[typ]:find(string.imatch-{list..'$'})) + notice(list..' removed from '..typ..' table.') + end + end + settings:save('all') + elseif S{'fonttype','fontsize','pos','bgcolor','txtcolor'}:contains(comm) then + if comm == 'fonttype' then ohShi_tb:font(args[1] or nil) + elseif comm == 'fontsize' then ohShi_tb:size(args[1] or nil) + elseif comm == 'pos' then ohShi_tb:pos(args[1] or nil,args[2] or nil) + elseif comm == 'bgcolor' then ohShi_tb:bgcolor(args[1] or nil,args[2] or nil,args[3] or nil) + elseif comm == 'txtcolor' then ohShi_tb:color(args[1] or nil,args[2] or nil,args[3] or nil) + end + settings:update(ohShi_tb._settings) + settings.bg.alpha = nil + settings.padding = nil + settings.text.alpha = nil + settings.text.content = nil + settings.visible = nil + saveSettings() + elseif comm == 'clear' then + tracking:clear() + textUpdate() + elseif S{'show','hide','settings'}:contains(comm) then + if comm == 'show' then + ohShi_tb:text('ohShi showing for settings') + ohShi_tb:show() + elseif comm == 'hide' then + settings:update(ohShi_tb._settings) + settings.bg.alpha = nil + settings.padding = nil + settings.text.alpha = nil + settings.text.content = nil + settings.visible = nil + textUpdate() + ohShi_tb:hide() + settings:save('all') + elseif comm == 'settings' then + windower.add_to_chat(207,'OhShi - Current Textbox Settings') + windower.add_to_chat(207,' BG: R: '..settings.bg.red..' G: '..settings.bg.green..' B: '..settings.bg.blue) + windower.add_to_chat(207,' Font: '..settings.text.font..' Size: '..settings.text.size) + windower.add_to_chat(207,' Text: R: '..settings.text.red..' G: '..settings.text.green..' B: '..settings.text.blue) + windower.add_to_chat(207,' Pos: X: '..settings.pos.x..' Y: '..settings.pos.y) + end + else + local helptext = [[OhShi - Command List: + 1. help - Brings up this menu. + 2. showrolls | selfrolls - Show corsair rolls in tracker | only own rolls. + 3. staggeronly - Only show voidwatch stagger notices. + 4. track(on/off) [abyssea/dangerous/legion/meebles/other/voidwatch] <name> + - Begin or stop tracking <type (default: other)> of mob named <name>. + 5. spell/ws(on/off) <name> - Start or stop watching for <name> spell|ws. + 6. clear - Clears the textbox and the tracking table (use if textbox locks up) + The following all correspond to the tracker: + fonttype <name> | fontsize <size> | pos <x> <y> - can also click/drag + bgcolor <r> <g> <b> | txtcolor <r> <g> <b> + duration <time> - Changes the duration things appear in tracker. + settings - shows current textbox settings + show/hide - toggles visibility of the tracker so you can make changes.]] + for _, line in ipairs(helptext:split('\n')) do + windower.add_to_chat(207, line..chat.controls.reset) + end + end + end +end) + +--This event happens when an action packet is received. +windower.register_event('action', function(act) + local curact = T(act) + local actor = T{} + actor.id = curact.actor_id + if windower.ffxi.get_mob_by_id(actor.id) then + actor.name = windower.ffxi.get_mob_by_id(actor.id).name + else + return + end + local extparam = curact.param + local targets = curact.targets + local party = T(windower.ffxi.get_party()) + local typ = '' + local danger = false + local player = T(windower.ffxi.get_player()) + + if not settings.staggeronly then + if settings.showrolls and curact.category == 6 and res.job_abilities[extparam].type == 'CorsairRoll' then + local allyroller = false + local selfroll = false + for pt,member in pairs(party) do + if type(member) == 'table' and member.name == actor.name then + allyroller = true + break + end + end + if allyroller or selfroll then + if actor.id == player.id then selfroll = true end + if settings.selfrolls and not selfroll then return end + addText(actor.name, 'roll', extparam, targets[1].actions[1].param) + end + elseif isMob(actor.id) and S{7,8}:contains(curact.category) and extparam ~= 28787 then + local inact = targets[1].actions[1] + if curact.category == 8 then typ = 'spell' + else typ = 'ws' end + if (mCheck(actor.name) or dCheck(typ,inact.param)) and inact.message ~= 0 then + addText(actor.name, typ, inact.param, mDanger(actor.name), dCheck(typ,inact.param)) + end + end + end +end) + +--Catches statuses wearing on mobs you applied them to +windower.register_event('action message',function(actor_id, target_id, actor_index, target_index, message_id, param_1, param_2, param_3) + if not settings.staggeronly then + local actor = T(windower.ffxi.get_mob_by_id(actor_id)) + local player = T(windower.ffxi.get_player()) + local target = T(windower.ffxi.get_mob_by_id(target_id)) + if S{204,205,206}:contains(message_id) and isMob(target_id) then + if actor.id == player.id then + if mCheck(target.name) then + if message_id == 204 then + addText(target.name .. ' is no longer ' .. res.buffs[param_1].english_log) + elseif message_id == 205 then + addText(target.name .. ' gains the effect of ' .. res.buffs[param_1].english_log) + else + addText(target.name .. ' ' .. res.buffs[param_1].english_log .. ' effect wears off.') + end + end + end + end + end +end) + +--This event happens whenever text is incoming to the chatlog +windower.register_event('incoming text', function(old,new,color,newcolor) + if string.find(old,'(%w+)\'s attack devastates the fiend%p') then + addText('devastates',string.find(old,'(%w+)\'s attack devastates the fiend%p')) + elseif string.find(old,'Blue: (%d+)%% / Red: (%d+)%%') then + addText('bluered',string.find(old,'Blue: (%d+)%% / Red: (%d+)%%')) + elseif string.find(old,'Blue: (%d+)') then + addText('blue',string.find(old,'Blue: (%d+)')) + elseif string.find(old,'Red: (%d+)') then + addText('red',string.find(old,'Red: (%d+)')) + elseif string.find(old,'The fiend appears(.*)vulnerable to ([%w%s]+)!') then + addText('vulnerable',string.find(old,'The fiend appears(.*)vulnerable to ([%w%s]+)!')) + elseif string.find(old,'(%w+) is the key to victory!') then + addText('victory',string.find(old,'(%w+) is the key to victory')) + end +end) diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/text_handling.lua b/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/text_handling.lua new file mode 100644 index 0000000..fb0d56e --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/ohShi/text_handling.lua @@ -0,0 +1,145 @@ +--[[ +Copyright (c) 2013, Ricky Gall +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of <addon name> 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 <your name> 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. +]] + +texts = require 'texts' + +--Create the textbox +function initText() + ohShi_tb = texts.new(settings) + tracking:append('ohShi initialized ') + textUpdate() + coroutine.schedule(remText, settings.duration or 7) +end + +--Removes first line of a textbox +function remText() + if tracking:length() > 0 then + table.remove(tracking,1) + textUpdate() + end +end + +--Add text to textbox. Anytime text is added this is called. +function addText(name, abtype, abil, dMob, dangerous) + if tracking:length() > 9 then + tracking:clear() + textUpdate() + end + if abtype == 'ws' then + abil = tonumber(abil) + doit = true + if abil <= 255 then + abilname = res.weapon_skills[abil].english + else + abilname = res.monster_abilities[abil].english + end + elseif abtype == 'spell' then + abil = tonumber(abil) + doit = true + abilname = res.spells[abil].english + elseif abtype == 'roll' then + abil = tonumber(abil) + doit = true + abilname = res.job_abilities[abil].english .. ' [' .. dMob .. ']' + dMob = nil + dangerous = nil + elseif name == 'vulnerable' then + if dMob == ' extremely ' then + tracking:append(' \\cs(255,100,100)Weakness 5: '..dangerous:capitalize()..'\\cr') + elseif dMob == ' highly ' then + tracking:append(' \\cs(255,100,100)Weakness 3: '..dangerous:capitalize()..'\\cr') + else + tracking:append(' Weakness 1: '..dangerous:capitalize()) + end + elseif name == 'bluered' then + tracking:append(' Blue: '..dMob..'% Red: '..dangerous..'%') + elseif name == 'red' then + tracking:append(' Red: '..dMob..'%') + elseif name == 'blue' then + tracking:append(' Blue: '..dMob..'%') + elseif name == 'devastates' then + tracking:append(' Fiend devastated by: '..dMob) + elseif name == 'victory' then + tracking:append(' Key to Victory: '..dMob) + else + tracking:append(' '..name) + end + if doit then + local str = name..': '..abilname + if dangerous or dMob then + tracking:append(' \\cs(255,100,100)'..str..'\\cr') + flashImage() + else + tracking:append(' '..str) + end + end + coroutine.schedule(remText, settings.duration or 7) + textUpdate() +end + +--Called anytime text is added to the tracking table +--Refreshes the textbox and hides/shows it if needed. +function textUpdate() + if #tracking > 0 then + local txt = '' + for inc = 1, #tracking do + txt = txt..tracking[inc] + if inc < #tracking then + txt = txt..'\n' + end + end + ohShi_tb:text(txt) + ohShi_tb:show() + else + ohShi_tb:text('') + ohShi_tb:hide() + end +end + +--image handling +--This function is used to flash the warning image +--when a danger tp/spell is used. +function flashImage() + local name = 'ohShi'..tostring(math.random(10000000,99999999)) + prims:add(name) + windower.prim.create(name) + windower.prim.set_color(name,255,255,255,255) + windower.prim.set_fit_to_texture(name,false) + windower.prim.set_texture(name,windower.addon_path..'data/warning.png') + windower.prim.set_repeat(name,1,1) + windower.prim.set_visibility(name,true) + windower.prim.set_position(name,settings.pos.x-30,settings.pos.y-10) + windower.prim.set_size(name,30,30) + coroutine.schedule(deleteImage:prepare(name), settings.duration or 7) +end + +--Called to delete the image after it's time is up. +function deleteImage(str) + prims:remove(str) + windower.prim.delete(str) +end |