Page 1 of 1

Item cooldown

Posted: Mon Apr 15, 2024 2:49 am
by ThulsaDoom
Hello;

I want to determine if I can use potions (in this case rage), using the following function:

Code: Select all

inventory:update();
local item1 = inventory:findItem(itemNameOrId)	
local item2 = inventory:findItem(itemNameOrId)	
local cd1, success = item1:getRemainingCooldown()
local cd2, success = item2:getRemainingCooldown()
if item1 and cd1 == 0 then
	item1:use()
elseif item2 and cd2 == 0 then
	item2:use()
end
The fact is that it always always tries to use item1 because the cooldown is always 0
Reviewing the function Classes -> Item -> CItem:getRemainingCooldown() I see the following and if I understand correctly, the function always returns cooldown = 0

Code: Select all

function CItem:getRemainingCooldown()
	local skillItemId = memoryReadInt( getProc(), self.BaseItemAddress + addresses.item.real_id );
	if ( skillItemId ~= nil and skillItemId ~= 0 ) then
		local skillItemAddress = GetItemAddress( skillItemId );
		if ( skillItemAddress ~= nil and skillItemAddress ~= 0 ) then
			local val = memoryReadRepeat("int", getProc(), skillItemAddress + 0xE0)
			local plusoffset
			if val == 1 then plusoffset = 0 elseif val == 3 then plusoffset = 0x80C else return 0, false end
			if memoryReadRepeat("int", getProc(), skillItemAddress + 0xE0) ~= 0 then
				--local offset = memoryReadRepeat("int", getProc(), skillItemAddress + addresses.skillRemainingCooldown_offset)
				--return (memoryReadRepeat("int", getProc(), addresses.staticCooldownsBase + plusoffset + (offset+1)*4) or 0)/10, true
				local index = memoryReadRepeat("int", getProc(), skillItemAddress + addresses.skill.remaining_cooldown) or 0
				local addr = getBaseAddress(addresses.cooldowns.base + addresses.cooldowns.array_start + plusoffset) + (index*4);
				local tmp = (memoryReadInt(getProc(), addr) or 0) / 10;
			end
		end
	end
	return 0, false
end

Is there a reason why this function is designed this way?

Thanks a lot for your support

Re: Item cooldown

Posted: Mon Apr 15, 2024 8:16 am
by Administrator
The game had an update awhile ago that moved where an item's cooldown is stored. That made it really difficult to keep track of. It looks like I put that temporary fix in to just make it work while I had patched up all the other changes and then just forgot about the item cooldown.

I just pushed up a fix now that should resolve this issue. Update your scripts and give it a try.

Re: Item cooldown

Posted: Mon Apr 15, 2024 1:09 pm
by ThulsaDoom
Now it works properly.

Thank you