Relationships
These are Relationship form (RELA) specific functions. These are low level 'building block' functions.
Spoiler
; Returns an array of Relationship forms that reference the given ActorBase Form[] Function GetRelationshipsForActor(ActorBase akBase) Global Native ; Returns the 'parent' Npc ActorBase of a relationship form ActorBase Function GetRelationshipParent(Form akRelationship) Global Native ; Returns the 'child' Npc ActorBase of a relationship form ActorBase Function GetRelationshipChild(Form akRelationship) Global Native ; Returns the Association type form (ASTP) between the two actors. Eg: ParentChild, Siblings, Spouse Form Function GetRelationshipAssociation(Form akRelationship) Global Native ; Returns the relationship rank between the two actors. Int Function GetRelationshipLevel(Form akRelationship) Global Native
Relation functions (more practical):
Spoiler
; Returns an array of BaseActor[] that have a relationship of some sort with akActor ; This array correspond as a 1:1 map with the results of GetRelations(), GetRelationsRefs(), GetRelationsTitles() & GetRelationsRanks() ActorBase[] Function GetRelations(Actor akActor) Global Native ; Returns an array of Actor[] that have some kind of relationship with akActor ; This array correspond as a 1:1 map with the results of GetRelations(), GetRelationsRefs(), GetRelationsTitles() & GetRelationsRanks() Actor[] Function GetRelationsRefs(Actor akActor) Global Native ; Returns an array of String[] relationship titles that akActor has. ; This array correspond as a 1:1 map with the results of GetRelations(), GetRelationsRefs(), GetRelationsTitles() & GetRelationsRanks() ; This function first and foremost returns the 'association type' - see below. String[] Function GetRelationsTitles(Actor akActor) Global Native ; Returns an array of Int[] relationship ranks that akActor has ; This array correspond as a 1:1 map with the results of GetRelations(), GetRelationsRefs(), GetRelationsTitles() & GetRelationsRanks() Int[] Function GetRelationsRanks(Actor akActor) Global Native ; Returns the relationship title from akActorA's perspective of akActorB. ; Returns empty string if no relationship exists. ; Returns the FIRST relationship title if multiple exist. String Function GetRelationshipTitle(Actor akActorA, Actor akActorB) Global Native ; Returns ALL relationship titles from akActorA's perspective of akActorB. ; Returns an empty array if none exist. String[] Function GetAllRelationshipTitles(Actor akActorA, Actor akActorB) Global Native ; Returns all actor bases with the specified relationships. ; Actor doesn't need to be loaded in memory but these are obviously bases not references. ; See GetActorsInAreaWithRelationship() for common relationship Titles. ; If provided with an empty RelationshipTitles array will return all relations. ActorBase[] Function GetActorBasesWithRelationship(Actor akActor, String[] RelationshipTitles) Global Native ; Returns all actor references with the specified relationships. ; Actor must be loaded in memory to be returned. Tends to work well despite the memory requirement since disposable actors don't generally have relationships. ; See GetActorsInAreaWithRelationship() for common relationship Titles. ; If provided with an empty RelationshipTitles array will return all relations. ; ReverseFilter: False = Return actors matching RelationshipTitles. True: Return actors that don't match RelationshipTitles. Actor[] Function GetActorsWithRelationship(Actor akActor, String[] RelationshipTitles, Bool ReverseFilter = false) Global Native ;/ Full list of possible vanilla relationships: Association type Relationships: Brother Sister Father Mother Son Daughter Aunt Uncle Niece Nephew Cousin Husband Wife Master Assistant Jarl Steward Housecarl Brother-in-Law Sister-in-Law Grandmother Grandfather Grandson Granddaughter Granduncle Grandaunt Grandnephew Grandniece Uncle-in-Law Aunt-in-Law Nephew-in-Law Niece-in-Law Boss Employee Grandfather-in-Law Grandmother-in-Law Grandson-in-Law Granddaughter-in-Law Great-Grandfather Great-Grandmother Great-Grandson Great-Granddaughter Father-in-Law Mother-in-Law Son-in-Law Daughter-in-Law Partner Boyfriend Girlfriend Acquaintance Conspirator Rank Titles (Fallback title - No association) 0 - Lover 1 - Ally 2 - Confidant 3 - Friend 4 - Acquaintance 5 - Rival 6 - Foe 7 - Enemy 8 - Archnemesis /; ; Returns a group of actors that share at least one relationship in RelationshipTitles[]. This returns a single 'grouping'. ; RelationshipTitles: See above for possibilities. ; akLoc: Restricts the NPC search. 0 - akLoc location level only, 1 - akLoc location level and one level up, 2 - akLoc location and 2 levels up, 3 - akLoc location and 3 levels up. ; ExcludeActors: Exclude these actors from results. Empty array = no exclusions. ; Note on locations. Most locations are set up as a hierarchy. For example, Sleeping Giant Inn is: ; SleepingGiantInnLocation ; RiverwoodLocation ; WhiterunHoldLocation ; TamrielLocation ; So if akLoc = SleepingGiantInnLocation and you wanted only Sleeping Giant Inn Npcs you'd use 0 (SleepingGiantInnLocation). ; If you wanted any Npc in Riverwood then you'd use 1 (SleepingGiantInnLocation + RiverwoodLocation) ; If you wanted any NPC in Whiterun hold, you'd use 2 (SleepingGiantInnLocation + RiverwoodLocation + WhiterunHoldLocation) Actor[] Function GetActorsInAreaWithRelationship(String[] RelationshipTitles, Location akLoc = None, Int LocLevel = 0, Actor[] ExcludeActors) Global Native ; Returns all actors in the given location with any of the listed relationships. ; RelationshipTitles: Titles to match (or exclude if abReverseTitleFilter is true) ; ReverseTitleFilter: If true, returns actors that do NOT have any of the listed relationship titles ; Location: Specific location to filter by. If None, uses player's current location ; LocationLevel: 0=Exact location, 1=Parent (town), 2=Grandparent (hold), 3=Great-grandparent ; ExcludeActors: Exclude these actors from results. Empty array = no exclusions. Actor[] Function GetAllActorsInAreaWithRelationship(String[] RelationshipTitles, Bool ReverseTitleFilter = false, Location akLoc = None, Int LocLevel = 0, Actor[] ExcludeActors) Global Native ; Finds a POTENTIAL compatible (unrelated, unattached) pair of actors from the provided array. ; Sexuality: 0 = Heterosexual (1 male + 1 female), 1 = Gay (2 males), 2 = Lesbian (2 females). This is just a gender check. ; ExtraExcludeTitles: Additional relationship titles to exclude on top of hardcoded defaults. ; Hardcoded exclusions cover Husband, Wife, Boyfriend, Girlfriend, Lover. These are already a couple. ; FamilyExcludeMask: Bitmask controlling which family relationships are excluded per-pair. ; ExcludeActors: Exclude these actors from results. Empty array = no exclusions. ; FamilyExcludeMask: ; Bit 0 (1) - Siblings: Brother, Sister ; Bit 1 (2) - Parents/Children: Father, Mother, Son, Daughter ; Bit 2 (4) - Grandparents/children: Grandfather, Grandmother, Grandson, Granddaughter ; Bit 3 (8) - Aunts/Uncles/Nieces/Nephews: Aunt, Uncle, Niece, Nephew ; Bit 4 (16) - Cousins: Cousin ; Bit 5 (32) - In-Laws: Father-in-Law, Mother-in-Law, Son-in-Law, ; Daughter-in-Law, Brother-in-Law, Sister-in-Law ; Bit 6 (64) - Extended: Great-grandparents/children, Grand in-laws, ; Granduncle/aunt/nephew/niece, Uncle/Aunt/Nephew/Niece-in-Law ; Default 0xFF (255) excludes all family types (most restrictive) ; Pass 0 to allow all family relationships (least restrictive) ; Pass 254 to allow siblings only (all excluded except siblings) ; Pass 253 to allow parents/children only (all excluded except parents/children) ; Pass 252 to allow both siblings and parents/children (all excluded except those two) Actor[] Function GetCompatiblePair(Actor[] akActors, Int Sexuality = 0, String[] akExtraExcludeTitles, Int FamilyExcludeMask = 0xFF, Actor[] ExcludeActors) Global Native ; Sorts a list of actors by family hierarchy. ; ; Without akAnchor — unit based scoring: ; 40 — Elder married pair ; 30 — Single elder adult ; 20 — Non-elder married pair ; 10 — Single non-elder adult ; 0 — Children (IsChild(), always last) ; ; With akAnchor — relationship-relative ordering: ; 0. Anchor (always first) ; 1. Anchor's Spouse (Husband / Wife) ; 2. Anchor's Parents (Father / Mother) ; 3. Anchor's Spouse's Parents (Father / Mother vs Spouse) ; 4. Anchor's Grandparents (Grandfather / Grandmother) ; 5. Anchor's Siblings (Brother / Sister) ; 6. Anchor's Adult Children (Son / Daughter, !IsChild()) ; 7. Remaining adults (elder, preferred gender. May not be related) ; 8. Children (IsChild(), always last) ; ; Within each group: elder first, then GenderPriority as tiebreaker. ; GenderPriority: 0 = no preference, 1 = male first (default), 2 = female first Actor[] Function SortFamily(Actor[] akActors, Int GenderPriority = 1, Actor akAnchor = None) Global Native ; A method of getting all groups in an area with the provided relationships. ; Since papyrus doesn't support multi dimensional arrays I came up with this. ; Provide a KeyForm and a KeyName and MGF will build a group of actor arrays on the form and key you provide. ; Best practice for KeyForm and KeyName: ; 1. Preferably use a form from your mod to prevent any conflicts. ; 2. Use a longish, unique KeyName. ; Actor groups are created on the form you provide like: StorageUtil.FormListCopy(KeyForm, KeyName + i, Group). ; How many groups are there: Int NumberOfGroups = StorageUtil.CountObjFormListPrefix(KeyForm, KeyName) ; This is why use a longish/unique KeyName. ; How to get a group: ; Actor[] Group0 = _MGF_Util.FormsToActors(StorageUtil.FormListToArray(KeyForm, KeyName + "0")) ; Actor[] Group1 = _MGF_Util.FormsToActors(StorageUtil.FormListToArray(KeyForm, KeyName + "1")) ; Otherwise all arguments are the same as GetActorsInAreaWithRelationship() above. ; Calling CollectAllActorGroupsWithRelationship() again on the same combination of KeyForm and KeyName will automatically delete the previous information Bool Function CollectAllActorGroupsWithRelationship(String[] RelationshipTitles, Location akLoc, Int LocLevel, Form KeyForm, String KeyName) If !KeyForm || KeyName == "" || RelationshipTitles.Length == 0 || LocLevel < 0 || LocLevel > 3 Return False EndIf Int QID = GetAllActorGroupsWithRelationship(RelationshipTitles, akLoc, LocLevel) If QID > 0 StorageUtil.ClearObjFormValuePrefix(KeyForm, KeyName) Int groupCount = GetQueryGroupCount(QID) Int i = 0 Form[] Group While i < groupCount Group = _MGF_ArrayCreate.ActorsToForms(GetActorGroup(QID, i), FilterDisabled = true, FilterDead = true) StorageUtil.FormListCopy(KeyForm, KeyName + i, Group) i += 1 EndWhile Return True EndIf Return False EndFunction ; Group of functions used for CollectAllActorGroupsWithRelationship Int Function GetAllActorGroupsWithRelationship(String[] RelationshipTitles, Location akLoc, Int LocLevel) Global Native Int Function GetQueryGroupCount(Int QueryID) Global Native Actor[] Function GetActorGroup(Int QueryID, Int GroupIndex) Global Native
Soft Relationships (runtime modifiable relationships):
Spoiler
; Soft Relationships - Dynamic runtime relationships. These exist only in the SKSE cosave. ; Works with all Relations query functions above. Soft relationships take precedence over hard coded relationships. ; This allows the evolution/modification of relationships between character that already have a hard coded relationship. ; Adds or updates a soft relationship between two NPCs. ; akActor1 occupies the 'parent' slot of akAssocType. ; akActor2 occupies the 'child' slot. ; The order is important. ; Example: AddSoftRelationship(Saadia, PlayerRef, ParentChild) = Saadia is Father/Mother, Player is Son/Daughter ; akAssocType: Optional BGSAssociationType for label resolution. Pass None to use ; custom titles or rank fallback. ; asNPC1Title: Title FROM akNPC1's perspective OF akNPC2 (e.g. "Father"). ; Used when akAssocType is None or has empty labels. ; asNPC2Title: Title FROM akNPC2's perspective OF akNPC1 (e.g. "Son"). ; Used when akAssocType is None or has empty labels. ; For symmetric relationships (Friend, Rival, etc.) pass the same ; string for both. Leave both empty to use aiRank fallback only. ; aiRank: Rank used when assocType is absent and both titles are empty. ; 0=Lover 1=Ally 2=Confidant 3=Friend 4=Acquaintance ; 5=Rival 6=Foe 7=Enemy 8=Archnemesis ; The soft relationship system: ; 1. Dynamically populates relationship form '_MGF_DialogueTargetDummyRel' with any soft relationship ; data the player has with the dialogue target whenever the dialogue window is opened. This Enables ; the use of vanilla relationship condition functions with soft relationships during dialogue. ; 2. Dynamically adds/removes/updates Npcs to factions in formlist '_MGF_PcRelTypesFactionList'. The faction rank reflects ; the rank of the relationship. This enables the use of relationship data via CK condition functions for pretty much ; any purpose - Hello comments, magic effect etc. ; Eg: Npc.GetInFaction(_MGF_PcRel1_Sibling) == 1 && GetSex() == Female -> Sister. ; Npc.GetInFaction(_MGF_PcRel2_Parent) == 1 && GetSex() == Male -> Father ; Full table of relationship values and their 'sex' breakdown. ; Value | RelType | GetSex==Male | GetSex==Female | Faction (For player relationships only) ; ------|---------------|-------------------|----------------------------------- ; 0 | None | - | - | _MGF_PcRel0_None (Should never be used) ; 1 | Sibling | Brother | Sister | _MGF_PcRel1_Sibling ; 2 | Parent | Father | Mother | _MGF_PcRel2_Parent ; 3 | Child | Son | Daughter | _MGF_PcRel3_Child ; 4 | Spouse | Husband | Wife | _MGF_PcRel4_Spouse ; 5 | Courting | Boyfriend | Girlfriend | _MGF_PcRel5_Courting ; 6 | Lover | Lover | Lover | _MGF_PcRel6_Lover ; 7 | AuntUncle | Uncle | Aunt | _MGF_PcRel7_AuntUncle ; 8 | NieceNephew | Nephew | Niece | _MGF_PcRel8_NieceNephew ; 9 | Grandparent | Grandfather | Grandmother | _MGF_PcRel9_Grandparent ; 10 | Grandchild | Grandson | Granddaughter | _MGF_PcRel10_Grandchild ; 11 | Cousin | Cousin | Cousin | _MGF_PcRel11_Cousin ; 12 | Friend | Friend | Friend | _MGF_PcRel12_Friend ; 13 | Rival | Rival | Rival | _MGF_PcRel13_Rival ; 14 | Enemy | Enemy | Enemy | _MGF_PcRel14_Enemy ; 15 | Acquaintance | Acquaintance | Acquaintance | _MGF_PcRel15_Acquaintance ; 16 | Boss | Boss/Master/Jarl | Boss/Master/Jarl | _MGF_PcRel16_Boss ; 17 | Employee | Employee/Steward | Employee/Steward | _MGF_PcRel17_Employee ; 18 | Partner | Partner | Partner | _MGF_PcRel18_Partner ; 19 | Conspirator | Conspirator | Conspirator | _MGF_PcRel19_Conspirator Bool Function AddSoftRelationship(Actor akActor1, Actor akActor2, Form akAssocType, String Npc1Title, String Npc2Title, Int Rank) Global Native ; Removes the soft relationship between two specific actors. Returns false if none existed. Bool Function RemoveSoftRelationship(Actor akActor1, Actor akActor2) Global Native ; Returns True if a soft relationship exists between the two actors. Bool Function HasSoftRelationship(Actor akActor1, Actor akActor2) Global Native ; Removes all soft relationships involving akActor. Returns the number of removed relationships. Use carefully please... Int Function ClearSoftRelationshipsForActor(Actor akActor) Global Native ; Finds an AssociationType by editor ID (case-insensitive, substring match). ; Useful for resolving vanilla assocTypes to pass to AddSoftRelationship. ; All 20 vanilla assocTypes (pass any substring of the EditorID): ; "Siblings" -> Brother / Sister ; "ParentChild" -> Father / Mother | Son / Daughter ; "AuntUncle" -> Uncle / Aunt | Nephew / Niece ; "Cousins" -> Cousin / Cousin ; "Spouse" -> Husband / Wife ; "MasterAssistant" -> Master | Assistant ; "JarlSteward" -> Jarl | Steward ; "JarlHousecarl" -> Jarl | Housecarl ; "InLawBrotherSister" -> Brother-in-Law / Sister-in-Law ; "GrandparentGrandchild" -> Grandmother / Grandfather | Grandson / Granddaughter ; "GrandAuntUncle" -> Granduncle / Grandaunt | Grandnephew / Grandniece ; "InLawAuntUncle" -> Uncle-in-Law / Aunt-in-Law | Nephew-in-Law / Niece-in-Law ; "BossEmployee" -> Boss | Employee ; "InLawGrandparentGrandchild" -> Grandfather-in-Law / Grandmother-in-Law | Grandson-in-Law / Granddaughter-in-Law ; "GreatGrandparentGreatgrandchild" -> Great-Grandfather / Great-Grandmother | Great-Grandson / Great-Granddaughter ; "InLawParentChild" -> Father-in-Law / Mother-in-Law | Son-in-Law / Daughter-in-Law ; "BusinessPartners" -> Partner / Partner (parent slot only) ; "Courting" -> Boyfriend / Girlfriend (parent slot only) ; "FavorTarget" -> Acquaintance / Acquaintance ; "Conspirators" -> Conspirator / Conspirator ; Returns None if not found. Form Function GetAssocType(String asName) Global Native ; Note on the following two functions: ; They are for MGF internal use only! ; Since the built in relationship CK condition functions are... rather limited (effectively limited to a rank lookup) I've added these: ; Relationship form: ; _MGF_DialogueTargetDummyRel ; Sets the relationship form to use as a dummy relationship form. ; Every time the dialogue window is opened this relationship form is dynamically populated ; with any soft relationship data that the player has with the dialogue actor. ; IE: Enables the use of vanilla relationship condition functions for dialogue. ; Note: does not work with custom title associations. Use the vanilla association types if you need this populated correctly. Function SetDialogueRelationshipForm(Form akDummyRel) Global Native ; Populated with the dialogue target's relationship with the player from the player's point of view. ; Full table of relationship values and their 'sex' breakdown. ; Value | RelType | GetSex==Male | GetSex==Female ; ------|---------------|-------------------|------------------ ; 0 | None | - | - ; 1 | Sibling | Brother | Sister ; 2 | Parent | Father | Mother ; 3 | Child | Son | Daughter ; 4 | Spouse | Husband | Wife ; 5 | Courting | Boyfriend | Girlfriend ; 6 | Lover | Lover | Lover ; 7 | AuntUncle | Uncle | Aunt ; 8 | NieceNephew | Nephew | Niece ; 9 | Grandparent | Grandfather | Grandmother ; 10 | Grandchild | Grandson | Granddaughter ; 11 | Cousin | Cousin | Cousin ; 12 | Friend | Friend | Friend ; 13 | Rival | Rival | Rival ; 14 | Enemy | Enemy | Enemy ; 15 | Acquaintance | Acquaintance | Acquaintance ; 16 | Boss | Boss/Master/Jarl | Boss/Master/Jarl ; 17 | Employee | Employee/Steward | Employee/Steward ; 18 | Partner | Partner | Partner ; 19 | Conspirator | Conspirator | Conspirator ; A set of factions that indicate Npcs relationship with the player only. ; The faction rank reflects the relationship rank. ; This completes the condition function 'hole' in relationship detection. ; Usable in hello comments, magic effects, dialogue conditions, faction searches etc. ; See formlist '_MGF_PcRelTypesFactionList'. This formlist is a 1:1 map with the table above. ; These factions are set automatically by Soft Relationship functions. ; Eg: Npc.GetInFaction(_MGF_PcRel1_Sibling) == 1 && GetSex() == Female -> Sister. ; Npc.GetInFaction(_MGF_PcRel2_Parent) == 1 && GetSex() == Male -> Father Function SetDialogueRelFactionList(Formlist akList) Global Native
Edited by Monoman1
0
0 Comments
Recommended Comments
There are no comments to display.