After spend something reading and trying to learn Ren´py, I was unsure of how to start something without trying aiming to high. Then I did remeber once, while trying to learn Visual Basic that I tried to make a simple program to create a role play character (in AD&D style), I wonder, why no try that here here too? and here is the result:
- In the current form is very AD&D style, why? well I was trying something simple and something I know well (also I figure that work with all variables that often creating a roleplay character often result might be a good train). But it could be easily changed or adapted.
- It is menu and text only.
- It´s not perfect nor very good and maybe it is a mess in the code, but if might help someone I would be happy.
Edit:Made a small edition to the overall code following trooper6 advice, mostly I just made better blocks and remove a few jumps.
Thanks to trooper6 and Onishion which helped me to solve a problem in the code.
Here is how it works.
- - Roll for atributes
- Attributes over 12 have a modifier of +2 (Not on the attribute itself, right now is a bonus that could be applied somewhere else), below 12 it does have a modifier of -2
- Race modify some atributes (+1 Str / -1 Wis for dwarves, per exemple)
- Choose your class (limited by attributes, except thief), each class have a special skill.
- Then you choose your skills (limited by class)
- Finally you buy some stuff (if you gold is lower that anything avaliable for sale, this part will end)
- Pick your name
- Just review all.
Script code.
Code: Select all
define e = Character('Eileen', color="#c8ffc8")
# The game starts here.
screen CHAR1:
frame:
xalign 0.01
yalign 0.05
vbox:
label "Attributes"
text "Strength = [STR] ([mstr])"
text "Constitution = [CON] ([mcon])"
text "Agility = [AGI] ([magi])"
text "Wisdom = [WIS] ([mwis]) "
label start:
show screen CHAR1
$ AGI = 0
$ STR = 0
$ WIS = 0
$ CON = 0
$ test= 10
$ mstr= 0
$ mcon =0
$ magi =0
$ mwis =0
$ FirstChar = True
while test >= 10:
menu:
"Roll Dices (3D6 for each attribute)":
$FirstChar = False
$STR = renpy.random.randint (6,18)
if STR >=12:
$mstr = 2
if STR <=12:
$mstr = -2
$AGI = renpy.random.randint (6,18)
if AGI >=12:
$magi = 2
if AGI <=12:
$magi =-2
$CON = renpy.random.randint (6,18)
if CON >=12:
$mcon = 2
if CON <=12:
$mcon =-2
$WIS = renpy.random.randint (6,18)
if WIS >=12:
$mwis = 2
if WIS <=12:
$mwis =-2
"Go with this numbers" if FirstChar==False:
jump race #this one remain as need to be a non-empty block.
label race:
$ race = ""
menu:
"Human":
$ race ="Human"
"Elf":
$ STR -=1
$ AGI +=1
$ race = "Elf"
"Dwarf":
$ race= "Dwarf"
$ STR +=1
$ WIS -=1
label Class:
e "choose your class"
$ class1 = "Novice"
menu:
"Fighter" if STR >=12 and AGI >=12:
$ class1 = "Fighter"
$ STR +=1
$ AGI +=1
$ extra = "More Weapon Skills"
"Barbarian" if STR >=14 and CON >=16:
$ class1 = "Barbarian"
$ STR +=2
$ CON +=2
$ WIS -=2
$ extra = "Berserk Rage"
"Thief" :
$ class1 = "Thief"
$ AGI+=2
$ extra = "Thief Skills"
"Cleric" if WIS >=12:
$ class1 = "Cleric"
$ WIS+=2
$ extra = "Clerical Spells"
e "current class [class1] and your current extra skill is [extra]"
label Skills:
e "choose your Skills"
$ sk = 4
$ sknormal = 4
$ skill =[]
$ sw = False
$ spe = False
$ ax = False
$ bw = False
$ mc = False
$ st = False
$ dg = False
if class1 == "Fighter":
$ sk +=1
$ sknormal +=1
if class1 == "Cleric":
$ sk -=2
$ sknormal -=2
if class1 == "Thief":
$ sk -=1
$ sknormal -=1
while skill >= sknormal:
e "current skill points left=[sk] and current skills [skill]"
menu:
"Sword" if sw == False and class1 in ["Fighter" , "Barbarian"]:
$sk -=1
$skill.append("Sword")
$ sw = True
"Spear" if spe == False and class1 in ["Fighter" , "Barbarian"]:
$sk -=1
$skill.append("Spear")
$ spe = True
"Bow" if bw == False and class1 in ["Fighter" , "Barbarian" , "Thief"]:
$sk -=1
$skill.append("Bow")
$ bw = True
"Axe" if ax == False and class1 in ["Fighter" , "Barbarian"]:
$sk -=1
$skill.append("Axe")
$ ax = True
"Mace" if mc == False and class1 in ["Fighter" , "Barbarian" , "Cleric" , "Thief"]:
$sk -=1
$skill.append("Mace")
$ mc = True
"Staff" if st == False :
$sk -=1
$skill.append("Staff")
$ st = True
"Dagger" if dg == False :
$sk -=1
$skill.append("Dagger")
$ dg = True
if sk == 0:
e "current skill points left=[sk] and current skills [skill]"
jump Inventory1 #Kept this jump since its the call to end this part.
label Inventory1:
e "buy your gear"
$money = 250
$ Inventory = [ ]
while money >=0:
menu:
"Long Sword - 60 Gold" if money >=59:
$money -=60
$Inventory.append ("Long Sword")
e "added a Long Sword [Inventory] current gold [money]"
"Spear - 45 Gold " if money >=44:
$money -=45
$Inventory.append ("Spear")
e "added Spear [Inventory] current gold [money]"
"Battle Axe - 50 Gold"if money >=49:
$money -=50
$Inventory.append ("Battle Axe")
"added a Battle Axe [Inventory] current gold [money]"
"Long Bow - 100 Gold" if money >=99:
$money -=100
$Inventory.append ("Long Bow")
"added a Long Bow [Inventory] current gold [money]"
"Infantary Mace - 45 Gold" if money >=44:
$Inventory.append ("Infantary Mace")
$money -=45
"added a Infantary Mace [Inventory] current gold [money]"
"Chain Mail - 200 Gold " if class1 in ["Fighter" , "Cleric"] and money >=199:
$Inventory.append ("Chain Mail")
$money -=200
"added a Chain Mail [Inventory] current gold [money]"
"Leather Armor - 100 Gold " if money >=99:
$Inventory.append ("Leather")
$money -=100
"added a Leather Armor [Inventory] current gold [money]"
"Finish":
jump Name
label Name:
e "current items [Inventory] gold left [money]"
e "lets make the final test for now"
e "names"
$ player_name = renpy.input ("What is your name?")
$ player_name = player_name.strip()
if player_name =="":
$ player_name ="Ren"
label Final:
e "So, your name is %(player_name)s!"
show screen overlay
e "feel free to check out everything in the overlay"
e "no hurry"
return
Screen code (just add at the end)
Code: Select all
screen overlay:
frame:
xalign 1.0 yalign 0.0
hbox:
textbutton "Character" action Show ("Char")
textbutton "Inventory" action Show ("Inventory1")
screen Char:
modal True
frame:
xalign 0.5 yalign 0.5
vbox:
label "Name"
vbox:
text "[player_name]"
label "Race"
vbox:
text "[race]"
label "Class"
vbox:
text "[class1]"
label "Special Ability"
vbox:
text "[extra]"
label "Attributes:"
frame:
xalign 0.0
yalign 0.0
vbox:
text "Strenght = [STR] ([mstr])" size 16
text "Constitution = [CON] ([mcon])" size 16
text "Agility = [AGI] ([magi])" size 16
text "Wisdom = [WIS] ([mwis]) " size 16
label "Skills"
vbox:
text "[skill]"
textbutton "Close" action Hide("Char")
screen Inventory1:
modal True
frame:
xalign 0.5 yalign 0.5
vbox:
label "Character"
frame:
xalign 0.0
yalign 0.0
vbox:
text "[Inventory]" size 16
label "Gold"
vbox:
text "[money]"
textbutton "Close" action Hide("Inventory1")