I'm making a module to play multiplayer with some friends and encountered a scripting dilemma. I wanted to draw upon the expertise of the NwN modding community.
What is the best way to get NPC's to speak to players using the names of other players? For example, I want an NPC to say something along the lines of the following:
"It's good that you are here, <FirstName>. Your companion, (INSERT PLAYER 2'S NAME), already went inside and I haven't heard from (INSERT PLAYER2'S HIM/HER) in hours."
It's probably a simple answer that I should know already. Thanks for any assistance.
Multiplayer module dialogue
Débuté par
Kalindor
, déc. 07 2010 05:19
#1
Posté 07 décembre 2010 - 05:19
#2
Posté 07 décembre 2010 - 11:20
CUSTOM TOKENS is the key, scripted commands such as SetCustomToken() will suffice to put your data where you need it, thereafter you can use the content of the Custom Token in a convo by <CUSTOM###> where ### is the number you assigned to the Custom Token.
Hope this helps, if not sufficient, try the NWNLEXICON for more.
Be well. Game on.
GM_ODA
Hope this helps, if not sufficient, try the NWNLEXICON for more.
Be well. Game on.
GM_ODA
#3
Posté 07 décembre 2010 - 04:49
Thanks. I'll try my hand at incorporating some custom tokens.
*Edit: Okay, is there some sort of GetFirstName() or GetLastName() function?
*Edit: Okay, is there some sort of GetFirstName() or GetLastName() function?
Modifié par Kalindor, 07 décembre 2010 - 04:57 .
#4
Posté 07 décembre 2010 - 05:25
GetName(oObject) returns both of them. Per the lexicon.
If you need to split them appart, You could search for a space in the name to know where the first name ends and the last begins.
Ill try to find some time later tonight after i get home to look at this a little closer. I half remember some 2da's that may be of use.
Description
Returns the first and last name of oObject. In the case of creatures, returns first and last names together as single concatenated string.
If you need to split them appart, You could search for a space in the name to know where the first name ends and the last begins.
Ill try to find some time later tonight after i get home to look at this a little closer. I half remember some 2da's that may be of use.
#5
Posté 07 décembre 2010 - 10:22
I appreciate it. Don't inconvenience yourself too much on my behalf. It's just a cosmetic thing, but it strikes me as rather odd for NPC's to frequently refer to someone they know well by their first and last name.
#6
Posté 07 décembre 2010 - 10:46
Just for future reference, there is a separate Scripting Forum
#7
Posté 08 décembre 2010 - 02:26
Yea, This has turned out to be a scripting question. After looking at the 2da for the tokens used in conversations I have found that it will easier to and faster to just script out what you need without using the 2da.
if you need help on how to set the value for the custom toke in the conversation the lexicon is a good place to look
Function - SetCustomToken - NWN LexiconGetting the value for the token will be different for acording to what you want to get. For the great mass of male/female tokens I would use something like the following. Keep in mind that the Bioware Tokenizer is not the most efficient of functions. It is however easy to use. you will also have to #include "x0_i0_stringlib" in order to use it.
string sToken = GetTokenByPosition("Mister/Miss","/",GetGender(oPC));
string sToken = GetTokenByPosition("boy/girl","/",GetGender(oPC));
string sToken = GetTokenByPosition("Lord/Lady","/",GetGender(oPC));
string sToken = GetTokenByPosition("lord/lady","/",GetGender(oPC));
string sToken = GetTokenByPosition("Master/Mistress","/",GetGender(oPC));
I hope you get the Idea.
For the first/last name I would get the value like this.
string sFirstName = GetTokenByPosition(GetName(oPC)," ",0);
string sLastName = GetTokenByPosition(GetName(oPC)," ",1);
I hope that helps,
L8
if you need help on how to set the value for the custom toke in the conversation the lexicon is a good place to look
Function - SetCustomToken - NWN LexiconGetting the value for the token will be different for acording to what you want to get. For the great mass of male/female tokens I would use something like the following. Keep in mind that the Bioware Tokenizer is not the most efficient of functions. It is however easy to use. you will also have to #include "x0_i0_stringlib" in order to use it.
string sToken = GetTokenByPosition("Mister/Miss","/",GetGender(oPC));
string sToken = GetTokenByPosition("boy/girl","/",GetGender(oPC));
string sToken = GetTokenByPosition("Lord/Lady","/",GetGender(oPC));
string sToken = GetTokenByPosition("lord/lady","/",GetGender(oPC));
string sToken = GetTokenByPosition("Master/Mistress","/",GetGender(oPC));
I hope you get the Idea.
For the first/last name I would get the value like this.
string sFirstName = GetTokenByPosition(GetName(oPC)," ",0);
string sLastName = GetTokenByPosition(GetName(oPC)," ",1);
I hope that helps,
L8
#8
Posté 08 décembre 2010 - 04:52
Thanks! I did some string clipping and got the custom tokens to work with the results I was looking for.
I apologize for posting in the wrong forum... I already knew there was a scripting one and must have gone to the wrong one by accident.
I apologize for posting in the wrong forum... I already knew there was a scripting one and must have gone to the wrong one by accident.
#9
Posté 08 décembre 2010 - 04:55
deleted, solved. Be well. Game on!
GM_ODA
GM_ODA
Modifié par ehye_khandee, 08 décembre 2010 - 04:56 .





Retour en haut







