I know this may seem a little too extreme, but I have often wished that I could rummage through those chests and shelves to get what I wanted, rather than the 14gp it seems to want to offer. You know, just press Cntrl-R or something and have the contents reinitialize so I am digging through it to find what I want. Not that I can go back for more, mind you. Just that I can walk away satisfied that I found something useful. And hey, maybe 14gp will be all I want at the time.
You kids stay out of my damn chests. Rummaging indeed. Grumbles…
Are you talking about existing modules or something you’re writing?
I think Swordflight for NWN1 did something like this. Opening a container for the first time would cause a Search or Appraise check, allowing skilled PCs to find something useful inside instead of junk items.
I am just asking if it can be done easily. No I am not writing anything myself.
I’m not sure what you consider to be easy, but it would take a bit of work. Chests can have scripts that run on open (or when destroyed), and you could potentially modify those scripts to do what you want. You could modify a module by going through the containers and adding scripts where they are lacking.
If Swordflight does it, the scripts from that may be fairly straightforward to adapt. SoZ also has a loot randomizer on at least some chests, but it only fires once per chest I think.
If you are developing your own module, I expanded Syria’s foraging scripts into a more general purpose system that I used in Drink or to allow the pc to do things like notice a painting was by a notable painter and thus valuable, this was not random however.
A good loot randomizer for chests can be found here (fw_container_on_open). There’re parameters that allow to set the total price of the loot. I guess It can be easily combined with Swordflight’s work. But, as rjshae said, you have to modify every chest in a module for it to work.