Item cooldown

Additional botting resources. Addons may be either for the game itself or for the RoM bot.
Forum rules
Only post additional bot resources here. Please do not ask unrelated questions.
Post Reply
Message
Author
User avatar
ThulsaDoom
Posts: 125
Joined: Mon Oct 19, 2015 2:46 pm

Item cooldown

#1 Post by ThulsaDoom » Mon Apr 15, 2024 2:49 am

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

User avatar
Administrator
Site Admin
Posts: 5308
Joined: Sat Jan 05, 2008 4:21 pm

Re: Item cooldown

#2 Post by Administrator » Mon Apr 15, 2024 8:16 am

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.

User avatar
ThulsaDoom
Posts: 125
Joined: Mon Oct 19, 2015 2:46 pm

Re: Item cooldown

#3 Post by ThulsaDoom » Mon Apr 15, 2024 1:09 pm

Now it works properly.

Thank you

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest