[Solved] Kind of a Virtual Pet System + points system?

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
UkiTheMaid
Newbie
Posts: 19
Joined: Tue Oct 25, 2016 10:26 am
Completed: Demon Dinner Date
Organization: GhostGlow Productions
Location: Brazil
Contact:

[Solved] Kind of a Virtual Pet System + points system?

#1 Post by UkiTheMaid »

So, recently I started a project, where, in essence, you are a gardener and you have to care for an alraune (human+plant monster). It's pretty bare bones at this point, but I know I want to implement a points system to it.

I've been reading on points systems, and I understood the basic type of points system very well, although, there's something I would like to ask, if it's possible to be done:

The game works on a day-by-day system, and when you visit your "plant", you have different choices on how to interact with it, like watering and chatting and so on. But, I want it for some things to happen, like, if you water it too much that decreases points and whatnot. How can I make it possible for the game to "remember" how much you did x activity and the plant is saturated? And is there a way for said saturated stat to go down after a while, so you can do it again (I mean, it wouldn't make sense to only water a flower once and never again!).
Last edited by UkiTheMaid on Mon Mar 13, 2017 10:19 pm, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2402
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Kind of a Virtual Pet System + points system?

#2 Post by Ocelot »

Let's write some code:

Code: Select all

# I have decided, that water level will be a number from 0 to 100, 
# where 0 is completely dry (and dead)
# and 100 is overwatered (and dead)
# 50 is a sweet spot, and we start from it
default water_level = 50

# We will have a 'friendship points' here
# we will start with two
default friendship = 2

# Just setting up some helper variable. 
# It kepps information if we talked today to flower.
default talked_today = False

label start:
    jump day_start

label day_start:
    'You walked to your flower'

    # Some text to describe flower condition
    # depending on water level
    if water_level <= 0:
        # If flower is completely dry, then it is dead, jump to death handling
        jump flower_dead.dry
    elif water_level <= 20:
        'The ground is dry, flower started to wither'
    elif water_level >= 100:
        # It is overwatered too much. This kills plant
        jump flower_dead.overwatered
    elif water_level >= 80:
        'You smell something moldy and rotten. Almost like in a swamp.'
    else:
        'Flower looks healthy!'

    # Each day the flower is not in pristine condition, your friendship will deteriorate.
    # I could put it in parts where I output text. It would work the same
    # I just decided to put some fancy condition here
    if  water_level not in xrange(21, 79):
        $ friendship -= 1

    # If friendship falls too low, it is the end of the game
    if friendship <= 0:
        jump flower_dead.heartbroken

    menu flower_menu:
        'What will you do with the flower?'

        'Water it':
            # Watering will increase water_level by 15 points
            $ water_level += 15
            'You watered your flower.'
            # And then we will jump back to the menu, allowing to water it again (or do something else in the future)
            jump flower_menu
        
        'Chat' if not talked_today:
            # We set this variable to True, so this options won't show again for today
            $ talked_today = True
            # And we will increase friendship by one
            $ friendship += 1
            'You told latest news to the plant'
            jump flower_menu

        "I think, it's enough":
            # just exit menu.
            pass
    'It is late evening. You went to bed.'
    jump night

label night:
    # We do some bookkeeping here
    # For example, with every day passed, water_level will decrease by 10
    $ water_level -= 10
    # With watering increasing it by 15, this means
    # that we need to water flower 2 of each 3 days
    
    # We will set talked_today variable back To False
    # So you could talk to it again next day
    $ talked_today = False

    # The win condition is to increase your friendship to 25.
    if friendship >= 25:
        jump win

    # Jump to the next morning when we finished
    jump day_start

# and now we should handle flower death
label flower_dead:
    return
label .dry:
    'It is a completely dried husk. Did you ever water it?'
    return
label .overwatered:
    'The stalk is completely rotted. Rest of the mlant is consumed by mold.'
    return
label .heartbroken:
    'The flower died of sadness.'
    return

label win:
    'You won the trust of the flower. Congratulations!'
    return
You can put it in freshly created project instead of whole script.rpy content and check, how it works.

EDIT: Added some more code
< < insert Rick Cook quote here > >

User avatar
UkiTheMaid
Newbie
Posts: 19
Joined: Tue Oct 25, 2016 10:26 am
Completed: Demon Dinner Date
Organization: GhostGlow Productions
Location: Brazil
Contact:

Re: Kind of a Virtual Pet System + points system?

#3 Post by UkiTheMaid »

Ooooh, this is good, very good!! =eats up the code=

I'll see how that works for me, and if I find any hiccups along the way I'll come back here!

User avatar
UkiTheMaid
Newbie
Posts: 19
Joined: Tue Oct 25, 2016 10:26 am
Completed: Demon Dinner Date
Organization: GhostGlow Productions
Location: Brazil
Contact:

Re: Kind of a Virtual Pet System + points system?

#4 Post by UkiTheMaid »

What should I do if I want the value of the default statements on a text box? Using [] doesn't seem to be working...

EDIT: Ops, never mind, I figured out XD

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]