Jump to content
ℹ️ Intermittent Download History issues ×

Identify Harvest Activity (Activity Type) in Papyrus?


Wolfpack49

Recommended Posts

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

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 Alias

Event 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

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

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

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

  • 2 years later...
  • Recently Browsing   0 members

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