//===== 15-3athena Script ====================================
//= Kagerou/Oboro Job Change Quest
//===== By: ================================================== 
//= M45T3R, Dastgir Pojee
//===== Current Version: ===================================== 
//= 1.0
//===== Description: ========================================= 
//= Kagerou/Oboro Job Change NPCs
//===== Additional Comments: ================================= 
//= 1.0 Cleaned UP the scripts a bit and added to 15-3athena. [15peaces]
//=     Thanks to M45T3R & Dastgir Pojee. Original version:
//=     https://github.com/M45T3Ryu/KO-Proyect/
//============================================================

//Kagerou/Oboro Job Change NPC
que_ng,28,156,1	script	Start#ko	139,1,1,{
OnTouch:
	if (BaseJob==Job_Ninja && BaseLevel > 98 && JobLevel > 69 && job_kagero==0){
		mes "Secret Passage to ^25C18DNinja Guild^25C18D";
		mes "You hear familiar voices talking to each other.";
		next;
		mes "[Unknown Voice A]";
		mes "Long time, no see. How are you? How are the kids you've taken in?";
		next;
		mes "[Unknown Voice B]";
		mes "I have to hand it to you. You've picked some competitive ones.";
		next;
		mes "[Unknown Voice A]";
		mes "Sounds like music to my ears. Being sent to a foreign land with air pollution was bad enough, now haunted with memories of this place...";
		next;
		mes "[Unknown Voice A]";
		mes "What do you think? Should we rotate now?";
		next;
		mes "[Unknown Voice B]";
		mes "Haven't given up, have ya. Do you really think he'll approve?";
		next;
		mes "[Unknown Voice A]";
		mes "No need to be bitter. Hey! Were any of the kids that come and go here the ones that found the ^BD0408place^BD0408?";
		next;
		mes "[Unknown Voice B]";
		mes "Since finding the hidden place was also a part of the test.";
		next;
		mes "[Unknown Voice A]";
		mes "You are as stubborn as the first time I met you. It's just a wall in some place...";
		next;
		mes "[Unknown Voice B]";
		mes "Shssh! I think someone is eavesdropping. Hurry! Go back to the mission area.";
		next;
		mes "The conversation stopped abruptly. Hidden place? Wall? Part of a test? What is all this about?";
		setquest 5131;	//Strange Conversation
		set job_kagero,1;
		set KO_QD,0;
		close;
	}else if (BaseJob!=Job_Ninja){
		for (set .i,5131; .i<5147; set .i,.i+1 ){
			if (checkquest(.i) != -1){erasequest .i;}
		}
		set job_kagero,0;
		warp "amatsu",147,136;
		end;
	}
	end;
}

que_ng,10,183,1	warp	warp#ko	1,1,que_ng,33,64	//Warp in que_ng

que_ng,21,76,1	script	Wall with a Drawing#ko	844,{
	if (Class == Job_Kagerou || Class == Job_Oboro){
		mes "You should no longer use this secret passage";
		close;
	}else if(job_kagero == 1 && Class == Job_Ninja){
		mes "You found a location that resembles the hidden place.";
		next;
		mes "This wall was here ever since. How come I didn't notice it before?";
		next;
		mes "Now that I know it's a secret passage, what do I do to get in?";
		next;
		if(select("Tear the drawing down.:Touch the drawing with your hand.")==1){
				mes "I can't rip it down because I don't own it.";
				close;
		}
		mes "You touch the drawing with the tip of your hand and felt a sudden sensation of being pulled.";
		close2;
		warp "job_ko",26,111;
		end;
	}else if (job_kagero > 0 && BaseJob == Job_Ninja){
		mes "Entrance to the ^25C18DNinja Guild^000000 hideout.";
		next;
		if(select("Enter.:Do not enter.") == 1){
			close2;
			warp "job_ko",26,111;
			end;
		}
		close;
	}else{
		mes "There is a wall with a great drawing on it.";
		close;
	}
}

