Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Crafting, a simple yet handy system

cairn

Member

"Back in black, I hit the sack
I've been too long, I'm glad to be back
Yes I'm let loose from the noose
That's kept me hangin' about"


Hello everybody. On the past few days I was completely taken over by school and other matters, but I found some time to think about a crafting system, and I actually built it (yay for useless philosophy and sociology classes). The system uses mainly conditional branches, a few labels, 2 variables, ccoa's UMS (although this could be taken out of it, the script makes changes so much easier to perform) and some common events.

NOTE1: This system was designed to only require 1 material of each kind, although it could be easily changed to require different amount of materials for different recipes. If asked I'll make an alternative version of the system and a tutorial on how to do it.

Before I begin explaining how it works, I'll say in advance that this is not a system you'd want to try right at the beginning of your eventer life, as it may not seem logical to you, but once you get the way some of RMXP's functions work, it will all become clear


The Structure of the Main Event



The way in which I built it is quite simple actually, but the numerous common events and branches may confuse some. I think most will be able to understand the choice lines, so I'll skip those. Sadly enough I had to use of a strategy I was not aiming for, but that's explained on the demo.

On the very beginning of the main common event, you must set BOTH variables used to 0, otherwise the system is easily breakable. For those that didn't get it very well, here's the code of how it should look on your editor:

