Author Sticky: Post Working Scripts Here
TheUglyOne Posted: Wednesday, 31 July 05:09AM
1) NPC appoach PC and initiate a conversation.

2) I know this has been covered in the OnPerception in the past. But I found that with all the different NPC's that I had in the area, those scripts didn't work. The NPC trying to initiate the conversation would sometimes get off track and try and talk to other NPC's. This was my sollution. This is 99.9% stolen from Bioware, but it definately serves its purpose well.

In the OnHeartbeat:

Code:
//Courtesy Bioware. Edited by TheUglyOne.

//This is an OnHeartbeat Script

//This searches for a PC within visual range who this NPC hasn't initiated

//dialogue with.  If one is present, the NPC will display a one line string

//overhead.

//Once conversation is initiated and the PC has hit continue at least once,

//The local int "Stop_Convo" + <tag of this character> should be set to TRUE

void main()

{

    if(IsInConversation(OBJECT_SELF) == FALSE)

    {

        int bFound = FALSE;

        int nNth = 1;

        object oPlayerInSight = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,

                                                   PLAYER_CHAR_IS_PC,

                                                   OBJECT_SELF,

                                                   nNth,

                                                   CREATURE_TYPE_PERCEPTION,

                                                   PERCEPTION_SEEN);

        while (GetIsObjectValid(oPlayerInSight) && bFound == FALSE)

        {

            if(GetLocalInt(oPlayerInSight,"Stop_Convo" + GetTag(OBJECT_SELF)) == FALSE)

            {

                bFound = TRUE;

            }

            else

            {

                nNth++;

                oPlayerInSight = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,

                                                    PLAYER_CHAR_IS_PC,

                                                    OBJECT_SELF,

                                                    nNth,

                                                    CREATURE_TYPE_PERCEPTION,

                                                    PERCEPTION_SEEN);

            }

        }

        if(bFound)

        {

         ActionMoveToObject(oPlayerInSight);

         ActionStartConversation (oPlayerInSight);

         }

    }

}



This gets put in an Actions Taken of the conversation tree. So that you dont end up in a conversation loop.

Code:
void main()

{

    SetLocalInt(GetPCSpeaker(),"Stop_Convo" + GetTag(OBJECT_SELF),TRUE);

}



Again, I can't take any scripting credit here, its all Bioware for the most part, I just edited it a tensy bit to suit my purpose, and make things a tiny bit clearer.