job_ko,25,115,4	script	Old Man#ko	588,{
	function KO_IB; function KO_QS;
	if (BaseJob != Job_Ninja && job_kagero>0){
		for (set.i,5131; .i<5147; set .i,.i+1){
			if (checkquest(.i) != -1){erasequest .i;}
		}
		set job_kagero,0;
		mes "[Cougar]";
		mes "You are not in Family of Ninja.";
		close2;
		warp "amatsu",147,136;
		end;
	}

	if (job_kagero==1){
		cutin "job_ko03",2;
		mes "^1A95E6An old man looking hale and hearty is sitting and gazing vacantly.^1A95E6";
		next;
		switch(select("Ignore.:Talk to him.")){
			case 1: close2; cutin "",255; end;
			case 2:
				mes "["+strcharinfo(0)+"]";
				mes "Excuse me...";
				next;
				mes "^1A95E6You tried to talk to the old man but there is no response. Just when you are about to turn away...^1A95E6";
				next;
				mes "[Old Man]";
				mes "At last, a customer! Hmm... and a live one, too!";
				select("Excuse me... where am I?");
				next;
				mes "[Old Man]";
				mes "^1A95E6He keeps talking and doesn't stop to answer your question.^1A95E6";
				next;
				mes "[Old Man]";
				mes "There once was a quiet family living in ancient Amatsu times that is never mentioned in history books or stories.";
				next;
				mes "[Old Man]";
				mes "They lived beneath shadows but always yearned for the bright sun, like a sunflower.";
				next;
				mes "[Old Man]";
				mes "A family that was loyal to their lord who they served as their bright sun.";
				next;
				mes "[Old Man]";
				mes "...a very trustworthy family...";
				next;
				mes "[Old Man]";
				mes "....loyal to their core...";
				next;
				mes "[Old Man]";
				mes "...a family of integrity...";
				next;
				select("What happened to them?");
				mes "^1A95E6The old man looks at you with a melancholy face.^1A95E6";
				next;
				mes "[Old Man]";
				mes "Why are you interested in a family that was abandoned by their lord and disappeared from history itself?";
				next;
				switch(select("I'm a Ninja.:I'm bored.")){
					case 1:
						cutin "job_ko02",2;
						mes "[Old Man]";
						mes "Ninja! There was a time when the family was called ninjas, too.";
						next;
						changequest 5131,5132;	//Family Business-(1)
						mes "[Old Man]";
						mes "You'll have to lend me your ear for I have so much to tell you about the family story.";
						set job_kagero,2;
						close2;
						cutin "",255;
						end;
					case 2:
						mes "[Old Man]";
						mes "Was nice to meet you.";
						close2;
						cutin "",255;
						warp "amatsu",147,136;
						end;
				}
		}
	} else if (job_kagero == 2){
		cutin "job_ko01",2;
		mes "^1A95E6The Old Man starts the story with a very soothing tone as if he is telling his grandchild a story.^1A95E6";
		next;
		mes "[Old Man]";
		mes "This goes way back to ancient times and nobody in Amatsu remembers about it.";
		next;
		mes "[Old Man]";
		mes "The family worked behind the scenes and basically lived their lives for their lord.";
		next;
		mes "[Old Man]";
		mes "They were very loyal doing whatever deed their lord asked for.";
		next;
		mes "[Old Man]";
		mes "Ninja, the family was known as the dark family but that doesn't mean they wanted to be hidden in the darkness.";
		next;
		mes "[Old Man]";
		mes "They were loyal enough to be satisfied as the lord's servants but their loyalty became the problem.";
		next;
		select("Problem?");
		mes "[Old Man]";
		mes "They are a secret organization that even the lord didn't know much about.";
		next;
		mes "[Old Man]";
		mes "The few that knew about the family's existence, tried to investigate them but nobody was able to reveal their true identity.";
		next;
		mes "[Old Man]";
		mes "That is why this family has grown from loyal servants to a group feared for its secrets.";
		next;
		mes "[Old Man]";
		mes "The lord shunned the family and didn't call them for their service any more but they never betrayed him.";
		next;
		select("They were really loyal people.");
		cutin "job_ko03",2;
		mes "[Old Man]";
		mes "Yes, they were. Very loyal.";
		next;
		set job_kagero,3;
		changequest 5132,5133;	//Family Business-(2)
		mes "^1A95E6The old man looks even more forlorn.^1A95E6";
		close2;
		cutin "",255;
		end;
	} else if (job_kagero == 3){
		cutin "job_ko03",2;
		mes "[Old Man]";
		mes "The family has been living in hiding for so long since the old days. The current lord didn't even know of their existence.";
		next;
		select(".........");
		cutin "job_ko01",2;
		mes "[Old Man]";
		mes "I'm Guide Gion, the last of the dark ninja family.";
		next;
		switch(select("I think your time has ended.:I need your teaching.")){
			case 1:
				cutin "job_ko04",2;
				mes "[Guide Gion]";
				mes "Are you an assassin to end this old man's life?";
				next;
				mes "[Guide Gion]";
				mes "So that is why you've shown interest in my family. I won't give up easily.";
				next;
				percentheal -99,0;
				mes "Pow!!";
				mes "^1A95E6You lose conscience with the great impact.^000000";
				close2;
				cutin "",255;
				warp "amatsu",147,136;
				end;
			case 2:
				cutin "job_ko02",2;
				mes "[Guide Gion]";
				mes "Teaching...";
				mes "Been a long time since I last heard that word.";
				next;
				mes "[Guide Gion]";
				mes "I guess this little visit was not by coincidence but a start of a connection.";
				next;
				mes "[Guide Gion]";
				mes "Sorry I am not a teacher. But!";
				next;
				mes "[Guide Gion]";
				mes "I can help you on the path you've chosen, the ^33CC71"+((Sex)?"Kagerou":"Oboro")+"^000000 path.";
				next;
				mes "^1A95E6You hear Guide Gion's voice faintly as you slip away.^1A95E6";
				next;
				set job_kagero,4;
				changequest 5133,5134;	//New path
				mes "[Guide Gion]";
				mes "If you are prepared to follow me, Guide Gion, on the "+((Sex)?"Kagerou":"Oboro")+" path, we will meet again.";
				close2;
				cutin "",255;
				warp "amatsu",147,136;
				end;
		}
	}else if (job_kagero == 4){
		cutin "job_ko02",2;
		mes "[Guide Gion]";
		mes "I thought you were afraid of the ^33CC71path of the "+((Sex)?"Kagerou":"Oboro")+"^33CC71 and wouldn't come back.";
		next;
		mes "[Guide Gion]";
		mes "But from the look of your eyes, I guess I misjudged you.";
		next;
		mes "[Guide Gion]";
		mes "You will have to train your mind and body to walk steadily in the unknown world and never fall into temptation to stay on the path.";
		next;
		mes "[Guide Gion]";
		mes "Our ancestors had 4 tests to train our people.";
		next;
		select("4 tests?");
		cutin "job_ko01",2;
		mes "[Guide Gion]";
		mes "Yes, there are 4 tests.";
		mes "My ancestors trained my people with 4 tests that involve ^087FF8knowledge^000000, ^087FF8survival^000000, ^087FF8weapons^000000, and ^087FF8battle^000000.";
		next;
		mes "[Guide Gion]";
		mes "I know you are curious what these tests are. Let me explain one by one.";
		while (1) {
			if (KO_Q&1 && KO_Q&2 && KO_Q&4 && KO_Q&8){
				cutin "job_ko02",2;
				changequest 5134,5135;	//4 tests
				set job_kagero,5;
				next;
				mes "[Guide Gion]";
				mes "Let's start right away after you are done with preparations.";
				close2;
				cutin "",255;
				end;
			}
			next;
			switch(select("Test of Knowledge:Test of Survival:Test of Weaponry:Test of Battle")){
				case 1:
					mes "[Guide Gion]";
					mes "We need to be knowledgeable in order to assist the lord. This test is for this purpose.";
					next;
					mes "[Guide Gion]";
					mes "You can pass the test if you successfully solve more than 9 out of 10 questions.";
					next;
					mes "[Guide Gion]";
					mes "The test will be easy to pass if you've been steady in your studies. Now what other test are you curious about?";
					set KO_Q,KO_Q|1;
					break;

				case 2:
					mes "[Guide Gion]";
					mes "Missions aren't always easy and safe. That is why survival instincts are vital to us.";
					next;
					mes "[Guide Gion]";
					mes "My ancestors call this test the dice test. It is a test to advance forward depending on the dice results.";
					next;
					mes "[Guide Gion]";
					mes "Think of it as the simple dice games people play.";
					next;
					mes "[Guide Gion]";
					mes "But never let your guard down during the test because it isn't called the survival test for nothing.";
					next;
					mes "[Guide Gion]";
					mes "There will be blocks that help you while there are blocks that will interrupt you.";
					next;
					mes "[Guide Gion]";
					mes "If you deal with various situations wisely, you will be able to pass the test. Now what other test are you curious about?";
					set KO_Q,KO_Q|2;
					break;

				case 3:
					mes "[Guide Gion]";
					mes "My family was famous for using unique weapons that we created.";
					next;
					mes "[Guide Gion]";
					mes "You would be considered blessed if you created your own unique weapon.";
					next;
					mes "[Guide Gion]";
					mes "Creating a weapon for yourself and refining it is the purpose of this test.";
					next;
					mes "[Guide Gion]";
					mes "I hope you will be blessed and find the best weapon for yourself. Now what other test are you curious about?";
					set KO_Q,KO_Q|4;
					break;

				case 4:
					mes "[Guide Gion]";
					mes "Missions are not always done alone. You will often work in teams of 2 or 3 for a common goal.";
					next;
					mes "[Guide Gion]";
					mes "The battle test is only for those that pass that knowledge, survival and weapon tests. So! It is the very last test.";
					next;
					mes "[Guide Gion]";
					mes "Unlike the other three tests that are done alone, you will have to compete with others in this final test.";
					next;
					mes "[Guide Gion]";
					mes "There is only one target!!";
					mes "And only the first to get to the target passes the test.";
					next;
					mes "[Guide Gion]";
					mes "You'll be lucky if you have no competitors during your test.";
					next;
					mes "[Guide Gion]";
					mes "A challenge is better than explaining it a hundred times. It's the actual experience that makes you better.";
					set KO_Q,KO_Q|8;
					break;
			}
		}
	} else if (job_kagero == 5){
		if (checkquest(5137) == 1){KO_IB(2);}
		else if (checkquest(5136) == 1){KO_IB(1);}
		else if (checkquest(5138) == 1){KO_IB(3);}
		else if (checkquest(5146) == 1){mes "[Guide Gion]"; mes "Weren't you taking the Test of Battle Now?"; if (select("I want to go back to test site.:Ah... no.")==1){KO_IB(4);}else{cutin "",255; close;}}
		else{
			if (KO_QD&1 && KO_QD&2 && KO_QD&4){	//All Test Completed
				cutin "job_ko01",2;
				mes "[Guide Gion]";
				mes "You've gone through three tests leaving only one to pass.";
				next;
				mes "[Guide Gion]";
				mes "As I've told you before, the last test is different because you have to compete against others.";
				select("Will you continue the Story?");
				cutin "job_ko02",2;
				next;
				mes "[Guide Gion]";
				mes "Ha ha ha. I will finish the story.";
				next;
				mes "[Guide Gion]";
				mes "Kagerou, warrior like the dancing flames of the sun";
				next;
				mes "[Guide Gion]";
				mes "Oboro, warrior like the misty moonlight";
				next;
				mes "[Guide Gion]";
				mes "It is told that the man that earned the loyalty of the two warriors was a humorous person.";
				next;
				mes "[Guide Gion]";
				mes "He like the jokes and conversations better than quarrels and he liked women over men.";
				next;
				mes "[Guide Gion]";
				mes "Hmm... I don't know why this part of the story was kept alive all these years but this man wanted to bring these two warriors together.";
				next;
				mes "[Guide Gion]";
				mes "Both warriors did travel together after the war but kept an awkward distance from each other.";
				next;
				mes "[Guide Gion]";
				mes "They must have had their reasons but their lord would send them out to a difficult mission together, put them in a secret room together and all sorts of situations together.";
				select("Sounds like an odd person.");
				next;
				mes "[Guide Gion]";
				mes "Yes, he was. And his efforts didn't go in vain since the two warriors eventually got acquainted and married.";
				next;
				mes "[Guide Gion]";
				mes "This is how the family started.";
				select("What happened after?");
				next;
				mes "[Guide Gion]";
				mes "Sadly, the next part of story was purposely discontinued.";
				next;
				mes "[Guide Gion]";
				mes "I think it's because someone wanted us to let go of the past and move forward.";
				next;
				mes "[Guide Gion]";
				mes "That's that. Now shouldn't you be preparing for the last test?";
				next;
				mes "[Guide Gion]";
				mes "But you must be tired from all the tests so far. Take a rest.";
				set KO_QD,KO_QD+8;
				set job_kagero,6;
				close2;
				cutin "",255;
				end;
			} else if ( (KO_QD&1 && KO_QD&2)||(KO_QD&1 && KO_QD&4)||(KO_QD&2 && KO_QD&4) ){	//2 Test Completed
				cutin "job_ko04",2;
				if (KO_QD&1 && KO_QD&2){set .KO_RE$,"Weaponry";}else if(KO_QD&1 && KO_QD&4){set .KO_RE$,"Survival";}else{set .KO_RE$,"Knowledge";}
				mes "[Guide Gion]";
				mes "You've Passed the "+((KO_QD&1 && KO_QD&2)?"Test of Knowledge and Survival":((KO_QD&1 && KO_QD&4)?"Test of Knowledge and Weaponry":"Test of Survival and Weaponry"))+".";
				next;
				mes "[Guide Gion]";
				mes "You are already done with two tests. Hope you've learned a lot from them.";
				next;
				cutin "job_ko01",2;
				mes "[Guide Gion]";
				mes "Shall we continue with the story?";
				next;
				mes "[Guide Gion]";
				mes "Kagerou, warrior like the dancing flames of the sun";
				next;
				mes "[Guide Gion]";
				mes "Oboro, warrior like the misty moonlight";
				next;
				mes "[Guide Gion]";
				mes "I think I left off when the two warriors met at the battlefield as enemies.";
				next;
				mes "[Guide Gion]";
				mes "The long war ended eventually but the wounds and pain of those that survived had just started.";
				next;
				mes "[Guide Gion]";
				mes "So these two warriors started to embrace and heal the war wounds together and became one.";
				next;
				mes "[Guide Gion]";
				mes "There is a backstory of a man appearing in front of them and winning the loyalty from both warriors.";
				next;
				select("Who is this man?");
				mes "[Guide Gion]";
				mes "There isn't much known about this man. Only a short mentioning of the two warriors pledging their allegiance.";
				next;
				mes "[Guide Gion]";
				mes "Maybe current generations like me are the ancestors of the current Amatsu lord? But this is only an assumption.";
				next;
				mes "[Guide Gion]";
				mes "I'm almost at the end of my family story. Come back after you've passed the third test and I will tell you the rest.";
				next;
				mes "[Guide Gion]";
				mes "Your third test is the Test of "+.KO_RE$+".";
				next;
				if (KO_QD&1 && KO_QD&2){KO_QS(3,3);}else if(KO_QD&1 && KO_QD&4){KO_QS(2,3);}else{KO_QS(1,3);}
				close;
			} else if (KO_QD&1 || KO_QD&2 || KO_QD&4) {	//Only 1 Test Completed.
				cutin "job_ko01",2;
				mes "[Guide Gion]";
				mes "You've Passed the "+((KO_QD&1)?"Test of Knowledge":((KO_QD&2?"Test of Survival":"Test of Weaponry")))+".";
				next;
				mes "[Guide Gion]";
				if (KO_QD&4){mes "I wonder if Joe is satisfied with your performance";}
				else if (KO_QD&2){mes "Looks like you went through hell with this test";}
				else{mes "My friend doesn't approve of others that easily but I guess he liked you.";}
				next;
				select("Please continue with the family story.");
				cutin "job_ko02",2;
				mes "[Guide Gion]";
				mes "Looks like you are pretty eager to hear more. Where did I leave off... Ah! I remember.";
				next;
				mes "[Guide Gion]";
				mes "Kagerou, warrior like the dancing flames of the sun";
				next;
				mes "[Guide Gion]";
				mes "Oboro, warrior like the misty moonlight";
				next;
				mes "[Guide Gion]";
				mes "Both warriors weren't close at first, because personality and everything else was completely opposite of each other.";
				next;
				mes "[Guide Gion]";
				mes "The first place they met was the battlefield. And you know how enemies greet each other on a battlefield.";
				next;
				mes "[Guide Gion]";
				mes "They ended up injuring each other badly.";
				next;
				mes "[Guide Gion]";
				mes "But what can you do? War is a war.";
				next;
				mes "[Guide Gion]";
				mes "The friend you've laughed with yesterday is a foe that you have to fight with in a war today.";
				next;
				mes "[Guide Gion]";
				mes "So nobody can get along with anyone during a war.";
				next;
				mes "[Guide Gion]";
				mes "I'll continue the story after you pass another test.";
				next;
				mes "[Guide Gion]";
				mes "Which test will you choose for the second test?";
				if (KO_QD&1){ set @menu,select("Test of Survival:Test of Weaponry"); set @menu,@menu+1;}
				if (KO_QD&2){ set @menu,select("Test of Knowledge:Test of Weaponry"); if (@menu==2){set @menu,3;}}
				if (KO_QD&4){ set @menu,select("Test of Knowledge:Test of Survival");}
				next;
				KO_QS(@menu,2);
				close;
			}else{
				cutin "job_ko03",2;
				mes "[Guide Gion]";
				mes "It's been a while.";
				next;
				mes "[Guide Gion]";
				mes "Since I felt happy like this. I feel young and energetic seeing young people like you challenge themselves with a new path.";
				next;
				mes "[Guide Gion]";
				mes "We're done with explaining about the tests, now should I tell you my family story?";
				next;
				cutin "job_ko01",2;
				mes "[Guide Gion]";
				mes "My family started from two warriors.";
				next;
				mes "[Guide Gion]";
				mes "Kagerou a warrior like the dancing flames of the sun.";
				next;
				mes "[Guide Gion]";
				mes "Oboro a warrior like the misty moonlight.";
				next;
				mes "[Guide Gion]";
				mes "The Sun and the Moon.";
				mes "The sunlight that lights up the world and the moonlight that lights up the night. Both were very similar but different warriors.";
				next;
				mes "[Guide Gion]";
				mes "There was a time there was an enmity between both warriors.";
				next;
				mes "[Guide Gion]";
				mes "But it didn't take long for them to become one as a family.";
				next;
				select("How did it go afterwards?");
				cutin "job_ko02",2;
				mes "[Guide Gion]";
				mes "Ha ha ha. It is never fun to listen to the whole story all at once, no? Come back after passing a test and I'll continue my story.";
				next;
				mes "[Guide Gion]";
				mes "Which test will you select as your first test?";
				next;
				switch(select("Test of Knowledge:Test of Survival:Test of Weaponry")){
					case 1:
						KO_QS(1,1);
						close;
					case 2:
						KO_QS(2,1);
						close;
					case 3:
						KO_QS(3,1);
						close;
				}
			}
		}
	}else if (job_kagero == 6){
		cutin "job_ko01",2;
		mes "[Guide Gion]";
		mes "You've come back already? You could have rested more. Is there a reason to hurry?";
		next;
		input @reason$;
		cutin "job_ko03",2;
		mes "[Guide Gion]";
		mes "Because of ^B24E59"+@reason$+"^000000?";
		next;
		mes "[Guide Gion]";
		mes "I have to admit,I don't understand you now.";
		next;
		mes "[Guide Gion]";
		mes "But since you've gone through much, I'm sure you will do good with the final test.";
		next;
		cutin "job_ko01",2;
		mes "[Guide Gion]";
		mes "Now! No more small talk. I'll let you know what the target is for the Test of Battle.";
		next;
		mes "[Guide Gion]";
		mes "The target is a monster called the ^FF0000Family Secret^000000.";
		next;
		mes "[Guide Gion]";
		mes "You will have to be careful because there are many similiar shaped and named monsters in test site.";
		next;
		mes "[Guide Gion]";
		mes "And if you are lucky, there will be others targeting the monster.";
		next;
		mes "[Guide Gion]";
		mes "May the blessings of '"+((Sex)?"Kagerou, dancing sun":"Oboro, misty moonlight")+"' be with you.";
		next;
		KO_QS(4,4);
		end;
	} else if (job_kagero == 7 || job_kagero == 8){
		cutin "job_ko03",2;
		KO_IB(3);
	} else {
		cutin "job_ko03",2;
		mes "[Guide Gion]";
		mes "You should not be here, Leave!";
		close2;
		warp "amatsu",147,136;
		end;
	}


	function	KO_IB	{	//Kagerou/Oboro In-Between
		//0=Test of Knowledge:1=Test of Survival:2=Test of Weaponry:3=Test of Battle
		cutin "job_ko04",2;
		mes "[Guide Gion]";
		mes "I see you are in the middle of the ^339CCCTest of "+((getarg(0)==0)?"Knowledge":((getarg(0)==1)?"Survival":((getarg(0)==2)?"Weaponry":"Battle")))+"^000000. Will you go back to the test site?";
		switch(select("Go back to the test site.:Visit the village.")){
			case 1:
			mes "Test of "+((getarg(0)==0)?"Knowledge":((getarg(0)==1)?"Survival":((getarg(0)==2)?"Weaponry":"Battle")))+" The test site is over here.";
			sleep2 2000;
			if (getarg(0)==0){warp "job_ko",72,128;}
			if (getarg(0)==1){warp "job_ko",62,16;}
			if (getarg(0)==2){warp "job_ko",121,129;}
			if (getarg(0)==3){
				if (rand(1,3)==1){warp "job_ko",142,80;}
				if (rand(1,3)==2){warp "job_ko",141,80;}
				else{warp "job_ko",107,60;}
			}
			end;
		case 2:
			mes "[Guide Gion]";
			mes "The village is over here.";
			warp "amatsu",147,136;
			end;
		}
	}
	function	KO_QS	{	//Kagerou/Oboro QuestSelect.
		//1=Test of Knowledge:2=Test of Survival:3=Test of Weaponry:4=Test of Battle
		if (getarg(1)<=2){
			mes "[Guide Gion]";
			mes "You are starting with the ^339CCCTest of "+((getarg(0)==1)?"Knowledge":((getarg(0)==2)?"Survival":"Weaponry"))+"^000000"+((getarg(1)==2)?" as Second test.":((getarg(1)==3)?" as Third test.":"."));
			next;
		}
		switch(getarg(0)){
			case 1:
				mes "[Guide Gion]";
				mes "Then I will get to see a familiar face after so long";
				select("Familiar face?");
				next;
				setquest 5136;	//Knowledge Test
				mes "[Guide Gion]";
				mes "Ha ha ha. You'll know when we get there. The Test of Knowledge is taken over here.";
				close2;
				cutin "",255;
				warp "job_ko",72,128;
				end;
			case 2:
				mes "[Guide Gion]";
				mes "It's a lonesome test that you have to face alone.";
				mes "But I believe you can handle it. The Test of Survival is taken over here.";
				setquest 5137;
				close2;
				cutin "",255;
				warp "job_ko",62,16;
				end;
			case 3:
				mes "[Guide Gion]";
				mes "I have something to give you before you go.";
				next;
				setquest 5138;	//Weapons test
				getitem 1002,5; getitem 1010,1;	//5 Iron ore and 1 Phracon
				mes "You receive 5 Iron Ore and 1 Phracon.";
				next;
				mes "[Guide Gion]";
				mes "You will find these useful. The Test of Weaponry is taken over here.";
				close2;
				cutin "",255;
				warp "job_ko",121,129;
				end;
			case 4:
				if(getarg(1)==4){set job_kagero,7;}
				setquest 5146;	//Battle Test
				mes "[Guide Gion]";
				mes "Then let's go to the battle test field.";
				close2;
				cutin "",255;
				if (rand(1,3)==1){warp "job_ko",142,80;}
				if (rand(1,3)==2){warp "job_ko",141,80;}
				else{warp "job_ko",107,60;}
				end;
		}
	}
}

job_ko,148,46,5	script	Guide Gion#ko2	588,{
	if (job_kagero==7){
		cutin "job_ko01",2;
		mes "[Guide Gion]";
		mes "Looks like you haven't taken care of the target yet.";
		next;
		mes "[Guide Gion]";
		mes "I'll tell you once more. The taget is the Family Secret.";	//Red Colour
		close2;
		cutin "",255;
		end;
	}else if (job_kagero==8){
		cutin "job_ko02",2;
		mes "Looks like you've taken care of the target. Hmm.";
		next;
		mes "[Guide Gion]";
		if (checkriding()){
			mes "Please get down from the frog";
			cutin "",255;
			close;
		}
		if ((BaseLevel < 99) && (JobLevel < 70)){
			mes "How did you get weak, Restore previous levels and come back to me.";
			cutin "",255;
			close;
		}
		if (SkillPoint){
			mes "Please come back after using all Skill Points.";
			cutin "",255;
			close;
		}
		mapannounce "job_ko","[Gion] Interrupting the Test of Battle.",bc_map;
		cutin "job_ko04",2;
		mes "The Test of Battle will be put off for a while. Don't worry because this does not have affect to other tests.";
		next;
		mapannounce "job_ko","[Gion] My Friend "+strcharinfo(0)+" made it to "+((Sex)?"Kagerou":"Oboro")+" Path. Congratulations!!",bc_map;
		mes "[Guide Gion]";
		mes "My friend "+strcharinfo(0)+" made it to "+((Sex)?"Kagerou":"Oboro")+" Path. Congratulations!!";
		next;
		cutin "job_ko02",2;
		mes "[Guide Gion]";
		mes "It is pleasant to meet a youth that is walking through a new path.";
		next;
		mes "[Someone's Voice]";
		mes "Wait for a while, Gion.";
		next;
		cmdothernpc "Cougar#ko2","OnCommandEnable";
		cmdothernpc "Red Leopard Joe#ko2","OnCommandEnable";
		cutin "job_ko04",2;
		mes "[Guide Gion]";
		mes "I'm sorry I almost forgot about you two. Do you have anything to share with "+strcharinfo(0)+"?";
		next;
		cutin "",255;
		mes "[Cougar]";
		mes "Hmm... Embarrassing... to speak so suddenly...";
		next;
		mes "[Cougar]";
		mes strcharinfo(0)+" you are now a proud member of our family. Always hold your head high and";
		next;
		mes "[Cougar]";
		mes "^777777(Gai's voice fades out.)^000000.";
		mes "I'm sorry I strangled you when we first met.";
		next;
		cmdothernpc "Cougar#ko2","OnCommandDisable";
		mes "[Red Leopard Joe]";
		mes "Puhahaha! Gai is all talk. I know I was know valuable to you than that Gai.";
		next;
		mes "[Red Leopard Joe]";
		mes "I did some work on the prototype "+((KO_OPT==1)?"dagger":"shuriken")+"dagger you made.";
		next;
		mes "[Red Leopard Joe]";
		mes ((KO_OPT==1)?"Knife":"Kurenai")+"'s now shines beatifully with a scarlet glow after I did the finishing touches.";
		next;
		mes "[Red Leopard Joe]";
		mes "I named your weapons on my own but I know you'll like the name.";
		next;
		mes "[Red Leopard Joe]";
		mes "Guide Gion, Please Continue.";
		next;
		cutin "job_ko01",2;
		cmdothernpc "Red Leopard Joe#ko2","OnCommandDisable";
		mes "[Guide Gion]";
		mes "I don't have much to add because Gai and Joe said it all.";
		next;
		mes "[Guide Gion]";
		mes "I'm just sorry that the environment of all these tests could have been better for our later generation.";
		next;
		mes "[Guide Gion]";
		mes "You only need to look forward and never turn back.";
		for (set .i,5131; .i<5147; set .i,.i+1 ){
			if (checkquest(.i) != -1){erasequest .i;}
		}
		set job_kagero,9;
		if (KO_OPT==1){getnameditem 13075,strcharinfo(0);}
		else{getnameditem 13311,strcharinfo(0);}
		if(Sex){jobchange Job_Kagerou;}else{jobchange Job_Oboro;}
		resetlvl(1);
		cmdothernpc "Summon Target#ko","OnCommandEnable";
		mes "[Guide Gion]";
		mes "I hope the blessings of Kagerou, dancing sun and Oboro, misty moonlight will be with you on your journey ahead.";
		close2;
		warp "que_ng",21,71;
		end;
	}else if (job_kagero==9){
		cutin "job_ko01",2;
		mes "[Guide Gion]";
		mes "I hope the blessings of Kagerou, dancing sun and Oboro, misty moonlight will be with you on your journey ahead.";
		close2;
		warp "que_ng",21,71;
		end;
	}else{
		cutin "job_ko01",2;
		mes "[Guide Gion]";
		mes "You should not come here, Leave!!";
		close2;
		warp "amatsu",147,136;
		end;
	}
	cutin "",255;
	close;
}


job_ko,145,47,6	script	Red Leopard Joe#ko2	730,{
	mes "[Red Leopard Joe]";
	mes "You have not found the target? Continue searching it.";
	close;

OnInit:
	disablenpc "Red Leopard Joe#ko2";
	end;

OnCommandEnable:
	enablenpc "Red Leopard Joe#ko2";
	end;
	
OnCommandDisable:
	disablenpc "Red Leopard Joe#ko2";
	end;
}

job_ko,151,47,4	script	Cougar#ko2	730,{
	mes "[Cougar]";
	mes "Congratulation for choosing the road of development!";
	close;
	
OnInit:
	disablenpc "Cougar#ko2";
	end;

OnCommandEnable:
	enablenpc "Cougar#ko2";
	end;
	
OnCommandDisable:
	disablenpc "Cougar#ko2";
	end;
}

job_ko,1,1,4	script	Summon Target#ko	844,{
OnInit:
	callsub OnCommandEnable;
	end;
OnTimer180000:
	callsub OnCommandEnable;
	end;
OnCommandEnable:
	stopnpctimer;
	switch (rand(1,7)){
		case 1: set .mob_id,1002; break;
		case 2: set .mob_id,1031; break;
		case 3: set .mob_id,1113; break;
		case 4: set .mob_id,1063; break;
		case 5: set .mob_id,1010; break;
		case 6: set .mob_id,1049; break;
		case 7: set .mob_id,1050; break;
		default: set .mob_id,1002; break;
	}
	areamonster "job_ko",100,10,180,90,"Family Secret",.mob_id,1,"Summon Target#ko::OnMyMobDead";
	return;
//------ 
OnCommandDisable:
	initnpctimer;
	return;
//------ 
OnMyMobDead:
	if (job_kagero == 7){
		callsub OnCommandDisable;
		set job_kagero,8;
	}else{
		callsub OnCommandEnable;
	}
	end;
}

job_ko,1,2,4	script	Summon Fake#ko	844,{
OnInit:
	callsub OnCommandEnable;
	end;
	
OnCommandEnable:
	areamonster "job_ko",100,10,180,90,"Family's Legacy",1002,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Kagerou's Memory",1002,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Oboro's Memory",1002,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Family's Mistake",1031,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Oboro's Mistake",1031,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Kagerou's Mistake",1031,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Family's Memory",1113,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Oboro's Past",1113,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Kagerou's Past",1113,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Family's Legacy",1063,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Oboro's Legacy",1063,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Kagerou's Legacy",1063,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Family's Mistake",1010,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Oboro's Memory",1010,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Kagerou's Memory",1010,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Family's Past",1049,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Oboro's Mistake",1049,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Kagerou's Mistake",1049,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Family's Memory",1050,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Oboro's Past",1050,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",100,10,180,90,"Kagerou's Past",1050,5,"Summon Fake#ko::OnMyMobDead";
	return;
OnCommandDisable:
	killmonster "job_ko","Summon Fake#ko::OnMyMobDead";
	return;

OnMyMobDead:
	if (mobcount("job_ko","Summon Fake#ko::OnMyMobDead") < 100){
		callsub OnCommandDisable;
		callsub OnCommandEnable;
		warp "job_ko",16,113;
	}
	end;
}

