Jump to content

Implementing a time delay to emulate building


Recommended Posts

Okay, let’s say I have a new settlement and the settlement is designed to be built in modules (e.g., SecurityModule, DormitoryModule, etc). Inside the base settlement which has a terminal to facilitate building the respective modules (menu select item). Realistically there should be some cost (e.g., caps, steel, concrete, etc) to implement said construction module and a check to see if the player has the requisite materials. Realistically, there should be a time factor as well but haven’t figured out how to implement that yet. More realistically I am thinking forcing the player to leave the area for several days would be appropriate, then when he or she returns the building is complete. Not sure if this is a scripting solution, a quest or a combo of both. Suggestions?


BTW, here is the script function to date.




;-- Functions ---------------------------------------
Function DormConstruct()
; Debug.Trace("MLS_ConstructionProtocolScript.DormConstruct Function has been called", 0)
If (pMLS_DormConstructState.GetValue() == 0 as float)
ObjectReference ThisWorkshop = Self.GetLinkedRef(pWorkshopItemKeyword)
If (ThisWorkshop == None)
;Debug.Trace("MLS_ConstructionProtocolScript.DormConstruct ERROR NoWorkshop", 0)
pMLS_CmdCntrTerminalNoWorkshop.Show(0, 0, 0, 0, 0, 0, 0, 0, 0)
Else
; Test to see if player has requisite materials
ObjectReference PlayerRef = Game.GetPlayer()
If (PlayerRef.getitemcount(c_Concrete as Form) >= 3016 && PlayerRef.getitemcount(c_Steel as Form) >= 934)
PlayerRef.removeitem(c_Concrete as Form, 3016, False, None)
PlayerRef.removeitem(c_Steel as Form, 934, False, None)
MLS_DormConstructEnabler.Enable()
; Disable the collision marker so NPC can access dormitory
MLS_DormCollision.disable()
pMLS_DormConstructState.SetValue(1 as float)
ElseIf
(ThisWorkshop.getitemcount(c_Concrete as Form) >= 3016 && ThisWorkshop.getitemcount(c_Steel as Form) >= 934)
ThisWorkshop.removeitem(c_Concrete as Form, 3016, False, None)
ThisWorkshop.removeitem(c_Steel as Form, 934, False, None)
MLS_DormConstructEnabler.Enable()
; Disable the collision marker so NPC can access dormitory
MLS_DormCollision.disable()
pMLS_DormConstructState.SetValue(1 as float)
Else
;Debug.Trace("MLS_ConstructionProtocolScript.DormConstruct ERROR InsufficientResources", 0)
pMLS_InsufficientResourcesMsg01.Show(0, 0, 0, 0, 0, 0, 0, 0, 0)
EndIf
EndIf
EndIf
EndFunction



Link to comment
Share on other sites

There are a bunch of different ways, but the really really important thing is how you will communicate the delay / dependency / latency to the user.

 

Every sh1t base game experience contains a "wait an unspecified time for an unspecified event and something may or may not happen". Thats really nasty, you know like "keep working with father" ... WTF ?

 

Consider if and how you want to inform the player of delay / dependency / latency start and completion (RTFM, modal or transient notification) and then key the script timers or trigger events to those messages.

Link to comment
Share on other sites

There should be a function to read the current game time and date. Then you tell the player "it will be finished on some date", and delay spawning into the world until that date. Use a time delay loop (pause or sleep, whatever papyrus has) to check the time.

 

You'll need to store that info someplace to allow tracking across logouts.

 

Use a run-on-start quest to trigger the time check script. Make sure to check the box allowing the quest to run more than once.

 

Oh, and since script time is tied to FPS it will never be exact, but you can get pretty close.

Link to comment
Share on other sites

Thanks for the input and suggestions. At present I am envisioning a 5 day construction project with notification message as follows:

Building construction at Settlement Name has begun. Completion expected in five days.
Construction project at Settlement Name is 25% complete
Construction project at Settlement Name is 50% complete
Construction project at Settlement Name is 75% complete
Construction project at Settlement Name is 100% complete. Building is available for use.
Roger the info on StartTimerGameTime and OnTimerGameTime.
Link to comment
Share on other sites

For the time delay, I would recommend using StartTimerGameTime and OnTimerGameTime : https://www.creationkit.com/fallout4/index.php?title=StartTimerGameTime_-_ScriptObject

instead of polling. The timers can have different ID's for different modules the player builds.

 

Thanks. I know in general loops are a bad idea for timing, but I'm not familiar enough with papyrus to know the right way to do it lol

Link to comment
Share on other sites

This is a generic function I use in multiple soluitons, but, I dont actually think thats what you want else you will need to poll for that value;

;*************************************************************************************
;pSKK_XXXTimeStamp actor value stores Utility.GetCurrentGameTime() on an object when the GameTimer starts.
;pSKK_XXXWaitGameHours global variable stores the game hours to wait before completion.
;0.04167 coverts game hours to game days and back again  

Float Function GameHoursToGo() 
   Float fReturnValue = (((Self.GetValue(pSKK_XXXTimeStamp) + (pSKK_XXXWaitGameHours.GetValue() * 0.04167)) - Utility.GetCurrentGameTime()) / 0.04167)
   Return fReturnValue
EndFunction
;**********************************************************************************************

You probably just want to start a game timer for 1.25 game days, OnTimerGameTime pop a notification, increment a counter and restart the timer until the counter reaches 4 then finish.

Link to comment
Share on other sites

Now within the StartTimerGameTime and OnTimerGameTime construct I need to figure out how to calculate the percentage of time elapsed.

 

Use 4 days and 25% a day?

 

You want the math? You are going to have to convert all times to hours (or minutes or seconds, depending on how precise you want to be). Have to use the same units for everything, hours is probably the best way.

 

((currentTime - startTime)/howLong)*100

Link to comment
Share on other sites

  • Recently Browsing   0 members

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