//================= Hercules Script =======================================
//=       _   _                     _
//=      | | | |                   | |
//=      | |_| | ___ _ __ ___ _   _| | ___  ___
//=      |  _  |/ _ \ '__/ __| | | | |/ _ \/ __|
//=      | | | |  __/ | | (__| |_| | |  __/\__ \
//=      \_| |_/\___|_|  \___|\__,_|_|\___||___/
//================= License ===============================================
//= This file is part of Hercules.
//= http://herc.ws - http://github.com/HerculesWS/Hercules
//=
//= Copyright (C) 2020-2026 Hercules Dev Team
//= Copyright (C) Dastgir
//=
//= Hercules is free software: you can redistribute it and/or modify
//= it under the terms of the GNU General Public License as published by
//= the Free Software Foundation, either version 3 of the License, or
//= (at your option) any later version.
//=
//= This program is distributed in the hope that it will be useful,
//= but WITHOUT ANY WARRANTY; without even the implied warranty of
//= MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//= GNU General Public License for more details.
//=
//= You should have received a copy of the GNU General Public License
//= along with this program.  If not, see <http://www.gnu.org/licenses/>.
//=========================================================================
//= Rebellion Job Quest
//================= Description ===========================================
//= Job change Quest from Gunslinger -> Rebellion
//================= Current Version =======================================
//= 1.0
//=========================================================================

job_gun,1,1,1	script	Administrator1	CLEAR_NPC,{
	callfunc("F_GM_NPC");
	mes("Please enter the password.");
	.@success = callfunc("F_GM_NPC", 1854, 0);
	if (.@sucess != 1)
		close();

	mes("[Time Administrator]");
	mes("What time would you like to return?");
	next();
	.@select = select("Cancel", "Test monster spawn", "Start from beginning", "Furnace Zone", "Shooting Zone", "Complete the test");
	if (.@select == 1) {
		close();
	} else if (.@select == 2) {
		donpcevent("#target::OnStart");
		donpcevent("#nontarget::OnStart");
		close();
	} else if (.@select == 4) {
		.@questComplete = 12341;
	} else if (.@select == 5) {
		.@questComplete = 12342;
	} else if (.@select == 6) {
		.@questComplete = 12344;
	}
	for (.@i = 12340; .@i <= 12345; .@i++) {
		erasequest(.@i);
		if (.@i <= .@questComplete) {
			setquest(.@i);
			completequest(.@i);
		}
	}
	close();

OnInit:
	disablenpc(strnpcinfo(NPC_NAME));
	end;
}

// Warps
job_gun,56,26,0	warp	rebelroom#1	2,2,einbroch,49,97
job_gun,18,10,0	warp	rebelroom#2	2,2,job_gun,81,29
job_gun,165,22,0	warp	rebelroom#3	2,2,job_gun,196,35
job_gun,197,49,0	warp	rebelroom#4	2,2,job_gun,157,21

job_gun,88,144,0	warp	shootingrange#1	3,3,job_gun,93,123
job_gun,105,97,0	warp	shootingrange#2	3,3,job_gun,125,98
job_gun,156,115,0	warp	shootingrange#3	3,3,job_gun,157,137
job_gun,152,154,0	warp	shootingrange#4	3,3,job_gun,135,154
job_gun,130,146,0	warp	shootingrange#5	3,3,job_gun,120,130

job_gun,165,18,1	script	Furnace Controller#1	CLEAR_NPC,{
	if (Class != Job_Gunslinger) {
		mes("Only authorized user can do the operation.");
		close();
	}
	if (getstatus(SC_MONSTER_TRANSFORM, 1) != G_L_SHECIL) {
		mes("Not an authorized user. Abort the operation.");
		close();
	}
	if (questprogress(12342) != 1) {
		mes("Not an authorized user. Abort the operation.");
		close();
	}
	mes("Do you want to dredge the mold up from the furnace?");
	next();
	if (select("Quit.", "Begin.") == 1) {
		mes("Switch to the Standby mode.");
		close();
	}
	hideonnpc("Furnace Controller#1");
	donpcevent("Furnace Controller#2::OnStart");
	mes("Initializing Furnace Controller ZX-3100...");
	close();

OnInit:
	hideoffnpc("Furnace Controller#1");
	end;
}

