Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Classes? (https://forums.graalonline.com/forums/showthread.php?t=49700)

Kigan 12-16-2003 08:32 PM

Classes?
 
Alright. I haven't been scripting in a while but decided to pick it up again. I started playing with mouse stuff and replacement status displays, menus, etc. and it seems simple enough.

I know that Stefan calls something on NPC server "classes" are these really classes as in objectorientedness? If so how do you declair a class and it's methods etc? If GScript were objectoriented it would be much eaiser to do a lot of cool stuff. :)

Loriel 12-16-2003 08:48 PM

Nope.
You can put scripts into units that are called classes. NPCs can join these classes using the 'join classname;' statement, obviously (which should be put outside of any block). These classes are then linked with the NPCs joining them as if they were a part of the main NPC's script. The NPC can call functions from the class, and the other way around, and events in the class get executed just as if you had placed them directly in the NPC.
The advantage is easier maintenance, and less memory use because code is not duplicated for multiple NPCs.

Kigan 12-16-2003 08:59 PM

So it's like pesudo-class. Gottcha.

I haven't tried this yet, but can you pass arguments to function calls? If so what's the syntax?

CheeToS2 12-16-2003 09:16 PM

Quote:

Originally posted by Kigan
So it's like pesudo-class. Gottcha.

I haven't tried this yet, but can you pass arguments to function calls? If so what's the syntax?

you'll be able to in v3. Right now you can only set variables, call the function, then use the variables in there (all this.vars are global for the npc they're created in)

Kigan 12-16-2003 09:19 PM

Well that stinks. Glad it's been added :D

Having coded for years I find myself amazingly fustrated at the amount of redundency required in GScript :)

GoZelda 12-17-2003 07:51 PM

Aren't they often called database-NPCs?

Anyway, yeah it's a NPC stored in the NPCserver which then can be 'called' [with certain variables i believe].

osrs 12-17-2003 08:09 PM

Quote:

Originally posted by GoZelda
Aren't they often called database-NPCs?
If you are saying that classes npcs are often called as database npcs, you're wrong. Database NPCs & classes npcs are different things.

Loriel 12-17-2003 08:10 PM

Quote:

Originally posted by CheeToS2
Right now you can only set variables, call the function, then use the variables in there
It is probably worth to mention that non-this. vars, meaning things like 'i' or 'foo' or whatever, are not shared with classes - afaik, at least.

And osrs is right.

GoZelda 12-17-2003 08:25 PM

Quote:

Originally posted by osrs


If you are saying that classes npcs are often called as database npcs, you're wrong. Database NPCs & classes npcs are different things.

That answers my question.
Half.
Then what are database NPCs?

osrs 12-17-2003 08:46 PM

Quote:

Originally posted by GoZelda

That answers my question.
Half.
Then what are database NPCs?

NPCs that are in npc list.

ForgottenLegacy 12-18-2003 01:44 AM

Quote:

Originally posted by osrs


NPCs that are in npc list.

Classes count as DB NPCs too

Loriel 12-18-2003 02:47 AM

No.

ZeLpH_MyStiK 12-18-2003 03:04 AM

LOL, classes are classes, and dbnpcs are dbnpcs, that's why there's two different buttons on the RC? Meaning there is a difference?

ForgottenLegacy 12-18-2003 03:13 AM

NPC Code:

#N(index) --Gets the name of the current DB NPC--


That message code got the name of the class when I used it in a class.

When I do /stats and it says:
DB NPCs: 2017

Babylon does NOT have 2017 DB NPCs in our NPC List. That number is how many NPCs are either joining a class, or are a class.

xManiamaNx 12-18-2003 04:36 AM

You counted? :megaeek:

ForgottenLegacy 12-18-2003 04:42 AM

Quote:

Originally posted by xManiamaNx
You counted? :megaeek:
No, it says so in rcchat when I did /stats.

TripleE 12-18-2003 05:01 AM

Quote:

Originally posted by ForgottenLegacy


No, it says so in rcchat when I did /stats.

You didnt sence the sarcasim.

Python523 12-18-2003 05:07 AM

Quote:

Originally posted by ForgottenLegacy
NPC Code:

#N(index) --Gets the name of the current DB NPC--


That message code got the name of the class when I used it in a class.

When I do /stats and it says:
DB NPCs: 2017

Babylon does NOT have 2017 DB NPCs in our NPC List. That number is how many NPCs are either joining a class, or are a class.

Please, do not say such a thing unless you know for sure. The number is so high is because putnpc2 npcs are considered DB NPCs (which is why they have the ability to warp)

osrs 12-18-2003 03:37 PM

Geez, i didn't know that #N existed. :whatever:

Duwul 12-23-2003 03:07 AM

o.o
 
I never knew local NPCs could use warpto...:O!

Termina_Owner 12-23-2003 10:18 AM

They don't. Putnpc2 doesn't make a local NPC, it's making a global NPC.... Like, for instance, the ships on GK isn't Database NPCs, each of them is a putnpc2 variable (except the Ferries, they run by a DB NPC themselves)

The differance between classes and Database NPCs is that:

Classes aren't NPCs, they are only excistant by the pure fact that they are used by NPCs

Database NPCs are NPCs on thier own. They aren't attached to levels as other NPCs are, and they can travel. (Thus, when you update a level, putnpc2 aren't wiped out because they aren't part of the level, however you could use /clearnpcs levelname and clear only the putnpc2's out, and not the npcs)

Hope that clairfies.


All times are GMT +2. The time now is 10:46 PM.

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