HOLYCRAPWHALES Posted December 22, 2017 Share Posted December 22, 2017 Hey guys, I have a function that I need to run whenever the player harvests an ingredient from a flora. Unfortunately there's nothing like "OnHarvest" or anything in flora script so I'm looking for alternatives. I have it working right now by watching the players inventory and if its an ingredient gets added, check the thing they're looking at and if its flora, run my function. It works...but it feels super shitty and inefficient. Anyone have a better idea of how to do this? Link to comment Share on other sites More sharing options...
Evangela Posted December 23, 2017 Share Posted December 23, 2017 (edited) You can try using a formlist of all flora forms and listen for them through an OnItemAdded event. That Event is just.. a mess though, but I don't know of another way to do this. Edit: It sounds like that what you're already doing. Edited December 23, 2017 by Rasikko Link to comment Share on other sites More sharing options...
TheWormpie Posted December 23, 2017 Share Posted December 23, 2017 There's the story manager as well. https://www.creationkit.com/index.php?title=OnStoryAddToPlayer_-_Quest Link to comment Share on other sites More sharing options...
Evangela Posted December 23, 2017 Share Posted December 23, 2017 (edited) I had a strange feeling about that, specifically the aiAcquireType parameter, and I tested it. Just as I thought, 0 and 4 will not detect items added to the inventory through harvesting. :/ And checking for them in a formlist via HasForm and doesn't work out either. Now it could be that I'm just not doing it right. But for all other types this event seems to be an amazing alternative to OnItemAdded. Just don't know how it handles stacked items. Edited December 23, 2017 by Rasikko Link to comment Share on other sites More sharing options...
HOLYCRAPWHALES Posted December 31, 2017 Author Share Posted December 31, 2017 (edited) I did a bit more experimenting and came accross two ways to do this: OnCrosshairRefChange and OnItemAddedRegister for the crosshair ref change and the OnItemAdded.In the OnCrosshairRefChange, update a global variable with whatever thing the player is looking at.When OnItemAdded gets triggered, check if the item is an ingredient. If it is, check the crosshair variable by casting it to a Flora.If both are true, its probabbly a Flora that just got harvested. OnActivate via QuestAliasesCreate a dummy quest with a reference alias pointing to the nearest Flora.Attach a script to it and use "OnActivate"That OnActivate will trigger off of harvest since Flora's are also Activators. Conclusion Both approaches suck, but use the OnActivate approach, its more accurate. The OnCrosshairRefChange approach is basically reads "I looted an ingredient and I'm looking at a flora therefore I'm harvesting". You aren't actually for sure harvesting something. It also falls apart if you don't immediately receive the ingredient for some reason, say there's some animation that happens when you harvest and the player happens to look away during the animation or something. Also Salmon count as Flora for some reason so watch out for that lol Edited December 31, 2017 by HOLYCRAPWHALES Link to comment Share on other sites More sharing options...
Evangela Posted December 31, 2017 Share Posted December 31, 2017 Knowing bethesda weird logic, they count as flora because you can "harvest" it rather than catch it. :rolleyes: Link to comment Share on other sites More sharing options...
foamyesque Posted January 1, 2018 Share Posted January 1, 2018 I did a bit more experimenting and came accross two ways to do this: OnCrosshairRefChange and OnItemAddedRegister for the crosshair ref change and the OnItemAdded.In the OnCrosshairRefChange, update a global variable with whatever thing the player is looking at.When OnItemAdded gets triggered, check if the item is an ingredient. If it is, check the crosshair variable by casting it to a Flora.If both are true, its probabbly a Flora that just got harvested. OnActivate via QuestAliasesCreate a dummy quest with a reference alias pointing to the nearest Flora.Attach a script to it and use "OnActivate"That OnActivate will trigger off of harvest since Flora's are also Activators. Conclusion Both approaches suck, but use the OnActivate approach, its more accurate. The OnCrosshairRefChange approach is basically reads "I looted an ingredient and I'm looking at a flora therefore I'm harvesting". You aren't actually for sure harvesting something. It also falls apart if you don't immediately receive the ingredient for some reason, say there's some animation that happens when you harvest and the player happens to look away during the animation or something. Also Salmon count as Flora for some reason so watch out for that lol Forget salmon: So are coin purses. Link to comment Share on other sites More sharing options...
sp0ckrates Posted January 2, 2018 Share Posted January 2, 2018 Maybe add a script to the item harvested and use OnContainerChange()? Thatâs what I used to remove heads from NPCs with the mod HUNT: NPC Skulls. Link to comment Share on other sites More sharing options...
Recommended Posts