//================= Hercules Script =======================================
//=       _   _                     _
//=      | | | |                   | |
//=      | |_| | ___ _ __ ___ _   _| | ___  ___
//=      |  _  |/ _ \ '__/ __| | | | |/ _ \/ __|
//=      | | | |  __/ | | (__| |_| | |  __/\__ \
//=      \_| |_/\___|_|  \___|\__,_|_|\___||___/
//================= License ===============================================
//= This file is part of Hercules.
//= http://herc.ws - http://github.com/HerculesWS/Hercules
//=
//= Copyright (C) 2013-2018  Hercules Dev Team
//= Copyright (C)  Euphy
//= Copyright (C)  Muad_Dib
//=
//= 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/>.
//=========================================================================
//= Octopus Cave
//================= Description ===========================================
//= Defeat the Disgusting Octopus.
//================= Current Version =======================================
//= 1.1
//=========================================================================

//== Instance Creation =====================================
mal_dun01,151,235,5	script	Starfish	4_ASTER,{

	.@party_id = getcharid(CHAR_ID_PARTY);
	.@md_name$ = _("Octopus Cave");

	if (!.@party_id) {
		mes("[Starfish]");
		mes("You alone is powerless, hehe! Better get someone to help you out. Make a party, and come back later.");
		close();
	}
	if (getcharid(CHAR_ID_CHAR) != getpartyleader(.@party_id, 2)) {
		mes("[Starfish]");
		mes("Where is your leader, hehe. I don't talk to some random people. Bring your boss to me.");
		close();
	}
	mes("[Starfish]");
	mes("I am guarding here, hehe! It is just roughly blocked for now. But someday this cave must be sealed forever, hehe!");
	next();
	while (true) {
		switch (select("Ask what's going on.", "Ask to open the gate.", "Go to other location.")) {
		case 1:
			mes("[Starfish]");
			mes("Lately, our Starfish lady is suffering with some issues, ooh ooh. Something bad happen in this peaceful place, hehe!");
			next();
			mes("[Starfish]");
			mes("Weird looking limbs came out from the hole there, tried to kidnap our lady Starfish. Ooh Ooh.");
			next();
			mes("[Starfish]");
			mes("It seems those limbs belong to that ugly octopus. That monster should be taken care of,\r"
				"but it's hard for ourselves only to make it happen, hehe.");
			next();
			mes("[Starfish]");
			mes("I want to find someone special, and ask to punish this ugly octopus.\r"
				"I hope this octopus won't ever harass our lady, hehe.");
			next();
			mes("[Starfish]");
			mes("Go catch that octopus and stick it to this pick. If you bring back the pick,\r"
				"I will open this gate for a while. You should challenge if you are interested, hehe.");
			next();
			break;
		case 2:
			.@playtime = questprogress(4197, PLAYTIME);
			if (.@playtime == 1) {
				mes("[Starfish]");
				mes("Octopus is not around now, hehe. Please come back later.");
				close();
			}
			if (.@playtime == 2)
				erasequest(4197);
			if (countitem(Octopus_Hunt_Stick)) {
				.@instance = instance_create(.@md_name$, .@party_id);
				if (.@instance >= 0) {
					if (instance_attachmap("1@cash", .@instance) == "") {
						mes("[Starfish]");
						mesf("Party name is... %s.", getpartyname(.@party_id));
						mesf("Party leader is... %s.", strcharinfo(PC_NAME));
						mesf("^0000FF%s^000000, I cannot open now, hehe.", .@md_name$);
						mes("Now is not the time, please wait.");
						instance_destroy(.@instance);
						close();
					}
					instance_set_timeout(3600, 300, .@instance);
					instance_init(.@instance);
				}
				mes("[Starfish]");
				mesf("I will open the gate for a while to ^0000FF%s^000000.", .@md_name$);
				mes("Please catch that pervert octopus, and come back with it sticked to the pick, hehe.");
				close();
			}
			mes("[Starfish]");
			mes("Prepare a pick first, so you can thread that octopus with that pick.\r"
				"Then, I will let you in for a while, hehe.");
			close();
		case 3:
			mes("[Starfish]");
			mes("This is not a good location, check someplace else.");
			close();
		}
	}
}

