Author Topic: Conversation Distance  (Read 379 times)

Legacy_Kelther

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Conversation Distance
« on: January 04, 2011, 05:44:43 am »


               I'm looking to script the following interaction elegantly. I have some parts of it correct, but there are other elements that need to be adjusted. This script regards meeting certain NPCs for the first time.

1. NPC "sees" player character. (OnUserDefined, flagged from default OnPerception script)

2. NPC says one-liner set as local variable. (ex. greeting)

3. NPC  walks over to PC until it reaches a certain distance.

4. NPC starts conversation.

Everything seems to work fine, except the one-liner is delayed until just before the conversation starts, and the NPC walks to a default conversation distance that I don't know how to change.

I should also mention that the script fired also activates cut scene mode, so the player can't escape the conversation and break plot until the conversation is completed.

Thank you for any assistance you can give from your experience.

James

<script>void main()
{
 int nEvent = GetUserDefinedEventNumber();
 string oneLine = GetLocalString(OBJECT_SELF, "oneLine");

 if (nEvent == 1002) // OnPerceive event
 {
   object oPC = GetLastPerceived();

   if(GetIsPC(oPC) && GetLocalInt(oPC, "Dlg_Init_" + GetTag(OBJECT_SELF)) == FALSE && !IsInConversation(OBJECT_SELF))
   {
       AssignCommand(OBJECT_SELF, ActionSpeakString(oneLine));
       SetCutsceneMode(oPC, TRUE, FALSE);

       ClearAllActions();

       AssignCommand(oPC, ClearAllActions());

       ActionStartConversation("", oPC);
   }
 }
}</script>
               
               

               


                     Modifié par Kelther, 04 janvier 2011 - 05:46 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Conversation Distance
« Reply #1 on: January 04, 2011, 06:32:47 am »


               


void main()

{

  int nEvent = GetUserDefinedEventNumber();

  string oneLine = GetLocalString(OBJECT_SELF, "oneLine");



  if (nEvent == 1002) // OnPerceive event

  {

    object oPC = GetLastPerceived();

    if(GetIsPC(oPC) && GetLocalInt(oPC, "Dlg_Init_" + GetTag(OBJECT_SELF)) == FALSE && !IsInConversation(OBJECT_SELF))

    {

      //First off Assigning commands to Object self like this is not a good Idea

      //Second since you are assigning it it will not be placed into the Npc's

      //Que untill this script is finished running.

      AssignCommand(OBJECT_SELF, ActionSpeakString(oneLine));

     

      SetCutsceneMode(oPC, TRUE, FALSE);

      ClearAllActions();



      AssignCommand(oPC, ClearAllActions());



      // This action will get placed into the npc's action que before

      // the script finishes running. So the NPC will start the conversation then

      // speak the one liner.

      ActionStartConversation("", oPC);

    }

  }

}




               
               

               


                     Modifié par Lightfoot8, 04 janvier 2011 - 06:35 .
                     
                  


            

Legacy_Kelther

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Conversation Distance
« Reply #2 on: January 04, 2011, 06:52:03 am »


               okk... I know exactly what the script does and there's no surprises there. I don't think I was very clear - I was wondering if there was a better way to do what I listed above, with the added benefit of the OneLiner popping immediately and the conversation distance set to 4.0f or so.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Conversation Distance
« Reply #3 on: January 04, 2011, 10:44:07 pm »


               Ok,  I though you where asking why your script was doing what it was doing. 

I have not tested this but it should work.

 
void main()
{
  int nEvent = GetUserDefinedEventNumber();
  string oneLine = GetLocalString(OBJECT_SELF, "oneLine");

  if (nEvent == 1002) // OnPerceive event
  {
    object oPC = GetLastPerceived();
    if(
        GetIsPC(oPC)
        && GetLocalInt(oPC, "Dlg_Init_" + GetTag(OBJECT_SELF)) == FALSE
        && !IsInConversation(OBJECT_SELF)
        && GetCommandable()
      )

    {
       AssignCommand(oPC, ClearAllActions(TRUE));
       SetCutsceneMode(oPC, TRUE, FALSE);


       ClearAllActions(TRUE);
       ActionMoveToObject(oPC,FALSE,4.0);
       ActionSpeakString(oneLine);
       ActionStartConversation( oPC);
       ActionDoCommand (SetCommandable(TRUE));
       SetCommandable(FALSE);
    }
  }
}
 

               
               

               


                     Modifié par Lightfoot8, 04 janvier 2011 - 10:45 .
                     
                  


            

Legacy_Kelther

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Conversation Distance
« Reply #4 on: January 05, 2011, 11:29:24 pm »


               Thank you for your help, Lightfoot! I threw the script in and cited you.



The NPC very clearly speaks while approaching the player, which is exactly what I was hoping for.