Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # ▼ GO GO TOTORI! (Алхимический синтез)
- # Автор: Kread-EX
- # Версия: 1.01
- # Дата выхода: 08.12.2011
- #
- # Перевод: mephis
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- #-------------------------------------------------------------------------------------------------
- # ▼ ОБНОВЛЕНИЯ
- #-------------------------------------------------------------------------------------------------
- # # 12/12/2011. Added detection for the future add-ons.
- #-------------------------------------------------------------------------------------------------
- # ▼ УСЛОВИЯ ИСПОЛЬЗОВАНИЯ
- #-------------------------------------------------------------------------------------------------
- # Вы можете изменять код этого скрипта под ваши нужды.
- # Вы можете использовать этот скрипт в коммерческих целях.
- # Обязательно указывайте автора.
- #
- # # По поддержке можно со мной связаться здесь:
- # # grimoirecastle.wordpress.com
- # # или здесь
- # # rpgmakervxace.net
- # # или здесь
- # # rpgrevolution.com
- #-------------------------------------------------------------------------------------------------
- # ▼ ВВЕДЕНИЕ
- #-------------------------------------------------------------------------------------------------
- # Это мощная система синтеза вещей, на создание которой меня вдохновила серия игр
- # Atelier от GUST и Atelier Totori в частности.
- #
- # Каковы её возможности?
- # - Создание объектов по рецептам.
- # - Замена одного ингридиента другим из той же группы.
- # - Задание особенностей ингридиентам и перенос их на готовую вещь.
- # - Уровни алхимии и сложность синтеза.
- # - Магазин синтеза (отдельный скрипт).
- #
- # Чего здесь нет?
- # - Синтез нескольких копий одной вещи
- # - Опыт в алхимии. Сейчас выставлять уровень можно только вручную.
- # - Панель эффектов. Если вы не знаете что это такое, то и не важно. А если вы в
- # курсе, то знайте, что я не собираюсь реализовывать её.
- # - Время синтеза. В игре Totori синтез может занять несколько дней. Учитывая то,
- # что в играх на RPG Maker системы времени редки, я и не стал делать
- # эту функцию.
- # - Особенности, связанные с ценой и качеством.
- #-------------------------------------------------------------------------------------------------
- # ▼ ИНСТРУКЦИЯ
- #-------------------------------------------------------------------------------------------------
- # На этой странице есть подробное описание использования скрипта.
- # http://grimoirecastle.wordpress.com/2011/12/08/alchemic-synthesis-go-go-totori/
- # К сожалению, не совсем простое для понимания.
- #-------------------------------------------------------------------------------------------------
- # ▼ СОВМЕСТИМОСТЬ
- #-------------------------------------------------------------------------------------------------
- # Пока что на Ace не так много скриптов, но этот должен нормально работать со
- # скриптами Yanfly.
- #
- # Новые классы: Scene_Alchemy, Window_SynthesisList, Window_SynthesisProp,
- # Window_IngredientList, Window_IngredientProp, Window_ItemFamily,
- # Window_TraitList, Window_FinalItem
- #
- # Список псевдонимов и перекрытий:
- # DataManager
- # load_database (alias)
- # load_synth_notetags (new method)
- #
- # Game_Party
- # initialize (alias)
- #
- # RPG::Item, RPG::Weapon, RPG::Armor
- # load_synth_notetags (new method)
- # synthesis_traits (new method)
- # effects (alias)
- # features (alias)
- #-------------------------------------------------------------------------------------------------
- $imported = {} if $imported.nil?
- $imported['KRX-AlchemicSynthesis'] = true
- # Ace grants us a debug console, and this is awesome.
- puts 'Load: Alchemic Synthesis ~GO GO TOTORI!~ v1.01 by Kread-EX'
- module KRX
- module REGEXP
- SYNTHESIS_ITEM = /<synth_item:[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- SYNTHESIS_ITEM_REQ = /<synth_req_item:[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- SYNTHESIS_WEAPON = /<synth_weapon:[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- SYNTHESIS_WEAPON_REQ = /<synth_req_weapon:[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- SYNTHESIS_ARMOR = /<synth_armor:[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- SYNTHESIS_ARMOR_REQ = /<synth_req_armor[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- SYNTHESIS_FAMILY = /<synth_family:[ ]*([[:alpha:]]+)>/i
- SYNTHESIS_TRAITS = /<synth_traits:[ ]*([^,]+(?:,[^,]+)*)>/i
- SYNTHESIS_QUALITY = /<synth_quality:[ ]*(\d+)>/i
- SYNTHESIS_LEVEL = /<synth_level:[ ]*(\d+)>/i
- end
- module VOCAB
- TRAITS = 'Особенности'
- INGREDIENTS = 'Ингридиенты'
- QUALITY = 'Качество:'
- SYNTH_POINTS = 'Очки синтеза:'
- CAULDRON = 'Котёл'
- LEVEL = 'Уровень синтеза:'
- SUCCESS_RATE = 'Шанс успеха:'
- SYNTH_FAILED = 'Синтез не удался!'
- SYNTH_SUCCESS = 'Синтез прошёл успешно!'
- end
- #==========================================================================
- # ■ СИНТЕЗ
- #----------------------------------------------------------------------------------------
- # ОСОБЕННОСТИ
- #----------------------------------------------------------------------------------------
- # Здесь перечислены все возможные эффекты в синтезе и их Цена Синтеза.
- # Вы можете добавить свои эффекты, если понимаете в скриптинге, но
- # в данный момент здесь используются стандартные эффекты VX Ace.
- #
- # Я добавлю больше особенностей когда выйдет полная версия.
- #
- # СИНТАКСИС ДЛЯ ЭКИПИРОВКИ
- # Название особенности => [0, Цена, [[Код свойства, ID свойства, Цена свойства]], Описание]
- # СИНТАКСИС ДЛЯ ИСПОЛЬЗУЕМОЙ ВЕЩИ
- # Название особенности => [1, Цена, [[Код эффекта, ID эффекта, Цена эффекта 1, Цена Эффекта 2]], Описание]
- #
- # Важное замечание: определённые эффекты могут не складываться. Например,
- # некоторые эффекты восстановления здоровья не складываются - если вы
- # выберете один, то не сможете выбрать другие.
- #==========================================================================
- module Synthesis
- # Индексы массивов
- TRAIT_CATEGORY = 0
- TRAIT_COST = 1
- TRAIT_OBJECTS = 2
- TRAIT_HELP = 3
- Traits = {
- # Особенности для экипирующихся вещей
- "Отравленный" => [0, 3, [[32, 2, 0.5]], "Отравляет с 50%-ым шансом."],
- "Ядовитый" => [0, 8, [[32, 2, 1.0]], "Отравляет со 100%-ым шансом."],
- "Сила дракона" => [0, 10, [[22, 2, 0.25]], "Повышает шанс критического удара на 25%."],
- "Уменьшитель урона" => [0, 20, [[23, 6, 0.5], [23, 7, 0.5]], "Уменьшает вдвое полученный урон."],
- "Карта безопасности" => [0, 8, [[64, 0, 0.0]], "Снижает частоту случайных сражений."],
- "Хорошая удача" => [0, 25, [[64, 4, 0.0]], "Удваивает полученные деньги."],
- "Великий ученик" => [0, [[25, 23, 9]], 1.5, "Увеличивает получаемый опыт на 50%."],
- "Щит огня" => [0, 10, [[11, 3, 0.0]], "Полностью защищает от огненного урона."],
- "Щит льда" => [0, 10, [[11, 4, 0.0]], "Полностью защищает от ледяного урона."],
- "Щит молнии" => [0, 10, [[11, 5, 0.0]], "Полностью защищает от урона молнией."],
- "Щит воды" => [0, 10, [[11, 6, 0.0]], "Полностью защищает от урона водой."],
- "Щит земли" => [0, 10, [[11, 7, 0.0]], "Полностью защищает от урона землёй."],
- "Щит ветра" => [0, 10, [[11, 8, 0.0]], "Полностью защищает от урона ветром."],
- "Сила ниндзи" => [0, 15, [[22, 1, 1.0]], "Повышает Уклонение"],
- "Душа героя" => [0, 15, [[21, 0, 1.5]], "Увеличивает максимальные HP."],
- "Двойной ход" => [0, 20, [[61, 0, 1.0]], "Позволяет действовать дважды за ход."],
- "Огонь" => [0, 3, [[41, 2, 0.0], [43, 3, 0.0]], "Герой может использовать заклинание огня."],
- "Ветер" => [0, 6, [[41, 2, 0.0], [43, 4, 0.0]], "Герой может использовать заклинание ветра."],
- "Лечение" => [0, 3, [[41, 2, 0.0], [43, 5, 0.0]], "Герой может использовать заклинание лечения."],
- "Воскрешение" => [0, 6, [[41, 2, 0.0], [43, 6, 0.0]], "Герой может использовать заклинание воскрешения."],
- # Особенности для используемых вещей
- "Атк+" => [1, 5, [[31, 2, 5.0, 0.0]], "Повышает Атаку на 5 ходов."],
- "Защ+" => [1, 5, [[31, 3, 5.0, 0.0]], "Повышает Защиту на 5 ходов."],
- "Маг+" => [1, 5, [[31, 4, 5.0, 0.0]], "Повышает Маг. атаку на 5 ходов."],
- "Мгз+" => [1, 5, [[31, 5, 5.0, 0.0]], "Повышает Маг. защиту на 5 ходов."],
- "Прв+" => [1, 5, [[31, 6, 5.0, 0.0]], "Повышает Проворство на 5 ходов."],
- "Удч+" => [1, 5, [[31, 7, 5.0, 0.0]], "Повышает Удачу на 5 ходов."],
- "Атк-" => [1, 5, [[32, 2, 5.0, 0.0]], "Снижает Атаку на 5 ходов."],
- "Защ-" => [1, 5, [[32, 3, 5.0, 0.0]], "Снижает Защиту на 5 ходов."],
- "Маг-" => [1, 5, [[32, 4, 5.0, 0.0]], "Снижает Маг. атаку на 5 ходов."],
- "Мгз-" => [1, 5, [[32, 5, 5.0, 0.0]], "Снижает Маг. защиту на 5 ходов."],
- "Прв-" => [1, 5, [[32, 6, 5.0, 0.0]], "Снижает Проворство на 5 ходов."],
- "Удч-" => [1, 5, [[32, 7, 5.0, 0.0]], "Снижает Удачу на 5 ходов."],
- "Восстановление здоровья XS" => [1, 1, [[11, 0, 0.1, 0.0]], "Восстанавливает 10% HP."],
- "Восстановление здоровья S" => [1, 4, [[11, 0, 0.25, 0.0]], "Восстанавливает 25% HP."],
- "Восстановление здоровья M" => [1, 8, [[11, 0, 0.5, 0.0]], "Восстанавливает 50% HP."],
- "Восстановление здоровья L" => [1, 16, [[11, 0, 0.75, 0.0]], "Восстанавливает 75% HP."],
- "Восстановление здоровья XL" => [1, 25, [[11, 0, 1.0, 0.0]], "Восстанавливает 100% HP."],
- "Восстановление маны XS" => [1, 1, [[12, 0, 0.1, 0.0]], "Восстанавливает 10% MP."],
- "Восстановление маны S" => [1, 4, [[12, 0, 0.25, 0.0]], "Восстанавливает 25% MP."],
- "Восстановление маны M" => [1, 8, [[12, 0, 0.5, 0.0]], "Восстанавливает 50% MP."],
- "Восстановление маны L" => [1, 16, [[12, 0, 0.75, 0.0]], "Восстанавливает 75% MP."],
- "Восстановление маны XL" => [1, 25, [[12, 0, 1.0, 0.0]], "Восстанавливает 100% MP."],
- "Восстановление техники XS" => [1, 1, [[13, 0, 2.0, 0.0]], "Восстанавливает 2% TP."],
- "Восстановление техники S" => [1, 4, [[13, 0, 5.0, 0.0]], "Восстанавливает 5% TP."],
- "Восстановление техники M" => [1, 8, [[13, 0, 10.0, 0.0]], "Восстанавливает 10% TP."],
- "Восстановление техники L" => [1, 16, [[13, 0, 16.0, 0.0]], "Восстанавливает 16% TP."],
- "Восстановление техники XL" => [1, 25, [[13, 0, 20.0, 0.0]], "Восстанавливает 20% TP."],
- "Воскрешение XS" => [1, 1, [[22, 1, 1.0, 0.0], [11, 0, 0.1, 0.0]], "Воскрешает и восстанавливает 10% HP."],
- "Воскрешение S" => [1, 4, [[22, 1, 1.0, 0.0], [11, 0, 0.25, 0.0]], "Воскрешает и восстанавливает 25% HP."],
- "Воскрешение M" => [1, 8, [[22, 1, 1.0, 0.0], [11, 0, 0.5, 0.0]], "Воскрешает и восстанавливает 50% HP."],
- "Воскрешение L" => [1, 16, [[22, 1, 1.0, 0.0], [11, 0, 0.75, 0.0]], "Воскрешает и восстанавливает 75% HP."],
- "Воскрешение XL" => [1, 25, [[22, 1, 1.0, 0.0], [11, 0, 1.0, 0.0]], "Воскрешает и восстанавливает 100% HP."],
- "Противоядие" => [1, 1, [[22, 2, 1.0, 0.0]], "Снимает отравление."],
- "Поглощатель магии" => [1, 13, [[12, 0, -0.75, 0.0]], "Уменьшает MP на 75%."]
- }
- end
- end
- #==========================================================================
- # ■ Scene_Alchemy
- #==========================================================================
- class Scene_Alchemy < Scene_MenuBase
- #--------------------------------------------------------------------------
- # ● Scene start
- #--------------------------------------------------------------------------
- def start
- super
- @item_cauldron, @family_cauldron = [], []
- @old_traits = $game_party.synthesis_traits.dup
- @old_qual = $game_party.synthesis_quality.dup
- create_help_window
- create_category_window
- create_properties_window
- create_item_window
- end
- #--------------------------------------------------------------------------
- # ● Creates the window displaying the item categories
- #--------------------------------------------------------------------------
- def create_category_window
- @category_window = Window_ItemCategory.new
- @category_window.viewport = @viewport
- @category_window.help_window = @help_window
- @category_window.y = @help_window.height
- @category_window.set_handler(:ok, method(:on_category_ok))
- @category_window.set_handler(:cancel, method(:return_scene))
- end
- #--------------------------------------------------------------------------
- # ● Creates the window displaying the item's properies and requirements
- #--------------------------------------------------------------------------
- def create_properties_window
- wy = @category_window.y + @category_window.height
- wh = Graphics.height - wy
- @prop_window = Window_SynthesisProp.new(Graphics.width / 2, wy, Graphics.width / 2, wh)
- @prop_window.viewport = @viewport
- end
- #--------------------------------------------------------------------------
- # ● Creates the window displaying the items available to synthesis
- #--------------------------------------------------------------------------
- def create_item_window
- wy = @category_window.y + @category_window.height
- wh = Graphics.height - wy
- @item_window = Window_SynthesisList.new(0, wy, Graphics.width / 2, wh)
- @item_window.viewport = @viewport
- @item_window.help_window = @help_window
- @item_window.prop_window = @prop_window
- @item_window.set_handler(:ok, method(:on_item_ok))
- @item_window.set_handler(:cancel, method(:on_item_cancel))
- @category_window.item_window = @item_window
- end
- #--------------------------------------------------------------------------
- # ● Creates the window displaying the iavailable ingredients
- #--------------------------------------------------------------------------
- def create_ingredient_window
- wy = @category_window.y + @category_window.height
- wh = Graphics.height - wy
- @i_prop_window = Window_IngredientProp.new(Graphics.width / 2, wy, Graphics.width / 2, wh)
- @i_prop_window.viewport = @viewport
- @ing_window = Window_IngredientList.new(0, wy, Graphics.width / 2, wh, @item_window.item)
- @ing_window.viewport = @viewport
- @ing_window.help_window = @help_window
- @ing_window.prop_window = @i_prop_window
- @ing_window.set_handler(:ok, method(:on_ing_ok))
- @ing_window.set_handler(:cancel, method(:on_ing_cancel))
- @family_window = Window_ItemFamily.new
- @family_window.y = @help_window.height
- @family_window.item_window = @ing_window
- @family_window.set_handler(:ok, method(:on_family_ok))
- @family_window.set_handler(:cancel, method(:on_family_cancel))
- @family_window.activate
- @family_window.select(0)
- end
- #--------------------------------------------------------------------------
- # ● Creates the windows related to the cauldron
- #--------------------------------------------------------------------------
- def create_cauldron_windows
- wy = @help_window.y + @help_window.height
- wh = Graphics.height - wy
- ww = Graphics.width / 2
- @trait_window = Window_TraitList.new(0, wy, ww, wh, @points)
- @trait_window.refresh
- @trait_window.activate
- @trait_window.select(0)
- @trait_window.help_window = @help_window
- @trait_window.set_handler(:ok, method(:on_trait_ok))
- @trait_window.set_handler(:cancel, method(:on_trait_cancel))
- @final_window = Window_FinalItem.new(ww, wy, ww, wh, @quality, @points,
- @level, @success)
- end
- #--------------------------------------------------------------------------
- # ● Destroys the ingredient-related windows
- #--------------------------------------------------------------------------
- def destroy_ingredient_windows
- @ing_window.dispose; @ing_window = nil
- @family_window.dispose; @family_window = nil
- @i_prop_window.dispose; @i_prop_window = nil
- end
- #--------------------------------------------------------------------------
- # ● Destroys the cauldron-related windows
- #--------------------------------------------------------------------------
- def destroy_cauldron_windows
- @trait_window.dispose; @trait_window = nil
- @final_window.dispose; @final_window = nil
- end
- #--------------------------------------------------------------------------
- # ● Returns the current ingredient selection
- #--------------------------------------------------------------------------
- def cauldron(item = false)
- item ? @item_cauldron : @family_cauldron
- end
- #--------------------------------------------------------------------------
- # ● Update the cauldron contents
- #--------------------------------------------------------------------------
- def update_cauldron(add = true)
- if add
- @item_cauldron.push(@ing_window.item)
- @family_cauldron.push(@ing_window.item.synthesis_family)
- @ing_window.unselect
- else
- @item_cauldron.pop
- @family_cauldron.pop
- end
- @family_window.refresh
- @family_window.update
- @family_window.activate
- @family_window.select(0)
- @ing_window.update_help
- end
- #--------------------------------------------------------------------------
- # ● Determine the final quality of the item
- #--------------------------------------------------------------------------
- def compute_quality
- total_value = 0
- ary = []
- ary = @item_cauldron.collect {|itm| itm.synthesis_quality}
- ary.each {|v| total_value += v}
- rate = total_value / ary.size
- @quality = rate
- @points = rate
- $game_party.synthesis_quality[$game_party.last_item.object] = rate
- end
- #--------------------------------------------------------------------------
- # ● Determine the synthesis success rate
- #--------------------------------------------------------------------------
- def compute_success
- @level = $game_party.last_item.object.synthesis_level
- @success = (100 * ($game_party.synthesis_level / @level)).round
- end
- #--------------------------------------------------------------------------
- # ● Synthesis outcome
- #--------------------------------------------------------------------------
- def process_outcome(failure = false)
- destroy_cauldron_windows
- wy = Graphics.height / 2 - @help_window.height / 2
- @help_window.move(0, wy, Graphics.width, @help_window.height - 16)
- @help_window.arrows_visible = false
- if failure
- @help_window.set_text(KRX::VOCAB::SYNTH_FAILED)
- $game_party.synthesis_traits = @old_traits.dup
- $game_party.synthesis_quality = @old_qual.dup
- else
- @help_window.set_text(KRX::VOCAB::SYNTH_SUCCESS)
- $game_party.gain_item($game_party.last_item.object, 1)
- end
- cauldron(true).each do |item|
- $game_party.lose_item(item, 1)
- end
- Graphics.wait(40)
- on_item_cancel
- @help_window.move(0, 0, Graphics.width, @help_window.height + 16)
- end
- #--------------------------------------------------------------------------
- # ● Confirms the category selection
- #--------------------------------------------------------------------------
- def on_category_ok
- @item_window.activate
- @item_window.select_last
- end
- #--------------------------------------------------------------------------
- # ● Confirms the item selection
- #--------------------------------------------------------------------------
- def on_item_ok
- $game_party.last_item.object = @item_window.item
- @item_window.hide
- @category_window.hide
- @prop_window.hide
- create_ingredient_window
- end
- #--------------------------------------------------------------------------
- # ● Returns to the category selection
- #--------------------------------------------------------------------------
- def on_item_cancel
- @item_window.unselect
- @item_window.show
- @item_window.refresh
- @prop_window.set_item(nil)
- @prop_window.show
- @category_window.activate
- @category_window.show
- end
- #--------------------------------------------------------------------------
- # ● Confirms the family selection
- #--------------------------------------------------------------------------
- def on_family_ok
- @family_window.deactivate
- @ing_window.select_last
- @ing_window.activate
- end
- #--------------------------------------------------------------------------
- # ● Returns to the item selection
- #--------------------------------------------------------------------------
- def on_family_cancel
- unless cauldron.empty?
- update_cauldron(false)
- return
- end
- destroy_ingredient_windows
- @item_window.show
- @item_window.activate
- @category_window.show
- @prop_window.show
- end
- #--------------------------------------------------------------------------
- # ● Confirms the ingredient selection
- #--------------------------------------------------------------------------
- def on_ing_ok
- update_cauldron
- if cauldron.size == $game_party.last_item.object.synthesis_reqs.size
- compute_quality
- compute_success
- destroy_ingredient_windows
- create_cauldron_windows
- end
- end
- #--------------------------------------------------------------------------
- # ● Returns to the family selection
- #--------------------------------------------------------------------------
- def on_ing_cancel
- @ing_window.unselect
- @i_prop_window.set_item(nil)
- @family_window.activate
- end
- #--------------------------------------------------------------------------
- # ● Validates a trait selection
- #--------------------------------------------------------------------------
- def on_trait_ok
- item = $game_party.last_item.object
- trait = @trait_window.item
- if trait == 'Finish!'
- if (rand(100) + 1) < @success
- process_outcome
- else
- process_outcome(true)
- end
- return
- end
- if $game_party.synthesis_traits[item] == nil
- $game_party.synthesis_traits[item] = []
- end
- $game_party.synthesis_traits[item].push(trait)
- $game_party.synthesis_traits[item].flatten!
- @points -= KRX::Synthesis::Traits[trait][KRX::Synthesis::TRAIT_COST]
- @trait_window.remove_item(trait, @points)
- @trait_window.activate
- @final_window.update_points(@points)
- @final_window.set_item(item)
- end
- #--------------------------------------------------------------------------
- # ● Returns to the ingredient selection
- #--------------------------------------------------------------------------
- def on_trait_cancel
- @family_cauldron.clear
- @item_cauldron.clear
- $game_party.synthesis_traits = @old_traits.dup
- destroy_cauldron_windows
- create_ingredient_window
- end
- end
- #==========================================================================
- # ■ Window_SynthesisList
- #==========================================================================
- class Window_SynthesisList < Window_ItemList
- #--------------------------------------------------------------------------
- # ● Determine if an item goes in the list
- #--------------------------------------------------------------------------
- def include?(item)
- case @category
- when :item
- item.is_a?(RPG::Item) && !item.key_item?
- when :weapon
- item.is_a?(RPG::Weapon)
- when :armor
- item.is_a?(RPG::Armor)
- when :key_item
- item.is_a?(RPG::Item) && item.key_item?
- else
- return false
- end
- end
- #--------------------------------------------------------------------------
- # ● Determine if the required ingredients for synthesis are available
- #--------------------------------------------------------------------------
- def enable?(item)
- return false if item.nil?
- ok = []
- families = item.synthesis_reqs.collect {|x| x.synthesis_family}
- families.each do |family|
- for itm in $game_party.all_items
- next unless itm.synthesis_family == family
- if $game_party.item_number(itm) >= 1
- ok.push(true)
- break
- end
- end
- end
- return ok.size == item.synthesis_reqs.size
- end
- #--------------------------------------------------------------------------
- # ● Creates the list based on the recipes
- #--------------------------------------------------------------------------
- def make_item_list
- @data = []
- recipes = $game_party.items.select {|item| !item.recipe_data.empty?}
- for rec in recipes
- for syn in rec.recipe_data
- @data.push(syn) if include?(syn)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● Displays the item icon and name
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- if item
- rect = item_rect(index)
- rect.width -= 4
- draw_item_name(item, rect.x, rect.y, enable?(item))
- end
- end
- #--------------------------------------------------------------------------
- # ● Assigns a properties window
- #--------------------------------------------------------------------------
- def prop_window=(value)
- @prop_window = value
- end
- #--------------------------------------------------------------------------
- # ● Refreshes the help and prop windows
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_item(item)
- @prop_window.set_item(item)
- end
- #--------------------------------------------------------------------------
- # ● Returns the number of columns
- #--------------------------------------------------------------------------
- def col_max
- return 1
- end
- end
- #==========================================================================
- # ■ Window_IngredientList
- #==========================================================================
- class Window_IngredientList < Window_ItemList
- #--------------------------------------------------------------------------
- # ● Object Initialize
- #--------------------------------------------------------------------------
- def initialize(x, y, w, h, item)
- super(x, y, w, h)
- @base_item = item
- refresh
- end
- #--------------------------------------------------------------------------
- # ● Determine if an item goes in the list
- #--------------------------------------------------------------------------
- def number?
- case @category
- when :ing0
- return 0
- when :ing1
- return 1
- when :ing2
- return 2
- when :ing3
- return 3
- else
- return 0
- end
- end
- #--------------------------------------------------------------------------
- # ● Enable (always true)
- #--------------------------------------------------------------------------
- def enable?(item)
- return true
- end
- #--------------------------------------------------------------------------
- # ● Creates the list based on the recipes
- #--------------------------------------------------------------------------
- def make_item_list
- family = @base_item.synthesis_reqs[number?].synthesis_family
- @data = $game_party.all_items.select {|itm| itm.synthesis_family == family}
- end
- #--------------------------------------------------------------------------
- # ● Returns the number of columns
- #--------------------------------------------------------------------------
- def col_max
- return 1
- end
- #--------------------------------------------------------------------------
- # ● Assigns a properties window
- #--------------------------------------------------------------------------
- def prop_window=(value)
- @prop_window = value
- end
- #--------------------------------------------------------------------------
- # ● Refreshes the help and prop windows
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_item(item)
- @prop_window.set_item(item)
- end
- end
- #==========================================================================
- # ■ Window_SynthesisProp
- #==========================================================================
- class Window_SynthesisProp < Window_Base
- #--------------------------------------------------------------------------
- # ● Object Initialize
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super
- set_item
- end
- #--------------------------------------------------------------------------
- # ● Refresh the contents
- #--------------------------------------------------------------------------
- def set_item(item = nil)
- contents.clear
- return if item.nil?
- draw_item_traits(item)
- draw_item_ingredients(item)
- end
- #--------------------------------------------------------------------------
- # ● Displays the item's traits
- #--------------------------------------------------------------------------
- def draw_item_traits(item)
- change_color(system_color)
- contents.draw_text(0, 0, width, line_height, KRX::VOCAB::TRAITS)
- change_color(normal_color)
- (1..4).each {|i| contents.draw_text(0, line_height * i, width, line_height, "#{i}.")}
- item.synthesis_traits.each_index do |i|
- trait = item.synthesis_traits[i]
- contents.draw_text(24, line_height * (i + 1), width - 24, line_height, trait)
- end
- draw_horz_line(line_height * 5)
- end
- #--------------------------------------------------------------------------
- # ● Displays the item's requires ingredients
- #--------------------------------------------------------------------------
- def draw_item_ingredients(item)
- change_color(system_color)
- contents.draw_text(0, line_height * 6, width, line_height, KRX::VOCAB::INGREDIENTS)
- change_color(normal_color)
- item.synthesis_reqs.each_index do |i|
- itm = item.synthesis_reqs[i]
- draw_item_name(itm, 0, line_height * (i + 7), true, width)
- end
- end
- #--------------------------------------------------------------------------
- # ● Displays an horizontal line
- #--------------------------------------------------------------------------
- def draw_horz_line(y)
- line_y = y + line_height / 2 - 1
- contents.fill_rect(0, line_y, contents_width, 2, line_color)
- end
- #--------------------------------------------------------------------------
- # ● Returns the color used for horizontal lines
- #--------------------------------------------------------------------------
- def line_color
- color = normal_color
- color.alpha = 48
- return color
- end
- end
- #==========================================================================
- # ■ Window_IngredientProp
- #==========================================================================
- class Window_IngredientProp < Window_SynthesisProp
- #--------------------------------------------------------------------------
- # ● Refresh the contents
- #--------------------------------------------------------------------------
- def set_item(item = nil)
- contents.clear
- draw_current_cauldron
- return if item.nil?
- draw_item_traits(item)
- end
- #--------------------------------------------------------------------------
- # ● Displays the item's traits
- #--------------------------------------------------------------------------
- def draw_item_traits(item)
- change_color(system_color)
- contents.draw_text(0, 0, width, line_height, KRX::VOCAB::QUALITY)
- size = text_size(KRX::VOCAB::QUALITY).width
- change_color(normal_color)
- contents.draw_text(size, 0, 32, line_height, item.synthesis_quality, 2)
- return if item.synthesis_traits.empty?
- item.synthesis_traits.each_index do |i|
- cost = KRX::Synthesis::Traits[item.synthesis_traits[i]][KRX::Synthesis::TRAIT_COST]
- contents.draw_text(0, line_height * (i + 1), width, line_height, "#{i + 1}.")
- contents.draw_text(24, line_height * (i + 1), width - 24, line_height,
- "#{item.synthesis_traits[i]} (#{cost})")
- end
- end
- #--------------------------------------------------------------------------
- # ● Displays the current ingredient selection
- #--------------------------------------------------------------------------
- def draw_current_cauldron
- draw_horz_line(line_height * 5)
- change_color(system_color)
- contents.draw_text(0, line_height * 6, width, line_height, KRX::VOCAB::CAULDRON)
- return if SceneManager.scene.cauldron.empty?
- change_color(normal_color)
- SceneManager.scene.cauldron.each_index do |i|
- draw_item_name(SceneManager.scene.cauldron(true)[i], 0, line_height * (i + 7), true, width)
- end
- end
- end
- #==========================================================================
- # ■ Window_ItemFamily
- #==========================================================================
- class Window_ItemFamily < Window_ItemCategory
- #--------------------------------------------------------------------------
- # ● Create the commands list
- #--------------------------------------------------------------------------
- def make_command_list
- itm = $game_party.last_item.object
- return if itm.nil?
- (0...itm.synthesis_reqs.size).each do |i|
- fam = itm.synthesis_reqs[i].synthesis_family
- next if SceneManager.scene.cauldron.include?(fam)
- symb = "ing#{i}".to_sym
- add_command(fam, symb)
- end
- end
- end
- #==========================================================================
- # ■ Window_TraitList
- #==========================================================================
- class Window_TraitList < Window_ItemList
- #--------------------------------------------------------------------------
- # ● Object Initialize
- #--------------------------------------------------------------------------
- def initialize(x, y, w, h, p)
- @points = p
- @deleted = []
- super(x, y, w, h)
- end
- #--------------------------------------------------------------------------
- # ● Lists the traits of the items in the cauldron
- #--------------------------------------------------------------------------
- def make_item_list
- @data = []
- cat = case $game_party.last_item.object
- when RPG::EquipItem then 0
- when RPG::Item then 1
- end
- SceneManager.scene.cauldron(true).each do |item|
- @data.push(item.synthesis_traits)
- end
- @data.flatten!
- @data.uniq!
- @data.select! do |x| (!@deleted.include?(x) &&
- KRX::Synthesis::Traits[x][KRX::Synthesis::TRAIT_CATEGORY] == cat)
- end
- @data.push('Finish!')
- end
- #--------------------------------------------------------------------------
- # ● Enable (always true)
- #--------------------------------------------------------------------------
- def enable?(item)
- return true if item == 'Finish!'
- @points >= KRX::Synthesis::Traits[item][KRX::Synthesis::TRAIT_COST]
- end
- #--------------------------------------------------------------------------
- # ● Remove a trait
- #--------------------------------------------------------------------------
- def remove_item(trait, points)
- @deleted.push(trait)
- @points = points
- refresh
- end
- #--------------------------------------------------------------------------
- # ● Displays the trait name and cost
- #--------------------------------------------------------------------------
- def draw_item(index)
- key = @data[index]
- change_color(normal_color, enable?(key))
- contents.draw_text(4, index * line_height, width, line_height, key)
- return if key == 'Finish!'
- cost = KRX::Synthesis::Traits[key][KRX::Synthesis::TRAIT_COST]
- contents.draw_text(4, index * line_height, width - 32, line_height, cost, 2)
- end
- #--------------------------------------------------------------------------
- # ● Returns the number of columns
- #--------------------------------------------------------------------------
- def col_max
- return 1
- end
- #--------------------------------------------------------------------------
- # ● Refreshes the help window
- #--------------------------------------------------------------------------
- def update_help
- if @data[index] == 'Finish!'
- help = 'Perform synthesis.'
- else
- help = KRX::Synthesis::Traits[@data[index]][KRX::Synthesis::TRAIT_HELP]
- end
- @help_window.set_text(help)
- end
- end
- #==========================================================================
- # ■ Window_FinalItem
- #==========================================================================
- class Window_FinalItem < Window_SynthesisProp
- #--------------------------------------------------------------------------
- # ● Object Initialize
- #--------------------------------------------------------------------------
- def initialize(x, y, w, h, q, p, l, s)
- @quality = q
- @points = p
- @level = l
- @success = s
- super(x, y, w, h)
- end
- #--------------------------------------------------------------------------
- # ● Alters the points value
- #--------------------------------------------------------------------------
- def update_points(value)
- @points = value
- end
- #--------------------------------------------------------------------------
- # ● Refresh the contents
- #--------------------------------------------------------------------------
- def set_item(item = $game_party.last_item.object)
- @item = item
- contents.clear
- draw_item_name(@item, 4, 0, true, width)
- draw_item_quality
- draw_item_traits
- draw_synthesis_success
- end
- #--------------------------------------------------------------------------
- # ● Displays the item quality
- #--------------------------------------------------------------------------
- def draw_item_quality
- change_color(system_color)
- contents.draw_text(4, line_height * 1, width, line_height, KRX::VOCAB::QUALITY)
- contents.draw_text(4, line_height * 2, width, line_height, KRX::VOCAB::SYNTH_POINTS)
- change_color(normal_color)
- s1 = text_size(KRX::VOCAB::QUALITY).width
- s2 = text_size(KRX::VOCAB::SYNTH_POINTS).width
- contents.draw_text(4 + s1, line_height * 1, 32, line_height, @quality.to_s, 2)
- contents.draw_text(4 + s2, line_height * 2, 32, line_height, @points.to_s, 2)
- end
- #--------------------------------------------------------------------------
- # ● Displays the item traits
- #--------------------------------------------------------------------------
- def draw_item_traits
- draw_horz_line(line_height * 3)
- change_color(system_color)
- contents.draw_text(4, line_height * 4, width, line_height, KRX::VOCAB::TRAITS)
- change_color(normal_color)
- (1..4).each {|i| contents.draw_text(0, line_height * (i + 4), width, line_height, "#{i}.")}
- @item.synthesis_traits.each_index do |i|
- trait = @item.synthesis_traits[i]
- contents.draw_text(24, line_height * (i + 5), width - 24, line_height, trait)
- end
- end
- #--------------------------------------------------------------------------
- # ● Displays the synthesis success rate
- #--------------------------------------------------------------------------
- def draw_synthesis_success
- draw_horz_line(line_height * 9)
- change_color(system_color)
- contents.draw_text(4, line_height * 10, width, line_height, KRX::VOCAB::LEVEL)
- contents.draw_text(4, line_height * 11, width, line_height, KRX::VOCAB::SUCCESS_RATE)
- s1 = text_size(KRX::VOCAB::LEVEL).width
- s2 = text_size(KRX::VOCAB::SUCCESS_RATE).width
- change_color(normal_color)
- contents.draw_text(4 + s1, line_height * 10, 32, line_height, @level.to_s, 2)
- case @success
- when 0..19
- change_color(knockout_color)
- when 20..49
- change_color(crisis_color)
- when 50..99
- change_color(normal_color)
- when 100
- change_color(mp_cost_color)
- end
- contents.draw_text(4 + s2, line_height * 11, 48, line_height, "#{@success}%", 2)
- end
- end
- #===========================================================================
- # ■ DataManager
- #===========================================================================
- module DataManager
- #--------------------------------------------------------------------------
- # ● Loads the database
- #--------------------------------------------------------------------------
- class << self
- alias_method(:krx_totori_dm_load_database, :load_database) unless $@
- end
- def self.load_database
- krx_totori_dm_load_database
- load_synth_notetags
- end
- #--------------------------------------------------------------------------
- # ● Loads the note tags
- #--------------------------------------------------------------------------
- def self.load_synth_notetags
- groups = [$data_items, $data_weapons, $data_armors]
- classes = [RPG::Item, RPG::Weapon, RPG::Armor]
- for group in groups
- for obj in group
- next if obj.nil?
- obj.load_synth_notetags if classes.include?(obj.class)
- end
- end
- puts "Read: Alchemic Synthesis Notetags"
- end
- end
- #==========================================================================
- # ■ RPG::Item
- #==========================================================================
- class RPG::Item < RPG::UsableItem
- #--------------------------------------------------------------------------
- # ● Public instance variables
- #--------------------------------------------------------------------------
- attr_reader :recipe_data
- attr_reader :synthesis_reqs
- attr_reader :synthesis_family
- attr_reader :synthesis_level
- #--------------------------------------------------------------------------
- # ● Loads the note tags
- #--------------------------------------------------------------------------
- def load_synth_notetags
- @recipe_data, @synthesis_reqs, @synthesis_traits = [], [], []
- @synthesis_family = nil
- @synthesis_quality, @synthesis_level = 0, 1
- @note.split(/[\r\n]+/).each do |line|
- case line
- when KRX::REGEXP::SYNTHESIS_ITEM
- $1.scan(/\d+/).each {|i| @recipe_data.push($data_items[i.to_i])}
- when KRX::REGEXP::SYNTHESIS_WEAPON
- $1.scan(/\d+/).each {|i| @recipe_data.push($data_weapons[i.to_i])}
- when KRX::REGEXP::SYNTHESIS_ARMOR
- $1.scan(/\d+/).each {|i| @recipe_data.push($data_armors[i.to_i])}
- when KRX::REGEXP::SYNTHESIS_ITEM_REQ
- $1.scan(/\d+/).each {|i| @synthesis_reqs.push($data_items[i.to_i])}
- when KRX::REGEXP::SYNTHESIS_WEAPON_REQ
- $1.scan(/\d+/).each {|i| @synthesis_reqs.push($data_weapons[i.to_i])}
- when KRX::REGEXP::SYNTHESIS_ARMOR_REQ
- $1.scan(/[[:alpha:]]+/).each {|i| @synthesis_reqs.push(i)}
- when KRX::REGEXP::SYNTHESIS_FAMILY
- @synthesis_family = $1
- when KRX::REGEXP::SYNTHESIS_TRAITS
- $1.scan(/[^,]+/).each {|i| @synthesis_traits.push(i)}
- when KRX::REGEXP::SYNTHESIS_QUALITY
- @synthesis_quality = $1.to_i
- when KRX::REGEXP::SYNTHESIS_LEVEL
- @synthesis_level = $1.to_i
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● Returns the synthesis quality
- #--------------------------------------------------------------------------
- def synthesis_quality
- if $game_party.nil? || $game_party.synthesis_quality[self].nil?
- return @synthesis_quality
- end
- return $game_party.synthesis_quality[self]
- end
- #--------------------------------------------------------------------------
- # ● Returns the synthesis traits
- #--------------------------------------------------------------------------
- def synthesis_traits
- if $game_party.nil? || $game_party.synthesis_traits[self].nil?
- return @synthesis_traits
- end
- return (@synthesis_traits + $game_party.synthesis_traits[self])
- end
- #--------------------------------------------------------------------------
- # ● Returns the effects
- #--------------------------------------------------------------------------
- alias_method(:krx_totori_rpgi_effects, :effects) unless $@
- def effects
- new_traits = []
- if synthesis_traits.size > 0
- for key in synthesis_traits
- ary = KRX::Synthesis::Traits[key][2]
- for trait in ary
- new_traits.push(RPG::UsableItem::Effect.new(trait[0],trait[1],trait[2]))
- end
- end
- return @effects + new_traits
- end
- krx_totori_rpgi_effects
- end
- end
- #==========================================================================
- # ■ RPG::Weapon
- #==========================================================================
- class RPG::Weapon < RPG::EquipItem
- #--------------------------------------------------------------------------
- # ● Public instance variables
- #--------------------------------------------------------------------------
- attr_reader :synthesis_reqs
- attr_reader :synthesis_family
- attr_reader :synthesis_level
- #--------------------------------------------------------------------------
- # ● Loads the note tags
- #--------------------------------------------------------------------------
- def load_synth_notetags
- @synthesis_reqs, @synthesis_traits = [], []
- @synthesis_family = nil
- @synthesis_quality, @synthesis_level = 0, 1
- @note.split(/[\r\n]+/).each do |line|
- case line
- when KRX::REGEXP::SYNTHESIS_WEAPON
- $1.scan(/\d+/).each {|i| @recipe_data.push($data_weapons[i.to_i])}
- when KRX::REGEXP::SYNTHESIS_ARMOR
- $1.scan(/\d+/).each {|i| @recipe_data.push($data_armors[i.to_i])}
- when KRX::REGEXP::SYNTHESIS_ITEM_REQ
- $1.scan(/\d+/).each {|i| @synthesis_reqs.push($data_items[i.to_i])}
- when KRX::REGEXP::SYNTHESIS_WEAPON_REQ
- $1.scan(/\d+/).each {|i| @synthesis_reqs.push($data_weapons[i.to_i])}
- when KRX::REGEXP::SYNTHESIS_ARMOR_REQ
- $1.scan(/[[:alpha:]]+/).each {|i| @synthesis_reqs.push(i)}
- when KRX::REGEXP::SYNTHESIS_FAMILY
- @synthesis_family = $1
- when KRX::REGEXP::SYNTHESIS_TRAITS
- $1.scan(/[^,]+/).each {|i| @synthesis_traits.push(i)}
- when KRX::REGEXP::SYNTHESIS_QUALITY
- @synthesis_quality = $1.to_i
- when KRX::REGEXP::SYNTHESIS_LEVEL
- @synthesis_level = $1.to_i
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● Returns the synthesis quality
- #--------------------------------------------------------------------------
- def synthesis_quality
- if $game_party.nil? || $game_party.synthesis_quality[self].nil?
- return @synthesis_quality
- end
- return $game_party.synthesis_quality[self]
- end
- #--------------------------------------------------------------------------
- # ● Returns the synthesis traits
- #--------------------------------------------------------------------------
- def synthesis_traits
- if $game_party.nil? || $game_party.synthesis_traits[self].nil?
- return @synthesis_traits
- end
- return (@synthesis_traits + $game_party.synthesis_traits[self])
- end
- #--------------------------------------------------------------------------
- # ● Returns the features
- #--------------------------------------------------------------------------
- alias_method(:krx_totori_rpgw_features, :features) unless $@
- def features
- new_traits = []
- if synthesis_traits.size > 0
- for key in synthesis_traits
- ary = KRX::Synthesis::Traits[key][2]
- for trait in ary
- new_traits.push(RPG::UsableItem::Effect.new(trait[0],trait[1],trait[2]))
- end
- end
- return @features + new_traits
- end
- krx_totori_rpgw_features
- end
- end
- #==========================================================================
- # ■ RPG::Armor
- #==========================================================================
- class RPG::Armor < RPG::EquipItem
- #--------------------------------------------------------------------------
- # ● Public instance variables
- #--------------------------------------------------------------------------
- attr_reader :synthesis_reqs
- attr_reader :synthesis_family
- attr_reader :synthesis_level
- #--------------------------------------------------------------------------
- # ● Loads the note tags
- #--------------------------------------------------------------------------
- def load_synth_notetags
- @synthesis_reqs, @synthesis_traits = [], []
- @synthesis_family = nil
- @synthesis_quality, @synthesis_level = 0, 1
- @note.split(/[\r\n]+/).each do |line|
- case line
- when KRX::REGEXP::SYNTHESIS_WEAPON
- $1.scan(/\d+/).each {|i| @recipe_data.push($data_weapons[i.to_i])}
- when KRX::REGEXP::SYNTHESIS_ARMOR
- $1.scan(/\d+/).each {|i| @recipe_data.push($data_armors[i.to_i])}
- when KRX::REGEXP::SYNTHESIS_ITEM_REQ
- $1.scan(/\d+/).each {|i| @synthesis_reqs.push($data_items[i.to_i])}
- when KRX::REGEXP::SYNTHESIS_WEAPON_REQ
- $1.scan(/\d+/).each {|i| @synthesis_reqs.push($data_weapons[i.to_i])}
- when KRX::REGEXP::SYNTHESIS_ARMOR_REQ
- $1.scan(/[[:alpha:]]+/).each {|i| @synthesis_reqs.push(i)}
- when KRX::REGEXP::SYNTHESIS_FAMILY
- @synthesis_family = $1
- when KRX::REGEXP::SYNTHESIS_TRAITS
- $1.scan(/[^,]+/).each {|i| @synthesis_traits.push(i)}
- when KRX::REGEXP::SYNTHESIS_QUALITY
- @synthesis_quality = $1.to_i
- when KRX::REGEXP::SYNTHESIS_LEVEL
- @synthesis_level = $1.to_i
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● Returns the synthesis quality
- #--------------------------------------------------------------------------
- def synthesis_quality
- if $game_party.nil? || $game_party.synthesis_quality[self].nil?
- return @synthesis_quality
- end
- return $game_party.synthesis_quality[self]
- end
- #--------------------------------------------------------------------------
- # ● Returns the synthesis traits
- #--------------------------------------------------------------------------
- def synthesis_traits
- if $game_party.nil? || $game_party.synthesis_traits[self].nil?
- return @synthesis_traits
- end
- return (@synthesis_traits + $game_party.synthesis_traits[self])
- end
- #--------------------------------------------------------------------------
- # ● Returns the features
- #--------------------------------------------------------------------------
- alias_method(:krx_totori_rpga_features, :features) unless $@
- def features
- new_traits = []
- if synthesis_traits.size > 0
- for key in synthesis_traits
- ary = KRX::Synthesis::Traits[key][2]
- for trait in ary
- new_traits.push(RPG::UsableItem::Effect.new(trait[0],trait[1],trait[2]))
- end
- end
- return @features + new_traits
- end
- krx_totori_rpga_features
- end
- end
- #==========================================================================
- # ■ Game_Party
- #==========================================================================
- class Game_Party < Game_Unit
- #--------------------------------------------------------------------------
- # ● Public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :synthesis_level
- attr_accessor :synthesis_traits
- attr_accessor :synthesis_quality
- #--------------------------------------------------------------------------
- # ● Object Initialize
- #--------------------------------------------------------------------------
- alias_method(:krx_totori_gp_initialize, :initialize) unless $@
- def initialize
- krx_totori_gp_initialize
- @synthesis_level = 1.00
- @synthesis_traits = {}
- @synthesis_quality = {}
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement