Original Source
- Original title: Eventing a Place-able Crafting System
- Original author: hiddenone
- Original date: August 27, 2017
- Source thread: https://forums.rpgmakerweb.com/threads/eventing-a-place-able-crafting-system.83283/
- Source forum path: Game Development Engines > RPG Maker Tutorials > RMMV Tutorials
Summary
's spot. The first command we add is 'select item', with the variable set to 'Ingredient #1 ID' and the item type set to 'regular' (since that's what we set our ingredients to). This lets the player choose what item to put down onto the table. Next are some conditional branches that check what the variable we just set equals and removes the proper item from the player's inventory. We don't want the player to be able to keep putting down infinite items, now do we? Spoiler: The very basic...
Archived First Post
aka: putting items on a table before cooking
It basically lets the player put down ingredients that can be used to try to craft something. While this system works best with small combinations and a limited number of recipes, it's really only limited by how much time and effort you want to invest in it.
Harold is here and ready to become a master chef!
- Let the player choose which ingredients to try to combine
- Leave ingredients on the table until the player either crafts or picks it back up
- Lets ingredients be added in any order
- Let the player use different methods to craft with the same ingredients to receive different results
- Make recipes for you
- Keep track of which recipes the player has discovered
- Make you a finished game
Step 1: Decision Time
Possibly the most important step and definitely the first thing to decide before getting things set up: just what do you want the player to be able to make?
Please no, Harold. Don't do that to us.
You don't need to know every possible recipe, but it's a good to have a general idea of what you'll be able to make. If you're making a cooking system, decide how many different ways you want to cook things, such as using pans, bowls, or ovens, as well.
For this tutorial I've decided that there will be 3 ingredients and 2 methods of cooking that will let Harold make 4 cooked dishes.
Much more manageable, Harold.
For most simple recipes, 3 spots will work well. We'll be using 3 spots for this tutorial, since sushi will require all three of our ingredients.
Harold's so excited that he's already prepped his kitchen!
With the big decisions out of the way, it's time to start setting things up. Let's start with the variables we'll need. Each ingredient spot needs its own variable to keep track of what ingredient was added (labelled for easy reference). We also need a variable that we'll use to store and compare the ingredients to later.
Since there are a few item types to choose from, decide whether or not you want the player to be able to see what ingredients they have. If you want them to be able to see them, choose either 'regular item' or 'key item', and if you don't want the player to be able see them pick 'hidden item A' or 'hidden item B'. There isn't a wrong choice for this, but make sure that all ingredients have the same item type (since we'll be using the select item event command later).
For this tutorial we'll have both the ingredients and cooked foods be 'regular items'.
Step 3: Creating the Ingredient Events
Now it's time to start the actual eventing! We'll start with Ingredient #1's spot. The first command we add is 'select item', with the variable set to 'Ingredient #1 ID' and the item type set to 'regular' (since that's what we set our ingredients to). This lets the player choose what item to put down onto the table.
Next are some conditional branches that check what the variable we just set equals and removes the proper item from the player's inventory. We don't want the player to be able to keep putting down infinite items, now do we?
One event page for each possible ingredient (remember when we talked about keeping things simple? The limit to event pages is one of the reasons to do that), with it's condition set to the corresponding variable. Interacting with the page will give the player back the item, and reset the variable to 0, so that the player can put down another ingredient if they want.
That is totally a box of fish, not clams... The default tiles are limited, okay?
To prevent that, we'll include another conditional branch that checks if the variable is larger than the highest ingredient ID that tells the player they can't add that and resets the variable back to 0. Reseting the variable is super important, since if we don't do that then the recipe will fail later!
With Ingredient #1's event finished, we can copy and paste it to make the other two! We just have to make sure to change every spot where a variable is mentioned to the one that fits that event (so Ingredient #2's variables should all be 'Ingredient #2 ID').
There is a way to remove the correct item with only one conditional branch if you use a script call:
$gameParty.gainItem($dataItems[$gameVariables.value(n)], -1);
Step 4: Creating the Crafting Event
With the ingredient spots finished, the only missing piece is the actual crafting event. The first and most import part of the event is this script call:
var array = [$gameVariables.value(1), $gameVariables.value(2), $gameVariables.value(3)]
array = array.sort(function(a, b) {
return a - b;
});
$gameVariables.setValue(4, array);
var array = [$gameVariables.value(1), $gameVariables.value(2), $gameVariables.value(3)]
array = array.sort(function(a, b) {
return a - b;
});
$gameVariables.setValue(4, array);
Now that we sort of understand the script call, we can put it into the event along with some conditional branches to compare the player's combined ingredients with the recipes we made. We're using another script call, this time checking to see if our variable matches a recipe (the recipe is presented as another array).
$gameVariables.value(4).equals([0,0,1])
Harold, that would lead to a terribly unbalanced system!
We've also added some comments from Harold, so that the player is informed about what they made. At the very end of the event is the failure message, which tells the player that the combination they tried just didn't work. To make sure that that message doesn't accidentally play if the player is successful, we put an 'exit event processing' into each conditional branch, so that the event stops running once it's found a successful match.
Yes you can! Congrats, Harold, you can now become the chef you've always dreamed of being!
With all our events finished, we just need to test everything. Time to try adding all of your items to see if any sneak past, and to make sure that all of your recipes work. Double and triple check that you're using the right variables in the right spots (it's easy to forget to change one conditional event, and that can cause everything to break). Once you've tested things, then you can celebrate your success!
If you'd like to take a look at how all the events work together, go ahead and download the demo project.
And that's it! The more ingredients and recipes you add, the more complicated this system can get, so start simply to get the hang of it. Good luck with your game making!
If you've got any questions, comments, suggestions, or other things you'd like to see, just let me know!
Downloads / Referenced Files
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadReferenced Images / Attachments
Creator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
Topic Summary
Loading summary...