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"+ [email protected] ) ) {
			mes .npc_name$;
			mes "Item required: ^FFCC00"+ getitemname( getd(".p"+ [email protected] ) ) +"^000000";
			mes "Chance to gain something: ^CC0000"+ getd(".p"+ [email protected] +"[1]" ) +"%^000000";
			mes "Possible gains:";
			for( [email protected] = 3; [email protected] < getarraysize( getd(".p"+ [email protected] ) ); [email protected] +=  3 )
				mes "^0000FFx"+ getd(".p"+ [email protected] +"["+ [email protected] +"]" ) +"^000000 "+ getitemname( getd(".p"+ [email protected] +"["+ ([email protected] -1) +"]" ) ) +" (^CC0000"+ getd(".p"+ [email protected] +"["+ ([email protected] +1) +"]" ) +"%^000000)";
			[email protected]++;
			next;
		}
		break;
	case 3:
		mes .npc_name$;
		mes "Bye!~";
		close;
	}
	mes .npc_name$;
	mes "Which item do you want to use ?";
	next;
	for( [email protected] = 0; getd(".p"+ [email protected] ); [email protected]++ ) {
		[email protected] = getarraysize( [email protected]$ );
		[email protected]$[ [email protected] ] = getitemname( getd(".p"+ [email protected] ) );
		[email protected][ [email protected] ] = [email protected];
	}
	[email protected] = [email protected][ select( implode( [email protected]$, ":" ) ) -1 ];
	while (1) {
		if ( countitem( getd(".p"+ [email protected] ) ) < 1 ) {
			mes .npc_name$;
			mes "it seems you have ran out of "+ getitemname( getd(".p"+ [email protected] ) );
			close;
		}
		mes .npc_name$;
		mes "Here we go...";
		delitem getd(".p"+ [email protected] ), 1;
		if( rand(100) > getd(".p"+ [email protected] +"[1]" ) )// lose
			mes "You got nothing";
		else {
			[email protected] = rand( getd(".totalchance"+ [email protected] ) );
			[email protected] = 1;
			while ( ( [email protected] = [email protected] - getd( ".p"+ [email protected] +"["+ (1+ 3 * [email protected]) +"]" ) ) >= 0 ) [email protected]++;
			getitem getd( ".p"+ [email protected] +"["+ (1+ 3*[email protected] -2) +"]" ), getd( ".p"+ [email protected] +"["+( 1+3*[email protected] -1 )+"]" );
			mes "You got ^FF00CC"+ getd( ".p"+ [email protected] +"["+( 1+3*[email protected] -1 )+"]" ) +" "+ getitemname( getd( ".p"+ [email protected] +"["+ (1+ 3*[email protected] -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"+ [email protected] ) ) {
		for( [email protected] = 4; [email protected] < getarraysize( getd(".p"+ [email protected] ) ); [email protected] += 3 )
			setd ".totalchance"+ [email protected], getd(".totalchance"+ [email protected] ) + getd(".p"+ [email protected] +"["+ [email protected] +"]" );
		[email protected]++;
	}
	
	.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 ([email protected] <= 3) {
	announce(strcharinfo(PC_NAME)+" got "+ getd( ".p"+ [email protected] +"["+( 1+3*[email protected] -1 )+"]" ) +" "+ getitemname( getd( ".p"+ [email protected] +"["+ (1+ 3*[email protected] -2) +"]" ) ) +"!", bc_blue|bc_all);
}

 

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...
Sign in to follow this  

×
×
  • Create New...

Important Information

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