//===== rAthena Script =======================================
//= Horror Toy Factory
//===== Description: =========================================
//= [Official Conversion]
//= Horror Toy Factory Instance
//===== Changelogs: ==========================================
//= 1.0 First version. Uses official script structure and text
//=     from iRO. [Capuche]
//============================================================

xmas,237,303,3	script	Catherine Jet Johnson	4_F_SKULL06GIRL,{
	if (getstatus(SC_MONSTER_TRANSFORM,1) > 0) {
		mes "[Catherine Jet Johnson]";
		mes "Aaa.. Are you going to go into there?";
		next;
		mes "[Catherine Jet Johnson]";
		mes "You'd better release your transformation if you'd like to enter. It could be dangerous in some ways.";
		close;
	}

	if (BaseLevel < 140) {
		mes "[Catherine Jet Johnson]";
		mes "Ah, wait! Please wait. This is not a good place for a promising young "+ ( Sex ? "man" : "woman" ) +" like you!";
		next;
		mes "[Catherine Jet Johnson]";
		mes "If you must, come back later after you become far stronger. Hmmm.. I would say.. Lv.140?";
		close;
	}

	mes "^ff0000Be cautious taming or other ways than hunting monsters are not considered as normal killing counts.^000000";
	next;
	mes "[Catherine Jet Johnson]";
	switch( isbegin_quest(12330) ) {
	case 0:
		mes "Do.. Don't be afraid of me. Now I look ugly, but I wasn't like this before.";
		next;
		mes "^0000ffThe skull-faced girl in front of you is speaking in a tearful voice. Void holes where there should be eyes are staring at you.^000000";
		next;
		select("What's wrong with your face?");
		mes "[Catherine Jet Johnson]";
		mes "This is a long story.. Would you mind if I talk to you? If you waste your time on someone like me?";
		next;
		if (select( "Quit.", "Please keep talking." ) == 1) {
			mes "[Catherine Jet Johnson]";
			mes "Okay, take care of yourself. And don't ever come near that odd entrance.";
			close;
		}
		mes "[Catherine Jet Johnson]";
		mes "Mmm.. Where should I start.. The story of this town first?...";
		next;
		mes "^0000ffWith a sigh, the girl begins to speak in a subdued tone like a bard who tells an old story.^000000";
		next;
		mes "[Catherine Jet Johnson]";
		mes "There was a toy factory in this town. All of the people in this town work there and I was one of the employees.";
		next;
		mes "[Catherine Jet Johnson]";
		mes "We all were happy in the beginning. We used to gather around together and have a friendly chat having gingerbread and hot tea after work.";
		next;
		select("I couldn't even imagine, seeing this mood...");
		mes "[Catherine Jet Johnson]";
		mes "Yes, because we couldn't earn a livng by packaging toys forever. The situations got tough after the villagers left in ones and twos.";
		next;
		mes "[Catherine Jet Johnson]";
		mes "I was the one who worked as an assistant beside the doll craftsman who made dolls to the end.";
		next;
		mes "^0000ffI could feel her slender jawbone is trembling due to the subtle change of her emotion.^000000";
		next;
		select("Ask her to continue.");
		mes "[Catherine Jet Johnson]";
		mes "On the day when the factory is decided to be closed, the doll maker dressed the last doll he made and shed tears.";
		next;
		mes "[Catherine Jet Johnson]";
		mes "Perhaps he thought he wouldn't make a doll anymore.";
		next;
		mes "[Catherine Jet Johnson]";
		mes "He named the last doll ^0000ffCeline Kimi^000000 and stopped all the lines in the factory.";
		next;
		select("Did he give a doll a name?");
		mes "[Catherine Jet Johnson]";
		mes "Sometimes there can be the work as if it were their child to doll makers. Kimi was the one for him.";
		next;
		mes "[Catherine Jet Johnson]";
		mes "I guess his earnestness breathed life to Kimi.";
		next;
		select("Do you mean the doll is alive?");
		mes "[Catherine Jet Johnson]";
		mes "Yes, ^0000ffShe^000000 became a living creature. I don't know the reason, but she is striding in the toy factory with heavy sorrow and rage.";
		next;
		mes "[Catherine Jet Johnson]";
		mes "When I first saw her, she was standing beside the doll maker who died and collapsed. She stood there with an unknowable expression.";
		next;
		mes "[Catherine Jet Johnson]";
		mes "That's the end. I was outside when I woke up again after I had been blacked out. My face has become like this.";
		next;
		select("Did Kimi do that?");
		mes "[Catherine Jet Johnson]";
		mes "I don't know.. She would do it, or it could be a different problem. I have no memory with this.";
		next;
		select("Do you blame her?");
		mes "[Catherine Jet Johnson]";
		mes "Ah, no. I don't blame her! I just want to know what happened to the doll craftsman on that day.";
		next;
		mes "[Catherine Jet Johnson]";
		mes "I don't think the scene I saw was everything. However, getting into the factory again is.. Re-entering there is...";
		next;
		mes "[Catherine Jet Johnson]";
		mes "Yes, I am scared and reluctant to do it. If there's someone who can help me..";
		next;
		if (select( "I am not very helpful to you.", "Maybe I can help you with it." ) == 1) {
			mes "[Catherine Jet Johnson]";
			mes "Thank you for.. for listening to me. Hope you will enjoy your trip..";
			close;
		}
		mes "[Catherine Jet Johnson]";
		mes "Heh? You would do me a favor?";
		next;
		select("Let's get into the factory with me.");
		mes "[Catherine Jet Johnson]";
		mes "We.. Well, I cannot help you at all except for providing you with directions. Besides, there can be a big danger to you.";
		next;
		select("You can reunite with Kimi, can't you?");
		mes "[Catherine Jet Johnson]";
		mes "Kimi, you mean Kimi..";
		next;
		mes "^0000ffShe is thinking about something intently with gaping eyes.^000000";
		next;
		mes "[Catherine Jet Johnson]";
		mes "I.. I've decided. It won't be a great help to you, but I can simply let you know the directions.";
		next;
		mes "[Catherine Jet Johnson]";
		mes "Wait, please wait until I am prepared. I can guide you when I am ready.";
		setquest 12330;// Skull-faced Girl
		close;
	case 1:
		mes "Done. Let me try to open the closed door.";
		completequest 12330;
		break;
	case 2:
		mes "Kimi's soul is still staying in this ground. When I can let her rest in peace...";
		break;
	}
	next;
	if (getcharid(1) < 1) {
		mes "^0000ffYou need to organize a party having more than a member to get into Horror Toy Factory.^000000";
		close;
	}
	switch( checkquest(12331,PLAYTIME) ) {
	case -1:
		if (getpartyleader(getcharid(1),2) != getcharid(0)) {
			mes "[Catherine Jet Johnson]";
			mes "Eh.. Give me a second. I am talking to the person in charge. Please wait for a while.";
			close;
		}
		if (select( "Unlock Horror Toy Factory", "Cancel" ) == 1) {
			mes "Door will be.. opened soon.. Would you wait for a moment?";
			if (instance_create("Horror Toy Factory") >= 0)
				'xm_d_map$ = instance_mapname("1@xm_d");
		}
		close;
	case 0:
	case 1:
		mes "[Catherine Jet Johnson]";
		mes "The smell of preservative from the factory has not been going away. You cannot stand longer there under this state.";
		next;
		mes "[Catherine Jet Johnson]";
		mes "I will keep you from entering before the scent of preservative is completely gone away.";
		close;
	case 2:
		mes "^0000ffThe smell of preservative has gone away. You can talk to Catherine Jet Johnson.^000000";
		erasequest 12331;
		close;
	}
}

xmas,233,305,4	script	Factory Dimension Telep	PORTAL,{
	if (getstatus(SC_MONSTER_TRANSFORM,1) > 0) {
		mes "[Factory Dimension Teleporter]";
		mes "There are some work study programs as monster workers during the Horror Toy Factory tour. Therefore, ^ff0000You are limited to enter when you are in transformation.^000000";
		close;
	}
	if (BaseLevel < 140) {
		mes "[Factory Dimension Teleporter]";
		mes "You are not eligible for dimensional shifting. You should be at least Lv.140.";
		close;
	}
	if (getcharid(1) < 1) {
		mes "[Factory Dimension Teleporter]";
		mes "You don't have any fellows? Please organize a party and come again if you go alone.";
		close;
	}
	switch( checkquest(12331,PLAYTIME) ) {
	case -1:
		switch( instance_enter("Horror Toy Factory") ) {
		case 3:
			mes "An unknown error has occurred.";
			close;
		case 2:
			mes "The gateway for dimensional shifting has not been activated.";
			close;
		case 1:// dummy
			mes "[Factory Dimension Teleporter]";
			mes "You don't have any fellows? Please organize a party and come again if you go alone.";
			close;
		case 0:
			mapannounce "xmas", getpartyname( getcharid(1) ) +" party's party member "+ strcharinfo(0) +" enters Horror Toy Factory.", bc_map, "0x00ff99";
			setquest 12331;// Trail of Toy Factory
			end;
		}
	case 0:
	case 1:
		mes "You already have a trail of dimensional shifting. Your access has been denied.";
		close;
	case 2:
		mes "^0000ffThe trail of dimensional shifting disappeared. You are allowed to use Factory Dimension Teleporter.^000000";
		erasequest 12331;
		close;
	}
}

