The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on August 07, 2011, 11:17:41 PM

Title: Item Instances Base
Post by: modern algebra on August 07, 2011, 11:17:41 PM
Item Instances Base
Version: 1.0
Author: modern algebra
Date: August 7, 2011

Version History



Description


This is a scripting tool that changes the way items are handled in the game to allow for item instances. This means that items specially marked will be uniquely saved every time you collect them.

This script was designed since scripts which require items to be saved as instances, even if they were conceptually simple (like durability), were impractical to make since they required a heavy overhaul of the entire item system. The only other scripts I know about that have tried tend to be very bulky and usually incompatible with every other item-based script out there. This script was therefore designed to (a) change the way marked items were saved so as to be more dynamic and saved as instances; (b) be compatible or easily made compatible with most other scripts that deal with items; and (c) be easy to create addons which make use of the framework to create functional changes to items, weapons, and armors.

This script makes little functional difference aside from changing how marked items are stacked in the menu and allows you to change the specific stats of items if you add them through the Change Item/Weapon/Armor event commands by using a comment. However, it provides a necessary structure for other scripts, such as a weapon durability or charges script, where the stats necessarily must vary between items of the same type.

While I made this script to provide a base for a series of scripts I will make, any scripter is welcome to use this as a base for their own scripts.

Features


Screenshots

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg204.imageshack.us%2Fimg204%2F1797%2Finstanceitems.png&hash=6c2b5051c113db2441752c149b4d40fff8fd1e56)
Though the same item, they are saved individually. The stats are different in this
case because I am using the Random Stat Variance for Items (http://rmrk.net/index.php/topic,43442.0.html) script.

Instructions

This script must be placed above Main and BELOW every regular custom script that might deal with items, even if they do so only incidentally.

However, it must be ABOVE any scripts that directly utilize this framework (see the "Derivative Scripts" list).

See the Header for more detailed instructions on utilization.

Guidelines

If you are a scripter and want to use this as a base for a script, you should familiarize yourself with it fully. However, here are a few little (non-exhaustive) guidelines/tips:

Script


The script is too long. Get it at Pastebin (http://pastebin.com/w8mdkSZW)

Derivative Scripts

The following is a list of scripts (existing and planned) that use this script as a base:

Credit



Support


Please post in this topic if you encounter any compatibility issues at all - I would love to know about them and fix them for you.

Known Compatibility Issues

This script must be placed above Main and below EVERY custom script that deals with items, weapons, or armors, even if they do so in a merely incidental way.

Though I tried to make this script highly compatible, I am extremely fallible and it will still be incompatible with some scripts. If you find such an incompatibility, alert me to it and I will quickly correct it.

Demo


I will eventually make a demo and will update it every time I make a new script that uses it. For now, since it makes no significant functional difference, there is no demo.

Author's Notes


This is a scripting utility I designed mostly for myself as I plan to make a series of scripts that require items to be saved as instances, such as item durability, poisoning and socketing weapons, unidentified artifacts, etc...

I experimented a little with this script, and I invite comments from other scripters on how I could improve it, particularly with an eye to anticipated incompatibilities.
Title: Re: Item Instances Base
Post by: TDS on August 07, 2011, 11:59:47 PM
I almost posted a script idea for this about weapons being able to have attribute ranges that were set at the creation of the weapon, but it seems you already made it.

Aside from that, this is a pretty good idea and should help in the creation of a lot of scripts.

I'll use it with a personal project to report any bugs or suggestions.
Title: Re: Item Instances Base
Post by: cozziekuns on August 08, 2011, 01:21:53 AM
Wow, this is amazing MA! I can think of so many ways to implement this (although you stole most of my ideas already >:() Needless to say, this is a great script and good luck with you scripting series endeavours!
Title: Re: Item Instances Base
Post by: modern algebra on August 08, 2011, 01:21:56 PM
Thanks! I'm glad you guys like it. I look forward to hearing any feedback you might have TDS.

Also, @cozzie, the only ones I've started working on so far are Durability and Unidentified Artifacts - you are welcome to work on any others. I will be rewriting my evidence script as a Dialog though, which will allow it to be called and an item picked without interrupting the scene processing. It will be helpful for the ones where you apply something to an item, so you might want to wait to do those, but I would love to see other scripters work with this script and tell me how I could improve it and make it more accessible.
Title: Re: Item Instances Base
Post by: cozziekuns on August 15, 2011, 11:05:19 PM
Hmm.. This is probably a dumb question because I haven't played around with this as much as I should have, but how can I convert an RPG::Item to a Game_Item? Or can I get the RPG::Item from the Game_Item?



Title: Re: Item Instances Base
Post by: modern algebra on August 15, 2011, 11:42:08 PM
You can create it with the code:

Code: [Select]
$data_items.create_instance (item)

where item is an RPG::Item.

From a Game_Item instance, you can retrieve the RPG::Item it was derived from with the code:

Code: [Select]
item.base_item
where item is a Game_Item. Alternatively, you could retrieve it with:

Code: [Select]
$data_items[item.item_id]
where item is either a Game_Item or an RPG::Item (though if it were an RPG::Item, it would be pointless since you already have it).
Title: Re: Item Instances Base
Post by: jargonchipmunk on January 21, 2013, 05:32:10 AM
I know this is necro, but have there been any updates to this script?

I put this script into an empty project by itself and get an expecting } error at line 566

 nil_ary = self.instance_methods.select { |method| !method.include?  ("=") && self.instance_methods.include? ("#{method}=") }


nevermind.  I was looking at the wrong date.  I thought this was a year newer lol
even more necro than I thought.  must be an xp script an an ace noob trying to use it.

pay no attention to the man behind the /facepalm
Title: Re: Item Instances Base
Post by: fatapi_shadramon on July 30, 2015, 10:00:54 AM
 :sdog: :sdog: :sdog: :sdog: :sdog: :sdog: :sdog: :sdog: :sdog: :sdog: :sdog: :sdog: :sdog:

so i decided to revive this topic in hopes of getting people to talk about this again. it seems that this script was so powerful that whatever i want with my item/weapon/armor now is possible. stuff like assigning a single slot for my 100+ variation of potions seems very smart as it would have taken alot of slot for my database thus making the game load a tinny bit slower. modern A dude, your really the best scripter ever. even in RRR, or rpgmakervx.net your the bomb. and now that i have returned in the rpg maker vx scene i might as well be active now.

EDIT
I forgot to add this yesterday and i was gonna keep this alive anyways so i just want to know how do i recreate the same instance so it stacks with its kind. see i tried to power-up the KGC Compose Item script so it uses Item Instance in a way that when the player creates a potion and his/her skill is only at novice, his potion will only heal 20 HP. but at Apprentice level, with the same ingredients, it will heal 100 HP. it works how i want it but every time i make the same thing, it doesnt stack with its kind. this will cause ALOT of the same item in the players inventory to stay and just clutter up the inventory menu which isnt a good sign of good programming. [*cough*]EA[*cough*]... so how do i stack the same instance?

EDIT EDIT:
well crap. as a programmer there is nothing more annoying than hitting a bump. a bump called a bug. yeah~~~~~. so i was happily using this and Omega Equipment Customization Script OECS. seems like they hate each other. could be because OECS clones equipment as well. bummer though. with my minimalistic skills and lack of perception on how OECS is made i cant fix it but im doing this edit so as to say "Let it be known" thing.
Title: Re: Item Instances Base
Post by: fatapi_shadramon on August 12, 2015, 03:35:29 PM
Just gonna bump this post so it remains relevant. this scripts need more love.