//Test of Knowledge KO
job_ko,81,124,1	script	Cougar#ko	730,{
	if (BaseJob!=Job_Ninja){
		for (set .i,5131; .i<5147; set .i,.i+1 ){
			if (checkquest(.i) != -1){erasequest .i;}
		}
		mes "[Cougar]";
		mes "Sorry, Your family is not same as ours, is there something wrong?";
		close2;
		warp "amatsu",147,136;
		end;
	}
	if (checkquest(5136)==1 && checkquest(5139) == -1){
		mes "[Cougar]";
		mes "It's been a while.";
		next;
		select("Aren't you...");
		mes "[Cougar]";
		mes "I remember you from before looking for the way of the ninja.";
		next;
		mes "[Cougar]";
		mes "You've grown this strong already?";
		next;
		mes "[Cougar]";
		mes "Ha ha ha-";
		mes "A truly determined youth! I like that.";
		next;
		mes "[Cougar]";
		mes "Good! The test you are about to take is the ^339CCCTest of Knowledge^000000.";
		next;
		mes "[Cougar]";
		mes "I hope you haven't been lazy with your studies while focusing on getting stronger?";
		next;
		switch(select("Yes:No")){	//Sets the quest on both the cases.
			case 1:
				setquest 5139;	//The Guy looks familiar!!
				mes "[Cougar]";
				mes "That's a relief. Let me know when you are ready to start the test.";
				close;
			case 2:
				setquest 5139;
				mes "[Cougar]";
				mes "So you were all talk? Well, let me know when you are ready then.";
				close;
		}
	} else if (checkquest(5136)==1 && checkquest(5139) == 1){
		mes "[Cougar]";
		mes "I'm ready at my end. Are you ready for the test?";
		next;
		if(select("Yes:No")==2){
			mes "[Cougar]";
			mes "Well, what can I do but wait for you.";
			close;
		}	
		mes "This isn't your first test, is it?";
		next;
		mes "[Cougar]";
		mes "You only need to choose the correct answer to my questions.";
		next;
		mes "[Cougar]";
		mes "Let's start.";
		next;
		function Question;
		set @cougar_correct,0;
		set .@k$,"";
		for(set .@i,1; .@i<=10; set .@i,.@i+1) {
			while(1) {
				set .@j,rand(1,50);
				if (!compare(.@k$,"|"+.@j+"|")) {
					set .@k$, .@k$+"|"+.@j+"|";
					break;
				}
			}
			mes "[Cougar]";
			mes ((.@i <= 10)?"Question number "+.@i+":":"Last question:");
			switch(.@j) {
				case 1:
					Question("What is the DEX + LUK total for a Job Master?",2,"8:10:12:14");
					break;
				case 2:
					Question("What is the highest job level for a ninja?",1,"70:50:99:100");
					break;
				case 3:
					Question("How many skill points do you need to master the Throw Coins skill?",3,"25:30:35:37");
					break;
				case 4:
					Question("Which of the following is the correct number of Evasion and effect duration for Mirror Image level 10?",4,"Up to 7 and 200 seconds:Up to 5 and 220 seconds:Up to 6 and 240 seconds:Up to 5 and 240 seconds");
					break;
				case 5:
					Question("How many skill points do you need to master the Cicada Skin Shed?",1,"5:3:1:4");
					break;
				case 6:
					Question("If Dagger Throwing Practice is at 7, how much ATK is added to Shuriken attacks?",2,"18:21:27:30");
					break;
				case 7:
					Question("What is the basic attack range for Throw Shuriken?",3,"7 blocks:8 blocks:9 blocks:10 blocks");
					break;
				case 8:
					Question("What is the maximum moving range of Shadow Leap?",4,"6 blocks:7 blocks:8 blocks:9 blocks");
					break;
				case 9:
					Question("How much money is used for Throw Coins level 6?",4,"2000-8000:1000-6000:3000-8000:3000-6000");
					break;
				case 10:
					Question("What is the most important aspect of increasing ATK for the Killing Strike skill?",2,"VIT:MAXHP:INT:MAXSP");
					break;
				case 11:
					Question("What is not the effect you get after reaching the STR status?",3,"Close range attack increase:Weight limit increase:Magic attack increase:Weapon attack increase");
					break;
				case 12:
					Question("What is not the effect you get after reaching the INT status?",4,"MAXSP increase:MATK increase:Magic damage increase:Staff attack increase");
					break;
				case 13:
					Question("What is not the effect you get after reaching the DEX status?",2,"Casting time decrease:Evasion increase:Accuracy increase:Long range attack increase");
					break;
				case 14:
					Question("What is not the effect you get after reaching the AGI status?",1,"Accuracy increase:Flee increase:Attack speed increase:Delay after attack decrease");
					break;
				case 15:
					Question("What is not the effect you get after reaching the VIT status?",4,"Weapon defense increase:MAXHP increase:Magic defense increase:Attack increase");
					break;
				case 16:
					Question("What is not the effect you get after reaching the LUK status?",3,"Accuracy increase:Complete evasion increase:Magic damage decrease:Critical rate increase");
					break;
				case 17:
					Question("You need to equip a card to your shoes to enhance Killing Strike attack. Which of the following is the appropriate card to equip?",2,"Gold Acidus Card:Matyr Card:Odium of Thantos Card:Eddga Card");
					break;
				case 18:
					Question("You need a catalyst to use ninja skills. Which of the following skills does not need a catalyst?",3,"Blaze Shield:Watery Evasion:Flaming Petals:Snow Flake Draft");
					break;
				case 19:
					Question("How much does STR/INT go up when Ninja Aura level 5 is used?",2,"4:5:6:7");
					break;
				case 20:
					Question("You are hunting the Orc Warrior. Which Kunai would you use? ",1,"Heat Wave Kunai:Icicle Kunai:Fell Poison Kunai:High Wind Kunai");
					break;
				case 21:
					Question("Which village is the Ninja Guild located in?",2,"Lutie:Amatsu:Dewata:Comodo");
					break;
				case 22:
					Question("How do Ninjas get promoted?",3,"By Val Kiwi:By Randgris:None:By Valkyrie");
					break;
				case 23:
					Question("What was next to me when you first met me?",4,"A cushion:A folding screen:A flowerpot:A brazier");
					break;
				case 24:
					Question("What is the level of Dagger Throwing Practice you have to reach to learn the Killing Strike skill?",1,"7:5:6:8");
					break;
				case 25:
					Question("How many hits does a Throw Kunai give to a monster?",2,"2:3:4:5");
					break;
				case 26:
					Question("When your First Wind is at level4, what will go with the MATK and range?",3,"MATK400, 8 blocks:MATK500, 7 blocks:MATK500, 8 blocks:MATK400, 7 blocks");
					break;
				case 27:
					Question("Which of the following skills can't you learn at Dagger Throwing Practice level 7?",4,"Throw Kunai:Throw Huuma Shuriken:Killing Strike:Throw Coins");
					break;
				case 28:
					Question("What level do you have to be in Dagger Throwing Practice in order to learn the Throw Coins skill?",4,"4:6:8:10");
					break;
				case 29:
					Question("What is the attack range for the Exploding Dragon?",3,"3*3:4*4:5*5:6*6");
					break;
				case 30:
					Question("How long is the effect time for the Watery Evasion level 7 skill?",2,"40 seconds:45 seconds:50 seconds:55 seconds");
					break;
				case 31:
					Question("What is the attack effect for Haze Slasher level 4?",1,"140%:150%:160%:170%");
					break;
				case 32:
					Question("How much power is in the Huuma Blaze Shuriken weapon?",1,"Fireball 5 , DEX-2:Fireball 5 , DEX-3:Fireball 4 , DEX-2:Fireball 4 , DEX-3");
					break;
				case 33:
					Question("How much power is in the Murasame weapon?",2,"Human attack 10%:Human critical +10:Demon attack 10%:Demon critical +10");
					break;
				case 34:
					Question("What is the maximum hit number for Blaze Shield level 10?",3,"7:8:9:10");
					break;
				case 35:
					Question("What is the property of the Lightning Jolt?",4,"Fire:Water:Ground:Wind");
					break;
				case 36:
					Question("You are creating a weapon for small monsters. What is the best card to use?",4,"Hydra Card:Minorous Card:Skel Woker Card:Desert Wolf Card");
					break;
				case 37:
					Question("You are creating a weapon for mid-sized monsters. What is the best card to use?",3,"Hydra Card:Minorous Card:Skel Woker Card:Desert Wolf Card");
					break;
				case 38:
					Question("You are creating a weapon for huge monsters. What is the best card to use?",2,"Hydra Card:Minorous Card:Skel Woker Card:Desert Wolf Card");
					break;
				case 39:
					Question("Which NPC promotes you?",1,"Valkyrie:Val Kiwi:Balp Hiri:Elephant");
					break;
				case 40:
					Question("Which catalyst do you need to use the Blaze Shield skill?",2,"Ice Stone:Flame Stone:Wind Stone:Earth Stone");
					break;
				case 41:
					Question("Which of the following is not an effect of the Watery Evasion skill?",4,"Movement speed decrease:Waterball availability:Holy Water craftability:VIT decrease");
					break;
				case 42:
					Question("Which of the following matches are incorrect for skill and property?",3,"Flaming Petals-Fire:Snow Flake Draft-Water:Freezing Spear-Ground:Lightning Jolt-Wind");
					break;
				case 43:
					Question("Which of the following is the best skill to use when attacking a ground property enemy?",2,"First Wind:Exploding Dragon:Snow Flake Draft:Wind Blade");
					break;
				case 44:
					Question("Which Ninja Mastery skill level do you need to learn the Exploding Dragon skill?",1,"10:9:8:1");
					break;
				case 45:
					Question("What is the attack range when you master Flip Tatami?",3,"5:7:3:1");
					break;
				case 46:
					Question("What weapon cannot be made by the blacksmith Khaibara?",4,"Khukri:Murasame:Hakujin:Humma Wing Shuriken");
					break;
				case 47:
					Question("Which of the following correctly matches material needed to make a Icicle Kunai?",2,"4 Nimbus Shuriken,2 Ice Stone:8 Nimbus Shuriken,2 Ice Stone:2 Nimbus Shuriken,1 Ice Stone:1 Nimbus Shuriken,2 Ice Stone");
					break;
				case 48:
					Question("Which of the following Kunai will give the most damage to the ground property monster, Porcellio?",1,"Heat Wave Kunai:Icicle Kunai:Fell Poison Kunai:High Wind Kunai");
					break;
				case 49:
					Question("Which of the following blacksmiths do not create ninja items?",2,"Khaibara:Aiku:Tetsu:Toshu");
					break;
				case 50:
					Question("What is the name of the suspicious man you can meet during the Ninja job change quest?",3,"Red Leopard Jack:Black Leopard Jack:Red Leopard Joe:Black Leopard Joe");
					break;
				default:
					mes "[Cougar]";
					mes "An Unknown Error Occured";
					mes "Please contact customer service.";
					close;
			}
		}
		mes "You're through all 10 questions. Wasn't so bad! The important part starts now.";
		next;
		mes "[Cougar]";
		mes "... ... ...";
		next;
		if (@cougar_correct < 9){
			mes "[Cougar]";
			mes "You fool!!";
			mes "You couldn't even solve these?";
			next;
			mes "[Cougar]";
			mes "Can't believe someone who is taking a new path can be so pathetic.";
			next;
			mes "[Cougar]";
			mes "I'll give you another chance.";
			mes "You will take the test again with new questions. Better pass it this time.";
		} else {
			next;
			mes "[Cougar]";
			mes "You passed!";
			next;
			mes "[Cougar]";
			mes "Hmm. "+(@cougar_correct*10)+"?";
			next;
			mes "[Cougar]";
			mes "Well, looks like you weren't lazy with your studies.";
			next;
			mes "[Cougar]";
			mes "What? Proud of yourself for solving these questions?";
			next;
			mes "[Cougar]";
			mes "You still have a long way to go and this is only a small fraction of it.";
			next;
			mes "[Cougar]";
			mes "Well... I'm curious how far your strong will can take you through other tests.";
			next;
			completequest 5136;
			erasequest 5139;
			set KO_QD,KO_QD+1;
			mes "[Cougar]";
			mes "I'll let you go now so go report back to Guide Gion with your results.";
			warp "job_ko",16,113;
			end;
		}
		set @cougar_correct,0;
		close;

	} else if (checkquest(5136)==2 && checkquest(5139) == -1){
		mes "[Cougar]";
		mes "Returning you to Guide";
		close2;
		warp "job_ko",16,113;
		end;
	} else {
		mes "[Cougar]";
		mes "How did you come here?";
		next;
		mes "[Cougar]";
		mes "You should move off immediatly.";
		mes "^000099(Old Man)^000000";
		mes "I will warp you back";
		close2;
		warp "amatsu",147,136;
		end;
	}
	close;

	function	Question	{
		mes getarg(0);
		next;
		if(select(getarg(2)) == getarg(1)){
			set @cougar_correct, @cougar_correct+1;
		}
		return;
	}

}

//Functions
function	script	Check_LP	{
	if (LPOINTS<1){
		mes "Due to insufficient ^FD0260LP^000000, you will be returned to starting position.";
		close2;
		warp "job_ko",63,16;
		end;
	}
	return;
}

function	script	KO_SD	{	//Kagerou/Oboro Survival-DiceTwice(LargerThan,Warpto,Smallthan,Warpto,Location,LPConsume,BlockBetween1,BlockBetween2)
	mes "Location: "+getarg(4);
	mes "Total LP: "+LPOINTS+"";
	mes "To roll the dice, you need to consume "+getarg(5)+" ^FD0260LP^000000.";
	next;
	if (select("Roll the first dice.")==1){
		callfunc("Check_LP");
		mes "< Used "+getarg(5)+" LP >";
		set LPOINTS,LPOINTS-getarg(5);
		set @dice1,rand(1,6);
		next;
		emotion 57+@dice1,0;
		mes "First dice result is "+@dice1+". Do you want to roll the second dice?";
		next;
		if (select("Roll the second dice.")==1){
			set @dice2,rand(1,6);
			emotion 57+@dice2,0;
			mes "Second dice result is "+@dice2+".";
		}
		if (getarg(0)==-1){
			if (@dice1!=@dice2){ mes "You didn't get the same results"; return;}
			else if (@dice1==@dice2){ mes "You got the same number. Press Close to move block 30."; close2; callfunc("KO_SW",31);}
		}
		else{
			next;
			set .@dresult,@dice1+@dice2;
			mes @dice1+" + "+@dice2+" = "+.@dresult;
			if (.@dresult<getarg(2)){ 
				mes "You total is lower than "+getarg(2)+". Press Close to move to block "+getarg(3)+"."; 
				close2;
				callfunc("KO_SW",getarg(3)+1);
			}
			else if (.@dresult>=getarg(2)){
				if (getarg(1)==-2){
					mes "You total is larger than "+getarg(0)+". Please choose a block to move to between blocks "+getarg(6)+" through "+getarg(7)+".";
					next;
					for (set .@i,1; .@i <= (getarg(7)-getarg(6)); set .@i,.@i +1){
						if (.@i==1) set .@menu$, "Move to block "+(getarg(7)-1+.@i)+".";
						else {set .@menu$, .@menu$+":Move to block "+(getarg(7)-1+.@i)+".";}
					}
					set .@menu,select(.@menu$);
					close2;
					callfunc("KO_SW",1+.@menu+getarg(6));
				}
				else if(getarg(1)==-1){
					mes "You total is larger than "+getarg(0)+".";
					callfunc("KO_SL",getarg(4),1);
					close2;
					callfunc("KO_SW",@dice+getarg(4)+1);
				}
				else{
					mes "You total is larger than "+getarg(0)+".";
					callfunc("KO_SW",getarg(1)+1);
				}
				
			}
		}
	}

}

