News:

Please request registration email again and then check your "Spam" folder

Former www.henthighschool.com

[Resources] Writing events for BK

Started by Goldo, May 19, 2022, 09:17 AM

Previous topic - Next topic

GoldoTopic starter

I have had surprising success using https://novelai.net/ to help me write a couple of H event for Chapter 3 (I'm curious if you guys will be able to spot which ones when it is released, without hurting my feelings ;) ). Just feed it the beginning of your event written using Ren'py script patterns and it will adjust pretty well.

Quote from: GMWinters on Oct 12, 2023, 01:29 PMIs it possible to make trait effects vary depending on personality? Or would either the BK code or Renpy engine get angry if conditionals were included in a Trait?

If it matters, I was originally thinking of situations where a trait indicates action XYZ hurts and so applies some penalty to it, but it occurs to be that a Masochist girl might see that as a benefit not a downside and could instead get a bonus.

That then led me to wondering about something like a "living stereotype" trait or whatever where the girl isn't just a pervert/princess/bimbo, she's the pervert/princess/bimbo or whatnot with the specific effect varying by personality or some other variable. But I assume the code would have to be designed to handle that kind of input and probably isn't?

The best way to design something like that would be to create an alternate trait that has the same name, but different effects, and add a personality check to BKgirlclass.rpy in 'add_trait()' to replace the vanilla trait with the special one for specific personalities. I'm not 100% clear if the checks that are done by trait name (such as 'has_trait()' ) would all work but my gut feeling is they would.
Maker of BK. Looking for the latest patch for BK 0.2? The link doesn't change, so bookmark it!

Vaan

Hi guys,

Managed to create a mod and already have a few events in it, about 5 so far, nothing complex. Will post it here once i get to 10 or something. Anyway, i was wondering, and this might be a stupid question, is there a way to draw a specific group of girls from the brothel? I came up with an idea to do events in the four different rooms, but i'm struggling to do it. I'm trying to draw out the dancers only as it's an event in that group only, for the first one, but can't seem to figure out how? This is what i've tried
$ able_girls = [g for g in MC.girls if not (g.away or g.hurt or g.exhausted)]
$ girl = rand_choice(able_girls,  job = "dancer")


$ able_girls = [g for g in MC.girls if not (g.away or g.hurt or g.exhausted)]
$ girl = rand_choice(able_girls, if girl.job in ("dancer"))

$ able_girls = [g for g in MC.girls if not (g.away or g.hurt or g.exhausted)]
$ girl = girl_job("dancer"), (able_girls))

Played around with all combinations and whatever i could find in the game's scripts, but couldn't find anything that resembles what i'm trying to do and i have no idea how to write it on my own. Any help would be appreciated, so far i've only ever used this on all my events, but it's getting a bit boring to choose a random girl from them all and wanted to do something a bit more specific:

$ able_girls = [g for g in MC.girls if not (g.away or g.hurt or g.exhausted)]
$ girl = rand_choice(able_girls)

neronero

Quote from: Vaan on Nov 20, 2023, 08:02 PMManaged to create a mod and already have a few events in it, about 5 so far, nothing complex. Will post it here once i get to 10 or something. Anyway, i was wondering, and this might be a stupid question, is there a way to draw a specific group of girls from the brothel? I came up with an idea to do events in the four different rooms, but i'm struggling to do it.
Nice, someone's cooking! ;D 

The purpose of rand_choice is: give it a list of things and it'll give back one random item from the list. In most of your attempts you're trying add your extra filtering criteria within the rand_choice() function. It should be done before that point, when you're defining the list that you're going to give to rand_choice()

Here's how you could do the filtering in 2 steps, to make it easy to understand
# Make a list of girls that are present in the brothel and not injured or burned out
$ able_girls = [g for g in MC.girls if not (g.away or g.hurt or g.exhausted)]

# Take the list above and reduce it to a smaller list, leaving only girls with the "dancer" job
$ dancer_girls = [g for g in able_girls if g.job == "dancer"]

# Give dancer_girls to rand_choice, which will pick a random thing from any list you put inside its brackets
$ girl = rand_choice(dancer_girls)

But it doesn't have to be an extra step, you could also add the extra criteria to the able_girls line to instantly create the right list:
$ able_girls = [g for g in MC.girls if not (g.away or g.hurt or g.exhausted) and g.job == "dancer"]
$ girl = rand_choice(able_girls)
My Girl Packs: [ link ] - Trait King mod: [ link ]

