SKKmods Posted March 30, 2021 Share Posted March 30, 2021 Yes the GetBaseObject qualifier was missing from my "is" test fragment. Its a fast way to validate objects that have scripts like If (ThisActor is WorkshopNPCScript) and good way to validate formlists that users can hack about in xedit to handle incorrect objects they may jam in ... If (GenericFormFromFormList is ObjectReference) Elseif (GenericFormFromFormList is ActorBase) & etc without generating errors. Link to comment Share on other sites More sharing options...
GrimGrim31 Posted March 30, 2021 Author Share Posted March 30, 2021 (edited) Thanks SKK50 and AnishaDawn! I think my script is doing what I want it to do now. The player can satisfy hunger by eating fruits, vegetables, and other flora ingredients straight off the plant or anywhere else a fruit, vegetable, or ingredient is located as long as it is not in a container. My working script for now is in the spoiler below. Maybe it will help someone else out in the future. I should learn how to paste my script with its syntax highlighting. I see that AnishaDawn can do that but I haven't figured it out yet. ActorValue Property Hunger AutoActorValue Property _MY_FloraIsHarvested Auto Const MandatoryActorValue Property _MY_FloraHarvestTimestamp Auto Mandatory Actor Property Owner AutoActor Property Target Auto sound Property NPCBrahminIdleChew Auto Const{plays each bite} int PlayEatingSound = 0 ;-- Functions --------------------------------------- Event OnEntryRun(int auiEntryID, ObjectReference akTarget, Actor akOwner) Hunger = Game.getformfromfile(0x000801, "SurvivetheWasteland.esp") as ActorValue If (Utility.GetCurrentGameTime() >= (akTarget.GetValue(_MY_FloraHarvestTimestamp) + 7)) ;Seven game days regrowth akTarget.SetValue(_MY_FloraIsHarvested, 0) akTarget.SetValue(_MY_FloraHarvestTimestamp, -1) akTarget.setharvested(False)EndIf If Game.GetPlayer().GetValue(Hunger) < 0.0 && akTarget.GetBaseObject() as Flora && akTarget.GetValue(_MY_FloraIsHarvested) == 0 akTarget.SendStealAlarm(akOwner) Debug.Notification("You eat from the " + akTarget.GetDisplayName() + ".") akTarget.setharvested(True) akTarget.SetValue(_MY_FloraIsHarvested, 1) akTarget.SetValue(_MY_FloraHarvestTimestamp, Utility.GetCurrentGameTime()) PlayEatingSound = NPCBrahminIdleChew.play(akOwner) Sound.SetInstanceVolume(PlayEatingSound, 1) Game.GetPlayer().ModValue(Hunger, 10) ElseIf Game.GetPlayer().GetValue(Hunger) < 0.0 && akTarget.GetBaseObject() as Potion Form baseForm = akTarget.GetBaseObject() Potion itemPotion = baseForm as Potion Game.GetPlayer().EquipItem(itemPotion as Form, False, True) Game.GetPlayer().AddItem(akTarget as Form, 1, True) Debug.Notification("You eat the " + akTarget.GetDisplayName() + ".") Game.GetPlayer().RemoveItem(baseForm, 1, True, None) PlayEatingSound = NPCBrahminIdleChew.play(akOwner) Sound.SetInstanceVolume(PlayEatingSound, 1) Game.GetPlayer().ModValue(Hunger, 10) ElseIf Game.GetPlayer().GetValue(Hunger) < 0.0 && akTarget.GetBaseObject() as Flora && akTarget.GetValue(_MY_FloraIsHarvested) == 1 Debug.Notification("The plant has nothing for you to eat.") Else Debug.Notification("You are not hungry now.")EndIfEndEvent Edited March 30, 2021 by GrimGrim31 Link to comment Share on other sites More sharing options...
AnishaDawn Posted March 31, 2021 Share Posted March 31, 2021 (edited) I use code tags for syntax highlighting.The one issue I see with your script is GetCurrentGameTime. This is the same as the GameDaysPassed global variable. Doesn't this mean your first statement will always be true, unless the game has started(because a day or a week hasn't passed yet)? Edited March 31, 2021 by AnishaDawn Link to comment Share on other sites More sharing options...
GrimGrim31 Posted March 31, 2021 Author Share Posted March 31, 2021 It should not be true at all for the first seven days of the game. Then it will be true for flora that the player has not eaten from, because CurrentGameTime will be greater than 7 days and the time stamp ActorValue for the flora will be 0. But then the flora will just be set to an unharvested condition which it already was in. Once a flora has a time stamp, the condition will only be true once CurrentGameTime is more than 7 days after the time stamp. Then the flora will be reset to unharvested and the time stamp will be set to -1. It's not an ideal way to reset flora but my options are limited. I can't use the game's native reset of flora because there is no way to query a flora to tell if it is harvested or unharvested. It's frustrating because you can see on screen whether or not it has ripe fruit or vegetables or other things on it, but you don't have a way in Papyrus or CK to tell your actor that the flora is harvested or not. Link to comment Share on other sites More sharing options...
Recommended Posts