2604 active members
  133 are online
Year Day Time
15 329 1:30:30
Guest Login
snewsgnewsmessagegeneralfactioninventorycombatroom
» General
    Character Creation | Movement | Vision | NPCs | Communication | Last Updated: Year 13 Day 175
  NPCs | Parties | Tutorial NPCs | Military NPCs | Civil NPCs | Scripts |
NPC scripts
All NPC conversations within the game are controlled by a scripting system. Most NPC scripts are written by the NPC team, however Custom NPCs can have their scripts customized by players. This page details how to use the scripting system.
You can access the NPC script editor through the NPC Inventory, any custom NPCs that you have permission to edit the scripts for will have an Edit Script link available.
The basic building block of a script is the block. The conversation starts at a block, and jumps between blocks. Each block represents one step in the conversation.

A block has a name, comprising of alphanumeric characters. The starting block is named start, and must exist within the script.

This is the simplest script you can create. The NPC will say "Hello World!" then finish.

Example
Block: start
Hello World!
In order to create a conversation tree, you need multiple blocks and responses. This is an example of such a tree:

Example
Block: start
How are you today?
Responses:
 I'm good -> good
 I'm poor -> bad

Block: good
That's great!

Block: bad
What a shame.
You can have as many responses as you like, however responses must point to valid blocks, and response block names should not contain wildcards. You can recurse to previous blocks to create loops.
This is a more complete script, however it does not use any advanced techniques below. It is advised to understand these scripts before continuing. Example
Block: start
 Hello
 How are you?
Responses:
 I'm Good -> good
 I'm bad  -> bad

Block: good
 That's great to hear!
 I'll talk to you later!

Block: bad
 That sucks!
 Let me cheer you up!
 How do you feel now?
Responses:
 I'm Good -> good
 I'm bad  -> stillbad

Block: stillbad
 Oh well, nothing I can do then!
Note the indentation is for clarity of reading, and is not required. "Block" commands must be on their own line. "Responses" must be on their own line, and each response must be on its own line. The responses section is optional.

Avoid using HTML within the script, as it is heavily filtered. Attempting to use the scripting system to gain intel or hack through means such as XSS or JS injection will be punished.
In order to make the experience more interactive, scripts provide wildcards to allow you to customize the conversation depending on the environment.

To use a wildcard, you simply put percentage marks around it.

Example
Block: start
How are you, %character.name%?
The following is a list of wildcards available and a description of what they do.

Wildcard Description Example Default For Custom NPCs?
 %npc.name% NPC's name Joe Bloggs N/A Yes
 %npc.race% NPC's race Nautolan N/A Yes
 %npc.infofield% NPC's infofield Master Carpenter N/A Yes
 %npc.gender% NPC's gender Male N/A Yes
 %npc.formal% NPC's formal greeting Sir/Ma'am N/A Yes
 %npc.ally% is NPC IFF friendly? N/A N/A Yes
 %npc.enemy% is NPC IFF enemy? N/A N/A Yes
 %npc.neutral% is NPC IFF neutral? N/A N/A Yes
 %npc.unharmed% is NPC unharmed? N/A N/A Yes
 %npc.slightlywounded% is NPC slightly wounded? N/A N/A Yes
 %npc.wounded% is NPC wounded? N/A N/A Yes
 %npc.badlywounded% is NPC badly wounded? N/A N/A Yes
 %character.name% Character's handle Clarr Solo N/A Yes
 %character.race% Character's race Human N/A Yes
 %character.infofield% Character's 1st infofield Emperor Empty String Yes
 %character.infofield2% Character's 2nd infofield 1st Recon Division Empty String Yes
 %character.infofield3% Character's 3rd infofield 2nd Expansionary Fleet Empty String Yes
 %character.gender% Character's gender Male N/A Yes
 %character.unharmed% is Character unharmed? N/A N/A Yes
 %character.slightlywounded% is Character slightly wounded? N/A N/A Yes
 %character.wounded% is Character wounded? N/A N/A Yes
 %character.badlywounded% is Character badly wounded? N/A N/A Yes
 %character.formal% Character's formal greeting Sir/Ma'am N/A Yes
 %character.faction% Character's current faction New Republic Freelance Yes
 %character.isowner% Is character the owner of the NPC Produces no output Empty String Yes
 %character.ismanager% Is character the manager of the NPC Produces no output Empty String Yes
 %character.issupervisor% Is character the owner of the NPC Produces no output Empty String Yes
 %faction.name% Character's faction's name New Republic Empty string (if freelance) Yes
 %faction.type% Character's faction's type Mining Empty string (if freelance) Yes
 %faction.leader% Character's faction's leaders name Ellias Empty String (if freelance) Yes
 %faction.website% Character's faction's leaders name http://swcombine.com (Link) Empty string (if freelance) Yes
 %owner.name% Name of the NPC's owner Darkness Empty string if special owner (Market, None) Yes
 %owner.entityType% Type of the NPC's owner Faction or Character Empty string if special owner (Market, None) Yes
 %character.infofield% Owner's 1st infofield Emperor Empty String Yes
 %character.infofield2% Owner's 2nd infofield 1st Recon Division Empty String Yes
 %character.infofield3% Owner's 3rd infofield 2nd Expansionary Fleet Empty String Yes
 %location.city% Current city name City 327 Unknown Yes*
 %location.planet% Current planet name Glee Anselm Unknown Yes*
 %location.system% Current system name Danju Unknown Yes*
 %location.sector% Current sector name Tapani Unknown Yes*
 %location.destination% Destination name "Corellia sector" (if deep space)
