Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Nymphodora), 485 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 9 1 2 3 4 5 6 7 8 9
The complete RPG Inventory + Tutorial #157238
09/28/07 01:41
09/28/07 01:41
Joined: Aug 2005
Posts: 390
Florida
O
oldschoolj Offline OP
Senior Member
oldschoolj  Offline OP
Senior Member
O

Joined: Aug 2005
Posts: 390
Florida



Well folks, I'm really happy to contribute this to the community, because it's taken me a long time to work out all the kinks, and I don't want anyone going through this like I had to.

This inventory system, should do most everything that you could want in a inventory, and although it is specifically geared toward RPG's, it will, with a bit of tweaking work for almost any game that needs an inventory. I have to say that I am pleased with what it does for me.

I've included a full tutorial with the inventory module. The tutorial has a fully illustrated outtake on the code, and the system that I used for setting it up. It uses a point- by - point layout, that I feel is fairly easy to follow. Even if I forgot to explain some things, I feel that by the time your done with the tutorial, you will have a very good grasp on how to make the inventory system work for you. The rar file also includes a prop panel for testing, and placeholder icons for items, as well as a few other goodies. Please read the enclosed disclaimer for more info.


The primary features:

• Custom dressing room feature. This feature simply creates a replica of the player model, with a black background. It will show the items that are equipped, so the player can stare at his or her character and beam with pride. It’s always visible, and is surrounded by the equipment slots for easy viewing. You can zoom in, and out. Rotate left or right. And the character model will of course play whatever animations you choose. You could get quite creative with this feature. If you equip a shield you could have the character play it’s “block” animation. A sword, it’s “salute” animation. The choice is yours, but the animation starts out with a default of “stand”, and as long as the inventory screen is open, the dressing room model will play it. All of its animations run completely independent of what the player is doing.



• Automatic mouse tracking, capable of storing and calling the mouse’s current location and what cell it is currently “housed in” while the inventory screen is visible.

• “Item backing” while items are equipped. This means that you can put placement pictures in your equipment slots, so that players know what items can go in which slot. Once you equip an item in that slot, the “item backing” will appear to remove that image. Removing the item will also remove the “item backing”.

• Large storage capacity, with backwards or forwards compatibility. The inventory is designed to handle 36 items, and houses 25 equipment slots for your players gear. However, it can very easily be modified to handle more or less by deleting a few lines of code, and modifying a few variables.

• Toggling, and dragging. The inventory can be toggled on or off, and dragged about the screen, while moving all items with it.

• Easy selection system. An item is picked up with the left mouse button, and while it is held down, the item will be dragged to wherever the user chooses. If it’s off the panel, it will automatically be placed in a slot that is free. Once the mouse is release the item is dropped, so no double clicking.

Here is a video showing the system in action in a testing room where I developed the inventory for my own game. Please do not redistribute this video as it does contain sensitive materials. What I mean by that, is posting on You-Tube or something of that nature. It is stricly for the community to look at and maybe gain some ideas.


Inventory Movie

Here is the tutorial and files -----> Inventory

Thanks and good luck!

PS There are a few bugs which I am aware of, such as synching issues. I am currently working on fixing these issues, and if you are inclined too, let me know if you find any bugs, so t hat I can fix them as well.

Jesse

Last edited by oldschoolj; 09/28/07 14:50.

you can find me with my face in the keyboard, unshaven, listening to some nameless techno tragedy, and hashing through code over a cold cup a stale joe. __________________________________ yours truly
Re: The complete RPG Inventory + Tutorial [Re: oldschoolj] #157239
09/28/07 02:09
09/28/07 02:09
Joined: Oct 2006
Posts: 45
J
juggalo10101 Offline
Newbie
juggalo10101  Offline
Newbie
J

Joined: Oct 2006
Posts: 45
Wow really nice, thanks a million

Last edited by juggalo10101; 09/28/07 02:13.
Re: The complete RPG Inventory + Tutorial [Re: juggalo10101] #157240
09/28/07 03:39
09/28/07 03:39
Joined: Mar 2003
Posts: 4,264
Wellington
Nems Offline

.
Nems  Offline

.

Joined: Mar 2003
Posts: 4,264
Wellington
Great stuff, was thinking if I needed one or not then decided I'd better have a look to learn anyway so thanks again, you just may see your inventory in my game one day (fingers crossed )

Re: The complete RPG Inventory + Tutorial [Re: Nems] #157241
09/28/07 04:03
09/28/07 04:03
Joined: Sep 2007
Posts: 63
J
JackShephard Offline
Junior Member
JackShephard  Offline
Junior Member
J

Joined: Sep 2007
Posts: 63
Its Great!
Thank you!


Re: The complete RPG Inventory + Tutorial [Re: JackShephard] #157242
09/28/07 04:33
09/28/07 04:33
Joined: Dec 2005
Posts: 478
India
M
msl_manni Offline
Senior Member
msl_manni  Offline
Senior Member
M

Joined: Dec 2005
Posts: 478
India
I a having problems running the demo. There are some functions and defines missing from the demo. Define - REAR not found. attach_item function not found. Please clarify the errors.


My Specialities Limited.
Re: The complete RPG Inventory + Tutorial [Re: msl_manni] #157243
09/28/07 07:22
09/28/07 07:22
Joined: Mar 2005
Posts: 969
ch
Loopix Offline
User
Loopix  Offline
User

Joined: Mar 2005
Posts: 969
ch
Outstanding work...thanks! It's indeed very generous of you to contribute this piece of hard work for free

I'm also stuck with the errors msl_manni mentioned...but I think this is no mayor issue.

Thanks again!

Re: The complete RPG Inventory + Tutorial [Re: Loopix] #157244
09/28/07 10:43
09/28/07 10:43
Joined: Aug 2005
Posts: 390
Florida
O
oldschoolj Offline OP
Senior Member
oldschoolj  Offline OP
Senior Member
O

Joined: Aug 2005
Posts: 390
Florida
this is because you will need to define those youself, if you look in the large function in the code, the one that is several thousand lines long, you will see the defines basicly you should define each possible space for you inventory. such as left ear, right ear and so on. I think i forgot a few. Here is the function "attach item". Please remember that these are based on vertex animations, so if you have not modeled your armor pieces correclt this function will not work:
Code:
function attach_item()
{
set (my, PASSABLE);
my.scale_x = 2;
my.scale_y = 2;
my.scale_z = 2;
wait(1);
c_updatehull(my,1);
while(player != NULL)
{
vec_set(my.x, player.x);
vec_set(my.pan, player.pan);
my.frame = player.frame;
my.nextframe = player.nextframe;
wait(1);
proc_mode = PROC_LATE;
}
}




BTW this is not a demo, this is just an inventory system, and without filling in the proper spaces for models, etc. it wont work right.

Last edited by oldschoolj; 09/28/07 10:45.

you can find me with my face in the keyboard, unshaven, listening to some nameless techno tragedy, and hashing through code over a cold cup a stale joe. __________________________________ yours truly
Re: The complete RPG Inventory + Tutorial [Re: oldschoolj] #157245
09/28/07 11:10
09/28/07 11:10
Joined: Aug 2005
Posts: 390
Florida
O
oldschoolj Offline OP
Senior Member
oldschoolj  Offline OP
Senior Member
O

Joined: Aug 2005
Posts: 390
Florida
I forgot to mention the re-scaling part, incase your inventory slots are larger
then your equipment slots, like the way that the template is set up. This is
very easy to customize. In the function ui_inv_attach_icon, you will notice
that there are 60 mouse locations, just like I mentioned in the tutorial. Each
mouse location is nearly a replica of the next, wit ha few exceptions. If you
goto line 650, this is mouse location zero. It has three posible states. Filled
with the icon coming from a inventory slot. Filled with an icon coming from a
equipment slot. And not filled, in which case the icon is placed there.
If you notice, inventory states are all scaled 1 to 1.
While the equipment state, orequipment slot return loop, sets the icon scale smaller.
You will need to change each and every mouse location's scale for this,
if you are using a different scale. It may be a bit tedious, bit it is
easy, and no coding.


