question

brendan avatar image
brendan asked

Random Result Tables, Containers, Bundles

Brendan Vanous
started a topic on Mon, 17 August 2015 at 3:58 PM

Question from a developer:

Could you clarify the usage of Random Result Tables and the ways they can be used (in Containers/Bundles)? If I want to have random loot as a reward to players, does it need to be in a container? And is this container consumed when used? Is it opened by a Key?

10 |1200

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

1 Answer

·
brendan avatar image
brendan answered

Best Answer
Brendan Vanous said on Mon, 17 August 2015 at 3:58 PM

First, I'd recommend having a look at this blog post on Gifting to Users: https://playfab.com/blog/2014/09/26/gift-giving-playfab-style.

A Random Result Table (or "Drop Table" or "Loot Table", if you prefer) is a weighted list of items, one of which will be selected at random (using the weights for the chance of each) when it is resolved. These tables can be put in Bundles or Containers, in order to give them to players.

Bundles are simply "with this item, I get these others". So when the Bundle itself is added to the player inventory, all the items listed in "Group Items" in the definition of the Bundle in your game's catalog are also added to the player inventory. If any of those items are Random Result Tables, that's the point at which the random choice is resolved. In this case, the Bundle itself is an inventory item, so if you want it to go away once it has delivered those items to the player inventory, just set its Usage Period to one second. That way, it will expire immediately after being added to the player inventory, but all the items it came with will remain.

Containers are like chests in the classic RPG sense. They may be locked or they may not, but you don't know what's in them until you open them. In PlayFab, you define an item as being a Container by selecting that flag in the item definition in the Catalog (or by setting the Container properties appropriately in the definition of the object when using our catalog API methods). The client can then attempt to get what's in it by calling UnlockContainerItem, which tells us to try to open the Container on the player's behalf. Containers may require a Key item to be opened - this is defined via the "Key Item ID" in the Container's definition in the game catalog. If there is a Key, that must also be present in the player's inventory for the Container to be opened. Both Containers and Keys can be defined as a limited consumable, by putting a value in their Usage Count. When you call UnlockContainerItem from the client, if the Container and any Key are present in the player's inventory, the items it contains are delivered to the player's inventory (this is the point where the Random Result Tables are resolved), and both Container and Key will have their Usage Counts (if any) decremented by one. If that results in them no longer having any uses left, they are removed from the player's inventory.

Brendan


1 Comment
Brendan Vanous said on Mon, 17 August 2015 at 3:58 PM

First, I'd recommend having a look at this blog post on Gifting to Users: https://playfab.com/blog/2014/09/26/gift-giving-playfab-style.

A Random Result Table (or "Drop Table" or "Loot Table", if you prefer) is a weighted list of items, one of which will be selected at random (using the weights for the chance of each) when it is resolved. These tables can be put in Bundles or Containers, in order to give them to players.

Bundles are simply "with this item, I get these others". So when the Bundle itself is added to the player inventory, all the items listed in "Group Items" in the definition of the Bundle in your game's catalog are also added to the player inventory. If any of those items are Random Result Tables, that's the point at which the random choice is resolved. In this case, the Bundle itself is an inventory item, so if you want it to go away once it has delivered those items to the player inventory, just set its Usage Period to one second. That way, it will expire immediately after being added to the player inventory, but all the items it came with will remain.

Containers are like chests in the classic RPG sense. They may be locked or they may not, but you don't know what's in them until you open them. In PlayFab, you define an item as being a Container by selecting that flag in the item definition in the Catalog (or by setting the Container properties appropriately in the definition of the object when using our catalog API methods). The client can then attempt to get what's in it by calling UnlockContainerItem, which tells us to try to open the Container on the player's behalf. Containers may require a Key item to be opened - this is defined via the "Key Item ID" in the Container's definition in the game catalog. If there is a Key, that must also be present in the player's inventory for the Container to be opened. Both Containers and Keys can be defined as a limited consumable, by putting a value in their Usage Count. When you call UnlockContainerItem from the client, if the Container and any Key are present in the player's inventory, the items it contains are delivered to the player's inventory (this is the point where the Random Result Tables are resolved), and both Container and Key will have their Usage Counts (if any) decremented by one. If that results in them no longer having any uses left, they are removed from the player's inventory.

Brendan

1 comment
10 |1200

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

andy-3 avatar image andy-3 commented ·

The gift giving link is broken. You can find it here. Gift Giving PlayFab Style

0 Likes 0 ·

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.