Jump to content

Problem with a script


Recommended Posts

Ok I'm running around in circles I fear and not figuring this out so... HEEEEEEEELP :tongue:

 

I have a script that changes the model on the base form of a weapon reference. I am trying to save said properties into a quest script which will re-apply these changes to the base form when the game is loaded by the player because the SetModelPath() and SetEquippedModel() functions are not persistent in the script and reset when the game is shut down.

 

so here is the base script that works fine for changing the models:

Scriptname DBM_WeaponModelScript 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

Quest Property DBM_WeaponModelHandler Auto

String Property CurModel Auto
Static Property CurOpt Auto

Event OnActivate(ObjectReference akActionRef)

    int MyBTN = MyMSG.Show()

        if MyBtn == 0 ; Default model appearance option from menu
                MyWeap.SetModelPath(ModelPath01)
                MyWeap.SetEquippedModel(Opt1)
                GetLinkedRef().Disable()
                GetLinkedRef().Enable()
                CurModel = ModelPath01
                CurOpt = Opt1    
        Elseif MyBtn == 1 ; Opt2 on menu
                MyWeap.SetModelPath(ModelPath02)
                MyWeap.SetEquippedModel(Opt2)
                GetLinkedRef().Disable()
                GetLinkedRef().Enable()
                CurModel = ModelPath02
                CurOpt = Opt2        
        Elseif MyBtn == 2 ; Opt3 on menu
                MyWeap.SetModelPath(ModelPath03)
                MyWeap.SetEquippedModel(Opt3)
                GetLinkedRef().Disable()
                GetLinkedRef().Enable()
                CurModel = ModelPath03
                CurOpt = Opt3        
        Elseif MyBtn == 3 ; Opt4 on menu
                MyWeap.SetModelPath(ModelPath04)
                MyWeap.SetEquippedModel(Opt4)
                GetLinkedRef().Disable()
                GetLinkedRef().Enable()
                CurModel = ModelPath04
                CurOpt = Opt4
        EndIf

EndEvent

I've tried coding the quest into the script and it send the script property to the quest but it doesn't register that the property is on that quest even though it is. I suspect it's an issue with the activator itself needing to be a reference alias of the controlling quest and have the script owned by said quest?:

 

MyQuest.WeaponModel = CurModel

MyQuest.WeaponOpt = CurOpt

 

Any help would be appreciated. I'm having another difficulty pertaining to this but having a hard time articulating it at the moment, so maybe if I get pointed in the right direction for the above stuff, the other will fall into place. Thanks.

Link to comment
Share on other sites

As usual, you've left some gaps for someone to only assume what you want. lol

 

 

Since your going to need inter script communication between your weapon display object and the maintenance quest script, put a scriptname extends on your code, so we can actually use the script name your using.

 

If you have a maintenance quest then same supply the alias script name and the quest script name.

So we can cater to what your after without assuming to much.

 

I notice in your code you have every option for CurOpt and CurModell all point to the first opt and weaponpath regardless of the option chosen and loaded.

Was that an oversight or meant to be that way?

 

As usual, I can't help but re-invent the wheel:

Scriptname Idontknow Extends ObjectReference (likely assumption)

ReloadWeapnModel Property RWM Auto ;This is the script attached to your maintenance quest and has the CurModel and CurOpt stored and will contain a function to set the cur weapon path/opt.

Static[] Property Opt Auto
String[] Property Modelpath Auto
Message Property MyMSG Auto
Weapon Property MyWeap Auto

Event OnActivate(ObjectReference akActionRef)
    Int MyBTN = MyMSG.Show()
    If MyBtn >= 0 && MyBtn < Opt.Length
        MyWeap.SetModelPath(ModelPath[MyBtn])
        MyWeap.SetEquippedModel(Opt[MyBtn])
        GetLinkedRef().Disable()
        GetLinkedRef().Enable()        
        RWM.CurModel = ModelPath[MyBtn] ;<-- Shouldn't this reflect the current model path string, all point to first modelpath string in your orig code.
        RWM.CurOpt = Opt[MyBtn] ;<-- Shouldn't this reflect the current static, all point to first static in your orig code.
    Else
        RWM.CurModel = ModelPath[0] ;Default ist option
        RWM.CurOpt = Opt[0]    ;Default ist option    
    EndIf
