Jump to content
  • 0

Gacha with announce


LewL

Question


  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.02
  • Content Count:  84
  • Reputation:   1
  • Joined:  01/08/20
  • Last Seen:  

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 ❤️

Gatcha.txt

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;
}

 

Edited by LewL
more info
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  63
  • Reputation:   35
  • Joined:  07/04/19
  • Last Seen:  

 

Add the option to set a threshold for announcement inside onInit, and then check for it whenever someone wins a reward:

OnInit:

setarray .p132131,100,   19827,1,1,  5335,1,1,   32041,1,2832091,1,2832092,1,2832093,1,2832040,1,287517,1,70;  // Gold Coin
announce_threshold = 5;        // <<<<<<<<<<<<<<< ADD THIS LINE
 
Inside your code:
mes "You got ^FF00CC"getd".p".@s +"["+( 1+3*.@r -1 )+"]" ) +" "getitemnamegetd".p".@s +"["+ (13*.@r -2) +"]" ) ) +"^000000";
 if(getd".p".@s +"["+ (13*.@r) +"]" ) <= .announce_threshold
        announce "Player "+strcharinfo(0)+" Has won "+getd".p".@s +"["+( 1+3*.@r -1 )+"]" ) +" "getitemnamegetd".p".@s +"["+ (13*.@r -2) +"]" ) )+" From the Gacha!";
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.01
  • Content Count:  24
  • Reputation:   0
  • Joined:  02/08/21
  • Last Seen:  

Hi I wanted to use this script but i am wondering where to edit the item required to do the gatcha.

Link to comment
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.   Paste as plain text instead

  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.

×
×
  • Create New...