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

ron1

hi everyone,

i tried to make something (not a mod, more like a 1 time event). but i have a few issues, i wanted to make something for later in the game (for around chapter 4 or 5 or so). i repeat do not direct install this, it does not work, i wanted to let this trigger around entering chapter 4 + 20 days, but i dont know how to write it... do i need to write some troubleshooting to? i wanted to keep it simple but without these things, i cant test it. dont be to harsh  :)  and i love some feedback (i know i am going to throw some more soundstuff in, but first things first), i hope i didnt do to much mistakes. love the work put in this game so far. i am hoping that ther is still progress for 3.0 to come out

https://www.mediafire.com/folder/crfos2km0sjbn/GUP

GoldoTopic starter

How you could do it:
- Add a 'silent' event that triggers only when Chapter 4 is reached (using the 'chapter' argument of the StoryEvent class)
- Make that event a single-line event that adds a second event with a calendar alarm set for 20 days later
- The second event is the one you want to proc

If you're not clear on how to do that, let me know and I can try and give you more detailed pointers.
Maker of BK. Looking for the latest patch for BK 0.2? The link doesn't change, so bookmark it!

ron1

i already looked at excisting files like the sewer girl event, but that gets triggered on location, then i tried looking at when kunoichi appeared and i didnt understand that writing either, i have seen that there is an alarm set, but i didnt understand the eventclose stuff (the eventclosing so it does not repeat itself), i am very basic in it. i wanted to do someting like this for some time, and i thought what the hell, if this is kinda working i wanna give it a shot for a repeating event, some shallow events that drain a few resources and that ´´break the game´´, in the end it gets kinda repetitive. (you got max girls, not much mre to explore.....)

thank you for replying

GoldoTopic starter

Quote from: ron1 on Mar 15, 2023, 06:28 PMi already looked at excisting files like the sewer girl event, but that gets triggered on location, then i tried looking at when kunoichi appeared and i didnt understand that writing either, i have seen that there is an alarm set, but i didnt understand the eventclose stuff (the eventclosing so it does not repeat itself), i am very basic in it. i wanted to do someting like this for some time, and i thought what the hell, if this is kinda working i wanna give it a shot for a repeating event, some shallow events that drain a few resources and that ´´break the game´´, in the end it gets kinda repetitive. (you got max girls, not much mre to explore.....)

thank you for replying

Ok so here is a more detailed walkthrough:

1/ Add a 'silent' event that declares in Chapter 4

Somewhere at the start of your mod, you want to add an event that triggers in Chapter 4. This event will be a StoryEvent() object. Here is what it should look like:

$ daily_events.append(StoryEvent(label = "my_silent_first_event", chapter=4))

Explanation:
- daily_events is the list of events that are tested daily (unlike city_events for instance, which are tested when visiting the city)
- label is the label of your event that will be called (make it unique)
- chapter is the minimum chapter you need to reach for the event to happen

2/ Create the first (silent) event

This event is very simple, it just sets a timer so that the next event (the real one) will proc in 20 days.

label my_silent_first_event():
    $ calendar.set_alarm(calendar.time+20, StoryEvent(label = "my_second_real_event", type = "night"))
    return

Explanation:
- calendar.set_alarm(date, event) is a method that adds the given event to daily_events but sets its minimum date to the first argument value (in days). If for some reason it doesn't proc on the given date, it will proc ASAP after that.
- calendar.time is the current date in days
- type can be morning, day, night, city or any. In this example, the event will proc at night (after the player clicks the 'End day' button).


3/ Add your final real event

The only thing left to do is to create your actual event. It's up to you depending on what you want to happen.

label my_second_real_event():
    # Put any code you like here...
    return



