init at game load and init at game restart

Post » Tue Jun 19, 2012 8:59 am

Hooray, Engine bug abuse... Maybe they will finally fix persistence of LeveledItems, I pointed this out like the day of release and it never got addressed. I wrote a long script to dynamically update loot tables that people could use for their clothing mods so I WOULDN'T ALWAYS HAVE TO BE A BLACKSMITH to get it. Then I found out LeveledItems weren't persistent and I cried.


Never use timed events unless the purpose is for the action to be timed, stick with other events as the triggers.
User avatar
Kayleigh Williams
 
Posts: 3397
Joined: Wed Aug 23, 2006 10:41 am

Post » Mon Jun 18, 2012 6:59 pm

Hooray, Engine bug abuse... Maybe they will finally fix persistence of LeveledItems, I pointed this out like the day of release and it never got addressed. I wrote a long script to dynamically update loot tables that people could use for their clothing mods so I WOULDN'T ALWAYS HAVE TO BE A BLACKSMITH to get it. Then I found out LeveledItems weren't persistent and I cried.
You can stop crying. Just use JustinOthers method to make a function that refill the leveled lists each time the game loads, provided there isn't an item in a known control leveled list. When/if the bug is fixed, the onload method won't work, and the loop will be broken, thanks to the control leveled list trick and you won't need to update it.
User avatar
Gemma Archer
 
Posts: 3492
Joined: Sun Jul 16, 2006 12:02 am

Post » Tue Jun 19, 2012 1:08 am

When/if the bug is fixed

I prefer to avoid script hacks to achieve a goal for that very reason. The problem with that script is its triggered every 3 seconds, sure it'll work but that's terrible practice. You really don't want a script running that often. You're better off using an event that isn't triggered as often.
User avatar
CArla HOlbert
 
Posts: 3342
Joined: Wed Feb 21, 2007 11:35 pm

Post » Mon Jun 18, 2012 5:04 pm



I prefer to avoid script hacks to achieve a goal for that very reason. The problem with that script is its triggered every 3 seconds, sure it'll work but that's terrible practice. You really don't want a script running that often.
The function is all that matters. I'd just set up the update stuff to test, making sure GetGameLoaded() always returned the appropriate value and left the event code there in case anyone wanted to easily verify it works.
User avatar
liz barnes
 
Posts: 3387
Joined: Tue Oct 31, 2006 4:10 am

Post » Tue Jun 19, 2012 6:49 am

I prefer to avoid script hacks to achieve a goal for that very reason. The problem with that script is its triggered every 3 seconds, sure it'll work but that's terrible practice. You really don't want a script running that often.
The function is all that matters. I'd just set up the update stuff to test, making sure GetGameLoaded() always returned the appropriate value and left the code there in case anyone wanted to easily verify it works.
Exactly, the method you use to call the function is not so important. Instead of a onupdate event you could use any other kind of event, kicking for sure when the game is loaded. I suppose onload, oncellattach and a lot of others.
User avatar
Harry-James Payne
 
Posts: 3464
Joined: Wed May 09, 2007 6:58 am

Post » Tue Jun 19, 2012 12:54 am

Another prossibility would be to play with the clock. Let's say that an onupdate event takes the system clock each 10 seconds. Then the taken time is compared with the previous one. If the different is too great to blame a little stuttering, let's say a minute, it only can be caused by the game being loaded.
My proposed script at the very top of this thread (which is updated to what I currently use in my mods) runs of the difference between the current Utility.GetCurrenRealTime () and what is saved in the saved-game. If it's more than 60 seconds, it's very likely that OnGameLoaded () happened. Check it out.

Anyway once, SKSE is released with Papyrus support, all these work-arounds will not be needed.
User avatar
A Boy called Marilyn
 
Posts: 3391
Joined: Sat May 26, 2007 7:17 am

Post » Mon Jun 18, 2012 7:58 pm

Yeah, I get that. I'm not so keen on using the hack but here's an interesting method you could try

Create a FormList called say OnLoadQuests

Create a Quest, like... GameLoaded, give it an alias to the player, hook to a less common actor triggered event... When the game is determined to be loaded through the leveleditem list hack, cycle through the FormList OnLoadQuests casting to GameLoaded calling a dummy function of GameLoaded called "OnGameLoaded"

Now, when you create a new quest, instead of extending Quest you extend GameLoaded and reimplement OnGameLoaded by overriding it, and when the quest initalizes, AddForm Self to OnLoadQuests