Code:
[color=#FF0000]Control Variable:[000X: Amount_of_Recipes] += 1[/color]

[color=#FF0000]Control Variable:[000Y: Amount_of_Mats] += 1[/color]

Secondly, you can prompt the player the choice for what kind of item he/she wants to craft. On this demo, I made only Weapons and Armors as choices, as it gets VERY repetitive from one item kind to the other. For those who need more practical visualization of what I'm talking about:

Code:
Show Choices : Item_Kind1,...Item_KindW

:  When Item_Kind1

   [color=#BF0000]Prompt the Item_Kind1 recipe choices[/color]

:  When Item_KindW

   [color=#BF0000]Prompt the Item_KindW recipe choices[/color]

:  Branch End

You can have as many item kinds as you want, just be sure to keep yourself organized, as 1 slight error can literally make the whole process very exploitable.

NOTE2: Everything below here is what I meant by Prompt the Item_KindW recipe choices.

Now, the actual branching and brain-scratching begin. You must analyze how many Recipes the player has on his/her inventory:

Code:
[color=#0000FF]Conditional Branch: [Recipe_Name] in inventory[/color]

[color=#FF0000]   Control Variable:[000x: Amount_of_Recipes] += 1[/color]

[color=#0000FF]: Branch End[/color]

Repeat this for every recipe your player can have.

Now that you have happily settled how many recipes your player can have, it's time to organize their decision of what recipe they want to use. It should look something like this:

Code:
[color=#0000FF]Conditional Branch: Variable[000x: Amount_of_Recipes] == N[/color]

   Show Choices : Recipe1_Name...RecipeN_Name

      :  When Recipe1_Name

            [color=#0000FF]Call Common Event: Recipe1_Name[/color]

      :  When RecipeY_Name

            [color=#0000FF]Call Common Event: RecipeN_Name[/color]

      :  Branch End

 

:  [color=#0000FF]Branch End[/color]

N is the number of recipes you have so, the more recipes the player has in possession, the more possibilities him/her has. When only 1 recipe is in possession, there will be only one choice to be made, when 3 recipes, 3 choices, and so on.

The above structures are the basis of your system. If you want more item kinds, repeat these structures (normaly on the order they appear here) on other branches when you give the player the option of what item kind he/she wants to use.

RAWR!!!!!!!!!!!!!!!!!!!!! SECTION 1 IS DONE!!! W000000000000000000000000000000000000000000000000000000000000000000T!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Oh wait, please don't, you are kidding me. THERE'S MORE!?!?!?!?!?!?!?!? NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!!!!!!!!!

Now that you had your moment of insanity, MOVING ON.



The Structure of the Secondary Events



This is where the actual item handling takes place. Here you will handle with some more branches and item management.
In order to extend the actual amount of craftable items, my recipes are small "books" and "compendiums", each one containing 4 craftable items. On this part I'll work with "books" on my item names, simply because "compendiums" are too long and boring to write all the time.

First of all, create 1 SEPARATE common event for EACH possible book. It makes editing and debugging INCREDIBLY easier. Remember the Call Common Event: RecipeN_Name from the last session? This is where they are coming in.
Before you go on a conditional branch creating spree, we have to give our beloved player the possibility of decision! This is done with a Show Choice command of course, and should look like so:

Code:
Show Choices : Item1,.Item2,Item3,Item4

:  When Item_Kind1

   [color=#BF0000]Prompt Item1 commands and respective item handling[/color]

:  When Item_Kind2

   [color=#BF0000]Prompt Item2 commands and respective item handling[/color]

:  When Item_Kind3

   [color=#BF0000]Prompt Item3 commands and respective item handling[/color]

:  When Item_Kind4

   [color=#BF0000]Prompt Item4 commands and respective item handling[/color]

:  Branch End

This shouldn't be too hard to understand, after all the choices we have allowed our friends to make.

Prompt Item1 commands and respective item handling is just a fancy name for what you are about to do on the next parts of this guide.

After your player has made his/her decision, you start what you wanted to do so long ago. Yes folks, that's right........ CONDITIONAL BRANCHES!!!!!!!!!!! *And the crowd goes wild!!!!!!!!*

You must set Variable:[000Y: Amount_of_Mats] to 0, just a fail-proof mechanism. After doing so, you must check if the players has all materials the materials in inventory. For the visualization needy people:

Code:
[color=#0000FF]Conditional Branch: [Material_Name] in inventory[/color]

[color=#FF0000]   Control Variable:[000x: Amount_of_Mats] += 1[/color]

[color=#0000FF]: Branch End[/color]

Repeat this process for as many materials as the item requires. We will call this material total T from now on.

After all the T branches have been established, it's time to check if the player has ALL the materials in inventory. How you do that? Easy. Yes, you guess right. BRANCHES! I'll explain what comes inside this branch along; makes it less time consuming. You can give your player the chance to give up or not, up to you. But assuming you won't give him/her that choice (yes, we are dictators!), you need to subtract 1 of EACH and every material required for the craft

Again, visualize it, and thy shall make it real!:

Code:
[color=#0000FF]Conditional Branch: Variable [000X: Amount_of_Mats] >= T[/color]

[color=#FF0000]   Change Items: [Material 1] - 1[/color]

[color=#FF0000]   Change Items: [Material 2] - 1[/color]

...

...

[color=#FF0000]   Change Items: [Material T] - 1[/color]

[color=#FF0000]   Change Weapons: [Weapon 1] + 1[/color]

[color=#0000FF]: Else

   Text: Insuficient Materials[/color]

[color=#0000FF]: Branch End[/color]

Repeat the above for every single craftable item, obviously replacing the required materials (if you want) and the result weapon/armor/item/mambojambo.

Well, this concludes the explanation on how the base of the system works. The Demo has a few more features, like labels and comments, but nothing big.


The Demo


This is a small something I set up while developing the system.
Oh yeah, before i forget, I give you folks, THA LINK!


Credits and Thanks


cairn (me) for developing the system.
ccoa for the UMS. It gives some style and an easier time when debugging and changing stuff inside the DB.
Enterbrain for developing RMXP.
Everyone of the HBGames community and the admins.
AC/DC for providing me hours of some good music to listen to.


Terms and Conditions


Feel free to use it anywhere you'd like, but please do give the appropriate credit. Also, if you WILL make some use of it, contact me via PM, just so I can know about it and give some more objective support.


Comments


I'd like to receive any critic, AT ALL. Be it either positive or negative, but please try to be constructive about it. I'll probably set up a workshop for evented systems when their ideas come to me, but for now this is my only thread on this section. For general support and doubts, post here and I'll try to the best of my abilities to clarify them.
Thanks for the time. Enjoy!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top