【Renpy Tutorial #06】Favorability system / Affection System (Use Of variable)

I think favorability system / affection system / point system or idk relationship system... etc. is a very important part of a VN. It might be hard for some people to do it so I create this tutorial! 

If you don't know how to work with variables, keep reading!

    Preparation for your Affection System

    Things you need to prepare before reading this tutorial:

    Renpy Itself: Download Renpy here 

    Atom ( Or other editors are also possible ) : Download Atom here

    Other than that, you don't need anything else


    Custom Renpy Affection System

    First of all you have to figure out how to define your values

    It is best to use the unified one, and it will be better to manage after 

    So before the value you want to define, your need to add  this symbol --> $

    For example:

    $ person_a_aff = 0

    $ person_b_aff = 0

    $ person_c_aff = 0

    $ person_d_aff = 0

    To add = 0 after the value because no option has been selected at the beginning of the value, so it is 0 (basic point = 0)
     
    When a player chooses an answer and you want to increase its favorability point
    You can use this code - ( just an example ) $ person_a_aff += 1

    $ person_a_aff - Let Renpy knows which value increased by a few points

    += - Let renpy knows whether to add or subtract this value --> + = favorability increases

    1 - Let Renpy know how much to add/subtract to this value --> 1 point increase in favorability

    If you want to add 5 points, you can change the back to 5:
     $ person_a_aff += 5

    If you want to subtract 5 points you can change + to -:

    $ person_a_aff  -= 5


    Trigger the plot based on favorability

    If you need to set something like when someone's favorability is higher than 5, a certain plot will be triggered

    You can do something like this:

    label (your label name) :

    if person_a_aff >= 5:

        jump special

    else:

        jump continue

    label (your label name) : #- Each new scene needs its own label name

    if person_a_aff >= 5: #- when person_a_aff''s favorability is greater than 5

        jump special #- screen jumps to a special scene

    else: #- If favorability is less than 5 (=The above code does not hold, so  it is False)

        jump continue #-Then just continue without jumping to the special plot.

    Of course, you can also set it to trigger a certain story when the favorability is lower than 5:


    label (your label name :

    if person_a_aff <= 5:

        jump ignore

    else:

        jump ThankYou


    Just change > (greater than ) to < (less than )

    If you want to set it to trigger a certain plot when the favorability is 5 (no more than or less than)

    You just need to change > (greater than ) or < (less than ) to = (equal to )

    For example like this: if person_a_aff == 5:


    Make Renpy remember an option

    If you don't set a favorability level and want the system to remember an option the player has made before

    For Example:

    menu:

      "pick Lisa":

            $ pick = "Lisa"

      "pick Tom":

            $ pick = "Tom"

      "pick Sam":

            $ pick = "Sam"

    "Next Day"

    "Knock Knock, someone knocks on your door."

    if pick == "Lisa":

        "Oh Its Lisa"

    if pick == "Tom":

        "Oh Its Tom"

    if pick == "Sam"

        "Oh Its Sam"


    menu: #- Choice command, to start a choice screen, you need to type menu: first

      "pick Lisa": - It is the option (choice) the player will see

            $ pick = "Lisa" - If the player chooses the option above then $ pick = "Lisa" will become Treu

    if pick == "Lisa": - == is used to confirm if the player has previously selected Lisa 

        "Oh Its Lisa" - it will show this line


    Show special options only if the player has selected an option

    If you want only players who picked Lisa to see an option you can do this (for example):

    Lisa "Do you want to come with me?"

    menu:

         "No":

              jump no

         "Yes" if pick == "Lisa":

              jump yes


        "No": - is an option that will definitely show no matter what player chose

              jump no - If player didn't choose Lisa before, the player will only has this option

         "Yes" if pick == "Lisa": - This option will only appear if player selected Lisa before

              jump yes - If player choose yes, it will jump to the label of yes

    Basically, a simple favorability function that an ordinary visual novel will use is just done!

    Other related links:

    Click here to read the 5th article (Custom Renpy Gallery screen)

    Click here to read the 4th article (Custom Renpy Confirm Screen)

    Click here to read the 3th article (Custom Renpy Preferences Screen)

    Click here to read the 2nd article (Custom Renpy GUI)

    Click here to read the 1st article (Basic Renpy Code Things)

    【Renpy Tutorial #06】Favorability system / Affection System (Use Of variable) 【Renpy Tutorial  #06】Favorability system / Affection System (Use Of variable) Reviewed by NingNing on July 20, 2021 Rating: 5

    2 comments:

    Leave A Message!

    Powered by Blogger.