Tsukihime 1,487 Posted January 7, 2014 (edited) This script introduces the concept of “instance itemsâ€. In order to understand what an instance item is, you need to first understand what a “template item†is. All of your database items, weapons, and armors are called “template itemsâ€. That is, they serve as templates for in-game items. An instance item is simply an instance of a template. For example, you design weapon ID 1 in your database and call it a “Short Swordâ€. This is a template of a Short Sword; everytime you receive a Short Sword in-game, you receive a unique “instance†of this template. Two Short Swords in your inventory are treated as two individual entities that have nothing to do with each other besides both being based on the Short Sword template. It is important to note that this script simply provides instance item functionality. Additional add-ons are required to provide various features such as equip levels, equip affixes, and so on. Get it at Hime Works! Edited February 18, 2014 by Tsukihime 2 ShidoLionheart and linkinin reacted to this Share this post Link to post Share on other sites
harvard1932 1 Posted January 8, 2014 The script crashes when you create a new weapon, newly added to weapon database file. The instance script doesn't seems to be able to handle newly created items. Also, it basically duplicate one item into two. One is the original, one is the instance item. I think you should add a method to remove the original item and keep the instance item. Thanks!! Share this post Link to post Share on other sites
Demintika 63 Posted January 8, 2014 Sounds like Formal's Individual Equipment. Let's see how compatibility this will get to. Share this post Link to post Share on other sites
ShidoLionheart 5 Posted January 8, 2014 (edited) when i create for example a chest, with one sword inside, and I opened it, the game give me two swords xD But after that, I think this script is better than the script by Formar, because the compatibility with other scripts is better Edited January 8, 2014 by ShidoLionheart Share this post Link to post Share on other sites
harvard1932 1 Posted January 8, 2014 It would be even better if it can cooperate with Formar's script Share this post Link to post Share on other sites
Tsukihime 1,487 Posted January 8, 2014 (edited) I will not provide compatibility with fomar's individual equips, because this script is supposed to provide that functionality. The script crashes when you create a new weapon, newly added to weapon database file. The instance script doesn't seems to be able to handle newly created items. You will have to explain what it means to "create a new weapon". Also, it basically duplicate one item into two. One is the original, one is the instance item. I think you should add a method to remove the original item and keep the instance item. This is what the script does: suppose you receive a hand ax. 1. It increases your hand ax template count by 1 2. It creates a hand ax instance, and increases that count by 1. This is used for counting purposes. If you ask "how many hand axes do I have?" I just need to look up the template count and tell you how many hand ax instances you have. Your inventory will only contain instances. There are likely compatibility issues if you are seeing both the template hand ax as well as the instance hand ax. when i create for example a chest, with one sword inside, and I opened it, the game give me two swords xD But after that, I think this script is better than the script by Formar, because the compatibility with other scripts is better I am unable to duplicate the problem. I have a chest that gives me one hand ax. My inventory is initially empty. When I open the chest and check my inventory, I have one hand ax. Check if this occurs in a new project, and whether it is a compatibility issue. Edited January 8, 2014 by Tsukihime Share this post Link to post Share on other sites
ShidoLionheart 5 Posted January 8, 2014 Understood. The Popup script "popups" two sword, but in the inventory there is only one. So it's a compatibility issue, sorry ^^ Share this post Link to post Share on other sites
Tsukihime 1,487 Posted January 8, 2014 (edited) Understood. The Popup script "popups" two sword, but in the inventory there is only one. So it's a compatibility issue, sorry ^^ The popup script is functionally correctly. It's because I actually add two items to the inventory, except one of them is used internally and is never seen by the player. For example, you have the following items in your inventory Hand Ax lv 1 Hand Ax lv 2 Hand Ax lv 3 How many hand axes do you have? You have 3? Or do you have 1? Or zero? A compatibility patch will be required for the popup script to distinguish between instances and templates. Edited January 8, 2014 by Tsukihime Share this post Link to post Share on other sites
harvard1932 1 Posted January 8, 2014 I don't get why for your instance item script: line 500 and 501: th_instance_items_gain_item(new_item, 1, include_equip) th_instance_items_gain_item(item_template, 1, include_equip) Why keeping a copy of template item when instance item is already created? Since the new instance item already have the attribute of the template item. Wouldn't it be better to just to remove the template item from even showing up? Share this post Link to post Share on other sites
Selchar 15 Posted January 9, 2014 (edited) Thinking about it, it's possible it's a compatibility thing with the following event commands. ::Control Variables::Game Data ::Conditional Branch(Page 2) ::Conditional Branch(Page 4) ::Change Equipment Item/Weapon/Armor + Possibly a few methods within the scripts as well. To make sure they detect the correct items since the instance items are given brand new id's. Another way of doing it would be to use an array or hash to keep track of item counts, and modify the methods within the script... tho that itself might cause different compatibility problems. Thinking about that, I decided to test something. It seems the change equipment event command can cause nilClass crashes depending on how you make a script. The command equipped me with the template, and then it crashed when my equip leveling script referenced an equip's exp(since I set it at template creation instead of pre-loading. I can work around the crash, but it shouldn't have given me a template in the first place. Edit: The method to modify would be this one to fix the event command. class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * Change Equipment (Specify with ID) # slot_id: Equipment slot ID # item_id: Weapons/armor ID #-------------------------------------------------------------------------- def change_equip_by_id(slot_id, item_id) if equip_slots[slot_id] == 0 change_equip(slot_id, $data_weapons[item_id]) else change_equip(slot_id, $data_armors[item_id]) end end end Edited January 9, 2014 by Selchar Share this post Link to post Share on other sites
Tsukihime 1,487 Posted January 9, 2014 (edited) You can assume all equips that you work with are instance items. Anything that goes into the inventory will be converted into an instance item. Anything comes out is guaranteed to be an instance item. This invariant must hold in order for my design to work properly. If you ever get a template item, assume it is a bug (or a compatibility issue). I don't get why for your instance item script: line 500 and 501: th_instance_items_gain_item(new_item, 1, include_equip) th_instance_items_gain_item(item_template, 1, include_equip) Why keeping a copy of template item when instance item is already created? Since the new instance item already have the attribute of the template item. Wouldn't it be better to just to remove the template item from even showing up? Template items should not show up. When you ask for a list of weapons or armors, it will be pulled from the instance weapons list and instance armors list. If you're seeing templates, then it is likely a compatibility issue. Thinking about that, I decided to test something. It seems the change equipment event command can cause nilClass crashes depending on how you make a script. The command equipped me with the template, and then it crashed when my equip leveling script referenced an equip's exp(since I set it at template creation instead of pre-loading. I can work around the crash, but it shouldn't have given me a template in the first place. The method to modify would be this one to fix the event command. Hmm, just noticed the issue. It was working before though, as I explicitly mentioned that in the documentation. Will look into why it's not giving the first instance. EDIT: I deleted the modified change_equip method for some reason. It was passing the checks from trade_item_with_party since that properly converted templates to instances, but it was still a template being equipped to the actor. I have updated the script to address this issue. alias :th_instance_items_change_equip :change_equip def change_equip(slot_id, item) if item && $game_party.has_item?(item) && item.is_template? new_item = $game_party.find_instance_item(item) end th_instance_items_change_equip(slot_id, new_item) end alias :th_instance_items_trade_item_with_party :trade_item_with_party def trade_item_with_party(new_item, old_item) if new_item && $game_party.has_item?(new_item) && new_item.is_template? new_item = $game_party.find_instance_item(new_item) end th_instance_items_trade_item_with_party(new_item, old_item) end At this point, I need to consider whether that trade_item check is actually necessary. Edited January 9, 2014 by Tsukihime Share this post Link to post Share on other sites
Selchar 15 Posted January 9, 2014 (edited) Just discovered why you removed it before, for some reason it breaks the normal equipping. So I guess it's a choice between not having that event command, or not being able to equip anything period... well, I can't figure out a solution, but I'll keep looking. Edit: Spoke too soon, this seems to work perfectly unless I missed something. alias :th_instance_items_change_equip :change_equip def change_equip(slot_id, item) new_item = item if item && $game_party.has_item?(item) && item.is_template? new_item = $game_party.find_instance_item(item) end th_instance_items_change_equip(slot_id, new_item) end Edited January 9, 2014 by Selchar Share this post Link to post Share on other sites
Tsukihime 1,487 Posted January 9, 2014 That works correctly. Hope that should resolve a lot of issues! Share this post Link to post Share on other sites
Tsukihime 1,487 Posted January 11, 2014 Latest version changes the way template counts are stored. Rather than explicitly gaining an item (which could have all sorts of additional logic attached to it), I moved the counting into my own instance item gaining/losing methods. The popup script should not incorrectly report extra items now. Share this post Link to post Share on other sites
harvard1932 1 Posted January 14, 2014 (edited) Is it possible for you to add script cooperation with Yanfly Engine Ace - Ace Equip Engine? It seems that Ace equip engine would break if you reload the game using a save file. And equipment using custom slots would no longer be equippable. But if you don't save the game and load the game, it would be all fine and working. Maybe perhaps instance items script didn't fully write everything into current savefile? EDIT. Actually nvm. I fixed it. Edited January 14, 2014 by harvard1932 Share this post Link to post Share on other sites
Selchar 15 Posted January 14, 2014 I think the save file you're trying to use was made before you added Yanfly's Ace Equip Engine. It works just fine if you start a new game after adding the scripts mentioned and save, then load. Share this post Link to post Share on other sites
harvard1932 1 Posted January 14, 2014 I think the save file you're trying to use was made before you added Yanfly's Ace Equip Engine. It works just fine if you start a new game after adding the scripts mentioned and save, then load. For some reason it wasn't the case. But anyways, it is fixed now. Share this post Link to post Share on other sites
Tsukihime 1,487 Posted January 16, 2014 Script has been updated to support a standard way to modify name, params, price, features. You should always use the "make" methods to apply changes to any of these shared attributes. Share this post Link to post Share on other sites
blacks888 0 Posted April 14, 2014 (edited) When I tried to use the instance item in a conditional branch: in inventory , include equipments it does not recognize it. Any help?? Edited April 14, 2014 by blacks888 Share this post Link to post Share on other sites
Tsukihime 1,487 Posted April 14, 2014 (edited) It works for me. Check whether it works on a new project. Edited April 14, 2014 by Tsukihime Share this post Link to post Share on other sites
blacks888 0 Posted April 15, 2014 Oops. . Sorry , What I used was Conditional Branch: Actor [ Eric] is [bandana] equipped . . .it supposed to change the actor graphic but it doesn't. Share this post Link to post Share on other sites
Tsukihime 1,487 Posted January 15, 2015 A patch for Falcao's Manastones Enchantment has been added http://himeworks.com/2015/01/instance-items-with-falcaos-manastone-enchantment/ Share this post Link to post Share on other sites
Guyver's Bane 38 Posted March 28, 2015 (edited) Once I figured it out, this script is far superior to the FP Inventory System. Great work as always Hime! Edited March 28, 2015 by Guyver's Bane Share this post Link to post Share on other sites
linkinin 2 Posted April 19, 2015 Hello. Great script, great help in my project. But there was a problem when changing gear. If you click "Remove All", the inventory duplicates appear clothes. For example, I put on a suit, then took it off, and they are now in the inventory appeared two. I apologize for my English, I'm from Russia. Share this post Link to post Share on other sites
Tsukihime 1,487 Posted April 19, 2015 Does this occur in a new project? Determine whether it is a script compatibility issue. Share this post Link to post Share on other sites