best method for an rpg inventory

For questions about using Classic.

Post » Mon May 09, 2011 4:18 pm

so for something similar to diablo (not the grid storage thing, just the random items) what would be the best storage method for a database? text files or an array?

you have a variety of different objects that have a long list of possible variable changes, new skills more damage, poisoning ext. yet you have relatively simple objects such as potions and scrolls all being stored in(what i amuse to be)just one array.

would it be better to have the objects id number stored in an array and have the actual object effects referenced in a text file witch tell what exactly the said object dose.(if thats possible.)

Or have a huge array with a long y/z length to accommodated all possible actions that gets checked
and populate the inventory array with this info when needed.
B
6
S
2
G
5
Posts: 249
Reputation: 2,323

Post » Mon May 09, 2011 6:24 pm

I think it may be best to use arrays. One guy here showed me a simple diablo like inventory before. Sorry but I forgot who gave it lol! And I don't have the file anymore so... sorry.
B
10
S
5
G
8
Posts: 203
Reputation: 4,395

Post » Tue May 10, 2011 4:31 am

I think it could work if you do this way:

Array1 contains all possible prefixes
Array2 contains all possible suffixes
Array3 contains all weapons
Array4 starts empty

When the enemy drops a weapon, gamble for a random weapon from Array3, at a 50% chance, gamble for a prefix from Array 1 and a suffix from Array2
Store those results on Array4. So Array4 would look like this:
1,1:Sword
1,2:Dark
1,3:of Doom

And on your inventory system, call for the weapon n# 1 from array 4 and that will be "Dark Sword of Doom"

But that's just the tip of the iceberg of course...

If you want, look for "LoD Kompendium v12" on google, they have the complete information on how D2 drop mechanics work, and a lot of other stuff too
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Tue May 10, 2011 7:58 am

I hate to bring it up again, but your best bet for a fully featured inventory system would be to use the S(uperstructure) plugin. Might be a hassle to learn at first, but it surely pays off in the long run.

Also this older answer to a similar thread has links to several different inventory examples:
[url:1a8ifykb]http://www.scirra.com/forum/viewtopic.php?f=3&t=8122&p=62428&hilit=inventory#p62404[/url:1a8ifykb]
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Tue May 10, 2011 12:52 pm

thanks for the reply's.
i was kinda thinking thee 4 arrays system originally ,thanks for the search tips 7soul.
but apparently there's a whole host of ways to go about it.

I've seen the Superstructure plugin before but wasn't working on anything it applied to at the time
forgot it existed, guess ill give it a shot. i hate to see all the work i did so fare be for nothing though. oh well apparently that's just how programing goes.
B
6
S
2
G
5
Posts: 249
Reputation: 2,323

Post » Thu May 12, 2011 5:13 am

there is a method for this type of inventory pixelrebirth made.. take a look:

[quote="PixelRebirth":rg0b7xr3]Oh since we're in a sharing mood:

[url:rg0b7xr3]http://dl.getdropbox.com/u/2306601/inventory_007x3.cap[/url:rg0b7xr3]

It's not NPC but still RPG-related. So this might interest some reading this. TheJanMan might already have it though. :wink:[/quote:rg0b7xr3]
B
30
S
6
G
5
Posts: 433
Reputation: 6,061

Post » Thu May 12, 2011 5:42 pm

That method works amazingly well too! I've used it a few times now.
B
5
S
2
G
5
Posts: 221
Reputation: 2,272

Post » Fri May 13, 2011 9:27 pm

I would recommend looking into Python.

It depends on what you're doing, but if I understand what you're going for, you might have the most flexibility in the long run just using simple Python data structures (e.g. lists). They can easily be converted to text, which in turn can be converted back into data structures, so testing and visualizing the contents of something like an inventory would be easy even before a front end viewer is implemented. Likewise editing the inventory for testing purposes could be done by editing human readable text.

I had put off using python in Construct for quite a while, and in retrospect I should have started in with it much earlier. It turns out it's much easier to use than I had anticipated.


Tutorial: A very simple Python-in-Construct intro tutorial on the forums.
viewtopic.php?f=8&t=5397

Scirra Wiki: The Construct Wiki page on Python:
http://sourceforge.net/apps/mediawiki/c ... _Scripting

Reference: A pretty good reference and documentation site for Python:
http://docs.python.org/tutorial/index.html
The above site might be a good place to start learning python if you're not already familiar with it, (but wait till after doing the tutorial at the first link I provided).


Anyway, if you decide that you want to try using Python I recommend using the reference site above to read a little about the basics, like syntax, operators, if/then/else, loops, and functions, and then just start building stuff. And when you need to know more, look it up on a case by case basis.

In your case, you'll probably be using lists and dictionaries.

One bit of advice though, is that you'll want to write down in one place the names of all global variables and functions you've created, so you don't have to go hunt them down to remember what they were named.

And if you've never done traditional text-based programming before, don't worry. If you can use Construct, then you can use Python in Construct. :)
B
21
S
13
G
8
Posts: 306
Reputation: 5,458


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests