AndrealphusVIII Posted January 31, 2016 Author Share Posted January 31, 2016 Script directly on actor or on a quest's reference alias that points to the actor would have an event something like this: Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem as Ammo Actor ME = Self.GetActorReference() If ME ;am I valid? Float CW = ME.GetActorValue("CarryWeight") Float IW = ME.GetActorValue("InventoryWeight") If IW >= CW Debug.Notification("Can't carry any more") If akSourceContainer ;ammo come from a container or NPC ME.RemoveItem(akBaseItem,aiItemCount,false,akSourceContainer) Else ME.DropObject(akBaseItem,aiItemCount) EndIf EndIf EndIf EndIf EndEvent It could probably be improved upon but it is a start. I was thinking about an alternative way. I'm looking for a way to put a set limit of 1 kind of arrows into an NPCs inventory. If it somehow exceeds that limit, the exceesive arrows will be dropped. So for instance, I set the limit to 100. Now the affected NPC will only be able to carry 1 kind of arrows and only 100 of them. So for instance, 100 Steel Arrows. If the Steel Arrows go over 100 OR any other kind of arrows (e.g.: Iron Arrows) are added, they will be dropped.Is there a way to do this? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted January 31, 2016 Share Posted January 31, 2016 Very similar actually... an event and necessary properties to get you started. I'm sure there is room for improvement.... Ammo Property FixedAmmo Auto Int Property FixedCount Auto ;ensures actor has only fixed ammount of ammo when ammo is added Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem as Ammo If akBaseItem as Ammo == FixedAmmo Actor ME = Self.GetActorReference() If ME ;am I valid? Int NumAmmo = ME.GetItemCount(akBaseItem) If NumAmmo > FixedCount Int RemAmmo = NumAmmo - FixedCount If akSourceContainer ;ammo came from a valid container or NPC ME.RemoveItem(akBaseItem,RemAmmo,false,akSourceContainer) Else ME.DropObject(akBaseItem,RemAmmo) EndIf EndIf EndIf EndIf EndIf EndEvent Thank you. I'll take a look at it. Edit: So in order for this to work, I have to attach this script to every NPC in the load order. (with a patcher?) You don't need to apply it to every NPC. You can set up quest aliases that reference the NPCs that you want to affect and apply the script to those aliases... Link to comment Share on other sites More sharing options...
AndrealphusVIII Posted February 2, 2016 Author Share Posted February 2, 2016 Very similar actually... an event and necessary properties to get you started. I'm sure there is room for improvement.... Ammo Property FixedAmmo Auto Int Property FixedCount Auto ;ensures actor has only fixed ammount of ammo when ammo is added Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem as Ammo If akBaseItem as Ammo == FixedAmmo Actor ME = Self.GetActorReference() If ME ;am I valid? Int NumAmmo = ME.GetItemCount(akBaseItem) If NumAmmo > FixedCount Int RemAmmo = NumAmmo - FixedCount If akSourceContainer ;ammo came from a valid container or NPC ME.RemoveItem(akBaseItem,RemAmmo,false,akSourceContainer) Else ME.DropObject(akBaseItem,RemAmmo) EndIf EndIf EndIf EndIf EndIf EndEvent Thank you. I'll take a look at it. Edit: So in order for this to work, I have to attach this script to every NPC in the load order. (with a patcher?) You don't need to apply it to every NPC. You can set up quest aliases that reference the NPCs that you want to affect and apply the script to those aliases... What Ammo should attach the property FixedAmmo too? I want the script to work for all types of ammo by default, including the ones added by other mods. Shouldn't I use keyword VendorItemArrow instead of a certain type of ammo? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted February 2, 2016 Share Posted February 2, 2016 Make up your mind... The one that checks actor weights would work with any ammo, but you came back and said you wanted it to work with a specific ammo and limit the quantity of said specific ammo. So I switched it to work with a specific ammo that limited by count rather than work with all by weight (as you'd originally talked about). So till you can get yourself focused on what you want, I'm done... Link to comment Share on other sites More sharing options...
Notanon81 Posted February 2, 2016 Share Posted February 2, 2016 Very similar actually... an event and necessary properties to get you started. I'm sure there is room for improvement.... Ammo Property FixedAmmo Auto Int Property FixedCount Auto ;ensures actor has only fixed ammount of ammo when ammo is added Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem as Ammo If akBaseItem as Ammo == FixedAmmo Actor ME = Self.GetActorReference() If ME ;am I valid? Int NumAmmo = ME.GetItemCount(akBaseItem) If NumAmmo > FixedCount Int RemAmmo = NumAmmo - FixedCount If akSourceContainer ;ammo came from a valid container or NPC ME.RemoveItem(akBaseItem,RemAmmo,false,akSourceContainer) Else ME.DropObject(akBaseItem,RemAmmo) EndIf EndIf EndIf EndIf EndIf EndEvent Thank you. I'll take a look at it. Edit: So in order for this to work, I have to attach this script to every NPC in the load order. (with a patcher?) You don't need to apply it to every NPC. You can set up quest aliases that reference the NPCs that you want to affect and apply the script to those aliases... What Ammo should attach the property FixedAmmo too? I want the script to work for all types of ammo by default, including the ones added by other mods. Shouldn't I use keyword VendorItemArrow instead of a certain type of ammo? That could work. You'd have to bear in mind that vanilla Skyrim doesn't necessarily add it to all arrows in the Creation Kit, so you would have to add it to all the arrows that you wish for it to apply to. On the other hand, that keyword is used in 3rd party mods for arrows, so that should make it relatively simple. If I had my way, arrows would have AmmoTypeArrow and bolts would have AmmoTypeBolt for the sake of consistency (inline with WeapTypeBow, WeapTypeSword, etc). Seems odd in retrospect why they didn't do this in the first place. Link to comment Share on other sites More sharing options...
GrandBulwark Posted February 4, 2016 Share Posted February 4, 2016 (edited) I don't really have time nor the patience to get into the actual code involved but it seems to me the simplest solution would be a combination of aliases as was mentioned earlier and from there adding placeholder objects checked as unplayable to the npcs to add the weight. This could be done on a update loop or a OnItemAdded () event, you could make a placeholder for each type of arrow as well as a generic onE that would cover all mod arrows. It would be a relatively simple process, especially if you are skilled enough to use existing aliases such as the current follower alias. Even mods such as UFO and AFT could be accounted for without a hard dependency. A good example of using existing aliases for alternate purposes is the follower summon spell here on nexus and it shows how to account for aft and ufo also. All that said you could just set their encumbrance as a Int, or a float. Set the amount to subtract from their carry weight based on the arrow and the multiply that subtraction by the arrow amount, if that makes sense. From there modav the carry weight down based on the scripts calculations. If no arrows are found the initial int storing their carryweight should be used to restore the carry weight to it's original number. Hope that made sense, pardon if it didn't. Would write out the code but limited to this phone at the moment. Bit rusty after all this time away anyway :p. May get to a PC tomorrow and if so I will type out a bit of an example. Good luck! Edited February 4, 2016 by GrandBulwark Link to comment Share on other sites More sharing options...
Recommended Posts