Advertisement
Guest User

actions-custom.lua

a guest
Oct 16th, 2016
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 25.16 KB | None | 0 0
  1. --[[
  2. A library to make the manipulation of the action packet easier.
  3.  
  4. The primary functionality provided here are iterators which allow for
  5. easy traversal of the sub-tables within the packet. Example:
  6.  
  7. =======================================================================================
  8. require 'actions'
  9.  
  10. function event_action(act)
  11.   action = Action(act) -- constructor
  12.  
  13.     -- print out all melee hits to the console
  14.     if actionpacket:get_category_string() == 'melee' then
  15.         for target in actionpacket:get_targets() do -- target iterator
  16.             for action in target:get_actions() do -- subaction iterator
  17.                 if action.message == 1 then -- 1 is the code for messages
  18.                     print(string.format("%s hit %s for %d damage",
  19.                           actionpacket:get_actor_name(), target:get_name(), action.param))
  20.                 end
  21.             end
  22.         end
  23.     end
  24. end
  25. =======================================================================================
  26.  
  27. ]]
  28.  
  29. _libs = _libs or {}
  30. _libs.actions = true
  31. _libs.tables = _libs.tables or require 'tables'
  32. local res = require 'resources'
  33.  
  34. local category_strings = {
  35.     'melee',
  36.     'ranged_finish',
  37.     'weaponskill_finish',
  38.     'spell_finish',
  39.     'item_finish',
  40.     'job_ability',
  41.     'weaponskill_begin',
  42.     'casting_begin',
  43.     'item_begin',
  44.     'unknown',
  45.     'mob_tp_finish',
  46.     'ranged_begin',
  47.     'avatar_tp_finish',
  48.     'job_ability_unblinkable',
  49.     'job_ability_run'
  50. }
  51.  
  52. -- ActionPacket operations
  53. ActionPacket = {}
  54.  
  55.  
  56. local actionpacket = {}
  57. -- Constructor for Actions.
  58. -- Usage: actionpacket = ActionPacket(raw_action)
  59.  
  60. function ActionPacket.new(a)
  61.     if a == nil then
  62.         return
  63.     end
  64.  
  65.     local new_instance = {}
  66.     new_instance.raw = a
  67.  
  68.     return setmetatable(new_instance, {__index = function(t, k) if rawget(t, k) ~= nil then return t[k] else return actionpacket[k] end end})
  69. end
  70.  
  71. function act_to_string(original,act)
  72.     if type(act) ~= 'table' then return act end
  73.    
  74.     function assemble_bit_packed(init,val,initial_length,final_length)
  75.         if not init then return init end
  76.        
  77.         if type(val) == 'boolean' then
  78.             if val then val = 1 else val = 0 end
  79.         elseif type(val) ~= 'number' then
  80.             return false
  81.         end
  82.         local bits = initial_length%8
  83.         local byte_length = math.ceil(final_length/8)
  84.        
  85.         local out_val = 0
  86.         if bits > 0 then
  87.             out_val = init:byte(#init) -- Initialize out_val to the remainder in the active byte.
  88.             init = init:sub(1,#init-1) -- Take off the active byte
  89.         end
  90.         out_val = out_val + val*2^bits -- left-shift val by the appropriate amount and add it to the remainder (now the lsb-s in val)
  91.        
  92.         while out_val > 0 do
  93.             init = init..string.char(out_val%256)
  94.             out_val = math.floor(out_val/256)
  95.         end
  96.         while #init < byte_length do
  97.             init = init..string.char(0)
  98.         end
  99.         return init
  100.     end
  101.    
  102.     local react = assemble_bit_packed(original:sub(1,4),act.size,32,40)
  103.     react = assemble_bit_packed(react,act.actor_id,40,72)
  104.     react = assemble_bit_packed(react,act.target_count,72,82)
  105.     react = assemble_bit_packed(react,act.category,82,86)
  106.     react = assemble_bit_packed(react,act.param,86,102)
  107.     react = assemble_bit_packed(react,act.unknown,102,118)
  108.     react = assemble_bit_packed(react,act.recast,118,150)
  109.    
  110.     local offset = 150
  111.     for i = 1,act.target_count do
  112.         react = assemble_bit_packed(react,act.targets[i].id,offset,offset+32)
  113.         react = assemble_bit_packed(react,act.targets[i].action_count,offset+32,offset+36)
  114.         offset = offset + 36
  115.         for n = 1,act.targets[i].action_count do
  116.             react = assemble_bit_packed(react,act.targets[i].actions[n].reaction,offset,offset+5)
  117.             react = assemble_bit_packed(react,act.targets[i].actions[n].animation,offset+5,offset+16)
  118.             react = assemble_bit_packed(react,act.targets[i].actions[n].effect,offset+16,offset+21)
  119.             react = assemble_bit_packed(react,act.targets[i].actions[n].stagger,offset+21,offset+27)
  120.             react = assemble_bit_packed(react,act.targets[i].actions[n].param,offset+27,offset+44)
  121.             react = assemble_bit_packed(react,act.targets[i].actions[n].message,offset+44,offset+54)
  122.             react = assemble_bit_packed(react,act.targets[i].actions[n].unknown,offset+54,offset+85)
  123.            
  124.             react = assemble_bit_packed(react,act.targets[i].actions[n].has_add_effect,offset+85,offset+86)
  125.             offset = offset + 86
  126.             if act.targets[i].actions[n].has_add_effect then
  127.                 react = assemble_bit_packed(react,act.targets[i].actions[n].add_effect_animation,offset,offset+6)
  128.                 react = assemble_bit_packed(react,act.targets[i].actions[n].add_effect_effect,offset+6,offset+10)
  129.                 react = assemble_bit_packed(react,act.targets[i].actions[n].add_effect_param,offset+10,offset+27)
  130.                 react = assemble_bit_packed(react,act.targets[i].actions[n].add_effect_message,offset+27,offset+37)
  131.                 offset = offset + 37
  132.             end
  133.             react = assemble_bit_packed(react,act.targets[i].actions[n].has_spike_effect,offset,offset+1)
  134.             offset = offset + 1
  135.             if act.targets[i].actions[n].has_spike_effect then
  136.                 react = assemble_bit_packed(react,act.targets[i].actions[n].spike_effect_animation,offset,offset+6)
  137.                 react = assemble_bit_packed(react,act.targets[i].actions[n].spike_effect_effect,offset+6,offset+10)
  138.                 react = assemble_bit_packed(react,act.targets[i].actions[n].spike_effect_param,offset+10,offset+24)
  139.                 react = assemble_bit_packed(react,act.targets[i].actions[n].spike_effect_message,offset+24,offset+34)
  140.                 offset = offset + 34
  141.             end
  142.         end
  143.     end
  144.     if react then
  145.         while #react < #original do
  146.             react = react..original:sub(#react+1,#react+1)
  147.         end
  148.     else
  149.         print('Action Library failure in '..(_addon.name or 'Unknown Addon')..': Invalid Act table returned.')
  150.     end
  151.     return react
  152. end
  153.  
  154.  
  155. -- Opens a listener event for the action packet at the incoming chunk level before modifications.
  156. -- Passes in the documented act structures for the original and modified packets.
  157. -- If a table is returned, the library will treat it as a modified act table and recompose the packet string from it.
  158. -- If an invalid act table is passed, it will silently fail to be returned.
  159. function ActionPacket.open_listener(funct)
  160.     if not funct or type(funct) ~= 'function' then return end
  161.     local id = windower.register_event('incoming chunk',function(id, org, modi, is_injected, is_blocked)
  162.         if id == 0x28 then
  163.             local act_org = windower.packets.parse_action(org)
  164.             act_org.size = org:byte(5)
  165.             local act_mod = windower.packets.parse_action(modi)
  166.             act_mod.size = modi:byte(5)
  167.             return act_to_string(org,funct(act_org,act_mod))
  168.         end
  169.     end)
  170.     return id
  171. end
  172.  
  173. function ActionPacket.close_listener(id)
  174.     if not id or type(id) ~= 'number' then return end
  175.     windower.unregister_event(id)
  176. end
  177.  
  178.  
  179. local actor_animation_twoCC = {
  180.         wh='White Magic',
  181.         bk='Black Magic',
  182.         bl='Blue Magic',
  183.         sm='Summoning Magic',
  184.         te='TP Move',
  185.         ['k0']='Melee Attack',
  186.         ['lg']='Ranged Attack',
  187.     }
  188.  
  189. function actionpacket:get_animation_string()
  190.     return actor_animation_twoCC[string.char(actor_animation_twoCC[self.raw['unknown']]%256,math.floor(actor_animation_twoCC[self.raw['unknown']]/256))]
  191. end
  192.    
  193.    
  194. function actionpacket:get_category_string()
  195.     return category_strings[self.raw['category']]
  196. end
  197.  
  198. function actionpacket:get_spell()
  199.     local info = self:get_targets()():get_actions()():get_basic_info()
  200.     if rawget(info,'resource') and rawget(info,'spell_id') and rawget(rawget(res,rawget(info,'resource')),rawget(info,'spell_id')) then
  201.         local copied_line = {}
  202.         for i,v in pairs(rawget(rawget(res,rawget(info,'resource')),rawget(info,'spell_id'))) do
  203.             rawset(copied_line,i,v)
  204.         end
  205.         setmetatable(copied_line,getmetatable(res[rawget(info,'resource')][rawget(info,'spell_id')]))
  206.         return copied_line
  207.     end
  208. end
  209.  
  210. -- Returns the name of this actor if there is one
  211. function actionpacket:get_actor_name()
  212.     local mob = windower.ffxi.get_mob_by_id(self.raw['actor_id'])
  213.  
  214.     if mob then
  215.         return mob['name']
  216.     else
  217.         return nil
  218.     end
  219. end
  220.  
  221. --Returns the id of the actor
  222. function actionpacket:get_id()
  223.     return self.raw['actor_id']
  224. end
  225.  
  226. -- Returns an iterator for this actionpacket's targets
  227. function actionpacket:get_targets()
  228.     local targets = self.raw['targets']
  229.     local target_count = self.raw['target_count']
  230.     local i = 0
  231.     return function ()
  232.         i = i + 1
  233.         if i <= target_count then
  234.             return Target(self.raw['category'],self.raw['param'],targets[i])
  235.         end
  236.     end
  237. end
  238.  
  239. local target = {}
  240.  
  241. -- Constructor for target wrapper
  242. function Target(category,top_level_param,t)
  243.     if t == nil then
  244.         return
  245.     end
  246.  
  247.     local new_instance = {}
  248.     new_instance.raw = t
  249.     new_instance.category = category
  250.     new_instance.top_level_param = top_level_param
  251.     new_instance.id = t.id
  252.  
  253.     return setmetatable(new_instance, {__index = function (t, k) if rawget(t, k) ~= nil then return t[k] else return target[k] end end})
  254. end
  255.  
  256. -- Returns an iterator for this target's actions
  257. function target:get_actions()
  258.     local action_count = self.raw['action_count']
  259.     local i = 0
  260.     return function ()
  261.         i = i + 1
  262.         if i <= action_count then
  263.             return Action(self.category,self.top_level_param,self.raw['actions'][i])
  264.         end
  265.     end
  266. end
  267.  
  268. -- Returns the name of this target if there is one
  269. function target:get_name()
  270.     local mob = windower.ffxi.get_mob_by_id(self.raw['id'])
  271.  
  272.     if mob then
  273.         return mob['name']
  274.     else
  275.         return nil
  276.     end
  277. end
  278.  
  279. local reaction_strings = {
  280.     [1] = 'evade',
  281.     [2] = 'parry',
  282.     [4] = 'block/guard',
  283.     [8] = 'hit'
  284.     -- 12 = blocked?
  285.     }
  286.  
  287. local animation_strings = {
  288.     [0] = 'main hand',
  289.     [1] = 'off hand',
  290.     [2] = 'left kick',
  291.     [3] = 'right kick',
  292.     [4] = 'daken throw'
  293.     }
  294.  
  295. local effect_strings = {
  296.     [2] = 'critical hit'
  297.     }
  298.  
  299. local stagger_strings = {
  300.     }
  301.  
  302. local action = {}
  303.  
  304. function Action(category,top_level_param,t)
  305.     if category == nil or t == nil then
  306.         return
  307.     end
  308.  
  309.     local new_instance = {}
  310.     new_instance.raw = t
  311.     new_instance.raw.category = category_strings[category] or category
  312.     new_instance.raw.top_level_param = top_level_param
  313.  
  314.     return setmetatable(new_instance, {__index = function (t, k) if rawget(t, k) ~= nil then return t[k] else return action[k] or rawget(rawget(t,'raw'),k) end end})
  315. end
  316.  
  317. function action:get_basic_info()
  318.     local reaction = self:get_reaction_string()
  319.     local animation = self:get_animation_string()
  320.     local effect = self:get_effect_string()
  321.     local stagger = self:get_stagger_string()
  322.     local message_id = self:get_message_id()
  323.    
  324.     local param, resource, spell_id, interruption, conclusion = self:get_spell()
  325.    
  326.     return {reaction = reaction, animation = animation, effect=effect, message_id = message_id,
  327.         stagger = stagger, param = param, resource = resource, spell_id = spell_id,
  328.         interruption = interruption, conclusion = conclusion}
  329. end
  330.  
  331. function action:get_reaction_string()
  332.     local reaction = rawget(rawget(self,'raw'),'reaction')
  333.     return rawget(reaction_strings,reaction) or reaction
  334. end
  335.  
  336. function action:get_animation_string()
  337.     local animation = rawget(rawget(self,'raw'),'animation')
  338.     return rawget(animation_strings,animation) or animation
  339. end
  340.  
  341. function action:get_effect_string()
  342.     local effect = rawget(rawget(self,'raw'),'effect')
  343.     return rawget(effect_strings,effect) or effect
  344. end
  345.  
  346. function action:get_stagger_string()
  347.     local stagger = rawget(rawget(self,'raw'),'stagger')
  348.     return rawget(stagger_strings,stagger) or stagger
  349. end
  350.  
  351. local cat_to_res_map = {['weaponskill_finish']='weapon_skills', ['spell_finish']='spells',
  352.     ['item_finish']='items', ['job_ability']='job_abilities', ['weaponskill_begin']='weapon_skills',
  353.     ['casting_begin']='spells', ['item_begin']='items', ['mob_tp_finish']='monster_abilities',
  354.     ['avatar_tp_finish']='job_abilities', ['job_ability_unblinkable']='job_abilities',
  355.     ['job_ability_run']='job_abilities'}
  356. local begin_categories = {['weaponskill_begin']=true, ['casting_begin']=true, ['item_begin']=true, ['ranged_begin']=true}
  357. local finish_categories = {['melee']=true,['ranged_finish']=true,['weaponskill_finish']=true, ['spell_finish']=true, ['item_finish']=true,
  358.     ['job_ability']=true, ['mob_tp_finish']=true, ['avatar_tp_finish']=true, ['job_ability_unblinkable']=true,
  359.     ['job_ability_run']=true}
  360. local msg_id_to_conclusion_map = {
  361.     [26]   = {subject="target", verb="gains",   objects={"HP","MP"}     },
  362.     [31]   = {subject="target", verb="loses",   objects={"shadows"}     },
  363.     [112]  = {subject="target", verb="count",   objects={"doom"}        },
  364.     [120]  = {subject="actor",  verb="gains",   objects={"Gil"}         },
  365.     [132]  = {subject="target", verb="steals",  objects={"HP"}          },
  366.     [133]  = {subject="actor",  verb="steals",  objects={"Petra"}       },
  367.     [152]  = {subject="actor",  verb="gains",   objects={"MP"}          },
  368.     [229]  = {subject="target", verb="loses",   objects={"HP"}          },
  369.     [231]  = {subject="actor",  verb="loses",   objects={"effects"}     },
  370.     [530]  = {subject="target", verb="count",   objects={"petrify"}     }, --  Gradual Petrify
  371.     [557]  = {subject="actor",  verb="gains",   objects={"Alexandrite"} }, --  Using a pouch
  372.     [560]  = {subject="actor",  verb="gains",   objects={"FMs"}         }, --  No Foot Rise
  373.     [572]  = {subject="actor",  verb="steals",  objects={"ailments"}    }, --  Sacrifice
  374.     [585]  = {subject="actor",  verb="has",     objects={"enmity"}      }, --  Libra with actor
  375.     [586]  = {subject="target", verb="has",     objects={"enmity"}      }, --  Libra without actor
  376.     [674]  = {subject="actor",  verb="gains",   objects={"items"}       }, --  Scavenge
  377.     [730]  = {subject="target", verb="has",     objects={"TP"}          },
  378.     }
  379. local expandable = {}
  380. expandable[{1,  2,  67, 77, 110,157,
  381.             163,185,196,197,223,252,
  382.             264,265,288,289,290,291,
  383.             292,293,294,295,296,297,
  384.             298,299,300,301,302,317,
  385.             352,353,379,419,522,576,
  386.             577,648,650,732}]         = {subject="target", verb="loses",   objects={"HP"}         }
  387. expandable[{122,167,383}]             = {subject="actor",  verb="gains",   objects={"HP"}         }
  388. expandable[{7,  24, 102,103,238,263,
  389.         306,318,357,367,373,382,384,
  390.         385,386,387,388,389,390,391,
  391.         392,393,394,395,396,397,398,
  392.         539,587,606,651}]             = {subject="target", verb="gains",   objects={"HP"}         }
  393. expandable[{25, 224,276,358,451,588}] = {subject="target", verb="gains",   objects={"MP"}         }
  394. expandable[{161,187,227,274,281}]     = {subject="actor",  verb="steals",  objects={"HP"}         }
  395. expandable[{165,226,454,652}]         = {subject="actor",  verb="steals",  objects={"TP"}         }
  396. expandable[{162,225,228,275,366}]     = {subject="actor",  verb="steals",  objects={"MP"}         }
  397. expandable[{362,363}]                 = {subject="target", verb="loses",   objects={"TP"}         }
  398. expandable[{369,403,417}]             = {subject="actor",  verb="steals",  objects={"attributes"} }
  399. expandable[{370,404,642}]             = {subject="actor",  verb="steals",  objects={"effects"}    }
  400. expandable[{400,570,571,589,607}]     = {subject="target", verb="loses",   objects={"ailments"}   }
  401. expandable[{401,405,644}]             = {subject="target", verb="loses",   objects={"effects"}    }
  402. expandable[{409,452,537}]             = {subject="target", verb="gains",   objects={"TP"}         }
  403. expandable[{519,520,521,591}]         = {subject="target", verb="gains",   objects={"daze"}       }
  404. expandable[{14, 535}]                 = {subject="actor",  verb="loses",   object={"shadows"}     }
  405. expandable[{603,608}]                 = {subject="target", verb="gains",   objects={"TH"}         }
  406. expandable[{33, 44, 536,}]            = {subject="actor",  verb="loses",   objects={"HP"}         }
  407. for ids,tab in pairs(expandable) do
  408.     for _,id in pairs(ids) do
  409.         msg_id_to_conclusion_map[id] = tab
  410.     end
  411. end
  412. local function msg_id_to_conclusion(msg_id)
  413.     return rawget(msg_id_to_conclusion_map,msg_id) or false
  414. end
  415.  
  416. function action:get_spell()
  417.     local category = rawget(rawget(self,'raw'),'category')
  418.     -- It's far more accurate to filter by the resources line.
  419.    
  420.     local function fieldsearch(message_id)
  421.         if not message_id or not res.action_messages[message_id] or not res.action_messages[message_id].en then return false end
  422.         local fields = {}
  423.         res.action_messages[message_id].en:gsub("${(.-)}", function(a) if a ~= "actor" and a ~= "target" and a ~= 'lb' then rawset(fields,a,true) end end)
  424.         return fields
  425.     end
  426.    
  427.     local message_id = self:get_message_id()
  428.     local fields = fieldsearch(message_id)
  429.     local param = rawget(finish_categories, category) and rawget(rawget(self, 'raw'), 'param')
  430.     local spell_id = rawget(begin_categories, category) and rawget(rawget(self, 'raw'), 'param') or
  431.         rawget(finish_categories, category) and rawget(rawget(self, 'raw'), 'top_level_param')
  432.     local interruption = rawget(begin_categories, category) and rawget(rawget(self, 'raw'), 'top_level_param') == 28787
  433.     if interruption == nil then interruption = false end
  434.        
  435.     local conclusion = msg_id_to_conclusion(message_id)
  436.    
  437.     local resource
  438.     if not fields or message_id == 31 then
  439.         -- If there is no message, assume the resources type based on the category.
  440.         if category == 'weaponskill_begin' and spell_id <= 256 then
  441.             resource = 'weapon_skills'
  442.         elseif category == 'weaponskill_begin' then
  443.             resource = 'monster_abilities'
  444.         else
  445.             resource = rawget(cat_to_res_map,category) or false
  446.         end
  447.     else
  448.         local msgID_to_res_map = {
  449.             [244] = 'job_abilities', -- Mug
  450.             [328] = 'job_abilities', -- BPs that are out of range
  451.             }
  452.         -- If there is a message, interpret the fields.
  453.         resource = msgID_to_res_map[message_id] or fields.spell and 'spells' or
  454.             fields.weapon_skill and spell_id <= 256 and 'weapon_skills' or
  455.             fields.weapon_skill and spell_id > 256 and 'monster_abilities' or
  456.             fields.ability and 'job_abilities' or
  457.             fields.item and 'items' or rawget(cat_to_res_map,category)
  458.         local msgID_to_spell_id_map = {
  459.             [240] = 43, -- Hide
  460.             [241] = 43, -- Hide failing
  461.             [303] = 74, -- Divine Seal
  462.             [304] = 75, -- Elemental Seal
  463.             [305] = 76, -- Trick Attack
  464.             [311] = 79, -- Cover
  465.             }
  466.         spell_id = msgID_to_spell_id_map[message_id] or spell_id
  467.     end
  468.    
  469.     -- param will be a number or false
  470.     -- resource will be a string or false
  471.     -- spell_id will either be a number or false
  472.     -- interruption will be true or false
  473.     -- conclusion will either be a table or false
  474.    
  475.     return param, resource, spell_id, interruption, conclusion
  476. end
  477.  
  478. function action:get_message_id()
  479.     local message_id = rawget(rawget(self,'raw'),'message')
  480.     return message_id or 0
  481. end
  482.  
  483.  
  484. ---------------------------------------- Additional Effects ----------------------------------------
  485. local add_effect_animation_strings = {}
  486.  
  487. add_effect_animation_strings['melee'] = {
  488.     [1]   = 'enfire',
  489.     [2]   = 'enblizzard',
  490.     [3]   = 'enaero',
  491.     [4]   = 'enstone',
  492.     [5]   = 'enthunder',
  493.     [6]   = 'enwater',
  494.     [7]   = 'enlight',
  495.     [8]   = 'endark',
  496.     [12]  = 'enblind',
  497.     [14]  = 'enpetrify',
  498.     [21]  = 'endrain',
  499.     [22]  = 'enaspir',
  500.     [23]  = 'enhaste',
  501.     }
  502.  
  503. add_effect_animation_strings['ranged_finish'] = add_effect_animation_strings['melee']
  504.  
  505. add_effect_animation_strings['weaponskill_finish'] = {
  506.     [1]   = 'light',
  507.     [2]   = 'darkness',
  508.     [3]   = 'gravitation',
  509.     [4]   = 'fragmentation',
  510.     [5]   = 'distortion',
  511.     [6]   = 'fusion',
  512.     [7]   = 'compression',
  513.     [8]   = 'liquefaction',
  514.     [9]   = 'induration',
  515.     [10]  = 'reverberation',
  516.     [11]  = 'transfixion',
  517.     [12]  = 'scission',
  518.     [13]  = 'detonation',
  519.     [14]  = 'impaction',
  520.     }
  521.  
  522. add_effect_animation_strings['spell_finish'] = add_effect_animation_strings['weaponskill_finish']
  523.  
  524. local add_effect_effect_strings = {
  525.     }
  526. function action:get_add_effect()
  527.     if not rawget(rawget(self,'raw'),'has_add_effect') then return false end
  528.     local animation = self:get_add_effect_animation_string()
  529.     local effect = self:get_add_effect_effect_string()
  530.     local param = rawget(rawget(self,'raw'),'add_effect_param')
  531.     local message_id = rawget(rawget(self,'raw'),'add_effect_message')
  532.     local conclusion = msg_id_to_conclusion(message_id)
  533.     return {animation = animation, effect = effect, param = param,
  534.         message_id = message_id,conclusion = conclusion}
  535. end
  536.  
  537. function action:get_add_effect_animation_string()
  538.     local add_effect_animation = rawget(rawget(self,'raw'),'add_effect_animation')
  539.     local add_eff_animation_tab = rawget(add_effect_animation_strings,rawget(rawget(self,'raw'),'category'))
  540.     return add_eff_animation_tab and rawget(add_eff_animation_tab,add_effect_animation) or add_effect_animation
  541. end
  542.  
  543. function action:get_add_effect_effect_string()
  544.     local add_effect_effect = rawget(rawget(self,'raw'),'add_effect_effect')
  545.     return rawget(add_effect_effect_strings,add_effect_effect) or add_effect_effect
  546. end
  547.  
  548. function action:get_add_effect_conclusion()
  549.     return msg_id_to_conclusion(rawget(rawget(self,'raw'),'add_effect_message'))
  550. end
  551.  
  552.  
  553. ------------------------------------------- Spike Effects ------------------------------------------
  554. local spike_effect_animation_strings = {
  555.     [1]  = 'blaze spikes',
  556.     [2]  = 'ice spikes',
  557.     [3]  = 'dread spikes',
  558.     [4]  = 'water spikes',
  559.     [5]  = 'shock spikes',
  560.     [6]  = 'reprisal',
  561.     [7]  = 'wind spikes',
  562.     [8]  = 'stone spikes',
  563.     [63] = 'counter',
  564.     }
  565.  
  566. local spike_effect_effect_strings = {
  567.     }
  568. function action:get_spike_effect()
  569.     if not rawget(rawget(self,'raw'),'has_spike_effect') then return false end
  570.     local effect = self:get_spike_effect_effect_string()
  571.     local animation = self:get_spike_effect_animation_string()
  572.     local param = rawget(rawget(self,'raw'),'spike_effect_param')
  573.     local message_id = rawget(rawget(self,'raw'),'spike_effect_message')
  574.     local conclusion = msg_id_to_conclusion(message_id)
  575.     return {animation = animation, effect = effect, param = param,
  576.         message_id = message_id,conclusion = conclusion}
  577. end
  578.  
  579. function action:get_spike_effect_effect_string()
  580.     local spike_effect_effect = rawget(rawget(self,'raw'),'spike_effect_effect')
  581.     return rawget(spike_effect_effect_strings,spike_effect_effect) or spike_effect_effect
  582. end
  583.  
  584. function action:get_spike_effect_animation_string()
  585.     local spike_effect_animation = rawget(rawget(self,'raw'),'spike_effect_animation')
  586.     return rawget(spike_effect_animation_strings,spike_effect_animation) or spike_effect_animation
  587. end
  588.  
  589. function action:get_additional_effect_conclusion()
  590.     return msg_id_to_conclusion(rawget(rawget(self,'raw'),'spike_effect_message'))
  591. end
  592.  
  593.  
  594.  
  595.  
  596. --[[
  597. Copyright (c) 2013, Suji
  598. All rights reserved.
  599.  
  600. Redistribution and use in source and binary forms, with or without
  601. modification, are permitted provided that the following conditions are met:
  602.  
  603.     * Redistributions of source code must retain the above copyright
  604.       notice, this list of conditions and the following disclaimer.
  605.     * Redistributions in binary form must reproduce the above copyright
  606.       notice, this list of conditions and the following disclaimer in the
  607.       documentation and/or other materials provided with the distribution.
  608.     * Neither the name of actions nor the
  609.       names of its contributors may be used to endorse or promote products
  610.       derived from this software without specific prior written permission.
  611.  
  612. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  613. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  614. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  615. DISCLAIMED. IN NO EVENT SHALL SUJI BE LIABLE FOR ANY
  616. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  617. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  618. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  619. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  620. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  621. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  622. ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement