Jump to content

[LE] Quests dropping aliases filled with ForceRefTo between loads.


Recommended Posts

I have a quest, that is start game enabled, with several aliases that are set to none to begin with. Later in the mod, certain actors will be placed into those aliases using ForceRefTo. However I noticed that when loading a save/starting the game back up after the aliases have been filled, they are now empty. It appears as though aliases filled using ForceRefTo aren't saved in savegames? I don't see any documentation/notes on this behaviour on the CK site or other forums.

 

This is a pretty big problem for what I currently have setup, if loading a save clears the aliases. Is there some way to address/fix this so that filled aliases are remembered through saves/loads.

Link to comment
Share on other sites

 

They are, so there's something in your setup that's clearing them.

What could clear a quest alias aside from stopping/reset the quest, which isn't happening, or calling clear() directly on the alias?

 

 

There shouldn't be anything AFAIK; a ForceRef to 'none' shouldn't do anything. There's a note in the wiki's talk page for ForceRef of someone having the same issue back in 2016, but I've used ForcedRef both script and console across saves without issue.

 

Without more details on your scripting / quest setup it's hard to figure the issue. One possibility is that Quests that are Start Game Enabled will start twice, so depending on how exactly you've set up your force-fill it could be that they're filling on game start and then being wiped when the quest starts for the second time (e.g., OnInit events fire twice in this scenario).

Link to comment
Share on other sites

Okay so the quest in question has several empty aliases, marked as optional, and one filled alias, for the player filled with PlayerRef. The quest has a script with OnInit() event which calls a function that checks if another mod is installed and depending on whether it is there or not, uses forcerefto to fill one of the empty aliases. The player alias, also has a script attached which calls this function using the event OnPlayerLoadGame(), in case a user removes the other mod later on.

 

When starting a new game, everything works fine. The player alias is filled as it should be, and the one other aliases is filled as well. Saving and loading the game, either in the same instance or with closing the game, causes all aliases to be set to none.

 

My MCM quest for the mod, which also has a player alias, does not have the same problem.

 

Edit: The function being called through the OnInit() and supposedly through OnPlayerLoadGame().

Event OnInit()

	ModCheck()

EndEvent

Function ModCheck()

	int modIndex = Game.GetModByName("Cutting Room Floor.esp")

	if modIndex == 255
		SC_KarindaMarker.Enable()
		KarindaHorse.ForceRefTo(SC_KarindaHorse)
		miscutil.PrintConsole("Cutting Room Floor not installed.")
	else
		Actor CRFKarindaHorse = Game.GetFormFromFile(0x0001FBCF, "Cutting Room Floor.esp") as Actor
		KarindaHorse.ForceRefTo(CRFKarindaHorse)
		miscutil.PrintConsole("Cutting Room Floor installed.")
		if KarindaHorse.GetReference() == None
			miscutil.PrintConsole("Error: Whiterun Horse Alias not filled.")
		else
			string horseName = (KarindaHorse.GetReference() as Actor).GetBaseObject().GetName()
			miscutil.PrintConsole("Whiterun Horse Alias filled with "+horseName+".")
		endif
	endif

EndFunction
Edited by NarcolepsyNick
Link to comment
Share on other sites

  • 2 months later...
  • 4 years later...

Pulling out this old thread, because I have been having this issue as well in my mod. I think I found out what is causing it:

Setting "Start Game Enabled" in a quest seems to be causing this issue in combination with filling the quest's ReferenceAliases via ForceRefTo().

In my mod, some users reported that the quest's ReferenceAliases where no longer filled after making a savegame and reloading that savegame, even if they were filled initially (before making the savegame).  While for other users, no such issue.

Consider a small test mod, which only contains a single quest, which is NOT "Start Game Enabled". It has a ReferenceAlias with a script (MyQuestAliasTestScript - see below) that calls OnInit():

image.thumb.png.eafd2f44ea4eca9d22fc74d11f7350c7.png

With the first version of OnInit()  the ReferenceAlias will reliably get cleared after Saving the game and reloading it (GetActorRef() == NULL), while with the second version the Reference alias will stay filled when Saving / reloading the savegame.

My _assumption_ on this is that for a "Start Game Enabled" quest, the sequence in which the game engine

  • starts the quest
  • executes OnInit()

is not determined, ie random when first starting the game with the mod.

In case the engine executes OnInit() before it starts the quest, the ReferenceAliases get cleared during saving the game. While if the quest starts before OnInit() is executed, no issue. This is why the issue appears to be randomly hitting some users, while others don't ever see this.

The take-away for me is: If you are filling ReferenceAliases of a quest with ForceRefTo() DO NOT use "Start Game Enabled". Instead keep "Start Game Enabled" off, and use OnInit() to Start the quest, and only AFTER Start() fill the RefAliases with ForceRefTo().

Link to comment
Share on other sites

Quest OnInit events fire multiple times, unlike most other OnInit events.

It fires when the game starts (or rather when the quest first appears).  On that run, isRunning() will return false.

It then fires again when the quest starts.  This time isRunning returns true.

It fires once more everytime setStage is called, again is isRunning returning true, and getStage returning the new stage number.

Start Enabled Quests fire two events right off the bat, with isRunning false and then isRunning true.

Checking Run Only Once suppresses the first (the one with isRunning false).

You should always test isRunning and getStage within your quests' OnInit scripts....

@staalo18 I'm not sure any of this explains your cleared aliases... it certainly does not explain how reloading a save game triggers this.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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