I've tried to make these compatible with the current implementation to make a minimal footprint and attached them below in case its suitable to include in standard rombot.
Also, I suggest we include one new address offset 'addresses.pawnCasting_offset - 0x04' which is the ID of the cast being done. I.E. when pawn.Casting is true the address above contains the ID of skill being cast.
best regards
DX
Code: Select all
function CPawn:updateBuffs()
if not self:hasAddress() then
self.buffs = {};
return
end
local proc = getProc()
local BuffSize = 0x54
local buffStart = memoryReadRepeat("uint", proc, self.Address + addresses.pawnBuffsStart_offset);
local buffEnd = memoryReadRepeat("uint", proc, self.Address + addresses.pawnBuffsEnd_offset);
self.Buffs = {} -- clear old values
if buffStart == nil or buffEnd == nil or buffStart == 0 or buffEnd == 0 then return end
if (buffEnd - buffStart)/ BuffSize > 50 then -- Something wrong, too many buffs
return
end
for i = buffStart, buffEnd - 4, BuffSize do
local tmp = {}
tmp.Id = memoryReadRepeat("int", proc, i + addresses.pawnBuffId_offset);
tmp.Count = 1
local name = GetIdName(tmp.Id)
if name ~= nil and name ~= "" then
tmp.Name, tmp.Count = parseBuffName(name)
end
tmp.TimeLeft = memoryReadRepeat("float", proc, i + addresses.pawnBuffTimeLeft_offset);
tmp.Level = memoryReadRepeat("int", proc, i + addresses.pawnBuffLevel_offset);
table.insert(self.Buffs,tmp)
end
end
Code: Select all
function CPawn:getBuff(buffnamesorids, count)
self:updateBuffs()
if type(buffnamesorids) == "number" then
buffnamesorids = {buffnamesorids}
elseif type(buffnamesorids) == "string" then
local buffs = {}
for buffname in string.gmatch(buffnamesorids,"[^,]+") do
table.insert(buffs, buffname)
end
buffnamesorids = buffs
end
-- for each buff the pawn has
for i, buff in pairs(self.Buffs) do
for j,buffname in pairs(buffnamesorids) do
if (buffname == buff.Name or buffname == buff.Id) and (count == nil or buff.Count >= count) then
return buff
end
end
end
return false
end