Jump to content

Script: Self-respawning plant


Zorkaz

Recommended Posts

I can't get into how the flora nifs work with their odd ninodes, so I made it an activator that gets disabled and Onload() might or might not enable itsefl again.

 

Has anyone a better option that's simple?

That's the current script for it, btw.


Event Onload()
Randoo = Utility.randomint(1,20)
If Randoo == 1
Self.enable()
Endif
EndEvent

 

The downside is the randomness of course and I might let it check the time additionally.

 

(I remember SKK50 made a flora workaround but can't find the post)

Link to comment
Share on other sites

Here ya go generic harvest & regrowth neat const script with no nasty timers.

 

If built at a workshop, when player is on site and 3d is loaded a flora management module iterates WorkshopItemKeyword linked references for object "is SKK_MWFloraScript" then "as SKK_MWFloraScript.UpdateHarvested()".

Scriptname SKK_MWFloraScript extends ObjectReference Const

ActorValue 	Property pSKK_MWTimeStamp 	        Auto Const Mandatory 
GlobalVariable 	Property pSKK_MWFloraRegrowthGameHours 	Auto Const Mandatory ;GameDaysPassed as 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.

;**********************************************************************************************
Event OnInit()
	Self.SetHarvested(TRUE)
	Self.SetValue(pSKK_MWTimeStamp, Utility.GetCurrentGameTime())
EndEvent
;**********************************************************************************************
Event OnLoad()
	UpdateHarvested()
EndEvent
;**********************************************************************************************
Event OnActivate(ObjectReference akActionObject)
	Self.SetHarvested(TRUE)
	Self.SetValue(pSKK_MWTimeStamp, Utility.GetCurrentGameTime())
EndEvent
;**********************************************************************************************
Function UpdateHarvested() ;  cf "SKK_MWFloraScript.UpdateHarvested"
	If (GameHoursToGo()  <= 0)
		Self.SetHarvested(FALSE)
	EndIf
EndFunction
;**********************************************************************************************
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

  • Recently Browsing   0 members

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