How is the itemchance calculated?

hyperionb

New Member
Hello,
I'm wondering right now how the itemchance is calculated.
The "itemchance" is set here with the array itemchance for each item, buildin, loottype etc... for example line 329.
https://github.com/R4Z0R49/DayZMod/blob/Release_1.7.6/SQF/dayz_code/config.cpp

Obviously the number set in itemchance for each item isn't the real itemchance. The real itemchance is calculated here:
https://github.com/R4Z0R49/DayZMod/blob/Release_1.7.6/SQF/dayz_code/init/loot_init.sqf

To be accurate it is between line 12 and 19.
here:
Code:
            _weighted = [];
            _j = 0;
            for "_l" from 0 to ((count _itemChances) - 1) do {
            _weight = round ((_itemChances select _l) * 100);
                for "_k" from 0 to _weight - 1 do {
                    _weighted set [_j + _k, _l];
                };
            _j = _j + _weight;

My Problem: I fail to understand what is calculated how etc. because I also only know a bit C++. The end result of the calculation seems to be _weighted which is also the real itemchance.
Please help. :)

regards
 
Back
Top