Neverwinter Nights - Binding Stone Tutorial

Overview

The goal of this tutorial is to create a Binding Stone, similar to the ones found in Dark Age of Camelot. When a player "uses" the stone they become bound to that stone. They can also be told where they are currently bound as well as get an overview of the purpose of Binding Stones. The way I've scripted it below you can easily create Binding Campfires, Binding Potted Plants, etc.

Updates

2002.07.01
  • Added OnClientEnter script to bind player to a default bind point. This prevents players from refusing to bind and being able to respawn where they die.
  • Object won't start conversation if you're already bound to it. It just let's the player know they are bound to that location.
  • Started refering to the player character as oPC instead of oPlayer since that's more correct.

Binding?

For those who don't know: in EverQuest and Dark Age of Camelot there is a concept called Binding. When you bind a character to an area or object he'll respawn at that place the next time he dies. Generally there are binding points/stones in major cities or other important locations.

Some of this code was taken from/inspired by the Official Worldbuilder Guide. It is an invaluable book. Go buy it. Now.

Create a template for the object the player will bind to

First we need to create a template for the object we will be placing throughout our world for the player to bind to. Once created and scripted we can place copies of this object through the module, being sure to give them each a unique name and tag. In the tradition of Dark Age of Camelot I'll be making a Binding Stone.

  1. Open the editor and load your module.
  2. Click the Paint Placeable Objects button on the right side.
  3. Click the Custom button that now shows up.
  4. Right-click on Miscellaneous and choose New.
  5. Choose Miscellaneous and click Next.
  6. Enter a name for the blueprint. In my case I'm going to call it Binding Stone. Then make sure Launch Properties Dialog is checked and click Finish.
  7. In the Basic tab check both Plot and Usable. Plot makes the item indestructable. Then change the Appearance Type to whatever you want your binding object to look like. In my case I'm going to use Boulder. It's nice a big and noticable. We can enhance it more later. Merchant's Shingle - 4 might also work nicely.
  8. Under the Lock tab uncheck Can Be Locked. You probably don't want people locking your binding stones.
  9. Under the Advanced tab you probably want to set the Faction the Binding Stone belongs to. In my case I'm choosing Commoner.
  10. Under the Description tab you'll want to give the object a generic description. This is what the player will see when they Examine it.
  11. Leave the Placeable Objects Properties window open.

Create the script that kicks off the "conversation"

As I said above we want to offer the player a few options when they use the Binding Stone. I figured the best way to do that is to give the object a conversation in which the different answers do different things. Note: As far as I can tell simply giving the object a Conversation under the Advanced Tab doesn't seem to work for some reason. So I've created the following "solution" to the problem.

With the Placeable Objects Properties still open click on the Scripts tab. Depending on the object you picked some of the scripts might be set already. Your probably want to clear them all. We're only worried about the OnUsed script. Make sure it's clear and click Edit. Copy and Paste the following code into the window:

pws_binding

Then click Save and use pws_binding as the name. Then clck Exit in the lower right and the click OK to close the Placeable Objects Properties window.

Create the dialog that object will "speak"

Now we need to create the conversation that the above script is going to call. I don't feel like going nuts with instructions on how to create Conversations so I'll just post a screenshot of how the general conversation should look. I'll leave it as an exercise for the read to recreate the flow. Go buy the Official Worldbuilder Guide. Buy two. Leave one in the bathroom.

I will tell you what you need to kick off where though.

Click on the Yes leg of the conversation and then on the Action Taken tab in the bottom right section of the Conversation Editor. Click on Edit and Copy and Paste the following code in:

pws_bind

Then click Save and use pws_bind as the name. Then clck Exit in the lower right.

This script does the actual bindning work. It sets a variable (BindPoint) on the player which is the tag of the stone they are binding to. It does a nifty little visual effect and then speaks to let them know they've been successfully bound. It's VERY IMPORTANT that when you place each Binding Stone you give it a unique tag and name. If two stones have the same tag then you'll never know which stone the player will end up respawning at.

Now click on the Where am I currently bound to? leg of the conversation, then on the Action Taken tab in the bottom right section of the Conversation Editor. Click on Edit and Copy and Paste the following code in:

pws_bindreport

Then click Save and use pws_bindreport as the name. Then clck Exit in the lower right.

This script basically looks for the variable we set in the pws_bind script. If it exists we tell the player where they were last bound to. If not, we say we don't know.

Click Done to close the Conversation Editor.

Create the script that respawns the character at their last bind point

Now for the script that seals the deal. When a player dies we want them to respawn at the stone they last bound to. Go into the Edit Menu and choose Module Properties. In the Events tab clear the OnPlayerRespawn entry, click Edit and Copy and Paste the following code:

Module : OnPlayerRespawn

Then click Save and use pws_respawn as the name. Then clck Exit in the lower right.

The top half of the script is standard NWN code. Raise the player, heal em and remove and nasty effects. After that we look to see if the player has a bind point stored and if so we instantly teleport them that location and do the pretty lights again.

Setting a Default Bind Point

A very good thing to do is to bind players to a default bind point if they don't have one. This prevents players from refusing to bind and then being able to respawn where they die. To accomplish this we'll put a check in the module's OnClientEnter event to set the default bind point. Go into the Edit Menu and choose Module Properties. In the Events click the Edit button next to OnClientEnter and Copy and Paste the following code in:

Module : OnClientEnter

Then click Save and name it whatever you want. Then clck Exit in the lower right.

Bringing it all together

Now it's time to try and make it all work. Create two areas and a transition between the two. In each area place a Binding Stone and give them each a unique Name and Tag (like Valley Binding Stone and ValleyBindingStone). Place some Magical Sparks above the stone and a MagicCrystalNeutral sound right on it. This will make your stone sparkle and play pretty sounds to attract a player's attention. Place some baddies to kill you in one of the areas. Bind yourself to the stone in the second area and get killed in the first area. Watch yourself respawn by the stone in the second area!

Conclusion

Well, that was certainly longer than I thought it would be. Hopefully somebody out there will find this useful. The code hasn't been extensively tested (I'm still working on it) so it probably has some bugs and what not. I also need to investigate how local player variables are dealt with via Local Characters and Server Characters.

If you have any comments or suggestions please email me at nwntutorials@spilth.org.