Neverwinter Nights Stuff

Worthy Links

Playing & Gen Game Info Building Scripting
Tutorials and Guides Links NWN For Builders Scripting Links
Scripting Links NWN Toolset NWN Scripting
Misc Forum Index   Scripting Tutorials
Misc Trailers, Screenshots, etc.   NWN Lexicon
    Scripting Archive

Scripts to Liberate http://nwn.bioware.com/forums/viewtopic.html?topic=136245&forum=46

MAKING UNIQUE PLACEABLES/BEHAVIOR


How do I pre-place map note pins on maps in the toolset?
(answer by Boneshank:) With the area open, click on the Paint Waypoints button (the one on the far right), then click on the "+" on the list to expand it. Choose Map Note. Paint it into area where you want it to show up in map. Rightclick it, choose properties. Click on Advanced tab. In the bottom field where it says <Enter Text Here>, do just that. Make sure the map point box is check, and voila - done deal.



How can I get my creatures to sit on chairs/benches/stools?

Put the script "nw_c2_sitting" in the creature's OnSpawn or OnHeartBeat sections, and change the tag of the object to "NW_CHAIR". The difference between the OnSpawn or OnHeartBeat is that the former only happens at the very beginning, the second repeats every 6 seconds. So if you talk to an OnSpawn sitter, they'll remain standing after the conversation.


How do I make chairs/benches/stools that my PCs can sit down on?

Put the following script in the OnUsed section for the object, and rename the object's tag to "Chair" (or change the tag used in the script).

NWScript:
void main()
{
object oPlayer = GetLastUsedBy ();
if (GetIsPC (oPlayer))
{
object oChair = GetNearestObjectByTag ("Chair", oPlayer, 0);
if (GetIsObjectValid(oChair) && !GetIsObjectValid (GetSittingCreature (oChair)))
{
AssignCommand (oPlayer, ActionSit (oChair));
}
}
}


Alternative:

 

change the line "object oChair = GetNearestObjectByTag ("Chair", oPlayer, 0);"
to
"object oChair = OBJECT_SELF;"

Then you can assign this script to any chairlike objects OnUsed Event.


Quote: Is it possible to rotate things like ships and boats, so that they're facing different directions?

After selecting a terrain Feature or Group but before painting it, right-click. Each right-click rotates the object 90 degrees.


I discovered a way to do this, placing a door on the cave entrance does work because well...the cave entrance is too big.

I loaded up the chapter 1 campaign module and took a peek at the door to the cult hideout in beggar's nest. I found the script I needed there.

This is the script:

NWScript:
void main()
{
object oClicker = GetClickingObject();
object oTarget = GetTransitionTarget(OBJECT_SELF);
location lLoc = GetLocation(oTarget);
if(GetLocalInt(OBJECT_SELF,"VariableName"))
{
SetLocalInt(OBJECT_SELF,"VariableName",TRUE);
SetAreaTransitionBMP(AREA_TRANSITION_RANDOM);
AssignCommand(oClicker,JumpToObject(oTarget));
}
else
{
ActionStartConversation(oClicker,"ConversationTag");
}
}

Basically the player initiates a conversation with the entrance. Once they have the proper item to access the 'unlock' convo tree...update the VariableName to TRUE...and the convo will no longer appear and the player can enter the area transition normally.


How do I pre-place map note pins on maps in the toolset?
(answer by Boneshank:) With the area open, click on the Paint Waypoints button (the one on the far right), then click on the "+" on the list to expand it. Choose Map Note. Paint it into area where you want it to show up in map. Rightclick it, choose properties. Click on Advanced tab. In the bottom field where it says <Enter Text Here>, do just that. Make sure the map point box is check, and voila - done deal.


 

Is there any way to make a nonstandard key?

Any item can be a key. Go to the Properties of the locked door or container in question, and select Lock. Under 'Key Tag' enter the Tag of the item that opens the Lock.

How do I give unique powers to an item?

To add unique powers to an item, go to Item Properties and select Properties (sounds redundant, I know). Now select Cast Spell: Unique Power or Cast Spell: Unique Power Self Only. Self Only means the power effects the user - otherwise the power needs to be targeted.

Now go to Module Properties, and select Events. Under OnActivateItem, add a script that first detects which item is activated, then applies whatever effects are needed.

- Aloro Silvertongue


 

Wow, that's cool! How do you do those neat-o script windows?

You type (nwscript) on a line, followed by your script code beneath it, then close with (/nwscript) on the line below. And you need to use square brackets [ and ] instead of the round brackets I've just used.


How do I give unique properties to items?

This is covered in one of David Gaider's tutorials (see General Stuff above) - the long and the short of it is you have to put a script in the OnActivateItem slot for the module.


I've got an archery target, but my arrows won't stick in it! How do I change this?

Bizarrely, you have to create a custom creature to shoot at, and give it the appearance of an archery target. It's just one of those things - arrows won't stick in placeables.


