Item System
So I have been working on an 2D MMORPG, and I want to make an item system similar to World of Warcraft or Guild Wars where you have a base item like a Sword, and you can upgrade or enchant it and change its stats. I have it setup right now so that all the items in the game are already made and preset, and I while I was playing around testing for bugs, I though about doing this, and it didn't seem like it would be a big deal. Now that I've spent some time thinking about how to do it, i'm not sure how. When a player makes a upgrades and item, to the server it would be a completely different item than what was started with, so the server would generate a new one, no big deal. But if I get lets say 10 people to play my game, and they customize 100 items, that is 1000 new items that the server has to keep track of, and you can see how this can be a problem. So is their anyone that has done a system like this, do you save each item as a new file or something else, and how do you work with that many items.
You could store each item similar to how you store a character with "stats" that you save, or an inventory that contains "enhancements".
What's the problem with that?
If you keep the data for the variations in the inventory database with just the base info in the item database.
that's what dynamic arrays and classes are for.
If you keep the data for the variations in the inventory database with just the base info in the item database.
that's what dynamic arrays and classes are for.
I suppose you may also be asking whether the modified item would have a unique Item ID, like how each of your original items has an ID.
So you were asking whether each item should be an entry in a database, with a global ID that the game uses, or whether the item should only be addressable through the character's inventory (as in at any moment of time, the game does not readily know the number of modified items in the universe. The game would have to go through the inventory of each character to count.)
Actually I don't know which is better.
In my game that is non-mmo, I am using the database approach, such that if I need to cycle through all of the items, I don't need to use recursion.
So you were asking whether each item should be an entry in a database, with a global ID that the game uses, or whether the item should only be addressable through the character's inventory (as in at any moment of time, the game does not readily know the number of modified items in the universe. The game would have to go through the inventory of each character to count.)
Actually I don't know which is better.
In my game that is non-mmo, I am using the database approach, such that if I need to cycle through all of the items, I don't need to use recursion.
Do you have your current items as database entries? Can you put only one upgrade per item, or more than one? Do you want the upgrades to be permanent or wear off over time? Do they also have durability, or other things that will be unique per player like can you paint your staff blue and get your guild symbol on your shield, or get your cloak in stripes, plaid, and dragonscale-texture?
I want to help design a "sandpark" MMO. Optional interactive story with quests and deeply characterized NPCs, plus sandbox elements like player-craftable housing and lots of other crafting. If you are starting a design of this type, please PM me. I also love pet-breeding games.
if it's a simple customization system you could just put every version into the database...
I wasn't initially planning on changing items once I had made them, so I have them saved as encrypted files rather than in a data base (I do have a database setup for characters, inventories, banks, etc, so it wouldn't much hassle to put the items in a database if needed). I would like for more than one enhancement on an item (but of course have a limit). Wai has got the idea of what I'm going after, if i should have each item as a unique item or do something different (I do like the idea of setting it to the inventory as the server is already setup to handle each inventory and inventory slot). My main concern is if I save each one the items as a unique item if that will be a strain on the server to sort through all of them. If I save each one I was thinking about having it setup in a multidimensional array like this
items(base_item_number,enhancement1_identifier,enhancement2_identifier,...enhancementX_identifier)
if i use this method, what the identifier will be and how this is going to work, as of now, I have no idea, so if anyone has any input or suggestions that would be great. I'm probably going to take some ideas and put together a small test engine to test out some ideas I have.
items(base_item_number,enhancement1_identifier,enhancement2_identifier,...enhancementX_identifier)
if i use this method, what the identifier will be and how this is going to work, as of now, I have no idea, so if anyone has any input or suggestions that would be great. I'm probably going to take some ideas and put together a small test engine to test out some ideas I have.
If you want to have the possibility of more than one enhancement on an item, it seems to me that the only good way to do it is store every item with a record of any modifications as part of each player's individual inventory data. This also allows the possibility of items which have one or more stats randomized when the item is generated from your permanent item templates. (Not sure why you'd bother to encrypt them though, then the server hast to decrypt them each time it wants to generate a new item?? Anyway, the server doesn't actually need to care about the modifications to the items unless they are currently equipped or being sold (where the buyers need to know what modifications are on what they are buying). Or unless you want to use different inventory icons for modified icons, but that probably isn't necessary.
I want to help design a "sandpark" MMO. Optional interactive story with quests and deeply characterized NPCs, plus sandbox elements like player-craftable housing and lots of other crafting. If you are starting a design of this type, please PM me. I also love pet-breeding games.
I am thinking about this:
An instance of an item:
The BaseID is for the game to know how to represent this item in the world, and how to interpret it and its inventory. (e.g. is it a bag with physical items or is it a weapon with enchantments?)
An item that is only used or not used (such as potion), with no other dynamic data maybe identified by the same ItemID in different Inventories (the same as how you have it now have). Inside an inventory, there could be multiple entries with ItemID [OneShotPotion], they are all potions. When it is used, it is simply removed from the inventory.
The inventory of a character stores the ItemIDs
The inventory of modified items also stores ItemIDs, but those Items are enhancement gems (for example, but they could also be abstract entities).
When a character equips a weapon, the program goes through the inventory of the item to compute the stats of the item. These stats are not saved. The action of putting and taking stuff from the inventory of an item is represented as "(Dis)Enchantment".
Most gems used for enchantment are generic. But your game could also enchant gems. Enchanted gems are gems (which are "Items") with a non-null InvID.
How do you store inventories at the moment? Do you have separate field for each slot or do you store things as a script (text string or XML) and you parse when a character is loaded?
Suppose another base item is [PotionJar]. When the PC first bought the Jar, [PotionJar] goes into his inventory. Now, the PC pours two units of potion (ItemID of 1 unit of HP potion is [1HP]). Since now the Jar is modified, the game creates a new ItemID for this Jar: [ITEM556] with a new InventoryID [INV68]. The inventory contains two units of [1HP].
If a certain particular mix of item is popular, it could gain "legendary status", where the game engine recognizes that mixture and assigns it an existing ItemID that has a set IsTemplate bit. The game engine could randomly pick an item or an inventory, and check how many other identical items there are in the world. If there are duplications, the engine would create a new template and clear the duplications. The engine could keep a partial list of popular compositions and periodically conslidate those. It does not need to be check in run-time because it is only a memory size issue.
Another example:
The ItemID [IsBrittle] has a BaseID pointing to {SpillInventoryWhenDropped}. Suppose [IsBrittle] is enchanted to [ITEM556] (which is the potion jar with 2 hp). When this drops, it spills its the two [1HP] items, which might be represented by spilled liquid. If a character could pick it up, he could put them into another jar.
In my non-mmo code, I store items, and for each item I store its container if it has one. I reconstruct the inventories when the game loads. Since the saved file is not a database, there are no "columns". So to store a generic [1HP] inside a [Jar], I store this:
This stores the information that there exists a Jar at (400,0) holding 2HP. Since 1HP is inside a container, I don't need to store its x and y coordinates in the world. You could do the same concept in a database where when you look for stuff that belongs to [Item556], you query a list of items with where Container=556.
[Edited by - Wai on January 1, 2009 10:06:38 PM]
An instance of an item:
ItemID: unique to this instanceBaseID: this points to the base item templatesInvID: this is NULL if the item has no modificationIsTemplate: this is TRUE if this particular item cannot be modified
The BaseID is for the game to know how to represent this item in the world, and how to interpret it and its inventory. (e.g. is it a bag with physical items or is it a weapon with enchantments?)
An item that is only used or not used (such as potion), with no other dynamic data maybe identified by the same ItemID in different Inventories (the same as how you have it now have). Inside an inventory, there could be multiple entries with ItemID [OneShotPotion], they are all potions. When it is used, it is simply removed from the inventory.
The inventory of a character stores the ItemIDs
The inventory of modified items also stores ItemIDs, but those Items are enhancement gems (for example, but they could also be abstract entities).
When a character equips a weapon, the program goes through the inventory of the item to compute the stats of the item. These stats are not saved. The action of putting and taking stuff from the inventory of an item is represented as "(Dis)Enchantment".
Most gems used for enchantment are generic. But your game could also enchant gems. Enchanted gems are gems (which are "Items") with a non-null InvID.
How do you store inventories at the moment? Do you have separate field for each slot or do you store things as a script (text string or XML) and you parse when a character is loaded?
Suppose another base item is [PotionJar]. When the PC first bought the Jar, [PotionJar] goes into his inventory. Now, the PC pours two units of potion (ItemID of 1 unit of HP potion is [1HP]). Since now the Jar is modified, the game creates a new ItemID for this Jar: [ITEM556] with a new InventoryID [INV68]. The inventory contains two units of [1HP].
If a certain particular mix of item is popular, it could gain "legendary status", where the game engine recognizes that mixture and assigns it an existing ItemID that has a set IsTemplate bit. The game engine could randomly pick an item or an inventory, and check how many other identical items there are in the world. If there are duplications, the engine would create a new template and clear the duplications. The engine could keep a partial list of popular compositions and periodically conslidate those. It does not need to be check in run-time because it is only a memory size issue.
Another example:
The ItemID [IsBrittle] has a BaseID pointing to {SpillInventoryWhenDropped}. Suppose [IsBrittle] is enchanted to [ITEM556] (which is the potion jar with 2 hp). When this drops, it spills its the two [1HP] items, which might be represented by spilled liquid. If a character could pick it up, he could put them into another jar.
In my non-mmo code, I store items, and for each item I store its container if it has one. I reconstruct the inventories when the game loads. Since the saved file is not a database, there are no "columns". So to store a generic [1HP] inside a [Jar], I store this:
NumItems = 3Item1_BaseID = "Jar"Item1_X = 400Item1_Y = 0Item2_BaseID = "1HP"Item2_Container = 1Item3_BaseID = "1HP"Item3_Container = 1
This stores the information that there exists a Jar at (400,0) holding 2HP. Since 1HP is inside a container, I don't need to store its x and y coordinates in the world. You could do the same concept in a database where when you look for stuff that belongs to [Item556], you query a list of items with where Container=556.
[Edited by - Wai on January 1, 2009 10:06:38 PM]
The way I have characters and inventories set up is like this. Characters and Inventories are saved in the same database but different tables and then loaded into an array like so.
Players()
----Inventory
-------Items()
-----------Item Number (Which item is in the slot)
-----------Item Count (Amount of the item in the stack)
So I basically load the inventories into the players. So it is setup to access individual inventory slots. So I could modify that do be like this
Players()
----Inventor
-------Items()
----------Item Number
----------Item Count
----------InvId
----------Is_Template
I also like the idea of polling the inventories to see if the items are repeating across several account and saving them as a template. Thanks for the input, it looks like I have it up so I can salvage most of what I have got going, and hopefully that means it won't take to long to get the new system up and going.
Players()
----Inventory
-------Items()
-----------Item Number (Which item is in the slot)
-----------Item Count (Amount of the item in the stack)
So I basically load the inventories into the players. So it is setup to access individual inventory slots. So I could modify that do be like this
Players()
----Inventor
-------Items()
----------Item Number
----------Item Count
----------InvId
----------Is_Template
I also like the idea of polling the inventories to see if the items are repeating across several account and saving them as a template. Thanks for the input, it looks like I have it up so I can salvage most of what I have got going, and hopefully that means it won't take to long to get the new system up and going.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement