@LabelIndex 422255
@StringIndex 0
class 1 timer_random_maker : default_maker {
parameter:
	int	spawn_interval = 0;
	int	script_event_use = 0;

handler:
	EventHandler ON_START(i0,i1,def0) {
		if( on_start_spawn == 0 ) {
			return;
		}
		myself.i_ai0 = 0;
		i0 = gg::Rand(myself.def_count);
		def0 = myself::GetSpawnDefine(i0);
		if( gg::IsNull(def0) == 0 ) {
			i1 = ( def0.total - def0.npc_count );
			if( i1 > 0 ) {
				if( myself::AtomicIncreaseTotal(def0,i1,1) ) {
					def0::Spawn2(i1,0,0);
				}
			}
		}
	}

	EventHandler ON_NPC_CREATED(created_def,created_npc,maker0,i0) {
		myself.i_ai0 = 1;
	}

	EventHandler ON_NPC_DELETED(deleted_def,i0,i1,maker0,reply) {
		myself.i_ai0 = 0;
		myself::AddTimerEx(1879,( ( spawn_interval * 60 ) * 1000 ));
	}

	EventHandler ON_TIMER(timer_id,i0,i1,maker0,def0) {
		if( timer_id == 1879 ) {
			if( myself.i_ai0 == 0 ) {
				i0 = gg::Rand(myself.def_count);
				def0 = myself::GetSpawnDefine(i0);
				if( gg::IsNull(def0) == 0 ) {
					i1 = ( def0.total - def0.npc_count );
					if( i1 > 0 ) {
						if( myself::AtomicIncreaseTotal(def0,i1,1) ) {
							def0::Spawn2(i1,0,0);
						}
					}
				}
			}
		}
	}

	EventHandler ON_SCRIPT_EVENT(script_event_arg1,script_event_arg2,script_event_arg3,i0,i1,def0) {
		if( script_event_use == 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: {
				if( myself.i_ai0 == 0 ) {
					i0 = gg::Rand(myself.def_count);
					def0 = myself::GetSpawnDefine(i0);
					if( gg::IsNull(def0) == 0 ) {
						i1 = ( def0.total - def0.npc_count );
						if( i1 > 0 ) {
							if( myself::AtomicIncreaseTotal(def0,i1,1) ) {
								def0::Spawn2(i1,0,0);
							}
						}
					}
				}
				break;
			}
		}
	}

}