I also want to talk a bit more about the defines. HEad over to line 1660, and
you will see that this is in fact our first equipment slot. S it's a equipment
slot zero, and mouse location 36, member we discussed that in the tutorial as
well. The layout is a template for the rest of the equiment slots:

Code:
if (mouse_item_location == 36)
{
if ((ui_equip_slot_array[0]>0) && (ui_inv_slot_return == 0))
{
temp_panel.pos_x = ui_inv_panel.pos_x + ui_equip_posx_array[ui_equip_slot_return];temp_panel.pos_y = ui_inv_panel.pos_y + ui_equip_posy_array[ui_equip_slot_return];
temp_panel.scale_x = .7;
temp_panel.scale_y = .7;
ui_equip_icon_backing[ui_equip_slot_return] = pan_create ("bmap = equip_icon_backing.tga;flags = VISIBLE;",1);
ui_equip_icon_backing[ui_equip_slot_return].pos_x = ui_inv_panel.pos_x + ui_equip_posx_array[ui_equip_slot_return];ui_equip_icon_backing[ui_equip_slot_return].pos_y = ui_inv_panel.pos_y + ui_equip_posy_array[ui_equip_slot_return];
ui_equip_slot_array[ui_equip_slot_return] = handle (temp_panel);
}
if ((ui_equip_slot_array[0]>0) && (ui_inv_slot_return > 0))
{
temp_panel.pos_x = ui_inv_panel.pos_x + ui_inv_slot_replacex_array[ui_inv_slot_return];temp_panel.pos_y = ui_inv_panel.pos_y + ui_inv_slot_replacey_array[ui_inv_slot_return];
temp_panel.scale_x = 1;
temp_panel.scale_y = 1;
ui_inv_slot_array[ui_inv_slot_return] = handle (temp_panel);
}
if ((ui_equip_slot_array[0]==0) && (player.ITEM_TYPE != REAR))
{
if (ui_inv_slot_return == 0)
{
temp_panel.pos_x = ui_inv_panel.pos_x + ui_equip_posx_array[ui_equip_slot_return];temp_panel.pos_y = ui_inv_panel.pos_y + ui_equip_posy_array[ui_equip_slot_return];
temp_panel.scale_x = .7;
temp_panel.scale_y = .7;
ui_equip_icon_backing[ui_equip_slot_return] = pan_create ("bmap = equip_icon_backing.tga;flags = VISIBLE;",1);
ui_equip_icon_backing[ui_equip_slot_return].pos_x = ui_inv_panel.pos_x + ui_equip_posx_array[ui_equip_slot_return];ui_equip_icon_backing[ui_equip_slot_return].pos_y = ui_inv_panel.pos_y + ui_equip_posy_array[ui_equip_slot_return];
ui_equip_slot_array[ui_equip_slot_return] = handle (temp_panel);
}
if (ui_inv_slot_return > 0)
{
temp_panel.pos_x = ui_inv_panel.pos_x + ui_inv_slot_replacex_array[ui_inv_slot_return];temp_panel.pos_y = ui_inv_panel.pos_y + ui_inv_slot_replacey_array[ui_inv_slot_return];
temp_panel.scale_x = 1;
temp_panel.scale_y = 1;
ui_inv_slot_array[ui_inv_slot_return] = handle (temp_panel);
}
}
if ((ui_equip_slot_array[0]==0) && (player.ITEM_TYPE == REAR))
{
temp_panel.pos_x = ui_inv_panel.pos_x + ui_equip_posx_array[0];temp_panel.pos_y = ui_inv_panel.pos_y + ui_equip_posy_array[0];
temp_panel.scale_x = .7;
temp_panel.scale_y = .7;
ui_equip_icon_backing[0] = pan_create ("bmap = equip_icon_backing.tga;flags = VISIBLE;",1);
ui_equip_icon_backing[0].pos_x = ui_inv_panel.pos_x + ui_equip_posx_array[0];ui_equip_icon_backing[0].pos_y = ui_inv_panel.pos_y + ui_equip_posy_array[0];
ui_equip_slot_array[0] = handle (temp_panel);
}
ui_inv_slot_return = 0;
ui_equip_slot_return = 0;
}



