Jump to content
  • 0
Sign in to follow this  
`Azhul

Gacha with announce

Question

Hello everyone, i have this working gacha script of Capuche

I want a little modification on it,  npc will announce when a player got the rare item from 1% to 3% chance.

i hope this is the right place to post this and hope you guys could help me. Thanks in advance

 

tavern,66,37,3	script	Gacha	562,{

	mes .npc_name$;
	mes "Hello, do you want to play the Gatcha??";
	next;
	switch( select( "Play !", "More Informations", "Leave" ) ) {
	case 1:
		break;
	case 2:
		while( getd(".p"+ .@j ) ) {
			mes .npc_name$;
			mes "Item required: ^FFCC00"+ getitemname( getd(".p"+ .@j ) ) +"^000000";
			mes "Chance to gain something: ^CC0000"+ getd(".p"+ .@j +"[1]" ) +"%^000000";
			mes "Possible gains:";
			for( .@i = 3; .@i < getarraysize( getd(".p"+ .@j ) ); .@i +=  3 )
				mes "^0000FFx"+ getd(".p"+ .@j +"["+ .@i +"]" ) +"^000000 "+ getitemname( getd(".p"+ .@j +"["+ (.@i -1) +"]" ) ) +" (^CC0000"+ getd(".p"+ .@j +"["+ (.@i +1) +"]" ) +"%^000000)";
			.@j++;
			next;
		}
		break;
	case 3:
		mes .npc_name$;
		mes "Bye!~";
		close;
	}
	mes .npc_name$;
	mes "Which item do you want to use ?";
	next;
	for( .@j = 0; getd(".p"+ .@j ); .@j++ ) {
		.@size = getarraysize( .@menu$ );
		.@menu$[ .@size ] = getitemname( getd(".p"+ .@j ) );
		.@sel[ .@size ] = .@j;
	}
	.@s = .@sel[ select( implode( .@menu$, ":" ) ) -1 ];
	while (1) {
		if ( countitem( getd(".p"+ .@s ) ) < 1 ) {
			mes .npc_name$;
			mes "it seems you have ran out of "+ getitemname( getd(".p"+ .@s ) );
			close;
		}
		mes .npc_name$;
		mes "Here we go...";
		delitem getd(".p"+ .@s ), 1;
		if( rand(100) > getd(".p"+ .@s +"[1]" ) )// lose
			mes "You got nothing";
		else {
			.@rand = rand( getd(".totalchance"+ .@s ) );
			.@r = 1;
			while ( ( .@rand = .@rand - getd( ".p"+ .@s +"["+ (1+ 3 * .@r) +"]" ) ) >= 0 ) .@r++;
			getitem getd( ".p"+ .@s +"["+ (1+ 3*.@r -2) +"]" ), getd( ".p"+ .@s +"["+( 1+3*.@r -1 )+"]" );
			mes "You got ^FF00CC"+ getd( ".p"+ .@s +"["+( 1+3*.@r -1 )+"]" ) +" "+ getitemname( getd( ".p"+ .@s +"["+ (1+ 3*.@r -2) +"]" ) ) +"^000000";
		}
		mes " ";
		mes "wanna try again ?";
		next;

		if ( select( "Yes", "No" ) == 2 ) close;
	}
	close;

OnInit:
// (item ID need) (chance), (reward 1) (number of reward 1) (chance to gain), (reward 2) (number of reward 2) (chance to gain)...
	setarray .p0, 32130,100,	31731,1,1,	20255,1,2,	31320,1,3,	6320,1,14,	32044,1,14,	7776,1,14,	32041,1,80,	32091,1,80,	32092,1,80,	32093,1,80,	32040,10,80;	// Mithril Coin
	setarray .p1, 32131,100,	19827,1,1,	5335,1,1,	32041,1,28,	32091,1,28,	32092,1,28,	32093,1,28,	32040,1,28,	7517,1,70;	// Gold Coin

	while ( getd(".p"+ .@j ) ) {
		for( .@i = 4; .@i < getarraysize( getd(".p"+ .@j ) ); .@i += 3 )
			setd ".totalchance"+ .@j, getd(".totalchance"+ .@j ) + getd(".p"+ .@j +"["+ .@i +"]" );
		.@j++;
	}
	
	.npc_name$ = "[ "+ strnpcinfo(1) +"]";
	end;
}

 

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

  • 0

Too lazy to understand the whole script, but please try adding this below the line with getitem.

 

if (.@rand <= 3) {
	announce(strcharinfo(PC_NAME)+" got "+ getd( ".p"+ .@s +"["+( 1+3*.@r -1 )+"]" ) +" "+ getitemname( getd( ".p"+ .@s +"["+ (1+ 3*.@r -2) +"]" ) ) +"!", bc_blue|bc_all);
}

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

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