Jump to content

[Papyrus] Adding Weighted Arrows to Container Weight Cap


Recommended Posts

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

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

Edited by AndrealphusVIII
Link to comment
Share on other sites

If the arrows actually have weight that script should work without any modifications.

 

I've never looked into it but if the arrow weight mods are really implementing the weight through scripts and dummy items then you'll have to implement the weight addition for arrows and bolts as a special case.

 

If you're willing to just assume that all arrows and bolts weigh a certain amount (0.005 for example) then this should work:

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()
    if (fItem == 0.0 && (akBaseItem as Ammo))
        fItem = 0.005
    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()
    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

If you are willing to require SKSE and want to assign different default weights for bolts and arrows you could use something like this:

    if fItem == 0.0 && (akBaseItem as Ammo)
        if (akBaseItem as Ammo).IsBolt()
            fItem = 0.01
        else ; arrow
            fItem = 0.005
        endif
    endif

Anything more specific will require checking against specific formID values and probably involve dependencies on various mods.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...