@LabelIndex 424810
@StringIndex 63921
class 1 immo_boss_maker : immo_basic_maker {
parameter:
	string	ech_atk_seq0_maker = "rumwarsha15_1424_echmusm1";
	string	ech_atk_expel_maker = "rumwarsha15_1424_expelm1";
	string	ech_def_seq0_maker = "rumwarsha15_1424_ech_dummy1m1";
	string	ech_def_seq1_maker = "rumwarsha15_1424_ech_dummy2m1";
	string	ech_def_seq2_maker = "rumwarsha15_1424_ech_dummy2m2";
	string	ech_def_seq3_maker = "rumwarsha15_1424_defwagonm1";
	string	ech_def_seq4_maker = "rumwarsha15_1424_veinm1";
	int	TM_boss_wagon_default_delay = 780001;
	int	TIME_boss_wagon_delay_default = 30;
	int	TIME_boss_wagon_delay_min = 10;
	int	TIME_boss_wagon_delay_max = 60;
	int	TM_challanger_notify_delay = 780002;
	int	TIME_challanger_notify_delay = 10;

handler:
	EventHandler ON_INSTANT_ZONE_EVENT(reply,i0,def0) {
		myself.i_ai0 = 0;
		myself.i_ai1 = 0;
		myself.i_ai2 = 0;
		myself.enabled = reply;
		if( reply == 1 ) {
			myself.i_ai4 = TIME_boss_wagon_delay_default;
			myself.i_quest0 = 1;
			if( zone == 3 && ( seq == 0 || seq == 1 ) ) {
				def0 = myself::GetSpawnDefine(0);
				if( gg::IsNull(def0) == 0 ) {
					if( myself::AtomicIncreaseTotal(def0,def0.total,1) ) {
						def0::Spawn2(def0.total,0,0);
					}
				}
			}
		}
	}

	EventHandler ON_NPC_CREATED(created_def) {
		if( zone == 3 && tide == 0 && seq == 0 && myself::GetSpawnDefine(1) == created_def ) {
			if( gg::IsNull(created_def) == 0 ) {
				myself.i_ai0 = 1;
				if( myself.i_ai1 != 0 ) {
					created_def::SendScriptEvent(78010067,myself.i_ai1,myself.i_ai2);
				}
			}
		}
	}

	EventHandler ON_NPC_DELETED(died,deleted_def,i0,i1,maker0,reply) {
		if( zone == 3 && tide == 0 && seq == 0 && deleted_def == myself::GetSpawnDefine(1) && died == 1 && myself.enabled == 1 ) {
			if( babble_mode == 1 ) {
				gg::Announce(" ");
			}
			maker0 = gg::InstantZone_GetNpcMaker(myself::GetInZoneID(),z3_a_dispatcher_maker);
			if( gg::IsNull(maker0) == 0 ) {
				gg::SendMakerScriptEvent(maker0,78010071,died,0);
			}
		} else if( zone == 3 && tide == 0 && seq == 0 && deleted_def == myself::GetSpawnDefine(1) && died == 0 && myself.enabled == 1 ) {
			if( babble_mode == 1 ) {
				gg::Announce(" ");
			}
		}
	}

