Conditional 'item get' events called from a file [Solved]

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
yon
Regular
Posts: 174
Joined: Tue Sep 09, 2014 5:09 pm
Projects: YDSP
Soundcloud: tetra-yon
itch: v-ual
Location: United States
Contact:

Conditional 'item get' events called from a file [Solved]

#1 Post by yon »

Please forgive me for the awful title. I have NO IDEA how to even articulate it right now, since it's more of an issue with how to go about implementing something, rather than an error I got while trying to do it. If anyone has any idea what I should change it to to be more clear, please tell me.

So, this is a hard issue for me to explain.
I'm trying to figure out how to call up certain item get events that are dependent on how far you are into the story, the location of the event, and what route you're on.
Let me back it up.

My game operates on a specific event schedule, broken up by chapter, day, and time period.

This is what it would typically look like.

Day____|_Morning_|_Day_|_Noon_|_Afternoon_|_Evening_|_Night
Monday_|_Snake___|__O__|_Yui__|____F_____|____F___|__X

O = Minor event that is just for fun, not route related. Something like your classmate complaining to you about homework, taking a nap, or even just thinking to yourself.
[Name] = Route event. You don't see them unless you're on that character's route.
F = Free time event. You get the option to choose where you want to hang out from an imagemap and you go there. Depending on the route, location, and chapter you're on, an item for that route may pop up.
X = Nightly check-in with the flowers. It's a plot thing that I can't explain here.

So, let me explain the free time events a little more.
Whenever you hit a free (as in, you have no route events) afternoon or evening period (or morning/day period on sundays), it calls up the free time file.

For instance, the code for this particular day might look like this:

Code: Select all

label Morning_09:
    if s_r == True:
         call s_route
label Day_09:
    centered "Location, Time"
    x "So cool!"
label Noon_09:
    if y_r == True:
         call y_route
label Night_09:
    call afternoon_freetime
label Evening_09:
    call evening_freetime
label Night_09:
    call flower_check
freetime.rpy looks like this:

Code: Select all

label evening_freetime:
    
    
    menu:

        "I've got some free time. Go out for a while?"
        
        "Yes.":
            pass
        "No.":
            return
    
    window hide None
    call screen test_imagemap
    window show None

    # Call screen assignes the chosen result from the imagemap to the
    # _return variable. We can use an if statement to vary what
    # happens based on the user's choice.

    if _return == "im_ainami":
        jump im_ai
    elif _return == "im_mall":
        jump im_evening_ma
    [...]

label im_ai:
    
    "Went back to Ainami."
    jump im_end

label im_evening_ma:
    
    "Went to the Black Market Mall."
    jump im_end
NOW, the issue I'm trying to figure out, is how to handle the actual location/free time events themselves.
Each character has 10 items you can find for their route, and they only appear if you're on their route. "Red Scarf", for instance, would only appear in the mall for character X starting from chapter 03.

Each location itself has two events written for it.
1) The item get event.
2) The no item event.

The item get event itself is basically "Hey, you got this!" And whatever item it is you got comes up. So, it's the same event for the location no matter what item it is.

IF YOU'RE ON X'S ROUTE, then you would only get the "Red Scarf" by checking the Mall during Chapter 03 or later. Otherwise, it would show the no item get event.

Now, I think partially what's tripping me up is because this would require conditional flags depending on not only the chapter, but the route itself.
The solution to this MAY be to take the dangan ronpa route and have it so that you can get all items and give them to any character, but only specific items work for specific characters.
I have it so that "Red Scarf" and "Blue Scarf" would be X-exclusive, and out of the two of them, only "Red Scarf" would make them happy.
But maybe I should make it so that you could give X any item you picked up, such as "Green Hat", which Character Y would like.

I'm really sorry for how rambling and incoherent this all is. It's a really vague issue I'm trying to address and I can't properly wrap my head around it in the first place.
Last edited by yon on Thu Oct 30, 2014 7:02 pm, edited 1 time in total.

User avatar
yon
Regular
Posts: 174
Joined: Tue Sep 09, 2014 5:09 pm
Projects: YDSP
Soundcloud: tetra-yon
itch: v-ual
Location: United States
Contact:

Re: Conditional 'item get' events called from a single file

#2 Post by yon »

I think I managed to come up with a solution, if anyone's wondering.

At the beginning of each chapter (in which you can get a present for your specific route) I have these little markers.

This one's in chapter 02.

Code: Select all

    if an_r == True:
        $ 02_ft_an = True
    elif az_r == True:
        $ 02_ft_az = True
    elif s_r == True:
        $ 02_ft_s = True
    elif y_r == True:
        $ 02_ft_y = True
And then this is in the free time file. Let's use the mall location.

Code: Select all

label im_morning_ma:
    
    if 02_ft_an == True:
        jump im_morning_ma_unlock
    elif 02_ft_az == True:
        jump im_morning_ma_unlock
    elif 03_ft_s == True:
        jump im_morning_ma_unlock
    elif 03_ft_y == True:
        jump im_morning_ma_unlock
    elif 07_ft_mi == True:
        jump im_morning_ma_unlock
    else:
        jump im_morning_ma_lock

Code: Select all

label im_ma_unlock:
    
    [...]

    if 02_ft_an == True:
        $ an_pres_02 = True
    elif 02_ft_az == True:
        $ az_pres_01 = True
    elif 03_ft_s == True:
        $ s_pres_04 = True
    elif 03_ft_y == True:
        $ y_pres_03 = True
    elif 07_ft_mi == True:
        $ mi_pres_04 = True
        
    $ 02_ft_an = False
    $ 02_ft_az = False
    $ 03_ft_s = False
    $ 03_ft_y = False
    $ 07_ft_mi = False

    return
So that's the code for making the present appear at that time. When I have sprites, I think I'll have it show up at this time, with a little text box saying "Obtained [Red Scarf]!" or something
I made the variables set to false after you unlock it so that you can only get it once while playing. Though, I suppose I could change the code for that part to, for example:

Code: Select all

    if mi_pres_04 == True:
        $ 07_ft_mi = False
That shouldn't cause any issues, right?

Also, if the necessary parameter isn't true, then this one plays instead.

Code: Select all

label im_morning_ma_lock:
    
    [...]
    
    return
As you can see, nothing really happens. It just shows some text and then you go home.

Post Reply

Who is online

Users browsing this forum: No registered users