Jump to content

Crashing script code question.


Thorham

Recommended Posts

Does anyone know why the following code crashes the game if I run it in an OnPlayerLoadGame event? If I use Utility.Wait(10) it works unreliably. When I have this code run by, for example, equipping an item (OnObjectEquipped event) it works fine.

 

Anyone any ideas?

 

Game.UpdateHairColor()
Game.UpdateTintMaskColors()
NiOverride.ApplyOverrides(thPlayer)
NiOverride.ApplyNodeOverrides(thPlayer)
Link to comment

These functions require the 3D model to be loaded.

 

So the OnPlayerLoadGame event may trigger when the 3D is not yet loaded.

 

You can do a watitng cycle to find when the 3D is actually loaded like:

 

while !thPlayer.Is3DLoaded()

  Utility.waitMenuMode(0.5)

endWhile

 

and then call your functions.

Link to comment
Then is presumably the CALL of the function in "time" or  "sequence" wrong - i think.
 
And Utility.wait (0.5) should be correct - at least would Utility.waitManuMode (0.5)
personally new to me.
 
 
If there are problems Texture / or morph problems - and you Tri-Files are using, then a bug in Skyrim is the cause.
 
Skyrim reads the morphs (Tri) as the last, which leads to many problems.
 
A "simple" change of weight (for example) - with script - (without changing the value) resolves this a problem.
This must be the last call in the function, or call  a separate function.
The error often occurs when using the NiAlphaProperty or Environment Map in Nif's.

 

Link to comment

Basically I'm changing the players skin textures with a script. I'm using NetImmerse Override to change the players head textures. The four functions I'm calling are needed to get the right face tint, etc, back.

 

Perhaps I'm just doing it wrong. One hint might be that changing things like eye shadow, etc, in the race menu don't work properly anymore with the node override I've made for the face texture set.
 

Link to comment
As I said, it's a bug in Skyrim.

As Skyrim was released, it was almost 100% sure -

you change in the vanilla Racemenu race or gender = CTD.

 

There was an update - this update was relatively unsuccessful - expressed polite.

Then gave PreChache mods, this was much better.

 

But the cause was never fixed.

 

To ensure that this bug is the cause - you can do the following.

 

After starting the game, and the texture bug exists - in console click on your PC and then type setnpcweight xxx.

xxx = your value (for example, 100)

 

If the textures are displayed properly - then 2 ways.

 

1. You find yourself so down - and despair - or write a script

2. You open your ESP again in CK - and invite all meshes and textures / Texture sets again.

Not very often - but sometimes - this is sufficient.

 

Also, the CK is a bit buggy - it is the master of the cache and forgets nothing.

 

Sometimes I had already create some ESP completely new, because there was no other way.

Link to comment

Try that:

 

 

while !thPlayer.Is3DLoaded()
  Utility.waitMenuMode(0.5)
endWhile
Game.UpdateHairColor()
Utility.waitMenuMode(0.5)
Game.UpdateTintMaskColors()
Utility.waitMenuMode(0.5)
NiOverride.ApplyOverrides(thPlayer)
Utility.waitMenuMode(0.5)
NiOverride.ApplyNodeOverrides(thPlayer)

 

Maybe the game engine requires some time between one call and the next one.

Link to comment

Thanks for the replies guys, much appreciated :)
 
I was somehow able to fix the issue by making the node override with the face textures non-persistent and simply re-applying it in the OnPlayerLoadGame event. As if by magic it now all works, and I only have to call Game.UpdateHairColor() and Game.UpdateTintMaskColors(). The fact that the two apply functions aren't needed anymore makes me think I'm using a newer version of the NiNode plugin that comes with the reacemenu replacer I'm using.
 

There was an update - this update was relatively unsuccessful - expressed polite.

 

:lol:
 

To ensure that this bug is the cause - you can do the following.
 
After starting the game, and the texture bug exists - in console click on your PC and then type setnpcweight xxx.
xxx = your value (for example, 100)
 
If the textures are displayed properly - then 2 ways.

 

Tried it. It shows the right textures for an instant, and then reverts back to what they were before. Very strange.
 

Try that:
 
 

while !thPlayer.Is3DLoaded()
  Utility.waitMenuMode(0.5)
endWhile
Game.UpdateHairColor()
Utility.waitMenuMode(0.5)
Game.UpdateTintMaskColors()
Utility.waitMenuMode(0.5)
NiOverride.ApplyOverrides(thPlayer)
Utility.waitMenuMode(0.5)
NiOverride.ApplyNodeOverrides(thPlayer)
 
Maybe the game engine requires some time between one call and the next one.

 

 

Tried it, but it doesn't work. For some bizarre reason the players face doesn't get updated at all if there are waits in between the functions.

Link to comment

 

 

Try that:

 

...
 

Maybe the game engine requires some time between one call and the next one.

 

 

Tried it, but it doesn't work. For some bizarre reason the players face doesn't get updated at all if there are waits in between the functions.

 

