Jump to content

Self-Resetting Flora


Zorkaz

Recommended Posts

When playing with no-respawn flora also won't respawn.

Has anyone scripted respawning flora?

 

Does self.reset() work?

 

 

Btw. I could obviously test this out but only in one or two days, so that's why I'm asking beforehand

 

 

 

Link to comment
Share on other sites

Sure thing:

Scriptname SKK_MWFloraScript extends ObjectReference Const

ActorValue 	Property pSKK_MWTimeStamp 		Auto Const Mandatory 
GlobalVariable 	Property pSKK_MWFloraRegrowthGameHours 	Auto Const Mandatory ;GameDaysPassed Hours: (1/24) = .04167

;Default regrowth is 24 game hours from harvest.
;The plant does not update unless the player leaves and returns so it can unload/load to refresh
;avoiding a s#*! load of timers ticking. There are solutions that tick a timer for each plant FFS. 

;**********************************************************************************************
Event OnInit()
	Self.SetHarvested(TRUE)
	Self.SetValue(pSKK_MWTimeStamp, Utility.GetCurrentGameTime())
EndEvent
;**********************************************************************************************
Event OnLoad()
    If (GameHoursToGo() <= 0)
        Self.SetHarvested(FALSE)
    EndIf
EndEvent
;**********************************************************************************************
Event OnActivate(ObjectReference akActionObject)
	Self.SetHarvested(TRUE)
	Self.SetValue(pSKK_MWTimeStamp, Utility.GetCurrentGameTime())
EndEvent
;**********************************************************************************************
Float Function GameHoursToGo() 
	Float fReturnValue = (((Self.GetValue(pSKK_MWTimeStamp) + (pSKK_MWFloraRegrowthGameHours.GetValue() * 0.04167)) - Utility.GetCurrentGameTime()) / 0.04167)
	Return fReturnValue
EndFunction
;**********************************************************************************************
Link to comment
Share on other sites

Thank you so much for sharing your script, SKK!

 

I've looked this up before, but came across the one made for Skyrim, thinking "all those timers ticking constantly on each plants can't be a good thing??" I decided to give up on it at the time. Your method looks like a much better solution! :thumbsup:

Link to comment
Share on other sites

Forgot to mention that script starts the plant as empty or harvested OnInit() as its workshop plantable from a food item and planting with produce would be a duplication glitch. If your hand placing or spawning in the wild you will not want to do that, just wait for OnActivate harvest.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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