Author Topic: Listening Patterns  (Read 402 times)

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Listening Patterns
« on: January 21, 2013, 04:43:20 pm »


                <coc...er, roostering...>

This is in regards to my Mounted familiar VFX. I want to mount the familiar when it's given the command to follow. That works fine with...


if (nMatch == ASSOCIATE_COMMAND_FOLLOWMASTER)
{
   // Mount familiar
   MountFamiliarVFX(oMaster);
   SetLocalString( OBJECT_SELF, "X2_SPECIAL_COMBAT_AI_SCRIPT", "ccc_fam_dismt");
}

...added to nw_ch_ac4.

The familiar *dismounts* when entering combat (handled by ccc_fam_dismt), or when "Attack Nearest" is commanded. That works, too.

But I also check for "Stand Ground" and "Guard Me" and neither of those fire. Here's that part:


else if ((nMatch == ASSOCIATE_COMMAND_ATTACKNEAREST) || ( nMatch == ASSOCIATE_COMMAND_STANDGROUND) || (nMatch == ASSOCIATE_COMMAND_GUARDMASTER))
{
   [b]DismountFamiliar(oMaster);[/b]
}

So my question is where is the listening pattern for "Guard Me" and "Stand Ground" set? And can anyone see a doofus reason (I *am* known for them...) why they won't trigger?

Edit: ASSOCIATE_COMMAND_UNPOSSESSFAMILIAR doesn't trigger either... and where is *that* set? Is there a voice activated *Possess* command somewhere...?

<...an ear>
               
               

               


                     Modifié par Rolo Kipp, 21 janvier 2013 - 07:17 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Listening Patterns
« Reply #1 on: January 21, 2013, 05:00:40 pm »


               This is a very interesting development.

One subject of investigation (perhaps to dig out of the NWN memory bank) includes voice chat commands: Does each one potentially have a silent shout hooked to it?

Another plan of attack is to create an OnConversation script which repeats everything that the familiar hears.
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Listening Patterns
« Reply #2 on: January 21, 2013, 05:14:26 pm »


               <straining his ears...>

How would we capture the raw shout heard by a creature without it being filtered by GetListenPatternNumber()?

<...to strain what he hears>
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Listening Patterns
« Reply #3 on: January 21, 2013, 05:30:14 pm »


               You set a creature to listen, and then have them repeat everything.  I'd done a bit with this when I overhauled the henchman scripts for my mod, I'd have to dig through the scripts a bit to remember exactly what I'd done though.  I'll do a quick test to see what I get from it, and then edit this post.


  Edit:  I don't have enough time this morning to go through it all, but here's what I do have:

In an NPCs onspawn, after setting them to listen, set a listen pattern as "**", as in: 
SetListenPattern(OBJECT_SELF, "**", 4200); 

This will make them report anything heard as chat as a certain listen pattern number you can then match in the OnConversation. 

