How can I simply track gifts given during dialogue?

Post » Fri Oct 16, 2015 12:29 am

I have a very basic situation here, that I designed exactly like the quest/dialogue when a player gives a beggar booze. However, I need it to appear that the recipient is "eating" the item given, and as such it needs to be removed from their inventory as soon as it is given (unless there is some way to force an NPC to use/consume an ingestible?). This is specifically for animals, by the way.

Everything takes place in a Papyrus fragment on the dialog response, just like the vanilla beggar/booze gifting, and works great, except for how to remove the item I just gifted them.

I learned about OnItemAdded, but it seems I cannot use this inside a fragment this way. Do I really have to make a whole quest/alias set up for this in addition to the dialogue fragment? I want to keep this as clean as humanly possible.

I can even run AddInventoryEventFilter on akSpeaker (the ObjectReference for the actor) but there doesn't seem to be any way to run Event OnItemAdded on the ObjectReference. It seems like filling an alias is just a long workaround to give me an objectreference, so in my head I can't understand why I couldn't add OnItemAdded to that akSpeaker ref from the fragment.

I know I'm missing something, I haven't gone too deep in my dealings with Papyrus.

Thank you!

Here's the code. I just slapped the event for OnItemAdded at the bottom, but it obviously doesn't have any context this way so it never executes. (Don't mind the conditions, this is half-baked, the old code used to remove a specific item each time rather than use the gifting menu...)

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment;NEXT FRAGMENT INDEX 7Scriptname TIF__020012CD Extends TopicInfo HiddenPotion Property DogTreat  Auto  SPELL Property FavorJobsFeedDogsAbility  Auto  Message Property FavorJobsFeedDogsMessage  Auto  FormList Property FormListFoodForAnimals  Auto  ;BEGIN FRAGMENT Fragment_6Function Fragment_6(ObjectReference akSpeakerRef)Actor akSpeaker = akSpeakerRef as Actor;BEGIN CODEakSpeaker.AddInventoryEventFilter(FormListFoodForAnimals);Show the gift menu, and bump the relationship rankIf akSpeaker.ShowGiftMenu(True, FormListFoodForAnimals, true, False) > 0	If (akspeaker.GetRelationshipRank(Game.GetPlayer()) == 0)		akspeaker.SetRelationshipRank(Game.GetPlayer(), 1)	EndIf	EndIfakSpeaker.RemoveAllInventoryEventFilters();Add the spell to the animal being fed, cast upon itself, targeted to itselfFavorJobsFeedDogsAbility.Cast(akspeaker, akspeaker);Play the sound of the dog eating since the dialogue plays before the script runs;Show the confirmation message the animal received the buffsFavorJobsFeedDogsMessage.Show();END CODEEndFunctionEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)	Debug.Notification("OnItemAdded Event Fired")EndEvent;END FRAGMENT;END FRAGMENT CODE - Do not edit anything between this and the begin comment
User avatar
Hayley Bristow
 
Posts: 3467
Joined: Tue Oct 31, 2006 12:24 am

Return to V - Skyrim