ITEM CRAFTING

RPG Maker VX Ace

Craft items/weapons/armor from other items

Overview
This script adds an item crafting system to the game.
Crafting recipes are set using note tags.

For example, if you wanted to be able to distil 5 potions to make a Hi-Potion, you would add this tag to the Hi-Potion item's Note:
<craft item:1:5>

And to allow a hi potion to be diluted to make 4 potions from it using the breakdown system, you would add this tag:
<craft break item:1:4>

That makes it possible to create hi-potions through the crafting menu if you have 5 potions in your inventory.

And break hi-potions into potions through the breakdown menu:

Features
  • Craft item/weapon/armour from other items/weapons/armour
  • Restrict individual recipes to require a tool
  • Hide individual recipes until the player acquires a specific item
  • Restrict the crafting system to a specific actor or class
  • Control access to the crafting system with a game switch
  • Launch the crafting system from an event instead of the menu
  • Breakdown items into components (new in 0.9.2)
  • Crafting shops - gold price for recipes (new in 0.9.4)
  • Crafting shops - use a game switch to control recipe visibility (new in 0.9.4)


Usage
To install the script, open the script editor in RPG Maker VX Ace.
Scroll to the bottom, and select a blank row between Materials and Main Process.
copy/paste the script code into the right hand editing pane.

For any item you want to be craftable, you need to add at least one craft tag to its note.
Each craft tag specified one ingredient of the recipe to create the item.
The tags are as follows:
TagMeaning
<craft item:id>Consume 1 item with the specified id
<craft weapon:id>Consume 1 weapon with the specified id
<craft armor:id>Consume 1 armor with the specified id
<craft item:id:number>Consume a number of items
<craft weapon:id:number>Consume a number of weapons
<craft armor:id:number>Consume a number of armors


With these tags, you have the basic crafting system.
If the player has the ingredients you specified, they can craft the item.

But maybe you want the player to find recipe books or need specific tools to craft items.
This is also possible with two more note tags:
TagMeaning
<craft tool:id>The tool must be in inventory to craft, but is not consumed
<craft recipe:id>The recipe item must be in inventory, or this item will be hidden from the crafting menu


These are pretty similar in function, which one to use depends if you want the player to be able to see the recipe or not.

If you want to use item breakdown as well as crafting, the tags are similar:
TagMeaning
<craft break item:id>Give 1 item with the specified id
<craft break weapon:id>Give 1 weapon with the specified id
<craft break armor:id>Give 1 armor with the specified id
<craft break item:id:number>Give a number of items
<craft break weapon:id:number>Give a number of weapons
<craft break armor:id:number>Give a number of armors
<craft break tool:id>The tool must be in inventory to breakdown this item
<craft break recipe:id>The recipe item must be in inventory, or this item will be hidden from the breakdown menu


Finally, do you want the crafting menu to be available all the time?
If not, there are restrictions you can set by editing the configuration variables at the top of the script.
You should use the IDs from your game database.
VariableEffectDefault
MENU_COMMANDAddto the game menutrue
MENU_COMMAND_TEXTName of the menu commandCrafting
MENU_COMMAND_ENABLEAlways enable the menu commandtrue
MENU_COMMAND_SWITCHEnable the menu, if a switch is on0 (disabled)
MENU_COMMAND_ACTOREnable the menu if a specific actor in the party0 (disabled)
TEXT_INGREDIENTS_TITLEHeading for the ingredients windowIngredients:
TEXT_INGREDIENTS_TOOLSHeading for tools in the ingredients windowTools:
TEXT_INGREDIENTS_PRICEHeading for price in the ingredients windowTools:


Configuration for the breakdown system follows the same pattern, in the "module CRAFT_BREAK" section.
It is therefore possible to enable only one system, or have different conditions to enable each one.

Crafting shops

Perhaps you want to have crafting performed at a shop?
Perhaps you want different shops to be able to craft different things?

Both of these are now possible.
First, we need to add note tags to the items:
TagMeaning
<craft gold:amount>Price to craft this item
<craft break gold:amount>Price to break down this item
<craft switch:id>Show this recipe only if the game switch is ON
<craft break switch:id>Show this recipe only if the game switch is ON


