GetFactionOwner - ObjectReference

From Creation Kit
Jump to: navigation, search

Member of: ObjectReference Script

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

Syntax

Faction Function GetFactionOwner() native

Parameters

None.

Return Value

The Faction that owns this object.

Examples

Returning an explicit owner

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

Returning an inherited owner

; 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

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