//===== rAthena Script =======================================
//= Kagerou/Oboro Job Quest
//===== By: ==================================================
//= M45T3R, Dastgir Pojee, Euphy
//===== Current Version: =====================================
//= 1.0
//===== Compatible With: =====================================
//= rAthena Project
//===== Description: =========================================
//= [Official Conversion]
//= Job change Quest from Ninja -> Kagerou/Oboro.
//===== Additional Comments: =================================
//= 1.0 First version. Uses official script structure and text
//=     from iRO (ripped by M45T3R/Dastgir Pojee). [Euphy]
//============================================================

// Starting the Quest
//============================================================
que_ng,28,156,0	script	Start#ko	139,1,1,{
	end;
OnTouch:
	if (BaseLevel >= 99 && JobLevel >= 70 && job_kagero == 0 && Class == Job_Ninja) {
		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;
		set job_kagero,1;
		close;
	} else if (BaseJob != Job_Ninja && job_kagero > 0) {
		for (set .@i,5131; .@i<=5146; set .@i,.@i+1)
			if (isbegin_quest(.@i)) erasequest .@i;
		set job_kagero,0;
	}
	end;
}

que_ng,21,76,0	script	Wall with a Drawing#ko	844,{
	if (Class == Job_Oboro || Class == Job_Kagerou) {
		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 > 1 && Class == Job_Ninja) {
		mes "Entrance to the ^25C18DNinja Guild^000000 hideout.";
		next;
		if(select("Enter.:Do not enter.") == 2)
			close;
		mes "When touching the drawing, you get the feeling of being pulled..."; //custom translation
		close2;
		warp "job_ko",26,111;
		end;
	} else {
		mes "There is a wall with a great drawing on it.";
		close;
	}
	end;
}

job_ko,25,115,4	script	Old Man#ko	588,{
	if (MaxWeight - Weight < 1000 || checkweight(1201,1) == 0) {
		mes "[Kuuga Gai]";
		mes "You don't need to carry so many things."; //custom translation
		close;
	}
	if (BaseJob != Job_Ninja) {
		for (set .@i,5131; .@i<=5146; set .@i,.@i+1)
			if (isbegin_quest(.@i)) erasequest .@i;
		set job_kagero,0;
		mes "[Kuuga Gai]";
		mes "You are not in the clan of the 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;
		if(select("Ignore.:Talk to him.") == 1) {
			close2;
			cutin "",255;
			end;
		}
		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!";
		next;
		select("Excuse me... where am I?");
		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 clan 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 clan that was loyal to their lord who they served as their bright sun.";
		next;
		mes "[Old Man]";
		mes "...a very trustworthy clan...";
		next;
		mes "[Old Man]";
		mes "....loyal to their core...";
		next;
		mes "[Old Man]";
		mes "...a clan 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 clan that was abandoned by their lord and disappeared from history itself?";
		next;
		if(select("I'm a Ninja.:I'm bored.") == 2) {
			mes "[Old Man]";
			mes "Was nice to meet you.";
			close2;
			warp "amatsu",147,136;
			end;
		}
		cutin "job_ko02",2;
		mes "[Old Man]";
		mes "Ninja! There was a time when the clan was called ninjas, too.";
		next;
		erasequest 5131;
		setquest 5132;
		set job_kagero,2;
		mes "[Old Man]";
		mes "You'll have to lend me your ear for I have so much to tell you about the clan story.";
		close2;
		cutin "",255;
		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 clan 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 clan was known as the dark clan 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 clan's existence, tried to investigate them but nobody was able to reveal their true identity.";
		next;
		mes "[Old Man]";
		mes "That is why this clan has grown from loyal servants to a group feared for its secrets.";
		next;
		mes "[Old Man]";
		mes "The lord shunned the clan 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;
		erasequest 5132;
		setquest 5133;
		set job_kagero,3;
		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 clan 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 Leader Gion, the last of the dark ninja clan.";
		next;
		if(select("I think your time has ended.:I need your teaching.") == 1) {
			cutin "job_ko04",2;
			mes "[Leader Gion]";
			mes "Are you an assassin to end this old man's life?";
			next;
			mes "[Leader Gion]";
			mes "So that is why you've shown interest in my clan. I won't give up easily.";
			next;
			percentheal -99,0;
			mes "Pow!!";
			mes "^1A95E6You lose conscience with the great impact.^000000";
			close2;
			warp "amatsu",147,136;
			end;
		}
		cutin "job_ko02",2;
		mes "[Leader Gion]";
		mes "Teaching...";
		mes "Been a long time since I last heard that word.";
		next;
		mes "[Leader Gion]";
		mes "I guess this little visit was not by coincidence but a start of a connection.";
		next;
		mes "[Leader Gion]";
		mes "Sorry I am not a teacher. But!";
		next;
		mes "[Leader Gion]";
		mes "I can help you on the path you've chosen, the ^33CC71"+((Sex == SEX_MALE)?"Kagerou":"Oboro")+"^000000 path.";
		next;
		mes "^1A95E6You hear Leader Gion's voice faintly as you slip away.^1A95E6";
		next;
		erasequest 5133;
		setquest 5134;
		set job_kagero,4;
		mes "[Leader Gion]";
		mes "If you are prepared to follow me, Leader Gion, on the "+((Sex == SEX_MALE)?"Kagerou":"Oboro")+" path, we will meet again.";
		close2;
		warp "amatsu",147,136;
		end;
	} else if (job_kagero == 4) {
		cutin "job_ko02",2;
		mes "[Leader Gion]";
		mes "I thought you were afraid of the ^33CC71path of the "+((Sex == SEX_MALE)?"Kagerou":"Oboro")+"^33CC71 and wouldn't come back.";
		next;
		mes "[Leader Gion]";
		mes "But from the look of your eyes, I guess I misjudged you.";
		next;
		mes "[Leader 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 "[Leader Gion]";
		mes "Our ancestors had 4 tests to train our people.";
		next;
		select("4 tests?");
		cutin "job_ko01",2;
		mes "[Leader 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 "[Leader Gion]";
		mes "I know you are curious what these tests are. Let me explain one by one.";
		next;
		while(1) {
			set .@i, select("Test of Knowledge:Test of Survival:Test of Weaponry:Test of Battle");
			set .@test, .@test | (1<<(.@i-1));
			switch (.@i) {
			case 1:
				mes "[Leader Gion]";
				mes "We need to be knowledgeable in order to assist the lord. This test is for this purpose.";
				next;
				mes "[Leader Gion]";
				mes "You can pass the test if you successfully solve more than 9 out of 10 questions.";
				next;
				if (.@test != 15) {
					mes "[Leader 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?";
					next;
				}
				break;
			case 2:
				mes "[Leader Gion]";
				mes "Missions aren't always easy and safe. That is why survival instincts are vital to us.";
				next;
				mes "[Leader Gion]";
				mes "My ancestors call this test the dice test. It is a test to advance forward depending on the dice results.";
				next;
				mes "[Leader Gion]";
				mes "Think of it as the simple dice games people play.";
				next;
				mes "[Leader Gion]";
				mes "But never let your guard down during the test because it isn't called the survival test for nothing.";
				next;
				mes "[Leader Gion]";
				mes "There will be blocks that help you while there are blocks that will interrupt you.";
				next;
				if (.@test != 15) {
					mes "[Leader 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?";
					next;
				}
				break;
			case 3:
				mes "[Leader Gion]";
				mes "My clan was famous for using unique weapons that we created.";
				next;
				mes "[Leader Gion]";
				mes "You would be considered blessed if you created your own unique weapon.";
				next;
				mes "[Leader Gion]";
				mes "Creating a weapon for yourself and refining it is the purpose of this test.";
				next;
				if (.@test != 15) {
					mes "[Leader Gion]";
					mes "I hope you will be blessed and find the best weapon for yourself. Now what other test are you curious about?";
					next;
				}
				break;
			case 4:
				mes "[Leader Gion]";
				mes "Missions are not always done alone. You will often work in teams of 2 or 3 for a common goal.";
				next;
				mes "[Leader 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 "[Leader Gion]";
				mes "Unlike the other three tests that are done alone, you will have to compete with others in this final test.";
				next;
				mes "[Leader Gion]";
				mes "There is only one target!!";
				mes "And only the first to get to the target passes the test.";
				next;
				mes "[Leader Gion]";
				mes "You'll be lucky if you have no competitors during your test.";
				next;
				if (.@test != 15) {
					mes "[Leader Gion]";
					mes "A challenge is better than explaining it a hundred times. It's the actual experience that makes you better.";
					next;
				}
				break;
			}
			if (.@test == 15) break;
		}
		cutin "job_ko02",2;
		mes "[Leader Gion]";
		mes "Seeing is believing, so go on and take the challenge."; //custom translation
		next;
		erasequest 5134;
		setquest 5135;
		set job_kagero,5;
		mes "[Leader Gion]";
		mes "Let's start right away after you are done with preparations.";
		close2;
		cutin "",255;
		end;
	} else if (job_kagero == 5) {
		set .@ko_test_01, isbegin_quest(5136);
		set .@ko_test_02, isbegin_quest(5137);
		set .@ko_test_03, isbegin_quest(5138);
		set .@ko_test, .@ko_test_01 + .@ko_test_02 + .@ko_test_03;
		if (.@ko_test == 0) {
			cutin "job_ko03",2;
			mes "[Leader Gion]";
			mes "It's been a while.";
			next;
			mes "[Leader 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 "[Leader Gion]";
			mes "We're done with explaining about the tests, now should I tell you my clan story?";
			next;
			cutin "job_ko01",2;
			mes "[Leader Gion]";
			mes "My clan started from two warriors.";
			next;
			mes "[Leader Gion]";
			mes "Kagerou, a warrior like the dancing flames of the sun.";
			next;
			mes "[Leader Gion]";
			mes "Oboro, a warrior like the misty moonlight.";
			next;
			mes "[Leader 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 "[Leader Gion]";
			mes "There was a time there was an enmity between both warriors.";
			next;
			mes "[Leader Gion]";
			mes "But it didn't take long for them to become one as a clan.";
			next;
			select("How did it go afterwards?");
			cutin "job_ko02",2;
			mes "[Leader 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 "[Leader Gion]";
			mes "Which test will you select as your first test?";
			next;
			callsub L_StartTest,select("Test of Knowledge:Test of Survival:Test of Weaponry"),1;
			end;
		} else if (.@ko_test == 2) {
			cutin "job_ko01",2;
			mes "[Leader Gion]";
			if (.@ko_test_01 == 2) {
				set .@menu$,":Test of Survival:Test of Weaponry";
				mes "You've passed the Test of Knowledge.";
				next;
				mes "[Leader Gion]";
				mes "My friend doesn't approve of others that easily but I guess he liked you.";
				next;
			} else if (.@ko_test_02 == 2) {
				set .@menu$,"Test of Knowledge::Test of Weaponry";
				mes "You've passed the Test of Survival.";
				next;
				mes "[Leader Gion]";
				mes "Looks like you went through hell with this test.";
				next;
			} else if (.@ko_test_03 == 2) {
				set .@menu$,"Test of Knowledge:Test of Survival:";
				mes "You've passed the Test of Weaponry.";
				next;
				mes "[Leader Gion]";
				mes "I wonder if Joe is satisfied with your performance.";
				next;
			}
			select("Please continue with the clan story.");
			cutin "job_ko02",2;
			mes "[Leader Gion]";
			mes "Looks like you are pretty eager to hear more. Where did I leave off... Ah! I remember.";
			next;
			mes "[Leader Gion]";
			mes "Kagerou, a warrior like the dancing flames of the sun.";
			next;
			mes "[Leader Gion]";
			mes "Oboro, a warrior like the misty moonlight.";
			next;
			mes "[Leader Gion]";
			mes "Both warriors weren't close at first, because personality and everything else was completely opposite of each other.";
			next;
			mes "[Leader Gion]";
			mes "The first place they met was the battlefield. And you know how enemies greet each other on a battlefield.";
			next;
			mes "[Leader Gion]";
			mes "They ended up injuring each other badly.";
			next;
			mes "[Leader Gion]";
			mes "But what can you do? War is a war.";
			next;
			mes "[Leader Gion]";
			mes "The friend you've laughed with yesterday is a foe that you have to fight with in a war today.";
			next;
			mes "[Leader Gion]";
			mes "So nobody can get along with anyone during a war.";
			next;
			mes "[Leader Gion]";
			mes "I'll continue the story after you pass another test.";
			next;
			mes "[Leader Gion]";
			mes "Which test will you choose for the second test?";
			next;
			callsub L_StartTest,select(.@menu$),2;
			end;
		} else if (.@ko_test == 4) {
			cutin "job_ko04",2;
			mes "[Leader Gion]";
			if (.@ko_test_01 == 2 && .@ko_test_02 == 2) {
				set .@last_test,3;
				mes "You've passed the ^339CCCTests of Knowledge and Survival^000000!";
			} else if (.@ko_test_01 == 2 && .@ko_test_03 == 2) {
				set .@last_test,2;
				mes "You've passed the ^339CCCTests of Knowledge and Weaponry^000000!";
			} else if (.@ko_test_02 == 2 && .@ko_test_03 == 2) {
				set .@last_test,1;
				mes "You've passed the ^339CCCTests of Survival and Weaponry^000000!";
			}
			next;
			mes "[Leader Gion]";
			mes "You are already done with two tests. Hope you've learned a lot from them.";
			next;
			cutin "job_ko01",2;
			mes "[Leader Gion]";
			mes "Shall we continue with the story?";
			next;
			mes "[Leader Gion]";
			mes "Kagerou, a warrior like the dancing flames of the sun.";
			next;
			mes "[Leader Gion]";
			mes "Oboro, a warrior like the misty moonlight.";
			next;
			mes "[Leader Gion]";
			mes "I think I left off when the two warriors met at the battlefield as enemies.";
			next;
			mes "[Leader Gion]";
			mes "The long war ended eventually but the wounds and pain of those that survived had just started.";
			next;
			mes "[Leader Gion]";
			mes "So these two warriors started to embrace and heal the war wounds together and became one.";
			next;
			mes "[Leader 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 "[Leader Gion]";
			mes "There isn't much known about this man. Only a short mentioning of the two warriors pledging their allegiance.";
			next;
			mes "[Leader Gion]";
			mes "Maybe current generations like me are the ancestors of the current Amatsu lord? But this is only an assumption.";
			next;
			mes "[Leader Gion]";
			mes "I'm almost at the end of my clan story. Come back after you've passed the third test and I will tell you the rest.";
			next;
			callsub L_StartTest,.@last_test,3;
			end;
		} else if (.@ko_test == 6) {
			cutin "job_ko01",2;
			mes "[Leader Gion]";
			mes "You've gone through three tests leaving only one to pass.";
			next;
			mes "[Leader Gion]";
			mes "As I've told you before, the last test is different because you have to compete against others.";
			next;
			select("Will you continue the story?");
			cutin "job_ko02",2;
			mes "[Leader Gion]";
			mes "Ha ha ha. I will finish the story.";
			next;
			mes "[Leader Gion]";
			mes "Kagerou, a warrior like the dancing flames of the sun.";
			next;
			mes "[Leader Gion]";
			mes "Oboro, a warrior like the misty moonlight.";
			next;
			mes "[Leader Gion]";
			mes "It is told that the man that earned the loyalty of the two warriors was a humorous person.";
			next;
			mes "[Leader Gion]";
			mes "He like the jokes and conversations better than quarrels and he liked women over men.";
			next;
			mes "[Leader 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 "[Leader Gion]";
			mes "Both warriors did travel together after the war but kept an awkward distance from each other.";
			next;
			mes "[Leader 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.";
			next;
			select("Sounds like an odd person.");
			mes "[Leader Gion]";
			mes "Yes, he was. And his efforts didn't go in vain since the two warriors eventually got acquainted and married.";
			next;
			mes "[Leader Gion]";
			mes "This is how the clan started.";
			next;
			select("What happened after?");
			mes "[Leader Gion]";
			mes "Sadly, the next part of story was purposely discontinued.";
			next;
			mes "[Leader Gion]";
			mes "I think it's because someone wanted us to let go of the past and move forward.";
			next;
			mes "[Leader Gion]";
			mes "That's that. Now shouldn't you be preparing for the last test?";
			next;
			set job_kagero,6;
			mes "[Leader Gion]";
			mes "But you must be tired from all the tests so far. Take a rest.";
			close2;
			cutin "",255;
			end;
		} else if (.@ko_test == 1 || .@ko_test == 3 || .@ko_test == 5) {
			cutin "job_ko04",2;
			if (.@ko_test_01 == 1)
				set .@test_ko$, "Knowledge";
			else if (.@ko_test_02 == 1)
				set .@test_ko$, "Survival";
			else if (.@ko_test_03 == 1)
				set .@test_ko$, "Weaponry";
			mes "[Leader Gion]";
			mes "Weren't you taking the Test of " + .@test_ko$ + " just now?"; //custom translation
			next;
			switch(select("I want to go back to test site.:Ah... no.")) {
			case 1:
				mes "[Leader Gion]";
				mes "The Test of " + .@test_ko$ + " site is over here."; //custom translation(?)
				close2;
				if (.@ko_test_01 == 1)
					warp "job_ko",72,128;
				else if (.@ko_test_02 == 1)
					warp "job_ko",62,16;
				else if (.@ko_test_03 == 1)
					warp "job_ko",121,129;
				end;
			case 2:
				mes "[Leader Gion]";
				mes "The village is over here.";
				close2;
				warp "amatsu",147,136;
				end;
			}
		}
	} else if (job_kagero == 6) {
		cutin "job_ko01",2;
		mes "[Leader Gion]";
		mes "You've come back already? You could have rested more. Is there a reason to hurry?";
		next;
		input .@inputstr$;
		cutin "job_ko03",2;
		mes "[Leader Gion]";
		mes "Because of ^B24E59" + .@inputstr$ + "^000000?";
		next;
		mes "[Leader Gion]";
		mes "I have to admit, I don't understand you now.";
		next;
		mes "[Leader 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 "[Leader Gion]";
		mes "Now! No more small talk. I'll let you know what the target is for the Test of Battle.";
		next;
		mes "[Leader Gion]";
		mes "The target is a monster called the ^FF0000Clan Secret^000000.";
		next;
		mes "[Leader Gion]";
		mes "You will have to be careful because there are many similiar shaped and named monsters in test site.";
		next;
		mes "[Leader Gion]";
		mes "And if you are lucky, there will be others targeting the monster.";
		next;
		mes "[Leader Gion]";
		mes "May the blessings of '" + ((Sex == SEX_MALE)?"Kagerou, dancing sun":"Oboro, misty moonlight") + "' be with you.";
		next;
		setquest 5146;
		set job_kagero,7;
		mes "[Leader Gion]";
		mes "Then let's go to the battle test field.";
		close2;
		switch(rand(3)) {
			case 0: warp "job_ko",142,20; break;
			case 1: warp "job_ko",141,80; break;
			case 2: warp "job_ko",107,60; break;
		}
		end;
	} else if (job_kagero == 7 || job_kagero == 8) {
		cutin "job_ko03",2;
		mes "[Leader Gion]";
		mes "I see you are in the middle of the ^339CCCTest of Battle^000000. Will you go back to the test site?";
		next;
		switch(select("Go back to the test site.:Visit the village.")) {
		case 1:
			mes "[Leader Gion]";
			mes "The test site is over here."; //custom translation(?)
			close2;
			switch(rand(3)) {
				case 0: warp "job_ko",142,20; break;
				case 1: warp "job_ko",141,80; break;
				case 2: warp "job_ko",107,60; break;
			}
			end;
		case 2:
			mes "[Leader Gion]";
			mes "The village is over here.";
			close2;
			cutin "",255;
			end;
		}
	} else {
		cutin "job_ko03",2;
		mes "[Leader Gion]";
		mes "You should not be here. Leave!";
		close2;
		warp "amatsu",147,136;
		end;
	}
	end;

