Ok, so I want a semi-RPG effect for my game, but I don't want to actually make an RPG. Basically, at certain points in the story the player will be given choices and some choices have a random element to them. You roll dice and add the applicable attribute. If the sum total meets or exceeds a certain value then the character succeeds at the task, failure and something bad happens.
i.e., the player is faced with a locked door. There's a choice to bash the door in or open the door with lockpicks. If the player selects to bash the door in, the game rolls some dice and adds the strength value. If the player selects to use lockpicks then the game rolls the dice, and adds the dexterity value.
The dice rolled should be 3 six-sided die. The attribute changes depending on the circumstances, but the values rarely ever change.
So far I've written the code like this,
Code: Select all
label lockeddoor:
if hitpoints <=1:
"Fighter collapses from exhaustion."
jump end
menu:
"The door is locked. Fighter has %(hitpoints)d HP left."
"Pick the lock":
"Fighter attempts to pick the lock."
$ d6dex = renpy.random.randint(1, 6)
$ d6dex += 2
if d6dex >= 8:
"Fighter rolled [d6dex]."
"As Fighter manipulates the tumbler, he hears the lock open with a satisfying click."
jump dooropen
else:
"Fighter rolled [d6dex]."
"Fighter failed to pick the lock. Try again?"
jump lockeddoor
"Bash the door in":
"Fighter steps back and gets a running start at the door."
$ d6str = renpy.random.randint(1, 6)
$ d6str += 4
if d6str >= 8:
"Fighter rolled [d6str]."
"POW!! Fighter did [d6str] damage!" with vpunch
jump dooropen
else:
"Fighter rolled [d6str]."
"Fighter attacks the door with all his might! The door is unmoved."
"Fighter was bruised in the attempt, and took 1 damage."
$ hitpoints -= 1
jump lockeddoor
- I can't roll 3 six-sided die. Instead I'm just rolling one die and adding a static attribute value.
- I can't use variable attributes. I don't know how to set an attribute and then call it or manipulate it. I'd like to set strength to equal (for example) 4, but then later if Fighter does something to increase his strength set it higher, or maybe he gets poisoned, which would lower it.
- The code gets really cumbersome. It means that I have to write up all of the code for what happens when the dice are rolled and all of the immediate reactions to those dice being rolled. If possible, I'd like to have a ".rpy" sheet with all of the attribute info and dice rolling functions. Then, should the game need dice to be rolled, I could use a call to have the game roll the dice and add the right attribute value together. From that point I can write the if/else/elif functions into the script.