Difference between revisions of "GetFactionOwner - ObjectReference"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Rhavlovick
m (1 revision: Clobber re-import by Henning)
 
imported>Fireundubh
(explicit vs. inherited ownership)
 
Line 6: Line 6:


== Syntax ==
== Syntax ==
<source lang="papyrus">
<source lang="papyrus">
Faction Function GetFactionOwner() native
Faction Function GetFactionOwner() native
Line 11: Line 12:


== Parameters ==
== Parameters ==
None.
None.


== Return Value ==
== Return Value ==
The [[Faction Script|Faction]] that owns this object.
The [[Faction Script|Faction]] that owns this object.


== Examples ==
== Examples ==
=== Returning an explicit owner ===
<source lang="papyrus">
<source lang="papyrus">
; Does the empire own the walker?
; Does the player faction own the sword?
bool ownsWalker = (WalkerProperty.GetFactionOwner() == EmpireFactionProperty)
Bool playerFactionOwnsSword = SwordProperty.GetFactionOwner() == PlayerFactionProperty
</source>
</source>
=== Returning an inherited owner ===
<source lang="papyrus">
; Does the player faction own the sword?
Bool playerFactionOwnsSword = GetInheritedOwner(SwordProperty, SwordRackProperty) == PlayerFactionProperty
Faction Function GetInheritedOwner(ObjectReference aObj, ObjectReference aContainer)
    Faction factionOwner = aObj.GetFactionOwner()
    If !factionOwner
        If aContainer
            factionOwner = aContainer.GetFactionOwner()
            If !factionOwner
                factionOwner = aContainer.GetParentCell().GetFactionOwner()
            EndIf
        EndIf
        If !factionOwner
            factionOwner = aObj.GetParentCell().GetFactionOwner()
        EndIf
    EndIf
    Return factionOwner
EndFunction
</source>
== Notes ==
=== Explicit vs. Inherited Ownership ===
Object references can have explicit owners and inherited owners. An ''explicit owner'' is associated directly with the object. An ''inherited owner'' is derived from the container that contains the object, the cell that contains the object, or the cell that contains the container that contains the object when the object has not been associated with an explicit owner. GetFactionOwner() returns only the explicit owner of an object reference and None when an explicit owner is not found.


== See Also ==
== See Also ==
*[[ObjectReference Script]]
 
*[[SetFactionOwner - ObjectReference]]
* [[ObjectReference Script]]
* [[SetFactionOwner - ObjectReference]]

Latest revision as of 02:56, 8 September 2015

Member of: ObjectReference Script

Gets the Faction that owns this object. Will return None if the object isn't owned by a faction.

Syntax[edit | edit source]

Faction Function GetFactionOwner() native

Parameters[edit | edit source]

None.

Return Value[edit | edit source]

The Faction that owns this object.

Examples[edit | edit source]

Returning an explicit owner[edit | edit source]

; Does the player faction own the sword?
Bool playerFactionOwnsSword = SwordProperty.GetFactionOwner() == PlayerFactionProperty

Returning an inherited owner[edit | edit source]

; Does the player faction own the sword?
Bool playerFactionOwnsSword = GetInheritedOwner(SwordProperty, SwordRackProperty) == PlayerFactionProperty

Faction Function GetInheritedOwner(ObjectReference aObj, ObjectReference aContainer)
    Faction factionOwner = aObj.GetFactionOwner()
    If !factionOwner 
        If aContainer
            factionOwner = aContainer.GetFactionOwner()
            If !factionOwner 
                factionOwner = aContainer.GetParentCell().GetFactionOwner()
            EndIf
        EndIf
        If !factionOwner 
            factionOwner = aObj.GetParentCell().GetFactionOwner()
        EndIf
    EndIf
    Return factionOwner
EndFunction

Notes[edit | edit source]

Explicit vs. Inherited Ownership[edit | edit source]

Object references can have explicit owners and inherited owners. An explicit owner is associated directly with the object. An inherited owner is derived from the container that contains the object, the cell that contains the object, or the cell that contains the container that contains the object when the object has not been associated with an explicit owner. GetFactionOwner() returns only the explicit owner of an object reference and None when an explicit owner is not found.

See Also[edit | edit source]