Difference between revisions of "GetPCSpeaker"

From NWN Lexicon
Jump to: navigation, search
(Created page with " =GetPCSpeaker()= Retrieves the PC that is currently in a conversation with an NPC. object  GetPCSpeaker(); ====Description==== Returns the P...")
 
 
(9 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 
+
{{DISPLAYTITLE:GetPCSpeaker()}}__NOTOC__
 
 
 
 
 
 
=GetPCSpeaker()=
 
 
 
 
Retrieves the PC that is currently in a conversation with an NPC.
 
Retrieves the PC that is currently in a conversation with an NPC.
 +
<nwscript>
 +
object GetPCSpeaker();
 +
</nwscript>
  
[[object | object ]] GetPCSpeaker();
+
====Description====
  
====Description====
+
Returns the PC that is speaking in the current conversation.
  
Returns the PC that is speaking in the current conversation. <br /><br /> It will return OBJECT_INVALID if there is no PC speaker, for example, with SpeakOneLinerConversation().
+
It will return OBJECT_INVALID if there is no PC speaker, for example, with [[SpeakOneLinerConversation]]().
  
<br /><br />
 
  
 
====Remarks====
 
====Remarks====
  
This function can only be used in scripts that are called as part of a conversation, and always returns the PC talking. <br /><br /> Of course, if it is an NPC speaking to another NPC, it will return the NPC who is the one who takes the conversation choices (NPC's always take the first one after a short delay).
+
This function can only be used in scripts that are called as part of a conversation, and always returns the PC talking.
 +
 
 +
Of course, if it is an NPC speaking to another NPC, it will return the NPC who is the one who takes the conversation choices (NPC's always take the first one after a short delay).
  
<br />
 
  
 
====Version====
 
====Version====
Line 27: Line 25:
 
====Example====
 
====Example====
  
<font color="#007f00">// An "Actions Taken" script to set a quest variable on the PC
+
<nwscript>
</font><font color="#007f00">// in an NPC conversation
+
// An "Actions Taken" script to set a quest variable on the PC
</font><font color="#0000ff">void</font> main() {
+
// in an NPC conversation
  <font color="#0000ff">object</font> oPC = GetPCSpeaker();
+
void main() {
  SetLocalInt( oPC, <font color="#00007f">"golden_duck"</font>, <font color="#7f007f">100</font>);
+
  object oPC = GetPCSpeaker();
}
+
  SetLocalInt( oPC, "golden_duck", 100);
<font color="#007f00">// --- end of the 'Actions Taken' example.
+
}
</font>
+
// --- end of the 'Actions Taken' example.
<font color="#007f00">// a StartingConditional for the "Text Appears When"
+
 
</font><font color="#007f00">// script of an NPC conversation. The conversation node
+
// a StartingConditional for the "Text Appears When"
</font><font color="#007f00">// this script is attached to will only appear when the PC
+
// script of an NPC conversation. The conversation node
</font><font color="#007f00">// variable "golden_duck" has set to 100.
+
// this script is attached to will only appear when the PC
</font><font color="#0000ff">int</font> StartingConditional() {
+
// variable "golden_duck" has set to 100.
  <font color="#0000ff">object</font> oPC = GetPCSpeaker();
+
int StartingConditional() {
  <font color="#0000ff">int</font> nDuckState = GetLocalInt( oPC, <font color="#00007f">"golden_duck"</font>);
+
  object oPC = GetPCSpeaker();
  <font color="#0000ff">if</font> (<font color="#7f007f">100</font> == nDuckState) <font color="#0000ff">return</font> <font color="#0000ff">TRUE</font>;
+
  int nDuckState = GetLocalInt( oPC, "golden_duck");
  <font color="#0000ff">return</font> <font color="#0000ff">FALSE</font>;
+
  if (100 == nDuckState) return TRUE;
}
+
  return FALSE;
 +
}
 +
</nwscript>
  
 
====See Also====
 
====See Also====
Line 51: Line 51:
 
| width="1px" align="right" valign="top" | <font color="gray">functions: </font>
 
| width="1px" align="right" valign="top" | <font color="gray">functions: </font>
 
|
 
|
[[  GetLastSpeaker  | GetLastSpeaker ]]
+
[[  GetLastSpeaker  | GetLastSpeaker ]] [[SpeakOneLinerConversation]] [[BeginConversation]] [[ActionStartConversation]]
 
|-
 
|-
 
|-
 
|-

Latest revision as of 20:31, 6 December 2020

Retrieves the PC that is currently in a conversation with an NPC.

Description

Returns the PC that is speaking in the current conversation.

It will return OBJECT_INVALID if there is no PC speaker, for example, with SpeakOneLinerConversation().


Remarks

This function can only be used in scripts that are called as part of a conversation, and always returns the PC talking.

Of course, if it is an NPC speaking to another NPC, it will return the NPC who is the one who takes the conversation choices (NPC's always take the first one after a short delay).


Version

1.28

Example

// An "Actions Taken" script to set a quest variable on the PC
// in an NPC conversation
void main() {
  object oPC = GetPCSpeaker();
  SetLocalInt( oPC, "golden_duck", 100);
}
// --- end of the 'Actions Taken' example.
 
// a StartingConditional for the "Text Appears When"
// script of an NPC conversation. The conversation node
// this script is attached to will only appear when the PC
// variable "golden_duck" has set to 100.
int StartingConditional() {
  object oPC = GetPCSpeaker();
  int nDuckState = GetLocalInt( oPC, "golden_duck");
  if (100 == nDuckState) return TRUE;
  return FALSE;
}

See Also

functions: 

GetLastSpeaker SpeakOneLinerConversation BeginConversation ActionStartConversation

events: 

OnConversation Event



 author: Iskander Merriman, editor: Jasperre, additional contributor(s): Charles Feduke