Advertisement
mrbubble

FF5 "Mix"

Aug 2nd, 2012
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 48.92 KB | None | 0 0
  1. #==============================================================================
  2. # ++ FF5 "Mix" ++                                                v1.2 (8/3/12)
  3. #==============================================================================
  4. # Script by:
  5. #     Mr. Bubble ( http://mrbubblewand.wordpress.com/ )
  6. #--------------------------------------------------------------------------
  7. # This script is based on the Chemist job class command "Mix" from Final
  8. # Fantasy 5. Mix allows the user to mix two items from the party's inventory
  9. # for a variety of effects in battle.
  10. #
  11. # All item combination formulae must be defined in the customization
  12. # module.
  13. #--------------------------------------------------------------------------
  14. #   ++ Changelog ++
  15. #--------------------------------------------------------------------------
  16. # v1.2 : Compatibility: "YEA-BattleCommandList" support added.
  17. #      : Compatibility: "YEA-BattleEngine" support added.
  18. #      : Fixed issues related to Attack Times+.
  19. #      : Unused mix items are now properly returned after battle.
  20. #      : Unused mix items are now properly returned when an actor dies.
  21. #      : Unused mix items are now properly returned when switching actors.
  22. #      : Console window now outputs when items are returned to inventory.
  23. #      : Game_Actor#prior_command is no longer aliased.
  24. #      : Comments added/changed.
  25. #      : Efficiency update. (8/3/2012)
  26. # v1.1 : Compatibility: Mix window properly resized for "YEA-BattleEngine".
  27. #      : Fixed crashes when using items normally.
  28. #      : Efficiency update with console output. (8/3/2012)
  29. # v1.0 : Initial release. (8/2/2012)
  30. #--------------------------------------------------------------------------
  31. #   ++ Installation ++
  32. #--------------------------------------------------------------------------
  33. # Install this script in the Materials section in your project's
  34. # script editor.
  35. #
  36. # I recommend pasting this script below all other scripts that also
  37. # modify the battle system in your script editor.
  38. #--------------------------------------------------------------------------
  39. #   ++ Usage Notes ++
  40. #--------------------------------------------------------------------------
  41. # --The targeting Scope of the result item will stay intact when made
  42. #   through mixed items. If the result item requires a player-selected
  43. #   target, the player can do so.
  44. #
  45. # --Spelling is very important with this script. Because of the high
  46. #   potential for user-errors to occur in regards with spelling errors,
  47. #   I've provided the option to have messages appear in the Playtest
  48. #   console window whenever certain errors or spelling mistakes associated
  49. #   with this script are encountered.
  50. #
  51. # --Item ID combinations will always take precedence over Mix Type
  52. #   combinations if the two selected mix items have a potential result
  53. #   in both.
  54. #
  55. # --If DEBUG_INFO is true, you will sometimes be informed in the console
  56. #   window whenever mix items are returned to the party's inventory.
  57. #   Please report to me when items are supposed to be returned to you but
  58. #   are not with information on how to reproduce it.
  59. #==============================================================================
  60. #   ++ Notetags ++
  61. #==============================================================================
  62. # Note: Some tags are given shorter tags for typing convenience. You only
  63. #       need to use one <tag> from a given group for a notebox.
  64. #       Use common sense.
  65. #
  66. # The following Notetags are for Skills only:
  67. #
  68. # <mix>
  69. #   This tag turns the skill into a Mix skill. When a Mix skill is selected
  70. #   in battle, a window with all possible mixable items will appear.
  71. #   Selecting two items in the window will produce a new item to be used
  72. #   instead. The player will not know what item is produced until the
  73. #   item is actually used. Mix skills do not have any special effect
  74. #   outside of battle.
  75. #
  76. # The following Notetags are for Items only:
  77. #
  78. # <mixtype: type>
  79. #   This tag defines an item's Mix Type where type is any type name you
  80. #   defined in MIX_TYPES in the customization module WITHOUT the colon. For
  81. #   more information about Mix Types, see the comments in the Mix Type
  82. #   Formulae section in the customization module. If the type in the tag
  83. #   is not found in MIX_TYPES, a message in the console will tell you.
  84. #
  85. # <unmixable>
  86. # <no mix>
  87. #   This tag will flag the item as unmixable. Items with this tag will
  88. #   not appear in the Mix window.
  89. #
  90. #--------------------------------------------------------------------------
  91. #   ++ FAQ ++
  92. #--------------------------------------------------------------------------
  93. # --I received the Syntax Error "unexpected tLBRACK, expecting '}'. How
  94. #   do I fix it?
  95. #
  96. #     This means you forgot the comma after the result_item_id number.
  97. #
  98. # --How do I stop the debug messages from appearing in the console window?
  99. #
  100. #     Set DEBUG_INFO to false in the customization module.
  101. #
  102. # --Can I mix more than two items?
  103. #
  104. #     No.
  105. #
  106. #--------------------------------------------------------------------------
  107. #   ++ Compatibility ++
  108. #--------------------------------------------------------------------------
  109. # !! IMPORTANT !!
  110. # Due to the nature of this script, script incompatibilities with other
  111. # scripts is likely and expected. Please do not ask if [insert script here]
  112. # is compatible with this script. You can test it yourself.
  113. #
  114. # Custom battle systems are very likely to have issues with this script
  115. # especially ones that are not turn-based like the default battle system.
  116. #
  117. # If you run into incompatibilities, please report them to me with a link
  118. # to the script and I will try to make it compatible.
  119. #
  120. # This script aliases the following default VXA methods:
  121. #
  122. #     DataManager#load_normal_database
  123. #     DataManager#load_battle_test_database
  124. #     DataManager#load_database
  125. #     Game_Action#clear
  126. #     Game_Actor#initialize
  127. #     Game_Actor#use_item
  128. #     Game_Actor#consume_item
  129. #     Game_Actor#on_turn_end
  130. #     Game_Actor#clear_actions
  131. #     Game_Actor#item_conditions_met
  132. #     Scene_Battle#on_skill_ok
  133. #     Scene_Battle#on_enemy_ok
  134. #     Scene_Battle#on_enemy_cancel
  135. #     Scene_Battle#on_actor_ok
  136. #     Scene_Battle#on_actor_cancel
  137. #     Scene_Battle#start_actor_command_selection
  138. #    
  139. # There are no default method overwrites.
  140. #
  141. # This script has built-in compatibility with the following scripts:
  142. #
  143. #     Yanfly Engine Ace – Ace Battle Engine
  144. #     Yanfly Engine Ace – Battle Command List
  145. #
  146. # Requests for compatibility with other scripts are welcome.
  147. #--------------------------------------------------------------------------
  148. #   ++ Terms and Conditions ++
  149. #--------------------------------------------------------------------------
  150. # Please do not repost this script elsewhere without permission.
  151. # Free for non-commercial use. For commercial use, contact me first.
  152. #
  153. # Newest versions of this script can be found at
  154. #                                           http://mrbubblewand.wordpress.com/
  155. #==============================================================================
  156.  
  157. $imported ||= {}
  158. $imported["BubsMix"] = true
  159.  
  160. #==========================================================================
  161. # ++ START OF USER CUSTOMIZATION MODULE ++
  162. #==========================================================================
  163. module Bubs
  164.   #==========================================================================
  165.   # ++ Mix Settings
  166.   #==========================================================================
  167.   module Mix
  168.   #--------------------------------------------------------------------------
  169.   #   Default Mix Result Item ID
  170.   #--------------------------------------------------------------------------
  171.   # This defines the default item ID that is used when absolutely no
  172.   # formula is found for a chosen item combination.
  173.   DEFAULT_MIX_RESULT_ITEM_ID = 1
  174.  
  175.   #--------------------------------------------------------------------------
  176.   #   Unmixable Item IDs
  177.   #--------------------------------------------------------------------------
  178.   # This setting allows you define the Item IDs that are ineligible to be
  179.   # selected in a mix combination. You can list as many Item IDs in the
  180.   # array as you like. This setting has the same effect as the <unmixable>
  181.   # tag.
  182.   UNMIXABLE_ITEMS = []
  183.  
  184.   #--------------------------------------------------------------------------
  185.   #   Debug Info Setting
  186.   #--------------------------------------------------------------------------
  187.   # This setting determines whether debug messages related to this
  188.   # script will appear in the console window during Playtests.
  189.   #
  190.   # I highly recommend that you keep this setting true until your
  191.   # game is complete.
  192.   DEBUG_INFO = true
  193.  
  194.   #--------------------------------------------------------------------------
  195.   #   Selected Mix Item Color Index
  196.   #--------------------------------------------------------------------------
  197.   # This setting determines the color a selected item in the Mix window
  198.   # turns into. The value is a Window skin color index.
  199.   SELECTED_MIX_ITEM_COLOR = 2 # Default 2 (orange)
  200.  
  201.   #--------------------------------------------------------------------------
  202.   #   Item ID Formulae
  203.   #--------------------------------------------------------------------------
  204.   # This hash is where you define Item ID formulae. The syntax for defining
  205.   # a formula is:
  206.   #
  207.   #       [item_id, item_id] => result_item_id,
  208.   #
  209.   # item_id is any existing item_id from your database. result_item_id is
  210.   # the item that will be used as a result of combining the two. The
  211.   # colloquial term for "=>" is "hashrocket". Just think of it as an arrow
  212.   # that points to the result item. The order of item_ids in the array does
  213.   # not matter. That means [1,2] is the same as [2,1].
  214.   #
  215.   # ALWAYS remember the comma at the end of result_item_id or you will get
  216.   # a Syntax Error.
  217.   #
  218.   # Don't bother making formulae with more than two item_ids. It won't work.
  219.   #
  220.   # I *highly* recommend that you include comments for your own formulae
  221.   # so that you can easily reference them.
  222.   MIX_FORMULA_BY_ID = {
  223.     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  224.     #   Create your own formulae starting here.
  225.     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  226.     # Potion + Potion = Hi-Potion
  227.     [1, 1] => 2,
  228.     # Potion + Hi-Potion = Stimulant
  229.     [1, 2] => 5,
  230.     # Hi-Potion + Hi-Potion = Full Potion
  231.     [2, 2] => 3,
  232.     # Full Potion + Magic Water = Elixir
  233.     [3, 4] => 8,
  234.     # Antidote + Antidote = Dispel Herb
  235.     [6, 6] => 7,
  236.  
  237.    
  238.    
  239.    
  240.    
  241.    
  242.     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  243.   } # <- Do not delete.
  244.  
  245.   #--------------------------------------------------------------------------
  246.   #   Mix Types
  247.   #--------------------------------------------------------------------------
  248.   # This array is where you define Mix Types. Mix Types are basically
  249.   # categories of mix items that you define. Items are assigned Mix Types
  250.   # with the <mixtype: type> tag (see ++ Notetags ++ for more info).
  251.   #
  252.   # You must always add the name of any new Mix Types that you create
  253.   # into this array. If DEBUG_INFO is true, you will be informed of any
  254.   # missing Mix Types.
  255.   #
  256.   # You can list as many Mix Types in the array separated by commas as
  257.   # you like.
  258.   #
  259.   # Mix Types are represented by symbols meaning that they begin with a
  260.   # colon ":". They should appear orange in the script editor. If the
  261.   # symbol is not orange, you are typing the symbol incorrectly.
  262.   #
  263.   # !! Important !!
  264.   # :none must always be the first symbol listed in this array. However,
  265.   # it can still be used in Mix Type formulae.
  266.   MIX_TYPES = [:none, :potions1, :potions2, :statup]
  267.  
  268.   #--------------------------------------------------------------------------
  269.   #   Mix Type Formulae
  270.   #--------------------------------------------------------------------------
  271.   # This hash is where you define Mix Type formulae. Mix Types are basically
  272.   # categories of mix items that you define. Items are assigned Mix Types
  273.   # with the <mixtype: type> tag (see ++ Notetags ++ for more info).
  274.   #
  275.   # Mix Types were created because it can be daunting to create item mix
  276.   # formulae for every single possible item ID combination in a project.
  277.   # To ease game development, you are able to use general category types
  278.   # that can combine into different results in the event that a specific
  279.   # item ID formula is not found.
  280.   #
  281.   # The syntax for defining a formula is:
  282.   #
  283.   #       [:mix_type, :mix_type] => result_item_id,
  284.   #
  285.   # :mix_type is any symbol that you created and defined in the MIX_TYPES
  286.   # array. result_item_id is the item that will be used as a result of
  287.   # combining the two. The colloquial term for "=>" is "hashrocket". Just
  288.   # think of it as an arrow that points to the result. The order of item_id
  289.   # in the array does not matter. That means [1,2] is the same as [2,1].
  290.   #
  291.   # ALWAYS remember the comma at the end of result_item_id or you will get
  292.   # a Syntax Error.
  293.   #
  294.   # Don't bother making formulae with more than two types. It won't work.
  295.   #
  296.   # Mix Types are represented by symbols meaning that they begin with
  297.   # a colon ":". They should appear orange in the script editor. If the
  298.   # symbol is not orange, you are typing the symbol incorrectly.
  299.   MIX_FORMULA_BY_TYPE = {
  300.     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  301.     #   Create your own formulae starting here.
  302.     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  303.     # Potions 1 + Potions 1 = Hi-Potion
  304.     [:potions1, :potions1] => 2,
  305.    
  306.     # Potions 1 + Potions 2 = Full Potion
  307.     [:potions1, :potions2] => 3,
  308.    
  309.     # Potions 2 + Potions 2 = Full Potion
  310.     [:potions2, :potions2] => 3,
  311.    
  312.     # Potions 1 + Stat Up = Stimulant
  313.     [:potions1, :statup]   => 5,
  314.    
  315.     # Potions 2 + Stat Up = Elixir
  316.     [:potions2, :statup]   => 8,
  317.    
  318.     # Stat Up + Stat Up = Elixir
  319.     [:statup, :statup]     => 8,
  320.  
  321.    
  322.    
  323.    
  324.     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  325.   } # <- Do not delete.
  326.  
  327.   end # module Mix
  328. end # module Bubs
  329.  
  330.  
  331. #==========================================================================
  332. # ++ END OF USER CUSTOMIZATION MODULE ++
  333. #==========================================================================
  334.  
  335.  
  336.  
  337.  
  338. #==========================================================================
  339. # ++ DataManager
  340. #==========================================================================
  341. module DataManager
  342.  
  343.   #--------------------------------------------------------------------------
  344.   # alias : load_normal_database
  345.   #--------------------------------------------------------------------------
  346.   class << self; alias load_normal_database_bubs_mix load_normal_database; end
  347.   def self.load_normal_database
  348.     load_normal_database_bubs_mix # alias
  349.    
  350.     $data_mix = MixData.new
  351.   end
  352.   #--------------------------------------------------------------------------
  353.   # alias : load_battle_test_database
  354.   #--------------------------------------------------------------------------
  355.   class << self; alias load_battle_test_database_bubs_mix load_battle_test_database; end
  356.   def self.load_battle_test_database
  357.     load_battle_test_database_bubs_mix # alias
  358.    
  359.     $data_mix = MixData.new
  360.   end
  361.  
  362.   #--------------------------------------------------------------------------
  363.   # alias : load_database
  364.   #--------------------------------------------------------------------------
  365.   class << self; alias load_database_bubs_mix load_database; end
  366.   def self.load_database
  367.     load_database_bubs_mix # alias
  368.     load_notetags_bubs_mix
  369.   end
  370.  
  371.   #--------------------------------------------------------------------------
  372.   # new method : load_notetags_bubs_mix
  373.   #--------------------------------------------------------------------------
  374.   def self.load_notetags_bubs_mix
  375.     groups = [$data_skills, $data_items]
  376.     for group in groups
  377.       for obj in group
  378.         next if obj.nil?
  379.         obj.load_notetags_bubs_mix
  380.       end # for obj
  381.     end # for group
  382.   end # def
  383.  
  384. end # module DataManager
  385.  
  386.  
  387.  
  388. #==========================================================================
  389. # ++ Bubs::Regexp
  390. #==========================================================================
  391. module Bubs
  392.   module Regexp
  393.     MIX_TAG = /<MIX>/i
  394.     MIX_TYPE_TAG = /<MIX[_\s]?TYPE:\s*(\w+)>/i
  395.     UNMIXABLE_TAG = /<(?:UNMIXABLE|no[_\s]?mix)>/i
  396.   end # module Regexp
  397. end # module Bubs
  398.  
  399.  
  400.  
  401. #==========================================================================
  402. # ++ RPG::BaseItem
  403. #==========================================================================
  404. class RPG::BaseItem
  405.   #--------------------------------------------------------------------------
  406.   # public instance variables
  407.   #--------------------------------------------------------------------------
  408.   attr_accessor :mix
  409.   attr_accessor :mix_type
  410.   attr_accessor :unmixable
  411.   #--------------------------------------------------------------------------
  412.   # common cache : load_notetags_bubs_mix
  413.   #--------------------------------------------------------------------------
  414.   def load_notetags_bubs_mix
  415.     @mix = false
  416.     @mix_type = :none
  417.     @unmixable = false
  418.     if self.is_a?(RPG::Item)
  419.       @unmixable = Bubs::Mix::UNMIXABLE_ITEMS.include?(self.id)
  420.     end
  421.    
  422.     self.note.split(/[\r\n]+/).each { |line|
  423.       case line
  424.       when Bubs::Regexp::MIX_TAG
  425.         @mix = true
  426.        
  427.       when Bubs::Regexp::MIX_TYPE_TAG
  428.         next unless self.is_a?(RPG::Item)
  429.         @mix_type = $1.to_sym
  430.         $data_mix.test_item_type_symbol(self)
  431.        
  432.       when Bubs::Regexp::UNMIXABLE_TAG
  433.         @unmixable = true
  434.        
  435.       end # case
  436.     } # self.note.split
  437.   end # def
  438.  
  439. end # class RPG::BaseItem
  440.  
  441.  
  442.  
  443. #==========================================================================
  444. # ++ Game_Action
  445. #==========================================================================
  446. class Game_Action
  447.   #--------------------------------------------------------------------------
  448.   # public instance variables
  449.   #--------------------------------------------------------------------------
  450.   attr_accessor :mixed_item  # flag that determine if action was result of Mix
  451.   #--------------------------------------------------------------------------
  452.   # alias : clear
  453.   #--------------------------------------------------------------------------
  454.   alias clear_bubs_mix clear
  455.   def clear
  456.     clear_bubs_mix
  457.    
  458.     @mixed_item = false
  459.   end
  460. end # class Game_Action
  461.  
  462.  
  463.  
  464. #==========================================================================
  465. # ++ Game_Actor
  466. #==========================================================================
  467. class Game_Actor < Game_Battler
  468.   #--------------------------------------------------------------------------
  469.   # public instance variables
  470.   #--------------------------------------------------------------------------
  471.   attr_accessor :mix_items
  472.   #--------------------------------------------------------------------------
  473.   # alias : initialize
  474.   #--------------------------------------------------------------------------
  475.   alias initialize_bubs_mix initialize
  476.   def initialize(actor_id)
  477.     # Mix item pairs are kept as pairs in the array [[item1, item2], ...]
  478.     @mix_items = []
  479.    
  480.     initialize_bubs_mix(actor_id) # alias
  481.   end
  482.  
  483.   #--------------------------------------------------------------------------
  484.   # alias : use_item
  485.   #--------------------------------------------------------------------------
  486.   alias use_item_bubs_mix use_item
  487.   def use_item(item)
  488.     # pay the item cost of the mix item
  489.     if $game_party.in_battle && current_action && current_action.mixed_item
  490.       consume_mix_items
  491.     end
  492.    
  493.     use_item_bubs_mix(item) # alias
  494.   end
  495.  
  496.   #--------------------------------------------------------------------------
  497.   # alias : consume_item
  498.   #--------------------------------------------------------------------------
  499.   alias consume_item_bubs_mix consume_item
  500.   def consume_item(item)
  501.     # prevent losing item if it was a mixed item
  502.     return if $game_party.in_battle && current_action && current_action.mixed_item
  503.     consume_item_bubs_mix(item) # alias
  504.   end
  505.  
  506.   #--------------------------------------------------------------------------
  507.   # alias : on_turn_end
  508.   #--------------------------------------------------------------------------
  509.   alias on_turn_end_bubs_mix on_turn_end
  510.   def on_turn_end
  511.     return_all_mix_items
  512.    
  513.     on_turn_end_bubs_mix # alias
  514.   end
  515.  
  516.   #--------------------------------------------------------------------------
  517.   # alias : clear_actions
  518.   #--------------------------------------------------------------------------
  519.   alias clear_actions_bubs_mix clear_actions
  520.   def clear_actions
  521.     clear_actions_bubs_mix # alias
  522.    
  523.     return_all_mix_items
  524.   end
  525.  
  526.   #--------------------------------------------------------------------------
  527.   # alias : item_conditions_met
  528.   #--------------------------------------------------------------------------
  529.   # Avoids the issue of not being to used mixed items when the player
  530.   # doesn't have one in their inventory
  531.   alias item_conditions_met_bubs_mix item_conditions_met?
  532.   def item_conditions_met?(item)
  533.     if $game_party.in_battle && current_action && current_action.mixed_item
  534.       return usable_item_conditions_met?(item)
  535.     else
  536.       return item_conditions_met_bubs_mix(item) # alias
  537.     end
  538.   end
  539.  
  540.   #--------------------------------------------------------------------------
  541.   # new method : consume_mix_items
  542.   #--------------------------------------------------------------------------
  543.   # Pay the cost of the mixed items
  544.   def consume_mix_items
  545.     @mix_items.shift
  546.   end
  547.  
  548.   #--------------------------------------------------------------------------
  549.   # new method : return_last_mix_items
  550.   #--------------------------------------------------------------------------
  551.   # Return last pair of mix items stored by the actor
  552.   def return_last_mix_items
  553.     return if @mix_items.empty?
  554.     array = @mix_items.pop
  555.     item1 = $data_items[array[0]]
  556.     item2 = $data_items[array[1]]
  557.     $data_mix.output_returned_items(item1, item2)
  558.     $game_party.gain_item(item1, 1)
  559.     $game_party.gain_item(item2, 1)
  560.   end
  561.  
  562.   #--------------------------------------------------------------------------
  563.   # new method : return_all_mix_items
  564.   #--------------------------------------------------------------------------
  565.   # Return all mix items stored by the actor
  566.   def return_all_mix_items
  567.     @mix_items.each do |array|
  568.       item1 = $data_items[array[0]]
  569.       item2 = $data_items[array[1]]
  570.       $data_mix.output_returned_items(item1, item2)
  571.       $game_party.gain_item(item1, 1)
  572.       $game_party.gain_item(item2, 1)
  573.     end
  574.     @mix_items.clear
  575.   end
  576.  
  577. end # class Game_Actor
  578.  
  579.  
  580.  
  581. #==============================================================================
  582. # ++ Window_MixItem
  583. #==============================================================================
  584. class Window_MixItem < Window_ItemList
  585.   #--------------------------------------------------------------------------
  586.   # public instance variables
  587.   #--------------------------------------------------------------------------
  588.   attr_accessor :selected_items
  589.   attr_accessor :last_window
  590.   attr_accessor :last_item
  591.   #--------------------------------------------------------------------------
  592.   # initialize
  593.   #--------------------------------------------------------------------------
  594.   def initialize(help_window, info_viewport)
  595.     y = help_window.height
  596.     super(0, y, Graphics.width, info_viewport.rect.y - y)
  597.     self.visible = false
  598.     @last_item = Game_BaseItem.new
  599.     @help_window = help_window
  600.     @info_viewport = info_viewport
  601.     @selected_items = []
  602.     @last_window = :skill_window
  603.   end
  604.  
  605.   #--------------------------------------------------------------------------
  606.   # include?
  607.   #--------------------------------------------------------------------------
  608.   def include?(item)
  609.     return false unless item.is_a?(RPG::Item)
  610.     return false if item.unmixable
  611.     return true
  612.   end
  613.  
  614.   #--------------------------------------------------------------------------
  615.   # enable?                             # Display in Enabled State?
  616.   #--------------------------------------------------------------------------
  617.   def enable?(item)
  618.     return false if item.nil?
  619.     return true
  620.   end
  621.  
  622.   #--------------------------------------------------------------------------
  623.   # show
  624.   #--------------------------------------------------------------------------
  625.   def show
  626.     @help_window.show
  627.     super
  628.   end
  629.  
  630.   #--------------------------------------------------------------------------
  631.   # hide
  632.   #--------------------------------------------------------------------------
  633.   def hide
  634.     @help_window.hide
  635.     super
  636.   end
  637.  
  638.   #--------------------------------------------------------------------------
  639.   # dispose
  640.   #--------------------------------------------------------------------------
  641.   def dispose
  642.     return_selected_items unless disposed?
  643.     super
  644.   end
  645.  
  646.   #--------------------------------------------------------------------------
  647.   # add_item
  648.   #--------------------------------------------------------------------------
  649.   def add_item
  650.     $game_party.lose_item(item, 1)
  651.     @selected_items.push(item.id)
  652.     refresh
  653.   end
  654.  
  655.   #--------------------------------------------------------------------------
  656.   # remove_item
  657.   #--------------------------------------------------------------------------
  658.   def remove_item
  659.     id = @selected_items.pop
  660.     $game_party.gain_item($data_items[id], 1) if id
  661.     refresh
  662.   end
  663.  
  664.   #--------------------------------------------------------------------------
  665.   # clear_selected_items
  666.   #--------------------------------------------------------------------------
  667.   def clear_selected_items
  668.     @selected_items = []
  669.     refresh
  670.   end
  671.  
  672.   #--------------------------------------------------------------------------
  673.   # return_selected_items
  674.   #--------------------------------------------------------------------------
  675.   def return_selected_items
  676.     @selected_items.size.times do remove_item end
  677.     refresh
  678.   end
  679.  
  680.   #--------------------------------------------------------------------------
  681.   # mix_done?
  682.   #--------------------------------------------------------------------------
  683.   def mix_done?
  684.     @last_item.object = item
  685.     return true if @selected_items.size == 2
  686.     return false
  687.   end
  688.  
  689.   #--------------------------------------------------------------------------
  690.   # mix_cancel?
  691.   #--------------------------------------------------------------------------
  692.   def mix_cancel?
  693.     return true if @selected_items.empty?
  694.     remove_item
  695.     refresh
  696.     return false
  697.   end
  698.  
  699.   #--------------------------------------------------------------------------
  700.   # mix_result
  701.   #--------------------------------------------------------------------------
  702.   def mix_result
  703.     item1 = $data_items[@selected_items[0]]
  704.     item2 = $data_items[@selected_items[1]]
  705.     return $data_mix.get_mix_item_result(item1, item2)
  706.   end
  707.  
  708.   #--------------------------------------------------------------------------
  709.   # select_last                   # Restore Previous Selection Position
  710.   #--------------------------------------------------------------------------
  711.   def select_last
  712.     select(@data.index(@last_item.object) || 0)
  713.   end
  714.  
  715.   #--------------------------------------------------------------------------
  716.   # draw_item_name
  717.   #--------------------------------------------------------------------------
  718.   def draw_item_name(item, x, y, enabled = true, width = 172)
  719.     return unless item
  720.     draw_icon(item.icon_index, x, y, enabled)
  721.     change_color(normal_color, enabled)
  722.     selected_mix_item_color if @selected_items.include?(item.id)
  723.     draw_text(x + 24, y, width, line_height, item.name)
  724.   end
  725.  
  726.   #--------------------------------------------------------------------------
  727.   # selected_mix_item_color
  728.   #--------------------------------------------------------------------------
  729.   def selected_mix_item_color
  730.     change_color(text_color(Bubs::Mix::SELECTED_MIX_ITEM_COLOR))
  731.   end
  732.  
  733. end # class Window_MixItem
  734.  
  735.  
  736.  
  737. #==============================================================================
  738. # ++ Scene_Battle
  739. #==============================================================================
  740. class Scene_Battle < Scene_Base
  741.   #--------------------------------------------------------------------------
  742.   # alias : create_mix_window
  743.   #--------------------------------------------------------------------------
  744.   alias create_all_windows_bubs_mix create_all_windows
  745.   def create_all_windows
  746.     create_all_windows_bubs_mix # alias
  747.    
  748.     create_mix_window
  749.   end
  750.  
  751.   #--------------------------------------------------------------------------
  752.   # alias : on_skill_ok
  753.   #--------------------------------------------------------------------------
  754.   alias on_skill_ok_bubs_mix on_skill_ok
  755.   def on_skill_ok
  756.     @skill = @skill_window.item
  757.    
  758.     # set skill cursor memorization
  759.     BattleManager.actor.last_skill.object = @skill
  760.    
  761.     # override normal skill processing if Mix skill
  762.     if @skill.mix
  763.       @mix_window.return_selected_items
  764.       @mix_window.last_window = :skill_window
  765.       @mixing = true
  766.       @skill_window.hide
  767.       @mix_window.refresh
  768.       @mix_window.show.activate.select(0)
  769.     else
  770.       on_skill_ok_bubs_mix # alias
  771.     end
  772.   end
  773.  
  774.   #--------------------------------------------------------------------------
  775.   # alias : on_enemy_ok
  776.   #--------------------------------------------------------------------------
  777.   alias on_enemy_ok_bubs_mix on_enemy_ok
  778.   def on_enemy_ok
  779.     set_actor_mix_items if @mixing
  780.     #@mixing = false
  781.    
  782.     on_enemy_ok_bubs_mix # alias
  783.   end
  784.  
  785.   #--------------------------------------------------------------------------
  786.   # alias : on_enemy_cancel
  787.   #--------------------------------------------------------------------------
  788.   alias on_enemy_cancel_bubs_mix on_enemy_cancel
  789.   def on_enemy_cancel
  790.     @enemy_window.hide
  791.     if @mixing
  792.       BattleManager.actor.input.clear
  793.      
  794.       if $imported["YEA-BattleEngine"]
  795.         @status_aid_window.refresh
  796.         @status_window.refresh
  797.       end
  798.      
  799.       @mix_window.remove_item
  800.       @mix_window.refresh
  801.       @mix_window.show.activate
  802.       @mix_window.select_last
  803.     else
  804.       on_enemy_cancel_bubs_mix # alias
  805.     end
  806.   end
  807.  
  808.   #--------------------------------------------------------------------------
  809.   # alias : on_actor_ok
  810.   #--------------------------------------------------------------------------
  811.   alias on_actor_ok_bubs_mix on_actor_ok
  812.   def on_actor_ok
  813.     set_actor_mix_items if @mixing
  814.     #@mixing = false
  815.    
  816.     on_actor_ok_bubs_mix # alias
  817.   end
  818.  
  819.   #--------------------------------------------------------------------------
  820.   # alias : on_actor_cancel
  821.   #--------------------------------------------------------------------------
  822.   alias on_actor_cancel_bubs_mix on_actor_cancel
  823.   def on_actor_cancel
  824.     @actor_window.hide
  825.     if @mixing
  826.       BattleManager.actor.input.clear
  827.      
  828.       if $imported["YEA-BattleEngine"]
  829.         @status_aid_window.refresh
  830.         @status_window.refresh
  831.       end
  832.      
  833.       @mix_window.remove_item
  834.       @mix_window.refresh
  835.       @mix_window.show.activate
  836.       @mix_window.select_last
  837.     else
  838.       on_actor_cancel_bubs_mix # alias
  839.     end
  840.   end
  841.  
  842.   #--------------------------------------------------------------------------
  843.   # alias : start_actor_command_selection
  844.   #--------------------------------------------------------------------------
  845.   alias start_actor_command_selection_bubs_mix start_actor_command_selection
  846.   def start_actor_command_selection
  847.     @mixing = false
  848.     cancel_mix_items
  849.    
  850.     start_actor_command_selection_bubs_mix # alias
  851.   end
  852.  
  853.   #--------------------------------------------------------------------------
  854.   # new method : cancel_mix_items
  855.   #--------------------------------------------------------------------------
  856.   def cancel_mix_items
  857.     actor = BattleManager.actor
  858.     if actor && actor.input.mixed_item
  859.       BattleManager.actor.return_last_mix_items
  860.       BattleManager.actor.input.mixed_item = false
  861.     end
  862.   end
  863.  
  864.   #--------------------------------------------------------------------------
  865.   # new method : create_mix_window
  866.   #--------------------------------------------------------------------------
  867.   def create_mix_window
  868.     @mix_window = Window_MixItem.new(@help_window, @info_viewport)
  869.     @mix_window.set_handler(:ok,     method(:on_mixitem_ok))
  870.     @mix_window.set_handler(:cancel, method(:on_mixitem_cancel))
  871.     resize_mix_window_yea_abe
  872.   end
  873.  
  874.   #--------------------------------------------------------------------------
  875.   # compatibility method : resize_mix_window_yea_abe
  876.   #--------------------------------------------------------------------------
  877.   def resize_mix_window_yea_abe
  878.     return unless $imported["YEA-BattleEngine"]
  879.     @mix_window.height = @skill_window.height
  880.     @mix_window.width = @skill_window.width
  881.     @mix_window.y = Graphics.height - @item_window.height
  882.   end
  883.  
  884.   #--------------------------------------------------------------------------
  885.   # new method : on_mixitem_ok
  886.   #--------------------------------------------------------------------------
  887.   def on_mixitem_ok
  888.     @mix_window.add_item
  889.     if @mix_window.mix_done?
  890.       @mix_window.hide
  891.       determine_mix_target
  892.     else
  893.       @mix_window.activate
  894.     end
  895.   end
  896.  
  897.   #--------------------------------------------------------------------------
  898.   # new method : on_mixitem_cancel
  899.   #--------------------------------------------------------------------------
  900.   def on_mixitem_cancel
  901.     case @mix_window.last_window
  902.     when :skill_window
  903.       on_mixitem_cancel_to_skill_window
  904.     when :yea_bcl # $imported["YEA-BattleCommandList"]
  905.       on_mixitem_cancel_to_yea_bcl
  906.     end
  907.   end
  908.  
  909.   #--------------------------------------------------------------------------
  910.   # new method : on_mixitem_cancel
  911.   #--------------------------------------------------------------------------
  912.   def on_mixitem_cancel_to_skill_window
  913.     if @mix_window.mix_cancel?
  914.       # return to @skill_window
  915.       @mixing = false
  916.       @mix_window.hide
  917.       @skill_window.refresh
  918.       @skill_window.show.activate
  919.     else
  920.       @mix_window.activate
  921.     end
  922.   end
  923.  
  924.   #--------------------------------------------------------------------------
  925.   # compatibility method : on_mixitem_cancel_to_yea_bcl
  926.   #--------------------------------------------------------------------------
  927.   def on_mixitem_cancel_to_yea_bcl
  928.     if @mix_window.mix_cancel?
  929.      
  930.       # YEA - Battle Engine Ace
  931.       if $imported["YEA-BattleEngine"]
  932.         @status_window.show
  933.         @actor_command_window.show
  934.         @status_aid_window.hide
  935.       end
  936.      
  937.       # return to @actor_command_window
  938.       @mixing = false
  939.       @mix_window.hide
  940.       @actor_command_window.show.activate
  941.     else
  942.       @mix_window.activate
  943.     end
  944.   end
  945.  
  946.   #--------------------------------------------------------------------------
  947.   # compatibility alias : command_use_skill
  948.   #--------------------------------------------------------------------------
  949.   if $imported["YEA-BattleCommandList"]
  950.   alias command_use_skill_bubs_mix command_use_skill
  951.   def command_use_skill
  952.     @skill = $data_skills[@actor_command_window.current_ext]
  953.     # override normal skill processing if Mix skill
  954.     if @skill.mix
  955.       # set skill cursor memorization
  956.       BattleManager.actor.last_skill.object = @skill
  957.       # from YEA-BattleCommandList
  958.       status_redraw_target(BattleManager.actor)
  959.      
  960.       if $imported["YEA-BattleEngine"]
  961.         @status_window.hide
  962.         @actor_command_window.hide
  963.         @status_aid_window.show
  964.       end
  965.      
  966.       # set last_window symbol for cancel memorization
  967.       @mix_window.last_window = :yea_bcl
  968.       @mix_window.return_selected_items
  969.       @mixing = true
  970.       @mix_window.refresh
  971.       @mix_window.show.activate.select(0)
  972.     else
  973.       command_use_skill_bubs_mix # alias
  974.     end # if
  975.   end # def
  976.   end # $imported["YEA-BattleCommandList"]
  977.  
  978.   #--------------------------------------------------------------------------
  979.   # new method : determine_mix_target
  980.   #--------------------------------------------------------------------------
  981.   def determine_mix_target
  982.     if $imported["YEA-BattleCommandList"]
  983.       determine_mix_target_yea_bcl
  984.     elsif $imported["YEA-BattleEngine"]
  985.       determine_mix_target_yea_abe
  986.     else # default battle system
  987.       @item = @mix_window.mix_result
  988.       BattleManager.actor.input.set_item(@item.id)
  989.      
  990.       if !@item.need_selection?
  991.         set_actor_mix_items # mix
  992.         next_command
  993.       elsif @item.for_opponent?
  994.         select_enemy_selection
  995.       else
  996.         select_actor_selection
  997.       end # if
  998.     end # if
  999.   end
  1000.  
  1001.   #--------------------------------------------------------------------------
  1002.   # compatibility method : determine_mix_target_yea_abe
  1003.   #--------------------------------------------------------------------------
  1004.   # This method is only used when "YEA-BattleEngine" is installed
  1005.   def determine_mix_target_yea_abe
  1006.     @item = @mix_window.mix_result
  1007.     $game_temp.battle_aid = @item
  1008.     BattleManager.actor.input.set_item(@item.id)
  1009.     if @item.for_opponent?
  1010.       select_enemy_selection
  1011.     elsif @item.for_friend?
  1012.       select_actor_selection
  1013.     else
  1014.       set_actor_mix_items # mix
  1015.       next_command
  1016.       $game_temp.battle_aid = nil
  1017.     end
  1018.   end
  1019.  
  1020.   #--------------------------------------------------------------------------
  1021.   # compatibility method : determine_mix_target_yea_bcl
  1022.   #--------------------------------------------------------------------------
  1023.   # This method is only used when "YEA-BattleCommandList" is installed
  1024.   def determine_mix_target_yea_bcl
  1025.     @item = @mix_window.mix_result
  1026.     BattleManager.actor.input.set_item(@item.id)
  1027.  
  1028.     status_redraw_target(BattleManager.actor)
  1029.     if $imported["YEA-BattleEngine"]
  1030.       $game_temp.battle_aid = @item
  1031.       if @item.for_opponent?
  1032.         select_enemy_selection
  1033.       elsif @item.for_friend?
  1034.         select_actor_selection
  1035.       else
  1036.         set_actor_mix_items # mix
  1037.         next_command
  1038.         $game_temp.battle_aid = nil
  1039.       end
  1040.     else
  1041.       if !@item.need_selection?
  1042.         set_actor_mix_items # mix
  1043.         next_command
  1044.       elsif @item.for_opponent?
  1045.         select_enemy_selection
  1046.       else
  1047.         select_actor_selection
  1048.       end
  1049.     end
  1050.   end
  1051.  
  1052.   #--------------------------------------------------------------------------
  1053.   # new method : set_actor_mix_items
  1054.   #--------------------------------------------------------------------------
  1055.   def set_actor_mix_items
  1056.     return if @mix_window.selected_items.empty?
  1057.     # push mix item pair into the $game_actor
  1058.     BattleManager.actor.mix_items.push(@mix_window.selected_items)
  1059.     # set current action flag
  1060.     BattleManager.actor.input.mixed_item = true
  1061.     # clear @selected_items
  1062.     @mix_window.clear_selected_items
  1063.     @mixing = false
  1064.   end
  1065.  
  1066. end # class Scene_Battle
  1067.  
  1068.  
  1069. #==========================================================================
  1070. # ++ MixData
  1071. #------------------------------------------------------------------------------
  1072. #  This class performs formulae initialization defined by the user and
  1073. # is used to compare player mix item choices what is possible. Also handles
  1074. # developer error messages.
  1075. #==========================================================================
  1076. class MixData
  1077.   #--------------------------------------------------------------------------
  1078.   # public instance variables
  1079.   #--------------------------------------------------------------------------
  1080.   attr_reader :id_formula         # stores all id formulae
  1081.   attr_reader :type_formula       # stores all mix type formulae
  1082.   attr_reader :type_values        # stores mix type integer values
  1083.   attr_accessor :debug_info       # debug window message flag
  1084.   attr_accessor :default_mix_id   # default item id for failed mixes
  1085.   #--------------------------------------------------------------------------
  1086.   # initialize
  1087.   #--------------------------------------------------------------------------
  1088.   def initialize
  1089.     @id_formula = {}
  1090.     @type_formula = {}
  1091.     @type_values = {}
  1092.     @debug_info = Bubs::Mix::DEBUG_INFO
  1093.     @default_mix_id = Bubs::Mix::DEFAULT_MIX_RESULT_ITEM_ID
  1094.     create_type_values
  1095.     create_id_formula
  1096.     create_type_formula
  1097.   end
  1098.  
  1099.   #--------------------------------------------------------------------------
  1100.   # create_type_values
  1101.   #--------------------------------------------------------------------------
  1102.   def create_type_values
  1103.     Bubs::Mix::MIX_TYPES.each_with_index do |symbol, index|
  1104.       @type_values[symbol] = index
  1105.     end
  1106.     # Sets default return value to 0 if key is not found
  1107.     @type_values.default = 0
  1108.   end
  1109.  
  1110.   #--------------------------------------------------------------------------
  1111.   # create_id_formula
  1112.   #--------------------------------------------------------------------------
  1113.   def create_id_formula
  1114.     Bubs::Mix::MIX_FORMULA_BY_ID.each do |key, value|
  1115.       @id_formula[key.sort] = value
  1116.     end
  1117.   end
  1118.  
  1119.   #--------------------------------------------------------------------------
  1120.   # create_type_formula
  1121.   #--------------------------------------------------------------------------
  1122.   def create_type_formula
  1123.     Bubs::Mix::MIX_FORMULA_BY_TYPE.each do |key, value|
  1124.       output_type_formula_error(key[0])
  1125.       output_type_formula_error(key[1])
  1126.       # converts symbols to integer values based on the index of the key
  1127.       # in MIX_TYPES
  1128.       a = get_mix_type_value(key[0])
  1129.       b = get_mix_type_value(key[1])
  1130.       array = [a, b]
  1131.       begin
  1132.         array.sort!
  1133.       rescue
  1134.         output_type_formula_error(key, value)
  1135.         next
  1136.       end # begin
  1137.       @type_formula[array] = value
  1138.     end # do
  1139.   end
  1140.  
  1141.   #--------------------------------------------------------------------------
  1142.   # test_item_type_symbol
  1143.   #--------------------------------------------------------------------------
  1144.   def test_item_type_symbol(item)
  1145.     output_mix_type_error(item) unless mix_type_ok?(item)
  1146.   end
  1147.  
  1148.   #--------------------------------------------------------------------------
  1149.   # mix_type_ok?
  1150.   #--------------------------------------------------------------------------
  1151.   # Checks item's mix_type symbol was provided by the user.
  1152.   def mix_type_ok?(item)
  1153.     Bubs::Mix::MIX_TYPES.include?(item.mix_type)
  1154.   end
  1155.  
  1156.   #--------------------------------------------------------------------------
  1157.   # output_type_formula_error
  1158.   #--------------------------------------------------------------------------
  1159.   def output_type_formula_error(key, value)
  1160.     return unless $TEST && @debug_info
  1161.     p "An error occurred with a Mix Type formula:"
  1162.     p sprintf("%s => %s", key, value)
  1163.   end
  1164.  
  1165.   #--------------------------------------------------------------------------
  1166.   # output_mix_type_error
  1167.   #--------------------------------------------------------------------------
  1168.   def output_mix_type_error(item)
  1169.     return unless $TEST && @debug_info
  1170.     p sprintf("An error occurred with Item ID %s: %s", item.id, item.name)
  1171.     p sprintf(":%s does not exist in MIX_TYPES", item.mix_type)
  1172.   end
  1173.  
  1174.   #--------------------------------------------------------------------------
  1175.   # output_mix_id_result
  1176.   #--------------------------------------------------------------------------
  1177.   def output_mix_id_result(item1, item2, result_item)
  1178.     return unless $TEST && @debug_info
  1179.     name1 = item1.name
  1180.     name2 = item2.name
  1181.     # If you get an error on this line, it means that the result item ID
  1182.     # doesn't exist in your database.
  1183.     name3 = result_item.name
  1184.     p sprintf("%s + %s = %s", name1, name2, name3)
  1185.   end
  1186.  
  1187.   #--------------------------------------------------------------------------
  1188.   # output_mix_type_result
  1189.   #--------------------------------------------------------------------------
  1190.   def output_mix_type_result(item1, item2, result_item)
  1191.     return unless $TEST && @debug_info
  1192.     name1 = item1.mix_type.to_s
  1193.     name2 = item2.mix_type.to_s
  1194.     # If you get an error on this line, it means that the result item ID
  1195.     # doesn't exist in your database.
  1196.     name3 = result_item.name
  1197.     p sprintf(":%s + :%s = %s", name1, name2, name3)
  1198.   end
  1199.  
  1200.   #--------------------------------------------------------------------------
  1201.   # output_default_result
  1202.   #--------------------------------------------------------------------------
  1203.   def output_default_result
  1204.     return unless $TEST && @debug_info
  1205.     name = $data_items[@default_mix_id].name
  1206.     p sprintf("Default mix result: %s", name)
  1207.   end
  1208.  
  1209.   #--------------------------------------------------------------------------
  1210.   # output_nil_result_error
  1211.   #--------------------------------------------------------------------------
  1212.   def output_nil_result_error(item, id)
  1213.     return unless $TEST && @debug_info
  1214.     return unless item.nil?
  1215.     p sprintf("Item ID %s doesn't exist in your Database!", id)
  1216.   end
  1217.  
  1218.   #--------------------------------------------------------------------------
  1219.   # output_type_formula_error
  1220.   #--------------------------------------------------------------------------
  1221.   def output_type_formula_error(symbol)
  1222.     return unless $TEST && @debug_info
  1223.     return if Bubs::Mix::MIX_TYPES.include?(symbol)
  1224.     p "An error occurred with a Mix Type formula:"
  1225.     p sprintf(":%s does not exist in MIX_TYPES", symbol)
  1226.   end
  1227.  
  1228.   #--------------------------------------------------------------------------
  1229.   # output_returned_items
  1230.   #--------------------------------------------------------------------------
  1231.   def output_returned_items(item1, item2)
  1232.     return unless $TEST && @debug_info
  1233.     p sprintf("Returned mix items: %s and %s", item1.name, item2.name)
  1234.   end
  1235.    
  1236.   #--------------------------------------------------------------------------
  1237.   # get_mix_type_value
  1238.   #--------------------------------------------------------------------------
  1239.   # returns the value the given mix type symbol
  1240.   # returns 0 if symbol does not exist
  1241.   def get_mix_type_value(symbol)
  1242.     @type_values[symbol]
  1243.   end
  1244.  
  1245.   #--------------------------------------------------------------------------
  1246.   # determine_id_formula
  1247.   #--------------------------------------------------------------------------
  1248.   # Compares the pair of item IDs to find any matching mix formula
  1249.   # returns 0 if none is found
  1250.   def determine_id_formula(item1, item2)
  1251.     @id_formula.each do |key, value|
  1252.       return value if (key <=> [item1.id, item2.id].sort) == 0
  1253.     end
  1254.     return 0
  1255.   end
  1256.  
  1257.   #--------------------------------------------------------------------------
  1258.   # determine_type_formula
  1259.   #--------------------------------------------------------------------------
  1260.   # Compares the pair of item mix_types to find any matching mix formula
  1261.   # returns 0 if none is found
  1262.   def determine_type_formula(item1, item2)
  1263.     value1 = get_mix_type_value(item1.mix_type)
  1264.     value2 = get_mix_type_value(item2.mix_type)
  1265.     @type_formula.each do |key, value|
  1266.       return value if (key <=> [value1, value2].sort) == 0
  1267.     end
  1268.     return 0
  1269.   end
  1270.  
  1271.   #--------------------------------------------------------------------------
  1272.   # process_id_formula_result
  1273.   #--------------------------------------------------------------------------
  1274.   def process_id_formula_result(item1, item2, id)
  1275.     result = $data_items[id]
  1276.     output_nil_result_error(result, id)
  1277.     output_mix_id_result(item1, item2, result)
  1278.     return result
  1279.   end
  1280.  
  1281.   #--------------------------------------------------------------------------
  1282.   # process_type_formula_result
  1283.   #--------------------------------------------------------------------------
  1284.   def process_type_formula_result(item1, item2, id)
  1285.     result = $data_items[id]
  1286.     output_nil_result_error(result, id)
  1287.     output_mix_type_result(item1, item2, result)
  1288.     return result
  1289.   end
  1290.  
  1291.   #--------------------------------------------------------------------------
  1292.   # get_mix_item_result
  1293.   #--------------------------------------------------------------------------
  1294.   # This should be the most used method from this class. Returns an item
  1295.   # to be used after comparing all possible formulae.
  1296.   def get_mix_item_result(item1, item2)
  1297.    
  1298.     # Checks if id formula exists for the two given item arguments
  1299.     id = determine_id_formula(item1, item2)
  1300.     return process_id_formula_result(item1, item2, id) if id > 0
  1301.    
  1302.     # Checks if type formula exists for the two given item arguments
  1303.     id = determine_type_formula(item1, item2)
  1304.     return process_type_formula_result(item1, item2, id) if id > 0
  1305.  
  1306.     output_default_result
  1307.     # return default item id if no formula is found
  1308.     return $data_items[@default_mix_id]
  1309.   end
  1310.  
  1311. end # class MixData
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement