Author Topic: NPC OnPerception Event  (Read 470 times)

Legacy_tmanfoo

  • Full Member
  • ***
  • Posts: 129
  • Karma: +0/-0
NPC OnPerception Event
« on: October 04, 2010, 09:57:05 pm »


               Ok, so I wrote this tiny bit of code to learn a bit about
the whole perception thing in NWN.  I found that the OnPerception event
fires twice.  Anyone know why that is?  Or how to make it fire only
once?

1 PC and 1 NPC in the area.

This is attached to the OnPerception NPC event, and all other scripts have been
removed from their respective events as a sanity check.

void main()

{
    SpeakString("I see you " + GetName(GetLastPerceived()),TALKVOLUME_SHOUT);
}

Any info would be helpful, I intend to attach this event to a database for a
NPC-Memory & Player reaction, but if it's going to fire off twice at
everything, I may have to re-think how to go about things.

Cheers,

T
               
               

               


                     Modifié par tmanfoo, 05 octobre 2010 - 12:19 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
NPC OnPerception Event
« Reply #1 on: October 04, 2010, 10:27:23 pm »


               Maybe, and I could be wrong it is firing once to check if the object is seen and once to see if it is heard. But I could well be wrong. I believe you can use GetLastPerceptionSeen or GetLastPerceptionHeard, to weed em out from one another.
               
               

               
            

Legacy_tmanfoo

  • Full Member
  • ***
  • Posts: 129
  • Karma: +0/-0
NPC OnPerception Event
« Reply #2 on: October 05, 2010, 01:20:34 am »


               Well I hadn't even thought of that.  I guess my debug session didn't make it too far; kids need to nap longer sometimes!

Anyways, thanks for the feedback, I'll check to see if it's calling separate events for seen & heard.

Update: It indeed fires once for each subtype of perception.  No wonder it's so high on the number of script calls.
               
               

               


                     Modifié par tmanfoo, 05 octobre 2010 - 01:43 .