Author Topic: Target character leaving moduel after conversation is finish.  (Read 859 times)

Legacy_simomate

  • Full Member
  • ***
  • Posts: 162
  • Karma: +0/-0
Target character leaving moduel after conversation is finish.
« on: September 18, 2010, 01:31:22 pm »


               So for my Mod, I require the person, in which the player speaks to, to leave the area after the conversation is over. How do I achieve this?
               
               

               
            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0
Target character leaving moduel after conversation is finish.
« Reply #1 on: September 18, 2010, 05:01:46 pm »


               One way to do it is to have the creature walk away towards a waypoint and disappear on the way.

This is an ActionsTaken script for the last line of the conversation when the npc is going to leave.
1) Make a waypoint at the location you want the npc to walk to.  ( I tagged mine "ExitWaypoint")
2) ClearAllActions makes sure that the Npc won't do anything unexpected.
3) Destroy the npc (but not for 5 seconds)
4) Immediately have the npc walk to the waypoint.

Notice that the walk action happens before destroy even though destroy is first in the script.  That is because of the 5.0 which is a delay time.


void main()
{
    object wp = GetWaypointByTag( "ExitWaypoint" );
    ClearAllActions(TRUE);
    DestroyObject( OBJECT_SELF, 5.0 );
    ActionMoveToObject( wp );
}


If you want the npc to be somewhere else later. You can create one at the destination. 
               
               

               
            

Legacy_simomate

  • Full Member
  • ***
  • Posts: 162
  • Karma: +0/-0
Target character leaving moduel after conversation is finish.
« Reply #2 on: September 23, 2010, 11:45:21 am »


               Hey thanks, it worked. But what say, I have 4 children, who all run into the forest after the convo is finished?
               
               

               
            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0
Target character leaving moduel after conversation is finish.
« Reply #3 on: September 23, 2010, 05:20:05 pm »


               Ok, this assumes that the 4 children all have the same tag which is "ChildTag".

void main()
{
    int i;
    object child;
    for( i=0; i<4; i++ )
    {
        child = GetObjectByTag("ChildTag",i);
        AssignCommand( child, ClearAllActions(TRUE) );
        DestroyObject( child, 5.0 );
        AssignCommand( child, ActionMoveToObject( wp ));
    }
}

The lexicon looks like the GetObjectByTag uses 0 to (N-1) for the children.  It might be wrong.  If so then the loop would be:
for( i=1; i<=4; i++)
               
               

               
            

Legacy_simomate

  • Full Member
  • ***
  • Posts: 162
  • Karma: +0/-0
Target character leaving moduel after conversation is finish.
« Reply #4 on: September 24, 2010, 07:29:34 am »


               I require the tags to be different, for each one talks during the conversation.
               
               

               
            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0
Target character leaving moduel after conversation is finish.
« Reply #5 on: September 24, 2010, 04:44:30 pm »


               Then incorporate the number into the tag.
Like:  Child0,Child1,Child2,Child3

void main()
{
        int i;
        object child;
        for( i=0; i<4; i++)
        {
              string childTag = "Child"+IntToString(i);
                child = GetObjectByTag(childTag);
                AssignCommand( child, ClearAllActions(TRUE) );
                DestroyObject( child, 5.0 );
                AssignCommand( child, ActionMoveToObject( wp ));
        }
}
               
               

               


                     Modifié par Mudeye, 24 septembre 2010 - 03:45 .