Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _addon.name = 'Voidslacker'
- _addon.author = 'Lygre'
- _addon.commands = {'vs','voidslacker'}
- _addon.version = '1.0.0.1'
- require('luau')
- require('pack')
- require('lists')
- require('logger')
- require('sets')
- files = require('files')
- extdata = require('extdata')
- packets = require('packets')
- require('chat')
- res = require('resources')
- local pkt = {}
- local busy = false
- local settings = {enabled=false,loot_action=10}
- windower.register_event('addon command', function(...)
- local args = T{...}
- local cmd = args[1]:lower()
- args:remove(1)
- if cmd == 'on' then
- settings.enabled = true
- elseif cmd == 'status' then
- windower.add_to_chat(3, 'Enabled: '..tostring(settings.enabled))
- elseif cmd == 'fix' then
- pkt = validate()
- if pkt then
- busy = true
- poke_npc(pkt['Target'],pkt['Target Index'])
- end
- elseif L{'loot','box'}:contains(cmd) then
- local cmd = args[1]:lower()
- args:remove(1)
- if L{'obtain','get'}:contains(cmd) then
- settings.loot_action = 10
- windower.add_to_chat(3, 'Loot action: Obtain')
- elseif L{'drop','relinquish'}:contains(cmd) then
- settings.loot_action = 9
- windower.add_to_chat(3, 'Loot action: relinquish')
- else
- windower.add_to_chat(3, 'invalid selection, option')
- end
- end
- end)
- -------------------------------------------------------
- --------------Identify Pyxis on Spawn------------------
- windower.register_event('incoming chunk', function(id,data)
- if settings.enabled then
- if id == 0x038 then
- local packet = packets.parse('incoming',data)
- local array = windower.ffxi.get_mob_array()
- local walker = check_vwalker()
- for k,v in pairs(array) do
- if packet['Mob'] == v.id and L{'Riftworn Pyxis'}:contains(array[k].name) and packet['Type'] == 'deru' and walker then
- print('Spawn',packet['Mob'],packet['Type'])
- pkt = validate()
- if pkt then
- busy = true
- coroutine.sleep(2)
- poke_npc(pkt['Target'],pkt['Target Index'])
- end
- end
- end
- end
- end
- if id == 0x034 then
- --Packet reponse from poking Pyxis
- if busy == true and pkt then
- local packet = packets.parse('incoming',data)
- --obtaining menu id for npc from packet
- pkt['Menu ID']=packet['Menu ID']
- windower.add_to_chat(3, pkt['Menu ID'])
- local packet = packets.new('outgoing', 0x05B)
- --injecting obtain all command to Pyxis and NPC release
- packet["Target"]=pkt['Target']
- packet["Option Index"]=settings.loot_action
- packet["_unknown1"]=0
- packet["Target Index"]=pkt['Target Index']
- packet["Automated Message"]=false
- packet["_unknown2"]=0
- packet["Zone"]=pkt['Zone']
- packet["Menu ID"]=pkt['Menu ID']
- packets.inject(packet)
- local packet = packets.new('outgoing', 0x016, {
- ["Target Index"]=pkt['me'],
- })
- packets.inject(packet)
- busy = false
- pkt = {}
- return true
- end
- end
- end)
- -------------------------------------------------------
- -----------Check for voidwalker status----------------
- ----Returns true if active, false otherwise-----------
- function check_vwalker()
- local buffs = windower.ffxi.get_player().buffs
- for _,v in pairs(buffs) do
- if v == 475 then
- return true
- end
- end
- return false
- end
- -------------------------------------------------------
- -----------Obtains player id, target id, index, and distance----------------
- ----returns result['me'] as player id-----------
- function validate()
- local me,target_index,target_id,distance
- local zone = windower.ffxi.get_info()['zone']
- local result = {}
- for i,v in pairs(windower.ffxi.get_mob_array()) do
- if v['name'] == windower.ffxi.get_player().name then
- result['me'] = i
- -- elseif L{'Riftworn Pyxis','Planar Rift'}:contains(v['name']) then
- elseif L{'Riftworn Pyxis'}:contains(v['name']) then
- target_index = i
- target_id = v['id']
- -- result['Menu ID'] = valid_zones[zone].menu
- distance = windower.ffxi.get_mob_by_id(target_id).distance
- end
- end
- if math.sqrt(distance)<6 then
- result['Target'] = target_id
- -- result['Option Index'] = ite['Option']
- -- result['_unknown1'] = ite['Index']
- result['Target Index'] = target_index
- result['Zone'] = zone
- else
- windower.add_to_chat(10,"Too far from npc")
- end
- return result
- end
- ----0x027 contains rift info?
- -------------------------------------------------------
- -----------Pokes given npc id & index----------------
- ----Injects an NPC interaction packet to which we receive another packet we can react to-----------
- function poke_npc(npc,target_index)
- if npc and target_index then
- local packet = packets.new('outgoing', 0x01A, {
- ["Target"]=npc,
- ["Target Index"]=target_index,
- ["Category"]=0,
- ["Param"]=0,
- ["_unknown1"]=0})
- packets.inject(packet)
- end
- end
Add Comment
Please, Sign In to add comment