"Corellia system" (if heading to that system)
"Corellia planet" (if heading in sublight)
"Atmosphere (3,4) of Corellia" (if heading in atmo)
"Ground (3,4) of city Cityname on Corellia" (if heading to ground in city)
"Ground (3,4) at (4,7) on Corellia" (if heading to ground outside a city)
Unknown Yes*
 %location.eta% ETA for current travel 3 days, 24 hours and 5 minutes Unknown Yes*
 %container.name% Current container name, e.g. the ship or vehicle standing in Tydirium Unknown Yes
 %container.type% Current container type, e.g. the ship or vehicle standing in Lambda Shuttle Unknown Yes
 %container.entityType% Current container entity type, e.g. the ship, vehicle, city, planet, station Ship, Vehicle, City, Planet, Space Station N/A Yes
 %cgt.year% Gets current CGT year 12 N/A Yes
 %cgt.day% Gets current CGT day 183 N/A Yes
 %time.ofday% Gets current phase of day Morning, Afternoon, Evening N/A Yes
Entries with a "Yes" are available for custom NPCs. Entries with a "Yes*" may have some limitations on their use (e.g. they may not be available when the NPC cannot reliably determine the information without godmodding - for example location whilst in hyperspace).
Some wildcards may be unavailable in some situations. In order to get around this, we have several simple branching instructions.

Putting the wildcard in exclamation marks rather than percentage marks will delete the line it appears on if the wildcard cannot be resolved. For example:

Example
Hi!
I am in a city named !location.city!
I am on a planet named !location.planet!
Will conditionally print out the last two lines if and only if they are in a city or on a planet.

E.g. If on a planet but not in a city, it would print this:

Example
Hi!
I am on a planet named Coruscant
Because the city line was removed using the conditional wildcard syntax.
You can use !if wildcard! and !ifnot wildcard! as a conditional. Example
!if location.system! I'm in a system
!ifnot location.system! I'm in deep space
Will produce "I'm in a a system" when within a system, and "I'm in deep space" when not in a system. Note this works much like the conditional wildcard in that if the check fails, the entire line gets deleted.

You can stack them.

Example
!if location.system! !ifnot character.faction! Are freelancers allowed in this system?
!if location.system! !if character.faction! Does your faction control this system?
Will produce two different results if within a system depending on if the character has a faction or not. It will produce no output if the character is not within a system.

You can do conditional responses on wildcards. For example: Example
Block: start
Hello.
Responses:
 So, how about !location.city! huh? => city
 !if location.city! Gee this is a nice city => city
Both are functionally the same, they will only allow proceeding if the character is within a city. If the character is not within a city no conversation options will be shown.
You can extend the !if wildcard! syntax to match specific things.

Example
!if character.race=Gungan! Don't slip over!
!if character.race=Human! Humans are the best!
!ifnot character.race=Human! Alien scum!
Note that this would not work as intended, as Coruscanti, Hapans, etc are all humanoid, but aren't "Humans". To solve this problem use the if in syntax.

Example
!if character.race in [Gungan, Dug, Hutt]! Filthy slime.
!ifnot character.race in [Gungan, Dug, Hutt]! Carry on.
If you wish to have "actions" within your script, for example situations where the player or NPC does something, use asterisks.

Example
Would you like a drink?
*The bartender reaches over and pours a glass of the finest ale*
Actions will be rendered in red italics.
You can achieve randomness in your scripts by using the random modifier.

Example
Take that you !random [slime, poodo, wermo]!
Will pick one of the three values within the list and display it, randomly each time.

You also have the capability for a seeded random generator.

Example
Take that you !seed [slime, poodo, wermo]!
Will pick a one of the values from the list, based on the NPC that is running the script.

E.g. NPC A will always print out "Take that you slime" and NPC B will always print out "Take that you poodo", because it is seeded by the NPC's ID.

This way you can write one script with seeded randomness and apply it to many NPCs and get a varied response from each NPC, yet it will remain consistent between speech sessions.

You can use randomness within the responses section.

Example
Block: start
Hi!
Responses:
!random [response1, response2, response3]! -> How are you?
Will randomly divert the player to one of three response blocks each time they speak to the NPC.