From a827f9214eb8e6c6ad9ae0f81fd4f4621c8045fb Mon Sep 17 00:00:00 2001 From: KenshiDRK Date: Sat, 13 Mar 2021 22:46:15 +0100 Subject: [PATCH 1/5] [Battlemod] Singular/Plural addition Added singular/plural handling. Added common/proper noum handling. Added quantity of items for message id 377 (Treasury autostack option sometimes interfere with it). Some minor changes. --- addons/battlemod/battlemod.lua | 89 ++++++++++--- addons/battlemod/generic_helpers.lua | 163 +++++++++++++++++++++++ addons/battlemod/parse_action_packet.lua | 153 +++++++++++++++++---- addons/battlemod/statics.lua | 14 +- 4 files changed, 370 insertions(+), 49 deletions(-) diff --git a/addons/battlemod/battlemod.lua b/addons/battlemod/battlemod.lua index fdf1a25966..ca551b9827 100644 --- a/addons/battlemod/battlemod.lua +++ b/addons/battlemod/battlemod.lua @@ -12,7 +12,7 @@ require 'generic_helpers' require 'parse_action_packet' require 'statics' -_addon.version = '3.29' +_addon.version = '3.30' _addon.name = 'BattleMod' _addon.author = 'Byrth, maintainer: SnickySnacks' _addon.commands = {'bm','battlemod'} @@ -24,7 +24,7 @@ end) windower.register_event('login',function (name) if debugging then windower.debug('login') end - windower.send_command('@wait 10;lua i battlemod options_load;') + options_load:schedule(10) end) windower.register_event('addon command', function(command, ...) @@ -149,12 +149,10 @@ windower.register_event('incoming text',function (original, modified, color, col local item = string.char(0x1E) if not bm_message(original) then if original:endswith(endline) then --allow add_to_chat messages with the modes we blocking - blocked = true - return blocked + return true end elseif original:endswith(endline) and string.find(original, item) then --block items action messages - blocked = true - return blocked + return true end end @@ -251,9 +249,42 @@ ActionPacket.open_listener(parse_action_packet) windower.register_event('incoming chunk',function (id,original,modified,is_injected,is_blocked) if debugging then windower.debug('incoming chunk '..id) end + +------- ITEM QUANTITY ------- + if id == 0x020 and parse_quantity then + --local packet = packets.parse('incoming', original) + local item = original:unpack("H",0x0D) + local count = original:unpack("I",0x05) + if item == 0 then return end + if item_quantity.id == item then + item_quantity.count = count..' ' + end -------- ACTION MESSAGE ------- - if id == 0x29 then +------- NOUNS AND PLURAL ENTITIES ------- + elseif id == 0x00E then + local mob_id = original:unpack("I",0x05) + local mask = original:unpack("C",0x0B) + local chat_info = original:unpack("C",0x28) + if bit.band(mask,4) == 4 then + if bit.band(chat_info,32) == 0 and not common_nouns:contains(mob_id) then + table.insert(common_nouns, mob_id) + elseif bit.band(chat_info,64) == 64 and not plural_entities:contains(mob_id) then + table.insert(plural_entities, mob_id) + elseif bit.band(chat_info,64) == 0 and plural_entities:contains(mob_id) then --Gears can change their grammatical number when they lose 2 gear? + for i, v in pairs(plural_entities) do + if v == mob_id then + table.remove(plural_entities, i) + break + end + end + end + end + elseif id == 0x00B then --Reset tables on Zoning + common_nouns = T{} + plural_entities = T{} + +------- ACTION MESSAGE ------- + elseif id == 0x29 then local am = {} am.actor_id = original:unpack("I",0x05) am.target_id = original:unpack("I",0x09) @@ -266,6 +297,9 @@ windower.register_event('incoming chunk',function (id,original,modified,is_injec local actor = player_info(am.actor_id) local target = player_info(am.target_id) + local actor_article = common_nouns:contains(am.actor_id) and 'The ' or '' + local target_article = common_nouns:contains(am.target_id) and 'The ' or '' + targets_condensed = false -- Filter these messages if not check_filter(actor,target,0,am.message_id) then return true end @@ -284,9 +318,16 @@ windower.register_event('incoming chunk',function (id,original,modified,is_injec windower.add_to_chat(color, msg) else local msg = res.action_messages[am.message_id][language] + if plural_entities:contains(am.actor_id) then + msg = plural_actor(msg) + end + if plural_entities:contains(am.target_id) then + msg = plural_target(msg) + end + local msg = clean_msg(msg :gsub('${status}',status or '') - :gsub('${target}',targ) - :gsub('${number}',number or '') + :gsub('${target}',target_article..targ) + :gsub('${number}',number or '')) windower.add_to_chat(color, msg) end elseif am.message_id == 206 and condensetargets then -- Wears off messages @@ -307,7 +348,7 @@ windower.register_event('incoming chunk',function (id,original,modified,is_injec if not multi_targs[status] and not stat_ignore:contains(am.param_1) then multi_targs[status] = {} multi_targs[status][1] = target - windower.send_command('@wait 0.5;lua i battlemod multi_packet '..status) + multi_packet:schedule(0.5, status) elseif not (stat_ignore:contains(am.param_1)) then multi_targs[status][#multi_targs[status]+1] = target else @@ -315,16 +356,23 @@ windower.register_event('incoming chunk',function (id,original,modified,is_injec -- Sneak, Invis, etc. that you don't want to see on a delay multi_targs[status] = {} multi_targs[status][1] = target - windower.send_command('@lua i battlemod multi_packet '..status) + multi_packet(status) end am.message_id = false elseif passed_messages:contains(am.message_id) then local item,status,spell,skill,number,number2 + local outstr = res.action_messages[am.message_id][language] + if plural_entities:contains(am.actor_id) then + outstr = plural_actor(outstr) + end + if plural_entities:contains(am.target_id) then + outstr = plural_target(outstr) + end - local fields = fieldsearch(res.action_messages[am.message_id][language]) + local fields = fieldsearch(outstr) if fields.status then - if log_form_debuffs:contains(am.param_1) then + if log_form_messages:contains(am.message_id) then status = res.buffs[am.param_1].english_log else status = nf(res.buffs[am.param_1],language) @@ -369,17 +417,17 @@ windower.register_event('incoming chunk',function (id,original,modified,is_injec skill = 'to be level '..am.param_1..' ('..ratings_arr[am.param_2-63]..')' end end - local outstr = (res.action_messages[am.message_id][language] - :gsub('$\123actor\125',color_it((actor.name or '') .. (actor.owner_name or ""),color_arr[actor.owner or actor.type])) + outstr = (clean_msg(outstr + :gsub('$\123actor\125',actor_article..color_it((actor.name or '') .. (actor.owner_name or ""),color_arr[actor.owner or actor.type])) :gsub('$\123status\125',status or '') :gsub('$\123item\125',color_it(item or '',color_arr.itemcol)) - :gsub('$\123target\125',color_it(target.name or '',color_arr[target.owner or target.type])) + :gsub('$\123target\125',target_article..color_it(target.name or '',color_arr[target.owner or target.type])) :gsub('$\123spell\125',color_it(spell or '',color_arr.spellcol)) :gsub('$\123skill\125',color_it(skill or '',color_arr.abilcol)) :gsub('$\123number\125',number or '') :gsub('$\123number2\125',number2 or '') :gsub('$\123skill\125',skill or '') - :gsub('$\123lb\125','\7')) + :gsub('$\123lb\125','\7'))) windower.add_to_chat(res.action_messages[am.message_id]['color'],outstr) am.message_id = false elseif debugging and res.action_messages[am.message_id] then @@ -429,9 +477,10 @@ end) function multi_packet(...) local ind = table.concat({...},' ') local targets = assemble_targets(multi_actor[ind],multi_targs[ind],0,multi_msg[ind]) - local outstr = res.action_messages[multi_msg[ind]][language] + local outstr = targets_condensed and plural_target(res.action_messages[multi_msg[ind]][language]) or res.action_messages[multi_msg[ind]][language] + outstr = clean_msg(outstr :gsub('$\123target\125',targets) - :gsub('$\123status\125',ind) + :gsub('$\123status\125',ind)) windower.add_to_chat(res.action_messages[multi_msg[ind]].color,outstr) multi_targs[ind] = nil multi_msg[ind] = nil diff --git a/addons/battlemod/generic_helpers.lua b/addons/battlemod/generic_helpers.lua index 4bb5ef14ca..1759cafcef 100644 --- a/addons/battlemod/generic_helpers.lua +++ b/addons/battlemod/generic_helpers.lua @@ -114,3 +114,166 @@ function check_filter(actor,target,category,msg) return true end + +function actor_noun(msg) + if msg then + msg = msg + :gsub('${actor}', 'The ${actor}') + end + return msg +end + +function plural_actor(msg) + if msg then + msg = msg + :gsub('${actor} hits ', '${actor} hit ') + :gsub('${actor} casts ', '${actor} cast ') + :gsub('${actor} starts ', '${actor} start ') + :gsub('${actor} defeats ', '${actor} defeat ') + :gsub('${actor} gains ', '${actor} gain ') + :gsub('${actor} attains ', '${actor} attain ') + :gsub('${actor} loses ', '${actor} lose ') + :gsub('${actor} falls ', '${actor} fall ') + :gsub("${actor}'s ", '${actor} ') + :gsub('${actor} misses ' , '${actor} miss ') + :gsub('${actor} calls ' , '${actor} call ') + :gsub('${actor} learns ' , '${actor} learn ') + :gsub('${actor} uses ' , '${actor} use ') + :gsub('${actor} is ' , '${actor} are ') + :gsub('${actor} takes ' , '${actor} take ') + :gsub('${actor} does ' , '${actor} do ') + :gsub('${actor} lacks ' , '${actor} lack ') + :gsub('${actor} redies ' , '${actor} ready ') + :gsub('${actor} earns ' , '${actor} earn ') + :gsub('${actor} scores ' , '${actor} score ') + :gsub('${actor} successfully removes ' , '${actor} successfully remove ') + :gsub('${actor} achieves ' , '${actor} achieve ') + :gsub('${actor} mugs ' , '${actor} mug ') + :gsub('${actor} steals ' , '${actor} steal ') + :gsub('${actor} fails ' , '${actor} fail ') + :gsub(' but finds nothing' , ' but find nothing') + :gsub(' and finds ${item}' , ' and find ${item}') + :gsub('${actor} recovers ' , '${actor} recover ') + :gsub('${ability}, but misses' , '${ability}, but miss') + :gsub(' but misses ${target}' , ' but miss ${target}') + :gsub('${actor} covers ' , '${actor} cover ') + :gsub('${actor} already has ' , '${actor} already have ') + :gsub('${actor} attempts ' , '${actor} attempt ') + :gsub(' but lacks ' , ' but lack ') + :gsub('${actor} destroys ' , '${actor} destroy ') + :gsub('${actor} absorbs ' , '${actor} absorb ') + :gsub('${actor} eats ' , '${actor} eat ') + :gsub('${actor} leads ' , '${actor} lead ') + :gsub('${actor} has ' , '${actor} have ') + :gsub('${actor} obtains ' , '${actor} obtain ') + :gsub(' and finds ${number}' , ' and find ${number}') + end + return msg +end + +function plural_target(msg) + if msg then + msg = msg + :gsub('${target} takes ', '${target} take ') + :gsub('${target} is ', '${target} are ') + :gsub('${target} recovers ', '${target} recover ') + :gsub("${target}'s ", '${target} ') + :gsub('${target} falls ', '${target} fall ') + :gsub('${target} uses ', '${target} use ') + :gsub('${target} resists', '${target} resist') + :gsub('${target} vanishes', '${target} vanish') + :gsub('${target} receives ', '${target} receive ') + :gsub('${target} seems ${skill}', '${target} seem ${skill}') + :gsub('${lb}It seems to have ', '${lb}They seem to have ') + :gsub('${target} gains ', '${target} gain ') + :gsub('${target} evades', '${target} evade') + :gsub('${target} regains ', '${target} regain ') + :gsub('${target} narrowly escapes ', '${target} narrowly escape ') + :gsub('${target} obtains ', '${target} obtain ') + :gsub('${target} learns ', '${target} learn ') + :gsub('${target} loses ', '${target} lose ') + :gsub('${target} was ', '${target} were ') + :gsub('${target} has ', '${target} have ') + :gsub('${target} completely resists ', '${target} completely resist ') + :gsub('${target} now has ', '${target} now have ') + :gsub('${target} feels ', '${target} feel ') + :gsub('${target} stands ', '${target} stand ') + end + return msg +end + +function clean_msg(msg) + if msg then + msg = msg + :gsub(' The ', ' the ') + msg = msg + :gsub('%. the ', '. The ') + :gsub(': the ', ': The ') + :gsub('! the ', '! The ') + end + return msg +end + +function grammatical_number_fix(msg, number) + if msg then + if number == 1 then + msg = msg + :gsub(' points', ' point') + :gsub('${number} Ballista Points', '${number} Ballista Point') + :gsub('healed of ${number} status ailments', 'healed of ${number} status ailment') + :gsub('magical effects from', 'magical effect from') + else + msg = msg + :gsub(' absorbs', ' absorb') + :gsub(' Petra', ' Petras') + :gsub('disappears', 'disappear') + :gsub('attributes is', 'attributes are') + :gsub('status effect is', 'status effects are') + :gsub('piece', 'pieces') + :gsub('Finishing move now ', 'Finishing moves now ') + end + end + return msg +end + +function item_article_fix(id,id2,msg) + if id then + if string.gmatch(msg, ' a ${item}') then + local article = res.items_grammar[id] and res.items_grammar[id].article + if article == 1 then + msg = string.gsub(msg,' a ${item}',' an ${item}') + end + end + end + if id2 then + if string.gmatch(msg, ' a ${item2}') then + local article = res.items_grammar[id2] and res.items_grammar[id2].article + if article == 1 then + msg = string.gsub(msg,' a ${item2}',' an ${item2}') + end + end + end + return msg +end + +function add_item_article(id) + local article = '' + local article_type = res.items_grammar[id] and res.items_grammar[id].article or nil + if id then + if article_type == 2 then + article = 'pair of ' + elseif article_type == 3 then + article = 'suit of ' + end + end + return article +end + +function send_delayed_message(color,msg) + local message = msg + :gsub('${count}', item_quantity.count) + windower.add_to_chat(color,message) + item_quantity.id = 0 + item_quantity.count = '' + parse_quantity = false +end diff --git a/addons/battlemod/parse_action_packet.lua b/addons/battlemod/parse_action_packet.lua index 83f2f09b85..99352f45db 100644 --- a/addons/battlemod/parse_action_packet.lua +++ b/addons/battlemod/parse_action_packet.lua @@ -11,6 +11,7 @@ function parse_action_packet(act) act.actor = player_info(act.actor_id) act.action = get_spell(act) -- Pulls the resources line for the action act.actor.name = act.actor and act.actor.name and string.gsub(act.actor.name,'-', string.char(0x81,0x7C)) --fix for ffxi chat splits on trusts with - + targets_condensed = false if not act.action then return act @@ -190,7 +191,7 @@ function parse_action_packet(act) elseif m.message == 435 or m.message == 436 then m.simp_name = act.action.name..' (JAs)' elseif m.message == 437 or m.message == 438 then m.simp_name = act.action.name..' (JAs and TP)' elseif m.message == 439 or m.message == 440 then m.simp_name = act.action.name..' (SPs, JAs, TP, and MP)' - elseif T{252,265,268,269,271,272,274,275,379,650}:contains(m.message) then m.simp_name = 'Magic Burst! '..act.action.name + elseif T{252,265,268,269,271,272,274,275,379,650,747}:contains(m.message) then m.simp_name = 'Magic Burst! '..act.action.name elseif not act.action then m.simp_name = '' act.action = {} @@ -216,8 +217,13 @@ function parse_action_packet(act) elseif m.status == 'weight' then m.status = 'weighed down' end end + + -- Some messages uses the english log version of the buff + if not simplify and log_form_messages:contains(m.message) then + m.status = res.buffs[m.param].enl + end --- if m.message == 93 or m.message == 273 then m.status=color_it('Vanish',color_arr['statuscol']) end + -- if m.message == 93 or m.message == 273 then m.status=color_it('Vanish',color_arr['statuscol']) end -- Special Message Handling if m.message == 93 or m.message == 273 then @@ -230,6 +236,10 @@ function parse_action_packet(act) targ = targ..' ('..color_it('attacks and defenses enhanced',color_arr['statuscol'])..')' elseif m.message == 762 and simplify then targ = targ..' ('..color_it('all status parameters boosted',color_arr['statuscol'])..')' + elseif m.message == 779 and simplify then + targ = 'A barrier pulsates around '..targ + elseif m.message == 780 and simplify then + targ = 'Takes aim on '..targ elseif T{158,188,245,324,592,658}:contains(m.message) and simplify then -- When you miss a WS or JA. Relevant for condensed battle. m.status = 'Miss' --- This probably doesn't work due to the if a==nil statement below. @@ -268,6 +278,32 @@ function parse_action_packet(act) end end + if col == 'D' or grammar_numb_msg:contains(m.message) then + msg = grammatical_number_fix(msg, (m.cparam or m.param)) + end + + local count = '' + if m.message == 377 and act.actor_id == Self.id then + parse_quantity = true + item_quantity.id = act.action.item2_id + count = '${count}' + end + + if not simplify then + if act.action.item_id or act.action.item2_id then + msg = item_article_fix(act.action.item_id,act.action.item2_id,msg) + end + if common_nouns:contains(act.actor.id) then + msg = actor_noun(msg) + end + if plural_entities:contains(act.actor.id) then + msg = plural_actor(msg) + end + if targets_condensed or plural_entities:contains(v.target[1].id) then + msg = plural_target(msg) + end + end + local reaction_lookup = reaction_offsets[act.category] and (m.reaction - reaction_offsets[act.category]) or 0 local has_line_break = string.find(res.action_messages[m.message].en, '${lb}') and true or false local prefix = (not has_line_break or simplify) and S{1,3,4,6,11,13,14,15}:contains(act.category) and (bit.band(m.unknown,1)==1 and "Cover! " or "") @@ -285,11 +321,11 @@ function parse_action_packet(act) ..(reaction_lookup == 4 and "Blocked! " or "") ..(reaction_lookup == 2 and "Guarded! " or "") ..(reaction_lookup == 3 and S{3,4,6,11,13,14,15}:contains(act.category) and "Parried! " or "") or "" --Unused? They are send the same as missed - windower.add_to_chat(color,prefix..make_condensedamage_number(m.number)..( (msg or tostring(m.message)) + local message = prefix..make_condensedamage_number(m.number)..( clean_msg((msg or tostring(m.message)) :gsub('${spell}',color_it(act.action.spell or 'ERROR 111',color_arr.spellcol)) :gsub('${ability}',color_it(act.action.ability or 'ERROR 112',color_arr.abilcol)) :gsub('${item}',color_it(act.action.item or 'ERROR 113',color_arr.itemcol)) - :gsub('${item2}',color_it(act.action.item2 or 'ERROR 121',color_arr.itemcol)) + :gsub('${item2}',count..color_it(act.action.item2 or 'ERROR 121',color_arr.itemcol)) :gsub('${weapon_skill}',color_it(act.action.weapon_skill or 'ERROR 114',color_arr.wscol)) :gsub('${abil}',m.simp_name or 'ERROR 115') :gsub('${numb}',numb or 'ERROR 116') @@ -299,6 +335,11 @@ function parse_action_packet(act) :gsub('${number}',act.action.number or m.param) :gsub('${status}',m.status or 'ERROR 120') :gsub('${gil}',m.param..' gil'))) + if m.message == 377 and act.actor_id == Self.id then + send_delayed_message:schedule(0.5,color,message) + else + windower.add_to_chat(color,message) + end if not non_block_messages:contains(m.message) then m.message = 0 end @@ -311,16 +352,20 @@ function parse_action_packet(act) elseif m.add_effect_message > 384 and m.add_effect_message < 399 then m.simp_add_name = skillchain_arr[m.add_effect_message-384] elseif m.add_effect_message > 766 and m.add_effect_message < 769 then m.simp_add_name = skillchain_arr[m.add_effect_message-752] elseif m.add_effect_message > 768 and m.add_effect_message < 771 then m.simp_add_name = skillchain_arr[m.add_effect_message-754] - elseif m.add_effect_message ==603 then m.simp_add_name = 'TH' - elseif m.add_effect_message ==776 then m.simp_add_name = 'AE: Chainbound' + elseif m.add_effect_message == 603 then m.simp_add_name = 'AE: TH' + elseif m.add_effect_message == 605 then m.simp_add_name = 'AE: Death' + elseif m.add_effect_message == 776 then m.simp_add_name = 'AE: Chainbound' else m.simp_add_name = 'AE' end local msg,numb = simplify_message(m.add_effect_message) + if not simplify and common_nouns:contains(act.actor.id) then + msg = actor_noun(msg) + end if m.add_effect_fields.status then numb = m.add_effect_status else numb = pref_suf((m.cadd_effect_param or m.add_effect_param),m.add_effect_message,act.actor.damage,col) end if not act.action then -- windower.add_to_chat(color, 'act.action==nil : '..m.message..' - '..m.add_effect_message..' - '..msg) else - windower.add_to_chat(color,make_condensedamage_number(m.add_effect_number)..(msg + windower.add_to_chat(color,make_condensedamage_number(m.add_effect_number)..(clean_msg(msg :gsub('${spell}',act.action.spell or 'ERROR 127') :gsub('${ability}',act.action.ability or 'ERROR 128') :gsub('${item}',act.action.item or 'ERROR 129') @@ -331,7 +376,7 @@ function parse_action_packet(act) :gsub('${target}',targ) :gsub('${lb}','\7') :gsub('${number}',m.add_effect_param) - :gsub('${status}',m.add_effect_status or 'ERROR 178'))) + :gsub('${status}',m.add_effect_status or 'ERROR 178')))) if not non_block_messages:contains(m.add_effect_message) then m.add_effect_message = 0 end @@ -361,8 +406,11 @@ function parse_action_packet(act) end local msg = simplify_message(m.spike_effect_message) + if not simplify and common_nouns:contains(act.actor.id) then + msg = actor_noun(msg) + end if m.spike_effect_fields.status then numb = m.spike_effect_status else numb = pref_suf((m.cspike_effect_param or m.spike_effect_param),m.spike_effect_message,actor.damage,col) end - windower.add_to_chat(color,make_condensedamage_number(m.spike_effect_number)..(msg + windower.add_to_chat(color,make_condensedamage_number(m.spike_effect_number)..(clean_msg(msg :gsub('${spell}',act.action.spell or 'ERROR 142') :gsub('${ability}',act.action.ability or 'ERROR 143') :gsub('${item}',act.action.item or 'ERROR 144') @@ -373,10 +421,10 @@ function parse_action_packet(act) :gsub((simplify and '${actor}' or '${target}'),targ) :gsub('${lb}','\7') :gsub('${number}',m.spike_effect_param) - :gsub('${status}',m.spike_effect_status or 'ERROR 150'))) - if not non_block_messages:contains(m.spike_effect_message) then - m.spike_effect_message = 0 - end + :gsub('${status}',m.spike_effect_status or 'ERROR 150')))) + if not non_block_messages:contains(m.spike_effect_message) then + m.spike_effect_message = 0 + end end end end @@ -386,11 +434,44 @@ end function pref_suf(param,msg_ID,actor_dmg,col) local outstr = (col == 'D' or dmg_drain_msg:contains(msg_ID)) and color_it(tostring(param),color_arr[actor_dmg]) or tostring(param) - if res.action_messages[msg_ID] and res.action_messages[msg_ID].prefix then - outstr = res.action_messages[msg_ID].prefix..' '..outstr - end - if res.action_messages[msg_ID] and res.action_messages[msg_ID].suffix then - outstr = outstr..' '..res.action_messages[msg_ID].suffix + local msg = res.action_messages[msg_ID] or nil + if msg then + if msg.prefix then + outstr = msg.prefix..' '..outstr + end + if msg.suffix then + if msg.suffix == 'shadow' and param ~= 1 then + outstr = outstr..' shadows' + elseif msg.suffix == 'Petra' and param ~= 1 then + outstr = outstr..' Petras' + elseif msg.suffix == 'effects disappears' and param ~= 1 then + outstr = outstr..' effects disappear' + elseif msg_ID == 641 then + outstr = outstr..' 1 attribute drained' + elseif msg.suffix == 'attributes drained' and param == 1 then + outstr = outstr..' attribute drained' + elseif msg.suffix == 'status effect drained' and param ~= 1 then + outstr = outstr..' status effects drained' + elseif msg.suffix == 'status ailments disappears' and param ~= 1 then + outstr = outstr..' status ailments disappear' + elseif msg.suffix == 'status ailments absorbed' and param == 1 then + outstr = outstr..' status ailment absorbed' + elseif msg.suffix == 'status ailments healed' and param == 1 then + outstr = outstr..' status ailment healed' + elseif msg.suffix == 'status benefits absorbed' and param == 1 then + outstr = outstr..' status benefit absorbed' + elseif msg.suffix == 'status effects removed' and param == 1 then + outstr = outstr..' status effect removed' + elseif msg.suffix == 'magic effects drained' and param == 1 then + outstr = outstr..' magic effect drained' + elseif msg.suffix == 'magical effects received' and param == 1 then + outstr = outstr..' magical effect received' + elseif msg.suffix == 'magical effects copied' and param == 1 then + outstr = outstr..' magical effect copied' + else + outstr = outstr..' '..msg.suffix + end + end end return outstr end @@ -399,7 +480,7 @@ function simplify_message(msg_ID) local msg = res.action_messages[msg_ID][language] local fields = fieldsearch(msg) - if simplify and not T{23,64,133,139,140,204,210,211,212,213,214,350,442,516,531,557,565,582,674}:contains(msg_ID) then + if simplify and not T{23,64,133,204,210,211,212,213,214,350,442,516,531,557,565,582}:contains(msg_ID) then if T{93,273,522,653,654,655,656,85,284,75,114,156,189,248,283,312,323,336,351,355,408,422,423,425,453,659,158,245,324,658}:contains(msg_ID) then fields.status = true end @@ -420,6 +501,10 @@ function simplify_message(msg_ID) fields.actor = true fields.target = true end + + if msg_ID == 139 then + fields.number = true + end local Despoil_msg = {[593] = 'Attack Down', [594] = 'Defense Down', [595] = 'Magic Atk. Down', [596] = 'Magic Def. Down', [597] = 'Evasion Down', [598] = 'Accuracy Down', [599] = 'Slow',} if line_full and fields.number and fields.target and fields.actor then @@ -485,13 +570,20 @@ function assemble_targets(actor,targs,category,msg) for i,v in pairs(targets) do local name + local article = common_nouns:contains(v.id) and not simplify and 'The ' or '' local numb = condensetargetname and samename[v.name] > 1 and ' {'..samename[v.name]..'}' or '' if i == 1 then name = color_it(v.name,color_arr[v.owner or v.type]) - out_str = out_str..name..numb + out_str = out_str..article..name..numb + if samename[v.name] > 1 then + targets_condensed = true + else + targets_condensed = false + end else + targets_condensed = true name = color_it(v.name,color_arr[v.owner or v.type]) - out_str = conjunctions(out_str,name..numb,#targets,i) + out_str = conjunctions(out_str,article..name..numb,#targets,i) end end out_str = string.gsub(out_str,'-', string.char(0x81,0x7C)) --fix for ffxi chat splits on trusts with - @@ -659,6 +751,9 @@ function get_spell(act) if spell then spell.name = color_it(spell[language],color_arr.abilcol) spell.ability = color_it(spell[language],color_arr.abilcol) + if msg_ID == 139 then + spell.number = 'Nothing' + end end elseif fields.weapon_skill then if abil_ID > 256 then -- WZ_RECOVER_ALL is used by chests in Limbus @@ -707,19 +802,25 @@ function get_spell(act) if fields.item then if T{125,593,594,595,596,597,598,599}:contains(msg_ID) then - spell.item = color_it(res.items[effect_val]['english_log'], color_arr.itemcol) + local item_article = not simplify and add_item_article(effect_val) or '' + spell.item = color_it(item_article..res.items[effect_val]['english_log'], color_arr.itemcol) + spell.item_id = res.items[effect_val].id else spell = res.items[abil_ID] + local item_article = not simplify and add_item_article(spell.id) or '' if spell then - spell.name = color_it(spell['english_log'],color_arr.itemcol) - spell.item = color_it(spell['english_log'],color_arr.itemcol) + spell.name = color_it(item_article..spell['english_log'],color_arr.itemcol) + spell.item = color_it(item_article..spell['english_log'],color_arr.itemcol) + spell.item_id = abil_ID end end end if fields.item2 then - local tempspell = res.items[effect_val] - spell.item2 = color_it(tempspell.english_log,color_arr.itemcol) + local item_article = not simplify and add_item_article(effect_val) or '' + local tempspell = (msg_ID == 377 or msg_ID == 674) and res.items_grammar[effect_val] and res.items_grammar[effect_val].plural or item_article..res.items[effect_val].english_log + spell.item2 = color_it(tempspell,color_arr.itemcol) + spell.item2_id = effect_val if fields.number then spell.number = act.targets[1].actions[1].add_effect_param end diff --git a/addons/battlemod/statics.lua b/addons/battlemod/statics.lua index 20b9a80815..436b376165 100644 --- a/addons/battlemod/statics.lua +++ b/addons/battlemod/statics.lua @@ -28,15 +28,21 @@ skillchain_arr = {'Light:','Darkness:','Gravitation:','Fragmentation:','Distorti ratings_arr = {'TW','IEP','EP','DC','EM','T','VT','IT'} current_job = 'NONE' default_filt = false +parse_quantity = false +targets_condensed = false +common_nouns = T{} +plural_entities = T{} +item_quantity = {id = 0, count = ''} rcol = string.char(0x1E,0x01) non_block_messages = T{1,2,7,14,15,24,25,26,30,31,32,33,44,63,67,69,70,77,102,103,110,122,132,152,157,158,161,162,163,165,167,185,187,188,196,197,223,224,225,226,227,228,229,238,245,252,263,264,265,274,275,276,281,282,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,306,317,318,324,352,353,354,357,358,366,367,373,379,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,409,413,451,452,454,522,535,536,537,539,576,577,587,588,592,603,606,648,650,651,658,732,736,746,747,748,749,750,751,752,753,767,768,769,770,781} -passed_messages = T{4,5,6,16,17,18,20,34,35,36,40,47,48,49,64,78,87,88,89,90,112,116,154,170,171,172,173,174,175,176,177,178,191,192,198,204,215,217,218,219,234,246,249,307,315,328,350,336,523,530,531,558,561,563,575,584,601,609,562,610,611,612,613,614,615,616,617,618,619,620,625,626,627,628,629,630,631,632,633,634,635,636,643,660,661,662,62,94,251,308,313,372,8,105,253,679,97,62,94,251,313,308,206,72,38,53} +passed_messages = T{4,5,6,16,17,18,20,34,35,36,38,40,47,48,49,53,62,64,72,78,87,88,89,90,94,97,112,116,154,170,171,172,173,174,175,176,177,178,191,192,198,204,206,215,217,218,219,234,246,249,251,307,308,313,315,328,336,350,523,530,531,558,561,563,575,584,601,609,562,610,611,612,613,614,615,616,617,618,619,620,625,626,627,628,629,630,631,632,633,634,635,636,643,660,661,662,679} agg_messages = T{85,653,655,75,156,189,248,323,355,408,422,425,82,93,116,127,131,134,151,144,146,148,150,166,186,194,230,236,237,242,243,268,271,319,320,364,375,412,414,416,420,424,426,432,433,441,602,645,668,435,437,439} color_redundant = T{26,33,41,71,72,89,94,109,114,164,173,181,184,186,70,84,104,127,128,129,130,131,132,133,134,135,136,137,138,139,140,64,86,91,106,111,175,178,183,81,101,16,65,87,92,107,112,174,176,182,82,102,67,68,69,170,189,15,208,18,25,32,40,163,185,23,24,27,34,35,42,43,162,165,187,188,30,31,14,205,144,145,146,147,148,149,150,151,152,153,190,13,9,253,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,284,285,286,287,292,293,294,295,300,301,301,303,308,309,310,311,316,317,318,319,324,325,326,327,332,333,334,335,340,341,342,343,344,345,346,347,348,349,350,351,355,357,358,360,361,363,366,369,372,374,375,378,381,384,395,406,409,412,415,416,418,421,424,437,450,453,456,458,459,462,479,490,493,496,499,500,502,505,507,508,10,51,52,55,58,62,66,80,83,85,88,90,93,100,103,105,108,110,113,122,168,169,171,172,177,179,180,12,11,37,291} -- 37 and 291 might be unique colors, but they are not gsubbable. block_messages = T{12} block_modes = T{20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,40,41,42,43,56,57,59,60,61,63,104,109,114,162,163,164,165,181,185,186,187,188} black_colors = T{}--352,354,356,388,390,400,402,430,432,442,444,472,474,484,486} dmg_drain_msg = T{132,161,187,227,274,281,736,748,749,802,803} +grammar_numb_msg = T{14,31,133,231,369,370,382,385,386,387,388,389,390,391,392,393,394,395,396,397,398,400,401,403,404,405,411,417,535,536,557,570,571,589,607,651,757,769,770,778,792} domain_buffs = S{ 250, -- EF Badge @@ -176,8 +182,9 @@ message_map[369] = T{403} -- Ultimate Terror spike_effect_valid = {true,false,false,false,false,false,false,false,false,false,false,false,false,false,false} add_effect_valid = {true,true,true,true,false,false,false,false,false,false,true,false,true,false,false} --- These are the debuffs that are expressed in their log form by battlemod -log_form_debuffs = T{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,28,29,30,31,134,135,155,156,157,168,176,177,259,260,261,262,263,264,309,474} +-- These are the debuffs that are expressed in their log form by battlemod (The status variable when using english log is code 14 while the other one is code 13 so it should be handled by messages) +--log_form_debuffs = T{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,28,29,30,31,134,135,155,156,157,168,176,177,259,260,261,262,263,264,309,474} +log_form_messages = T{64,73,82,127,128,130,141,203,204,236,242,270,271,272,277,279,350,374,531,645,754} default_filters = [[ @@ -542,6 +549,7 @@ default_settings = [[ ${numb} ]]..string.char(129,168)..[[ ${target} ${abil} ${numb} ]]..string.char(129,168)..[[ ${target} [${actor}] ${abil} ]]..string.char(129,168)..[[ ${target} + [${actor}] ${abil} ]]..string.char(129,168)..[[ ${number} ${actor} ${abil} ]]..string.char(129,168)..[[ ${target} ]]..string.char(129,170)..[[ ${number} From 5820f9203b421c5a4b2f7de92757bc1ad159f0fc Mon Sep 17 00:00:00 2001 From: KenshiDRK Date: Wed, 17 Mar 2021 03:06:51 +0100 Subject: [PATCH 2/5] fixing a bug fixing a bug --- addons/battlemod/parse_action_packet.lua | 2 +- addons/battlemod/statics.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/battlemod/parse_action_packet.lua b/addons/battlemod/parse_action_packet.lua index 99352f45db..596ac6e2f1 100644 --- a/addons/battlemod/parse_action_packet.lua +++ b/addons/battlemod/parse_action_packet.lua @@ -199,7 +199,7 @@ function parse_action_packet(act) end -- Debuff Application Messages - if message_map[82]:contains(m.message) then + if simplify and message_map[82]:contains(m.message) then if m.status == 'Evasion Down' then m.message = 237 end diff --git a/addons/battlemod/statics.lua b/addons/battlemod/statics.lua index 436b376165..4c64889b2d 100644 --- a/addons/battlemod/statics.lua +++ b/addons/battlemod/statics.lua @@ -134,7 +134,7 @@ message_map[75] = T{283} -- No Effect: Spell, Target message_map[248] = T{355} -- no ability of any kind message_map['No effect'] = T{283,423,659} -- generic "no effect" messages for sorting by category message_map[432] = T{433} -- Receives: Spell, Target -message_map[82] = T{230,236,237,268,271} -- Receives: Spell, Target, Status +message_map[82] = T{230,236,237,267,268,271} -- Receives: Spell, Target, Status message_map[230] = T{266} -- Receives: Spell, Target, Status message_map[319] = T{266} -- Receives: Spell, Target, Status (Generic for avatar buff BPs) message_map[134] = T{287} -- Receives: Spell, Target, Status From 380bab58010fe39b60808b06df73342f815b29e2 Mon Sep 17 00:00:00 2001 From: KenshiDRK Date: Wed, 24 Mar 2021 23:29:09 +0100 Subject: [PATCH 3/5] more fixes more fixes --- addons/battlemod/battlemod.lua | 27 ++++++----- addons/battlemod/generic_helpers.lua | 7 +-- addons/battlemod/parse_action_packet.lua | 57 +++++++++++++++++------- 3 files changed, 60 insertions(+), 31 deletions(-) diff --git a/addons/battlemod/battlemod.lua b/addons/battlemod/battlemod.lua index ca551b9827..12b768eb5f 100644 --- a/addons/battlemod/battlemod.lua +++ b/addons/battlemod/battlemod.lua @@ -418,16 +418,18 @@ windower.register_event('incoming chunk',function (id,original,modified,is_injec end end outstr = (clean_msg(outstr - :gsub('$\123actor\125',actor_article..color_it((actor.name or '') .. (actor.owner_name or ""),color_arr[actor.owner or actor.type])) - :gsub('$\123status\125',status or '') - :gsub('$\123item\125',color_it(item or '',color_arr.itemcol)) - :gsub('$\123target\125',target_article..color_it(target.name or '',color_arr[target.owner or target.type])) - :gsub('$\123spell\125',color_it(spell or '',color_arr.spellcol)) - :gsub('$\123skill\125',color_it(skill or '',color_arr.abilcol)) - :gsub('$\123number\125',number or '') - :gsub('$\123number2\125',number2 or '') - :gsub('$\123skill\125',skill or '') - :gsub('$\123lb\125','\7'))) + :gsub('${actor}\'s',actor_article..color_it(actor.name or '',color_arr[actor.owner or actor.type])..'\'s'..actor.owner_name) + :gsub('${actor}',actor_article..color_it(actor.name or '',color_arr[actor.owner or actor.type])..actor.owner_name) + :gsub('${status}',status or '') + :gsub('${item}',color_it(item or '',color_arr.itemcol)) + :gsub('${target}\'s',target_article..color_it(target.name or '',color_arr[target.owner or target.type])..'\'s'..target.owner_name) + :gsub('${target}',target_article..color_it(target.name or '',color_arr[target.owner or target.type])..target.owner_name) + :gsub('${spell}',color_it(spell or '',color_arr.spellcol)) + :gsub('${skill}',color_it(skill or '',color_arr.abilcol)) + :gsub('${number}',number or '') + :gsub('${number2}',number2 or '') + :gsub('${skill}',skill or '') + :gsub('${lb}','\7'))) windower.add_to_chat(res.action_messages[am.message_id]['color'],outstr) am.message_id = false elseif debugging and res.action_messages[am.message_id] then @@ -479,8 +481,9 @@ function multi_packet(...) local targets = assemble_targets(multi_actor[ind],multi_targs[ind],0,multi_msg[ind]) local outstr = targets_condensed and plural_target(res.action_messages[multi_msg[ind]][language]) or res.action_messages[multi_msg[ind]][language] outstr = clean_msg(outstr - :gsub('$\123target\125',targets) - :gsub('$\123status\125',ind)) + :gsub('${target}\'s',targets) + :gsub('${target}',targets) + :gsub('${status}',ind)) windower.add_to_chat(res.action_messages[multi_msg[ind]].color,outstr) multi_targs[ind] = nil multi_msg[ind] = nil diff --git a/addons/battlemod/generic_helpers.lua b/addons/battlemod/generic_helpers.lua index 1759cafcef..c3677a0eb2 100644 --- a/addons/battlemod/generic_helpers.lua +++ b/addons/battlemod/generic_helpers.lua @@ -39,9 +39,10 @@ end function colconv(str,key) -- Used in the options_load() function local out - strnum = tonumber(str) + local strnum = tonumber(str) if strnum >= 256 and strnum < 509 then strnum = strnum - 254 + if strnum == 4 then strnum = 3 end --color 258 can bug chatlog out = string.char(0x1E,strnum) elseif strnum >0 then out = string.char(0x1F,strnum) @@ -134,7 +135,7 @@ function plural_actor(msg) :gsub('${actor} attains ', '${actor} attain ') :gsub('${actor} loses ', '${actor} lose ') :gsub('${actor} falls ', '${actor} fall ') - :gsub("${actor}'s ", '${actor} ') + :gsub("${actor}'s ", "${actor}' ") :gsub('${actor} misses ' , '${actor} miss ') :gsub('${actor} calls ' , '${actor} call ') :gsub('${actor} learns ' , '${actor} learn ') @@ -177,7 +178,7 @@ function plural_target(msg) :gsub('${target} takes ', '${target} take ') :gsub('${target} is ', '${target} are ') :gsub('${target} recovers ', '${target} recover ') - :gsub("${target}'s ", '${target} ') + :gsub("${target}'s ", targets_condensed and '${target} ' or "${target}' ") :gsub('${target} falls ', '${target} fall ') :gsub('${target} uses ', '${target} use ') :gsub('${target} resists', '${target} resist') diff --git a/addons/battlemod/parse_action_packet.lua b/addons/battlemod/parse_action_packet.lua index 596ac6e2f1..21bc48d486 100644 --- a/addons/battlemod/parse_action_packet.lua +++ b/addons/battlemod/parse_action_packet.lua @@ -10,7 +10,7 @@ function parse_action_packet(act) end act.actor = player_info(act.actor_id) act.action = get_spell(act) -- Pulls the resources line for the action - act.actor.name = act.actor and act.actor.name and string.gsub(act.actor.name,'-', string.char(0x81,0x7C)) --fix for ffxi chat splits on trusts with - + act.actor.name = act.actor and act.actor.name and string.gsub(act.actor.name,'[- ]', {['-'] = string.char(0x81,0x7C), [' '] = string.char(0x81,0x3F)}) --fix for ffxi chat splits on trusts with - and spaces targets_condensed = false if not act.action then @@ -329,7 +329,9 @@ function parse_action_packet(act) :gsub('${weapon_skill}',color_it(act.action.weapon_skill or 'ERROR 114',color_arr.wscol)) :gsub('${abil}',m.simp_name or 'ERROR 115') :gsub('${numb}',numb or 'ERROR 116') - :gsub('${actor}',color_it((act.actor.name or 'ERROR 117' ) .. (act.actor.owner_name or "") ,color_arr[act.actor.owner or act.actor.type])) + :gsub('${actor}\'s',color_it(act.actor.name or 'ERROR 117',color_arr[act.actor.owner or act.actor.type])..'\'s'..act.actor.owner_name) + :gsub('${actor}',color_it(act.actor.name or 'ERROR 117',color_arr[act.actor.owner or act.actor.type])..act.actor.owner_name) + :gsub('${target}\'s',targ) :gsub('${target}',targ) :gsub('${lb}','\7'..prefix2) :gsub('${number}',act.action.number or m.param) @@ -358,8 +360,16 @@ function parse_action_packet(act) else m.simp_add_name = 'AE' end local msg,numb = simplify_message(m.add_effect_message) - if not simplify and common_nouns:contains(act.actor.id) then - msg = actor_noun(msg) + if not simplify then + if common_nouns:contains(act.actor.id) then + msg = actor_noun(msg) + end + if plural_entities:contains(act.actor.id) then + msg = plural_actor(msg) + end + if targets_condensed or plural_entities:contains(v.target[1].id) then + msg = plural_target(msg) + end end if m.add_effect_fields.status then numb = m.add_effect_status else numb = pref_suf((m.cadd_effect_param or m.add_effect_param),m.add_effect_message,act.actor.damage,col) end if not act.action then @@ -372,7 +382,9 @@ function parse_action_packet(act) :gsub('${weapon_skill}',act.action.weapon_skill or 'ERROR 130') :gsub('${abil}',m.simp_add_name or act.action.name or 'ERROR 131') :gsub('${numb}',numb or 'ERROR 132') - :gsub('${actor}',color_it(act.actor.name,color_arr[act.actor.owner or act.actor.type])) + :gsub('${actor}\'s',color_it(act.actor.name,color_arr[act.actor.owner or act.actor.type])..'\'s'..act.actor.owner_name) + :gsub('${actor}',color_it(act.actor.name,color_arr[act.actor.owner or act.actor.type])..act.actor.owner_name) + :gsub('${target}\'s',targ) :gsub('${target}',targ) :gsub('${lb}','\7') :gsub('${number}',m.add_effect_param) @@ -406,8 +418,16 @@ function parse_action_packet(act) end local msg = simplify_message(m.spike_effect_message) - if not simplify and common_nouns:contains(act.actor.id) then - msg = actor_noun(msg) + if not simplify then + if common_nouns:contains(act.actor.id) then + msg = actor_noun(msg) + end + if plural_entities:contains(act.actor.id) then + msg = plural_actor(msg) + end + if targets_condensed or plural_entities:contains(v.target[1].id) then + msg = plural_target(msg) + end end if m.spike_effect_fields.status then numb = m.spike_effect_status else numb = pref_suf((m.cspike_effect_param or m.spike_effect_param),m.spike_effect_message,actor.damage,col) end windower.add_to_chat(color,make_condensedamage_number(m.spike_effect_number)..(clean_msg(msg @@ -417,7 +437,9 @@ function parse_action_packet(act) :gsub('${weapon_skill}',act.action.weapon_skill or 'ERROR 145') :gsub('${abil}',m.simp_spike_name or act.action.name or 'ERROR 146') :gsub('${numb}',numb or 'ERROR 147') - :gsub((simplify and '${target}' or '${actor}'),color_it(act.actor.name,color_arr[act.actor.owner or act.actor.type])) + :gsub('${actor}\'s',color_it(act.actor.name,color_arr[act.actor.owner or act.actor.type])..'\'s'..act.actor.owner_name) + :gsub((simplify and '${target}' or '${actor}'),color_it(act.actor.name,color_arr[act.actor.owner or act.actor.type])..act.actor.owner_name) + :gsub('${target}\'s',targ) :gsub((simplify and '${actor}' or '${target}'),targ) :gsub('${lb}','\7') :gsub('${number}',m.spike_effect_param) @@ -569,20 +591,23 @@ function assemble_targets(actor,targs,category,msg) end for i,v in pairs(targets) do - local name - local article = common_nouns:contains(v.id) and not simplify and 'The ' or '' + local name = string.gsub(v.name,' ', string.char(0x81,0x3F)) --fix for ffxi chat splits on space + local article = common_nouns:contains(v.id) and (not simplify or msg == 206) and 'The ' or '' local numb = condensetargetname and samename[v.name] > 1 and ' {'..samename[v.name]..'}' or '' if i == 1 then - name = color_it(v.name,color_arr[v.owner or v.type]) - out_str = out_str..article..name..numb + name = color_it(name,color_arr[v.owner or v.type])..v.owner_name if samename[v.name] > 1 then targets_condensed = true else + if (not simplify or msg == 206) and string.find(res.action_messages[msg][language], '${target}\'s') then + name = color_it(name,color_arr[v.owner or v.type])..(plural_entities:contains(v.id) and '\'' or '\'s')..v.owner_name + end targets_condensed = false end + out_str = out_str..article..name..numb else targets_condensed = true - name = color_it(v.name,color_arr[v.owner or v.type]) + name = color_it(name,color_arr[v.owner or v.type])..v.owner_name out_str = conjunctions(out_str,article..name..numb,#targets,i) end end @@ -637,7 +662,7 @@ function player_info(id) dmg = 'mydmg' end owner = i - owner_name = showownernames and ' (' .. v.mob.name .. ')' + owner_name = showownernames and ' ('..color_it(v.mob.name, color_arr[owner or typ])..')' break elseif type(v) == 'table' and v.mob and v.mob.fellow_index and v.mob.fellow_index == player_table.index then if i == 'p0' then @@ -646,7 +671,7 @@ function player_info(id) dmg = 'mydmg' end owner = i - owner_name = showownernames and ' (' .. v.mob.name .. ')' + owner_name = showownernames and ' ('..color_it(v.mob.name, color_arr[owner or typ])..')' break end end @@ -682,7 +707,7 @@ function player_info(id) end end if not typ then typ = 'debug' end - return {name=player_table.name,id=id,is_npc = player_table.is_npc,type=typ,damage=dmg,filter=filt,owner=(owner or nil), owner_name=(owner_name or nil),race = player_table.race} + return {name=player_table.name,id=id,is_npc = player_table.is_npc,type=typ,damage=dmg,filter=filt,owner=(owner or nil), owner_name=(owner_name or ''),race = player_table.race} end function get_spell(act) From e42e631fd24025c1eb50a51904a903757025db7d Mon Sep 17 00:00:00 2001 From: KenshiDRK Date: Thu, 1 Apr 2021 04:46:14 +0200 Subject: [PATCH 4/5] more fixes more fixes --- addons/battlemod/parse_action_packet.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/battlemod/parse_action_packet.lua b/addons/battlemod/parse_action_packet.lua index 21bc48d486..8261adac3c 100644 --- a/addons/battlemod/parse_action_packet.lua +++ b/addons/battlemod/parse_action_packet.lua @@ -268,7 +268,7 @@ function parse_action_packet(act) end local msg,numb = simplify_message(m.message) if not color_arr[act.actor.owner or act.actor.type] then windower.add_to_chat(123,'Battlemod error, missing filter:'..tostring(act.actor.owner)..' '..tostring(act.actor.type)) end - if m.fields.status then numb = m.status else numb = pref_suf((m.cparam or m.param),m.message,act.actor.damage,col) end + if m.fields.status then numb = m.status else numb = pref_suf((m.message == 674 and m.add_effect_param or m.cparam or m.param),m.message,act.actor.damage,col) end if msg and m.message == 70 and not simplify then -- fix pronoun on parry if v.target[1].race == 0 then @@ -599,7 +599,7 @@ function assemble_targets(actor,targs,category,msg) if samename[v.name] > 1 then targets_condensed = true else - if (not simplify or msg == 206) and string.find(res.action_messages[msg][language], '${target}\'s') then + if (not simplify or msg == 206) and #targets == 1 and string.find(res.action_messages[msg][language], '${target}\'s') then name = color_it(name,color_arr[v.owner or v.type])..(plural_entities:contains(v.id) and '\'' or '\'s')..v.owner_name end targets_condensed = false From 2c9d0e650864923baccc9365ff1ccb6393f112f8 Mon Sep 17 00:00:00 2001 From: KenshiDRK Date: Sat, 17 Apr 2021 16:03:10 +0200 Subject: [PATCH 5/5] requested changes requested changes --- addons/battlemod/battlemod.lua | 47 ++-- addons/battlemod/generic_helpers.lua | 283 ++++++++++++++++------- addons/battlemod/parse_action_packet.lua | 77 +++--- addons/battlemod/statics.lua | 55 +++++ 4 files changed, 316 insertions(+), 146 deletions(-) diff --git a/addons/battlemod/battlemod.lua b/addons/battlemod/battlemod.lua index 12b768eb5f..904570df19 100644 --- a/addons/battlemod/battlemod.lua +++ b/addons/battlemod/battlemod.lua @@ -253,8 +253,8 @@ windower.register_event('incoming chunk',function (id,original,modified,is_injec ------- ITEM QUANTITY ------- if id == 0x020 and parse_quantity then --local packet = packets.parse('incoming', original) - local item = original:unpack("H",0x0D) - local count = original:unpack("I",0x05) + local item = original:unpack('H',0x0D) + local count = original:unpack('I',0x05) if item == 0 then return end if item_quantity.id == item then item_quantity.count = count..' ' @@ -262,9 +262,9 @@ windower.register_event('incoming chunk',function (id,original,modified,is_injec ------- NOUNS AND PLURAL ENTITIES ------- elseif id == 0x00E then - local mob_id = original:unpack("I",0x05) - local mask = original:unpack("C",0x0B) - local chat_info = original:unpack("C",0x28) + local mob_id = original:unpack('I',0x05) + local mask = original:unpack('C',0x0B) + local chat_info = original:unpack('C',0x28) if bit.band(mask,4) == 4 then if bit.band(chat_info,32) == 0 and not common_nouns:contains(mob_id) then table.insert(common_nouns, mob_id) @@ -286,14 +286,14 @@ windower.register_event('incoming chunk',function (id,original,modified,is_injec ------- ACTION MESSAGE ------- elseif id == 0x29 then local am = {} - am.actor_id = original:unpack("I",0x05) - am.target_id = original:unpack("I",0x09) - am.param_1 = original:unpack("I",0x0D) - am.param_2 = original:unpack("H",0x11)%2^9 -- First 7 bits - am.param_3 = math.floor(original:unpack("I",0x11)/2^5) -- Rest - am.actor_index = original:unpack("H",0x15) - am.target_index = original:unpack("H",0x17) - am.message_id = original:unpack("H",0x19)%2^15 -- Cut off the most significant bit + am.actor_id = original:unpack('I',0x05) + am.target_id = original:unpack('I',0x09) + am.param_1 = original:unpack('I',0x0D) + am.param_2 = original:unpack('H',0x11)%2^9 -- First 7 bits + am.param_3 = math.floor(original:unpack('I',0x11)/2^5) -- Rest + am.actor_index = original:unpack('H',0x15) + am.target_index = original:unpack('H',0x17) + am.message_id = original:unpack('H',0x19)%2^15 -- Cut off the most significant bit local actor = player_info(am.actor_id) local target = player_info(am.target_id) @@ -318,16 +318,17 @@ windower.register_event('incoming chunk',function (id,original,modified,is_injec windower.add_to_chat(color, msg) else local msg = res.action_messages[am.message_id][language] + msg = grammatical_number_fix(msg, number, am.message_id) if plural_entities:contains(am.actor_id) then - msg = plural_actor(msg) + msg = plural_actor(msg, am.message_id) end if plural_entities:contains(am.target_id) then - msg = plural_target(msg) + msg = plural_target(msg, am.message_id) end local msg = clean_msg(msg :gsub('${status}',status or '') :gsub('${target}',target_article..targ) - :gsub('${number}',number or '')) + :gsub('${number}',number or ''), am.message_id) windower.add_to_chat(color, msg) end elseif am.message_id == 206 and condensetargets then -- Wears off messages @@ -363,10 +364,10 @@ windower.register_event('incoming chunk',function (id,original,modified,is_injec local item,status,spell,skill,number,number2 local outstr = res.action_messages[am.message_id][language] if plural_entities:contains(am.actor_id) then - outstr = plural_actor(outstr) + outstr = plural_actor(outstr, am.message_id) end if plural_entities:contains(am.target_id) then - outstr = plural_target(outstr) + outstr = plural_target(outstr, am.message_id) end local fields = fieldsearch(outstr) @@ -429,7 +430,7 @@ windower.register_event('incoming chunk',function (id,original,modified,is_injec :gsub('${number}',number or '') :gsub('${number2}',number2 or '') :gsub('${skill}',skill or '') - :gsub('${lb}','\7'))) + :gsub('${lb}','\7'), am.message_id)) windower.add_to_chat(res.action_messages[am.message_id]['color'],outstr) am.message_id = false elseif debugging and res.action_messages[am.message_id] then @@ -445,8 +446,8 @@ windower.register_event('incoming chunk',function (id,original,modified,is_injec ------------ SYNTHESIS ANIMATION -------------- elseif id == 0x030 and crafting then - if windower.ffxi.get_player().id == original:unpack("I",5) or windower.ffxi.get_mob_by_target('t') and windower.ffxi.get_mob_by_target('t').id == original:unpack("I",5) then - local crafter_name = (windower.ffxi.get_player().id == original:unpack("I",5) and windower.ffxi.get_player().name) or windower.ffxi.get_mob_by_target('t').name + if windower.ffxi.get_player().id == original:unpack('I',5) or windower.ffxi.get_mob_by_target('t') and windower.ffxi.get_mob_by_target('t').id == original:unpack('I',5) then + local crafter_name = (windower.ffxi.get_player().id == original:unpack('I',5) and windower.ffxi.get_player().name) or windower.ffxi.get_mob_by_target('t').name local result = original:byte(13) if result == 0 then windower.add_to_chat(8,' ------------- NQ Synthesis ('..crafter_name..') -------------') @@ -479,11 +480,11 @@ end) function multi_packet(...) local ind = table.concat({...},' ') local targets = assemble_targets(multi_actor[ind],multi_targs[ind],0,multi_msg[ind]) - local outstr = targets_condensed and plural_target(res.action_messages[multi_msg[ind]][language]) or res.action_messages[multi_msg[ind]][language] + local outstr = targets_condensed and plural_target(res.action_messages[multi_msg[ind]][language], multi_msg[ind]) or res.action_messages[multi_msg[ind]][language] outstr = clean_msg(outstr :gsub('${target}\'s',targets) :gsub('${target}',targets) - :gsub('${status}',ind)) + :gsub('${status}',ind), multi_msg[ind]) windower.add_to_chat(res.action_messages[multi_msg[ind]].color,outstr) multi_targs[ind] = nil multi_msg[ind] = nil diff --git a/addons/battlemod/generic_helpers.lua b/addons/battlemod/generic_helpers.lua index c3677a0eb2..1f015ae554 100644 --- a/addons/battlemod/generic_helpers.lua +++ b/addons/battlemod/generic_helpers.lua @@ -84,7 +84,7 @@ end function fieldsearch(message) local fieldarr = {} - string.gsub(message,"{(.-)}", function(a) fieldarr[a] = true end) + string.gsub(message,'{(.-)}', function(a) fieldarr[a] = true end) return fieldarr end @@ -124,114 +124,223 @@ function actor_noun(msg) return msg end -function plural_actor(msg) +function plural_actor(msg, msg_id) if msg then - msg = msg - :gsub('${actor} hits ', '${actor} hit ') - :gsub('${actor} casts ', '${actor} cast ') - :gsub('${actor} starts ', '${actor} start ') - :gsub('${actor} defeats ', '${actor} defeat ') - :gsub('${actor} gains ', '${actor} gain ') - :gsub('${actor} attains ', '${actor} attain ') - :gsub('${actor} loses ', '${actor} lose ') - :gsub('${actor} falls ', '${actor} fall ') - :gsub("${actor}'s ", "${actor}' ") - :gsub('${actor} misses ' , '${actor} miss ') - :gsub('${actor} calls ' , '${actor} call ') - :gsub('${actor} learns ' , '${actor} learn ') - :gsub('${actor} uses ' , '${actor} use ') - :gsub('${actor} is ' , '${actor} are ') - :gsub('${actor} takes ' , '${actor} take ') - :gsub('${actor} does ' , '${actor} do ') - :gsub('${actor} lacks ' , '${actor} lack ') - :gsub('${actor} redies ' , '${actor} ready ') - :gsub('${actor} earns ' , '${actor} earn ') - :gsub('${actor} scores ' , '${actor} score ') - :gsub('${actor} successfully removes ' , '${actor} successfully remove ') - :gsub('${actor} achieves ' , '${actor} achieve ') - :gsub('${actor} mugs ' , '${actor} mug ') - :gsub('${actor} steals ' , '${actor} steal ') - :gsub('${actor} fails ' , '${actor} fail ') - :gsub(' but finds nothing' , ' but find nothing') - :gsub(' and finds ${item}' , ' and find ${item}') - :gsub('${actor} recovers ' , '${actor} recover ') - :gsub('${ability}, but misses' , '${ability}, but miss') - :gsub(' but misses ${target}' , ' but miss ${target}') - :gsub('${actor} covers ' , '${actor} cover ') - :gsub('${actor} already has ' , '${actor} already have ') - :gsub('${actor} attempts ' , '${actor} attempt ') - :gsub(' but lacks ' , ' but lack ') - :gsub('${actor} destroys ' , '${actor} destroy ') - :gsub('${actor} absorbs ' , '${actor} absorb ') - :gsub('${actor} eats ' , '${actor} eat ') - :gsub('${actor} leads ' , '${actor} lead ') - :gsub('${actor} has ' , '${actor} have ') - :gsub('${actor} obtains ' , '${actor} obtain ') - :gsub(' and finds ${number}' , ' and find ${number}') + if msg_id == 6 then + msg = msg:gsub('${actor} defeats ', '${actor} defeat ') + elseif msg_id == 9 then + msg = msg:gsub('${actor} attains ', '${actor} attain ') + elseif msg_id == 10 then + msg = msg:gsub('${actor} loses ', '${actor} lose ') + elseif msg_id == 11 then + msg = msg:gsub('${actor} falls ', '${actor} fall ') + elseif msg_id == 19 then + msg = msg:gsub('${actor} calls ' , '${actor} call ') + elseif msg_id == 35 then + msg = msg:gsub('${actor} lacks ' , '${actor} lack ') + elseif msg_id == 67 then + msg = msg:gsub('${actor} scores ' , '${actor} score ') + elseif msg_id == 124 then + msg = msg:gsub('${actor} achieves ' , '${actor} achieve ') + elseif msg_id == 129 then + msg = msg:gsub('${actor} mugs ' , '${actor} mug ') + elseif msg_id == 244 then + msg = msg:gsub('${actor} fails ' , '${actor} fail ') + elseif msg_id == 311 then + msg = msg:gsub('${actor} covers ' , '${actor} cover ') + elseif msg_id == 315 then + msg = msg:gsub('${actor} already has ' , '${actor} already have ') + elseif msg_id ==411 then + msg = msg + :gsub('${actor} attempts ' , '${actor} attempt ') + :gsub(' but lacks ' , ' but lack ') + elseif msg_id == 536 then + msg = msg:gsub('${actor} takes ' , '${actor} take ') + elseif msg_id == 563 then + msg = msg:gsub('${actor} destroys ' , '${actor} destroy ') + elseif msg_id == 772 then + msg = msg:gsub('${actor} stands ', '${actor} stand ') + elseif replacements_map.actor.hits:contains(msg_id) then + msg = msg:gsub('${actor} hits ', '${actor} hit ') + elseif replacements_map.actor.misses:contains(msg_id) then + msg = msg:gsub('${actor} misses ' , '${actor} miss ') + elseif replacements_map.actor.starts:contains(msg_id) then + msg = msg:gsub('${actor} starts ', '${actor} start ') + elseif replacements_map.actor.casts:contains(msg_id) then + msg = msg:gsub('${actor} casts ', '${actor} cast ') + if msg_id == 83 then + msg = msg:gsub('${actor} successfully removes ' , '${actor} successfully remove ') + elseif msg_id == 572 or msg_id == 642 then + msg = msg:gsub('${actor} absorbs ' , '${actor} absorb ') + end + elseif replacements_map.actor.readies:contains(msg_id) then + msg = msg:gsub('${actor} readies ' , '${actor} ready ') + elseif replacements_map.actor.recovers:contains(msg_id) then + msg = msg:gsub('${actor} recovers ' , '${actor} recover ') + elseif replacements_map.actor.gains:contains(msg_id) then + msg = msg:gsub('${actor} gains ', '${actor} gain ') + elseif replacements_map.actor.apos:contains(msg_id) then + msg = msg:gsub('${actor}\'s ', '${actor}\' ') + if msg_id == 33 then + msg = msg:gsub('${actor} takes ' , '${actor} take ') + elseif msg_id == 606 then + msg = msg:gsub('${actor} recovers ' , '${actor} recover ') + elseif msg_id == 799 then + msg = msg:gsub('${actor} is ' , '${actor} are ') + end + elseif replacements_map.actor.uses:contains(msg_id) then + msg = msg:gsub('${actor} uses ' , '${actor} use ') + if msg_id == 122 then + msg = msg:gsub('${actor} recovers ' , '${actor} recover ') + elseif msg_id == 123 then + msg = msg:gsub('${actor} successfully removes ' , '${actor} successfully remove ') + elseif msg_id == 126 or msg_id == 136 or msg_id == 528 then + msg = msg:gsub('${actor}\'s ', '${actor}\' ') + elseif msg_id == 137 or msg_id == 153 then + msg = msg:gsub('${actor} fails ' , '${actor} fail ') + elseif msg_id == 139 then + msg = msg:gsub(' but finds nothing' , ' but find nothing') + elseif msg_id == 140 then + msg = msg:gsub(' and finds a ${item2}' , ' and find a ${item2}') + elseif msg_id == 158 then + msg = msg:gsub('${ability}, but misses' , '${ability}, but miss') + elseif msg_id == 585 then + msg = msg:gsub('${actor} is ' , '${actor} are ') + elseif msg_id == 674 then + msg = msg:gsub(' and finds ${number}' , ' and find ${number}') + elseif msg_id == 780 then + msg = msg:gsub('${actor} takes ' , '${actor} take ') + elseif replacements_map.actor.steals:contains(msg_id) then + msg = msg:gsub('${actor} steals ' , '${actor} steal ') + elseif replacements_map.actor.butmissestarget:contains(msg_id) then + msg = msg:gsub(' but misses ${target}' , ' but miss ${target}') + end + elseif replacements_map.actor.is:contains(msg_id) then + msg = msg:gsub('${actor} is ' , '${actor} are ') + elseif replacements_map.actor.learns:contains(msg_id) then + msg = msg:gsub('${actor} learns ' , '${actor} learn ') + elseif replacements_map.actor.has:contains(msg_id) then + msg = msg:gsub('${actor} has ' , '${actor} have ') + elseif replacements_map.actor.obtains:contains(msg_id) then + msg = msg:gsub('${actor} obtains ' , '${actor} obtain ') + elseif replacements_map.actor.does:contains(msg_id) then + msg = msg:gsub('${actor} does ' , '${actor} do ') + elseif replacements_map.actor.leads:contains(msg_id) then + msg = msg:gsub('${actor} leads ' , '${actor} lead ') + elseif replacements_map.actor.eats:contains(msg_id) then + msg = msg:gsub('${actor} eats ' , '${actor} eat ') + if msg_id == 604 then + msg = msg:gsub(' but finds nothing' , ' but find nothing') + end + elseif replacements_map.actor.earns:contains(msg_id) then + msg = msg:gsub('${actor} earns ' , '${actor} earn ') + end end return msg end -function plural_target(msg) +function plural_target(msg, msg_id) if msg then - msg = msg - :gsub('${target} takes ', '${target} take ') - :gsub('${target} is ', '${target} are ') - :gsub('${target} recovers ', '${target} recover ') - :gsub("${target}'s ", targets_condensed and '${target} ' or "${target}' ") - :gsub('${target} falls ', '${target} fall ') - :gsub('${target} uses ', '${target} use ') - :gsub('${target} resists', '${target} resist') - :gsub('${target} vanishes', '${target} vanish') - :gsub('${target} receives ', '${target} receive ') - :gsub('${target} seems ${skill}', '${target} seem ${skill}') - :gsub('${lb}It seems to have ', '${lb}They seem to have ') - :gsub('${target} gains ', '${target} gain ') - :gsub('${target} evades', '${target} evade') - :gsub('${target} regains ', '${target} regain ') - :gsub('${target} narrowly escapes ', '${target} narrowly escape ') - :gsub('${target} obtains ', '${target} obtain ') - :gsub('${target} learns ', '${target} learn ') - :gsub('${target} loses ', '${target} lose ') - :gsub('${target} was ', '${target} were ') - :gsub('${target} has ', '${target} have ') - :gsub('${target} completely resists ', '${target} completely resist ') - :gsub('${target} now has ', '${target} now have ') - :gsub('${target} feels ', '${target} feel ') - :gsub('${target} stands ', '${target} stand ') + if msg_id == 282 then + msg = msg:gsub('${target} evades', '${target} evade') + elseif msg_id == 359 then + msg = msg:gsub('${target} narrowly escapes ', '${target} narrowly escape ') + elseif msg_id == 419 then + msg = msg:gsub('${target} learns ', '${target} learn ') + elseif msg_id == 671 then + msg = msg:gsub('${target} now has ', '${target} now have ') + elseif msg_id == 764 then + msg = msg:gsub('${target} feels ', '${target} feel ') + elseif replacements_map.target.takes:contains(msg_id) then + msg = msg:gsub('${target} takes ', '${target} take ') + if msg_id == 197 then + msg = msg:gsub('${target} resists', '${target} resist') + end + elseif replacements_map.target.is:contains(msg_id) then + msg = msg:gsub('${target} is ', '${target} are ') + elseif replacements_map.target.recovers:contains(msg_id) then + msg = msg:gsub('${target} recovers ', '${target} recover ') + elseif replacements_map.target.apos:contains(msg_id) then --coincidence in 439 and 440 + msg = msg:gsub('${target}\'s ', targets_condensed and '${target} ' or '${target}\' ') + if msg_id == 439 or msg_id == 440 then + msg = msg:gsub('${target} regains ', '${target} regain ') + end + elseif replacements_map.target.falls:contains(msg_id) then + msg = msg:gsub('${target} falls ', '${target} fall ') + elseif replacements_map.target.uses:contains(msg_id) then + msg = msg:gsub('${target} uses ', '${target} use ') + elseif replacements_map.target.resists:contains(msg_id) then + msg = msg:gsub('${target} resists', '${target} resist') + elseif replacements_map.target.vanishes:contains(msg_id) then + msg = msg:gsub('${target} vanishes', '${target} vanish') + elseif replacements_map.target.receives:contains(msg_id) then + msg = msg:gsub('${target} receives ', '${target} receive ') + elseif replacements_map.target.seems:contains(msg_id) then + msg = msg:gsub('${target} seems ${skill}', '${target} seem ${skill}') + if msg_id ~= 174 then + msg = msg:gsub('${lb}It seems to have ', '${lb}They seem to have ') + end + elseif replacements_map.target.gains:contains(msg_id) then + msg = msg:gsub('${target} gains ', '${target} gain ') + elseif replacements_map.target.regains:contains(msg_id) then + msg = msg:gsub('${target} regains ', '${target} regain ') + elseif replacements_map.target.obtains:contains(msg_id) then + msg = msg:gsub('${target} obtains ', '${target} obtain ') + elseif replacements_map.target.loses:contains(msg_id) then + msg = msg:gsub('${target} loses ', '${target} lose ') + elseif replacements_map.target.was:contains(msg_id) then + msg = msg:gsub('${target} was ', '${target} were ') + elseif replacements_map.target.has:contains(msg_id) then + msg = msg:gsub('${target} has ', '${target} have ') + elseif replacements_map.target.compresists:contains(msg_id) then + msg = msg:gsub('${target} completely resists ', '${target} completely resist ') + end end return msg end -function clean_msg(msg) +function clean_msg(msg, msg_id) if msg then msg = msg :gsub(' The ', ' the ') - msg = msg - :gsub('%. the ', '. The ') :gsub(': the ', ': The ') :gsub('! the ', '! The ') + if replacements_map.the.point:contains(msg_id) then + msg = msg:gsub('%. the ', '. The ') + end end return msg end -function grammatical_number_fix(msg, number) +function grammatical_number_fix(msg, number, msg_id) if msg then if number == 1 then - msg = msg - :gsub(' points', ' point') - :gsub('${number} Ballista Points', '${number} Ballista Point') - :gsub('healed of ${number} status ailments', 'healed of ${number} status ailment') - :gsub('magical effects from', 'magical effect from') + if replacements_map.number.points:contains(msg_id) then + msg = msg:gsub(' points', ' point') + elseif msg_id == 411 then + msg = msg:gsub('${number} Ballista Points', '${number} Ballista Point') + elseif msg_id == 589 then + msg = msg:gsub('healed of ${number} status ailments', 'healed of ${number} status ailment') + elseif msg_id == 778 then + msg = msg:gsub('magical effects from', 'magical effect from') + end else - msg = msg - :gsub(' absorbs', ' absorb') - :gsub(' Petra', ' Petras') - :gsub('disappears', 'disappear') - :gsub('attributes is', 'attributes are') - :gsub('status effect is', 'status effects are') - :gsub('piece', 'pieces') - :gsub('Finishing move now ', 'Finishing moves now ') + if replacements_map.number.absorbs:contains(msg_id) then + msg = msg:gsub(' absorbs', ' absorb') + elseif msg_id == 133 then + msg = msg:gsub(' Petra', ' Petras') + elseif replacements_map.number.attributes:contains(msg_id) then + msg = msg:gsub('attributes is', 'attributes are') + elseif replacements_map.number.status:contains(msg_id) then + msg = msg:gsub('status effect is', 'status effects are') + elseif msg_id == 557 then + msg = msg:gsub('piece', 'pieces') + elseif msg_id == 560 then + msg = msg:gsub('Finishing move now ', 'Finishing moves now ') + end + if replacements_map.number.disappears:contains(msg_id) then + msg = msg:gsub('disappears', 'disappear') + end end end return msg diff --git a/addons/battlemod/parse_action_packet.lua b/addons/battlemod/parse_action_packet.lua index 8261adac3c..89c21c22f3 100644 --- a/addons/battlemod/parse_action_packet.lua +++ b/addons/battlemod/parse_action_packet.lua @@ -278,10 +278,6 @@ function parse_action_packet(act) end end - if col == 'D' or grammar_numb_msg:contains(m.message) then - msg = grammatical_number_fix(msg, (m.cparam or m.param)) - end - local count = '' if m.message == 377 and act.actor_id == Self.id then parse_quantity = true @@ -290,6 +286,9 @@ function parse_action_packet(act) end if not simplify then + if col == 'D' or grammar_numb_msg:contains(m.message) then + msg = grammatical_number_fix(msg, (m.cparam or m.param), m.message) + end if act.action.item_id or act.action.item2_id then msg = item_article_fix(act.action.item_id,act.action.item2_id,msg) end @@ -297,30 +296,30 @@ function parse_action_packet(act) msg = actor_noun(msg) end if plural_entities:contains(act.actor.id) then - msg = plural_actor(msg) + msg = plural_actor(msg, m.message) end if targets_condensed or plural_entities:contains(v.target[1].id) then - msg = plural_target(msg) + msg = plural_target(msg, m.message) end end local reaction_lookup = reaction_offsets[act.category] and (m.reaction - reaction_offsets[act.category]) or 0 local has_line_break = string.find(res.action_messages[m.message].en, '${lb}') and true or false - local prefix = (not has_line_break or simplify) and S{1,3,4,6,11,13,14,15}:contains(act.category) and (bit.band(m.unknown,1)==1 and "Cover! " or "") - ..(bit.band(m.unknown,4)==4 and "Magic Burst! " or "") --Used on Swipe/Lunge MB - ..(bit.band(m.unknown,8)==8 and "Immunobreak! " or "") --Unused? Displayed directly on message - ..(bit.band(m.unknown,16)==16 and "Critical Hit! " or "") --Unused? Crits have their own message - ..(reaction_lookup == 4 and "Blocked! " or "") - ..(reaction_lookup == 2 and "Guarded! " or "") - ..(reaction_lookup == 3 and S{3,4,6,11,13,14,15}:contains(act.category) and "Parried! " or "") or "" --Unused? They are send the same as missed - local prefix2 = has_line_break and S{1,3,4,6,11,13,14,15}:contains(act.category) and (bit.band(m.unknown,1)==1 and "Cover! " or "") - ..(bit.band(m.unknown,2)==2 and "Resist! " or "") - ..(bit.band(m.unknown,4)==4 and "Magic Burst! " or "") --Used on Swipe/Lunge MB - ..(bit.band(m.unknown,8)==8 and "Immunobreak! " or "") --Unused? Displayed directly on message - ..(bit.band(m.unknown,16)==16 and "Critical Hit! " or "") --Unused? Crits have their own message - ..(reaction_lookup == 4 and "Blocked! " or "") - ..(reaction_lookup == 2 and "Guarded! " or "") - ..(reaction_lookup == 3 and S{3,4,6,11,13,14,15}:contains(act.category) and "Parried! " or "") or "" --Unused? They are send the same as missed + local prefix = (not has_line_break or simplify) and S{1,3,4,6,11,13,14,15}:contains(act.category) and (bit.band(m.unknown,1)==1 and 'Cover! ' or '') + ..(bit.band(m.unknown,4)==4 and 'Magic Burst! ' or '') --Used on Swipe/Lunge MB + ..(bit.band(m.unknown,8)==8 and 'Immunobreak! ' or '') --Unused? Displayed directly on message + ..(bit.band(m.unknown,16)==16 and 'Critical Hit! ' or '') --Unused? Crits have their own message + ..(reaction_lookup == 4 and 'Blocked! ' or '') + ..(reaction_lookup == 2 and 'Guarded! ' or '') + ..(reaction_lookup == 3 and S{3,4,6,11,13,14,15}:contains(act.category) and 'Parried! ' or '') or '' --Unused? They are send the same as missed + local prefix2 = has_line_break and S{1,3,4,6,11,13,14,15}:contains(act.category) and (bit.band(m.unknown,1)==1 and 'Cover! ' or '') + ..(bit.band(m.unknown,2)==2 and 'Resist! ' or '') + ..(bit.band(m.unknown,4)==4 and 'Magic Burst! ' or '') --Used on Swipe/Lunge MB + ..(bit.band(m.unknown,8)==8 and 'Immunobreak! ' or '') --Unused? Displayed directly on message + ..(bit.band(m.unknown,16)==16 and 'Critical Hit! ' or '') --Unused? Crits have their own message + ..(reaction_lookup == 4 and 'Blocked! ' or '') + ..(reaction_lookup == 2 and 'Guarded! ' or '') + ..(reaction_lookup == 3 and S{3,4,6,11,13,14,15}:contains(act.category) and 'Parried! ' or '') or '' --Unused? They are send the same as missed local message = prefix..make_condensedamage_number(m.number)..( clean_msg((msg or tostring(m.message)) :gsub('${spell}',color_it(act.action.spell or 'ERROR 111',color_arr.spellcol)) :gsub('${ability}',color_it(act.action.ability or 'ERROR 112',color_arr.abilcol)) @@ -336,7 +335,7 @@ function parse_action_packet(act) :gsub('${lb}','\7'..prefix2) :gsub('${number}',act.action.number or m.param) :gsub('${status}',m.status or 'ERROR 120') - :gsub('${gil}',m.param..' gil'))) + :gsub('${gil}',m.param..' gil'), m.message)) if m.message == 377 and act.actor_id == Self.id then send_delayed_message:schedule(0.5,color,message) else @@ -361,14 +360,17 @@ function parse_action_packet(act) end local msg,numb = simplify_message(m.add_effect_message) if not simplify then + if col == 'D' or grammar_numb_msg:contains(m.add_effect_message) then + msg = grammatical_number_fix(msg, (m.cparam or m.param), m.add_effect_message) + end if common_nouns:contains(act.actor.id) then msg = actor_noun(msg) end if plural_entities:contains(act.actor.id) then - msg = plural_actor(msg) + msg = plural_actor(msg, m.add_effect_message) end if targets_condensed or plural_entities:contains(v.target[1].id) then - msg = plural_target(msg) + msg = plural_target(msg, m.add_effect_message) end end if m.add_effect_fields.status then numb = m.add_effect_status else numb = pref_suf((m.cadd_effect_param or m.add_effect_param),m.add_effect_message,act.actor.damage,col) end @@ -388,7 +390,7 @@ function parse_action_packet(act) :gsub('${target}',targ) :gsub('${lb}','\7') :gsub('${number}',m.add_effect_param) - :gsub('${status}',m.add_effect_status or 'ERROR 178')))) + :gsub('${status}',m.add_effect_status or 'ERROR 178'), m.add_effect_message))) if not non_block_messages:contains(m.add_effect_message) then m.add_effect_message = 0 end @@ -419,14 +421,17 @@ function parse_action_packet(act) local msg = simplify_message(m.spike_effect_message) if not simplify then + if col == 'D' or grammar_numb_msg:contains(m.spike_effect_message) then + msg = grammatical_number_fix(msg, (m.cparam or m.param), m.spike_effect_message) + end if common_nouns:contains(act.actor.id) then msg = actor_noun(msg) end if plural_entities:contains(act.actor.id) then - msg = plural_actor(msg) + msg = plural_actor(msg, m.spike_effect_message) end if targets_condensed or plural_entities:contains(v.target[1].id) then - msg = plural_target(msg) + msg = plural_target(msg, m.spike_effect_message) end end if m.spike_effect_fields.status then numb = m.spike_effect_status else numb = pref_suf((m.cspike_effect_param or m.spike_effect_param),m.spike_effect_message,actor.damage,col) end @@ -443,7 +448,7 @@ function parse_action_packet(act) :gsub((simplify and '${actor}' or '${target}'),targ) :gsub('${lb}','\7') :gsub('${number}',m.spike_effect_param) - :gsub('${status}',m.spike_effect_status or 'ERROR 150')))) + :gsub('${status}',m.spike_effect_status or 'ERROR 150'), m.spike_effect_message))) if not non_block_messages:contains(m.spike_effect_message) then m.spike_effect_message = 0 end @@ -555,9 +560,9 @@ function simplify_message(msg_ID) msg = line_noability elseif line_notarget and fields.actor and fields.number then if msg_ID == 798 then --Maneuver message - msg = line_notarget.."%" + msg = line_notarget..'%' elseif msg_ID == 799 then --Maneuver message with overload - msg = line_notarget.."% (${actor} overloaded)" + msg = line_notarget..'% (${actor} overloaded)' else msg = line_notarget end @@ -862,37 +867,37 @@ function color_filt(col,is_me) --Depends on whether or not the target is you, the same as using in-game colors -- Returns a color code for windower.add_to_chat() -- Does not currently support a Debuff/Buff distinction - if col == "D" then -- Damage + if col == 'D' then -- Damage if is_me then return 28 else return 20 end - elseif col == "M" then -- Misses + elseif col == 'M' then -- Misses if is_me then return 29 else return 21 end - elseif col == "H" then -- Healing + elseif col == 'H' then -- Healing if is_me then return 30 else return 22 end - elseif col == "B" then -- Beneficial effects + elseif col == 'B' then -- Beneficial effects if is_me then return 56 else return 60 end - elseif col == "DB" then -- Detrimental effects (I don't know how I'd split these) + elseif col == 'DB' then -- Detrimental effects (I don't know how I'd split these) if is_me then return 57 else return 61 end - elseif col == "R" then -- Resists + elseif col == 'R' then -- Resists if is_me then return 59 else diff --git a/addons/battlemod/statics.lua b/addons/battlemod/statics.lua index 4c64889b2d..17021d9b0d 100644 --- a/addons/battlemod/statics.lua +++ b/addons/battlemod/statics.lua @@ -44,6 +44,61 @@ black_colors = T{}--352,354,356,388,390,400,402,430,432,442,444,472,474,484,486} dmg_drain_msg = T{132,161,187,227,274,281,736,748,749,802,803} grammar_numb_msg = T{14,31,133,231,369,370,382,385,386,387,388,389,390,391,392,393,394,395,396,397,398,400,401,403,404,405,411,417,535,536,557,570,571,589,607,651,757,769,770,778,792} +replacements_map = { + actor = { + hits = T{1,373}, + casts = T{2,7,42,82,83,85,86,93,113,114,227,228,230,236,237,252,268,271,274,275,309,329,330,331,332,333,334,335,341,342,430,431,432,433,454,533,534,570,572,642,647,653,655}, + starts = T{3,327,716}, + gains = T{8,54,105,166,253,371,372,718,735}, + apos = T{14,16,33,69,70,75,248,310,312,352,353,354,355,382,493,535,574,575,576,577,592,606,798,799}, + misses = T{15,63}, + learns = T{23,45,442}, + uses = T{28,77,100,101,102,103,108,109,110,115,116,117,118,119,120,121,122,123,125,126,127,129,131,133,134,135,136,137,138,139,140,141,142,143,144,146,148,150,153,156,157,158,159,185,186,187,188,189,194,197,221,224,225,226,231,238,242,243,245,303,304,305,306,317,318,319,320,321,322,323,324,360,362,364,369,370,375,376,377,378,379,399,400,401,402,405,406,407,408,409,412,413,414,416,417,418,420,422,424,425,426,435, + 437,439,441,451,452,453,519,520,521,522,526,527,528,529,532,539,560,585,591,593,594,595,596,597,598,599,602,607,608,644,645,646,657,658,663,664,667,668,670,671,672,674,730,734,736,737,738,743,746,747,748,750,752,754,755,758,762,763,764,765,766,778,779,780,792,802,803,804,805,1023}, + is = T{29,49,84,106,191}, + does = T{34,91,192}, + readies = T{43,326,675}, + earns = T{50,368,719}, + steals = T{125,133,453,593,594,595,596,597,598,599}, + recovers = T{152,167}, + butmissestarget = T{188,245,324,658}, + eats = T{600,604}, + leads = T{648,650,651}, + has = T{515,661,665,688}, + obtains = T{582,673}, + }, + target = { + takes = T{2,67,77,110,157,185,196,197,229,252,264,265,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,317,353,379,413,522,648,650,732,747,767,768,800}, + is = T{4,13,64,78,82,86,107,127,128,130,131,134,136,141,148,149,150,151,154,198,203,204,232,236,242,246,270,271,272,277,279,286,287,313,328,350,519,520,521,529,531,586,591,593,594,595,596,597,598,599,645,754,776}, + recovers = T{7,24,25,26,74,102,103,224,238,263,276,306,318,367,373,382,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,651,769,770}, + apos = T{31,38,44,53,73,83,106,112,116,120,121,123,132,159,168,206,221,231,249,285,308,314,321,322,329,330,331,332,333,334,335,341,342,343,344,351,360,361,362,363,364,365,369,374,378,383,399,400,401,402,403,405,407,409,417,418,430,431,435,436,437,438,439,440,459,530,533,534,537,570,571,572,585,606,607,641,642,644,647,676,730,743,756,757,762,792,805,806,1023}, + falls = T{20,113,406,605,646}, + uses = T{79,80}, + resists = T{85,197,284,653,654}, + vanishes = T{93,273}, + receives = T{142,144,145,146,147,237,243,267,268,269,278,320,375,412,414,415,416,420,421,424,432,433,441,532,557,602,668,672,739,755,804}, + seems = T{170,171,172,173,174,175,176,177,178}, + gains = T{186,194,205,230,266,280,319}, + regains = T{357,358,439,440,451,452,539,587,588}, + obtains = T{376,377,565,566,765,766}, + loses = T{426,427,652}, + was = T{97,564}, + has = T{589,684,763}, + compresists = T{655,656}, + }, + number = { + points = T{1,2,8,10,33,38,44,54,67,77,105,110,157,163,185,196,197,223,229,252,253,264,265,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,310,317,352,353,371,372,373,379,382,385,386,387,388,389,390,391,392,393,394,395,396,397,398,413,522,536,576,577,648,650,651,718,721,722,723,724,725,726,727,728,729,732,735,747,767,768,769,770,800}, + absorbs = T{14,31,535}, + disappears = T{14,31,231,400,401,405,535,570,571,607,757,792,}, + attributes = T{369,403,417}, + status = T{370,404}, + + }, + the = { + point = T{33,308,536,800}, + } +} + domain_buffs = S{ 250, -- EF Badge 257, -- Besieged