Difference between revisions of "Talk:GetDialogueTarget - Actor"

no edit summary
imported>Zartar
imported>Jbezorg
Line 55: Line 55:
== Notes ==
== 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.  
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.  
== Alternative Method ==
Same usage, slower, but in theory the examples above could miss the Dialogue target by testing the same NPC several times. Unlikely with a 200 unit radius but it also cannot test outside the 200 unit radius but I've had arresting city guards enter dialogue with the player at a much greater distance. ~[[jbezorg]]
<source lang="papyrus">
Actor Function GetPlayerDialogueTarget() global
Actor kPlayerRef = Game.GetPlayer()
Actor kTargetRef = None
Actor kNthRef    = None
Cell kCell      = kPlayerRef.GetParentCell()
Int iType        = 43 ; kNPC = 43
Int iIndex      = kCell.GetNumRefs( iType )
While iIndex && !kTargetRef
iIndex -= 1
kNthRef = kCell.GetNthRef( iIndex, iType ) as Actor
If kNthRef != kPlayerRef && kNthRef.IsInDialogueWithPlayer()
kTargetRef = kNthRef
EndIf
EndWhile
Return kTargetRef
EndFunction
</source>


== See Also ==
== See Also ==
Anonymous user