@LabelIndex 421962
@StringIndex 0
class 1 inzone_maker : (null) {
parameter:
	int	inzone_type_param = 0;
	int	spawn_event_id = -2;
	int	despawn_event_id = -1;
	int	on_start_spawn = 1;
	int	script_event_enable = 1;
	int	inzone_cluster_id = 0;

handler:
	EventHandler ON_START() {
		if( script_event_enable == 1 ) {
			myself.enabled = script_event_enable;
		} else {
			myself.enabled = 0;
		}
		if( on_start_spawn == 1 ) {
			myself::RegisterInstantZoneEventEx(inzone_type_param,inzone_cluster_id,spawn_event_id,1);
		}
		myself::RegisterInstantZoneEventEx(inzone_type_param,inzone_cluster_id,despawn_event_id,0);
	}

	EventHandler ON_INSTANT_ZONE_EVENT(inzone_type_id,inzone_id,event_id,reply,i0,def0) {
		myself.enabled = reply;
		if( reply == 1 ) {
			for(i0 = 0; i0 < myself.def_count; i0++) {
				def0 = myself::GetSpawnDefine(i0);
				if( gg::IsNull(def0) == 0 ) {
					if( myself.maximum_npc >= ( myself.npc_count + def0.total ) ) {
						if( myself::AtomicIncreaseTotal(def0,def0.total,1) ) {
							def0::Spawn2(def0.total,0,0);
						}
					}
				}
			}
		} else if( reply == 0 ) {
			for(i0 = 0; i0 < myself.def_count; i0++) {
				def0 = myself::GetSpawnDefine(i0);
				if( gg::IsNull(def0) == 0 ) {
					def0::Despawn();
				}
			}
		}
	}

	EventHandler ON_NPC_CREATED(created_npc) {
		if( myself.enabled == 0 ) {
			created_npc::Despawn();
		}
	}

	EventHandler ON_NPC_DELETED(deleted_def,i0,i1,maker0,reply) {
		if( myself.enabled ) {
			if( deleted_def.respawn_time != 0 ) {
				if( myself.maximum_npc >= ( myself.npc_count + 1 ) ) {
					if( myself::AtomicIncreaseTotal(deleted_def,1,1) ) {
						deleted_def::Spawn2(1,deleted_def.respawn_time,deleted_def.respawn_rand);
					}
				}
			}
		}
	}

	EventHandler ON_SCRIPT_EVENT(script_event_arg1,script_event_arg2,script_event_arg3,def0,i0,i1) {
		if( myself.enabled == 0 ) {
			return;
		}
		switch(script_event_arg1) {
			case 1000: {
				for(i0 = 0; i0 < myself.def_count; i0++) {
					def0 = myself::GetSpawnDefine(i0);
					if( gg::IsNull(def0) == 0 ) {
						def0::Despawn();
					}
				}
				break;
			}
			case 1001: {
				for(i0 = 0; i0 < myself.def_count; i0++) {
					def0 = myself::GetSpawnDefine(i0);
					if( gg::IsNull(def0) == 0 ) {
						i1 = ( def0.total - def0.npc_count );
						if( i1 > 0 ) {
							if( myself.maximum_npc >= ( myself.npc_count + i1 ) ) {
								if( myself::AtomicIncreaseTotal(def0,i1,1) ) {
									def0::Spawn2(i1,script_event_arg2,0);
								}
							}
						}
					}
				}
				break;
			}
		}
	}

}
