Jump to content

problem with SetModelPath()


Recommended Posts

so I have functions all set up for SetModelPath() to change a weapon or armor item properly but the change reverts back to the original when the game is closed and reloaded. Am I doing something wrong or is this a known limitation of the function?

 

For reference, here's one of the scripts:

 

 

Scriptname DBM_ChrysamereModelScript extends ObjectReference  

Static Property Opt1 Auto
Static Property Opt2 Auto
Static Property Opt3 Auto
Static Property Opt4 Auto

String Property Modelpath01 Auto
String Property Modelpath02 Auto
String Property Modelpath03 Auto
String Property Modelpath04 Auto

Message Property MyMSG Auto

Weapon Property MyWeap Auto

Event OnActivate(ObjectReference akActionRef)


    int MyBTN = MyMSG.Show()

        if MyBtn == 0 ; Default
                MyWeap.SetModelPath(ModelPath01)
                MyWeap.SetEquippedModel(Opt1)
                GetLinkedRef().Disable()
                GetLinkedRef().Enable()
        Elseif MyBtn == 1 ; Opt1
                MyWeap.SetModelPath(ModelPath02)
                MyWeap.SetEquippedModel(Opt2)
                GetLinkedRef().Disable()
                GetLinkedRef().Enable()        
        Elseif MyBtn == 2 ; Opt1
                MyWeap.SetModelPath(ModelPath03)
                MyWeap.SetEquippedModel(Opt3)
                GetLinkedRef().Disable()
                GetLinkedRef().Enable()            
        Elseif MyBtn == 3 ; Opt2
                MyWeap.SetModelPath(ModelPath04)
                MyWeap.SetEquippedModel(Opt4)
                GetLinkedRef().Disable()
                GetLinkedRef().Enable()
        EndIf

EndEvent

 

Thanks

Link to comment
Share on other sites

Nope, your not doing anything wrong.

There's quite a few SKSE functions are not persistent across reloading.

You'll need to set it up in a simple quest alias filled with the player with a OnPlayerLoadGame() event as maintenance.

 

http://www.creationkit.com/OnPlayerLoadGame_-_Actor

Edited by sLoPpYdOtBiGhOlE
Link to comment
Share on other sites

You can link objectreferences together through the CK. It is nice for when you want a specific objectreference, like a lever or button, to modify another ObjectReference without needing to define a property variable.
Ive mainly seen it used as a way to setup patrols.

Link to comment
Share on other sites

Yeah GetLinkedRef() I use in a much more elaborate way (which Sloppy above helped me debug the script for and re-wrote parts) and using GetNthLinkedRef() which is an SKSE function it can grab a specific object reference on a chain of linked references. In the above script I'm basically setting an activator to link to a display model and you can change the model path of said display item as long as its a weapon or armor. The more elaborate chain of linked references I use for a container based display system that will enable the same item on the chain of displays (or enable based on model or other condition). You should really look at the function list at the creation kit wiki site, there are so many functions you never knew you needed :)

Link to comment
Share on other sites

If you want a dynamic array of model paths for say weapons (can be used for armors as well).

Then you would scan every mod the user has when they load a game and dump all the base forms and get their model paths and store them in an array.

SKSE 1.7.3 GameData functions are damn handy and fast to dump all the base forms of a type from a esm/esp into an array pretty well instantly.
From there it's a case of the slow looping through all the base forms and getting their model paths and storing them in a an array of strings.
But once that's done Activating an object in game is fast to supply the model you need and covers every possible model the user may have even from other mods.

Basically it does away with that whole hard coded lists and If/ElseIf/Else/EndIf repeated over and over again and again with hard set values in your script.

Eg: By dynamic I mean Adaptable without rewriting the script with each a additional change.

Edited by sLoPpYdOtBiGhOlE
Link to comment
Share on other sites

  • Recently Browsing   0 members

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