	EventHandler ON_SCRIPT_EVENT(script_event_arg1,script_event_arg2,script_event_arg3,maker0,def0,i0,i1) {
		if( script_event_arg1 == 78010067 && myself.enabled == 1 ) {
			if( zone == 3 && tide == 0 && seq == 0 && script_event_arg2 == 0 && script_event_arg3 == 0 ) {
				if( babble_mode == 1 ) {
					gg::Announce(" ");
				}
				def0 = myself::GetSpawnDefine(0);
				if( gg::IsNull(def0) == 0 ) {
					def0::Despawn();
				}
			} else if( zone == 3 && tide == 0 && seq == 0 && script_event_arg2 == 1 && script_event_arg3 == 0 ) {
				if( babble_mode == 1 ) {
					gg::Announce(" ");
				}
				def0 = myself::GetSpawnDefine(1);
				if( gg::IsNull(def0) == 0 ) {
					if( myself::AtomicIncreaseTotal(def0,def0.total,1) ) {
						def0::Spawn2(def0.total,0,0);
					}
				}
			} else if( zone == 3 && tide == 0 && seq == 0 ) {
				if( babble_mode == 1 ) {
					gg::Announce("ˆ ");
				}
				if( myself.i_ai0 == 1 ) {
					def0 = myself::GetSpawnDefine(1);
					if( gg::IsNull(def0) == 0 ) {
						def0::SendScriptEvent(script_event_arg1,script_event_arg2,script_event_arg3);
					}
				} else {
					myself.i_ai1 = script_event_arg2;
					myself.i_ai2 = script_event_arg3;
				}
			} else if( tide == 1 && zone == 3 && seq == 3 ) {
				if( babble_mode == 1 ) {
					gg::Announce("  ");
				}
				myself::AddTimerEx(TM_boss_wagon_default_delay,1000);
			}
		}
		if( ( zone == 3 && tide == 0 && seq == 0 && ( script_event_arg1 == 78010068 || script_event_arg1 == 78010070 ) ) && myself.enabled == 1 ) {
			if( babble_mode == 1 ) {
				gg::Announce("  ");
			}
			def0 = myself::GetSpawnDefine(1);
			if( gg::IsNull(def0) == 0 ) {
				def0::SendScriptEvent(script_event_arg1,script_event_arg2,script_event_arg3);
			}
		}
		if( ( zone == 3 && tide == 1 && seq == 3 && ( script_event_arg1 == 78010068 || script_event_arg1 == 78010070 ) ) && myself.enabled == 1 ) {
			if( script_event_arg1 == 78010070 ) {
				if( myself.i_quest0 > 2 ) {
					myself.i_quest0 = ( myself.i_quest0 - 1 );
				}
				if( ( myself.i_ai4 - 5 ) > TIME_boss_wagon_delay_min ) {
					myself.i_ai4 = ( myself.i_ai4 - 5 );
				} else {
					myself.i_ai4 = TIME_boss_wagon_delay_min;
				}
				if( babble_mode == 1 ) {
					gg::Announce("  ˆ: " + gg::IntToStr(myself.i_ai4) + " " + gg::IntToStr(myself.i_quest0) + " ");
				}
			} else if( myself.i_quest0 < 4 ) {
				myself.i_quest0 = ( myself.i_quest0 + 1 );
			}
			if( ( myself.i_ai4 + 5 ) < TIME_boss_wagon_delay_max ) {
				myself.i_ai4 = ( myself.i_ai4 + 5 );
			} else {
				myself.i_ai4 = TIME_boss_wagon_delay_max;
			}
			if( babble_mode == 1 ) {
				gg::Announce("  ˆ: " + gg::IntToStr(myself.i_ai4) + " " + gg::IntToStr(myself.i_quest0) + " ");
			}
		} else if( zone == 3 && tide == 1 && seq == 3 && script_event_arg1 == 78010073 && myself.enabled == 1 ) {
			if( babble_mode == 1 ) {
				gg::Announce("    ");
			}
			maker0 = gg::InstantZone_GetNpcMaker(myself::GetInZoneID(),ech_def_seq4_maker);
			if( gg::IsNull(maker0) == 0 ) {
				gg::SendMakerScriptEvent(maker0,78010073,0,0);
			}
		} else if( zone == 3 && tide == 1 && seq == 4 && script_event_arg1 == 78010073 && myself.enabled == 1 ) {
			if( babble_mode == 1 ) {
				gg::Announce(" ");
			}
			i0 = gg::Rand(3);
			def0 = myself::GetSpawnDefine(i0);
			if( gg::IsNull(def0) == 0 ) {
				if( myself::AtomicIncreaseTotal(def0,def0.total,1) ) {
					def0::Spawn2(def0.total,0,0);
				}
			}
			maker0 = gg::InstantZone_GetNpcMaker(myself::GetInZoneID(),z3_d_dispatcher_maker);
			if( gg::IsNull(maker0) == 0 ) {
				gg::SendMakerScriptEvent(maker0,78010073,0,0);
			}
		} else if( zone == 3 && tide == 1 && seq == 2 && script_event_arg1 == 78010070 && myself.enabled == 1 ) {
			if( babble_mode == 1 ) {
				gg::Announce("ˆ");
			}
			def0 = myself::GetSpawnDefine(0);
			if( gg::IsNull(def0) == 0 ) {
				if( myself::AtomicIncreaseTotal(def0,1,1) ) {
					def0::Spawn2(1,0,0);
				}
			}
		} else if( zone == 3 && tide == 1 && seq == 0 && script_event_arg1 == 78010070 && myself.enabled == 1 ) {
			def0 = myself::GetSpawnDefine(0);
			if( gg::IsNull(def0) == 0 ) {
				def0::SendScriptEvent(script_event_arg1,script_event_arg2,script_event_arg3);
			}
		} else if( script_event_arg1 == 1000 ) {
			myself.enabled = 0;
			if( babble_mode == 1 ) {
				gg::Announce("NPC");
			}
			for(i0 = 0; i0 < myself.def_count; i0++) {
				def0 = myself::GetSpawnDefine(i0);
				if( gg::IsNull(def0) == 0 && def0.npc_count > 0 ) {
					def0::Despawn();
				}
			}
		}
	}

	EventHandler ON_TIMER(timer_id,i0,i1,i2,maker0,def0) {
		if( timer_id == TM_boss_wagon_default_delay && zone == 3 && tide == 1 && seq == 3 && myself.enabled == 1 ) {
			def0 = myself::GetSpawnDefine(0);
			if( gg::IsNull(def0) == 0 ) {
				if( myself.maximum_npc >= ( myself.def_count + myself.i_quest0 ) && myself::AtomicIncreaseTotal(def0,myself.i_quest0,1) ) {
					if( babble_mode == 1 ) {
						gg::Announce(" ");
					}
					def0::Spawn2(myself.i_quest0,0,0);
				}
			}
			myself::AddTimerEx(TM_boss_wagon_default_delay,( myself.i_ai4 * 1000 ));
		}
	}

}
