Jump to content

Need help with I *think* a pretty basic script


Recommended Posts

Greetings. So I am using something that grants a trait on level-up and it works fine except for one minor detail.

The trait menu appears after you have selected a perk. Works fine unless you take Intense Training, which prompts the SPECIAL menu upon selection. What happens here is that the SPECIAL menu is superimposed by the trait menu and looks quite unsightly, like a bug tbh. Don't get me wrong, functionality is there, you can select the trait, which will close the trait menu and allow you to make your SPECIAL selection. But I would like to make it so the trait menu only appears after all other menus have been concluded. Maybe a kind of scripted condition, but I have no idea how to go about this.

Can anybody offer some relevant scripting wisdom to me in this regard? It would be greatly appreciated.

Link to comment
Share on other sites

I think this would do. Giving 1 to bShowTraitMenu will activate the trait menu after the levelup menu is closed.:

int iMenuID
int bShowTraitMenu
SetOnMenuOpenEventHandler (begin function {iMenuID}
	if bShowTraitMenu
		CallWhen ({} => ShowTraitMenu) ({} => 1 != MenuMode) 16
	endif
end) 1 1027
Link to comment
Share on other sites

Greetings again. Does this script go in a config folder or in the plugin? I tried inserting into the already-done plugin script because something I forgot to mention, the mod has a customizable option to set how often the trait menu appears. Ideally I want it set to appear every fifteen level-ups.

Link to comment
Share on other sites

If you need to store the value for the level requirement in a separate file, create 

data\config\amokrun1s mod.ini

 and place the following in it:

[General]
iModLevel=15 ;Give the player a trait at every 15 level.

Since the code I posted is an event-handler, it needs to run once at the start of a session. Place it in the GameMode block of a quest script, like this:

scn QuestScript

float fSetting
int iMenuID
int iModLevel
int iQ

begin GameMode
    if GetGameRestarted

        ; Read the level requirement value from a config file.
        TestExpr iModLevel = GetINIFloat "General:iModLevel" "amokrun1s mod.ini"

        if 0 < iModLevel

            ; Set an event-handler so it runs everytime the levelup menu is opened. 
            SetOnMenuOpenEventHandler (begin function {iMenuID}

                ; Test if the player's level meets the requirement.
                iQ = Floor ((player.Getlevel) / iModLevel)
                if 0 == (player.Getlevel) - (iQ * iModLevel)

                    ; If the requirement is met, run the trait menu after the levelup menu is closed.
                    CallWhen (begin function {}
                        
                        ; Give the player only 1 trait.
                        fSetting = GetNumericGameSetting "iTraitMenuMaxNumTraits"
                        SetNumericGameSetting "iTraitMenuMaxNumTraits" 1
                        ShowTraitMenu
                        
                        ; Set "iTraitMenuMaxNumTraits" the original value.
                        SetNumericGameSetting "iTraitMenuMaxNumTraits" fSetting 
                    end) ({} => 1 != MenuMode) 16
                endif
            end) 1 1027
        endif
    endif
end


Or for a Script Runner script, create a script file with "gr_" prefix, something like this:

"data\nvse\plugins\scripts\gr_amokrun1s_mod.txt"


So that it runs once at the start of a session.

In gr_amokrun1s_mod.txt:

float fSetting
int iMenuID
int iModLevel
int iQ

; Read the level requirement value from a config file.
TestExpr iModLevel = GetINIFloat "General:iModLevel" "amokrun1s mod.ini"

if 0 < iModLevel

    ; Set an event-handler so it runs everytime the levelup menu is opened. 
    SetOnMenuOpenEventHandler (begin function {iMenuID}

        ; Test if the player's level meets the requirement.
        iQ = Floor ((player.Getlevel) / iModLevel)
        if 0 == (player.Getlevel) - (iQ * iModLevel)

            ; If the requirement is met, run the trait menu after the levelup menu is closed.
            CallWhen (begin function {}
                
                ; Give the player only 1 trait.
                fSetting = GetNumericGameSetting "iTraitMenuMaxNumTraits"
                SetNumericGameSetting "iTraitMenuMaxNumTraits" 1
                ShowTraitMenu
                
                ; Set "iTraitMenuMaxNumTraits" the original value.
                SetNumericGameSetting "iTraitMenuMaxNumTraits" fSetting 
            end) ({} => 1 != MenuMode) 16
        endif
    end) 1 1027
endif


 

Link to comment
Share on other sites

Ah I see, thanks for the explanation.

So it worked! I didn't use your script exclusively, what I did was go into the mod's scripts, found the right one, then injected some of yours into it. Worked like a charm! Thanks so much for this, it makes the mod fit with vanilla so much better.

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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