Advertisement
Lygre

Void

Mar 15th, 2017
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.44 KB | None | 0 0
  1. _addon.name = 'Voidslacker'
  2. _addon.author = 'Lygre'
  3. _addon.commands = {'vs','voidslacker'}
  4. _addon.version = '1.0.0.1'
  5.  
  6.  
  7. require('luau')
  8. require('pack')
  9. require('lists')
  10. require('logger')
  11. require('sets')
  12. files = require('files')
  13. extdata = require('extdata')
  14. packets = require('packets')
  15. require('chat')
  16. res = require('resources')
  17.  
  18. local pkt = {}
  19. local busy = false
  20. local settings = {enabled=false}
  21.  
  22. windower.register_event('addon command', function(...)
  23.     local args = T{...}
  24.     local cmd = args[1]
  25.     args:remove(1)
  26.     if cmd == 'on' then
  27.         settings.enabled = true
  28.     elseif cmd == 'off' then
  29.         settings.enabled = false
  30.     elseif cmd == 'status' then
  31.         windower.add_to_chat(3, 'Enabled: '..tostring(settings.enabled))
  32.     elseif cmd == 'fix' then
  33.         pkt = validate()
  34.         if pkt then
  35.             busy = true
  36.             poke_npc(pkt['Target'],pkt['Target Index'])
  37.         end
  38.     end
  39. end)
  40.  
  41. -------------------------------------------------------
  42. --------------Identify Pyxis on Spawn------------------
  43. windower.register_event('incoming chunk', function(id,data)
  44.     if settings.enabled then
  45.         if id == 0x038 then
  46.             local packet = packets.parse('incoming',data)
  47.             local array = windower.ffxi.get_mob_array()
  48.             local walker = check_vwalker()
  49.             for k,v in pairs(array) do
  50.                 if packet['Mob'] == v.id and L{'Riftworn Pyxis'}:contains(array[k].name) and packet['Type'] == 'deru' and walker then
  51.                     print('Spawn',packet['Mob'],packet['Type'])
  52.                     pkt = validate()
  53.                     if pkt then
  54.                         busy = true
  55.                         coroutine.sleep(2)
  56.                         poke_npc(pkt['Target'],pkt['Target Index'])
  57.                     end
  58.                 end
  59.             end
  60.         end
  61.     end
  62.     if id == 0x034 then
  63.         --Packet reponse from poking Pyxis
  64.         if busy == true and pkt then
  65.             local packet = packets.parse('incoming',data)
  66.             --obtaining menu id for npc from packet
  67.                 pkt['Menu ID']=packet['Menu ID']
  68.                 windower.add_to_chat(3, pkt['Menu ID'])
  69.             local packet = packets.new('outgoing', 0x05B)
  70.             --injecting obtain all command to Pyxis and NPC release
  71.                 packet["Target"]=pkt['Target']
  72.                 packet["Option Index"]=10
  73.                 packet["_unknown1"]=0
  74.                 packet["Target Index"]=pkt['Target Index']
  75.                 packet["Automated Message"]=false
  76.                 packet["_unknown2"]=0
  77.                 packet["Zone"]=pkt['Zone']
  78.                 packet["Menu ID"]=pkt['Menu ID']
  79.                 packets.inject(packet)
  80.             local packet = packets.new('outgoing', 0x016, {
  81.             ["Target Index"]=pkt['me'],
  82.             })
  83.             packets.inject(packet)
  84.             busy = false
  85.             pkt = {}
  86.             return true
  87.         end
  88.     end
  89. end)
  90.  
  91. -------------------------------------------------------
  92. -----------Check for voidwalker status----------------
  93. ----Returns true if active, false otherwise-----------
  94. function check_vwalker()
  95.     local buffs = windower.ffxi.get_player().buffs
  96.  
  97.     for _,v in pairs(buffs) do
  98.         if v == 475 then
  99.             return true
  100.         end
  101.     end
  102.  
  103.     return false
  104. end
  105.  
  106. -------------------------------------------------------
  107. -----------Obtains player id, target id, index, and distance----------------
  108. ----returns result['me'] as player id-----------
  109. function validate()
  110.     local me,target_index,target_id,distance
  111.     local zone = windower.ffxi.get_info()['zone']
  112.     local result = {}
  113.     for i,v in pairs(windower.ffxi.get_mob_array()) do
  114.         if v['name'] == windower.ffxi.get_player().name then
  115.             result['me'] = i
  116.         -- elseif L{'Riftworn Pyxis','Planar Rift'}:contains(v['name']) then
  117.         elseif L{'Riftworn Pyxis'}:contains(v['name']) then
  118.             target_index = i
  119.             target_id = v['id']
  120.             -- result['Menu ID'] = valid_zones[zone].menu
  121.             distance = windower.ffxi.get_mob_by_id(target_id).distance
  122.         end
  123.     end
  124.     if math.sqrt(distance)<6 then
  125.         result['Target'] = target_id
  126.         -- result['Option Index'] = ite['Option']
  127.         -- result['_unknown1'] = ite['Index']
  128.         result['Target Index'] = target_index
  129.         result['Zone'] = zone
  130.     else
  131.         windower.add_to_chat(10,"Too far from npc")
  132.     end
  133.     return result
  134. end
  135.  
  136. ----0x027 contains rift info?
  137.  
  138. -------------------------------------------------------
  139. -----------Pokes given npc id & index----------------
  140. ----Injects an NPC interaction packet to which we receive another packet we can react to-----------
  141. function poke_npc(npc,target_index)
  142.     if npc and target_index then
  143.         local packet = packets.new('outgoing', 0x01A, {
  144.             ["Target"]=npc,
  145.             ["Target Index"]=target_index,
  146.             ["Category"]=0,
  147.             ["Param"]=0,
  148.             ["_unknown1"]=0})
  149.         packets.inject(packet)
  150.     end
  151. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement