forked from Priestytheplushie/Corrupted-Shadows-Legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloot_tables.py
More file actions
80 lines (65 loc) · 2.05 KB
/
Copy pathloot_tables.py
File metadata and controls
80 lines (65 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import random
from items import *
from item_data import item_library
from item_factory import create_item
loot_tables = {
"goblin": {
"Goblin Tooth": 0.30,
"Health Potion": 0.15
},
"orc": {
"Orc's Mace": 0.05,
"Health Potion": 0.20
}
}
corrupted_extras = {
"generic": {
"Corrupted Essence": 0.25
},
"unstable": {
"Unstable Shard": 0.10
}
}
def roll_loot(table_name):
# If the table name is "none", return an empty list (no loot)
if table_name == "none" or table_name not in loot_tables:
return []
loot_drops = []
table = loot_tables[table_name]
# Iterate over the loot table to determine which items drop
for item_name, chance in table.items():
if random.random() <= chance:
item = create_item(item_name)
if item:
loot_drops.append(item)
return loot_drops
def roll_corrupted_loot(base_table_name, unstable=False):
if base_table_name == "none":
return []
loot = roll_loot(base_table_name)
for item_name, chance in corrupted_extras["generic"].items():
if random.random() <= chance:
item = create_item(item_name)
if item:
loot.append(item)
if unstable:
for item_name, chance in corrupted_extras["unstable"].items():
if random.random() <= chance:
item = create_item(item_name)
if item:
loot.append(item)
return loot
def roll_corrupted_loot(base_table_name, unstable=False):
loot = roll_loot(base_table_name)
for item_name, chance in corrupted_extras["generic"].items():
if random.random() <= chance:
item = create_item(item_name)
if item:
loot.append(item)
if unstable:
for item_name, chance in corrupted_extras["unstable"].items():
if random.random() <= chance:
item = create_item(item_name)
if item:
loot.append(item)
return loot