Jump to content

Photo

How to force an NPC to "re-check" their inventory via Papyrus?

papyrus shout dragonrend inventory additem

  • Please log in to reply
5 replies to this topic

#1
Obsidiman01

Obsidiman01

    Stranger

  • Members
  • Pip
  • 3 posts

I'm working on a mod that adds a custom dragonborn follower (a little cliché, I'll admit), and I'm having an issue that I haven't been able to find a solution to so far. I've searched on Google, around the Nexus forums, on the CC website, but I've had no luck.

A little background: There are several shouts that you can add to an NPC, and the NPC will be able to use them no problem. This includes just under half of the vanilla shouts. However, one shout that NPCs don't use right out of the box is Dragonrend, and I'd like my follower to be able to use it. So, I put together a quest that gets the nearest dragon as an alias, and using a combat override package with the "Shout" template, passing the dragon alias as the target, I was successfully able to make the follower use Dragonrend on dragons.

Now, here's the issue:

The Shout package force-equips the Dragonrend shout in the follower's shout/power slot. After the package is over, the NPC doesn't go back to the usual behavior where they automatically equip shouts from their available spells. Instead, the follower will use other shouts (like Fire Breath), but won't equip them. Dragonrend stays in the equipped shout slot, and this causes issues, since I use GetEquippedShout to determine what voice lines should play when the follower shouts (same as how it's done in vanilla). In effect, this means my follower will say "Joor Zah Frul" when using Fire Breath.

 

I haven't been able to figure out how or why this happens, but I have figured out that giving the NPC an item (using the AddItem console command) will make them re-check their inventory (similar to when you trade items with your follower, and the decide whether they should use the new gear you gave them). So I tried implementing this in Papyrus, adding a fragment at the end of my dragonrend package to give them a temporary item, just to get them to recheck their inventory and realize that they've got the wrong shout equipped. But it seems that the AddItem() Papyrus function doesn't cause NPCs to recheck their inventory.

 

Which leads me to my question: Is there a way to make NPCs recheck their inventory & equip the proper equipment by using a Papyrus function? Am I missing something, or doing something wrong? Or, alternatively, is there another way to make an NPC use dragonrend (or any other shouts they don't normally use) that avoids this issue entirely?



#2
Dromundas

Dromundas

    Fan

  • Members
  • PipPipPip
  • 411 posts

My mod has a resurrection spell that does force them to re-evaluate their equipment after resurrection with this method, by equipping and then removing a custom 2h sword with Papyrus. I don't know if this works for shouts and magic though. It makes the actors in my mod re-equip weapons and armors in their inventory as you would expect.



#3
Obsidiman01

Obsidiman01

    Stranger

  • Members
  • Pip
  • 3 posts

I changed my Papyrus fragment to add & remove a sword instead of a septim, and that seems to have worked! Thanks for that suggestion, I greatly appreciate it.



#4
Dromundas

Dromundas

    Fan

  • Members
  • PipPipPip
  • 411 posts

That's awesome!



#5
IsharaMeradin

IsharaMeradin

    The Pale Redguard

  • Members
  • PipPipPipPipPip
  • 10,399 posts

Couldn't you have just force unequipped the shout at the end of the package?

UnequipShout



#6
Obsidiman01

Obsidiman01

    Stranger

  • Members
  • Pip
  • 3 posts

That was one of my first thoughts when I was trying to come up with a solution, but unfortunately it didn't quite work. It did unequip the shout, but I still ended up with the same issue where the actor was using the fire breath shout without equipping it, the only difference being now there was no shout equipped. I also tried calling EvaluatePackage() at various points after the package finished, but that didn't work either.







Also tagged with one or more of these keywords: papyrus, shout, dragonrend, inventory, additem

IPB skins by Skinbox
Page loaded in: 1.030 seconds