Aller au contenu

Photo

Modifying OnPerception script to save a local int if the NPC sees the PC


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

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I want to save a local int on an NPC if it sees the PC.  I am doing this by modifying the main function of the standard on perception script.  I am just putting in some lines to save the local int if oPercep (defined by GetLastPerceived()) == PC.  Is this going to break the AI?  I am asking because I have not changed the AI coding much.  Any input is really appreciated.

#2
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
No it should not be an issue, make sure you use GetObjectSeen too though, perception does not always mean the creature seeing, it's more something done within a certain range to allow that function to fire, or when states change, it can fire a lot.



int GetObjectSeen(object oTarget, object oSource=OBJECT_SELF);

int GetObjectHeard(object oTarget, object oSource=OBJECT_SELF);

( and i always do range as well )



Might be a better solution than modding the AI which i would avoid, to just use the above in whatever real code is doing the work.

#3
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Thanks pain. That's what I ended up doing. I found the function that handles the object that is seen and just modified that one. It worked really well.