Хорошо! Хорошо!:  0
Плохо! Плохо!:  0
Показано с 1 по 7 из 7

Тема: EK Craft

  1. #1

    По умолчанию EK Craft

    EK Craft 1.0b

    Описание
    Данная система скриптов добавляет в игру возможность создавать предметы, используя рецепты\схемы тех или иных предметов, а так же необходимые ингридиенты и ресурсы.

    Скриншоты



    Скачать демоверсию
    CraftDemo_v.1.00b (647kb)

    Внимание!!!
    Скрипт использует библиотеку RGSS102E.dll (смотрим в Game.ini). Последняя идет в комплекте с R&W Path 4.2 или выше.

    Библиотека
    Код:
    #==============================================================================
    # EK Lib v.1.3b
    #------------------------------------------------------------------------------
    # Created by: Equilibrium Keeper [equilibriumkeeper@inbox.com]
    # Created on: 11.07.2008 23:11:45
    # Отдельное спасибо: insider, Рольф
    #          А так же: rpgmaker.sk6.ru, rpg-maker.info, gdsa.rpgmaker.ru
    #==============================================================================
    # Описание: Библиотека содержит несколько наиболее часто используемых мной
    #           функций. При желании вы можете воспользоваться ими, но делайте
    #           это на свой страх и риск.
    #------------------------------------------------------------------------------
    # Установка: В редакторе скриптов создайте чистую страницу над "Main" и
    #            скопируйте туда данный скрипт.
    #==============================================================================
    class EKLib
      
      # Метод ворвращает фрагмент изображения.
      # filename :string   - имя файла, относительно папки проекта.
      # index    :integer - порядковый номер изображения
      # width    :integer - ширина фрагмента
      # height   :integer - высота фрагмента
      # Примечание: Счет ведется слева направо, сверху вниз.
      def getImagePartByIndex (filename, index, width, height)
        bitmap = Bitmap.new (filename)
        bitmap_result = Bitmap.new (width, height)
        n = bitmap.width / width
        x = (index * width - width) - ((index - 1) / n) * width * n
        y = ((index - 1) / n) * height
        rect = Rect.new(x, y, width, height)
        bitmap_result.blt(0, 0, bitmap, rect)
        return bitmap_result
      end
      
      # Метод построчно рисует заданный text на bitmap, перенося непомещающиеся слова
      # text         : string   - строка (длина не важна), которую требуется записать
      # bitmap       : bitmap   - изображение, на котором будем рисовать
      # width        : integer - максимальная надписи строк
      # x            : integer - Координата x начала первой строки
      # y            : integer - Координата y начала первой строки
      # stringheight : integer - Высота строки; -1 - высота будет высчитана автоматически
      # correct      : integer - Коректеровка длины строки (количество байт); +/-
      # fontsize     : integer - Размер шрифта. Используется только для вычеслений.
      def hyphenDrawText (text, bitmap, width, x = 20, y = 20, stringheight = -1, correct = 0, fontsize = bitmap.font.size)
        n = 0
        index = 0
        strings = []
        # Если высота строки не была задана, высчитываем ее исходя из размера шрифта
        if stringheight == -1 then stringheight = 24 - 0.2 * (24 - fontsize) end
        # Высчитываем примерное количество знаков на строку исходя из размера шрифта
        if fontsize > 24 then const = 2 else const = 6 end
        maxchar = width / fontsize * 5 - (24 - fontsize) * const + correct
        maxchar = maxchar / 2 * 2
        # Делим строку на несколько
        while n < text.size
          # Записываем в массив фрагмент строки начиная с n байта длиной maxchar байт
          strings[index] = text[n, maxchar]
          lenght = maxchar # Временная переменная для переноса слов
          # Пока на конце строки не окажется пробела или она не закончится...
          while strings[index][lenght - 1, 1] != " " && strings[index][lenght - 1, 1] != ""
            # ...урезаем строку на один байт
            lenght -= 1
            strings[index] = strings[index][0, lenght]
          end
          n += lenght - 1 # Задаем новый начальный байт для следующей строки
          index += 1 # Переходим к следующему элементу массива
        end
        for i in 0..strings.size - 1
          # Отрезаем пробелы в начале строки
          if strings[i][0, 1] == " " then strings[i] = strings[i][1, strings[i].size] end
          # Записываем все получившиеся строки на понравившийся bitmap
          bitmap.draw_text(x, y + stringheight * i, width, stringheight, strings[i])
        end
      end
      
      # Метод рисует геометрические фигуры на заданном изображении
      # bitmap : bitmap - изображение, на котором будем рисовать
      # type   : string - тип фигуры, которую будем рисовать
      # color  : color  - цвет, который будем использовать, к примеру Color.new(255,255,255,255)
      # Прочие параметры изменяются от фигуры к фигуре - смотрим скрипт
      # Доступные типы фигур: square => квадрат;
      def drawFigure (bitmap, type, color, param1 = 0, param2 = 0, param3 = 0, param4 = 0, param5 = 0, param6 = 0)
        case type
        when "square"
          filling = param1 # : integer [0, 1] Будем ли заливать квадрат или оставим его пустым
          gauge   = param2 # : integer Толщина линии, в случае заливки принципиального значения не имеет
          x       = param3 # : integer Координата x верхнего левого угла квадрата
          y       = param4 # : integer Координата y верхнего левого угла квадрата
          width   = param5 # : integer Ширина квадрата
          height  = param6 # : integer Высота квадрата
          if filling != 0
            bitmap.fill_rect(x, y, width, height, color)
          else
            bitmap.fill_rect(x, y, width, gauge, color)
            bitmap.fill_rect(x, y, gauge, height, color)
            bitmap.fill_rect(x, y + height - gauge, width, gauge, color)
            bitmap.fill_rect(x + width - gauge, y, gauge, height, color)
          end
        end
      end
       
    end
    Craft
    Код:
    #==============================================================================
    # EK Craft v.1.0b
    #------------------------------------------------------------------------------
    # Created by: Equilibrium Keeper [equilibriumkeeper@inbox.com]
    # Created on: 11.07.2008 23:11:45
    # Отдельное спасибо: insider, Рольф
    #          А так же: rpgmaker.sk6.ru, rpg-maker.info, gdsa.rpgmaker.ru
    #==============================================================================
    # Описание: Данная система скриптов добавляет в игру возможность создавать
    #           предметы, используя рецепты\схемы тех или иных предметов, а так
    #           же необходимые ингридиенты и ресурсы.
    #------------------------------------------------------------------------------
    # Примечание: Это мой третий скрипт и он весьма сырой. О всех найденных багах,
    #             а так же свои предложения по улучшению работы скрипта вы можете
    #             присылать мне на e-mail, icq(496300614) или в приват. Любая
    #             помощь приветствуется!
    #             Профессия чароплет не работает!
    #------------------------------------------------------------------------------
    # Установка: В редакторе скриптов создайте чистые страницы над "Main" и
    #            скопируйте туда в них скрипты, не нарушая их порядок следования.
    #            При желании вы можете объединить все скрипты в один.
    #------------------------------------------------------------------------------
    # Настройка: Скрипт писался с расчетом запуска из главного меню, однако вы можете
    #            вызвать его в любой момент, вставив тому или иному событию следующий
    #            Script: $scene = Scene_Craft.new
    #    Что бы добавить новый рецепт, вам необходимо создать новый массив в уже
    # существующем массиве RECIPES. Его структура:у вы можете посмотреть в RECIPES_CONSTRUCTION.
    # Так же посмотрите уже готовые рецепты. Тоже касается прочих предметов - читайте
    # описания соответсвующих массивов ниже. Задавайте вопросы.
    #==============================================================================
    
    module Craft
      
      MAX_VALUE = 50 # Максимальное значение для уровня профессии
      
      # Примерная структура рецепта. Подробнее - смотрите примеры.
      RECIPES_CONSTRUCTION = [
        "RECIPE_ID",
        ["PROFESSION", "PROFESSION_POINT"],
        [["TOOL1_ID", "TOOL1_ALT1_ID", "TOOL1_ALT2_ID", "...."], ["TOOL2"], ["TOOL3"], ["TOOL4"]],
        ["INPUT_TYPE", "OUTPUT_TYPE", "OUTPUT_ID"],
        [["RESOURCE1_ID", "RSOURCE1_ALT1_ID, ...."], ["RESOURCE2_ID"], ["RESOURCE3_ID"], ["RESOURCE4_ID"]],
        [["RESOURCE1_AMOUNT", ], ["RESOURCE2_AMOUNT"], ["RESOURCE3_AMOUNT"], ["RESOURCE4_AMOUNT"]],
        "ICON", "DESCRIPTION"
      ]
      # [0] - Список всех профессий.
      # [x][0] - Профессиональные навыки персонажа с ID = x
      # [x][1] - Прогресс (0 - 100) получения профессиональных навыков персонажа с ID = x
      # [x][0][z] - Навык персонажа с id [x] в профессии [z]
      PROFESSIONS = [
       ["Кузнец", "Плотник", "Кожевник", "Портной", "Ювелир", "Чароплет", "Алхимик", "Повар"],
       [[1, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],
       [[1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],
       [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],
       [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],
       [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],
       [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],
       [[0, 0, 0, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]],
       [[0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]
      ]
      # [0] - ID рецепта
      # [1][0] - ID требуемой профессии
      # [1][1] - Необходимое значение требуемой профессии
      # [2][x][z] - Инструмент № [x] (0-3) и ID его и его заменяющих из массива [z]
      # [3][0] - Тип ресурсов (пока возможно только RPG::Item)
      # [3][1] - Тип результата (PRG::Item, RPG::Armor, RPG::Weapon)
      # [3][2] - ID результата.
      # [4][x][z] - Ресурс № [x] (0-3) и ID его и его заменяющих из массива [z]
      # [5][x][z] - Ресурс № [x] (0-3) и количество его и его заменяющих из массива [z]
      # [6] - Номер иконки (Graphics\Icons\craft_?????_recipes.png)
      # [7] - Описание рецепта
      RECIPES = [
        [34, [6, 1], [[37]], [RPG::Item, RPG::Item, 45], [[35], [36]], [[1], [3]], 1, "Рецепт зелья в народе известного, как \"Панацея\". Его можно приготовить практически из любых целебных растений, если под рукой есть ступка с пестиком да пустая бутылка... Вот только эффект такого зелья сильно разнится от мастерства алхимика и использованных реагентов..."],
        [49, [0, 1], [[39, 40, 41], [42, 43, 44]], [RPG::Item, RPG::Armor, 34], [[46, 47, 48]], [[10, 8, 4]], 1, "Чертееж для изготовления металлической кирасы... На длинное описание меня не хватает - спать хочу."],
        [50, [0, 3], [[39, 40, 41], [42, 43, 44]], [RPG::Item, RPG::Weapon, 34], [[46, 47, 48], [51, 52, 53]], [[15, 12, 6], [5, 4, 2]], 1, "Чертееж для изготовления металлического боевого молота... На длинное описание меня не хватает - спать хочу."]
      ]
      # [0] - ID инструмента
      # [1] - Ценность\качество\полезность\бонус инструмента - не работает(!)
      # [2] - Надежность\прочность инструмента
      # [3] - Номер иконки (Graphics\Icons\craft_?????_tools.png)
      # [4] - Описание инструмента
      TOOLS = [
        [37, 5, 50, 7, "Предмет необходимый любому алхимику. Правда, стоит задуматься о лучшем материале - в таких разве что крысиный яд готовить... или лечебные зелья для не притязательных воинов..."],
        [39, 5, 40, 1, "Наковальня - без нее кузнецу никуда. Правда стоит задуматься о лучшем материале..."],
        [40, 10, 60, 2, "Наковальня - без нее кузнецу никуда. Такая не развалится после пары ударов, но и ждать от нее чего-то большего не стоит..."],
        [41, 20, 90, 3, "Наковальня - без нее кузнецу никуда. Нужно приложить не мало усилий, что бы сломать ТАКОЙ инструмент..."],
        [42, 5, 40, 4, "Молот. Кузнечный. Бронза. Спать хочу. -_-"],
        [43, 5, 60, 5, "Молот. Кузнечный. Железо. Спать хочу. -_-"],
        [44, 5, 90, 6, "Молот. Кузнечный. Сталь. Спать хочу. -_-"]
      ]
      # [0] - ID ресурса
      # [1] - Ценность\качество\полезность\бонус инструмента - не работает(!)
      # [2] - Номер иконки (Graphics\Icons\craft_?????_resources.png)
      # [3] - Описание инструмента
      RESOURCES = [
        [35, 5, 1, "Самая обыкновенная бутылка для разливки и хранения различных жидкостей. Небольшой объем и низкокачественное тонкое стекло... Придется хорошенько поискать, что бы найти емкость хуже этой."],
        [36, 5, 2, "Селиановый лист, как нетрудно догодаться, растет на дереве \"селиана\", которое, как считают в народе, уходит корнями глубоко под землю, где напивается целительной влагой из источника жизни. Слухи эти остаются слухами, но тем не менее листья этого дерева обладают некоторыми целебными свойствами и в руках опытного алхимика способны спасти кому-нибудь жизнь..."],
        [46, 5, 3, "Кусок бронзы - не самый лучший выбор для кузнеца."],
        [47, 10, 4, "Кусок железа - из этого уже можно попробовать что-нибудь выковать."],
        [48, 20, 5, "Кусок стали - прекрасный материал для ковки, испортить его могут только кривые руки."],
        [51, 5, 6, "Ивовая древесина безспорно хороша... когда нужна палка для храмого колеки, но не для изготовления оружия!"],
        [52, 10, 6, "Из тополя можно сделать неплохую палку. Этой палкой можно кого-нибудь хорошенько приложить..."],
        [53, 20, 6, "Дуб - прекрасный материал, как для рукоятий молотов, так и для изготовления боевых луков!"]
      ]
      # [0] - ID предмета
      # [1] - Номер иконки (Graphics\Icons\items_?????.png)
      # [2] - Описание предмета
      ITEMS = [
        [45, 1, "Зелье, способное исцелять самые тяжелые недуги за считанные мгновения..."]
      ]
      # [0] - ID оружия
      # [1] - Номер иконки (Graphics\Icons\weapons_?????.png)
      # [2] - Описание оружия
      WEAPONS = [
        [34, 1, "Мега-молот сделанный криворукими персами по кривым скриптам крафта"]
      ]
      # [0] - ID экипировки
      # [1] - Номер иконки (Graphics\Icons\armors_?????.png)
      # [2] - Описание экипировки
      ARMORS = [
        [34, 1, "Мега-кираса сделанная криворукими персами по кривым скриптам крафта"]
      ]
      
    end
    Craft_Scenes
    Код:
    #==============================================================================
    # EK Craft v.1.0b
    #------------------------------------------------------------------------------
    # Created by: Equilibrium Keeper [equilibriumkeeper@inbox.com]
    # Created on: 11.07.2008 23:11:45
    # Отдельное спасибо: insider, Рольф
    #          А так же: rpgmaker.sk6.ru, rpg-maker.info, gdsa.rpgmaker.ru
    #==============================================================================
    # Описание: Подробнее смотрим Craft
    #==============================================================================
    
    class Scene_Craft
      
      $fontface = "Arial" # Не требуется, если стоит R&W Path версии 4.2 или выше
      $fontsize = 24      # Не требуется, если стоит R&W Path версии 4.2 или выше
      #--------------------------------------------------------------------------
      def main
        # --- Подключаем библиотеку ---
        @EKLib = EKLib.new
        # -----------------------------
        # Создаем главное меню
        @main_menu_items = [["Создать", "Рецепты", "Инструменты", "Ресурсы"], ["Создать предмет по рецепту", "Просмотреть список рецептов", "Просмотреть список инструментов", "Просмотреть список ресурсов"], ["recipes", "recipes", "tools", "resources"]]
        @main_menu = Window_Command.new (160, @main_menu_items[0])
        @main_menu.y = 480 - @main_menu.height
        @main_menu_index = @main_menu.index
        # Создаем список персонажей
        @actor_list = Window_PartyList.new (0, 0, 160, 480 - @main_menu.height)
        @actor_list.active = false
        # Инициализация списка профессий
        @professions_menu = Window_Professions.new (200, 0)
        @professions_menu.dispose
        # Создаем окно помощи
        @help_window = Window_Help.new (@actor_list.width, 0, 640 - @actor_list.width)
        # Создаем окно предметов
        @item_window = Window_Item.new (@actor_list.width, @help_window.height, 640 - @actor_list.width, 480 - @help_window.height, 1, "recipes")
        @item_window.help_window = @help_window
        @item_window.active = false
        # Создаем окно информации о предмете
        @item_info = Window_ItemInfo.new ($data_items[Craft::RESOURCES[0][0]], @actor_list.width, 0, 640 - @actor_list.width)
        @item_info.active = false
        @item_info.visible = false
        # Создаем окно крафта
        @craft_window = Window_Craft.new (0, 0, @actor_list.width, @help_window.height, 640 - @actor_list.width, 480 - @help_window.height)
        @craft_window.help_window = @help_window
        @craft_window.active = false
        @craft_window.visible = false
        # Создаем окно-сообщение о поломке инструмнта
        @craft_end_window = Window_CraftEnd.new
        @craft_end_window.active = false
        @craft_end_window.visible = false
        
        Graphics.transition
        
        loop do
          Graphics.update
          Input.update
          update
          if $scene != self
            break
          end
        end
        dispose    
      end
      #--------------------------------------------------------------------------
      def dispose
        Graphics.freeze
        @main_menu.dispose
        @actor_list.dispose
        @help_window.dispose
        @item_window.dispose
        @item_info.dispose
        @craft_window.dispose
        @craft_end_window.dispose
      end
      #--------------------------------------------------------------------------
      def update
        if @main_menu.active
          @main_menu.update
          update_main_menu
        elsif @actor_list.active
          @actor_list.update
          update_actor_list
        elsif !@professions_menu.disposed?
          @professions_menu.update
          update_professions_menu
        elsif @item_window.active
          @help_window.update
          @item_window.update
          update_item_window
        elsif @item_info.active
          update_item_info
        elsif @craft_window.active
          @craft_window.update
          update_craft_window
        elsif @craft_end_window.active
          @craft_end_window.update
          update_craft_end_window
        end
        return
      end
      #--------------------------------------------------------------------------
      def update_main_menu
        if Input.trigger?(Input::B)
          $game_system.se_play($data_system.cancel_se)
          $scene = Scene_Menu.new(0)
          return
        elsif Input.trigger?(Input::C)
          $game_system.se_play($data_system.decision_se)
          @main_menu.active = false
          if @main_menu.index == 0
            @actor_list.active = true
            @actor_list.index = 0
          else
            $game_system.se_play($data_system.decision_se)
            @item_window.active = true
          end
          return
        end
        if @main_menu_index != @main_menu.index
          @item_window.type = @main_menu_items[2][@main_menu.index]
          @item_window.refresh
          @item_window.index = 0
          @main_menu_index = @main_menu.index
        end
        if @help_window.text != @main_menu_items[1][@main_menu.index]
          @help_window.set_text(@main_menu_items[1][@main_menu.index])
        end
      end
      #--------------------------------------------------------------------------
      def update_actor_list
        if Input.trigger?(Input::B)
          $game_system.se_play($data_system.cancel_se)      
          @actor_list.active = false
          @actor_list.index = -1
          @main_menu.active = true
        elsif Input.trigger?(Input::C)
          $game_system.se_play($data_system.decision_se)
          @actor_list.active = false
          @professions_menu = Window_Professions.new (200, @actor_list.index)
        end
        return
      end
      #--------------------------------------------------------------------------
      def update_professions_menu
        if Input.trigger?(Input::B)
          $game_system.se_play($data_system.cancel_se)      
          @professions_menu.dispose
          @actor_list.active = true
          return
        end
        if Input.trigger?(Input::C)
          if Craft::PROFESSIONS[$game_party.actors[@actor_list.index].id][0][@professions_menu.index] == 0
            $game_system.se_play($data_system.buzzer_se)
            return
          end
          $game_system.se_play($data_system.decision_se)
          @professions_menu.dispose
          @item_window.type = "recipes"
          @item_window.subtype = @professions_menu.index
          @item_window.refresh
          @item_window.index = 0
          @item_window.active = true      
          return
        end
      end
      #--------------------------------------------------------------------------
      def update_item_window
        if Input.trigger?(Input::B)
          $game_system.se_play($data_system.cancel_se)
          @item_window.active = false
          if @main_menu.index == 0
            if @craft_end_window.index != - 1
              @craft_window.index = -1
              @craft_end_window.index = -1
            end
            if @craft_window.index == -1
              @item_window.type = "recipes"
              @item_window.subtype = -1
              @item_window.refresh
              @item_window.index = 0
              @actor_list.active = true
            else
              @item_window.active = false
              @craft_window.visible = true
              @craft_window.active = true
            end
          else
            @main_menu.active = true
          end
          return
        end
        if Input.trigger?(Input::C)
          if @item_window.item == nil
            $game_system.se_play($data_system.buzzer_se)
            return
          end
          if @main_menu_index == 0
            if @craft_window.index == -1
              $game_system.se_play($data_system.decision_se)
              @item_window.active = false
              @craft_window.recipe = @item_window.item
              @craft_window.actor = $game_party.actors[@actor_list.index]
              @craft_window.refresh
              @craft_window.visible = true
              @craft_window.active = true
              @craft_window.index = 0
            elsif @craft_window.index != -1 || @craft_end_window.index != - 1
              if @item_window.disabled_items.include?(@item_window.index)
                $game_system.se_play($data_system.buzzer_se)
              else
                $game_system.se_play($data_system.decision_se)
                @item_window.active = false
                if @craft_end_window.index != - 1
                  @craft_window.set_item(@item_window.item, @craft_end_window.success[2])
                  @item_window.type = "recipes"
                  @item_window.refresh
                  @item_window.index = 0
                  @craft_end_window.index = -1
                  begin_craft
                else
                  @craft_window.set_item(@item_window.item)
                  @craft_window.visible = true
                  @craft_window.active = true
                  @item_window.type = "recipes"
                  @item_window.refresh
                  @item_window.index = 0
                end
              end
            end
          else        
            $game_system.se_play($data_system.decision_se)
            @item_window.active = false
            @item_info.item = @item_window.item
            @item_info.update
            @item_info.active = true
            @item_info.visible = true
          end
          return
        end
      end
      #--------------------------------------------------------------------------
      def update_item_info
        if Input.trigger?(Input::B) || Input.trigger?(Input::C)
          $game_system.se_play($data_system.cancel_se)      
          @item_info.active = false
          @item_info.visible = false
          @item_window.active = true
          return
        end    
      end
      #--------------------------------------------------------------------------
      def update_craft_window
        if Input.trigger?(Input::B)
          $game_system.se_play($data_system.cancel_se)
          @item_window.type = "recipes"
          @item_window.subtype = @professions_menu.index
          @item_window.refresh
          @item_window.index = 0
          @craft_window.active = false
          @craft_window.visible = false
          @craft_window.index = -1
          @item_window.active = true
          return
        end
        if Input.trigger?(Input::C)
          if @craft_window.index == 8
            if @craft_window.items.size == 0
              $game_system.se_play($data_system.buzzer_se)
              return
            else
              for i in 0..@craft_window.item_max - 2
                if @craft_window.items[i] == nil && @craft_window.enabled?(i)
                  $game_system.se_play($data_system.buzzer_se)
                  return
                end
              end        
            end
            begin_craft
          elsif !@craft_window.enabled?(@craft_window.index)
            $game_system.se_play($data_system.buzzer_se)
            return
          else
            for i in 0..Craft::RECIPES.size - 1
              if Craft::RECIPES[i][0] == @craft_window.recipe.id then break end
              end
              if @craft_window.index <= 3
                @item_window.type = [Craft::RECIPES[i][2][@craft_window.index], "tools"]
              else
                @item_window.type = [
                  Craft::RECIPES[i][4][@craft_window.index - 4],
                  Craft::RECIPES[i][5][@craft_window.index - 4]
                ]
              end
            if @craft_window.index < 3
              @item_window.min_quantity = 1
            else
              @item_window.min_quantity = Craft::RECIPES[i][5][@craft_window.index - 4 * (@craft_window.index / 4)]
            end
            @item_window.refresh
            @item_window.index = 0
            @item_window.min_quantity = -1
            @craft_window.active = false
            @craft_window.visible = false
            @item_window.active = true
          end
          return
        end
      end
      #--------------------------------------------------------------------------
      def update_craft_end_window
        if Input.trigger?(Input::B)
          if @craft_end_window.success[0] == false
            if @craft_end_window.success[1] == "tool" then @craft_end_window.burn end
            $game_system.se_play($data_system.cancel_se)
            @craft_end_window.active = false
            @craft_end_window.visible = false
            @craft_end_window.index = -1
            @item_window.type = "recipes"
            @item_window.subtype = @professions_menu.index
            @item_window.refresh
            @craft_window.index = -1
            @item_window.index = 0
            @item_window.active = true
            return
          end
        end
        if Input.trigger?(Input::C)
          if @craft_end_window.success[0] == false && @craft_end_window.success[1] == "tool"
            if @craft_end_window.index == 0          
              @item_window.type = [@craft_end_window.recipe[2][@craft_end_window.success[2]], "tool"]
              @item_window.min_quantity = -1
              @item_window.refresh
              @item_window.index = 0          
              @craft_end_window.active = false
              @craft_end_window.visible = false
              @item_window.active = true
            elsif @craft_end_window.index == 1
              $game_system.se_play($data_system.cancel_se)
              @craft_end_window.burn
              @craft_end_window.active = false
              @craft_end_window.visible = false
              @craft_end_window.index = -1
              @craft_window.index = -1
              @item_window.type = "recipes"
              @item_window.subtype = @professions_menu.index
              @item_window.refresh
              @item_window.index = 0
              @item_window.active = true
              return
            end
          elsif @craft_end_window.success[0] == false && @craft_end_window.success[1] == "resources"
            if @craft_end_window.disabled.include?(@craft_end_window.index)
              $game_system.se_play($data_system.buzzer_se)
              return
            end
            @craft_end_window.active = false
            @craft_end_window.visible = false
            if @craft_end_window.index == 0
              @craft_end_window.index = -1
              begin_craft
            else
              @craft_end_window.index = -1
              $game_system.se_play($data_system.cancel_se)
              @craft_window.index = -1
              @item_window.type = "recipes"
              @item_window.subtype = @professions_menu.index
              @item_window.refresh
              @item_window.index = 0
              @item_window.active = true          
            end
          else
            if @craft_end_window.disabled.include?(@craft_end_window.index)
              $game_system.se_play($data_system.buzzer_se)
              return
            end
            @craft_end_window.active = false
            @craft_end_window.visible = false
            if @craft_end_window.index == 0
              @craft_end_window.index = -1
              begin_craft
            else
              @craft_end_window.index = -1
              $game_system.se_play($data_system.cancel_se)
              @craft_window.index = -1
              @item_window.type = "recipes"
              @item_window.subtype = @professions_menu.index
              @item_window.refresh
              @item_window.index = 0
              @item_window.active = true          
            end
          end
        end
      end
      #--------------------------------------------------------------------------
      def begin_craft
        # Инициализация
        for i in 0..Craft::RECIPES.size - 1
          if @craft_window.recipe.id == Craft::RECIPES[i][0]
            @recipe = Craft::RECIPES[i] # Рецепт
          end
        end
        @tools = [[],[],[],[]] # Инструменты
        for i in 0..3
          @tools[i][0] = @craft_window.items[i] # Номер используемого инструмента
          if @tools[i][0] != nil # Если инструмент используется
            @tools[i][1] = Craft::TOOLS[@tools[i][0]][0] # Его ID
            @tools[i][2] = Craft::TOOLS[@tools[i][0]][1] # Его качество
            @tools[i][3] = Craft::TOOLS[@tools[i][0]][2] # Его надежность
            @tools[i][4] = Craft::TOOLS[@tools[i][0]][3] # Его иконка
          end
        end
        @resources = [[],[],[],[]] # Ресурсы
        for i in 4..7
          @resources[i - 4][0] = @craft_window.items[i] # Номер используемых ресурсов
          if @resources[i - 4][0] != nil # Если ресурсы используются
            @resources[i - 4][1] = Craft::RESOURCES[@resources[i - 4][0]][0] # Их ID
            @resources[i - 4][2] = Craft::RESOURCES[@resources[i - 4][0]][1] # Их качество
            @resources[i - 4][3] = Craft::RESOURCES[@resources[i - 4][0]][2] # Их иконка
          end
        end
        @actor = $game_party.actors[@actor_list.index] # Крафтер
        @actor_skill = Craft::PROFESSIONS[@actor.id][0][@professions_menu.index] # Навык крафтера
        # Отключаем окно крафта
        @craft_window.visible = false
        @craft_window.active = false
        # Передаем рецепт и ресурсы конечному окну
        @craft_end_window.recipe = @recipe
        @craft_end_window.resources = @resources
        # Ломаем оборудование
        for i in 0..3
          if @tools[i][0] == nil then break end
          chance = @tools[i][3] + @actor_skill / 5 + @actor.level / 10
          if chance > 95 then chance = 95 end
          if rand(100) + 1 > chance
            Audio.se_play("Audio/SE/057-Wrong01")
            $game_party.lose_item(@tools[i][1], 1)
            @craft_end_window.success = [false, "tool", i]
            @craft_end_window.tool = @tools[i]
            @craft_end_window.refresh
            @craft_end_window.visible = true
            @craft_end_window.active = true
            @craft_end_window.index = 0
            give_prof_exp
            return
          end
        end
        @craft_end_window.tool = -1
        # Портим ресурсы
        chance = @actor_skill / @recipe[1][1] * 75
        if @actor_skill < @recipe[1][1] / 2
          chance = 1
        elsif chance > 95 then chance = 95 end
        if rand(100) + 1 > chance
          Audio.se_play("Audio/SE/057-Wrong01")
          @craft_end_window.burn
          @craft_end_window.success = [false, "resources"]
          @craft_end_window.refresh
          @craft_end_window.visible = true
          @craft_end_window.active = true
          @craft_end_window.index = 0
          give_prof_exp
          return
        end
        # Выдаем результат
        Audio.se_play("Audio/SE/120-Ice01")
        @craft_end_window.success = [true]
        @craft_end_window.give_item
        @craft_end_window.burn
        give_prof_exp
        @craft_end_window.refresh
        @craft_end_window.visible = true
        @craft_end_window.active = true
        @craft_end_window.index = 0
        return
      end
      #--------------------------------------------------------------------------
      def give_prof_exp
        if @craft_end_window.success[0] == false
          Craft::PROFESSIONS[@actor.id][1][@professions_menu.index] += 1
        else
          plus = (@recipe[1][1].to_f / @actor_skill.to_f * 10).round
          Craft::PROFESSIONS[@actor.id][1][@professions_menu.index] += plus
        end
        if Craft::PROFESSIONS[@actor.id][1][@professions_menu.index] >= 100
          Craft::PROFESSIONS[@actor.id][1][@professions_menu.index] -= 100
          Craft::PROFESSIONS[@actor.id][0][@professions_menu.index] += 1
        end
      end
      #--------------------------------------------------------------------------
    end
    Craft_WindowsNew
    Код:
    #==============================================================================
    # EK Craft v.1.0b
    #------------------------------------------------------------------------------
    # Created by: Equilibrium Keeper [equilibriumkeeper@inbox.com]
    # Created on: 11.07.2008 23:11:45
    # Отдельное спасибо: insider, Рольф
    #          А так же: rpgmaker.sk6.ru, rpg-maker.info, gdsa.rpgmaker.ru
    #==============================================================================
    # Описание: Подробнее смотрим Craft
    #==============================================================================
    
    class Window_PartyList < Window_Selectable
      #--------------------------------------------------------------------------
      def initialize (x = 0, y = 0, width = 160, height = 128)
        super(x, y, width, height)
        self.contents = Bitmap.new(width - 32, height - 32)
        self.contents.font.name = $fontface
        self.contents.font.size = $fontsize
        refresh
        self.active = false
        self.index = -1
      end
      #--------------------------------------------------------------------------
      def refresh
        self.contents.clear
        @item_max = $game_party.actors.size
        for i in 0...$game_party.actors.size
          x = 64
          y = i * 72
          actor = $game_party.actors[i]
          draw_actor_graphic(actor, x - 40, y + 60)
          draw_actor_name(actor, x, y)
        end
      end
      #--------------------------------------------------------------------------
      def update_cursor_rect
        if @index < 0
          self.cursor_rect.empty
        else
          self.cursor_rect.set(0, @index * 72, self.width - 32, 72)
        end
      end
    end
    #==============================================================================
    
    class Window_ItemInfo < Window_Base
      #--------------------------------------------------------------------------
      attr_accessor :item  
      #--------------------------------------------------------------------------
      def initialize (item, x = 340, y = 0, width = 300, height = 480)
        # --- Подключаем библиотеку ---
        @EKLib = EKLib.new
        # -----------------------------
        super(x, y, width, height)
        self.contents = Bitmap.new(width - 32, height - 32)
        self.contents.font.name = $fontface
        @fontsize = [24, 20, 24, 20]
        @fontcolor = [Color.new(255, 255, 255, 255)]
        self.z += 10
        @item = item
    
        update
      end
      #--------------------------------------------------------------------------
      def update
        self.contents.clear
        # Ищем предмет в массивах, записываем его тип и порядковый номер в массиве
        for i in 0..Craft::RECIPES.size - 1
          if Craft::RECIPES[i][0] == @item.id
            @type = "recipes"
            @index = i
            @icon = Craft::RECIPES[i][6]
            break
          end
        end
        for i in 0..Craft::TOOLS.size - 1
          if Craft::TOOLS[i][0] == @item.id
            @type = "tools"
            @index = i
            @icon = Craft::TOOLS[i][3]
            break
          end
        end
        for i in 0..Craft::RESOURCES.size - 1
          if Craft::RESOURCES[i][0] == @item.id
            @type = "resources"
            @index = i
            @icon = Craft::RESOURCES[i][2]
            break
          end
        end
        # Рисуем изображение предмета
        @filename = "Graphics/Icons/craft_large_" + @type
        bitmap = @EKLib.getImagePartByIndex(@filename, @icon, 100, 100)
        self.contents.blt(10, 20, bitmap, Rect.new(0, 0, 100, 100))
        @EKLib.drawFigure(self.contents, "square", Color.new(255,255,255,255), 0, 2, 10, 20, 100, 100)
        # Пишем название предмета
        self.contents.font.size = @fontsize[0]
        self.contents.draw_text (120, 20, @item.name.size * 8, 32, @item.name)  
        
        if @type == "recipes"
          # Ищем и записываем сведения о требуемой профессии
          self.contents.font.size = @fontsize[1]
          @professions = "Требования: " + Craft::PROFESSIONS[0][Craft::RECIPES[@index][1][0]] + " (" + Craft::RECIPES[@index][1][1].to_s + ")"
          self.contents.draw_text (120, 48, self.width - 160, 32, @professions)
          # Ищем и рисуем необходимые инструменты
          self.contents.draw_text(10, 134, self.width - 40, 32, "инструменты")
          for i in 0..Craft::RECIPES[@index][2].size - 1
            for n in 0..Craft::TOOLS.size - 1
              if Craft::TOOLS[n][0] == Craft::RECIPES[@index][2][i][0]
                @icon = Craft::TOOLS[n][3]
                @filename = "Graphics/Icons/craft_small_tools"
                bitmap = @EKLib.getImagePartByIndex(@filename, @icon, 24, 24)
                self.contents.blt(10 + 27 * i, 164, bitmap, Rect.new(0, 0, 100, 100))
                @EKLib.drawFigure(self.contents, "square", Color.new(255,255,255,255), 0, 2, 10 + 27 * i, 164, 24, 24)
                break
              end
            end
          end
          # Ищем и рисуем необходимые ресурсы
          self.contents.draw_text(270, 134, self.width - 40, 32, "ресурсы")
          for i in 0..Craft::RECIPES[@index][4].size - 1
            for n in 0..Craft::RESOURCES.size - 1
              if Craft::RESOURCES[n][0] == Craft::RECIPES[@index][4][i][0]
                @icon = Craft::RESOURCES[n][2]
                @filename = "Graphics/Icons/craft_small_resources"
                bitmap = @EKLib.getImagePartByIndex(@filename, @icon, 24, 24)
                self.contents.blt(202 + 57 * i, 164, bitmap, Rect.new(0, 0, 100, 100))
                @EKLib.drawFigure(self.contents, "square", Color.new(255,255,255,255), 0, 2, 202 + 57 * i, 164, 24, 24)
                # ... и их количество
                amount = "x" + Craft::RECIPES[@index][5][i].to_s
                self.contents.draw_text(230 + 57 * i, 164, 24, 32, amount)
                break
              end
            end
          end
          # Рисуем надпись: "Описание"
          x = self.width / 2 - "Описание".size * 4
          self.contents.font.size = @fontsize[2]
          self.contents.draw_text (x, 200, "Описание".size * 8, 32, "Описание")
          # Ищем и записываем описание предмета
          self.contents.font.size = @fontsize[3]
          @EKLib.hyphenDrawText (Craft::RECIPES[@index][7], self.contents, self.width - 60, 10, 232)
        else
          if @type == "tools"
            @array = Craft::TOOLS[@index]
            @array_index = 2
          else
            @array = Craft::RESOURCES[@index]
            @array_index = 4
          end
          # Ищем и записываем - где используется предмет или инструмент
          @data = []
          @professions = ""
          for i in 0..Craft::RECIPES.size - 1
            for n in 0..Craft::RECIPES[i][@array_index].size - 1
              if Craft::RECIPES[i][@array_index][n].include?(@array[0])
                unless @data.include?(Craft::PROFESSIONS[0][Craft::RECIPES[i][1][0]])
                  @data.push(Craft::PROFESSIONS[0][Craft::RECIPES[i][1][0]])
                end
              end
            end
          end
          for i in 0..@data.size - 1
            @professions += @data[i]
            if i != @data.size - 1 then @professions += ", " end
          end
            @professions = "Используют: " + "\n" + @professions
            self.contents.font.size = @fontsize[1]
            self.contents.draw_text (120, 48, self.width - 160, 32, @professions)
            # Ищем и записываем информацию о качестве предмета
            self.contents.draw_text (120, 72, self.width - 160, 32, "Ценность: " + quality(@array[1]))
            # Ищем и записываем информацию о надежности инструмента
            if @type == "tools"
              self.contents.draw_text (120, 96, self.width - 160, 32, "Надежность: " + quality(@array[2]))
            end        
            # Рисуем надпись: "Описание"
            x = self.width / 2 - "Описание".size * 4
            self.contents.font.size = @fontsize[2]
            self.contents.draw_text (x, 144, "Описание".size * 8, 32, "Описание")
            # Ищем и записываем описание предмета
            if @type == "tools" then n = 4 else n = 3 end
            self.contents.font.size = @fontsize[3]
            @EKLib.hyphenDrawText (@array[n], self.contents, self.width - 60, 10, 176)
        end
        
      end
      #--------------------------------------------------------------------------
      def quality (int)
        result = "Неизвестна"
        case int
        when 0 then result = "Очень низкая"
        when 1..20 then result = "Низкая"
        when 21..40 then result = "Ниже средней"
        when 41..60 then result = "Средняя"
        when 61..70 then result = "Выше средней"
        when 71..80 then result = "Высокая"
        when 81..90 then result = "Очень высокая"
        when 91..100 then result = "Огромная"
        end
      end
    end
    #==============================================================================
    
    class Window_Professions < Window_Selectable
      #--------------------------------------------------------------------------
      def initialize(width, party_index)
        @commands = Craft::PROFESSIONS[0]
        @party_index = party_index
        x = 80
        y = (20 + @party_index * 80) - @party_index * @commands.size * 4
        super(x, y, width, @commands.size * 32 + 32)   
        @item_max = @commands.size
        self.contents = Bitmap.new(width - 32, @item_max * 32)
        self.contents.font.name = $fontface
        self.contents.font.size = $fontsize
        self.z += 10
        refresh
        self.index = 0
      end
      #--------------------------------------------------------------------------
      def refresh
        self.contents.clear
        for i in 0...@item_max
          if Craft::PROFESSIONS[$game_party.actors[@party_index].id][0][i] > 0
            draw_item(i, normal_color)
          else
            draw_item(i, disabled_color)
          end
        end
      end
      #--------------------------------------------------------------------------
      def draw_item(index, color)
        self.contents.font.color = color
        rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
        self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
        percent = (Craft::PROFESSIONS[$game_party.actors[@party_index].id][0][index].to_f / Craft::MAX_VALUE.to_f * 100).round
        if Craft::PROFESSIONS[$game_party.actors[@party_index].id][0][index] > 0 && percent == 0
          percent += 1
        end
        name = @commands[index] + " (" + percent.to_s + "%)"
        self.contents.draw_text(rect, name)    
      end
      #--------------------------------------------------------------------------
    end
    #==============================================================================
    
    class Window_Craft < Window_Selectable
      #--------------------------------------------------------------------------
      attr_accessor :recipe
      attr_accessor :actor
      attr_accessor :items
      attr_reader   :item_max
      #--------------------------------------------------------------------------
      def initialize (recipe, actor, x = 0, y = 0, width = 640, height = 480)
        super (x, y, width, height)
        # --- Подключаем библиотеку ---
        @EKLib = EKLib.new
        # -----------------------------
        self.contents = Bitmap.new (width - 32, height - 32)
        @fontfaces = [$fontface]
        @fontsizes = [$fontsize, 24, 20, 20, 24]
        @item_max = 9
        item_max = @item_max
        @column_max = 4
        self.z += 10
        @recipe = recipe
        @actor = actor
        @enabled = []
        @items = []
      end
      #--------------------------------------------------------------------------
      def refresh
        # Чистим себя на случай, если окно уже обновлялось
        self.contents.clear
        @enabled.clear
        @items.clear
        # Ищим рецепт в массиве рецептов
        for i in 0..Craft::RECIPES.size - 1
          if Craft::RECIPES[i][0] == @recipe.id
            @recipe_index = i
            break
          end
        end
        # Рисуем изображение рецепта
        bitmap = @EKLib.getImagePartByIndex("Graphics/Icons/craft_medium_recipes", Craft::RECIPES[@recipe_index][6], 50, 50)
        self.contents.blt(10, 20, bitmap, Rect.new(0, 0, 50, 50))
        @EKLib.drawFigure(self.contents, "square", Color.new(255,255,255,255), 0, 2, 10, 20, 50, 50)
        # Рисуем изображение создаваемого предмета
        if Craft::RECIPES[@recipe_index][3][1] == RPG::Item
          filename = "Graphics/Icons/items_medium"
          @array = Craft::ITEMS
        elsif Craft::RECIPES[@recipe_index][3][1] == RPG::Weapon
          filename = "Graphics/Icons/weapons_medium"
          @array = Craft::WEAPONS
        elsif Craft::RECIPES[@recipe_index][3][1] == RPG::Armor
          filename = "Graphics/Icons/armors_medium"
          @array = Craft::ARMORS
        end
        for i in 0..@array.size - 1
          if @array[i][0] == Craft::RECIPES[@recipe_index][3][2]
            @array_index = i
            break        
          end
        end
        if @array[@array_index][1] == 0 || @array[@array_index][1] == nil
          icon_index = Craft::RECIPES[@recipe_index][3][2]
        else
          icon_index = @array[@array_index][1]
        end
        bitmap = @EKLib.getImagePartByIndex(filename, icon_index, 50, 50)
        self.contents.blt(self.width - 100, 20, bitmap, Rect.new(0, 0, 50, 50))
        @EKLib.drawFigure(self.contents, "square", Color.new(255,255,255,255), 0, 2, self.width - 100, 20, 50, 50)
        # Записываем название рецепта
        self.contents.font.size = @fontsizes[1]
        self.contents.draw_text (100, 20, self.width - 200, 32, @recipe.name)
        # Записываем требования к профессии
        @actor_skill = Craft::PROFESSIONS[@actor.id][0][Craft::RECIPES[@recipe_index][1][0]]
        if @actor_skill < Craft::RECIPES[@recipe_index][1][1] / 2
          @color = Color.new(0, 0, 0, 255)
        elsif @actor_skill < Craft::RECIPES[@recipe_index][1][1] / 1.5
          @color = Color.new(255, 0, 0, 255)
        elsif @actor_skill < Craft::RECIPES[@recipe_index][1][1] / 1.2
          @color = Color.new(128, 128, 0, 255)
        elsif @actor_skill < Craft::RECIPES[@recipe_index][1][1] * 1.2
          @color = Color.new(255, 255, 255, 255)
        elsif @actor_skill < Craft::RECIPES[@recipe_index][1][1] * 1.5
          @color = Color.new(0, 128, 128, 255)
        else
          @color = Color.new(0, 255, 0, 255)
        end
        self.contents.font.color = @color
        self.contents.font.size = @fontsizes[2]
        professions = "Требования: " + Craft::PROFESSIONS[0][Craft::RECIPES[@recipe_index][1][0]] + " (" + Craft::RECIPES[@recipe_index][1][1].to_s + ")"
        self.contents.draw_text (100, 48, self.width - 200, 32, professions)
        self.contents.font.color = Color.new(255, 255, 255, 255)
        # Рисуем необходимые инструменты и ресурсы
        @requirements = []
        @requirements[0] = []
        @requirements[1] = []
        for i in 0..Craft::RECIPES[@recipe_index][2].size - 1
          for n in 0..Craft::TOOLS.size - 1
            if Craft::TOOLS[n][0] == Craft::RECIPES[@recipe_index][2][i][0]
              @requirements[0][i] = n
              break
            end
          end
        end
        for i in 0..Craft::RECIPES[@recipe_index][4].size - 1
          for n in 0..Craft::RESOURCES.size - 1
            if Craft::RESOURCES[n][0] == Craft::RECIPES[@recipe_index][4][i][0]
              @requirements[1][i] = n
              break
            end
          end
        end
        for i in 0..@requirements[0].size - 1
          bitmap = @EKLib.getImagePartByIndex("Graphics/Icons/craft_medium_tools", Craft::TOOLS[@requirements[0][i]][3], 50, 50)
          self.contents.blt(10 + 86 * i, 100, bitmap, Rect.new(0, 0, 50, 50), 120)
        end
         for i in 0..@requirements[1].size - 1
          bitmap = @EKLib.getImagePartByIndex("Graphics/Icons/craft_medium_resources", Craft::RESOURCES[@requirements[1][i]][2], 50, 50)
          self.contents.blt(10 + 86 * i, 164, bitmap, Rect.new(0, 0, 50, 50), 120)
        end
        # Блокируем не используемые ячейки
        for i in 0..@item_max - 1
          if i < @item_max / 2
            if Craft::RECIPES[@recipe_index][2][i] != nil then @enabled.push(i) end
          else
            if Craft::RECIPES[@recipe_index][4][i - @item_max / 2] != nil then @enabled.push(i) end
          end
        end
        # Рисуем квадратики и заливаем не доступные
        for i in 0..@item_max - 2
          x = 10 + 86 * i - 86 * ((@item_max - 1) / 2) * (i / ((@item_max - 1) / 2))
          y = 100 + 64 * (i / ((@item_max - 1) / 2))
          @EKLib.drawFigure(self.contents, "square", Color.new(255,255,255,255), 0, 2, x, y, 50, 50)
          if !@enabled.include?(i)
            @EKLib.drawFigure(self.contents, "square", Color.new(255,0,0,50), 1, 2, x + 2, y + 2, 46, 46)
          end
        end
        # Пишем описание
        if Craft::RECIPES[@recipe_index][8] == nil || Craft::RECIPES[@recipe_index][8] == "" then n = 7 else n = 8 end
        self.contents.font.size = @fontsizes[3]
        @EKLib.hyphenDrawText(Craft::RECIPES[@recipe_index][n], self.contents, self.width - 20, 10, 228)
        # Пишем кнопку "Создать"
        self.contents.font.size = @fontsizes[4]
        self.contents.draw_text(self.width - 142, self.height - 64, 100, 32, "Создать")
      end
      #--------------------------------------------------------------------------
      def set_item(item, index = self.index)
        if index < (@item_max - 1) / 2
          array = Craft::TOOLS
          filename = "tools"
          array_index = 3
        else
          array = Craft::RESOURCES
          filename = "resources"
          array_index = 2
        end
        for i in 0..array.size - 1
          if array[i][0] == item.id then break end
        end      
        x = 10 + 86 * index - 86 * ((@item_max - 1) / 2) * (index / ((@item_max - 1) / 2))
        y = 100 + 64 * (index / ((@item_max - 1) / 2))
        bitmap = @EKLib.getImagePartByIndex("Graphics/Icons/craft_medium_" + filename, array[i][array_index], 50, 50)
        self.contents.blt(x, y, bitmap, Rect.new(0, 0, 50, 50), 255)
        @EKLib.drawFigure(self.contents, "square", Color.new(255,255,255,255), 0, 2, x, y, 50, 50)
        @items[index] = i
      end
      #--------------------------------------------------------------------------
      def enabled?(index)
        if index != false
          return @enabled.include?(index)
        else
          return @enabled.size
        end
      end
      #--------------------------------------------------------------------------
      def update_help
        if self.index < 4
          @help_window.set_text(@items[self.index] == nil ? "Место для инструмента" : $data_items[Craft::TOOLS[@items[self.index]][0]].description)
        elsif self.index < 8
          @help_window.set_text(@items[self.index] == nil ? "Место для ресурсов" : $data_items[Craft::RESOURCES[@items[self.index]][0]].description)
        else
          @help_window.set_text("Создать предмет")
        end
        return
      end
      #--------------------------------------------------------------------------
      def update_cursor_rect
        if @index < 0
          self.cursor_rect.empty
          return
        end
        cursor_width = 54
        x = @index % @column_max * (cursor_width + 32) + 8
        y = @index / @column_max * (cursor_width + 10) - self.oy + 98
        if @index < 8
          self.cursor_rect.set(x, y, cursor_width, cursor_width)
        elsif @index == 8
          self.cursor_rect.set(self.width - 150, self.height - 64, 108, 32)
        end
      end
      #--------------------------------------------------------------------------
    end
    #==============================================================================
    
    class Window_CraftEnd < Window_Selectable
      #--------------------------------------------------------------------------
      attr_accessor :success
      attr_accessor :tool
      attr_accessor :resources
      attr_accessor :recipe  
      attr_reader   :disabled
      attr_reader   :last_item
      #--------------------------------------------------------------------------
      def initialize (x = 40, y = 40, width = 560, height = 400)
        super (x, y, width, height)
        # --- Подключаем библиотеку ---
        @EKLib = EKLib.new
        # -----------------------------
        self.contents = Bitmap.new (width - 32, height - 32)
        @fontfaces = [$fontface]
        @fontsizes = [$fontsize, 32, 20, 24]
        @item_max = 2
        self.z += 20
        @success = success
        @tool = tool
        @resources = resources
        @recipe = recipe
        @disabled = disabled = []
        @last_item = last_item
        @array = []
      end
      #--------------------------------------------------------------------------
      def refresh
        # Чистим себя на случай, если окно уже обновлялось
        self.contents.clear
        @disabled = []
        if @success[0] == false
          self.contents.font.size = @fontsizes[1]
          self.contents.draw_text (self.width / 2 - "Неудача!".size * 5, 32, "Неудача!".size * 8, 30, "Неудача!")
          case @success[1]
          when "tool"
            self.contents.font.size = @fontsizes[2]
            self.contents.draw_text (10, 64, self.width - 20, 32, "Во время работы один из ваших инструментов вышел из строя:")
            bitmap = @EKLib.getImagePartByIndex("Graphics/Icons/craft_medium_tools", @tool[4], 50, 50)
            self.contents.blt(10, 106, bitmap, Rect.new(0, 0, 50, 50))
            @EKLib.drawFigure(self.contents, "square", Color.new(255,255,255,255), 0, 2, 10, 106, 50, 50)
            self.contents.draw_text (10, 166, self.width - 20, 32, "Если вы немедленно не замените его, то все ресурсы будут потеряны!")
            self.contents.font.size = @fontsizes[3]
            self.contents.draw_text (self.width - 164, self.height - 96, 108, 32, "Заменить")
            self.contents.draw_text (self.width - 164, self.height - 64, 108, 32, "Отменить")
          when "resources"
            self.contents.font.size = @fontsizes[2]
            self.contents.draw_text (10, 64, self.width - 20, 32, "Сотворить что-то более-менее удобоваримое вам не удалось.")
            self.contents.draw_text (10, 96, self.width - 20, 32, "Ресурсы были потрачены в пустую...")
            @repeat = true
            for i in 0..3
              if @resources[i][0] == nil then break end
              bitmap = @EKLib.getImagePartByIndex("Graphics/Icons/craft_medium_resources", @resources[i][3], 50, 50)
              self.contents.blt(10 + 60 * i, 138, bitmap, Rect.new(0, 0, 50, 50))
              @EKLib.drawFigure(self.contents, "square", Color.new(255,255,255,255), 0, 2, 10 + 60 * i, 138, 50, 50)
              for n in 0..@recipe[4][i].size - 1
                if @recipe[4][i][n] == @resources[i][1] then break end
              end
              if $game_party.item_number(@resources[i][1]) < @recipe[5][i][n] then @repeat = false end
            end
            self.contents.draw_text (10, 198, self.width - 20, 32, "Если у вас есть ресурсы в запасе, вы можете попытать счастье снова...")
            self.contents.font.size = @fontsizes[3]
            if @repeat == false
              self.contents.font.color = disabled_color
              @disabled.push(0)
            end
            self.contents.draw_text (self.width - 164, self.height - 96, 108, 32, "Повторить")
            self.contents.font.color = normal_color
            self.contents.draw_text (self.width - 164, self.height - 64, 108, 32, "Отменить")
          end
        else
          if @recipe[3][1] == RPG::Item
            @last_item = $data_items[@recipe[3][2]]
            file_name = "Graphics/Icons/items_large"
            @array = Craft::ITEMS
          elsif @recipe[3][1] == RPG::Armor
            @last_item = $data_armors[@recipe[3][2]]
            file_name = "Graphics/Icons/armors_large"
            @array = Craft::ARMORS
          else
            @last_item = $data_weapons[@recipe[3][2]]
            file_name = "Graphics/Icons/weapons_large"
            @array = Craft::WEAPONS
          end
          for i in 0..@array.size - 1
            if @array[i][0] == @recipe[3][2] then break end
          end
          self.contents.font.size = @fontsizes[1]
          self.contents.draw_text (self.width / 2 - "Успех!".size * 3, 32, "Успех!".size * 6, 30, "Успех!")
          self.contents.font.size = @fontsizes[3]      
          self.contents.draw_text (self.width / 2 - @last_item.name.size * 3, 64, @last_item.name.size * 6, 30, @last_item.name)
          bitmap = @EKLib.getImagePartByIndex(file_name, @array[i][1], 100, 100)
          self.contents.blt(10, 94, bitmap, Rect.new(0, 0, 100, 100))
          @EKLib.drawFigure(self.contents, "square", Color.new(255,255,255,255), 0, 2, 10, 94, 100, 100)
          self.contents.font.size = @fontsizes[2]
          @EKLib.hyphenDrawText (@array[i][2], self.contents, self.width - 130, 120, 94)
          @repeat = true
          for i in 0..3
            if @resources[i][0] == nil then break end        
            for n in 0..@recipe[4][i].size - 1
              if @recipe[4][i][n] == @resources[i][1] then break end
            end
            if $game_party.item_number(@resources[i][1]) < @recipe[5][i][n] then @repeat = false end
          end
          self.contents.font.size = @fontsizes[3]
          if @repeat == false
            self.contents.font.color = disabled_color
            @disabled.push(0)
          end
          self.contents.draw_text (self.width - 164, self.height - 96, 108, 32, "Повторить")
          self.contents.font.color = normal_color
          self.contents.draw_text (self.width - 164, self.height - 64, 108, 32, "Закончить")
        end      
      end
      #--------------------------------------------------------------------------
      def burn
        for i in 0..3
          if @resources[i][0] == nil then break end
          for n in 0..@recipe[4][i].size - 1
            if @recipe[4][i][n] == @resources[i][1] then break end
          end
          $game_party.lose_item(@resources[i][1], @recipe[5][i][n])
        end
      end
      #--------------------------------------------------------------------------
      def give_item
        case @array
        when Craft::ITEMS
          $game_party.gain_item(@recipe[3][2], 1)
        when Craft::ARMORS
          $game_party.gain_armor(@recipe[3][2], 1)
        when Craft::WEAPONS
          $game_party.gain_weapon(@recipe[3][2], 1)
        end
      end
      #--------------------------------------------------------------------------
      def update_cursor_rect
        if @index < 0
          self.cursor_rect.empty
          return
        end
        x = self.width - 174
        y = self.height - 96 + 32 * index
        self.cursor_rect.set(x, y, 118, 32)
      end
      #--------------------------------------------------------------------------
    end
    Craft_WindowsEdited
    Код:
    #==============================================================================
    # EK Craft v.1.0b
    #------------------------------------------------------------------------------
    # Created by: Equilibrium Keeper [equilibriumkeeper@inbox.com]
    # Created on: 11.07.2008 23:11:45
    # Отдельное спасибо: insider, Рольф
    #          А так же: rpgmaker.sk6.ru, rpg-maker.info, gdsa.rpgmaker.ru
    #==============================================================================
    # Описание: Подробнее смотрим Craft
    #==============================================================================
    
    class Window_Help
      #--------------------------------------------------------------------------
      attr_accessor :text
      #--------------------------------------------------------------------------
      def initialize (x = 0, y = 0, width = 640, height = 64)
        super(x, y, width, height)
        self.contents = Bitmap.new(width - 32, height - 32)
        self.contents.font.name = $fontface
        self.contents.font.size = $fontsize
      end
      #--------------------------------------------------------------------------
    end
    #==============================================================================
    
    class Window_Item < Window_Selectable
      #--------------------------------------------------------------------------
      attr_accessor :type
      attr_accessor :subtype
      attr_accessor :min_quantity
      attr_reader   :disabled_items
      #--------------------------------------------------------------------------
      def initialize (x = 0, y = 64, width = 640, height = 416, column_max = 2, type = "exclude", subtype = -1, min_quantity = -1)
        super(x, y, width, height)
        @column_max = column_max
        @type = type
        @subtype = subtype
        @min_quantity = min_quantity
        @disabled_items = disabled_items
        refresh
        self.index = 0
        if $game_temp.in_battle
          self.y = 64
          self.height = 256
          self.back_opacity = 160
        end
      end
      #--------------------------------------------------------------------------
      def refresh
        if self.contents != nil
          self.contents.dispose
          self.contents = nil
        end
        @data = []
        @disabled_items = []
        for i in 1...$data_items.size
          if $game_party.item_number(i) > 0
            @push = true
            case @type
            when "exclude"
              for n in 0..Craft::RECIPES.size - 1
                if Craft::RECIPES[n][0] == $data_items[i].id
                  @push = false
                  break
                end
              end
              for n in 0..Craft::TOOLS.size - 1
                if Craft::TOOLS[n][0] == $data_items[i].id
                  @push = false
                  break
                end
              end
              for n in 0..Craft::RESOURCES.size - 1
                if Craft::RESOURCES[n][0] == $data_items[i].id
                  @push = false
                  break
                end
              end
            when "recipes"
              @push = false
              for n in 0..Craft::RECIPES.size - 1
                if Craft::RECIPES[n][0] == $data_items[i].id
                  if @subtype == -1
                    @push = true
                  else
                    if Craft::RECIPES[n][1][0] == @subtype
                      @push = true
                    end
                  end
                  break
                end
              end
            when "tools"
              @push = false
              for n in 0..Craft::TOOLS.size - 1
                if Craft::TOOLS[n][0] == $data_items[i].id
                  @push = true
                  break
                end
              end
            when "resources"
              @push = false
              for n in 0..Craft::RESOURCES.size - 1
                if Craft::RESOURCES[n][0] == $data_items[i].id
                  @push = true
                  break
                end
              end
            end
            if @type.is_a?(Array)
              @push = false
              if @type[1] != "tool"
                for n in 0..@type[0].size - 1
                  if @type[0][n] == $data_items[i].id
                    @num = @type[1][n]
                    @push = true
                    break
                  end
                end
              else
                for n in 0..@type[0].size - 1
                  if @type[0][n] == $data_items[i].id
                    @num = 1
                    @push = true
                    break
                  end
                end
              end
            end
            if @push == true
              @data.push($data_items[i])
            end
          end
        end
        unless $game_temp.in_battle
          for i in 1...$data_weapons.size
            if $game_party.weapon_number(i) > 0 && @type == "exclude"
              @data.push($data_weapons[i])
            end
          end
          for i in 1...$data_armors.size
            if $game_party.armor_number(i) > 0 && @type == "exclude"
              @data.push($data_armors[i])
            end
          end
        end
        @item_max = @data.size
        if @item_max > 0
          self.contents = Bitmap.new(width - 32, row_max * 32)
          self.contents.font.name = $fontface
          self.contents.font.size = $fontsize
          for i in 0...@item_max
            draw_item(i)
          end
        end
      end
      #--------------------------------------------------------------------------
      def draw_item(index)
        item = @data[index]
        case item
        when RPG::Item
          number = $game_party.item_number(item.id)
        when RPG::Weapon
          number = $game_party.weapon_number(item.id)
        when RPG::Armor
          number = $game_party.armor_number(item.id)
        end
        if @min_quantity == -1
          if item.is_a?(RPG::Item) and
             $game_party.item_can_use?(item.id)
            self.contents.font.color = normal_color
          else
            self.contents.font.color = disabled_color
          end
        elsif @min_quantity.is_a?(Array)
          if number >= @num
            self.contents.font.color = normal_color
          else
            self.contents.font.color = disabled_color
            disabled_items.push(index)
          end
        else
          if number >= @min_quantity
            self.contents.font.color = normal_color
          else
            self.contents.font.color = disabled_color
            disabled_items.push(index)
          end
        end
        x = 4 + index % @column_max * (288 + 32)
        y = index / @column_max * 32
        rect = Rect.new(x, y, self.width / @column_max - 32, 32)
        self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
        bitmap = RPG::Cache.icon(item.icon_name)
        opacity = self.contents.font.color == normal_color ? 255 : 128
        self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
        self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
        self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
        self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
      end
      #--------------------------------------------------------------------------  
    end
    Авторы и Благодарности

    Equilibrium Keeper
    Кодер
    insider
    Консультант
    Рольф
    Консультант

    Примечание автора
    Мой третий скрипт. И для меня это было явно слишком. Моск медленно плавиться. Скрипт обещает кучу глюков и недоработок, указание на кои естественно приветствуется, однако срочно требуется человек, способный "помочь" (это слово лишнее) оптимизировать данный скрипт и\или изменить его так, что бы он, не потеряв всех своих фич (коих и так не много) был более просто в использовании, а главное - модернизации. В общем, нужна помощь!

    В следующих версиях планируется:
    - Исправить баг с отображением количества требуемых ресурсов в окне рецепта.
    - Добавить оное в окне крафта.
    - Добавить возможность использовать в качестве входного типа оружие и экипировку.
    - Добавить возможность создания однотипных предметов с различными параметрами.
    -- Задействовать качество ресурсов\инструментов\крив изну рук.
    - Добавить возможность создавать несколько предметов.
    -- Добавить возможность в игре задавать условия для остановки крафта, автоматическую замену ресурсов\инструментов при необходимости.
    - Добавить анимацию крафта.
    - Исправить все найденные баги, оптимизировать код, написать более подробный мануал.
    Последний раз редактировалось Equilibrium Keeper; 24.11.2008 в 17:41.

  2. #2
    Познающий Аватар для BuBlicK
    Информация о пользователе
    Регистрация
    25.04.2008
    Адрес
    Кишинёв
    Сообщений
    286
    Репутация: 5 Добавить или отнять репутацию

    По умолчанию

    да уж мэн... неверится что это написал русский...

    не знаю, предусмотер ты или нет, но:

    *Неплохо бы больше вещей которые можно создавать...
    *А вот професий вроде много...имхо..
    *Я тоже спать хочу...

    +1 задумка отличная
    Последний раз редактировалось BuBlicK; 11.07.2008 в 23:54.
    Растягивая удовольствие, не порви его

    О господин, я много раз получал от девушек, прекрасных девушек, но еще не разу не получал от рыцарей с ро-га-ми

  3. #3

    По умолчанию

    да уж мэн... неверится что это написал русский...
    Толи комплимент, то ли послали... х_х

    *Неплохо бы больше вещей которые можно создавать...
    Читай руководство в Craft'е - сколько хочешь. (=

    *А вот професий вроде много...имхо..
    Опять же мануал - лишний можно выкинуть. Тут племянник в вов рубился - вот я его и того. В демке доступно только 2 свитку кузнеца и 1 алхимика.

    *Я тоже спать хочу...
    Предлагаю обоим идти дрыхнуть (=

    +1 задумка отличная
    Пасиб, я ее еще на 2003 событиями реализовывал ((=

  4. #4
    Создатель Аватар для Рольф
    Информация о пользователе
    Регистрация
    14.04.2008
    Адрес
    Южно- Сахалинск/Пенза
    Сообщений
    10,081
    Записей в дневнике
    2
    Репутация: 108 Добавить или отнять репутацию

    По умолчанию

    1. Первая ты делал на патчи, что я не люблю не отображаться надписи во всей игре.
    2. Очень не красивый баг. Незнаю почему ты его не исправил. Подтяни все окна: золото, шаги, время. А то у тебя курсор залазит.
    Очень хороший скрипт.

  5. #5

    По умолчанию

    1. Тож не люблю, но так получилось. По сути я делал не на патч - он не нужен. Нужна только библиотека RGSS102E.dll о чем я предупредил. (= Ну, я люблю последние версии библиотек (гнилая отмазка), а вобще, просто в начале разработки забыл что у меня стоит R&W (=
    2. Потому что не хотел менять скрипт меню. После исправления чего-нибудь поправлю в следующей демке. (=

    P.S. Пасиб. (=

  6. #6
    Создатель Аватар для Рольф
    Информация о пользователе
    Регистрация
    14.04.2008
    Адрес
    Южно- Сахалинск/Пенза
    Сообщений
    10,081
    Записей в дневнике
    2
    Репутация: 108 Добавить или отнять репутацию

    По умолчанию

    1. Я ее кидал все равно так.
    2. Там всего две строчки.

  7. #7
    Познающий Аватар для BuBlicK
    Информация о пользователе
    Регистрация
    25.04.2008
    Адрес
    Кишинёв
    Сообщений
    286
    Репутация: 5 Добавить или отнять репутацию

    По умолчанию

    Цитата Сообщение от Equilibrium Keeper Посмотреть сообщение
    Толи комплимент, то ли послали... х_х
    Первое...
    Просто реально, отличная задумка..

    и главное что на последней библиотеке работает, странно, но прям как у меня
    Растягивая удовольствие, не порви его

    О господин, я много раз получал от девушек, прекрасных девушек, но еще не разу не получал от рыцарей с ро-га-ми

Информация о теме

Пользователи, просматривающие эту тему

Эту тему просматривают: 1 (пользователей: 0 , гостей: 1)

Социальные закладки

Социальные закладки

Ваши права

  • Вы не можете создавать новые темы
  • Вы не можете отвечать в темах
  • Вы не можете прикреплять вложения
  • Вы не можете редактировать свои сообщения
  •  
EK Craft