How to add "relationship meters" and "turns" to renpy...

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.
Message
Author
User avatar
laprimavera
Newbie
Posts: 15
Joined: Mon Aug 08, 2011 6:27 pm
Contact:

How to add "relationship meters" and "turns" to renpy...

#1 Post by laprimavera » Mon Aug 08, 2011 6:47 pm

Does anyone know how to add turns and relationship meters to renpy? For the turns, depending on which turn, there will be an event triggered (such as on turn 10 there will be an automatic event after finishing the turn and before the next turn starts). And does anyone know how to add relationship meters to renpy also? so depending on how much visits to the person, the meter will increase (or decrease if you offend the person). It is a map based game (that's what the visits mean) and i want the game to be that depending on how much time you visit the person, the meter will increase. And, if possible, I want there to be other things to affect another meter (this meter is about the main character's morale and health).

User avatar
Rewritten Ennui
Veteran
Posts: 279
Joined: Thu Jul 14, 2011 1:50 pm
Organization: TwinTurtle Games
Contact:

Re: How to add "relationship meters" and "turns" to renpy...

#2 Post by Rewritten Ennui » Mon Aug 08, 2011 7:43 pm

:| I'm a little confused by the 'turn' part of your game, but I do know how to implement a relationship system in Ren'Py. First define variable values at the beginning of the game, like so:

Code: Select all

label start:
    $ Bob = 0
    $ Joe = 0
    $ Tom = 0
All three of the guys like you equally, which is not at all. The values can be changed throughout the game, so don't worry about that :lol: The player will probably talk to the people, so you can raise or lower the values when you use a menu.

Code: Select all

menu:
    "What should you say to Bob?"
    "\"I think you're really cool.\"":
        $ Bob += 1
        "Bob" "Thanks for the complement."
    "\I totally hate your guts and stuff.\"":
        $ Bob -= 1
        "Bob" "I am suddenly feeling very offended!"
The dollar sign ($) makes Ren'Py recognize that a variable is in use. When you complement Bob, the plus sign (+) before the equal sign (=) tells Ren'Py to increase the value of how much he likes you. When you tell Bob that you don't like him, the minus sign (-) will subtract points from how much he likes you. If you want to activate a special event, use the 'if' statement.

Code: Select all

if Bob >= 5:
    "Bob" "I kinda like you."
else:
    "Bob" "Oh, so we meet again?"
'>=' is greater than or equal to, just like in math. So that means if the player's points are equal or greater than 5, Bob will say that he likes you. If the player's points are a lower value like 4, then Bob will say something else.

And that's about it for your relationship meter. As for health and morale, that sounds like something that the Dating Sim Engine could do. DSE is rather powerful though, so you shouldn't tinker with it unless your confident about your coding skills. I really can't help you with your map dilemma though; you'll have to give me an example of an existing game that has a feature like that before I can suggest anything. Hopefully I helped you a little bit, and good luck.
I've swapped accounts to CheeryMoya, so this account is no longer in use. Refer to the new account if you want to contact me.

Twinturtle Games Website

User avatar
laprimavera
Newbie
Posts: 15
Joined: Mon Aug 08, 2011 6:27 pm
Contact:

Re: How to add "relationship meters" and "turns" to renpy...

#3 Post by laprimavera » Mon Aug 08, 2011 7:54 pm

Thanks so much for replying so fast! The information you provided was very helpful :D.

What I mean by "turns" is that every time you visit someone on the map I'm talking about, the turn includes the visit and any event that happens in between.

For example, visiting person A 10 times is 10 turns. Visiting person A 8 times and person B 2 times is also 10 turns. I want, after a specific amount of turns, there is an event played.

So, for example, after visiting person person A on your 10th turn, and depending on your relationship level, an cg event is triggered with that person. I'd like to know how to do that :)

User avatar
laprimavera
Newbie
Posts: 15
Joined: Mon Aug 08, 2011 6:27 pm
Contact:

Re: How to add "relationship meters" and "turns" to renpy...

#4 Post by laprimavera » Mon Aug 08, 2011 7:56 pm