//Test of Survival KO
function	script	KO_SL	{	//Kagerou/Oboro Survival-Location(Location,LPConsume)
	mes "Roll the dice.";
	next;
	mes "Location: "+getarg(0);
	mes "Total LP: "+LPOINTS;
	mes "To roll the dice, you need to consume "+getarg(1)+" ^FD0260LP^000000.";
	next;
	if (select("Roll the dice.")==1){
		callfunc("Check_LP");
		set LPOINTS, LPOINTS-getarg(1);
		set @dice, rand(1,6);
		emotion 57+@dice,0;
		mes "The dice came out as "+@dice+".";
		mes "Press Close to move forward "+@dice+" blocks.";
	}
	return;
}
function	script	KO_SW	{	//Kagerou/Oboro Survival-Warpto(WarpLocation)
	switch(getarg(0)){
		case 1:		warp "job_ko",63,16; end;
		case 2:		warp "job_ko",54,16; end;
		case 3:		warp "job_ko",46,16; end;
		case 4:		warp "job_ko",38,16; end;
		case 5:		warp "job_ko",30,16; end;
		case 6:		warp "job_ko",22,16; end;
		case 7:		warp "job_ko",17,19; end;
		case 8:		warp "job_ko",17,27; end;
		case 9:		warp "job_ko",17,35; end;
		case 10:	warp "job_ko",17,43; end;
		case 11:	warp "job_ko",17,51; end;
		case 12:	warp "job_ko",17,60; end;
		case 13:	warp "job_ko",25,60; end;
		case 14:	warp "job_ko",33,60; end;
		case 15:	warp "job_ko",41,60; end;
		case 16:	warp "job_ko",49,60; end;
		case 17:	warp "job_ko",57,60; end;
		case 18:	warp "job_ko",62,56; end;
		case 19:	warp "job_ko",62,48; end;
		case 20:	warp "job_ko",62,40; end;
		case 21:	warp "job_ko",62,32; end;
		case 22:	warp "job_ko",62,24; end;
		case 23:	warp "job_ko",54,23; end;
		case 24:	warp "job_ko",46,23; end;
		case 25:	warp "job_ko",38,23; end;
		case 26:	warp "job_ko",30,23; end;
		case 27:	warp "job_ko",25,27; end;
		case 28:	warp "job_ko",25,35; end;
		case 29:	warp "job_ko",25,43; end;
		case 30:	warp "job_ko",25,52; end;
		case 31:	warp "job_ko",33,52; end;
		case 32:	warp "job_ko",41,52; end;
		case 33:	warp "job_ko",49,52; end;
		case 34:	warp "job_ko",54,48; end;
		case 35:	warp "job_ko",54,40; end;
		case 36:	warp "job_ko",54,31; end;
		case 37:	warp "job_ko",46,31; end;
		case 38:	warp "job_ko",38,31; end;
		case 39:	warp "job_ko",33,35; end;
		case 40:	warp "job_ko",33,44; end;
		case 41:	warp "job_ko",41,44; end;
	}
	return;
}

function	script	KO_DL	{
	mes "[No. "+getarg(0)+"]";
	mes "^1A95E6Other letters are too small to read. Let's look up close.^000000";
	close;
}

function	script	KO_SR	{	//Kagerou/Oboro Survival-RPS(Win,Lose,Draw,Location,BlockBetween1,BlockBetween2)
	mes "Rock! Paper! Scissors!";
	next;
	set .@player,select("Give scissors.:Give rock.:Give paper.");
	emotion (9+.@player),1;
	emotion (9+.@master),0;
	set .@master, rand(1,3);
	mes "=Game Results=";
	mes "Machine: "+((.@master==1)?"Scissors":((.@master==2)?"Rock":"Paper"))+".";
	mes "You: "+((.@player==1)?"Scissors":((.@player==2)?"Rock":"Paper"))+".";
	if (.@master==.@player) {
		mes "Draw";
		if (getarg(2)==-1){callfunc("KO_SL",getarg(4),1); close2; callfunc("KO_SW",@dice+getarg(4)+1);}
		close2;
		callfunc("KO_SW",getarg(2)+1);
	} else if ( (.@player==1 && .@master==2) || (.@player==2 && .@master==3) || (.@player==3 && .@master==1) ) {
		mes "You Lose";
		if (getarg(1)==-1){callfunc("KO_SL",getarg(4),1); close2; callfunc("KO_SW",@dice+getarg(4)+1);}
		else{
			mes "Press Close to move to block "+getarg(1)+".";
			close2;
			callfunc("KO_SW",getarg(1)+1);
		}
	} else{
		mes "You Win";
		if (getarg(0)==-1){callfunc("KO_SL",getarg(4),1); close2; callfunc("KO_SW",@dice+getarg(4)+1);}
		else if (getarg(0)==-2){
			for (set .@i,1; .@i <= (getarg(5)-getarg(4)); set .@i,.@i +1){
				if (.@i==1) set .@menu$,"Move to block "+(getarg(5)-1+.@i)+".";
				else {set .@menu$, .@menu$+":Move to block "+(getarg(5)-1+.@i)+".";}
			}
			set .@menu,select(.@menu$);
			close2;
			callfunc("KO_SW",1+.@menu+getarg(4));
			end;
		}
		else{
			mes "Press Close to move to block "+getarg(0)+".";
			close2;
			callfunc("KO_SW",getarg(0)+1);
		}
	}
}
//=== FUNCTIONS END ===//
job_ko,57,16,1	script	Sight#ko_00	858,1,1,{
	callfunc("KO_DL",0);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	if(checkquest(5137)==1 && checkquest(5140)==-1){
		while (select("Read the description.:Start the test.")==1){
			mes "The Test of Survival starts from here and you use ^FD0260100 Life Points (LP)^000000 and roll dice to advance forward through the test.";
			next;
			mes "The whole test starts from block 0 to block 40 and each block you get can either give or take your LP.";
			next;
			mes "You need to have some ^FD0260LP^000000 till you get to the arrival block at the end to pass the test.";
			next;
			mes "But! You still pass the test if your ^FD0260LP^000000 becomes 0 when you get to the arrival block.";
			next;
			mes "Game instructions end here. Good luck to you.";
			next;
		}
		setquest 5140;
		set LPOINTS, 100;
		mes "You've gained 100 Life Points (LP).";
		next;
	}else{
		set LPOINTS, 100;
		mes "You've returned to the first block. Your LP is recovered.";
		next;
		while (select("Read the description.:Start the test.")==1){
			mes "The Test of Survival starts from here and you use ^FD0260100 Life Points (LP)^000000 and roll dice to advance forward through the test.";
			next;
			mes "The whole test starts from block 0 to block 40 and each block you get can either give or take your LP.";
			next;
			mes "You need to have some ^FD0260LP^000000 till you get to the arrival block at the end to pass the test.";
			next;
			mes "But! You still pass the test if your ^FD0260LP^000000 becomes 0 when you get to the arrival block.";
			next;
			mes "Game instructions end here. Good luck to you.";
			next;
		}
		if(checkquest(5140)==-1)
			setquest 5140;
	}
	callfunc("KO_SL",0,1);
	close2;
	callfunc("KO_SW",@dice+1);
	end;
}

job_ko,49,16,1	script	Sight#ko_01	858,1,1,{
	callfunc("KO_DL",1);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "You are really bad at rolling dice. How can you get a 1 from the start? You can move to block 9 if you pay up 10 LP in this block.";
	next;
	switch(select("Use 10 LP:Roll the dice.")){
		case 1:
			set LPOINTS, LPOINTS-10;
			mes "< Used 10 LP >";
			mes "Press Close to move to block 9.";
			close2;
			
			callfunc("KO_SW",10);
		case 2:
			callfunc("KO_SL",1,1);	
			close2;
			callfunc("KO_SW",@dice+2);
	}
}

job_ko,41,16,1	script	Sight#ko_02	858,1,1,{
	callfunc("KO_DL",2);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "This block has a trap.";
	mes "Press Close to go back to block 0.";
	close2;
	callfunc("KO_SW",1);
}

job_ko,33,16,1	script	Sight#ko_03	858,1,1,{
	callfunc("KO_DL",3);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Used 5 LP so you will have to resist the curse passed down through generations before moving forward.";
	next;
	switch(select("Use 5 LP")){
		case 1:
		mes "< Used 5 LP >";
		set LPOINTS, LPOINTS-5;
		callfunc("KO_SL",3,1);	
		callfunc("KO_SW",@dice+4);
	}
}

job_ko,25,16,1	script	Sight#ko_04	858,1,1,{
	callfunc("KO_DL",4);

OnTouch:
	mes "There are tiny letters scribbled on the sign.";
	next;
	if (.KO_WH$!="") {
		mes .KO_WH$+" was here.";
		next;
	}
	mes "Should I leave my name since taking the test is a special occasion?";
	next;
	switch(select("Use 5 LP and leave your name.:Continue to roll the dice.")){
		case 1:
			mes "< Used 5 LP >";
			set LPOINTS,LPOINTS-5;
			next;
			set .KO_WH$,"strcharinfo(0)";
			mes strcharinfo(0)+" was here.";
			mes "You left your name.";
			callfunc("KO_SL",4,1);	
			close2;
			callfunc("KO_SW",@dice+5);
			
		case 2:
			mes "Roll the dice.";
			next;
			callfunc("KO_SL",4,1);	
			close2;
			callfunc("KO_SW",@dice+5);
	}
}

job_ko,17,16,1	script	Sight#ko_05	858,1,1,{
	callfunc("KO_DL",5);

OnTouch:
	if (checkquest(5141,PLAYTIME) == 0){
		mes "You are cursed and cannot move to any other block for 2 minutes.";
		close;
	}
	if (checkquest(5141,PLAYTIME) == 2){
		mes "The immobilize curse lasted for 2 minutes and then was removed.";
		erasequest 5141;
		callfunc("KO_SL",5,1);
		callfunc("KO_SW",@dice+6);
	}
	mes "There are tiny letters on the sign.";
	next;
	mes "If you do not pay 5 LP, you will be cursed and immobilized for 2 minutes.";
	next;
	switch(select("Use 5 LP:Do not pay.")){
		case 1:
			mes "<Used 5 LP>";
			set LPOINTS,LPOINTS-5;
			callfunc("KO_SL",5,1);
			callfunc("KO_SW",@dice+6);
			
		case 2:
			setquest 5141;
			mes "You are cursed and cannot move to any other block for 2 minutes.";
			close;
	}
}

job_ko,17,24,1	script	Sight#ko_06	858,1,1,{
	callfunc("KO_DL",6);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "This block is blessed.";
	mes "Life Point recovers 7 LP.";
	mes "Cannot exceed maximum 100 LP.";
	next;
	if (LPOINTS<93) set LPOINTS,LPOINTS+7;
	else set LPOINTS,100;
	mes "< Recovered "+((LPOINTS==100)?"":"7")+" LP >";
	callfunc("KO_SL",6,1);
	close2;
	callfunc("KO_SW",@dice+7);
}

job_ko,17,32,1	script	Sight#ko_07	858,1,1,{
	callfunc("KO_DL",7);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "This block has a trap.";
	mes "Press Close to go back to block 5.";
	close2;
	callfunc("KO_SW",6);
}

job_ko,17,40,1	script	Sight#ko_08	858,1,1,{
	callfunc("KO_DL",8);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Rock-paper-scissors Machine";
	mes "If you win, move to block 15.";
	mes "If it is a draw, roll the dice.";
	mes "If you lose, move to block 0.";
	next;
	callfunc("KO_SR",15,0,-1,8,0,0);	
}

job_ko,17,48,1	script	Sight#ko_09	858,1,1,{
	callfunc("KO_DL",9);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Please proceed.";
	next;
	callfunc("KO_SL",9,1);
	close2;
	callfunc("KO_SW",@dice+10);
}

job_ko,17,56,1	script	Sight#ko_10	858,1,1,{
	callfunc("KO_DL",10);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "If you don't want to be caught, install a trap.";
	next;
	if (.trap){
		mes "You are caught in the trap installed.";
		mes "Press Close to go back to block 0.";
		set .trap,0;
		close2;
		callfunc("KO_SW",1);
	}
	mes "There is currently no trap installed.";
	mes "Do you want to use 10 LP to install a trap?";
	switch(select("Install a trap.:Roll the Dice.")){
		case 1:
			mes "< Used 10 LP >";
			mes "The trap is installed. Please roll the dice.";
			set .trap,1;
			set LPOINTS,LPOINTS-10;
			next;
			callfunc("KO_SL",10,1);
			callfunc("KO_SW",@dice+11);
			
		case 2:
			callfunc("KO_SL",10,1);
			callfunc("KO_SW",@dice+11);
	}
}

