Aller au contenu

Photo

NPC OnPerception Event


  • Veuillez vous connecter pour répondre
2 réponses à ce sujet

#1
tmanfoo

tmanfoo
  • Members
  • 85 messages
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 .


#2
Baragg

Baragg
  • Members
  • 271 messages
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.

#3
tmanfoo

tmanfoo
  • Members
  • 85 messages
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 .