//callsub L_StartTest,<1=Knowledge,2=Survival,3=Weaponry>,<test number [1..3]>;
L_StartTest:
	switch (getarg(1)) {
		case 1: set .@str$,"You are starting with the ^339CCCTest of %s^000000? "; break;
		case 2: set .@str$,"You are taking the ^339CCCTest of %s^000000 as the second test? "; break; //custom translation
		case 3: set .@str$,"Your third test is the ^339CCCTest of %s^000000! "; break;
	}
	mes "[Leader Gion]";
	switch (getarg(0)) {
	case 1:
		mes sprintf(.@str$ + "Then I will get to see a familiar face after so long...","Knowledge");
		next;
		select("Familiar face?");
		setquest 5136;
		mes "[Leader Gion]";
		mes "Ha ha ha. You'll know when we get there. The Test of Knowledge is taken over here.";
		close2;
		warp "job_ko",72,128;
		end;
	case 2:
		mes sprintf(.@str$ + "It's a lonesome test that you have to face alone.","Survival");
		next;
		setquest 5137;
		mes "[Leader Gion]";
		mes "But I believe you can handle it. The Test of Survival is taken over here.";
		close2;
		warp "job_ko",62,16;
		end;
	case 3:
		mes sprintf(.@str$ + "I have something to give you before you go.","Weaponry");
		next;
		setquest 5138;
		getitem 1002,5; //Iron_Ore
		getitem 1010,1; //Phracon
		mes "You receive 5 Iron Ore and 1 Phracon.";
		next;
		mes "[Leader Gion]";
		mes "You will find these useful. The Test of Weaponry is taken over here.";
		close2;
		warp "job_ko",121,129;
		end;
	}
}

// Test of Knowledge
//============================================================
job_ko,81,124,4	script	Kuuga Gai#ko	730,{
	if (BaseJob != Job_Ninja) {
		for (set .@i,5131; .@i<=5146; set .@i,.@i+1)
			if (isbegin_quest(.@i)) erasequest .@i;
		set job_kagero,0;
		mes "[Kuuga Gai]";
		mes "Sorry, your clan is not same as ours, is there something wrong?";
		close2;
		warp "amatsu",147,136;
		end;
	}
	if (job_kagero != 5) {
		goto L_Kick;
	}
	if (MaxWeight - Weight < 1000 || checkweight(1201,1) == 0) {
		mes "[Kuuga Gai]";
		mes "This is a test of knowledge, so why did you bring so many things?"; //custom translation
		close;
	}
	set .@ko_test_01, isbegin_quest(5136);
	set .@ko_test_01_1, isbegin_quest(5139);
	if (.@ko_test_01 == 1 && .@ko_test_01_1 == 0) {
		mes "[Kuuga Gai]";
		mes "It's been a while.";
		next;
		select("Aren't you...");
		mes "[Kuuga Gai]";
		mes "I remember you from before looking for the way of the ninja.";
		next;
		mes "[Kuuga Gai]";
		mes "You've grown this strong already?";
		next;
		mes "[Kuuga Gai]";
		mes "Ha ha ha-";
		mes "A truly determined youth! I like that.";
		next;
		mes "[Kuuga Gai]";
		mes "Good! The test you are about to take is the ^339CCCTest of Knowledge^000000.";
		next;
		mes "[Kuuga Gai]";
		mes "I hope you haven't been lazy with your studies while focusing on getting stronger?";
		next;
		switch(select("Yes:No")) {
		case 1:
			setquest 5139;
			mes "[Kuuga Gai]";
			mes "That's a relief. Let me know when you are ready to start the test.";
			close;
		case 2:
			setquest 5139;
			mes "[Kuuga Gai]";
			mes "So you were all talk? Well, let me know when you are ready then.";
			close;
		}
	} else if (.@ko_test_01 == 1 && .@ko_test_01_1 == 1) {
		mes "[Kuuga Gai]";
		mes "I'm ready at my end. Are you ready for the test?";
		next;
		if(select("Yes:No") == 2) {
			mes "[Kuuga Gai]";
			mes "Well, what can I do but wait for you.";
			close;
		}
		mes "[Kuuga Gai]";
		mes "This isn't your first test, is it?";
		next;
		mes "[Kuuga Gai]";
		mes "You only need to choose the correct answer to my questions.";
		next;
		mes "[Kuuga Gai]";
		mes "Let's start.";
		next;

		set .@questions,10;  // number of questions to ask

		// shuffle array an array of questions to be asked
		freeloop(1);
		setarray .@n[0],
			1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,
			26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50;
		for (set .@i,getarraysize(.@n)-1; .@i>0; set .@i,.@i-1) {
			set .@rand, rand(.@i);
			set .@tmp, .@n[.@i];
			set .@n[.@i], .@n[.@rand];
			set .@n[.@rand], .@tmp;
		}
		deletearray .@n[10],getarraysize(.@n) - .@questions;
		freeloop(0);

		set @job_ko_Kuuga,0;
		for (set .@i,1; .@i<=.@questions; set .@i,.@i+1) {
			mes "[Kuuga Gai]";
			mes (.@i < .@questions)?"Question number "+.@i+":":"Last question:";
			switch (.@n[.@i-1]) {
				case 1: callsub L_Question,"What is the DEX + LUK total for a Job Master?",2,"8:10:12:14"; break;
				case 2: callsub L_Question,"What is the highest job level for a ninja?",1,"70:50:99:100"; break;
				case 3: callsub L_Question,"How many skill points do you need to master the Throw Coins skill?",3,"25:30:35:37"; break;
				case 4: callsub L_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: callsub L_Question,"How many skill points do you need to master the Cicada Skin Shed?",1,"5:3:1:4"; break;
				case 6: callsub L_Question,"If Dagger Throwing Practice is at 7, how much ATK is added to Shuriken attacks?",2,"18:21:27:30"; break;
				case 7: callsub L_Question,"What is the basic attack range for Throw Shuriken?",3,"7 blocks:8 blocks:9 blocks:10 blocks"; break;
				case 8: callsub L_Question,"What is the maximum moving range of Shadow Leap?",4,"6 blocks:7 blocks:8 blocks:9 blocks"; break;
				case 9: callsub L_Question,"How much money is used for Throw Coins level 6?",4,"2000-8000:1000-6000:3000-8000:3000-6000"; break;
				case 10: callsub L_Question,"What is the most important aspect of increasing ATK for the Killing Strike skill?",2,"VIT:MAXHP:INT:MAXSP"; break;
				case 11: callsub L_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: callsub L_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: callsub L_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: callsub L_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: callsub L_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: callsub L_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: callsub L_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: callsub L_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: callsub L_Question,"How much does STR/INT go up when Ninja Aura level 5 is used?",2,"4:5:6:7"; break;
				case 20: callsub L_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: callsub L_Question,"Which village is the Ninja Guild located in?",2,"Lutie:Amatsu:Dewata:Comodo"; break;
				case 22: callsub L_Question,"How do Ninjas get promoted?",3,"By Val Kiwi:By Randgris:None:By Valkyrie"; break;
				case 23: callsub L_Question,"What was next to me when you first met me?",4,"A cushion:A folding screen:A flowerpot:A brazier"; break;
				case 24: callsub L_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: callsub L_Question,"How many hits does a Throw Kunai give to a monster?",2,"2:3:4:5"; break;
				case 26: callsub L_Question,"When your First Wind is at level 4, what will go with the MATK and range?",3,"MATK400, 8 blocks:MATK500, 7 blocks:MATK500, 8 blocks:MATK400, 7 blocks"; break;
				case 27: callsub L_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: callsub L_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: callsub L_Question,"What is the attack range for the Exploding Dragon?",3,"3*3:4*4:5*5:6*6"; break;
				case 30: callsub L_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: callsub L_Question,"What is the attack effect for Haze Slasher level 4?",1,"140%:150%:160%:170%"; break;
				case 32: callsub L_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: callsub L_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: callsub L_Question,"What is the maximum hit number for Blaze Shield level 10?",3,"7:8:9:10"; break;
				case 35: callsub L_Question,"What is the property of the Lightning Jolt?",4,"Fire:Water:Ground:Wind"; break;
				case 36: callsub L_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: callsub L_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: callsub L_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: callsub L_Question,"Which NPC promotes you?",1,"Valkyrie:Val Kiwi:Balp Hiri:Elephant"; break;
				case 40: callsub L_Question,"Which catalyst do you need to use the Blaze Shield skill?",2,"Ice Stone:Flame Stone:Wind Stone:Earth Stone"; break;
				case 41: callsub L_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: callsub L_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: callsub L_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: callsub L_Question,"Which Ninja Mastery skill level do you need to learn the Exploding Dragon skill?",1,"10:9:8:1"; break;
				case 45: callsub L_Question,"What is the attack range when you master Flip Tatami?",3,"5:7:3:1"; break;
				case 46: callsub L_Question,"What weapon cannot be made by the blacksmith Khaibara?",4,"Khukri:Murasame:Hakujin:Humma Wing Shuriken"; break;
				case 47: callsub L_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: callsub L_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: callsub L_Question,"Which of the following blacksmiths do not create ninja items?",2,"Khaibara:Aiku:Tetsu:Toshu"; break;
				case 50: callsub L_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 "[Kuuga Gai]";
					mes "An unknown error has occurred.";
					mes "Please contact customer service.";
					close;
			}
		}
		mes "[Kuuga Gai]";
		mes "You're through all 10 questions. Wasn't so bad! The important part starts now.";
		next;
		mes "[Kuuga Gai]";
		mes "... ... ...";
		next;
		if (@job_ko_Kuuga < 90) {
			mes "[Kuuga Gai]";
			mes "You fool!!";
			mes "You couldn't even solve these?";
			next;
			mes "[Kuuga Gai]";
			mes "Can't believe someone who is taking a new path can be so pathetic.";
			next;
			mes "[Kuuga Gai]";
			mes "I'll give you another chance.";
			mes "You will take the test again with new questions. Better pass it this time.";
		} else {
			mes "[Kuuga Gai]";
			mes "Hmm. " + (@job_ko_Kuuga) + "?";
			next;
			mes "[Kuuga Gai]";
			mes "Well, looks like you weren't lazy with your studies.";
			next;
			mes "[Kuuga Gai]";
			mes "What? Proud of yourself for solving these questions?";
			next;
			mes "[Kuuga Gai]";
			mes "You still have a long way to go and this is only a small fraction of it.";
			next;
			mes "[Kuuga Gai]";
			mes "Well... I'm curious how far your strong will can take you through other tests.";
			next;
			completequest 5136;
			erasequest 5139;
			mes "[Kuuga Gai]";
			mes "I'll let you go now so go report back to Leader Gion with your results.";
			close2;
			warp "job_ko",16,113;
			end;
		}
		set @job_ko_Kuuga,0;
		close;
	} else if (.@ko_test_01 == 2 && .@ko_test_01_1 == 0) {
		mes "[Kuuga Gai]";
		mes "I'll let you go now so go report back to Leader Gion with your results.";
		close2;
		warp "job_ko",16,113;
		end;
	} else {  //custom translation
	L_Kick:
		mes "[Kuuga Gai]";
		mes "How did you get here?";
		next;
		mes "[Kuuga Gai]";
		mes "It's my duty to get rid of you.";
		mes "^000099(He's a short, silent man.)^000000";
		mes "This will push you back!";
		close2;
		warp "amatsu",147,136;
		end;
	}
	end;

//callsub L_Question,"<Question>",<correct answer choice>,"<Choice 1>:<Choice 2>:<Choice 3>:<Choice 4>";
L_Question:
	mes getarg(0);
	next;
	if(select(getarg(2)) == getarg(1))
		set @job_ko_Kuuga, @job_ko_Kuuga + 10;
	return;
}

// Test of Survival
//============================================================

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

function	script	F_KO_Survival_warp	{
	close2;
	switch (getarg(0)) {
		case  0: warp "job_ko",63,16; break;
		case  1: warp "job_ko",54,16; break;
		case  2: warp "job_ko",46,16; break;
		case  3: warp "job_ko",38,16; break;
		case  4: warp "job_ko",30,16; break;
		case  5: warp "job_ko",22,16; break;
		case  6: warp "job_ko",17,19; break;
		case  7: warp "job_ko",17,27; break;
		case  8: warp "job_ko",17,35; break;
		case  9: warp "job_ko",17,43; break;
		case 10: warp "job_ko",17,51; break;
		case 11: warp "job_ko",17,60; break;
		case 12: warp "job_ko",25,60; break;
		case 13: warp "job_ko",33,60; break;
		case 14: warp "job_ko",41,60; break;
		case 15: warp "job_ko",49,60; break;
		case 16: warp "job_ko",57,60; break;
		case 17: warp "job_ko",62,56; break;
		case 18: warp "job_ko",62,48; break;
		case 19: warp "job_ko",62,40; break;
		case 20: warp "job_ko",62,32; break;
		case 21: warp "job_ko",62,23; break;
		case 22: warp "job_ko",54,23; break;
		case 23: warp "job_ko",46,23; break;
		case 24: warp "job_ko",38,23; break;
		case 25: warp "job_ko",30,23; break;
		case 26: warp "job_ko",25,27; break;
		case 27: warp "job_ko",25,35; break;
		case 28: warp "job_ko",25,43; break;
		case 29: warp "job_ko",25,52; break;
		case 30: warp "job_ko",33,52; break;
		case 31: warp "job_ko",41,52; break;
		case 32: warp "job_ko",49,52; break;
		case 33: warp "job_ko",54,48; break;
		case 34: warp "job_ko",54,40; break;
		case 35: warp "job_ko",54,31; break;
		case 36: warp "job_ko",46,31; break;
		case 37: warp "job_ko",38,31; break;
		case 38: warp "job_ko",33,35; break;
		case 39: warp "job_ko",33,44; break;
		case 40: warp "job_ko",41,44; break;
	}
	end;
}

//callfunc "F_KO_Survival_dice",<location>{,<LP (default:1)>{,<0:auto-warp (default), 1:do not warp>}}
//Return: dice value [1..6] ONLY IF arg2 = 1
function	script	F_KO_Survival_dice	{
	mes "Location: " + getarg(0);
	mes "Total LP: " + job_kagero_lp;
	mes "To roll the dice, you need to consume " + getarg(1,1) + " ^FD0260LP^000000.";
	next;
	select("Roll the dice.");
	if (job_kagero_lp < getarg(1,1)) {
		mes "Due to insufficient ^FD0260LP^000000, you will be returned to starting position.";
		callfunc "F_KO_Survival_warp",0;
		end;
	}
	set job_kagero_lp, job_kagero_lp - getarg(1,1);
	set .@dice, rand(1,6);
	emotion ET_OTL + .@dice, playerattached();
	mes "The dice came out as " + .@dice + ".";
	if (getarg(2,0))
		return .@dice;
	else {
		mes "Press Close to move forward " + .@dice + " blocks.";
		callfunc "F_KO_Survival_warp", .@dice + getarg(0);
		end;
	}
}

//callfunc "F_KO_Survival_dice2",<location>{,<LP (default:2)>}
function	script	F_KO_Survival_dice2	{
	mes "Location: " + getarg(0);
	mes "Total LP: " + job_kagero_lp;
	mes "To roll the dice, you need to consume " + getarg(1,2) + " ^FD0260LP^000000.";
	next;
	select("Roll the first dice.");
	if (job_kagero_lp < getarg(1,2)) {
		mes "Due to insufficient ^FD0260LP^000000, you will be returned to starting position.";
		callfunc "F_KO_Survival_warp",0;
		end;
	}
	set job_kagero_lp, job_kagero_lp - getarg(1,2);
	mes "< Used " + getarg(1,2) + " LP >";
	next;
	set @job_ko_dice1, rand(1,6);
	emotion ET_OTL + @job_ko_dice1, playerattached();
	mes "First dice result is " + @job_ko_dice1 + ". Do you want to roll the second dice?";
	next;
	select("Roll the second dice.");
	set @job_ko_dice2, rand(1,6);
	emotion ET_OTL + @job_ko_dice2, playerattached();
	return;
}

//Return: 1:win, 0:draw, -1:lose
function	script	F_KO_Survival_rps	{
	setarray .@rps$[1], "Scissors", "Rock", "Paper";
	setarray .@emote[1], ET_SCISSOR, ET_ROCK, ET_WRAP;  //might be iRO custom(?)

	mes "Rock! Paper! Scissors!";
	next;
	set .@pc, select("Give scissors.:Give rock.:Give paper.");
	set .@npc, rand(1,3);
	emotion .@emote[.@pc], playerattached();
	emotion .@emote[.@npc];
	mes "=Game Results=";
	mes "Machine: " + .@rps$[.@npc] + ".";
	mes "You: " + .@rps$[.@pc] + ".";
	next;
	if ((.@npc == 1 && .@pc == 2) || (.@npc == 2 && .@pc == 3) || (.@npc == 3 && .@pc == 1)) {
		mes "You Win";
		return 1;
	} else if (.@pc == .@npc) {
		mes "Draw";
		return 0;
	} else if ((.@npc == 1 && .@pc == 3) || (.@npc == 2 && .@pc == 1) || (.@npc == 3 && .@pc == 2)) {
		mes "You Lose";
		return -1;
	} else {
		mes "An unknown error has occurred.";
		mes "Please contact customer service.";
		close;
	}
}

// -----------------------------------------------------------
//  Templates
// -----------------------------------------------------------
-	script	Sight#ko_trap	-1,{
	callfunc "F_KO_Survival_mes", atoi(substr(strnpcinfo(2),3,4));
	end;
OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	switch (atoi(substr(strnpcinfo(2),3,4))) {
		case  2: set .@id,0; break;
		case  7: set .@id,5; break;
		case 11: set .@id,9; break;
		case 23: set .@id,18; break;
		case 26: set .@id,20; break;
		case 30: set .@id,9; break;
		case 35: set .@id,29; break;
	}
	mes "This block has a trap.";
	mes "Press Close to go back to block " + .@id + ".";
	callfunc "F_KO_Survival_warp", .@id;
	end;
}

-	script	Sight#ko_trap2	-1,{
	callfunc "F_KO_Survival_mes", atoi(substr(strnpcinfo(2),3,4));
	end;
OnTouch:
	set .@id, atoi(substr(strnpcinfo(2),3,4));
	switch (.@id) {
		case 10: set .@var$, "$20110808_vko01"; break;
		case 28: set .@var$, "$20110808_vko03"; break;
		//case 38: set .@var$, "$20110808_vko04"; break;
	}
	mes "There are tiny letters on the sign.";
	next;
	mes "If you don't want to be caught, install a trap.";
	next;
	if (getd(.@var$) == 0) {
		mes "There is currently no trap installed.";
		next;
		mes "Do you want to use 10 ^FD0260LP^000000 to install a trap?";
		next;
		if(select("Install a trap.:Roll the Dice.") == 1) {
			if (job_kagero_lp > 9) {
				mes "< Used 10 LP >";
				set job_kagero_lp, job_kagero_lp - 10;
				setd .@var$,1;
				next;
				mes "The trap is installed. Please roll the dice.";
				next;
			} else {
				mes "< Did not use 10 LP >";
				mes "^FD0260LP^000000 insufficient! Please roll the dice.";
				next;
			}
		}
	} else {
		set job_kagero_lp,0;
		setd .@var$,0;
		mes "You are caught in the trap installed.";
		mes "Press Close to go back to block 0.";
		callfunc "F_KO_Survival_warp",0;
		end;
	}
	callfunc "F_KO_Survival_dice",.@id;
	end;
}

-	script	Sight#ko_heal	-1,{
	callfunc "F_KO_Survival_mes", atoi(substr(strnpcinfo(2),3,4));
	end;
OnTouch:
	set .@id, atoi(substr(strnpcinfo(2),3,4));
	mes "There are tiny letters on the sign.";
	next;
	mes "This block is blessed.";
	mes "Life Point recovers 7 ^FD0260LP^000000.";
	mes "Cannot exceed maximum 100 ^FD0260LP^000000.";
	next;
	mes "< Recovered " + ((job_kagero_lp + 7 > 100) ? "" : "7") + " LP >";
	next;
	set job_kagero_lp, ((job_kagero_lp + 7 > 100) ? 100 : job_kagero_lp + 7);
	callfunc "F_KO_Survival_dice",.@id;
	end;
}

-	script	Sight#ko_curse	-1,{
	callfunc "F_KO_Survival_mes", atoi(substr(strnpcinfo(2),3,4));
	end;
OnTouch:
	set .@id, atoi(substr(strnpcinfo(2),3,4));
	set .@playtime, checkquest(5141,PLAYTIME);
	if (.@playtime == -1) {
		mes "There are tiny letters on the sign.";
		next;
		mes "If you do not pay 5 ^FD0260LP^000000, you will be cursed and immobilized for 2 minutes.";
		next;
		if(select("Use 5 LP:Do not pay.") == 1) {
			if (job_kagero_lp > 4) {
				set job_kagero_lp, job_kagero_lp - 5;
				mes "<Used 5 LP>";
				mes "You can roll the dice.";
				next;
				callfunc "F_KO_Survival_dice",.@id;
				end;
			} else {
				mes "< Did not use 5 LP >";
				mes "Could not withstand the curse.";  //custom translation
				next;
			}
		}
		setquest 5141;
		mes "You are cursed and cannot move to any other block for 2 minutes.";
		close;
	} else if (.@playtime == 0 || .@playtime == 1) {
		mes "You are cursed and cannot move to any other block for 2 minutes.";
		close;
	} else if (.@playtime == 2) {
		mes "The immobilize curse lasted for 2 minutes and then was removed.";
		next;
		erasequest 5141;
		callfunc "F_KO_Survival_dice",.@id;
		end;
	} else {
		erasequest 5141;
		mes "An unknown error has occurred.";
		mes "Please contact customer service.";
		close;
	}
}

-	script	Sight#ko_gravity	-1,{
	callfunc "F_KO_Survival_mes", atoi(substr(strnpcinfo(2),3,4));
	end;
OnTouch:
	set .@id, atoi(substr(strnpcinfo(2),3,4));
	mes "There are tiny letters on the sign.";
	next;
	mes "Area cursed with 10 times the normal gravity. You will need 10 ^FD0260LP^000000 to roll the dice.";
	next;
	callfunc "F_KO_Survival_dice",.@id,10;
	end;
}

// -----------------------------------------------------------
//  Blocks (00-40)
// -----------------------------------------------------------

job_ko,57,16,4	script	Sight#ko_00	858,1,1,{
	callfunc "F_KO_Survival_mes",0;
	end;
OnTouch:
	if (job_kagero != 5) {
		mes "You should not be here.";  //custom translation
		close2;
		warp "amatsu",147,136;
		end;
	}
	if (isbegin_quest(5137) == 1 && isbegin_quest(5140) == 0) {
		mes "There are tiny letters on the sign.";
		next;
		callsub L_Description;
		setquest 5140;
		set job_kagero_lp,100;
		mes "You've gained 100 Life Points (LP).";
		next;
	} else {
		if (checkquest(5141,PLAYTIME) > -1)
			erasequest 5141;
		set job_kagero_lp,100;
		mes "You've returned to the first block. Your LP is recovered.";
		next;
		callsub L_Description;
	}
	callfunc "F_KO_Survival_dice",0;
	end;

L_Description:
	while (1) {
		if(select("Read the description.:Start the test.") == 2)
			break;
		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;
	}
	return;
}

job_ko,49,16,4	script	Sight#ko_01	858,1,1,{
	callfunc "F_KO_Survival_mes",1;
	end;
OnTouch:
	set .@life_p, job_kagero_lp;
	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;
	if(select("Use 10 LP:Roll the dice.") == 1) {
		if (job_kagero_lp > 9) {
			set .@reset_p, .@life_p - 10;
			set job_kagero_lp, .@reset_p;
			mes "< Used 10 LP >";
			mes "Press Close to move to block 9.";
			callfunc "F_KO_Survival_warp",9;
			end;
		} else {
			mes "< Did not use 10 LP >";
			mes "^FD0260LP^000000 insufficient!";
			next;
		}
	}
	mes "Roll the dice.";
	next;
	callfunc "F_KO_Survival_dice",1;
	end;
}

job_ko,41,16,4	duplicate(Sight#ko_trap)	Sight#ko_02	858,1,1

job_ko,33,16,4	script	Sight#ko_03	858,1,1,{
	callfunc "F_KO_Survival_mes",3;
	end;
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;
	select("Use 5 LP");
	if (job_kagero_lp > 4) {
		mes "< Used 5 LP >";
		set job_kagero_lp, job_kagero_lp - 5;
		callfunc "F_KO_Survival_dice",3;
	} else {
		mes "< Did not use 5 LP >";
		mes "^FD0260LP^000000 insufficient! Returning to start location.";
		callfunc "F_KO_Survival_warp",0;
	}
	end;
}

job_ko,25,16,4	script	Sight#ko_04	858,1,1,{
	callfunc "F_KO_Survival_mes",4;
	end;
OnTouch:
	mes "There are tiny letters scribbled on the sign.";
	next;
	if ($20110808_sko01$ != "") {
		mes "^0000FF" + $20110808_sko01$ +" was here.^000000";
		next;
	}
	mes "Should I leave my name since taking the test is a special occasion?";
	next;
	if(select("Use 5 LP and leave your name.:Continue to roll the dice.") == 1) {
		if (job_kagero_lp > 4) {
			mes "< Used 5 LP >";
			set job_kagero_lp, job_kagero_lp - 5;
			next;
			set $20110808_sko01$, strcharinfo(0);
			mes strcharinfo(0)+" was here.";
			mes "You left your name.";
			next;
		} else {
			mes "< Did not use 5 LP >";
			mes "^FD0260LP^000000 insufficient! You can roll the dice.";
			next;
		}
	}
	callfunc "F_KO_Survival_dice",4;
	end;
}

job_ko,17,16,4	duplicate(Sight#ko_curse)	Sight#ko_05	858,1,1

job_ko,17,24,4	duplicate(Sight#ko_heal)	Sight#ko_06	858,1,1

job_ko,17,32,4	duplicate(Sight#ko_trap)	Sight#ko_07	858,1,1

job_ko,17,40,4	script	Sight#ko_08	858,1,1,{
	callfunc "F_KO_Survival_mes",8;
	end;
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;
	switch (callfunc("F_KO_Survival_rps")) {
	case 1:
		mes "Press Close to move to block 15.";
		callfunc "F_KO_Survival_warp",15;
		end;
	case 0:
		mes "A tie, so roll the dice!";
		next;
		callfunc "F_KO_Survival_dice",8;
		end;
	case -1:
		mes "Press Close to move to block 0.";
		callfunc "F_KO_Survival_warp",0;
		end;
	}
}

job_ko,17,48,4	script	Sight#ko_09	858,1,1,{
	callfunc "F_KO_Survival_mes",9;
	end;
OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Please proceed.";
	next;
	callfunc "F_KO_Survival_dice",9;
	end;
}

job_ko,17,56,4	duplicate(Sight#ko_trap2)	Sight#ko_10	858,1,1

job_ko,22,60,4	duplicate(Sight#ko_trap)	Sight#ko_11	858,1,1

job_ko,30,60,4	script	Sight#ko_12	858,1,1,{
	callfunc "F_KO_Survival_mes",12;
	end;
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;
	switch (callfunc("F_KO_Survival_rps")) {
	case 1:
		mes "Press Close to move to block 20.";
		callfunc "F_KO_Survival_warp",20;
		end;
	case 0:
		mes "A tie, so roll the dice!";
		next;
		callfunc "F_KO_Survival_dice",12;
		end;
	case -1:
		mes "Press Close to move to block 9.";
		callfunc "F_KO_Survival_warp",9;
		end;
	}
}

job_ko,38,60,4	duplicate(Sight#ko_heal)	Sight#ko_13	858,1,1

job_ko,46,60,4	duplicate(Sight#ko_curse)	Sight#ko_14	858,1,1

job_ko,54,60,4	script	Sight#ko_15	858,1,1,{
	callfunc "F_KO_Survival_mes",15;
	end;
OnTouch:
	set .@playtime, checkquest(5141,PLAYTIME);
	if (.@playtime == -1) {
		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;
	} else if (.@playtime == 0 || .@playtime == 1) {
		mes "You are cursed and cannot move to any other block for 2 minutes.";
		close;
	} else if (.@playtime == 2) {
		mes "The immobilize curse lasted for 2 minutes and then was removed.";
		next;
		erasequest 5141;
		callfunc "F_KO_Survival_dice",15;
		end;
	} else {
		erasequest 5141;
		mes "An unknown error has occurred.";
		mes "Please contact customer service.";
		close;
	}
}

job_ko,62,60,4	script	Sight#ko_16	858,1,1,{
	callfunc "F_KO_Survival_mes",16;
	end;
OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Consume 2 ^FD0260LP^000000 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 "F_KO_Survival_dice2",16;
		if (@job_ko_dice1 == @job_ko_dice2) break;
		else {
			mes "Second dice result is " + @job_ko_dice2 + ", which is not the same number.";  //custom translation
			next;
		}
	}
	set @job_ko_dice1,0;
	set @job_ko_dice2,0;
	//mes "Second dice result is " + @job_ko_dice2 + ", which is the same number. Press Close to move block 30.";
	mes "You got the same number. Press Close to move block 30.";
	callfunc "F_KO_Survival_warp",30;
	end;
}

job_ko,62,51,4	duplicate(Sight#ko_gravity)	Sight#ko_17	858,1,1

job_ko,62,43,4	script	Sight#ko_18	858,1,1,{
	callfunc "F_KO_Survival_mes",18;
	end;
OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Consume 2 ^FD0260LP^000000 and roll the dice twice.";
	next;
	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.";
	next;
	callfunc "F_KO_Survival_dice2",18;
	mes "Second dice result is " + @job_ko_dice2 + ".";
	next;
	set .@dice_sum, @job_ko_dice1 + @job_ko_dice2;
	mes @job_ko_dice1 + " + " + @job_ko_dice2 + " = " + .@dice_sum;
	set @job_ko_dice1,0;
	set @job_ko_dice2,0;
	if (.@dice_sum < 5) {
		mes "You total is lower than 5. Press Close to move to block 30.";
		callfunc "F_KO_Survival_warp",30;
		end;
	} else {
		mes "You total is larger than 5. Press Close to move to block 19.";
		callfunc "F_KO_Survival_warp",19;
		end;
	}
}

job_ko,62,35,4	script	Sight#ko_19	858,1,1,{
	callfunc "F_KO_Survival_mes",19;
	end;
OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Move forward.";
	next;
	callfunc "F_KO_Survival_dice",19;
	end;
}

job_ko,62,27,4	duplicate(Sight#ko_heal)	Sight#ko_20	858,1,1

job_ko,57,23,4	duplicate(Sight#ko_gravity)	Sight#ko_21	858,1,1

job_ko,49,23,4	script	Sight#ko_22	858,1,1,{
	callfunc "F_KO_Survival_mes",22;
	end;
OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Leave all your remaining ^FD0260LP^000000 and go back to block 0, then the next person will be redeemed.";
	next;
	if ($20110808_vko02 == 0) {
		mes "Do you want to leave your ^FD0260LP^000000?";
		mes "If you leave your ^FD0260LP^000000 then the next person for test that arrives at the block will automatically pass the test.";
		next;
		if(select("Leave all your LP.:Continue to roll the dice.") == 1) {
			set job_kagero_lp,0;
			set $20110808_vko02,1;
			mes "Leave all remaining ^FD0260LP^000000 here. Press Close and go back to block 0.";
			callfunc "F_KO_Survival_warp",0;
			end;
		}
	} else if ($20110808_vko02 == 1) {
		set $20110808_vko02,0;
		mes "Someone before you sacrificed all their ^FD0260LP^000000, so press Close and go to the last block."; //custom translation
		callfunc "F_KO_Survival_warp",40;
		end;
	} else {
		mes "An unknown error has occurred.";
		mes "Please contact customer service.";
		close;
	}
	callfunc "F_KO_Survival_dice",22;
	end;
}

job_ko,41,23,4	duplicate(Sight#ko_trap)	Sight#ko_23	858,1,1

job_ko,33,23,4	script	Sight#ko_24	858,1,1,{
	callfunc "F_KO_Survival_mes",24;
	end;
OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Consume 2 ^FD0260LP^000000 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 "F_KO_Survival_dice2",24;
	mes "Second dice result is " + @job_ko_dice2 + ".";
	next;
	set .@dice_sum, @job_ko_dice1 + @job_ko_dice2;
	if (.@dice_sum > 8) {
		mes @job_ko_dice1 + " + " + @job_ko_dice2 + " = " + .@dice_sum;
		set @job_ko_dice1,0;
		set @job_ko_dice2,0;
		mes "You total is larger than 8. Please choose a block to move between blocks 25 through 30.";
		callfunc "F_KO_Survival_warp", select("Move to block 25:Move to block 26:Move to block 27:Move to block 28:Move to block 29:Move to block 30") + 24;
		end;
	} else {
		set @job_ko_dice1,0;
		set @job_ko_dice2,0;
		mes "You total is lower than 8. Press Close to move to block 19.";
		callfunc "F_KO_Survival_warp",19;
		end;
	}
}

job_ko,25,23,4	script	Sight#ko_25	858,1,1,{
	callfunc "F_KO_Survival_mes",25;
	end;
OnTouch:
	set .@playtime, checkquest(5141,PLAYTIME);
	if (.@playtime == -1) {
		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.";
		next;
		switch(select("Try something.:Do nothing.")) {
		case 1:
			specialeffect2 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:
			if (rand(1,10) == 4) {
				mes "Its a wise decision to do nothing.";
				next;
			} else {
				mes "Nothing happened. Still need to do something.";
				close;
			}
			break;
		}
	} else if (.@playtime == 0 || .@playtime == 1) {
		mes "Cannot move because you are cursed.";
		close;
	} else if (.@playtime == 2) {
		mes "The immobilize curse lasted for 2 minutes and then was removed.";
		next;
		erasequest 5141;
	} else {
		erasequest 5141;
		mes "An unknown error has occurred.";
		mes "Please contact customer service.";
		close;
	}
	callfunc "F_KO_Survival_dice",25;
	end;
}

