function script F_MesItemInfo {
.@item = getarg(0);
.@itemname$ = getitemname(.@item);
if (.@itemname$ != "null") {
.@itemslot = getitemslots(.@item);
if (.@itemslot)
.@itemname$ = sprintf("%s [%d]", .@itemname$, .@itemslot);
}
else
.@itemname$ = "Unknown Item";
if (PACKETVER >= 20150729)
return sprintf("<ITEM>%s<INFO>%d</INFO></ITEM>", .@itemname$, .@item);
else if (PACKETVER >= 20130130)
return sprintf("<ITEMLINK>%s<INFO>%d</INFO></ITEMLINK>", .@itemname$, .@item);
else
return .@itemname$;
}
function script timeleft__ {
.@left = getarg(0);
if ( .@left <= 0 )
return getarg(0);
.@day = .@left / 86400;
.@hour = .@left % 86400 / 3600;
.@min = .@left % 3600 / 60;
.@sec = .@left % 60;
if ( .@day )
return sprintf( _$( "%d day %d hour" ), .@day, .@hour );
else if ( .@hour )
return sprintf( _$( "%d hour %d min" ), .@hour, .@min );
else if ( .@min )
return sprintf( _$( "%d min %d sec" ), .@min, .@sec );
else
return sprintf( _$( "%d sec" ), .@sec );
}
prontera,155,185,5 script kjdsfhskhf 1_F_MARIA,{
// #daily_supply = 0;
.@today = atoi( gettimestr( "%Y%m%d", 9 ) );
if ( #daily_supply == .@today ) {
mes "You have already taken today's supply";
mesf "You have to wait %s countdown to get next supply", timeleft__( getcalendartime(0,0) - gettimetick(2) );
}
else if ( checkweight( Knife, 3 ) == false ) {
mes "It appears you have overweight";
}
else {
mes "Retrieving today's supply...";
for ( .@i = 1; .@i <= 3; ++.@i ) {
.@r = rand(.totalchance[.@i]);
for ( .@j = 3; ( .@r -= getd(".item"+ .@i +"["+ .@j +"]") ) >= 0; .@j += 2 );
getitem getd(".item"+ .@i +"["+( .@j -1 )+"]"), rand( getd(".item"+ .@i +"[0]"), getd(".item"+ .@i +"[1]") );
}
#daily_supply = .@today;
}
next;
// chinese government enforce the law when giving items based on probability
mes "The Chances are:-";
for ( .@i = 1; .@i <= 3; ++.@i ) {
mes " ";
mesf "Set %d :", .@i;
mesf "Randomly get any one type of these item, the amount between %d~%d", getd(".item"+ .@i +"[0]"), getd(".item"+ .@i +"[1]");
for ( .@j = 3; .@j < getd(".item"+ .@i +"size"); .@j += 2 )
mesf "%s : %s", F_MesItemInfo( getd(".item"+ .@i +"["+( .@j -1 )+"]") ), getd(".chance_display_item"+ .@i +"$["+ .@j +"]");
}
close;
OnInit:
setarray .item1,
1, 10, // amount : rand(1,10)
// chance of getting the items Set#1
// <Item ID>,<chance>
Red_Potion, 5,
Orange_Potion, 4,
Yellow_Potion, 3,
White_Potion, 2,
Blue_Potion, 1,
Green_Potion, 6;
setarray .item2,
5, 15, // amount : rand(5,15)
// chance of getting the items Set#1
// <Item ID>,<chance>
Red_Herb, 5,
Yellow_Herb, 4,
White_Herb, 3,
Blue_Herb, 2,
Green_Herb, 1;
setarray .item3,
10, 20, // amount : rand(10,20)
// chance of getting the items Set#1
// <Item ID>,<chance>
Apple, 5,
Banana, 4,
Grape, 3,
Carrot, 2,
Sweet_Potato, 1,
Meat, 99,
Honey, 50,
Milk, 100;
for ( .@i = 1; .@i <= 3; ++.@i ) {
setd ".item"+ .@i +"size", getarraysize( getd(".item"+ .@i) );
for ( .@j = 3; .@j < getd(".item"+ .@i +"size"); .@j += 2 )
.totalchance[.@i] += getd(".item"+ .@i +"["+ .@j +"]");
for ( .@j = 3; .@j < getd(".item"+ .@i +"size"); .@j += 2 ) {
.@chance = getd(".item"+ .@i +"["+ .@j +"]") *10000 / .totalchance[.@i];
.@division = .@chance / 100;
.@remainder$ = .@chance % 100;
while ( getstrlen(.@remainder$) < 2 )
.@remainder$ = insertchar(.@remainder$, "0", 0);
setd ".chance_display_item"+ .@i +"$["+ .@j +"]", .@division +"."+ .@remainder$ +"%";
}
}
end;
}