Advertisement
mephis

KrEX - Alchemic Synthesis GO GO TOTORI!

Jan 20th, 2012
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 54.83 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. #  ▼ GO GO TOTORI! (Алхимический синтез)
  3. #  Автор: Kread-EX
  4. #  Версия: 1.01
  5. #  Дата выхода: 08.12.2011
  6. #
  7. #  Перевод: mephis
  8. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  9.  
  10. #-------------------------------------------------------------------------------------------------
  11. #  ▼ ОБНОВЛЕНИЯ
  12. #-------------------------------------------------------------------------------------------------
  13. # # 12/12/2011. Added detection for the future add-ons.
  14. #-------------------------------------------------------------------------------------------------
  15. #  ▼ УСЛОВИЯ ИСПОЛЬЗОВАНИЯ
  16. #-------------------------------------------------------------------------------------------------
  17. # Вы можете изменять код этого скрипта под ваши нужды.
  18. # Вы можете использовать этот скрипт в коммерческих целях.
  19. # Обязательно указывайте автора.
  20. #
  21. # # По поддержке можно со мной связаться здесь:
  22. # # grimoirecastle.wordpress.com
  23. # # или здесь
  24. # # rpgmakervxace.net
  25. # # или здесь
  26. # # rpgrevolution.com
  27. #-------------------------------------------------------------------------------------------------
  28. #  ▼ ВВЕДЕНИЕ
  29. #-------------------------------------------------------------------------------------------------
  30. # Это мощная система синтеза вещей, на создание которой меня вдохновила серия игр
  31. # Atelier от GUST и Atelier Totori в частности.
  32. #
  33. # Каковы её возможности?
  34. # - Создание объектов по рецептам.
  35. # - Замена одного ингридиента другим из той же группы.
  36. # - Задание особенностей ингридиентам и перенос их на готовую вещь.
  37. # - Уровни алхимии и сложность синтеза.
  38. # - Магазин синтеза (отдельный скрипт).
  39. #
  40. # Чего здесь нет?
  41. # - Синтез нескольких копий одной вещи
  42. # - Опыт в алхимии. Сейчас выставлять уровень можно только вручную.
  43. # - Панель эффектов. Если вы не знаете что это такое, то и не важно. А если вы в
  44. #     курсе, то знайте, что я не собираюсь реализовывать её.
  45. # - Время синтеза. В игре Totori синтез может занять несколько дней. Учитывая то,
  46. #     что в играх на RPG Maker системы времени редки, я и не стал делать
  47. #     эту функцию.
  48. # - Особенности, связанные с ценой и качеством.
  49. #-------------------------------------------------------------------------------------------------
  50. #  ▼ ИНСТРУКЦИЯ
  51. #-------------------------------------------------------------------------------------------------
  52. # На этой странице есть подробное описание использования скрипта.
  53. #   http://grimoirecastle.wordpress.com/2011/12/08/alchemic-synthesis-go-go-totori/
  54. # К сожалению, не совсем простое для понимания.
  55. #-------------------------------------------------------------------------------------------------
  56. #  ▼ СОВМЕСТИМОСТЬ
  57. #-------------------------------------------------------------------------------------------------
  58. # Пока что на Ace не так много скриптов, но этот должен нормально работать со
  59. # скриптами Yanfly.
  60. #
  61. # Новые классы: Scene_Alchemy, Window_SynthesisList, Window_SynthesisProp,
  62. #   Window_IngredientList, Window_IngredientProp, Window_ItemFamily,
  63. #   Window_TraitList, Window_FinalItem
  64. #  
  65. # Список псевдонимов и перекрытий:
  66. #  DataManager
  67. #   load_database (alias)
  68. #   load_synth_notetags (new method)
  69. #  
  70. #  Game_Party
  71. #   initialize (alias)
  72. #  
  73. #  RPG::Item, RPG::Weapon, RPG::Armor
  74. #   load_synth_notetags (new method)
  75. #   synthesis_traits (new method)
  76. #   effects (alias)
  77. #   features (alias)
  78. #-------------------------------------------------------------------------------------------------
  79.  
  80. $imported = {} if $imported.nil?
  81. $imported['KRX-AlchemicSynthesis'] = true
  82.  
  83. # Ace grants us a debug console, and this is awesome.
  84. puts 'Load: Alchemic Synthesis ~GO GO TOTORI!~ v1.01 by Kread-EX'
  85.  
  86. module KRX
  87.  
  88.   module REGEXP
  89.     SYNTHESIS_ITEM = /<synth_item:[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  90.     SYNTHESIS_ITEM_REQ = /<synth_req_item:[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  91.     SYNTHESIS_WEAPON = /<synth_weapon:[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  92.     SYNTHESIS_WEAPON_REQ = /<synth_req_weapon:[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  93.     SYNTHESIS_ARMOR = /<synth_armor:[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  94.     SYNTHESIS_ARMOR_REQ = /<synth_req_armor[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  95.     SYNTHESIS_FAMILY = /<synth_family:[ ]*([[:alpha:]]+)>/i
  96.     SYNTHESIS_TRAITS = /<synth_traits:[ ]*([^,]+(?:,[^,]+)*)>/i
  97.     SYNTHESIS_QUALITY = /<synth_quality:[ ]*(\d+)>/i
  98.     SYNTHESIS_LEVEL = /<synth_level:[ ]*(\d+)>/i
  99.   end
  100.  
  101.   module VOCAB
  102.     TRAITS = 'Особенности'
  103.     INGREDIENTS = 'Ингридиенты'
  104.     QUALITY = 'Качество:'
  105.     SYNTH_POINTS = 'Очки синтеза:'
  106.     CAULDRON = 'Котёл'
  107.     LEVEL = 'Уровень синтеза:'
  108.     SUCCESS_RATE = 'Шанс успеха:'
  109.     SYNTH_FAILED = 'Синтез не удался!'
  110.     SYNTH_SUCCESS = 'Синтез прошёл успешно!'
  111.   end
  112.  
  113.   #==========================================================================
  114.   #  ■  СИНТЕЗ
  115.   #----------------------------------------------------------------------------------------
  116.   # ОСОБЕННОСТИ
  117.   #----------------------------------------------------------------------------------------
  118.   # Здесь перечислены все возможные эффекты в синтезе и их Цена Синтеза.
  119.   # Вы можете добавить свои эффекты, если понимаете в скриптинге, но
  120.   # в данный момент здесь используются стандартные эффекты VX Ace.
  121.   #
  122.   # Я добавлю больше особенностей когда выйдет полная версия.
  123.   #
  124.   # СИНТАКСИС ДЛЯ ЭКИПИРОВКИ
  125.   # Название особенности => [0, Цена, [[Код свойства, ID свойства, Цена свойства]], Описание]
  126.   # СИНТАКСИС ДЛЯ ИСПОЛЬЗУЕМОЙ ВЕЩИ
  127.   # Название особенности => [1, Цена, [[Код эффекта, ID эффекта, Цена эффекта 1, Цена Эффекта 2]], Описание]
  128.   #
  129.   # Важное замечание: определённые эффекты могут не складываться. Например,
  130.   #  некоторые эффекты восстановления здоровья не складываются - если вы
  131.   #  выберете один, то не сможете выбрать другие.
  132.   #==========================================================================
  133.  
  134.   module Synthesis
  135.  
  136.     # Индексы массивов
  137.    
  138.     TRAIT_CATEGORY = 0
  139.     TRAIT_COST = 1
  140.     TRAIT_OBJECTS = 2
  141.     TRAIT_HELP = 3
  142.  
  143.     Traits = {
  144.    
  145.     # Особенности для экипирующихся вещей
  146.    
  147.     "Отравленный" => [0, 3, [[32, 2, 0.5]], "Отравляет с 50%-ым шансом."],
  148.     "Ядовитый" => [0, 8, [[32, 2, 1.0]], "Отравляет со 100%-ым шансом."],
  149.     "Сила дракона" => [0, 10, [[22, 2, 0.25]], "Повышает шанс критического удара на 25%."],
  150.     "Уменьшитель урона" => [0, 20, [[23, 6, 0.5], [23, 7, 0.5]], "Уменьшает вдвое полученный урон."],
  151.     "Карта безопасности" => [0, 8, [[64, 0, 0.0]], "Снижает частоту случайных сражений."],
  152.     "Хорошая удача" => [0, 25, [[64, 4, 0.0]], "Удваивает полученные деньги."],
  153.     "Великий ученик" => [0, [[25, 23, 9]], 1.5, "Увеличивает получаемый опыт на 50%."],
  154.     "Щит огня" => [0, 10, [[11, 3, 0.0]], "Полностью защищает от огненного урона."],
  155.     "Щит льда" => [0, 10, [[11, 4, 0.0]], "Полностью защищает от ледяного урона."],
  156.     "Щит молнии" => [0, 10, [[11, 5, 0.0]], "Полностью защищает от урона молнией."],
  157.     "Щит воды" => [0, 10, [[11, 6, 0.0]], "Полностью защищает от урона водой."],
  158.     "Щит земли" => [0, 10, [[11, 7, 0.0]], "Полностью защищает от урона землёй."],
  159.     "Щит ветра" => [0, 10, [[11, 8, 0.0]], "Полностью защищает от урона ветром."],
  160.     "Сила ниндзи" => [0, 15, [[22, 1, 1.0]], "Повышает Уклонение"],
  161.     "Душа героя" => [0, 15, [[21, 0, 1.5]], "Увеличивает максимальные HP."],
  162.     "Двойной ход" => [0, 20, [[61, 0, 1.0]], "Позволяет действовать дважды за ход."],
  163.     "Огонь" => [0, 3, [[41, 2, 0.0], [43, 3, 0.0]], "Герой может использовать заклинание огня."],
  164.     "Ветер" => [0, 6, [[41, 2, 0.0], [43, 4, 0.0]], "Герой может использовать заклинание ветра."],
  165.     "Лечение" => [0, 3, [[41, 2, 0.0], [43, 5, 0.0]], "Герой может использовать заклинание лечения."],
  166.     "Воскрешение" => [0, 6, [[41, 2, 0.0], [43, 6, 0.0]], "Герой может использовать заклинание воскрешения."],
  167.    
  168.     # Особенности для используемых вещей
  169.    
  170.     "Атк+" => [1, 5, [[31, 2, 5.0, 0.0]], "Повышает Атаку на 5 ходов."],
  171.     "Защ+" => [1, 5, [[31, 3, 5.0, 0.0]], "Повышает Защиту на 5 ходов."],
  172.     "Маг+" => [1, 5, [[31, 4, 5.0, 0.0]], "Повышает Маг. атаку на 5 ходов."],
  173.     "Мгз+" => [1, 5, [[31, 5, 5.0, 0.0]], "Повышает Маг. защиту на 5 ходов."],
  174.     "Прв+" => [1, 5, [[31, 6, 5.0, 0.0]], "Повышает Проворство на 5 ходов."],
  175.     "Удч+" => [1, 5, [[31, 7, 5.0, 0.0]], "Повышает Удачу на 5 ходов."],
  176.     "Атк-" => [1, 5, [[32, 2, 5.0, 0.0]], "Снижает Атаку на 5 ходов."],
  177.     "Защ-" => [1, 5, [[32, 3, 5.0, 0.0]], "Снижает Защиту на 5 ходов."],
  178.     "Маг-" => [1, 5, [[32, 4, 5.0, 0.0]], "Снижает Маг. атаку на 5 ходов."],
  179.     "Мгз-" => [1, 5, [[32, 5, 5.0, 0.0]], "Снижает Маг. защиту на 5 ходов."],
  180.     "Прв-" => [1, 5, [[32, 6, 5.0, 0.0]], "Снижает Проворство на 5 ходов."],
  181.     "Удч-" => [1, 5, [[32, 7, 5.0, 0.0]], "Снижает Удачу на 5 ходов."],
  182.     "Восстановление здоровья XS" => [1, 1, [[11, 0, 0.1, 0.0]], "Восстанавливает 10% HP."],
  183.     "Восстановление здоровья S" => [1, 4, [[11, 0, 0.25, 0.0]], "Восстанавливает 25% HP."],
  184.     "Восстановление здоровья M" => [1, 8, [[11, 0, 0.5, 0.0]], "Восстанавливает 50% HP."],
  185.     "Восстановление здоровья L" => [1, 16, [[11, 0, 0.75, 0.0]], "Восстанавливает 75% HP."],
  186.     "Восстановление здоровья XL" => [1, 25, [[11, 0, 1.0, 0.0]], "Восстанавливает 100% HP."],
  187.     "Восстановление маны XS" => [1, 1, [[12, 0, 0.1, 0.0]], "Восстанавливает 10% MP."],
  188.     "Восстановление маны S" => [1, 4, [[12, 0, 0.25, 0.0]], "Восстанавливает 25% MP."],
  189.     "Восстановление маны M" => [1, 8, [[12, 0, 0.5, 0.0]], "Восстанавливает 50% MP."],
  190.     "Восстановление маны L" => [1, 16, [[12, 0, 0.75, 0.0]], "Восстанавливает 75% MP."],
  191.     "Восстановление маны XL" => [1, 25, [[12, 0, 1.0, 0.0]], "Восстанавливает 100% MP."],
  192.     "Восстановление техники XS" => [1, 1, [[13, 0, 2.0, 0.0]], "Восстанавливает 2% TP."],
  193.     "Восстановление техники S" => [1, 4, [[13, 0, 5.0, 0.0]], "Восстанавливает 5% TP."],
  194.     "Восстановление техники M" => [1, 8, [[13, 0, 10.0, 0.0]], "Восстанавливает 10% TP."],
  195.     "Восстановление техники L" => [1, 16, [[13, 0, 16.0, 0.0]], "Восстанавливает 16% TP."],
  196.     "Восстановление техники XL" => [1, 25, [[13, 0, 20.0, 0.0]], "Восстанавливает 20% TP."],
  197.     "Воскрешение XS" => [1, 1, [[22, 1, 1.0, 0.0], [11, 0, 0.1, 0.0]], "Воскрешает и восстанавливает 10% HP."],
  198.     "Воскрешение S" => [1, 4, [[22, 1, 1.0, 0.0], [11, 0, 0.25, 0.0]], "Воскрешает и восстанавливает 25% HP."],
  199.     "Воскрешение M" => [1, 8, [[22, 1, 1.0, 0.0], [11, 0, 0.5, 0.0]], "Воскрешает и восстанавливает 50% HP."],
  200.     "Воскрешение L" => [1, 16, [[22, 1, 1.0, 0.0], [11, 0, 0.75, 0.0]], "Воскрешает и восстанавливает 75% HP."],
  201.     "Воскрешение XL" => [1, 25, [[22, 1, 1.0, 0.0], [11, 0, 1.0, 0.0]], "Воскрешает и восстанавливает 100% HP."],
  202.     "Противоядие" => [1, 1, [[22, 2, 1.0, 0.0]], "Снимает отравление."],
  203.     "Поглощатель магии" => [1, 13, [[12, 0, -0.75, 0.0]], "Уменьшает MP на 75%."]
  204.    
  205.     }
  206.    
  207.   end
  208.  
  209. end
  210.  
  211. #==========================================================================
  212. #  ■  Scene_Alchemy
  213. #==========================================================================
  214.  
  215. class Scene_Alchemy < Scene_MenuBase
  216.   #--------------------------------------------------------------------------
  217.   # ● Scene start
  218.   #--------------------------------------------------------------------------
  219.   def start
  220.     super
  221.     @item_cauldron, @family_cauldron = [], []
  222.     @old_traits = $game_party.synthesis_traits.dup
  223.     @old_qual = $game_party.synthesis_quality.dup
  224.     create_help_window
  225.     create_category_window
  226.     create_properties_window
  227.     create_item_window
  228.   end
  229.   #--------------------------------------------------------------------------
  230.   # ● Creates the window displaying the item categories
  231.   #--------------------------------------------------------------------------
  232.   def create_category_window
  233.     @category_window = Window_ItemCategory.new
  234.     @category_window.viewport = @viewport
  235.     @category_window.help_window = @help_window
  236.     @category_window.y = @help_window.height
  237.     @category_window.set_handler(:ok,     method(:on_category_ok))
  238.     @category_window.set_handler(:cancel, method(:return_scene))
  239.   end
  240.   #--------------------------------------------------------------------------
  241.   # ● Creates the window displaying the item's properies and requirements
  242.   #--------------------------------------------------------------------------
  243.   def create_properties_window
  244.     wy = @category_window.y + @category_window.height
  245.     wh = Graphics.height - wy
  246.     @prop_window = Window_SynthesisProp.new(Graphics.width / 2, wy, Graphics.width / 2, wh)
  247.     @prop_window.viewport = @viewport
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ● Creates the window displaying the items available to synthesis
  251.   #--------------------------------------------------------------------------
  252.   def create_item_window
  253.     wy = @category_window.y + @category_window.height
  254.     wh = Graphics.height - wy
  255.     @item_window = Window_SynthesisList.new(0, wy, Graphics.width / 2, wh)
  256.     @item_window.viewport = @viewport
  257.     @item_window.help_window = @help_window
  258.     @item_window.prop_window = @prop_window
  259.     @item_window.set_handler(:ok,     method(:on_item_ok))
  260.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  261.     @category_window.item_window = @item_window
  262.   end
  263.   #--------------------------------------------------------------------------
  264.   # ● Creates the window displaying the iavailable ingredients
  265.   #--------------------------------------------------------------------------
  266.   def create_ingredient_window
  267.     wy = @category_window.y + @category_window.height
  268.     wh = Graphics.height - wy
  269.     @i_prop_window = Window_IngredientProp.new(Graphics.width / 2, wy, Graphics.width / 2, wh)
  270.     @i_prop_window.viewport = @viewport
  271.     @ing_window = Window_IngredientList.new(0, wy, Graphics.width / 2, wh, @item_window.item)
  272.     @ing_window.viewport = @viewport
  273.     @ing_window.help_window = @help_window
  274.     @ing_window.prop_window = @i_prop_window
  275.     @ing_window.set_handler(:ok,     method(:on_ing_ok))
  276.     @ing_window.set_handler(:cancel, method(:on_ing_cancel))
  277.     @family_window = Window_ItemFamily.new
  278.     @family_window.y = @help_window.height
  279.     @family_window.item_window = @ing_window
  280.     @family_window.set_handler(:ok,     method(:on_family_ok))
  281.     @family_window.set_handler(:cancel,     method(:on_family_cancel))
  282.     @family_window.activate
  283.     @family_window.select(0)
  284.   end
  285.   #--------------------------------------------------------------------------
  286.   # ● Creates the windows related to the cauldron
  287.   #--------------------------------------------------------------------------
  288.   def create_cauldron_windows
  289.     wy = @help_window.y + @help_window.height
  290.     wh = Graphics.height - wy
  291.     ww = Graphics.width / 2
  292.     @trait_window = Window_TraitList.new(0, wy, ww, wh, @points)
  293.     @trait_window.refresh
  294.     @trait_window.activate
  295.     @trait_window.select(0)
  296.     @trait_window.help_window = @help_window
  297.     @trait_window.set_handler(:ok, method(:on_trait_ok))
  298.     @trait_window.set_handler(:cancel, method(:on_trait_cancel))
  299.     @final_window = Window_FinalItem.new(ww, wy, ww, wh, @quality, @points,
  300.     @level, @success)
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # ● Destroys the ingredient-related windows
  304.   #--------------------------------------------------------------------------
  305.   def destroy_ingredient_windows
  306.     @ing_window.dispose; @ing_window = nil
  307.     @family_window.dispose; @family_window = nil
  308.     @i_prop_window.dispose; @i_prop_window = nil
  309.   end
  310.   #--------------------------------------------------------------------------
  311.   # ● Destroys the cauldron-related windows
  312.   #--------------------------------------------------------------------------
  313.   def destroy_cauldron_windows
  314.     @trait_window.dispose; @trait_window = nil
  315.     @final_window.dispose; @final_window = nil
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   # ● Returns the current ingredient selection
  319.   #--------------------------------------------------------------------------
  320.   def cauldron(item = false)
  321.     item ? @item_cauldron : @family_cauldron
  322.   end
  323.   #--------------------------------------------------------------------------
  324.   # ● Update the cauldron contents
  325.   #--------------------------------------------------------------------------
  326.   def update_cauldron(add = true)
  327.     if add
  328.       @item_cauldron.push(@ing_window.item)
  329.       @family_cauldron.push(@ing_window.item.synthesis_family)
  330.       @ing_window.unselect
  331.      
  332.     else
  333.       @item_cauldron.pop
  334.       @family_cauldron.pop
  335.     end
  336.     @family_window.refresh
  337.     @family_window.update
  338.     @family_window.activate
  339.     @family_window.select(0)
  340.     @ing_window.update_help
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # ● Determine the final quality of the item
  344.   #--------------------------------------------------------------------------
  345.   def compute_quality
  346.     total_value = 0
  347.     ary = []
  348.     ary = @item_cauldron.collect {|itm| itm.synthesis_quality}
  349.     ary.each {|v| total_value += v}
  350.     rate = total_value / ary.size
  351.     @quality = rate
  352.     @points = rate
  353.     $game_party.synthesis_quality[$game_party.last_item.object] = rate
  354.   end
  355.   #--------------------------------------------------------------------------
  356.   # ● Determine the synthesis success rate
  357.   #--------------------------------------------------------------------------
  358.   def compute_success
  359.     @level = $game_party.last_item.object.synthesis_level
  360.     @success = (100 * ($game_party.synthesis_level / @level)).round
  361.   end
  362.   #--------------------------------------------------------------------------
  363.   # ● Synthesis outcome
  364.   #--------------------------------------------------------------------------
  365.   def process_outcome(failure = false)
  366.     destroy_cauldron_windows
  367.     wy = Graphics.height / 2 - @help_window.height / 2
  368.     @help_window.move(0, wy, Graphics.width, @help_window.height - 16)
  369.     @help_window.arrows_visible = false
  370.     if failure
  371.       @help_window.set_text(KRX::VOCAB::SYNTH_FAILED)
  372.       $game_party.synthesis_traits = @old_traits.dup
  373.       $game_party.synthesis_quality = @old_qual.dup
  374.     else
  375.       @help_window.set_text(KRX::VOCAB::SYNTH_SUCCESS)
  376.       $game_party.gain_item($game_party.last_item.object, 1)
  377.     end
  378.    
  379.     cauldron(true).each do |item|
  380.       $game_party.lose_item(item, 1)
  381.     end
  382.     Graphics.wait(40)
  383.     on_item_cancel
  384.     @help_window.move(0, 0, Graphics.width, @help_window.height + 16)
  385.   end
  386.   #--------------------------------------------------------------------------
  387.   # ● Confirms the category selection
  388.   #--------------------------------------------------------------------------
  389.   def on_category_ok
  390.     @item_window.activate
  391.     @item_window.select_last
  392.   end
  393.   #--------------------------------------------------------------------------
  394.   # ● Confirms the item selection
  395.   #--------------------------------------------------------------------------
  396.   def on_item_ok
  397.     $game_party.last_item.object = @item_window.item
  398.     @item_window.hide
  399.     @category_window.hide
  400.     @prop_window.hide
  401.     create_ingredient_window
  402.   end
  403.   #--------------------------------------------------------------------------
  404.   # ● Returns to the category selection
  405.   #--------------------------------------------------------------------------
  406.   def on_item_cancel
  407.     @item_window.unselect
  408.     @item_window.show
  409.     @item_window.refresh
  410.     @prop_window.set_item(nil)
  411.     @prop_window.show
  412.     @category_window.activate
  413.     @category_window.show
  414.   end
  415.   #--------------------------------------------------------------------------
  416.   # ● Confirms the family selection
  417.   #--------------------------------------------------------------------------
  418.   def on_family_ok
  419.     @family_window.deactivate
  420.     @ing_window.select_last
  421.     @ing_window.activate
  422.   end
  423.   #--------------------------------------------------------------------------
  424.   # ● Returns to the item selection
  425.   #--------------------------------------------------------------------------
  426.   def on_family_cancel
  427.     unless cauldron.empty?
  428.       update_cauldron(false)
  429.       return
  430.     end
  431.     destroy_ingredient_windows
  432.     @item_window.show
  433.     @item_window.activate
  434.     @category_window.show
  435.     @prop_window.show
  436.   end
  437.   #--------------------------------------------------------------------------
  438.   # ● Confirms the ingredient selection
  439.   #--------------------------------------------------------------------------
  440.   def on_ing_ok
  441.     update_cauldron
  442.     if cauldron.size == $game_party.last_item.object.synthesis_reqs.size
  443.       compute_quality
  444.       compute_success
  445.       destroy_ingredient_windows
  446.       create_cauldron_windows
  447.     end
  448.   end
  449.   #--------------------------------------------------------------------------
  450.   # ● Returns to the family selection
  451.   #--------------------------------------------------------------------------
  452.   def on_ing_cancel
  453.     @ing_window.unselect
  454.     @i_prop_window.set_item(nil)
  455.     @family_window.activate
  456.   end
  457.   #--------------------------------------------------------------------------
  458.   # ● Validates a trait selection
  459.   #--------------------------------------------------------------------------
  460.   def on_trait_ok
  461.     item = $game_party.last_item.object
  462.     trait = @trait_window.item
  463.     if trait == 'Finish!'
  464.       if (rand(100) + 1) < @success
  465.         process_outcome
  466.       else
  467.         process_outcome(true)
  468.       end
  469.       return
  470.     end
  471.     if $game_party.synthesis_traits[item] == nil
  472.       $game_party.synthesis_traits[item] = []
  473.     end
  474.     $game_party.synthesis_traits[item].push(trait)
  475.     $game_party.synthesis_traits[item].flatten!
  476.     @points -= KRX::Synthesis::Traits[trait][KRX::Synthesis::TRAIT_COST]
  477.     @trait_window.remove_item(trait, @points)
  478.     @trait_window.activate
  479.     @final_window.update_points(@points)
  480.     @final_window.set_item(item)
  481.   end
  482.   #--------------------------------------------------------------------------
  483.   # ● Returns to the ingredient selection
  484.   #--------------------------------------------------------------------------
  485.   def on_trait_cancel
  486.     @family_cauldron.clear
  487.     @item_cauldron.clear
  488.     $game_party.synthesis_traits = @old_traits.dup
  489.     destroy_cauldron_windows
  490.     create_ingredient_window
  491.   end
  492. end
  493.  
  494. #==========================================================================
  495. #  ■  Window_SynthesisList
  496. #==========================================================================
  497.  
  498. class Window_SynthesisList < Window_ItemList
  499.   #--------------------------------------------------------------------------
  500.   # ● Determine if an item goes in the list
  501.   #--------------------------------------------------------------------------
  502.   def include?(item)
  503.     case @category
  504.     when :item
  505.       item.is_a?(RPG::Item) && !item.key_item?
  506.     when :weapon
  507.       item.is_a?(RPG::Weapon)
  508.     when :armor
  509.       item.is_a?(RPG::Armor)
  510.     when :key_item
  511.       item.is_a?(RPG::Item) && item.key_item?
  512.     else
  513.       return false
  514.     end
  515.   end
  516.   #--------------------------------------------------------------------------
  517.   # ● Determine if the required ingredients for synthesis are available
  518.   #--------------------------------------------------------------------------
  519.   def enable?(item)
  520.     return false if item.nil?
  521.     ok = []
  522.     families = item.synthesis_reqs.collect {|x| x.synthesis_family}
  523.     families.each do |family|
  524.       for itm in $game_party.all_items
  525.         next unless itm.synthesis_family == family
  526.         if  $game_party.item_number(itm) >= 1
  527.           ok.push(true)
  528.           break
  529.         end
  530.       end
  531.     end
  532.     return ok.size == item.synthesis_reqs.size
  533.   end
  534.   #--------------------------------------------------------------------------
  535.   # ● Creates the list based on the recipes
  536.   #--------------------------------------------------------------------------
  537.   def make_item_list
  538.     @data = []
  539.     recipes = $game_party.items.select {|item| !item.recipe_data.empty?}
  540.     for rec in recipes
  541.       for syn in rec.recipe_data
  542.         @data.push(syn) if include?(syn)
  543.       end
  544.     end
  545.   end
  546.   #--------------------------------------------------------------------------
  547.   # ● Displays the item icon and name
  548.   #--------------------------------------------------------------------------
  549.   def draw_item(index)
  550.     item = @data[index]
  551.     if item
  552.       rect = item_rect(index)
  553.       rect.width -= 4
  554.       draw_item_name(item, rect.x, rect.y, enable?(item))
  555.     end
  556.   end
  557.   #--------------------------------------------------------------------------
  558.   # ● Assigns a properties window
  559.   #--------------------------------------------------------------------------
  560.   def prop_window=(value)
  561.     @prop_window = value
  562.   end
  563.   #--------------------------------------------------------------------------
  564.   # ● Refreshes the help and prop windows
  565.   #--------------------------------------------------------------------------
  566.   def update_help
  567.     @help_window.set_item(item)
  568.     @prop_window.set_item(item)
  569.   end
  570.   #--------------------------------------------------------------------------
  571.   # ● Returns the number of columns
  572.   #--------------------------------------------------------------------------
  573.   def col_max
  574.     return 1
  575.   end
  576. end
  577.  
  578. #==========================================================================
  579. #  ■  Window_IngredientList
  580. #==========================================================================
  581.  
  582. class Window_IngredientList < Window_ItemList
  583.   #--------------------------------------------------------------------------
  584.   # ● Object Initialize
  585.   #--------------------------------------------------------------------------
  586.   def initialize(x, y, w, h, item)
  587.     super(x, y, w, h)
  588.     @base_item = item
  589.     refresh
  590.   end
  591.   #--------------------------------------------------------------------------
  592.   # ● Determine if an item goes in the list
  593.   #--------------------------------------------------------------------------
  594.   def number?
  595.     case @category
  596.     when :ing0
  597.       return 0
  598.     when :ing1
  599.       return 1
  600.     when :ing2
  601.       return 2
  602.     when :ing3
  603.       return 3
  604.     else
  605.       return 0
  606.     end
  607.   end
  608.   #--------------------------------------------------------------------------
  609.   # ● Enable (always true)
  610.   #--------------------------------------------------------------------------
  611.   def enable?(item)
  612.     return true
  613.   end
  614.   #--------------------------------------------------------------------------
  615.   # ● Creates the list based on the recipes
  616.   #--------------------------------------------------------------------------
  617.   def make_item_list
  618.     family = @base_item.synthesis_reqs[number?].synthesis_family
  619.     @data = $game_party.all_items.select {|itm| itm.synthesis_family == family}
  620.   end
  621.   #--------------------------------------------------------------------------
  622.   # ● Returns the number of columns
  623.   #--------------------------------------------------------------------------
  624.   def col_max
  625.     return 1
  626.   end
  627.   #--------------------------------------------------------------------------
  628.   # ● Assigns a properties window
  629.   #--------------------------------------------------------------------------
  630.   def prop_window=(value)
  631.     @prop_window = value
  632.   end
  633.   #--------------------------------------------------------------------------
  634.   # ● Refreshes the help and prop windows
  635.   #--------------------------------------------------------------------------
  636.   def update_help
  637.     @help_window.set_item(item)
  638.     @prop_window.set_item(item)
  639.   end
  640. end
  641.  
  642. #==========================================================================
  643. #  ■  Window_SynthesisProp
  644. #==========================================================================
  645.  
  646. class Window_SynthesisProp < Window_Base
  647.   #--------------------------------------------------------------------------
  648.   # ● Object Initialize
  649.   #--------------------------------------------------------------------------
  650.   def initialize(x, y, width, height)
  651.     super
  652.     set_item
  653.   end
  654.   #--------------------------------------------------------------------------
  655.   # ● Refresh the contents
  656.   #--------------------------------------------------------------------------
  657.   def set_item(item = nil)
  658.     contents.clear
  659.     return if item.nil?
  660.     draw_item_traits(item)
  661.     draw_item_ingredients(item)
  662.   end
  663.   #--------------------------------------------------------------------------
  664.   # ● Displays the item's traits
  665.   #--------------------------------------------------------------------------
  666.   def draw_item_traits(item)
  667.     change_color(system_color)
  668.     contents.draw_text(0, 0, width, line_height, KRX::VOCAB::TRAITS)
  669.     change_color(normal_color)
  670.     (1..4).each {|i| contents.draw_text(0, line_height * i, width, line_height, "#{i}.")}
  671.     item.synthesis_traits.each_index do |i|
  672.       trait = item.synthesis_traits[i]
  673.       contents.draw_text(24, line_height * (i + 1), width - 24, line_height, trait)
  674.     end
  675.     draw_horz_line(line_height * 5)
  676.   end
  677.   #--------------------------------------------------------------------------
  678.   # ● Displays the item's requires ingredients
  679.   #--------------------------------------------------------------------------
  680.   def draw_item_ingredients(item)
  681.     change_color(system_color)
  682.     contents.draw_text(0, line_height * 6, width, line_height, KRX::VOCAB::INGREDIENTS)
  683.     change_color(normal_color)
  684.     item.synthesis_reqs.each_index do |i|
  685.       itm = item.synthesis_reqs[i]
  686.       draw_item_name(itm, 0, line_height * (i + 7), true, width)
  687.     end
  688.   end
  689.   #--------------------------------------------------------------------------
  690.   # ● Displays an horizontal line
  691.   #--------------------------------------------------------------------------
  692.   def draw_horz_line(y)
  693.     line_y = y + line_height / 2 - 1
  694.     contents.fill_rect(0, line_y, contents_width, 2, line_color)
  695.   end
  696.   #--------------------------------------------------------------------------
  697.   # ● Returns the color used for horizontal lines
  698.   #--------------------------------------------------------------------------
  699.   def line_color
  700.     color = normal_color
  701.     color.alpha = 48
  702.     return color
  703.   end
  704. end
  705.  
  706. #==========================================================================
  707. #  ■  Window_IngredientProp
  708. #==========================================================================
  709.  
  710. class Window_IngredientProp < Window_SynthesisProp
  711.   #--------------------------------------------------------------------------
  712.   # ● Refresh the contents
  713.   #--------------------------------------------------------------------------
  714.   def set_item(item = nil)
  715.     contents.clear
  716.     draw_current_cauldron
  717.     return if item.nil?
  718.     draw_item_traits(item)
  719.   end
  720.   #--------------------------------------------------------------------------
  721.   # ● Displays the item's traits
  722.   #--------------------------------------------------------------------------
  723.   def draw_item_traits(item)
  724.     change_color(system_color)
  725.     contents.draw_text(0, 0, width, line_height, KRX::VOCAB::QUALITY)
  726.     size = text_size(KRX::VOCAB::QUALITY).width
  727.     change_color(normal_color)
  728.     contents.draw_text(size, 0, 32, line_height, item.synthesis_quality, 2)
  729.     return if item.synthesis_traits.empty?
  730.     item.synthesis_traits.each_index do |i|
  731.       cost = KRX::Synthesis::Traits[item.synthesis_traits[i]][KRX::Synthesis::TRAIT_COST]
  732.       contents.draw_text(0, line_height * (i + 1), width, line_height, "#{i + 1}.")
  733.       contents.draw_text(24, line_height * (i + 1), width - 24, line_height,
  734.       "#{item.synthesis_traits[i]} (#{cost})")
  735.     end
  736.   end
  737.   #--------------------------------------------------------------------------
  738.   # ● Displays the current ingredient selection
  739.   #--------------------------------------------------------------------------
  740.   def draw_current_cauldron
  741.     draw_horz_line(line_height * 5)
  742.     change_color(system_color)
  743.     contents.draw_text(0, line_height * 6, width, line_height, KRX::VOCAB::CAULDRON)
  744.     return if SceneManager.scene.cauldron.empty?
  745.     change_color(normal_color)
  746.     SceneManager.scene.cauldron.each_index do |i|
  747.       draw_item_name(SceneManager.scene.cauldron(true)[i], 0, line_height * (i + 7), true, width)
  748.     end
  749.   end
  750. end
  751.  
  752. #==========================================================================
  753. #  ■  Window_ItemFamily
  754. #==========================================================================
  755.  
  756. class Window_ItemFamily < Window_ItemCategory
  757.   #--------------------------------------------------------------------------
  758.   # ● Create the commands list
  759.   #--------------------------------------------------------------------------
  760.   def make_command_list
  761.     itm = $game_party.last_item.object
  762.     return if itm.nil?
  763.     (0...itm.synthesis_reqs.size).each do |i|
  764.       fam = itm.synthesis_reqs[i].synthesis_family
  765.       next if SceneManager.scene.cauldron.include?(fam)
  766.       symb = "ing#{i}".to_sym
  767.       add_command(fam, symb)
  768.     end
  769.   end
  770. end
  771.  
  772. #==========================================================================
  773. #  ■  Window_TraitList
  774. #==========================================================================
  775.  
  776. class Window_TraitList < Window_ItemList
  777.   #--------------------------------------------------------------------------
  778.   # ● Object Initialize
  779.   #--------------------------------------------------------------------------
  780.   def initialize(x, y, w, h, p)
  781.     @points = p
  782.     @deleted = []
  783.     super(x, y, w, h)
  784.   end
  785.   #--------------------------------------------------------------------------
  786.   # ● Lists the traits of the items in the cauldron
  787.   #--------------------------------------------------------------------------
  788.   def make_item_list
  789.     @data = []
  790.     cat = case $game_party.last_item.object
  791.       when RPG::EquipItem then 0
  792.       when RPG::Item then 1
  793.     end
  794.     SceneManager.scene.cauldron(true).each do |item|
  795.       @data.push(item.synthesis_traits)
  796.     end
  797.     @data.flatten!
  798.     @data.uniq!
  799.     @data.select! do |x| (!@deleted.include?(x) &&
  800.       KRX::Synthesis::Traits[x][KRX::Synthesis::TRAIT_CATEGORY] == cat)
  801.     end
  802.     @data.push('Finish!')
  803.   end
  804.   #--------------------------------------------------------------------------
  805.   # ● Enable (always true)
  806.   #--------------------------------------------------------------------------
  807.   def enable?(item)
  808.     return true if item == 'Finish!'
  809.     @points >= KRX::Synthesis::Traits[item][KRX::Synthesis::TRAIT_COST]
  810.    end
  811.   #--------------------------------------------------------------------------
  812.   # ● Remove a trait
  813.   #--------------------------------------------------------------------------
  814.   def remove_item(trait, points)
  815.     @deleted.push(trait)
  816.     @points = points
  817.     refresh
  818.   end
  819.   #--------------------------------------------------------------------------
  820.   # ● Displays the trait name and cost
  821.   #--------------------------------------------------------------------------
  822.   def draw_item(index)
  823.     key = @data[index]
  824.     change_color(normal_color, enable?(key))
  825.     contents.draw_text(4, index * line_height, width, line_height, key)
  826.     return if key == 'Finish!'
  827.     cost = KRX::Synthesis::Traits[key][KRX::Synthesis::TRAIT_COST]
  828.     contents.draw_text(4, index * line_height, width - 32, line_height, cost, 2)
  829.   end
  830.   #--------------------------------------------------------------------------
  831.   # ● Returns the number of columns
  832.   #--------------------------------------------------------------------------
  833.   def col_max
  834.     return 1
  835.   end
  836.   #--------------------------------------------------------------------------
  837.   # ● Refreshes the help window
  838.   #--------------------------------------------------------------------------
  839.   def update_help
  840.     if @data[index] == 'Finish!'
  841.       help = 'Perform synthesis.'
  842.     else
  843.       help = KRX::Synthesis::Traits[@data[index]][KRX::Synthesis::TRAIT_HELP]
  844.     end
  845.     @help_window.set_text(help)
  846.   end
  847. end
  848.  
  849. #==========================================================================
  850. #  ■  Window_FinalItem
  851. #==========================================================================
  852.  
  853. class Window_FinalItem < Window_SynthesisProp
  854.   #--------------------------------------------------------------------------
  855.   # ● Object Initialize
  856.   #--------------------------------------------------------------------------
  857.   def initialize(x, y, w, h, q, p, l, s)
  858.     @quality = q
  859.     @points = p
  860.     @level = l
  861.     @success = s
  862.     super(x, y, w, h)
  863.   end
  864.   #--------------------------------------------------------------------------
  865.   # ● Alters the points value
  866.   #--------------------------------------------------------------------------
  867.   def update_points(value)
  868.     @points = value
  869.   end
  870.   #--------------------------------------------------------------------------
  871.   # ● Refresh the contents
  872.   #--------------------------------------------------------------------------
  873.   def set_item(item = $game_party.last_item.object)
  874.     @item = item
  875.     contents.clear
  876.     draw_item_name(@item, 4, 0, true, width)
  877.     draw_item_quality
  878.     draw_item_traits
  879.     draw_synthesis_success
  880.   end
  881.   #--------------------------------------------------------------------------
  882.   # ● Displays the item quality
  883.   #--------------------------------------------------------------------------
  884.   def draw_item_quality
  885.     change_color(system_color)
  886.     contents.draw_text(4, line_height * 1, width, line_height, KRX::VOCAB::QUALITY)
  887.     contents.draw_text(4, line_height * 2, width, line_height, KRX::VOCAB::SYNTH_POINTS)
  888.     change_color(normal_color)
  889.     s1 = text_size(KRX::VOCAB::QUALITY).width
  890.     s2 = text_size(KRX::VOCAB::SYNTH_POINTS).width
  891.     contents.draw_text(4 + s1, line_height * 1, 32, line_height, @quality.to_s, 2)
  892.     contents.draw_text(4 + s2, line_height * 2, 32, line_height, @points.to_s, 2)
  893.   end
  894.   #--------------------------------------------------------------------------
  895.   # ● Displays the item traits
  896.   #--------------------------------------------------------------------------
  897.   def draw_item_traits
  898.     draw_horz_line(line_height * 3)
  899.     change_color(system_color)
  900.     contents.draw_text(4, line_height * 4, width, line_height, KRX::VOCAB::TRAITS)
  901.     change_color(normal_color)
  902.     (1..4).each {|i| contents.draw_text(0, line_height * (i + 4), width, line_height, "#{i}.")}
  903.     @item.synthesis_traits.each_index do |i|
  904.       trait = @item.synthesis_traits[i]
  905.       contents.draw_text(24, line_height * (i + 5), width - 24, line_height, trait)
  906.     end
  907.   end
  908.   #--------------------------------------------------------------------------
  909.   # ● Displays the synthesis success rate
  910.   #--------------------------------------------------------------------------
  911.   def draw_synthesis_success
  912.     draw_horz_line(line_height * 9)
  913.     change_color(system_color)
  914.     contents.draw_text(4, line_height * 10, width, line_height, KRX::VOCAB::LEVEL)
  915.     contents.draw_text(4, line_height * 11, width, line_height, KRX::VOCAB::SUCCESS_RATE)
  916.     s1 = text_size(KRX::VOCAB::LEVEL).width
  917.     s2 = text_size(KRX::VOCAB::SUCCESS_RATE).width
  918.     change_color(normal_color)
  919.     contents.draw_text(4 + s1, line_height * 10, 32, line_height, @level.to_s, 2)
  920.     case @success
  921.       when 0..19
  922.       change_color(knockout_color)
  923.       when 20..49
  924.       change_color(crisis_color)
  925.       when 50..99
  926.       change_color(normal_color)
  927.       when 100
  928.       change_color(mp_cost_color)
  929.     end
  930.     contents.draw_text(4 + s2, line_height * 11, 48, line_height, "#{@success}%", 2)
  931.   end
  932. end
  933.  
  934. #===========================================================================
  935. # ■ DataManager
  936. #===========================================================================
  937.  
  938. module DataManager  
  939.   #--------------------------------------------------------------------------
  940.   # ● Loads the database
  941.   #--------------------------------------------------------------------------
  942.   class << self
  943.     alias_method(:krx_totori_dm_load_database, :load_database) unless $@
  944.   end
  945.   def self.load_database
  946.     krx_totori_dm_load_database
  947.     load_synth_notetags
  948.   end  
  949.   #--------------------------------------------------------------------------
  950.   # ● Loads the note tags
  951.   #--------------------------------------------------------------------------
  952.   def self.load_synth_notetags
  953.     groups = [$data_items, $data_weapons, $data_armors]
  954.     classes = [RPG::Item, RPG::Weapon, RPG::Armor]
  955.     for group in groups
  956.       for obj in group
  957.         next if obj.nil?
  958.         obj.load_synth_notetags if classes.include?(obj.class)
  959.       end
  960.     end
  961.     puts "Read: Alchemic Synthesis Notetags"
  962.   end
  963. end
  964.  
  965. #==========================================================================
  966. #  ■  RPG::Item
  967. #==========================================================================
  968.  
  969. class RPG::Item < RPG::UsableItem
  970.   #--------------------------------------------------------------------------
  971.   # ● Public instance variables
  972.   #--------------------------------------------------------------------------
  973.   attr_reader    :recipe_data
  974.   attr_reader    :synthesis_reqs
  975.   attr_reader    :synthesis_family
  976.   attr_reader    :synthesis_level
  977.   #--------------------------------------------------------------------------
  978.   # ● Loads the note tags
  979.   #--------------------------------------------------------------------------
  980.   def load_synth_notetags
  981.     @recipe_data, @synthesis_reqs, @synthesis_traits = [], [], []
  982.     @synthesis_family = nil
  983.     @synthesis_quality, @synthesis_level = 0, 1
  984.     @note.split(/[\r\n]+/).each do |line|
  985.       case line
  986.       when  KRX::REGEXP::SYNTHESIS_ITEM
  987.         $1.scan(/\d+/).each {|i| @recipe_data.push($data_items[i.to_i])}
  988.       when KRX::REGEXP::SYNTHESIS_WEAPON
  989.         $1.scan(/\d+/).each {|i| @recipe_data.push($data_weapons[i.to_i])}
  990.       when KRX::REGEXP::SYNTHESIS_ARMOR
  991.         $1.scan(/\d+/).each {|i| @recipe_data.push($data_armors[i.to_i])}
  992.       when KRX::REGEXP::SYNTHESIS_ITEM_REQ
  993.         $1.scan(/\d+/).each {|i| @synthesis_reqs.push($data_items[i.to_i])}
  994.       when KRX::REGEXP::SYNTHESIS_WEAPON_REQ
  995.         $1.scan(/\d+/).each {|i| @synthesis_reqs.push($data_weapons[i.to_i])}
  996.       when KRX::REGEXP::SYNTHESIS_ARMOR_REQ
  997.         $1.scan(/[[:alpha:]]+/).each {|i| @synthesis_reqs.push(i)}
  998.       when KRX::REGEXP::SYNTHESIS_FAMILY
  999.         @synthesis_family = $1
  1000.       when KRX::REGEXP::SYNTHESIS_TRAITS
  1001.         $1.scan(/[^,]+/).each {|i| @synthesis_traits.push(i)}
  1002.       when KRX::REGEXP::SYNTHESIS_QUALITY
  1003.         @synthesis_quality = $1.to_i
  1004.       when KRX::REGEXP::SYNTHESIS_LEVEL
  1005.         @synthesis_level = $1.to_i
  1006.       end
  1007.     end
  1008.   end
  1009.   #--------------------------------------------------------------------------
  1010.   # ● Returns the synthesis quality
  1011.   #--------------------------------------------------------------------------
  1012.   def synthesis_quality
  1013.     if $game_party.nil? || $game_party.synthesis_quality[self].nil?
  1014.       return @synthesis_quality
  1015.     end
  1016.     return $game_party.synthesis_quality[self]
  1017.   end
  1018.   #--------------------------------------------------------------------------
  1019.   # ● Returns the synthesis traits
  1020.   #--------------------------------------------------------------------------
  1021.   def synthesis_traits
  1022.     if $game_party.nil? || $game_party.synthesis_traits[self].nil?
  1023.       return @synthesis_traits
  1024.     end
  1025.     return (@synthesis_traits + $game_party.synthesis_traits[self])
  1026.   end
  1027.   #--------------------------------------------------------------------------
  1028.   # ● Returns the effects
  1029.   #--------------------------------------------------------------------------
  1030.   alias_method(:krx_totori_rpgi_effects, :effects) unless $@
  1031.   def effects
  1032.     new_traits = []
  1033.     if synthesis_traits.size > 0
  1034.       for key in synthesis_traits
  1035.         ary = KRX::Synthesis::Traits[key][2]
  1036.         for trait in ary
  1037.           new_traits.push(RPG::UsableItem::Effect.new(trait[0],trait[1],trait[2]))
  1038.         end
  1039.       end
  1040.       return @effects + new_traits
  1041.     end
  1042.     krx_totori_rpgi_effects
  1043.   end
  1044. end
  1045.  
  1046. #==========================================================================
  1047. #  ■  RPG::Weapon
  1048. #==========================================================================
  1049.  
  1050. class RPG::Weapon < RPG::EquipItem
  1051.   #--------------------------------------------------------------------------
  1052.   # ● Public instance variables
  1053.   #--------------------------------------------------------------------------
  1054.   attr_reader    :synthesis_reqs
  1055.   attr_reader    :synthesis_family
  1056.   attr_reader    :synthesis_level
  1057.   #--------------------------------------------------------------------------
  1058.   # ● Loads the note tags
  1059.   #--------------------------------------------------------------------------
  1060.   def load_synth_notetags
  1061.      @synthesis_reqs, @synthesis_traits = [], []
  1062.     @synthesis_family = nil
  1063.     @synthesis_quality, @synthesis_level = 0, 1
  1064.     @note.split(/[\r\n]+/).each do |line|
  1065.       case line
  1066.       when KRX::REGEXP::SYNTHESIS_WEAPON
  1067.         $1.scan(/\d+/).each {|i| @recipe_data.push($data_weapons[i.to_i])}
  1068.       when KRX::REGEXP::SYNTHESIS_ARMOR
  1069.         $1.scan(/\d+/).each {|i| @recipe_data.push($data_armors[i.to_i])}
  1070.       when KRX::REGEXP::SYNTHESIS_ITEM_REQ
  1071.         $1.scan(/\d+/).each {|i| @synthesis_reqs.push($data_items[i.to_i])}
  1072.       when KRX::REGEXP::SYNTHESIS_WEAPON_REQ
  1073.         $1.scan(/\d+/).each {|i| @synthesis_reqs.push($data_weapons[i.to_i])}
  1074.       when KRX::REGEXP::SYNTHESIS_ARMOR_REQ
  1075.         $1.scan(/[[:alpha:]]+/).each {|i| @synthesis_reqs.push(i)}
  1076.       when KRX::REGEXP::SYNTHESIS_FAMILY
  1077.         @synthesis_family = $1
  1078.       when KRX::REGEXP::SYNTHESIS_TRAITS
  1079.         $1.scan(/[^,]+/).each {|i| @synthesis_traits.push(i)}
  1080.       when KRX::REGEXP::SYNTHESIS_QUALITY
  1081.         @synthesis_quality = $1.to_i
  1082.       when KRX::REGEXP::SYNTHESIS_LEVEL
  1083.         @synthesis_level = $1.to_i
  1084.       end
  1085.     end
  1086.   end
  1087.   #--------------------------------------------------------------------------
  1088.   # ● Returns the synthesis quality
  1089.   #--------------------------------------------------------------------------
  1090.   def synthesis_quality
  1091.     if $game_party.nil? || $game_party.synthesis_quality[self].nil?
  1092.       return @synthesis_quality
  1093.     end
  1094.     return $game_party.synthesis_quality[self]
  1095.   end
  1096.   #--------------------------------------------------------------------------
  1097.   # ● Returns the synthesis traits
  1098.   #--------------------------------------------------------------------------
  1099.   def synthesis_traits
  1100.     if $game_party.nil? || $game_party.synthesis_traits[self].nil?
  1101.       return @synthesis_traits
  1102.     end
  1103.     return (@synthesis_traits + $game_party.synthesis_traits[self])
  1104.   end
  1105.   #--------------------------------------------------------------------------
  1106.   # ● Returns the features
  1107.   #--------------------------------------------------------------------------
  1108.   alias_method(:krx_totori_rpgw_features, :features) unless $@
  1109.   def features
  1110.     new_traits = []
  1111.     if synthesis_traits.size > 0
  1112.       for key in synthesis_traits
  1113.         ary = KRX::Synthesis::Traits[key][2]
  1114.         for trait in ary
  1115.           new_traits.push(RPG::UsableItem::Effect.new(trait[0],trait[1],trait[2]))
  1116.         end
  1117.       end
  1118.       return @features + new_traits
  1119.     end
  1120.     krx_totori_rpgw_features
  1121.   end
  1122. end
  1123.  
  1124. #==========================================================================
  1125. #  ■  RPG::Armor
  1126. #==========================================================================
  1127.  
  1128. class RPG::Armor < RPG::EquipItem
  1129.   #--------------------------------------------------------------------------
  1130.   # ● Public instance variables
  1131.   #--------------------------------------------------------------------------
  1132.   attr_reader    :synthesis_reqs
  1133.   attr_reader    :synthesis_family
  1134.   attr_reader    :synthesis_level
  1135.   #--------------------------------------------------------------------------
  1136.   # ● Loads the note tags
  1137.   #--------------------------------------------------------------------------
  1138.   def load_synth_notetags
  1139.      @synthesis_reqs, @synthesis_traits = [], []
  1140.     @synthesis_family = nil
  1141.     @synthesis_quality, @synthesis_level = 0, 1
  1142.     @note.split(/[\r\n]+/).each do |line|
  1143.       case line
  1144.       when KRX::REGEXP::SYNTHESIS_WEAPON
  1145.         $1.scan(/\d+/).each {|i| @recipe_data.push($data_weapons[i.to_i])}
  1146.       when KRX::REGEXP::SYNTHESIS_ARMOR
  1147.         $1.scan(/\d+/).each {|i| @recipe_data.push($data_armors[i.to_i])}
  1148.       when KRX::REGEXP::SYNTHESIS_ITEM_REQ
  1149.         $1.scan(/\d+/).each {|i| @synthesis_reqs.push($data_items[i.to_i])}
  1150.       when KRX::REGEXP::SYNTHESIS_WEAPON_REQ
  1151.         $1.scan(/\d+/).each {|i| @synthesis_reqs.push($data_weapons[i.to_i])}
  1152.       when KRX::REGEXP::SYNTHESIS_ARMOR_REQ
  1153.         $1.scan(/[[:alpha:]]+/).each {|i| @synthesis_reqs.push(i)}
  1154.       when KRX::REGEXP::SYNTHESIS_FAMILY
  1155.         @synthesis_family = $1
  1156.       when KRX::REGEXP::SYNTHESIS_TRAITS
  1157.         $1.scan(/[^,]+/).each {|i| @synthesis_traits.push(i)}
  1158.       when KRX::REGEXP::SYNTHESIS_QUALITY
  1159.         @synthesis_quality = $1.to_i
  1160.       when KRX::REGEXP::SYNTHESIS_LEVEL
  1161.         @synthesis_level = $1.to_i
  1162.       end
  1163.     end
  1164.   end
  1165.   #--------------------------------------------------------------------------
  1166.   # ● Returns the synthesis quality
  1167.   #--------------------------------------------------------------------------
  1168.   def synthesis_quality
  1169.     if $game_party.nil? || $game_party.synthesis_quality[self].nil?
  1170.       return @synthesis_quality
  1171.     end
  1172.     return $game_party.synthesis_quality[self]
  1173.   end
  1174.   #--------------------------------------------------------------------------
  1175.   # ● Returns the synthesis traits
  1176.   #--------------------------------------------------------------------------
  1177.   def synthesis_traits
  1178.     if $game_party.nil? || $game_party.synthesis_traits[self].nil?
  1179.       return @synthesis_traits
  1180.     end
  1181.     return (@synthesis_traits + $game_party.synthesis_traits[self])
  1182.   end
  1183.   #--------------------------------------------------------------------------
  1184.   # ● Returns the features
  1185.   #--------------------------------------------------------------------------
  1186.   alias_method(:krx_totori_rpga_features, :features) unless $@
  1187.   def features
  1188.     new_traits = []
  1189.     if synthesis_traits.size > 0
  1190.       for key in synthesis_traits
  1191.         ary = KRX::Synthesis::Traits[key][2]
  1192.         for trait in ary
  1193.           new_traits.push(RPG::UsableItem::Effect.new(trait[0],trait[1],trait[2]))
  1194.         end
  1195.       end
  1196.       return @features + new_traits
  1197.     end
  1198.     krx_totori_rpga_features
  1199.   end
  1200. end
  1201.  
  1202. #==========================================================================
  1203. #  ■  Game_Party
  1204. #==========================================================================
  1205.  
  1206. class Game_Party < Game_Unit
  1207.   #--------------------------------------------------------------------------
  1208.   # ● Public instance variables
  1209.   #--------------------------------------------------------------------------
  1210.   attr_accessor  :synthesis_level
  1211.   attr_accessor  :synthesis_traits
  1212.   attr_accessor  :synthesis_quality
  1213.   #--------------------------------------------------------------------------
  1214.   # ● Object Initialize
  1215.   #--------------------------------------------------------------------------
  1216.   alias_method(:krx_totori_gp_initialize, :initialize) unless $@
  1217.   def initialize
  1218.     krx_totori_gp_initialize
  1219.     @synthesis_level = 1.00
  1220.     @synthesis_traits = {}
  1221.     @synthesis_quality = {}
  1222.   end
  1223. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement