Issue #24775: WorkshopFloraHarvestTime Actor Value Not Set on Workshop Flora Creation
There appears to be a bug with newly created workshop plants (mutfruit, tatos, corn, etc.) being SetHarvested(False) when they first reload. For instance, if I create a mutfruit plant, unload and reload the workshop, the mutfruit plant will suddenly have fruit on it. This occurs because the Actor Value WorkshopFloraHarvestTime is only set when the plant is activated (through the OnActivate() event in WorkshopObjectScript), and not when it is created.
Therefore, when the plant is first placed, WorkshopFloraHarvestTime defaults to 0. So, when the game checks whether a day has elapsed in the HandleWorkshopReset() function (as per the WorkshopObjectScript), it will always return true. That is, assuming that the player is at least 1 in-game day into the save.
I call this a bug because the HandleCreation() function goes out of it's way to ensure that there won't be any fruit on any newly created plant. So, it doesn't make much sense that the plant could then instantly grow fruit on reload, given that it would otherwise take a full day.
A simple fix would be to run SetValue(WorkshopParent.WorkshopFloraHarvestTime, Utility.GetCurrentGameTime()) where HandleCreation() has SetHarvested(True). I had a quick look over the UFO4P WorkshopObjectScript (with the find feature) and I didn't come across anything addressing this issue. Additionally, installing UFO4P doesn't appear to fix this issue in-game.
This section of code appears to work as a solution, and can be implemented into an external script. It's just something that I've included in my mod in absence of another fix.
Event OnInit() Self.RegisterForCustomEvent(akSender = WorkshopParent, asEventName = "WorkshopObjectBuilt" EndEvent Event WorkshopParentScript.WorkshopObjectBuilt(WorkshopParentScript akSender, Var akArgs) If ((akArgs As WorkshopObjectScript).GetBaseObject() As Flora) If (!(akArgs As WorkshopObjectScript).GetValue(akAV = WorkshopParent.WorkshopFloraHarvestTime)) (akArgs As WorkshopObjectScript).SetValue(akAV = WorkshopParent.WorkshopFloraHarvestTime, afValue = Utility.GetCurrentGameTime()) EndIf EndIf EndEvent
if bNewlyBuilt ; if flora, mark initially as harvested if GetBaseObject() as Flora SetHarvested(true) ;UFO4P 2.0.5 Bug #24775: also initialize the related actor value: SetValue (WorkshopParent.WorkshopFloraHarvestTime, Utility.GetCurrentGameTime()) endif endif
;UFO4P 2.0.5 Bug #24775: also check for destroyed crops. Otherwise, they may be regrown immediately after the repair: if !IsDestroyed() && IsActorAssigned() && utility.GetCurrentGameTime() > (harvestTime + floraResetHarvestDays) SetHarvested(false) endif
elseif aiCurrentStage == 0 && IsBed() == false ;: ;UFO4P 2.0.5 Bug #24775: added check: ;Reset the actor value that controls the harvest time. Otherwise, this crop will regrow faster than a newly built one. if GetBaseObject() as Flora SetValue(WorkshopParent.WorkshopFloraHarvestTime, Utility.GetCurrentGameTime()) endif endif