Jump to content

Scripting - Put an item into a container at player level


Recommended Posts

Hello guys,

 

Could someone please help me with the scripting part? I've always hated any kind of programming (I am a 3D artist, any prog. language is a rocket science for me)

What I want is:
When a player reaches level 30, put items X and Y into a storage container in the player's room in The Lodge.


I tried to find some tutorials, but none of them are for exactly THIS + Bethesda WIKI doesn't work anymore 😄

Link to comment
Share on other sites

Something like this should work:

1) Create a quest: uncheck Starts Game Enabled, check Allow Repeated Stages, add a Quest Stage to it (give it the Stage Index 1 and check Run on Start)

2) Navigate to the Story Manager Event Node and add the your quest to the node called "Increase Level"

    - might can bit difficult at first if you haven't done this previously; just add the branch and quest nodes then the quest

    - add this condition to the newly added quest node: GetLevel, Run on: Player, comparison value == 30 (or whatever Level you need)

3) Navigate back to your quest, then in the first quest fragment you just added to it, paste this script:

    LodgeSafeRef.AddItem(myItemX)
    LodgeSafeRef.AddItem(myItemY)
    Utility.Wait(0.5)
    Stop()

    this would add myItemX and myItemY to the LodgeSafeRef when the Story Manager starts the quest; this happens (as per the GetLevel condition function) when the player reaches Level 30.
    here's a bit more info on Story Manager: in short, it's a hardcoded manager that after receiving certain events sent by the native code, tries to start quests one can specify in the Creation Kit. As you can see, it only supports a few events like Actor Dialogue Event, Increase Level and so on but it still can be pretty handy.

4) Make sure to fill out the script properties myItemX and myItemY after you attempt to Compile it: to do so, click Advanced, Edit Source then paste the properties like:

    Form Property myItemX Auto Const
    Form Property myItemY Auto Const
    ObjectReference Property LodgeSafeRef Auto Const

    at the bottom of the script. Save the script file, click Properties and select the Property and Form from the dropdown lists. (You can take a look at some other quest fragments and scripts).
    note that you can replace "Form" with another game form depending on the item, e.g. if it's a Potion then "Potion Property myItemX Auto Const"

Link to comment
Share on other sites

1 hour ago, LarannKiar said:

Something like this should work:

1) Create a quest: uncheck Starts Game Enabled, check Allow Repeated Stages, add a Quest Stage to it (give it the Stage Index 1 and check Run on Start)

2) Navigate to the Story Manager Event Node and add the your quest to the node called "Increase Level"

    - might can bit difficult at first if you haven't done this previously; just add the branch and quest nodes then the quest

    - add this condition to the newly added quest node: GetLevel, Run on: Player, comparison value == 30 (or whatever Level you need)

3) Navigate back to your quest, then in the first quest fragment you just added to it, paste this script:

    LodgeSafeRef.AddItem(myItemX)
    LodgeSafeRef.AddItem(myItemY)
    Utility.Wait(0.5)
    Stop()

    this would add myItemX and myItemY to the LodgeSafeRef when the Story Manager starts the quest; this happens (as per the GetLevel condition function) when the player reaches Level 30.
    here's a bit more info on Story Manager: in short, it's a hardcoded manager that after receiving certain events sent by the native code, tries to start quests one can specify in the Creation Kit. As you can see, it only supports a few events like Actor Dialogue Event, Increase Level and so on but it still can be pretty handy.

4) Make sure to fill out the script properties myItemX and myItemY after you attempt to Compile it: to do so, click Advanced, Edit Source then paste the properties like:

    Form Property myItemX Auto Const
    Form Property myItemY Auto Const
    ObjectReference Property LodgeSafeRef Auto Const

    at the bottom of the script. Save the script file, click Properties and select the Property and Form from the dropdown lists. (You can take a look at some other quest fragments and scripts).
    note that you can replace "Form" with another game form depending on the item, e.g. if it's a Potion then "Potion Property myItemX Auto Const"

Hi, thank you very much for your time 🙂

Unfortunately I am doing something wrong.
This is the story manager:

image.thumb.jpeg.e12ecd04f747972ed834dda5bb7d538a.jpeg

Here I changed the name for the safe in the Lodge to LodgeSafe (otherwise the reference was empty)

image.thumb.jpeg.e1e980a2b7cfdf461f39ec0fc4b37bd9.jpeg

and here is the Quest Stage after clicking Compile
image.thumb.jpeg.42aa6655da14c937b524495655124294.jpeg 

I tried to follow your step 4 but there is no Edit Source when clicking on Advanced tab

Link to comment
Share on other sites

When you click Compile, press OK to the Papyrus Errors window then press OK to the Quest window. Reopen the Quest Window then click the Advanced tab. The Edit Script button shouldn't be grayed out by then.

Alternatively, you can add script properties in the Script Properties window accessible though the Properties button.

Link to comment
Share on other sites

52 minutes ago, LarannKiar said:

When you click Compile, press OK to the Papyrus Errors window then press OK to the Quest window. Reopen the Quest Window then click the Advanced tab. The Edit Script button shouldn't be grayed out by then.

Alternatively, you can add script properties in the Script Properties window accessible though the Properties button.

You are right, Edit Script is not greyed out, but clicking on it asks me to open the .psc in External Editor. When I use Notepad for example, it looks like this:

 

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
Scriptname Fragments:Quests:QF_artesianpulserifle_quest_02002289 Extends Quest Hidden Const

