Wolfpack49 Posted January 10, 2021 Share Posted January 10, 2021 So not sure if it is possible to identify specifically an (E) keypress activity that is Harvesting vs the other types of activities (Steal/Take/Open/Read). Is there some way to identify the activity type in Papyrus? The closest I could find in the papyrus documentation is GetActionRef under the OnActivate event but there does not appear to be any documentation on it. Has anyone sucessfully been able to parse an Activity Type? Link to comment Share on other sites More sharing options...
RichWebster Posted January 10, 2021 Share Posted January 10, 2021 The way I had to do this in Hunting in Skyrim is to store the IngredientsHarvested stat, track every time the player added a new item, compare it to that stat saved as a global, and then increment my global. Here's my source. You should be able to alter to your needs. Start by setting your global to the stat value, I did this in a quest. ; Set my global count to the Ingredients Harvested stat so we can check against it HISIngredientsHarvestedTotal.SetValueInt(Game.QueryStat("Ingredients Harvested")) Attach this script to a Player AliasEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) if !akSourceContainer && !akItemReference ; Only track any added items for the following scenarios: ; If there was no original source container and no object reference Ranger.IngredientHarvested(akBaseItem) endif endEvent I created a form list of ingredient keywords so I didn't have to check for every single item that wasn't valid.Event IngredientHarvested(Form akBaseItem) Int iList = HISIngList01.GetSize() while iList iList -= 1 Keyword iKeyword = HISIngList01.GetAt(iList) as Keyword if akBaseItem.HasKeyword(iKeyword) Int OldCount = HISIngredientsHarvestedTotal.GetValue() as Int Int NewCount = Game.QueryStat("Ingredients Harvested") if NewCount > OldCount ; For harvesting an ingredient the player earns XP Int XP = 1 if !HISRangerKnownIngredients.HasForm(akBaseItem) HISRangerKnownIngredients.AddForm(akBaseItem) ; If the player has never harvested this ingredient before, give extra XP XP = 3 endif HISIngredientsHarvestedTotal.SetValueInt(NewCount) TrackedStatXP(XP) iList = 0 return endif endif endwhile endEvent Link to comment Share on other sites More sharing options...
Wolfpack49 Posted January 10, 2021 Author Share Posted January 10, 2021 Thanks @RichWebster -- this is great! I think my need might be simpler -- I just need to check whether an added item was harvested, then do something. Right now, I am successfully detecting added ingredients, flora and food and excluding anything grabbed via inventory menu. I'd like also to exclude stuff that is simply picked up on tables or on shelves. I was thinking of perhaps checking whether the item is in an interior to exclude most dungeons and shops, but this of course wouldnt catch everything, and some stuff in interiors do actually need to be harvested. I'm actully suiprised there isn't some kind of flag/indicator for activity types, but I'm going to take a closer look at the IngredientsHarvested stat. Thanks again. :) Link to comment Share on other sites More sharing options...
RichWebster Posted January 10, 2021 Share Posted January 10, 2021 Ingredients Harvested is one of the stats that doesn't fire an OnTrackedStatsEvent(), so you have to manually check for it. The basis of my script will do that for you, keep a track of the stat number and every time the player has an ingredient added, if the stat is higher than the previous number, you know it was an ingredient harvest :) Link to comment Share on other sites More sharing options...
Wolfpack49 Posted January 10, 2021 Author Share Posted January 10, 2021 Ah ha! OnTrackedStatsEvent was the one I was looking for, but that's really too bad Ingredients Harvested doesn't fire. Okay, well, I think I can work this -- thanks Rich! :) Link to comment Share on other sites More sharing options...
RichWebster Posted January 10, 2021 Share Posted January 10, 2021 Yea it's really a shame, what's why I had to roll my own solution. Ingredients Eaten is another one that doesn't fire an event. Link to comment Share on other sites More sharing options...
Wolfpack49 Posted January 10, 2021 Author Share Posted January 10, 2021 Well, I think I was able to express this really simply using the existing handler I had and Game.queryStat. It seems to do a pretty reliable job of picking up harvested ingredients, but comparing the newly queried number with the last number manages to isolate the harvested items was a great find! Tested harvestable items and plain stuff on tables and it's now doing what it should only for the harvests. Thanks for pointing me in the right direction! :smile: int item_harvested Function handle_added_item(Form item, int count, ObjectReference ref, ObjectReference src) int item_harvested_now = Game.queryStat("Ingredients Harvested") if item_harvested_now > item_harvested _debug("Item(s) Harvested") item_harvested = item_harvested_now endif EndFunction Link to comment Share on other sites More sharing options...
RichWebster Posted January 11, 2021 Share Posted January 11, 2021 No problem :) My source is full of code that you wouldn't need but I didn't have time to trim it, dinner was ready ;) Link to comment Share on other sites More sharing options...
HurricainReaperProductions Posted August 7, 2023 Share Posted August 7, 2023 hey could you write a tutorial for this i would like to use it in a mod for custom farmers in my buildable homes serires Link to comment Share on other sites More sharing options...
Recommended Posts