EndEvent
Edited by sLoPpYdOtBiGhOlE
Link to comment
Share on other sites

So I updated the script above... All I basically need is to figure out how to send these two properties through to the DBM_WeaponModelHandler script so that a player referencealias OnPlayerLoadGame() function can set each of the models to the models in the quest script's current properties

 

We aren't working with Arrays here, so the String and Static properties for the ModelPath and Opt properties all do need to be there because they are all manually applied in the properties tab.

Link to comment
Share on other sites

 

 

We aren't working with Arrays here, so the String and Static properties for the ModelPath and Opt properties all do need to be there because they are all manually applied in the properties tab.

That was surely blonde moment when you posted that dude..

 

There's a difference in filling a Property Array to a single Property in CK.?

News to me, guess I should stop assigning and filling Array Properties in CK property tab then huh. :P

 

Sorry couldn't help myself :D

Link to comment
Share on other sites

Ok enough shits and giggles, on with the show...

 

All compile fine, but not actually tested it.

 

This is your maintenance quest script (no properties for you to fill)

 

Scriptname DBM_WeaponModelHandler Extends Quest

String Property CurModel Auto Hidden
Static Property CurOpt Auto Hidden
ObjectReference Property WpnDisplay Auto Hidden

Function SetCurWpn()
    If WpnDisplay && CurOpt && CurModel != ""
        (WpnDisplay As DBM_WeaponModelScript).SetCurWeapon(CurModel, CurOpt)
    EndIf
EndFunction

 

This is your Alias script that you attach to the player alias in your maintenance quest

 

Scriptname DBM_WeaponHandlerAlias Extends ReferenceAlias

Event OnPlayerLoadGame()
    (GetOwningQuest() As DBM_WeaponModelHandler).SetCurWpn()
EndEvent

 

This is your weapon display object script

 

Scriptname DBM_WeaponModelScript Extends ObjectReference

DBM_WeaponModelHandler Property WMH Auto
{Set this in CK to point to the maintenance quest that the script is attached to.}

Static[] Property Opt Auto ;Fill this in CK, index 0 matches Modelpath index 0 which matches the Msg option 0 and so on.
String[] Property Modelpath Auto ;Fill this in CK, index 0 matches Opt index 0 which matches the Msg option 0 and so on.
Message Property MyMSG Auto
Weapon Property MyWeap Auto

Event OnInit()
    WMH.WpnDisplay = Self
EndEvent

Event OnActivate(ObjectReference akActionRef)
    Int MyBTN = MyMSG.Show()
    If MyBtn >= 0 && MyBtn < Opt.Length
        SetCurWeapon(ModelPath[MyBtn], Opt[MyBtn])
        WMH.CurModel = ModelPath[MyBtn]
        WMH.CurOpt = Opt[MyBtn]
    EndIf
EndEvent

Function SetCurWeapon(String CurModel, Static CurOpt)
    MyWeap.SetModelPath(CurModel)
    MyWeap.SetEquippedModel(CurOpt)
    GetLinkedRef().Disable()
    GetLinkedRef().Enable()
EndFunction

Link to comment
Share on other sites

k... tried the quest script both in the native script for the quest and as a new script attached to the quest and get errors when it compiles:

 

 


Starting 1 compile threads for 1 files...
Compiling "DBM_WeaponModelHandler"...
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DBM_WeaponModelHandler.psc(9,20): cannot convert to unknown type dbm_weaponmodelscript
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DBM_WeaponModelHandler.psc(9,20): cannot cast a objectreference to a dbm_weaponmodelscript, types are incompatible
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DBM_WeaponModelHandler.psc(9,46): dbm_weaponmodelscript is not a known user-defined type
No output generated for DBM_WeaponModelHandler, compilation failed.

 

I attach the activator script and the damned compiler just tries to compile the first script, which is very odd. It will compile accurate scripts no problem, but if there are any errors in the script it keeps reporting the original script compiling, which is just weird. Gonna restart the CK and see what the hell is going on

Link to comment
Share on other sites

  • Recently Browsing   0 members

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