Open source: RPG extensions for Ren'Py

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.
Message
Author
herenvardo
Veteran
Posts: 359
Joined: Sat Feb 25, 2006 11:09 am
Location: Sant Cugat del Vallès (Barcelona, Spain)
Contact:

Open source: RPG extensions for Ren'Py

#1 Post by herenvardo »

As I promised some days ago, here is the code for the combat and inventory systems I'm using on my NaNoRenO project Fall of Jayshn.
It's not a final version; and there are some aspects to care before trying to use it:
  • There is a known (in fact, intended) bug in the shop() function: when in a shop, using an item will not remove it from the inventory. This is done to allow bumping stats of a character and testing it against different oponents. You can copy the code to remove the used item from the inventory from the fight function.
  • The fight function implements combats against a group of monsters of the same race. To allow combats against mixed groups, you should modify the first part of the function's code.
  • I've tried to explain all the code through comments. If you need a clarification of something, have any doubt, or something to comment, let me know and I'll do my best to answer you.
Edit: Attached file has been removed. Access it at this URI: http://download.open-gdt.org/rpgext.rpy
Last edited by herenvardo on Tue Mar 21, 2006 7:55 pm, edited 1 time in total.
I have failed to meet my deadlines so many times I'm not announcing my projects anymore. Whatever I'm working on, it'll be released when it is ready :P

herenvardo
Veteran
Posts: 359
Joined: Sat Feb 25, 2006 11:09 am
Location: Sant Cugat del Vallès (Barcelona, Spain)
Contact:

#2 Post by herenvardo »

Wow! 6 downloads! That's a success record for me! :P
But no comments at all? Oh, please, I'd love some feedback. I'm eager to know what do people think about this code...
Well, I guess that after one single day, I cannot complain, at least it has been downloaded... anyhow, I'm expecting that feedback. 8)
I have failed to meet my deadlines so many times I'm not announcing my projects anymore. Whatever I'm working on, it'll be released when it is ready :P

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#3 Post by PyTom »

One python comment is that it's preferable to write code like:

Code: Select all

        shop2 = [(item_life_potion, 50), (item_haste_potion, 100), (item_end_potion, 75)]
        shop2[len(shop2):] = [(item_Glife_potion, 250), (item_Ghaste_potion, 500), (item_Gend_potion, 375)]
        shop2[len(shop2):] = [(item_PHP_potion, 1000), (item_PSp_potion, 1000), (item_PPw_potion, 1000)]
        shop2[len(shop2):] = [(item_PEn_potion, 1000), (item_PSk_potion, 1000), (item_PAl_potion, 7200)]
as:

Code: Select all

        shop2 = [
    (item_life_potion, 50), 
    (item_haste_potion, 100), 
    (item_end_potion, 75),
    (item_Glife_potion, 250), 
    (item_Ghaste_potion, 500), 
    (item_Gend_potion, 375),
    (item_PHP_potion, 1000), 
    (item_PSp_potion, 1000), 
    (item_PPw_potion, 1000),
    (item_PEn_potion, 1000), 
    (item_PSk_potion, 1000), 
    (item_PAl_potion, 7200),
    ]
I wouldn't be overly surprised by a lack of interest in your code. In general, people aren't interested in things until they see a completed game made with them. There were no Ren'Py games made until I released the first, but after that several games were made in short order. Without even a runnable demo, it's hard to see what the code even does.

Another reason is that I'd suspect your market is a relatively small one. Bishoujo games are a niche inside the anime niche, and so the market is fairly small to begin with. Developing such games is probably a niche within a niche. Of the maybe 10k people who play original english-language games, there might be a hundred people interested in developing them (judging from how many downloads a new version of Ren'Py gets), and the number serious is probably in the dozens, if that.

Of those dozens of developers, most seem less interested in RPGs, and more interested in novel games. So your potential audience isn't too big. I count 3 people interested in making B-RPGs: Grey, Lemma, and yourself. The latter two are programmers who have made their own engines for the game.