job_gun,214,36,1	script	Auto Anvil#1	CLEAR_NPC,{
	if (Class != Job_Gunslinger) {
		mes("Only authorized user can do the operation.");
		close();
	}
	if (countitem(Tiny_Flame) > 0) {
		mes("Unauthorized firearm creation has been detected. Report to Manager Elwin.");
		close();
	}
	if (checkweight(Tiny_Flame, 1) == 0) {
		mes("You have too many items, please reduce them to continue.");
		close();
	}
	if (getstatus(SC_MONSTER_TRANSFORM, 1) != G_L_SHECIL || countitem(Steel_Article_) <= 4 || questprogress(12342) != 1) {
		mes("Not an authorized user. Abort the operation.");
		close();
	}
	
	mes("Do you want to use the auto anvil and shape the standard Steel Artifacts into a firearm?");
	next();
	if (select("Quit.", "Begin.") == 1) {
		mes("For your safety, please step away from the auto anvil.");
		close();
	}
	if (rand(1, 10) > 6) {
		specialeffect(EF_REPAIRWEAPON);
		mes("You have successfully created a firearm using the auto anvil. ^ff0000Please report before your transformation expires^000000.");
		delitem(Steel_Article_, 5);
		getitem(Tiny_Flame, 1);
	} else {
		specialeffect(EF_SUI_EXPLOSION);
		mes("Failed to create a firearm.");
		delitem(Steel_Article_, 5);
	}
	close();
	
OnInit:
	hideoffnpc("Auto Anvil#1");
	end;
}

job_gun,165,18,1	script	Furnace Controller#2	CLEAR_NPC,{
	mes("The system is busy dredging a completed mold from the furnace.");
	close();

OnInit:
	hideonnpc("Furnace Controller#2");
	end;

OnStart:
	hideoffnpc("Furnace Controller#2");
	sleep(3000);
	mapannounce("job_gun", "Furnace Controller: Dredging a mold up from the furnace... Workers, stand by at the production line.", bc_map, "0x00ff44");
	sleep(500);
	.@wh_start = 0;
	while (true) {
		if (.@wh_start >= 30)
			break;
		
		.@eff_rnd = rand(1, 100);
		if (.@eff_rnd < 33) { // 0 - 32
			donpcevent("Heating Furnace#3::OnStart");
		} else if (.@eff_rnd > 66) { // 67-100
			donpcevent("Heating Furnace#4::OnStart");
		} else { // 33-66
			donpcevent("Heating Furnace#5::OnStart");
		}
		sleep(200);
		makeitem(Steel_Article, 1, "job_gun", rand(127, 143), rand(26, 29));
		if (rand(1, 10) > 7) {
			makeitem(Steel_Article_, 1, "job_gun", rand(127, 143), rand(26, 29));
		}
		.@wh_start += 1;
		sleep(500);
		
	}
	sleep(2000);
	mapannounce("job_gun", "Furnace Controller: Finishing the operation... Entering Standby mode in 15 seconds.", bc_map, "0x00ff44");
	sleep(15000);
	hideonnpc("Furnace Controller#2");
	hideoffnpc("Furnace Controller#1");
	end;
}

job_gun,130,31,1	script	Heating Furnace#3	CLEAR_NPC,{
	end;

OnStart:
	specialeffect(EF_FIREPILLAR);
	sleep(500);
	specialeffect(EF_FIREPILLARBOMB);
	end;
}

job_gun,136,31,1	script	Heating Furnace#4	CLEAR_NPC,{
	end;

OnStart:
	specialeffect(EF_FIREPILLAR);
	sleep(500);
	specialeffect(EF_FIREPILLARBOMB);
	end;
}

job_gun,141,31,1	script	Heating Furnace#5	CLEAR_NPC,{
	end;

OnStart:
	specialeffect(EF_FIREPILLAR);
	sleep(500);
	specialeffect(EF_FIREPILLARBOMB);
	end;
}

function	script	F_summonTargetMonster	{
	.@monster_id = getarg(0);
	.@max_mob_count = getarg(1);
	.@monster_name$ = getarg(2);
	.@event_name$ = getarg(3);
	while(true) {
		.@mob_dead_num = mobcount("job_gun", .@event_name$);
		if (.@mob_dead_num >= .@max_mob_count)
			break;

		switch(rand(1, 5)) {
			case 1:
				.@mobx = rand(88, 99);
				.@moby = rand(143, 147);
				break;
			case 2:
				.@mobx = rand(92, 96);
				.@moby = rand(95, 122);
				break;
			case 3:
				.@mobx = rand(143, 159);
				.@moby = rand(99, 100);
				break;
			case 4:
				.@mobx = rand(157, 158);
				.@moby = rand(137, 160);
				break;
			case 5:
				.@mobx = rand(119, 134);
				.@moby = rand(156, 160);
				break;
		}
		monster("job_gun", .@mobx, .@moby, .@monster_name$, .@monster_id, 1, .@event_name$);
	}
	return;
}

job_gun,1,4,1	script	#target	CLEAR_NPC,{
	end;

