Getting when the player harvests from a flora

Post » Fri Jan 03, 2014 12:29 am

Hey everyone,

I'm writing a mod that involves harvesting. When the player harvests something I need the baseobject of the Flora he's harvesting and the ingredient that was harvested.

I did some research and found this post:

http://www.gamesas.com/topic/1463636-ingredients-harvested-tracked-stat-workaround/?p=22772590

However in game the container source is returning None, which means its not registering that its coming from a plant (its just saying world) which really svcks for me.

Is there another way I can do this? I'm forced into using SKSE because of other functions if that helps

User avatar
Cartoon
 
Posts: 3350
Joined: Mon Jun 25, 2007 4:31 pm

Post » Fri Jan 03, 2014 1:30 am

This isn't a perfect solution, but you could check what type of base object the player has the crosshair pointed at to see if the player is interacting with a plant/fungi/etc. Perhaps have the OnCrosshairRefChange event update a boolean that is then used in an if-statement inside the OnItemAdded event.

User avatar
Claire Jackson
 
Posts: 3422
Joined: Thu Jul 20, 2006 11:38 pm

Post » Fri Jan 03, 2014 8:54 am

So like this?

int isFlora = 0;Event OnInit()	RegisterForCrosshairRef()EndEventEvent OnCrosshairRefChange(ObjectReference ref)	If ref && ref as Flora		Debug.Trace("Targeted a Flora")                isFlora=1        else                Debug.Trace("Targetting nothing or a non-flora")                isFlora=0	EndIfEndEventEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)      If (akBaseItem as Ingredient)         ;Picked up an Ingredient         if (isFlora == 1)             ;picked up Ingredient while looking at a flora             ;Do the thing         EndIf      EndIfEndEvent
User avatar
Dean Brown
 
Posts: 3472
Joined: Fri Aug 31, 2007 10:17 pm

Post » Fri Jan 03, 2014 7:12 am

Yeah. Some ingredients are also harvested from Tree forms, possibly Activator forms as well though I might be remembering incorrectly. It might be a good idea to set isFlora to 0 at the end of the OnItemAdded event so that other ingredients aren't processed by the script by mistake. You'll need to set up a system for RegisterForCrosshairRef to be called when the player loads the game in case SKSE's co-save has been removed.

User avatar
james tait
 
Posts: 3385
Joined: Fri Jun 22, 2007 6:26 pm


Return to V - Skyrim