Jump to content

Mentoring Req: Workbench On Activate help


FlashyJoer

Recommended Posts

Hi all, looking for some guidance on how to make a specific function work for a quest I am working on... in a nutshell, at one point in a dialogue, a fragment sets a global variable (WantsHome) to 1. When this variable is one, it opens the 'Find a home' quest, which in essence is to identify a single settlement to use as a private player home. As I understand it, I could use an Event On Activate for the workbench and attach conditions to it, to ensure quest is running. The whole purpose of activating the workbench is to pop open a messagebox with two choice buttons, use as home or not this one. In the on activate event, if the choose this as home is selected, it would only set a global called 'FoundHome' which is used to trigger next dialogue. Still with me?

 

What I am asking for guidance on, is how to set up the Event OnActivate for any and all workbenches in the game. I assume generically, the event looks for items that have a keyword, say like WorkshopWorkbench or something. If that condition is met, it will go onto the MSG.show() and the if/endif statements for the buttons and their functions.

 

Ive never used an Event On[xxxx] before, nor Reference Objects, so not entirely sure how to proceed, nor how to set this up... anyone willing to offer a newbie some assistance, if this is even possible to do? If the workbench will not allow such an onactivate event, perhaps another object, like a Settlement Bell or something perhaps? Much thanks!

 

Idea of script:

 

Event OnActivate (....)

If ObjectReference.haskeyword(....)

If WantsHome.getvalueint() == 1 && FindHome.getstage() == 10

int Choice = MSG_WantsHome.show()

If Choice == 0

WantsHome.setvalueint(1)

Else

Return

Endif

Endif

Endif

EndEvent

 

Would that work? And more importantly, how to set the OnActivate parameters and objectreference for workbenches...

Link to comment
Share on other sites

Ive decided to test this out with something other than the workbench, so I created a constructable object using the Sanctuary Empty Mailbox. I can get it to show in the Special Build Menu just fine and it builds / scraps. So this is a start in the right direction. I opted for this method, as I can attach a script to the object and it is in there I want to add the ObjRef OnActivate yes? Or is there a better one I can use that relates to the fact it is built? I think I will check out Mama Murphys chair to see how it triggers things...

 

EDIT: So, it appears just by building the object, it triggers quest updates, based on the script below that is attached to her chair. Am I reading into this correctly, that building it alone is enough to update variables and quest stages? Because if so, I wont need the objRef stuff I asked about above, will I?

 

Event OnInit()
debug.trace(self + " OnInit")
MurphyChair.ForceRefTo(Self)
MQ00ChairMamaMurphyBuilt.SetValueint(1)
MQ00MamaMurphy.SetStage(50)
MQ00MamaMurphy.AssignToChair((self as ObjectReference) as WorkshopObjectScript)
EndEvent

Link to comment
Share on other sites

I have gotten the mailbox to work on instantly updating my global variable upon placement in a settlement. :)

 

The downside is the messagebox obviously does not show in build mode and it doesnt populate when exiting build mode... but that is a trade off I am comfortable with.

 

For clarity / history for those looking for similar solutions:

 

Clone the item you want to have added to the build menu. Change the name of the item to whatever you want it to show as once built ingame.

Clone / create a new created object and add a workbench keyword and a recipe filter, so the game can put it into the build menu. Add required items to build and then point the COBJ (created object) to the item you made in the step above.

Final step, add a script to the object created / modified in step 1. If you want it to simply do as I did, to update a variable and trigger a quest stage, do:

 

Event OnInit()

{global variable name}.setvalueint(xxx)

{Quest name}.setstage(xxx)

EndEvent

 

Simple, I know, but sometimes the simple answers are harder to find than the more complicated stuff that seldom makes sense to modding newbies ;)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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