GoldoTopic starter

Quote from: neronero on Nov 24, 2023, 08:02 PM
Quote from: Vaan on Nov 20, 2023, 08:02 PMManaged to create a mod and already have a few events in it, about 5 so far, nothing complex. Will post it here once i get to 10 or something. Anyway, i was wondering, and this might be a stupid question, is there a way to draw a specific group of girls from the brothel? I came up with an idea to do events in the four different rooms, but i'm struggling to do it.
Nice, someone's cooking! ;D 

The purpose of rand_choice is: give it a list of things and it'll give back one random item from the list. In most of your attempts you're trying add your extra filtering criteria within the rand_choice() function. It should be done before that point, when you're defining the list that you're going to give to rand_choice()

Here's how you could do the filtering in 2 steps, to make it easy to understand
# Make a list of girls that are present in the brothel and not injured or burned out
$ able_girls = [g for g in MC.girls if not (g.away or g.hurt or g.exhausted)]

# Take the list above and reduce it to a smaller list, leaving only girls with the "dancer" job
$ dancer_girls = [g for g in able_girls if g.job == "dancer"]

# Give dancer_girls to rand_choice, which will pick a random thing from any list you put inside its brackets
$ girl = rand_choice(dancer_girls)

But it doesn't have to be an extra step, you could also add the extra criteria to the able_girls line to instantly create the right list:
$ able_girls = [g for g in MC.girls if not (g.away or g.hurt or g.exhausted) and g.job == "dancer"]
$ girl = rand_choice(able_girls)

Just don't forget to add a check for what happens if no girl fits the criteria (rand_choice will return 'False'), or you're in for a crash.
Maker of BK. Looking for the latest patch for BK 0.2? The link doesn't change, so bookmark it!

Vaan

#79
Thank you, i did. Learned how to do it from a different event you helped me with. I have managed to do it and have a very basic version of the mod that i am sending the link to. There are still a lot of events i will do and will probably be able to upload monthly, but as i said before, the quality of these events is pretty basic, because i don't have a lot of knowledge of coding and renpy. I only started this mod, because i enjoy playing the game a lot and wanted to expand on that. To make my experience even better.

I feel like it did it at least for me. Thanks to you guys i added 9 - 10 events to the game and i will probably add more every month. Depending on whether the mod picks up, i might upload it here too, but for now, i think i will just use it for me, because the quality is not on the same level as yours. The events expand on a lot of the tags which i don't think are fully used and add a lot of features.

Some of them will not work with the lore of BK, such as "femdom" (i might remove that one), added a "pool day", which is kind of a pool party with all girls in the brothel. Expanded on the Cosplay tags, so now they are all included in one event, i will probably add to that more at some point. As i mentioned, i am still polishing the events i created and creating new ones at the same time, removing and adding things i don't like.


Felt like i had to upload at least a basic version of it, since you guys have been so nice and answered all the questions i had! Feel like i am at a place where i know everything i needed to know to create my events. Only thing i don't like (and i really wanted to do) is that i was not able to create a button for my events. My original idea was to add the button where the menus are, kind of like the Augment Mod. Button would have basically said "go on a walk or "take some time off", at which point you would get a list of my events and you could choose what you wanted to do. My knowledge is quite limited and could not achieve it.


Currently you would have to go into the mods menu, click on "walk around", then you will get a list of all events and you can choose what you want to do. One of the options in the list also allows you to choose randomly. Other than appearing automatically, you can choose what you want to do, it takes away 2 interaction points each time you do an event. As i said, if the mod picks up, i will upload a new version monthly or every 2 - 3 weeks with new events and upgrades to the old ones, but for now, i am planning on using it for myself, i am quite happy with what i achieved even if it is quite basic. Please find a link below, let me know if you're having issues with it. Once again, thanks for all your help! Oh, if anyone wants to do anything with the code or edit anything on the mod, they have full permission! Code is a bit of a mess, since i'm a beginner, but if you find anything useful, you are welcome to use it!

https://mega.nz/file/TLpHVL6I#tYfIspdED0rovvw2B2CLeg07XuzjcgD9ff4xvMXx9uA

GoldoTopic starter

Thanks, I recommend making a separate thread for it to give the mod visibility and collect people's feedback.
Maker of BK. Looking for the latest patch for BK 0.2? The link doesn't change, so bookmark it!

Aetheran