mal_dun01,153,237,5	script	Weird Entrance	CLEAR_NPC,{
	mes("There is a strange entrance blocked roughly with some boards.");
	next();
	switch (select("Go in.", "Stop.")) {
	case 1:
		if (countitem(Octopus_Hunt_Stick)) {
			if (has_instance("1@cash") == "") {
				if (questprogress(4197, PLAYTIME) == 1) {
					mes("[Starfish]");
					mes("Ah, now is not the time... Would you come back later? Hehe.");
					close();
				}
				mes("[Starfish]");
				mes("Shhh... Weird aura is coming from that entrance. Big trouble is waiting, if you go in now.");
				close();
			}

			mapannounce("mal_dun01", sprintf(_$("%s party's %s member started to hunt the Octopus!"), getpartyname(getcharid(CHAR_ID_PARTY)), strcharinfo(PC_NAME)), bc_map, C_SPRINGGREEN);
			if (!questprogress(4197))
				setquest(4197);
			warp("1@cash", 199, 99);
			end;
		}
		mes("[Starfish]");
		mes("You should definitely prepare hunting stick if you want to punish the Octopus. Or I will not let you in! Hehe.");
		close();
	case 2:
		mes("[Starfish]");
		mes("Yes Yes, you better quit.");
		close();
	}
}

//== Instance Scripts ======================================
1@cash,199,99,0	script	oct_enter	HIDDEN_WARP_NPC,4,4,{
	end;
OnTouch:
	donpcevent(instance_npcname("oct_enter_broad")+"::OnEnable");
	specialeffect(EF_BASH);
	disablenpc(instance_npcname("oct_enter"));
	end;
}

1@cash,1,1,0	script	oct_enter_broad	FAKE_NPC,{
	end;
OnInstanceInit:
	donpcevent(instance_npcname("oct_enter_broad")+"::OnDisable");
	end;
OnEnable:
	enablenpc(instance_npcname("oct_enter_broad"));
	donpcevent(instance_npcname("oct_foot_4")+"::OnEnable");
	donpcevent(instance_npcname("oct_mob_con")+"::OnEnable");
	initnpctimer();
	end;
OnDisable:
	disablenpc(instance_npcname("oct_enter_broad"));
	end;
OnTimer1000:
	mapannounce(instance_mapname("1@cash"), _("Pervert Octopus : How dare you to come inside of my place!"), bc_map, C_YELLOW);
	end;
OnTimer4000:
	mapannounce(instance_mapname("1@cash"), _("Pervert Octopus : But I blocked all the cave gates!! There is nothing you can do!"), bc_map, C_YELLOW);
	end;
OnTimer7000:
	mapannounce(instance_mapname("1@cash"), _("Pervert Octopus : My juniors~ There is your toy! Play with it~ kakaka"), bc_map, C_YELLOW);
	stopnpctimer();
	donpcevent(instance_npcname("oct_enter_broad")+"::OnDisable");
	end;
}

1@cash,3,3,0	script	oct_foot_4	FAKE_NPC,{
	end;
OnInstanceInit:
	donpcevent(instance_npcname("oct_foot_4")+"::OnDisable");
	end;
OnEnable:
	enablenpc(instance_npcname("oct_foot_4"));
	donpcevent(instance_npcname("oct_foot1")+"::OnEnable");
	donpcevent(instance_npcname("oct_foot2")+"::OnEnable");
	donpcevent(instance_npcname("oct_foot3")+"::OnEnable");
	donpcevent(instance_npcname("oct_foot4")+"::OnEnable");
	.@map$ = instance_mapname("1@cash");
	monster(.@map$, 20, 114, _("Octopus Leg#1"), MD_OCTOPUS_LEG, 1, instance_npcname("oct_foot_4")+"::OnMyMobDead");
	monster(.@map$, 88, 190, _("Octopus Leg#2"), MD_OCTOPUS_LEG, 1, instance_npcname("oct_foot_4")+"::OnMyMobDead");
	monster(.@map$, 307, 215, _("Octopus Leg#3"), MD_OCTOPUS_LEG, 1, instance_npcname("oct_foot_4")+"::OnMyMobDead");
	monster(.@map$, 372, 131, _("Octopus Leg#4"), MD_OCTOPUS_LEG, 1, instance_npcname("oct_foot_4")+"::OnMyMobDead");
	end;
OnDisable:
	disablenpc(instance_npcname("oct_foot_4"));
	end;
OnMyMobDead:
	.@map$ = instance_mapname("1@cash");
	if (mobcount(.@map$, instance_npcname("oct_foot_4")+"::OnMyMobDead") < 1) {
		donpcevent(instance_npcname("oct_boss_con")+"::OnEnable");
		mapannounce(.@map$, _("Hey you!! I'll personally take care of you all! Let's bring it on!"), bc_map, C_SPRINGGREEN);
		enablenpc(instance_npcname("oct_boss_warp"));
		instance_warpall(.@map$, 199, 99);
		end;
	}
	mapannounce(.@map$, _("Arrgg!! That hurts!!! I need another strategy..."), bc_map, C_SPRINGGREEN);
	end;
}

