@LabelIndex 422519
@StringIndex 0
class 1 crystal_c_hall_maker : inzone_door_open_maker {
parameter:
	string	open_door_name1 = "crystal_c_hall_open_door_name1_default";
	string	open_door_name2 = "crystal_c_hall_open_door_name2_default";
	string	c_hall_first_door_name = "cyratal_cave_c_6";
	string	treasure_door_name = "cyratal_cave_c_13";
	int	room_index = 0;
	string	alarm_maker_name = "innadril22_2422_049m1";

handler:
	EventHandler ON_TIMER(timer_id,def0,maker0,i0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11) {
		if( timer_id == 2001 ) {
			gg::Castle_GateOpenCloseEx(open_door_name1,0,myself::GetInZoneID());
			gg::Castle_GateOpenCloseEx(open_door_name2,0,myself::GetInZoneID());
			myself::AddTimerEx(2002,( 20 * 1000 ));
		} else if( timer_id == 2002 ) {
			gg::Castle_GateOpenCloseEx(open_door_name1,1,myself::GetInZoneID());
			gg::Castle_GateOpenCloseEx(open_door_name2,1,myself::GetInZoneID());
		} else if( timer_id == 2003 ) {
			i0 = gg::Rand(11);
			def0 = myself::GetSpawnDefine(i0);
			if( gg::IsNull(def0) == 0 ) {
				def0::SendScriptEvent(12568,0,0);
			}
		} else if( timer_id == 2004 ) {
			gg::Castle_GateOpenCloseEx(c_hall_first_door_name,1,myself::GetInZoneID());
		}
	}

	EventHandler ON_DOOR_EVENT(enabled,i0,i1,i2,def0,maker0) {
		if( enabled ) {
			if( myself.enabled ) {
				return;
			}
			myself.enabled = 1;
			if( room_index == 1 ) {
				i2 = myself::GetInZoneID();
				maker0 = gg::InstantZone_GetNpcMaker(i2,alarm_maker_name);
				if( gg::IsNull(maker0) == 0 ) {
					gg::SendMakerScriptEvent(maker0,1001,0,0);
					gg::SendMakerScriptEvent(maker0,12566,room_index,0);
				}
				myself::AddTimerEx(2004,( 20 * 1000 ));
			}
			if( room_index == 8 ) {
				myself::AddTimerEx(2003,3000);
			}
			for(i0 = 0; i0 < myself.def_count; i0++) {
				def0 = myself::GetSpawnDefine(i0);
				if( gg::IsNull(def0) == 0 ) {
					if( myself::AtomicIncreaseTotal(def0,def0.total,1) ) {
						def0::Spawn2(def0.total,0,0);
					}
				}
			}
		}
	}

	EventHandler ON_ALL_NPC_DELETED(i0,def0,maker0) {
		myself::AddTimerEx(2001,2000);
		if( room_index < 8 ) {
			i0 = myself::GetInZoneID();
			maker0 = gg::InstantZone_GetNpcMaker(i0,alarm_maker_name);
			if( gg::IsNull(maker0) == 0 ) {
				gg::SendMakerScriptEvent(maker0,12566,( room_index + 1 ),0);
			}
			maker0 = gg::InstantZone_GetNpcMaker(i0,alarm_maker_name);
			if( gg::IsNull(maker0) == 0 ) {
				gg::SendMakerScriptEvent(maker0,1001,0,0);
			}
			if( room_index == 7 ) {
				gg::Castle_GateOpenCloseEx(c_hall_first_door_name,0,myself::GetInZoneID());
				gg::Castle_GateOpenCloseEx(treasure_door_name,0,myself::GetInZoneID());
			}
		}
	}

}
