[Question]NPC Dialogue from Ini

08/11/2010 14:19 Beta Limit#1
Ok so ive been messing with NPC dialogue, trying to find a good way to load them and make them editable while the server is running.

Using COSX 5065 (i think) ive managed to load npc dialogue from an ini, and they are editable while the server is running BUT i still have the NPC options cases still hard coded.

Would it be a good idea to keep these hard coded (limiting the edit-ability to just the text)

Or should i go for a full rewrite of the npc dialogue area.

This is based on a crappy source but if i can implement it i can put it into a better source or release it.

How would i go about De-hard coding the options case or make it adaptable to as many options i write into the ini.

Any help, comments etc. is appreciated.
08/11/2010 17:49 Basser#2
Id rather use something different than INI files, and use a very basic script language.
Which reads dialogs and actions such as Command("@tele x y id"); which would teleport.
Depending on your skill of course.
You could also create for instance VB files and use the VB syntax, and create a parser for it, which will read the VB syntax / script syntax.
08/11/2010 18:29 CptSky#3
The INI File isn't a good idea. To combine the external and the internal system, it's a good idea. As Basser said, for your external system, a script language will be faster and better. Personaly, I use a binary structure.

The binder is if you want the option selected. The page is like all the possibility of the option.
Code:
if (Binder == 0)
{
    if (Page[0].Req == OK)
    {
        ...
    }
}
Code:
Char[3] -> Identifier
Int32 -> UniqId
Char[32] -> Name
Int16 -> Face
UInt8 -> Binder Count
**** Binder Start ****
UInt8 -> Page Count
*** Page Start ***
UInt8 -> Requirement Count
UInt8 -> Reward Count
UInt8 -> Option Count
** Requirement Start **
UInt8 -> Type
UInt8 -> Operator
Boolean -> IsString
if (true)
   Char[32] -> Value
else
   Int32 -> Value
** Requirement End **
** Reward Start **
UInt8 -> Type
UInt8 -> Operator
Boolean -> IsString
if (true)
   Char[32] -> Value
else
   Int32 -> Value
** Reward End **
Boolean -> Text Exist
if (true)
{
   Int16 -> Length
   Char[] -> Text
}
** Option Start **
UInt8 -> UniqId
UInt8 -> Length
Char[] -> Text
** Option End **
*** Page End ***
**** Binder End ****
08/11/2010 19:21 Beta Limit#4
Quote:
Originally Posted by Basser View Post
Id rather use something different than INI files, and use a very basic script language.
Which reads dialogs and actions such as Command("@tele x y id"); which would teleport.
Depending on your skill of course.
You could also create for instance VB files and use the VB syntax, and create a parser for it, which will read the VB syntax / script syntax.
Well i dont know VB; wouldnt that require me to compile it each time i add something?

Quote:
Originally Posted by CptSky View Post
The INI File isn't a good idea. To combine the external and the internal system, it's a good idea. As Basser said, for your external system, a script language will be faster and better. Personaly, I use a binary structure.

The binder is if you want the option selected. The page is like all the possibility of the option.
Code:
if (Binder == 0)
{
    if (Page[0].Req == OK)
    {
        ...
    }
}
Code:
Char[3] -> Identifier
Int32 -> UniqId
Char[32] -> Name
Int16 -> Face
UInt8 -> Binder Count
**** Binder Start ****
UInt8 -> Page Count
*** Page Start ***
UInt8 -> Requirement Count
UInt8 -> Reward Count
UInt8 -> Option Count
** Requirement Start **
UInt8 -> Type
UInt8 -> Operator
Boolean -> IsString
if (true)
   Char[32] -> Value
else
   Int32 -> Value
** Requirement End **
** Reward Start **
UInt8 -> Type
UInt8 -> Operator
Boolean -> IsString
if (true)
   Char[32] -> Value
else
   Int32 -> Value
** Reward End **
Boolean -> Text Exist
if (true)
{
   Int16 -> Length
   Char[] -> Text
}
** Option Start **
UInt8 -> UniqId
UInt8 -> Length
Char[] -> Text
** Option End **
*** Page End ***
**** Binder End ****
i have no idea what this is lmao
08/12/2010 23:09 _tao4229_#5
If you're on MSN i'll help you (that means get on).
09/10/2010 20:15 sorengwapo11#6
where can i find the npcdialog,cs ?? plzz answer..
09/11/2010 02:05 pro4never#7
My server is using full C# syntax stored as .npc files which are debugged and executed at runtime when requested (that way if there are errors it's not executed which would cause crashing/issues)
09/11/2010 04:22 Santa#8
Quote:
Originally Posted by pro4never View Post
My server is using full C# syntax stored as .npc files which are debugged and executed at runtime when requested (that way if there are errors it's not executed which would cause crashing/issues)
^^ Fail.
09/11/2010 05:11 -Fáng-#9
Hm.. well I'm working on mine being full MySQL. Spawns through a MySQL and loads dialogs through MySQL. That way when someone comes and says "this NPC has a spelling mistake!", you can edit it without taking down the server! =o

Good idea or... bad idea? lol
Because I've never made an NPC System!
09/11/2010 05:15 pro4never#10
Problem with npcs based on sql is that it's SO much harder to do complex npcs that way....

sql is not exactly a friendly scripting language...

personally I'd chose .ini files over that any day with basic functions for checking things...

IronPython is the best option according to saint. The way me and Schmidty were doing it apparently causes memory leaks if done incorrectly... so yah... iron python or something similar is a great way to do things. External scripts ftw
09/11/2010 06:49 Santa#11
Quote:
Originally Posted by pro4never View Post
Problem with npcs based on sql is that it's SO much harder to do complex npcs that way....

sql is not exactly a friendly scripting language...

personally I'd chose .ini files over that any day with basic functions for checking things...

IronPython is the best option according to saint. The way me and Schmidty were doing it apparently causes memory leaks if done incorrectly... so yah... iron python or something similar is a great way to do things. External scripts ftw
You have to admit, my way was pretty good until Dream-Crusher came into play =p
09/11/2010 07:01 -Fáng-#12
Quote:
Originally Posted by pro4never View Post
Problem with npcs based on sql is that it's SO much harder to do complex npcs that way....

sql is not exactly a friendly scripting language...

personally I'd chose .ini files over that any day with basic functions for checking things...

IronPython is the best option according to saint. The way me and Schmidty were doing it apparently causes memory leaks if done incorrectly... so yah... iron python or something similar is a great way to do things. External scripts ftw
The only problem with ini files: "file in use" errors (rare but annoying).
I think i'm going to code the less demanding NPCs with the MySQL database then... and figure out something for the others. Thanks! =]
09/11/2010 07:17 Arcо#13
Quote:
Originally Posted by -Fáng- View Post
The only problem with ini files: "file in use" errors (rare but annoying).
I think i'm going to code the less demanding NPCs with the MySQL database then... and figure out something for the others. Thanks! =]
o.O
Make sure no other process is using the file?
Not that big a problem.
09/11/2010 07:23 pro4never#14
Quote:
Originally Posted by .Arco View Post
o.O
Make sure no other process is using the file?
Not that big a problem.
He just needs to queue the npc or lock access until current operation is finished. if multiple people are trying to use the same npc during the same fraction of the second it can give errors such as that.

It's VERY unlikely and very simple to fix... not really much of an issue.
09/11/2010 07:51 -Fáng-#15
Quote:
Originally Posted by pro4never View Post
He just needs to queue the npc or lock access until current operation is finished. if multiple people are trying to use the same npc during the same fraction of the second it can give errors such as that.

It's VERY unlikely and very simple to fix... not really much of an issue.
Kinda like what I did with the SaveCharacter problem I guess.
Well I'll look into it more I guess as an option. Thanks =]