[Papyrus] Adding Weighted Arrows to Container Weight Cap

Post » Sun Jan 31, 2016 11:52 pm

After many hours of googling I found this script, which adds weight limits to containers:




Spoiler

Scriptname zzzContainerWeightCap extends ObjectReference  

Float Property fMax = 1000.0 Auto

Float fItem
Float fCurrent
Int iCount
Bool bFull

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
fItem = akBaseItem.GetWeight()
iCount = Math.Floor((fMax-fCurrent)/fItem)
fCurrent += fItem*aiItemCount

If(aiItemCount > iCount)
RemoveItem(akBaseItem, (aiItemCount - iCount), False, akSourceContainer)
bFull = True
EndIf

;Debug.Notification(fCurrent as Int + "/" + fMax as Int + " (Add)")
EndEvent

Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
fItem = akBaseItem.GetWeight()
fCurrent -= fItem*aiItemCount
;Debug.Notification(fCurrent as Int + "/" + fMax as Int + " (Remove)")
If(bFull)
Debug.Notification("The " + GetBaseObject().GetName() + " is full. (Current weight: " + fCurrent as Int + " of " + fMax as Int + ")")
bFull = False
EndIf
EndEvent



My knowledge of scripting is very limited, though, so I don't know what this script does.



It seems to work pretty good, though, except for arrows. I have tried several weighted arrow mods, but none of them seem to be compatible.



I would like to extend this script so that it also add weight to arrows and bolt (even from other mods, when they're using a keyword or something? VendorArrow?)



I heard you can add weight to arrows by using a dummy item? How do you do this?



Finally I want this script to also work with weighted arrows. So arrows put in the container with this script will have their weight counted properly.



Does anyone have any clue on how to do this?



Keep in mind that I know almost nothing about scripting.



Thanks in advance



Kind regards



Andre

User avatar
louise tagg
 
Posts: 3394
Joined: Sun Aug 06, 2006 8:32 am

Post » Mon Feb 01, 2016 9:02 am

Looking at the Arrows in the CK, it seems they don't have a weight option... I do not use any weighted Arrow Mods, but I assume they must script it, or something? Which is probably why the Script does not work--it is looking for the Weight on the Base Form. You should be able to 'cheat' it though with a specific weight for Arrows and Bolts, but it would not cover Types...



Scriptname zzzContainerWeightCap extends ObjectReference 

Float Property fMax = 1000.0 Auto
Float fItem
Float fCurrent
Int iCount
Bool bFull
Keyword Property VendorItemArrow Auto

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
fItem = akBaseItem.GetWeight()
if ( akBaseItem.HasKeyword(VendorItemArrow) == 1 )
fItem = 0.1
Elseif ( akBaseItem.HasKeyword(VendorItemBolt) == 1 )
fItem = 0.2
EndIf
iCount = Math.Floor((fMax-fCurrent)/fItem)
fCurrent += fItem*aiItemCount
If(aiItemCount > iCount)
RemoveItem(akBaseItem, (aiItemCount - iCount), False, akSourceContainer)
bFull = True
EndIf
;Debug.Notification(fCurrent as Int + "/" + fMax as Int + " (Add)")
EndEvent
Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
fItem = akBaseItem.GetWeight()
if ( akBaseItem.HasKeyword(VendorItemArrow) == 1 )
fItem = 0.1
Elseif ( akBaseItem.HasKeyword(VendorItemBolt) == 1 )
fItem = 0.2
EndIf
fCurrent -= fItem*aiItemCount
;Debug.Notification(fCurrent as Int + "/" + fMax as Int + " (Remove)")
If(bFull)
Debug.Notification("The " + GetBaseObject().GetName() + " is full. (Current weight: " + fCurrent as Int + " of " + fMax as Int + ")")
bFull = False
EndIf
EndEvent


You'll have to check what the Keyword for Bolts is, as I do not have it in front of me right now, but that should work. You can change 0.2 and 0.1 to whatever your Arrow Weight Mod uses.

User avatar
Flash
 
Posts: 3541
Joined: Fri Oct 13, 2006 3:24 pm

Post » Sun Jan 31, 2016 11:10 pm

Awesome! I'll try this out.



Thank you very much! :)

User avatar
Cat Haines
 
Posts: 3385
Joined: Fri Oct 27, 2006 9:27 am


Return to V - Skyrim