Jump to content

Limited containers capacity weight


baronesbc

Recommended Posts

Hi all, I was wondering if was possible to create a mod that add a limit capacity weight for boxes barrels or other containers, I never could stand the unrealistic idea to add items inside the containers to infinity... Unfortunately I could not find a mod like this anywhere, (if this already exists please post me) so if this idea would be developed by some modder I'd love to ... Thank you and sorry my bad English by google translate :)

Link to comment
Share on other sites

It is possible. SKSE has a GetWeight function for objects. So defining a weight cap, checking items for their weight as added and doing a little math one could deny items that exceed the specified weight for that container. Problem tho. Assigning the script directly to stock containers can cause issues should the mod be uninstalled. Using a quest system would be better. But then the quest would need to reference every container in the game and that is probably not feasible (or at least not desirable to do).

Link to comment
Share on other sites

It could be done. I've tried something similar. But you either have to repeatedly update or do something "immersion" breaking like use a hotkey to start and stop the quest. Constantly running an update cycle to temporarily apply a script to containers in the area is IMHO a little excessive. Better to have a means to do it at the desired moment.

Link to comment
Share on other sites

True enough. What about a script on a player alias which checks for triggers anytime an item is removed from the player? You can get the object and the destination from the event, so it should.

Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
	If ( akDestContainer )
		If ( akDestContainer.GetTotalItemWeight() > Max )
			akDestContainer.RemoveItem( akItemReference, aiItemCount, true, Game.GetPlayer() )
			Debug.Notification("This item won't fit in this container")
		EndIf
	EndIf
EndEvent

Unfortunately, the function GetTotalItemWeight() only works on the player. Any way to find the total weight of items that you know of?

Link to comment
Share on other sites

You can use SKSE's GetWeight for any item and it can run on any script as it is native to the Form script.

 

But you can't use a script on the player alias unless you want to deal with an unwieldy number of global variables to remember the current weight of each container.

 

By having the script somehow on the container itself, you can use a local variable to keep track of the running weight as items are added or removed. So the script needs to be on the container. Either directly or as an alias.

 

I suppose instead of one large quest that manages every container in the game, you could have multiple quests separated by hold, cell, or something along those lines... but then that leaves mod containers in the lurch...

 

The big problem with dynamic attaching of scripts to the container is that once the quest is stopped and started again, the previous containers forget their current weight and short of removing those items and putting them back in there would be no way of bringing it back up to date if it were to be re-selected as an alias again on another run of the quest.

 

 

The again... One could simply edit the base containers directly and state to the users that the mod applies a script direct to stock objects and if they are not comfortable with that then they should not use the mod. That should they remove the mod mid-game, this risk corrupting their save, making any or all containers inaccessible and/or blow up their computer. :P

Link to comment
Share on other sites

Thanks for respond me! unfortunately didn't know anything about modding, I dabbled only to change some values ​​with the ck, but nothing more ... I agree, however, only change a container in front of us, with a spell or more ... It would be ideal, rather than changing all containers of Skyrim.

Link to comment
Share on other sites

You can use SKSE's GetWeight for any item and it can run on any script as it is native to the Form script.

 

But you can't use a script on the player alias unless you want to deal with an unwieldy number of global variables to remember the current weight of each container.

 

By having the script somehow on the container itself, you can use a local variable to keep track of the running weight as items are added or removed. So the script needs to be on the container. Either directly or as an alias.

 

I suppose instead of one large quest that manages every container in the game, you could have multiple quests separated by hold, cell, or something along those lines... but then that leaves mod containers in the lurch...

 

The big problem with dynamic attaching of scripts to the container is that once the quest is stopped and started again, the previous containers forget their current weight and short of removing those items and putting them back in there would be no way of bringing it back up to date if it were to be re-selected as an alias again on another run of the quest.

 

 

The again... One could simply edit the base containers directly and state to the users that the mod applies a script direct to stock objects and if they are not comfortable with that then they should not use the mod. That should they remove the mod mid-game, this risk corrupting their save, making any or all containers inaccessible and/or blow up their computer. :tongue:

 

I think you might be thinking a little too deeply into it Ishara,I don't see a need to A: Store the Weight of each container and B: To have all Containers monitored at once.

 

What's wrong with just managing the container that the player is interacting with? hiding or removing/dropping items and not allowing the player to place items into that container that are beyond the capacity for the container?

 

This could be done through an Activation perk entry, a quest with a single alias containing the interacted target (which is recieved via the perk entry), and of course a script attached to the RefAlias, stopping the quest once the player leaves interaction.

 

Although you would probably need a second quest to add the perk to the player and remove it if you wished to remove the mod.

Edited by CraftySentinel
Link to comment
Share on other sites

If you read, you would see that I indicated that dynamically attaching scripts is not a good idea for maintaining the weight of the container's contents. The only way to do it with dynamically attached scripts would be to remove and re-add the items stored in order to recalculate the containers current weight before allowing the player to add any more weight.

 

I'll quote for you

 

 

The big problem with dynamic attaching of scripts to the container is that once the quest is stopped and started again, the previous containers forget their current weight and short of removing those items and putting them back in there would be no way of bringing it back up to date if it were to be re-selected as an alias again on another run of the quest.

 

I did not say it wasn't possible. I merely stated that that was the drawback of attaching the script dynamically.

 

You might think that I'm over thinking it but I like to cover all the bases. It is part of the brainstorming process. Does not matter to me one way or the other how someone wishes to implement this idea. Putting my ideas and thought process out there can get other people thinking about it too. Obviously it worked, since you suggested using a perk in the process. I've never worked with perks and would not have thought of that myself.

Link to comment
Share on other sites

If you read, you would see that I indicated that dynamically attaching scripts is not a good idea for maintaining the weight of the container's contents. The only way to do it with dynamically attached scripts would be to remove and re-add the items stored in order to recalculate the containers current weight before allowing the player to add any more weight.

 

I'll quote for you

 

 

The big problem with dynamic attaching of scripts to the container is that once the quest is stopped and started again, the previous containers forget their current weight and short of removing those items and putting them back in there would be no way of bringing it back up to date if it were to be re-selected as an alias again on another run of the quest.

 

I did not say it wasn't possible. I merely stated that that was the drawback of attaching the script dynamically.

 

You might think that I'm over thinking it but I like to cover all the bases. It is part of the brainstorming process. Does not matter to me one way or the other how someone wishes to implement this idea. Putting my ideas and thought process out there can get other people thinking about it too. Obviously it worked, since you suggested using a perk in the process. I've never worked with perks and would not have thought of that myself.

 

I did come off alittle, erm...'douchy' didn't I? re-read your post and it came off completely different to what I thought it was :sweat: , sorry.

Edited by CraftySentinel
Link to comment
Share on other sites

  • Recently Browsing   0 members

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