How can I make someone (or something) invulnerable?

Check the 'Plot' box under the Basic or Advanced tab in the thing's properties.


Help - silly players are decimating the NPC/Door/Innocent Badger population of my module! How can I stop them?

If stern warnings don't work, might I suggest the script below? (To be placed in the OnDeath section for the NPC/Door/Innocent Badger)

void main()
{
effect ePenguin = ExtraordinaryEffect(EffectPolymorph(POLYMORPH_TYPE_PENGUIN));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, ePenguin, GetLastKiller());
}

You might also like to attach a line or two of text (see the SpeakString Q&A above) to inform the player that yes, you really *did* mean what you said.


Alternate approach

Well there are several ways to do this. Here is one of them. Make sure all of your (doors/object to be destroyed) are of faction Defender. Make some guards (using the creature wizard) make several levels of guards (1st, 5th, 10th, 20th) make them have waypoints to walk around the town. (there is a thread for waypoints). make sure they are all of faction Defender or commoner. then when someone bashes a door they will attack them on sight. With about ten well equiped 20th level (make sure CR is 20) guards walking around pc's will find that breaking doors/killing NPC's is not a good thing to do.

Another way of doing this would be to create a faction based on commoner, call it something like "Breakable objects". Then set all breakable objects in your town to be of this faction. then create some guards of this same faction. Then create very hard encounters including these guards, then set the encounters to be of the same faction. When someone walks around normally nothing happens, when someone breaks a door then wanders around suddenly guards spawn every few streets or whatever and attack them.


How can I raise the PCs abilities? (giving them both the choice of which one and not, for different reasons.)

check out EffectAbilityIncrease
e.g. effect eRise = EffectAbilityIncrease (ABILITY_CONSTITUTION,2)
and then ApplyEffectToObject


How do I prevent corpses from fading out?

You need to incorporate the script below (or just the 'Set...' line) in the creature's OnSpawn script.

void main()
{
SetIsDestroyable(FALSE, FALSE, FALSE);
}

If you want the corpse to be useable (for looting, say) change the third 'FALSE' to 'TRUE'.


TALKING



To make an npc start a conversation there are two ways to do this which have two different uses.

1a. The first is if you want the NPC to talk to everyone (with the text floating above his head) just make a new script and put it on his onSpawn. in this script put this:

ActionStartConversation(OBJECT_SELF);

then create a one liner conversation and assign it to the NPC.

1b. The second is to make the NPC talk to the first pc that walks up to him. you would create an onPercieve script. This script would check to make sure the thing that set it off was a pc, then it would set a variable on the pc that said it already talked to him, then it would start a conversation. this has been done many many times try searching for it on the scripting forum or the vault.

2. The way to make an object sing to itself is easy, do step 1a, however make the conversation (including what the pc says parts) be each line of the song don't make multiple branches. like to make the NPC sing a song do this
create in the conversation file the starting line "this is the song that never ends". then click that line and add a new line put "it goes on and on my friend". into that one click on it then create a new node with "some people started singing it not knowing what it was and kept on singing it just because..." then right click the first line and hit copy. then right click on the last line and hit paste as link. and there you have it an NPC that does nothing but sing.


Hi, I was just wondering how to make an NPC attack the PC if he says the wrong thing in a conversation. Thanks in advance!

In the conversation editor click on the line that you want to make the NPC attack the pc if he chooses. make sure it ends the conversation(or use the last one in that thread). then on the lower right hand corner of the editor click the action tab. Then click the little wizard hat. then select perform an action (or whatever the toolset is not in front of me right now) then click next there should be an option to make the NPC attack name the script and you have it.


I've read about How DO I Make My NPC's Initiate Dialouge On Their Own in the Scripting Tutorials.

It sais how to make the NPC start to talk with a PC. But how do I make an NPC start to talk with another NPC on their own, when the PC is near them (notice: when near the NPC, NOT when clicking on the NPC).

Thanks in advance!

//Jussi

In the on percieve event of the first npc. make a check to make sure a pc is percieved then use the ActionStartConversation( "NPCtagtotalkto" );


 

There is a function called ListenPattern
as I can't saw, it work only on NPC

Let see how it work with an exemple.
In a tavern, there is a Drunk man.
Put it in the scene. Open his options and go to the OnSpawn event.

void main()
{
SetListenPattern(OBJECT_SELF, "**drunk**", 1000);
SetListenPattern(OBJECT_SELF, "**junky**", 1001);
SetListenPattern(OBJECT_SELF, "**more**", 1002);
SetListenPattern(OBJECT_SELF, "**beer**", 1003);
SetListenPattern(OBJECT_SELF, "**gold**", 1004);
SetListening(OBJECT_SELF, 1000);
}

so go now in OnConversation event

