Author Topic: OnConversation event queries  (Read 339 times)

Legacy_Aradan Kir

  • Jr. Member
  • **
  • Posts: 57
  • Karma: +0/-0
OnConversation event queries
« on: August 30, 2011, 11:55:07 am »


               I'm having some trouble with a script that should fire when a PC talks to an NPC.

I've added the script into the OnConversation event of an NPC, and when a PC talks to them, the script fires fine.  However, I've discovered that a) the script fires even when the PC just speaks something near the NPC and 'B)' the NPCs seem to speak to each other (possibly the script firing for one NPC making the script fire for another nearby NPC).  This can cause an avalanche of scripts firing and conversations happening (often crashes the game).

I've looked up the OnConversation description and it states "The OnConversation event is fired when a Player Character
attempts to talk to a NPC or other creature.  It also fires whenever
the dialogue with another creature ends, or a shout is heard."

So, now I'm a bit stuck.  Should I be putting the script into another event instead, but if so, none of them seem relevant for what I want.  Or does it need to go in the OnUserDefined event, but not sure how that works - never used it before.  Or should the NPC just have the default scripts and use the standard conversation file to get this to work - although I'm not sure if it will do what I want.

Incidentally, the purpose of the script is to call a random piece of gossip from the database and display that as "speech", and a small % chance of calling a conversation file which asks the PC to deliver an item.  That bit is all working fine when there's 1 NPC present and the PC initiates the conversation.

Any help would be much appreciated!  Thanks '<img'>
               
               

               
            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
OnConversation event queries
« Reply #1 on: August 30, 2011, 12:44:10 pm »


               The OnConversation Event for NPCs is a Listening Scripts, where if the NPC Percieves they heard something then the script fires, it's NOT for placing a conversation through scripting. all you really need to do is put the conversation on the NPC (right click on NPC > select properties, or if from the Palette, right click > select edit), if you want to do "checks" as to WHO can open the conversation then use the StartingConditional in the first line to read WHO is trying to talk to the NPC, if they don't meet your checks, then they get to read nothing or the next line if you wish the NPC to say anything at all.

To ensure that something only happens to a PC only, use the following function:
(NOTE: You must define oObject, where oObject would be the "creature" which the NPC heard.)

if(!GetIsPC(oObject)) { return; }

Hope that helped.
               
               

               


                     Modifié par _Guile, 30 août 2011 - 11:47 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
OnConversation event queries
« Reply #2 on: August 30, 2011, 01:11:35 pm »


               You neeed to filter what runs in the script using Function - GetListenPatternNumber . If the event is ran by clicking on the npc the function will return a value of -1.   If it is ran by hearing someone speak it will return a valid listening pattern number.


But  It looks like every thing you are trying to do could be done just by writting a conversation and adding it it the NPC.  

Your one  liners would just be a nore in the conversation that do not have any PC responces to them.  
               
               

               
            

Legacy_Aradan Kir

  • Jr. Member
  • **
  • Posts: 57
  • Karma: +0/-0
OnConversation event queries
« Reply #3 on: August 30, 2011, 02:35:27 pm »


               Thanks for the ideas - that listen pattern worked perfectly.  It's still not great in that it's inefficent in that it's called the script when people are just speaking nearby (the listening thing), but at least this prevents the rest of the script firing.

I'll have a look at using the conversation thing to run a script directly, but not certain if that will do exactly what I need.

Thanks for the help guys!
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
OnConversation event queries
« Reply #4 on: August 30, 2011, 04:56:06 pm »


               

aradankir wrote...

Thanks for the ideas - that listen pattern worked perfectly. It's still not great in that it's inefficent in that it's called the script when people are just speaking nearby (the listening thing), but at least this prevents the rest of the script firing.

I'll have a look at using the conversation thing to run a script directly, but not certain if that will do exactly what I need.

Thanks for the help guys!


True, If you are replacing the standard conversation file and do not want the NPC responding to shout. you could just turn off the listning so that the script does not fire when something is said.    SetListening(oPC,FALSE);   

Just keep in mind that by  replacing the conversation script you are disabling the part of the AI that controlls how the NPC reacts to what is going on around him.    example. If you attack an NPC he sends out a silent message that the was attacked.   other NPC hear that message in the OnConversation event and react to it.  Either by joining in the fight or running away.    By not allowing the Event to handle this by just replacing the event, your NPC's will basicly just ingnor combat going on around them.    OR any other shouts being made that they should be responding to.