Skip to content
User Avatar
#3607
Auto-translated
arts = {
[1] = {mass = 1},
[2] = {mass = 14},
[3] = {mass = 7},
[4] = {mass = 8},
[5] = {mass = 11},
}

function GetRandomArt()
local sum
local n
for id, props in arts do
sum = sum + props.mass
end
n = random(sum)+1
local start, finish, shift = 0, 0, 0
for id, props in arts do
finish = start + props.mass
if start<=n and n<finish then
return id
else shift = finish-start
start = finish
finish = start+shift
end
end
return 0
end


You can also manually create a table of 95 elements (not necessarily all of them), specifying a weight for each — the higher the weight, the greater the chance of it dropping.

С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________