PDA

View Full Version : Form Database System


Inverness
08-30-2007, 02:36 AM
This is a system I created for Val Dev to be the skeleton for the Mud and various other systems, its directly based upon the database system used in Morrowind and Oblivion. I discontinued it because I don't know how Graal would handle the system if it got to 30,000+ forms like I would expect in the future. Its not something that would work too well on a large scale if its interpreted like Graal Script is, I believe.

I would love to have my system integrated into Graal if Stefan ever finds time <3, I believe it would be useful to many as a database designed to work with the Mud.

There are some things I planned to do but haven't since I discontinued it:
1. Cache variable indexes
2. Remove dependency on the allforms array, since I think Graal would kill itself with a 20,000 member array.
3. Update the function scheduling so the operation is done on timed intervals rather than a time after the last operation.
4. I forget the rest.

Attached to the post is the system itself, the default definitions I had, and two of its dependencies.


Anyhow, now for the explanation of it. In this system, a Form is simply an array with its first variable being the type, allowing the system to identify the rest of the data in the array, all forms have an ID and can be referenced with a special string: "#f1002" which would mean a form with the ID 1002. Those special strings are made to be like pointers in C++, you need them to access the database by function at all times.

There are two overall types of Forms, Default and Cloned. Default forms can be defined by any means the user wishes and they are not saved to file so they must be actively defined somewhere (I use a database NPC).

The only way to create new forms is to clone them using the CloneForm() function, this takes a form reference (i.e: "#f1034") as a parameter and returns a reference of a duplicate form. Blank forms are generated automatically for each type and their reference defined in a variable in the system (i.e.: "playerdata = cloneForm(Forms.newplyr);"). Cloned forms are saved to file on change and creation, and are loaded from file when the server starts. Cloning forms is how you would add new data for new players and new items created.

For clientside stuff, Forms are sent to client when needed. All forms sent to client are parsed for form references that exist in them, these form references are gathered in a list and if those forms exist but are not yet loaded on the clientside they're requested from the server and the process starts over again.

For how the Mud Items related to the database, there is a single form type for an item instance, and multiple types for their bases. Item bases are how the stacks are organized. For example, you would have a form of type 'weap' which contains base information for a Sword, including its name, icon, damage, scripts, weight, value, etc. From this base the Mud creates new forms of type 'item' which are instances of an item. The 'item' form contains information such as quantity, and the condition of the item and its owner or other things unique to that item, also the most important variable is the base, each item instance has a variable for the base form that its representing so the inventory and such knows where to load name and image data from.

And also Mud related, is what happens when a new player logs in. Three new forms are created of type 'plyr', 'char', and 'cont'. The 'plyr' type is meaning player, it contains information specific to actual accounts on the server and not game characters. The 'char' type is meaning character, it has information related to game-characters such as their health, class, stats, etc. Both Players and NPCs would have an instance of this. Also contained in every character form is a reference to its container form, type 'cont'. Container forms store an array of form references to the items that are contained within it, and are used for both characters and objects in the world such as barrels or crates or even dead baddies.

Heres an example of the forms a player would receive on login and how they're connected to eachother:

form5001:
type = "plyr" (player)
cloned = true
id = ""
name = "Inverness" (the account of the player)
version = 3 (Indicating any adjustments that need to be made, like resets, or broken items)
char = "#f5002" (The reference to the character of the player)

form5002:
type = "char" (Character)
cloned = true
id = ""
name = "Inverness Moon" (in-character name)
health = {0,0,100,0,100} (A stat array: base,bonus,total,minvalue,maxvalue)
mana = {0,0,200,0,200}
stats = ...
class = ...
race = ...
spells = {"#f304","#f311","#f400"} (Array of spell forms the character has)
cont = "#f5003" (The container form reference)

form5003:
type = "cont" (Container)
cloned = true
id = ""
owner = "#f5002" (The character that owns it, player or npc)
weight = 70000 (The weight of all items in the container)
maxweight = 120000 (The limiter on the number of items that can be placed in the container)
items = {"#f5004","#f5005","#f5006"} (Array of item instances in the container)

form5004:
type = "item"
cloned = true
id = ""
quantity = 20
data = {"#f5002",100,0} (stack data: owner, health percent, is stolen?. Items can be stacked as long as these variables are matching and are unstacked for any changes, and have same base)
base = "#f200" (The base form of the item)

form5005:
type = "item"
cloned = true
id = ""
quantity = 2
data = {"#f5002",100,0}
base = "#f201"

form5006: (Same base as 5005, yet in different stack because item is damaged)
type = "item"
cloned = true
id = ""
quantity = 1
data = {"#f5003",95,0}
base = "#f201"

form200: (Default Form, can not be changed, only cloned if you wish to make a custom item)
type = "misc" (Misc Item Type)
cloned = false
id = "gold"
name = "Gold Coin"
icon = "valmud_gold.png"
value = 1
weight = 0
script = ""
quest = false (Quest items are weightless since they are important)

form201:
type = "weap" (Weapon Item)
cloned = false
id = "ironsword"
name = "Iron Sword"
icon = "valmud_sword.png"
value = 20
weight = 6500
script = ""
quest = false
weapontype = "sword1h"
weaponreach = 2
weaponspeed = 1
weapondamage = 6
weapongraphic = "valweapon_ironsword.png"


If you wanted to customize and instance of a sword, you would remove 1 instance of it from the player, clone the base form of the item, make changes to the base form, then add an instance of the base form to the player, which would be the customized item, all changes are saved automatically.

...

Wow, thats alot of typing :D

Chompy
08-30-2007, 02:37 PM
Amazing Inver, just amazing!

Very nice :p!