Using Loot Tables

Discussions, Solutions & How To with Inventory
User avatar
Adam
Site Admin
Posts: 106
Joined: 07 Aug 2009, 14:54
Location: London, UK
Contact:

Using Loot Tables

Postby Adam » 07 May 2011, 12:51

Using Loot Tables

This system supports two "Lootable Classes". Lootable Item and Lootable Object.

Lootable Items are designed for looting or picking up single objects or looting containers with only one item in them. Imagine a single weapon like a shotgun, or a box of ammunition, or a sword. The Lootable Item is usually attached to the GameObject in the game world allowing the pickup or looting of this item only. In the demo, items discarded back into the game world use a Lootable Item component to allow re-looting. The Lootable Item could also be an object or container that returns one single item, say a quest item, like a statue where one can loot a gem from it's head, or picking a flower that returns the "picked flower". Lootable Items contain only one item and it's always dropped at 100%. Lootable Item is primarily a convenience class, as one could have a standard Lootable Object that only contained only one item, but setting the master and child loot tables for just one item is cumbersome, and there is no reason not to create a convenience class for single items.

Lootable Objects are designed to be a typical object lootable by the player like a dead monster or chest that can contain any number of randomized items. Each Lootable Object contains a Master Loot Table which is an array/list of separate individual Loot Tables:
Image Image
This is done for ease of organization and or complete control over how loot spawns. As you can see in the two examples, you can organize these in any way you choose.

Each individual Loot Table within the Master Loot Table can be set up to behave differently from one another. A standard Loot Table is setup to take an array/list of items and their individual chances to spawn. This way you simply use a "string" variable that matches the name of the item in the item list and the chance for it to spawn.
Image

Currently the spawn chance is set as a number from 1-100, but this number is a float, so you could set the chance to 0.1 to get 1:1000.

To add control to Loot Generation, each individual Loot Table can be set to behave differently:
Image

Chance for List is an additional randomizer. This tests whether the list is used at all for loot generation. If Chance for List is set to true, you must also enter a List Chance. This is another random chance from 1-100. If you set Chance for List with a List Chance of 50, on average, only half of the objects with this loot table will spawn items from this list.

Pick Items from List is a different form of randomizing items from a Loot Table. When Pick Items from List is set to true, the system does not iterate through all of the items and test it's spawn chance, but randomly picks a number of items at random from the list. When Pick Items from List is set to true, you must also enter Number of Items. This sets the number of items from the list to pick. If an item has a Chance value set, this number will be ignored. The Chance value may be left blank/null. Optionally you may set Pick No Duplicate Items. When Pick No Duplicate Items is set to true and Number of Items is greater than one, the system will make sure that the same item is not chosen twice when spawning loot. (See important notes below!)

USING the complexity of the Loot Tables:
At first blush, this may seem to be an overly complicated system, but upon closer inspection the developer will be able to see that this will enable not only an ease in play balancing by being able to see different loot types (like trash loot & valuable loot) separated from each other with different loot tables, but the developer will also have control over situations where they need to deliver controlled amounts of loot using separate loot tables and pick from list.

In a simple example one could have a trash loot table and a valuable loot table for organization, each with a series of items that have their own chance to spawn. Then, in addition, have a special loot table with a series of important items set to "pick from list" and the number to pick as "1". In this scenario, the developer will know that this loot combination will only return one piece of valuable loot from any given lootable object sharing that same loot table. To further control loot generation, that loot table could be set to "Chance For List" and the "List Chance" to 33.3, so the developer can know that a valuable item will be created on an average of one in 3 lootable objects sharing that same loot table.

I am sure you can imagine even more complex situations, but with these simple tools, the developer should have accurate control over an item's loot generation.

PLEASE NOTE: Using "Pick Items from List" and "Pick No Duplicate Items" can lead to complicated situations, especially when used with "Unique" Items. If any of the optional details are set, the lootable object should be thoroughly tested and the developer should watch for details or errors throw into the console, as some options can create situations that are either incompatible or impossible. As I said: Be particularly careful with "Pick Items from List" and either "Pick No Duplicates" or when using items marked as "Unique" as situations can be created where there are not enough items to pick to fulfill systemic requirements. These situations should all be trapped and will throw an error into the console, but this could stop the looting process, which is acceptable during testing and development but not game play.

PLEASE NOTE: As "Lootable Items" are "pre-spawned" by the developer, and using a "Lootable Item" will bypass the unique item check. It is up to the developer to make sure that they only create and use one instance of any individual unique lootable item in the game world, and if a unique lootable item is placed in the game world that they do not add it to a loot table as well. This could create duplicate unique items.

Return to “Inventory (for Unity Gui)”

Who is online

Users browsing this forum: No registered users and 1 guest