Jump to content
Sclerocephalus

Caravan philosophy

Recommended Posts

Is it possible that the script hooks up when it waits for the caravan leader to unload (as this is the condition that must be fulfilled before the camp site is enabled) ?

 

The first thing the script does upon arrival of a party at a camp site is setting the globals that make the actors sandbox. It then proceeds with enabling the camp site and only then registers the caravan leader's alias for an OnSingleUpdateGameTime event. That is, the possibility of the leader alias having somehow lost his update registration (although I have no idea how that could have happened either) is out of the question. All reports of caravans getting stuck indicate that they sandbox (although in a rather minimalistic way; but that's because the idle markers are not available until the camp site is enabled), and the only explanation is that the script fails when attempting to enable the camp site.

 

All caravan folks are force filled into their aliases, which makes them permanently persistent. Their references never unload from memory, even when the quest would be stopped. This actually doesn't mean that their 3D never unloads either, and after all, if it would, there would be no caravan camp site ever enabled or disabled in the game.

 

What I could imagine though is that there are situations where the engine handles a permanently persistent reference in a different manner than it would handle a reference that is not permanently persistent (or not persistent at all). More precisely,  could there be situations where it would not unload it although we would expect it does ?

 

Pretty confusing, I know ...

Share this post


Link to post
Share on other sites

It should be possible to make a cell persistent by running a script on it. Pure speculation: what would the engine do with a persistent reference while in a persistent cell ? Not unload its 3D, perhaps ?

 

I have searched for reports on the caravan bug and it appears that only Riften, Whiterun and Windhelm are affected. Coincidentally, these are places where the camp sites are within areas that are affected by dragon attacks quite often. What does the dragon attack script with the cell it's running on ?

Share this post


Link to post
Share on other sites

wasn't the caravan bug fixed by USKP already? in a new game i see them reproducably appear in whiterun shortly after me.

the only quirk is, that they stand around aimlessly, until the cell is unloaded. after reload the camp is built.

but to actually have them build the camp (even if just simulated, e.g. carry around a few hides and boxes as long as he cell is not unloaded, then after reloading again, camp is built) should be something for an immersion mod and not the USKP.

 

or did you mean you found another bug with the caravans?

Share this post


Link to post
Share on other sites

It's all explained here:

http://forums.nexusmods.com/index.php?/topic/456679-unofficial-skyrim-patch/?p=8890331

 

There is a rare bug, where caravans REALLY stop moving, and there are cases with an unusually long delay until the camps are set up:

  • The latter case could be dealt with by modifying the Is3DLoaded check in the caravan script. Note however that the script is actually doing what it's expected to do, so this isn't really a bug. There are indications that this problem occurs more often when the UGridsToLoad value is increased (which is no surprise).
  • The reason for the former bug is completely unknown. I had this happen myself in one earlier playthrough where a caravan stopped moving at Windhelm. I went to Blackreach, spent almost one in-game week there, returned to Windhelm even much later (it's impossible that the respective cells did not unload in the meantime) and the caravan had still not moved on.

Most people who are experiencing a caravan glitch will check the camp site in (too) short intervals just out of curiosity. It's obvious why this (1) keeps the caravans in place and (2) does not help in confirming whether or not somebody's game is affected by the real bug. Can you tell ? If you can't, forget about asking for savegames, as this will lead nowhere (at least not in the present stage of investigation).

Share this post


Link to post
Share on other sites

an uploaded savegame is no harm to anyone. and if the caravan can indeed be made to move on another PC, it's at least clear that this report can be disregarded.

 

but if you say you already possess a save file, where the bug has occured and is reproducable, then of course currently no new save files are needed.

Share this post


Link to post
Share on other sites

The irony is that I had already conceived a workaround for that check while fixing the caravan script, because I did foresee that it might become problematic. In the end, the workaround proved to be more problematic than the check in the vanilla script and has been left out.

Share this post


Link to post
Share on other sites

To prevent the script from getting stuck in the while loop for whatever reason, the UpdateCaravan function of the caravan script has to be modified as follows:

Function UpdateCaravan (Int WhichCaravan, Actor LeaderRef, Bool WeAreEnablingCamp = False, Bool WeAreDisablingCamp = False)
	
	If (ArraysAreInitialized == False)
		InitArrays()
	EndIf
	
	If (WeAreDisablingCamp == True)

		While (LeaderRef.Is3DLoaded() == True) && !Game.GetPlayer().GetParentCell().IsInterior()
			Utility.Wait(1)
		EndWhile

		ToggleCamp (WhichCaravan, False)

	EndIf

	SetGlobals (CaravanCampStates [WhichCaravan], CaravanLocations [WhichCaravan])
	
	If (WeAreEnablingCamp == True)
	
		While (LeaderRef.Is3DLoaded() == True) && !Game.GetPlayer().GetParentCell().IsInterior()
			Utility.Wait(1)
		EndWhile
			
		ToggleCamp (WhichCaravan, True)

		CaravanMembers [WhichCaravan].RegisterForSingleUpdateGameTime (CampTime)
		
	EndIf

EndFunction

The only modification consists in adding the "!Game.GetPlayer().GetParentCell().IsInterior()" condition to the loops. When the player enters an interior cell, the conditions for enabling/disabling the camp are fulfilled (i.e. the player is not around the camp site) and the script will proceed no matter whether or not the caravan guys' 3D is loaded. This solution is a good compromise. There are more situations where toggling the camp would be safe even when the player is not in an interior cell AND the caravan guys are still loaded, but checking them all is far too tedious.

 

The problem is that this fix is not retroactive. Once the script gets stuck in the loop, it will remain in this state forever. when stopped while within a function, a script will never load a new version of that function when it resumes the task after reloading the game (this would obviously not work), but load the old version from the save again. Only when the task is completed (and the code in the respective function has been processed), it will switch to the new version and run that version when the function is called again. Though, because it is stuck, it will never get there ...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Support us on Patreon!

×