Skip to content
User Avatar
#3819
Auto-translated
In other words, you want to replace all creatures from 1 to k when a certain condition is met, with a random selection, but you want this to happen:
a) Non-sequentially
b) Without repetitions
c) With all k elements

Then you need an interesting algorithm:
local used_indexes = {}
for i=1, k do
repeat N=random(k)+1
until not used_indexes[N]
used_indexes[N] = 1;
--Actions with the creature with number N (not k!!)
end
С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________