A final note: Maybe you not only want to call events, but you want to give them arguments too (for instance, the 'girl' argument. In that case, you can do it like this:

$ daily_events.append(StoryEvent(label = "my_silent_first_event", call_args=[girl], chapter=4))

[...]

label my_silent_first_event(girl):
    $ calendar.set_alarm(calendar.time+20, StoryEvent(label = "my_second_real_event", call_args=[girl], type = "night"))
    return

[...]

[code]label my_second_real_event(girl):
    girl.char "Hi, my name is [girl.name]."
    # Put any code you like here...
    return

[/code]

Note that you must provide a list as call_args even if there is only one argument.

I hope it helps you.
Maker of BK. Looking for the latest patch for BK 0.2? The link doesn't change, so bookmark it!

ron1

 yeah i adjusted the file and now it keeps crashing :D, i am still an idiot

Full Traceback ------------------------------------------------------------

Full traceback:
  File "renpy/bootstrap.py", line 331, in bootstrap
    renpy.main.main()
  File "renpy/main.py", line 492, in main
    renpy.game.script.load_script() # sets renpy.game.script.
  File "renpy/script.py", line 283, in load_script
    self.load_appropriate_file(".rpyc", ".rpy", dir, fn, initcode)
  File "renpy/script.py", line 781, in load_appropriate_file
    data, stmts = self.load_file(dir, fn + source)
  File "renpy/script.py", line 594, in load_file
    stmts = renpy.parser.parse(fullfn)
  File "renpy/parser.py", line 2953, in parse
    lines = list_logical_lines(fn, filedata, linenumber)
  File "renpy/parser.py", line 238, in list_logical_lines
    data = f.read().decode("utf-8", "python_strict")
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python2.7/encodings/utf_8.py", line 16, in decode
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb4 in position 367: invalid start byte

Windows-10-10.0.22621
Ren'Py 7.4.11.2266
 
Wed Mar 15 20:35:53 2023

https://www.mediafire.com/folder/j21nrf6ezizl9/GUP

GoldoTopic starter

Ok, I don't know what to tell you because this is Ren'py crashing not BK. Either you modded a native renpy file (not recommended), or you included wrong characters in your code that fuck up Ren'py.

My advice is commenting out some parts of your code until you find the likely culprit.
Maker of BK. Looking for the latest patch for BK 0.2? The link doesn't change, so bookmark it!

ron1

i threw everything out and started over, just trying the basics now, but how do you define a picture path? if i use this: Picture(path="NPC/GUP/sex21)

i got perhaps you left a " at the end of the first line.
if i add it, i got an error saying expected statement.
Picture (path="NPC/GUP/sex21")    (arrow backwards)
this is all i wrote for the moment, just to test the beginning

label time_for_GUP_event(): # Happens after Chapter 4 begins after 20days.


    $ calendar.set_alarm(calendar.time+1, StoryEvent(label = "time_for_aGUP_event", type = "morning"))

    return

label time_for_aGUP_event(): # Morning event


    "As you get on with your morning routine, the brothel receives some unexpected visitors."

Picture(path="NPC/GUP/sex21")

    $ MC.interactions = 0

"You have lost all remaining actions for the day."

GoldoTopic starter

Quote from: ron1 on Mar 16, 2023, 05:30 PMi threw everything out and started over, just trying the basics now, but how do you define a picture path? if i use this: Picture(path="NPC/GUP/sex21)

You left out the " at the end in Picture(path="NPC/GUP/sex21") so it won't work. Every time you open a string with " you must also close it.

Quotei got perhaps you left a " at the end of the first line.
if i add it, i got an error saying expected statement.
Picture (path="NPC/GUP/sex21")    (arrow backwards)
this is all i wrote for the moment, just to test the beginning

The 'expected statement' error usually happens when you try to use python code in Ren'py script, aka you forgot either the '$' sign or the python: header.

Quotelabel time_for_GUP_event(): # Happens after Chapter 4 begins after 20days.


    $ calendar.set_alarm(calendar.time+1, StoryEvent(label = "time_for_aGUP_event", type = "morning"))

    return

label time_for_aGUP_event(): # Morning event


    "As you get on with your morning routine, the brothel receives some unexpected visitors."

Picture(path="NPC/GUP/sex21")

    $ MC.interactions = 0

"You have lost all remaining actions for the day."


Calling an object of the Picture class like that in the middle of the code will do nothing useful for you. If you just want to display a given picture, use renpy to define and then show the picture.
Maker of BK. Looking for the latest patch for BK 0.2? The link doesn't change, so bookmark it!

Kyzer

hi goldo is it possible to make the free girl only show up in a specific location rather than randomly all over the place

GoldoTopic starter

You mean using _BK.ini? Not now unless you include custom events, but I could add this to the next version if needed.
Maker of BK. Looking for the latest patch for BK 0.2? The link doesn't change, so bookmark it!

Kyzer


Hareb

I was working on the 'bookworm' event I started in the autumn after quite some delay ... I can't seem to get it to launch in the console anymore (with the command 'call test_hareb')

The 'label test_hareb:' line is where it should be.

I definitely have one Loyal and one Class President in my stall, so it should work and I've tried to temporarily remove the personality requirement, so it should work with any girl.

There is no error message. The event just won't launch.

GoldoTopic starter

Quote from: Hareb on Mar 20, 2023, 07:51 PMI was working on the 'bookworm' event I started in the autumn after quite some delay ... I can't seem to get it to launch in the console anymore (with the command 'call test_hareb')

The 'label test_hareb:' line is where it should be.

I definitely have one Loyal and one Class President in my stall, so it should work and I've tried to temporarily remove the personality requirement, so it should work with any girl.

There is no error message. The event just won't launch.

Can you put a simple line of dialogue as the beginning of your event such as:
sill 'Event launched'
so you know for certain if it is running or not? Maybe an 'if' statement is screwing with your event.

Using call in the console is vanilla renpy and very straightforward, so it should work. Sometimes the console deactivates renpy commands and restricts to python for no apparent reason (but it does give an error message). If that happens, going into the options menu then back usually reactivates them (no clue why). You would also get an error if the label didn't exist.

So the most likely scenario is that your event is indeed called, but returns immediately for some reason.

Maker of BK. Looking for the latest patch for BK 0.2? The link doesn't change, so bookmark it!

GoldoTopic starter

Quote from: darkzerotor on Mar 20, 2023, 01:58 PMhi goldo is it possible to make the free girl only show up in a specific location rather than randomly all over the place

One thing I didn't think about: Girls are 'shuffled' between locations every week. What should we do for girls that are set to a specific location by their _BK.ini setting? It would be weird if they were nailed in place.

I lean towards the following solution: Girls with that setting generate in place and do not shuffle until MC first interacts with them. After that they change locations normally.

I'm willing to hear other suggestions.
Maker of BK. Looking for the latest patch for BK 0.2? The link doesn't change, so bookmark it!

Kyzer

QuoteWhat should we do for girls that are set to a specific location by their _BK.ini setting? It would be weird if they were nailed in place.
I mean for normal girl it would be weird, but if it's for specific girl like a mermaid that you just want to stay at beach location or something it would be quite normal right?