Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #16  
Old 01-16-2007, 02:57 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Thanks Invern
__________________
Deep into the Darkness peering...
Reply With Quote
  #17  
Old 01-16-2007, 03:50 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
In my mudlib, all items are simply arrays: clientr.mud.item<uniqueid>
Anytime you make an item it gets a unique ID from the
serverr.mud.item.counter, this is so items dont overwrite eachother if you trade or anything like that since you're going to move the whole array.
The most important part of item data is the type which is the first var in array, the type is how you're going to know what stuff is where in the item array. All types are defined in serverr strings so they're easily available.
When you want a variable from an item, such as them name, you use:
mud_getitemvar(itemid, varname);
Or for example, mud_getitemvar("2006","name");

What this does is looks for the item in the clientr strings. When it finds the item, it looks at the item type (index 0) and loads the list of vars from that, and returns the index of the item array that matches the varname's index in the varlist. If you already know the index you simply use:
mud_getitem(id, index);
Any index less than zero returns the whole item array.

For updating the player, when you log in the mudlib compares your items with the archetypes that are loaded into the server, if there is a difference the mudlib updates all the variables except the 'noupdvars' such as the quantity, type, and archetype. Custom items lack an archetype so they're not updated.
__________________
Reply With Quote
  #18  
Old 01-16-2007, 05:10 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
so how do we add items to players? Like when they beat a boss or opens a NPC Chest?
__________________
Deep into the Darkness peering...
Reply With Quote
  #19  
Old 01-16-2007, 05:44 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Make a function for it.

I use mud_createitem(archetype, quantity);
Its a public function in the MudItems weapon that can be called clientside or serverside. If you want to call a function from a remote object you have to use:
Object.function(params); = MudItems.mud_createitem(params);

And for that, what I did was make an interface class. Which contains functions that call the function in the weapon object. So if I join the interface class I only have to use mud_createitem() in script and it executes fine.
__________________
Reply With Quote
  #20  
Old 01-16-2007, 03:38 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
My mudlib is different, almost same item setup as yours Inver :]

clientr.mud.item<ID> = { type, quantity, vars};

Type is what to trigger, like weapon, armor, food etc..
quantity is ammount ( obvious) and vars are the variables needed for the type :o
__________________
Reply With Quote
  #21  
Old 01-16-2007, 03:59 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
The mud library vars on Theed can get pretty hectic. Especially for armor. Short format example:

clientr.muditem_16=itemname=Twinny's Test Sword, equiptype= WEAPON_SWORD,weight=2

and so on.

It's done this way so you can load make object with vars from it. Eg.
PHP Code:
temp.mud = new TStaticVar();
temp.mud.loadvarsfromarray(clientr.muditem_16);
echo(
temp.mud.itemname); 
The system does have unique identifiers for each number but instead of being stored as a serverr flag, it is stored as a var in a DBNPC npc called 'mudlib'. The mudlib also has functions as well relating to speed/efficiency. Thanks to Kuji, this system is incredibly fast and versatile. But no secrets to give away .

Mud commands can be done via a player class. Eg. player.Mud_CreateItem("sword3", 1); being mudname then quantity.
Reply With Quote
  #22  
Old 01-16-2007, 05:14 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Twinny View Post
The mud library vars on Theed can get pretty hectic. Especially for armor. Short format example:

clientr.muditem_16=itemname=Twinny's Test Sword, equiptype= WEAPON_SWORD,weight=2

and so on.

It's done this way so you can load make object with vars from it. Eg.
PHP Code:
temp.mud = new TStaticVar();
temp.mud.loadvarsfromarray(clientr.muditem_16);
echo(
temp.mud.itemname); 
The system does have unique identifiers for each number but instead of being stored as a serverr flag, it is stored as a var in a DBNPC npc called 'mudlib'. The mudlib also has functions as well relating to speed/efficiency. Thanks to Kuji, this system is incredibly fast and versatile. But no secrets to give away .

Mud commands can be done via a player class. Eg. player.Mud_CreateItem("sword3", 1); being mudname then quantity.
Is your mudlib based on the one I wrote for thamhic? Same var and function names, and methods of storing data, by the looks of it.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #23  
Old 01-16-2007, 05:17 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
:O I haven't bothered making a mudlib using weight, never found a good algorithm for weight and speed ( movement)
__________________
Reply With Quote
  #24  
Old 01-16-2007, 05:31 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by ApothiX View Post
Is your mudlib based on the one I wrote for thamhic? Same var and function names, and methods of storing data, by the looks of it.
Kinda similar. Thamhic was used as a reference for the original mudlib but than alot of changes were made in the second version .

Kuji insisted on making all the systems on Theed. I can only touch them after he has finished. To his credit though, the new mudlib is awesome.