OnStart:
	killmonster("job_gun", "#target::OnTargetDead");
	callfunc("F_summonTargetMonster", J_REB_SHECIL1, 16, _("Standard-issue Target"), "#target::OnTargetDead");
	end;

OnInit:
	hideonnpc("#target");
	callfunc("F_summonTargetMonster", J_REB_SHECIL1, 16, _("Standard-issue Target"), "#target::OnTargetDead");
	end;

OnTargetDead:
	hideonnpc("#target");
	callfunc("F_summonTargetMonster", J_REB_SHECIL1, 16, _("Standard-issue Target"), "#target::OnTargetDead");
	end;
}

job_gun,1,5,1	script	#nontarget	CLEAR_NPC,{
	end;
OnStart:
	killmonster("job_gun", "#nontarget::OnNonTargetDead");
	hideonnpc("#nontarget");
	callfunc("F_summonTargetMonster", J_REB_SHECIL2, 56, _("Defective Target"), "#nontarget::OnNonTargetDead");
	end;

OnInit:
	hideonnpc("#nontarget");
	callfunc("F_summonTargetMonster", J_REB_SHECIL2, 56, _("Defective Target"), "#nontarget::OnNonTargetDead");
	end;

OnNonTargetDead:
	hideonnpc("#nontarget");
	callfunc("F_summonTargetMonster", J_REB_SHECIL2, 56, _("Defective Target"), "#nontarget::OnNonTargetDead");
	end;
}

moc_fild12,261,318,3	script	Suspicious Man	4_M_MOCASS2,2,2,{
	end;
OnTouch:
	if (Class != Job_Gunslinger || BaseLevel < 99 || JobLevel < 70)
		end;
	if (questprogress(12340) < 1) {
		mes("[Suspicious Man]");
		mes("Finally I've found you, Vagabond Spike! Your neck is mine!");
		next();
		select("Say what?");
		
		mes("[Suspicious Man]");
		mes("*Snort* Don't pretend like you don't know. Look at this poster! You're in it!");
		next();
		select("I see the resemblance, but that's not me.");

		mesf("[%s]", strcharinfo(PC_NAME));
		mes("Forget the resemblance. Where did you get that poster? I've never committed a crime.");
		next();
		mes("[Suspicious Man]");
		mes("I knew you'd try to lie your way out.");
		next();
		mes("[Suspicious Man]");
		mes("The ^0000ffEinbroch Private Pub^000000 has released that wanted poster. You have many bounty hunters like me on your heels.");
		next();
		mes("[Suspicious Man]");
		mes("I don't care if you're the right one so long as you look it and I can take you dead or alive.");
		next();
	} else {
		mes("[Suspicious Man]");
		mes("It's you again! You've got guts to come back here!");
		next();
	}
	switch (select("Make a run for it.", "Fight him.")) {
	case 1:
		mes("^0000ffI should run for now and think about this later.^000000");
		close2();
		break;
	case 2:
		mes("^0000ffHe's not the only bounty hunter after me, if he's telling the truth. I need time to strategize.^000000");
		close2();
		break;
	}
	setquest(12340);
	warp("moc_fild12", 186, 83);
	end;
}

einbroch,54,97,3	script	Bouncer	4_M_REBELLION,2,2,{
	if (Class != Job_Gunslinger) {
		mes("[Bouncer]");
		mes("No loitering around the venue.");
		close();
	}
	if (questprogress(12340) < 1) {
		mes("[Bouncer]");
		mes("Under construction, can't get in.");
		close();
	} else if (questprogress(12340) == 1) {
		mes("[Bouncer]");
		mes("*Gasp* You! I thought you were already captured. Ooh, doesn't matter now. You're my Get Out of Jail Free card!");
		next();
		select("I'm not the criminal you think I am!");
		mes("[Bouncer]");
		mes("You aren't?");
		next();
		mes("^0000ffThe bouncer examines your face.^000000");
		next();
		mes("[Bouncer]");
		mes("Hm, you bear a striking resemblance, though you don't look not as menacing as that criminal Spike");
		next();
		select("I want to talk to the poster publisher.");
		mes("[Bouncer]");
		mes("Your problem is a bit out of my league. Get in. If I find out you're the real deal all along, I'll see that you'll never see the outside again.");
		close2();
		warp("job_gun", 81, 29);
	} else if (questprogress(12340) > 1) {
		mes("[Bouncer]");
		mes("You're back. Why?");
		next();
		if (select("I want in.", "I was passing by.") == 2) {
			mes("[Bouncer]");
			mes("You're silly.");
			close();
		}
		mes("[Bouncer]");
		mes("Go ahead. Stay out of trouble.");
		close2();
		warp("job_gun", 70, 28);
	}
	end;
}

job_gun,68,33,3	script	Ruthless Rebellion	4_F_REBELLION,2,2,{
	mes("[Ruthless Rebellion]");
	mes("Do you know how to use a gun?");
	close();
}

job_gun,78,33,6	script	Suspicious Gunslinger	4_M_JOB_BLACKSMITH,2,2,{
	mes("[Suspicious Gunslinger]");
	mes("... ");
	next();
	mes("[Quiet Gunslinger]");
	mes("Don't say I look like a blacksmith you know.");
	close();
}

job_gun,74,24,6	script	Drunken Man	4_M_LIEMAN,2,2,{
	mes("[Drunken Man]");
	mes("*Hiccups* Oh, I'm the owner here.");
	mes("Oh wait, am I in the pub or someplace else? Zzz...");
	close();
}

job_gun,64,33,6	script	Anxious Man	4_M_ALCHE_A,2,2,{
	mes("[Anxious Man]");
	mes("Maybe I'm in the wrong place. This place doesn't look like a pub.");
	close();
}

job_gun,86,29,3	script	Kulbertinov	4_M_REBELLION,2,2,{
	if (Class != Job_Gunslinger) {
		mes("[Kulbertinov]");
		mes("Are you looking for me?");
		close();
	}
	if (questprogress(12340) < 1) {
		mes("[Kulbertinov]");
		mes("Can I help you?");
		close();
	} else if (questprogress(12340) == 1) {
		mes("[Kulbertinov]");
		mes("What do you want?");
		next();
		select("I'm mistaken for a criminal!");
		mes("[Kulbertinov]");
		mes("Wait a minute... Mwah hah hah!");
		next();
		mes("^0000ffHe scans your face, then guffaws.^000000");
		next();
		mes("[Kulbertinov]");
		mes("I'm sorry. For a moment, I thought Spike came back to life. He was found dead three days ago.");
		next();
		select("He was captured already?");
		mes("[Kulbertinov]");
		mes("Yes, and the bounty hunter was already paid. The news hasn't spread, and you're the spitting image of him. Go figure.");
		next();
		select("You have to do something!");
		mes("[Kulbertinov]");
		mes("I'm sorry, but I can't talk to every single bounty hunter for you. Of course, I'm willing to compensate for your inconvenience.");
		next();
		mes("[Kulbertinov]");
		mes("Hey, how about you join our ranks? At the very last, you won't get shot.");
		next();
		select("You want me become a bounty hunter?");
		mes("[Kulbertinov]");
		mes("No, bounty hunting is just a pastime. We're the experts of all the firearms in the world.");
		next();
		mes("[Kulbertinov]");
		mes("Carefree spirits!");
		mes("Magical spitfires!");
		mes("We call ourselves the ^0000ffRebellion^000000.");
		next();
		mes("[Kulbertinov]");
		mes("You look like you know how to use a gun. How'd you like to join our ranks? You won't have to worry about other bounty hunters anymore too.");
		next();
		switch (select("Let me think it over.", "I don't think I have a choice.")) {
		case 1:
			mes("[Kulbertinov]");
			mes("You can think it over and over, but the answer won't change. Just take the offer.");
			break;
		case 2:
			mes("[Kulbertinov]");
			mes("Good thinking. Might as well do it now and get it over with.");
			break;
		}
		next();
		mes("[Kulbertinov]");
		mes("Talk to Enwin Conick. She guides drifting spirits like you to the way of the Rebellion. I'll send word to her. Ah, and don't point your gun at her.");
		setquest(12341);
		completequest(12340);
	} else if (questprogress(12340) > 1) {
		mes("[Kulbertinov]");
		mes("Do you have business with Elwin Conick?");
		next();
		if (select("No.", "Send me to Elwin Conick.") == 1) {
			mes("[Kulbertinov]");
			mes("All right. Care for a shot of vodka?");
			close();
		}
		mes("[Kulbertinov]");
		mes("Okay, I'll let her know.");	
	}
	close2();
	warp("job_gun", 19, 15);
	end;
}

job_gun,19,24,3	script	Elwin Conick#1	4_F_REBELLION,2,2,{
	if (Class != Job_Gunslinger) {
		mes("[Elwin Conick]");
		mes("If you don't want to join Rebellions, just get out.");
		close2();
		warp("job_gun", 81, 29);
		end;
	}
	if (questprogress(12341) == 1) {
		mes("[Elwin Conick]");
		mes("Do you to join us Rebellions?");
		next();
		mes("^0000ffThe short woman with keen eyes stares into your eyes.^000000");
		next();
		mes("[Elwin Conick]");
		mes("Sign here.");
		next();
		mes("^0000ffThe undersigned party [_____] will not speak of the test even if he or she suffers injury, mutilation, or death in an unforeseen accident that may occur during the test.^000000");
		next();
		select("WHAT?!");
		mes("[Elwin Conick]");
		mes("Do you want join us or not?");
		next();
		if (select("I give up.", "...I'll sign.") == 1) {
			mes("[Elwin Conick]");
			mes("Your choice.");
			close2();
			warp("job_gun", 81, 29);
			end;
		}
		mes("[Elwin Conick]");
		mes("Good. Now, follow me.");
		close2();
		warp("job_gun", 117, 41);
		end;
	}
	if (questprogress(12342) == 1) {
		mes("[Elwin Conick]");
		mes("Do you want to try again?");
		next();
		if (select("I give up.", "Do it.") == 1) {
			mes("[Elwin Conick]");
			mes("Your choice.");
			close2();
			warp("job_gun", 81, 29);
			end;
		}
		mes("[Elwin Conick]");
		mes("Follow me.");
		close2();
		warp("job_gun", 117, 41);
		end;
	}
	if (questprogress(12343) == 1) {
		mes("[Elwin Conick]");
		mes("You still have Ivan's shooting test, do you want to try again?");
		next();
		if (select("I give up.", "Do it.") == 1) {
			mes("[Elwin Conick]");
			mes("It's not worth to give up, now go out and relax.");
			close2();
			warp("job_gun", 81, 29);
			end;
		}
		mes("[Elwin Conick]");
		mes("Remember to give your best.");
		close2();
		warp("job_gun", 120, 130);
		end;
	}
	if (questprogress(12343) > 1) {
		mes("[Elwin Conick]");
		mes("Ivan's shooting test have not finished yet, do you want to try again?");
		next();
		if (select("I give up.", "Do it.") == 1) {
			mes("[Elwin Conick]");
			mes("It's not worth to give up, now go out and relax.");
			close2();
			warp("job_gun", 81, 29);
			end;
		}
		mes("[Elwin Conick]");
		mes("Remember to give your best.");
		close2();
		warp("job_gun", 120, 130);
		end;
	}
	if (questprogress(12345) == 1) {
		mes("[Elwin Conick]");
		mes("Ivan is waiting for you, go find him.");
		close2();
		warp("job_gun", 120, 130);
		end;
	}
	mes("[Elwin Conick]");
	mes("You have no more test to take. Why don't you go out and have a drink?");
	close2();
	warp("job_gun", 81, 29);
	end;
}

job_gun,117,46,3	script	Elwin Conick#2	4_F_REBELLION,2,2,{
	if (Class != Job_Gunslinger) {
		mes("[Elwin Conick]");
		mes("If you don't want to join Rebellions, just get out.");
		close2();
		warp("job_gun", 81, 29);
		end;
	}
	if (getstatus(SC_MONSTER_TRANSFORM, 1) == G_L_SHECIL) {
		mes("^0000ffYou are already in the test form. If you have finished all your tests, report to Elwin Conick in the Assembly Room^000000.");
		close();
	} else if (getstatus(SC_MONSTER_TRANSFORM, 1) > 1) {
		mes("[Elwin Conick]");
		mes("Look at yourself, do you really want to test?");
		next();
		mes("^0000ffElwin see you turn into another form and she is very angry. Wait for your current form ends, and then find her again.^000000");
		next();
		if (select("Wait.", "Go away.") == 1) {
			mes("[Elwin Conick]");
			mes("It's not worth to give up, now go out and relax..");
			close();
		}
		mes("[Elwin Conick]");
		mes("Come back when you aren't in any form.");
		close2();
		warp("job_gun", 81, 29);
		end;
	}
	if (questprogress(12341) == 1) {
		.@st_job1 = countitem(Steel_Article);
		.@st_job2 = countitem(Steel_Article_);
		if (.@st_job1 > 0) {
			delitem(Steel_Article, .@st_job1);
			mes("[Elwin Conick]");
			mes("Any leftover Steel Artifacts must be returned after the test.");
			close();
		}
		if (.@st_job2 > 0) {
			delitem(Steel_Article_, .@st_job2);
			mes("[Elwin Conick]");
			mes("Any leftover Steel Artifacts must be returned after the test.");
			close();
		}
		if (countitem(Tiny_Flame) > 0) {
			delitem(Tiny_Flame, 1);
			mes("[Elwin Conick]");
			mes("Time over. You failed the test. Let me take all your leftover test materials.");
			close();
		}
		setquest(12342);
		completequest(12341);
		.@showDialog = true;
	} else if (questprogress(12342) == 1) {
		.@st_job1 = countitem(Steel_Article);
		.@st_job2 = countitem(Steel_Article_);
		if (.@st_job1 > 0) {
			delitem(Steel_Article, .@st_job1);
			mes("[Elwin Conick]");
			mes("Any leftover Steel Artifacts must be returned after the test.");
			close();
		}
		if (.@st_job2 > 0) {
			delitem(Steel_Article_, .@st_job2);
			mes("[Elwin Conick]");
			mes("Time over. You failed the test. Let me take all your leftover test materials.");
			close();
		}
		if (countitem(Tiny_Flame) > 0) {
			delitem(Tiny_Flame, 1);
			mes("[Elwin Conick]");
			mes("Time over. You failed the test. Let me take all your leftover test materials.");
			close2();
			end;
		}
		.@showDialog = true;
	}
	if (.@showDialog) {
		mes("[Elwin Conick]");
		mes("Listen up. I'm not going to great lengths trying to explain the test to you.");
		next();
		select("Okay.");
		mes("[Elwin Conick]");
		mes("This is where the firearm molds are cast. Everywhere you can see Steel Artifacts are being produced.");
		next();
		mes("[Elwin Conick]");
		mes("You'll be asked to control switches on the machine and select 5 standard Steel Artifacts.");
		next();
		mes("[Elwin Conick]");
		mes("You'll then take them to the next Assembly Room and assemble them into a complete firearm. You'll be given 3 minutes to finish all that. ^0000ffTo check the elapsed time, you'll be transformed into a different job^000000.");
		next();
		mes("[Elwin Conick]");
		mes("I'll be in the next room, waiting for you to bring me a complete firearm. Remember, ^0000ffyou fail the test when your transformation expires after 3 minutes^000000.");
		montransform(G_L_SHECIL, 180000);
		close();
	}
	mes("[Elwin Conick]");
	mes("Ah? Are you lost? You need to register first and then get back here.");
	close2();
	warp("job_gun", 81, 29);
	end;
}

job_gun,198,39,3	script	Elwin Conick#3	4_F_REBELLION,2,2,{
	if (Class != Job_Gunslinger) {
		mes("[Elwin Conick]");
		mes("If you don't want to join Rebellions, just get out.");
		close2();
		warp("job_gun", 81, 29);
		end;
	}
	if (questprogress(12342) != 1) {
		mes("[Elwin Conick]");
		mes("Ah? Are you lost? You need to register first and then get back here.");
		close2();
		warp("job_gun", 81, 29);
		end;
	}
	if (getstatus(SC_MONSTER_TRANSFORM, 1) == G_L_SHECIL) {
		if (countitem(Tiny_Flame) == 0) {
			mes("[Elwin Conick]");
			mes("Are you done? I don't see any completed firearm in your inventory.");
			close();
		}
		delitem(Tiny_Flame, 1);
		mes("[Elwin Conick]");
		mes("It's shoddy but not bad, given the time. You passed.");
		next();
		mes("[Elwin Conick]");
		mes("Let me take all your leftover test materials.");
		.@st_job1 = countitem(Steel_Article);
		.@st_job2 = countitem(Steel_Article_);
		if (.@st_job1 > 0) {
			delitem(Steel_Article, .@st_job1);
		}
		if (.@st_job2 > 0) {
			delitem(Steel_Article_, .@st_job2);
		}
		next();
		mes("[Elwin Conick]");
		mes("Now you can move on to the next course. Ivan Sidorenko will oversee your test.");
		completequest(12342);
		close2();
		warp("job_gun", 120, 133);
		end;

	} else if (getstatus(SC_MONSTER_TRANSFORM, 1) > 1) {
		mes("[Elwin Conick]");
		mes("Look at yourself, do you really want to test?");
		next();
		mes("^0000ffElwin see you turn into another form and she is very angry. Wait for your current form ends, and then find her again.^000000");
		next();
		if (select("Wait.", "Go away.") == 1) {
			mes("[Elwin Conick]");
			mes("It's not worth to give up, now go out and relax..");
			close();
		}
		mes("[Elwin Conick]");
		mes("Come back when you aren't in any form.");
		close2();
		warp("job_gun", 81, 29);
		end;
	} else {
		mes("[Elwin Conick]");
		mes("Time over. You failed the test. Let me take all your leftover test materials.");
		.@st_job1 = countitem(Steel_Article);
		.@st_job2 = countitem(Steel_Article_);
		if (.@st_job1 > 0) {
			delitem(Steel_Article, .@st_job1);
		}
		if (.@st_job2 > 0) {
			delitem(Steel_Article_, .@st_job2);
		}
		if (countitem(Tiny_Flame) > 0) {
			delitem(Tiny_Flame, 1);
		}
		next();
		mes("[Elwin Conick]");
		mes("Let's start again.");
		close2();
		warp("job_gun", 117, 41);
		end;
	}
	end;
}

