Jump to content

NPCs losing keywords after loading savegame


Recommended Posts

Posted

I have a number of scripts adding keywords to some NPCs. Keywords get added just fine and are persistent through cell changes, however after quitting the game and re-loading the save, they "get lost" (NPCs no longer have them)

 

I've never seen this in FO4, is it a Skyrim limitation, keywords being not savegame persistent?

 

Thx

 

LE: could be this happens only on dead actors (insufficiently tested), but I need to ensure keyword persistence on dead actors anyway, or to find a workaround if it's a hard skyrim limitation

 

Posted

How are you adding the keywords through the script? I don't see any papyrus functions on Actor script to do it.

 

In SLAX, there is a "KeywordUtil" script that's used to add the keywords to a form, this one doesn't persist it's changes through save games. The workaround in that mod is to duplicate the keyword info in a StorageUtil array and reapply it every time the game is reloaded:

 

Function RestoreKeywords(String keyValue, Keyword wordValue)

    Form[] addItems = StorageUtil.FormListToArray(player, keyValue)
    Form[] removeItems = StorageUtil.FormListToArray(player, keyValue+"No")
    
    If addItems
        KeywordUtil.AddKeywordToForms(addItems, wordValue)
    EndIf

    If removeItems
        KeywordUtil.RemoveKeywordFromForms(removeItems, wordValue)
    EndIf
    
EndFunction





Event OnGameReload()

    slax.Info("SLAX - OnGameReload")
    
    ResetConstants()

    RestoreKeywords(keyNakedArmor,   wordNakedArmor)
    RestoreKeywords(keyBikiniArmor,  wordBikiniArmor)
    RestoreKeywords(keySexyArmor,    wordSexyArmor)
    RestoreKeywords(keySlootyArmor,  wordSlootyArmor)
    RestoreKeywords(keyIllegalArmor, wordIllegalArmor)
    RestoreKeywords(keyPoshArmor,    wordPoshArmor)
    RestoreKeywords(keyRaggedArmor,  wordRaggedArmor)
    RestoreKeywords(keyKillerHeels,  wordKillerHeels)
    
	slaMain = Quest.GetQuest("sla_Main") As slaMainScr
	slaMain.Maintenance()
    
    parent.OnGameReload() ; Don't forget to call the parent!

EndEvent

 

Posted
3 hours ago, DayTri said:

How are you adding the keywords through the script? I don't see any papyrus functions on Actor script to do it.

 

To my dismay, there isn't one in skyrim, there is one in FO4.

 

For skyrim I am using these two (redundant) methods.

sac_kw_alias.forcerefto(target as actor) <= sac_kw_alias is an object reference alias which has the keyword attached, this is supposed to be the vanilla skyrim mechanism

AddKeywordToRef(target, sac_intended_kw) <= after I've discovered papyrus extension

 

Either one works (i.e. add the keyword), redundancy is due to me discovering the second method later and being lazy to clean up, problem is they don't seem to be persistent through save / load

 

Thanks

Posted
9 hours ago, SAC said:

 

To my dismay, there isn't one in skyrim, there is one in FO4.

 

For skyrim I am using these two (redundant) methods.


sac_kw_alias.forcerefto(target as actor) <= sac_kw_alias is an object reference alias which has the keyword attached, this is supposed to be the vanilla skyrim mechanism

AddKeywordToRef(target, sac_intended_kw) <= after I've discovered papyrus extension

 

Either one works (i.e. add the keyword), redundancy is due to me discovering the second method later and being lazy to clean up, problem is they don't seem to be persistent through save / load

 

Thanks

 

Alias keywords (method 1) should definitely persist after game load, that's very strange. Could you double check:

 

1. Your alias is still filled after game load? `sqv name_of_your_quest` in console to check

 

2. Make sure your quest isn't reseting on game load for some reason, for example because you're calling reset in an OnPLayerLoadGame event maybe?

 

Posted
12 hours ago, DayTri said:

 

Alias keywords (method 1) should definitely persist after game load, that's very strange. Could you double check:

 

1. Your alias is still filled after game load? `sqv name_of_your_quest` in console to check

 

2. Make sure your quest isn't reseting on game load for some reason, for example because you're calling reset in an OnPLayerLoadGame event maybe?

 

 

Let me clarify the use case: I use the quest in order to populate multiple NPCs with the keyword, recursively.

 

Meaning:

- NPC1 gets forced into the alias

- NPC1 gets the keyword from the alias

- NPC2 gets forced into the same alias

- NPC2 gets the keyword from the (same) alias

 

So it's not a persistent allocation of one NPC into one alias, the alias is just a vehicle to add the keyword and move on to the next NPC.

 

Problem is I was hoping the NPCs would get persistent saved with the keyword, and apparently they don't.

 

Posted
2 hours ago, SAC said:

 

Let me clarify the use case: I use the quest in order to populate multiple NPCs with the keyword, recursively.

 

Meaning:

- NPC1 gets forced into the alias

- NPC1 gets the keyword from the alias

- NPC2 gets forced into the same alias

- NPC2 gets the keyword from the (same) alias

 

So it's not a persistent allocation of one NPC into one alias, the alias is just a vehicle to add the keyword and move on to the next NPC.

 

Problem is I was hoping the NPCs would get persistent saved with the keyword, and apparently they don't.

 

Aha, I see

 

Actually I am surprised NPC1 even keeps the keyword once NPC2 is assigned in that alias. With factions they are removed right away.

 

Also, once NPC1 leaves the alias it will no longer be persistent, unless something else is making it persistent. So for example if you apply it to a leveled bandit, when you leave the cell NPC1 should leave memory and be brought back when you return, my understanding is all data will be copied from the ActorBase again. So NPC1 should not keep the keyword data between cell transitions unless it's an otherwise persistent reference.

 

Since you want these aliases to persist through death anyway, maybe you could:

 

1. Create a large number of aliases on your quest

2. Set a property to point to the "latest" alias

3. When you assign all the aliases have the pointer wrap around and start replacing aliases from the start of the list.

 

I think there must be a script or automated way to create a large number of aliases on a quest. Sexlab has 500 for the animation registry and I can't believe someone created them all by hand in the creationkit.

Posted
5 hours ago, DayTri said:

Since you want these aliases to persist through death anyway, maybe you could:

 

1. Create a large number of aliases on your quest

2. Set a property to point to the "latest" alias

3. When you assign all the aliases have the pointer wrap around and start replacing aliases from the start of the list.

 

I think there must be a script or automated way to create a large number of aliases on a quest. Sexlab has 500 for the animation registry and I can't believe someone created them all by hand in the creationkit.

 

Actually, I don't want the aliases to persist, just the keywords :) but thanks, I'll look more into it and I have some workarounds (which I've hoped to stop using, but oh well, such is the modding life).

 

I believe there is a way to define arrays of aliases, but it's vague in my memory and I'm perhaps mistaken.

 

Posted
2 hours ago, SAC said:

 

Actually, I don't want the aliases to persist, just the keywords :) but thanks, I'll look more into it and I have some workarounds (which I've hoped to stop using, but oh well, such is the modding life).

 

I believe there is a way to define arrays of aliases, but it's vague in my memory and I'm perhaps mistaken.

 

 

Probably your best bet then is to keep an array of actors you've applied the keywords to and reapply them every time you load the game. That's what Lupine did for clothing in SLAX and I imagine if there was a faster or more convenient way to handle this then they would have implemented it

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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