That Ren'Py isn't designed for RPGs doesn't help. (I've resisted adding support for a world map, for example... there are other tools more suitable for RPGs.)

My advice would be to make a game with your toolkit. That will increase awareness, and perhaps increase the number of people who want to make a game like yours, especially by attracting new developers.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

herenvardo
Veteran
Posts: 359
Joined: Sat Feb 25, 2006 11:09 am
Location: Sant Cugat del Vallès (Barcelona, Spain)
Contact:

#4 Post by herenvardo »

About your comments on coding, I'll apply them.
PyTom wrote:I wouldn't be overly surprised by a lack of interest in your code. In general, people aren't interested in things until they see a completed game made with them. [...] Without even a runnable demo, it's hard to see what the code even does.
The 'runnable demo' will be out in a few days :P
PyTom wrote:Of those dozens of developers, most seem less interested in RPGs, and more interested in novel games. So your potential audience isn't too big. I count 3 people interested in making B-RPGs: Grey, Lemma, and yourself. The latter two are programmers who have made their own engines for the game.
I've published this code because I was asked to publish it. As a curious fact, I'll comment that the one who asked it is not among the 3 people you've counted :P
PyTom wrote:That Ren'Py isn't designed for RPGs doesn't help. (I've resisted adding support for a world map, for example... there are other tools more suitable for RPGs.)
This may depend on what do you understand as RPGs. When I speak of RPGs, I refer mainly to the table&dice ones, and maybe a few computer games. But most of the computer games that are called RPGs do not fit in what I understand by RPG, simply because they don't fit the meaning of role-playing. In my opinion, rpgs are a subset of interactive narrations, with the only difference that, in addition to allow you to mark the outcome of the narration, you play a role. Combat & inventory are not a property of RPGs, these are features that simply most RPGs use, but other games may use them. In addition, a inventory system may be used in a non-rpg visual novel to keep track of plot items and even events.
As a last comment, about the support for a world map... well, I already have it in mind, for my next project... I love challenges 8) :P Anyhow, I'm pretty sure it won't be too much a challenge.

And at last, but not less important, thanks for the feedback. It's been really usefull.
I have failed to meet my deadlines so many times I'm not announcing my projects anymore. Whatever I'm working on, it'll be released when it is ready :P

herenvardo
Veteran
Posts: 359
Joined: Sat Feb 25, 2006 11:09 am
Location: Sant Cugat del Vallès (Barcelona, Spain)
Contact:

#5 Post by herenvardo »

Well... just added a mini-game as a demo for the code: it's some kind of Arena, where you're put to fight against a random ammount of random monsters. In addition, you are given 10000 money at start, and are allowed to shop items before the fray, so you may test both the combat and the shoping system. Please, do not abuse the 'cheat' I commented with the first version. It's there for test & debug purposes only.
I have failed to meet my deadlines so many times I'm not announcing my projects anymore. Whatever I'm working on, it'll be released when it is ready :P

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#6 Post by PyTom »

How well tested is this code? I just tried it, and got repeated errors.

For example, on line 589, party is initialize to the empty list. But then, on line 609, the script assigns to party[0], which doesn't exist, causing an error.

Fixing that causes an error that char_money is not defined. (On line 432.)

Fixing that by defining char_money lets me buy an item, but when I buy the item, it shows me an object representation rather then the item name. "Bought <renpy.store.Item object at 0xb752c36c>".

Trying to equip an item when I have none leads me to an empty menu.

Etcetera...
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

herenvardo
Veteran
Posts: 359
Joined: Sat Feb 25, 2006 11:09 am
Location: Sant Cugat del Vallès (Barcelona, Spain)
Contact:

#7 Post by herenvardo »