job_gun,120,138,3	script	Ivan Sidorenko#1	4_M_REBELLION,2,2,{
	if (Class != Job_Gunslinger) {
		mes("[Ivan Sidorenko]");
		mes("This is shooting test area, you can't come here as you like.");
		close2();
		warp("job_gun", 81, 29);
		end;
	}
	if (questprogress(12342) < 2) {
		mes("[Ivan Sidorenko]");
		mes("There seems to be a mistake, you can't stay here.");
		close2();
		warp("job_gun", 81, 29);
		end;
	}
	if (questprogress(12343) < 1) {
		mes("[Ivan Sidorenko]");
		mes("Hey, stay focused--we're using live ammo here, and you can get shot anytime.");
		next();
		mes("[Ivan Sidorenko]");
		mes("Let me make this quick. Basically you'll be running in this shooting range consisting of 5 sections.");
		next();
		mes("[Ivan Sidorenko]");
		mes("The objective is to find enemies in the midst of a crowd quickly and without fail.");
		next();
		mes("[Ivan Sidorenko]");
		mes("Among all the targets, you must shoot only the ^0000ffStandard-issue Targets^000000. If you make a mistake, you'll lose points.");
		next();
		mes("[Ivan Sidorenko]");
		mes("Let's try. There aren't many ^0000ffStandard-issue Targets^000000, so keep your eyes peeled.");
		next();
		mes("[Ivan Sidorenko]");
		mes("^0000ffYou have 3 minutes to finish this test. If you can't finish before your transformation expires^000000, you'll fail. If that happens, just follow the path back to me.");
		next();
		mes("[Ivan Sidorenko]");
		mes("^0000ffYou'll fail if you miss a Standard-issue Target, or shoot 3 incorrect targets^000000. Let's get started.");
		setquest(12343);
		setquest(12344);
		montransform(G_L_SHECIL, 180000);
		close2();
		warp("job_gun", 102, 146);
		end;
	} else if (questprogress(12343) == 1) {
		.@standard_target = 0;
		.@failed_target = 0;
		.@total_target = 0;
		if (questprogress(12343, HUNTING) == 2) {
			.@standard_target = 10;
		}
		if (questprogress(12344, HUNTING) == 2) {
			.@failed_target = 2;
		}
		if (getstatus(SC_MONSTER_TRANSFORM, 1) != G_L_SHECIL) {
			.@total_target = 5;
		}
		.@target_count = .@standard_target - (.@failed_target + .@total_target);	// 
		if (.@target_count > 9) { // Killed 10 Standard, 0 Failed
			completequest(12343);
			completequest(12344);
			setquest(12345);
			mes("[Ivan Sidorenko]");
			mes("Good job. I didn't think you could pass so quickly.");
			next();
			mes("[Ivan Sidorenko]");
			mes("You may leave and wait outside. I'll bring other instructors' evaluation reports to see you.");
			close2();
			warp("job_gun", 210, 132);
			end;
		} else if (.@target_count == 8) { // Killed 10 Standard, 3 failed
			erasequest(12343);
			erasequest(12344);
			mes("[Ivan Sidorenko]");
			mes("You're quick enough, but you shot too many incorrect targets. You failed.");
			next();
		} else if (.@target_count == 5) { // Timeout
			erasequest(12343);
			erasequest(12344);
			mes("[Ivan Sidorenko]");
			mes("You accurate enough, but you took too much time. Slow Rebellions don't survive long enough.");
			next();
		} else if (.@target_count < 5) { // Timeout and failed targets
			erasequest(12343);
			erasequest(12344);
			mes("[Ivan Sidorenko]");
			mes("You failed at both speed and accuracy. How did you survive this long?");
			next();
		} else {
			erasequest(12343);
			erasequest(12344);
			mes("[Ivan Sidorenko]");
			mes("There's a problem, the statistic seems to be wrong. Well... This can happen sometimes.");
			next();
		}
		mes("[Ivan Sidorenko]");
		mes("Let's try again. Be more careful this time.");
		setquest(12343);
		setquest(12344);
		montransform(G_L_SHECIL, 180000);
		close2();
		warp("job_gun", 102, 146);
		end;
	} else {
		mes("[Ivan Sidorenko]");
		mes("How did you not leave?");
		next();
		mes("[Ivan Sidorenko]");
		mes("You may leave and wait outside. I'll bring other instructors' evaluation reports to see you.");
		close2();
		warp("job_gun", 210, 132);
		end;
	}
	end;
}

