Author Topic: Grabbing NPC speaker during conversation  (Read 394 times)

Legacy_Verilazic

  • Sr. Member
  • ****
  • Posts: 263
  • Karma: +0/-0
Grabbing NPC speaker during conversation
« on: January 26, 2015, 11:48:03 pm »


               

 



   GetLastSpeaker()

Determines the last creature that was communicated with.


object GetLastSpeaker();

   Description

Use this in a conversation script to get the person with whom the PC is conversing. Returns OBJECT_INVALID if the caller is not a valid creature.





   Remarks

If called within a conversation (e.g., as part of the "StartingConditional" script for a PC line of text AFTER the NPC has spoken previously), the function will not return the last NPC speaker, but will return OBJECT_INVALID.


The value is apparently set after the whole conversation with an NPC is completed, not after each line of conversation. This means you can't use this function during a conversation to grab the tag of the NPC that is speaking.



 


The above is what I found on this function in the Lexicon. The way I'm reading this is that a simple script using this function to identify the NPC in conversation and make them perform an action won't work reliably... am I right in this assessment? If so, how am I supposed to do... anything in a conversation? >.<


               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Grabbing NPC speaker during conversation
« Reply #1 on: January 27, 2015, 01:10:22 am »


               

Generally, the conversation scripts run as the NPC (or other object) speaking so OBJECT_SELF should work.


               
               

               
            

Legacy_Verilazic

  • Sr. Member
  • ****
  • Posts: 263
  • Karma: +0/-0
Grabbing NPC speaker during conversation
« Reply #2 on: January 27, 2015, 01:32:28 am »


               

Ah. Makes sense. Would that count for any other NPCs showing up in the same conversation?



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Grabbing NPC speaker during conversation
« Reply #3 on: January 27, 2015, 03:08:33 am »


               

I think it's always the owner of the convo, not the other speakers. If you need them you may need to use GetNearestObjectByTag.



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Grabbing NPC speaker during conversation
« Reply #4 on: January 27, 2015, 07:46:57 am »


               

Yes, OBJECT_SELF is always the conversation owner.


 


Since the builder assigns tags to lines spoken by other NPCs, they already know who is speaking those lines, and can use GetNearestObjectByTag or GetObjectByTag to identify them in scripts.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Grabbing NPC speaker during conversation
« Reply #5 on: January 27, 2015, 01:30:52 pm »


               

Thanks for the confirmation, Proleric.



               
               

               
            

Legacy_Verilazic

  • Sr. Member
  • ****
  • Posts: 263
  • Karma: +0/-0
Grabbing NPC speaker during conversation
« Reply #6 on: January 27, 2015, 01:57:02 pm »


               

Okay, thanks guys. But a bit of a bummer nevertheless. I was hoping I could put together a really extensive set of conversation scripts that would be generalizable. But it sounds like I'll have to write specific scripts for specific conversations in most cases. =/



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Grabbing NPC speaker during conversation
« Reply #7 on: January 27, 2015, 10:47:28 pm »


               You can make complicated generic conversations. The NPC with whom the PC starts conversation is always OBJECT_SELF, from which you can obtain their local variables, name, tag, gender etc to tailor conditional branches.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Grabbing NPC speaker during conversation
« Reply #8 on: January 29, 2015, 05:18:29 am »


               

The lexicon is way off base on this one.   The GetLastSpeaker function is not an accessor function for a conversation.  Nor is it set after the conversation is complete.  


 


It is an Accessor for the OnConversation Event  and as far as I know totally meaningless  and unpredictable once outside of that event.