To explain as briefly as I can; There is a shop system in the game, you can "custom order" items if the item you are looking for isn't in the shop inventory during your visit (it reshuffles every week). This custom order takes whatever amount you want to invest in from 350G to 5000G using a bar VariableValue function. The more you invest the better chance the quality outcome will be. So if you invest 350G you will get "cheap" quality, invest 5000G you will likely get "masterwork" quality.
The Function Code:
Code: Select all
QUALITY_TO_INDEX = {
"Cheap": 0,
"Simple": 1,
"Fine": 2,
"Elegant": 3,
"Ornate": 4,
"Masterwork": 5
}
APPAREL_MIN_MAX = {
"Cheap": (28, 2000),
"Simple": (322, 3500),
"Fine": (600, 5000),
"Elegant": (1200, 6000),
"Ornate": (2500, 7000),
"Masterwork": (4000, 6000)
}
DISPLAY_PERCENTAGES = [0, 0, 0, 0, 0, 0]
def custom_chance(price):
AVAIL_QUALITIES = []
POSSIBLE_PERCENTAGES = []
CUSTOM_ORDER_WEIGHTS = []
for key, value in APPAREL_MIN_MAX.items():
min_value = value[0]
if price > min_value:
AVAIL_QUALITIES.append(key)
min_value = [tup[0] for tup in APPAREL_MIN_MAX.values()]
max_value = [tup[1] for tup in APPAREL_MIN_MAX.values()]
idx = QUALITY_TO_INDEX[AVAIL_QUALITIES[0]]
count = 0
while count < len(AVAIL_QUALITIES):
qual_min_weight = price - min_value[idx]
qual_max_weight = price - max_value[idx]
idx += 1
count += 1
qweight = min([qual_min_weight, abs(qual_max_weight)])
CUSTOM_ORDER_WEIGHTS.append(qweight)
for weight in CUSTOM_ORDER_WEIGHTS:
percent = (weight/(sum(CUSTOM_ORDER_WEIGHTS)))*100
POSSIBLE_PERCENTAGES.append(percent)
count = 0
for quality in AVAIL_QUALITIES:
DISPLAY_PERCENTAGES[QUALITY_TO_INDEX.get(quality)] = round(POSSIBLE_PERCENTAGES[count], 2)
count += 1
renpy.show_screen("tailor_hud")
Code: Select all
screen shop_list():
tag first
text "Choose where to shop." xoffset glist_posX+290 yoffset glist_posY+22 font "font/maian.ttf" size 18
hbox:
xoffset glist_posX+12
yoffset glist_posY+15
spacing 11
imagebutton:
auto "tailor_btn_%s.png"
action (Function(custom_chance(CUSTOM_ITEM_PRICE), SetScreenVariable("selected_shop", "tailor")))
imagebutton: #ignore this for now
auto "merchant_btn_%s.png"
action (Show("merchant_hud"), SetScreenVariable("selected_shop", "merchant"))
screen tailor_hud():
tag second
add "gui/main_hud/tailor_hud.jpg" xoffset glist_posX yoffset glist_posY+62
bar:
value VariableValue("CUSTOM_ITEM_PRICE", 4650, offset=350, step=50, force_step=True)
xoffset glist_posX+32
yoffset glist_posY+560
base_bar "gui/bar/shop_price.png"
thumb "gui/bar/mini_thumb.png"
thumb_offset 7
xysize (380, 30)
left_gutter 10
right_gutter 22
text "[CUSTOM_ITEM_PRICE]" xoffset glist_posX+178 yoffset glist_posY+528 size 21 font "font/maian.ttf" color gold_color
vbox:
for txt in DISPLAY_PERCENTAGES:
text str(txt)
xalign 0.5
yalign 0.5
At first this is the correct output. But when I slide my slider the numbers go all wonky. This is after sliding it to 750G. The numbers here are already wrong as some chances should even be 0%.:
And sliding it back again to 350G. In theory, it should go back to 92% and 8%, but it just messes up:
Sorry for the long thread but I've spent a couple days trying to figure this out and it sure is frustrating lol. Very much thanks to anyone who has read my long ass thread and is willing to give advice. ^^~