:? Sorry, I didn't test it. The functions were taken from my project, which has been tested a lot of times, and I wrote the 'Arena' code during a break at work... since it was very simple I thought I could write it 'on the fly', but it seems that I was wrong. :oops: Sorry for the inconveniences it may have caused.
Well, I've been debugging it during all this afternoon, and most problems are gone.
To avoid posting here each new version of the script, I've put it on my web server. You can take it from http://download.open-gdt.org/rpgext.rpy
Currently, there's only one thing I've been unable to solve: when a fallen oponent is spoiled, the treasure didn't match what was expected. Looking deeper, it seems that all Profile objects share the same inv field, which is suposed to hold each creature's and character's inventory. Does somebody how to avoid that?
I have failed to meet my deadlines so many times I'm not announcing my projects anymore. Whatever I'm working on, it'll be released when it is ready :P

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#8 Post by PyTom »

herenvardo wrote:Looking deeper, it seems that all Profile objects share the same inv field, which is suposed to hold each creature's and character's inventory. Does somebody how to avoid that?
The base reason for this is that you don't set the inv field in the __init__ method of Profile, but instead you set it in Profile itself. This means that it's shared by all Profile objects.

In general, code of the form:

Code: Select all

        class Profile(object):
            name ="" #The name that will identify the creature/profile in menus
            # The following two fields are intended to be boolean (0/1) for creatures.
            # They are non-applicable when the object refers to a modifier, this may be represented by a -1 value.
            AI = 0 #Indicates, for the case of creatures, whether the creature is controlled by player or AI (computer)
            evil = 0 #Indicates in which side a creature fights: 0 for player and 1 for opponents
            HP = 50 #Total HitPoints
            cHP = HP #Current HitPoints
            speed = 5 #Action points got in each combat round.
            act = 0 #Action points
            pow = 5 #Attack/Spell power
            end = 5 #Attack&Spell endurance/resistance
            cend = end #Modified endurance due to absorbed damage
            skl = 50 #Skill: chance (over %) to do a succesful action (attack, spell, steal, etc)
            inv = [] #Inventory: List of tuples, using the format:
            # (item, q) #Where item is a reference to an Item object and q is the ammount of those items in the inventory
            money = 0 #Ammount of money the creature carries. Gold Pieces (gp) are used in the original version, but it's currency-independent
            def __init__(self, n, AI, ev, h, s, p, e, k, m=0):
                # This initializator is simple and self-explanatory:
                self.name = n
                self.AI = AI
                self.evil = ev
                self.HP = h
                self.cHP = h #All creatures start unwounded
                self.speed = s
                self.pow = p
                self.end = e
                self.cend = e #Endurance is only modified during combat.
                self.skl = k
                self.money = m
Is wrong. If you're creating fields on objects, there's no need to set them outside of the __init__ method. Doing so is at best wasteful, and at worst can serve to mask bugs.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

herenvardo
Veteran
Posts: 359
Joined: Sat Feb 25, 2006 11:09 am
Location: Sant Cugat del Vallès (Barcelona, Spain)
Contact:

#9 Post by herenvardo »

So then, if I take out all the variables from the class and put them only in the __init__ will it work? Since I'm too used to C/C++, I instinctively declare everything as soon as possible :oops:
I have failed to meet my deadlines so many times I'm not announcing my projects anymore. Whatever I'm working on, it'll be released when it is ready :P

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#10 Post by PyTom »

Yes. There's no need to declare things in python. Python creates a new field on an object when you assign to it. (The downside of this, of course, is there's no checking as in C/Java/etc.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

herenvardo
Veteran
Posts: 359
Joined: Sat Feb 25, 2006 11:09 am
Location: Sant Cugat del Vallès (Barcelona, Spain)
Contact:

#11 Post by herenvardo »

Great! It's working! Well... when you die in the arena, you spoil your oponents and go on as if nothing had happened, but that's not grave... the full game already has code to produce the 'bad' ending when the main character dies. Currently, this 'Arena' allows to see how inventory, shops and combat work, which is what it was intended for. Thanks for all this help.
I have failed to meet my deadlines so many times I'm not announcing my projects anymore. Whatever I'm working on, it'll be released when it is ready :P