However, i find having each var for an item in an array quite ugly. What you could do is have a DBNPC which has items like this
mudlib.sword=itemname=Hax,somevar=hax!
or perhaps an address to a .arc which can be loaded.

Then for players, you could have muditem_2=sword, followed by any modifications/buffs. eg.
muditem_2=sword,+2fire,-50sharpness,+200rust
When accessed, mud function can return either an array of vars or an object containing the vars for use.

If anyone has any questions regarding mud systems, pm my RC on GX. Or forum pm but gx is faster.

If alot of people poke me, I'll write a guide on the wiki and my site. (though still waiting for mysql reset on my site)

Depends what you like though

Last edited by Twinny; 01-16-2007 at 06:24 PM..
Reply With Quote
  #25  
Old 01-16-2007, 11:08 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
I don't like the idea of having the variable names in the array, considering arrays get cut off after a certain point. If I did that I'd make all variable names only 4 characters to limit length.

For weight, I have the function mud_calculate() to parse all the items for values you need, when it gets the total weight it sets that in clientr strings, then the total weight is applied in the movement system somewhere.

I'm still kinda iffy about using Objects for the mud items or anything since I don't know exactly how they work with the server and don't want to spend time trying to find out, its just easier for me to use the function mud_getitemvar() or mud_getitem().

Also on Aeon, because the default Graal Q-Menu is not in use, I renamed all Weapons so simple letter-only names so they don't require quotes or makevar() to be referenced: MudItems, System, SystemGuiFactory, GuiInventory, GuiHud, etc. None of those slashes or anything else, and I love it that way
__________________

Last edited by Inverness; 01-16-2007 at 11:18 PM..
Reply With Quote
  #26  
Old 01-17-2007, 12:50 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Twinny View Post
Kinda similar. Thamhic was used as a reference for the original mudlib but than alot of changes were made in the second version .

Kuji insisted on making all the systems on Theed. I can only touch them after he has finished. To his credit though, the new mudlib is awesome.

However, i find having each var for an item in an array quite ugly. What you could do is have a DBNPC which has items like this
mudlib.sword=itemname=Hax,somevar=hax!
or perhaps an address to a .arc which can be loaded.

Then for players, you could have muditem_2=sword, followed by any modifications/buffs. eg.
muditem_2=sword,+2fire,-50sharpness,+200rust
When accessed, mud function can return either an array of vars or an object containing the vars for use.

If anyone has any questions regarding mud systems, pm my RC on GX. Or forum pm but gx is faster.

If alot of people poke me, I'll write a guide on the wiki and my site. (though still waiting for mysql reset on my site)

Depends what you like though
It's uglier when you load the player's attributes, but a lot more organised when you are coding with it :P The architypes in my mudlib were only used as a guide when creating the items. The original plan was to have each item have slightly different stats than others of the same type. Also, the overhead of having to load the archetype file, or access some DB NPC variables would be too much if players had a lot of items.

Quote:
Originally Posted by Inverness View Post
I don't like the idea of having the variable names in the array, considering arrays get cut off after a certain point. If I did that I'd make all variable names only 4 characters to limit length.
They only get cut off if you use the default RC client to open the player's attributes. Which is why scripted RC is for the win.

Quote:
Originally Posted by Inverness View Post
I'm still kinda iffy about using Objects for the mud items or anything since I don't know exactly how they work with the server and don't want to spend time trying to find out, its just easier for me to use the function mud_getitemvar() or mud_getitem().
If you take the time to learn them while they are fresh, they will save you more time in the future.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #27  
Old 01-17-2007, 11:01 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
I really don't see how making the items Objects will help me, I already have a simple way of getting the item data, so if anyone could point this out?
__________________
Reply With Quote
  #28  
Old 01-17-2007, 11:15 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Quote:
Originally Posted by Inverness View Post
I really don't see how making the items Objects will help me, I already have a simple way of getting the item data, so if anyone could point this out?
Well it's not a big advantage I guess, but such objects can join classes and could do dynamic things. On Graal Kingdoms that is mainly used for illnesses which sit in the inventory of the player and infect other players or npcs or reduce the hitpoints each few seconds or drop some item (e.g. teeth). If such functionality is not needed then you don't need to use TStaticVar.
Reply With Quote
  #29  
Old 01-18-2007, 04:57 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
okay I;m totally lost on this archetype thing, I'm trying to understand but I can't figure out how to add one of my custom to Okies Inventory weapon. :/ Any insight?
__________________
Deep into the Darkness peering...
Reply With Quote
  #30  
Old 01-19-2007, 02:49 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
*bump*
__________________
Deep into the Darkness peering...
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:24 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.