#81
So I'm starting to create my own events for a mod I want to do, and am a bit confused on how exactly to structure the code. I have very *very* minimal coding experience from years ago, but I do understand pseudo-code. I know what if/elseif statements are, what variables are, etc etc, so with that level of knowledge in mind, I was wondering if I could get some help?

I tried looking through the mymod example mod, as well as Goldo's first few posts in this topic to try and figure it out, but I'm still unsure how to actually start the events, how to set trigger conditions, what variables I need to set, etc etc.

For reference, I'm using Visual Studio Code with the Ren'py Language Extension to do the coding.

I'll post my pseudo-code below to give an idea of what I'm trying to do for the very first event. Any help would be greatly appreciated.

Pseudo-code:
Spoiler
Silver Wolf Intro 01;
Random Event: Can trigger when MC is walking around Warehouse or Dock districts.
Event Requirements: 2nd Brothel unlocked. Warehouse/Dock districts unlocked (Chapter 2?)

SCENE TRANSITION IN
[TOWN SCENE]

[SFX: Low crowd mumble]
[SFX: Guards yelling/whistling]

???: *yelling* "Stop! Stop I said!"

You're walking around town when you hear a commotion coming from the direction of some shops.

[SHOW Silver Wolf PIC]

Looking over, you notice a silver-haired girl in odd clothing being chased by some city guards.

Guard: *yelling* "You're only making it worse for yourself when we catch you!"

[SFX: Running?]

The girl continues running. She's extremely nimble, athletically dodging through the crowd as she runs from the guards.

With almost laughable ease, she keeps ahead of the guards. You guess that she could easily lose the them if she wanted.

Maybe she has a reason to keep them chasing her?

[HORIZONTAL MOVE Silver Wolf PIC OFF SCREEN (indicating her running away)]

Soon enough they disappear around a corner. You hear the guards continuing to tell her to stop. Good luck with that, guys.

TRANSITION OUT

FLAG [Intro 01 - Silver Wolf] COMPLETE

ENABLE [[Intro 02 - Silver Wolf 02]]
[close]

EDIT: Ok so I looked through some of the BK chapter events to get an idea of what I need to use for what, and this is now what I have in actual code:

EDIT 2 (Dec 19): So I took a look at the headhunter mod to figure out how it calls the headhunter NPC picture, so I figured that part of it out. It displays the girls full body picture and portrait picture fine during the event.
New questions:

1. How do I add new sounds? I know the game already has laugh sounds, but I have sound clips of the character's actual laugh I'd like to insert. Again using the Headhunter mod as a reference, I see it has defines for sounds, for example: $ s_giggle = "giggle.mp3". So is there a way I can add my swlaugh.ogg in here somehow? The headhunter mod doesn't actually have a giggle.mp3 so I assume it was using BK 0.2's giggle.mp3, does that mean that define automatically looks in the /sound/ folder?
2. So I'm using the call function in the console to test the event. After the event runs, the screen stays black. How would I make it go back to its original location? I looked around in BKchapter2.rpy to see how Goldo does it but the events I looked at all also end with "screen black with fade", so I'm not sure how its done...

Actual code (edited Dec 19):
Spoiler
############ BROTHEL KING: STAR RAIL VARIABLES (edited from Headhunter mod) ############
## TO BE DONE:  - "color=c_firered" = text color? If so, change to blueish-purple
##              - Find out how the games knows where to pull sounds from.

init -2:

    define silverwolf = Character("Silver Wolf", color=c_firered, image = "silverwolf", window_left_padding=int(config.screen_height*0.205))

    $ game_image_dict["Characters"]["silverwolf"] = [
                                            declare('silverwolf', 'Mods/Brothel Star Rail/Pictures/Silver Wolf/silverwolf__smile_profile (bw outline).webp', 'f', x=0.5, y=0.5),
#                                            declare('headhunter strip1', 'NPC/Headhunter/Headhunter2.webp', 'f', x=0.5, y=0.5),
#                                            declare('headhunter strip2', 'NPC/Headhunter/Headhunter3.webp', 'f', x=0.5, y=0.5),
#                                            declare('headhunter angry', 'NPC/Headhunter/Headhunter4.webp', 'f', x=0.5, y=0.5),
                                            declare('side silverwolf', 'Mods/Brothel Star Rail/Pictures/Silver Wolf/silverwolf_portrait.webp', 'p', x=200, y=200, gallery=False),
#                                            declare('side headhunter strip1', 'NPC/Headhunter/Headhunter_portrait2.webp', 'p', x=152, y=152, gallery=False),
#                                            declare('side headhunter strip2', 'NPC/Headhunter/Headhunter_portrait3.webp', 'p', x=152, y=152, gallery=False),
#                                            declare('side headhunter angry', 'NPC/Headhunter/Headhunter_portrait4.webp', 'p', x=152, y=152, gallery=False),
                                            ]

#    $ game_image_dict["Backgrounds"]["slavemarket"] += [declare("bg slave market21", "backgrounds/slave market21.webp", "p")]

    $ s_erm = "erm.mp3"
    $ s_hmmm = "uhm.mp3"
    $ s_hmm = "uhm.mp3"
    $ s_ahh_frustrated = "ahh_frustrated.ogg"
    $ s_giggle = "giggle.mp3"

init -1 python:

    ## TO BE DONE:  -Define new characters. Should that be in this file?
    ##              -

    bstarrail_template = Mod(

                ## Basic mod information (Important: Version is used to check for new versions of the mod. Failure to update the version number may lead to broken mods and saved games)
                name = "Brothel King: Star Rail",
                folder = "Brothel Star Rail",
                creator = "Aetheran",
                version = 0.01,
                pic = "bstarrail-logo.webp",
                description = """Brothel King: Star Rail is a mod that incorperates a few girls from the Honkai: Star Rail universe into the Brothel King world using (relatively) lore-friendly events.\n\n{b}May contain story spoilers for Honkai: Star Rail up to patch 1.6.{/b}""",

                ## Mod option menu (access through the Help (click on '?') menu)
                ## help_prompts = [("About Brothel: Star Rail", "bstarrail_about_event")],

                ## Init label: This will run when the mod is activated, allowing you to set some variables and events if necessary
                init_label = "bstarrail_init",
                update_label = "bstarrail_update",

                ## Event dictionary (all mod events must be declared here)
                events = {
                            "Intro Silver Wolf" : StoryEvent("bstarrail_introsw01", location = "market"),
                            "Intro Silver Wolf 02" : StoryEvent("bstarrail_introsw02", location = "market"),
                            "Intro March 7th" : StoryEvent("bstarrail_introm701", location = "thieves guild"),
                            "Intro Fu Xuan" : StoryEvent("bstarrail_introfu01", condition = "mymod_stolen_gold", min_gold = 200),
                        },
                home_rightmenu_add_buttons = ["test_mod_but"]*10
                )

## This label runs when the mod is activated
label bstarrail_init():

    ## Important! It is necessary to copy the mod template to a variable upon initializing it if you would like mod variables to save together with the player's saved game (ie. most cases)
    $ bstarrail = bstarrail_template

    "You have just installed [bstarrail.name]."

    "The writing in this mod assumes the Player Character is good or neutral. The dialogue won't fit those roleplaying an evil character, sorry!"

    return

## label bstarrail_about_event():

## "This mod incorperates a few girls from the Honkai: Star Rail universe into the game using (relatively) lore-friendly events."

label bstarrail_introsw01():

    ## Silver Wolf Intro Event 01

    scene black
    show bg street at top
    with fade

    hide screen visit_location
    hide screen overlay

    # SFX: Low crowd mumbles
   
    "You're walking around town on another peaceful day"

    "Suddenly, you hear a commotion further ahead"

    # SFX: Guards yelling/whistling

    guard "Stop! Stop I said!"

    show silverwolf at left with dissolve

    "Looking over in the direction of the noise, you notice a silver-haired girl in odd clothing being chased by some city guards."

    guard "You're only making it worse for yourself when we catch you! Stop immediately!"

    silverwolf "You know what? I don't think I will!"

    # SFX Running foot noises

    play sound s_laugh

    "The girl continues running. She's extremely nimble, athletically dodging through the crowd as she runs from the guards."

    "With almost laughable ease, she keeps ahead of the guards. You guess that she could easily lose them if she wanted."

    "Maybe she has a reason to keep them chasing her?"

    # MOVE HORIZONTALLY Silver Wolf PIC OFF SCREEN (indicating her running away)

    "Soon enough they disappear around a corner. You hear the guards continuing to shout at her to stop. Good luck with that, guys."

    scene black with fade

    # $ calendar.set_alarm(calendar.time+7+dice(3), StoryEvent(label = "bstarrail_introsw02", type = "morning"))

    return

# label bstarrail_introsw02():

    ## Silver Wolf Intro Event 02

#    return
[close]

vadi92