As wit hthe inventory positions, if the slot os filled and it came from an
inventoy slot, it is returned, or if it came from another equipment it is returned there.
If it is the wrong item type, (this is the REAR you were talking about) it is
also returned becaue it doesnt belong there. In this case it's a REAR slot
or "right ear", but this is almos tthe exact same code as the
rest of the equip slot locations. Only the positions in the array is increased
by one, for ever slot after this one. And the item type check is changed. You
will not have to edit anything besides these two things, as long as you are
using the same type of design. This means that you have a item, a equipment
slot, and a inventory slot. So lets say that you wanted to attach a laser turret to your brandnew space cruiser, in a space shooter game. And you wanted
it to be a position 1, or equipment slot one. Well this is how you would edit that part of the code:

Code:
if (mouse_item_location == 37)
{
if ((ui_equip_slot_array[1]>0) && (ui_inv_slot_return == 0))
{
temp_panel.pos_x = ui_inv_panel.pos_x + ui_equip_posx_array[ui_equip_slot_return];temp_panel.pos_y = ui_inv_panel.pos_y + ui_equip_posy_array[ui_equip_slot_return];
temp_panel.scale_x = .7;
temp_panel.scale_y = .7;
ui_equip_icon_backing[ui_equip_slot_return] = pan_create ("bmap = equip_icon_backing.tga;flags = VISIBLE;",1);
ui_equip_icon_backing[ui_equip_slot_return].pos_x = ui_inv_panel.pos_x + ui_equip_posx_array[ui_equip_slot_return];ui_equip_icon_backing[ui_equip_slot_return].pos_y = ui_inv_panel.pos_y + ui_equip_posy_array[ui_equip_slot_return];
ui_equip_slot_array[ui_equip_slot_return] = handle (temp_panel);
}
if ((ui_equip_slot_array[1]>0) && (ui_inv_slot_return > 0))
{
temp_panel.pos_x = ui_inv_panel.pos_x + ui_inv_slot_replacex_array[ui_inv_slot_return];temp_panel.pos_y = ui_inv_panel.pos_y + ui_inv_slot_replacey_array[ui_inv_slot_return];
temp_panel.scale_x = 1;
temp_panel.scale_y = 1;
ui_inv_slot_array[ui_inv_slot_return] = handle (temp_panel);
}
if ((ui_equip_slot_array[1]==0) && (player.ITEM_TYPE != LASER_TURRET))
{
if (ui_inv_slot_return == 0)
{
temp_panel.pos_x = ui_inv_panel.pos_x + ui_equip_posx_array[ui_equip_slot_return];temp_panel.pos_y = ui_inv_panel.pos_y + ui_equip_posy_array[ui_equip_slot_return];
temp_panel.scale_x = .7;
temp_panel.scale_y = .7;
ui_equip_icon_backing[ui_equip_slot_return] = pan_create ("bmap = equip_icon_backing.tga;flags = VISIBLE;",1);
ui_equip_icon_backing[ui_equip_slot_return].pos_x = ui_inv_panel.pos_x + ui_equip_posx_array[ui_equip_slot_return];ui_equip_icon_backing[ui_equip_slot_return].pos_y = ui_inv_panel.pos_y + ui_equip_posy_array[ui_equip_slot_return];
ui_equip_slot_array[ui_equip_slot_return] = handle (temp_panel);
}
if (ui_inv_slot_return > 0)
{
temp_panel.pos_x = ui_inv_panel.pos_x + ui_inv_slot_replacex_array[ui_inv_slot_return];temp_panel.pos_y = ui_inv_panel.pos_y + ui_inv_slot_replacey_array[ui_inv_slot_return];
temp_panel.scale_x = 1;
temp_panel.scale_y = 1;
ui_inv_slot_array[ui_inv_slot_return] = handle (temp_panel);
}
}
if ((ui_equip_slot_array[1]==0) && (player.ITEM_TYPE == LASER_TURRET))
{
temp_panel.pos_x = ui_inv_panel.pos_x + ui_equip_posx_array[1];temp_panel.pos_y = ui_inv_panel.pos_y + ui_equip_posy_array[1];
temp_panel.scale_x = .7;
temp_panel.scale_y = .7;
ui_equip_icon_backing[1] = pan_create ("bmap = equip_icon_backing.tga;flags = VISIBLE;",1);
ui_equip_icon_backing[1].pos_x = ui_inv_panel.pos_x + ui_equip_posx_array[1];ui_equip_icon_backing[1].pos_y = ui_inv_panel.pos_y + ui_equip_posy_array[1];
ui_equip_slot_array[1] = handle (temp_panel);
var l;
for (l = 0000;l<999;l++)
{
if(temp_panel == item_icon[l])
{
temp_ent[1] = ptr_for_handle(item_model_array[l]);
temp_droom_ent[1] = ptr_for_handle(droom_item_model_array[l]);
item_temp[1] = ent_create(temp_ent[1], player.x, attach_item);
droom_item_temp[1] = ent_create(temp_droom_ent[1], dressing_room_model.x, attach_dressingroom_item);
equip_slot_backing_toggle[1]=1;
}
}
}
ui_inv_slot_return = 0;
ui_equip_slot_return = 0;
}





