じ☆ve冰风 发表于 3 天前

Create your crafting system with no plugins

A crafting system is always appreciated. But it often needs plugins, which mean compatibility issues and less personalization. But what if you could create your crafting system from scratch, only with events?

Requirements: This is optional, but to create a"recipes" system you will need the plugin HIME_HiddenChoicesConditions. All the script calls used in the part 3) can be used without any plugin. It is also useful to have a good comprehension of events.

First, why create a new crafting system?
Well, it will allow you to personalize it as you want, and also to change recipes in-game (for example, you could use a variable as amount needed for a specific ingredient, add specializations linked to experience…)
To create your crafting system, you will need to create ingredients. Just create new items and define their use on "never". Next, let's start this tutorial and create a common event. If you have many crafting categories, you will create a common event for each one.
1)- Choose an item to craft, then craft it
In this common event, you will show choices to make the player choose what he wants to craft. In each branch, you will show a message that shows a short description of the item and the necessary ingredients. You will also put in variables the amount of ingredients needed to craft the item. Don't make too much variables! If your recipes have three ingredients at maximum, create only three variables!
Spoiler: message example

You can use this variables with text codes to show to the player how many ingredients he owns.
Next, you can add a Yes/No choice to avoid crafting an unused item. In the "Yes" branch, you can add conditionnal branches to make sure the player really has the ingredients. If he has, remove them and add the crafted item to the player's inventory. If he has not, you can add an "else" branch and play a buzzer sound or show a message to inform the player that he has not the necessary stuff.
Spoiler: event (only one potion)

Now, you can create an event that will call this common event or use it with a menu plugin!
2)- Create recipes
With Hime's Hidden Choices, we can add a recipes system to our game. Just create a "Recipe" item and use this script call before your recipe choice:
                Code:       
hide_choice(CHOICE_NUMBER,!$gameParty.hasItem($dataItems))

You won't be able to see the craft option until you have the necessary recipe.
3)- Item Synthesis : Choose two ingredients to make a new item
This first craft system is very cool, but what if I prefer the player to try different combinations?
To create this synthesis system, you can be more efficient by using variables.
BE CAREFUL: YOUR ITEMS MUST KEEP AT SPECIFIC ORDER.
Example of my database:
Spoiler: items and weapons



Create your choices. In our example, it will be blacksmithing: the player will choose the base weapon, next the metal ore that they will use.
Spoiler: common event (only one metal)



Ok... But why so much variables? To find more easily the weapon crafted! Look at the end of my common event...
Spoiler: craft item

The ID of the crafted weapon is the sum of the IDs of the ingredients! (Now you understand why I told you to keep your items in specific order).
Use this script calls to remove or gain items :
                Code:       
$gameParty.gainItem($dataWeapons[$gameVariables.value(VARIABLE_ID)], AMOUNT);// You can replace $dataWeapons with $dataItems or $dataArmors

                Code:       
$gameParty.loseItem($dataItems[$gameVariables.value(VARIABLE_ID)], AMOUNT);//Same. If you want to remove armors or weapons, write:$gameParty.loseItem($dataWeapons[$gameVariables.value(VARIABLE_ID)], AMOUNT, true/false);//Set true if you want to include equipped weapons/armors. You can also use $dataArmors.


The Self Switch is used to create a new branch if the player have cancelled to avoid crafting an item if the player cancelled.
Here the metal is the only losable ingredient, but you can add more conditionnal branches or just copy/paste your second part.

Thanks for looking at my tutorial! How will you personalize your game's crafting system?
Tags: crafting, events, common events, script calls, choices, create, no plugins


本贴来自国际rpgmaker官方论坛作者:Midona018处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/create-your-crafting-system-with-no-plugins.178139/
页: [1]
查看完整版本: Create your crafting system with no plugins