PJMail Posted October 15, 2023 Share Posted October 15, 2023 Where the OMOD changes the Ammo (like Receivers that convert to using .38 ammo). NPC.GetEquippedWeapon().GetAmmo() returns the default Ammo of the weapon - not it's new Ammo based on the OMOD. Is this just a consequence of the dumb way items in an inventory are treated (GetEquippedWeapon() returns the base weapon ID - not the modified instance)? If so does anyone have an idea how to get the Ammo being used by an NPC's currently equipped weapon - correctly? I am not even sure Scanning through the actual OMOD's properties, via F4SE like below, will work for an object in an NPC inventory... Objectmod:PropertyModifier[] omodProperties = NPC.GetEquippedWeapon().GetEmbeddedMod().GetPropertyModifiers() Note that the OMOD has been added via NPC.AttachModToInventoryItem(baseWeapon) so is not on the base weapon. I can probably scan through the Property modifiers of the OMOD I am attaching - but really Bethesda - isn't there an easier way??? Link to comment Share on other sites More sharing options...
DieFeM Posted October 15, 2023 Share Posted October 15, 2023 There's another GetAmmo function in InstanceData Script. You can call it on the actor equipping it, or on the weapon itself. Maybe that makes a difference. PS: Take a look at the source code in InstanceData.psc, there are useful comments. Link to comment Share on other sites More sharing options...
LarannKiar Posted October 15, 2023 Share Posted October 15, 2023 (edited) NPC.GetEquippedWeapon().GetAmmo() returns the default Ammo of the weapon - not it's new Ammo based on the OMOD. Is this just a consequence of the dumb way items in an inventory are treated (GetEquippedWeapon() returns the base weapon ID - not the modified instance)? Unfortunately, yes. If so does anyone have an idea how to get the Ammo being used by an NPC's currently equipped weapon - correctly? I am not even sure Scanning through the actual OMOD's properties, via F4SE like below, will work for an object in an NPC inventory... You can try this script. It's based on InstanceData. Ammo Function GetEquippedWeaponAmmo(Actor akActor) Weapon akWeapon = akActor.GetEquippedWeapon() Ammo theAmmo If akWeapon InstanceData:Owner akOwner = akActor.GetInstanceOwner(41) ; 41 is the weapon equip slot theAmmo = InstanceData.GetAmmo(akOwner) EndIf Return theAmmo EndFunction Objectmod:PropertyModifier[] omodProperties = NPC.GetEquippedWeapon().GetEmbeddedMod().GetPropertyModifiers() Note that the OMOD has been added via NPC.AttachModToInventoryItem(baseWeapon) so is not on the base weapon. I can probably scan through the Property modifiers of the OMOD I am attaching - but really Bethesda - isn't there an easier way??? GetEquippedWeapon() returns the BaseForm of the equipped weapon and GetEmbeddedMod() returns the Embedded Weapon Mod of a weapon (Weapon form >> bottom most dropdown menu). The developers didn't expose any of the necessary data to Papyrus to make proper inventory scanning possible so they surely didn't make it easy.. In vanilla, the fastest method I've found is RemoveItem() the target items based on their Keywords to separate actor inventories, apply a MagicEffect to the actors then process their inventories in ActiveMagicEffect scripts, "multithreaded": DropObject(), which creates object references that can actually be processed, then AddItem() them back to the original inventory. Edited October 15, 2023 by LarannKiar Link to comment Share on other sites More sharing options...
PJMail Posted October 16, 2023 Author Share Posted October 16, 2023 Unfortunately InstanceData:Owner akOwner = akActor.GetInstanceOwner(41) didn't work for any of the weapon slots (32 - 43).To make this more difficult, this is a Vertibird which has 2 guns equipped - getequippedweapon DOES return one of those weapons - so this looks like yet another Bethesda Kludge. Oh well... Thanks anyway LarannKiar Link to comment Share on other sites More sharing options...
LarannKiar Posted October 16, 2023 Share Posted October 16, 2023 (edited) That's unfortunate.. Just took a look at the Vertibirds' inventory and they seem to contain 3 items: "[1] Vertibird Front Right Cannon (1) (E)", "[2] Vertibird Front Left Cannon (1)", "[3] 5mm Round (1)". (Syntax: [itemIndex] ItemName (Count) (E = IsEquipped) ). The left cannon is probably "used" (but not equipped) due to Can Dual Wield (VertibirdRace >> Combat Data). GetWornItem() most likely won't work either because Vertibirds don't have assigned Biped Slots (VertibirdRace >> Body Data). Edited October 16, 2023 by LarannKiar Link to comment Share on other sites More sharing options...
PJMail Posted October 16, 2023 Author Share Posted October 16, 2023 Yeah, 2 equipped weapons but only one returned (via GetEquippedWeapon(1) - they don't even fill weapon slot 0 like most other NPCs). Dodgy. They have the code for 2 equipped weapons, but it doesn't seem to be exposed correctly to papyrus. Link to comment Share on other sites More sharing options...
Recommended Posts