where dressing_room_model.x is really just the name of your dummy ship model in the view window. Simple as pie.

Last edited by oldschoolj; 09/28/07 11:41.
Re: The complete RPG Inventory + Tutorial [Re: oldschoolj] #157246
09/28/07 11:44
09/28/07 11:44
Joined: Dec 2005
Posts: 478
India
M
msl_manni Offline
Senior Member
msl_manni  Offline
Senior Member
M

Joined: Dec 2005
Posts: 478
India
I see that you have provided a tutorial. It would have been nice to have a working project too to see it working, but you have provided a movie instead. Thanks for everything.


My Specialities Limited.
Re: The complete RPG Inventory + Tutorial [Re: msl_manni] #157247
09/28/07 11:57
09/28/07 11:57
Joined: Aug 2005
Posts: 390
Florida
O
oldschoolj Offline OP
Senior Member
oldschoolj  Offline OP
Senior Member
O

Joined: Aug 2005
Posts: 390
Florida
If you want to have all of the defines to solve any issues here they are, I apologize that I didnt include them to begin with:

Code:
#define ITEM_TYPE skill1
#define WAIST 1
#define ONE_HAND_WEAP 2
#define OFF_HAND 3
#define HEAD 4
#define LFOOT 5
#define RFOOT 6
#define LSHOULDER 7
#define RSHOULDER 8
#define RWRIST 9
#define REAR 10
#define CHEST 11
#define RHAND 12
#define RRING 13
#define UPPER_LEG_ACC 14
#define MASK 15
#define KNECK 16
#define RANGED_WEAP 17
#define AMMO 18
#define LEAR 19
#define BACK 20
#define LWRIST 21
#define LHAND 22
#define LRING 23
#define WAIST_STOR 24
#define LEGS 25



You will still need to add the info to the big function like i showed in the previous post.


you can find me with my face in the keyboard, unshaven, listening to some nameless techno tragedy, and hashing through code over a cold cup a stale joe. __________________________________ yours truly
Page 1 of 9 1 2 3 4 5 6 7 8 9

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1