How do you make a henchman INITIATE a conversation when you do something?

#1

Hi, everyone. Just wondering. How do you make a henchman initiate a conversation when you do something, say open a door? Presumably you’ll need to place some script in the OnOpen slot of the door. I already know how to make a henchman blurt out a one-liner in this way, but now I’m aiming for more: I want the henchman – and only the henchman of my specification, so that if I happen to have another henchman that other one will keep silent – to start with a specified node (how to specify?) in the conversation file assigned to him as a henchman. (Or should it be a separate conversation file altogether, to be specially created for the present purpose?) I suppose I’d need to use ActionStartConversation, but I’m not sure how.

I reckon the script should go something like this if I have a henchman named Aiden:

void main()
{
//Verify that the user is Aiden’s Master.
object oAiden = GetObjectByTag(“aiden”);
object oClicker = GetLastUsedBy();
object oMaster = GetMaster(oAiden);
if (oClicker == oMaster)
{
//Verify that Aiden is still alive.
object oAiden = GetObjectByTag(“aiden”);
if (oAiden != OBJECT_INVALID)
{
//If he is, let him start a conversation and make sure he only does this once, meaning he won’t do it again if you open the thing again later.
int iAidenTalk = GetLocalInt(OBJECT_SELF, “AidenTalk”);
if (iAidenTalk < 1)
{
SetLocalInt(OBJECT_SELF, “AidenTalk”, 1);
??? (here’s where I wouldn’t really know what to do…);
}
}
}
}

Help, please, anyone? Thanks!

#2

The simplest method would be

AssignCommand(oAiden, ActionStartConversation(oMaster, "foobar", FALSE, FALSE));

where foobar is the name of the conversation.

This might fail if the associate is busy, out of conversation range, or interrupted by AI. Here’s a function I use to overcome that:

void bhForceConversation(object oNPC, object oPC, int nRun, string sConversation, int nJump)
{
    float fRange = 10.0;

    ClearAllActions(TRUE);

    if ((GetDistanceBetween(oPC, oNPC) > fRange)
    ||  (GetArea(oPC) != GetArea(oNPC)))
      {
        if (nJump)
          ActionJumpToLocation(GetLocation(oPC));
        else
        ActionMoveToObject(oPC, nRun, fRange);
      }

    ActionStartConversation(oPC, sConversation, FALSE, FALSE);
    ActionDoCommand(SetCommandable(TRUE));
    SetCommandable(FALSE);
}

which you would invoke by

AssignCommand(oAiden, bhForceConversation(oAiden, oMaster, TRUE, "foobar", TRUE));

assuming you were happy for the associate to run or jump to the PC before starting the conversation.

This still won’t work if the associate is dead, paralysed or similar, but that might be desirable.

2 Likes
#3

Will be trying this out. Thanks ever so much! :+1:

1 Like
#4

Don’t forget that there are the original scripting FAQs (Frequently Asked Questions with answers) on here that you can download. There are a number of conversation scripts (amongst a number of topics) in there that you can either use or adapt for your own use. Even if what you need to know is not covered there are almost certainly things in there that you will find useful.

TR

2 Likes
#5

To Proleric:

Your suggestions worked beautifully when I placed the scripts in the OnOpen slot of doors and placeables. Thanks ever so much. :smile: They don’t seem to work when used with triggers, though. Guess I’ll have to experiment a bit to find out how to make them work with triggers. Thanks again all the same!

To Tarot Redhand:

Will be checking out the FAQs. I’m sure there’ll be useful stuff there. Thanks for letting me know of them! :+1:

1 Like
#6

Those techniques do work in triggers. Check that the entering object is a PC and clear their actions. Personally, I freeze the PC for a moment, to stop them cancelling any actions in the script, but looking at other modules I can see that’s not strictly necessary.

1 Like
#7

I just discovered that when trying to make the thing work with triggers, I forgot to change the line

object oClicker = GetLastUsedBy();

to

object oClicker = GetEnteringObject();

Once I remedied this, everything worked nicely again. Thought I’d share how I overcame the problem. Thanks yet again for the help. :smile:

1 Like