Home | Purchase SimCMS | News | Star War News | Forum | FAQ | Vote | Story | Rules and Guides | List of Factions | Live Chat |
NPC Scripting

NPC Scripting Engine:

The NPC Scripting engine allows you to add life to characters, NPCs, droids and other entities within the universe. It adds functionality and conversations to these entities.

The syntax for the engine is a custom made syntax and some aspects functions similarly to other programming languages such as C++ or Javascript for advanced functionality.

Scripting Engine Features:
*Scripting complete discussions
*Customizable character portraits
*Incorporating location, character and NPC Details into your discussion with the use of wildcards.
*If Else and then commands
*Creation of modules for simplified scripting.
*Ability to create quests and global variables to be used in quests.
*Admins have ability to add scripting functions that alter character database functions(EG: Give XP, take away HP, etc..).
*Math and string functions as well as a Random function.
*Allowing text input from the player character.
*And more.

Script Locations:
You have 3 locations which can be altered by the script.

The NPC Portrait(Coming Soon)
The Discussion pane
The Options pane

The NPC Portrait can be changed at command into a stored image on the database. These can be to reflect mood or gestures from the NPC and adds life to the character.

The Discussion pane is where the NPCs as well as the characters responses will be posted while the options pane is where the user can select what to say to the NPC or what action comes next.

Starting a script:
All conversations and their options are created in a block or section. Each block begins with TAGSTART::tagname::TAGSTART and end with ::ENDTAG to close off the block. Each script must begin with the tagname Beginnings. For example, this is what a beginning NPC Scripting code would like:




Each TAGSTART::name::TAGSTART is case sensitive. So if you direct someone to TAGSTART::IceCream::TAGSTART, then you need to refer to IceCream and not icecream or ICECREAM.

Tag/Block names can not have any special characters except for the follow: Underscore_. No spaces are allowed either in a Tag/Block name.

The Discussion Pane:
In order to send output to the Discussion Pane, you will need to use the Say command to have the output spoken. There are three different variations of Say.

NPCSay - This command will initialize a comment made by the NPC.
CharSay - This command will initialize a comment made by you, the playing character.
NarSay - This command will narrate text.

The Say command always ends its syntax with ::ESC which stands for End Speech Command. The Syntax for the Say command is: SayCommand(Text to say)::EC. For example, the following will output NPC: Hello there. I am NPC.:

NPCSay(Hello there. I am NPC.)::ESC

While the following will have the character output CHAR: Nice to meet you NPC. I am Char.:

CharSay(Nice to meet you NPC. I am Char.)::ESC

And finally, the following will have ***And so NPC met CHAR for the first time.*** by the Narrator:

NarSay(And so NPC met CHAR for the first time.)::ESC

So this is what an example script might look like using what we have learned so far:


NPCSay(Hello there. I am NPC.)::ESC
CharSay(Nice to meet you NPC. I am Char.)::ESC
NarSay(And so NPC met CHAR for the first time.)::ESC


Which would have the following result in the discussion pane:

NPC: Hello there. I am NPC.
CHAR:Nice to meet you NPC. I am Char.
And so NPC met CHAR for the first time.

The Options Pane:
The options pane will dictate what happens next in your interaction with the NPC or other entity. To do that, you need to assign in between arrows, -->--> <--<--, where the next tag/block needs to be based on the choice that the user makes. You can express a saying after the arrows and close it off with ::EC. For example, If we want the player response to say I am in the mood for ice cream and then take them to the tagstart/block icecream, you would do the following:

-->-->icecream<--<--I am in the mood for ice cream.::ER

This would display simply as a clickable link that reads:

I am in the mood for ice cream.

You would then continue the conversation in the new tag:


Ending a conversation:
To end a conversation, simply create an ending tag/block and name it however you would like. The only thing you would need to do is omit a responce. So your ending Tag/Block can look like so:


or even like:

CharSay(Hi ###?GetNPCName?### , my name is ###?GetPlayerName?###.)::EC
NPCSay(Pleasure to meet you)::EC
NarSay(And so ends your introduction to ###?GetNPCName?###)::EC

But make sure you do not have a response option, otherwise the conversation is meant to continue.

Procedural programming:
The NPC Script engine is procedural, meaning that everything occurs in the order it was written. However, Say commands and response commands will always appear in the appropriate window.

Variables versus Wildcards:
The NPC Scripting engine will make use of wildcards and variables. Variables are used for conditional events while wild cards are used within a sentence that is being said on screen. For example, this would be considered a variable(<?GetNPCName?>):

if (<?GetNPCName?> == Han Solo) {
CharSay(You rotten Scoundrel!)::EC

This on the other hand would be considered a wildcard (###?GetNPCName?###), assuming the NPCs name is Han Solo:

CharSay(You are one rotten scoundrel ###?GetNPCName?###!!!)::EC

This would return:

You are one rotten scoundrel Han Solo!!!

This is the full list of current variables or wildcards that a player can use:
<?GetCharHP?> or <?GetNPCHP?> - Gets the character or NPC HP.
<?GetCharMaxHP?> or <?GetNPCMaxHP?> - Gets the Max HP a character or NPC can have.
<?GetCharXP?> or <?GetNPCXP?> - Gets the current XP for player or NPC
<?GetCharXPLevel?> or <?GetNPCXPLevel?> - Get the XP Level
<?GetPlayerName?> or <?GetNPCName?> - Returns the name of the player or NPC you are talking to.
<?GetCharFaction?> or <?GetNPCFaction?> - Will return the NPC they belong to.
<?GetCharSpecies?> or <?GetNPCSpecies?> - returns the species of the character or NPC.

To use these variables as wildcards, simply switch <? ?> with ###? ?###. For example, <?GetCharHP?> becomes ###?GetCharHP?### instead if you were to use it as a wildcard.

When referring to the variable, the value must always be surrounded by quotes, unless it is to represent a numerical value. For example, calling <?GetCharFaction?> in an IF statement would work like this:

if(<?GetCharFaction?> == Galactic Empire)
Or if you are referring to it as a numerical value, in the case of obtaining the character HP, you do not need to put the value in quotes, eg:

if(<?GetCharXP?> == 150)

Declaring Variables:
If you would like to declare your own variables to use, you may simply surround a variable name with vardec::variable name::vardec. So you can declare the variable: UserSpokenTo as this:

To use the variable later on, you will need to address it like any other variable, like so:


You may also give the variable a value as well like so:

vardec::UserSpokenTo = 1::vardec

This will assign a value of 1 to the user.

Variables that are declared are case sensitive and the only special character they can use is underscore_. Numerical values that are strictly numerical and not meant to be used as text must be declared and called without quotes. EG:

When declaring: vardec::<?UserSpokenTo?> = 1::vardec
When calling the variable: if(<?UserSpokenTo?> == 1)

If it is a text that will be in the variable, then the value must be in quotes, eg:

vardec::<?UserSpokenTo?> = Han Solo::vardec

Internal values can be written however you wish. However, you should avoid the use of quotes within the values themselves, eg:

vardec::<?SpokenPhrase?> = The fox said Hello! and then ran away::vardec

If you still wish to use quotes, then make sure they follow a \ , eg:

vardec::<?SpokenPhrase?> = The fox said \Hello!\ and then ran away::vardec

You can always declare the variable and declare a value for it later on. If you declare a value later on, you must close off the operation with ::EA. EG:

<?CustomCharName?> = Han Solo::EO

Declaring Custom Wildcards:
A custom wild card can only be an already declared variable. Otherwise it will not have a result and may produce an error in your script. Errors may result in an empty conversation window. Once a variable is declared you may use it as a wildcard in a sentence by encapsulating it in ###?variableOrWildcardName?### so the variable UserSpokenTo would look like this as a wildcard:


The NPC Scripting engine can use conditionals such as If, Else or even Else If. To any conditional, you must have a condition to meet and then an action to perform. So your syntax for declaring an IF Statement would look like so:

if(<?UserSpokenTo?> == 1) {
if the UserSpokenTo variable has a value of 1, then perform an action

So an example would be like the one mentioned earlier:

if (<?GetNPCName?> == Han Solo) {
CharSay(You rotten Scoundrel!)::EC

If the NPCs name is Han Solo, then your character would call him a rotten scoundrel. If the value was anything other than Han Solo, you would use an Else statement then to continue the or Else If, much the same way you would use it in C++ or Javascript:

if (<?GetNPCName?> == Han Solo) {
CharSay(You rotten Scoundrel!)::EC
} else if (<?GetNPCName?> == Luke Skywalker) {
CharSay(The force is strong with you!)::EC
}else {
CharSay(You are just an ordinary person)::EC

If the character is called Han Solo, he will be referred to as a scoundrel. If it is Luke Skywalker, he will be told the Force is strong with him. For everyone else, you will be told youre ordinary.

Operators are used in accord with variables. You have two types of operators you can use: Arithmetic and Comparison. Arithmetic operators are used to alter the value of a variable. Comparison operators are used to compare the value of a variable. All arithmetic operations must be closed with ::EO.

For example:

The plus sign can concactinate two strings together or it can add the value of two variables together.Example of adding values together:

<?CharCustomHP?> = 3 + 4 ::EO

Now the value of <?CharCustomHP?> Becomes 7. You can also do it this way:

<?CharCustomHP?> = 2::EO
<?CharCustomHP?> = <?CharCustomHP?> + 2::EO

Now the value of <?CharCustomHP?> would be 4. To concactinate two strings, it is the same format, but the values would be surrounded by quotes like so:

<?CharCustomSaying1?> = Hello there.::EO
<?CharCustomSaying2?> = <?CharCustomSaying?> + I am John!::EO

Now you would have a value of Hello there. I am John!.

All other arithmetic operators must be used for math:

Minus - is for subtraction
Asterisk * is for multiplication
Backslash / is for division

As far as a comparison operators go, you may use the following:

== which means is equal to, eg: <?CharName?> == Han Solo
!= means not equal to, EG: <?CharName?> != Han Solo. - character is not Han.
< Less than: EG: <?CharHP?> < 25 - means the characters HP is less than 25
> More than, same as above, just the opposite value.
<= Less than or equal to
=> More than or equal to.

Comparison operators are mostly and specifically used in if, else and else if statements.

E-mail Or Handle: Password:

Forgot Password
Galactic News Network
Galactic Date
Year: 318 SWC Time

Social News
War News
Eco News
General News