From 591377163a28c0ca0ee42d472fd1da6590094b2b Mon Sep 17 00:00:00 2001 From: LoafyLemon Date: Mon, 13 Mar 2023 20:29:05 +0000 Subject: [PATCH] Lint, CDS, and bug fixes * Added weights support to random block statements * Added missing `open_wide_tongue_panties` mouth for Hermione * Simplified CDS vars and attributes, and changed them to be in line with Renpy standards * Fixed linting of character statements * Fixed 'jazz take 2.ogg' file being located in the wrong directory * Fixed minimum and maximum allowed initialization offset for statements * Fixed show image statement missing space * Fixed poster image show statement to enable prediction * Fixed updater screen lacking parenthesis (was valid but slowed down initialization) * Fixed random statement prediction * Fixed uncommented Tonks chit-chat check (forgot to do so after testing) --- .../{crooked => crooked_smile}/smile.webp | 0 .../open_wide_tongue_panties/expression.webp | 3 + game/{sounds => music}/jazz take 2.ogg | 0 game/scripts/cds.rpy | 82 +++++++++++-------- game/scripts/characters.rpy | 2 +- .../events/favors/lets_have_sex_anal.rpy | 2 +- game/scripts/characters/tonks/chitchats.rpy | 18 ++-- game/scripts/mods.rpy | 2 +- .../rooms/main_room/objects/poster.rpy | 2 +- game/scripts/utility/devtools.rpy | 4 +- game/scripts/utility/lint.rpy | 4 +- game/scripts/utility/updater.rpy | 2 +- 12 files changed, 69 insertions(+), 52 deletions(-) rename game/characters/cho/poses/default/face/mouth/{crooked => crooked_smile}/smile.webp (100%) create mode 100644 game/characters/hermione/poses/default/face/mouth/open_wide_tongue_panties/expression.webp rename game/{sounds => music}/jazz take 2.ogg (100%) diff --git a/game/characters/cho/poses/default/face/mouth/crooked/smile.webp b/game/characters/cho/poses/default/face/mouth/crooked_smile/smile.webp similarity index 100% rename from game/characters/cho/poses/default/face/mouth/crooked/smile.webp rename to game/characters/cho/poses/default/face/mouth/crooked_smile/smile.webp diff --git a/game/characters/hermione/poses/default/face/mouth/open_wide_tongue_panties/expression.webp b/game/characters/hermione/poses/default/face/mouth/open_wide_tongue_panties/expression.webp new file mode 100644 index 00000000..dcc6348b --- /dev/null +++ b/game/characters/hermione/poses/default/face/mouth/open_wide_tongue_panties/expression.webp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa1ee00eb2c69ef538a9e405a78de1917868a55ae999777cd5df8b26283ce984 +size 6480 diff --git a/game/sounds/jazz take 2.ogg b/game/music/jazz take 2.ogg similarity index 100% rename from game/sounds/jazz take 2.ogg rename to game/music/jazz take 2.ogg diff --git a/game/scripts/cds.rpy b/game/scripts/cds.rpy index 3f545fee..dc294285 100644 --- a/game/scripts/cds.rpy +++ b/game/scripts/cds.rpy @@ -1,26 +1,26 @@ python early: - def parse_chibi(lexer): - who = lexer.simple_expression() - action = lexer.simple_expression() + def parse_chibi(l): + who = l.simple_expression() + action = l.simple_expression() return (who, action) - def execute_chibi(parsed_object): - print(f"{parsed_object}") - who, action = parsed_object + def execute_chibi(p): + print(f"{p}") + who, action = p func = eval(f"{who[:3]}_chibi_new.{action}") print(f"Execution: {who} {action}") - def lint_chibi(parsed_object): - who, action = parsed_object + def lint_chibi(p): + who, action = p try: chibi = eval(f"{who[:3]}_chibi_new") # TODO: Update naming once testing is done except Exception: renpy.error(f"Character chibi not defined: {who}") - def predict_chibi(parsed_object): - who, action = parsed_object + def predict_chibi(p): + who, action = p chibi = eval(f"{who[:3]}_chibi_new") doll = eval(f"{who}") @@ -41,41 +41,53 @@ python early: predict=predict_chibi, ) - def parse_random(lexer): - l = lexer.subblock_lexer() - choices = [] + def parse_random(l): + l.require(":") + l.expect_eol() - while l.advance(): - loc = l.get_location() - condition = "True" + ll = l.subblock_lexer() + blocks = [] - if l.keyword('block'): - l.require(':') - l.expect_eol() - l.expect_block('block') + while ll.advance(): + with ll.catch_error(): + weight = 1.0 + condition = "True" - block = l.subblock_lexer().renpy_block() - choices.append((block, condition)) - elif l.keyword('if'): - l.expect_block("if block") - condition = l.require(l.python_expression) - l.require(':') + if ll.keyword("block"): + ll.expect_block("block") - block = l.subblock_lexer().renpy_block() - choices.append((block, condition)) + block = ll.subblock_lexer().renpy_block() + + if ll.keyword("weight"): + weight = float(ll.require(ll.float)) + + if ll.keyword("if"): + ll.expect_block("if block") + condition = ll.require(ll.python_expression) + else: + block = ll.renpy_statement() + + blocks.append((block, weight, condition)) + + return {"blocks": blocks} + + def next_random(p): + blocks = [(block, weight, condition) for block, weight, condition in p["blocks"] if eval(condition)] + total_weight = sum(weight for _, weight, _ in blocks) + n = renpy.random.random() * total_weight + + for block, weight, _ in blocks: + if n <= weight: + break else: - stmt = l.renpy_statement() - choices.append((stmt, condition)) + n -= weight - return choices - - def next_random(choices): - choices = [block for block, cond in choices if eval(cond)] - return renpy.random.choice(choices) + return block renpy.register_statement( name="random", block=True, + predict_all=True, parse=parse_random, next=next_random, ) diff --git a/game/scripts/characters.rpy b/game/scripts/characters.rpy index 78847ad9..6cb9a373 100644 --- a/game/scripts/characters.rpy +++ b/game/scripts/characters.rpy @@ -1,5 +1,5 @@ -init -1401 python: +init -999 python: # Remove style overrides adv.who_args.pop("style", None) adv.what_args.pop("style", None) diff --git a/game/scripts/characters/hermione/events/favors/lets_have_sex_anal.rpy b/game/scripts/characters/hermione/events/favors/lets_have_sex_anal.rpy index fcb1f055..cfca9e9d 100644 --- a/game/scripts/characters/hermione/events/favors/lets_have_sex_anal.rpy +++ b/game/scripts/characters/hermione/events/favors/lets_have_sex_anal.rpy @@ -1451,7 +1451,7 @@ label hg_anal_sex_3: play sound "sounds/slick_01.ogg" call cum_block - show her_sex_personal cum_pussy_light mouth_grin eyes_narrow_mid eyebrows_base cheeks_blush tears_softas cg + show her_sex_personal cum_pussy_light mouth_grin eyes_narrow_mid eyebrows_base cheeks_blush tears_soft as cg her "!!!" gen "{size=+15}Yes! *Argh*!{/size}" diff --git a/game/scripts/characters/tonks/chitchats.rpy b/game/scripts/characters/tonks/chitchats.rpy index a4424e69..6a3d6671 100644 --- a/game/scripts/characters/tonks/chitchats.rpy +++ b/game/scripts/characters/tonks/chitchats.rpy @@ -1,8 +1,8 @@ label tonks_chitchat: - # if tonks_chatted: - # return + if tonks_chatted: + return $ tonks_chatted = True @@ -135,35 +135,35 @@ label tonks_chitchat: ton "A foul creature that is drawn to footwear..." ("open", "base", "base", "R") ton "It doesn't actually exist, I just wanted an excuse to have the students show me their feet." ("horny", "base", "base", "mid") - if tonks_morph_known: + block if tonks_morph_known: ton "Since Metamorphmagi can change their skin, I sometimes just don't bother wearing any clothes." ("soft", "base", "shocked", "mid") ton "I once changed the colour of my skin and made it look like a tight shirt..." ("grin", "narrow", "base", "R") ton "I might have worked topless once or twice..." ("horny", "base", "raised", "mid") - if tonks_morph_known: + block if tonks_morph_known: ton "I often got detentions by morphing into prefects..." ("normal", "base", "base", "R") ton "It was worth it though as I had free range to the prefects' bathroom..." ("base", "wide", "base", "mid") - if tonks_morph_known: + block if tonks_morph_known: ton "Most of my abilities are based around emotions..." ("open", "base", "base", "mid") ton "My hair can go red when I'm upset or angry..." ("upset", "base", "base", "mid") ton "Don't tell anyone but my natural hair colour is actually more brown..." ("open", "base", "base", "R") ton "People think it's pink but that's because I'm horny all the time." ("base", "base", "base", "down") - if tonks_morph_known: + block if tonks_morph_known: ton "There are rumours that Snape has set up an Age Line to keep students away from his private stash..." ("normal", "narrow", "base", "R") ton "Won't stop me borrowing some polyjuice potions though... Not that I need them..." ("open", "base", "base", "R") ton "But maybe I can find a girl that doesn't mind drinking it and have some fun." ("horny", "base", "raised", "R") - if tonks_morph_known: + block if tonks_morph_known: ton "I'm a metamorphmagus. I can change my appearance at will..." ("open", "base", "base", "mid") ton "Makes spying on the other teachers and students a lot easier..." ("grin", "base", "raised", "mid") - if tonks_morph_known: + block if tonks_morph_known: ton "I can change the shape and length of my tongue any way I want." ("open", "base", "base", "mid") ton "Imagine the possibilities..." ("open_wide_tongue2", "narrow", "base", "mid") - if susan_unlocked: + block if susan_unlocked: ton "Susan is such a lovely girl..." ("open", "base", "base", "mid") ton "But she really isn't very confident in her body..." ("open", "base", "raised", "R") ton "I do hope your little games can help her open up a bit..." ("base", "base", "base", "mid") diff --git a/game/scripts/mods.rpy b/game/scripts/mods.rpy index 7c914dc6..ed724974 100644 --- a/game/scripts/mods.rpy +++ b/game/scripts/mods.rpy @@ -1,6 +1,6 @@ default persistent.mods_enabled = set() -init -1000: +init -999: python: import json import os diff --git a/game/scripts/rooms/main_room/objects/poster.rpy b/game/scripts/rooms/main_room/objects/poster.rpy index b4af2a1c..3af7134d 100644 --- a/game/scripts/rooms/main_room/objects/poster.rpy +++ b/game/scripts/rooms/main_room/objects/poster.rpy @@ -1,6 +1,6 @@ label enlarge_poster: show image "#00000080" as underlay - $ renpy.show(name="poster", what=Image(poster_OBJ.decoration.image), zorder=25, at_list=[truecenter]) + show image Image(poster_OBJ.decoration.image) zorder 25 at truecenter as poster call ctc diff --git a/game/scripts/utility/devtools.rpy b/game/scripts/utility/devtools.rpy index 4cb4b696..7476b2cf 100644 --- a/game/scripts/utility/devtools.rpy +++ b/game/scripts/utility/devtools.rpy @@ -1,4 +1,4 @@ -init -1000 python early: +init -999 python early: if renpy.version_tuple < (7,5,3,22090809): raise RuntimeWarning("Your Ren'Py launcher is outdated, the current minimal requirement is 7.5.3.22090809+\nPlease perform an update and try launching the game again.") @@ -130,7 +130,7 @@ screen placeholder(): add Placeholder("girl") -init 2000 python hide: +init 999 python hide: def set_screen_layer(layer, *screens): for scr_name in screens: for _, scr in renpy.display.screen.get_all_screen_variants(scr_name): diff --git a/game/scripts/utility/lint.rpy b/game/scripts/utility/lint.rpy index 6ce193a5..7e8fe63e 100644 --- a/game/scripts/utility/lint.rpy +++ b/game/scripts/utility/lint.rpy @@ -25,6 +25,7 @@ init -1 python: nodes = [i for i in renpy.game.script.all_stmts if isinstance(i, (renpy.ast.Say, renpy.ast.Menu))] nodes.sort(key=lambda x: (x.filename, x.linenumber)) + files = renpy.list_files() SELF_CLOSING_TAGS = re.compile(r'(\{\{)|(\{(p|w|nw|fast|done|image|space)(?:\=([^}]*))?\})', re.S) @@ -92,7 +93,8 @@ init -1 python: val = strip(val) msg = "'{}'".format(key) - fn = "characters/{}/face/{}/{}.webp".format(SAYERS.get(who), key, val) + fp = f"characters/{SAYERS.get(who)}/poses/default/face/{key}/{val}/" + fn = next((f for f in files if f.startswith(fp)), f"{fp}expression.webp") if not has_failed: # Avoid repeating node destination diff --git a/game/scripts/utility/updater.rpy b/game/scripts/utility/updater.rpy index 6b97348c..3bb137fb 100644 --- a/game/scripts/utility/updater.rpy +++ b/game/scripts/utility/updater.rpy @@ -259,7 +259,7 @@ define update_message_list = [ "Insert disc 2", ] -screen updater: +screen updater(): tag menu