Difference between revisions of "Talk:GetDialogueTarget - Actor"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Zartar
(Created page with "Obtains the actor the player is currently in dialogue with. == Syntax == <source lang="papyrus"> Actor Function GetPlayerDialogueTarget() non-native Actor kPlayerDialogueTar...")
 
imported>Zartar
Line 4: Line 4:
<source lang="papyrus">
<source lang="papyrus">
Actor Function GetPlayerDialogueTarget() non-native
Actor Function GetPlayerDialogueTarget() non-native
Source:
Actor Function GetPlayerDialogueTarget()
Actor kPlayerDialogueTarget
Actor kPlayerDialogueTarget
         Actor kPlayerRef = Game.GetPlayer()
         Actor kPlayerRef = Game.GetPlayer()

Revision as of 21:04, 9 February 2013

Obtains the actor the player is currently in dialogue with.

Syntax

Actor Function GetPlayerDialogueTarget() non-native

Source:

Actor Function GetPlayerDialogueTarget()
	Actor kPlayerDialogueTarget
        Actor kPlayerRef = Game.GetPlayer()
	Int iLoopCount = 10
	While iLoopCount > 0
		iLoopCount -= 1
		kPlayerDialogueTarget = Game.FindRandomActorFromRef(kPlayerRef , 200.0)
		If kPlayerDialogueTarget != kPlayerRef && kPlayerDialogueTarget.IsInDialogueWithPlayer() 
			Return kPlayerDialogueTarget
		EndIf
	EndWhile
        Return None
EndFunction

Parameters

None.

Return Value

The actor the player is currently in dialogue with (if any).

Examples

; Print a message if the player is in dialogue with Bob.
if (GetPlayerDialogueTarget() == Bob)
  Debug.Trace("The player is in dialogue with Bob!")
endIf

Notes

This usually finds the actor the player is in dialogue with but more testing is required. It works very well for me, so far... I tend to modify this by passing in the player's reference and lowering iLoopCount but the version I posted is safe and convenient.

See Also