@LabelIndex 424977
@StringIndex 63940
class 1 immo_npc_maker : fieldcycle_maker {
parameter:
	int	seq = 0;
	int	FieldCycle = 3;
	int	Threshold_Min = 0;
	int	Threshold_Max = 6;
	int	Point_Min = 0;
	int	Point_Max = 6000000;
	string	type = "";
	int	zone = 0;
	int	TM_check_point = 78001;
	int	TIME_check_point = 60;
	int	babble_mode = 0;

handler:
	EventHandler ON_START(i0,i1,i2,def0) {
		if( FieldCycle != -1 ) {
			myself::RegisterFieldCycleEventEx(FieldCycle);
			i0 = gg::GetStep_FieldCycle(FieldCycle);
			i1 = gg::GetPoint_FieldCycle(FieldCycle);
			if( i0 >= Threshold_Min && i0 <= Threshold_Max && i1 >= Point_Min && i1 <= Point_Max ) {
				for(i0 = myself.npc_count; i0 < myself.maximum_npc; i0++) {
					def0 = myself::GetSpawnDefine(gg::Rand(myself.def_count));
					if( gg::IsNull(def0) == 0 ) {
						if( myself.maximum_npc > myself.npc_count ) {
							if( myself::AtomicIncreaseTotal(def0,1,1) ) {
								def0::Spawn2(1,0,0);
							}
						}
					}
				}
			}
			myself::AddTimerEx(TM_check_point,( TIME_check_point * 1000 ));
		}
		super;
	}

	EventHandler ON_TIMER(timer_id,i0,i1,i2,maker0,def0) {
		if( timer_id == TM_check_point ) {
			i0 = gg::GetStep_FieldCycle(FieldCycle);
			i1 = gg::GetPoint_FieldCycle(FieldCycle);
			if( Point_Min > 0 && Point_Max < 6000000 && i0 >= Threshold_Min && i0 <= Threshold_Max && i1 >= Point_Min && i1 <= Point_Max && gg::IsSameString(type,"seed_energy") == 0 ) {
				gg::SendMakerScriptEvent(myself,1001,0,0);
			} else if( Point_Min > 0 && Point_Max < 6000000 ) {
				for(i0 = 0; i0 < myself.def_count; i0++) {
					def0 = myself::GetSpawnDefine(i0);
					if( gg::IsNull(def0) == 0 && def0.npc_count > 0 ) {
						def0::Despawn();
					}
				}
			}
			if( i0 == 0 || ( i0 == 6 && i1 >= 6000000 ) ) {
				if( babble_mode == 1 ) {
					gg::Announce("***¬ˆ   1 !***");
				}
				gg::SetStepWithoutActor_FieldCycle(FieldCycle,1,1);
			}
			myself::AddTimerEx(TM_check_point,( TIME_check_point * 1000 ));
		}
		super;
	}

	EventHandler ON_FIELD_CYCLE_CHANGED_EVENT(event_id,state,i0,i1,i2,maker0,def0) {
		if( event_id == FieldCycle ) {
			i0 = gg::GetStep_FieldCycle(FieldCycle);
			i1 = gg::GetPoint_FieldCycle(FieldCycle);
			if( i0 >= Threshold_Min && i0 <= Threshold_Max && i1 >= Point_Min && i1 <= Point_Max ) {
				if( gg::IsSameString(type,"seed_energy") == 0 ) {
					gg::SendMakerScriptEvent(myself,1001,0,0);
				} else {
					for(i0 = myself.npc_count; i0 <= myself.maximum_npc; i0++) {
						def0 = myself::GetSpawnDefine(gg::Rand(myself.def_count));
						if( gg::IsNull(def0) == 0 ) {
							if( myself.maximum_npc > myself.npc_count ) {
								if( myself::AtomicIncreaseTotal(def0,def0.total,1) ) {
									def0::Spawn2(def0.total,def0.respawn_time,def0.respawn_rand);
								}
							}
						}
					}
				}
			} else {
				for(i0 = 0; i0 < myself.def_count; i0++) {
					def0 = myself::GetSpawnDefine(i0);
					if( gg::IsNull(def0) == 0 && def0.npc_count > 0 ) {
						def0::Despawn();
					}
				}
			}
			if( i0 == 0 || ( i0 == 6 && i1 >= 6000000 ) ) {
				if( babble_mode == 1 ) {
					gg::Announce("***¬ˆ   1 !***");
				}
				gg::SetStepWithoutActor_FieldCycle(FieldCycle,1,1);
			}
		}
	}

	EventHandler ON_NPC_DELETED(deleted_def,def0,i0,i1,maker0,reply) {
		if( deleted_def.respawn_time != 0 ) {
			i0 = gg::GetStep_FieldCycle(FieldCycle);
			i1 = gg::GetPoint_FieldCycle(FieldCycle);
			if( i0 >= Threshold_Min && i0 <= Threshold_Max && i1 >= Point_Min && i1 <= Point_Max ) {
				if( gg::IsSameString(type,"seed_energy") == 0 ) {
					if( myself.maximum_npc > myself.npc_count ) {
						if( myself::AtomicIncreaseTotal(deleted_def,1,1) ) {
							deleted_def::Spawn2(1,deleted_def.respawn_time,deleted_def.respawn_rand);
						}
					}
				} else {
					gg::AddPointWithoutActor_FieldCycle(3,100,5);
					if( myself.maximum_npc > myself.npc_count ) {
						def0 = myself::GetSpawnDefine(gg::Rand(myself.def_count));
						if( gg::IsNull(def0) == 0 && myself::AtomicIncreaseTotal(def0,def0.total,1) ) {
							def0::Spawn2(def0.total,deleted_def.respawn_time,deleted_def.respawn_rand);
						}
					}
				}
			}
		}
	}

}