job_ko,25,32,4	duplicate(Sight#ko_trap)	Sight#ko_26	858,1,1

job_ko,25,40,4	duplicate(Sight#ko_heal)	Sight#ko_27	858,1,1

job_ko,25,48,4	duplicate(Sight#ko_trap2)	Sight#ko_28	858,1,1

job_ko,30,52,4	script	Sight#ko_29	858,1,1,{
	callfunc "F_KO_Survival_mes",29;
	end;
OnTouch:
	mes "There are tiny letters on the sign.";
	next;
	mes "Go forth.";
	next;
	callfunc "F_KO_Survival_dice",29;
	end;
}

job_ko,38,52,4	duplicate(Sight#ko_trap)	Sight#ko_30	858,1,1

job_ko,46,52,4	duplicate(Sight#ko_curse)	Sight#ko_31	858,1,1

job_ko,54,52,4	script	Sight#ko_32	858,1,1,{
	callfunc "F_KO_Survival_mes",32;
	end;
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.";
	next;
	switch (callfunc("F_KO_Survival_rps")) {
	case 1:
		mes "Please choose a block to move between blocks 33 through 38.";
		next;
		callfunc "F_KO_Survival_warp", select("Move to block 33:Move to block 34:Move to block 35:Move to block 36:Move to block 37:Move to block 38") + 32;
		end;
	case 0:
	case -1:
		mes "Press Close to move to block 0.";
		callfunc "F_KO_Survival_warp",0;
		end;
	}
}

job_ko,54,43,4	script	Sight#ko_33	858,1,1,{
	callfunc "F_KO_Survival_mes",33;
	end;
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 ^FD0260LP^000000 to roll the dice one last time.";
	next;
	switch(select("Pay LP.:Move forward a little bit at a time.")) {
	case 1:
		set .@sell_p, job_kagero_lp - 1;
		set job_kagero_lp,1;
		mes "< Used " + .@sell_p + " LP >";
		next;
		mes "Press Close to move to block 39.";
		callfunc "F_KO_Survival_warp",39;
		end;
	case 2:
		mes "Please roll the dice.";
		next;
		break;
	}
	callfunc "F_KO_Survival_dice",33;
	end;
}

job_ko,54,35,4	duplicate(Sight#ko_heal)	Sight#ko_34	858,1,1

job_ko,49,31,4	duplicate(Sight#ko_trap)	Sight#ko_35	858,1,1

job_ko,41,31,4	script	Sight#ko_36	858,1,1,{
	callfunc "F_KO_Survival_mes",36;
	end;
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)"; //iRO custom dialogue(?)
	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"; //iRO custom dialogue(?)
	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.";
	next;
	switch(select("Try it the other way.:Go by the rules.")) {
	case 1:
		//mes "The Other Way (2nd Rule)"; //iRO custom dialogue(?)
		set .@dodoripo,0;
		break;
	case 2:
		set .@dodoripo,1;
		break;
	}
	set .@dice, callfunc("F_KO_Survival_dice",36,1,1);
	if (.@dodoripo == 0) {
		if (.@dice <= 3) {
			mes "Press Close to move to the end.";
			callfunc "F_KO_Survival_warp",40;
			end;
		} else {
			mes "Press Close to move to block 29.";
			callfunc "F_KO_Survival_warp",29;
			end;
		}
	} else {
		mes "Press Close to move to forward " + .@dice + " blocks.";
		callfunc "F_KO_Survival_warp", ((.@dice <= 3) ? .@dice + 36 : 40);
		end;
	}
}

job_ko,33,31,4	script	Sight#ko_37	858,1,1,{
	callfunc "F_KO_Survival_mes",37;
	end;
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.";
	next;
	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.";
	next;
	set .@dice, callfunc("F_KO_Survival_dice",37,1,1);
	if (.@dice % 2) {
		mes "Press Close to move to the last block.";
		callfunc "F_KO_Survival_warp",40;
		end;
	} else {
		mes "Press Close to move to the starting point.";
		callfunc "F_KO_Survival_warp",0;
		end;
	}
}

job_ko,33,40,4	script	Sight#ko_38	858,1,1,{
	callfunc "F_KO_Survival_mes",38;
	end;
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 ($20110808_vko04 == 0) {
		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:
			set .@reset_p, job_kagero_lp - 1;
			set job_kagero_lp,1;
			set $20110808_vko04,1;
			mes "< Used " + .@reset_p + " LP >";
			next;
			mes "The trap is installed. Please roll the dice.";
			next;
			break;
		case 2:
			mes "Did not set a trap. Please roll the dice.";
			next;
			break;
		}
	} else {
		set $20110808_vko04,0;
		set job_kagero_lp,0;
		mes "You are caught in the trap installed. Press Close to go back to block 0.";
		callfunc "F_KO_Survival_warp",0;
		end;
	}
	set .@dice, callfunc("F_KO_Survival_dice",38,1,1);
	mes "Press Close to move forward " + .@dice + " blocks.";
	callfunc "F_KO_Survival_warp", ((.@dice == 1) ? .@dice + 38 : 40);
	end;
}

job_ko,38,44,4	script	Sight#ko_39	858,1,1,{
	callfunc "F_KO_Survival_mes",39;
	end;
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.";
	next;
	set .@dice, callfunc("F_KO_Survival_dice",39,1,1);
	if (.@dice == 3) {
		mes "Press Close to move to the 3rd block.";
		callfunc "F_KO_Survival_warp",3;
		end;
	} else {
		mes "Press Close to move to the arrival point.";
		callfunc "F_KO_Survival_warp",40;
		end;
	}
}

job_ko,46,41,4	script	Sight#ko_40	858,1,1,{
	callfunc "F_KO_Survival_mes",40;
	end;
OnTouch:
	if (job_kagero != 5) {
		mes "You should not be here.";  //custom translation
		close2;
		warp "amatsu",147,136;
		end;
	}
	if (isbegin_quest(5137) != 1 || isbegin_quest(5140) != 1) {
		mes "You must be here by mistake.";  //custom translation
		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;
	completequest 5137;
	erasequest 5140;
	if (isbegin_quest(5141)) erasequest 5141;
	set job_kagero_lp,0;
	mes "Let's read all the writing on the sign.";
	mes "You feel like you are moved to another place.";
	close2;
	warp "job_ko",35,113;
	end;
}

// Test of Weaponry
//============================================================
job_ko,127,125,4	script	Red Leopard Joe#ko	730,{
	if (MaxWeight - Weight < 1000 || checkweight(1201,1) == 0) {
		mes "[Red Leopard Joe]";
		mes "Go reduce your weight! This test will be too difficult otherwise...";  //custom translation
		close;
	}
	if (BaseJob != Job_Ninja) {
		for (set .@i,5131; .@i<=5146; set .@i,.@i+1)
			if (isbegin_quest(.@i)) erasequest .@i;
		set job_kagero,0;
		mes "[Red Leopard Joe]";
		mes "Sorry, your clan is not the same as ours, is there something wrong?";
		close2;
		warp "amatsu",147,136;
		end;
	}
	if (job_kagero != 5) {  //custom translation
		mes "[Red Leopard Joe]";
		mes "You are not supposed to be here...";
		mes "It's my duty to get rid of you,";
		mes "so I'll send you back now!";
		close2;
		warp "amatsu",147,136;
		end;
	}
	set .@ko_test_03_1, isbegin_quest(5138);
	set .@ko_test_03_2, isbegin_quest(5142);
	set .@ko_test_03_3, isbegin_quest(5143);
	set .@ko_test_03_4, isbegin_quest(5144);
	set .@ko_test_03_5, isbegin_quest(5145);
	if (.@ko_test_03_1 == 1 && .@ko_test_03_2 == 0 && .@ko_test_03_3 == 0 && .@ko_test_03_4 == 0 && .@ko_test_03_5 == 0) {
		mes "[Red Leopard Joe]";
		mes "It's been a while!";
		next;
		select("Long time indeed, Joe.");
		mes "[Red Leopard Joe]";
		mes "You aren't surprised I'm here. Did you meet ^0237FDKuuga Gai^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 clan.";
		next;
		mes "[Red Leopard Joe]";
		mes "Our clan 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 clan.";
		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 "[Red Leopard Joe]";
		mes "Let's now create a new prototype weapon.";
		next;
		specialeffect EF_GUIDEDATTACK,AREA,"Crafting Tools#ko_01";
		mes "[Red Leopard Joe]";
		mes "Feel free to use tools from here, and...";
		next;
		specialeffect EF_GUIDEDATTACK,AREA,"Crafting Tools#ko_02";
		mes "[Red Leopard Joe]";
		mes "...there...";
		next;
		specialeffect EF_GUIDEDATTACK,AREA,"Crafting Tools#ko_03";
		setquest 5142;
		mes "[Red Leopard Joe]";
		mes "...and everywhere else. Now let's begin!!";
		close;
	} else if (.@ko_test_03_1 == 1 && .@ko_test_03_2 == 1 && .@ko_test_03_3 == 0 && .@ko_test_03_4 == 0 && .@ko_test_03_5 == 0) {
		callsub L_Weapon,":";
		end;
	} else if (.@ko_test_03_1 == 1 && .@ko_test_03_2 == 0 && (.@ko_test_03_3 == 1 || .@ko_test_03_4 == 1) && .@ko_test_03_5 == 0) {
		callsub L_Weapon,":Yes, I'm done.";
		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]";
		} 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.";
		} else {
			mes "[Red Leopard Joe]";
			mes "Ahh, how is it possible? You don't have weapons? Maybe you equipped it?";
			close;
		}
		mes "Very creative. I do see room for improvement but the weapon itself may come out useful after smoothing it out a bit.";
		next;
		mes "[Red Leopard Joe]";
		mes "Good. I think you are ready.";
		next;
		mes "[Red Leopard Joe]";
		mes "Now it's time to upgrade?";
		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.";
		next;
		setquest 5145;
		mes "[Red Leopard Joe]";
		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 (.@ko_test_03_1 == 1 && .@ko_test_03_2 == 0 && (.@ko_test_03_3 == 1 || .@ko_test_03_4 == 1) && .@ko_test_03_5 == 1) {
		disable_items;
		mes "[Red Leopard Joe]";
		mes "Did you get a successful result?";
		next;
		switch(select("Not yet.:Here it is.:Actually...")) {
		case 1:
			mes "[Red Leopard Joe]";
			mes "It isn't easy to get a satisfactory result at first.";
			close;
		case 2:
			break;
		case 3:
			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.";
			next;
			nude;
			if (countitem(13074) || countitem(13312)) {
				mes "[Red Leopard Joe]";
				mes "What is this? You still have the prototype. Stop playing around.";
				close;
			}
			mes "[Red Leopard Joe]";
			mes "Oh! You really lost it.";
			next;
			setquest 5142;
			if (isbegin_quest(5143)) erasequest 5143;
			if (isbegin_quest(5144)) erasequest 5144;
			erasequest 5145;
			mes "[Red Leopard Joe]";
			mes "Well! Lets try to make it again!";
			close;
		}
		mes "[Red Leopard Joe]";
		mes "Looks like you've got some results.";
		next;
		set .@part, EQI_HAND_R;
		if (!getequipisequiped(.@part)) {
			mes "[Red Leopard Joe]";
			mes "Ahh! You have not equipped any weapons!";
			close;
		} else {
			set .@equip_id, getequipid(.@part);
			set .@equip_refine, getequiprefinerycnt(.@part);
			if (.@equip_id == 13074 || .@equip_id == 13312) {
				mes "[Red Leopard Joe]";
				mes "Is that weapon yours? Let me have a look.";
				next;
			} else {  //custom translation
				mes "[Red Leopard Joe]";
				mes "Are you certain it's that weapon?";
				next;
				mes "[Red Leopard Joe]";
				mes "You plan to trick me with that? Again!!";
				close;
			}
		}
		mes "Joe took a thorough look at the seal.";
		next;
		if (.@equip_refine < 7) {
			mes "[Red Leopard Joe]";
			mes "Are you that low?";
			mes "I must have misjudged you. You might have been satisfied yourself but I'm not. Do it again!!";
			close;
		} else if (.@equip_refine > 6 && .@equip_refine < 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.";
			next;
		} else if (.@equip_refine > 8 && .@equip_refine < 13) {  //custom translation(?)
			mes "[Red Leopard Joe]";
			mes "Ah, as I expected.";
			mes "I still believe that you will not stop here.";
			next;
			if(select("I want to stop.:I want to continue.") == 2) {
				mes "[Red Leopard Joe]";
				mes "I will look forward for your result.";
				close;
			}
			mes "[Red Leopard Joe]";
			mes "Your competence is enough.";
			next;
		} else {  //custom translation(?)
			mes "[Red Leopard Joe]";
			mes "Better than expected.";
			next;
			mes "[Red Leopard Joe]";
			mes "For beginners, quite good. This test may not be significant to you, but 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;

		// anti-hack
		if (callfunc("F_IsEquipIDHack", .@part, .@equip_id) || callfunc("F_IsEquipRefineHack", .@part, .@equip_refine))
			close;

		delequip .@part;
		erasequest 5145;
		completequest 5138;
		if (isbegin_quest(5143) == 1) completequest 5143;
		if (isbegin_quest(5144) == 1) completequest 5144;
		mes "[Red Leopard Joe]";
		mes "'" + strcharinfo(0) + "'";
		mes "Passed the weapon test!!";
		close;
	} else if (.@ko_test_03_1 == 2 && .@ko_test_03_2 == 0 && (.@ko_test_03_3 == 2 || .@ko_test_03_4 == 2) && .@ko_test_03_5 == 0) {
		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 {  //custom translation
		mes "[Red Leopard Joe]";
		mes "You should not have come here...";
		mes "It's my duty to get rid of you.";
		mes "This will push you back!";
		close2;
		warp "amatsu",147,136;
		end;
	}
	end;

L_Weapon:
	mes "[Red Leopard Joe]";
	mes "Are you done making the prototype of the new weapons?";
	next;
	switch(select("Crafting tools?:I don't have enough materials.:How do you expect me to make a weapon?" + getarg(0))) {
	case 1:
		specialeffect EF_GUIDEDATTACK,AREA,"Crafting Tools#ko_01";
		mes "[Red Leopard Joe]";
		mes "Feel free to use tools from here, and...";
		next;
		specialeffect EF_GUIDEDATTACK,AREA,"Crafting Tools#ko_02";
		mes "[Red Leopard Joe]";
		mes "...there...";
		next;
		specialeffect EF_GUIDEDATTACK,AREA,"Crafting Tools#ko_03";
		mes "[Red Leopard Joe]";
		mes "...and everywhere else.";
		close;
	case 2:
		mes "[Red Leopard Joe]";
		mes "You haven't brought enough materials?";
		next;
		specialeffect EF_GUIDEDATTACK,AREA,"Drawer#ko";
		mes "[Red Leopard Joe]";
		mes "Then we'll have to pay a visit to the village. Try the ^FF0000drawer^000000 over there. It'll take you to the village.";
		close;
	case 3:
		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.";
		next;
		mes "[Red Leopard Joe]";
		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:
		return;
	}
}

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

job_ko,131,124,0	script	Crafting Tools#ko_01	844,{
	if (MaxWeight - Weight < 1000 || checkweight(1201,1) == 0) {
		mes "Too heavy! Please reduce your weight.";  //custom translation
		close;
	}
	if (isbegin_quest(5138) == 1 && isbegin_quest(5142) == 1 && isbegin_quest(5143) == 0 && isbegin_quest(5144) == 0 && isbegin_quest(5145) == 0) {
		// fall through
	} else {
		mes "A crafting tool.";
		mes "Don't really need it now.";
		close;
	}
	mes "Tool to create weapons.";
	next;

	// Part 1: Melting Metal
	// Input similar materials to proceed to next step.
	mes "First need to melt metals like iron and iron ore to use to create a weapon.";
	next;
	callsub L_CheckMaterials;
	while(1) {
		switch(select("Melt Iron Ore.:Melt Iron.:Melt Steel.:Melt Phracon.:Melt Emveretarcon.:Melt Rough Oridecon.:Melt Rough Elunium.:Stop.")) {
			case 1: set .@item,1002; setarray .@val[0],1,0,0; break;  //Iron_Ore
			case 2: set .@item, 998; setarray .@val[0],2,0,0; break;  //Iron
			case 3: set .@item, 999; setarray .@val[0],3,0,0; break;  //Steel
			case 4: set .@item,1010; setarray .@val[0],0,1,0; break;  //Phracon
			case 5: set .@item,1011; setarray .@val[0],0,2,0; break;  //Emveretarcon
			case 6: set .@item, 756; setarray .@val[0],0,3,0; break;  //Oridecon_Stone
			case 7: set .@item, 757; setarray .@val[0],0,0,5; break;  //Elunium_Stone
			case 8: close;
		}
		if (countitem(.@item)) {
			delitem .@item,1;
			if (.@val[0]) {			//Iron Ore, Iron, Steel
				set .@ston_t01, .@ston_t01 + .@val[0];
				if (.@ston_t02 > 0)
					set .@ston_t02, .@ston_t02 - .@val[0];
			} else if (.@val[1]) {	//Phracon, Emveretarcon, Rough Oridecon
				set .@ston_t02, .@ston_t02 + .@val[1];
				if (.@ston_t01 > 0)
					set .@ston_t01, .@ston_t01 - .@val[1];
			} else if (.@val[2]) {	//Rouch Elunium
				if (.@ston_t01 > 0)
					set .@ston_t01, .@ston_t01 - .@val[2];
				if (.@ston_t02 > 0)
					set .@ston_t02, .@ston_t02 - .@val[2];
			}
			specialeffect EF_DEMONSTRATION;
			mes "Melted " + getitemname(.@item) + " in high temperature.";
			next;
			if (.@ston_t01 > 49 || .@ston_t02 > 49)
				break;
		} else {
			mes "Don't have " + getitemname(.@item) + ".";
			next;
		}
		callsub L_CheckMaterials;
		mes "Which metal will be melted next?";
		next;
	}
	set .@boll_01, ((.@ston_t01 > 49) ? .@ston_t01 : .@ston_t02);

	// Part 2: Forging
	// Grind and temper a weapon.
	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?";
	next;
	switch(select("Dagger Mold:Shuriken Mold")) {
	case 1:
		set .@weapon_who,0;
		mes "Poured the melted metal into the dagger mold.";
		break;
	case 2:
		set .@weapon_who,1;
		mes "Poured the melted metal into the shuriken mold.";
		break;
	}
	next;
	progressbar "ffff00",3;
	mes "Looks like the metal is taking shape. Now what next?";
	next;
	set @job_ko_forge,0;
	set @job_ko_lastaction,0;
	callsub L_ForgeWeapon,":";
	while(1) {
		mes "Now what next?";
		next;
		if (callsub(L_ForgeWeapon,":Final Touches") == 0)
			break;
	}
	set .@boll_02, @job_ko_forge;
	set @job_ko_forge,0;
	set @job_ko_lastaction,0;

	// Part 3: Create the Weapon
	// Success rate based on previous two parts.
	set .@boll_00, .@boll_01 + .@boll_02;
	mes "Start to sharpen the tool using a whetstone for finishing touches.";
	next;
	progressbar "ffff00",3;
	set .@success_pp, rand(1,100);
	if (.@boll_00 < 100) {
		if (.@success_pp == 77) set .@success,1;
	} else {
		if (.@success_pp != 44) set .@success,1;
	}
	if (.@success) {
		specialeffect2 EF_PERFECTION;
		erasequest 5142;
		if (.@weapon_who == 0) {
			setquest 5143;
			getitem 13074,1; //Ninja_Cutter
		} else {
			setquest 5144;
			getitem 13312,1; //Huuma_Job_Test
		}
		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;
	}
	end;

L_CheckMaterials:
	if (!countitem(1002) && !countitem(998) && !countitem(999) && !countitem(1010) && !countitem(1011) && !countitem(756) && !countitem(757)) {
		mes "But you do not have any more metal to melt. Let's try again after getting more metal.";
		close;
	}
	return;

L_ForgeWeapon:
	set .@i, select("Grind the weapon:Temper the weapon" + getarg(0));
	switch (.@i) {
	case 1:
		specialeffect2 EF_DETOXICATION;
		mes "Ground the weapon.";
		break;
	case 2:
		specialeffect2 EF_REPAIRWEAPON;
		mes "Tempered the weapon.";
		break;
	case 3:
		return 0;
	}
	next;
	if (@job_ko_lastaction == .@i)
		set @job_ko_forge, @job_ko_forge + 1;
	else
		set @job_ko_forge, @job_ko_forge + 2;
	set @job_ko_lastaction, .@i;
	return 1;
}
job_ko,129,129,0	duplicate(Crafting Tools#ko_01)	Crafting Tools#ko_02	844
job_ko,116,124,0	duplicate(Crafting Tools#ko_01)	Crafting Tools#ko_03	844

job_ko,121,121,0	script	Refinement Tools#ko_01	844,{
	if (isbegin_quest(5138) == 1 && isbegin_quest(5142) == 0 && (isbegin_quest(5143) == 1 || isbegin_quest(5144) == 1) && isbegin_quest(5145) == 1) {
		disable_items;
	} 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.";
	next;
	if(select("Start refining.:Do not start refining.") == 2) {
		mes "You turned off the tool.";
		close;
	}
	set .@part, EQI_HAND_R;
	if (!getequipisequiped(.@part)) {
		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 {
		set .@equip_id, getequipid(.@part);
		set .@equip_refine, getequiprefinerycnt(.@part);
		setarray .@card[0], getequipcardid(.@part,0), getequipcardid(.@part,1), getequipcardid(.@part,2), getequipcardid(.@part,3);
		if (.@equip_id == 13074 || .@equip_id == 13312) {
			mes "Analyzing the weapon.";
			next;
		} else {
			mes "[Red Leopard Joe]";
			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;
		}
	}
	if (!getequipisenableref(.@part)) {
		mes "Bzzzt";
		mes "A warning beep comes from the tool.";
		next;
		mes "[Red Leopard Joe]";
		mes "That weapon cannot be refined. Where did you get it?";  //custom translation
		close;
	}
	if (.@equip_refine >= 20) {
		mes "Bzzzt";
		mes "A warning beep comes from the tool.";
		next;
		mes "[Red Leopard Joe]";
		mes "This equipment is perfectly refined. Keep it for yourself!";  //custom translation
		close;
	}
	if (getequippercentrefinery(.@part) < 100) {
		mes "This is very well refined equipment. Do you want to continue? Refine skill decreases by 1 if refinement fails.";
		next;
		if(select("Continue.:Stop.") == 2) {
			mes "You turned off the tool.";
			close;
		}
	} else {
		mes "Starting to refine.";  //custom translation
		next;
	}
	progressbar "ffff00",1;
	set .@rand, rand(1,100);
	if (.@equip_refine < 5) {			// 0>5 100%
		set .@wlevel_up,1;
	} else if (.@equip_refine == 5) {	// 5>6  40%
		if (.@rand < 41) set .@wlevel_up,1;
	} else if (.@equip_refine == 6) {	// 6>7  30%
		if (.@rand < 31) set .@wlevel_up,1;
	} else if (.@equip_refine == 7) {	// 7>8  20%
		if (.@rand < 21) set .@wlevel_up,1;
	} else if (.@equip_refine == 8) {	// 8>9  10%
		if (.@rand < 11) set .@wlevel_up,1;
	} else if (.@equip_refine == 9) {	// 9>10  5%
		if (.@rand < 6) set .@wlevel_up,1;
	} else {							// 10>20 2%
		if (.@rand < 3) set .@wlevel_up,1;
	}

	// anti-hack
	if (callfunc("F_IsEquipIDHack", .@part, .@equip_id) || callfunc("F_IsEquipCardHack", .@part, .@card[0], .@card[1], .@card[2], .@card[3]) || callfunc("F_IsEquipRefineHack", .@part, .@equip_refine))
		close;

	if (.@wlevel_up) {
		successrefitem .@part;
		mes "Succeeded in refining.";
		mes "Turned off the refining tool.";
		close;
	} else {
		downrefitem .@part;
		mes "Failed in refining.";
		mes "Your weapon refinement skill dropped by 1.";
		mes "Turned off the refining tool.";
		close;
	}
	end;
}
job_ko,127,121,0	duplicate(Refinement Tools#ko_01)	Refinement Tools#ko_02	844

// Test of Battle
//============================================================
job_ko,148,46,4	script	Leader Gion#ko2	588,{
	if (MaxWeight - Weight < 2000 || checkweight(1201,1) == 0) {
		mes "[Leader Gion]";
		mes "You don't need so many things now!"; //custom translation
		close;
	}
	if (job_kagero == 7) {
		cutin "job_ko01",2;
		mes "[Leader Gion]";
		mes "Looks like you haven't taken care of the target yet.";
		next;
		mes "[Leader Gion]";
		mes "I'll tell you once more. The target is the ^FF0000Clan Secret^000000.";
		next;
		mes "[Leader Gion]";
		mes "Of course the path will be difficult, so continue searching!"; //custom translation
		close2;
		cutin "",255;
		end;
	} else if (job_kagero == 8) {
		cutin "job_ko02",2;
		mes "[Leader Gion]";
		mes "Looks like you've taken care of the target. Hmm.";
		next;

		//custom translations
		if (ismounting()) {
			mes "[Leader Gion]";
			mes "But please get down from your frog. Otherwise I can't continue!";
			close2;
			cutin "",255;
			end;
		}
		if (BaseLevel < 99 || JobLevel < 70) {
			mes "[Leader Gion]";
			mes "How did you get weaker? Come back once you've regained your previous levels.";
			close2;
			cutin "",255;
			end;
		}
		if (SkillPoint != 0) {
			mes "[Leader Gion]";
			mes "Please come back after using all your Skill Points.";
			close2;
			cutin "",255;
			end;
		}

		mapannounce "job_ko","[Gion] Interrupting the Test of Battle.",bc_map;
		cutin "job_ko04",2;
		mes "[Leader Gion]";
		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 == SEX_MALE)?"Kagerou":"Oboro") + " Path. Congratulations!!",bc_map;
		mes "[Leader Gion]";
		mes "My friend " + strcharinfo(0) + " made it to " + ((Sex == SEX_MALE)?"Kagerou":"Oboro") + " Path. Congratulations!!";
		next;
		cutin "job_ko02",2;
		mes "[Leader 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;
		donpcevent "Kuuga Gai#ko2::OnEnable";
		donpcevent "Red Leopard Joe#ko2::OnEnable";
		cutin "job_ko04",2;
		mes "[Leader Gion]";
		mes "I'm sorry I almost forgot about you two. Do you have anything to share with " + strcharinfo(0) + "?";
		next;
		cutin "",255;
		mes "[Kuuga Gai]";
		mes "Hmm... Embarrassing... to speak so suddenly...";
		next;
		mes "[Kuuga Gai]";
		mes strcharinfo(0) + ", you are now a proud member of our clan. Always hold your head high and...";
		next;
		mes "[Kuuga Gai]";
		mes "^777777(Gai's voice fades out.)^000000.";
		mes "I'm sorry I strangled you when we first met.";
		next;
		donpcevent "Kuuga Gai#ko2::OnDisable";
		mes "[Red Leopard Joe]";
		mes "Puhahaha! Gai is all talk. I know I was know valuable to you than that Gai.";
		next;
		if (isbegin_quest(5143) == 2) {
			set .@item,13075; //Kurenai
			set .@weapon$,"dagger";
		} else {
			set .@item,13311; //Huuma_Shadow
			set .@weapon$,"shuriken";
		}
		mes "[Red Leopard Joe]";
		mes "I did some work on the prototype " + .@weapon$ + " you made.";
		next;
		mes "[Red Leopard Joe]";
		mes getitemname(.@item) + " now shines beautifully 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 "Leader Gion, please continue.";
		next;
		cutin "job_ko01",2;
		donpcevent "Red Leopard Joe#ko2::OnDisable";
		mes "[Leader Gion]";
		mes "I don't have much to add because Gai and Joe said it all.";
		next;
		mes "[Leader Gion]";
		mes "I'm just sorry that the environment of all these tests could have been better for our later generation.";
		next;
		mes "[Leader Gion]";
		mes "You only need to look forward and never turn back.";
		next;
		for (set .@i,5131; .@i<=5146; set .@i,.@i+1)
			if (isbegin_quest(.@i)) erasequest .@i;
		set job_kagero,9;
		getnameditem .@item,strcharinfo(0);
		jobchange (Sex == SEX_MALE)?Job_Kagerou:Job_Oboro;
		donpcevent "Summon Target#ko::OnEnable";
		mes "[Leader 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 "[Leader 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 "[Leader Gion]";
		mes "You should not be here. Please leave!"; //custom translation
		close2;
		warp "amatsu",147,136;
		end;
	}
}

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

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:
OnDisable:
	disablenpc "Red Leopard Joe#ko2";
	end;
OnEnable:
	enablenpc "Red Leopard Joe#ko2";
	end;
}

job_ko,1,1,4	script	Summon Target#ko	844,{
	end;
OnInit:
OnTimer180000:
	donpcevent "Summon Target#ko::OnEnable";
	end;
OnEnable:
	stopnpctimer;
	switch (rand(1,7)) {
		case 1: set .@mob,1002; break;
		case 2: set .@mob,1031; break;
		case 3: set .@mob,1113; break;
		case 4: set .@mob,1063; break;
		case 5: set .@mob,1010; break;
		case 6: set .@mob,1049; break;
		case 7: set .@mob,1050; break;
	}
	areamonster "job_ko",120,30,160,70,"Clan Secret",.@mob,1,"Summon Target#ko::OnMyMobDead";
	end;
OnDisable:
	initnpctimer;
	end;
OnMyMobDead:
	if (mobcount("job_ko","Summon Target#ko::OnMyMobDead") < 1) {
		if (job_kagero == 7) {
			donpcevent "Summon Target#ko::OnDisable";
			set job_kagero,8;
		} else
			donpcevent "Summon Target#ko::OnEnable";
	}
	end;
}

job_ko,1,2,4	script	Summon Fake#ko	844,{
	end;
OnInit:
	donpcevent "Summon Fake#ko::OnEnable";
	end;
OnEnable:
	areamonster "job_ko",120,30,160,70,"Clan's Legacy",1002,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Kagerou's Memory",1002,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Oboro's Memory",1002,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Clan's Mistake",1031,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Oboro's Mistake",1031,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Kagerou's Mistake",1031,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Clan's Memory",1113,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Oboro's Past",1113,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Kagerou's Past",1113,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Clan's Legacy",1063,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Oboro's Legacy",1063,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Kagerou's Legacy",1063,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Clan's Mistake",1010,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Oboro's Memory",1010,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Kagerou's Memory",1010,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Clan's Past",1049,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Oboro's Mistake",1049,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Kagerou's Mistake",1049,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Clan's Memory",1050,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Oboro's Past",1050,5,"Summon Fake#ko::OnMyMobDead";
	areamonster "job_ko",120,30,160,70,"Kagerou's Past",1050,5,"Summon Fake#ko::OnMyMobDead";
	end;
OnDisable:
	killmonster "job_ko","Summon Fake#ko::OnMyMobDead";
	end;
OnMyMobDead:
	if (mobcount("job_ko","Summon Fake#ko::OnMyMobDead") < 100) {
		donpcevent "Summon Fake#ko::OnDisable";
		donpcevent "Summon Fake#ko::OnEnable";
		warp "job_ko",16,113;
	}
	end;
}

// GM Control Panel (custom translations)
//============================================================
job_ko,3,1,4	script	Battle Test Control#ko	588,{
	callfunc "F_GM_NPC";
	if (callfunc("F_GM_NPC",1854,0) == 1) {
		mes "This is the Battle Test Control NPC.";
		next;
	} else {
		mes "Incorrect password.";
		close;
	}
	switch(select("Summon Target:Summon Target Disable:Summon Fake:Summon Fake Disable")) {
	case 1:
		donpcevent "Summon Target#ko::OnEnable";
		mes "Summon Target activated.";
		break;
	case 2:
		donpcevent "Summon Target#ko::OnDisable";
		mes "Summon Target disabled.";
		break;
	case 3:
		donpcevent "Summon Fake#ko::OnEnable";
		mes "Summon Fake activated.";
		break;
	case 4:
		donpcevent "Summon Fake#ko::OnDisable";
		mes "Summon Fake disabled.";
		break;
	}
	next;
	mes "Control has completed.";
	close;
}

job_ko,4,1,4	script	Guide#ko_helper	588,{
	callfunc "F_GM_NPC";
	if (callfunc("F_GM_NPC",1854,0) == 1) {
		mes "This is the Kagerou and Oboro Job Change assistant NPC.";
		next;
	} else {
		mes "Incorrect password.";
		close;
	}
	mes "I can solve any problems in the job change quest.";
	next;
	switch(select("Current Status:Test Set:Pre-Transfer:Initialize")) {
	case 1:
		mes "Variable states (current/maximum)";
		mes "job_kagero (" + job_kagero + "/9)";
		mes "job_kagero_lp (" + job_kagero_lp + "/100)";
		next;
		mes "Quest states (current/maximum)";
		mes "5131 (" + isbegin_quest(5131) + "/1)";
		mes "5132 (" + isbegin_quest(5132) + "/1)";
		mes "5133 (" + isbegin_quest(5133) + "/1)";
		mes "5134 (" + isbegin_quest(5134) + "/1)";
		mes "5135 (" + isbegin_quest(5135) + "/1)";
		mes "5136 (" + isbegin_quest(5136) + "/2)";
		mes "5139 (" + isbegin_quest(5139) + "/1)";
		mes "5137 (" + isbegin_quest(5137) + "/2)";
		mes "5140 (" + isbegin_quest(5140) + "/1)";
		mes "5141 (" + checkquest(5141,PLAYTIME) + "/1)";
		mes "5138 (" + isbegin_quest(5138) + "/2)";
		mes "5142 (" + isbegin_quest(5142) + "/1)";
		mes "5143 (" + isbegin_quest(5143) + "/2)";
		mes "5144 (" + isbegin_quest(5144) + "/2)";
		mes "5145 (" + isbegin_quest(5145) + "/1)";
		mes "5146 (" + isbegin_quest(5146) + "/1)";
		close;
	case 2:
		mes "Which test do you want to set as completed?";
		mes "Three tests must be completed before changing jobs. If you wish to reach a job change state, please select [Pre-Transfer] directly from the previous menu!";
		next;
		switch(select("Complete Test of Knowledge:Complete Test of Survival:Complete Test of Weaponry")) {
		case 1:
			set job_kagero,5;
			setquest 5136;
			completequest 5136;
			mes "The Test of Knowledge has been set as complete. I hope you have finished your initialization.";
			break;
		case 2:
			set job_kagero,5;
			set job_kagero_lp,0;
			setquest 5137;
			completequest 5137;
			mes "The Test of Survival has been set as complete. I hope you have finished your initialization.";
			break;
		case 3:
			set job_kagero,5;
			setquest 5138;
			completequest 5138;
			mes "The Test of Weaponry has been set as complete. I hope you have finished your initialization.";
			break;
		}
		close;
	case 3:
		mes "I will change your quest status to Pre-Transfer, but before that...";
		next;
		mes "Please select a weapon.";
		next;
		switch(select("Dagger:Shuriken")) {
			case 1: set .@quest,5143; break;
			case 2: set .@quest,5144; break;
		}
		setquest 5136;
		completequest 5136;
		setquest 5137;
		completequest 5137;
		setquest 5138;
		completequest 5138;
		setquest .@quest;
		completequest .@quest;
		setquest 5146;
		set job_kagero,8;
		mes "I've set the Pre-Transfer status. Good luck!!";
		close;
	case 4:
		set job_kagero,0;
		set job_kagero_lp,0;
		for (set .@i,5131; .@i<=5146; set .@i,.@i+1)
			if (isbegin_quest(.@i)) erasequest .@i;
		mes "The task of initialization is complete. You can confirm this through the [Current Status] option!";
		close;
	}
	end;
}