job_gun,220,132,3	script	Ivan Sidorenko#2	4_M_REBELLION,2,2,{
	.@now_weight = MaxWeight - Weight;
	if (checkweight(Knife, 1) == 0) {
		mes("You have too many items, please reduce them to continue.");
		close();
	}
	if (.@now_weight < 1000) {
		mes("The items in your inventory are weighing you down. Lighten your weight first.");
		close();
	}
	if (questprogress(12345) != 1) {
		mes("[Ivan Sidorenko]");
		mes("There must have been a mistake. You aren't supposed to remain here.");
		close2();
		warp("job_gun", 81, 29);
		end;
	}
	if (Class == Job_Gunslinger) {
		if (BaseLevel < 99 || JobLevel < 70) {
			mes("[Ivan Sidorenko]");
			mes("Huh? You look so weak? I have nothing more to say.");
			close();
		}
		if (SkillPoint != 0) {
			mes("[Ivan Sidorenko]");
			mes("Oh no~ You still have Skill Points.");
			close();
		}
		mes("[Ivan Sidorenko]");
		mes("Kulbertinov, Elwin, and I've evaluated your Rebellion test results.");
		next();
		mes("[Ivan Sidorenko]");
		mes("And...");
		next();
		mes("[Ivan Sidorenko]");
		mes("You've met all our requirements including the attitude and the test performance.");
		next();
		mes("[Ivan Sidorenko]");
		mes("That's right, you're now a member of the Rebellion. Get ready to be wowed.");
		next();
		jobchange(Job_Rebellion);
		completequest(12345);
		mes("[Ivan Sidorenko]");
		mes("And Elwin wants you to have this. Take good care of it. He made it for you.");
		getitem(Freedom_Flame, 1);
		next();
		mes("[Ivan Sidorenko]");
		mes("See you later.");
		close2();
		warp("job_gun", 81, 29);
		end;
	} else if (Class == Job_Rebellion) {
		mes("[Ivan Sidorenko]");
		mes("This life should be fun, not boring.");
		next();
		mes("[Ivan Sidorenko]");
		mes("And by becoming a Rebellion your life should be upgraded. So, go and create a great journey, make us proud!");
		close();
	} else {
		mes("[Ivan Sidorenko]");
		mes("Do you have something to say to me, don't you?");
		close();
	}
}

job_gun,220,138,4	trader	Prop Vending Machine	2_VENDING_MACHINE1,{
	end;
OnInit:
	sellitem(Slug_Bullet_1);
	sellitem(Slug_Bullet_2);
	sellitem(Slug_Bullet_3);
	sellitem(Slug_Bullet_4);
	sellitem(Slug_Bullet_5);
	sellitem(Fullmetal_Jacket_Bullet);
	sellitem(Mine_Projectile);
	sellitem(Dragon_Tail_Missile);
	end;
}

job_gun,216,138,4	script	Butler Karlex	1_M_01,{
	mes("[Butler Karlex]");
	mes("Use this temporary storage to keep your items safe while on the Advancement test.");
	next();
	.@select = select("Cancel", "Open the storage.");
	mes("[Butler Karlex]");
	mes("Thank you for using the service.");
	close2();
	if (.@select == 2) {
		openstorage(STORAGE_TYPE_MAIN);
	}
	end;
}

prontera,92,209,4	trader	Rebellion Weapons	2_VENDING_MACHINE1,{
	end;
OnInit:
	sellitem(H_FEATHER_H_FIRE);
	sellitem(ALTAIR_ARES);
	sellitem(COLORSCOPE);
	sellitem(RAG203);
	sellitem(DEATHFIRE);
	sellitem(R_THUNDER);
	sellitem(P_BREAKER);
	sellitem(MINIMAY);
	sellitem(TEMPEST);
	sellitem(END_OF_HORIZON);
	sellitem(Southern_Cross_R);
	end;
}

prontera,96,209,4	trader	Rebellion Accessories	2_VENDING_MACHINE1,{
	end;
OnInit:
	sellitem(Slug_Bullet);
	sellitem(Fullmetal_Jacket_Bullet);
	sellitem(Mine_Projectile);
	sellitem(Dragon_Tail_Missile);
	sellitem(Special_Alloy_Trap);
	sellitem(Bullet);
	sellitem(Silver_Bullet_);
	sellitem(Shell_Of_Blood_);
	sellitem(AP_Ammo);
	sellitem(Blaze_Bullet);
	sellitem(Freezing_Bullet);
	sellitem(Electric_Shock_Bullet);
	sellitem(Magical_Stone_Bullet);
	sellitem(Sanctified_Bullet);
	sellitem(Flare_Bullet);
	sellitem(Lightning_Bullet);
	sellitem(Poison_Bullet);
	sellitem(Blind_Bullet);
	sellitem(Ice_Bullet);
	end;
}