int    nMatch   = GetListenPatternNumber();
if (nMatch == 4200)
   {
      int nString = GetMatchedSubstringsCount();
      SpeakString (IntToString (nString));
      string sString = GetMatchedSubstring (nString - 1);
      SpeakString (sString);


  With this quick test, you'll notice that it'll likely report the matched count as 1, but the heard message itself is on count - 1.

  It has to be noted, that if you test this way, you can only have ~1~ npc in listening range set this way, or it creates an infinite loop of shout/return shout between nearby NPCs.

  The voice commands didn't seem to report anything using this method, but I only tried a couple.  It might be possible to catch some that don't have matches set up this way, but it already looks unlikely.
               
               

               


                     Modifié par Failed.Bard, 21 janvier 2013 - 06:01 .
                     
                  


            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Listening Patterns
« Reply #4 on: January 21, 2013, 07:07:02 pm »


               <being buffeted repeatedly about the face and shoulders by a raven...>

Doofus I said, Doofus I meant.

The function is "DismountFamiliarVFX( oMaster )", not "DismountFamiliar( oMaster )". Attack nearest must have worked because determinecombatround was called and the special_combat_ai_script was called.

Anyway, they work now, but I'm still *very* interested in why Bioware made an Associate_command_unpossessfamiliar constant and if somewhere there is a script we can crack open to empower it. And it's mate - "possess".

<...because he deserves it>
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Listening Patterns
« Reply #5 on: January 21, 2013, 08:07:20 pm »


               All we need are the shouts. If there are shouts that happen at the moment of possession and the moment of dispossession... then we can construct userdefined events to respond to these.
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Listening Patterns
« Reply #6 on: January 22, 2013, 03:18:38 pm »


               <hunting for fodder...>

Interesting thing with your echo routine, FB; the familiar doesn't echo things that already have a listening pattern set.

Say "Hello world" - echoed
Say "Possess familiar" - echoed
Say "inventory" - silence

I think I tried "pick lock" too.
So it looks like we don't hear any shouts echoed except the ones not filtered...
So we still don't know if there's a magic word or two set somewhere... :-P

Edit: which is probably what I missed in your last paragraph :-P

<...in the raw>
               
               

               


                     Modifié par Rolo Kipp, 22 janvier 2013 - 03:22 .
                     
                  


            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Listening Patterns
« Reply #7 on: January 22, 2013, 05:03:04 pm »


               SetListenPattern(OBJECT_SELF, "NW_I_WAS_ATTACKED", 1);
SetListenPattern(OBJECT_SELF, "NW_MOB_ATTACK", 2);
SetListenPattern(OBJECT_SELF, "NW_I_AM_DEAD", 3);
SetListenPattern(OBJECT_SELF, "NW_ATTACK_MY_TARGET", 5);
SetListenPattern(OBJECT_SELF, "NW_CALL_TO_ARMS", 6);


SetListenPattern(OBJECT_SELF, "inventory",101);
SetListenPattern(OBJECT_SELF, "pick",102);
SetListenPattern(OBJECT_SELF, "trap", 103); 

Those seem to be all the soft coded ones I could find.  I'm not sure what triggers the other ones still, but it's very likely a silent shout accompanies the voice commands.  I expect you'd need someone like Virusman to tell you what the others are, since they'd be buried somewhere in the engine.  Above the constants is the one hint though:

// These must match the values in nwscreature.h and nwccreaturemenu.cpp
// Cannot use the value -1 because that is used to start a conversation 



 
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Listening Patterns
« Reply #8 on: January 22, 2013, 05:17:45 pm »


               

Rolo Kipp wrote...

<hunting for fodder...>

Interesting thing with your echo routine, FB; the familiar doesn't echo things that already have a listening pattern set.

Say "Hello world" - echoed
Say "Possess familiar" - echoed
Say "inventory" - silence

I think I tried "pick lock" too.
So it looks like we don't hear any shouts echoed except the ones not filtered...
So we still don't know if there's a magic word or two set somewhere... :-P

Edit: which is probably what I missed in your last paragraph :-P

<...in the raw>


That is most likely because of the order the patterns are in.   But, for your test, you really want this reporting everything anyway.  So just get rid of the filter and let it report reguardless of what caused the event to fire.

int nMatch = GetListenPatternNumber();
if (nMatch == 4200)
  { 

   int nString = GetMatchedSubstringsCount();
   SpeakString (IntToString (nString));
   string sString = GetMatchedSubstring (nString - 1);
   SpeakString (sString);
 } ;   
               
               

               


                     Modifié par Lightfoot8, 22 janvier 2013 - 05:19 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Listening Patterns
« Reply #9 on: January 23, 2013, 02:25:53 pm »


               I found that the Voice Chat commands appear to be hardcoded, and yet are picked up in the conversation event. You need to have SetAssociateListeningPatterns in the creature's Spawn.

However there is no matched substring to echo back. The only thing it can do is tell you that it had a match with GetListenPatternNumber. but no string is retrieved with the above function.

That said... it doesn't really matter. All the commands that show up in a familiar's radial menu have a listen pattern number as well as those in the voice chat list with an asterisk next to them.

Interestingly these voice chats have a negative number for their patterns.
Hold Ground -2
Attack -3
Heal -4
Follow -5
Guard -7

I haven't been able to get the actions Possess or Unpossess to echo anything, even when writting a timestamped log entry.