The first thing that need to be done before working on any functions is to nail down the scale value.
Rolo Kipp wrote...
The dependent placeables will be sized in binary fashion (i.e. the #2 is twice the volume of #1, #3 is twice the volume of #2, etc. They will all have the same origin, but be offset in different directions, with overlap. In fact, the first 3 will mostly just fill up the interior of the chest (with a little spillage).
When you are saying #1, #2 and Number #3.
Are they bit numbers?
#1 (0010)
#2 (0100)
#3 (1000) // Yes bits are 0 based.
Or are they numbers?
#1 (0001)
#2 (0010)
#3 (0011)
Bit NumbersIf they are Bit numbers. The Scale would simply be your Total Chest Value(TCV) devided by a Scale Value(SV).
Scale = TCV/SV;
That would give you no Bits set until you reached you SV.
0 <TCV > SV = (0000) // bits
SV < TCV > 2SV = (0001)
2SV < TCV > 4SV = (001?) // ? means the value may or may not be set.
4SV < TCV > 8SV = (01??)
8SV < TCV > 16SV = (1???)
If you wanted to shift the scale up one, so that the first bit was set with the first item placed in the chest, you would just add the SV to the TCV before the division.
Scale = (TCV+SV)/ SV
Giving you:
0 <TCV > SV = (0001) // bits
SV < TCV > 2SV = (001?)
2SV < TCV > 4SV = (01??)
4SV < TCV > 8SV = (1???)
With a SV of 10,000 this would look like.
0 <TCV > 10,000 = (0001) // bits
10,000 < TCV > 20,000 = (001?)
20,000 < TCV > 40,000 = (01??)
40,000 < TCV > 80,000 = (1???)
...
64,000 <TCV> 128,000 = (1???_?
) // Bit 8 Set.
NumbersIf they are numbers. It would be a log base 2.
Scale = log(TCV) / log(2)
(TCV < 2) = 0 (0000)
(TCV< 4) = 1 (0001)
(TCV<
= 2 (0010)
(TCV< 16) = 3 (0011)
(TCV< 32) = 4 (0100)
(TCV< 64) = 5 (0101)
(TCV< 128) = 6 (0110)
...
(TCV< 512) = 8 (1000)
...
(65,536< TVC > 131,072) = 16 (0001_0000)
...
Scale = 31 is TCV 2.14 Billion. The max number an NWN int can be. ( 0001_1111)
It looks to me that if you used:
Scale = log( TCV * 2 ) / log(2)
You would never go over 8 bits.