LewL Posted April 28, 2021 Share Posted April 28, 2021 (edited) 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"+ [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; } Edited April 28, 2021 by LewL more info Quote Link to comment Share on other sites More sharing options...
0 Mastagoon Posted May 6, 2021 Share Posted May 6, 2021 Add the option to set a threshold for announcement inside onInit, and then check for it whenever someone wins a reward: OnInit: 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 announce_threshold = 5; // <<<<<<<<<<<<<<< ADD THIS LINE Inside your code: mes "You got ^FF00CC"+ getd( ".p"+ [email protected] +"["+( 1+3*[email protected] -1 )+"]" ) +" "+ getitemname( getd( ".p"+ [email protected] +"["+ (1+ 3*[email protected] -2) +"]" ) ) +"^000000"; if(getd( ".p"+ [email protected] +"["+ (1+ 3*[email protected]) +"]" ) <= .announce_threshold) announce "Player "+strcharinfo(0)+" Has won "+getd( ".p"+ [email protected] +"["+( 1+3*[email protected] -1 )+"]" ) +" "+ getitemname( getd( ".p"+ [email protected] +"["+ (1+ 3*[email protected] -2) +"]" ) )+" From the Gacha!"; Quote Link to comment Share on other sites More sharing options...
0 erick26 Posted May 30, 2021 Share Posted May 30, 2021 Hi I wanted to use this script but i am wondering where to edit the item required to do the gatcha. Quote Link to comment Share on other sites More sharing options...
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"+ [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; }
Edited by LewLmore info
Link to comment
Share on other sites