job_ko,22,60,1	script	Sight#ko_11	858,1,1,{
	callfunc("KO_DL",11);

OnTouch:
mes "There are tiny letters on the sign.";
next;
mes "This block has a trap.";
mes "Press Close to go back to block 9.";
close2;
callfunc("KO_SW",10);
}

job_ko,30,60,1	script	Sight#ko_12	858,1,1,{
	callfunc("KO_DL",12);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Rock-paper-scissors Machine";
	mes "If you win, move to block 20.";
	mes "If it is a draw, roll the dice.";
	mes "If you lose, move to block 9.";
	next;
	callfunc("KO_SR",20,9,-1,12,0,0);
}

job_ko,38,60,1	script	Sight#ko_13	858,1,1,{
	callfunc("KO_DL",13);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "This block is blessed.";
	mes "Life Point recovers 7 LP.";
	mes "Cannot exceed maximum 100 LP.";
	next;
	if (LPOINTS<93) set LPOINTS,LPOINTS+7;
	else set LPOINTS,100;
	mes "< Recovered "+((LPOINTS==100)?"":"7")+" LP >";
	callfunc("KO_SL",13,1);
	close2;
	callfunc("KO_SW",@dice+14);
}

job_ko,46,60,1	script	Sight#ko_14	858,1,1,{
	callfunc("KO_DL",14);

OnTouch:
	if (checkquest(5141,PLAYTIME) == 0){
		mes "You are cursed and cannot move to any other block for 2 minutes.";
		close;
	}
	if (checkquest(5141,PLAYTIME) == 2){
		mes "The immobilize curse lasted for 2 minutes and then was removed.";
		erasequest 5141;
		callfunc("KO_SL",5,1);
		callfunc("KO_SW",@dice+6);
	}
	mes "There are tiny letters on the sign.";
	next;
	mes "If you do not pay 5 LP, you will be cursed and immobilized for 2 minutes.";
	next;
	switch(select("Use 5 LP:Do not pay.")){
		case 1:
			mes "<Used 5 LP>";
			set LPOINTS,LPOINTS-5;
			callfunc("KO_SL",14,1);
			callfunc("KO_SW",@dice+15);
		case 2:
			setquest 5141;
			mes "You are cursed and cannot move to any other block for 2 minutes.";
			close;
	}
}

job_ko,54,60,1	script	Sight#ko_15	858,1,1,{
	callfunc("KO_DL",15);

OnTouch:
	if (checkquest(5141,PLAYTIME) == 0){
		mes "You are cursed and cannot move to any other block for 2 minutes.";
		close;
	}
	if (checkquest(5141,PLAYTIME) == 2){
		mes "The immobilize curse lasted for 2 minutes and then was removed.";
		erasequest 5141;
		callfunc("KO_SL",5,1);
		close2;
		callfunc("KO_SW",@dice+6);
	}
	mes "There are tiny letters on the sign.";
	next;
	mes "You will be cursed by a powerful gravity curse that immobilizes you for 2 minutes.";
	setquest 5141;
	close;
}

job_ko,62,60,1	script	Sight#ko_16	858,1,1,{
	callfunc("KO_DL",16);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Consume 2 LP and roll the dice twice.";
	mes "If you get the same number then you can move to block 30, if the numbers are different, consume 2 LP to roll again... until you get the same numbers.";
	next;
	while(1){
		callfunc("KO_SD",-1,30,-1,-3,16,2,0,0);
	}
}

job_ko,62,51,1	script	Sight#ko_17	858,1,1,{
	callfunc("KO_DL",17);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Area cursed with 10 times the normal gravity. You will need 10LP to roll the dice.";
	callfunc("KO_SL",17,10);
	close2;
	callfunc("KO_SW",@dice+18);
}

job_ko,62,43,1	script	Sight#ko_18	858,1,1,{
	callfunc("KO_DL",18);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Consume 2 LP and roll the dice twice.";
	mes "If the sum of the numbers from both dice is lower than 5, move to block 30, if it higher than 5, move to block 19.";
	callfunc("KO_SD",5,19,5,30,18,2,0,0);


}

job_ko,62,35,1	script	Sight#ko_19	858,1,1,{
	callfunc("KO_DL",19);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Move forward.";
	callfunc("KO_SL",19,1);
	close2;
	callfunc("KO_SW",@dice+20);
}

job_ko,62,27,1	script	Sight#ko_20	858,1,1,{
	callfunc("KO_DL",20);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "This block is blessed.";
	mes "Life Point recovers 7 LP.";
	mes "Cannot exceed maximum 100 LP.";
	next;
	if (LPOINTS<93) set LPOINTS,LPOINTS+7;
	else set LPOINTS,100;
	mes "< Recovered "+((LPOINTS==100)?"":"7")+" LP >";
	callfunc("KO_SL",20,1);
	close2;
	callfunc("KO_SW",@dice+21);
}

job_ko,57,23,1	script	Sight#ko_21	858,1,1,{
	callfunc("KO_DL",21);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Area cursed with 10 times the normal gravity. You will need 10LP to roll the dice.";
	callfunc("KO_SL",21,10);
	close2;
	callfunc("KO_SW",@dice+22);
}

job_ko,49,23,1	script	Sight#ko_22	858,1,1,{
	callfunc("KO_DL",22);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	if ($KO_SO == 1){
		mes "Someone Leaved LP for you.";
		mes "You will directly Pass the test";	//Dialog Info
		close2;
		set $KO_SO,0;
		callfunc("KO_SW",41);
	}
	mes "Leave all your remaining LP and go back to block 0, then the next person will be redeemed.";
	next;
	mes "Do you want to leave your LP?";
	mes "If you leave your LP then the next person for test that arrives at the block will automatically pass the test.";
	switch(select("Leave all your LP.:Continue to roll the dice.")){
		case 1:
			set $KO_SO,1;
			mes "Leave all remaining LP here.";
			mes "Press Close and go back to block 0.";
			set LPOINTS,0;
			close2;
			callfunc("KO_SW",1);
			end;
		
		case 2:
			callfunc("KO_SL",22,1);
			close2;
			callfunc("KO_SW",@dice+23);
			end;
	}
}

job_ko,41,23,1	script	Sight#ko_23	858,1,1,{
	callfunc("KO_DL",23);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "This block has a trap.";
	mes "Press Close to go back to block 18.";
	close2;
	callfunc("KO_SW",19);
	end;
	
}


job_ko,33,23,1	script	Sight#ko_24	858,1,1,{
	callfunc("KO_DL",24);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "consume 2 LP and roll the dice twice.";
	next;
	mes "If the sum of the numbers from both dice is larger than 8, then you can move to any block between 25 to 30. But! If the sum is below 8, you must move back to block 19.";
	next;
	callfunc("KO_SD",8,-2,8,19,24,2,25,30);
}

job_ko,25,23,1	script	Sight#ko_25	858,1,1,{
	callfunc("KO_DL",25);

OnTouch:
	if (checkquest(5141,PLAYTIME) == 0){
		mes "Cannot move because you are cursed.";
		close;
	}
	if (checkquest(5141,PLAYTIME) == 2){
		mes "The immobilize curse lasted for 2 minutes and then was removed.";
		erasequest 5141;
		callfunc("KO_SL",25,1);
		close2;
		callfunc("KO_SW",@dice+26);
	}
	mes "There are tiny letters on the sign.";
	next;
	mes "This is lame.";
	mes "Cannot read the writing. There should be a way to read it.";
	switch(select("Try Something.:do Nothing.")){
		case 1:
			next;
			misceffect EF_TALK_FROSTJOKE;
			mes "Tried a recent Prontera joke to do something.";
			next;
			setquest 5141;
			mes "Got cursed and became immobilized for 2 minutes.";
			close;
			
			
		case 2:
			next;
			if (rand(1,10)==4){mes "Its a wise decision to do nothing";}
			else{mes "Nothing happened. Still need to do something.";}
			close;
	}
}

job_ko,25,32,1	script	Sight#ko_26	858,1,1,{
	callfunc("KO_DL",26);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "This block has a trap.";
	mes "Press Close to go back to block 20.";
	close2;
	callfunc("KO_SW",21);
	end;
	
}

job_ko,25,40,1	script	Sight#ko_27	858,1,1,{
	callfunc("KO_DL",27);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "This block is blessed.";
	mes "Life Point recovers 7 LP.";
	mes "Cannot exceed maximum 100 LP.";
	next;
	if (LPOINTS<93) set LPOINTS,LPOINTS+7;
	else set LPOINTS,100;
	mes "< Recovered "+((LPOINTS==100)?"":"7")+" LP >";
	callfunc("KO_SL",27,1);
	close2;
	callfunc("KO_SW",@dice+28);
}

job_ko,25,48,1	script	Sight#ko_28	858,1,1,{
	callfunc("KO_DL",28);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "If you don't want to be caught, install a trap.";
	next;
	if (.trap){
		mes "You are caught in the trap installed.";
		mes "Press Close to go back to block 0.";
		set .trap,0;
		close2;
		callfunc("KO_SW",1);
	}
	mes "There is currently no trap installed.";
	mes "Do you want to use 10 LP to install a trap?";
	switch(select("Install a trap.:Roll the Dice.")){
		case 1:
			mes "< Used 10 LP >";
			mes "The trap is installed. Please roll the dice.";
			set .trap,1;
			set LPOINTS,LPOINTS-10;
			next;
			callfunc("KO_SL",28,1);
			close2;
			callfunc("KO_SW",@dice+29);
			
		case 2:
			callfunc("KO_SL",28,1);
			close2;
			callfunc("KO_SW",@dice+29);
	}
}
job_ko,30,52,1	script	Sight#ko_29	858,1,1,{
	callfunc("KO_DL",29);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Go forth.";
	callfunc("KO_SL",29,1);
	close2;
	callfunc("KO_SW",@dice+30);
	end;
}

job_ko,38,52,1	script	Sight#ko_30	858,1,1,{
	callfunc("KO_DL",30);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "This block has a trap.";
	mes "Press Close to go back to block 9.";
	close2;
	callfunc("KO_SW",10);
	end;
	
}

job_ko,46,52,1	script	Sight#ko_31	858,1,1,{
	callfunc("KO_DL",31);

OnTouch:
	if (checkquest(5141,PLAYTIME) == 0){
		mes "You are cursed and cannot move to any other block for 2 minutes.";
		close;
	}
	if (checkquest(5141,PLAYTIME) == 2){
		mes "The immobilize curse lasted for 2 minutes and then was removed.";
		erasequest 5141;
		callfunc("KO_SL",5,1);
		callfunc("KO_SW",@dice+6);
	}
	mes "There are tiny letters on the sign.";
	next;
	mes "If you do not pay 5 LP, you will be cursed and immobilized for 2 minutes.";
	next;
	switch(select("Use 5 LP:Do not pay.")){
		case 1:
			mes "<Used 5 LP>";
			set LPOINTS,LPOINTS-5;
			callfunc("KO_SL",31,1);
			close2;
			callfunc("KO_SW",@dice+32);
			
		case 2:
			setquest 5141;
			mes "You are cursed and cannot move to any other block for 2 minutes.";
			close;
	}

}

job_ko,46,52,1	script	Sight#ko_32	858,1,1,{
	callfunc("KO_DL",32);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Rock-paper-scissors Machine";
	mes "If you win, you get to move to any block between 33 to 38; if you lose or is a draw, you have to move to block 0.";
	callfunc("KO_SR",-2,0,0,32,33,38);
}

job_ko,54,43,1	script	Sight#ko_33	858,1,1,{
	callfunc("KO_DL",33);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "You can move to block 39 if you pay all points except for the last 1 LP to roll the dice one last time.";
	switch(select("Pay LP.:Move forward little bit at a time.")){
		case 1:
			next;
			set @temp,LPOINTS-1;
			set LPOINTS,1;
			mes "<"+@temp+" Used LP >";
			mes "Press Close to move to block 39.";
			close2;
			callfunc("KO_SW",40);
			end;
			
		case 2:
			callfunc("KO_SL",33,1);
			close2;
			callfunc("KO_SW",@dice+34);
			end;
	}
}

job_ko,54,35,1	script	Sight#ko_34	858,1,1,{
	callfunc("KO_DL",34);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "This block is blessed.";
	mes "Life Point recovers 7 LP.";
	mes "Cannot exceed maximum 100 LP.";
	next;
	if (LPOINTS<93) set LPOINTS,LPOINTS+7;
	else set LPOINTS,100;
	mes "< Recovered "+((LPOINTS==100)?"":"7")+" LP >";
	callfunc("KO_SL",34,1);
	close2;
	callfunc("KO_SW",@dice+35);
}

job_ko,49,31,1	script	Sight#ko_35	858,1,1,{
	callfunc("KO_DL",35);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "This block has a trap.";
	mes "Press Close to go back to block 29.";
	close2;
	callfunc("KO_SW",30);
	end;
}

