function script array_shuffle {
.@size = getarraysize(getarg(0));
for (.@i = .@size - 1; .@i >= 1; --.@i)
swap(getelementofarray(getarg(0), rand(0, .@i)), getelementofarray(getarg(0), .@i));
return true;
}
function script array_sort {
.@total = .@size = getarraysize( getarg(0) );
copyarray .@arr, getarg(0), .@size;
for ( .@i = 0; .@i < .@size; ++.@i )
++.@tmp[.@arr[.@i]];
for ( ; .@size; --.@size ) {
.@index = getarraysize(.@tmp) -1;
.@output[.@size-1] = .@index;
--.@tmp[.@index];
}
copyarray getarg(0), .@output, .@total;
return;
}
function script printdispbottom {
.@size = getarraysize( getarg(1) );
for ( .@i = 0; .@i < .@size; ++.@i )
.@print$ += getelementofarray( getarg(1), .@i )+",";
dispbottom getarg(0) +" = "+ .@print$;
return;
}
poring_w01,105,100,5 script 222 1_F_MARIA,{
dispbottom " ==== "+ strnpcinfo(NPC_NAME) +" ===";
setarray .@a, 0,1,2,3,4,5,6,7,8,9;
// 1,2,5,6,3,8,9,4,6,3,5,6,8,3,5;
printdispbottom "original", .@a;
array_shuffle .@a;
printdispbottom " shuffle", .@a;
array_sort .@a;
printdispbottom " sort", .@a;
end;
}