//===== Athena Script ========================================
//= Disguise Event NPC
//===== By: ==================================================
//= Masao
//===== Current Version: =====================================
//= 2.0
//===== Compatible With: =====================================
//= eAthena SVN
//===== Description: =========================================
//= Disguise Event
//===== Additional Comments: =================================
//= Version 1.0 if there are any Bugs please let me know.
//= Version 1.2 Added Check if someone already guessed the Monster Name.
//= Version 1.5 Fixed so the NPC will display it's originial View ID when the Event ends.
//= Version 2.0 Changed some Global / Temporary Variables into NPC Variables.
//============================================================

-	script	DAnnouncer#12345	-1,{
OnClock0300:
OnClock0700:
OnClock1100:	
OnClock1500:
OnClock1900:
OnClock2300:
OnStart:
	announce "The [Disguise Event] will be starting in 30 seconds.",0;
	sleep 30000;
	donpcevent "Disguise#12345::OnStart";
	announce "The [Disguise Event] starts now!",0;
	end;
}

quiz_02,305,245,4	script	Disguise#12345	795,{
	set .@n$,"[^0000FFDisguise NPC^000000]";
	if (getgmlevel() < 60) {
		mes .@n$;
		mes "Hi, how can i help you?";
		next;
		menu "How does it work?",-,"Cancel.",L_Cancel;

		mes .@n$;
		mes "This is an very easy Event.";
		mes "At the beginning of the Event i will disguise myself into a randomly chosen Monster.";
		mes "After i've done that, you've to put the correct Name into the Box.";
		next;
		mes "If the name was correct, you win a Prize! if it was wrong, just try again ;)";
		mes "And that's it! Good luck.";
		close;
	}
L_DisguiseAdmin:
	mes .@n$;
	mes "^FF0000~Hi "+strcharinfo(0)+", what can i do for you?~^000000";
	switch(select(((!$startdisguise)?"Start Event":"End Event")+":Check Prize:Set Prizes:Rounds:Nothing")) {
		case 1:
			next;
			mes .@n$;
			mes "Would you like to "+(($startdisguise)?"End":"Start")+" the Event now?";
			next;
			if(select("Yes:No")==1) {
				if ($startdisguise) {
					set .Monster,0;
					set .MonsterName$,"";
					set .Round,0;
					set .disguisewin,0;
					set $startdisguise,0;
					setnpcdisplay "Disguise Event",795;
					announce "The [Disguise Event] has been ended by an GM! There will be no prizes!",0;
				} else donpcevent "DAnnouncer#12345::OnStart";
				close;
			}
			break;
		case 2:
			next;
			mes .@n$;
			mes "^FF0000~The current winning Prize is ^000000 ^008000"+$prize_item_amount+" "+getitemname($prize_item_id)+".^000000";
			next;
			goto L_DisguiseAdmin;
		case 3:
			next;
			mes .@n$;
			mes "^FF0000~What should the Prize be? Please insert the Item ID.~^000000";
			input $prize_item_id;
			next;
			mes .@n$;
			mes "^FF0000~Now the amount?~^000000";
			input $prize_item_amount;
			next;
			mes .@n$;
			mes "^FF0000~So, the Prize is^000000 ^008000"+$prize_item_amount+" "+getitemname($prize_item_id)+"^000000? ^FF0000Great.~^000000";
			emotion 33;
			next;
			goto L_DisguiseAdmin;
		case 4:
			next;
			mes .@n$;
			mes "Here you can set how many Rounds will be played each time the Event Starts";
			input $Rounds;
			next;
			mes "^FF0000~So, there will be ^FF0000"+$Rounds+" Rounds played.^000000";
			next;
			goto L_DisguiseAdmin;			
		case 5:
			break;
	}
	next;
	mes .@n$;
	mes "Ok, bye.";
	close;

OnStart:
	set .Monster,1000+rand(1,323);
	set .MonsterName$,getmonsterinfo(.Monster,0);
	set .Round,0;
	set .disguisewin,0;
	set $startdisguise,1;
	deletepset 1;
	defpattern 1,"([^:]+):.\\s*"+.MonsterName$+".*", "L_Correct";
	activatepset 1;
	setnpcdisplay "Disguise Event",.Monster;
	initnpctimer;
	end;

OnTimer15000:
	stopnpctimer;
	set .dfk,1;
	goto L_Correct;
	end;

L_Correct:
	if (!.dfk) {
		set .disguisewin,1;
		mapannounce "quiz_02",""+strcharinfo(0)+" won! I was disguised as: "+.MonsterName$+"",0;
		if (!$prize_item_id) npctalk "Sorry there are no prizes."; else getitem $prize_item_id,$prize_item_amount;
	}
	set .dfk,0;
	set .Round,.Round+1;
	if (.Round<$Rounds) goto L_Round;
	set $startdisguise,0;
	setnpcdisplay "Disguise Event",795;
	npctalk "Thank you all for playing. That was the last round of the Disguise Event. See you next time.";
	end;

L_Round:
	set .Disguise_Delay,gettimetick(2)+5;
	set .Monster,1000+rand(1,323);
	set .MonsterName$,getmonsterinfo(.Monster,0);
	set .disguisewin,0;
	setnpcdisplay "Disguise Event",.Monster;
	deletepset 1;
	defpattern 1,"([^:]+):.\\s*"+.MonsterName$+".*", "L_Correct";
	activatepset 1;
	initnpctimer;
	end;

L_Cancel:
	close;
	
OnInit:
	set $startdisguise,0;
	end;
}