job_ko,41,31,1	script	Sight#ko_36	858,1,1,{
	callfunc("KO_DL",36);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "There are only 4 blocks left till the last block.";
	next;
	mes "Rule 1 (Normal Dice Roll)";
	mes "You get to pass if you get 4 or above but nobody knows what will come from a dice roll.";
	next;
	mes "Rule 2";
	mes "If you get 1, 2, or 3 you move right to the arrival point; if you get 4, 5, or 6 you get to choose to move to block 29.";
	mes "next;";
	switch(select("Try it the other way.:Go by the rule.")){
		case 1:
			mes "The Other Way (2nd Rule)";
			callfunc("KO_SD",3,29,3,40,36,1,0,0);
			end;
		case 2:
			callfunc("KO_SL",36,1);
			close2;
			if (@dice >= 4){callfunc("KO_SW",41);}
			else{callfunc("KO_SW",@dice+37);}
			end;
	}
}

job_ko,33,31,1	script	Sight#ko_37	858,1,1,{
	callfunc("KO_DL",37);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "There are only 3 blocks left to the finish line but you can't you go so easily.";
	mes "If you get 1, 3, or 5, move to the arrival point; if you get 2, 4, or 6, go back to the starting point.";
	callfunc("KO_SL",37,1);
	next;
	if (@dice%2 == 0){
		mes "Press Close to move to starting point.";
		close2;
		callfunc("KO_SW",1);
		end;
	}
	else if (@dice%2 == 1){
		mes "Press Close to move to the last block.";
		close2;
		callfunc("KO_SW",41);
		end;
	}
}

job_ko,33,40,1	script	Sight#ko_38	858,1,1,{
	callfunc("KO_DL",37);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Leave 1 LP and invest the remaining LP to install the trap to bring down other players";
	next;
	if (.trap){
		mes "You are caught in the trap installed.";
		mes "Press Close to go back to block 0.";
		set .trap,0;
		close2;
		callfunc("KO_SW",1);
	}
	mes "There is currently no trap installed. Do you want to install a trap?";
	next;
	switch(select("Install a trap.:Do not install.")){
		case 1:
			mes "< Used "+LPOINTS-1+" LP >";
			next;
			mes "The trap is installed. Please roll the dice.";
			set .trap,1;
			set LPOINTS,1;
			next;
		case 2:
			callfunc("KO_SL",38,1);
			if (@dice>1){callfunc("KO_SW",41);}
			else{callfunc("KO_SW",40);}
	}
}

job_ko,38,44,1	script	Sight#ko_39	858,1,1,{
	callfunc("KO_DL",39);

OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Now there is only 1 block left till the end. Congratulations on all you've been through to get here.";
	next;
	mes "But you cannot go so easily. If you get a 3, you will go back to block 3.";
	callfunc("KO_SL",39,1);
	if (@dice==3){
		mes "Press Close to move to 3rd block.";
		close2;
		callfunc("KO_SW",4);
	}
	else{
		mes "Press Close to move to the arrival point.";
		close2;
		callfunc("KO_SW",41);
	}
}

job_ko,46,41,1	script	Sight#ko_40	858,1,1,{
	callfunc("KO_DL",40);

OnTouch:
	if ((job_kagero!=5) || ( checkquest(5137)!=1 && checkquest(5140)!=1 ) ){
		mes "You should not be here";
		close2;
		warp "amatsu",147,136;
		end;
	}
	mes "There are tiny letters on the sign.";
	next;
	mes "To those you are preparing for a new turn...";
	mes "Well begun is half done. However always remember it is not the end.";
	next;
	mes "Let's read all the writing on the sign.";
	mes "You feel like you are moved to another place.";
	next;
	completequest 5137;
	erasequest 5140;
	erasequest 5141;
	set LPOINTS,0;
	set KO_Q,1;
	set KO_QD,KO_QD+2;
	warp "job_ko",35,113;
	end;

}

job_ko,117,128,0	script	Drawer#ko	844,{
	mes "There is some kind of device on the drawer.";
	next;
	switch(select("Stop.:Try to operate it.")){
		case 1:
			close;
		case 2:
			mes "Clank clunk clink";
			next;
			warp "amatsu",147,136;
			end;
}

OnEffect:
	misceffect EF_GUIDEDATTACK;
end;
}

job_ko,127,125,1	script	Red Leopard Joe#ko	730,{
	if (BaseJob!=Job_Ninja){
		for (set .i,5131; .i<5147; set.i,.i+1 ){
			if (checkquest(.i) != -1){erasequest .i;}
		}
		mes "[Red Leopard Joe]";
		mes "Sorry, Your family is not same as ours, is there something wrong?";
		close2;
		warp "amatsu",147,136;
		end;
	}
	/**/
	if (checkquest(5138)==1 && checkquest(5142)==-1 && checkquest(5143)==-1 && checkquest(5144)==-1 && checkquest(5145)==-1){
		mes "[Red Leopard Joe]";
		mes "Been a While";
		next;
		select("Long time indeed,Joe.");
		mes "[Red Leopard Joe]";
		mes "You aren't surprised I'm here. Did you meet ^0237FDCougar^000000 before coming here?";
		next;
		mes "[Red Leopard Joe]";
		mes "Don't like it that I'm not the first one you visited but that is not important.";
		next;
		mes "[Red Leopard Joe]";
		mes "Alright! "+strcharinfo(0);
		mes "Welcome to the workshop where weapons are created for the family.";
		next;
		mes "[Red Leopard Joe]";
		mes "Our family has been creating and using unique weapons to serve our secret missions since ancient times.";
		next;
		select("Really? At Einbroch?");
		mes "[Red Leopard Joe]";
		mes "Hmm? You are not as slow as I thought you were!";
		next;
		mes "[Red Leopard Joe]";
		mes "Yes. Einbroch is known as an industrial city, the city of great blacksmiths create new technology.";
		next;
		mes "[Red Leopard Joe]";
		mes "My mission is to analyze their technology and report back to the family.";
		next;
		mes "[Red Leopard Joe]";
		mes "I spoke more than I intended to.";
		next;
		mes "[Red Leopard Joe]";
		mes "Did you bring enough ^6848B7Iron Ore, Iron, Steel, Phracon, Emveretaron, Rough Oridecon, and Rough Elunium^000000?";
		next;
		mes "Let's now create a new prototype weapon.";
		next;
		donpcevent "Crafting Tools#ko_01::OnEffect";
		mes "[Red Leopard Joe]";
		mes "Feel free to use tools from here,";
		next;
		donpcevent "Crafting Tools#ko_02::OnEffect";
		mes "[Red Leopard Joe]";
		mes "there";
		next;
		donpcevent "Crafting Tools#ko_03::OnEffect";
		setquest 5142;	//Prototype-(1)
		mes "[Red Leopard Joe]";
		mes "and everywhere else. Now let's begin!!";
		close;
	}else if (checkquest(5138)==1 && checkquest(5142)==1 && checkquest(5143)==-1 && checkquest(5144)==-1 && checkquest(5145)==-1){
		mes "Are you done making the prototype of the new weapons?";
		switch(select("Crafting tools?:I don't have enough materials.:How do you expect me to make a weapon?")){
			case 1:
				next;
				donpcevent "Crafting Tools#ko_01::OnEffect";
				mes "[Red Leopard Joe]";
				mes "Feel free to use tools from there and";
				next;
				donpcevent "Crafting Tools#ko_02::OnEffect";
				mes "[Red Leopard Joe]";
				mes "there";
				next;
				donpcevent "Crafting Tools#ko_03::OnEffect";
				mes "[Red Leopard Joe]";
				mes "and anything else you can use";
				close;

			case 2:
				next;
				mes "[Red Leopard Joe]";
				mes "Are you done making the prototype of the new weapons?";
				next;
				mes "[Red Leopard Joe]";
				mes "You haven't brought enough materials?";
				next;
				donpcevent "Drawer#ko::OnEffect";
				mes "[Red Leopard Joe]";
				mes "Then we'll have to pay a visit to the village. Try the drawer over there. It'll take you to the village.";
				close;
				
			case 3:
				next;
				mes "[Red Leopard Joe]";
				mes "Hmm... Guess I expected too much? Let me explain.";
				next;
				mes "[Red Leopard Joe]";
				mes "You first have to melt the ore to use for the weapon. And the best way to get high purity metal is to melt materials that are of the same kind.";
				mes "For example, Iron Ore, Iron, and Steel are of similar property so you can get a high purity metal out of them.";
				next;
				mes "[Red Leopard Joe]";
				mes "Once you've melted a high purity metal, pour it in a mold to get the shape of the weapon and then make it firm through grinding and tempering.";
				next;
				mes "[Red Leopard Joe]";
				mes "By the way, you will get the best results by thoroughly rotating, grinding and tempering.";
				next;
				mes "[Red Leopard Joe]";
				mes "I think this is enough to get you started, don't you think? Now go and work on that prototype!!";
				close;

		}
	}else if (checkquest(5138)==1 && checkquest(5142)==-1 && (checkquest(5143)==1 || checkquest(5144)==1) && checkquest(5145)==-1){
		mes "[Red Leopard Joe]";
		mes "Are you done making the prototype of the new weapons?";
		switch(select("Crafting Tools?:I don't have enough materials:How do you expect me to make a weapon?:Yes, I'm done.")){
			case 1:
				next;
				donpcevent "Crafting Tools#ko_01::OnEffect";
				mes "[Red Leopard Joe]";
				mes "Feel free to use tools from there and";
				next;
				donpcevent "Crafting Tools#ko_02::OnEffect";
				mes "[Red Leopard Joe]";
				mes "there";
				next;
				donpcevent "Crafting Tools#ko_03::OnEffect";
				mes "[Red Leopard Joe]";
				mes "and anything else you can use";
				close;

			case 2:
				next;
				mes "[Red Leopard Joe]";
				mes "Are you done making the prototype of the new weapons?";
				next;
				mes "[Red Leopard Joe]";
				mes "You haven't brought enough materials?";
				next;
				donpcevent "Drawer#ko::OnEffect";
				mes "[Red Leopard Joe]";
				mes "Then we'll have to pay a visit to the village. Try the drawer over there. It'll take you to the village.";
				close;
				
			case 3:
				next;
				mes "[Red Leopard Joe]";
				mes "Hmm... Guess I expected too much? Let me explain.";
				next;
				mes "[Red Leopard Joe]";
				mes "You first have to melt the ore to use for the weapon. And the best way to get high purity metal is to melt materials that are of the same kind.";
				mes "For example, Iron Ore, Iron, and Steel are of similar property so you can get a high purity metal out of them.";
				next;
				mes "[Red Leopard Joe]";
				mes "Once you've melted a high purity metal, pour it in a mold to get the shape of the weapon and then make it firm through grinding and tempering.";
				next;
				mes "[Red Leopard Joe]";
				mes "By the way, you will get the best results by thoroughly rotating, grinding and tempering.";
				next;
				mes "[Red Leopard Joe]";
				mes "I think this is enough to get you started, don't you think? Now go and work on that prototype!!";
				close;
				
			case 4:
				next;
				if (countitem(13074)){
					mes "[Red Leopard Joe]";
					mes "Hmm... Interesting... Is it a dagger in a shape of a Kunai?";
					next;
					mes "[Red Leopard Joe]";
					mes "Very creative. I do see room for improvement but the weapon itself may come out useful after smoothing it out a bit.";
				}else if(countitem(13312)){
					mes "[Red Leopard Joe]";
					mes "Hmm... Is this an Ordinary Huuma?";
					next;
					mes "[Red Leopard Joe]";
					mes "Ahh, Its not an Ordinary Huuma.";
					mes "Very creative. I do see room for improvement but the weapon itself may come out useful after smoothing it out a bit.";
				}else{
					mes "[Red Leopard Joe]";
					mes "Ahh, How is it possible? You don't have weapons? maybe you equipped it?";
					close;
				}
				next;
				mes "[Red Leopard Joe]";
				mes "Good. I think you are ready.";
				mes "Now it's time to upgrade?";
				next;
				mes "[Red Leopard Joe]";
				mes "There are refinement tools on both sides of me. Use those to refine a weapon and come back.";
				next;
				mes "[Red Leopard Joe]";
				mes "I created the refinement tools myself with great effort so you won't have any trouble using them.";
				setquest 5145;	//Prototype-(3)
				mes "Ah... But just in case,";
				mes "^FF0000be careful not to cause trouble by showing these to blacksmiths outside of here.^000000";
				close;
		}
	}else if (checkquest(5138)==1 && checkquest(5142)==-1 && (checkquest(5143)==1 || checkquest(5144)==1) && checkquest(5145)==1){
		mes "[Red Leopard Joe]";
		mes "Did you get a successful result?";
		switch(select("Not yet.:Here it is.:Actually")){
			case 1:
				next;
				mes "[Red Leopard Joe]";
				mes "It isn't easy to get a satisfactory result at first.";
				close;
				
			case 3:
				next;
				mes "[Red Leopard Joe]";
				mes "You've lost the weapon even with my warning.";
				next;
				mes "[Red Leopard Joe]";
				mes "Nothing else we can do. Wait!";
				next;
				mes "Red Leopard Joe mumbles something and suddenly all weapons are unequipped.";
				nude;
				next;
				if(countitem(13074) || countitem(13312)) {
					mes "[Red Leopard Joe]";
					mes "What is this? You still have the prototype. Stop playing around.";
				} else {
					mes "[Red Leopard Joe]";
					mes "Oh! You really lost it.";
					next;
					setquest 5142;
					if(checkquest(5143)){erasequest 5143;}
					else{erasequest 5144;}
					erasequest 5145;
					mes "[Red Leopard Joe]";
					mes "Well! Lets try to make it again!";
				}
				close;
				
			case 2:
				next;
				mes "[Red Leopard Joe]";
				mes "Looks like you've got some results.";
				next;
				if (!getequipid(4)){
					mes "[Red Leopard Joe]";
					mes "Ahh! You have not equipped any weapons!";
					close;
				} else if (isequipped(13074) || isequipped(13312)){
					mes "[Red Leopard Joe]";
					mes "Is that weapon yours? Let me have a look.";
					next;
				} else {
					mes "[Red Leopard Joe]";
					mes "Hmm? But you didn't equip the weapon you were going to show me.";
					close;
				}
				mes "Joe took a thorough look at the seal.";
				next;
				if(getequiprefinerycnt(4) < 7){
					mes "[Red Leopard Joe]";
					mes "Are you that low?";
					mes "I've must have misjudged you. You might have been satisfied yourself but I'm not. Do it again!!";
					close;
				} else if (getequiprefinerycnt(4) > 6 && getequiprefinerycnt(4) < 9){
					mes "[Red Leopard Joe]";
					mes "Hmm... Is this your limit?";
					mes "You've just made it that close to passing. I will ask one more time, are you satisfied?";
					next;
					if(select("Yes:No")==2){
						mes "[Red Leopard Joe]";
						mes "You're still here. Why?";
						close;
					}
					mes "[Red Leopard Joe]";
					mes "Your competence is enough.";
				} else if (getequiprefinerycnt(4) > 8 && getequiprefinerycnt(4) < 13){
					mes "[Red Leopard Joe]";
					mes "Ahh, Nice, as I expected,";
					mes "I still believe that you will not stop here.";
					next;
					if(select("Yes:No")==2){
						mes "[Red Leopard Joe]";
						mes "I will look forward for your result.";
						close;
					}
					mes "[Red Leopard Joe]";
					mes "Your competence is enough.";
				} else {
					mes "[Red Leopard Joe]";
					mes "Better than Expected.";
					next;
					mes "[Red Leopard Joe]";
					mes "For beginners, quite good, This test may be little significant to you, Your competence is enough.";
				}
				next;
					mes "[Red Leopard Joe]";
					mes "I can feel it.";
					mes "I will take this weapon to give it some finishing touches";
					next;
					unequip 4;
					erasequest 5145;
					completequest 5138;
					if (checkquest(5143)==1){delitem 13074,1; completequest 5143;}
					else if(checkquest(5144)==1){delitem 13312,1; completequest 5144;}
					set KO_QD,KO_QD+4;
					set KO_Q,2;
					mes "[Red Leopard Joe]";
					mes "'"+strcharinfo(0)+"'";
					mes "Passed the weapon test!!";
					close;
		}
	}else if (checkquest(5138)==2 && checkquest(5142)==-1 && (checkquest(5143)==2 || checkquest(5144)==2) && checkquest(5145)==-1){
		mes "[Red Leopard Joe]";
		mes "Oh, I almost forgot";
		mes "Go report the test results to Gion";
		close2;
		warp "job_ko",26,104;
		end;
	}else{
		mes "[Red Leopard Joe]";
		mes "You should not come here..";
		mes "Put your feet away and get ready to go back.";
		close2;
		warp "amatsu",147,136;
		end;
	}
	}

	job_ko,131,124,1	script	Crafting Tools#ko_01	844,{
	if (checkquest(5138)==1 && checkquest(5142)==1 && checkquest(5143)==-1 && checkquest(5144)==-1 && checkquest(5145)==-1 ){
		function KO_WR; function KO_WC; function KO_PF;
		set @percent,0; 
		set KO_OPT,0; 
		set @wtype,0; 
		set @temp,0; 
		set @grind,0;
		mes "Tool to create weapons.";
		mes "First need to melt metals like iron and iron ore to use to create a weapon.";
		next;
		if (countitem(998) || countitem(999) || countitem(1002) || countitem(1010) || countitem(1011) || countitem(756) || countitem(757)){
			while(1){
				if (countitem(998) || countitem(999) || countitem(1002) || countitem(1010) || countitem(1011) || countitem(756) || countitem(757)){
					set KO_OPT, select("Melt iron ore.:Melt iron.:Melt steel.:Melt phracon.:Melt emveretarcon.:Melt rough oriecon.:Melt rough elunium.:Stop.");
					KO_WC(KO_OPT);
					if (@percent>49){set percent, @percent; break;}
					else if(@percent2>49){set percent,@percent2; break;}
				}else{mes "But you do not have any more metal to melt. Let's try again after getting more metal."; close;}
			}
			next;
			mes "Now the metal is melted to use for creating weapons.";
			next;
			mes "Next is to make the melted metal firm by pouring it into a mold. Which mold shape will you use?";
			set KO_OPT, select("Dagger Mold:Shuriken Mold");
			next;
			mes "Poured the melted metal into the "+((KO_OPT==1)?"dagger":"shuriken")+" mold.";
			next;
			progressbar "0xffff00",3;
			next;
			mes "Looks like the metal is taking shape. Now what next?";
			set @wtype, select("Grind the Weapon:Temper the weapon");
			while(1){
				KO_WR(@wtype-1);
				set @wtype, select("Grind the Weapon:Temper the weapon:Final Touches");
			}
			close;
		}else{mes "But you do not have any more metal to melt. Let's try again after getting more metal."; close;}
	}else{
		mes "A crafting tool.";
		mes "Don't really need it now.";
		close;
	}
	function	KO_WC	{	//Kagerou/Oboro	Weapon-Crafting
		switch(getarg(0)){
			case 1: set .@item,1002; break;
			case 2: set .@item,998; break;
			case 3: set .@item,999; break;
			case 4: set .@item,1010; break;
			case 5: set .@item,1011; break;
			case 6: set .@item,756; break;
			case 7: set .@item,757; break;
			case 8: close;
		}
		if (!countitem(.@item)) {mes "Don't have "+getitemname(.@item); next; return;}
		delitem .@item,1;
		if (.@item==1002 || .@item==1010){set @temp,1;}
		else if (.@item==998 || .@item==1011){set @temp,2;}
		else if (.@item==999 || .@item==756){set @temp,3;}
		else{set @temp,5;}
		if (getarg(0)<=3){
			set @percent,@percent+@temp;
			if(@percent2){set @percent2,@percent2-1;}
		}else if(getarg(0)>=4 && getarg(0)<=6){
			set @percent2,@percent2+@temp;
			if(@percent){set @percent,@percent-1;}
		}else{
			if(@percent){set @percent,@percent-5;}
			if(@percent2){set @percent2,@percent2-5;}
		}
		misceffect EF_DEMONSTRATION;
		mes "Melted "+getitemname(.@item)+" in high temperature.";
		next;
		mes "Which metal will be melted next?";
		next;
		return;
	}
	function	KO_WR	{	//Kagerou/Oboro	Weapon-Refining
		if (getarg(0)<=1){
			if (getarg(0)==0) {
				specialeffect2 EF_DETOXICATION;
				if(@temp==2){set @refine,@refine+1;}
				else{set @refine,@refine+2;}
			}
			else if (getarg(0)==1) {
				specialeffect2 EF_REPAIRWEAPON;
				if(@temp==1){set @refine,@refine+1;}
				else{set @refine,@refine+2;}
			}
			next;
			set @temp,getarg(0)+1;
			mes ((getarg(0)==0)?"Ground":"Tempered")+" the weapon";
			next;
			mes "Now what next?";
			return;
		}
		else if (getarg(0)==2){
			set @temp,percent+@refine;
		}
		mes "Start to sharpen the tool using a whetstone for finishing touches.";
		next;
		progressbar "0xffff00",3;
		if (@temp < 100){
			if (rand(1,100) == 77){KO_PF(0);}
			else{KO_PF(1);}
		}else{
			if (rand(1,100) == 44){KO_PF(1);}
			else{KO_PF(0);}
		}
		return;
	}
	function	KO_PF	{	//Kagerou/Oboro	PASS-FAIL
		if(getarg(0)==0){
			specialeffect2 EF_PERFECTION;
			if(KO_OPT==1){changequest 5142,5143; getitem 13074,1;}	//Ninja Cutter
			else if (KO_OPT==2){changequest 5142,5144; getitem 13312,1;}	//Huuma Ninja Job
			mes "The weapon was created successfully.";
			next;
			mes "Let's take it to Red Leopard Joe.";
			close;
		}else{
			specialeffect2 EF_SUI_EXPLOSION;
			mes "The weapon was destroyed while doing the finishing touches to it.";
			next;
			mes "There must have been something missed while creating the weapon. Very sad this happened but you'll have to start all over again.";
			close;
		}
		return;
		
	}

OnEffect:
	misceffect EF_GUIDEDATTACK;
end;
}

job_ko,121,121,1	script	Refinement Tools#ko_01	844,{
	if (checkquest(5138)==1 && checkquest(5142)==-1 && (checkquest(5143)==1 || checkquest(5144)==1) && checkquest(5145)==1){
	}
	else{
		mes "This tool helps you refine your weapons automatically. However you won't need this just now.";
		close;
	}
	mes "You turn on the refinement tool.";
	mes "The equipment starts up with a pleasant vibration.";
	next;
	mes "Looks like you can use the tool right away for refinement because it holds a good deal of Elunium and Oridecon within it.";
	if (select("Start refining.:Do not start refining.")==2){
		next;
		mes "You turned off the tool.";
		close;
	}
	next;
	if (getequipisenableref(4)==0 || getequipisidentify(4)==0){
		mes "Bzzzt";
		mes "A warning beep comes from the tool.";
		next;
		mes "[Red Leopard Joe]";
		mes "This equipment does not work without an equipped item to refine.";
		close;
	} else if ((KO_OPT==1 && isequipped(13074)==0) || (KO_OPT==2 && isequipped(13312)==0)){
		mes "Wait... this weapon is not a customized one.";
		next;
		mes "[Red Leopard Joe]";
		mes "Why don't you refine this with those hot-headed blacksmiths out there?";
		close;
	} else if (getequiprefinerycnt(4)>=20){
		mes "Bzzzt";
		mes "A warning beep comes from the tool.";
		next;
		mes "[Red Leopard Joe]";
		mes "This equipment is quite perfectly refined,Keep it for yourself..";
		close;
	}else if (getequippercentrefinery(4)<100){
		mes "Analyzing the weapon.";
		next;
		mes "This is very well refined equipment. Do you want to continue? Refine skill decreases by 1 if refinement fails.";
		switch(select("Continue.:Stop.")){
			case 2:
				next;
				mes "You turned off the tool.";
				close;
			case 1:
				next;
		}
	}
	progressbar "0xffff00",1;
	set @rand,rand(1,100);
	set @temp,0;
	if (getequiprefinerycnt(4) < 5){set @temp, 1;}
	else if (getequiprefinerycnt(4) == 5 && (@rand>=1 && @rand<41)){set @temp, 1;}
	else if (getequiprefinerycnt(4) == 6 && (@rand>=1 && @rand<31)){set @temp, 1;}
	else if (getequiprefinerycnt(4) == 7 && (@rand>=1 && @rand<21)){set @temp, 1;}
	else if (getequiprefinerycnt(4) == 8 && (@rand>=1 && @rand<11)){set @temp, 1;}
	else if (getequiprefinerycnt(4) == 9 && (@rand>=1 && @rand<6)){set @temp, 1;}
	else if (@rand>=1 && @rand < 3){set @temp, 1;}
	if (@temp){
		successrefitem 4;
		mes "Succeeded in refining.";
		close;
	} else {
		downrefitem 4;
		mes "Failed in refining.";
		mes "Your weapon refinement skill dropped by 1.";	//in dispbottom its, training point is adjusted downward? Any confirmation how to show this?
		close;	//It closes the dialog box.
	}
	close;
}


//Duplicates.
job_ko,129,129,1	duplicate(Crafting Tools#ko_01)	Crafting Tools#ko_02	844
job_ko,116,124,1	duplicate(Crafting Tools#ko_01)	Crafting Tools#ko_03	844
job_ko,127,121,1	duplicate(Refinement Tools#ko_01)	Refinement Tools#ko_02	844