In need of help on my inventory system.
by Kyrah Abattoir · in Game Design and Creative Issues · 09/16/2011 (10:33 am) · 3 replies
SO i settled on an inventory system which is a hybrid of the classic "Diablo style" grid based inventory and something else:
Inventory slots can be typed and can have a size expressed in grid units X/Y (2x2, 1x1, 2x3, etc...)
The player has a special "in hand" inventory slot which is his interaction point with the world for grabbing objects, because of this, EVERY inventory-able object is technically a "weapon" object.
Every weapon object can potentially have an inventory of it's own.
If an object has an inventory it is first expressed with an X/Y "inventory bound" 2D vector, then a fixed array is used to express the different types of slots, from "anything goes" slots to "unuseable" which allow to design inventory spaces of arbitrary shape.
Weapon objects for simplicity sake can only use rectangular space to allow simple object rotation in the inventory (swapping X and Y)
I assume i will also have to make a function so once a player pick an object and has it land in his "hands" slot, he can press another key that will "auto stash" the object in ANY free slot the game finds (that or simply open his inventory and move the object from the hands slot to a more suitable place). I assume i could use a clientside routine to test for any possibilities, the server always has the final word for valid placement of items in inventory.
But the bottom line is that a player has direct acces to his inventory, but also the inventory of any objects he is currently carrying and the inventory of the objects inside those objects... etc...)
So i only started to grasp how weapon objects work in torque, but i also do not want to have weapons and items spin in the air, i rather have them spawn on the ground and obey to physics, at least until their position settle.
That means that, unless i go butcher the weapon code i need to have two objects: item in hand (weapon class) and item on the ground (something else) and copy all their informations from one to the other?
So lets say i have an item "pistol" (world id 10) and a backpack (world id 12) and a player (world id 1)
-i would , i suppose, mount the backpack on the player's back mounting point,
-put on the player inventory array that the backpack slot is in use by id:12
-since the pistol is stored and not equiped no weapon image will be mounted on the player. the pistol is 2x2 space units.
-in the backpack object's inventory array, i would use 4 cells and reference in them the pistol's id:10.
Now i'm not sure that i understand everything, the player will need 3 commands:
-pickup(id)
-move(id,target_container_id,is_rotated,top_left_inventory_slot)
-drop(id)
'pickup' will take the object and put it in the player's hand(if the player is strong enough for example)
'drop' will take the object, check that it's in a container the player control, copy it's data in a "world" item, delete the original and drop the world item on the ground.
'move' will move the object from it's current container to the target container, if the required slots are free and if the container is in the player's control/reach (for world containers), it will at the same time "cleanup" the old references to the weapon object's id.
Now i have a few questions...
Instead of doing copy paste work between the weapon item and the world item, if i simply make the world item "reference" the weapon item, is there a way to have a weapon object "exist" on the server but not exist in the "real" game world?
Every weapon item has to be unique, two copies of the same weapon object shouldn't magically "merge" they should remain distinct from eachothers. Does the builtin weapon system allow this?
If i dismount a weaponimage from the player, where is the weapon object now?
Inventory slots can be typed and can have a size expressed in grid units X/Y (2x2, 1x1, 2x3, etc...)
The player has a special "in hand" inventory slot which is his interaction point with the world for grabbing objects, because of this, EVERY inventory-able object is technically a "weapon" object.
Every weapon object can potentially have an inventory of it's own.
If an object has an inventory it is first expressed with an X/Y "inventory bound" 2D vector, then a fixed array is used to express the different types of slots, from "anything goes" slots to "unuseable" which allow to design inventory spaces of arbitrary shape.
Weapon objects for simplicity sake can only use rectangular space to allow simple object rotation in the inventory (swapping X and Y)
I assume i will also have to make a function so once a player pick an object and has it land in his "hands" slot, he can press another key that will "auto stash" the object in ANY free slot the game finds (that or simply open his inventory and move the object from the hands slot to a more suitable place). I assume i could use a clientside routine to test for any possibilities, the server always has the final word for valid placement of items in inventory.
But the bottom line is that a player has direct acces to his inventory, but also the inventory of any objects he is currently carrying and the inventory of the objects inside those objects... etc...)
So i only started to grasp how weapon objects work in torque, but i also do not want to have weapons and items spin in the air, i rather have them spawn on the ground and obey to physics, at least until their position settle.
That means that, unless i go butcher the weapon code i need to have two objects: item in hand (weapon class) and item on the ground (something else) and copy all their informations from one to the other?
So lets say i have an item "pistol" (world id 10) and a backpack (world id 12) and a player (world id 1)
-i would , i suppose, mount the backpack on the player's back mounting point,
-put on the player inventory array that the backpack slot is in use by id:12
-since the pistol is stored and not equiped no weapon image will be mounted on the player. the pistol is 2x2 space units.
-in the backpack object's inventory array, i would use 4 cells and reference in them the pistol's id:10.
Now i'm not sure that i understand everything, the player will need 3 commands:
-pickup(id)
-move(id,target_container_id,is_rotated,top_left_inventory_slot)
-drop(id)
'pickup' will take the object and put it in the player's hand(if the player is strong enough for example)
'drop' will take the object, check that it's in a container the player control, copy it's data in a "world" item, delete the original and drop the world item on the ground.
'move' will move the object from it's current container to the target container, if the required slots are free and if the container is in the player's control/reach (for world containers), it will at the same time "cleanup" the old references to the weapon object's id.
Now i have a few questions...
Instead of doing copy paste work between the weapon item and the world item, if i simply make the world item "reference" the weapon item, is there a way to have a weapon object "exist" on the server but not exist in the "real" game world?
Every weapon item has to be unique, two copies of the same weapon object shouldn't magically "merge" they should remain distinct from eachothers. Does the builtin weapon system allow this?
If i dismount a weaponimage from the player, where is the weapon object now?
About the author
3D artist, programmer, game designer, jack of all trades, master of none.
#2
the inventory slots that are flagged as "active slots" automatically add their content to the player's weapon list.
For example a pistol inside a backpack will be stashed in inventory, but a pistol in a holster's inventory (holsters have active inventory slots) will be available for use (added to the weapon list).
The player has a few "primordial" slots, to wear clothes and storage objects but beyon those he doesn't have useable inventory space by himself.
situation example:
Myke is wearing military pants in his "lowerbody" slot, those pants have two large 2x2 pockets and two small 1x2 pockets, since they are pockets, all the slots are marked as active.
Myke has a revolver (2x2) using all the space of his left pocket and a bunch of loose bullets in his right pocket (1x1 stackable by 5, so 20),
He's also carrying a snack in his left 1x2 pocket and a small knife in the other.
Since all those items are in active slots, Myke can pull out his gun, knife, or take a byte from his snack at any moment, he also has access to the bullets to reload (bullets in a non active slot can't be accessed directly for reloading)
Myke is also wearing a ragged t-shirt (shirt slot) and also has a small bag slung on his back (backpack slot 3x3 non active slots).
In his pack he's carrying a small first aid kit (3x2) a small radio transmitter (1x2) and a box of bullets (1x1 with a 2x2 inventory restricted to bullets)
If Myke where to need his first aid kit he couldn't use it right away, he would first have to clear his hands (holster any item/weapon he is carrying) and equip the first aid kit to his hands from the inventory screen because the backpack content isn't "active", likewise he would have to fetch his radio from the pack to use it.
The bullet box example show that some objects can be compacted in a smaller place (2x2 worth of ammo in a 1x1 slot) through special inactive containers, the price to pay obviously is that the contained item cannot be accessed directly in combat.
In Myke's case he felt that having 20 bullets directly available from his pocket was more interesting than lets say, 2 boxes (40 bullets) and only having 10 bullets directly available.
It also means that ultimately, his revolver has an inventory with 6 bullet slots, by using the reload key, the game is replacing the spent casings by fresh compatible bullets from the first available source.
09/20/2011 (8:34 am)
Well the idea is a diablo style grid/array inventory space system, but instead of having a single array to store everything, the player's inventory is basically the sum of all the objects with inventory he is using (they do not merge and remain independant from eachothers)the inventory slots that are flagged as "active slots" automatically add their content to the player's weapon list.
For example a pistol inside a backpack will be stashed in inventory, but a pistol in a holster's inventory (holsters have active inventory slots) will be available for use (added to the weapon list).
The player has a few "primordial" slots, to wear clothes and storage objects but beyon those he doesn't have useable inventory space by himself.
situation example:
Myke is wearing military pants in his "lowerbody" slot, those pants have two large 2x2 pockets and two small 1x2 pockets, since they are pockets, all the slots are marked as active.
Myke has a revolver (2x2) using all the space of his left pocket and a bunch of loose bullets in his right pocket (1x1 stackable by 5, so 20),
He's also carrying a snack in his left 1x2 pocket and a small knife in the other.
Since all those items are in active slots, Myke can pull out his gun, knife, or take a byte from his snack at any moment, he also has access to the bullets to reload (bullets in a non active slot can't be accessed directly for reloading)
Myke is also wearing a ragged t-shirt (shirt slot) and also has a small bag slung on his back (backpack slot 3x3 non active slots).
In his pack he's carrying a small first aid kit (3x2) a small radio transmitter (1x2) and a box of bullets (1x1 with a 2x2 inventory restricted to bullets)
If Myke where to need his first aid kit he couldn't use it right away, he would first have to clear his hands (holster any item/weapon he is carrying) and equip the first aid kit to his hands from the inventory screen because the backpack content isn't "active", likewise he would have to fetch his radio from the pack to use it.
The bullet box example show that some objects can be compacted in a smaller place (2x2 worth of ammo in a 1x1 slot) through special inactive containers, the price to pay obviously is that the contained item cannot be accessed directly in combat.
In Myke's case he felt that having 20 bullets directly available from his pocket was more interesting than lets say, 2 boxes (40 bullets) and only having 10 bullets directly available.
It also means that ultimately, his revolver has an inventory with 6 bullet slots, by using the reload key, the game is replacing the spent casings by fresh compatible bullets from the first available source.
#3
10/07/2011 (12:52 pm)
Sounds valid to me. That said - it should be interesting to implement.
Torque 3D Owner Walker Twyman
Hope that helps, but I'm still rather confused.