//==========================================================
//Roll a Dice  NPC
//==========================================================
//Made by birkiczd
//==========================================================
//This game lets you and the Dicer throw 3 dices.
//Whoever get's a higher number (the player or dealer) wins.
//==========================================================
//Version:1.0 - made script public
//        1.1 - fixed a few bugs,added dice emos =)
//        1.2 - made variables for the amount of zenys for 
//	          each bet so it is easy for people to costumize 
//              the script
//	    1.3 - added more emoticons,made an Info menu 
//		    option which contains explanations and rules,
//		    added the amount of lost/won zeny on the end 
//		    of each game,added more colors
//	    1.4 - some small code optimization thanks to Myzter             
//==========================================================


cmd_in02.gat,181,98,2	script	Dicer	57,{

//These variables allow you to set the amount of zeny people can bet
set @betzeny1,500; //500 zeny
set @betzeny2,1000; //1000 zeny
set @betzeny3,2000; //2000 zeny
set @betzeny4,10000; //10000 zeny

//Variable for the number guess zeny bet
set @betnum, 1000; //1000 Zeny

	
	mes "[Dicer]";
	mes "Welcome to the Revolution Dice Game.You wanna check your luck with dices?Remember I am the dice expert and rarely someone was able to beat me.";
	next;
	mes "[Dicer]";
	mes "What would you like to do?";
	next;
	menu "Play",L_play,"Info",L_info,"Go away",L_go;

L_go:
	mes "[Dicer]";
	mes "Please come again when you are ready.";
	close;

L_info:
	mes "[Dicer]";
	mes "Please choose one of the following options for more informations:";
	next;
	menu "Main Rules",L_main,"Bets and Wins",L_bet,"Extra Games",L_extra,"Go away",L_go;

L_main:
	mes "[Dicer]";
	mes "^0080FFRoll A Dice^000000 is a very simple game.The game allows you and the NPC to throw 3 dices.Whoever gets a higher total number wins.";
	next;
	goto L_info;

L_bet:
	mes "[Dicer]";
	mes "You have 4 zeny amounts to choose for your bet.If you choose a high bet your win will also be higher,it is that simple.Also various extra games can increase your win.";
	next;
	mes "[Dicer]";
	mes "Example:";
	mes "^0080FFBet^000000         ^0080FFWin^000000";
	mes "500       1000";
	mes "1000     2000";
	mes "2000     4000";
	mes "10000   20000";
	next;
	goto L_info;

L_extra:
	mes "[Dicer]";
	mes "You can also try increasing your win by playing extra games like guessing your total number at the end of the game.It will cost you an extra amount of zeny but if you guess the number your win will be tripled instead of doubled.";
	next;
	goto L_info;
	  
L_play:
	mes "[Dicer]";
	mes "Ok,please choose the amount of zeny you want to bet:";
	next;
	menu ""+@betzeny1+" Zeny",L_zeny1,""+@betzeny2+" Zeny",L_zeny2,""+@betzeny3+" Zeny",L_zeny3,""+@betzeny4+" Zeny",L_zeny4,"Too rich for my blood...",L_go;

	L_zeny1:
		if(Zeny < @betzeny1) goto L_nzeny;
		set @bet, @betzeny1;
		goto L_gamea;
	L_zeny2:
		if(Zeny < @betzeny2) goto L_nzeny;
		set @bet, @betzeny2;
		goto L_gamea;
	L_zeny3:
		if(Zeny < @betzeny3) goto L_nzeny;
		set @bet, @betzeny3;
		goto L_gamea;
	L_zeny4:
		if(Zeny < @betzeny4) goto L_nzeny;
		set @bet, @betzeny4;
		goto L_gamea;

L_nzeny:
	mes "[Dicer]";
	emotion 20;
	mes "Sorry but it seems you don't have enough zeny!";
      close;

L_gamea:
	mes "[Dicer]";
	mes "Would you like to try to increase your win by trying to guess the number you will get?";
	mes "It will cost you another ^0080FF"+@betnum+"^000000 zeny.";
	next;
	menu "Yes",L_gamec,"No",L_gameb;

L_gamec:
	if(Zeny < @betnum + @bet) goto L_nzeny;
	mes "[Dicer]";
	mes "Please input the number you think you will get (3-18).";
	input @numg;
	if(@numg<3) message strcharinfo(0),"Number is too low, input again.";
	if(@numg>18) message strcharinfo(0),"Number is too high, input again.";
	if(@numg<3||@numg>18) goto L_gamec;
	set Zeny, Zeny - @betnum;
	next;
	goto L_gameb;

L_gameb:

	set @dea1, rand(1,6);
	set @dea2, rand(1,6);
	set @dea3, rand(1,6);
	set @pla1, rand(1,6);
	set @pla2, rand(1,6);
	set @pla3, rand(1,6);
	set @deatot, @dea1+@dea2+@dea3;
	set @platot, @pla1+@pla2+@pla3;

	mes "[Dicer]";
	mes "I will be the first one to roll the dices,and after that you will throw them.I am feeling lucky today, so you better go away before I take every zeny you have.";
	next;
	mes "[^0080FFDicer 1st Turn^000000]";
	mes "Throwing first dice!";
	mes ".....roll.....roll....roll....";
	emotion 58;
	mes " ";
	mes "First throw: ^0080FF"+@dea1+" ^000000";
	next;
	mes "[^0080FFDicer 2nd Turn^000000]";
	mes "Throwing second dice!";
	emotion 58;
	mes ".....roll.....roll....roll....";
	mes " ";
	mes "Second throw: ^0080FF"+@dea2+" ^000000";
	next;
	mes "[^0080FFDicer 3rd Turn^000000]";
	mes "Throwing third dice!";
	emotion 58;
	mes ".....roll.....roll....roll....";
	mes " ";
	mes "Third throw: ^0080FF"+@dea3+" ^000000";
	next;
	mes "[Dicer]";
	mes "Now it's your turn to throw the dices.I bet you can't get higher numbers then me.";
	next;
	mes "[^0080FFPlayer 1st Turn^000000]";
	mes "Throwing first dice!";
	mes ".....roll.....roll....roll....";
	emotion 58;
	mes " ";
	mes "First throw: ^0080FF"+@pla1+" ^000000";
	next;
	mes "[^0080FFPlayer 2nd Turn^000000]";
	mes "Throwing second dice!";
	emotion 58;
	mes ".....roll.....roll....roll....";
	mes " ";
	mes "Second throw: ^0080FF"+@pla2+" ^000000";
	next;
	mes "[^0080FFPlayer 3rd Turn^000000]";
	mes "Throwing third dice!";
	emotion 58;
	mes ".....roll.....roll....roll....";
	mes " ";
	mes "Third throw: ^0080FF"+@pla3+" ^000000";
	next;
      mes "[Dicer]";
	mes "Let's look at our total numbers:";
	mes " ";
	mes "Dicer Total: ^0080FF"+@deatot+" ^000000.";
	mes "Player Total: ^0080FF"+@platot+" ^000000.";
	next;
 	if (@platot < @deatot) goto L_lose;
	if (@platot == @deatot) goto L_again;
	if (@platot > @deatot && @platot == @numg) goto L_win2;
	if (@platot > @deatot) goto L_win1;

L_lose:
	mes "[Dicer]";
	set Zeny, Zeny - @bet;
	emotion 39;
	mes "I got a higher number!!!";
	mes "See I told you nobody can beat me!";
	mes " ";
	mes "You lost ^0080FF"+@bet+"^000000 Zeny.";
	next;
	goto L_againa;
	
L_again:
	mes "[Dicer]";
	emotion 54;
	mes "It seems it's a draw.Let's play again.";
	next;
	goto L_play;

L_win1:
	mes "[Dicer]";
	set Zeny, Zeny + @bet*2;
	set @wona, @bet*2;
	emotion 36;
	mes "I can't belive I lost. Here take your money.";
	mes " ";
	mes "You won ^0080FF"+@wona+"^000000 Zeny.";
	next;
	goto L_againa;

L_win2:
	mes "[Dicer]";
	set Zeny, Zeny + @bet*3;
	set @wonb, @bet*3;
	emotion 36;
	mes "You even guessed the total number you got.I can't belive I lost. Here is your money.";
	mes " ";
	mes "You won ^0080FF"+@wonb+"^000000 Zeny.";
	next;
	goto L_againa;

L_againa:
	mes "[Dicer]";
	mes "Would you like to play again?";
	next;
	menu "Yes",L_play,"No",L_go;

 
}
