question

brendan avatar image
brendan asked

How does a container behave if there's no key defined for it?

Brendan Vanous
started a topic on Thu, 18 September 2014 at 10:13 AM

I'd like to create a "gift" container, which I'm going to distribute to players as awards for certain actions in my game. I see that the key item in the container item is optional. If I create a container with no key, will it stay in the player's inventory as a container until the unlock call is made (and what happens when it is)?

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 Thu, 18 September 2014 at 10:13 AM

Yes, a container defined as having no key acts exactly the same as any other container, waiting in the user inventory until the UnlockContainerItem API is called on it. When that call is made, a check is made for the key item. If there isn't one defined, the container is opened, and the items added to the user inventory (as well as any virtual currency). Those items can be other defined catalog items, but they can also be random result tables, allowing for random loot drop treasure chests, for example.

One other thing to note: Containers and keys should normally be defined as consumables, having a limited number of uses. When the container is opened, if it is a consumable, its remaining uses will be decremented by one. The same applies to the key, if one is defined. Any key or container not defined as consumable will be infinitely re-usable.


1 Comment
Brendan Vanous said on Thu, 18 September 2014 at 10:13 AM

Yes, a container defined as having no key acts exactly the same as any other container, waiting in the user inventory until the UnlockContainerItem API is called on it. When that call is made, a check is made for the key item. If there isn't one defined, the container is opened, and the items added to the user inventory (as well as any virtual currency). Those items can be other defined catalog items, but they can also be random result tables, allowing for random loot drop treasure chests, for example.

One other thing to note: Containers and keys should normally be defined as consumables, having a limited number of uses. When the container is opened, if it is a consumable, its remaining uses will be decremented by one. The same applies to the key, if one is defined. Any key or container not defined as consumable will be infinitely re-usable.

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.