Creating an active event randomiser

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
nature1996
Regular
Posts: 62
Joined: Wed Jun 21, 2017 10:35 am
Contact:

Creating an active event randomiser

#1 Post by nature1996 » Sun Jan 07, 2018 3:01 am

Hi,

I'm trying to create an active system that will select an event from a list, particularly for a hunting system, but I will also use it for other aspect in my game.

What I mean by active is that I would like for the possible event, and their probability, to vary based on some variable like who is following you, what is your distance from the closing city, how much food you have on you, etc.

The kind of event also varies greatly, going from being attacked by wolf to finding a branch. It will also vary based on the season. For now, I have a basic code, but I'm not satisfied for two reason: first, I can't choose if a give option is possible or not, and two, I can't dynamically change the probability.

Btw, a day is composed of ten action, and cs is referring to the currant season, namely winter for now. Also, sorry for the strange define, but my script is over 500 lines long, and I only have one character yet, so I don't want to lose the event.

Code: Select all

label hunting:
    define winterhunt=[None,"wwolfs","wwolf",None,"wwolf","wdear","wfox","whorse",None,"wbranch","wrock","wrock","wdear"]
    $act=10
    if cs==0:
        while act>0:
            $evt=renpy.random.choice(winterhunt)
            
            if evt!=None:
                call expression evt
            else:
                "you spent a bit of time looking around, but found nothing."
                
                
            $act=act-1
            nvl clear
            
        return
I would like to be able to say, for example, that an attack by a wolf pack, therefor defined by the label "wwolfs", is only likely by 1%, but goes to up to 5% if you have a lot of food.

I could I guess redefine the list each time, but that doesn't solve the problem of probability associated with each possibility.

I tried to search on the forum for previous answer, but I couldn't seem to be able to do so.
Je parle aussi français

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

Re: Creating an active event randomiser

#2 Post by Ocelot » Sun Jan 07, 2018 5:45 am

You might be interested in weighted choice: viewtopic.php?p=326131
< < insert Rick Cook quote here > >

User avatar
nature1996
Regular
Posts: 62
Joined: Wed Jun 21, 2017 10:35 am
Contact:

Re: Creating an active event randomiser

#3 Post by nature1996 » Sun Jan 07, 2018 6:39 am

That would seem almost ideal. I mostly now just need to figure out how to add thing to a list.

Thanks a lot
Je parle aussi français

Post Reply

Who is online

Users browsing this forum: No registered users