Randomizing Outcomes? (Solved)
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.
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.
-
- Veteran
- Posts: 298
- Joined: Thu Jan 06, 2011 9:28 am
- Projects: Unnamed Slenderman VN, Secret 10560
- Location: USA
- Contact:
Randomizing Outcomes? (Solved)
I'm not sure how to phrase the title and my situation, sorry! ><
Basically what I have in mind is that there is a menu in the game with a "run away" option; when the player clicks on "run away", what will take place after that will be randomized so that you may not get the same route twice (either the player runs into a bad guy or the player runs into her friend who saves her from the bad guy). I was also wanting to make it so that if the player talked to the friend before this event, they would have a higher chance of getting the route with the friend. I have no idea how to code this, help is very much appreciated C:
Basically what I have in mind is that there is a menu in the game with a "run away" option; when the player clicks on "run away", what will take place after that will be randomized so that you may not get the same route twice (either the player runs into a bad guy or the player runs into her friend who saves her from the bad guy). I was also wanting to make it so that if the player talked to the friend before this event, they would have a higher chance of getting the route with the friend. I have no idea how to code this, help is very much appreciated C:
Last edited by Lotus on Wed Mar 02, 2011 1:23 pm, edited 1 time in total.
-
- Regular
- Posts: 74
- Joined: Wed Jul 14, 2010 4:56 am
- Completed: cafe minigame
- Projects: Beach Restaurant
- Location: Indonesia
- Contact:
Re: Randomizing Outcomes?
Do you mean like this?
for a percentage of higher chance to get certain event, I don't know about that.
Code: Select all
$ event = renpy.random.choice(['random1', 'random2', 'random3', 'random4', 'random5'])
menu:
"go to the left":
jump left
"run away":
$ renpy.jump(event)
label left:
"text goes here"
label random1:
"text goes here"
--- you can figure out the rest ---
for a percentage of higher chance to get certain event, I don't know about that.
"*cackle*cackle*! In short, it's all about cleverly using the gaps between jobs to play. If it goes too far, it can turn to laziness. However, people only become mature when they learn to balance work with pleasure. Simply put, if all you care about is work all the time, you're not fully mature." - Gaap (Umineko no Naku Koro ni)
-
- Veteran
- Posts: 298
- Joined: Thu Jan 06, 2011 9:28 am
- Projects: Unnamed Slenderman VN, Secret 10560
- Location: USA
- Contact:
Re: Randomizing Outcomes?
I think that's sort of what I want, though I still need the code for increasing the chances of getting one over the other. Thank you for that code though c: That does help a little.
Edit: Will this work for what I need? http://www.renpy.org/wiki/renpy/doc/coo ... han_others
Edit: Will this work for what I need? http://www.renpy.org/wiki/renpy/doc/coo ... han_others
- Aleema
- Lemma-Class Veteran
- Posts: 2677
- Joined: Fri May 23, 2008 2:11 pm
- Organization: happyB
- Tumblr: happybackwards
- Contact:
Re: Randomizing Outcomes?
I just use:
Code: Select all
num = renpy.random.randint(0,100)
if num <= 25:
#25% chance option#
else:
#75% chance option#
- Alera
- Miko-Class Veteran
- Posts: 651
- Joined: Sun Mar 21, 2010 3:20 am
- Completed: Tortichki // Zayay // Hero's Spirit
- Deviantart: psyalera
- itch: psyalera
- Location: UK
- Contact:
Re: Randomizing Outcomes?
Oh, what Aleema said sounds really easy! ^^
Another thought I had is just to make more labels that lead to the same place? 'random1'-goes to 1 point of the sotry you want and lets say 'random2 and 3' go to a second! You have 1:2 chances now. XD
But yeah- better try Aleema's way. ;'D
Another thought I had is just to make more labels that lead to the same place? 'random1'-goes to 1 point of the sotry you want and lets say 'random2 and 3' go to a second! You have 1:2 chances now. XD
But yeah- better try Aleema's way. ;'D
-
- Regular
- Posts: 74
- Joined: Wed Jul 14, 2010 4:56 am
- Completed: cafe minigame
- Projects: Beach Restaurant
- Location: Indonesia
- Contact:
Re: Randomizing Outcomes?
waw, this was great!Aleema wrote:I just use:
Code: Select all
num = renpy.random.randint(0,100) if num <= 25: #25% chance option# else: #75% chance option#
thanks for the knowledge, Aleema.
"*cackle*cackle*! In short, it's all about cleverly using the gaps between jobs to play. If it goes too far, it can turn to laziness. However, people only become mature when they learn to balance work with pleasure. Simply put, if all you care about is work all the time, you're not fully mature." - Gaap (Umineko no Naku Koro ni)
-
- Veteran
- Posts: 298
- Joined: Thu Jan 06, 2011 9:28 am
- Projects: Unnamed Slenderman VN, Secret 10560
- Location: USA
- Contact:
Re: Randomizing Outcomes?
Thanks a bunch for that, Aleema! I still don't know how to do this
Also, is anyone else having troubles with apostrophes? I wasn't having any problems yesterday, then I checked my script today and they messed up! D: I tried the backslash trick but it didn't work.Never mind on that, it seems to have fixed itself. I guess it was because I accidentally left out a " at the end of a line. D'oh!
but would that be done with an if code? Like this:I was also wanting to make it so that if the player talked to the friend before this event, they would have a higher chance of getting the route with the friend.
Code: Select all
if friend_meeting:
num = renpy.random.randint(0,100)
if num <= 25:
#25% chance option#
else:
#75% chance option#
else:
num = renpy.random.randint(0,100)
if num <= 50:
#50% chance option#
else:
#50% chance option#
-
- Veteran
- Posts: 298
- Joined: Thu Jan 06, 2011 9:28 am
- Projects: Unnamed Slenderman VN, Secret 10560
- Location: USA
- Contact:
Re: Randomizing Outcomes?
Sorry for double posting, but I just tried the code you suggested for the random outcomes and it gave me an error.
Here's the code I used
and here's the error
Here's the code I used
Code: Select all
menu:
"Run.":
"I ran."
num = renpy.random.randint(0,100) ##This is line 110
if num <= 25:
jump run1
else:
jump run2
Code: Select all
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.
On line 110 of G:\Lauren\Beauty and Beast/game/script.rpy: expected statement.
num = renpy.random.randint(0,100)
^
Ren'Py Version: Ren'Py 6.12.0e
- Aleema
- Lemma-Class Veteran
- Posts: 2677
- Joined: Fri May 23, 2008 2:11 pm
- Organization: happyB
- Tumblr: happybackwards
- Contact:
Re: Randomizing Outcomes?
You need to put a $ sign in front of it when you're not in python.
Code: Select all
$ num = renpy.random.randint(0,100)
-
- Veteran
- Posts: 298
- Joined: Thu Jan 06, 2011 9:28 am
- Projects: Unnamed Slenderman VN, Secret 10560
- Location: USA
- Contact:
Re: Randomizing Outcomes?
D'oh! Thanks for the fast response Aleema. C:
Who is online
Users browsing this forum: No registered users