Jump to content

[LE] How to add & take away an item form a NPC?


Apugloaf

Recommended Posts

Hello!

 

I would like my follower (also spouse) to equip a custom item whenever they have a meal ready for me. And, whenever the dialogue, "do you have a meal ready for me" is triggered. the item is removed form them/ unequipped, restarting the process until the end of time. Why? Because I think it would be cool to have a visual cue for when a meal is ready. I've also modded the meal to be more useful, so i use it a lot.

 

I only need help in modding the "RelationshipMarriageFIN" quest in getting a spouse to receive and equip an item. Then removing said item on the dialogue trigger. I have already done all the rest.

 

This seems like it should be simple (famous last words). I'm hoping to someone better acquainted in modding quests, this is no biggie.

 

Thanks for reading/ any help you can give!

Link to comment
Share on other sites

In the player dialogue tab, look for the meal info dialogues. First you have to add your custom item property. To do that, click on the TIF script, properties and Add to add your custom item property. Then in the Begin papyrus fragment, you can put AkSpeaker.EquipItem(MyCustomItem) and in the End papyrus fragment you can put akSpeaker.UnEquipItem(MyCustomItem). You have to do this for each of the meal dialogues.

Link to comment
Share on other sites

In the player dialogue tab, look for the meal info dialogues. First you have to add your custom item property. To do that, click on the TIF script, properties and Add to add your custom item property. Then in the Begin papyrus fragment, you can put AkSpeaker.EquipItem(MyCustomItem) and in the End papyrus fragment you can put akSpeaker.UnEquipItem(MyCustomItem). You have to do this for each of the meal dialogues.

 

Hey, I really appreciate you helping me out!

 

I've managed to get some degree of success of what I'm going for. The item is being added and removed, however this only happens during the dialogue. I feel like the "begin" & "end" parts of the scripting section only take action during the dialogue and that's why. Also, the item remains within the characters inventory after receiving a meal, allowing them to re-equip it after a loading screen.

 

I think I might need to set up a quest stage or two to get the character to equip the item proper? after that, the rest will take place within the "end" section of the dialogue.

Edited by Apugloaf
Link to comment
Share on other sites

No problem. Okay I think I understand better what you want. First, add this script to the RelationshipMarriageFIN quest in the scripts tab and compile.

 

Scriptname MarriageEquipMealScript extends Quest 

Armor Property MyCustomItem Auto 
Actor Property Spouse Auto

Function SetMealItem() 
    Spouse.UnequipItem(MyCustomItem, true) ; unequip item, preventing re-equip 
    RegisterForSingleUpdateGameTime(24) ;update in 24 hours game time
EndFunction

Event OnUpdateGameTime()
    If Spouse.GetRelationshipRank(Game.Getplayer()) == 4 ;checks if spouse is lover
        Spouse.EquipItem(MyCustomItem, true) ;equips item, preventing unequip 
    Else ;If spouse not lover, unequips and removes custom item
        Spouse.UnequipItem(MyCustomItem)
        Spouse.RemoveItem(MyCustomItem, 1)
    Endif
EndEvent

 

Only fill the MyCustomItem property. Leave the Spouse property blank.

 

Then in the End Papyrus Fragment for the meals dialogue, put in this:

MarriageEquipMealScript MealScriptRef = GetOwningQuest() as MarriageEquipMealScript 
MealScriptRef.Spouse = akSpeaker 
MealScriptRef.SetMealItem()
Link to comment
Share on other sites

It works... IT ACTUALLY WORKS!!

 

I can't thank you enough for helping me with this. I don't think I would have been able to figure this out on my own (I suck at coding).

 

Edit:

For some reason the item still isn't being removed from the NPCs inventory allowing them to equip it after a loading screen. Other than that every things working wonderfully. Any ideas as to why this is happening?

Edited by Apugloaf
Link to comment
Share on other sites

No problem. Did you see them equipping the item again after? That shouldn't be happening as the script prevents it. You can change the SetMealItem() function to this though if it's an issue:

Function SetMealItem() 
    Spouse.UnequipItem(MyCustomItem) ; unequip item
    Spouse.RemoveItem(MyCustomItem, 1) ; remove item
    RegisterForSingleUpdateGameTime(24) ;update in 24 hours game time
EndFunction
Link to comment
Share on other sites

  • Recently Browsing   0 members

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