If you want the same items to be craftable at every shop, you can ignore the switch.
However the switch lets you make a blacksmith, alchemist, etc, each of which can craft different items.
Switches can also be used to enable new items as the player progresses through the game. If you specify multiple switches in a recipe, all of them must be on.
(note that <craft switch> and <craft recipe> perform the same function, so you could use switches exclusively if you don't like using key items)

To launch the crafting from a shop event, you will need to use a script call:
SceneManager.call(Scene_Crafting)
Fiber.yield


And the equivalent for calling breakdown from an event:
SceneManager.call(Scene_Craft_Breakdown)
Fiber.yield


Here is an example of a blacksmith's shop event:


I have given the halberd these notes:
<craft weapon:1>
<craft weapon:13>
<craft gold:100>
<craft switch:10>

And in the game, it looks like this:

Posts

Pages: first prev 1234 last
yes. what is the call I should put there? I tried just putting SceneManager.call(compare_crafting_level) at the end of the script (I wasn't expecting success!), and of course I got an error on loading.
Then I can experiment with putting it in different places and see if anything works.

EDIT: Was looking at posts on forums and it seems that you cannot call scripts from other scripts, only functions inside that script. So, I don't know if what I want is going to be possible.
Marrend
Guardian of the Description Thread
21806
Well, I've taken a brief look at the code. The solution that makes the most sense (given what I believe you're looking for), is to attach the process to Scene_Crafting...

class Scene_Crafting < Scene_CraftBase
  #--------------------------------------------------------------------------
  # * Item [OK]
  # remove ingredients, add new item to inventory
  #--------------------------------------------------------------------------
  alias altered_on_item_ok on_item_ok
  def on_item_ok
    altered_on_item_ok
    compare_crafting_level
  end

  def compare_crafting_level
    count = 0
    for id in 1 .. 50
      val = 431 + id
      puts(val)
      if $game_switches[val] == true
        count += 1
      end
    end
  
    craft_level = $game_variables[63]
    level_difference = craft_level - count
    
    case level_difference
    when 0
      if rand <= 0.2
        # 20% chance of level-up
        $game_switches[63] += 1
      end
    when 1
      if rand <= 0.17
        # 17% chance of level-up
        $game_switches[63] += 1
      end
    when 2
      if rand <= 0.15
        # 15% chance of level-up
        $game_switches[63] += 1
      end
    when 3
      if rand <= 0.1
        # 10% chance of level-up
        $game_switches[63] += 1
      end
    end
    # In any other case, the crafting level is either too high, or too low.
    # No way skill can increment, so no need to create additional functionality.
  end
end

...like so. Again, using a separate code-section as to allow the original script to exist untampered.

*Edit: I think there would be an error in the calculation of "level_difference", but, if that's the only error that is caused, I think I would be happy for a little while.
Thanks for the effort.

I copied it into the original script in the place you said (replacing nothing in the original script), and upon launch I get "undefined method 'on_item_ok'"
Hi! I have 2 questions.

1) Is there an easy way to disable item categories in the script?
For example, what if I don't want the Crafting window to show Items or Key Items?
I tried to look for common words that the script uses in an example project like "Key Items" though I tried to look for "keyitem", "key_item" or "key.item" too, but that didn't work out.

2) How can I change the sound effect that plays when you make an item?
By default it seems to be "Decision3".
I tried to comment out the 2 uses of "Sound.play_ok" and add a "RPG::SE.new("Bell2", 50, 100).play" right after, but that didn't seem to work.

Thanks!
author=Nanjo
1) Is there an easy way to disable item categories in the script?

There isn't.
The script re-uses Window_ItemCategory, in create_category_window.
You could replace the Window_ItemCategory with your own window that has fewer options; or change the scene to not have a category window at all and jump directly in to the specific category.
But there's no built-in option for it.

2) How can I change the sound effect that plays when you make an item?
By default it seems to be "Decision3".
I tried to comment out the 2 uses of "Sound.play_ok" and add a "RPG::SE.new("Bell2", 50, 100).play" right after, but that didn't seem to work.

This seems like the right track, you could also try Audio.se_play.
author=coelocanth
author=Nanjo
1) Is there an easy way to disable item categories in the script?
There isn't.
The script re-uses Window_ItemCategory, in create_category_window.
You could replace the Window_ItemCategory with your own window that has fewer options; or change the scene to not have a category window at all and jump directly in to the specific category.
But there's no built-in option for it.
I see. Coincidentally, I found my way after I submitted that post.
I tracked down the file in which the categories are handled myself when I read the "create_category_window" function, and hid the Items and Key Items categories there behind a
if $game_switches[3] != true

Naturally, I made the crafting system set that Switch when it's activated and clear it when it's no longer active, and that does seem to work nicely, though now I kinda want to center the Weapons and Armours categories, since they start on the far end left which is kinda ugly, hehe.
https://i.imgur.com/thXMjrZ.png

Any tips you could give me about that? Right now my plan is to track down the location of "add_command" and see where that takes me.

author=coelocanth
author=Nanjo
2) How can I change the sound effect that plays when you make an item?
By default it seems to be "Decision3".
I tried to comment out the 2 uses of "Sound.play_ok" and add a "RPG::SE.new("Bell2", 50, 100).play" right after, but that didn't seem to work.
This seems like the right track, you could also try Audio.se_play.
Thanks!
I tried the following and it worked nicely:
Audio.se_play('Audio/SE/Bell2', 100, 0)

However, I notice that Decision3 is still playing at the same time.
I imagine that's tied to one of the default RPGMVXA that are being used here in this crafting system?
https://streamable.com/hcojxt

On a separate note, I honestly didn't think you'd still be active seeing how the last reply before mine was from 2021.
Thank you very very much for giving me a hand here, and for making this awesome script!
It looks nice and it's really simple to use!

EDIT: Actually, instead of bothering with centering the Weapons and Armours options, would it be easier to just enter a specific mode and category?

I'm realizing I don't need to reinforce Armours per se.

So basically, is there a script I could call from within an event in a map that would open the "Crafting - Weapons" window directly?

EDIT2: I'm not exactly proud of this because it looks rather hacky, but the result looks much better InGame this way (in my personal opinion of course), so I think I'll keep it.

I basically wrote a script by copy-pasting functions from the default scripts that would allow me to merge the 4 item categories for shops into a single one if the specified Switch (in this case the 3rd) is enabled. That is, the same Switch I made this Item Crafting script of yours toggle On and Off on its own.
https://pastebin.com/ebPu7Ung

I wish I could have just made the interface enter the menu to craft weapons straight up without showing or having to choose a category at all, but I'm happy enough with this result too.
https://streamable.com/zqfffi

Thank you for everything, seriously!
Hello. Is there a way to make the same item be accessed through different switches? For example: I want weapon 1 to be accessed in switches 1 and 2, but not in switch 3.
Pages: first prev 1234 last