;BEGIN FRAGMENT Fragment_Stage_0001_Item_00
Function Fragment_Stage_0001_Item_00()
;BEGIN CODE
LodgeSafe.Additem(artesianpulserifle)
Utility.Wait(0.5)
Stop()
;END CODE
EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

 

I am not sure where should I add those prompts(below) you said, to not break anything. I used only one additem(artesianpulserifle) in this case.

 

Form Property artesianpulserifleAuto Const
ObjectReference Property LodgeSafe Auto Const

 

The same goes If I'd want to use the 2nd option you said:

image.thumb.jpeg.82349f93f4d0658576e6a76091320ad5.jpeg

(is that correct?)

Sorry for asking so many questions 🙂

Link to comment
Share on other sites

No problem at all. 🙂 

The script should like this:

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
Scriptname Fragments:Quests:QF_artesianpulserifle_quest_02002289 Extends Quest Hidden Const

;BEGIN FRAGMENT Fragment_Stage_0001_Item_00
Function Fragment_Stage_0001_Item_00()
;BEGIN CODE
LodgeSafe.Additem(artesianpulserifle)
Utility.Wait(0.5)
Stop()
;END CODE
EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

Form Property artesianpulserifle Auto Const

Or, assuming "artesianpulserifle" is a weapon, you can replace "Form" with "Weapon" in the last line.

Then save the file in your text editor, select this weapon form in the Properties window so that the game will know which exact form this script property should point to, then press OK.

Notes:

     - the file you save in the text editor is the script's source file, they have the file extension .psc; the compiled ones are binary, non human readable .pex files

     - a script property is actually a script variable; AddItem() can only add a form to the LodgeSafe if the script variable you pass into it by writing Additem(artesianpulserifle) points to an actual form; you choose this form when you select one in the Properties window

Link to comment
Share on other sites

9 hours ago, LarannKiar said:

No problem at all. 🙂 

The script should like this:

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
Scriptname Fragments:Quests:QF_artesianpulserifle_quest_02002289 Extends Quest Hidden Const

;BEGIN FRAGMENT Fragment_Stage_0001_Item_00
Function Fragment_Stage_0001_Item_00()
;BEGIN CODE
LodgeSafe.Additem(artesianpulserifle)
Utility.Wait(0.5)
Stop()
;END CODE
EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

Form Property artesianpulserifle Auto Const

Or, assuming "artesianpulserifle" is a weapon, you can replace "Form" with "Weapon" in the last line.

Then save the file in your text editor, select this weapon form in the Properties window so that the game will know which exact form this script property should point to, then press OK.

Notes:

     - the file you save in the text editor is the script's source file, they have the file extension .psc; the compiled ones are binary, non human readable .pex files

     - a script property is actually a script variable; AddItem() can only add a form to the LodgeSafe if the script variable you pass into it by writing Additem(artesianpulserifle) points to an actual form; you choose this form when you select one in the Properties window

Morning!
I used the code you sent me and saved it, but there is no option how to select the weapon form. Clicking on the Properties button doesn't do anything. So I clicked to arrow next to it and Created property like this:

image.thumb.jpeg.be3578689f274053eacec24545f6594b.jpeg

But after clicking OK I still have compilation errors:

image.thumb.jpeg.cc0b5f073e22292b7f013891182e8a79.jpeg

 

 

 

 

 

 

Link to comment
Share on other sites

I forgot about the LodgeSafeRef property, you need to have ( ObjectReference Property LodgeSafeRef Auto Const ) as well.

Form Property artesianpulserifle Auto Const
ObjectReference Property LodgeSafeRef Auto Const

You can add this property similarly to the weapon but as it is an Object Reference and not a Base Form ("Base Object"), you'll have to select it in the game world using the Render Window.

Link to comment
Share on other sites

1 hour ago, LarannKiar said:

I forgot about the LodgeSafeRef property, you need to have ( ObjectReference Property LodgeSafeRef Auto Const ) as well.

Form Property artesianpulserifle Auto Const
ObjectReference Property LodgeSafeRef Auto Const

You can add this property similarly to the weapon but as it is an Object Reference and not a Base Form ("Base Object"), you'll have to select it in the game world using the Render Window.

How do you select it in the game world when it's only a script? I dont see any option that woud allow me to select anything from the render window 😮
So right now I have this in Papyrus Fragment:

LodgeSafe.AddItem(artesianpulserifle, 1)
Utility.Wait(0.5)
Stop()

image.thumb.jpeg.c802c1cf57c090a1549749f6a422bf61.jpeg


And this is when I click Advanced and Edit script:

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
Scriptname Fragments:Quests:QF_artesianpulserifle_ques_02002289_1 Extends Quest Hidden Const

;BEGIN FRAGMENT Fragment_Stage_0001_Item_00
Function Fragment_Stage_0001_Item_00()
;BEGIN CODE
LodgeSafe.AddItem(artesianpulserifle, 1)
Utility.Wait(0.5)
Stop()
;END CODE
EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

Weapon Property artesianpulserifle Auto Const

ObjectReference Property LodgeSafe Auto Const

image.thumb.jpeg.52d27ae4db5aa7c9126f109a404aa53b.jpeg

After clicking Compile button, there is no "error" showing. Sooo... is it working as it should (I know I should test it first but I am affraid now 😄 )

Link to comment
Share on other sites

  • Recently Browsing   0 members

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