RPG Loot Drop Engine
Project description
RPG Loot Drop Engine
What started as a personal project of getting better at python and learning about lootboxes turned into something that might be useful to others.
These sites helped me understand the basic concept and mechanics of loot boxes/tables:
When I stumbled across this two article series, I was "Booyah!!!!". The original code was written in C#. This project is my resulting translation.
Differences between the original and this engine:
- The flag
always
will always drop at least one item from a table or of that item. Initial testing showed thatalways
would always drop one and only one. To always drop one and only onealways
andunique
will both need to betrue
. - The
Randomizer
was not implemented - The
IRDSObjectCreator
and subsequent code was not implemented. I didn't see the need, based on what I was trying to do.
Install
pip install drop-generator
Sample code
from dropgen.RDSTable import RDSTable
from dropgen.RDSItem import RDSItem
if __name__ == '__main__':
loot_table = RDSTable(count=5)
loot_table.add_entry(RDSItem("Ham Sandwich"))
loot_table.add_entry(RDSItem("Felt Hat"))
loot_table.add_entry(RDSItem("Diamond Ring"))
loot_table.add_entry(RDSItem("Red Brick"))
loot_table.add_entry(RDSItem("Feral Cat"))
loot_table.add_entry(RDSItem("Empty Flask"))
loot_table.add_entry(RDSItem("Someone's garbage"))
results = loot_table.rds_result
print("Simple loot drop. Everything has the same chance")
for result in results:
print(f"\t{result}")
Code changes to try out
Flags can be set at RDSItem
or RDSTable
creation time or set/adjusted upon being added to the parent RDSTable
.
loot_table.add_entry(RDSItem("Feral Cat", probability=5))
and
loot_table.add_entry(RDSItem("Feral Cat"), probability=5)
These two statements functionally achieve the same thing.
The flags you can set.
always
: An item or item from a table will always drop at least once. If enough items/tables are marked withalways
, then actual drops could actually exceed what is defined (count
)in the parent table.unique
: If the item is selected, then it will be dropped only once.probability
: The probability of the item dropping. Wikipediaenabled
: Will this item drop.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for drop_generator-0.0.35-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e41c0dc8b34f1f5298675b4aee88803ddff9691b4f037cc29042e7945d6d751 |
|
MD5 | a04fc2dce8a316aead577c42e938358c |
|
BLAKE2b-256 | 2ccd96a6aee0a27fb7c9bf0e88ebb71718619621e362588c73ab0ebdfbe0553f |