Variables: bonuses and penalties [solved]

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
maklakara
Newbie
Posts: 20
Joined: Fri May 31, 2013 7:09 pm
Contact:

Variables: bonuses and penalties [solved]

#1 Post by maklakara » Sun Jun 23, 2013 8:28 pm

So, I'm trying to add a basic check that would work like this: each day the character would need to sleep. When you select the "sleep" action, there would be a call that would check your fitness level. If the fitness level is low, it would add a penalty on your "health" variable.

The "penalty" system should work like a "equipment" system. Meaning that if you have low fitness, you should have a -10 health penalty, if you have very low fitness, you should have a -20 health penalty, if you have normal fitness, you would have no health penalty, if you have good fitness, you would have a +10 health bonus, etc.

The thing is, it shouldn't repeatedly lower your health if you have low fitness on two consecutive days, it's an "one-time" penalty. If I make something like this:

Code: Select all

$ fitness = 5

Menu:
    "Sleep":
        call health_label

label health_label:
    if fitness <= 10:
        health -= 15
    return
Then on every night there would be a 15 health loss, which isn't the idea. This also wouldn't restore the "-15" health lost when you get a "normal" fitness level once again.

I couldn't think of any solution that wouldn't be an absolute clusterfuck of variables and conditions. Is there any practical way of doing this?


Cheers :)
Last edited by maklakara on Mon Jun 24, 2013 10:11 pm, edited 1 time in total.

pwisaguacate
Veteran
Posts: 356
Joined: Mon Mar 11, 2013 11:03 pm
Contact:

Re: Variables: bonuses and penalties

#2 Post by pwisaguacate » Sun Jun 23, 2013 9:33 pm

Here goes an attempt:

Code: Select all

    $ health_max = 100
    $ health = 100
    $ fitness = 5

label health_label:
    $ health = health_max # health_max is not needed if full health is constant

    if fitness <= 10:
        $ health -= 15

    return
This assumes that health is to restore completely when no effects are applied.

maklakara
Newbie
Posts: 20
Joined: Fri May 31, 2013 7:09 pm
Contact:

Re: Variables: bonuses and penalties

#3 Post by maklakara » Mon Jun 24, 2013 10:10 pm

Very simple but clever & efficient. Solved my problem 100%!

Thank you :D

Post Reply

Who is online

Users browsing this forum: _ticlock_