Jump to content

Added Forms to Formlist removed on Load Game?


Recommended Posts

I have this weird issue with formlists, with a very simple scripted enchantment on a piece of armor which is intended to add an NPC to a Formlist when the item's equipped and remove him from the formlist when the item's unequipped.

 

But every time I reload my game, all equipped NPCs have been removed from the list, in fact the list debugs as being completely empty!..

 

Are all added forms not saved? Or is it just when used in Magic Effects?

Link to comment
Share on other sites

Please note that my experience is with Skyrim rather than Fallout 4

 

They should be saved. However, if they are not being saved it could be possible that the formlist needs to be persistent. As a test, place a property containing that formlist on an object or quest that will exist for the life of the mod. If having it in a persistent location solves the problem, then it must indeed be because of using it solely in a magic effect.

 

Its only a theory but one easily tested...

Link to comment
Share on other sites

Oh, persistency... I hadn't thought of that, many thanks IsharaMeradin :)

 

Yes, I have more experience with Skyrim's functions, and forms added at runtime were indeed saved, whether they were actors or custom forms from other mods. I vaguely remember reading something about some issues with MagicEffects though but I can't lay my hands on it.

 

I'll try your suggestion, a quest would be ideal for what I'm working on, do you think I'd have to be a quest which runs on game start though?

Link to comment
Share on other sites

Quick test seems to prove your theory very right!.. :yes:

 

I just added my formlists as properties to the one persistent object my mod holds as you suggested (even though that script has no need for these formlists), and this seems to do the trick, at least on a couple of "quit and reload" tests.

 

I still have to test it on a quest, none of my quests run at game start and for the moment none is scripted either, but I'll test it anyway and let you know.

 

I was so careful to leave the lightest footprints with this mod that I completely forgot that some forms need to be persistent!.. Lesson learnt!.. Many thanks again for "occasionally lurking", IsharaMeradin!.. :thumbsup:

 

 

Edit: Yep, it does work with a quest as well and it does not matter whether that quest runs at game start or not. Great!

Link to comment
Share on other sites

Well, after further testing, that issue is far from entirely solved. Making the formlists persistent only delays the moment when the formlist reverts to empty, but does not avoid it.

 

As a reminder:

 

1. Actor added to FormLists, via a scripted Enchantment placed on a piece of armor. When the item's equipped, the actor is added to FormLists, when unequipped, the actor is removed from FormLists.

 

2. Using this on followers, I use "GetBaseObject()" to get the editor form of the actor as it returns more accurately than "GetLeveledActorBase() - that's the form initially added to my FormLists.

 

3. What made me aware of the issue is my FormLists debugged as empty after quitting and reloading a couple of times. Making the FormList persistent seemed to fix that, but only temporarily. They're attached as properties to a persistent reference, a non-respawning Container placed in a holding cell - that's actually the only persistent object in my mod.

 

4. Still, after playing an hour or so to test it all further, my FormLists revert to empty again even though the actor never unequipped the enchanted item - which seems to indicate the FormLists do revert at run-time. On what event is hard to track: the actor never left the player's sight and was always loaded.

 

I'm not sure what to think of it all yet.

 

The reason I need those formlists is to find the closest actor to the player in a given FormList for my mod to work - using "FindClosestReferenceOfAnyTypeInList", it's the fastest and safest to return properly. If I am to use Factions instead, which I do for other purposes, that'll mean a complicated workaround to achieve the same results.

 

I'm gonna keep on testing, trying to isolate what type of events contribute to reverting my formlists at run-time - but I'd welcome gladly any idea, hint or advice at this point :)

 

Thanks a bunch, guys!

Link to comment
Share on other sites

Workaround solution: Build two additional formlists one that contains every NPC that you have ever given the item to and one that contains every NPC that you have purposefully taken the item away from. Then with an OnPlayerLoadGame event (I'm hoping Fallout 4 has that) compare the current list against those two and rebuild as necessary.

Link to comment
Share on other sites

Hey thanks for dropping by again, IsharaMeradin :)

 

And thanks for the suggestion, I'm sure I could get around it with a player quest or perk (yeah, OnPlayerLoadGame seems to work the same as in Skyrim), but that'll mean more scripts, more formlists, more factions, and reccurrent polling to track NPCs surrounding the player, polling which I'm trying to avoid. As I did on most of my mods, I'm trying to stick to scripts which only run when needed, do their job and revert back to a default empty state. Also this mod serves as a test for 2 other mods where I'll need reliable FormLists changing at runtime too.

 

Thanks to your first suggestion, my issue seems to be fully solved on quit and reload game. If the actor is on the formlist when I quit, he still is in it when I reload now. The issue I'm left with is that actors are removed from the formlists at runtime. I'm testing it on just one follower atm because it's easier to keep track of one single actor. The only tiny hint I've had for the moment is when I was trading equipment with him (weapons), some of my debug's notifications quickly flashed beneath the inventory UI, which may suggest that NPCs reevaluate their inventory in a somewhat similar manner that they did in Skyrim. I could not reproduce that unfortunately, so it may be something that runs on a timer rather than directly related to inventory management. If it's hard coded, it's going to be hard to isolate.

 

I'm going to keep testing it a bit longer and in different configurations (dismissed, waiting for player, unloaded, fast travel, etc.) to see if I can isolate a specific event causing this issue. And if I can't, yeah, I'll have to find some workaround and hopefully one which does not involve polling... Thanks for your help, it always makes things easier to be able to share experiences :)

Link to comment
Share on other sites

:huh: Hmm... I stumbled upon a most unexpected cause: the scripted enchantment used to add actors to my formlists is placed on a Ring (slot 51) - when the actor is equipped with this ring and I trade stuff with him, if I unequip his slot 58 (a completely different item), my ring remains equipped BUT it makes my scripted enchantment cast "OnEffectFinish" !.. (and of course removes the actor from my formlists!..)

 

Provided that's the only cause of my formlists reverting to empty at runtime (can't be sure of that yet), this does not make much sense - but it IS a repeatable and consistent issue.

 

I checked in the CK, that 58 slot equipement should not affect slot 51, the armor addon is also set to slot 58 only. And my ring's AA or Armor are both only set to slot 51 (hands). Besides, when I unequip my actor's slot 58, my slot 51 remains equipped and visible, it's only my scripted enchantment which is removed - so it's probably not a slot issue.

 

It also happens that that slot 58 item which causes my trouble has an attached enchantment too and one that involves a perk and a peak value modifier (I was not even aware of that). Now I'm wondering if some enchantments don't take some sort of priority over some others, even though nothing in the CK seems to suggest that... OR if modifying an actor value doesn't not force him to reevaluate his equipement... :huh: (in which case, he should silently unequip and reequip the ring nonetheless, but he does not).

 

Ahem, clearly no longer a FormList issue - probably more related to enchantments or actor values - not entirely sure yet, I'm going to test that against more slots and more enchantments (Vanilla and custom), see if I can find some sort of pattern.

Link to comment
Share on other sites

Well, it would seem that bonuses and items' enchantments are not disabed only when an actor steps into a power armor, they can also get disabled - at least for followers - on Inventory Management too. I could not detect any specific pattern other than for weapons: as long as you make an actor equip a specific weapon through inventory management, all other enchanted items this actor has equipped are somehow "reevaluated", and at least temporarily disabled, then apparently reenabled once you close their inventory.

 

This happens with weapons whether they are enchanted or not, and for some armor pieces but not all, enchanted or not too. Possibly a hard-coded way to reevaluate their armors and weapons values.

 

This has little effect on non scripted enchantments - add carryweight or strength to an actor with an enchantment item, the enchantment is temporarily disabled and immediately reapplied. But when you add a scripted enchantment the way I did, using "OnEffectStart" to get the job done and "OnEffectFinish" to remove whatever you scripted this enchantment to be, "OnEffectFinish" does fire when the enchantments are temporarily disabled, but for some reason "OnEffectStart" never fires again when other enchantments are reapplied - and so the enchantment is lost, until you forcibly unequip and reequip the actor.

 

In my case, the issue will very likely be solved by scripting the armor form directly rather than applying a scripted magic effect to the armor.

 

I don't know if that potential issue with scripted enchantments is documented or not - haven't found anything so far. So just in case, and because this is now clearly unrelated to formlists, I'll start a new thread tomorrow to let other modders know.

 

Thanks guys :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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