There, now you've created a simulated OnGameLoaded event.
User avatar
Betsy Humpledink
 
Posts: 3443
Joined: Wed Jun 28, 2006 11:56 am

Post » Tue Jun 19, 2012 2:16 am

I think it was the 'ScriptName GetGameLoadedScript' part throwing people off. I edited the post so, hopefully, the baby isn't thrown out with the bath water.
User avatar
Mrs shelly Sugarplum
 
Posts: 3440
Joined: Thu Jun 15, 2006 2:16 am

Post » Mon Jun 18, 2012 11:59 pm

My proposed script at the very top of this thread (which is updated to what I currently use in my mods) runs of the difference between the current Utility.GetCurrenRealTime () and what is saved in the saved-game. If it's more than 60 seconds, it's very likely that OnGameLoaded () happened. Check it out.

Anyway once, SKSE is released with Papyrus support, all these work-arounds will not be needed.
I should have read your script :blush:
User avatar
Bellismydesi
 
Posts: 3360
Joined: Sun Jun 18, 2006 7:25 am

Post » Tue Jun 19, 2012 6:57 am

Just came by chance upon this note on wiki:
NOTE: Relationship data is NOT stored for Templated Actors, and any scripts that would set relationship data on a Templated actor will get wiped once your game session is over (which obviously has bad implications for Save/Load).
From: http://www.creationkit.com/GetRelationshipRank_-_Actor
I always thought something like this would help with load detection. I'm not interested in load detection right now and my time is limited but if someone wishes I believe this could be researched and something might come up.
PS: what exactly is "templated actor"?
User avatar
Ria dell
 
Posts: 3430
Joined: Sun Jun 25, 2006 4:03 pm

Post » Mon Jun 18, 2012 5:44 pm

I think it means actors that are pulled from levelled lists (Mob Markers on your map?)
User avatar
Mr. Ray
 
Posts: 3459
Joined: Sun Jul 29, 2007 8:08 am

Post » Mon Jun 18, 2012 7:46 pm

Just came by chance upon this note on wiki:
NOTE: Relationship data is NOT stored for Templated Actors, and any scripts that would set relationship data on a Templated actor will get wiped once your game session is over (which obviously has bad implications for Save/Load).
From: http://www.creationkit.com/GetRelationshipRank_-_Actor
I always thought something like this would help with load detection. I'm not interested in load detection right now and my time is limited but if someone wishes I believe this could be researched and something might come up.
PS: what exactly is "templated actor"?
Good catch. This look like a reliable parameter to check, that not being a bug won't be fixed.

Unless it didn't affects other instances of the actor, in which case a reset could be mistaken with a new game session.
User avatar
Blackdrak
 
Posts: 3451
Joined: Thu May 17, 2007 11:40 pm

Post » Tue Jun 19, 2012 4:16 am

Cool! So what's a templated actor? Is it an actor from a Levelled List? If so, do we set a Levelled List Actor in a hidden cell and set its Relationship rank? Because that would work.
User avatar
Marion Geneste
 
Posts: 3566
Joined: Fri Mar 30, 2007 9:21 pm

Post » Mon Jun 18, 2012 5:01 pm

MQ00 Stage 5 suggests that some things shouldn't start when the game starts.
; called by MQ102 during chargen - place to put "startup" quests that can't start enabled for various reasonsHousePurchase.Start()
So, I've updated my OnUpdate () function to check for this.

The problem I found with all my mods is that the player gets stuck in the auto-walk towards the chopping block in the prologue scene. Something I was doing in this procedure was causing the problem. Adding "If questMq00.GetStage () >= 5" in my OnUpdate () block fixed it.

Note that the problem doesn't present itself after you've chosen to follow either Ralof or Hadvar.

Note to new users, the methods suggested in this thread are better by Justiinother for GetGameLoaded () and by RandomNoob for GetGameRestarted (): http://www.gamesas.com/topic/1345542-getting-a-script-to-run-when-the-game-loads. To summarise: the checks respectively uses (1) changing an Actor Value that is never saved and (2) adding a Scripted Spell to the player. However, I've not implemented or tested neither and have stuck with my method (which checks for changes in Game.GetCurrentRealTime ()).

I'm sure that future versions of SKSE will have non-hacked versions of OnGameLoaded () and OnGameRestarted ().
User avatar
Georgia Fullalove
 
Posts: 3390
Joined: Mon Nov 06, 2006 11:48 pm

Previous

Return to V - Skyrim