Jump to content

[LE] Need a very simple script to add item to a chest after dialogue


Dahveed

Recommended Posts

No, the property must be on the script that uses it, so on the topic script.

 

It's easy to understand why: let's say your script writes

 

Game.GetPlayer().AddItem( Garnet)

How is this script supposed to know what Garnet means? It wasn't declared anywhere. Just because you define it for another script, this script still won't know it. You need to attach the properties to each.

Link to comment
Share on other sites

Actually, you can put the properties on a single script attached to the same quest.

 

Assume you have a script on the quest holding all the various properties needed throughout all the various topic info fragments. Assume that one of those properties points to a garnet and has been labeled as Garnet. Assume that you have named said quest script "myQuestScript".

 

You can then do the following whenever you need to use that property from the quest script:

MiscObject myObject = (GetOwningQuest() as myQuestScript).Garnet

Or you can go more generic and pass the property into Form instead of the specific type that the property may be listed as.

Form myObject = (GetOwningQuest() as myQuestScript).Garnet

You can then use myObject as a local variable throughout the fragment doing whatever you need (i.e. transferring from the player to the NPC).

Link to comment
Share on other sites

@IsharaMeradin Thanks again, but I think my brain is too smol to understand any of that!

 

In my example the two things I'd constantly be reusing would be the container (DomGiftChest) and the "reputation" item I created (I just made a miscobject called _Dom_BrowniePoint), the number of BrowniePoint objects in the chest being the eventual measure of the player's relationship level with the follower.

 

Could the same thing be done?

 

So the line would be like:

 

Form DomGiftChest = (GetOwningQuest() as _DOM_DominiqueRecruitQuest).BrowniePoint

 

Or did I just completely butcher that code (most likely!)?

Link to comment
Share on other sites

You butchered it. :P

 

On your quest script you would have a property for the chest and a property for the points

ObjectReference Property DomGiftChest Auto
MiscObject Property _Dom_BrowniePoint Auto

Then in your topic info fragments when you need them you can do the following:

Form BP = (GetOwningQuest() as _DOM_DominqueRecruitQuest)._Dom_BrowniePoint
ObjectReference DGC = (GetOwningQuest() as _DOM_DominiqueRecruitQuest).DomGiftChest

Then in that fragment you can do things like:

DGC.AddItem(BP,5) ; adds five brownie points to the chest
Link to comment
Share on other sites

Okay, so the name of the "BrowniePoint" CK item is _DOM_BrowniePoint

The name of the chest is actually _DOM_BrownieCounterChest

 

So in the "scripts" tab of my quest I would add to the main quest script:

 

ObjectReference Property DomGiftChest Auto
MiscObject Property BrowniePoint Auto

 

Then in the script fragment box (in the bottom right of each dialogue) I would add:

 

Form BP = (GetOwningQuest() as _DOM_DominqueRecruitQuest).BrowniePoint
ObjectReference DGC = (GetOwningQuest() as _DOM_DominiqueRecruitQuest).DomGiftChest

 

What I don't understand is how the script will know what specific object in the game world needs to be added, and how it will know where the chest is in the game world? Since nothing seems to be pointing to them anywhere, it just seems that I've given arbitrary names that are similar to the actual objects, but not the objects themselves?

 

It seems to me that this script is still not telling the game to put a _DOM_BrowniePoint object into the _DOM_BrowniePointCounter container?

Link to comment
Share on other sites

The properties on the quest script would need to have the correct object data assigned to them. After compiling that script, highlight the script on the quest record and press the properties button. A new window appears that you can use to assign each property the correct object or value. If your property variable has the same name as the Editor ID of the target object then you can press the auto fill button and have it automatically assigned.

Link to comment
Share on other sites

Starting 1 compile threads for 1 files...
Compiling "_DOM_TIF__060D0ADB"...
F:\Skyrim Special Edition\Data\Source\Scripts\temp\_DOM_TIF__060D0ADB.psc(9,28): cannot convert to unknown type _dom_dominquerecruitquest
F:\Skyrim Special Edition\Data\Source\Scripts\temp\_DOM_TIF__060D0ADB.psc(9,28): cannot cast a quest to a _dom_dominquerecruitquest, types are incompatible
F:\Skyrim Special Edition\Data\Source\Scripts\temp\_DOM_TIF__060D0ADB.psc(9,58): _dom_dominquerecruitquest is not a known user-defined type
F:\Skyrim Special Edition\Data\Source\Scripts\temp\_DOM_TIF__060D0ADB.psc(10,40): cannot convert to unknown type _dom_dominiquerecruitquest
F:\Skyrim Special Edition\Data\Source\Scripts\temp\_DOM_TIF__060D0ADB.psc(10,40): cannot cast a quest to a _dom_dominiquerecruitquest, types are incompatible
F:\Skyrim Special Edition\Data\Source\Scripts\temp\_DOM_TIF__060D0ADB.psc(10,71): _dom_dominiquerecruitquest is not a known user-defined type
No output generated for _DOM_TIF__060D0ADB, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on _DOM_TIF__060D0ADB

Link to comment
Share on other sites

In the scripts tab of my follower quest:

 

 

ObjectReference Property DomGiftChest Auto

MiscObject Property BrowniePoint Auto

 

 

 

In the dialogue fragment section (bottom right):

 

Form BP = (GetOwningQuest() as _DOM_DominqueRecruitQuest).BrowniePoint
ObjectReference DGC = (GetOwningQuest() as _DOM_DominiqueRecruitQuest).DomGiftChest

 

DGC.AddItem(BP,5)

 

 

Then it leads to the errors above.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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