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
  #1  
Old 12-16-2003, 08:32 PM
Kigan Kigan is offline
Banned
Join Date: Dec 2003
Posts: 92
Kigan is on a distinguished road
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.
Reply With Quote
  #2  
Old 12-16-2003, 08:48 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
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.
Reply With Quote
  #3  
Old 12-16-2003, 08:59 PM
Kigan Kigan is offline
Banned
Join Date: Dec 2003
Posts: 92
Kigan is on a distinguished road
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?
Reply With Quote
  #4  
Old 12-16-2003, 09:16 PM
CheeToS2 CheeToS2 is offline
That Guy
CheeToS2's Avatar
Join Date: Dec 2001
Location: Seattle, WA
Posts: 2,528
CheeToS2 will become famous soon enough
Send a message via AIM to CheeToS2
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)
__________________

Reply With Quote
  #5  
Old 12-16-2003, 09:19 PM
Kigan Kigan is offline
Banned
Join Date: Dec 2003
Posts: 92
Kigan is on a distinguished road
Well that stinks. Glad it's been added

Having coded for years I find myself amazingly fustrated at the amount of redundency required in GScript
Reply With Quote
  #6  
Old 12-17-2003, 07:51 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
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].
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #7  
Old 12-17-2003, 08:09 PM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
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.
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote
  #8  
Old 12-17-2003, 08:10 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
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.
Reply With Quote
  #9  
Old 12-17-2003, 08:25 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
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?
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #10  
Old 12-17-2003, 08:46 PM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
Quote:
Originally posted by GoZelda

That answers my question.
Half.
Then what are database NPCs?
NPCs that are in npc list.
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote
  #11  
Old 12-18-2003, 01:44 AM
ForgottenLegacy ForgottenLegacy is offline
-Backtoscripts-
Join Date: Aug 2003
Location: California
Posts: 289
ForgottenLegacy is on a distinguished road
Send a message via AIM to ForgottenLegacy
Quote:
Originally posted by osrs


NPCs that are in npc list.
Classes count as DB NPCs too
__________________
"The higher you fly, the harder it is to breathe."

[Kaidenn] Maybe I will somehow take control of Lance's body when he isn't looking, have him log onto Kingdoms, update one script, and leave.
[Kaidenn] And leave him exactly where I found him, unchanged and completely unnaware of what just took place the last two minutes.
[GrowlZ] Lance: You might want to lock your bedroom door tonight
Reply With Quote
  #12  
Old 12-18-2003, 02:47 AM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
No.
Reply With Quote
  #13  
Old 12-18-2003, 03:04 AM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
LOL, classes are classes, and dbnpcs are dbnpcs, that's why there's two different buttons on the RC? Meaning there is a difference?
__________________
Reply With Quote
  #14  
Old 12-18-2003, 03:13 AM
ForgottenLegacy ForgottenLegacy is offline
-Backtoscripts-
Join Date: Aug 2003
Location: California
Posts: 289
ForgottenLegacy is on a distinguished road
Send a message via AIM to 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.
__________________
"The higher you fly, the harder it is to breathe."

[Kaidenn] Maybe I will somehow take control of Lance's body when he isn't looking, have him log onto Kingdoms, update one script, and leave.
[Kaidenn] And leave him exactly where I found him, unchanged and completely unnaware of what just took place the last two minutes.
[GrowlZ] Lance: You might want to lock your bedroom door tonight
Reply With Quote
  #15  
Old 12-18-2003, 04:36 AM
xManiamaNx xManiamaNx is offline
Supreme Dictator
xManiamaNx's Avatar
Join Date: Nov 2002
Location: 127.0.0.1
Posts: 385
xManiamaNx is on a distinguished road
Send a message via MSN to xManiamaNx Send a message via Yahoo to xManiamaNx
You counted?
__________________
Maniaman

Play Maloria Now: [2.3] [3]
Maloria Website

Reply With Quote
  #16  
Old 12-18-2003, 04:42 AM
ForgottenLegacy ForgottenLegacy is offline
-Backtoscripts-
Join Date: Aug 2003
Location: California
Posts: 289
ForgottenLegacy is on a distinguished road
Send a message via AIM to ForgottenLegacy
Quote:
Originally posted by xManiamaNx
You counted?
No, it says so in rcchat when I did /stats.
__________________
"The higher you fly, the harder it is to breathe."

[Kaidenn] Maybe I will somehow take control of Lance's body when he isn't looking, have him log onto Kingdoms, update one script, and leave.
[Kaidenn] And leave him exactly where I found him, unchanged and completely unnaware of what just took place the last two minutes.
[GrowlZ] Lance: You might want to lock your bedroom door tonight
Reply With Quote
  #17  
Old 12-18-2003, 05:01 AM
TripleE TripleE is offline
Down with GK Corruption
Join Date: Jun 2003
Posts: 1,005
TripleE is on a distinguished road
Quote:
Originally posted by ForgottenLegacy


No, it says so in rcchat when I did /stats.
You didnt sence the sarcasim.
Reply With Quote
  #18  
Old 12-18-2003, 05:07 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
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)
Reply With Quote
  #19  
Old 12-18-2003, 03:37 PM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
Geez, i didn't know that #N existed.
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote
  #20  
Old 12-23-2003, 03:07 AM
Duwul Duwul is offline
Registered User
Join Date: Nov 2003
Posts: 105
Duwul is on a distinguished road
o.o

I never knew local NPCs could use warpto...:O!
Reply With Quote
  #21  
Old 12-23-2003, 10:18 AM
Termina_Owner Termina_Owner is offline
Registered User
Join Date: Oct 2003
Posts: 175
Termina_Owner is on a distinguished road
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.
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 01:05 AM.


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