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