![]() |
NPCS, Classes Weapons.
Well i know this sounds stupid. But i never understood what goes where.
I know in Classes instead of having the script in a level you make a class and just call the class from the level. And for weapons i know you add weapons to a player. and NPCs are databases. I also know that in NPCs you can store items. Such as a gun. (on atrius) PHP Code:
PHP Code:
But i don't understand How i can add other things like a medkit (just an example.) I don't know if i should put it in all three (npc,class,weapons) or just weapons and npc. Can someone explain this to me? |
Well, first of all the way the item systems are set up on Atrius is rather....stupid. Having first hand experience. You don't want to follow how anything is set up there.
But you'd be better off with the use of objects. And not holding information for each weapon in it's own respective class. I'll be back with a better explanation in a few moments. I'm a bit busy atm. |
Ok.
Now, what I was trying to touch up on earlier. Is it's better to use objects to store your information because objects are so flexible and pliable. You can add objects to arrays, then the objects you have in arrays, can have objects as vars inside that object in an array. So in essence you can store many, many pieces of information starting with one object. If you will, go download Inverness' two Object-Based Mudlibs he released on the forums. They're both quite confusing at times but very good learning tools if you're interested in objects. IT's all really a matter of transfering variables of objects to other objects and then to strings and then all back again. It's quite fun. :] If you'd like some one on one assistance you're free to AIM me. |
Quote:
NPCs and Weapons are objects. Objects can have attributes (script variables) and can have a script. Classes (in Graal) are a collection of script functions which you can attach to an object by letting the object join the class. So you expand the script of the object. Items are mainly a collection of script variables to know what items the player has and how they look like. They are most of the time stored in script variables of the player (clientr.) To make an item system you also need to define the item templates - a list of items which can be created. These are most of the time defined in the script variables of a db npc. When you add an item to a player you then copy the item template or only copy important data, e.g. copy the icon of the weapon, but don't copy the strength since you only need it on serverside. More advanced item systems store items separately from the player, e.g. in files. When loading those item files then you can create an own object for each item (new TStaticVar) and load the item variables into the script variables of that object. You can then also let the item object join classes, e.g. you create classes for weapons and food items and add in both classes a function apply() which then either changes the look of the player when applying the weapon, or adds food points when applying the food. For clientside things you still need weapons. Most of the time each item template has an own weapon (sword, axe, dagger etc.). On the old classic servers each item was actually a weapon, in modern servers the weapons are managed by a System script which activates the right weapon script depending on which item you have equipped. That way you can reuse the "Sword" weapon for different sword items. |
Quote:
|
Thanks a lot Stefan that was a really good explanation = )
|
Haha... Wowzers. I think me and Mike should tweak our Inventory system now! :). Thanks Stefan
|
No, you should make it an object based mudlib.
|
Quote:
|
Mudlibs arnt all they are cracked up to be, our DB is perfectly fine now :)
|
Actually, yes they are. It isn't all it's cracked up to be to YOU. Because you probably couldn't get it to work Mr. Switcheroo.
|
Quote:
|
Mudlibs aren't even used properly on Graal, according to Skyld. But from my own experienced Mudlibs normally control EVERYTHING in a normal MMORPG game.
|
Object-based is the way to go for efficiency. If only we had custom object types that could be alot better.
I have yet to find that perfect unifying system unfortunately. Also, something I just noticed, when using getVarNames() it got the function too, nearly pulled out my hair in frustration. Quote:
|
| All times are GMT +2. The time now is 03:29 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.