I’m trying to prevent NPC “barking” from playing when the player is in a conversation with said NPC.
I tried using isinConversation but i get errors and i can’t find any documentation about the expression being used.
void main()
{
ExecuteScript("nw_c2_default1", OBJECT_SELF);
if(IsInConversation)PlaySound("");
int rand=Random(3); //Random number from 0 to 2
//if(rand==0)PlaySound("vs_nils_bark001");
else if(rand==1)PlaySound("vs_nils_bark002");
else if(rand==2)PlaySound("vs_nils_bark003");
}
EDIT: Hmm, come to think about it, this might not prevent the bark sound from playing after all…I don’t know how these things work in NWN1, but my guess is you put this script on the OnConversation of the NPC?
EDIT2: As this script hurt @kevL_s ’ eyes, I have edited it to his liking and removed the last else if statement as that was redundant.
Even shorter (but unfortunately less flexible, since the sounds will need to have similar names):
void main(int nMax=3)
{
if (!IsInConversation(OBJECT_SELF))
{
int rand = Random(nMax)+1; // value between 1 and nMax
string sFile = "vs_nils_bark0" + GetStringRight("00"+IntToString(rand),2); // sFile will be "vs_nils-bark0" followed by a number between "01" and "99" (so nMax is limited to 99)
PlaySound(sFile);
}
}
@kevL_s - I asked my brother what hurt your eyes so much with my script, as I was confused by that, and now I understand. He understood your reaction completely (he’s programmer too and has taught me a great deal about the fundamentals of programming/scripting (together with everyone here on the vault), even if it has taken a few years to get it through my thick head).
Yes, I didn’t have this in my original attempt, but I got insecure about how this script was called, so I put that in there just in case…but I know it’s not really needed.
I’m glad my simple script worked still, and that I could help a fellow neverwinternighter out.