I'm also wondering how to make a transparent menu in renpy, where the widgets are clear and you can see the background.

User avatar
Rewritten Ennui
Veteran
Posts: 279
Joined: Thu Jul 14, 2011 1:50 pm
Organization: TwinTurtle Games
Contact:

Re: How to add "relationship meters" and "turns" to renpy...

#5 Post by Rewritten Ennui » Mon Aug 08, 2011 8:18 pm

Sorry, still stumped :| The only thing I can think of right now is the imagemap function, which will let you use an image and hotspots. You can combine it with the points system I mentioned earlier, but you have to set up the imagemap first. I already answered a question like this earlier, so here's pretty much a copypasta of my code.

Code: Select all

screen Town:
    imagemap:
        auto "imagemap_%s.jpg"
        
        hotspot (57, 81, 149, 194) action Return("Bob's house")
        hotspot (207, 145, 310, 210) action Return(Joe's house")
        hotspot (220, 25, 340, 90) action Return("Tom's house")
"imagemap_%s.jpg" saves you some space by referring to two files simultaneously; "imagemap_ground.jpg" and "imagemap_hover.jpg". The hover image should be the same as the ground image, except with something indicating a hotspot's presence. Notice the 4 numbers in parenthesis after hotspot. The first two numbers indicate the upper-lefthand corner, while the last two numbers indicate the lower-righthand corner. All the space in-between is the hotspot itself, which will reveal itself when you hover your mouse over it.

To implement the imagemap in the game, the code looks like this. I'll modify it so that way there are also points for turns.

Code: Select all

window hide None
    call screen Town
    window show None
    if _return == "Bob's house":
        $ turn += 1
        "You visited Bob."
    elif _return == "Joe's house":
        $ turn += 1
        "You visited Joe."
    elif _return == "Tom's house":
        $ turn += 1
        "You visited Tom."
Be sure to define the 'turn' variable first. So while this is a rather crude way of keeping track of visits, it should get the job done for you.

As for your transparent menus, I don't know >_> I have absolutely no idea how to do that, but maybe you should go search in some older topics. I had a lot of my questions answered that way, and you'd be surprised at how often the same types of questions are asked.
I've swapped accounts to CheeryMoya, so this account is no longer in use. Refer to the new account if you want to contact me.

Twinturtle Games Website

User avatar
laprimavera
Newbie
Posts: 15
Joined: Mon Aug 08, 2011 6:27 pm
Contact:

Re: How to add "relationship meters" and "turns" to renpy...

#6 Post by laprimavera » Mon Aug 08, 2011 9:22 pm

Is there any way for a meter to be shown on the screen?

User avatar
xelacroix
Regular
Posts: 68
Joined: Mon Jul 25, 2011 2:28 am
Projects: beautiful girls
Contact:

Re: How to add "relationship meters" and "turns" to renpy...

#7 Post by xelacroix » Tue Aug 09, 2011 2:53 am

helpful

User avatar
laprimavera
Newbie
Posts: 15
Joined: Mon Aug 08, 2011 6:27 pm
Contact:

Re: How to add "relationship meters" and "turns" to renpy...

#8 Post by laprimavera » Tue Aug 09, 2011 4:08 pm

If you still don't understand what "turns" mean, if you are familiar with Heart no Kuni no Alice and other games of the like, then you would know what it is. In the game, every 10 turns is a cg. In each turn you talk to a person, and that is the turn. During the 10th turn, after talking to a person, you get a cg with the person you just talked to (if your relationship level is high enough with them).
Like I said earlier, I'd like to also know how to put a chart or meter on one of the menu buttons so players can keep track of relationship levels.
The imagemap definatly helps with the "turn" question I have, but I 'd like cg's to be shown every few turns depending on the relationship level.
I guess I'll explain it better now:
I have a good idea of how it should work, but I don't know how to implement it into Ren'Py.
I want to use a code like this:

Code: Select all

if Bob >= 5:
    "Bob" "I kinda like you."
else:
    "Bob" "Oh, so we meet again?"
But except for words, I want pictures. For the "else" part, I want it to be the Jump function, so it continues onward with the game, skipping the cg.

User avatar
Rewritten Ennui
Veteran
Posts: 279
Joined: Thu Jul 14, 2011 1:50 pm
Organization: TwinTurtle Games
Contact:

Re: How to add "relationship meters" and "turns" to renpy...

#9 Post by Rewritten Ennui » Tue Aug 09, 2011 7:28 pm

I haven't played Heart no Kuni no Alice, nor am I able to find any gameplay vids of it. If you can find one to show me, then I'll understand it better. As for showing those relationship levels, the easiest way to let the player see them would be to use the DSE framework. I've been trying to pull out the code and test it on a new template, but I can't seem to find the exact string of commands to show the meters that you want :( Sorry, I'm still trying to learn advanced commands myself.

But showing a picture during an event is easy. Just use the 'scene' statement.

Code: Select all

if Bob >= 5:
    scene Bob doing stuff
    "Bob" "So... you want to go to the movies or something?"
else:
    jump somewhere
It's really simple stuff. It's mainly trying to keep the blocks in order and stuff. I suggest you familiarize yourself with the Ren'Py jargon some more by reading the tutorials, which are right here. Hopefully you'll find answers to most of your questions.
I've swapped accounts to CheeryMoya, so this account is no longer in use. Refer to the new account if you want to contact me.

Twinturtle Games Website

User avatar
laprimavera
Newbie
Posts: 15
Joined: Mon Aug 08, 2011 6:27 pm
Contact:

Re: How to add "relationship meters" and "turns" to renpy...

#10 Post by laprimavera » Tue Aug 09, 2011 7:31 pm

I know a link to where you can download it. It's in japanese, and you can use the link I provided to translate it. Should I private message you the link?

User avatar
Camille
Eileen-Class Veteran
Posts: 1227
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: the head well lost
Organization: L3
Tumblr: narihira
Deviantart: crownwaltz
itch: lore
Contact:

Re: How to add "relationship meters" and "turns" to renpy...

#11 Post by Camille » Tue Aug 09, 2011 9:50 pm

I added this page to the cookbook, which shows how to show points and meters and whatnot on the screen. For the turns, you'd just use a variable, right? Like make:

Code: Select all

init:
    $ turns = 0
And then as you go through the game, keep adding +1 to turns. When you want a CG:

Code: Select all

    if turns == 10 and bob_points > larry_points:
        show image bob_cg
Something like that. It's not too hard.

User avatar
laprimavera
Newbie
Posts: 15
Joined: Mon Aug 08, 2011 6:27 pm
Contact:

Re: How to add "relationship meters" and "turns" to renpy...

#12 Post by laprimavera » Tue Aug 09, 2011 9:55 pm

thanks Camille! It helped a lot :D
Do you know how to make the menu buttons transparent?

User avatar
Camille
Eileen-Class Veteran
Posts: 1227
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: the head well lost
Organization: L3
Tumblr: narihira
Deviantart: crownwaltz
itch: lore
Contact:

Re: How to add "relationship meters" and "turns" to renpy...

#13 Post by Camille » Tue Aug 09, 2011 9:57 pm

There's a transform property called "alpha" that controls the opacity of a displayable. Alternately, if you're using image buttons, you could just make your image transparent.

User avatar
laprimavera
Newbie
Posts: 15
Joined: Mon Aug 08, 2011 6:27 pm
Contact:

Re: How to add "relationship meters" and "turns" to renpy...

#14 Post by laprimavera » Tue Aug 09, 2011 10:06 pm

for the init part, do you add that to the script, or another .rpy file?

User avatar
Camille
Eileen-Class Veteran
Posts: 1227
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: the head well lost
Organization: L3
Tumblr: narihira
Deviantart: crownwaltz
itch: lore
Contact:

Re: How to add "relationship meters" and "turns" to renpy...

#15 Post by Camille » Tue Aug 09, 2011 10:07 pm

It doesn't really matter where you put it as long as you indent properly. More on that here.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], _ticlock_