A set of simple tools to spawn random loot.
Requires DataManager!
The script operates with three types of entities: "drops" - a random count of the specified item to be spawned, "roll" - a collection of drops to choose one (or none) from at random, "stock" - a collection of rolls to generate an inventory at random.
example.lua
shows how to use it (also makes use of ContainerFramework)
DoorFramework.createDrop(
creates an item drop record to be added to an item roll/
item,
a table withrefId
,charge
,enchantmentCharge
andsoul
of the item. All butrefId
are optional.
min,
minimal possible count ofitem
max,
amximal possible count ofitem
distribution
distribution to be used when taking count at random. 'uniform' by default.
)
returnsdropId
DropFramework.getDrop(dropId)
returns the drop record: (distribution and some fields ofitem
could benil
){ item = item, min = min, max = max, distribution = distribution }
DropFramework.removeDrop(dropId)
removes the given drop from DropFramework's data
DropFramework.addDrop(name, dropId)
creates a single-drop roll to stock withname
DropFramework.addRoll(
adds a roll with specified drops and their chances of being selected (if the sum of chances is>=1
it's guaranteed not to select nothing)
name,
of the stock to add this roll to
drops,
list ofdropId
s
chances
list of values between0
and1
)
DropFramework.addStock(name)
creates an empty stock withname
DropFramework.removeStock(name)
removes the stock withname
DropFramework.resolveStock(name)
returns a randomly generated inventory dictated by stock withname