Charas-Project

Game Creation => Requests => Tutorials => Topic started by: WarxePB on June 30, 2005, 05:19:52 PM

Title: Alchemy/Smithing/Item Mixing For Dummies
Post by: WarxePB on June 30, 2005, 05:19:52 PM
.:Alchemy/Smithing/Item Mixing :.

By: Warxe P.B.


If you've ever wanted to do any of the above systems  in your RM2K/3 project, but don't know how, you've come to the right place. All 3 of them are exactly the same, and use the same system.


Difficulty: Advanced-Medium (A decent knowledge of RM2K/3 scripting is recommended.)

What You'll Need:
-Some items/weapons/whatever
-Charsets of the abovementioned items/weapons/whatevers
-A blank map


Basically, we're going to make a very basic CMS using a map.


So, first off, open up Notepad. Write down all the items you want to be able to use, and assign a number to each. For this example, here's my list:

1 - Potion
2 - Ether
3 - Leather Armor
4 - Iron Sword
5 - Magnesium


Now, open up your blank map. Create events that have the graphics of your items/weapons/whatevers. Set the trigger to Action Key, set the layer to Same as Hero, and leave the code blank. We're done with this, so close the event.

Now, create a new event beside one of the events that you just created. Set the trigger to Action Key, and set the layer to Below Hero. I'll say that the item is a Potion.
Start the code with a message that asks how much of this item you want. Use a Variable Operation with a variable called "ItemQuantity" to set how many Potions you have. Then, use an Input Number command with 2 digits that stores it in a variable called "FusionQuantity". Then, use a Conditional Branch to check both variables' values; if var FusionQuantity is greater than ItemQuantity, create an Else Handler that says "You don't have that many Potions" and do nothing.

Here's what your code should look like:

<>Message: How many Potions do you want to use?
<>Variable Operations: Var[3302: ItemQuantity] Set, Potion Possessed
<>Input Number: 2 Digit, [3303: FusionQuantity]
<>Branch if Var [3303: FusionQuantity] is Var[3302] Greater
|<>Message: You don't have that many Potions.
|<>
<>Else Handler
|<>
<>End
<>

The Else Handler will only activate if the amount of Potions you want to use is less or equal to the amount of Potions you currently have, which is what we want.

In the Else Handler, create another Branch that checks if var FusionQuantity is 0. If it is, create a message saying "You didn't select any Potions to use" or something.
In the Else handler of that branch, set another variable called FusionType to the number that corresponds to the item you selected (In my example, Potion is number 1, so I would set FusionType to 1). Then, create a switch called Select1-Done, and turn it ON.

Code:

<>Message: How many Potions do you want to use?
<>Variable Operations: Var[3302: ItemQuantity] Set, Potion Possessed
<>Input Number: 2 Digit, [3303: FusionQuantity]
<>Branch if Var [3303: FusionQuantity] is Var[3302] Greater
|<>Message: You don't have that many Potions.
|<>
<>Else Handler
|<>Branch if Var[3303: FusionQuantity] is 0
||<>Message: You didn't select any Potions to use.
||<>
|<>Else Handler
||<>Variable Operation: Var[3304: FusionType] Set, 1
||<>Switch Operation: Switch[1298: Select1-Done] ON
||<>
|<>End
|<>
<>End
<>

Now, copy that page, and paste it in the same event. On the second page, set the Preconditions to Switch Select1-Done ON.

Create two more variables, FusionQuantity2 and FusionType2, and another switch, Select2-Done. Then replace FusionQuantity with FusionQuantity2, FusionType with FusionType2, and SelectDone-1 with SelectDone-2.

<>Message: How many Potions do you want to use?
<>Variable Operations: Var[3302: ItemQuantity] Set, Potion Possessed
<>Input Number: 2 Digit, [3305: FusionQuantity2]
<>Branch if Var [3305: FusionQuantity2] is Var[3302] Greater
|<>Message: You don't have that many Potions.
|<>
<>Else Handler
|<>Branch if Var[3305: FusionQuantity2] is 0
||<>Message: You didn't select any Potions to use.
||<>
|<>Else Handler
||<>Variable Operation: Var[3306: FusionType2] Set, 1
||<>Switch Operation: Switch[1299: Select2-Done] ON
||<>
|<>End
|<>
<>End
<>

Copy the event, and modify the code for different items (change the messages, and change the FusionType variable to reflect the new item).


Now, comes the boring part. Create a new event. Set the preconditions to switch Select1-Done ON and swith Select2-Done ON, set the Trigger to Auto-Start, and leave the graphic blank.


Create a Conditional Branch that checks what FusionType equals. Inside the Branch, create another Branch that checks what FusionType2 equals. Then, remove the amount of items used, and add (a) new item(s). Then set all used variables to 0, and turn both switches OFF.

<>Branch if Var[3304: FusionType] is 1 (Potion)
|<>Branch if Var[3306: FusionType2] is 2 (Ether)
||<>Change Items: Potion [3304] Remove
||<>Change Items: Ether [3306] Remove
||<>Change Items: Super Potion 1 Add
||<>Message: Fused Potion and Ether to get Super Potion!
||<>Variable Operation: Var[3302-3306] Set, 0
||<>Switch Operation: Switch[1298-1299] OFF
||<>
|<>Else Handler
||<>
|<>End
|<>
<>Else Handler
|<>
<>End
<>

Now, here's the repetitive part: You're going to have to make a set of branches like the above set for EVERY POSSIBLE OUTCOME. So, if you have 100 fusable items, may God have mercy on your screwed soul :p


That's the gist of an item fusion system, anyways. There's always room for expansion, but if you're not good with RM2K/3 coding, this should do just fine.


Note: All of this code is untested; use at your own risk.
Title:
Post by: Dashman on June 30, 2005, 07:31:28 PM
It looks like a good tutorial
Title:
Post by: darkrune on July 02, 2005, 01:26:41 AM
Nice Warxe :)
Title:
Post by: BlackIceAdept on July 03, 2005, 04:29:17 PM
...thanks...warxe... >:  :|  _sweat_
Title:
Post by: WarxePB on July 03, 2005, 04:42:26 PM
Oh yes, I forgot to add that even if you don't know how to create an item fusion system, you're not a dummy. I just needed a good title. So don't take any offense.
Title:
Post by: Drace on July 03, 2005, 08:43:52 PM
Drace: So this wasn't for the crash-test-dummies?
Warxe: No....
Drace: *turns to some dummies* Sorry guys, parties over.
Crash-test-dummies: *crashes into a wall*