Quote from: Aetheran on Dec 17, 2023, 12:22 AM1. How do I add new sounds? I know the game already has laugh sounds, but I have sound clips of the character's actual laugh I'd like to insert. Again using the Headhunter mod as a reference, I see it has defines for sounds, for example: $ s_giggle = "giggle.mp3". So is there a way I can add my swlaugh.ogg in here somehow? The headhunter mod doesn't actually have a giggle.mp3 so I assume it was using BK 0.2's giggle.mp3, does that mean that define automatically looks in the /sound/ folder?

You find it in the BKSettings.rpy around line 434. (But its better if you create a separate rpy file for it.

Aetheran

#83
Quote from: vadi92 on Dec 19, 2023, 09:13 PMYou find it in the BKSettings.rpy around line 434. (But its better if you create a separate rpy file for it.


Awesome thanks. Looking at those lines in BKSettings.rpy and then googling the renpy.music.register_channel line, I was able to work it out and get it working. Someone on the f95 forums was saying to add my own sounds I needed Goldo to put in hooks for the sound code or something? Will my above line of code mess anything up with the game? Or was that user just not knowing how sound works? I'm still new to this but from what knowledge I do have, I *think* this solution works fine?

I just added this at the top of my .rpy file:

init -3 python:

    renpy.music.register_channel("bkstarrail", mixer = "sfx", file_prefix = "Mods/Brothel Star Rail/Sounds/", loop = False)

Then in my  init -2: section below that, I added this:

$ s_bksr_sw_isthatit = "silver_is_that_it.ogg"

And then to play it, in the event (again, within my own .rpy file):

play bkstarrail s_bksr_sw_isthatit

Worked perfectly

GoldoTopic starter

Quote from: Aetheran on Dec 19, 2023, 11:51 PM
Quote from: vadi92 on Dec 19, 2023, 09:13 PMYou find it in the BKSettings.rpy around line 434. (But its better if you create a separate rpy file for it.


Awesome thanks. Looking at those lines in BKSettings.rpy and then googling the renpy.music.register_channel line, I was able to work it out and get it working. Someone on the f95 forums was saying to add my own sounds I needed Goldo to put in hooks for the sound code or something? Will my above line of code mess anything up with the game? Or was that user just not knowing how sound works? I'm still new to this but from what knowledge I do have, I *think* this solution works fine?

I just added this at the top of my .rpy file:

init -3 python:

    renpy.music.register_channel("bkstarrail", mixer = "sfx", file_prefix = "Mods/Brothel Star Rail/Sounds/", loop = False)

Then in my  init -2: section below that, I added this:

$ s_bksr_sw_isthatit = "silver_is_that_it.ogg"

And then to play it, in the event (again, within my own .rpy file):

play bkstarrail s_bksr_sw_isthatit

Worked perfectly

You don't need any hooks at all to add your own sounds and music. See this for reference.

You can just refer to it using the relative path and quotes, like in this example:
play sound "Mods/AetheranMod/silver_is_that_it.ogg"
Of course this is the same as:
$ s_bksr_sw_isthatit = "Mods/AetheranMod/silver_is_that_it.ogg"

[...]

play sound s_bksr_sw_isthatit


That allows you to keep your sound and music in a separate folder if you want to.

I don't see the point of adding a separate sound channel for your sounds, unless you're planning on doing some weird stuff like separate volume settings or special effects. The base game has four channels (sound, sound2, sound3, and music), which should be enough for most use cases.
Maker of BK. Looking for the latest patch for BK 0.2? The link doesn't change, so bookmark it!

Aetheran

#85
Quote from: Goldo on Dec 21, 2023, 03:50 PMYou don't need any hooks at all to add your own sounds and music. See this for reference.

You can just refer to it using the relative path and quotes, like in this example:
play sound "Mods/AetheranMod/silver_is_that_it.ogg"


Holy crap that is a lot easier lol. Ya I don't care too much about keeping music/sound in different folders so this way will suit me fine.
LONG EDIT: It actually gives me an error when I try with just this line.
I added: play sound "Mods/AetheranMod/silver_is_that_it.ogg"
Error:OSError: Couldn't find file "sounds/Mods/BK Star Rail/Sounds/silver_is_that_it.ogg"
So its still defaulting to look into the BK/game/sounds/ folder, not the BK/game/Mods/ folder. The reference link you posted is where I learned how to do the sound channel stuff, actually. I looked through it again and couldn't find how to go UP directories, so I tried the other example on there and did:

Into init -2:
define audio.silverwolf_sound = "Mods/BK Star Rail/Sounds/silver_is_that_it.ogg"
Into the event label:
play music silverwolf_sound
Now I get the same error, but its looking for the file in "music/Mods/BK Star Rail/Sounds/silver_is_that_it.ogg"

So... so far the renpy.music.register_channel is the only way that has actually made it look in the correct folder.

ANYWHO... this was a long edit. Now back to the original reason for this reply... which is more issues (of course)

...

One problem I have yet to figure, though, is how exactly I call my first event. I spent about an hour this morning looking through other events to try to figure it out but had to goto work before I made any progress.

I took a look in mymod and saw the following within init -1 python:

               events = {
                          "surprise me" : StoryEvent("mymod_surprise"),
                          "meet me" : StoryEvent("mymod_meeting", location = "thieves guild", min_gold = 100),
                          "justice prevails" : StoryEvent("mymod_justice", condition = "mymod_stolen_gold"),
                          },

And then within label my_mod_init, there was this:

$ mymod.add_event("justice prevails", type="morning", call_args = [end_picture])
So am I correct in that the first part defines the event, and the 2nd part enables it within the game to be triggered, in this case during the morning (if min_gold = 200)?

I took those examples and tried to make it work, but the event never fires. I added into "init -1 python:" this:

                events = {
                            "Intro Silver Wolf" : StoryEvent("bkstarrail_introsw01", location = "market"),
                        },

Then into label bkstarrail_init I put this:

    $ bkstarrail.add_event("Intro Silver Wolf", type="city", location = "market")
However, bkstarrail_introsw01 never fired when visiting the market. I thought this was because I used "Intro Silver Wolf" instead of "bkstarrail_introsw01", but neither worked. So I copied your kosmo example from the start of this thread:

    $ bkstarrail.add_event("Intro Silver Wolf", date = calendar.time+1, type = "morning")
After passing a few days, it didn't work either, so again I changed "Intro Silver Wolf" to "bkstarrail_introsw01".

Still nothing (again after waiting a few days).

I know the event works cause I can use the console to call it, so I dunno. Obviously I'm doing something wrong but I have no idea what. I also tried adding to bkstarrail_init this:

#    python:
#        calendar.set_alarm(calendar.time+1, StoryEvent(label="bkstarrail_introsw01", type="morning"))

Because I saw that type of code in other events, and figured out calendar.time stores the current day since game start, so that *should* trigger it 1 day later? But it still didn't work.

I figured I may be over-thinking things so I decided to copy your mymod examples EXACTLY. The issue with this is the only event mymod adds within label my_mod_init is the "justice prevails" one. which has a custom condition in the declare (mymod_stolen_gold) AND "call_args = [end_picture]" in the $ line... I'm assuming the call_args end picture thing means it displays a picture? But that means I can't really copy this code exactly, so *again* I tried to edit it to suit my needs but it still didn't work. This time I added this to init -1 python:
                events = {
                            "Intro Silver Wolf" : StoryEvent("bkstarrail_introsw01"),
                        },
And then to label bkstarrail_init:
    $ bkstarrail.add_event("bkstarrail_introsw01", type = "morning")Which *should* call that event in the morning? But it doesn't. Again neither does "Intro Silver Wolf"

I also tried other variations. type="city", location="market" or "thieves guild". Other random stuff. I can't seem to get this to trigger no matter what I do.

GoldoTopic starter

#86
My bad sorry!

I forgot the sound channel changed the root directory. In that case, try this:
play audio "Mods/AetheranMod/silver_is_that_it.ogg"
Untested but I think the 'audio' channel will use the root game folder for the relative path. You can also use it to play music, and the beauty of it is that it will play along fine with other sounds at the same time without the need to switch channels. It will probably only work with v0.3 though, but give it a try.

QuoteOne problem I have yet to figure, though, is how exactly I call my first event. I spent about an hour this morning looking through other events to try to figure it out but had to goto work before I made any progress.

It's been a long while since I've worked on mod events, let me dive into the code and see if I can help you.

Edit: After some testing, mod events seem to work as intended but mod activation during a game doesn't. My advice is to make sure your mod is properly activated by turning it on from the start menu, and then restarting the game for good measure. You should see your Mod is activated from the notification or Mod menu. Then, start a new game and see if things now work.
Maker of BK. Looking for the latest patch for BK 0.2? The link doesn't change, so bookmark it!

Aetheran

Quote from: Goldo on Dec 22, 2023, 10:05 AMMy bad sorry!

I forgot the sound channel changed the root directory. In that case, try this:
play audio "Mods/AetheranMod/silver_is_that_it.ogg"
Untested but I think the 'audio' channel will use the root game folder for the relative path. You can also use it to play music, and the beauty of it is that it will play along fine with other sounds at the same time without the need to switch channels. It will probably only work with v0.3 though, but give it a try.

Yep, that works perfectly, thanks!

QuoteEdit: After some testing, mod events seem to work as intended but mod activation during a game doesn't. My advice is to make sure your mod is properly activated by turning it on from the start menu, and then restarting the game for good measure. You should see your Mod is activated from the notification or Mod menu. Then, start a new game and see if things now work.

Ok, following your advice I tried that out, and was able to get the first event to fire from mod init event by using

$ calendar.set_alarm(calendar.time+1, StoryEvent(label = "bkstarrail_introsw01", type = "morning"))
After changing the code, steps I followed:

- Started BK
- Disabled mod
- Closed BK
- Started BK
- Enabled mod
- Closed BK
- Started BK
- Started new game (Normal Mode - No intro)

I'm not too sure I need to close the game after every mod deactivation/activation, but you DID mention restarting the game after making sure the mod is activated, soooo... I took that to the extreme just to be safe.

After all that, the event properly fires in the morning after waiting a day.

HOWEVER, I then did the same steps as above again (deactivate, close/open BK, activate, close/open BK), but this time instead of starting a new game, I loaded a test save in chapter 2, and the event never fires in the morning, even after waiting multiple days.

So I decided to change the event type. In "init -1 python" I changed the line in the Event dictionary from
"Intro Silver Wolf" : StoryEvent("bkstarrail_introsw01", type="morning"),to "Intro Silver Wolf" : StoryEvent("bkstarrail_introsw01", location = "farm"),
And in the mod init, I changed the add_event from
$ bkstarrail.add_event("Intro Silver Wolf", type = "morning")to $ bkstarrail.add_event("Intro Silver Wolf", type = "city")
The above code now matches Goldo's "mymod_meeting" parameters, but just with my event names instead of his.

Again I did the whole close/open deactivate/activate mod shenanigans, and started a new game (no intro). Went to the farm, and the event triggered fine.

Did the close/open deactivate/activate again, but this time loaded my save game, and the event didn't fire.

So.... will my mod just never work with anyone who wants to use it in an existing save? That seems... odd.

Pre-post EDIT: I did some checking on the only two other mods I know of that adds events, Headhunters and Friends and Foes. Friends and Foes mod actually schedules an event in their mod init label, but it's exactly like my first one (the calender.set_alarm one). So why does theirs work and mine doesn't?

I'll keep on playing around with it and see if I can work it out. Maybe hit up a renpy discord or something.

GoldoTopic starter

Quote from: Aetheran on Dec 22, 2023, 02:13 PM
Quote from: Goldo on Dec 22, 2023, 10:05 AMMy bad sorry!

I forgot the sound channel changed the root directory. In that case, try this:
play audio "Mods/AetheranMod/silver_is_that_it.ogg"
Untested but I think the 'audio' channel will use the root game folder for the relative path. You can also use it to play music, and the beauty of it is that it will play along fine with other sounds at the same time without the need to switch channels. It will probably only work with v0.3 though, but give it a try.

Yep, that works perfectly, thanks!

QuoteEdit: After some testing, mod events seem to work as intended but mod activation during a game doesn't. My advice is to make sure your mod is properly activated by turning it on from the start menu, and then restarting the game for good measure. You should see your Mod is activated from the notification or Mod menu. Then, start a new game and see if things now work.

Ok, following your advice I tried that out, and was able to get the first event to fire from mod init event by using

$ calendar.set_alarm(calendar.time+1, StoryEvent(label = "bkstarrail_introsw01", type = "morning"))
After changing the code, steps I followed:

- Started BK
- Disabled mod
- Closed BK
- Started BK
- Enabled mod
- Closed BK
- Started BK
- Started new game (Normal Mode - No intro)

I'm not too sure I need to close the game after every mod deactivation/activation, but you DID mention restarting the game after making sure the mod is activated, soooo... I took that to the extreme just to be safe.

After all that, the event properly fires in the morning after waiting a day.

HOWEVER, I then did the same steps as above again (deactivate, close/open BK, activate, close/open BK), but this time instead of starting a new game, I loaded a test save in chapter 2, and the event never fires in the morning, even after waiting multiple days.

So I decided to change the event type. In "init -1 python" I changed the line in the Event dictionary from
"Intro Silver Wolf" : StoryEvent("bkstarrail_introsw01", type="morning"),to "Intro Silver Wolf" : StoryEvent("bkstarrail_introsw01", location = "farm"),
And in the mod init, I changed the add_event from
$ bkstarrail.add_event("Intro Silver Wolf", type = "morning")to $ bkstarrail.add_event("Intro Silver Wolf", type = "city")
The above code now matches Goldo's "mymod_meeting" parameters, but just with my event names instead of his.

Again I did the whole close/open deactivate/activate mod shenanigans, and started a new game (no intro). Went to the farm, and the event triggered fine.

Did the close/open deactivate/activate again, but this time loaded my save game, and the event didn't fire.

So.... will my mod just never work with anyone who wants to use it in an existing save? That seems... odd.

Pre-post EDIT: I did some checking on the only two other mods I know of that adds events, Headhunters and Friends and Foes. Friends and Foes mod actually schedules an event in their mod init label, but it's exactly like my first one (the calender.set_alarm one). So why does theirs work and mine doesn't?

I'll keep on playing around with it and see if I can work it out. Maybe hit up a renpy discord or something.

I'm not sure I'd need to take a look at your code. But what did you do exactly?

If you activated the mod, started a new game, and saved, before the event happened, there's really no reason why it wouldn't work when loading that save.

If you're trying to load a save from before installing the mod, then it's totally normal that it doesn't load the event.

Finally, it sounds like you may be trying to trigger the event a second time. Are you trying to trigger the event several times in one playthrough? As a reminder, StoryEvent objects come with the once property set to True, so they only fire up once. If you want an event to be repeatable, you need to change it likeso:
"Intro Silver Wolf" : StoryEvent("bkstarrail_introsw01", type="morning", once=False),
And then you'll need to think about if/when to remove the event manually.
Maker of BK. Looking for the latest patch for BK 0.2? The link doesn't change, so bookmark it!

Aetheran

Quote from: Goldo on Dec 22, 2023, 02:24 PMI'm not sure I'd need to take a look at your code. But what did you do exactly?

If you activated the mod, started a new game, and saved, before the event happened, there's really no reason why it wouldn't work when loading that save.

If you're trying to load a save from before installing the mod, then it's totally normal that it doesn't load the event.

Finally, it sounds like you may be trying to trigger the event a second time. Are you trying to trigger the event several times in one playthrough? As a reminder, StoryEvent objects come with the once property set to True, so they only fire up once. If you want an event to be repeatable, you need to change it likeso:
"Intro Silver Wolf" : StoryEvent("bkstarrail_introsw01", type="morning", once=False),
And then you'll need to think about if/when to remove the event manually.

The only two places I have the event mentioned are in the "init -1 python:" section, this portion:

                ## Event dictionary (all mod events must be declared here)
                events = {
                            "Intro Silver Wolf" : StoryEvent("bkstarrail_introsw01", location = "farm"),
                        },

And then in "label bkstarrail_init():", here:

label bkstarrail_init():

    ## Important! It is necessary to copy the mod template to a variable upon initializing it if you would like mod variables to save together with the player's saved game (ie. most cases)
    $ bkstarrail = bkstarrail_template

    "You have just installed [bkstarrail.name]."

    "The writing in this mod assumes the Player Character is good or neutral. The dialogue won't fit those roleplaying an evil character, sorry!"

    $ bkstarrail.add_event("Intro Silver Wolf", type = "city")

    return

Which is examples directly from your mymod. In my testing, I tried a bunch of different ways to call this event, as listed above, but I never tried to call it more then once anywhere, and only in the "label bkstarrail_init():"

My post may have been confusing since I did list a bunch of different ways I tried, but I've only had one call line in the "label bkstarrail_init():" at one time.

QuoteIf you're trying to load a save from before installing the mod, then it's totally normal that it doesn't load the event.

I think this is the important part of your message here. What I've been trying to do is have the event trigger from a game that was started before the mod was added. From what you've been saying, I'm assuming that only games that were created WITH the mod activated from the start will work.

I've been under the assumption that I can start a game, then at a later date add a mod (kind of like how you can add girl packs to existing games). But apparently that isn't the case? Mods only work with brand new games?