// -- This function was originally from Annieruru
function script F_ShuffleNumbers {
deletearray getarg(2);
.@static = getarg(0);
.@range = getarg(1) +1 - .@static;
.@count = getarg(3, .@range);
if (.@range <= 0 || .@count <= 0)
return 0;
if (.@count > .@range)
.@count = .@range;
for (.@i = 0; .@i < .@range; ++.@i)
.@temparray[.@i] = .@i;
for (.@i = 0; .@i < .@count; ++.@i) {
.@rand = rand(.@range);
set getelementofarray( getarg(2), .@i ), .@temparray[.@rand] + .@static;
.@temparray[.@rand] = .@temparray[--.@range];
}
return .@count;
}
- script Dropped -1,{
OnInit:
setarray .item_id, 501, 645, 533; // Possible items to receive (ID, amount)
setarray .item_qty, 25, 5, 30;
monster "jupe_ele",0,0,"--ja--",1004,1,strnpcinfo(0)+"::OnDropping";
end;
OnDropping:
getmapxy(@map$, @x, @y, BL_PC);
.@t = rand(getarraysize(.item_id));
callfunc "F_ShuffleNumbers", 0, .@t, .@id;
callfunc "F_ShuffleNumbers", 0, .@t, .@qt;
for ( .@i = 0; .@i < .@t; .@i++ )
makeitem .item_id[.@id[.@i]], .item_qty[.@qt[.@i]], @map$, @x, @y;
monster "jupe_ele",0,0,"--ja--",1004,1,strnpcinfo(0)+"::OnDropping";
end;
}
I was using annieruru's number shuffler function because it is reliable (at least for me)