AndrealphusVIII Posted May 21, 2016 Share Posted May 21, 2016 Hi thereI'm working on a mod which overhauls the way containers work. So far, I have been able to give them realistic weight limits and adding weight for arrows that are stored in the container. (should be combined with an arrow weight mod).I have encountered some issues, though:The script won't work on containers in custom home mods that use autosort scripts.It also doesn't work with the Quick Loot mod. (untested, though)I need to find a way to limit the arrows added NPCs/followers.About the last one, I can't use arrow weight to NPCs. Since the game will still think they're 0 weight when I move them into the NPCs inventory, and won't block me from doing this, so I'll need to set a limit. I want to limit the amount of arrows an NPC can carry to 100-150. Since I also want maximum compatibility, I need to apply this to ALL NPCs (not only Vanilla followers), as some mods (AFT, FLP, EFF) have spells to make any NPC a follower. The script should also work with all NPCs added by mods, without needing to make a patch for every single mod. (Interesting NPCs, etc)I was thinking about doing the following:The script will only fire, when then player opens the inventory of an NPC (NOT vendors, though!), so no OnUpdate() to keep the script lightweight.If the amount of items with the keyword "VendorItemArrow" in the NPCs inventory becomes >= 100 -> return the item(s) to the player + display message: "This person's quiver is full."I need to somehow apply this script to ALL npcs. (also modded NPCs and followers) -> I'm thinking of doing this via a perk, so I can use ASIS to dsitribute the perk automatically to ALL NPCs.Anyone know how I should to give an arrow limit to an actor (NOT ONLY THE PLAYER!) via a perk. Thanks in advance Kind regards Andre Link to comment Share on other sites More sharing options...
lofgren Posted May 21, 2016 Share Posted May 21, 2016 Check out my mod: http://www.nexusmods.com/skyrim/mods/62385/? It only affects the player but there is nothing player-specific about it. Just pop that ability into a perk and distribute via ASIS if that's your thing. Might want to make a couple of tweaks so that the arrows are simply removed from inventory instead of dropping on the ground, and so that the initial inventory is adjusted immediately instead of waiting to be triggered by opening a container. You also don't need the initialization procedure to run more than once and NPCs obviously don't need the vendor adjustments. Should be a pretty simple script by the time you're done. The truth is that 150 arrows is WAY more than most NPCs carry, which is one of the reasons I didn't worry about it when I made my mod. Most NPCs have about 20 arrows, with dedicated archers sometimes having 30-some. If the only thing you are worried about is the player adding more than 150 arrows to an follower's inventory, then I would say the best thing to do is simply put a script on the player to limit the number of arrows they can give to a follower. No distribution by ASIS and no need to add a script to every NPC in the game. Link to comment Share on other sites More sharing options...
AndrealphusVIII Posted May 22, 2016 Author Share Posted May 22, 2016 Check out my mod: http://www.nexusmods.com/skyrim/mods/62385/? It only affects the player but there is nothing player-specific about it. Just pop that ability into a perk and distribute via ASIS if that's your thing. Might want to make a couple of tweaks so that the arrows are simply removed from inventory instead of dropping on the ground, and so that the initial inventory is adjusted immediately instead of waiting to be triggered by opening a container. You also don't need the initialization procedure to run more than once and NPCs obviously don't need the vendor adjustments. Should be a pretty simple script by the time you're done. The truth is that 150 arrows is WAY more than most NPCs carry, which is one of the reasons I didn't worry about it when I made my mod. Most NPCs have about 20 arrows, with dedicated archers sometimes having 30-some. If the only thing you are worried about is the player adding more than 150 arrows to an follower's inventory, then I would say the best thing to do is simply put a script on the player to limit the number of arrows they can give to a follower. No distribution by ASIS and no need to add a script to every NPC in the game. I'm interesting into making a script that affects the player when opening another NPCs inventory and limiting the arrows that are in the followers inventory. But I'm not really sure how I should do this. Link to comment Share on other sites More sharing options...
lofgren Posted May 22, 2016 Share Posted May 22, 2016 It would be something like: Formlist property AmmoList auto event OnItemRemoved(form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) if(akBaseItem as ammo) if(AmmoList.HasForm(akBaseItem) == false) AmmoList.AddForm(akBaseItem) endif if(akDestContainer as actor) int arrowcount = akDestContainer.GetItemCount(AmmoList) if(arrowcount > 150) ArrowCount -= 150 if(ArrowCount > aiItemCount) ArrowCount = aiItemCount endif akDestContainer.RemoveItem(akBaseItem, ArrowCount, true, GetReference()) endif endif endif endEvent Note that this script does not address corner cases and only removes the last arrows that the player gave to the follower. If this mod was added to an existing save where followers already had more than 150 arrows, it would not remove those arrows. The script will not prevent selling to vendors who have a vendor chest (i.e. most vendors who have a storefront), but would prevent selling to a vendor who only sells from his inventory (e.g. hunters). There are a few ways to deal with that, such as checking to see if the target is in the current follower faction (though not all follower mods use the current follower faction) or checking to see if the vendor interface is open (would require SKSE). Link to comment Share on other sites More sharing options...
AndrealphusVIII Posted May 22, 2016 Author Share Posted May 22, 2016 You're awesome! :D Thank you so much! :smile: How would I be able to check if the Vendor Interface is open? I don't mind an SKSE requirement. Link to comment Share on other sites More sharing options...
lofgren Posted May 22, 2016 Share Posted May 22, 2016 IsMenuOpen http://www.creationkit.com/index.php?title=IsMenuOpen_-_UI Link to comment Share on other sites More sharing options...
AndrealphusVIII Posted May 23, 2016 Author Share Posted May 23, 2016 IsMenuOpen http://www.creationkit.com/index.php?title=IsMenuOpen_-_UI I tweaked the script a bit (I'm still learning) to this: Keyword Property VendorItemArrow auto event OnItemRemoved(form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) if(akBaseItem as ammo) && UI.IsMenuOpen("BarterMenu") == 0 if(akDestContainer as actor) int arrowcount = akDestContainer.GetItemCount(VendorItemArrow) if(arrowcount > 150) ArrowCount -= 150 if(ArrowCount > aiItemCount) ArrowCount = aiItemCount endif akDestContainer.RemoveItem(akBaseItem, ArrowCount, true, GetReference()) endif endif endif endEvent Does this look okay? Could I also use this IsMenuOpen when I'm activating a container? I could be very useful to exclude merchant chests that way for my container weight cap script. So when I barter with someone, the script won't affect the merchant chest. This is escpecially useful when I'm going to use MXPF or another type of patcher to run it on every container. Or even better yet, is there a script somewhere which checks for used meshes? For instance, something like akContainer.GetModel() == "Clutter\Barrel.NIF". Is there something similar in SKSE or anywhere? Thanks in advance Kind regards Andre Link to comment Share on other sites More sharing options...
Recommended Posts