And what about forcing a NiNode update with thPlayer.QueueNiNodeUpdate()

After each function call? (Or maybe just at the end, I don't know.)

Link to comment

I spoke too soon about having solved the problem. Without the wait function it sometimes crashes and sometimes it works fine.

 

And what about forcing a NiNode update with thPlayer.QueueNiNodeUpdate()
After each function call? (Or maybe just at the end, I don't know.)

 

Doesn't work, sadly. I found out that the crashes are caused by Game.UpdateTintMaskColors(). The problem is calling it at the wrong time. If the function gets called after the fade-in when loading a game ends, it's fine.

Link to comment

NiOverride.UpdateModelWeight(thPlayer) already exists or tried?

 

Tried it. It shows the right textures for an instant, and then reverts back to what they were before. Very strange.

 

 

Are you sure that your script is executed only 1x?  ;)

 

I spoke too soon about having solved the problem. Without the wait function it sometimes crashes and sometimes it works fine.

 

 

It never hurts to let in serial calling functions some time.

Link to comment

NiOverride.UpdateModelWeight(thPlayer) already exists or tried?

 

Tried it just now. Doesn't work.

 

Are you sure that your script is executed only 1x?  ;)

 

It doesn't have an effect when called from a script. From the console it shows the standard race skin texture and the correct tint maps and reverts back in an instant.

 

It never hurts to let in serial calling functions some time.

 

What do you mean by that?

 

If only there was a good alternative to Game.UpdateTintMaskColors() that could be called at any time.

 

 

Link to comment

 

 

It doesn't have an effect when called from a script. From the console it shows the standard race skin texture and the correct tint maps and reverts back in an instant.

 

 

 

From the console, you mean you "setnpcweight xxx" entered?
And it works just a moment - and then shit again.
 
So my question is how many times "your" script is called?
 
The horror would be an endless loop  :lol:
Link to comment

From the console, you mean you "setnpcweight xxx" entered?

And it works just a moment - and then shit again.

 

Yes and yes.

 

So my question is how many times "your" script is called?

 

Once when you set the player's skin texture. This is done with an item, and happens while in the inventory menu. Game.UpdateTintMaskColors() works completely properly when it's called like that (the function was designed for menu use), and the player's new skin textures shows up and all the face tints are correct.

 

It's also called once in the OnPlayerLoadGame event, where it crashes because of Game.UpdateTintMaskColors(), unless I add a wait for ten seconds or so. The wait is somewhat unreliable, and I would like to see it go.

 

A solid alternative may be to call the function in a menu event. Hit tab, and then exit the menu, and done. Should work great, but if it's at all possible to have it work automatically, then that's of course preferred.

 

The horror would be an endless loop  :lol:

Yeah, that would be very bad indeed, but that isn't the case ;)

Link to comment

Did you tried to have the game to fully render the player before trying to alter it?

 

Like using the 3DReady first, then a small wait (0.5 seconds), then force 3d view, wait 0.5 second, and put back the first person view.

Link to comment
 
Should work great, but if it's at all possible to have it work automatically, then that's of course preferred.

 

 

 
 
 
changelog of SKSE:

1.6.6:
- fix Potion.IsFood
- fix crash in Actor.GetNthSpell when called on actors with no spells
- cosaves are deleted properly when overwriting existing saves
- cosave path now respects sLocalSavePath config setting
- steam_loader no longer uses current working directory
- automatic translation loader correctly derives current language
- set [Debug] WriteMinidumps=1 in the .ini file to write a minidump to <My Documents>\My Games\Skyrim\SKSE\Minidumps\ when the game crashes
- set [Display] iTintTextureResolution=<number> to pick the size of dynamically built tint textures (default is 256)
- ActiveEffects may now register for and send events
- Alias.SendModEvent
- Game.Get/SetMiscStat
- Race.GetRace, Race.Get/SetDefaultVoiceType
- Game.UpdateTintMaskColors, UpdateHairColor
- TextureSet.Get/SetNthTexturePath
- ActorBase.Get/SetFaceTextureSet
- Book.IsRead
- added NetImmerse class with various NiNode manipulation functions
 

 

 

 
My English sucks, but I suppose the functions / methods send a Return.
If the return is a boolean, then this would be a thought:
 
 
 
if Game.UpdateHairColor()
        if Game.UpdateTintMaskColors()
               ... etc.
        endif
endif

 

Link to comment

Did you tried to have the game to fully render the player before trying to alter it?

 

The player model is completely loaded when the fade-in after loading a game starts. That's what causes the crash: Updating during the transition from black screen to 3D view. It's easy to check this. Just open a debug message box in the load game event, and show if the 3D is loaded or not. The message box will show up when the screen is still black and it shows that the 3D is loaded.

 

My English sucks, but I suppose the functions / methods send a Return.

 

The functions don't return anything.

 

For now I've made the update to occur when you enter the main menu for the first time. Seems to work nicely and is easy to use, but if anyone feels like paining their brains some more, then by all means ;)

Link to comment

Archived

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

  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use