Browse Source

Fixed an issue with the addon not grabbing the attachment from the memory in startup.

I think i finally tracked down and fixed the part of the code that kept either erroring out or not loading the default attachments.
master
Tornac 5 years ago
parent
commit
a4aa098ed7
  1. 29
      pupatt.lua

29
pupatt.lua

@ -23,9 +23,9 @@
* No warranties are given. * No warranties are given.
]]-- ]]--
_addon.author = 'tornac'; _addon.author = 'Tornac';
_addon.name = 'pupatt'; _addon.name = 'pupatt';
_addon.version = '1.10'; _addon.version = '1.12';
--------------------------------- ---------------------------------
--DO NOT EDIT BELOW THIS LINE --DO NOT EDIT BELOW THIS LINE
@ -39,26 +39,25 @@ require 'timer'
-------------------------------------------------------------- --------------------------------------------------------------
-- Default settings. -- Default settings.
-------------------------------------------------------------- --------------------------------------------------------------
currentProfile = { };
attachmentQueue = { }; -- Table to hold commands queued for sending
objDelay = 0.65; -- The delay to prevent spamming packets. objDelay = 0.65; -- The delay to prevent spamming packets.
objTimer = 0; -- The current time used for delaying packets. objTimer = 0; -- The current time used for delaying packets.
unequip = 0x00; unequip = 0x00;
pupSub = 0x00; pupSub = 0x00;
offset = 0x04; offset = 0x04;
local PlayerName = nil;
inProgress = false; -- packet sending is in progress. inProgress = false; -- packet sending is in progress.
queOffset = 1; -- smoother experience for packets. queOffset = 1; -- smoother experience for packets.
defaultAtt = false;
currentProfile = { };
attachmentQueue = { }; -- Table to hold commands queued for sending
currentAttachments = { }; -- table for holding current attachments
pupattProfiles = { }; -- table for holding attachment profiles pupattProfiles = { }; -- table for holding attachment profiles
petlessZones = {50,235,234,224,284,233,70,257,251,14,242,250,226,245, petlessZones = {50,235,234,224,284,233,70,257,251,14,242,250,226,245,
237,249,131,53,252,231,236,246,232,240,247,243,223,248,230, 237,249,131,53,252,231,236,246,232,240,247,243,223,248,230,
26,71,244,239,238,241,256,257} 26,71,244,239,238,241,256,257}
--------------------------------------------------------------- ---------------------------------------------------------------
--try to load file when addon is loaded. --try to load file when addon is loaded
--------------------------------------------------------------- ---------------------------------------------------------------
ashita.register_event('load', function() ashita.register_event('load', function()
@ -96,9 +95,6 @@ ashita.register_event('incoming_packet', function(id, size, packet)
end end
end end
end end
if (id == 0x000A) then
attFromMemory()
end
return false; return false;
end); end);
@ -214,7 +210,6 @@ end;
function process_queue() function process_queue()
if (os.clock() >= (objTimer + objDelay)) then if (os.clock() >= (objTimer + objDelay)) then
objTimer = os.clock(); objTimer = os.clock();
-- Ensure the queue has something to process.. -- Ensure the queue has something to process..
if (#attachmentQueue > queOffset) then if (#attachmentQueue > queOffset) then
queOffset = 0 queOffset = 0
@ -241,8 +236,10 @@ end
ashita.register_event('render', function() ashita.register_event('render', function()
-- Process the objectives packet queue.. -- Process the objectives packet queue..
process_queue(); process_queue();
attFromMemory();
end); end);
--------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------
-- func: load_pupattSettings -- func: load_pupattSettings
-- desc: load pup attachments from a file and sets currentattachment equip. -- desc: load pup attachments from a file and sets currentattachment equip.
@ -250,7 +247,6 @@ end);
function load_pupattSettings() function load_pupattSettings()
local tempCommands = ashita.settings.load(_addon.path .. '/settings/pupattProfiles.json'); local tempCommands = ashita.settings.load(_addon.path .. '/settings/pupattProfiles.json');
if tempCommands ~= nil then if tempCommands ~= nil then
print('Stored objective profiles found.'); print('Stored objective profiles found.');
pupattProfiles = tempCommands; pupattProfiles = tempCommands;
@ -296,6 +292,7 @@ end;
--------------------------------------------------------------- ---------------------------------------------------------------
function attFromMemory() function attFromMemory()
if (defaultAtt == false) then
local pointer1 = ashita.memory.findpattern('FFXiMain.dll', 0, 'C1E1032BC8B0018D????????????B9????????F3A55F5E5B', 10, 0); local pointer1 = ashita.memory.findpattern('FFXiMain.dll', 0, 'C1E1032BC8B0018D????????????B9????????F3A55F5E5B', 10, 0);
if (pointer1 == 0) then if (pointer1 == 0) then
err('Failed to locate current attachments, please cycle a attachment to continue.'); err('Failed to locate current attachments, please cycle a attachment to continue.');
@ -304,9 +301,13 @@ function attFromMemory()
pointer = ashita.memory.read_uint32(AshitaCore:GetPointerManager():GetPointer('inventory')); pointer = ashita.memory.read_uint32(AshitaCore:GetPointerManager():GetPointer('inventory'));
pointer = ashita.memory.read_uint32(pointer); pointer = ashita.memory.read_uint32(pointer);
currentAttachments = ashita.memory.read_array((pointer + offset1) + offset, 0x0E); currentAttachments = ashita.memory.read_array((pointer + offset1) + offset, 0x0E);
if (currentAttachments ~= nil) then
for i = 1, 14 do for i = 1, 14 do
currentAttachments[i] = string.format("0x%X" , currentAttachments[i]); currentAttachments[i] = string.format("0x%X" , currentAttachments[i]);
end end
defaultAtt = true
end
end
end end
end; end;
@ -408,4 +409,6 @@ ashita.register_event('command', function(command, ntype)
{'/pupatt despawn', ' - despawns the puppet.'}, {'/pupatt despawn', ' - despawns the puppet.'},
}); });
return true; return true;
end); end);

Loading…
Cancel
Save