Dialogue sound length?

// NWNScript for cinematic dialogue
void main()
{
    // Get the NPC who is speaking
    object oPC = GetPCSpeaker();
    object oSelf = OBJECT_SELF;

    // Attach the camera to the NPC, set bFindClearView to "true" to make the camera look at the NPC
    AttachCamera(oPC, oSelf, TRUE);

    // Delay the camera detachment by the length of the dialog sound
    float fDelay = GetDialogSoundLength("") / 1000.0;

    // Detach the camera after the delay
    DelayCommand(fDelay, DetachCamera());
}

Unfortunately, this doesn’t work. I can’t find a convenient way to use GetDialogSoundLength on the current audio file in the conversation.

Can StrRef be defined dynamically, like OBJECT_SELF?

One thing that I notice offhand: GetDialogSoundLength takes an integer variable, not a string.

image

The parameter is a StrRef, so it points to a tlk line. You can use lines from dialog.tlk or from your custom tlk.

Alright, thanks. Is there a way to make “AttachCamera” instant? Can I use “CAMERA_TRANSITION_TYPE_SNAP”?

I have a new script. My new problem is that the “LockCamera” functions prevents the other camera functions from making changes.

// NWScript for cinematic dialogue
void main()
{
    // Get the NPC who is speaking
    object oPC = GetPCSpeaker(); // the player
    object oSelf = OBJECT_SELF;

    // Saves the players current camera
    StoreCameraFacing();

    {
        // Attach the camera to the NPC, set bFindClearView to "true" to make the camera look at the NPC
        //AttachCamera(oPC, oSelf, TRUE);
        AttachCamera(oPC, oSelf, FALSE);

        //Prevents the player from moving the camera during conversation
        //SetCameraLimits(oPC, 89.0, 89.0, 1.0, 3.0);

        // Sets the pitch to 89
        AssignCommand(oPC, SetCameraFacing(-1.0f, 2.0, 89.0));

        {
            SetCameraHeight(oPC, 1.5);

            {

                LockCameraDirection(oPC);
                LockCameraDistance(oPC);
                LockCameraPitch(oPC);

            }
        }
    }
}