Jump to content

Dark Theme was set as default for all members. Please report any issues here.

  • 0
MikZ

Daily random supplies

Question

Hi!

May I request a sample random prize giver.
What I'm looking for is.

This npc will give all 3 set  1 type of item from set A,B to C randomly, with random number of pieces too.

Set A: random (1x,10x) pcs

random :656 , 657 , 505 , 645 , 506 , 14510 

Set B: random (5x,15x) pcs

random :656 , 657 , 505 , 645 , 506 , 14510 

Set C: random (10x,20x) pcs

random :656 , 657 , 505 , 645 , 506 , 14510 

please help me. 

thanks!

Share this post


Link to post
Share on other sites

12 answers to this question

Recommended Posts

  • 0
Spoiler
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 == [email protected] ) {
		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 = [email protected];
	}
	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;
}

 

erm ... its getting interestingly ... complexity ...

Share this post


Link to post
Share on other sites
  • 0
On 3/16/2019 at 5:46 PM, MikZ said:

Hi!

May I request a sample random prize giver.
What I'm looking for is.

This npc will give all 3 set  1 type of item from set A,B to C randomly, with random number of pieces too.

Set A: random (1x,10x) pcs

random :656 , 657 , 505 , 645 , 506 , 14510 

Set B: random (5x,15x) pcs

random :656 , 657 , 505 , 645 , 506 , 14510 

Set C: random (10x,20x) pcs

random :656 , 657 , 505 , 645 , 506 , 14510 

please help me. 

thanks!

Like this?

prontera,158,167,3	script	Sample	4_M_SIT_NOVICE,{
if (#gotreward + .next_take> gettimetick(2)) {
	mes "[Random Item Giver]";
	mes "Please talk to me after 24 hours.";
	close;
}
	else {
	set .random1,rand(getarraysize (.count1));	
	set .random2,rand(getarraysize (.count2));
	set .random3,rand(getarraysize (.count3));
	mes "[Random Item Giver]";
	mes "Have some of these!";
		getitem .item[rand(getarraysize (.item))],.count1[.random1];
		getitem .item[rand(getarraysize (.item))],.count2[.random2];
		getitem .item[rand(getarraysize (.item))],.count3[.random3];
		#gotreward = gettimetick(2);
		next;
     	close;
}


OnInit:
.next_take = 24*60*60;
setarray .item[0],656,657,505,645,506,14510;
setarray .count1[0],1,10;
setarray .count2[0],5,15;
setarray .count3[0],10,20;
end;
}

Edit: 
Thought it was 1-10 , 5-15 , and 10-20 instead of 1,10 5,15 and 10,20

Edited by Kuroe
recode

Share this post


Link to post
Share on other sites
  • 0
On 3/16/2019 at 5:46 PM, MikZ said:

Set A: random (1x,10x) pcs

random :656 , 657 , 505 , 645 , 506 , 14510 

Set B: random (5x,15x) pcs

random :656 , 657 , 505 , 645 , 506 , 14510 

Set C: random (10x,20x) pcs

random :656 , 657 , 505 , 645 , 506 , 14510

curious, why all 3 sets have same item ID ?
so it means they can be repeated ?

 

prontera,155,185,5	script	kjdsfhskhf	1_F_MARIA,{	
	getitem F_Rand( 656, 657, 505, 645, 506, 14510 ), rand(1,10);
	getitem F_Rand( 656, 657, 505, 645, 506, 14510 ), rand(5,15);
	getitem F_Rand( 656, 657, 505, 645, 506, 14510 ), rand(10,20);
	end;
}

 

Share this post


Link to post
Share on other sites
  • 0

prontera,158,167,3	script	Sample	4_M_SIT_NOVICE,{

if (#xTaken + .next_take> gettimetick(2)) {
	mes "[Random Item Giver]";
	mes "Please talk to me after 24 hours.";
	close;
}
	else {

	mes "[Random Item Giver]";
	mes "Have some of these!";
		.@riRate1 = rand (.@Ai11,.@Ai12);
		.@riRate2 = rand (.@Ai21,.@Ai22);
		.@riRate3 = rand (.@Ai31,.@Ai32);
		.@rItemid1 = .@Aitem1[rand(getarraysize (.@Aitem1))];
		.@rItemid2 = .@Aitem2[rand(getarraysize (.@Aitem2))];
		.@rItemid3 = .@Aitem3[rand(getarraysize (.@Aitem3))];
		getitem ( .@rItemid1, .@riRate1 ) ;
//		dispbottom ( "rItemid1 :: " + [email protected] + " riRate1 :: " + [email protected] + " Name :: " + getitemname ( [email protected] ) ) ; // debug use only !!!
		getitem ( .@rItemid2, .@riRate2 ) ;
//		dispbottom ( "rItemid2 :: " + [email protected] + " riRate2 :: " + [email protected] + " Name :: " + getitemname ( [email protected] ) ) ; // debug use only !!!
		getitem ( .@rItemid3, .@riRate3 ) ;
//		dispbottom ( "rItemid3 :: " + [email protected] + " riRate3 :: " + [email protected] + " Name :: " + getitemname ( [email protected] ) ) ; // debug use only !!!
		#xTaken = gettimetick(2);
		next;
     	close;
}


OnInit:

	//set cooldown to take item again.
	.next_take = 24*60*60;

	//set item here
	setarray .Aitem1[0],501,502,503,504,505,14510; 
	setarray .Aitem2[0],601,602,603,604,605,14510;
	setarray .Aitem3[0],701,702,703,704,705,14510;
	//set rate here
	.Ai11 = 1;
	.Ai12 = 10;
	.Ai21 = 5;
	.Ai22 = 15;
	.Ai31 = 10;
	.Ai32 = 20;

	end;
}