1@xm_d,112,20,6	script	Catherine Jet Johnson#0	4_F_SKULL06GIRL,{
	if (getstatus(SC_MONSTER_TRANSFORM,1) > 0) {
		mes "[Catherine Jet Johnson]";
		mes "You cannot come to here if you are under the effect of a monstre transformation.";
		next;
		mes "[Catherine Jet Johnson]";
		mes "Please wait until the transformation is finished. You cannot move to another area before you become normal.";
		close;
	}
	if (getpartyleader(getcharid(1),2) != getcharid(0)) {
		mes "[Catherine Jet Johnson]";
		mes "Eh.. Give me a second. I am talking to the person in charge. Please wait.";
		close;
	}
	mes "[Catherine Jet Johnson]";
	mes "Everyone is in their mortal corruptible state right?";
	npctalk "Catherine Jet Johnson: Everyone is in their mortal corruptible state right?";
	next;
	switch( select( "Quit the story", "Listen to her story.", "I know your situation. Let's start quickly!" ) ) {
	case 1:
		mes "[Catherine Jet Johnson]";
		mes "Oh, dear. Let me know when you are ready.";
		close;
	case 2:
		donpcevent instance_npcname("Catherine Jet Johnson#01") + "::OnStart";
		close;
	case 3:
		donpcevent instance_npcname("Catherine Jet Johnson#01") + "::OnStart2";
		close;
	}
}

1@xm_d,112,20,1	script	Catherine Jet Johnson#01	4_F_SKULL06GIRL,{
	end;
OnStart:
	enablenpc instance_npcname("#bgm01");
	enablenpc instance_npcname("Catherine Jet Johnson#01");
	disablenpc instance_npcname("Catherine Jet Johnson#0");
	sleep 3000;
	npctalk "Catherine Jet Johnson: This area was Factory No.1. It used to be the place where the toys and dolls were stored before given as presents.";
	sleep 5000;
	npctalk "Catherine Jet Johnson: Ah, I remember several things. If someone wasn't in the employee's uniform, the guards used to come and scold them....";
	sleep 5000;
	npctalk "Catherine Jet Johnson: By the way...";
	donpcevent instance_npcname("#fac1ct") + "::OnStart";
	sleep 3000;
	mapannounce 'xm_d_map$, "Factory announcement: Wake up, toy factory working time has come...", bc_map, "0x00ff44";
	sleep 6000;
	npctalk "Catherine Jet Johnson: Wh.. What happened? Toys and dolls are wandering instead of human workers. As if they are employees...";
	sleep 5000;
	npctalk "Catherine Jet Johnson: I think other spirits have inhabited the empty factory for too long.";
	sleep 3000;
	mapannounce 'xm_d_map$, "Factory announcement: Waste and other debries should be kept clear from work areas. This is to keep you safe at all times.", bc_map, "0x00ff44";
	sleep 3000;
	npctalk "Catherine Jet Johnson: It's just like when humans worked here.";
	sleep 3000;
	mapannounce 'xm_d_map$, "Factory announcement: Let's make presents for every child's dream today.", bc_map, "0x00ff44";
	sleep 3000;
	npctalk "Catherine Jet Johnson: But, it's not the time to be happy. Once we find the last factory area, we will need to halt all production lines.";
	sleep 1000;
	mapannounce 'xm_d_map$, "Factory announcement: Please start product line No.1. Don't forget to wear a safety helmet! This means you Bob!", bc_map, "0x00ff44";
	sleep 3000;
	npctalk "Catherine Jet Johnson: Ah, maybe we should restore those toys and gift boxes to their original condition.";
	sleep 5000;
	npctalk "Catherine Jet Johnson: Eh? I... I mean... To return them as they were.. Yes... We need to fight them? I don't how exactly.";
	sleep 2000;
	mapannounce 'xm_d_map$, "Factory announcement: All employees must wear a proper uniform and identification. Please check with security if you do not have yours.", bc_map, "0x00ff44";
	sleep 3000;
	npctalk "Catherine Jet Johnson: Good heavens, I home the guards are still human. There were boxes of uniforms near here in the past..";
	enablenpc instance_npcname("Employees' Uniform Box#1");
	enablenpc instance_npcname("Employees' Uniform Box#2");
	enablenpc instance_npcname("Employees' Uniform Box#3");
	sleep 5000;
	npctalk "Catherine Jet Johnson: Ah, they are behind me. You'd better change into the uniform. Fortunately, I still have my employee card.";
	sleep 5000;
	npctalk "Catherine Jet Johnson: I will find my way around here. Let's meet near the second production line. Cheer up its a toy factory. It can't be all that bad!!";
	sleep 6000;
	disablenpc instance_npcname("Catherine Jet Johnson#01");
	disablenpc instance_npcname("#bgm01");
	end;

OnStart2:
	enablenpc instance_npcname("#bgm01");
	enablenpc instance_npcname("Catherine Jet Johnson#01");
	disablenpc instance_npcname("Catherine Jet Johnson#0");
	sleep 3000;
	npctalk "Catherine Jet Johnson: Ah.. We have explored here before? Okay, let's meet at the same spot again.";
	sleep 6000;
	disablenpc instance_npcname("Catherine Jet Johnson#01");
	enablenpc instance_npcname("Employees' Uniform Box#1");
	enablenpc instance_npcname("Employees' Uniform Box#2");
	enablenpc instance_npcname("Employees' Uniform Box#3");
	mapannounce 'xm_d_map$, "Factory announcement: Wake up, toy factory working time has come...", bc_map, "0x00ff44";
	sleep 6000;
	mapannounce 'xm_d_map$, "Factory announcement: Waste and other debries should be kept clear from work areas. This is to keep you safe at all times.", bc_map, "0x00ff44";
	sleep 6000;
	mapannounce 'xm_d_map$, "Factory announcement: Let's make presents for every child's dream today.", bc_map, "0x00ff44";
	donpcevent instance_npcname("#fac1ct") + "::OnStart";
	disablenpc instance_npcname("#bgm01");
	end;

OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	// disable some warps
	disablenpc instance_npcname("#fac3wp");
	disablenpc instance_npcname("#fac3wp2");
	disablenpc instance_npcname("#fac4wp");
	disablenpc instance_npcname("#fac4wp2");
	disablenpc instance_npcname("#fac5wp");
	disablenpc instance_npcname("#fac6wp");
	end;
}

1@xm_d,112,20,0	script	#bgm01	-1,9,9,{
	end;
OnTouch:
	playBGM "99";
	end;
OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,13,105,6	script	Employees' Uniform Box#1	4_NONMYSTCASE,{
	progressbar "ffff00",1;
	playBGM "52";
	.@mob_id_transform = getstatus(SC_MONSTER_TRANSFORM,1);
	if (.@mob_id_transform == 1246 || .@mob_id_transform < 1) {
		mes "^0000ffYou put on a factory uniform. There still seem to be a few uniforms left in the box.^000000";
		transform 1246,180000;// COOKIE_XMAS
		close;
	}
	mes "^ff0000In transformation";
	mes "You cannot use uniform box when already transformed.^000000";
	close;
OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}
1@xm_d,116,16,6	duplicate(Employees' Uniform Box#1)	Employees' Uniform Box#2	4_NONMYSTCASE
1@xm_d,10,20,6	duplicate(Employees' Uniform Box#1)	Employees' Uniform Box#3	4_NONMYSTCASE

1@xm_d,1,5,3	script	#fac1ct	CLEAR_NPC,{
	end;
OnStart:
	.@event$ = instance_npcname("#fac1ct") + "::OnMyMobDead";
	killmonster 'xm_d_map$, .@event$;
	areamonster 'xm_d_map$,16,24,114,112, "Vicious Cookie",2989,31, .@event$;	// XM_COOKIE
	areamonster 'xm_d_map$,16,24,114,112, "Evil Dwelling Box",2991,36, .@event$;// XM_MYSTCASE
	end;

OnMyMobDead:
	if (mobcount( 'xm_d_map$, instance_npcname("#fac1ct") + "::OnMyMobDead" ) < 30)
		initnpctimer;
	end;

OnTimer1000:
	killmonster 'xm_d_map$, instance_npcname("#fac1ct") + "::OnMyMobDead";
	enablenpc instance_npcname("#fac1bs");
	mapannounce 'xm_d_map$, "Coordinator's announcement: Huh? Where's everyone! How dare workers to be absent from the line!", bc_map, "0xff8800";
	for ( .@i = 61; .@i <= 89; .@i++ )
		disablenpc instance_npcname( "alert#"+ .@i );
	stopnpctimer;
	end;

OnInstanceInit:
	hideonnpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,71,129,3	script	#fac1bs	4_M_COOKIE,{
	if (getpartyleader(getcharid(1),2) == getcharid(0)) {
		.@mob_id_transform = getstatus(SC_MONSTER_TRANSFORM,1);
		mes "[Coordinator]";
		if (.@mob_id_transform == 1246) {
			mes "I can't find the other workers. We don't have time for dawdling. Children are waiting for presents.";
			next;
			mes "[Coordinator]";
			mes "Hurry up! Carry ^ff0000the gift box over there^000000 and move to the east.";
			enablenpc instance_npcname("#pck1");
			npctalk "Coordinator: Hurry up! Carry the gift box over there and move to the east.";
		}
		else if (.@mob_id_transform == 1249)
			mes "Why are you hanging around! Carry ^ff0000the gift box over here^000000 and move to the east.";
		else {
			mes "What!? Humans!!!";
			donpcevent instance_npcname("#fac1bs") + "::OnAlert";
		}
		close;
	}
	end;

OnAlert:
	.@npc_name$ = instance_npcname("#fac1bs");
	.@event$ = .@npc_name$ + "::OnMyMobDead";
	killmonster 'xm_d_map$, .@event$;
	npctalk "Coordinator: Guard! Where is guard! Humans are invading!!";
	sleep 3000;
	disablenpc .@npc_name$;
	for ( .@i = 0; .@i <= 10; .@i++ ) {
		areamonster 'xm_d_map$,61,118,71,128, "Guard",2990,1, .@event$;// XM_CRUISER
		sleep 300;
	}
	initnpctimer;
	end;
OnMyMobDead:
	end;

OnTimer60000:
	.@npc_name$ = instance_npcname("#fac1bs");
	killmonster 'xm_d_map$, .@npc_name$ + "::OnMyMobDead";
	enablenpc .@npc_name$;
	npctalk "Coordinator: This kind of things happens a lot these days...";
	stopnpctimer;
	end;

OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,65,127,6	script	#pck1	4_NONMYSTCASE,{
	progressbar "ffff00",1;
	.@mob_id_transform = getstatus(SC_MONSTER_TRANSFORM,1);
	if (.@mob_id_transform == 1246) {
		mes "^0000ffYou are carrying the packaged present.^000000";
		transform 1249,180000;// MYSTCASE
	}
	else if (.@mob_id_transform == 1249)
		mes "^009900The box is in your hands. You cannot carry more than one boxe.^000000";
	else
		mes "^ff0000You are not in uniform. The Coordinator won't let you pick it up.^000000";
	close;

OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,76,129,0	script	#fac1wp	WARPNPC,2,2,{
OnTouch:
	if (getstatus(SC_MONSTER_TRANSFORM,1) == 1249) {
		warp 'xm_d_map$,88,129;
		playBGM "54";
	}
	end;
}

1@xm_d,179,129,0	script	#fac2wp	WARPNPC,2,2,{
OnTouch:
	if (getstatus(SC_MONSTER_TRANSFORM,1) == 1249) {
		warp 'xm_d_map$,183,100;
		playBGM "54";
	}
	end;
}

1@xm_d,1,5,3	script	#alert1	CLEAR_NPC,{
	end;
OnStart:
	.@r = rand(1,10);
	if (.@r == 1)
		mapannounce 'xm_d_map$, "Factory announcement: Outsiders are spotted on the product line. Guard, please move out immediately.",bc_map,"0x00ffff";
	else if (.@r == 2)
		mapannounce 'xm_d_map$, "Factory announcement: Invaders have been identified. Distinction Code AX0829. Type: Human. Chase them away.", bc_map, "0x00ffff";
	else if (.@r == 3)
		mapannounce 'xm_d_map$, "Guard's announcement: Please immediately leave here, outsiders.", bc_map, "0xffff00";
	else if (.@r == 4)
		mapannounce 'xm_d_map$, "Factory announcement: Outsiders, hold up your hands and surrender. Otherwise, I will shoot you.", bc_map, "0x00ffff";
	else if (.@r == 5)
		mapannounce 'xm_d_map$, "Factory announcement: Dispatch the guard. Suppress the invaders.", bc_map, "0x00ffff";
	else if (.@r == 6)
		mapannounce 'xm_d_map$, "CAUTION: The plant manger is coming to inspect. Wipe out the outsiders.", bc_map, "0xff4444";
	else if (.@r == 7)
		mapannounce 'xm_d_map$, "Factory announcement: Not good news. Outside creatures are detected. Guard, please mobilize.", bc_map, "0x00ff88";
	else if (.@r == 8)
		mapannounce 'xm_d_map$, "Factory announcement: Outsiders or invaders are obstacles to operate the factory. You can kill them if it is necessary.", bc_map, "0xff9999";
	else if (.@r == 9)
		mapannounce 'xm_d_map$, "Factory announcement: Okay that's it, party's over! Get out of my house!", bc_map, "0x00ffff";
	else
		mapannounce 'xm_d_map$, "Guard's announcement: Invaders are spotted! They seem human! I will blip them off!", bc_map, "0xffff00";
	end;

OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,10,24,0	script	alert#61	-1,10,10,{
OnTouch_:
	if (getstatus(SC_MONSTER_TRANSFORM,1) != 1246) {
		switch( atoi(strnpcinfo(2)) ) {
			case 63: case 66:
			case 69: case 72:
			case 79: case 82:
			case 85: case 88:
				.@count = 4;
				break;
			case 61: case 64:
			case 67: case 70:
			case 73: case 75:
			case 77: case 80:
			case 83: case 86:
			case 89:
				.@count = 6;
				break;
			default:
				.@count = 5;
				break;
		}
		getmapxy .@map$, .@x, .@y, 0;
		.@npc_name$ = instance_npcname( strnpcinfo(0) );
		.@event$ = .@npc_name$ + "::OnMyMobDead";
		playBGM "125";
		specialeffect EF_VENOMDUST;
		donpcevent instance_npcname("#alert1") + "::Onstart";
		disablenpc .@npc_name$;
		killmonster 'xm_d_map$, .@event$;
		areamonster 'xm_d_map$,(.@x-10),(.@y-10),(.@x+10),(.@y+10), "Toy Factory Guard",2990,.@count, .@event$;// XM_CRUISER
		initnpctimer;
	}
	end;

OnTimer45000:
	enablenpc instance_npcname( strnpcinfo(0) );
	killmonster 'xm_d_map$, instance_npcname( strnpcinfo(0) ) +"::OnMyMobDead";
	stopnpctimer;
	end;

OnMyMobDead:
	end;
}
1@xm_d,30,24,0	duplicate(alert#61)	alert#62	-1,10,10
1@xm_d,50,24,0	duplicate(alert#61)	alert#63	-1,10,10
1@xm_d,70,24,0	duplicate(alert#61)	alert#64	-1,10,10
1@xm_d,90,24,0	duplicate(alert#61)	alert#65	-1,10,10
1@xm_d,10,44,0	duplicate(alert#61)	alert#66	-1,10,10
1@xm_d,30,44,0	duplicate(alert#61)	alert#67	-1,10,10
1@xm_d,50,44,0	duplicate(alert#61)	alert#68	-1,10,10
1@xm_d,70,44,0	duplicate(alert#61)	alert#69	-1,10,10
1@xm_d,90,44,0	duplicate(alert#61)	alert#70	-1,10,10
1@xm_d,110,44,0	duplicate(alert#61)	alert#71	-1,10,10
1@xm_d,10,64,0	duplicate(alert#61)	alert#72	-1,10,10
1@xm_d,30,64,0	duplicate(alert#61)	alert#73	-1,10,10
1@xm_d,50,64,0	duplicate(alert#61)	alert#74	-1,10,10
1@xm_d,70,64,0	duplicate(alert#61)	alert#75	-1,10,10
1@xm_d,90,64,0	duplicate(alert#61)	alert#76	-1,10,10
1@xm_d,110,64,0	duplicate(alert#61)	alert#77	-1,10,10
1@xm_d,10,84,0	duplicate(alert#61)	alert#78	-1,10,10
1@xm_d,30,84,0	duplicate(alert#61)	alert#79	-1,10,10
1@xm_d,50,84,0	duplicate(alert#61)	alert#80	-1,10,10
1@xm_d,70,84,0	duplicate(alert#61)	alert#81	-1,10,10
1@xm_d,90,84,0	duplicate(alert#61)	alert#82	-1,10,10
1@xm_d,110,84,0	duplicate(alert#61)	alert#83	-1,10,10
1@xm_d,10,104,0	duplicate(alert#61)	alert#84	-1,10,10
1@xm_d,30,104,0	duplicate(alert#61)	alert#85	-1,10,10
1@xm_d,50,104,0	duplicate(alert#61)	alert#86	-1,10,10
1@xm_d,70,104,0	duplicate(alert#61)	alert#87	-1,10,10
1@xm_d,90,104,0	duplicate(alert#61)	alert#88	-1,10,10
1@xm_d,110,104,0	duplicate(alert#61)	alert#89	-1,10,10
1@xm_d,155,20,0	duplicate(alert#61)	alert#90	-1,10,10
1@xm_d,180,50,0	duplicate(alert#61)	alert#91	-1,10,10
1@xm_d,205,80,0	duplicate(alert#61)	alert#92	-1,10,10
1@xm_d,230,110,0	duplicate(alert#61)	alert#93	-1,10,10
1@xm_d,180,20,0	duplicate(alert#61)	alert#94	-1,10,10
1@xm_d,180,50,0	duplicate(alert#61)	alert#95	-1,10,10
1@xm_d,180,80,0	duplicate(alert#61)	alert#96	-1,10,10
1@xm_d,205,20,0	duplicate(alert#61)	alert#97	-1,10,10
1@xm_d,205,50,0	duplicate(alert#61)	alert#98	-1,10,10
1@xm_d,205,80,0	duplicate(alert#61)	alert#99	-1,10,10
1@xm_d,205,110,0	duplicate(alert#61)	alert#100	-1,10,10
1@xm_d,230,20,0	duplicate(alert#61)	alert#101	-1,10,10
1@xm_d,230,50,0	duplicate(alert#61)	alert#102	-1,10,10
1@xm_d,230,80,0	duplicate(alert#61)	alert#103	-1,10,10
1@xm_d,230,110,0	duplicate(alert#61)	alert#104	-1,10,10


1@xm_d,185,100,6	script	Catherine Jet Johnson#2	4_F_SKULL06GIRL,{
	if (getpartyleader(getcharid(1),2) == getcharid(0)) {
		mes "[Catherine Jet Johnson]";
		mes "Lucky you got here safely.";
		next;
		switch( select( "Quit the story", "Listen to her tatics.", "I know what to do. Proceed quickly!" ) ) {
		case 1:
			mes "[Catherine Jet Johnson]";
			mes "Oh, dear. Let me know when you are ready.";
			close;
		case 2:
			donpcevent instance_npcname("Catherine Jet Johnson#21") + "::OnStart";
			close;
		case 3:
			donpcevent instance_npcname("Catherine Jet Johnson#21") + "::OnStart2";
			close;
		}
	}
	mes "[Catherine Jet Johnson]";
	mes "Hold on~ I am talking to your manager, so please wait.";
	close;
}

1@xm_d,185,100,6	script	Catherine Jet Johnson#21	4_F_SKULL06GIRL,{
	end;
OnStart:
	callsub S_Skip,0;
OnStart2:
	callsub S_Skip,1;
S_Skip:
	enablenpc instance_npcname("#bgm06");
	enablenpc instance_npcname("Catherine Jet Johnson#21");
	disablenpc instance_npcname("Catherine Jet Johnson#2");
	sleep 3000;
	if (getarg(0) == 1)
		npctalk "Catherine Jet Johnson: If you find all clues, search other places. I will look for the spot where I met the doll maker last time I was here.";
	else {
		npctalk "Catherine Jet Johnson: This place was Factory No.2.";
		sleep 5000;
		npctalk "Catherine Jet Johnson: It used to be filled with people, but now it isn't.";
		sleep 5000;
		npctalk "Catherine Jet Johnson: Ah, I realized something while coming here. Some...Children...";
		sleep 5000;
		npctalk "Catherine Jet Johnson: How can I say.. There were lots of souls looking very scary, but awfully sad.";
		sleep 5000;
		npctalk "Catherine Jet Johnson: How pitiful they are, but please make them rest if they attack you. Fortunately, they won't come at me.";
		sleep 5000;
		npctalk "Catherine Jet Johnson: If you see a worker toy on duty while searching here, would you ask it about the doll maker?";
		sleep 5000;
		npctalk "Catherine Jet Johnson: He might be sent to Heaven if they recall the memory of doll maker. That the only hope.";
		sleep 5000;
		npctalk "Catherine Jet Johnson: If you find all clues, search other places. I will look for the spot where I met the doll maker last time I was here.";
		sleep 5000;
		npctalk "Catherine Jet Johnson: Sorry that I can't be a big help to you. See you in a minute.";
	}
	sleep 6000;
	disablenpc instance_npcname("Catherine Jet Johnson#21");
	enablenpc instance_npcname("Employees' Uniform Box#4");
	donpcevent instance_npcname("#fac2ct") + "::OnStart";

	for ( .@i = 1; .@i <= 10; .@i++ )
		enablenpc instance_npcname( "Worker#"+ .@i );
	disablenpc instance_npcname("#bgm06");
	end;

OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,185,100,0	script	#bgm06	-1,9,9,{
OnTouch:
	playBGM "99";
	end;
OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,185,94,6	script	Employees' Uniform Box#4	4_NONMYSTCASE,{
	progressbar "ffff00",1;
	playBGM "128";
	.@mob_id_transform = getstatus(SC_MONSTER_TRANSFORM,1);
	if (.@mob_id_transform == 1246 || .@mob_id_transform == 1249 || .@mob_id_transform < 1) {
		mes "^0000ff>You changed into uniform.^000000";
		transform 1246,300000;// COOKIE_XMAS
		close;
	}
	mes "^ff0000You transformed into a different form.";
	mes "You can't seem to put on the uniform over your fangs.^000000";
	close;

OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,1,5,3	script	#fac2ct	CLEAR_NPC,{
	end;
OnEnd:
	killmonster 'xm_d_map$, instance_npcname("#fac2ct") + "::OnMyMobDead";
	end;

OnStart:
	.@event$ = instance_npcname("#fac2ct") + "::OnMyMobDead";
	killmonster 'xm_d_map$, .@event$;
	areamonster 'xm_d_map$,140,18,240,120, "Malicious Baby Ghost",2993,19, .@event$;	// XM_HYLOZOIST
	areamonster 'xm_d_map$,140,18,240,120, "Evil Dwelling Box",2991,16, .@event$;		// XM_MYSTCASE
	areamonster 'xm_d_map$,140,18,240,120, "Abandoned Teddy bear",2995,22, .@event$;	// XM_TEDDY_BEAR
	areamonster 'xm_d_map$,140,18,240,120, "Creepy Demon",2992,16, .@event$;			// XM_LUDE
	end;
OnMyMobDead:
	end;

OnInstanceInit:
	hideonnpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,1,2,3	script	#fac2wpc	CLEAR_NPC,{
	end;
OnStart:
	.@fac_open = 'worker[1] + 'worker[2] + 'worker[3] + 'worker[4] + 'worker[5] + 'worker[6] + 'worker[7] + 'worker[8] + 'worker[9] + 'worker[10];
	if (.@fac_open == 10) {
		enablenpc instance_npcname("#fac3wp");
		enablenpc instance_npcname("#fac3wp2");
		donpcevent instance_npcname("#fac2ct") + "::OnEnd";
		mapannounce 'xm_d_map$, "Factory announcement: Everyone has gone home. The line is shut down and the employee's lounge is open.", bc_map, "0x00ff44";
		for ( .@i = 90; .@i <= 104; .@i++ )
			disablenpc instance_npcname( "alert#"+ .@i );
	}
	else
		mapannounce 'xm_d_map$, "Factory announcement: Now there are " + (10 - .@fac_open) + " people on the packaging line. Take care of yourself.", bc_map, "0x00ff44";
	end;

OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,155,98,3	script	Worker#1	4_M_COOKIE,{
	if (getstatus(SC_MONSTER_TRANSFORM,1) == 1246) {
		.@num = atoi(strnpcinfo(2));
		mes "[Worker]";
		mes "Huh? What happened?";
		next;
		if (select( "No, nothing special", "Do you know about the doll maker?" ) == 1) {
			mes "[Worker]";
			if (.@num == 8)
				mes "I'm working now! I'm very busy!";
			else
				mes "I'm very busy with working, so could you stop chatting?";
			close;
		}
		close2;
		pcblockmove getcharid(3),1;// todo : not able to talk to npc
		pcblockskill getcharid(3),1;
		switch(.@num) {
		case 1:
			npctalk "Worker: Ah! Grandpa? He's a real good man. He oiled us everyday and cleaned the dust very often.";
			sleep2 3000;
			npctalk "Worker: I wish he wouldn't pass away. Ah... Ahah... I feel better.";
			break;
		case 2:
			npctalk "Worker: Did Kimi kill the craftman grandpa? Who said that? That's not true. Kimi was going to save him!";
			sleep2 3000;
			npctalk "Worker: Ah... B.. By the way, why my body becomes...";
			break;
		case 3:
			npctalk "Worker: He had chronic cardiac disease, but it suddenly started to fit on the day he died. Kimi found him and gave him first aid, but..";
			sleep2 3000;
			npctalk "Worker: Ah.. Did you do something to me? I feel strange...";
			break;
		case 4:
			npctalk "Worker: Kimi didn't move at all for sometime and sat down like ordinary dolls.";
			sleep2 3000;
			npctalk "Worker: She was about to fly her soul forever... Like me now... Oh, my... What happened to me?";
			break;
		case 5:
			npctalk "Worker: Oh, Kimi.. My dear.. She thought the doll maker passed away because she startled him.";
			sleep2 3000;
			npctalk "Worker: Grandpa was just very pleased that Kimi was moving..";
			break;
		case 6:
			npctalk "Worker: He could see a living doll for a while. That's what Kimi first did.";
			sleep2 3000;
			npctalk "Worker: And what she first saw was his death. What a misery.";
			break;
		case 7:
			npctalk "Worker: Kimi was able to hear the Grandpa's voice and feel before she was indwelled.";
			sleep2 3000;
			npctalk "Worker: Perhaps Grandpa's affection made her move and become alive. Ahah.. I'm sleepy..";
			break;
		case 8:
			npctalk "Worker: Grandpa good man! Kimi pity! Kimi loves Grandpa! Granpa died. I'm sad!";
			sleep2 3000;
			break;
		case 9:
			npctalk "Worker: He was so amazed to see Kimi's opening eyes and his heart... It became like that.";
			sleep2 3000;
			npctalk "Worker: Anyhow, why my body... It's likely to float in the air.... Something strange.";
			break;
		case 10:
			npctalk "Worker: Kimi didn't hurt Grandpa! Kimi's wanted to save Grandpa! People are scared of Kimi Kimi is kind! Kimi is a good girl!";
			sleep2 3000;
			npctalk "Worker: Grandpa... I miss him. Grandpa, Grandpa...";
			break;
		}
		sleep2 3000;
		disablenpc instance_npcname( strnpcinfo(0) );
		if ('worker[.@num] == 0) {
			'worker[.@num] = 1;
			donpcevent instance_npcname("#fac2wpc") + "::OnStart";
		}
		pcblockmove getcharid(3),0;
		pcblockskill getcharid(3),0;
		end;
	}
	mes "[Worker]";
	mes "What!? You are not one of us!!";
	donpcevent instance_npcname( strnpcinfo(0) ) + "::OnAlert";
	close;

OnAlert:
	.@npc_name$ = instance_npcname( strnpcinfo(0) );
	killmonster 'xm_d_map$, .@npc_name$ + "::OnMyMobDead";
	.@num = atoi(strnpcinfo(2));
	if (.@num == 8)
		npctalk "Worker: Guard! Guard!!";
	else
		npctalk "Worker: Guard, Guard! Where are you?! Humans are here!!";
	sleep 3000;
	switch(.@num) {
	case 9:
		setarray .@coord[0],233,27;
		break;
	case 10:
		setarray .@coord[0],209,27;
		break;
	default:
		getmapxy .@map$, .@coord[0], .@coord[1], UNITTYPE_NPC;
		break;
	}
	areamonster 'xm_d_map$,(.@coord[0]-8),(.@coord[1]-8),(.@coord[0]+8),(.@coord[1]+8), "Guard",2990,21, .@npc_name$ + "::OnMyMobDead";
	disablenpc .@npc_name$;
	if ('worker[.@num] == 0) {
		'worker[.@num] = 1;
		donpcevent instance_npcname("#fac2wpc") + "::OnStart";
	}
	initnpctimer;
	end;
OnTimer60000:
	killmonster 'xm_d_map$, instance_npcname( strnpcinfo(0) ) + "::OnMyMobDead";
	stopnpctimer;
	end;

OnMyMobDead:
	end;

OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}
1@xm_d,130,72,3	duplicate(Worker#1)	Worker#2	4_M_COOKIE
1@xm_d,134,34,1	duplicate(Worker#1)	Worker#3	4_M_COOKIE
1@xm_d,195,28,3	duplicate(Worker#1)	Worker#4	4_M_COOKIE
1@xm_d,228,30,1	duplicate(Worker#1)	Worker#5	4_M_COOKIE
1@xm_d,203,55,3	duplicate(Worker#1)	Worker#6	4_M_COOKIE
1@xm_d,132,52,1	duplicate(Worker#1)	Worker#7	4_M_COOKIE
1@xm_d,162,52,1	duplicate(Worker#1)	Worker#8	4_M_COOKIE
1@xm_d,242,17,5	duplicate(Worker#1)	Worker#9	4_M_COOKIE
1@xm_d,209,15,3	duplicate(Worker#1)	Worker#10	4_M_COOKIE


// Note : aegis script have OnClick part
1@xm_d,131,208,0	script	Captured Santa#2	4_M_SANTA,10,10,{
	end;
OnTouch_:
	disablenpc instance_npcname("Captured Santa#2");
	enablenpc instance_npcname("Captured Santa#3");
	donpcevent instance_npcname("Antonio#1") + "::OnStart";
	enablenpc instance_npcname("#bgm04");
	end;
}

1@xm_d,131,208,8	script	Captured Santa#3	4_M_SANTA,{
	mes "[Captured Santa]";
	mes "Even if no one owns it, its not right to steal it from everyone.";
	close;

OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,131,213,4	script	Antonio#1	4_M_ANTONIO,{
	mes "[Antonio]";
	mes "Hey, Santa. Stop being stuffy, you old man. Fair is fair after all, kekeke.";
	close;

OnStart:
	.@antonio$ = instance_npcname("Antonio#1");
	.@santa$ = instance_npcname("Captured Santa#3");
	sleep 3000;
	npctalk "Antonio: Listen to me, Santa~ I mean, I like this factory.", .@antonio$;
	sleep 3000;
	npctalk "Antonio: No one owns it~ And there are a number of things I can use.", .@antonio$;
	sleep 3000;
	npctalk "Captured Santa: You silly! Just to be sure, I followed you. Now you steal from everyones factory!", .@santa$;
	sleep 4000;
	npctalk "Antonio: Hey, is this a big deal if I have surplus presents? I don't know about that~", .@antonio$;
	sleep 4000;
	npctalk "Captured Santa: Whew... Okay, but think about that how children feel when they got them.", .@santa$;
	sleep 4000;
	npctalk "Captured Santa: How they feel if they know you distributed the masterless things to them?", .@santa$;
	sleep 4000;
	npctalk "Antonio: Hmm...", .@antonio$;
	sleep 2000;
	npctalk "Antonio: Maybe... I will be happy?! Anyway, that's a present, kekekeke.", .@antonio$;
	sleep 5000;
	npctalk "Captured Santa: Who said the present itself is the problem! You'd better stop this theft, Antonio!", .@santa$;
	sleep 5000;
	mapannounce 'xm_d_map$, "Factory announcement: The sending preparations have finished in Factory No.3.", bc_map, "0x00ff44";
	sleep 5000;
	mapannounce 'xm_d_map$, "Factory announcement: Delivery employees, please stand by.", bc_map, "0x00ff44";
	sleep 3000;
	npctalk "Antonio: Oh! Wohuhu! A bunch of presents are dealayed. Let's have a party today?!", .@antonio$;
	sleep 4000;
	npctalk "Antonio: Hey, human. You can follow me if you'd like to help. I'm okay unless you disturb me!", .@antonio$;
	sleep 4000;
	disablenpc .@antonio$;
	sleep 2000;
	npctalk "Captured Santa: Tha.. That dude has no ethics!", .@santa$;
	sleep 4000;
	npctalk "Captured Santa: Hey, would you go kick that Antonio out? He might run away if you hit several times.", .@santa$;
	sleep 5000;
	npctalk "Captured Santa: Its not right to steal from the community!", .@santa$;

	disablenpc instance_npcname("#bgm04");
	enablenpc instance_npcname("#fac4wp");
	enablenpc instance_npcname("#fac4wp2");
	donpcevent instance_npcname("#fac3ct") + "::OnStart";
	donpcevent instance_npcname("#fac3ct2") + "::OnStart";
	donpcevent instance_npcname("#fac3ct3") + "::OnStart";
	sleep 3000;
	enablenpc instance_npcname("#bgm05");
	end;
}

1@xm_d,131,208,0	script	#bgm04	-1,9,9,{
OnTouch:
	playBGM "54";
	end;
OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,131,208,0	script	#bgm05	-1,9,9,{
OnTouch:
	playBGM "105";
	end;
OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,1,5,3	script	#fac3ct	CLEAR_NPC,{
	end;
OnEnd:
	killmonster 'xm_d_map$, instance_npcname( strnpcinfo(0) ) + "::OnMyMobDead";
	end;
OnStart:
	.@event$ = instance_npcname( strnpcinfo(0) ) + "::OnMyMobDead";
	killmonster 'xm_d_map$, .@event$;
	areamonster 'xm_d_map$,13,144,121,248, "Dancing Marionette",2994,37, .@event$;	// XM_MARIONETTE
	areamonster 'xm_d_map$,13,144,121,248, "Decorated Evil Tree",2987,31, .@event$;	// XM_TREE
	areamonster 'xm_d_map$,13,144,121,248, "Abandoned Teddy bear",2995,43, .@event$;// XM_TEDDY_BEAR
	areamonster 'xm_d_map$,13,144,121,248, "Creepy Demon",2992,31, .@event$;		// XM_LUDE
	end;
OnMyMobDead:
	end;
OnInstanceInit:
	hideonnpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,1,5,3	script	#fac3ct2	CLEAR_NPC,{
	end;
OnEnd:
	killmonster 'xm_d_map$, instance_npcname( strnpcinfo(0) ) + "::OnMyMobDead";
	end;
OnStart:
	.@event$ = instance_npcname( strnpcinfo(0) ) + "::OnMyMobDead";
	killmonster 'xm_d_map$, .@event$;
	areamonster 'xm_d_map$,159,215,241,247, "Malicious Baby Ghost",2993,13, .@event$;	// XM_HYLOZOIST
	areamonster 'xm_d_map$,159,215,241,247, "Decorated Evil Tree",2987,11, .@event$;	// XM_TREE
	areamonster 'xm_d_map$,159,215,241,247, "Abandoned Teddy bear",2995,15, .@event$;	// XM_TEDDY_BEAR
	areamonster 'xm_d_map$,159,215,241,247, "Creepy Demon",2992,11, .@event$;			// XM_LUDE
	end;
OnMyMobDead:
	end;
OnInstanceInit:
	hideonnpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,1,5,3	script	#fac3ct3	CLEAR_NPC,{
	end;
OnStart:
	if (rand(1,10) > 3)
		areamonster 'xm_d_map$,13,144,121,248 ,"Antonio",2988,1, instance_npcname("#fac3ct3")+"::OnMyMobDead";// ANTONIO
	else
		areamonster 'xm_d_map$,159,215,241,247, "Antonio",2988,1, instance_npcname("#fac3ct3")+"::OnMyMobDead";
	end;

OnMyMobDead:
	if (mobcount( 'xm_d_map$, instance_npcname("#fac3ct3") + "::OnMyMobDead" ) < 1)
		initnpctimer;
	end;

OnTimer1000:
OnEnd:
	killmonster 'xm_d_map$, instance_npcname( strnpcinfo(0) ) + "::OnMyMobDead";
	donpcevent instance_npcname("#fac3ct") + "::OnEnd";
	donpcevent instance_npcname("#fac3ct2") + "::OnEnd";
	donpcevent instance_npcname("#finalbs") + "::OnStart";
	disablenpc instance_npcname("Captured Santa#3");
	mapannounce 'xm_d_map$, "???: I won't harm you if you leave quietly without spoiling it for me.", bc_map, "0xff8800";
	stopnpctimer;
	end;

OnInstanceInit:
	hideonnpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,1,5,3	script	#finalbs	CLEAR_NPC,{
	end;
OnStart:
	enablenpc instance_npcname("Catherine Jet Johnson#5");
	enablenpc instance_npcname("Celine Kimi#0");
	enablenpc instance_npcname("#fac5wp");
	// enablenpc instance_npcname("#fac5wp2");// never enabled
	enablenpc instance_npcname("#jeton1");
	end;
OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

/*
// never enabled
1@xm_d,160,208,0	script	#fac5wp2	WARPNPC,2,2,{
OnTouch:
	warp 'xm_d_map$,145,208;
	end;
OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}
*/

1@xm_d,233,183,3	script	Celine Kimi#0	4_F_KIMI,{
	mes "[Celine Kimi]";
	mes "Did you come here as well? Why all the humans are anxious to destroy what we built?";
	close;
OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,222,183,0	script	#jeton1	-1,7,7,{
OnTouch_:
	disablenpc instance_npcname("#jeton1");
	donpcevent instance_npcname("Catherine Jet Johnson#5") + "::OnStart";
	enablenpc instance_npcname("#bgm02");
	end;
OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,222,183,0	script	#bgm02	-1,9,9,{
OnTouch:
	playBGM "101";
	end;
OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,222,183,6	script	Catherine Jet Johnson#5	4_F_SKULL06GIRL,{
	mes "[Catherine Jet Johnson]";
	mes "Wa.. Watch out! Kimi isn't under the normal status.";
	close;

OnStart:
	.@kimi$ = instance_npcname("Celine Kimi#0");
	sleep 2000;
	npctalk "Catherine Jet Johnson: Kimi! Listen to me. I didn't come to blame you here.";
	sleep 3000;
	npctalk "Celine Kimi: Everyone hates me!... You don't like me as well? This ugly and creepy doll likes me...", .@kimi$;
	sleep 4000;
	npctalk "Catherine Jet Johnson: Kimi, I heard about you from dolls here. The doll maker adored you so much!";
	sleep 4000;
	mapannounce 'xm_d_map$, "Phantom's yell: Lie!", bc_map, "0xff8800";
	sleep 1000;
	npctalk "Celine Kimi: Don't lie. If that's true, why didn't he see me with love in his eyes?", .@kimi$;
	sleep 4000;
	npctalk "Celine Kimi: Why didn't call my name? [Kimi] [Kimi!] I was anxious to hear the Grandpa's voice.", .@kimi$;
	sleep 4000;
	mapannounce 'xm_d_map$, "Phantom's yell: Yes, Kimi~ Father was frightened! He was scared of you~", bc_map, "0xff8800";
	sleep 3000;
	npctalk "Catherine Jet Johnson: No, don't listen to it, Kimi! He really cherished you.";
	sleep 3000;
	npctalk "Celine Kimi: Did he... cherish me?", .@kimi$;
	sleep 3000;
	npctalk "Catherine Jet Johnson: Yes, when you start to move, he was so plea...";
	sleep 1000;
	mapannounce 'xm_d_map$, "Phantom's yell: He was scared of your appearance and his heart stopped, Kimi~ You killed him!", bc_map, "0xff8800";
	sleep 3000;
	npctalk "Celine Kimi: D.. Did I.. kill him?...", .@kimi$;
	sleep 2000;
	npctalk "Catherine Jet Johnson: No, Kimi! I've realized that. I misunderstood you. Just he had a disease!";
	sleep 3000;
	npctalk "Celine Kimi: D.. Di.. Did I... kill... him?", .@kimi$;
	sleep 2000;
	mapannounce 'xm_d_map$, "Phantom's yell: See how you look, Kimi~ See the mirror~ How do yo feel? ", bc_map, "0xff8800";
	sleep 3000;
	npctalk "Celine Kimi: I... I...", .@kimi$;
	sleep 1000;
	mapannounce 'xm_d_map$, "Phantom's yell: Don't you agree you are frightening? No one loves you, Kimi~", bc_map, "0xff8800";
	sleep 3000;
	npctalk "Celine Kimi: Because of me, granpa was dead...", .@kimi$;
	specialeffect EF_MAPPILLAR2, AREA, .@kimi$;
	sleep 3000;
	npctalk "Catherine Jet Johnson: It became serious. Kimi is suffering. It would be dangerous under this condition!";
	specialeffect EF_MAPPILLAR2, AREA, .@kimi$;
	sleep 1000;
	mapannounce 'xm_d_map$, "Phantom's yell: Rage~ Sorrow~ No one cries for you, Kimi~", bc_map, "0xff8800";
	sleep 3000;
	npctalk "Catherine Jet Johnson: I will find the emergency exit to escape. Run away, adventurer!";
	sleep 3000;
	disablenpc instance_npcname("Catherine Jet Johnson#5");
	sleep 2000;
	disablenpc .@kimi$;
	donpcevent instance_npcname("#finalbs2") + "::OnStart";
	disablenpc instance_npcname("#bgm02");
	end;

OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,1,5,3	script	#finalbs2	CLEAR_NPC,{
	end;
OnStart:
	stopnpctimer;
	enablenpc instance_npcname("#bgm03");
	.@event$ = instance_npcname("#finalbs2") + "::OnMyMobDead";
	killmonster 'xm_d_map$, .@event$;
	monster 'xm_d_map$,231,184, "Celine Kimi",2996,1, .@event$;// XM_CELINE_KIMI
	'celene_id = $@mobid[0];
	monster 'xm_d_map$,226,190, "Kimi's Phantom",2997,1, .@event$;// G_XM_CELINE_KIMI
	'phantom_id = $@mobid[0];
	setunitdata 'celene_id, UMOB_HP,20000000;
	setunitdata 'phantom_id,UMOB_HP,20000000;

	unittalk 'celene_id, "I don't want to be deserted. I don't want to be abandoned.";
	initnpctimer;
	end;

OnMyMobDead:
	if (mobcount( 'xm_d_map$, instance_npcname("#finalbs2") + "::OnMyMobDead" ) < 1)
		donpcevent instance_npcname("#finalbs2") + "::OnEnd";
	end;

OnEnd:
	stopnpctimer;
	killmonster 'xm_d_map$, instance_npcname( strnpcinfo(0) ) + "::OnMyMobDead";
	disablenpc instance_npcname("#bgm03");
	donpcevent instance_npcname("#finalbs_e") + "::OnStart";
	end;

OnTalk:
	.@chat_r = rand(1,10);
	if (.@chat_r == 1)
		unittalk 'celene_id, "I will burn you with hell inferno.";
	else if (.@chat_r == 2)
		unittalk 'celene_id, "Will you bear this flame?!";
	else if (.@chat_r == 3)
		unittalk 'celene_id, "I shouldn't have done, but...";
	else if (.@chat_r == 4)
		unittalk 'celene_id, "It's boiling!... Bear it if you can.";
	else if (.@chat_r == 5)
		unittalk 'celene_id, "Breathe as much as you can. It'll be the last breath you make.";
	else if (.@chat_r == 6)
		unittalk 'celene_id, "Frankly, I don't like fire.";
	else
		unittalk 'celene_id, "Everyone is afraid of me! What have I done so wrong?!";
	end;

OnTimer1000:
	getunitdata 'celene_id, .@data;
	if ((.@data[UMOB_X] < 211 || .@data[UMOB_X] > 241 || .@data[UMOB_Y] < 166 || .@data[UMOB_Y] > 201) && (.@data[UMOB_X] > 0 || .@data[UMOB_Y] > 0)) {
		mapannounce 'xm_d_map$, "Celine Kimi: No! I should keep my place!",bc_map,"0xff6666",FW_NORMAL,15;
		donpcevent instance_npcname("#finalbs2") + "::Onfail";
	}
	end;

Onfail:
	stopnpctimer;
	killmonster 'xm_d_map$, instance_npcname( strnpcinfo(0) ) + "::OnMyMobDead";
	enablenpc instance_npcname("Celine Kimi#2");
	disablenpc instance_npcname("#bgm03");
	enablenpc instance_npcname("#kimion1");
	end;

OnTimer5000:
	donpcevent instance_npcname("#bssk01") + "::OnStart";
	end;

OnTimer10000:
	if (mobcount( 'xm_d_map$, instance_npcname("#finalbs2") + "::OnMyMobDead" ) > 1) {
		.@npc_name$ = instance_npcname("#finalbs2");
		getunitdata 'celene_id, .@MOB_HP1;
		getunitdata 'phantom_id, .@MOB_HP2;
		if (.@MOB_HP1[UMOB_HP] > .@MOB_HP2[UMOB_HP]) {
			setarray .@mob_hp[0], .@MOB_HP1[UMOB_HP], .@MOB_HP2[UMOB_HP];
			setarray .@string$[0],
				"You and I are the one! I will recover you!",
				"Celine Kimi recovers herself and her phantom ";
			.@talk = 'celene_id;
		}
		else if (.@MOB_HP2[UMOB_HP] > .@MOB_HP1[UMOB_HP]) {
			setarray .@mob_hp[0], .@MOB_HP2[UMOB_HP], .@MOB_HP1[UMOB_HP];
			setarray .@string$[0],
				"I will restore you!!",
				"Celine Kimi's phantom recovers herself and her master ";
			.@talk = 'phantom_id;
		}
		.@diff_hp = .@mob_hp[0] - .@mob_hp[1];
		if (.@diff_hp > 100000) {
			.@set_bs_hp = (.@diff_hp * 5) / 10;
			.@MOB_HP3 = .@mob_hp[0] + .@set_bs_hp;
			if (.@MOB_HP3 > 66666666)
				.@MOB_HP3 = 66666666;
			setunitdata 'celene_id, UMOB_HP, .@MOB_HP3;
			setunitdata 'phantom_id, UMOB_HP, .@MOB_HP3;
			donpcevent instance_npcname("#eff_f01") + "::OnStart";
			unittalk .@talk, .@string$[0];
			sleep 1000;
			mapannounce 'xm_d_map$,  .@string$[1] + .@set_bs_hp +" HP has been recovered.", bc_map, "0xff6666";
			donpcevent instance_npcname("#heal_c") + "::OnStart";
		}
		initnpctimer;
	}
	end;

OnInstanceInit:
	hideonnpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,216,193,3	script	#eff_f01	CLEAR_NPC,{
	end;
OnStart:
	for ( .@i = 1; .@i < 10; .@i++ )
		specialeffect EF_HEARTCASTING, AREA, instance_npcname( "#eff_f0"+ .@i );
	end;
OnInstanceInit:
	hideonnpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,226,193,3	script	#eff_f02	CLEAR_NPC,{
	end;
OnInstanceInit:
	hideonnpc instance_npcname( strnpcinfo(0) );
	end;
}
1@xm_d,236,193,3	duplicate(#eff_f02)	#eff_f03	CLEAR_NPC
1@xm_d,216,183,3	duplicate(#eff_f02)	#eff_f04	CLEAR_NPC
1@xm_d,226,183,3	duplicate(#eff_f02)	#eff_f05	CLEAR_NPC
1@xm_d,236,183,3	duplicate(#eff_f02)	#eff_f06	CLEAR_NPC
1@xm_d,216,173,3	duplicate(#eff_f02)	#eff_f07	CLEAR_NPC
1@xm_d,226,173,3	duplicate(#eff_f02)	#eff_f08	CLEAR_NPC
1@xm_d,236,173,3	duplicate(#eff_f02)	#eff_f09	CLEAR_NPC

1@xm_d,1,5,3	script	#bssk01	CLEAR_NPC,{
	end;
OnStart:
	.@r = rand(1,3);
	if (.@r == 1)
		donpcevent instance_npcname("#bssk02") + "::OnStart";
	else if (.@r == 2)
		donpcevent instance_npcname("#bssk03") + "::OnStart";
	end;
OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,1,5,3	script	#bssk02	CLEAR_NPC,{
	end;
OnStart:
	donpcevent instance_npcname("#finalbs2") + "::OnTalk";
	for ( .@i = 1; .@i < 5; .@i++ )
		donpcevent instance_npcname( "#crssk"+ .@i ) + "::OnStart";
	end;
OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,1,5,3	script	#bssk03	CLEAR_NPC,{
	end;
OnStart:
	.@event$ = instance_npcname( strnpcinfo(0) ) + "::OnMyMobDead";
	killmonster 'xm_d_map$, .@event$;
	while (1) {
		getunitdata 'celene_id, .@data;
		.@x = .@data[UMOB_X] + rand(1,20) - 10;
		.@y = .@data[UMOB_Y] + rand(1,20) - 10;
		monster 'xm_d_map$,.@x,.@y, "#f_w_1",3038,1, .@event$;// HIDDEN_MOB7
		.@mon_num++;
		if (.@mon_num > 20)
			break;
		sleep 200;
	}
	sleep 6000;
	killmonster 'xm_d_map$, .@event$;
	end;

OnMyMobDead:
	end;

OnInstanceInit:
	hideonnpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,1,5,3	script	#crssk1	CLEAR_NPC,{
	end;
OnStart:
	.@event$ = instance_npcname( strnpcinfo(0) ) + "::OnMyMobDead";
	killmonster 'xm_d_map$, .@event$;
	getunitdata 'celene_id, .@data;
	setarray .@coord[0], .@data[UMOB_X], .@data[UMOB_Y];
	.@num = atoi(strnpcinfo(2));
	.@index = ( .@num > 2 ? 1 : 0 );// x or y
	.@signe = pow(-1,.@num+1);
	while(1) {
		.@coord[.@index] = .@coord[.@index] + (2 * .@signe);
		.@coord[!.@index] = .@coord[!.@index] + rand(0,2) - 1;
		monster 'xm_d_map$,.@coord[0], .@coord[1], "#f_w_1",3038,1, .@event$;
		if (.@coord[0] < 211 || .@coord[0] > 241 || .@coord[1] < 166 || .@coord[1] > 201)
			break;
		sleep 200;
	}
	sleep 6000;
	killmonster 'xm_d_map$, .@event$;
	end;
OnMyMobDead:
	end;

OnInstanceInit:
	hideonnpc instance_npcname( strnpcinfo(0) );
	end;
}
1@xm_d,1,5,3	duplicate(#crssk1)	#crssk2	CLEAR_NPC
1@xm_d,1,5,3	duplicate(#crssk1)	#crssk3	CLEAR_NPC
1@xm_d,1,5,3	duplicate(#crssk1)	#crssk4	CLEAR_NPC

1@xm_d,233,183,0	script	#kimion1	-1,7,7,{
OnTouch_:
	disablenpc instance_npcname("#kimion1");
	donpcevent instance_npcname("Celine Kimi#2") + "::OnStart";
	end;
OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,233,183,3	script	Celine Kimi#2	4_F_KIMI,{
	mes "[Celine Kimi]";
	mes "You also... come here to kill me?";
	close;

OnStart:
	npctalk "Celine Kimi: You also... come here to kill me?";
	specialeffect EF_MAPPILLAR2;
	sleep 5000;
	disablenpc instance_npcname("Celine Kimi#2");
	donpcevent instance_npcname("#finalbs2") + "::OnStart";
	end;
OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,228,183,0	script	#bgm03	-1,25,25,{
OnTouch:
	playBGM "123";
	end;
OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,1,5,3	script	#heal_c	CLEAR_NPC,{
	end;
OnStart:
	if (rand(1,10) > 4)
		initnpctimer;
	end;
OnTimer3000:
	mapannounce 'xm_d_map$, "Celine Kimi and her phantom are shared their strength. They will be stronger than ever!",bc_map,"0xff6666";
	stopnpctimer;
	end;

OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,1,5,3	script	#finalbs_e	CLEAR_NPC,{
	end;
OnStart:
	mapannounce 'xm_d_map$, "Celine Kimi: It is no use to defeat me! My body will be restored.",bc_map,"0xff6666",FW_NORMAL,15;
	enablenpc instance_npcname("#fac6wp");
	enablenpc instance_npcname("#jeton2");
	enablenpc instance_npcname("Catherine Jet Johnson#6");
	for ( .@i = 1; .@i <= 10; .@i++ )
		enablenpc instance_npcname("Packaged Present#"+ .@i);
	sleep 6000;
	mapannounce 'xm_d_map$, "Catherine Jet Johnson's yell: Are you okay? Flee to the south emergency exit!",bc_map,"0xffff00";
	end;

OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,218,145,0	script	#jeton2	-1,4,4,{
OnTouch_:
	disablenpc instance_npcname("#jeton2");
	donpcevent instance_npcname("Catherine Jet Johnson#6") + "::OnStart";
	end;
OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,218,145,5	script	Catherine Jet Johnson#6	4_F_SKULL06GIRL,{
	end;
OnStart:
	sleep 1000;
	npctalk "Catherine Jet Johnson: Unfortunately, I am failed to persuade Kimi.";
	sleep 3000;
	npctalk "Catherine Jet Johnson: What was the voice of phantom? Why it torments Kimi so harshly...";
	sleep 4000;
	npctalk "Catherine Jet Johnson: I guess that the curse of my face was form the unidentified voice.";
	sleep 4000;
	npctalk "Catherine Jet Johnson: Anyway, even Kimi, saying hates everyone, has collected her recollections here a lot.";
	sleep 6000;
	npctalk "Catherine Jet Johnson: I will put this thing safely even if her soul will return and she won't be disappointed.";
	sleep 5000;
	npctalk "Catherine Jet Johnson: Thanks to you, everything that I have wondered is completely resolved. Please call me again if you are going to send her to Heaven next time.";
	sleep 5000;
	npctalk "Catherine Jet Johnson: I will open the exit way out. I will go outside first, so just follow me.";
	sleep 3000;
	disablenpc instance_npcname("Catherine Jet Johnson#6");
	enablenpc instance_npcname("#exwp1");
	end;
OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,218,150,5	script	#exwp1	PORTAL,{
	mes "Will you exit?";
	next;
	if (select( "Take a look around", "Go outside" ) == 1) {
		mes "Stop the machine.";
		close;
	}
	close2;
	warp "xmas",233,300;
	end;

OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}

1@xm_d,210,141,3	script	Packaged Present#1	4_TREASURE_BOX,{
	specialeffect EF_COIN;
	disablenpc instance_npcname( strnpcinfo(0) );
	initnpctimer;
	end;

OnTimer1000:
	switch( atoi(strnpcinfo(2)) ) {
	case 1:
		.@num = rand(4,8);
		for ( .@i = 0; .@i < .@num; .@i++ )
			makeitem 7642,1, 'xm_d_map$, rand(208,212), rand(139,143);// Bloody_Coin
		if (rand(1,1000) > 150)
			makeitem 644,1, 'xm_d_map$,209,141;// Gift_Box;
		if (rand(1,1000) > 600)
			makeitem 617,1, 'xm_d_map$,210,141;// Old_Violet_Box;
		if (rand(1,1000) > 900)
			makeitem 22534,1, 'xm_d_map$,211,141;// Closedmind_Box
		break;
	case 2:
		.@num = rand(3,7);
		for ( .@i = 0; .@i < .@num; .@i++ )
			makeitem 7642,1, 'xm_d_map$, rand(212,216), rand(139,143);// Bloody_Coin
		if (rand(1,1000) > 400)
			makeitem 603,1, 'xm_d_map$,213,141;// Old_Blue_Box
		if (rand(1,1000) > 700)
			makeitem 616,1, 'xm_d_map$,214,141;// Old_Card_Album
		if (rand(1,1000) > 950)
			makeitem 13442,1, 'xm_d_map$,215,141;// Old_Parasol
		break;
	case 3:
		.@num = rand(2,6);
		for ( .@i = 0; .@i < .@num; .@i++ )
			makeitem 7642,1, 'xm_d_map$, rand(216,220), rand(139,143);// Bloody_Coin
		if (rand(1,1000) > 850)
			makeitem 7229,1, 'xm_d_map$,217,141;// Silver_Bullion
		if (rand(1,1000) > 800)
			makeitem 12246,1, 'xm_d_map$,218,141;// Magic_Card_Album
		if (rand(1,1000) > 950)
			makeitem 2486,1, 'xm_d_map$,219,141;// Shadow_Walk_
		break;
	case 4:
		.@num = rand(4,8);
		for ( .@i = 0; .@i < .@num; .@i++ )
			makeitem 7642,1, 'xm_d_map$, rand(220,224), rand(139,143);// Bloody_Coin
		if (rand(1,1000) > 700)
			makeitem 7228,1, 'xm_d_map$,221,141;// Gold_Bullion
		if (rand(1,1000) > 600)
			makeitem 617,1, 'xm_d_map$,222,141;// Old_Violet_Box
		if (rand(1,1000) > 900)
			makeitem 22534,1, 'xm_d_map$,223,141;// Closedmind_Box
		break;
	case 5:
		.@num = rand(3,7);
		for ( .@i = 0; .@i < .@num; .@i++ )
			makeitem 7642,1, 'xm_d_map$, rand(224,228), rand(139,143);// Bloody_Coin
		if (rand(1,1000) > 150)
			makeitem 644,1, 'xm_d_map$,225,141;// Gift_Box
		if (rand(1,1000) > 700)
			makeitem 616,1, 'xm_d_map$,226,141;// Old_Card_Album
		if (rand(1,1000) > 950)
			makeitem 2976,1, 'xm_d_map$,227,141;// Red_Lantern
		break;
	case 6:
		.@num = rand(2,6);
		for ( .@i = 0; .@i < .@num; .@i++ )
			makeitem 2976,1, 'xm_d_map$, rand(208,212), rand(134,138);// Red_Lantern
		if (rand(1,1000) > 400)
			makeitem 603,1, 'xm_d_map$,209,136;// Old_Blue_Box
		if (rand(1,1000) > 800)
			makeitem 12246,1, 'xm_d_map$,210,136;// Magic_Card_Album
		if (rand(1,1000) > 950)
			makeitem 2977,1, 'xm_d_map$,211,136;// Hurt_Mind
		break;
	case 7:
		.@num = rand(4,8);
		for ( .@i = 0; .@i < .@num; .@i++ )
			makeitem 7642,1, 'xm_d_map$, rand(212,216), rand(134,138);// Bloody_Coin
		if (rand(1,1000) > 850)
			makeitem 7229,1, 'xm_d_map$,213,136;// Silver_Bullion
		if (rand(1,1000) > 600)
			makeitem 617,1, 'xm_d_map$,214,136;// Old_Violet_Box
		if (rand(1,1000) > 900)
			makeitem 22534,1, 'xm_d_map$,215,136;// Closedmind_Box
		break;
	case 8:
		.@num = rand(3,7);
		for ( .@i = 0; .@i < .@num; .@i++ )
			makeitem 7642,1, 'xm_d_map$, rand(216,220), rand(134,138);// Bloody_Coin
		if (rand(1,1000) > 700)
			makeitem 7228,1, 'xm_d_map$,217,136;// Gold_Bullion
		if (rand(1,1000) > 700)
			makeitem 616,1, 'xm_d_map$,218,136;// Old_Card_Album
		if (rand(1,1000) > 950)
			makeitem 2978,1, 'xm_d_map$,219,136;// KindHeart
		break;
	case 9:
		.@num = rand(2,6);
		for ( .@i = 0; .@i < .@num; .@i++ )
			makeitem 7642,1, 'xm_d_map$, rand(220,224), rand(134,138);// Bloody_Coin
		if (rand(1,1000) > 150)
			makeitem 644,1, 'xm_d_map$,221,136;// Gift_Box
		if (rand(1,1000) > 800)
			makeitem 12246,1, 'xm_d_map$,222,136;// Magic_Card_Album
		if (rand(1,1000) > 950)
			makeitem 18848,1, 'xm_d_map$,223,136;// Lush_Rose
		break;
	case 10:
		.@num = rand(4,8);
		for ( .@i = 0; .@i < .@num; .@i++ )
			makeitem 7642,1, 'xm_d_map$, rand(224,228), rand(134,138);// Bloody_Coin
		if (rand(1,1000) > 400)
			makeitem 603,1, 'xm_d_map$,225,136;// Old_Blue_Box
		if (rand(1,1000) > 600)
			makeitem 617,1, 'xm_d_map$,226,136;// Old_Violet_Box
		if (rand(1,1000) > 900)
			makeitem 22534,1, 'xm_d_map$,227,136;// Closedmind_Box
		break;
	}
	stopnpctimer;
	end;

OnInstanceInit:
	disablenpc instance_npcname( strnpcinfo(0) );
	end;
}
1@xm_d,214,141,3	duplicate(Packaged Present#1)	Packaged Present#2	4_TREASURE_BOX
1@xm_d,218,141,3	duplicate(Packaged Present#1)	Packaged Present#3	4_TREASURE_BOX
1@xm_d,222,141,3	duplicate(Packaged Present#1)	Packaged Present#4	4_TREASURE_BOX
1@xm_d,226,141,3	duplicate(Packaged Present#1)	Packaged Present#5	4_TREASURE_BOX
1@xm_d,210,136,3	duplicate(Packaged Present#1)	Packaged Present#6	4_TREASURE_BOX
1@xm_d,214,136,3	duplicate(Packaged Present#1)	Packaged Present#7	4_TREASURE_BOX
1@xm_d,218,136,3	duplicate(Packaged Present#1)	Packaged Present#8	4_TREASURE_BOX
1@xm_d,222,136,3	duplicate(Packaged Present#1)	Packaged Present#9	4_TREASURE_BOX
1@xm_d,226,136,3	duplicate(Packaged Present#1)	Packaged Present#10	4_TREASURE_BOX

// Warps
//==========================================
1@xm_d,79,129,0	warp2	#fac1wp2	2,2,1@xm_d,73,129
1@xm_d,184,109,0	warp2	#fac2wp2	2,2,1@xm_d,170,129
1@xm_d,130,178,0	warp2	#fac3wp	2,2,1@xm_d,130,193
1@xm_d,130,184,0	warp2	#fac3wp2	2,2,1@xm_d,129,173
1@xm_d,107,208,0	warp2	#fac4wp	2,2,1@xm_d,87,208
1@xm_d,95,208,0	warp2	#fac4wp2	2,2,1@xm_d,115,208
1@xm_d,152,208,0	warp2	#fac5wp	2,2,1@xm_d,167,208
1@xm_d,205,159,0	warp2	#fac6wp	2,2,1@xm_d,205,147

// Instance GM Functions :: mx_xm_ad
//==========================================
1@xm_d,1,1,3	script	#adsw	CLEAR_NPC,{
	if (callfunc("F_GM_NPC",1854,0) == 1) {
		mes "[Time Manager]";
		mes "What time would you like to return?";
		next;
		switch (select("Cancel:Factory No.1 Complete:Factory No.2 Complete:Factory No.3 Complete:Boss Start:Boss Complete")) {
		case 1:
			break;
		case 2:
			transform 1246,180000;
			enablenpc instance_npcname("#fac1bs");
			mapannounce 'xm_d_map$, "Coordinator's announcement: Huh? Where's everyone! How dare you workers to be absent their line and muck around!",bc_map,"0xff8800";
			warp 'xm_d_map$,70,125;
			break;
		case 3:
			for ( .@i = 1; .@i <= 10; ++.@i )
				disablenpc instance_npcname( "Worker#" + .@i );
			donpcevent instance_npcname("#fac2wpc") + "::OnStart";
			warp 'xm_d_map$,131,210;
			break;
		case 4:
			donpcevent instance_npcname("#fac3ct3") + "::OnEnd";
			warp 'xm_d_map$,131,210;
			break;
		case 5:
			donpcevent instance_npcname("#finalbs2") + "::OnStart";
			warp 'xm_d_map$,215,182;
			break;
		case 6:
			donpcevent instance_npcname("#finalbs2") + "::OnEnd";
			warp 'xm_d_map$,215,182;
			break;
		}
	}
	close;
}

1@xm_d,3,1,3	script	#adsw2	CLEAR_NPC,{
	if (callfunc("F_GM_NPC",1854,0) == 1) {
		getunitdata 'Antonio, .@mob;
		mapannounce 'xm_d_map$, "Factory announcement: Exist in " + .@mob[UMOB_X] + " - " + .@mob[UMOB_Y] + ".",bc_map,"0x00ff44";
	}
	end;
}
