[Papyrus] Help me finish container weight script

Post » Sat May 28, 2016 4:37 pm

I have been working on a script to add weight caps to containers. Thanks to the help of other modders, I got a basic script set up.



I was wondering if someone can take a look at it and help me finish:




Spoiler

Scriptname zzzContainerWeightCap extends Actor

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

Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
If UI.IsMenuOpen("ContainerMenu") == 1
; Set the containers max weight
If (akDestContainer.GetBaseObject().GetWorldModelPath() == "Clutter\Containers\Satchel.nif" )
fMax = 10.0
ElseIf (akDestContainer.GetBaseObject().GetWorldModelPath() == "Clutter\Containers\MiscSackSmall.nif" OR "Clutter\Containers\MiscSack02Small.nif" OR "Clutter\Containers\MiscSack02SmallFlat.nif" OR "Clutter\Common\StrongBox01.nif" )
fMax = 25.0
ElseIf (akDestContainer.GetBaseObject().GetWorldModelPath() == "Clutter\WoodFires\SpitPotClosedLoose01.nif" OR "Clutter\WoodFires\SpitPotClosed01.nif" OR "Clutter\WoodFires\SpitPotClosed01.nif" )
fMax = 30.0
ElseIf (akDestContainer.GetBaseObject().GetWorldModelPath() == "Architecture\WhiteRun\WRClutter\WRBurialUrn01.nif" OR "Clutter\Sack01.NIF" OR "Clutter\SBurialUrn01.nif" OR "Clutter\Containers\MiscPouch.nif" OR "Clutter\Ruins\RuinsCanopicJar01.nif" OR "Clutter\Ruins\RuinsCanopicJar02.nif" )
fMax = 50.0
ElseIf (akDestContainer.GetBaseObject().GetWorldModelPath() == "Clutter\Containers\MiscSackLarge.nif" OR "Clutter\Containers\MiscSackLargeFlat01.nif" OR "Clutter\Containers\MiscSackLargeFlat02.nif" OR "Clutter\Containers\MiscSackLargeFlat03.nif" OR "Clutter\Containers\MiscSack02Large.nif" OR "Clutter\Containers\MiscSack02LargeFlat.nif" OR "Effects\FXSpiderWebKitSkeeverDinner.nif" OR "Effects\FXSpiderWebKitDinner.nif" )
fMax = 75.0
ElseIf (akDestContainer.GetBaseObject().GetWorldModelPath() == "Clutter\Common\EndTable01.nif" OR "Clutter\Ruins\RuinsLargeUrnWithStand01.nif" OR "Clutter\Upperclass\UpperEndTable01.nif" OR "Furniture\Noble\NobleNightTable01.nif" OR "Furniture\OrcFurniture\OrcEndTable01.nif" OR "_BYOH\Furniture\BYOHUpperEndTable02.nif" )
fMax = 100.0
ElseIf (akDestContainer.GetBaseObject().GetWorldModelPath() == "Architecture\WhiteRun\WRClutter\WRCoffin01.nif" OR "Architecture\Riften\Clutter\RTCoffin01.nif" OR "Clutter\Barrel01.NIF" OR "Clutter\Common\Cupboard01.nif" OR "Clutter\Common\Dresser01.nif" OR "Clutter\Common\Wardrobe01.nif" OR "Clutter\Common\CommonCoffin01.nif" OR "Clutter\Containers\SafeandLock01.nif" OR "Clutter\Dwemer\DweDresser01.nif" OR "Clutter\Sovngarde\SovBarrel01.nif" OR "Clutter\Upperclass\UpperCupboard.nif" OR "Clutter\Upperclass\UpperDresser01.nif" OR "Clutter\Upperclass\UpperWardrobe01.nif" OR "Clutter\Windhelm\WHcoffin01.nif" OR "Dungeons\Dwemer\Clutter\MrkCryptCoffin01container.nif" OR "Dungeons\Dwemer\Clutter\MrkCryptCoffin02container.nif" OR "Furniture\OrcFurniture\OrcDresser01.nif" OR "Dungeons\Dwemer\Clutter\MrkCryptCoffin01container.nif" OR "Dungeons\Dwemer\Clutter\MrkCryptCoffin02container.nif" OR "Furniture\OrcFurniture\OrcDresser01.nif" OR "Furniture\Noble\NobleChestDrawers01.nif" OR "Furniture\Noble\NobleChestDrawers02.nif" OR "Furniture\Noble\NobleWardrobe01.nif" OR "Furniture\Noble\SCoffin.nif" OR "Furniture\Noble\SCoffinPoor.nif" OR "DLC02\Dungeons\Apocrypha\Animated\ApoUrn\ApoUrn01.nif" OR "DLC02\Clutter\DLC2DarkElfUrn01.nif" )
fMax = 125.0
ElseIf (akDestContainer.GetBaseObject().GetWorldModelPath() == "Clutter\Dwemer\DweContainter02.nif" OR "DLC02\Dungeons\Apocrypha\Animated\ApoUrn\ApoUrn02.nif" )
fMax = 150.0
ElseIf (akDestContainer.GetBaseObject().GetWorldModelPath() == "Clutter\Ruins\Ruins_SmallChest.nif" OR "DLC02\Architecture\Riekling\DLC2RieklingTent01.nif" )
fMax = 175.0
ElseIf (akDestContainer.GetBaseObject().GetWorldModelPath() == "Clutter\Containers\Chest01\Chest01.nif" OR "Clutter\Falmer\FalmerContainer.nif" OR "Clutter\Upperclass\UpperChest01.nif" OR "DLC01\Clutter\DLC01SnowElfChest.nif" OR "DLC01\SoulCairn\sc_chest.nif" OR "DLC01\SoulCairn\sc_chest02.nif" )
fMax = 200.0
ElseIf (akDestContainer.GetBaseObject().GetWorldModelPath() == "Clutter\Dwemer\DweChest01.nif" OR "Clutter\Dwemer\DweContainer01.nif" OR "Clutter\Falmer\FalmerContainer02.nif" OR "Clutter\Ruins\Ruins_LargeChest.nif" OR "Furniture\Noble\NobleChest01.nif" )
fMax = 225.0
Else
fMax = 150.0
EndIf
fItem = akBaseItem.GetWeight()
if ( akBaseItem.HasKeyword(VendorItemArrow) == 1 )
fItem = 0.1
EndIf
iCount = Math.Floor((fMax-fCurrent)/fItem)
fCurrent += fItem*aiItemCount
If(aiItemCount > iCount)
akDestContainer.RemoveItem(akBaseItem, (aiItemCount - iCount), true, GetReference())
bFull = True
EndIf
;Debug.Notification(fCurrent as Int + "/" + fMax as Int + " (Add)")
EndIf
EndEvent
Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
If UI.IsMenuOpen("ContainerMenu") == 1
; Set the containers max weight
If (akSourceContainer.GetBaseObject().GetWorldModelPath() == "Clutter\Containers\Satchel.nif" )
fMax = 10.0
ElseIf (akSourceContainer.GetBaseObject().GetWorldModelPath() == "Clutter\Containers\MiscSackSmall.nif" OR "Clutter\Containers\MiscSack02Small.nif" OR "Clutter\Containers\MiscSack02SmallFlat.nif" OR "Clutter\Common\StrongBox01.nif" )
fMax = 25.0
ElseIf (akSourceContainer.GetBaseObject().GetWorldModelPath() == "Clutter\WoodFires\SpitPotClosedLoose01.nif" OR "Clutter\WoodFires\SpitPotClosed01.nif" OR "Clutter\WoodFires\SpitPotClosed01.nif" )
fMax = 30.0
ElseIf (akSourceContainer.GetBaseObject().GetWorldModelPath() == "Architecture\WhiteRun\WRClutter\WRBurialUrn01.nif" OR "Clutter\Sack01.NIF" OR "Clutter\SBurialUrn01.nif" OR "Clutter\Containers\MiscPouch.nif" OR "Clutter\Ruins\RuinsCanopicJar01.nif" OR "Clutter\Ruins\RuinsCanopicJar02.nif" )
fMax = 50.0
ElseIf (akSourceContainer.GetBaseObject().GetWorldModelPath() == "Clutter\Containers\MiscSackLarge.nif" OR "Clutter\Containers\MiscSackLargeFlat01.nif" OR "Clutter\Containers\MiscSackLargeFlat02.nif" OR "Clutter\Containers\MiscSackLargeFlat03.nif" OR "Clutter\Containers\MiscSack02Large.nif" OR "Clutter\Containers\MiscSack02LargeFlat.nif" OR "Effects\FXSpiderWebKitSkeeverDinner.nif" OR "Effects\FXSpiderWebKitDinner.nif" )
fMax = 75.0
ElseIf (akSourceContainer.GetBaseObject().GetWorldModelPath() == "Clutter\Common\EndTable01.nif" OR "Clutter\Ruins\RuinsLargeUrnWithStand01.nif" OR "Clutter\Upperclass\UpperEndTable01.nif" OR "Furniture\Noble\NobleNightTable01.nif" OR "Furniture\OrcFurniture\OrcEndTable01.nif" OR "_BYOH\Furniture\BYOHUpperEndTable02.nif" )
fMax = 100.0
ElseIf (akSourceContainer.GetBaseObject().GetWorldModelPath() == "Architecture\WhiteRun\WRClutter\WRCoffin01.nif" OR "Architecture\Riften\Clutter\RTCoffin01.nif" OR "Clutter\Barrel01.NIF" OR "Clutter\Common\Cupboard01.nif" OR "Clutter\Common\Dresser01.nif" OR "Clutter\Common\Wardrobe01.nif" OR "Clutter\Common\CommonCoffin01.nif" OR "Clutter\Containers\SafeandLock01.nif" OR "Clutter\Dwemer\DweDresser01.nif" OR "Clutter\Sovngarde\SovBarrel01.nif" OR "Clutter\Upperclass\UpperCupboard.nif" OR "Clutter\Upperclass\UpperDresser01.nif" OR "Clutter\Upperclass\UpperWardrobe01.nif" OR "Clutter\Windhelm\WHcoffin01.nif" OR "Dungeons\Dwemer\Clutter\MrkCryptCoffin01container.nif" OR "Dungeons\Dwemer\Clutter\MrkCryptCoffin02container.nif" OR "Furniture\OrcFurniture\OrcDresser01.nif" OR "Dungeons\Dwemer\Clutter\MrkCryptCoffin01container.nif" OR "Dungeons\Dwemer\Clutter\MrkCryptCoffin02container.nif" OR "Furniture\OrcFurniture\OrcDresser01.nif" OR "Furniture\Noble\NobleChestDrawers01.nif" OR "Furniture\Noble\NobleChestDrawers02.nif" OR "Furniture\Noble\NobleWardrobe01.nif" OR "Furniture\Noble\SCoffin.nif" OR "Furniture\Noble\SCoffinPoor.nif" OR "DLC02\Dungeons\Apocrypha\Animated\ApoUrn\ApoUrn01.nif" OR "DLC02\Clutter\DLC2DarkElfUrn01.nif" )
fMax = 125.0
ElseIf (akSourceContainer.GetBaseObject().GetWorldModelPath() == "Clutter\Dwemer\DweContainter02.nif" OR "DLC02\Dungeons\Apocrypha\Animated\ApoUrn\ApoUrn02.nif" )
fMax = 150.0
ElseIf (akSourceContainer.GetBaseObject().GetWorldModelPath() == "Clutter\Ruins\Ruins_SmallChest.nif" OR "DLC02\Architecture\Riekling\DLC2RieklingTent01.nif" )
fMax = 175.0
ElseIf (akSourceContainer.GetBaseObject().GetWorldModelPath() == "Clutter\Containers\Chest01\Chest01.nif" OR "Clutter\Falmer\FalmerContainer.nif" OR "Clutter\Upperclass\UpperChest01.nif" OR "DLC01\Clutter\DLC01SnowElfChest.nif" OR "DLC01\SoulCairn\sc_chest.nif" OR "DLC01\SoulCairn\sc_chest02.nif" )
fMax = 200.0
ElseIf (akSourceContainer.GetBaseObject().GetWorldModelPath() == "Clutter\Dwemer\DweChest01.nif" OR "Clutter\Dwemer\DweContainer01.nif" OR "Clutter\Falmer\FalmerContainer02.nif" OR "Clutter\Ruins\Ruins_LargeChest.nif" OR "Furniture\Noble\NobleChest01.nif" )
fMax = 225.0
Else
fMax = 150.0
EndIf
fItem = akBaseItem.GetWeight()
if ( akBaseItem.HasKeyword(VendorItemArrow) == 1 )
fItem = 0.1
EndIf
fCurrent -= fItem*aiItemCount
;Debug.Notification(fCurrent as Int + "/" + fMax as Int + " (Remove)")
If(bFull)
Debug.Notification("This container is full. (Current weight: " + fCurrent as Int + " of " + fMax as Int + ")")
bFull = False
EndIf
EndIf
EndEvent




Basically I will attach this script to a player alias in a quest.



Could anyone help me correct this script/help me finish it?



Thanks in advance



Kind regards



Sac

User avatar
Julie Ann
 
Posts: 3383
Joined: Thu Aug 23, 2007 5:17 am

Return to V - Skyrim