From b439246d6de5be57ce4b9c06a1fd82d0db7e79d8 Mon Sep 17 00:00:00 2001 From: Asriel Senna Date: Sun, 17 Dec 2023 10:13:58 +0100 Subject: [PATCH] Better constant and random management in door/summon Using a local __choice like in map to avoid unnecessary inconstantness This is same-behavior, but I would be in favor of reseeding only at the beginning of the day/night instead of every time the summon menu is opened (next commit) --- game/scripts/interface/door.rpy | 127 +++++++++++++++++--------------- 1 file changed, 69 insertions(+), 58 deletions(-) diff --git a/game/scripts/interface/door.rpy b/game/scripts/interface/door.rpy index e9d0769e..d918e4b3 100644 --- a/game/scripts/interface/door.rpy +++ b/game/scripts/interface/door.rpy @@ -3,6 +3,71 @@ #################################### default summon_show_busy = True +default door_randomobj = renpy.random.Random() + +init python: + def __choice(seq): + seed = door_randomobj.getstate() + rv = door_randomobj.choice(seq) + door_randomobj.setstate(seed) + return rv + +define map_transcript_loc = dict( + library = "Library", + room_g = "Gryffindor Dormitory", + room_s = "Slytherin Dormitory", + room_r = "Ravenclaw Dormitory", + room_h = "Hufflepuff Dormitory", + great_hall = "Great Hall", + courtyard = "Courtyard", + forest = "Forest", + greenhouse = "Greenhouse", + defense = "D.A.D.A Classroom", + training_grounds = "Training Grounds", + Lake = "Lake", + randomstudent = functools.partial(__choice, ( + "Classroom", + "Bathroom", + "Hagrid's Hut", + "Weasley's Store", + "Mafkin's Store", + "Broom Cupboard", + "Attic")), + randomsnape = functools.partial(__choice, ( + "Classroom", + "Boathouse", + "Bathroom", + "Snape's Office", + "Hall", + "Slytherin Dormitory", + "Library", + "Attic", + "Forest", + "Lake", + "Dungeons", + "Quidditch Cave", + "Staircase", + "Behind your door", + "Room of Doom")), + randomtonks = functools.partial(__choice, ( + "Classroom", + "Bathroom", + "Hall", + "Gryffindor Dormitory", + "Slytherin Dormitory", + "Hufflepuff Dormitory", + "Ravenclaw Dormitory", + "Training Grounds", + "Tonks's Room", + "Quidditch Pitch", + "Infirmary", + "Sex Dungeon", + "Hospital Wing", + "Forest", + "Lake", + "Greenhouse", + "Mafkin's Store")), +) label summon: $ gui.in_context("summon_menu") @@ -11,63 +76,6 @@ label summon: label summon_menu(xx=723, yy=90): $ renpy.dynamic( - map_transcript_loc = { - "library": "Library", - "room_g": "Gryffindor Dormitory", - "room_s": "Slytherin Dormitory", - "room_r": "Ravenclaw Dormitory", - "room_h": "Hufflepuff Dormitory", - "great_hall": "Great Hall", - "courtyard": "Courtyard", - "forest": "Forest", - "greenhouse": "Greenhouse", - "defense": "D.A.D.A Classroom", - "training_grounds": "Training Grounds", - "Lake": "Lake", - "randomstudent": renpy.random.choice(( - "Classroom", - "Bathroom", - "Hagrid's Hut", - "Weasley's Store", - "Mafkin's Store", - "Broom Cupboard", - "Attic")), - "randomsnape": renpy.random.choice(( - "Classroom", - "Boathouse", - "Bathroom", - "Snape's Office", - "Hall", - "Slytherin Dormitory", - "Library", - "Attic", - "Forest", - "Lake", - "Dungeons", - "Quidditch Cave", - "Staircase", - "Behind your door", - "Room of Doom")), - "randomtonks": renpy.random.choice(( - "Classroom", - "Bathroom", - "Hall", - "Gryffindor Dormitory", - "Slytherin Dormitory", - "Hufflepuff Dormitory", - "Ravenclaw Dormitory", - "Training Grounds", - "Tonks' Room", - "Quidditch Pitch", - "Infirmary", - "Sex Dungeon", - "Hospital Wing", - "Forest", - "Lake", - "Greenhouse", - "Mafkin's Store")), - }, - # Door dictionary summon_dict = { # the order will be the one in the menu @@ -82,6 +90,8 @@ label summon_menu(xx=723, yy=90): }, ) + $ door_randomobj.seed() + call screen summon(xx, yy) return @@ -179,7 +189,8 @@ screen summon_menu(): xysize (48, 48) add crop_image_zoom("interface/icons/head/"+char_dict["ico"]+".webp", 42, 42, char_dict["busy"]) align (0.5, 0.5) - text map_transcript_loc[char_dict["loc"]] size 10 xcenter 0.6 yalign 0.9 + $ loc = map_transcript_loc[char_dict["loc"]] + text (loc() if callable(loc) else loc) size 10 xcenter 0.6 yalign 0.9 if not states.sna.unlocked: text "You don't know anyone" size 12 at truecenter