1@cash,20,114,0	script	oct_foot1	HIDDEN_WARP_NPC,6,6,{
	end;
OnInstanceInit:
	donpcevent(instance_npcname(strnpcinfo(NPC_NAME))+"::OnDisable");
	end;
OnEnable:
	enablenpc(instance_npcname(strnpcinfo(NPC_NAME)));
	.@label$ = instance_npcname(strnpcinfo(NPC_NAME))+"::OnMyMobDead";
	.@i = atoi(charat(strnpcinfo(NPC_NAME), 8));
	.@map$ = instance_mapname("1@cash");
	switch (.@i) {
	case 1:
		areamonster(.@map$, 34, 96, 38, 100, _("Octopus's Henchman"), MD_OCTOPUS, 3, .@label$);
		areamonster(.@map$, 39, 90, 41, 92, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 38, 76, 40, 78, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 39, 58, 41, 60, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 50, 38, 56, 44, _("Octopus's Henchman"), MD_OCTOPUS, 5, .@label$);
		areamonster(.@map$, 68, 32, 72, 36, _("Octopus's Henchman"), MD_OCTOPUS, 5, .@label$);
		areamonster(.@map$, 83, 26, 85, 28, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 107, 28, 109, 30, _("Octopus's Henchman"), MD_OCTOPUS, 1, .@label$);
		areamonster(.@map$, 123, 28, 125, 30, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 134, 31, 138, 35, _("Octopus's Henchman"), MD_OCTOPUS, 5, .@label$);
		areamonster(.@map$, 142, 39, 146, 43, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		break;
	case 2:
		areamonster(.@map$, 139, 113, 143, 117, _("Octopus's Henchman"), MD_OCTOPUS, 5, .@label$);
		areamonster(.@map$, 135, 104, 137, 106, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 123, 93, 127, 97, _("Octopus's Henchman"), MD_OCTOPUS, 3, .@label$);
		areamonster(.@map$, 113, 90, 115, 92, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 103, 89, 105, 91, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 89, 90, 91, 92, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 74, 104, 76, 106, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 74, 120, 76, 122, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 83, 131, 87, 135, _("Octopus's Henchman"), MD_OCTOPUS, 3, .@label$);
		areamonster(.@map$, 92, 142, 94, 144, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 98, 159, 100, 161, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 94, 180, 98, 184, _("Octopus's Henchman"), MD_OCTOPUS, 5, .@label$);
		break;
	case 3:
		areamonster(.@map$, 299, 209, 303, 213, _("Octopus's Henchman"), MD_OCTOPUS, 3, .@label$);
		areamonster(.@map$, 292, 203, 296, 207, _("Octopus's Henchman"), MD_OCTOPUS, 3, .@label$);
		areamonster(.@map$, 291, 186, 293, 188, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 292, 166, 294, 168, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 293, 151, 295, 153, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 299, 137, 303, 141, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 300, 123, 304, 127, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 300, 104, 304, 108, _("Octopus's Henchman"), MD_OCTOPUS, 3, .@label$);
		areamonster(.@map$, 279, 101, 281, 103, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		monster(.@map$, 260, 103, _("Octopus's Henchman"), MD_OCTOPUS, 1, .@label$);
		break;
	case 4:
		areamonster(.@map$, 363, 123, 367, 127, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 364, 108, 368, 112, _("Octopus's Henchman"), MD_OCTOPUS, 5, .@label$);
		areamonster(.@map$, 363, 93, 367, 97, _("Octopus's Henchman"), MD_OCTOPUS, 3, .@label$);
		areamonster(.@map$, 364, 72, 366, 74, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 364, 58, 366, 60, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 355, 44, 359, 48, _("Octopus's Henchman"), MD_OCTOPUS, 3, .@label$);
		areamonster(.@map$, 346, 36, 350, 40, _("Octopus's Henchman"), MD_OCTOPUS, 3, .@label$);
		areamonster(.@map$, 319, 28, 325, 34, _("Octopus's Henchman"), MD_OCTOPUS, 5, .@label$);
		areamonster(.@map$, 305, 27, 307, 29, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		areamonster(.@map$, 276, 29, 280, 33, _("Octopus's Henchman"), MD_OCTOPUS, 5, .@label$);
		areamonster(.@map$, 258, 37, 262, 41, _("Octopus's Henchman"), MD_OCTOPUS, 2, .@label$);
		break;
	}
	end;
OnDisable:
	killmonster(instance_mapname("1@cash"), instance_npcname(strnpcinfo(NPC_NAME))+"::OnMyMobDead"); // Not in official script.
	disablenpc(instance_npcname(strnpcinfo(NPC_NAME)));
	end;
OnTouch:
	if (getd("."+strnpcinfo(NPC_NAME)+instance_id()))
		end;
	setd("."+strnpcinfo(NPC_NAME)+instance_id(), 1);
	hideonnpc(instance_npcname(strnpcinfo(NPC_NAME)));
	mapannounce(instance_mapname("1@cash"), _("Come out all my babies and help me out!"), bc_map, C_YELLOW);
	initnpctimer();
	end;
OnTimer5000:
	.@map$ = instance_mapname("1@cash");
	mapannounce(.@map$, _("Let's give them a lesson!"), bc_map, C_YELLOW);
	.@label$ = instance_npcname(strnpcinfo(NPC_NAME))+"::OnMyMobDead";
	.@i = atoi(charat(strnpcinfo(NPC_NAME), 8));
	switch (.@i) {
	case 1:
		areamonster(.@map$, 18, 112, 22, 116, _("Octopus's Henchman"), MD_OCTOPUS, 3, .@label$);
		areamonster(.@map$, 18, 112, 22, 116, _("Octopus's Henchman"), MD_OCTOPUS, 3, .@label$);
		break;
	case 2:
		areamonster(.@map$, 86, 188, 90, 192, _("Octopus's Henchman"), MD_OCTOPUS, 3, .@label$);
		areamonster(.@map$, 96, 98, 100, 102, _("Octopus's Henchman"), MD_OCTOPUS, 3, .@label$);
		break;
	case 3:
		areamonster(.@map$, 305, 213, 309, 217, _("Octopus's Henchman"), MD_OCTOPUS, 3, .@label$);
		areamonster(.@map$, 305, 213, 309, 217, _("Octopus's Henchman"), MD_OCTOPUS, 3, .@label$);
		break;
	case 4:
		areamonster(.@map$, 370, 129, 374, 133, _("Octopus's Henchman"), MD_OCTOPUS, 3, .@label$);
		areamonster(.@map$, 370, 129, 374, 133, _("Octopus's Henchman"), MD_OCTOPUS, 3, .@label$);
		break;
	}
	end;
OnTimer30000:
	setd("."+strnpcinfo(NPC_NAME)+instance_id(), 0);
	stopnpctimer();
	.@i = atoi(charat(strnpcinfo(NPC_NAME), 8));
	donpcevent(instance_npcname("oct_foot_exit"+.@i)+"::OnEnable");
	donpcevent(instance_npcname(strnpcinfo(NPC_NAME))+"::OnDisable");
	end;
OnMyMobDead:
	.@map$ = instance_mapname("1@cash");
	if (mobcount(.@map$, instance_npcname(strnpcinfo(NPC_NAME))+"::OnMyMobDead") < 1) {
		mapannounce(.@map$, _("You hurt my babies!!? You'll have to pay for this!!!"), bc_map, C_SPRINGGREEN);
		setd("."+strnpcinfo(NPC_NAME)+instance_id(), 0);
		stopnpctimer();
		.@i = atoi(charat(strnpcinfo(NPC_NAME), 8));
		donpcevent(instance_npcname("oct_foot_exit"+.@i)+"::OnEnable");
		donpcevent(instance_npcname(strnpcinfo(NPC_NAME))+"::OnDisable");
		end;
	}
	end;
}
1@cash,88,190,0	duplicate(oct_foot1)	oct_foot2	HIDDEN_WARP_NPC,6,6
1@cash,307,215,0	duplicate(oct_foot1)	oct_foot3	HIDDEN_WARP_NPC,6,6
1@cash,372,131,0	duplicate(oct_foot1)	oct_foot4	HIDDEN_WARP_NPC,6,6

1@cash,16,117,0	script	oct_foot_exit1	WARPNPC,2,2,{
	end;
OnInstanceInit:
	disablenpc(instance_npcname(strnpcinfo(NPC_NAME)));
	end;
OnEnable:
	enablenpc(instance_npcname(strnpcinfo(NPC_NAME)));
	end;
OnTouch:
	warp(instance_mapname("1@cash"), 198, 99);
	end;
}
1@cash,77,193,0	duplicate(oct_foot_exit1)	oct_foot_exit2	WARPNPC,2,2
1@cash,312,214,0	duplicate(oct_foot_exit1)	oct_foot_exit3	WARPNPC,2,2
1@cash,370,139,0	duplicate(oct_foot_exit1)	oct_foot_exit4	WARPNPC,2,2

1@cash,15,15,0	script	oct_mob_con	FAKE_NPC,{
	end;
OnInstanceInit:
	donpcevent(instance_npcname("oct_mob_con")+"::OnDisable");
	end;
OnEnable:
	.@map$ = instance_mapname("1@cash");
	enablenpc(instance_npcname("oct_mob_con"));
	monster(.@map$, 32, 94, _("Hydra"), HYDRA, 1);
	monster(.@map$, 41, 101, _("Hydra"), HYDRA, 1);
	monster(.@map$, 35, 78, _("Hydra"), HYDRA, 1);
	monster(.@map$, 35, 62, _("Hydra"), HYDRA, 1);
	monster(.@map$, 49, 54, _("Hydra"), HYDRA, 1);
	monster(.@map$, 70, 28, _("Hydra"), HYDRA, 1);
	monster(.@map$, 83, 22, _("Hydra"), HYDRA, 1);
	monster(.@map$, 99, 23, _("Hydra"), HYDRA, 1);
	monster(.@map$, 115, 23, _("Hydra"), HYDRA, 1);
	monster(.@map$, 132, 25, _("Hydra"), HYDRA, 1);
	monster(.@map$, 100, 185, _("Hydra"), HYDRA, 1);
	monster(.@map$, 92, 178, _("Hydra"), HYDRA, 1);
	monster(.@map$, 92, 162, _("Hydra"), HYDRA, 1);
	monster(.@map$, 70, 121, _("Hydra"), HYDRA, 1);
	monster(.@map$, 70, 105, _("Hydra"), HYDRA, 1);
	monster(.@map$, 105, 85, _("Hydra"), HYDRA, 1);
	monster(.@map$, 121, 84, _("Hydra"), HYDRA, 1);
	monster(.@map$, 292, 209, _("Hydra"), HYDRA, 1);
	monster(.@map$, 303, 206, _("Hydra"), HYDRA, 1);
	monster(.@map$, 290, 163, _("Hydra"), HYDRA, 1);
	monster(.@map$, 299, 150, _("Hydra"), HYDRA, 1);
	monster(.@map$, 308, 141, _("Hydra"), HYDRA, 1);
	monster(.@map$, 308, 125, _("Hydra"), HYDRA, 1);
	monster(.@map$, 295, 97, _("Hydra"), HYDRA, 1);
	monster(.@map$, 279, 97, _("Hydra"), HYDRA, 1);
	monster(.@map$, 370, 111, _("Hydra"), HYDRA, 1);
	monster(.@map$, 370, 110, _("Hydra"), HYDRA, 1);
	monster(.@map$, 371, 96, _("Hydra"), HYDRA, 1);
	monster(.@map$, 371, 80, _("Hydra"), HYDRA, 1);
	monster(.@map$, 367, 55, _("Hydra"), HYDRA, 1);
	monster(.@map$, 343, 29, _("Hydra"), HYDRA, 1);
	monster(.@map$, 327, 24, _("Hydra"), HYDRA, 1);
	monster(.@map$, 311, 22, _("Hydra"), HYDRA, 1);
	monster(.@map$, 295, 22, _("Hydra"), HYDRA, 1);
	monster(.@map$, 279, 22, _("Hydra"), HYDRA, 1);
	areamonster(.@map$, 30, 67, 50, 87,  _("Stapo"), STAPO, 1);
	areamonster(.@map$, 102, 19, 122, 39,  _("Stapo"), STAPO, 1);
	areamonster(.@map$, 89, 138, 109, 158,  _("Stapo"), STAPO, 1);
	areamonster(.@map$, 112, 83, 132, 103,  _("Stapo"), STAPO, 1);
	areamonster(.@map$, 283, 168, 303, 188,  _("Stapo"), STAPO, 1);
	areamonster(.@map$, 292, 97, 312, 117,  _("Stapo"), STAPO, 1);
	areamonster(.@map$, 355, 64, 375, 84,  _("Stapo"), STAPO, 1);
	areamonster(.@map$, 317, 17, 337, 37,  _("Stapo"), STAPO, 1);
	donpcevent(instance_npcname("oct_backattack1")+"::OnEnable");
	donpcevent(instance_npcname("oct_backattack2")+"::OnEnable");
	donpcevent(instance_npcname("oct_backattack3")+"::OnEnable");
	donpcevent(instance_npcname("oct_backattack4")+"::OnEnable");
	donpcevent(instance_npcname("oct_mob_con")+"::OnDisable");
	end;
OnDisable:
	disablenpc(instance_npcname("oct_mob_con"));
	end;
}

1@cash,45,53,0	script	oct_backattack1	HIDDEN_WARP_NPC,3,3,{
	end;
OnInstanceInit:
	disablenpc(instance_npcname("oct_backattack1"));
	end;
OnTouch:
	.@map$ = instance_mapname("1@cash");
	monster(.@map$, 39, 59, _("Hydra"), HYDRA, 1);
	monster(.@map$, 40, 59, _("Hydra"), HYDRA, 1);
	monster(.@map$, 41, 59, _("Hydra"), HYDRA, 1);
	monster(.@map$, 47, 50, _("Hydra"), HYDRA, 1);
	monster(.@map$, 48, 50, _("Hydra"), HYDRA, 1);
	monster(.@map$, 49, 50, _("Hydra"), HYDRA, 1);
	monster(.@map$, 41, 53, _("Octopus's Henchman"), MD_OCTOPUS, 1);
	mapannounce(.@map$, _("Don't let them break through, stop them!!!"), bc_map, C_SPRINGGREEN);
	specialeffect(EF_BASH);
	disablenpc(instance_npcname("oct_backattack1"));
	end;
OnEnable:
	enablenpc(instance_npcname("oct_backattack1"));
	end;
}

1@cash,78,99,0	script	oct_backattack2	HIDDEN_WARP_NPC,3,3,{
	end;
OnInstanceInit:
	disablenpc(instance_npcname("oct_backattack2"));
	end;
OnTouch:
	if (getd("."+instance_id()))
		end;
	setd("."+instance_id(), 1);
	initnpctimer();
	.@map$ = instance_mapname("1@cash");
	monster(.@map$, 71, 105, _("Octopus's Henchman"), MD_OCTOPUS, 1);
	mapannounce(.@map$, _("Headquarters are empty, GO!!!"), bc_map, C_SPRINGGREEN);
	hideonnpc(instance_npcname("oct_backattack2"));
	end;
OnTimer2000:
	.@map$ = instance_mapname("1@cash");
	monster(.@map$, 71, 105, _("Octopus's Henchman"), MD_OCTOPUS, 1);
	mapannounce(.@map$, _("Run, RUN! Go, GO!!!"), bc_map, C_SPRINGGREEN);
	end;
OnTimer4000:
	.@map$ = instance_mapname("1@cash");
	monster(.@map$, 71, 105, _("Octopus's Henchman"), MD_OCTOPUS, 1);
	mapannounce(.@map$, _("No time, come out fast!"), bc_map, C_SPRINGGREEN);
	end;
OnTimer6000:
	.@map$ = instance_mapname("1@cash");
	monster(.@map$, 71, 105, _("Octopus's Henchman"), MD_OCTOPUS, 3);
	mapannounce(.@map$, _("Let's take over the headquarters!!!"), bc_map, C_SPRINGGREEN);
	end;
OnTimer8000:
	.@map$ = instance_mapname("1@cash");
	monster(.@map$, 71, 105, _("Octopus's Henchman"), MD_OCTOPUS, 1);
	mapannounce(.@map$, _("There is no time to lose, hurry up!!!"), bc_map, C_SPRINGGREEN);
	stopnpctimer();
	end;
OnEnable:
	enablenpc(instance_npcname("oct_backattack2"));
	end;
}

1@cash,299,144,0	script	oct_backattack3	HIDDEN_WARP_NPC,3,3,{
	end;
OnInstanceInit:
	disablenpc(instance_npcname("oct_backattack3"));
	end;
OnTouch:
	if (getd("."+instance_id()))
		end;
	setd("."+instance_id(), 1);
	.@map$ = instance_mapname("1@cash");
	monster(.@map$, 293, 153, _("Octopus's Henchman"), MD_OCTOPUS, 1);
	monster(.@map$, 294, 152, _("Octopus's Henchman"), MD_OCTOPUS, 1);
	monster(.@map$, 292, 153, _("Octopus's Henchman"), MD_OCTOPUS, 1);
	monster(.@map$, 293, 151, _("Octopus's Henchman"), MD_OCTOPUS, 1);
	monster(.@map$, 293, 152, _("Octopus's Henchman ?"), MD_MARSE, 1);
	mapannounce(.@map$, _("Kakaka! Suprised??!!"), bc_map, C_SPRINGGREEN);
	initnpctimer();
	hideonnpc(instance_npcname("oct_backattack3"));
	end;
OnTimer5000:
	mapannounce(instance_mapname("1@cash"), _("... Looks like we have a spy among us."), bc_map, C_SPRINGGREEN);
	stopnpctimer();
	end;
OnEnable:
	enablenpc(instance_npcname("oct_backattack3"));
	end;
}

1@cash,336,36,0	script	oct_backattack4	HIDDEN_WARP_NPC,3,3,{
	end;
OnInstanceInit:
	disablenpc(instance_npcname("oct_backattack4"));
	end;
OnTouch:
	if (getd("."+instance_id()))
		end;
	setd("."+instance_id(), 1);
	.@map$ = instance_mapname("1@cash");
	monster(.@map$, 332, 37, _("Octopus's Henchman"), MD_OCTOPUS, 1);
	monster(.@map$, 332, 36, _("Octopus's Henchman"), MD_OCTOPUS, 1);
	monster(.@map$, 332, 35, _("Octopus's Henchman"), MD_OCTOPUS, 1);
	monster(.@map$, 332, 34, _("Octopus's Henchman"), MD_OCTOPUS, 1);
	monster(.@map$, 341, 37, _("Octopus's Henchman"), MD_OCTOPUS, 1);
	monster(.@map$, 341, 36, _("Octopus's Henchman"), MD_OCTOPUS, 1);
	monster(.@map$, 341, 35, _("Octopus's Henchman"), MD_OCTOPUS, 1);
	monster(.@map$, 341, 34, _("Octopus's Henchman"), MD_OCTOPUS, 1);
	monster(.@map$, 260, 40, _("Mercenary Squid"), MD_MARSE, 1);
	monster(.@map$, 260, 41, _("Mercenary Squid"), MD_MARSE, 1);
	monster(.@map$, 260, 39, _("Mercenary Squid"), MD_MARSE, 1);
	monster(.@map$, 259, 40, _("Mercenary Squid"), MD_MARSE, 1);
	monster(.@map$, 261, 40, _("Mercenary Squid"), MD_MARSE, 1);
	mapannounce(.@map$, _("What a successful pincer tactic! The enemy is strong! Let's not lose yourselves! Anyway, where are all the mercenaries??"), bc_map, C_SPRINGGREEN);
	initnpctimer();
	hideonnpc(instance_npcname("oct_backattack4"));
	end;
OnTimer5000:
	mapannounce(instance_mapname("1@cash"), _("Mercenary Squid : eh...eh... wrong direction. No enemies are shown in this direction."), bc_map, C_SPRINGGREEN);
	end;
OnTimer7000:
	mapannounce(instance_mapname("1@cash"), _("Pervert Octopus : Fools! Can't you read the map??!! Useless!!"), bc_map, C_SPRINGGREEN);
	stopnpctimer();
	end;
OnEnable:
	enablenpc(instance_npcname("oct_backattack4"));
	end;
}

1@cash,2,2,0	script	oct_boss_con	FAKE_NPC,{
	end;
OnInstanceInit:
	donpcevent(instance_npcname("oct_boss_con")+"::OnDisable");
	end;
OnDisable:
	disablenpc(instance_npcname("oct_boss_con"));
	end;
OnEnable:
	enablenpc(instance_npcname("oct_boss_con"));
	donpcevent(instance_npcname("oct_boss_foot")+"::OnEnable");
	monster(instance_mapname("1@cash"), 199, 188, _("Disgusting Octopus"), MD_GIANT_OCTOPUS, 1, instance_npcname("oct_boss_con")+"::OnMyMobDead");
	initnpctimer();
	end;
OnTimer7000:
	callsub OnAnnounce,
		"You won't attack the one man.",
		"I got fired from ink manufacturer last week.",
		"Disgusting Octopus : Arghhhhh, come on!";
	end;
OnTimer14000:
	callsub OnAnnounce,
		"Why... why can't you know my heart!",
		"Do you know how hard it is to live these days because there are not many new adventurers?",
		"You.. I'll destroy you all...!";
	end;
OnTimer21000:
	callsub OnAnnounce,
		"What? I'm a disgusting octopus? You're sadists.",
		"Let's not do this and how about we look for the best solution, huh??",
		"Even if I fail here, I will keep coming back, forever!!!";
	end;
OnTimer28000:
	callsub OnAnnounce,
		"Instinct of mating is for males, what did I do wrong?",
		"Do you really want to solve the problem between humans by violence?? Ah, I'm an octopus...",
		"That's enough! Back off!";
	end;
OnTimer35000:
	callsub OnAnnounce,
		"Do I have to spend Christmas alone again...",
		"Youth unemployment became a big issue these days... You won't get a job if you keep playing with me here.",
		"This is as far as I can go!";
	end;
OnTimer42000:
	callsub OnAnnounce,
		"Hand on your heart and think if you come onto anyone...",
		"Let's not do this here and follow the law!",
		"You'll keep on doing this til the end, is that it?";
	end;
OnTimer49000:
	callsub OnAnnounce,
		"errrrrrrrrrrrrrrrrrrrrrrrr... Cough! Cough!",
		"Disgusting Octopus : Violence cannot be justified in any case.",
		"This is my place!!!";
	stopnpctimer();
	initnpctimer();
	end;
OnAnnounce:
	mapannounce(instance_mapname("1@cash"), sprintf(_$("Disgusting Octopus : %s"), getarg(rand(3))), bc_map, C_YELLOW);
	return;
OnMyMobDead:
	.@map$ = instance_mapname("1@cash");
	if (mobcount(.@map$, instance_npcname("oct_boss_con")+"::OnMyMobDead") < 1) {
		mapannounce(.@map$, _("Disgusting Octopus : That's it for the today! Next time, I will play with you badly!"), bc_map, C_YELLOW);
		enablenpc(instance_npcname("oct_exit_1"));
		enablenpc(instance_npcname("oct_exit_2"));
		donpcevent(instance_npcname("oct_boss_foot")+"::OnDisable");
		stopnpctimer();
		donpcevent(instance_npcname("oct_boss_con")+"::OnDisable");
		end;
	}
	end;
}

1@cash,4,4,0	script	oct_boss_foot	FAKE_NPC,{
	end;
OnInstanceInit:
	donpcevent(instance_npcname("oct_boss_foot")+"::OnDisable");
	end;
OnEnable:
	enablenpc(instance_npcname("oct_boss_foot"));
	initnpctimer();
	end;
OnCall:
	.@map$ = instance_mapname("1@cash");
	if (mobcount(.@map$, instance_npcname("oct_boss_foot")+"::OnMyMobDead") < 100) {
		switch (rand(2)) {
		case 0:
			mapannounce(.@map$, _("Disgusting Octopus : Do you know how many legs octopus have? It doesn't matter, I have unlimited legs!!"), bc_map, C_YELLOW);
			areamonster(.@map$, 192, 181, 206, 195, _("Octopus Leg"), MD_OCTOPUS_LEG, 1, instance_npcname("oct_boss_foot")+"::OnMyMobDead");
			break;
		case 1:
			mapannounce(.@map$, _("Disgusting Octopus : I...cannot..hold anymore, my babies~ please come out and fight!"), bc_map, C_YELLOW);
			areamonster(.@map$, 192, 181, 206, 195, _("Octopus's Henchman"), MD_OCTOPUS, 5, instance_npcname("oct_boss_foot")+"::OnMyMobDead");
			break;
		}
	}
	initnpctimer();
	end;
OnTimer10000:
	stopnpctimer();
	donpcevent(instance_npcname("oct_boss_foot")+"::OnCall");
	end;
OnDisable:
	stopnpctimer();
	killmonster(instance_mapname("1@cash"), instance_npcname("oct_boss_foot")+"::OnMyMobDead"); // Not in official script.
	disablenpc(instance_npcname("oct_boss_foot"));
	end;
OnMyMobDead:
	end;
}

1@cash,198,116,0	script	oct_boss_warp	WARPNPC,2,2,{
	end;
OnInstanceInit:
	disablenpc(instance_npcname("oct_boss_warp"));
	end;
OnTouch:
	warp(instance_mapname("1@cash"), 210, 172);
	end;
}

1@cash,190,208,0	script	oct_exit_1	WARPNPC,2,2,{
	end;
OnInstanceInit:
	disablenpc(instance_npcname(strnpcinfo(NPC_NAME)));
	end;
OnTouch:
	mes("Do you want to go out from the octopus dungeon?");
	next();
	if (select("No!", "Yes!") == 2)
		warp("mal_dun01", 153, 233);
	close();
}
1@cash,198,82,0	duplicate(oct_exit_1)	oct_exit_2	WARPNPC,2,2
// This is never enabled in the official script.
//1@cash,200,161,0	duplicate(oct_exit_1)	oct_exit_3	WARPNPC,2,2

//== Warp Portals ==========================================
1@cash,193,82,0	warp	oct_door1	2,2,1@cash,151,48
1@cash,154,53,0	warp	oct_door2	2,2,1@cash,197,87
1@cash,187,99,0	warp	oct_door3	2,2,1@cash,148,128
1@cash,153,133,0	warp	oct_door4	2,2,1@cash,197,99
1@cash,209,100,0	warp	oct_door5	2,2,1@cash,250,111
1@cash,244,118,0	warp	oct_door6	2,2,1@cash,199,100
1@cash,209,83,0	warp	oct_door7	2,2,1@cash,252,46
1@cash,246,53,0	warp	oct_door8	2,2,1@cash,203,83
