Some questions about creating an inventory

Posted By: reknak

Some questions about creating an inventory - 07/29/11 13:16

Hey guys,

I am trying to create an inventory (an inventory like in diablo, deus ex, etc.) and I have some questions concerning it. I looked in the manual but I couldn't figure this out:

1. Is it possible to show an entity (in this case a sprite) in front of a panel and if possible how can this be done?
2. Can a panel be connected to an action like an entity can (e.g. the entity player can be connected to action that lets the player move) and if possible how can this be done?

Thanks for taking the time!
Posted By: 3run

Re: Some questions about creating an inventory - 07/29/11 14:27

Take a look at the last AUM there is a basic inventory, it'll answer most (if not all) of your questions.
Posted By: reknak

Re: Some questions about creating an inventory - 07/31/11 13:23

Ok I have looked into both AUM 100 and 101 but I still don't get it entirely (I know now that items should be Pans too than and I quess that the things I asked about are not possible). Anyway I'll just mess around more with the script editor.
Posted By: Walori

Re: Some questions about creating an inventory - 07/31/11 19:01

Quote:

Anyway I'll just mess around more with the script editor.

Well that's something you should do really if you're looking for inventory. Inventories vary between the games so much that if you're looking for something specific from the inventory it's allways better to create your own. As with the own inventory you allways get the things you need.

Know it's a hard task, even more if you're a beginner or never have done invnetory, but with little ambition and help you should be able to do it. Here's some hints to the inventory, I can't answer to question 1 as I've never done it myself the second question I don't get really, if you mean the events (see event in the manual)of the panel then yes, if something different please clarify.

The inventory, in short, consist the following "items":
-The base inventory that holds everything, you can do this by structs if you wish to have more than one inventory on your screen at a time. But in basic inventory you don't have to worry about this.

-Slots that hold the items inside the inventory. Slots have id for item and panel(s) to show the item on screen. At first you can create this with one variable(for item id) and one panel (for the output). Store the item id to panels skills and use that skill id to identify the item. When you want more features to the iventory, you should really use structs. With structs it's easier to add new features to the slot, however it's also harder to work with them if you've not done that earlier.

-The items are stored as ID, or as struct if you want to, to the slot. Each item can be a basic structure that holds the name, id and so on. Store them to an array for easier picking up from the slots, as then you can use the id number to get item from the array and remove the loop to get the item.
Posted By: reknak

Re: Some questions about creating an inventory - 08/01/11 10:10

Thanks for the info. With the second question I meant connecting an action to an panel, but I quess that's only possible with entities.
When I began to try making the inventory I used panels with buttons for the inventory and entities (/sprites) for the items. All went well except for the fact that I forgot that entities move with x, y and z coordinates and not with only x and y (like panels) and that panels are in frond of entities. Than I tried to make an inventory entirely made of entities (I was getting a bit tired of panels :P) but that didn't work either for me (hard with the x, y and z coordinates and such). I noticed that both entities and panels have their advantages and disadvantages for creating an inventory; entities can have an action connected to them and can have skills which really makes it alot easier but else they make it more difficult.

Speaking of skills, I saw in the manual that panels have skill_x and skill_y, what do do they do exactly?

I also found that rpgtemplate by Claus N., Nighthawk Arts has a good working inventory in it (similar to the deus ex and diablo ones), I'm going to try that one out.

Again thanks for the helpfull comment!
Posted By: Widi

Re: Some questions about creating an inventory - 08/01/11 10:52

skill_x and skill_y is the same as the skills for entity, here you can save some vars. If you need more then this two skills, then you can use a struct that contains your panels and some more vars.
Posted By: reknak

Re: Some questions about creating an inventory - 08/05/11 13:34

Damn that's good news :D, that was precisely what I hoped for. Thanks for the clarification Widi.
Posted By: Aku_Aku

Re: Some questions about creating an inventory - 08/05/11 16:53

Quote:
1. Is it possible to show an entity (in this case a sprite) in front of a panel and if possible how can this be done?

Try with ent_createlayer function. Set the layer nnumber higher than the panel's layer. It is for model, i know.
Posted By: reknak

Re: Some questions about creating an inventory - 08/08/11 10:48

Thanks Aku_Aku, I will keep that in mind. I'm now making it fully with panels (panels for the items in the inventory and the inventory self as panel). So far going great, only one more thing I wanted to know, about pointer for panels. I want to make pointers for the items put into the inventory slots. So lets say I have 10 inventory slots and 2 equipment slots, in the begin of the script I want to create 10 pointers for the item panels placed in the inventory slots and 2 pointers for item panels placed in the equipment slots. I know how pointers work, except with panels. Should I use *PANEL = ... or should I use *BMAP = ... for the item panel pointers?

Sorry if I sound confusing, if so, please say so and I will try to be more clear.

Thanks in advance!
Posted By: 3dgs_snake

Re: Some questions about creating an inventory - 08/08/11 11:19

... confusing grin

Can you explain more what you want to achieve?

Best regards.
Posted By: reknak

Re: Some questions about creating an inventory - 08/08/11 14:52

I will give it a try,

Code:
#include <acknex.h> //not important atm
#include <default.c> //not important atm
#include <mtlView.c> //not important atm

#define STATE     			skill1 //not important atm
#define ANIMATION 			skill2 //not important atm
#define CREATOR   			skill3 //not important atm
.....

.....

BMAP* crosshair_tga = "crosshair.tga"; //not important atm
BMAP* Defeat_bmp = "Defeat.bmp"; //not important atm
Is this good? (I hope this): 
-> PANEL* ItemInInventorySlot1;
-> PANEL* ItemInInventoryEquipmentSlot1;
Or should it be this?:
-> BMAP* ItemInInventorySlot1_bmp = "Item1.bmp"; 
-> BMAP* ItemInInventoryEquipmentSlot1_bmp = "Item1.bmp"; 
ENTITY* my_sky; //not important atm



The reason why I want to add these pointers is because this way I can easily link the items (/itempanels) placed in the inventory slots with the inventory slots. In other words, I want to give the items (/itemspanels) another addres when placed in an inventory slot that shows in which inventory slot the item lies/is (otherwise the item only reacts to the my and you pointers).
Posted By: Aku_Aku

Re: Some questions about creating an inventory - 08/08/11 16:28

You can create a panel and its background image named bmap more than one way.
The static one:
Code:
BMAP* compass_map = "compass.pcx"; 

PANEL* aircraft_pan =
{
   bmap = compass_map; // compass_map as panel background
   flags = SHOW;
}


The dynamic one:
Code:
PANEL* splashscreen;
splashscreen.bmap = bmap_create("splash.pcx");


I think there are more ways to create a panel and assign a bmap to it. Just read the manual careful. All may examples based on the manual's examples.
Just one more dynamic example (from my project):
Code:
#define PAN_MENUS_SUM 3
PANEL* pan_menus[PAN_MENUS_SUM];
pan_menus[1]=pan_create(NULL,2);
pan_menus[1].bmap = bmap_create("foo.jpg");


Posted By: reknak

Re: Some questions about creating an inventory - 08/17/11 19:10

Sorry for the late response,

Thank you Aku_Aku, I got it working now. The PANEL* pointers work excellent. I recommend other people too to use pointers when making an inventory, easy and efficient in my opinion.
© 2024 lite-C Forums