Jealousy scenes?

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
wonderland
Regular
Posts: 70
Joined: Mon Dec 31, 2012 12:22 am
Projects: Fairy Tale Stupor [GxB] [Fantasy] [Adventure]
Contact:

Jealousy scenes?

#1 Post by wonderland » Mon Jan 28, 2013 12:28 am

Bleh, coding is seriously my worst enemy yet like i've stated before it has also become my cool older brother that teaches me life lessons to make me cooler.. Anyways, I know how to do the:

Code: Select all

if boy1_points > max(boy2_points, boy3_points, boy4_points):
And then you do one for each, but how do you do the jealousy scenes? Like when the MC raises two people's "affection points" to be the same, how can you call a scene that makes them confront the MC and pick the ending?

Sorry if this has been asked before! :/ I've tried the other codes but they just give me chest pains problems.

Thank you SO much!
"Keep your head up princess, if not the crown falls.."
Image

User avatar
Ayutac
Regular
Posts: 150
Joined: Thu Oct 18, 2012 2:23 pm
Projects: Pokémon Dating Sim
Organization: A Breeze Of Science
Deviantart: Ubro
Location: Mayence, Germany
Contact:

Re: Jealousy scenes?

#2 Post by Ayutac » Mon Jan 28, 2013 1:11 am

hmmm... you could built you variables together I guess...

Code: Select all

python:
    boy_points = [boy1_points, boy2_points, boy3_points, boy4_points] ## we put all points in one array to handle them better
    max_points = 0 ## the maximal points archived, we will iterate through all, so no problem starting with boy1
    max_points_indices = [] ## stores which boys points are the max, although the index is lowered by one due to arrays (contains 0 if boy1 has most points)
    for i in range(0, len(boy_points)): ## make the loop relative to number of boys
        if boy_points[i] > max_points: ## got new maximal points
            max_points = boy_points[i] ## save them
            max_points_indices = [i] ## renew the indices array
        ## up to here, this code does the same as your if statements, but now it get's interesting
        if boy_points[i] == max_points: ## another one with the same points
            max_points_indices.append(i) ## add him to the indices list as well
    
    ## now we got all boys with maximal points in one (indices) array
    if len(max_points_indices) == 0: ## this can only happen if every boy has negative points. 
        pass ## If that can't happen, you cann leave the line above and this one out of your code
    if len(max_points_indices) == 1: ## your old situation, only one boy with max points
        renpy.jump('boy' + str(max_points_indices[0]+1) + '_ending') ## jump to the right ending
    else: ## if multiple boys with max points, build a menu (python style)
        boyChoiceSelection = []
        for i in range(0,len(max_points_indices)): ## only the ones with max points
            boyChoiceSelection.append(("Choose boy " + str(i+1), i+1)) ## add each boy (with menu text)
        narrator("Which boy to choose?", interact = False) ## the menu line
        choosenBoy = menu(boyChoiceSelection) ## display the menu
        renpy.jump('boy' + str(choosenBoy) + '_ending')
(normally, I would prefer using camelCase instead of underlines (e.g. maxPoints instead of max_points), but I sticked with your notation)
I commented very much so you understand every step. I hope I did good. I also assumed you have the endings boy1_ending, boy2_ending etc. Change it to whatever is the case; it is only important that they are numbered through.

That would be my style. However, an alternative for the menu would be

Code: Select all

    else: ## if multiple boys with max points, build a menu (python style 2)
        boyChoiceSelection = []
        for i in range(0,len(max_points_indices)): ## only the ones with max points
            ## but with individual texts (of course that could have been in example 1 too with the use of another array)
            if max_points_indices[i] == 0: ## boy 1
                boyChoiceSelection(("choose sweet Adam", 1))
            elif max_points_indices[i] == 1: ## boy 2
                boyChoiceSelection(("choose sexy Barney", 2))
            elif max_points_indices[i] == 2: ## boy 3
                boyChoiceSelection(("choose super Charlie", 3))
            elif max_points_indices[i] == 3: ## boy 4
                boyChoiceSelection(("choose swag Dan", 4))
        narrator("Which boy to choose?", interact = False) ## the menu line
        choosenBoy = menu(boyChoiceSelection) ## display the menu
        renpy.jump('boy' + str(choosenBoy) + '_ending')
Of course you can do all that with less python and more ren'py language, then you would change the code to

Code: Select all

    else: ## if multiple boys with max points, build a menu (ren'py style)
        has_max_points = [False, False, False, False] ## flags
        for i in range(0,len(max_points_indices)): ## only the ones with max points
            has_max_points[max_points_indices[i]] = True

## now we are out of python
menu:
    "Which boy to choose?" ## menu line
    
    "choose sweet Adam" if has_max_points[0]:
        jump boy1_ending ## or jump adam_ending, however you named it (in this example only)
    
    "choose sexy Barney" if has_max_points[1]:
        jump boy2_ending 
    
    "choose super Charlie" if has_max_points[2]:
        jump boy3_ending 
    
    "choose swag Dan" if has_max_points[3]:
        jump boy4_ending 

Some python is necessary if you don't want to hard code all 2 power to the 4 = 16 possibilities.
Up next: An original, open source, text-based Dating Sim. Stay tuned ;)

Post Reply

Who is online

Users browsing this forum: Google [Bot], _ticlock_