@LabelIndex 424750
@StringIndex 0
class 1 immo_trap_maker : immo_basic_maker {
parameter:
	int	TM_trap_delay = 780001;
	int	TIME_trap_delay = 30;

handler:
	EventHandler ON_NPC_DELETED(deleted_def,died,i0,i1,def0,maker0,reply) {
		if( myself.enabled == 1 ) {
			def0 = myself::GetSpawnDefine(gg::Rand(3));
			if( gg::IsNull(def0) == 0 ) {
				if( myself::AtomicIncreaseTotal(def0,def0.total,1) ) {
					def0::Spawn2(def0.total,def0.respawn_time,def0.respawn_rand);
				}
			}
		}
	}

	EventHandler ON_TIMER(timer_id,i0,i1,maker0,def0) {
		if( timer_id == TM_trap_delay && myself.enabled == 1 ) {
			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);
				}
			}
		}
	}

	EventHandler ON_SCRIPT_EVENT(script_event_arg1,script_event_arg2,script_event_arg3,def0,i0,i1) {
		if( script_event_arg1 == 78010067 && myself.enabled == 1 ) {
			myself::AddTimerEx(TM_trap_delay,( TIME_trap_delay * 1000 ));
		} else if( script_event_arg1 == 1000 ) {
			myself.enabled = 0;
			for(i0 = 0; i0 < myself.def_count; i0++) {
				def0 = myself::GetSpawnDefine(i0);
				if( gg::IsNull(def0) == 0 && def0.npc_count > 0 ) {
					def0::Despawn();
				}
			}
		}
	}

}
