Advertisement
Guest User

Untitled

a guest
Nov 12th, 2010
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 54.57 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Yanfly Engine RD - Actor Item Synthesis
  4. # Last Date Updated: 2009.06.23
  5. # Level: Hard
  6. #
  7. # This item synthesis script is influenced after Gust RPG's famous synthesizing
  8. # systems. To synthesize an item, one would need a recipe and the required actor
  9. # in your party. Different actors can yield different outcomes, but they all
  10. # possess and use the same ingredients.
  11. #
  12. # Another thing this script will provide (for the player) is that any items that
  13. # were synthesized through the shop's recipes can then be bought without need
  14. # to synthesize them again. The need to constantly resynthesize items to get
  15. # more of them becomes rather tedious and that really isn't something we should
  16. # put the player through.
  17. #
  18. # This script also allows playing events after item creation similar to that of
  19. # the Gust RPG's. There you can play out little skits and such or even unlock
  20. # certain parts of the game for synthesizing a particular item.
  21. #
  22. #===============================================================================
  23. # Updates:
  24. # ----------------------------------------------------------------------------
  25. # o 2009.06.23 - Compatibility fix with KGC Help Extension
  26. # o 2009.06.21 - Compatibility update with Display Item Query
  27. # o 2009.06.14 - Bug fix for Synth Listing
  28. # o 2009.06.10 - Added <synth unbuyable>
  29. # o 2009.06.04 - Added <synth block actor x>
  30. #              - Common events are played only once per actor now
  31. #              - Added <replay event> to replay common events more than once
  32. #              - Added <synth exp x> and <synth exp x:y>
  33. # o 2009.06.03 - Finished script
  34. # o 2009.06.02 - Started script
  35. #===============================================================================
  36. # Instructions
  37. #===============================================================================
  38. #
  39. # These go into the recipe's notebox. Recipes can be items, weapons, or armours
  40. # but they must contain the following information before they can be recipes:
  41. # -----------------------------------------------------------------------------
  42. #
  43. # <synth actor a b:c>
  44. # a is the ID of the actor that can use the recipe. If the ID is 0, all actors
  45. # can user the recipe. b has to be either I, W, or A. This will determine what
  46. # type of item will be produced, an item, weapon, or armour. c is the ID of the
  47. # item type to be created. <synth actor 3 I:8> means if actor 3 uses this recipe
  48. # then actor 3 will create Item ID 8.
  49. #
  50. # <synth cost n>
  51. # This is how much synthesizing the recipe will cost. If this isn't included,
  52. # the synthesis is considered to be free.
  53. #
  54. # <ingredients a:b> or <ingredients a:b xc>
  55. # This determines what ingredients are needed. a has to be either I, W, or A to
  56. # determine what type of item is being used. b determines the item ID of the
  57. # item type to be used. Should you decide to use the second tag, c is how many
  58. # of the item is needed for the recipe to be made.
  59. #
  60. # -----------------------------------------------------------------------------
  61. # The following are optional tags you may place in a recipe's notebox.
  62. # -----------------------------------------------------------------------------
  63. #
  64. # <synth block actor x> or <synth block actor x,x>
  65. # This will prevent actors from being able to perform the synthesis at all,
  66. # even if actor 0 is listed for <synth actor>. To block multiple actors, just
  67. # add more of the tags or use the <synth block actor x,x> version.
  68. #
  69. # <synth actor a event:b>
  70. # For those that want to play a common event after a synthesis, set b to the ID
  71. # of the common event desired. a is the actor set to play after that actor makes
  72. # an item. If a is 0, it is set for all actors.
  73. #
  74. # <replay event>
  75. # This will allow the common event to be replayable after viewing once.
  76. #
  77. # <consume recipe> or <not consume recipe>
  78. # This will override the default rules set for consuming recipes. The first will
  79. # always consume the recipe regardless of the rulesetting and the second one
  80. # will prevent the recipe from being consumed.
  81. #
  82. # <synth exp x> or <synth exp x:y>
  83. # This determines how much experience the actor synthesizing the item gains
  84. # from performing the synthesis. The first time through, the actor will gain x
  85. # experience. On follow-up synthesis sessions, the actor will not gain any exp
  86. # unless the second tag is used. Only y exp will be gained on follow up any
  87. # follow-up sessions. But no matter how much experience the actor gains, the
  88. # actor cannot level up from synthesizing items (to prevent bugs from occuring).
  89. #
  90. # <synth unbuyable>
  91. # This makes the item unable to be bought even after synthesizing it. This tag
  92. # can be used in either the item to be bought or the recipe. If it's on the
  93. # item to be bought, then only that item is is disabled from the recipe. If the
  94. # tag is on the recipe, all items created by that recipe cannot be bought.
  95. #
  96. #===============================================================================
  97. #
  98. # Compatibility
  99. # - Works With: KGC's LimitBreak, Help Extension
  100. # - Works With: Yanfly's Variable Controlled Discounts
  101. # - Alias: Scene_Map: call_shop
  102. #
  103. #===============================================================================
  104.  
  105. $imported = {} if $imported == nil
  106. $imported["ActorItemSynthesis"] = true
  107.  
  108. module YE
  109.   module SYNTH
  110.    
  111.     # This is the switch required to be on before the shop can be called out.
  112.     # Remember to turn off your switches beforehand.
  113.     SYNTH_SWITCH = 72
  114.    
  115.     # The following determines the various settings for the synthesis shop.
  116.     SYNTH_TEXT   = "Synth"             # Synthesis option for shop commands.
  117.     SYNTH_INCOMP = "Incompatible"      # Text for incompatible actors.
  118.     SYNTH_INCOLR = 10                  # Colour for incompatible actors.
  119.     SYNTH_INGRED = "Ingredients"       # Text used for ingredients.
  120.     SYNTH_OUTCOM = "Outcome"           # Text used for ingredients.
  121.     SYNTH_FSIZE  = 16                  # Font size for smaller text.
  122.     SYNTH_OFFSET = 48                  # X offset for text next to actor sprite.
  123.     SYNTH_TOTAL  = "Recipes Known: %d" # Total recipes done by actor.
  124.     SYNTH_COST   = "Synth Cost"        # Text for synthesis cost.
  125.     SYNTH_C_ICON = 205                 # Icon for synthesis cost.
  126.     SYNTH_T_COST = "%d %s"             # Text format used for synth amount.
  127.     SYNTH_AMT    = "%d/%d"             # Ingredients required over possessed.
  128.     SYNTH_HIDE_0 = true                # This will hide amount needed if zero.
  129.     SYNTH_UNICON = 144                 # Icon used for unknown items.
  130.     SYNTH_UNMASK = "Unknown"           # Mask used for unknown items.
  131.    
  132.     # The following determines the rules for recipe consumption. This will
  133.     # govern whether or not you would want recipes to be used up after synthing
  134.     # an item. If it's set to true, recipes will be included in the ingredients
  135.     # listing. The number consumed depends on how many items were synthesized
  136.     # from the recipe.
  137.     CONSUME_RECIPE_ITEM   = false  # If recipe is an item, consume item.
  138.     CONSUME_RECIPE_WEAPON = true   # If recipe is an weapon, consume weapon.
  139.     CONSUME_RECIPE_ARMOUR = true   # If recipe is an armour, consume armour.
  140.    
  141.     # The following determines the rules governing common events. Note that if
  142.     # common events are played outside of the shop, the player will not return
  143.     # to the shop after the event is done.
  144.     EVENT_IN_SHOP = true    # Stay inside the shop for common events.
  145.     FADE_TIME     = 30      # The amount of frames of fade in between events.
  146.    
  147.   end
  148. end
  149.  
  150. #===============================================================================
  151. # Editting anything past this point may potentially result in causing computer
  152. # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
  153. # Therefore, edit at your own risk.
  154. #===============================================================================
  155.  
  156. module YE
  157. module REGEXP
  158. module SYNTH
  159.      
  160.   ACTOR = /<(?:SYNTH_ACTOR|synth actor)[ ]*(\d+)[ ]\s*([IWA]):(\d+)?>/i
  161.   EVENT = /<(?:SYNTH_ACTOR|synth actor)[ ]*(\d+)[ ](?:EVENT|event):(\d+)?>/i
  162.   BLOCK = /<(?:SYNTH_BLOCK_ACTOR|synth block actor)[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  163.   COST  = /<(?:SYNTH_COST|synth cost)[ ]*(\d+)>/i
  164.   INGRE = /<(?:INGREDIENT|ingredients)\s*([IWA]):(\d+)?>/i
  165.   INGRX = /<(?:INGREDIENT|ingredients)\s*([IWA]):(\d+)[ ]x(\d+)?>/i
  166.   CONSUME = /<(?:CONSUME|consume recipe)>/i
  167.   NOTCONSUME = /<(?:NOT_CONSUME|not consume recipe|not consume)>/i
  168.   REPLAY = /<(?:REPLAY_EVENT|replay event)>/i
  169.   UNBUYABLE = /<(?:SYNTH_UNBUYABLE|synth unbuyable)>/i
  170.   EXP1 = /<(?:SYNTH_EXP|synth exp)[ ]*(\d+)>/i
  171.   EXP2 = /<(?:SYNTH_EXP|synth exp)[ ]*(\d+):(\d+)>/i
  172.      
  173. end # BASEITEM
  174. end # REGEXP
  175. end # YE
  176.  
  177. #===============================================================================
  178. # RPG::BaseItem
  179. #===============================================================================
  180.  
  181. class RPG::BaseItem
  182.  
  183.   #--------------------------------------------------------------------------
  184.   # Yanfly_Cache_BaseItem_AIS
  185.   #--------------------------------------------------------------------------
  186.   def yanfly_cache_baseitem_ais
  187.     @recipe = false; @synth_actor = {}; @ingredients = {}; @synth_cost = 0
  188.     @synth_consume = false; @synth_event = {}; @synth_block = []
  189.     @replay_event = false; @synth_exp1 = 0; @synth_exp2 = 0
  190.     @synth_unbuyable = false
  191.    
  192.     self.note.split(/[\r\n]+/).each { |line|
  193.       case line
  194.       when YE::REGEXP::SYNTH::ACTOR
  195.         case $2.upcase
  196.         when "I"
  197.           @synth_actor[$1.to_i] = $data_items[$3.to_i]
  198.           @synth_consume = YE::SYNTH::CONSUME_RECIPE_ITEM
  199.         when "W"
  200.           @synth_actor[$1.to_i] = $data_weapons[$3.to_i]
  201.           @synth_consume = YE::SYNTH::CONSUME_RECIPE_WEAPON
  202.         when "A"
  203.           @synth_actor[$1.to_i] = $data_armors[$3.to_i]
  204.           @synth_consume = YE::SYNTH::CONSUME_RECIPE_ARMOUR
  205.         end
  206.       when YE::REGEXP::SYNTH::EVENT
  207.         @synth_event[$1.to_i] = $2.to_i
  208.       when YE::REGEXP::SYNTH::BLOCK
  209.         $1.scan(/\d+/).each { |num|
  210.         if num.to_i > 0
  211.           @synth_block.push(num.to_i)
  212.         end }
  213.       when YE::REGEXP::SYNTH::COST
  214.         @synth_cost = $1.to_i
  215.       when YE::REGEXP::SYNTH::INGRE
  216.         case $1.upcase
  217.         when "I"
  218.           @ingredients[$data_items[$2.to_i]] = 1
  219.         when "W"
  220.           @ingredients[$data_weapons[$2.to_i]] = 1
  221.         when "A"
  222.           @ingredients[$data_armors[$2.to_i]] = 1
  223.         end
  224.       when YE::REGEXP::SYNTH::INGRX
  225.         case $1.upcase
  226.         when "I"
  227.           @ingredients[$data_items[$2.to_i]] = $3.to_i
  228.         when "W"
  229.           @ingredients[$data_weapons[$2.to_i]] = $3.to_i
  230.         when "A"
  231.           @ingredients[$data_armors[$2.to_i]] = $3.to_i
  232.         end
  233.       when YE::REGEXP::SYNTH::REPLAY
  234.         @replay_event = true
  235.       when YE::REGEXP::SYNTH::EXP1
  236.         @synth_exp1 = $1.to_i
  237.       when YE::REGEXP::SYNTH::EXP2
  238.         @synth_exp1 = $1.to_i
  239.         @synth_exp2 = $2.to_i
  240.       when YE::REGEXP::SYNTH::UNBUYABLE
  241.         @synth_unbuyable = true
  242.       end
  243.     }
  244.     self.note.split(/[\r\n]+/).each { |line|
  245.       case line
  246.       when YE::REGEXP::SYNTH::CONSUME
  247.         @synth_consume = true
  248.       when YE::REGEXP::SYNTH::NOTCONSUME
  249.         @synth_consume = false
  250.       end
  251.     }
  252.    
  253.     if @synth_actor != {} and @ingredients != {}
  254.       @recipe = true
  255.     end
  256.   end
  257.  
  258.   #--------------------------------------------------------------------------
  259.   # definitions
  260.   #--------------------------------------------------------------------------
  261.   def recipe?
  262.     yanfly_cache_baseitem_ais if @recipe == nil
  263.     return @recipe
  264.   end
  265.   def synth_actor
  266.     yanfly_cache_baseitem_ais if @synth_actor == nil
  267.     return @synth_actor
  268.   end
  269.   def synth_event
  270.     yanfly_cache_baseitem_ais if @synth_event == nil
  271.     return @synth_event
  272.   end
  273.   def synth_block
  274.     yanfly_cache_baseitem_ais if @synth_block == nil
  275.     return @synth_block
  276.   end
  277.   def synth_cost
  278.     yanfly_cache_baseitem_ais if @synth_cost == nil
  279.     return @synth_cost
  280.   end
  281.   def synth_consume?
  282.     yanfly_cache_baseitem_ais if @synth_consume == nil
  283.     return @synth_consume
  284.   end
  285.   def ingredients
  286.     yanfly_cache_baseitem_ais if @ingredients == nil
  287.     return @ingredients
  288.   end
  289.   def replay_event?
  290.     yanfly_cache_baseitem_ais if @replay_event == nil
  291.     return @replay_event
  292.   end
  293.   def synth_exp1
  294.     yanfly_cache_baseitem_ais if @synth_exp1 == nil
  295.     return @synth_exp1
  296.   end
  297.   def synth_exp2
  298.     yanfly_cache_baseitem_ais if @synth_exp2 == nil
  299.     return @synth_exp2
  300.   end
  301.   def synth_unbuyable
  302.     yanfly_cache_baseitem_ais if @synth_unbuyable == nil
  303.     return @synth_unbuyable
  304.   end
  305.  
  306. end # RPG::BaseItem
  307.  
  308. #===============================================================================
  309. # Game_Actor
  310. #===============================================================================
  311.  
  312. class Game_Actor < Game_Battler
  313.  
  314.   #--------------------------------------------------------------------------
  315.   # Next Exp - The experience needed for the next level.
  316.   #--------------------------------------------------------------------------
  317.   def next_exp
  318.     return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  319.   end
  320.  
  321.   #--------------------------------------------------------------------------
  322.   # learn_recipe
  323.   #--------------------------------------------------------------------------
  324.   def learn_recipe(item)
  325.     if item.is_a?(RPG::Item)
  326.       unless synth_items.include?(item.id)
  327.         synth_items.push(item.id)
  328.         exp = [[item.synth_exp1, next_exp - 1].min, 0].max
  329.         gain_exp(exp, false)
  330.       else
  331.         exp = [[item.synth_exp2, next_exp - 1].min, 0].max
  332.         gain_exp(exp, false)
  333.       end
  334.     elsif item.is_a?(RPG::Weapon)
  335.       unless synth_weapons.include?(item.id)
  336.         synth_weapons.push(item.id)
  337.         exp = [[item.synth_exp1, next_exp - 1].min, 0].max
  338.         gain_exp(exp, false)
  339.       else
  340.         exp = [[item.synth_exp2, next_exp - 1].min, 0].max
  341.         gain_exp(exp, false)
  342.       end
  343.     elsif item.is_a?(RPG::Armor)
  344.       unless synth_armours.include?(item.id)
  345.         synth_armours.push(item.id)
  346.         exp = [[item.synth_exp1, next_exp - 1].min, 0].max
  347.         gain_exp(exp, false)
  348.       else
  349.         exp = [[item.synth_exp2, next_exp - 1].min, 0].max
  350.         gain_exp(exp, false)
  351.       end
  352.     end
  353.   end
  354.  
  355.   #--------------------------------------------------------------------------
  356.   # synth_events
  357.   #--------------------------------------------------------------------------
  358.   def synth_events
  359.     @synth_events = [] if @synth_events == nil
  360.     return @synth_events
  361.   end
  362.  
  363.   #--------------------------------------------------------------------------
  364.   # synth_items
  365.   #--------------------------------------------------------------------------
  366.   def synth_items
  367.     @synth_items = [] if @synth_items == nil
  368.     return @synth_items
  369.   end
  370.  
  371.   #--------------------------------------------------------------------------
  372.   # synth_weapons
  373.   #--------------------------------------------------------------------------
  374.   def synth_weapons
  375.     @synth_weapons = [] if @synth_weapons == nil
  376.     return @synth_weapons
  377.   end
  378.  
  379.   #--------------------------------------------------------------------------
  380.   # synth_armours
  381.   #--------------------------------------------------------------------------
  382.   def synth_armours
  383.     @synth_armours = [] if @synth_armours == nil
  384.     return @synth_armours
  385.   end
  386.  
  387. end # Game_Actor
  388.  
  389. #===============================================================================
  390. # Spriteset_Menu
  391. #===============================================================================
  392.  
  393. class Spriteset_Menu
  394.   unless method_defined?(:create_viewports)
  395.   #--------------------------------------------------------------------------
  396.   # initialize
  397.   #--------------------------------------------------------------------------
  398.   def initialize
  399.     create_viewports
  400.     create_pictures
  401.     update
  402.   end
  403.  
  404.   def create_viewports
  405.     @viewport1 = Viewport.new(0, 0, 544, 416)
  406.     @viewport2 = Viewport.new(0, 0, 544, 416)
  407.     @viewport3 = Viewport.new(0, 0, 544, 416)
  408.     @viewport2.z = 50
  409.     @viewport3.z = 100
  410.   end
  411.  
  412.   def create_pictures
  413.     @picture_sprites = []
  414.     for i in 1..20
  415.       @picture_sprites.push(Sprite_Picture.new(@viewport2,
  416.       $game_map.screen.pictures[i]))
  417.     end
  418.   end
  419.  
  420.   #--------------------------------------------------------------------------
  421.   # dispose
  422.   #--------------------------------------------------------------------------
  423.   def dispose
  424.     dispose_pictures
  425.     dispose_viewports
  426.   end
  427.  
  428.   def dispose_pictures
  429.     for sprite in @picture_sprites
  430.       sprite.dispose
  431.     end
  432.   end
  433.    
  434.   def dispose_viewports
  435.     @viewport1.dispose
  436.     @viewport2.dispose
  437.     @viewport3.dispose
  438.   end
  439.  
  440.   #--------------------------------------------------------------------------
  441.   # update
  442.   #--------------------------------------------------------------------------
  443.   def update
  444.     update_pictures
  445.     update_viewports
  446.   end
  447.  
  448.   def update_pictures
  449.     for sprite in @picture_sprites
  450.       sprite.update
  451.     end
  452.   end
  453.  
  454.   def update_viewports
  455.     @viewport1.tone = $game_map.screen.tone
  456.     @viewport1.ox = $game_map.screen.shake
  457.     @viewport2.color = $game_map.screen.flash_color
  458.     @viewport3.color.set(0, 0, 0, 255 - $game_map.screen.brightness)
  459.     @viewport1.update
  460.     @viewport2.update
  461.     @viewport3.update
  462.   end
  463.   end
  464. end # Spriteset_Menu
  465.  
  466. #===============================================================================
  467. # Scene_Map
  468. #===============================================================================
  469.  
  470. class Scene_Map < Scene_Base
  471.  
  472.   #--------------------------------------------------------------------------
  473.   # alias call_shop
  474.   #--------------------------------------------------------------------------
  475.   alias call_shop_ais call_shop unless $@
  476.   def call_shop
  477.     if $game_switches[YE::SYNTH::SYNTH_SWITCH]
  478.       $game_temp.next_scene = nil
  479.       $game_switches[YE::SYNTH::SYNTH_SWITCH] = false
  480.       $scene = Scene_Synthesis.new
  481.     else
  482.       call_shop_ais
  483.     end
  484.   end
  485.  
  486. end # Scene_Map
  487.  
  488. #===============================================================================
  489. # Scene_Synthesis
  490. #===============================================================================
  491.  
  492. class Scene_Synthesis < Scene_Base
  493.  
  494.   #--------------------------------------------------------------------------
  495.   # start
  496.   #--------------------------------------------------------------------------
  497.   def start
  498.     super
  499.     create_menu_background
  500.     @actor_index = 0
  501.     @actor_id = $game_party.members[@actor_index].id
  502.     @interpreter = Game_Interpreter.new
  503.     @common_event = 0
  504.     @spriteset = Spriteset_Menu.new
  505.     @running = false
  506.     @help_window = Window_Help.new
  507.     @gold_window = Window_Gold.new(384, @help_window.height)
  508.     create_command_window
  509.     adjust_window_size
  510.     dy = @help_window.height + @gold_window.height
  511.     dw = Graphics.width - 304
  512.     dh = Graphics.height - dy
  513.     @buy_window = Window_SynthBuy.new(0, dy, 304, dh)
  514.     @buy_window.help_window = @help_window
  515.     @number_window = Window_ShopNumber.new(0, 112)
  516.     @number_window.active = false
  517.     @number_window.visible = false
  518.     @status_window = Window_ShopStatus.new(304, dy)
  519.     @status_window.height = dh
  520.     @status_window.create_contents
  521.     @synth_list = Window_SynthList.new(0, dy, 304, dh)
  522.     @synth_list.help_window = @help_window
  523.     @ingre_list = Window_Ingredients.new(304, dy, dw, dh)
  524.     @synth_number = Window_SynthNumber.new(0, 112)
  525.     @synth_number.visible = false
  526.     @synth_number.active = false
  527.     @message_window = Window_Message.new
  528.     @help_window.set_text("")
  529.     setup_display_item_query if $imported["DisplayItemQuery"]
  530.   end
  531.  
  532.   #--------------------------------------------------------------------------
  533.   # adjust_window_size
  534.   #--------------------------------------------------------------------------
  535.   def adjust_window_size
  536.     return unless $imported["HelpExtension"]
  537.     @help_window.row_max = KGC::HelpExtension::ROW_MAX
  538.     @command_window.y = @help_window.height
  539.     @gold_window.y = @help_window.height
  540.     dy = @help_window.height + @command_window.height
  541.   end
  542.  
  543.   #--------------------------------------------------------------------------
  544.   # terminate
  545.   #--------------------------------------------------------------------------
  546.   def terminate
  547.     super
  548.     dispose_menu_background
  549.     @spriteset.dispose if @spriteset != nil
  550.     @help_window.dispose if @help_window != nil
  551.     @gold_window.dispose if @gold_window != nil
  552.     @buy_window.dispose if @buy_window != nil
  553.     @number_window.dispose if @number_window != nil
  554.     @status_window.dispose if @status_window != nil
  555.     @synth_list.dispose if @synth_list != nil
  556.     @ingre_list.dispose if @ingre_list != nil
  557.     @command_window.dispose if @command_window != nil
  558.     @synth_number.dispose if @synth_number != nil
  559.     @message_window.dispose if @message_window != nil
  560.   end
  561.  
  562.   #--------------------------------------------------------------------------
  563.   # create_command_window
  564.   #--------------------------------------------------------------------------
  565.   def create_command_window
  566.     carray = []
  567.     carray.push(Vocab::ShopBuy)
  568.     carray.push(YE::SYNTH::SYNTH_TEXT)
  569.     carray.push(Vocab::ShopCancel)
  570.     @command_window = Window_Command.new(384, carray, 3)
  571.     @command_window.y = @help_window.height
  572.   end
  573.  
  574.   #--------------------------------------------------------------------------
  575.   # setup_display_item_query
  576.   #--------------------------------------------------------------------------
  577.   def setup_display_item_query
  578.     sdx = 0
  579.     sdy = @buy_window.y
  580.     sdw = 272
  581.     sdh = @buy_window.height
  582.     @item_data_window = Window_Item_Data.new(0, sdy, 272, sdh)
  583.     @item_data_window.visible = false
  584.     @item_data_window.active = false
  585.   end
  586.  
  587.   #--------------------------------------------------------------------------
  588.   # update
  589.   #--------------------------------------------------------------------------
  590.   def update
  591.     super
  592.     update_basic
  593.     update_ingredients_window
  594.     return if @interpreter.running?
  595.     return if $game_message.visible
  596.     if $imported["DisplayItemQuery"] and @item_data_window != nil and
  597.     @item_data_window.active
  598.       update_item_data_window
  599.     elsif @command_window.active
  600.       update_command_window
  601.     elsif @buy_window.active
  602.       @last_index = @buy_window.index + 1
  603.       update_buy_selection
  604.     elsif @synth_list.active
  605.       update_synth_list
  606.     elsif @number_window.active
  607.       update_number_input
  608.     elsif @synth_number.active
  609.       update_synth_number
  610.     end
  611.   end
  612.  
  613.   #--------------------------------------------------------------------------
  614.   # update_basic
  615.   #--------------------------------------------------------------------------
  616.   def update_basic
  617.     update_menu_background
  618.     update_interpreter
  619.     $game_map.update
  620.     @interpreter.update
  621.     @spriteset.update
  622.     @message_window.update
  623.   end
  624.  
  625.   #--------------------------------------------------------------------------
  626.   # update_interpreter
  627.   #--------------------------------------------------------------------------
  628.   def update_interpreter
  629.     if !@interpreter.running? and @running
  630.       Graphics.fadeout(YE::SYNTH::FADE_TIME)
  631.       @command_window.visible = true
  632.       @gold_window.visible = true
  633.       @help_window.visible = true
  634.       @synth_list.visible = true
  635.       @ingre_list.visible = true
  636.       @synth_list.update
  637.       Graphics.fadein(YE::SYNTH::FADE_TIME)
  638.       @running = false
  639.     elsif @interpreter.running? and !@running
  640.       Graphics.fadeout(YE::SYNTH::FADE_TIME)
  641.       @command_window.visible = false
  642.       @gold_window.visible = false
  643.       @help_window.visible = false
  644.       @synth_list.visible = false
  645.       @ingre_list.visible = false
  646.       Graphics.fadein(YE::SYNTH::FADE_TIME)
  647.       @running = true
  648.     end
  649.     if @common_event > 0
  650.       @interpreter.setup($data_common_events[@common_event].list)
  651.       @common_event = 0
  652.       return
  653.     end
  654.   end
  655.  
  656.   #--------------------------------------------------------------------------
  657.   # update_ingredients_window
  658.   #--------------------------------------------------------------------------
  659.   def update_ingredients_window
  660.     return unless @ingre_list.visible
  661.     return if @ingre_list.item == @synth_list.item
  662.     @ingre_list.item = @synth_list.item
  663.     @ingre_list.refresh(@actor_index)
  664.   end
  665.  
  666.   #--------------------------------------------------------------------------
  667.   # update_item_data_window
  668.   #--------------------------------------------------------------------------
  669.   def update_item_data_window
  670.     @item_data_window.update
  671.     if Input.trigger?(Input::B)
  672.       Sound.play_cancel
  673.       @item_data_window.disappear
  674.       @buy_window.active = true
  675.     elsif Input.trigger?(Input::LEFT) or Input.trigger?(Input::UP)
  676.       @item_data_window.previous_page
  677.     elsif Input.trigger?(Input::RIGHT) or Input.trigger?(Input::DOWN)
  678.       @item_data_window.next_page
  679.     elsif Input.trigger?(Input::L)
  680.       @item_data_window.top_page
  681.     elsif Input.trigger?(Input::R)
  682.       @item_data_window.bottom_page
  683.     end
  684.   end
  685.  
  686.   #--------------------------------------------------------------------------
  687.   # update_command_window
  688.   #--------------------------------------------------------------------------
  689.   def update_command_window
  690.     @command_window.update
  691.     if Input.trigger?(Input::B)
  692.       Sound.play_cancel
  693.       $scene = Scene_Map.new
  694.     elsif Input.trigger?(Input::C)
  695.       Sound.play_decision
  696.       case @command_window.index
  697.       when 0
  698.         Sound.play_decision
  699.         @command_window.active = false
  700.         @buy_window.index = 0 if @buy_window.index < 0
  701.         @buy_window.active = true
  702.         @buy_window.refresh
  703.         @status_window.visible = true
  704.       when 1
  705.         @synth_list.active = true
  706.         @synth_list.visible = true
  707.         @ingre_list.visible = true
  708.         @synth_list.refresh(@actor_index)
  709.         @buy_window.visible = false
  710.         @status_window.visible = false
  711.         @command_window.active = false
  712.       when 2
  713.         $scene = Scene_Map.new
  714.       end
  715.     end
  716.   end
  717.  
  718.   #--------------------------------------------------------------------------
  719.   # update_buy_selection
  720.   #--------------------------------------------------------------------------
  721.   def update_buy_selection
  722.     if @last_index != @buy_window.index
  723.       @last_index = @buy_window.index
  724.       @status_window.item = @buy_window.item
  725.     end
  726.     @buy_window.update
  727.     if $imported["DisplayItemQuery"] and
  728.     Input.trigger?(YE::MENU::ITEM::ITEM_QUERY_SHOP_BUTTON)
  729.       @item = @buy_window.item
  730.       if @item == nil
  731.         Sound.play_buzzer
  732.       else
  733.         Sound.play_decision
  734.         @item = @buy_window.item
  735.         @item_data_window.appear(@item, @buy_window, 2)
  736.         @buy_window.active = false
  737.       end
  738.     elsif Input.trigger?(Input::B)
  739.       Sound.play_cancel
  740.       @command_window.active = true
  741.       @buy_window.active = false
  742.       @status_window.item = nil
  743.       @help_window.set_text("")
  744.       return
  745.     elsif Input.trigger?(Input::C)
  746.       @item = @buy_window.item
  747.       if @item == nil
  748.         Sound.play_buzzer
  749.         return
  750.       end
  751.       number = $game_party.item_number(@item)
  752.       limit = $imported["LimitBreak"] ? @item.number_limit : 99
  753.       if $imported["VariableControlledDiscounts"]
  754.         price = @item.price * $game_variables[YE::EVENT::VARIABLE::PERCENT_BUY]
  755.         price /= YE::EVENT::VARIABLE::PERCENT_DIVISOR
  756.       else
  757.         price = @item.price
  758.       end
  759.       if @item == nil or price > $game_party.gold or number == limit
  760.         Sound.play_buzzer
  761.       else
  762.         Sound.play_decision
  763.         if $imported["LimitBreak"]
  764.           max = (price == 0 ? @item.number_limit : $game_party.gold / price)
  765.           max = [max, @item.number_limit - number].min
  766.         else
  767.           max = price == 0 ? 99 : $game_party.gold / price
  768.           max = [max, 99 - number].min
  769.           end
  770.         @buy_window.active = false
  771.         @buy_window.visible = false
  772.         @number_window.set(@item, max, price)
  773.         @number_window.active = true
  774.         @number_window.visible = true
  775.       end
  776.     end
  777.   end
  778.  
  779.   #--------------------------------------------------------------------------
  780.   # update_synth_list
  781.   #--------------------------------------------------------------------------
  782.   def update_synth_list
  783.     @synth_list.update
  784.     @help_window.update
  785.     if Input.trigger?(Input::B)
  786.       Sound.play_cancel
  787.       @command_window.active = true
  788.       @command_window.visible = true
  789.       @synth_list.active = false
  790.       @synth_list.visible = false
  791.       @ingre_list.visible = false
  792.       @buy_window.visible = true
  793.       @buy_window.refresh
  794.       @status_window.visible = true
  795.       @help_window.set_text("")
  796.     elsif Input.trigger?(Input::C)
  797.       item = @synth_list.item
  798.       unless enabled?(item)
  799.         Sound.play_buzzer
  800.       else
  801.         Sound.play_decision
  802.         synthesize_item(item)
  803.       end
  804.     elsif Input.trigger?(Input::LEFT)
  805.       Sound.play_cursor
  806.       if @actor_index == 0
  807.         @actor_index = $game_party.members.size - 1
  808.       else
  809.         @actor_index -= 1
  810.       end
  811.       @actor_id = $game_party.members[@actor_index].id
  812.       @synth_list.refresh(@actor_index)
  813.       @ingre_list.refresh(@actor_index)
  814.     elsif Input.trigger?(Input::RIGHT)
  815.       Sound.play_cursor
  816.       if @actor_index == $game_party.members.size - 1
  817.         @actor_index = 0
  818.       else
  819.         @actor_index += 1
  820.       end
  821.       @actor_id = $game_party.members[@actor_index].id
  822.       @synth_list.refresh(@actor_index)
  823.       @ingre_list.refresh(@actor_index)
  824.     end
  825.   end
  826.  
  827.   #--------------------------------------------------------------------------
  828.   # update_number_input
  829.   #--------------------------------------------------------------------------
  830.   def update_number_input
  831.     @number_window.update
  832.     if Input.trigger?(Input::B)
  833.       Sound.play_decision
  834.       @buy_window.active = true
  835.       @buy_window.visible = true
  836.       @buy_window.refresh
  837.       @number_window.active = false
  838.       @number_window.visible = false
  839.     elsif Input.trigger?(Input::C)
  840.       Sound.play_shop
  841.       if $imported["VariableControlledDiscounts"]
  842.         price = @item.price * $game_variables[YE::EVENT::VARIABLE::PERCENT_BUY]
  843.         price /= YE::EVENT::VARIABLE::PERCENT_DIVISOR
  844.       else
  845.         price = @item.price
  846.       end
  847.       $game_party.lose_gold(@number_window.number * price)
  848.       $game_party.gain_item(@item, @number_window.number)
  849.       @gold_window.refresh
  850.       @buy_window.refresh
  851.       @status_window.refresh
  852.       @buy_window.active = true
  853.       @buy_window.visible = true
  854.       @buy_window.refresh
  855.       @number_window.active = false
  856.       @number_window.visible = false
  857.     end
  858.   end
  859.  
  860.   #--------------------------------------------------------------------------
  861.   # update_synth_number
  862.   #--------------------------------------------------------------------------
  863.   def update_synth_number
  864.     @synth_number.update
  865.     if Input.trigger?(Input::B)
  866.       Sound.play_decision
  867.       @synth_list.active = true
  868.       @synth_list.visible = true
  869.       @synth_number.active = false
  870.       @synth_number.visible = false
  871.     elsif Input.trigger?(Input::C)
  872.       Sound.play_shop
  873.       item = @synth_list.item
  874.       $game_party.lose_gold(@synth_number.number * item.synth_cost)
  875.       if item.synth_actor.include?($game_party.members[@actor_index].id)
  876.         synth = item.synth_actor[$game_party.members[@actor_index].id]
  877.       else
  878.         synth = item.synth_actor[0]
  879.       end
  880.       $game_party.gain_item(synth, @synth_number.number)
  881.       consume_ingredients(item, @synth_number.number)
  882.       @gold_window.refresh
  883.       $game_actors[@actor_id].learn_recipe(item)
  884.       run_common_event(item)
  885.       @synth_list.refresh(@actor_index)
  886.       @ingre_list.refresh(@actor_index)
  887.       @synth_list.active = true
  888.       @synth_list.visible = true
  889.       @synth_number.active = false
  890.       @synth_number.visible = false
  891.     end
  892.   end
  893.  
  894.   #--------------------------------------------------------------------------
  895.   # enabled?
  896.   #--------------------------------------------------------------------------
  897.   def enabled?(item)
  898.     return false if item == nil
  899.     return false if @actor_index == -1
  900.     return false if item.synth_block.include?(@actor_id)
  901.     return false unless (item.synth_actor.include?(@actor_id) or
  902.     item.synth_actor.include?(0))
  903.     for ingredient in item.ingredients
  904.       return false if $game_party.item_number(ingredient[0]) < ingredient[1]
  905.     end
  906.     return false unless $game_party.gold >= item.synth_cost
  907.     return true
  908.   end
  909.  
  910.   #--------------------------------------------------------------------------
  911.   # synthesize_item
  912.   #--------------------------------------------------------------------------
  913.   def synthesize_item(item)
  914.     if item.synth_cost > 0
  915.       max = $game_party.gold / item.synth_cost
  916.     else
  917.       max = $game_party.gold
  918.     end
  919.     if item.synth_consume?
  920.       max = [max, $game_party.item_number(item)].min
  921.     end
  922.     for ingredient in item.ingredients
  923.       next if ingredient[1] == 0
  924.       n = $game_party.item_number(ingredient[0]) / ingredient[1]
  925.       max = [max, n].min
  926.     end
  927.     number = $game_party.item_number(item)
  928.     limit = ($imported["LimitBreak"] ? item.number_limit : 99)
  929.     max = [max, limit - number].min
  930.     synth = synth_number_item(item)
  931.     @synth_number.set(synth, max, item.synth_cost, item)
  932.     @synth_number.visible = true
  933.     @synth_number.active = true
  934.     @synth_list.visible = false
  935.     @synth_list.active = false
  936.   end
  937.  
  938.   #--------------------------------------------------------------------------
  939.   # consume_ingredients
  940.   #--------------------------------------------------------------------------
  941.   def consume_ingredients(item, number)
  942.     if item.synth_consume?
  943.       $game_party.lose_item(item, number)
  944.     end
  945.     for ingredient in item.ingredients
  946.       $game_party.lose_item(ingredient[0], number * ingredient[1])
  947.     end
  948.   end
  949.  
  950.   #--------------------------------------------------------------------------
  951.   # synth_number_item
  952.   #--------------------------------------------------------------------------
  953.   def synth_number_item(item)
  954.     if item.is_a?(RPG::Item)
  955.       if $game_party.members[@actor_index].synth_items.include?(item.id)
  956.         if item.synth_actor.include?($game_party.members[@actor_index].id)
  957.           item = item.synth_actor[$game_party.members[@actor_index].id]
  958.         elsif item.synth_actor.include?(0)
  959.           item = item.synth_actor[0]
  960.         end
  961.       end
  962.     elsif item.is_a?(RPG::Weapon)
  963.       if $game_party.members[@actor_index].synth_weapons.include?(item.id)
  964.         if item.synth_actor.include?($game_party.members[@actor_index].id)
  965.           item = item.synth_actor[$game_party.members[@actor_index].id]
  966.         elsif item.synth_actor.include?(0)
  967.           item = item.synth_actor[0]
  968.         end
  969.       end
  970.     elsif item.is_a?(RPG::Armor)
  971.       if $game_party.members[@actor_index].synth_armours.include?(item.id)
  972.         if item.synth_actor.include?($game_party.members[@actor_index].id)
  973.           item = item.synth_actor[$game_party.members[@actor_index].id]
  974.         elsif item.synth_actor.include?(0)
  975.           item = item.synth_actor[0]
  976.         end
  977.       end
  978.     end
  979.     return item
  980.   end
  981.  
  982.   #--------------------------------------------------------------------------
  983.   # run_common_event
  984.   #--------------------------------------------------------------------------
  985.   def run_common_event(item)
  986.     event = nil
  987.     actor = $game_party.members[@actor_index]
  988.     if item.synth_event.include?(actor.id)
  989.       @synth_list.update
  990.       event = item.synth_event[actor.id]
  991.     elsif item.synth_event.include?(0)
  992.       @synth_list.update
  993.       event = item.synth_event[0]
  994.     end
  995.     return if event == nil
  996.     if !actor.synth_events.include?(event) or item.replay_event?
  997.       actor.synth_events.push(event) unless actor.synth_events.include?(event)
  998.       if YE::SYNTH::EVENT_IN_SHOP
  999.         @common_event = event
  1000.       else
  1001.         $game_temp.common_event_id = event
  1002.         $scene = Scene_Map.new
  1003.       end
  1004.     end
  1005.   end
  1006.  
  1007. end # Scene_Synthesis
  1008.  
  1009. #==============================================================================
  1010. # Window_SynthList
  1011. #==============================================================================
  1012.  
  1013. class Window_SynthList < Window_Selectable
  1014.  
  1015.   #--------------------------------------------------------------------------
  1016.   # initialize
  1017.   #--------------------------------------------------------------------------
  1018.   def initialize(x, y, w, h)
  1019.     super(x, y, w, h)
  1020.     self.visible = false
  1021.     self.active = false
  1022.     self.index = 0
  1023.     refresh
  1024.   end
  1025.  
  1026.   #--------------------------------------------------------------------------
  1027.   # refresh
  1028.   #--------------------------------------------------------------------------
  1029.   def refresh(actor_index = -1)
  1030.     @data = []
  1031.     for goods_item in $game_temp.shop_goods
  1032.       case goods_item[0]
  1033.       when 0
  1034.         item = $data_items[goods_item[1]]
  1035.       when 1
  1036.         item = $data_weapons[goods_item[1]]
  1037.       when 2
  1038.         item = $data_armors[goods_item[1]]
  1039.       end
  1040.       next if item == nil
  1041.       next unless item.recipe?
  1042.       next unless $game_party.has_item?(item)
  1043.       @data.push(item)
  1044.     end
  1045.     @item_max = @data.size
  1046.     create_contents
  1047.     @actor_index = actor_index
  1048.     @actor_id = $game_party.members[@actor_index].id
  1049.     for i in 0...@item_max
  1050.       draw_item(i)
  1051.     end
  1052.   end
  1053.  
  1054.   #--------------------------------------------------------------------------
  1055.   # draw_item
  1056.   #--------------------------------------------------------------------------
  1057.   def draw_item(index)
  1058.     rect = item_rect(index)
  1059.     self.contents.clear_rect(rect)
  1060.     item = @data[index]
  1061.     enable = enabled?(item)
  1062.     if @actor_index >= 0 and item.synth_actor.include?(@actor_id)
  1063.       if item.is_a?(RPG::Item)
  1064.         if $game_actors[@actor_id].synth_items.include?(item.id)
  1065.           item = item.synth_actor[@actor_id]
  1066.         end
  1067.       elsif item.is_a?(RPG::Weapon)
  1068.         if $game_actors[@actor_id].synth_weapons.include?(item.id)
  1069.           item = item.synth_actor[@actor_id]
  1070.         end
  1071.       elsif item.is_a?(RPG::Armor)
  1072.         if $game_actors[@actor_id].synth_armours.include?(item.id)
  1073.           item = item.synth_actor[@actor_id]
  1074.         end
  1075.       end
  1076.     elsif @actor_index >= 0 and item.synth_actor.include?(0)
  1077.       if item.is_a?(RPG::Item)
  1078.         if $game_actors[@actor_id].synth_items.include?(item.id)
  1079.           item = item.synth_actor[0]
  1080.         end
  1081.       elsif item.is_a?(RPG::Weapon)
  1082.         if $game_actors[@actor_id].synth_weapons.include?(item.id)
  1083.           item = item.synth_actor[0]
  1084.         end
  1085.       elsif item.is_a?(RPG::Armor)
  1086.         if $game_actors[@actor_id].synth_armours.include?(item.id)
  1087.           item = item.synth_actor[0]
  1088.         end
  1089.       end
  1090.     end
  1091.     draw_item_name(item, rect.x, rect.y, enable)
  1092.   end
  1093.  
  1094.   #--------------------------------------------------------------------------
  1095.   # enabled?
  1096.   #--------------------------------------------------------------------------
  1097.   def enabled?(item)
  1098.     return false if item == nil
  1099.     return false if @actor_index == -1
  1100.     return false if item.synth_block.include?(@actor_id)
  1101.     return false unless (item.synth_actor.include?(@actor_id) or
  1102.     item.synth_actor.include?(0))
  1103.     for ingredient in item.ingredients
  1104.       return false if $game_party.item_number(ingredient[0]) < ingredient[1]
  1105.     end
  1106.     return false unless $game_party.gold >= item.synth_cost
  1107.     return true
  1108.   end
  1109.  
  1110.   #--------------------------------------------------------------------------
  1111.   # return item
  1112.   #--------------------------------------------------------------------------
  1113.   def item
  1114.     return @data[self.index]
  1115.   end
  1116.  
  1117.   #--------------------------------------------------------------------------
  1118.   # update_help
  1119.   #--------------------------------------------------------------------------
  1120.   def update_help
  1121.     if item == nil
  1122.       text = ""
  1123.     else
  1124.       text = item.description
  1125.     end
  1126.     if item.is_a?(RPG::Item)
  1127.       if $game_party.members[@actor_index].synth_items.include?(item.id)
  1128.         if item.synth_actor.include?($game_party.members[@actor_index].id)
  1129.           text =
  1130.           item.synth_actor[$game_party.members[@actor_index].id].description
  1131.         elsif item.synth_actor.include?(0)
  1132.           text = item.synth_actor[0].description
  1133.         end
  1134.       end
  1135.     elsif item.is_a?(RPG::Weapon)
  1136.       if $game_party.members[@actor_index].synth_weapons.include?(item.id)
  1137.         if item.synth_actor.include?($game_party.members[@actor_index].id)
  1138.           text =
  1139.           item.synth_actor[$game_party.members[@actor_index].id].description
  1140.         elsif item.synth_actor.include?(0)
  1141.           text = item.synth_actor[0].description
  1142.         end
  1143.       end
  1144.     elsif item.is_a?(RPG::Armor)
  1145.       if $game_party.members[@actor_index].synth_armours.include?(item.id)
  1146.         if item.synth_actor.include?($game_party.members[@actor_index].id)
  1147.           text =
  1148.           item.synth_actor[$game_party.members[@actor_index].id].description
  1149.         elsif item.synth_actor.include?(0)
  1150.           text = item.synth_actor[0].description
  1151.         end
  1152.       end
  1153.     end
  1154.     @help_window.set_text(text)
  1155.   end
  1156.  
  1157. end # Window_SynthList
  1158.  
  1159. #==============================================================================
  1160. # Window_Ingredients
  1161. #==============================================================================
  1162.  
  1163. class Window_Ingredients < Window_Base
  1164.  
  1165.   #--------------------------------------------------------------------------
  1166.   # initialize
  1167.   #--------------------------------------------------------------------------
  1168.   def initialize(x, y, w, h)
  1169.     super(x, y, w, h)
  1170.     self.visible = false
  1171.     @item = nil
  1172.     refresh
  1173.   end
  1174.  
  1175.   #--------------------------------------------------------------------------
  1176.   # refresh
  1177.   #--------------------------------------------------------------------------
  1178.   def refresh(actor_index = -1)
  1179.     self.contents.clear
  1180.     self.contents.font.color = normal_color
  1181.     self.contents.font.color.alpha = 255
  1182.     self.contents.font.size = Font.default_size
  1183.     @actor_index = actor_index
  1184.     draw_actor
  1185.     draw_ingredients
  1186.   end
  1187.  
  1188.   #--------------------------------------------------------------------------
  1189.   # return item
  1190.   #--------------------------------------------------------------------------
  1191.   def item
  1192.     return @item
  1193.   end
  1194.  
  1195.   #--------------------------------------------------------------------------
  1196.   # item=
  1197.   #--------------------------------------------------------------------------
  1198.   def item=(item)
  1199.     if @item != item
  1200.       @item = item
  1201.       refresh
  1202.     end
  1203.   end
  1204.  
  1205.   #--------------------------------------------------------------------------
  1206.   # draw_actor
  1207.   #--------------------------------------------------------------------------
  1208.   def draw_actor
  1209.     return if @actor_index < 0
  1210.     sw = self.width - 32
  1211.     actor = $game_party.members[@actor_index]
  1212.     draw_actor_graphic(actor, 24, WLH*2)
  1213.     self.contents.draw_text(48, 0, sw-48, WLH, actor.name)
  1214.     self.contents.font.size = YE::SYNTH::SYNTH_FSIZE
  1215.     total = actor.synth_items.size + actor.synth_weapons.size +
  1216.     actor.synth_armours.size
  1217.     text = sprintf(YE::SYNTH::SYNTH_TOTAL, total)
  1218.     xoffset = YE::SYNTH::SYNTH_OFFSET
  1219.     self.contents.draw_text(48, 24, sw-48, WLH, text)
  1220.   end
  1221.  
  1222.   #--------------------------------------------------------------------------
  1223.   # draw_ingredients
  1224.   #--------------------------------------------------------------------------
  1225.   def draw_ingredients
  1226.     return if @item == nil
  1227.     self.contents.font.size = Font.default_size
  1228.     sw = self.width - 32
  1229.     dy = 48
  1230.     if incompatible? or
  1231.     @item.synth_block.include?($game_party.members[@actor_index].id)
  1232.       self.contents.font.color = text_color(YE::SYNTH::SYNTH_INCOLR)
  1233.       self.contents.draw_text(0, dy, sw, WLH, YE::SYNTH::SYNTH_INCOMP, 1)
  1234.       return
  1235.     else
  1236.       self.contents.font.color = system_color
  1237.       self.contents.draw_text(0, dy, sw, WLH, @item.name, 1)
  1238.     end
  1239.     dy += 24
  1240.     self.contents.font.color = normal_color
  1241.     self.contents.font.size = YE::SYNTH::SYNTH_FSIZE
  1242.     if item.synth_cost > 0
  1243.       enabled = ($game_party.gold >= item.synth_cost) ? true : false
  1244.       draw_icon(YE::SYNTH::SYNTH_C_ICON, 0, dy, enabled)
  1245.       self.contents.font.color.alpha = enabled ? 255 : 128
  1246.       self.contents.draw_text(24, dy, sw-24, WLH, YE::SYNTH::SYNTH_COST)
  1247.       text = sprintf(YE::SYNTH::SYNTH_T_COST, item.synth_cost, Vocab.gold)
  1248.       self.contents.draw_text(24, dy, sw-24, WLH, text, 2)
  1249.       dy += 24
  1250.     end
  1251.     if item.synth_consume?
  1252.       draw_item_name(item, 0, dy)
  1253.       amount = $game_party.item_number(item)
  1254.       text = sprintf(YE::SYNTH::SYNTH_AMT, 1, amount)
  1255.       self.contents.draw_text(0, dy, sw, WLH, text, 2)
  1256.       dy += 24
  1257.     end
  1258.     item_list = @item.ingredients.sort { |a,b| a[0].name <=> b[0].name }
  1259.     for key in item_list
  1260.       amount = $game_party.item_number(key[0])
  1261.       if amount >= key[1]
  1262.         self.contents.font.color.alpha = 255
  1263.         enabled = true
  1264.       else
  1265.         self.contents.font.color.alpha = 128
  1266.         enabled = false
  1267.       end
  1268.       draw_item_name(key[0], 0, dy, enabled)
  1269.       text = sprintf(YE::SYNTH::SYNTH_AMT, key[1], amount)
  1270.       self.contents.draw_text(0, dy, sw, WLH, text, 2) unless key[1] == 0 and
  1271.       YE::SYNTH::SYNTH_HIDE_0
  1272.       dy += 24
  1273.     end
  1274.   end
  1275.  
  1276.   #--------------------------------------------------------------------------
  1277.   # incompatible?
  1278.   #--------------------------------------------------------------------------
  1279.   def incompatible?
  1280.     actor = $game_party.members[@actor_index]
  1281.     if item.synth_actor.include?(actor.id)
  1282.       return false
  1283.     elsif item.synth_actor.include?(0)
  1284.       return false
  1285.     end
  1286.     return true
  1287.   end
  1288.  
  1289. end # Window_Ingredients
  1290.  
  1291. #==============================================================================
  1292. # Window_SynthBuy
  1293. #==============================================================================
  1294.  
  1295. class Window_SynthBuy < Window_Selectable
  1296.  
  1297.   #--------------------------------------------------------------------------
  1298.   # initialize
  1299.   #--------------------------------------------------------------------------
  1300.   def initialize(x, y, w, h)
  1301.     super(x, y, w, h)
  1302.     @shop_goods = $game_temp.shop_goods
  1303.     refresh
  1304.     self.active = false
  1305.     self.index = -1
  1306.   end
  1307.  
  1308.   #--------------------------------------------------------------------------
  1309.   # return item
  1310.   #--------------------------------------------------------------------------
  1311.   def item
  1312.     return @data[self.index]
  1313.   end
  1314.  
  1315.   #--------------------------------------------------------------------------
  1316.   # refresh
  1317.   #--------------------------------------------------------------------------
  1318.   def refresh
  1319.     @data = []
  1320.     for goods_item in @shop_goods
  1321.       case goods_item[0]
  1322.       when 0
  1323.         item = $data_items[goods_item[1]]
  1324.         next if item == nil
  1325.         next unless item.recipe?
  1326.         next if item.synth_unbuyable
  1327.         for i in 1..$data_actors.size
  1328.           actor = $game_actors[i]
  1329.           next if actor == nil
  1330.           if actor.synth_items.include?(item.id)
  1331.             if item.synth_actor.include?(actor.id)
  1332.               @data.push(item.synth_actor[actor.id]) unless @data.include?(item)
  1333.             elsif item.synth_actor.include?(0)
  1334.               @data.push(item.synth_actor[0]) unless @data.include?(item)
  1335.             end
  1336.           end
  1337.         end
  1338.       when 1
  1339.         item = $data_weapons[goods_item[1]]
  1340.         next if item == nil
  1341.         next unless item.recipe?
  1342.         next if item.synth_unbuyable
  1343.         for i in 1..$data_actors.size
  1344.           actor = $game_actors[i]
  1345.           next if actor == nil
  1346.           if actor.synth_weapons.include?(item.id)
  1347.             if item.synth_actor.include?(actor.id)
  1348.               @data.push(item.synth_actor[actor.id]) unless @data.include?(item)
  1349.             elsif item.synth_actor.include?(0)
  1350.               @data.push(item.synth_actor[0]) unless @data.include?(item)
  1351.             end
  1352.           end
  1353.         end
  1354.       when 2
  1355.         item = $data_armors[goods_item[1]]
  1356.         next if item == nil
  1357.         next unless item.recipe?
  1358.         next if item.synth_unbuyable
  1359.         for i in 1..$data_actors.size
  1360.           actor = $game_actors[i]
  1361.           next if actor == nil
  1362.           if actor.synth_armours.include?(item.id)
  1363.             if item.synth_actor.include?(actor.id)
  1364.               @data.push(item.synth_actor[actor.id]) unless @data.include?(item)
  1365.             elsif item.synth_actor.include?(0)
  1366.               @data.push(item.synth_actor[0]) unless @data.include?(item)
  1367.             end
  1368.           end
  1369.         end
  1370.       end
  1371.     end
  1372.     sort_list
  1373.     @item_max = @data.size
  1374.     create_contents
  1375.     for i in 0...@item_max
  1376.       draw_item(i)
  1377.     end
  1378.   end
  1379.  
  1380.   #--------------------------------------------------------------------------
  1381.   # draw_item
  1382.   #--------------------------------------------------------------------------
  1383.   def draw_item(index)
  1384.     item = @data[index]
  1385.     number = $game_party.item_number(item)
  1386.     if $imported["VariableControlledDiscounts"]
  1387.       price = item.price * $game_variables[YE::EVENT::VARIABLE::PERCENT_BUY]
  1388.       price /= YE::EVENT::VARIABLE::PERCENT_DIVISOR
  1389.     else
  1390.       price = item.price
  1391.     end
  1392.     if $imported["LimitBreak"]
  1393.       max = item.number_limit
  1394.     else
  1395.       max = 99
  1396.     end
  1397.     if $imported["DisplayItemQuery"]
  1398.       if item.is_a?(RPG::Item)
  1399.         $game_party.purchased_items[item.id] = [] if
  1400.           $game_party.purchased_items[item.id] == nil
  1401.         $game_party.purchased_items[item.id].push($game_map.map_id) unless
  1402.           $game_party.purchased_items[item.id].include?($game_map.map_id)
  1403.       elsif item.is_a?(RPG::Weapon)
  1404.         $game_party.purchased_weapons[item.id] = [] if
  1405.           $game_party.purchased_weapons[item.id] == nil
  1406.         $game_party.purchased_weapons[item.id].push($game_map.map_id) unless
  1407.           $game_party.purchased_weapons[item.id].include?($game_map.map_id)
  1408.       elsif item.is_a?(RPG::Armor)
  1409.         $game_party.purchased_armours[item.id] = [] if
  1410.           $game_party.purchased_armours[item.id] == nil
  1411.         $game_party.purchased_armours[item.id].push($game_map.map_id) unless
  1412.           $game_party.purchased_armours[item.id].include?($game_map.map_id)
  1413.       end
  1414.     end
  1415.     enable = (price <= $game_party.gold and number < max)
  1416.     rect = item_rect(index)
  1417.     self.contents.clear_rect(rect)
  1418.     draw_item_name(item, rect.x, rect.y, enable)
  1419.     rect.width -= 4
  1420.     self.contents.draw_text(rect, price, 2)
  1421.   end
  1422.  
  1423.   #--------------------------------------------------------------------------
  1424.   # sort_list
  1425.   #--------------------------------------------------------------------------
  1426.   def sort_list
  1427.     dummy_items = []; dummy_weapons = []; dummy_armours = []
  1428.     for item in @data
  1429.       next unless item.is_a?(RPG::Item)
  1430.       next if item.synth_unbuyable
  1431.       dummy_items.push(item)
  1432.     end
  1433.     dummy_items = dummy_items.sort{ |a,b| a.id <=> b.id }
  1434.     for item in @data
  1435.       next unless item.is_a?(RPG::Weapon)
  1436.       next if item.synth_unbuyable
  1437.       dummy_weapons.push(item)
  1438.     end
  1439.     dummy_weapons = dummy_weapons.sort{ |c,d| c.id <=> d.id }
  1440.     for item in @data
  1441.       next unless item.is_a?(RPG::Armor)
  1442.       next if item.synth_unbuyable
  1443.       dummy_armours.push(item)
  1444.     end
  1445.     dummy_armours = dummy_armours.sort{ |e,f| e.id <=> f.id }
  1446.     @data = dummy_items.uniq
  1447.     @data += dummy_weapons.uniq
  1448.     @data += dummy_armours.uniq
  1449.   end
  1450.  
  1451.   #--------------------------------------------------------------------------
  1452.   # update_help
  1453.   #--------------------------------------------------------------------------
  1454.   def update_help
  1455.     @help_window.set_text(item == nil ? "" : item.description)
  1456.   end
  1457.  
  1458. end #Window_SynthBuy
  1459.  
  1460. #==============================================================================
  1461. # Window_SynthNumber
  1462. #==============================================================================
  1463.  
  1464. class Window_SynthNumber < Window_ShopNumber
  1465.  
  1466.   #--------------------------------------------------------------------------
  1467.   # set
  1468.   #--------------------------------------------------------------------------
  1469.   def set(item, max, price, real)
  1470.     @real = real
  1471.     super(item, max, price)
  1472.   end
  1473.  
  1474.   #--------------------------------------------------------------------------
  1475.   # refresh
  1476.   #--------------------------------------------------------------------------
  1477.   def refresh
  1478.     dy = 0
  1479.     sw = self.width - 32
  1480.     self.contents.clear
  1481.     self.contents.font.color = system_color
  1482.     self.contents.draw_text(0, dy, sw, WLH, YE::SYNTH::SYNTH_OUTCOM, 1)
  1483.     dy += 24
  1484.     self.contents.font.color = normal_color
  1485.     if @item == @real
  1486.       draw_icon(YE::SYNTH::SYNTH_UNICON, 0, dy)
  1487.       text = YE::SYNTH::SYNTH_UNMASK
  1488.       self.contents.draw_text(24, dy, 172, WLH, text)
  1489.     else
  1490.       draw_item_name(@item, 0, dy)
  1491.     end
  1492.     self.contents.draw_text(212, dy, 20, WLH, "×")
  1493.     self.contents.draw_text(218, dy, 50, WLH, @number, 2)
  1494.     self.cursor_rect.set(207, dy, 64, WLH)
  1495.     dy += 24
  1496.     self.contents.font.color = system_color
  1497.     self.contents.draw_text(0, dy, sw, WLH, YE::SYNTH::SYNTH_INGRED, 1)
  1498.     self.contents.font.color = normal_color
  1499.     if @price != 0
  1500.       dy += 24
  1501.       draw_icon(YE::SYNTH::SYNTH_C_ICON, 0, dy)
  1502.       self.contents.draw_text(24, dy, 172, WLH, YE::SYNTH::SYNTH_COST)
  1503.       draw_currency_value(@price * @number, 4, dy, 264)
  1504.     end
  1505.     if @real.synth_consume?
  1506.       dy += 24
  1507.       draw_item_name(@real, 0, dy)
  1508.       self.contents.draw_text(212, dy, 20, WLH, "×")
  1509.       self.contents.draw_text(218, dy, 50, WLH, @number, 2)
  1510.     end
  1511.     ingredients = @real.ingredients.sort { |a,b| a[0].name <=> b[0].name }
  1512.     for ingredient in ingredients
  1513.       next if ingredient[0] == nil
  1514.       dy += 24
  1515.       draw_item_name(ingredient[0], 0, dy)
  1516.       unless (@number * ingredient[1] == 0) and YE::SYNTH::SYNTH_HIDE_0
  1517.         self.contents.draw_text(212, dy, 20, WLH, "×")
  1518.         self.contents.draw_text(218, dy, 50, WLH, @number * ingredient[1], 2)
  1519.       end
  1520.     end
  1521.   end
  1522.  
  1523. end # Window_SynthNumber
  1524.  
  1525. #===============================================================================
  1526. #
  1527. # END OF FILE
  1528. #
  1529. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement