Friday, June 13, 2008


Alright, so I'm gonna do yet another database revision.

I gotta do it anyway so I can clean up my map code with "selectable icons" for the users and make it all done by variables (I don't have a field in the tables of Towns and Players for what "icons" they use, the urls for pictures need really long fields and I didn't have any extra).

Plus I wanna start working on the Character Class and Combat and Monster and Loot and Inventory stuff, 'cause that's the fun shit.

And one of the things I need to do for that is to change the stuff I put in the database for how to handle inventory and backpacks and bank slots and treasure chests and places you can stash shit in your vehicles and whatever buildings you own and npc merchants and stuff.

'Cause right now all I got is forty inventory slots and forty bank slots per "character" inside the character table.

Which is a really dumb way to do it.

'Cause I can give people the potential for way the hell more inventory if I make a separate table to store something like "forty-slot backpacks" and then just make sure that the "backpacks" have the character's name on it (well, their ID, but same thing).

And its just more efficient to do it that way anyway, when you think about cutting down the amount of data moving through the pipes, like, you don't really need to know about your inventory (and especially all the shit in your bank and whatever else) unless you wanna look at it or equip something out of it or sell it or put something in the bank or something, aside from those things, it can stay "asleep," basically.

Well, there's also the thing about like, giving people crappy backpacks to start with, and a limited amount of bank slots, and then giving them better ones and more slots as they get bigger, so I need some fields for that "how many slots does the backpack have" in the Inventory Database.

Hmm, are backpacks a kind of loot?

They're definitely something the users could add pictures for, a cheap way to customize your User Interface to suit your character heh.

But really all they'd have is a pic and a number of slots, they ain't got any other attributes, I don't think.

Well, they'd need to know who they belonged to, so I could pull them back out of the "Inventory" database by character ID, and then they'd need to know what kind of inventory they were, like, whether they were a backpack on a character, or a bank slot, or the trunk of a car, or something in a building.

And they might not have an "owner," if they're a treasure chest in a dungeon or an abandoned car or something.

So I need some fields for "where" they belonged, too.

Or I could just reference them from the thing they belonged to, by giving buildings and vehicles "slots' for storing whatever "backpacks" or "inventories" they own.

And then the user owns the character, the character owns the car, and the car owns whatever its got in its glove box and trunk, and it checks back up the tree to its owner before it lets anybody else mess with it heh.

And if it don't have an owner, then whatever its got in its trunk is free for the taking to everybody.

Yah, that's the way to do it, same thing with all the houses and Taverns and forts your character might own and stuff.

But his bank slots and personal inventory will be directly assigned to him, and not assigned to him through some other object that's between him and that inventory with a chain of command and stuff.

Okay, so that's the way I'm gonna do it.

An inventory table made out of "forty slot backpacks" with fields for an owner, a name (so you can give the backpack a name), an image, the max number of slots it has ('cause it might be less than forty), the number of slots that its using, and some space to store the IDs of the items that are currently stored in that backpack.

I'm just going with 40 'cause I think that's a good number even though there's some junk like "gloveboxes" that can't hardly store anything, it don't take a "glovebox" any more time to move out of the database than it takes a forty slot backpack with the same amount of items in it.

And I don't wanna get into chaining "ten slot backpacks" together into one big forty slot back pack, that's actually inefficient in the database ('cause each of those "tiny bags" would need to store their owners and all those other "header" variables, which are just about as big as the tiny bag itself heh) and its inefficient on the player side of things where their machine has to do more math and queries and crap to put things together, its better to go with the "biggest" size you think you might wanna display as a single inventory, I think, even though that don't sound exactly right.

I could make the slots as a "text field" that expanded to any size too, and then just parse the thing.

Mebbe I should do that.

The only bad thing about that is that you gotta parse the thing before you can grab something out of it, if you got forty fields in the database, instead of a "variable" amount of slots stored as a string that you gotta parse, you can go straight to field 32 in the database and grab whatever that thing is without bothering with anything else.

I dunno if I'm ever gonna wanna do that, I'm just thinking it all out heh.

And if you store it as a string, you gotta parse it out into an array to play with it and then smush it all back into a string to stick it back in there, insteada just updating one slot of it.

I dunno if that's that big a deal though, I mean, a string with forty IDs isn't all that big a deal, and its one read or write from and to the database either way.

And with the string, you could grow it to anything you want, 100 slot backpacks and all that, and it doesn't waste any "unused" space in the database on "empty slots."

Yah but one programming mistake or a glitch and that whole backpack gets torched, where if you do things one at a time you are limiting the potential damage heh.

I think that's what is giving me the willies about the string idea ahaha.

I think I'm gonna do the string thing though.

Hmm, the thing with the car owning an inventory isn't going to work, 'cause cars (and all the other things that might have an inventory) might have the same ID as a character, 'cause they live in a separate table.

So I need to keep track of the ID of the inventory in the thing that owns it, and not search the database for "things owned by this or that guy," 'cause it might not be a guy that owns it.

Unless I add a field that's a number that says what type of thing it is that owns it.

Yah I'm gonna do that just so that I can do it either way, its always good to have a little more rope than you need, y'know, 'cause what if I wanna do treasure chests that only open up after you kill their owner or something like that heh.

No comments: