Success/failure Chance: randomness + variables = skillcheck

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
Colt
Newbie
Posts: 3
Joined: Thu Aug 01, 2013 1:16 pm
Projects: Shining Days
Location: Brazil
Contact:

Success/failure Chance: randomness + variables = skillcheck

#1 Post by Colt »

Hello, I'm trying to do something like Disco Elysium, where the choices show the % of success, something like skills + random chance. At the moment, I'm using this code:

Code: Select all

init:
    $ strength = 40
    $ fatigue = 10
    $ pct = 100 - strength + fatigue 
label start:
    scene black
    menu:
        "Attack(success chance: \%[pct].":
            $ d100 = renpy.random.randint(1,100) + strength - fatigue 
            if d100 >= 60:
                $ strength += 5
                jump a
            if d100 <= 60:
                $ strength += 3
                jump b

label a:
    "Win"
    $ strength += 10
    $ pct = 100 - strength + fatigue 
    menu:
        "Attack(success chance: \%[pct].":
            $ d100 = renpy.random.randint(1,100) + strength - fatigue 
            if d100 >= 60:
                $ strength += 5
                jump c
            if d100 <= 60:
                $ strength += 5
                jump d
    return

label b:
    "Loss"
    $ strength -= 10
    $ pct = 100 - strength + fatigue 
    menu:
        "Attack(success chance: \%[pct].":
            $ d100 = renpy.random.randint(1,100) + strength - fatigue 
            if d100 >= 60:
                $ strength += 5
                jump c
            if d100 <= 60:
                $ strength += 3
                jump d
I wonder if there's an easier way of achieving this?
Thank you

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]