Advice Req: how to design a crafting system for RPG?

Started by
0 comments, last by mrcheesewheel 16 years, 11 months ago
Not sure if this is the correct forum, but here goes.... I have been working on a Web-based game (written in PHP and MySQL) off and on over the last year, as part of a "teach yourself programming" exercise. See it for yourself at http://www.everthorn.net/RPG However, I've been attempting to impliment a type of crafting system that is not simply a huge subroutine of "if-then" statements. Details follow, but essentially I am trying to wrap my brain around the meta-code and process of designing a crafting system, and not having much luck doing so. Currently, I have a very poorly executed example, where certain recipes are coded so that a particular item can be created if you have at least one of various types of other objects in the player inventory. (Healing Potion =Herb+Water+Flask for example) What I am having issues with is trying to figure out the possibility of making projects require numbers of objects, or types of items (tools) in the inventory and be "generic" enough that I could build a table of recipes. Currently, I just have a field called "Recipe" and a field called "Skill" for each object. When you attempt to use something like the "alchemy skill", it does an SQL query for "skill=Alchemy" and displays a listing of what items you cna make, as well as listing the ingredients needed. However, my checks to verify you can make something are pretty basic, and is not smart enough to use two of the same object (ie: Potion = Herb+Herb+Water) Ideally, I want to build a system where players can construct buildings as well as the usual RPG items (weaponry, potions, etc) using huge amounts of items in a cooperative manner (such as Cottage=1000stones+1500Wood and I currently limit characters to carrying 255 of any one item). Additionally, have something like a "Battle Axe" require parts (Axehead + Handle) and those parts be made from other materials (AxeHandle=20Wood+Knife [or] 10IronWood+Knife [or] 25steel) I'm not asking for specific code, and am more looking to connect with a knowledgable programmer to discuss (via email, etc) how to go about designing such a crafting system. It's obviously been done to death before, but I can't quite break down the process in my head sufficiently to impliment something similar in my own scripts. Thanks in advance! -Maebius
-Maebius http://www.everthorn.net/RPG
Advertisement
In the end you need recipes... you could have item equivalence classes so as a number of items serve the same purpose for a recipe, but in the end you need to make the recipes. You can't let the computer invent what makes what. For things like potions you could have ingredients marked as various types of poison and antidote... and certain poison/antidote mixtures have special properties. in that case you could have poison equivalence classes... and associated strengths. Basically no matter how clever you are... one was or another your going to have to check some sort of recipe book to decide what makes what... With equivalence classes the recipe could contain specific items or classes of item to allow for more flexibility... but you can't really automate it completely. One interesting option might be to store items as their components internally... so one could potentially add further ingredients. That might mean you could add a poison to a beer and leave it and it'd look like beer still, but it'd be poisoned. Anyway, I know this isn't a very focussed response, but I hope it contains something useful.

Dan

This topic is closed to new replies.

Advertisement