I know this is a seemingly easy thing to script in our games if you're kinda good, good, or an expert with python and have been working with Renpy for months to years now. But, I figured I'd code up a script that could show some new comers who wanna learn how to program their games how to create a neat affection system, and how it can affect choices later on in the game. Here's the code:
Code: Select all
define m = Character('Me', color="#c8ffc8")define g1 = Character('Mai', color="#c8ffc8")define g2 = Character('Yui', color="#c8ffc8")define g3 = Character('Hina', color="#c8ffc8")# The game starts here.label start:# Affection Begin$girl_one_aff = 0$girl_two_aff = 0$girl_three_aff = 0m "Let's try raising our affection with the girls..!"m "WARNING: Some choices we make will make the the other girl(s) dislike us more, so be careful!"menu: "Who should I talk to first?" "Mai": jump choice_mai "Yui": jump choice_yui "Hina": jump choice_hinalabel choice_mai:m "Hey, Mai!"g1 "Oh, Hello! How are you?"m "I'm doing fine...hey, listen..um.."menu: "What should I ask her?" "Wanna go on a date?": $girl_one_aff += 5 $girl_two_aff = 0 $girl_three_aff -=5 jump mai_date "What have you been up to?": $girl_one_aff -=5 $girl_two_aff = 0 $girl_three_aff +=5 jump next_daylabel mai_date:g1 "A date? *blush* O-of course!"m "{i}Wow, can't believe it was that easy...{/i}""You and Mai go on a date. You both drink warm cider on the boardwalk, and then enjoy the rest of the evening at the beach."m "{i}Wow, Mai is a real nice girl..{/i}""Mai looks into your eyes, smiling."menu: "What do you do?" "Make my move!": $girl_one_aff += 10 $girl_two_aff -= 5 $girl_three_aff -= 20 "You lean in, and kiss Mai. She is surprised, but for a moment you can see true love in her eyes." g1 "..I love you!" jump next_day "Hug her, and head back home..?": $girl_one_aff -= 3 $girl_two_aff = 0 $girl_three_aff +=3 m "Well, see you later." g1 "Oh...okay..." jump next_daylabel choice_yui:"You run into Yui at a restaurant near your home."m "Hey, Yui!"g2 "Hey, you! What's up?"menu: "What shall I answer?" "Do you...wanna go on a date?": $girl_one_aff -= 5 $girl_two_aff -= 5 $girl_three_aff = 0 g2 "I wouldn't necessarily call it a date, but fine. Whatever." jump yui_date "Just asking.": $girl_one_aff = 0 $girl_two_aff -= 10 $girl_three_aff = 0 jump next_daylabel yui_date:"You and Yui go to a club down the road to have some drinks and dance. It's normal fun as friends...""Then, you realize you may be a bit tipsy.."g2 "Are you sure you're feeling alright, hm?"menu: "What to say?" "Say nothing. Just go for a kiss!": $girl_one_aff -= 20 $girl_two_aff += 15 $girl_three_aff -= 10 "To your surprise, after you've realised what you've done, Yui kisses back! Congrats!" g2 "That was..amazing!" jump next_day "I'm alright, thanks for caring..": $girl_one_aff = 0 $girl_two_aff -= 10 $girl_three_aff = 0 jump next_daylabel choice_hina:m "Hey there, Hina!"g3 "Hey. What's up??"menu: "What's your answer?" "Wanna..erm...go on a date?": $girl_one_aff = 0 $girl_two_aff -= 10 $girl_three_aff += 10 g3 "OOOOH! I'd LOOOOOOOOOOOVE TOO! HEHEHE, I'M SO HAPPY YOU ASKED!" jump hina_date "Just walking around.": $girl_one_aff = 0 $girl_two_aff = 0 $girl_three_aff -= 20 g3 "Oh..um...okay.." jump next_daylabel hina_date:"You and Hina go to your home, and play video games. You're surpsied with her skills." m "Wow, Hina. You're really good at this game."g3 "Thank you!!!""She looks at you for a good moment with a lovely smile and a glare in her eyes."menu: "What will you do?" "Go in for a kiss!": $girl_one_aff -= 5 $girl_two_aff -= 20 $girl_three_aff += 25 "You lean in for the kiss, but surprisingly, Hina kisses you first!" g3 "You don't know how long I've waited for this :) ...." jump next_day "Continue the game.": $girl_one_aff = 0 $girl_two_aff +=1 $girl_three_aff -=5 "You continue the game..." "Nothing else interesting happens that night..." jump next_daylabel next_day:m "OK! Now that I've talked to the girls, it's time to pop the big question to one of them!""It's time to propose to the girl of your interest.""First, let's see how the girls feel about you!""Mai has %(girl_one_aff)d points for you. Yui has %(girl_two_aff)d points for you. And, Hina as %(girl_three_aff)d points for you!"menu: "Who will you marry?" "Mai": if girl_one_aff <= 9: g1 "Marry you? I'm sorry, but I don't like you.." jump bad_end else: $hina_marry = False g1 "Ma-marriage! Of course! Oh we're going to have a wonderful wedding!" jump good_end "Yui": if girl_two_aff <= 9: g2 "Marriage? AHahah, this is a great joke. If you'r being serious, the answer is no." jump bad_end else: $hina_marry = False g2 "I've been waiting for this question! I can't wait to be your wife!" jump good_end "Hina": if girl_three_aff <= 9: g3 "Sorry, but you ignored me and broke my heart. I can't marry you..." jump bad_end else: $hina_marry = True g3 "YES YES YES YES! I've been waiting for you to ask this my entire life!" jump good_endlabel bad_end:"So, you didn't get any of the girls to like you. Nor did you become a husband.""Too bad. ~Bad ending."returnlabel good_end:"You had a wonderful wedding! Cake, all your friends, your parents, the whole 9 yards.""Then, you went home for your honeymoon treat.."if hina_marry: "You also found out that Hina has been stalking you since middle school."else: "The end!"return
At the beginning, each girls feels 0 affection for you, but you wanna marry one of the girls right? So you need to build their affection. This is something a lot of Visual Novels with Love or DSE's will have. Sometimes, you will even see a notification of some sort showing your affection raised/lowered, but this gives newcomers a good feel of what's going on here. NOTE: It's important to keep the blocks as is. Renpy uses Python blocks when coding, and each block will contain a label/name/dialogue,etc and then the data is detailed in the block after the : using four spaces. To test, just copy & paste the code into your script.rpy file.
Effecting Menus and Choices:
Felt like I should add this too, since this topic is old enough for an update, and since my skills with Ren'py have gotten much better over the course of the last few months. Anyways, you can easily make these 'affection' points into so much more, as a way of displaying only certain options in a menu or a certain menu at times, like so:
Hiding/Showing different menus based on Affection Points:
Code: Select all
if girl_one_aff >=5 and girl_one_aff <=10: menu: "Call Mai.": jump call_mai "Go on a date with Mai": jump date_maiif girl_two_aff >=5 and girl_two_aff <=10: menu: "Call Yui.": jump call_yui "Go on a date with Yui": jump date_Yui
The above is a very basic example of how to do this. Basically, if you have more than 5 affection points but less than 10 with Mai or Yui (girl one and girl two), then the menus will show. Naturally, you should define a base menu that won't require any skills and have a menu defined for higher values. Let's get a bit more advanced with it:
Showing certain options based on Affection Points:
Code: Select all
menu: "Call Yui.": jump call_yui "Go on a date with Yui": jump date_Yui "Activate \'Coffee Mod\' with Yui." if girl_two_aff >=20 and girl_two_aff <=25: jump yui_coffee_mod
The above will show a menu with two options by default, and if your affection points with Yui are higher than 20 but less than 25, you can choose the 'Coffee Mod' option (+1 cookie to whoever knows that little reference). You can also add in more to the above that will require the player makes more additional statements in order to see the option:
Code: Select all
menu: "Call Yui.": jump call_yui "Go on a date with Yui": jump date_Yui "Activate \'Coffee Mod\' with Yui." if yuis_club and girl_two_aff >=20 and girl_two_aff <=25: jump yui_coffee_mod
So now, to see the 'Coffee Mod' option, you will need to have the variable yuis_club set on true and the right amount of affection.
Simplified Syntax..of some sort:
Code: Select all
if girl_one_aff >=5 and <=10:
Simplified: If girl one's affection points are greater than 5 but less than 10, do the following.
Code: Select all
if yuis_club and girl_two_aff >=20 and girl_two_aff <=25:
Simplified: If yuis_club is true (Basically, if $yuis_club = True ) and girl two's affection points are greater than 20 and less than 25 do the following:
Those are very basic examples of how to do this, you can get even more in detailed with this but since I've been using something similar in my W.I.P game, I figured I'd share the basics here with you all. You can definitely do much more with this. Hope it helps.
Beginning pre-production work on a project in Renpy. After being away for 5 years, it's time to get back in the game