Problem: The default NWN script editor has one script per NPC action. This results in a lot of unneeded scripts when creating a quest or NPCs reacting to events which occur during the game.
Potential solution: I have been told that EE now has conversation parameters which are passed to the script. The person had not used that before so I am hoping that you may be able to assist me with how this is done with an example so I may replicate it.
Thank you for your assistance and guidance.
First, I only work with NWN2, but scripting is very similar in both games. And even though I’ve played NWN1 since 2003, I have never played EE.
That being said, I’m not sure I understand the problem you’re having though. What exactly do you mean by “one script per NPC action”? Couldn’t you do a script with a bunch of “if” and “else if” statements? That way you would only need one script, if you so desire, reacting to events concering a particular quest that occur during the course of the game.
Maybe those conversation parameters you’re talking about are really handy, but I don’t really see a need for it, I guess.
Maybe this doesn’t help you at all but these are just my thoughts on the matter. Do you have something concrete which you are trying to achieve? If you tell us, I’m sure there’s a bunch of people here that could make a script for you.
Edit: You can always use local and global ints when stuff happens in the game. Then your script can check for these ints and thus NPCs would react when different events occur during the game.
If you want one script to handle multiple NPCs (i.e. when they step on a trigger), use tags to tell them apart:
/* one handler script for multiple NPCs */
string sTag = GetTag(OBJECT_SELF);
if(sTag == "NPC1")
/* handle NPC 1 here */
else if(sTag == "NPC2")
/* handle NPC 2 here */
else /* (only if no other tags are expected here) */
/* tag of OBJECT_SELF is not handled by this script */
"Warning: unknown creature tag: '" + sTag + "'!");
If you want one script to handle multiple situations for one NPC, you’d use local variables to find out at which quest stage you are. Though it is generally not a good idea to directly use one script for different in-game events (i.e. OnAttack and OnHeartbeat).
In a conversation same can be achieved using parameters, except that you’d probably want to use them to directly mark the action to perform (same paradigm as with tags in code above, except that you’d pass something like “attack”, “join_party”, etc, so I’m not including an example).
I want to thank everyone for responding. I do apologize for not being more precise. As mentioned Beamdog introduced a new scripting feature in NWN:EE which I am looking to take advantage of. I believe the result is now Beamdog is coding for the conversation to look for those local variables directly from the script. I have never used them however so I am looking for some help.
The person I originally asked for assistance from used the old work around which is no longer needed.
This may be set at both to show the option as well as action taken.
Hmmm, looking at your picture doesn’t give much clues as to what’s going on, I’m afraid. If I owned NWN:EE I could maybe have helped you but…
I found an explanation with examples:
If anyone has experience of actually doing this in EE, please comment.
Ah, I was searching yesterday for such a info. Especially that functions, but due the late hour, I didn’t had the time to look at the Lexicon. I’ll take a look at that tomorrow, eventually I can get some experiances with that.
So I was able to do a little bit of toying around with the conversation editor and a script.
First the NPC speaks and sets a wing and a tail on the player than the PC speaks and the wings and tail changed.
My second test was passing a parameter and then testing it by checking if it worked by setting the show if the parameter was set. It failed both from the NPC setting it and the PC.
How did you test to see whether the second part is working?
As far as I can see, it’s attempting to set the parameter, but doesn’t do anything that would prove the point either way.
For example, after setting the parameter, you could ExecuteScript to run something like this:
void main ()
SendMessageToPC(GetFirstPC(), "param=" + GetScriptParam("race"));
If I’ve read the Lexicon correctly, you need to run a new script to pick up changes to the parameters.
The description of SetScriptParam() says:
// Set a script parameter value for the next script to be run.
// Call this function to set parameters right before calling ExecuteScript().
So you can’t use SetScriptParam() and GetScriptParam() within the same script.
If SetScriptParam() is used in one script and then second script is called with ExecuteScript() you can use GetScriptParam() in that script to retrieve the parameter. However you can achieve the same (and much more) using SetLocalXXX() and GetLocalXXX(). So in my opinion SetScriptParam() and especially GetScriptParam() is really useful only when used in dialogs.
Thank you for the response.
The test was for a dialogue after setting the race fey’ri or race cow there was a test dialogue which showed if either one was true.
I thought that may be the case that I would not be able to, however thought I would double check in case it was user error. For creating conversations for a quest or a NPC who remembers a PC as you mentioned they can still set the information from the parameter. Just using set string with a variable called race to either feyri or cow. With the following checking if the PC has that string set on them and responding appropriately.
Thank you both for your insight and assistance. Slow steps, however I should be able to get the results I want.
There is an exception, when you want to use the same script in conversation and in Execute Script.