Page 1 of 1

Bot buys Potions and trowbag when allready there

Posted: Fri Dec 03, 2010 5:01 am
by botje
Like stated in Title, bot buys potion and trowbag, even when i have them.

i guess its because im botting in a region where i can only buy lower potions and trowbags, but should bot not be able to detect the higher ones anyway?

it should not buy lower ones if higher ones are present right?

Botje

Re: Bot buys Potions and trowbag when allready there

Posted: Fri Dec 03, 2010 5:36 am
by rock5
If it does, then it shouldn't. I'll look into it.

What it should do is, after finding the best store item, it should check the inventory and see how many items (of whatever level) are better than it. If there are more than the required amount, it doesn't buy any.

Re: Bot buys Potions and trowbag when allready there

Posted: Fri Dec 03, 2010 5:38 am
by botje
cool, thanx man :)

Re: Bot buys Potions and trowbag when allready there

Posted: Fri Dec 03, 2010 6:30 am
by rock5
Ok Ive done it but I couldn't be bothered to properly test it as I don't usually use consumables and would have to do too much, to set up conditions like you described, to do a test.

Could you just replace the whole storeBuyConsumable function in your inventory.lua with this code and see how it goes?

Code: Select all

function CInventory:storeBuyConsumable(type, quantity)
	-- Find best store item
	local bestLevel = 0;
	for storeSlot = 1, 28, 1 do
		local storeItemLink, icon, name, storeItemCost = RoMScript("GetStoreSellItemLink("..storeSlot.."),GetStoreSellItemInfo("..storeSlot..")");

		if (storeItemLink == "" or storeItemLink == nil) then
			break;
		end

		storeItemId, storeItemColor, storeItemName = CItem:parseItemLink(storeItemLink);
--		printf("%s %s\n", storeItemId, storeItemName);

		local consumable = database.consumables[storeItemId];

		if( consumable
		  and consumable.Type == type
		  and consumable.Level <= player.Level ) then
			if consumable.Level > bestLevel then
				bestLevel = consumable.Level;
				bestItem = storeItemId;
				bestItemSlot = storeSlot;
			end
		end
	end

	if bestLevel == 0 then
	    return false;
 	end

	-- Count number of better items in inventory
	self:update();

	local totalCount = 0;
 	for slot,item in pairs(self.BagSlot) do
		local consumable = database.consumables[item.Id];
	    if item.Available and
		  consumable and
		  consumable.Type == type and
		  consumable.Level >= bestLevel then
			totalCount = totalCount + item.ItemCount
		end;
	end;

	-- See how many needed
	if totalCount < quantity then
	    numberToBuy = quantity - totalCount;
	    printf(language[1001]);  -- Shopping
	    for i = 1, numberToBuy, 1 do
	    	RoMScript("StoreBuyItem("..bestItemSlot..")");
	    	printf(".");
		end
		printf("\n");
	end

	return true;
end

Re: Bot buys Potions and trowbag when allready there

Posted: Fri Dec 03, 2010 6:43 am
by botje
nice, works fine so far, doesnt buy any other items now :)

Botje

Re: Bot buys Potions and trowbag when allready there

Posted: Fri Dec 03, 2010 7:01 am
by rock5
Committed to rev 532.

Re: Bot buys Potions and trowbag when allready there

Posted: Fri Dec 03, 2010 8:12 am
by Giram
Is it possible to select what potions bot is buying?

Re: Bot buys Potions and trowbag when allready there

Posted: Fri Dec 03, 2010 6:04 pm
by rock5
Giram wrote:Is it possible to select what potions bot is buying?
Why would you want that? Isn't the highest one always the best?

It wouldn't be much of a auto buy function if you had to specify which potions to buy.

Which gives me a thought. Let me just check...

Yep, I forgot to check if the inventory potions are lower than the player level. Which means, when checking to see if you have higher lever items in your inventory, it will include ones that are too high for your player to use.

I'll have to fix that.

Re: Bot buys Potions and trowbag when allready there

Posted: Sat Dec 04, 2010 9:31 pm
by rock5
rock5 wrote:I forgot to check if the inventory potions are lower than the player level. Which means, when checking to see if you have higher lever items in your inventory, it will include ones that are too high for your player to use.

I'll have to fix that.
Finally added this fix in rev 536.