ActionStartConversation(object, string, int, int)

NPC action to start a conversation with a PC

void ActionStartConversation(
    object oObjectToConverseWith,
    string sDialogResRef = "",
    int bPublicConversation = FALSE,
    int bPlayHello = TRUE
);

Parameters

oObjectToConverseWith

An object to converse with.

sDialogResRef

The resource reference (filename) of a conversation. (Default: "")

bPublicConversation

Specify whether the conversation is audible to everyone or only to the PC. (Default: FALSE)

bPlayHello

Determines if initial greeting is played. (Default: TRUE)


Description

Using this function in a script adds ActionStartConversation to the executing object's Action Queue.

When an object executes ActionStartConversation, it attempts to use the dialogue file specified as sDialogResRef to start conversing with the target, oObjectToConverseWith. If the target is not a PC, the target's onConversation event fires.

sResRef is the filename resource reference of a conversation file. If no sResRef is specified, then default conversation of whichever object is not the PC is used (set in its properties in the Toolset).

If bPublicConversation is unspecified or FALSE, then the conversation remains between the PC and the other object. Otherwise, the conversation is broadcast as chat, and 'audible' to other players.



Remarks

PCs can have dialogue with NPCs, placeables, triggers and doors. Items cannot converse (but invisible placeables with the same name as an item can).

Note that originally bPublicConversation was named bPrivateConversation (from BioWare's prototype) but this parameter name is confusing as it works opposite as one would expect.

Any immobile object in a conversation must be within the PC's camera view (approximately 10 meters when the camera is auto-zoomed in). If you try to start a conversation between a door and a PC, and the door is more than 10 meters away, the conversation box will appear briefly and then close immediately, although the door's first line will appear in the PC's chat window. If the object executing the action is mobile, it will attempt to run to oObjectToConverseWith and begin conversation, but will give up if another action is added to its queue

Unreliable results can occur from using AssignCommand() to add ActionStartConversation() to a PC's action queue, since players' normal movement commands are very likely to cancel the action.

sResRef is the filename of the conversation file, which is the string that appears in the Module Contents' "Conversations" chooser.

PCs do not have the OnConversation event, and do not have a default conversation file.

It is not possible at present to control camera zoom, although angle and mode can be scripted.


Known Bugs

Prior to patch 1.28, ActionStartConversation caused a crash when it was assigned to an area or module.


Version

1.61

Example

// ---    NPCs   ----
/* 
 * In the OnPerception event of an NPC, this will cause the 
 * NPC to start the "q_dragnbone" conversation 
 * default conversation with the first PC it perceives. The 
 * conversation will only be heard by the PC
 */
ActionStartConversation( GetLastPerceived(), "q_dragnbone");

// --- Placeables ---
/* 
 * In the OnUsed event of a non-static placeable, this will 
 * start the placeable's default conversation (set on the 
 * advanced tab of Placeable Properties) with a PC that 
 * uses the placeable.
 */
ActionStartConversation( GetLastUsedBy() );

/* 
 * In the OnUsed event of a non-static placeable, this will 
 * start the conversation in a file called "offer_healing"
 * with the PC that used the placeable.  Other Players will
 * be able to hear the conversation
 */
ActionStartConversation( GetLastUsedBy(), "offer_healing", TRUE );

// --- Triggers ---
/* 
 * In the OnEnter script of a trigger, this will cause an
 * entering PC to try start the "odd_voice" conversation
 * with the trigger. Only the PC entering will hear the
 * conversation. Player movement may cancel this
 * conversation before it begins, however.
 */
ActionStartConversation( GetLastEntering(), "odd_voice" );

/*
 * In the OnEnter script of a trigger, an NPC with the
 * tag "rat_boy" will run towards the PC and attempt to 
 * start his default conversation.  The conversation will
 * be audible to others. Also, Rat Boy's onConversation
 * event will fire, and if present, should conclude with
 * BeginConversation. If a different conversation resref is
 * set during the execution of the onConversation script,
 * that conversation will be begun.
 */
object oBoy = GetObjectByTag("rat_boy");
object oPC = GetEnteringObject();
AssignCommand(oBoy, ActionStartConversation(oPC, "", TRUE));

See Also

functions: ActionPauseConversation | ActionResumeConversation | ActionSpeakString | BeginConversation | FloatingTextStringOnCreature | GetLastSpeaker | GetPCSpeaker | PersistentConversationAttempt
categories: Action on Object Functions | Conversation Functions


 author: Iskander Merriman, editor: Charles Feduke, additional contributor(s): Michael Mason, John Detwiler, Jotham, Jassper, Agard
 Send comments on this topic.