question

Jose Pablo Monge Chacon avatar image
Jose Pablo Monge Chacon asked

Changing item granted from container after droptable

Hello there playfab team, still in love with everything.

I have a question, right now we are creating a random drop system, where we should be making a check on the item that's going to be granted before we assign it to make sure that's not a duplicate. To my understanding, opening a container item automatically assigns items (and the droptable calculations are done when it's being opened). But we need it to sort of cascade for example we have

Rare head item

Common head item

Currency containers

in the container we'd have

Rare head droptable 20%

Common head droptable 30%

Currency droptable 50%

What we want to do is check if the item that comes from the "roll of the dice" is already in the player's inventory, and if not,be able to roll again (either roll again or try to get the next item in the droptable to assign it).  The way we want it to work is to cascade to the lower items, for example, if I already have all the rare head items, I should cascade to the common head items, and if I already have all of them, then I should be able to drop down to currency (which would be the last step on the cascade since we don't have a limit to currency).

 

I am trying to figure out how to do this using the already built in functionality in playfab, before actually going in and programming the whole system on cloud script from scratch.  Is there an event that is activated when the droptable is calculated?? How could I intercept the result before actually assigning the item?? We have several items that we need to work out with this.

Thanks in advance!

 

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

Thanks!

Right now, the way drop tables work is as part of a Container or Bundle, so there is no "shortcut" mechanism such as you describe - you would need to do randomization in Cloud Script directly (also as you describe).

That said, this is a request we've heard a few times now, so let me ask - what's your timeframe like for this?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

As discussed in our other thread on this (https://community.playfab.com/hc/en-us/community/posts/210474687-Changing-item-granted-from-container-after-droptable), we'll have EvaluateRandomResultTable available in the Server API set next week, so the way to do this at that point would be:

Use EvaluateRandomResultTable to get a result from table1, which would be built with the weightings: Rare (20), Common (30), Currency (50). If that results in a Rare item the player already has, get a result from table2, which would be built with only Common and Currency (weightings could be 50/50 or whatever else you feel is appropriate). If you get an item the player doesn't have, you would use GrantItemsToUser to give the item to the player, and if not (or if you get the Currency result), you would use either AddUserVirtualCurrency or GrantItemsToUser with a bundle item containing the currency to give the appropriate amount to the user.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jose Pablo Monge Chacon avatar image
Jose Pablo Monge Chacon answered

Hi Brendan,

We'll we have to deliver the system on may 16th, so it has to be ready by next week, (a week after that tops).
Right now, based on what you are telling me I am going to do the following:

1. Change all items to be stackable

2. Once we "open" the chest, check if the delivered item now has a stack count of > 1

3. If it does, then we just cascade down to currency.

 

This is not the ideal case of what we wanted to do, but I guess is as good as we can get with the current state of the tools.

 

 

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

So, to be completely transparent for everyone's sake, normally we would have to say this simply isn't possible. Swapping unplanned work into our schedule requires pulling someone off their currently prioritized work, causing delays to other feature work - and commonly, work which will directly impact many people (since we prioritize in part based on the aggregate need of our community).

But as it happens, we've heard the request for a Server API to get the ItemId result from a Random Result Table without actually generating the item and putting it in the player inventory a number of times now, and I was able to carve out some of my time today to implement this feature. It is in testing now, and will be rolled live early next week (it will be Server/EvaluateRandomResultTable).

Jose, in answer to your questions for around your implementation, this new API method will enable you to have a Cloud Script which checks the result, and then use a grant operation to either give they player that item or some virtual currency. You could also have a fallback table that you use for a second lookup potentially, as well.

And while it's not your design goal, I'll point out for everyone's sake that using a loop to iteratively hit the table to try to get something the player doesn't have is not a good idea. Cloud Scripts are limited to 10 Server API calls during their execution, so that would result in the script failing for any case where that limit is hit.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jose Pablo Monge Chacon avatar image
Jose Pablo Monge Chacon answered

Sweet! Thanks for this Brendan,  right now my solution is currently working. But with this implementation I would be saving a couple of Server API calls which is always welcome to have. 

In case anyone is curious,we made all items stackable and consumable. Once that's set

UnlockContainer

We search the player's inventory to check ifthe received item stack is > 1

Then we Consume 1 use

Add Currency

And then done

 

And I agree, looping to try tog get something might make the server get stuck for a while, so we are taking the route of always falling back to currency.

 

Thanks a lot Brendan! You are awesome as usual.

 

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.