WTS/game/scripts/rooms/main_room/objects/cupboard.rpy

165 lines
6.5 KiB
Plaintext
Raw Normal View History

2022-05-16 23:48:22 +00:00
label cupboard:
if states.cupboard_rummaged:
if states.env.daytime:
nar "You have already searched the cupboard today."
2022-05-16 23:48:22 +00:00
else:
nar "You have already searched the cupboard tonight."
2022-05-16 23:48:22 +00:00
jump main_room_menu
$ states.cupboard_rummaged = True # Resets every day/night.
$ states.cupboard_rummaged_times += 1 # Stat counter.
2022-05-16 23:48:22 +00:00
$ cupboard_OBJ.idle = "cupboard_open"
call gen_chibi("rummage", 160, 459, flip=False) # Note: Flip is inconsistent
with d3
show screen bld1
with d3
nar "You rummage through the cupboard for a while..."
2022-05-16 23:48:22 +00:00
$ random_percent = renpy.random.randint(1, 100)
# Dueling potion
2024-04-25 19:14:25 +00:00
if states.env.day <= 3 and states.cupboard_rummaged_times in [1,2]:
$ states.healing_potions += 1
call give_reward("You found some sort of healing potion...","interface/icons/item_potion.webp")
2022-05-16 23:48:22 +00:00
$ cupboard_OBJ.idle = "cupboard_idle"
call gen_chibi("sit_behind_desk")
jump main_room_menu
# Dumbledore card
2024-04-25 19:14:25 +00:00
if states.env.day >= 26 and states.cardgame.unlocked and random_percent <= 40 and not card_exist(unlocked_cards,card_dumbledore) :
2022-05-16 23:48:22 +00:00
call give_reward("You have found a special card!", "images/cardgame/t1/special/dumbledore_v1.webp")
$ unlocked_cards += [card_dumbledore]
$ cupboard_OBJ.idle = "cupboard_idle"
call gen_chibi("sit_behind_desk")
jump main_room_menu
# Map
if not states.map.unlocked and states.her.favors_unlocked:
$ states.map.unlocked = True
call give_reward("You found a map of the school grounds.", "interface/icons/generic_scroll.webp")
2022-05-16 23:48:22 +00:00
gen "What's this? A map?" ("base", xpos="far_left", ypos="head")
$ cupboard_OBJ.idle = "cupboard_idle"
call gen_chibi("sit_behind_desk")
call tutorial("map")
gen "Sweet! That will be useful." ("grin", xpos="far_left", ypos="head")
jump main_room_menu
# Randomly drop something
call rum_block(drop_item_from_cupboard(random_percent))
$ cupboard_OBJ.idle = "cupboard_idle"
call gen_chibi("sit_behind_desk")
jump main_room_menu
label examine_cupboard:
if not states.gen.ev.intro.cupboard_examined:
$ states.gen.ev.intro.cupboard_examined = True
$ cupboard_OBJ.idle = "cupboard_idle"
$ cupboard_OBJ.action = Jump("examine_cupboard")
call gen_chibi("stand","behind_desk","base", flip=False)
with d5
pause.2
call bld
gen "*Hmm*..." ("base", xpos="far_left", ypos="head")
gen "A cupboard..." ("base", xpos="far_left", ypos="head")
gen "Maybe I should rummage through this one later..." ("base", xpos="far_left", ypos="head")
call gen_chibi("sit_behind_desk")
else:
gen "Looks like any other cupboard, maybe a bit dustier." ("base", xpos="far_left", ypos="head")
jump main_room_menu
2022-05-16 23:48:22 +00:00
label rum_block(item):
if isinstance(item, int):
2024-04-25 19:12:50 +00:00
$ states.env.gold += item
call give_reward("You found [item] gold...", "interface/icons/gold.webp")
2022-05-16 23:48:22 +00:00
elif item == "nothing":
nar "You found nothing of value..."
2022-05-16 23:48:22 +00:00
else:
$ item.owned += 1
if item == wine_ITEM:
call give_reward("You found a bottle of wine from professor Dumbledore's personal stash...", item)
2022-05-16 23:48:22 +00:00
elif item == firewhisky_ITEM:
call give_reward("You found a bottle of firewhisky from professor Dumbledore's personal stash...", item)
2022-05-16 23:48:22 +00:00
else:
call give_reward("You found [item.name]...", item)
2022-05-16 23:48:22 +00:00
call tutorial("inventory")
hide screen gift
with d3
return
init python:
def drop_item_from_cupboard(random_percent):
drop_list = [item for item in inventory.get_instances_of_type("gift") if item.unlocked]
2024-04-25 19:14:25 +00:00
dr = max(states.cupboard_rummaged_times - states.env.day, 0) * 2 # Frequent rummaging penalty
progress_factor = math.log(states.her.tier + states.cho.tier + states.ton.tier + states.lun.tier + states.env.day)
2022-05-16 23:48:22 +00:00
if firewhisky_ITEM.unlocked and firewhisky_ITEM.owned < 1:
return firewhisky_ITEM
elif wine_ITEM.owned < 1:
return wine_ITEM
2024-04-25 19:10:46 +00:00
if states.env.difficulty == 1:
2022-05-16 23:48:22 +00:00
# Easy
# Soft diminishing returns, more rubber banding. Guaranteed item drop.
2024-04-25 19:14:25 +00:00
if states.env.gold < int(170 * math.log(states.env.day)) and random_percent <= 56 - dr:
2024-04-26 23:51:45 +00:00
return int(progress_factor * states.env.random.randint(8, 40))
2022-05-16 23:48:22 +00:00
else:
2022-09-29 21:19:55 +00:00
filtered_list = [x for x in drop_list if x.owned <= 5]
random_item = renpy.random.choice(filtered_list or drop_list)
2022-05-16 23:48:22 +00:00
return random_item
2024-04-25 19:10:46 +00:00
elif states.env.difficulty == 2:
2022-05-16 23:48:22 +00:00
# Normal
# Fair diminishing returns, soft rubber banding. High chance for item drop. (Recommended)
2024-04-25 19:14:25 +00:00
if states.env.gold < int(120 * math.log(states.env.day)) and random_percent <= 38 - dr:
2024-04-26 23:51:45 +00:00
return int(progress_factor * states.env.random.randint(8, 40))
2022-05-16 23:48:22 +00:00
else:
2022-09-29 21:19:55 +00:00
filtered_list = [x for x in drop_list if x.owned <= 3]
random_item = renpy.random.choice(filtered_list or drop_list)
2022-05-16 23:48:22 +00:00
2024-04-25 19:14:25 +00:00
if int(120 * math.log(states.env.day)) / 3 < random_item.price:
2022-05-16 23:48:22 +00:00
chance = max(6 - (random_item.owned * 5), 1)
2024-04-25 19:12:50 +00:00
elif states.env.gold > random_item.price:
2022-05-16 23:48:22 +00:00
chance = max(65 - (random_item.owned * 15), 5)
else:
chance = max(95 - (random_item.owned * 10), 15)
if random_percent <= chance - dr:
return random_item
else:
return "nothing"
2024-04-25 19:10:46 +00:00
elif states.env.difficulty == 3:
2022-05-16 23:48:22 +00:00
# Hard
# Harsh diminishing returns, no rubber banding. Chance for item drop.
2024-04-25 19:14:25 +00:00
if states.env.gold < int(90 * math.log(states.env.day)) and random_percent <= 33 - dr:
2024-04-26 23:51:45 +00:00
return int(progress_factor * states.env.random.randint(8, 40))
2022-05-16 23:48:22 +00:00
else:
random_item = renpy.random.choice(drop_list)
2024-04-25 19:14:25 +00:00
if int(90 * math.log(states.env.day)) / 3 < random_item.price:
2022-05-16 23:48:22 +00:00
chance = max(3 - (random_item.owned * 5), 1)
2024-04-25 19:12:50 +00:00
elif states.env.gold > random_item.price:
2022-05-16 23:48:22 +00:00
chance = max(40 - (random_item.owned * 15), 0)
else:
chance = max(75 - (random_item.owned * 10), 5)
if random_percent <= chance - dr:
return random_item
else:
return "nothing"