void main()
{
int nListen = GetListenPatternNumber();
object oPC = GetLastSpeaker();
switch (nListen)
{
case 1000:
{
SpeakString("nooooo I'm not druuuunnnk hips");
break;
}
case 1001:
{
SpeakString("yeeees who call meee ?");
break;
}
case 1002:
{
SpeakString("YES YES ME too I want some more ! hips");
break;
}
case 1003:
{
SpeakString("yeeeeeeeahhh general round !!! ");
break;
}
case 1004:
{
SpeakString("guy ! you're a friend for give me one more drink with your gold !");
break;
}
}
}

ok, now when a player is in the tavern and talk with the mj or with another PC the drunk man speak alone bouncing the player words

** will match zero or more characters
*w one or more whitespace
*n one or more numeric
*p one or more punctuation
*a one or more alphabetic
| is or
( and ) can be used for blocks
- setting a creature to listen for "**" will match any string
- telling him to listen for "**funk**" will match any string that contains the word "funk".
- "**(bash|open|unlock)**(chest|door)**" will match strings like "open the door please" or "he just bashed that chest!"


How do I get my NPCs/objects/badgers to speak lines above their heads?

There are several ways to do this. One way is to create a one node conversation, with no player reply, and attach it to the speaker. Another (the way I do it) is to use the SpeakString or ActionSpeakString functions in a script. A very simple example would be:

NWScript:
void main()
{
SpeakString("Hello, I like badgers.");
}


How do I make an NPC say a different line if he's already talked to the PC?

Download the tutorial module and instructions and check out the conversation for Falstadd.

If that's too hard (and it shouldn't be), in a nutshell:
1. Write the initial conversation. In the first line of the conversation, go to the Action Taken Tab. Click the wizard and select the radio button for "Set a Local Variable."
2. Pick a variable name and set it to "1"
3. ABOVE the initial conversation nodes, start a second NPC conversation node. (note: you can't create the node above the first. Instead, you have to create it below the first and then click and drag it above it). This time, go to the Text Appears When tab. Click the wizard and select the radio button to check for a Local Variable.
4. Enter your variable name and the value to check for ("1").

When the NPC is first spoken to, the game will check the first node in the conversation and see that the variable does NOT equal 1 (it equals zero, since it hasn't been set yet). It will then move to the next node. Since there's no check being made, the NPC will say that line and set the variable to 1. The next time the NPC's being talked to, the game will check the first node and find the variable equals 1. The NPC will now say that line.


How do you loop conversations (go back to an earlier part of the NPC dialog)?
Choose the conversation node that will be the destination of the loop. Right-click and Copy it. Find the node that will be the beginning of the loop. Right-click and Paste as Link.


Is it possible to always have the same conversation unti lyou ocmplete a quest or kill a certain monster or something?

Using the "Text Appears When" tab in the conversation node, you can enter scripts which determine when the NPC takes those branches of the conversation, as well as which branches of PC response are available.

For a branch that appears after you kill a certain monster, you must use a variable to tell whether you have killed the monster, and check that variable in the conversation. Use the script wizard to check the variable (check Local Variable, variable name "bKilledMob" without the quotes, constant int 1). To set the variable, you can modify the creature's OnDeath script (be sure to save it as a different name, or else all of your creatures will be setting that variable when they die!). Place this code at the end of the script, just before the closing curly bracket }
NWScript:

object oPC = GetLastKiller();
if( !GetIsPC(oPC) )
{
oPC = GetMaster(oPC); //make sure it's not a pet
}
SetLocalInt(oPC,"bKilledMob",1);

To check if a quest has been completed, you can check the player's local variable NW_JOURNAL_ENTRYqtag, where qtag is the TAG of the quest in the Journal Editor. So if you set a quest's tag to be qBob, you can check the variable NW_JOURNAL_ENTRYqBob to see which step of the quest they are on.


ENCOUNTERS
How the heck do I draw Encounters/Area Transitions? I just get this coloured line I can't let go of!

You need to double left-click to stop drawing. Try drawing a polygon (like a rectangle) that covers an area you want to act as a trigger.


want a custom item that I can re-use...

If you want to create an custom item or encounter that you can re-use throughout your module yu need to add it to the Custom Pallete. You can do this by choosing to 'Edit Copy' and make sure you give your item a unique tag.

This is useful for creating things like encounter groups too. For example, you can add your custom militia to the pallete and then create an encounter that deploys them. This encounter itelf can be added to the pallette and then used wherever you like.

My Encounter never triggers

The faction of the encounter is important. Encounters ONLY trigger if that faction is hostile to the PC (for player triggered encounters). If you want the encounter to spawn Friendly creatures you must make sure the creatures spawned are of a friendly faction. (Hence the tip above becomes useful)

So you can setup a Militia faction with encounters that never spawn as long as the PC stays on the right side of the Militia faction, but get in trouble with the law and that faction can be made hostile and wherever the player goes the will now be attacked by spawning Militia.

Likewise I suspect you could setup 'helper' encounters that are NOT set to PC only and are of a friendly faction. If a monster follows you into town those friendly Militia will attack the Monster (as long as they are Hostile to that creature's faction of course)