Challenge System For Ren'Py
Posted: Thu Apr 11, 2019 10:52 am
This may be a really obvious type of thing for some people, but I have been lurking here for so long that I feel the need to actually contribute so this is something I came up with. This is based on the challenge system that StoryNexus uses, as I switched from that program to this one.
It's super basic, but I find the formula used to work in many cases. If the value of your stat and the difficulty of the challenge are equal, you will have a difscale percent chance of succeeding. If that rate doesn't suit you, just change the difscale.
Here is a test/example of the functions in use:
Anyway, maybe someone will find good use out of this. Cheers!
Code: Select all
#Challenge variables
srate = 0
difscale = 0.60
success = 0
r = 0
sdisplay = 0
#Challenge functions
def chaldiff(stat, dif):
global difscale
global srate
global sdisplay
srate = (stat/dif) * difscale
sdisplay = srate * 100
def challenge(stat, dif):
import random
global difscale
global srate
global success
global r
r = random.random()
srate = (stat/dif) * difscale
if srate >= r:
success = 1
else:
success = 0
Here is a test/example of the functions in use:
Code: Select all
#Jump to this to check challenge difficulty and stuff.
init python:
strength = 10
label challengetest:
scene black
$ chaldiff(strength, 10)
"Make a strength check and see if you succeed.
{color=#00ff00}You have a [sdisplay]%% chance to succeed.{/color}"
menu:
"Make check.":
$ challenge(strength, 10)
if success == 1:
scene black
"Success."
"Info: srate = [srate], r = [r]."
return
else:
scene black
"Fail."
"Info: srate = [srate], r = [r]."
return
"No.":
return