Hello everyone, I came into another road block with Ren’Py, I figured out how to do dialouges,basic menus, and defining characters. But i am confuse on how to do mechanics for the game. For my game i want to add a weight gain mechanic,a fullness mechanic and sickness mechanics. How do i do this?
Addition: I want to turn off the sickness mechanic in the message screen
It really depends on what you exactly want going on for a feature. At the very least, you will need an understanding of variables and how to set and modify them. I can take your sickness mechanic as an example and explain how it could function in a few ways.
Totally Random
Lets say you have a day loop setup and at end of day you add up points, increase the day value, and decide if the player has gotten sick. It could be annoying for the player, but we will make it totally random that they can become sick any particular start of the day. Lets say, there’s a 1 in 10 chance that they will wake up sick. First will want a variable to know that they are sick, lets call it ‘isSick’. In the rest of the code, just check if isSick
is True, then you can do specific logic on that. This is how it would look.
Code Block
# This block gets run first, put your library imports here.
init python:
import math
# Get the Python Random Library
import random
# You can also define vars here too.
is_sick = False
label endOfDayLoop:
# Do End of Day Stuff Here
# Apply Sick Logic
# First check if the player is not already sick
if is_sick == False:
# This makes it a python block for easy maths
python:
# This method randomly selects a value between 1 and 10
# Then performs modulous which returns 0 if the left side matches the right.
if ( 1 % random.randint(1,10)) == 0:
# The player is now sick!
is_sick = True
# Do other Logic here
# ...
# Jump to start of day
jump startOfDay
Hitting a score
You can use a number value for sickness. When over a specific number, say 100, it means the player is sick. See the following example.
Code Block
init python:
import math
# Get the Python Random Library
import random
# # You can also define vars here too.
# is_sick = False
sickness_score = 0
label endOfDay:
# Do End of Day Stuff Here
"You go to bed."
# Jump to start of day
jump startOfDay
label startOfDay:
if sickness_score >= 100:
"You are sick."
"You take some medicine and begin to feel better"
$ sickness_score = 0
else:
"You are feeling fine."
# Do something to make yourself get sicker
"You roll in the mud"
$ sickness_score += 10
jump endOfDay
Weighted probability
I was going to write this more complicated version out, but ran out of time…
Just a few notes:
- First up don’t declare variables in
init python
blocks. There’s a good chance they won’t end up in any saved game. Use Ren’Py’sdefault
to declare variables that need to be persisted in a save game. - Don’t use the
random
library directly. Use therenpy.random
wrapper instead as this makes it play nicely with rollback. You don’t need imports this way either, justrenpy.random.randint(1, 10)
.
I agree though we need more information from @KingNovum about how these mechanics are supposed to work before anything could be coded up as a suggestion.
@ticktock @dingotush, What i had in mind for each mechanic is as follows:
Weight gain mechanic: Weight gain is based on calories eaten and is determine by the MC height and weight (64 inches and 120 lbs),Eating a certain amount will cause the MC to gain weight.To make it realistic,it is roughly 3500 calories a day.
Fullness and sickness:
So for this mechanic, i wanted to have it to where after eating a certain amount,the MC starts getting full and have 4 stages(for image purposes). The four stages are: Empty,full,Stuffed and overstuffed. This is allow me to update the MC image accordingly. The sickness ties into this by only appearing after being stuffed. This enables a menu option to throw up to get rid of the fullness and sickness but will make a character more aggressive if caught. Seeing as not everyone would like see that i want to be able to turn it off without make two different paths and duplicate all the endings.
I know need variables, but im not sure to do it properly. How would you guys do it?
I managed to code that weight gain mechanic hopefully it works,the fullness mechanic might be iffy,i don’t know how to make it display yet and update