User avatar
mikey
Lemma-Class Veteran
Posts: 3249
Joined: Sat Jan 10, 2004 6:03 am
itch: atpprojects
Contact:

#12 Post by mikey »

I have one thought on this one (RPG and VN mixes):

A visual novel isn't really a medium that is gameplay-oriented, but story-oriented. You don't play it as much as you actually read it, simply influencing its outcome.

The classic PC/console RPG like FF7 or NeverwinterX however, is something that is oriented on playing. You have a set of rules with logic and random elements. This applies also to paper/dice based RPGs. The narrative is present, but the emphasis is on playing and game rules.

Anyway, my point is, Ren'Py was designed for the creation of visual novels. Its main point should be text effects, some screen effects, blurs, zooms and flexible music.

So, maybe, if your project is something like Brave Soul (which is at least 80% RPG), or if simply a set of gameplay rules will be a major part of your project, it's better to not use Ren'Py, but a dedicated RPG engine (I'm sure there is a lot of those, certainly more than VN engines), because all those engines will IMO certainly be able to depict text in a box and some overlayed characters whenever you'll need the story to advance in a VN-way.

Many RPGs really look like VNs if you look at their "reading" segments. So what I'm trying to say is why reinvent the wheel with a Ren'Py add-on when a ren'ai RPG can maybe be created easier with its core being an RPG engine.

This is of course just an opinion. I don't have the deeper technical knowledge to judge what is easier, but I suspect that the RPG section in a VN engine will never feel as crisp as one done in a RPG engine. So it's a matter of finding out how much percent of the gameplay will in fact be spent in RPG mode and how much in VN mode and select the engine accordingly.

RedSlash
Veteran
Posts: 351
Joined: Sun Oct 31, 2004 12:48 am
Location: Canada
Contact:

#13 Post by RedSlash »

RPG+VN, or atleast what Herenvardo seems to be doing would seem to me more of like a MUD (Multi-user dungeon). Atleast I remember it back in the days, you had to dial in with your modem and through a telnet terminal, you'd be presented with a story and various choices on what you can do. MUD's usually allow you to go to shops and fight monsters as well. This kind of concept seems like it could work with ren'py. This is ofcourse if I had not misunderstood his meaning of "RPG".

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#14 Post by PyTom »

mikey wrote:Anyway, my point is, Ren'Py was designed for the creation of visual novels. Its main point should be text effects, some screen effects, blurs, zooms and flexible music.
I think mikey has a good point with this. The reason I made, and continue to make, Ren'Py is that I wanted to be able to play visual novels. If I wanted to play RPGs, I could go out to my local Best Buy and buy some.

VNs are different. Back in 2004, when I started Ren'Py for the first time, there weren't any OEL VNs, save for ToL1, Black Pencil, and I think Kasuka. Even the commercial market was limited to a few titles, some good (Kana, Crescendo, etc.) and many not. To encourage people to make new games, I wrote Ren'Py, an open-source VN engine that lets people who are not primarily programmers make VNs.

Two years later, we have a thriving community, and we have a score of games, and then some. I'd like to think Ren'Py had something to do with that. I think it's neat to get in near the ground floor of an art form that was almost unknown to the western world. Maybe not as a father, but perhaps as something of a big brother*.

Anyway, the reason I made Ren'Py was to make the VNs I like to play, and not other forms of games. Now, if you want to make an RPG or other type of game using Ren'Py, knock yourself out. But mikey's right, you're using a tool that isn't designed for that, and the results will probably be below what you could get using a tool better suited for the task.

Ren'Py is designed for visual novels, and related storytelling games, like dating sims. I've specifically not added features, like a world, map, that would move it beyond that. While I will support people who want to make other kinds of games, I'm doing so mostly to be polite, as I'm not overly interested in those games. I probably won't compromise Ren'Py's core to support non-VN, non-DS mechanics.

Just letting people know where I stand on non-VN games using Ren'Py.

* Call me oniichan!
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

herenvardo
Veteran
Posts: 359
Joined: Sat Feb 25, 2006 11:09 am
Location: Sant Cugat del Vallès (Barcelona, Spain)
Contact:

#15 Post by herenvardo »

mikey wrote:So what I'm trying to say is why reinvent the wheel with a Ren'Py add-on when a ren'ai RPG can maybe be created easier with its core being an RPG engine.
I'll answer to that. I've mainly 3 reasons:
  1. Most of RPG engines and RPG making software are commercial, and I love free software. (I've found some free tools, like rpgtoolkit, but it happened after my project was started).
  2. Most of RPG engines either force you into a rule-system, or aren't unable to let you produce an elaborated system. This is mainly because any rule-system requires programming, and those tools usually try to let you make your game without programming.
  3. I love breaking rules. I like doing weird things. To put an example, I know that the most sane option to build a house is to use bricks, but I find it would be fun to build one using apples instead. If you didn't notice already from my avatar or my signature, I'll tell you that sanity is not among my qualities... in fact, I'm pretty sure that if I went to a psychiatrist he'd discover new mental diseases on me :lol:
PyTom wrote:Ren'Py is designed for visual novels, and related storytelling games, like dating sims. I've specifically not added features, like a world, map, that would move it beyond that. While I will support people who want to make other kinds of games, I'm doing so mostly to be polite, as I'm not overly interested in those games. I probably won't compromise Ren'Py's core to support non-VN, non-DS mechanics.
I want you to know that as long as Ren'Py supports a general-purpose language (in this case, Python), anything would be doable with it.
In addition, I want to comment that I considered making the game in plain C++. I derived to Ren'Py mainly because it solved the graphics and is platform independent; also it's able to manage music. In C++, I'd have to have different code for graphics and sound for each platform, which would be even more insane than what I'm used to, and almost undoable within the NaNoRenO deathline.
mikey wrote:A visual novel isn't really a medium that is gameplay-oriented, but story-oriented. You don't play it as much as you actually read it, simply influencing its outcome.

The classic PC/console RPG like FF7 or NeverwinterX however, is something that is oriented on playing. You have a set of rules with logic and random elements. This applies also to paper/dice based RPGs. The narrative is present, but the emphasis is on playing and game rules.
Games as FF or Neverwinter fall out of the meaning of 'role-playing'. They are called RPGs only because they use mechanics taken from paper games. About paper/dice based RPGs, in most cases game rules care only about all aspects of the game that are not 'role-playing'. The term RPG has been deformed during years by lots of games that are called so, and nowadays is light-years far from the meaning of 'role-playing'. I'll put an example of what a role-playing is supposed to be. Let somebody be a Game Master (or Dungeon Master, or Game Director, or whatever you want to call him), and some players. With the supervision of the GM (to make it fit to what it's possible in the game's world), each player writes down a description of his/her character... between one paragraph and half a sheet would be ok. Then the GM starts telling the story and, as it goes on, players take any choice corresponding to the characters they play. When there is an action that might be failed, the GM will assign a chance of success, and the player will use a die to determine the result of the action.
That is role-playing, and you may notice that there are no rule-systems at all.
You said that VN are story-oriented, while RPGs are game-oriented. This may be true applied to recent RPGs; but the true essence of role-playing games is to melt toghether story-telling and game-play, up to the point that the game and the story are the same thing. And this is the kind of game I'd most like. Anyhow, I need some rule-system because a computer cannot arbitrarily assign success chances to actions; but I've tried to keep it simple.
I have failed to meet my deadlines so many times I'm not announcing my projects anymore. Whatever I'm working on, it'll be released when it is ready :P

Post Reply

Who is online

Users browsing this forum: Google [Bot], henne