recording speech

Moderator: Event DM

User avatar
maxinion
Team Member; Retired with Honors
Posts: 2778
Joined: Mon Mar 17, 2003 7:44 pm
DM Avatar: Andrinor
Location: Bay Area, CA
Contact:

Post by maxinion » Sat Sep 13, 2003 12:21 am

You'd have to manipulate the String. AKA, looking for two spaces through the entire string.*sighs* No easy way to do it. I'm not familiar enough with NWScript to get actual code up, but that's what it would take.
User avatar
Neve
Prince of Bloated Discourse
Posts: 192
Joined: Mon Apr 14, 2003 4:09 pm
Location: The Netherlands
Contact:

Post by Neve » Sun Sep 14, 2003 12:31 pm

About the floaty name over a null human issue : you can apply EffectVisualEffect(VFX_DUR_CUTSCENE_INVISIBILITY) on it to make it totally invisible, even for the mouse pointer =)
- As you gaze unknowingly into the seemingly infinite depths of the optics of this altogether passionate embodiment of insatiability, you experience a gradual realisation that the heavily-embellished vocabulary scattered lavishly throughout the sentence you are currently reading is indisputably nothing greater than a generous ration of masculine bovine faeces.
User avatar
NoneOf Seven
Knight of Useless Drivel
Posts: 50
Joined: Mon May 26, 2003 8:19 am
Location: in your shadow

Post by NoneOf Seven » Sun Sep 14, 2003 12:37 pm

now, why couldn't you have posted THAT three months ago ?

*chuckles and redoes some things*

Great and many thanks
the dark shadow, created by the light.

I am none, but all
User avatar
Neve
Prince of Bloated Discourse
Posts: 192
Joined: Mon Apr 14, 2003 4:09 pm
Location: The Netherlands
Contact:

Post by Neve » Sun Sep 14, 2003 1:09 pm

Sorry, I only just found that =p
- As you gaze unknowingly into the seemingly infinite depths of the optics of this altogether passionate embodiment of insatiability, you experience a gradual realisation that the heavily-embellished vocabulary scattered lavishly throughout the sentence you are currently reading is indisputably nothing greater than a generous ration of masculine bovine faeces.
Myk D'vor
Lord of Blithering Idiots
Posts: 111
Joined: Mon Feb 24, 2003 9:05 am

Post by Myk D'vor » Sun Sep 14, 2003 5:56 pm

It's simply a matter of parsing the spoken text into words using FindSubString. Add this to the OnSpawn of the creature listening:

Code: Select all

    SetSpawnInCondition(NW_FLAG_ON_DIALOGUE_EVENT);      //OPTIONAL BEHAVIOR - Fire User Defined Event 1004

    SetListenPattern(OBJECT_SELF,"**",777);
    SetListening(OBJECT_SELF,TRUE);
And then use this script for the UserDefined script to detect speech and parse the words...

Code: Select all

#include "nw_i0_tool"
#include "nw_i0_generic"

void main()
{
    int nCalledBy = GetUserDefinedEventNumber();
    if(nCalledBy==1004)
    {
        if (GetListenPatternNumber() == 777)
        {
            object oPC   = GetLastSpeaker();
            string sText = GetMatchedSubstring(0);
            object oSelf = OBJECT_SELF;
            int iSpace   = FindSubString(sText," ");
            int iRight   = GetStringLength(sText) - iSpace - 1;
            int iWordCnt = 0;
            string sWord = GetStringLeft(sText,iSpace);
            string sRemaining = sText;
            if(sText=="") return;
            while(iSpace>=0)
            {
                if(iSpace>0)
                {
                    SendMessageToPC(oPC,"Word "+IntToString(iWordCnt)+": "+sWord);
                    SetLocalString(oSelf,"Heard word"+IntToString(iWordCnt),sWord);
                    iWordCnt++;
                }
                sRemaining = GetStringRight(sText,iRight);
                iSpace     = FindSubString(sRemaining," ");
                iRight    -= (iSpace+1);
                sWord      = GetStringLeft(sRemaining,iSpace);
            }
            sWord = sRemaining;
            SendMessageToPC(oPC,"Word "+IntToString(iWordCnt)+": "+sWord);
            SetLocalString(oSelf,"Heard word"+IntToString(iWordCnt),sWord);
            SetLocalInt(oSelf,"Heard word count",iWordCnt);
        }
        else return;
    }
    return;
}
For now all this does is listen to all things spoken near the NPC and repeat the words back to the speaker, parsing them out. It also stores them in an array of Local strings for other uses. You should be able to modify this to pick any number of words out, and do anything with them that you wish to, like send them to another PC or have another invisible object speak them aloud using SpeakString. It will strip extra spaces out without counting them as words as well.

Myk D'Vor
Post Reply