Refined and fixed up npc variable..

Edited by utofaery

Share this post


Link to post
Share on other sites
  • 0
11 hours ago, utofaery said:

prontera,158,167,3	script	Sample	4_M_SIT_NOVICE,{

if (#xTaken + .next_take> gettimetick(2)) {
	mes "[Random Item Giver]";
	mes "Please talk to me after 24 hours.";
	close;
}
	else {

	mes "[Random Item Giver]";
	mes "Have some of these!";
		.@riRate1 = rand (.@Ai11,.@Ai12);
		.@riRate2 = rand (.@Ai21,.@Ai22);
		.@riRate3 = rand (.@Ai31,.@Ai32);
		.@rItemid1 = .@Aitem1[rand(getarraysize (.@Aitem1))];
		.@rItemid2 = .@Aitem2[rand(getarraysize (.@Aitem2))];
		.@rItemid3 = .@Aitem3[rand(getarraysize (.@Aitem3))];
		getitem ( .@rItemid1, .@riRate1 ) ;
//		dispbottom ( "rItemid1 :: " + [email protected] + " riRate1 :: " + [email protected] + " Name :: " + getitemname ( [email protected] ) ) ; // debug use only !!!
		getitem ( .@rItemid2, .@riRate2 ) ;
//		dispbottom ( "rItemid2 :: " + [email protected] + " riRate2 :: " + [email protected] + " Name :: " + getitemname ( [email protected] ) ) ; // debug use only !!!
		getitem ( .@rItemid3, .@riRate3 ) ;
//		dispbottom ( "rItemid3 :: " + [email protected] + " riRate3 :: " + [email protected] + " Name :: " + getitemname ( [email protected] ) ) ; // debug use only !!!
		#xTaken = gettimetick(2);
		next;
     	close;
}


OnInit:

	//set cooldown to take item again.
	.next_take = 24*60*60;

	//set item here
	setarray .Aitem1[0],501,502,503,504,505,14510; 
	setarray .Aitem2[0],601,602,603,604,605,14510;
	setarray .Aitem3[0],701,702,703,704,705,14510;
	//set rate here
	.Ai11 = 1;
	.Ai12 = 10;
	.Ai21 = 5;
	.Ai22 = 15;
	.Ai31 = 10;
	.Ai32 = 20;

	end;
}

Refined and fixed up npc variable..

@utofaery Hello, just what i wanted with success rate for rare ones, can you add countdown timer 

"you still have 00 hours, minute/s seconds countdown to get next supplies"

Also, im getting error like and no items were given.

Buildin_getitem: Nonexistant item 0 requested.

 

11 hours ago, AnnieRuru said:

curious, why all 3 sets have same item ID ?
so it means they can be repeated ?

 

prontera,155,185,5	script	kjdsfhskhf	1_F_MARIA,{	
	getitem F_Rand( 656, 657, 505, 645, 506, 14510 ), rand(1,10);
	getitem F_Rand( 656, 657, 505, 645, 506, 14510 ), rand(5,15);
	getitem F_Rand( 656, 657, 505, 645, 506, 14510 ), rand(10,20);
	end;
}

 

Hi @AnnieRuru yes can be repeated. can you add rates for the rare ones, like the above. thnx!

 

 

Edited by MikZ

Share this post


Link to post
Share on other sites
  • 0

https://github.com/AnnieRuru/Release/blob/master/Guides/Daily Quest - use gettimetick(2) or gettimestr.md

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,{
	.@today = atoi( gettimestr( "%Y%m%d", 9 ) );
	if ( #daily_supply == [email protected] ) {
		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) );
		close;
	}
	getitem F_Rand( 656, 657, 505, 645, 506, 14510 ), rand(1,10);
	getitem F_Rand( 656, 657, 505, 645, 506, 14510 ), rand(5,15);
	getitem F_Rand( 656, 657, 505, 645, 506, 14510 ), rand(10,20);
	#daily_supply = [email protected];
	end;
}

Share this post


Link to post
Share on other sites
  • 0
19 minutes ago, AnnieRuru said:

https://github.com/AnnieRuru/Release/blob/master/Guides/Daily Quest - use gettimetick(2) or gettimestr.md

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,{
	.@today = atoi( gettimestr( "%Y%m%d", 9 ) );
	if ( #daily_supply == [email protected] ) {
		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) );
		close;
	}
	getitem F_Rand( 656, 657, 505, 645, 506, 14510 ), rand(1,10);
	getitem F_Rand( 656, 657, 505, 645, 506, 14510 ), rand(5,15);
	getitem F_Rand( 656, 657, 505, 645, 506, 14510 ), rand(10,20);
	#daily_supply = [email protected];
	end;
}

That was fast,

I like to add some twist, can you add like rate for rare one.

example item 506 is @ 5% and item 14510 is @ 2% success chance to get in set A

for set b 505 @ 9% and 657 @ 1%

for Set C 657 @ 10% 14510 @ 1%.
of course ill be adding more item like bubble gums, Food items, TCGs

something like that. thanks!

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, AnnieRuru said:
  Reveal hidden contents

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 == [email protected] ) {
		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 = [email protected];
	}
	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;
}

 

erm ... its getting interestingly ... complexity ...

Perfect!
Thank you so much @AnnieRuru

Share this post


Link to post
Share on other sites
  • 0
3 hours ago, AnnieRuru said:
  Reveal hidden contents

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 == [email protected] ) {
		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 = [email protected];
	}
	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;
}

 

erm ... its getting interestingly ... complexity ...

@AnnieRuru sorry, what if I add case 2 for 12 hours.

 

Can i Just add these? but im getting infinity loop.

Case 2:
	mes "Retrieving today's half day supplies...";
		for ( [email protected] = 1; [email protected] <= 3; [email protected] ) {
			[email protected] = rand(.totalchance[[email protected]]);
			for ( [email protected] = 3; ( [email protected] -= getd(".twelve"+ [email protected] +"["+ [email protected] +"]") ) >= 0; [email protected] += 2 );
			getitem getd(".twelve"+ [email protected] +"["+( [email protected] -1 )+"]"), rand( getd(".twelve"+ [email protected] +"[0]"), getd(".twelve"+ [email protected] +"[1]") );
		}	
		#daily_twelvet = gettimetick(2);
	}

	close;
}

OnInit:
       setarray .twelve1,
		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 .twelve2,
		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 .twelve3,
		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 ( [email protected] = 1; [email protected] <= 3; [email protected] ) {
		setd ".twelve"+ [email protected] +"size", getarraysize( getd(".twelve"+ [email protected]) );
		for ( [email protected] = 3; [email protected] < getd(".twelve"+ [email protected] +"size"); [email protected] += 2 )
			.totalchance[[email protected]] += getd(".twelve"+ [email protected] +"["+ [email protected] +"]");
		for ( [email protected] = 3; [email protected] < getd(".twelve"+ [email protected] +"size"); [email protected] += 2 ) {
			[email protected] = getd(".twelve"+ [email protected] +"["+ [email protected] +"]") *10000 / .totalchance[[email protected]];
			[email protected] = [email protected] / 100;
			[email protected]$ = .gchance % 100;
			while ( getstrlen([email protected]$) < 2 )
				[email protected]$ = insertchar([email protected]$, "0", 0);
			setd ".chance_display_item"+ [email protected] +"$["+ [email protected] +"]", [email protected] +"."+ [email protected]$ +"%";
		}
	}

	end;
}

 

Edited by MikZ

Share this post


Link to post
Share on other sites
  • 0

can we do this with quest log system instead ?

there is no need to waste a variable ... well, quest log system also support UI

screen2019Hercules032.jpg

problem ? not every server use up to date client version

are you using client version in year 2018 ?
I'm using PACKETVER 20180621

and for your answer, just add *getcalendartime(12,0) something like that on the daily quest log script

if your server using up to date client version, then I could write this script easily with *getcalendartime script command
using outdated client version, then have to hijack another script variable

Edited by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0
19 hours ago, AnnieRuru said:

problem ? not every server use up to date client version

are you using client version in year 2018 ?
I'm using PACKETVER 20180621

and for your answer, just add *getcalendartime(12,0) something like that on the daily quest log script

if your server using up to date client version, then I could write this script easily with *getcalendartime script command
using outdated client version, then have to hijack another script variable

I'm planning to, meantime I'm using 20141022 . Awaiting from AndRO dev how can I update my client in mobile and if it is free.

does 20180621 is stable?

Share this post


Link to post
Share on other sites
  • 0

https://rathena.org/board/topic/114244-andro-for-athena/
the latest AndRO is 20171227, and the new quest log is only for 2018-03-07b onward
use old school method then

https://github.com/AnnieRuru/Release/blob/master/scripts/Utility/daily supply/daily_supply_0.3.txt

 

20180621 is the default version rathena is using right now, so I guess its stable

Edited by AnnieRuru

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.