The random toggle in the script wizard only sets that particular string to be spoken if a the SC variable is within the random range defined. I think this is more likely what you are looking for:
http://forum.bioware...esting-finding/
Basically, what you do is
- Create a conversation for the NPC that contains several one-line nodes that do NOT have a PC response. Make sure the one-liners are ABOVE any other conversation nodes for the NPC (e.g. if you have a NPC that enters into a conversation with the PC once a quest has been completed).
- For each conversation node you need to assign x0_d2_hen_line## as the SC script (where ## is the number of the node in the file - e.g. node 1 uses x0_d2_hen_line1.nss as its SC script)
- Save the file and exit the Conversation Editor.
- Set the int variable "X2_USERDEFINED_ONSPAWN_EVENTS" = 2 on the NPC.
- Create a custom OnUserDefined script for the creature (see example below).
- Edit the line "int nRandom = d10();" to however many one-liner nodes are in your dialog file. If your number doesn't correspond to a dice function, use the Random function instead: "int nRandom = Random(##);" where ## = the number of one-liners -1 (e.g. if you have 16 one-liners use "int nRandom = Random(15);"
- Save the file and exit the Script Editor.
When you click on the creature it will now speak a random line from its conversation file.
Note, the example in the other thread is called from the Heartbeat event via the OnUserDefined script. That's because I wanted the NPC to perform random tasks which included spouting off random phrases (i.e. he cusses quite a bit while at work). The script provided below, converts this to a Dialog event and removes the additional coding that modified the NPC's behavior.
//::///////////////////////////////////////////////
//:: Custom User Defined Event
//:: FileName
//:: Copyright © 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
If you set an integer on the creature named
"X2_USERDEFINED_ONSPAWN_EVENTS" then the
creature will fire a pre- and a post-spawn
event on itself, depending on the value of that
variable:
1 - Fire Userdefined Event 1510 (pre spawn)
2 - Fire Userdefined Event 1511 (post spawn)
3 - Fire both events
*/
//:://////////////////////////////////////////////
//:: Created By:
//:: Created On:
//:://////////////////////////////////////////////
const int EVENT_USER_DEFINED_PRESPAWN = 1510;
const int EVENT_USER_DEFINED_POSTSPAWN = 1511;
#include "nw_i0_generic"
void main()
{
int nUser = GetUserDefinedEventNumber();
if(nUser == EVENT_DIALOGUE) // ON DIALOGUE
{
// delete one-liner marker here as the action taken script in the conversation file wasn't always allowed to fire.
DeleteLocalInt(OBJECT_SELF,"X0_CURRENT_ONE_LINER");
int nRandom = d10(); // set the value to be equal to the number of one-liner nodes in the dialog file
SetLocalInt(OBJECT_SELF,"X0_CURRENT_ONE_LINER",nRandom);
SpeakOneLinerConversation();
}
else if (nUser == EVENT_USER_DEFINED_PRESPAWN)
{
}
else if (nUser == EVENT_USER_DEFINED_POSTSPAWN)
{
SetSpawnInCondition(NW_FLAG_ON_DIALOGUE_EVENT);
}
}
Répondre aux messages cités Effacer
- The BioWare Forum
- → BioWare
- → Legacy Games
- → Neverwinter Nights
- → Builders - Scripting