Jump to content

Keeping track of my loot values :)


shaba123

Recommended Posts

                    if (itemToPickUp.interact("Take")) {
                            lootValue = lootValue + itemValues.get(itemToPickUp.getName());
                            Sleep.sleepUntil(() -> !itemToPickUp.exists() , 5000); 
                            log(lootValue);

As you can see after i click take on the grounditem i add the value of the item to my lootvalue integer. The problem is if it clicks the item more than once it will add the value of the item twice. I cant check if the item is in my inventory to add the value because i am using a looting bag.

I could add a longer sleep timer to make sure my player reaches the loot before clicking it again but someitmes my player is frozen.

Any ideas guys? thanks :)

 

edit: also another question while iv got you guys, i sleep until !item.exists but that doesnt correctly if there is multiple of the same item on the ground.

Edited by shaba123
Link to comment
Share on other sites

I personally make a hash of inventory before looting and after looting, and if the two values are different then it means you picked up an item, ofc this doesn't apply to looting bag so you may want to check if grounditem disappeared (still can be looted by someone else tho) so it's never 100% accurate :feels: 

I would definitely give this one a read though, it's an inventory listener that keeps track of items gained: 

 

  • Like 1
Link to comment
Share on other sites

On 6/2/2023 at 7:14 AM, shaba123 said:

edit: also another question while iv got you guys, i sleep until !item.exists but that doesnt correctly if there is multiple of the same item on the ground.

You will probably have to make your own exist method. And best way to track loot for looting bag would be when you bank update it, otherwise check for inventory changes then update etc

  • Like 1
Link to comment
Share on other sites

19 hours ago, Czar said:

I personally make a hash of inventory before looting and after looting, and if the two values are different then it means you picked up an item, ofc this doesn't apply to looting bag so you may want to check if grounditem disappeared (still can be looted by someone else tho) so it's never 100% accurate :feels: 

I would definitely give this one a read though, it's an inventory listener that keeps track of items gained: 

 

 

12 hours ago, Gunman said:

You will probably have to make your own exist method. And best way to track loot for looting bag would be when you bank update it, otherwise check for inventory changes then update etc

Thank you !

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...