PDA

View Full Version : NPCS, Classes Weapons.


PrinceOfKenshin
06-13-2007, 06:01 PM
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)
AK47=AK47,gun,at_ak47-icon1.gif,automatic,clipinfo,1,AK47

and in the classes you have all the information for the gun.

this.gun.AK47 = {"AK47", "at_ak47-", "at-newbullet", "Rifle Ammo", false, false, 0.3, 0.1, 1.5, -.10, 1, 0, 0.4, 0.4, {{0,0},{-1.8,-.6},{0,0},{1.8,-.6}}, {{{.5,0},{-.5,0}}, {{-.7,-1.35},{-.5,-1}}, {{-.5,0},{.5,0}}, {{.7,-1.35}, {.7,-.7}}}};

And in the weapons you have the main script for the gun that makes it fire, reload and all that good stuff.

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?

killerogue
06-13-2007, 06:20 PM
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.

killerogue
06-13-2007, 06:33 PM
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.

Admins
06-13-2007, 08:05 PM
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?
Those are not really the same:
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.

killerogue
06-13-2007, 08:53 PM
Explanation

I need say no more. xD

PrinceOfKenshin
06-14-2007, 01:21 AM
Thanks a lot Stefan that was a really good explanation = )

TheJames
06-14-2007, 07:39 AM
Haha... Wowzers. I think me and Mike should tweak our Inventory system now! :). Thanks Stefan

killerogue
06-14-2007, 01:48 PM
No, you should make it an object based mudlib.

Chompy
06-14-2007, 02:34 PM
No, you should make it an object based mudlib.

Depends :)

TheJames
06-14-2007, 04:55 PM
Mudlibs arnt all they are cracked up to be, our DB is perfectly fine now :)

killerogue
06-14-2007, 05:52 PM
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.

zokemon
06-14-2007, 08:14 PM
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.

Mudlibs are nice but aren't always appropriate. Some people use systems that would be much more efficient without them.

killerogue
06-14-2007, 08:51 PM
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.

Inverness
06-15-2007, 02:15 AM
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.
Mudlibs are nice but aren't always appropriate. Some people use systems that would be much more efficient without them.
Examples?