Jump to content

function to list all NPCs that have a relationship with a given actor


Recommended Posts

Looking for a function that given an NPC will list all the other NPCs that have a relationship with that NPC (father, sibling, etc)

https://ck.uesp.net/wiki/Actor_Script lists getting the relationship between two ids.

If it doesn't exist, I am interested in creating such a function. Does there exist a function that will return a full list of all NPCs active in the game?

Thinking I can create a mod with the function by storing the pairwise function of all the ids into a file, store it as part of a mod, and then have that mod provide the functionality.

Link to comment
Share on other sites

Could I approximate the list of active NPCs by crawling the RefIds from https://en.uesp.net/wiki/Skyrim:Essential_NPCs, https://en.uesp.net/wiki/Skyrim:Followers, 
https://en.uesp.net/wiki/Skyrim:Dawnguard, and https://en.uesp.net/wiki/Skyrim:Dragonborn?

 

It wouldn't support mods, but if the code read all the JSON files in it's data directory they could be added by other mods and over time. 

Link to comment
Share on other sites

I don't think you need to crawl the refids in UESP.  You can create a form list that has all the unique named NPCs and add to that list via script over time as you wish to support other mods.  GetFormFromFile would allow you to pull and store the actor reference ids without having a hard requirement of the third-party mods.

While getting the list is part of the battle, I'm still not sure of the best way to obtain what you want nor to store that information for easy retrieval.  HasParentRelationship, HasFamilyRelationship and HasAssociation may be helpful to get the information you seek.  But I have never used those and the wiki doesn't seem to be very helpful in an actual usage case.

 

Link to comment
Share on other sites

48 minutes ago, IsharaMeradin said:

I don't think you need to crawl the refids in UESP.  You can create a form list that has all the unique named NPCs and add to that list via script over time as you wish to support other mods.  GetFormFromFile would allow you to pull and store the actor reference ids without having a hard requirement of the third-party mods.

I am just learning papyrus and don't know what a "form list" is.  Do you have sample code you could reference?

 

50 minutes ago, IsharaMeradin said:

I'm still not sure of the best way to obtain what you want nor to store that information for easy retrieval.  HasParentRelationship, HasFamilyRelationship and HasAssociation may be helpful to get the information you seek.  But I have never used those and the wiki doesn't seem to be very helpful in an actual usage case.

I image it would be implemented as three separate scripts: 

1. A python script, run outside Skyrim, that crawls the wiki and pulls
  out refids, and saves them into npc-relationships/data/ids.json.

2. A papyrus script that reads ids.json and calls HasParentRelationship, HasFamilyRelationship and HasAssociation across all ids pairs and  stores that into npc-relationships/data/relationships.json. This would only be run once, or rarely.
  Use https://www.nexusmods.com/skyrimspecialedition/mods/13048 (or similair)

{
    "name":"Sigrid",
    "refid":"0002BFA2"
    "relationships":[
        {
            "type":"spouse",
            "refid:"00013482"
        },
        {
            "type":"child",
            "refid:"00013484"
        }
    ]
}

3. A papyrus script with GetRelationships. It reads relationships.json and stores it in memory.  If that is not possible, the relationships.json file will be split into individual (refid).json files for each actor and that refid file matching the requested refid will be read when the function is called. If the functions can be return an array of structs the full information will be returned, if it can not just an array of refids will be returned.

Scripts 2 and 3 could be in different mods, or combined into a single mod with the RebuildDB function called via MCM.
 

 

Link to comment
Share on other sites

A form list is a record created in the Creation Kit.  It is similar to an array.  The main difference is that a form list can hold a mix of object types, if needed, and exceed the 128 entry limit that arrays have under most circumstances.

There are RELA (relationship records) within the game's plugins.  xEdit (TES5Edit, SSEEdit, etc) could be used to scan those instead of relying on information found in a third party site.  If may even be possible to set up a script to use in xEdit that will scan the relationship records and store the data into a format that is more accessible to your needs.  If done right, the end user could run the script on their specific setup and all mod added NPC relationships would be accounted for on their end.  Don't ask me how to write an xEdit script, that is something I still cannot wrap my mind around.

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...