Guest User

Untitled

a guest
Apr 21st, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 55.38 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Yanfly Engine Melody - Item Overhaul
  4. # Last Date Updated: 2010.06.20
  5. # Level: Normal, Hard
  6. #
  7. # The item scene can become seriously lacking as it often keeps players in the
  8. # dark as to what items actually do. This script rewrites the item scene and
  9. # provides the player adequate information about how an item functions, be it
  10. # a healing item, battle item, weapon, or a piece of armour. And if needed,
  11. # custom data can be inserted, too.
  12. #
  13. #===============================================================================
  14. # Updates
  15. # -----------------------------------------------------------------------------
  16. # o 2010.06.20 - Finished Script.
  17. # o 2010.06.18 - Started Script.
  18. #===============================================================================
  19. # Instructions
  20. # -----------------------------------------------------------------------------
  21. # To install this script, open up your script editor and copy/paste this script
  22. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  23. #
  24. # -----------------------------------------------------------------------------
  25. # Item and Equip Tags - For Items, Weapons, and Armours.
  26. # -----------------------------------------------------------------------------
  27. # <key item>
  28. # This labels the item as a key item, making it appear in the key item category
  29. # inside of the item scene. Does nothing else.
  30. #
  31. # <custom data>
  32. # icon, string1, string2
  33. # </custom data>
  34. # This allows you to input in custom data to be displayed in the item list
  35. # data window. Replace "icon" with a number to depict which icon you want
  36. # shown in the data. Replace "string1" with the category you want shown in the
  37. # data. Replace "string2" with the text you want shown in the data.
  38. #===============================================================================
  39.  
  40. $imported = {} if $imported == nil
  41. $imported["ItemOverhaul"] = true
  42.  
  43. module YEM
  44.   module ITEM
  45.    
  46.     #===========================================================================
  47.     # Section I. Basic Settings
  48.     # --------------------------------------------------------------------------
  49.     # The following below will adjust the basic settings and vocabulary that
  50.     # alter the basic item scene the players see before them.
  51.     #===========================================================================
  52.    
  53.     # This adjusts the commands used within the item scene. The command window
  54.     # is the window that lets you switch between various item scene options.
  55.     #
  56.     # :usable           Opens up usable menu items.
  57.     # :battle           Views battle-only items.
  58.     # :weapons          Views weapons list.
  59.     # :armours          Views armours list.
  60.     # :misc             Views miscellaneous items.
  61.     # :key_items        Views key items.
  62.     # :all_items        Views all items.
  63.     #
  64.     COMMANDS =[
  65.       :usable,        # Opens up usable menu items.
  66.       :battle,        # Views battle-only items.
  67.       :weapons,       # Views weapons list.
  68.       :armours,       # Views armours list.
  69.       :misc,          # Views miscellaneous items.
  70.       :key_items,     # Views key items.
  71.     # :all_items,     # Views all items.
  72.     ] # Do not remove this.
  73.    
  74.     # The following determines the vocabulary used for the remade item scene.
  75.     # Adjust it accordingly to set the way text is displayed.
  76.     VOCAB ={
  77.       :usable         => "Usable",
  78.       :battle         => "Battle",
  79.       :weapons        => "Weapons",
  80.       :armours        => "Armours",
  81.       :misc           => "Various",
  82.       :key_items      => "Key Items",
  83.       :all_items      => "All Items",
  84.     } # Do not remove this.
  85.    
  86.     #===========================================================================
  87.     # Section II. Data Window Settings
  88.     # --------------------------------------------------------------------------
  89.     # These settings adjust what you see in the data window shown to the lower
  90.     # right of the item scene. The window shows the selected item's properties.
  91.     # The data represented differs depending on the item, its tags, and whether
  92.     # or not it is an item, weapon, or armour.
  93.     #===========================================================================
  94.    
  95.     # These constants determine how the gold value appears in the data windows.
  96.     DRAW_GOLD_ICON  = 205
  97.     DRAW_GOLD_TEXT  = "Value"
  98.    
  99.     # This adjusts the settings shown for items. Adjust as you see fit. The
  100.     # majority of these keys are vocab settings.
  101.     ITEM_DATA ={
  102.       :properties   => "Properties",
  103.       :gold_value   => true,
  104.       :fontsize     => 16,
  105.       :hp_heal_icon => 128,
  106.       :hp_heal_text => "HP Heal",
  107.       :mp_heal_icon => 214,
  108.       :mp_heal_text => "MP Heal",
  109.       :dmg_icon     => 119,
  110.       :base_dmg     => "Base Damage",
  111.       :heal_icon    => 128,
  112.       :base_heal    => "Base Healing",
  113.       :multiplier   => "%s Multiplier",
  114.       :element      => "Element",
  115.       :add_state    => "Applies",
  116.       :rem_state    => "Cancels",
  117.       :growth       => "%s Growth",
  118.       :resist       => "%s Resist",
  119.       :bonus        => "%s Bonus",
  120.     } # Do not remove this.
  121.    
  122.     # This adjusts the settings shown for equipment. Adjust as you see fit. For
  123.     # :shown_stats, valid stats to be shown are as follows:
  124.     #   :hp, :mp, :atk, :def, :spi, :res, :dex, :agi
  125.     EQUIP_DATA ={
  126.       :properties   => "Attributes",
  127.       :gold_value   => false,
  128.       :fontsize     => 16,
  129.       :shown_stats  => [:hp, :mp, :atk, :def, :spi, :res, :dex, :agi],
  130.       :ele_weapon   => "Adds",
  131.       :ele_armour   => "Guards",
  132.       :state_weapon => "Applies",
  133.       :state_armour => "Resists",
  134.     } # Do not remove this.
  135.    
  136.     # This array contains all of the elements you want displayed and in which
  137.     # order to display them in. You can display them as individual integers or
  138.     # as number ranges.
  139.     SHOWN_ELEMENTS = [3, 4, 5, 6..10]
  140.    
  141.     # Since elements do not have icons innately, use the following hash below
  142.     # adjust and apply icons to them.
  143.     ELEMENT_ICONS ={
  144.       3 => 104,  # Fire element.
  145.       4 => 105,  # Ice element.
  146.       5 => 106,  # Volt element.
  147.       6 => 108,  # Earth element.
  148.       7 => 107,  # Water element.
  149.       8 => 109,  # Air element.
  150.       9 => 110,  # Light element.
  151.      10 => 111,  # Dark element.
  152.     } # Do not remove this.
  153.    
  154.   end # ITEM
  155. end # YEM
  156.  
  157. #===============================================================================
  158. # Editting anything past this point may potentially result in causing computer
  159. # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
  160. # Therefore, edit at your own risk.
  161. #===============================================================================
  162.  
  163. module YEM
  164.   module REGEXP
  165.   module BASEITEM
  166.      
  167.     KEY_ITEM = /<(?:KEY_ITEM|key item|key)>/i
  168.    
  169.     CUSTOM_DATA1 = /<(?:CUSTOM_DATA|custom data)>/i
  170.     CUSTOM_DATA2 = /<\/(?:CUSTOM_DATA|custom data)>/i
  171.    
  172.   end # BASEITEM
  173.   end # REGEXP
  174.   module ITEM
  175.     module_function
  176.     #--------------------------------------------------------------------------
  177.     # convert_integer_array
  178.     #--------------------------------------------------------------------------
  179.     def convert_integer_array(array)
  180.       result = []
  181.       array.each { |i|
  182.         case i
  183.         when Range; result |= i.to_a
  184.         when Integer; result |= [i]
  185.         end }
  186.       return result
  187.     end
  188.  
  189.     #--------------------------------------------------------------------------
  190.     # converted_contants
  191.     #--------------------------------------------------------------------------
  192.     SHOWN_ELEMENTS = convert_integer_array(SHOWN_ELEMENTS)
  193.   end # ITEM
  194. end # YEM
  195.  
  196. #===============================================================================
  197. # module Icon
  198. #===============================================================================
  199.  
  200. module Icon
  201.  
  202.   #--------------------------------------------------------------------------
  203.   # self.gold_cost
  204.   #--------------------------------------------------------------------------
  205.   def self.gold_cost; return YEM::ITEM::DRAW_GOLD_ICON; end
  206.  
  207.   #--------------------------------------------------------------------------
  208.   # self.element
  209.   #--------------------------------------------------------------------------
  210.   def self.element(element_id)
  211.     icon = YEM::ITEM::ELEMENT_ICONS[element_id]
  212.     return (icon == nil) ? 0 : icon
  213.   end
  214.  
  215.   #--------------------------------------------------------------------------
  216.   # self.hp_heal
  217.   #--------------------------------------------------------------------------
  218.   def self.hp_heal; return YEM::ITEM::ITEM_DATA[:hp_heal_icon]; end
  219.  
  220.   #--------------------------------------------------------------------------
  221.   # self.mp_heal
  222.   #--------------------------------------------------------------------------
  223.   def self.mp_heal; return YEM::ITEM::ITEM_DATA[:mp_heal_icon]; end
  224.  
  225.   #--------------------------------------------------------------------------
  226.   # self.base_damage
  227.   #--------------------------------------------------------------------------
  228.   def self.base_damage; return YEM::ITEM::ITEM_DATA[:dmg_icon]; end
  229.  
  230.   #--------------------------------------------------------------------------
  231.   # self.base_healing
  232.   #--------------------------------------------------------------------------
  233.   def self.base_healing; return YEM::ITEM::ITEM_DATA[:heal_icon]; end
  234.  
  235.   #--------------------------------------------------------------------------
  236.   # self.stat
  237.   #--------------------------------------------------------------------------
  238.   def self.stat(actor, item); return 0; end
  239.  
  240. end # Icon
  241.  
  242. #===============================================================================
  243. # RPG::BaseItem
  244. #===============================================================================
  245.  
  246. class RPG::BaseItem
  247.  
  248.   #--------------------------------------------------------------------------
  249.   # public instance variables
  250.   #--------------------------------------------------------------------------
  251.   attr_accessor :custom_data
  252.   attr_accessor :key_item
  253.  
  254.   #--------------------------------------------------------------------------
  255.   # common cache: yem_cache_baseitem_io
  256.   #--------------------------------------------------------------------------
  257.   def yem_cache_baseitem_io
  258.     return if @cached_baseitem_io; @cached_baseitem_io = true
  259.     @key_item = false
  260.     enable_custom_data = false
  261.     @custom_data = [] unless self.is_a?(RPG::Skill)
  262.     self.note.split(/[\r\n]+/).each { |line|
  263.       case line
  264.       #---
  265.       when YEM::REGEXP::BASEITEM::KEY_ITEM
  266.         @key_item = true
  267.       #---
  268.       when YEM::REGEXP::BASEITEM::CUSTOM_DATA1
  269.         next if self.is_a?(RPG::Skill)
  270.         enable_custom_data = true
  271.       when YEM::REGEXP::BASEITEM::CUSTOM_DATA2
  272.         next if self.is_a?(RPG::Skill)
  273.         enable_custom_data = false
  274.       when /(\d+),[ ](.*),[ ](.*)/i
  275.         next unless enable_custom_data
  276.         next if self.is_a?(RPG::Skill)
  277.         array = [$1.to_i, $2.to_s, $3.to_s]
  278.         @custom_data.push(array)
  279.       end
  280.     } # end self.note.split
  281.   end # yem_cache_baseitem_io
  282.  
  283. end # RPG::BaseItem
  284.  
  285. #===============================================================================
  286. # Scene_Title
  287. #===============================================================================
  288.  
  289. class Scene_Title < Scene_Base
  290.  
  291.   #--------------------------------------------------------------------------
  292.   # alias method: load_bt_database
  293.   #--------------------------------------------------------------------------
  294.   alias load_bt_database_io load_bt_database unless $@
  295.   def load_bt_database
  296.     load_bt_database_io
  297.     load_io_cache
  298.   end
  299.  
  300.   #--------------------------------------------------------------------------
  301.   # alias method: load_database
  302.   #--------------------------------------------------------------------------
  303.   alias load_database_io load_database unless $@
  304.   def load_database
  305.     load_database_io
  306.     load_io_cache
  307.   end
  308.  
  309.   #--------------------------------------------------------------------------
  310.   # new method: load_io_cache
  311.   #--------------------------------------------------------------------------
  312.   def load_io_cache
  313.     groups = [$data_items, $data_weapons, $data_armors]
  314.     for group in groups
  315.       for obj in group
  316.         next if obj == nil
  317.         obj.yem_cache_baseitem_io if obj.is_a?(RPG::BaseItem)
  318.       end
  319.     end
  320.   end
  321.  
  322. end # Scene_Title
  323.  
  324. #===============================================================================
  325. # Window_ItemStatus
  326. #===============================================================================
  327.  
  328. class Window_ItemStatus < Window_Base
  329.  
  330.   #--------------------------------------------------------------------------
  331.   # initialize
  332.   #--------------------------------------------------------------------------
  333.   def initialize
  334.     super(160, 0, Graphics.width - 160, 128)
  335.     refresh
  336.   end
  337.  
  338.   #--------------------------------------------------------------------------
  339.   # refresh
  340.   #--------------------------------------------------------------------------
  341.   def refresh
  342.     self.contents.clear
  343.     @item = @item_window == nil ? nil : @item_window.item
  344.     draw_item
  345.     draw_party_members
  346.   end
  347.  
  348.   #--------------------------------------------------------------------------
  349.   # set_item_window
  350.   #--------------------------------------------------------------------------
  351.   def set_item_window(new_item_window)
  352.     @item_window = new_item_window
  353.     update
  354.   end
  355.  
  356.   #--------------------------------------------------------------------------
  357.   # update
  358.   #--------------------------------------------------------------------------
  359.   def update
  360.     super
  361.     return if @item_window == nil
  362.     refresh if @item != @item_window.item
  363.   end
  364.  
  365.   #--------------------------------------------------------------------------
  366.   # draw_item
  367.   #--------------------------------------------------------------------------
  368.   def draw_item
  369.     return if @item == nil
  370.     draw_icon(@item.icon_index, 0, 0)
  371.     self.contents.draw_text(24, 0, contents.width-28, WLH, @item.name, 0)
  372.   end
  373.  
  374.   #--------------------------------------------------------------------------
  375.   # draw_party_members
  376.   #--------------------------------------------------------------------------
  377.   def draw_party_members
  378.     $game_temp.in_battle = true
  379.     size = $game_party.members.size
  380.     dx = (contents.width - (size * 64))/2 + 32
  381.     dy = contents.height * 3/4
  382.     for member in $game_party.members
  383.       next if member == nil
  384.       draw_member(member, dx, dy)
  385.       dx += 64
  386.     end
  387.     $game_temp.in_battle = false
  388.   end
  389.  
  390.   #--------------------------------------------------------------------------
  391.   # draw_member
  392.   #--------------------------------------------------------------------------
  393.   def draw_member(actor, dx, dy)
  394.     bitmap = Cache.character(actor.character_name)
  395.     sign = actor.character_name[/^[\!\$]./]
  396.     if sign != nil and sign.include?('$')
  397.       cw = bitmap.width / 3
  398.       ch = bitmap.height / 4
  399.     else
  400.       cw = bitmap.width / 12
  401.       ch = bitmap.height / 8
  402.     end
  403.     n = actor.character_index
  404.     src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
  405.     if @item.is_a?(RPG::Weapon) or @item.is_a?(RPG::Armor)
  406.       opacity = actor.equippable?(@item) ? 255 : 128
  407.     elsif @item.is_a?(RPG::Item)
  408.       opacity = @item.for_friend? ? 255 : 128
  409.     else
  410.       opacity = 255
  411.     end
  412.     self.contents.blt(dx - cw / 2, dy - ch, bitmap, src_rect, opacity)
  413.   end
  414.  
  415. end # Window_ItemStatus
  416.  
  417. #===============================================================================
  418. # Window_ItemList
  419. #===============================================================================
  420.  
  421. class Window_ItemList < Window_Selectable
  422.  
  423.   #--------------------------------------------------------------------------
  424.   # initialize
  425.   #--------------------------------------------------------------------------
  426.   def initialize(help_window)
  427.     @help_window = help_window
  428.     dy = @help_window.y + @help_window.height
  429.     super(0, dy, Graphics.width - 240, Graphics.height - dy)
  430.     refresh
  431.     self.active = false
  432.     self.index = 0
  433.   end
  434.  
  435.   #--------------------------------------------------------------------------
  436.   # item
  437.   #--------------------------------------------------------------------------
  438.   def item; return @data[[self.index, 0].max]; end
  439.  
  440.   #--------------------------------------------------------------------------
  441.   # used_item_refresh
  442.   #--------------------------------------------------------------------------
  443.   def used_item_refresh(array)
  444.     for item in array
  445.       next if item == nil
  446.       next unless @data.include?(item)
  447.       refresh
  448.       break
  449.     end
  450.   end
  451.  
  452.   #--------------------------------------------------------------------------
  453.   # refresh
  454.   #--------------------------------------------------------------------------
  455.   def refresh
  456.     @data = []
  457.     for item in $game_party.items
  458.       next unless include?(item)
  459.       @data.push(item)
  460.     end
  461.     @data.push(nil) if @data.size <= 0
  462.     @item_max = @data.size
  463.     self.index = [self.index, @item_max - 1].min
  464.     create_contents
  465.     for i in 0...@item_max; draw_item(i); end
  466.   end
  467.  
  468.   #--------------------------------------------------------------------------
  469.   # include?
  470.   #--------------------------------------------------------------------------
  471.   def include?(item)
  472.     return false if item == nil
  473.     return false if item.name == ""
  474.     return false unless item.is_a?(RPG::Item)
  475.     return item.menu_ok?
  476.   end
  477.  
  478.   #--------------------------------------------------------------------------
  479.   # draw_item
  480.   #--------------------------------------------------------------------------
  481.   def draw_item(index)
  482.     rect = item_rect(index)
  483.     self.contents.clear_rect(rect)
  484.     item = @data[index]
  485.     return if item == nil
  486.     enabled = enable?(item)
  487.     draw_obj_name(item, rect.clone, enabled)
  488.     draw_obj_charges(item, rect.clone, enabled)
  489.     draw_obj_total(item, rect.clone, enabled)
  490.   end
  491.  
  492.   #--------------------------------------------------------------------------
  493.   # enable?
  494.   #--------------------------------------------------------------------------
  495.   def enable?(item)
  496.     return false if item == nil
  497.     return $game_party.has_item?(item)
  498.   end
  499.  
  500.   #--------------------------------------------------------------------------
  501.   # new method: draw_obj_name
  502.   #--------------------------------------------------------------------------
  503.   def draw_obj_name(obj, rect, enabled)
  504.     draw_icon(obj.icon_index, rect.x, rect.y, enabled)
  505.     self.contents.font.size = Font.default_size
  506.     self.contents.font.color = normal_color
  507.     self.contents.font.color.alpha = enabled ? 255 : 128
  508.     rect.width -= 48
  509.     self.contents.draw_text(rect.x+24, rect.y, rect.width-24, WLH, obj.name)
  510.   end
  511.  
  512.   #--------------------------------------------------------------------------
  513.   # new method: draw_obj_charges
  514.   #--------------------------------------------------------------------------
  515.   def draw_obj_charges(obj, rect, enabled)
  516.     return unless $imported["BattleEngineMelody"]
  517.     return unless obj.is_a?(RPG::Item)
  518.     return unless obj.consumable
  519.     return if obj.charges <= 1
  520.     $game_party.item_charges = {} if $game_party.item_charges == nil
  521.     $game_party.item_charges[obj.id] = obj.charges if
  522.       $game_party.item_charges[obj.id] == nil
  523.     charges = $game_party.item_charges[obj.id]
  524.     dx = rect.x; dy = rect.y + WLH/3
  525.     self.contents.font.size = YEM::BATTLE_ENGINE::ITEM_SETTINGS[:charge]
  526.     self.contents.font.color = normal_color
  527.     self.contents.font.color.alpha = enabled ? 255 : 128
  528.     self.contents.draw_text(dx, dy, 24, WLH * 2/3, charges, 2)
  529.     self.contents.font.size = Font.default_size
  530.   end
  531.  
  532.   #--------------------------------------------------------------------------
  533.   # new method: draw_obj_total
  534.   #--------------------------------------------------------------------------
  535.   def draw_obj_total(obj, rect, enabled)
  536.     if $imported["BattleEngineMelody"]
  537.       hash = YEM::BATTLE_ENGINE::ITEM_SETTINGS
  538.     else
  539.       hash ={ :size => Font.default_size, :colour => 0, :text => "×%2d" }
  540.     end
  541.     number = $game_party.item_number(obj)
  542.     dx = rect.x + rect.width - 36; dy = rect.y; dw = 32
  543.     text = sprintf(hash[:text], number)
  544.     self.contents.font.size = hash[:size]
  545.     self.contents.font.color = text_color(hash[:colour])
  546.     self.contents.font.color.alpha = enabled ? 255 : 128
  547.     self.contents.draw_text(dx, dy, dw, WLH, text, 2)
  548.   end
  549.  
  550.   #--------------------------------------------------------------------------
  551.   # update_help
  552.   #--------------------------------------------------------------------------
  553.   def update_help
  554.     @help_window.set_text(item == nil ? "" : item.description)
  555.   end
  556.  
  557. end # Window_ItemList
  558.  
  559. #===============================================================================
  560. # Window_BattleItemList
  561. #===============================================================================
  562.  
  563. class Window_BattleItemList < Window_ItemList
  564.  
  565.   #--------------------------------------------------------------------------
  566.   # include?
  567.   #--------------------------------------------------------------------------
  568.   def include?(item)
  569.     return false if item == nil
  570.     return false if item.name == ""
  571.     return false unless item.is_a?(RPG::Item)
  572.     return false if item.menu_ok?
  573.     return item.battle_ok?
  574.   end
  575.  
  576. end # Window_BattleItemList
  577.  
  578. #===============================================================================
  579. # Window_WeaponItemList
  580. #===============================================================================
  581.  
  582. class Window_WeaponItemList < Window_ItemList
  583.  
  584.   #--------------------------------------------------------------------------
  585.   # include?
  586.   #--------------------------------------------------------------------------
  587.   def include?(item)
  588.     return false if item == nil
  589.     return false if item.name == ""
  590.     return item.is_a?(RPG::Weapon)
  591.   end
  592.  
  593. end # Window_WeaponItemList
  594.  
  595. #===============================================================================
  596. # Window_ArmourItemList
  597. #===============================================================================
  598.  
  599. class Window_ArmourItemList < Window_ItemList
  600.  
  601.   #--------------------------------------------------------------------------
  602.   # include?
  603.   #--------------------------------------------------------------------------
  604.   def include?(item)
  605.     return false if item == nil
  606.     return false if item.name == ""
  607.     return item.is_a?(RPG::Armor)
  608.   end
  609.  
  610. end # Window_ArmourItemList
  611.  
  612. #===============================================================================
  613. # Window_MiscItemList
  614. #===============================================================================
  615.  
  616. class Window_MiscItemList < Window_ItemList
  617.  
  618.   #--------------------------------------------------------------------------
  619.   # include?
  620.   #--------------------------------------------------------------------------
  621.   def include?(item)
  622.     return false if item == nil
  623.     return false if item.name == ""
  624.     return false if item.is_a?(RPG::Weapon)
  625.     return false if item.is_a?(RPG::Armor)
  626.     return false if item.menu_ok?
  627.     return false if item.battle_ok?
  628.     return false if item.key_item
  629.     return true
  630.   end
  631.  
  632. end # Window_MiscItemList
  633.  
  634. #===============================================================================
  635. # Window_KeyItemList
  636. #===============================================================================
  637.  
  638. class Window_KeyItemList < Window_ItemList
  639.  
  640.   #--------------------------------------------------------------------------
  641.   # include?
  642.   #--------------------------------------------------------------------------
  643.   def include?(item)
  644.     return false if item == nil
  645.     return false if item.name == ""
  646.     return item.key_item
  647.   end
  648.  
  649. end # Window_KeyItemList
  650.  
  651. #===============================================================================
  652. # Window_AllItemList
  653. #===============================================================================
  654.  
  655. class Window_AllItemList < Window_ItemList
  656.  
  657.   #--------------------------------------------------------------------------
  658.   # include?
  659.   #--------------------------------------------------------------------------
  660.   def include?(item)
  661.     return false if item == nil
  662.     return false if item.name == ""
  663.     return true
  664.   end
  665.  
  666. end # Window_AllItemList
  667.  
  668. #===============================================================================
  669. # Window_ItemData
  670. #===============================================================================
  671.  
  672. class Window_ItemData < Window_Base
  673.  
  674.   #--------------------------------------------------------------------------
  675.   # initialize
  676.   #--------------------------------------------------------------------------
  677.   def initialize(help_window)
  678.     dy = help_window.y + help_window.height
  679.     super(Graphics.width - 240, dy, 240, Graphics.height - dy)
  680.     create_clone
  681.   end
  682.  
  683.   #--------------------------------------------------------------------------
  684.   # create_clone
  685.   #--------------------------------------------------------------------------
  686.   def create_clone
  687.     @clone = Game_Actor.new(1)
  688.     @clone.maxhp = @clone.base_maxhp
  689.     @clone.maxmp = @clone.base_maxmp
  690.     @clone.atk = @clone.base_atk
  691.     @clone.def = @clone.base_def
  692.     @clone.spi = @clone.base_spi
  693.     @clone.res = @clone.base_res if $imported["RES Stat"]
  694.     @clone.dex = @clone.base_dex if $imported["DEX Stat"]
  695.     @clone.agi = @clone.base_agi
  696.   end
  697.  
  698.   #--------------------------------------------------------------------------
  699.   # set_item_window
  700.   #--------------------------------------------------------------------------
  701.   def set_item_window(new_item_window)
  702.     @item_window = new_item_window
  703.     update
  704.   end
  705.  
  706.   #--------------------------------------------------------------------------
  707.   # update
  708.   #--------------------------------------------------------------------------
  709.   def update
  710.     super
  711.     return if @item_window == nil
  712.     refresh if @item != @item_window.item
  713.   end
  714.  
  715.   #--------------------------------------------------------------------------
  716.   # refresh
  717.   #--------------------------------------------------------------------------
  718.   def refresh
  719.     self.contents.clear
  720.     @item = @item_window.item
  721.     return if @item == nil
  722.     dx = 0; dy = 0
  723.     dy = draw_item_name(dy)
  724.     if @item.is_a?(RPG::Item)
  725.       @hash = YEM::ITEM::ITEM_DATA
  726.       dy = draw_item_properties(dy)
  727.     elsif @item.is_a?(RPG::Weapon) or @item.is_a?(RPG::Armor)
  728.       @hash = YEM::ITEM::EQUIP_DATA
  729.       dy = draw_equip_properties(dy)
  730.     end
  731.   end
  732.  
  733.   #--------------------------------------------------------------------------
  734.   # draw_item_name
  735.   #--------------------------------------------------------------------------
  736.   def draw_item_name(dy)
  737.     draw_icon(@item.icon_index, 0, dy)
  738.     self.contents.font.size = Font.default_size
  739.     self.contents.font.color = normal_color
  740.     self.contents.draw_text(24, dy, contents.width-28, WLH, @item.name)
  741.     dy += WLH
  742.     return dy
  743.   end
  744.  
  745.   #--------------------------------------------------------------------------
  746.   # draw_item_properties
  747.   #--------------------------------------------------------------------------
  748.   def draw_item_properties(dy)
  749.     dy = draw_properties(dy)
  750.     dy = draw_item_value(dy)
  751.     dy = draw_healing_properties(dy)
  752.     dy = draw_base_damage(dy)
  753.     dy = draw_multipliers(dy)
  754.     dy = draw_elements(dy)
  755.     dy = draw_plus_states(dy)
  756.     dy = draw_minus_states(dy)
  757.     dy = draw_item_growth(dy)
  758.     dy = draw_custom_data(dy)
  759.     return dy
  760.   end
  761.  
  762.   #--------------------------------------------------------------------------
  763.   # draw_equip_properties
  764.   #--------------------------------------------------------------------------
  765.   def draw_equip_properties(dy)
  766.     dy = draw_properties(dy)
  767.     dy = draw_item_value(dy)
  768.     dy = draw_equip_stats(dy)
  769.     dy = draw_elements(dy)
  770.     dy = draw_states(dy)
  771.     dy = draw_custom_data(dy)
  772.     return dy
  773.   end
  774.  
  775.   #--------------------------------------------------------------------------
  776.   # draw_properties
  777.   #--------------------------------------------------------------------------
  778.   def draw_properties(dy)
  779.     text = @hash[:properties]
  780.     self.contents.font.size = @hash[:fontsize]
  781.     self.contents.font.color = system_color
  782.     self.contents.draw_text(4, dy, contents.width-8, WLH, text, 1)
  783.     dy += WLH
  784.     return dy
  785.   end
  786.  
  787.   #--------------------------------------------------------------------------
  788.   # draw_item_value
  789.   #--------------------------------------------------------------------------
  790.   def draw_item_value(dy)
  791.     return dy unless @hash[:gold_value]
  792.     return dy if @item.price == 0
  793.     draw_icon(Icon.gold_cost, 0, dy)
  794.     text = YEM::ITEM::DRAW_GOLD_TEXT
  795.     self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  796.     text = sprintf("%d%s", @item.price, Vocab.gold)
  797.     self.contents.font.color = normal_color
  798.     self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  799.     dy += WLH
  800.     return dy
  801.   end
  802.  
  803.   #--------------------------------------------------------------------------
  804.   # draw_healing_properties
  805.   #--------------------------------------------------------------------------
  806.   def draw_healing_properties(dy)
  807.     return dy if dy + WLH > contents.height
  808.     #---
  809.     if @item.hp_recovery_rate != 0 or @item.hp_recovery != 0
  810.       draw_icon(Icon.hp_heal, 0, dy)
  811.       self.contents.font.color = system_color
  812.       text = @hash[:hp_heal_text]
  813.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  814.       self.contents.font.color = normal_color
  815.       if @item.hp_recovery_rate != 0 and @item.hp_recovery != 0
  816.         text = sprintf("%+d%%", @item.hp_recovery_rate)
  817.         self.contents.draw_text(24, dy, (contents.width-28)*2/3, WLH, text, 2)
  818.         text = sprintf("%+d", @item.hp_recovery)
  819.         self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  820.       elsif @item.hp_recovery_rate != 0
  821.         text = sprintf("%+d%%", @item.hp_recovery_rate)
  822.         self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  823.       elsif @item.hp_recovery != 0
  824.         text = sprintf("%+d", @item.hp_recovery)
  825.         self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  826.       end
  827.       dy += WLH
  828.     end
  829.     #---
  830.     return dy if dy + WLH > contents.height
  831.     #---
  832.     if @item.mp_recovery_rate != 0 or @item.mp_recovery != 0
  833.       draw_icon(Icon.mp_heal, 0, dy)
  834.       self.contents.font.color = system_color
  835.       text = @hash[:mp_heal_text]
  836.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  837.       self.contents.font.color = normal_color
  838.       if @item.mp_recovery_rate != 0 and @item.mp_recovery != 0
  839.         text = sprintf("%+d%%", @item.mp_recovery_rate)
  840.         self.contents.draw_text(24, dy, (contents.width-28)*2/3, WLH, text, 2)
  841.         text = sprintf("%+d", @item.mp_recovery)
  842.         self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  843.       elsif @item.mp_recovery_rate != 0
  844.         text = sprintf("%+d%%", @item.mp_recovery_rate)
  845.         self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  846.       elsif @item.mp_recovery != 0
  847.         text = sprintf("%+d", @item.mp_recovery)
  848.         self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  849.       end
  850.       dy += WLH
  851.     end
  852.     #---
  853.     return dy
  854.   end
  855.  
  856.   #--------------------------------------------------------------------------
  857.   # draw_base_damage
  858.   #--------------------------------------------------------------------------
  859.   def draw_base_damage(dy)
  860.     return dy if dy + WLH > contents.height
  861.     return dy if (-5..5) === @item.base_damage
  862.     if @item.base_damage > 0
  863.       draw_icon(Icon.base_damage, 0, dy)
  864.       text = @hash[:base_dmg]
  865.     else
  866.       draw_icon(Icon.base_healing, 0, dy)
  867.       text = @hash[:base_heal]
  868.     end
  869.     self.contents.font.color = system_color
  870.     self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  871.     self.contents.font.color = normal_color
  872.     text = (@item.base_damage).abs
  873.     self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2); dy += WLH
  874.     return dy
  875.   end
  876.  
  877.   #--------------------------------------------------------------------------
  878.   # draw_multipliers
  879.   #--------------------------------------------------------------------------
  880.   def draw_multipliers(dy)
  881.     return dy if dy + WLH > contents.height
  882.     return dy if @item.base_damage == 0
  883.     icon = @item.base_damage > 0 ? Icon.base_damage : Icon.base_healing
  884.     #---
  885.     if @item.atk_f > 0
  886.       draw_icon(icon, 0, dy)
  887.       text = sprintf(@hash[:multiplier], Vocab.atk)
  888.       self.contents.font.color = system_color
  889.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  890.       text = sprintf("%s%%", @item.atk_f)
  891.       self.contents.font.color = normal_color
  892.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  893.       dy += WLH
  894.     end
  895.     #---
  896.     return dy if dy + WLH > contents.height
  897.     #---
  898.     if $imported["BattleEngineMelody"] and @item.def_f > 0
  899.       draw_icon(icon, 0, dy)
  900.       text = sprintf(@hash[:multiplier], Vocab.def)
  901.       self.contents.font.color = system_color
  902.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  903.       text = sprintf("%s%%", @item.def_f)
  904.       self.contents.font.color = normal_color
  905.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  906.       dy += WLH
  907.     end
  908.     #---
  909.     return dy if dy + WLH > contents.height
  910.     #---
  911.     if @item.spi_f > 0
  912.       draw_icon(icon, 0, dy)
  913.       text = sprintf(@hash[:multiplier], Vocab.spi)
  914.       self.contents.font.color = system_color
  915.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  916.       text = sprintf("%s%%", @item.spi_f)
  917.       self.contents.font.color = normal_color
  918.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  919.       dy += WLH
  920.     end
  921.     #---
  922.     return dy if dy + WLH > contents.height
  923.     #---
  924.     if $imported["BattleEngineMelody"] and $imported["RES Stat"] and
  925.     @item.res_f > 0
  926.       draw_icon(icon, 0, dy)
  927.       text = sprintf(@hash[:multiplier], Vocab.res)
  928.       self.contents.font.color = system_color
  929.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  930.       text = sprintf("%s%%", @item.res_f)
  931.       self.contents.font.color = normal_color
  932.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  933.       dy += WLH
  934.     end
  935.     #---
  936.     return dy if dy + WLH > contents.height
  937.     #---
  938.     if $imported["BattleEngineMelody"] and $imported["DEX Stat"] and
  939.     @item.dex_f > 0
  940.       draw_icon(icon, 0, dy)
  941.       text = sprintf(@hash[:multiplier], Vocab.dex)
  942.       self.contents.font.color = system_color
  943.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  944.       text = sprintf("%s%%", @item.dex_f)
  945.       self.contents.font.color = normal_color
  946.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  947.       dy += WLH
  948.     end
  949.     #---
  950.     return dy if dy + WLH > contents.height
  951.     #---
  952.     if $imported["BattleEngineMelody"] and @item.agi_f > 0
  953.       draw_icon(icon, 0, dy)
  954.       text = sprintf(@hash[:multiplier], Vocab.agi)
  955.       self.contents.font.color = system_color
  956.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  957.       text = sprintf("%s%%", @item.agi_f)
  958.       self.contents.font.color = normal_color
  959.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  960.       dy += WLH
  961.     end
  962.     #---
  963.     return dy
  964.   end
  965.  
  966.   #--------------------------------------------------------------------------
  967.   # draw_elements
  968.   #--------------------------------------------------------------------------
  969.   def draw_elements(dy)
  970.     return dy if @item.element_set == []
  971.     for element_id in YEM::ITEM::SHOWN_ELEMENTS
  972.       break if dy + WLH > contents.height
  973.       next unless @item.element_set.include?(element_id)
  974.       draw_icon(Icon.element(element_id), 0, dy)
  975.       text = @hash[:element] if @item.is_a?(RPG::Item)
  976.       text = @hash[:ele_weapon] if @item.is_a?(RPG::Weapon)
  977.       text = @hash[:ele_armour] if @item.is_a?(RPG::Armor)
  978.       self.contents.font.color = system_color
  979.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  980.       text = $data_system.elements[element_id]
  981.       self.contents.font.color = normal_color
  982.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  983.       dy += WLH
  984.     end
  985.     return dy
  986.   end
  987.  
  988.   #--------------------------------------------------------------------------
  989.   # total_drawn_states
  990.   #--------------------------------------------------------------------------
  991.   def total_drawn_states(array)
  992.     result = 0
  993.     for state_id in array
  994.       next if $data_states[state_id] == nil
  995.       next if $data_states[state_id].icon_index == 0
  996.       result += 1
  997.     end
  998.     return [result, 8].min
  999.   end
  1000.  
  1001.   #--------------------------------------------------------------------------
  1002.   # draw_states
  1003.   #--------------------------------------------------------------------------
  1004.   def draw_states(dy)
  1005.     return dy if @item.state_set == []
  1006.     total = total_drawn_states(@item.state_set)
  1007.     if total == 1
  1008.       return dy if dy + WLH > contents.height
  1009.       state = $data_states[@item.state_set[0]]
  1010.       draw_icon(state.icon_index, 0, dy)
  1011.       text = @hash[:state_weapon] if @item.is_a?(RPG::Weapon)
  1012.       text = @hash[:state_armour] if @item.is_a?(RPG::Armor)
  1013.       self.contents.font.color = system_color
  1014.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1015.       text = state.name
  1016.       self.contents.font.color = normal_color
  1017.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1018.     else
  1019.       return dy if dy + WLH*2 > contents.height
  1020.       text = @hash[:state_weapon] if @item.is_a?(RPG::Weapon)
  1021.       text = @hash[:state_armour] if @item.is_a?(RPG::Armor)
  1022.       self.contents.font.color = system_color
  1023.       self.contents.draw_text(4, dy, contents.width-8, WLH, text, 1)
  1024.       dy += WLH
  1025.       dx = (contents.width - total*24)/2
  1026.       for state_id in @item.state_set
  1027.         break if dx + 24 > contents.width
  1028.         state = $data_states[state_id]
  1029.         next if state.icon_index == 0
  1030.         draw_icon(state.icon_index, dx, dy)
  1031.         dx += 24
  1032.       end
  1033.     end
  1034.     dy += WLH
  1035.     return dy
  1036.   end
  1037.  
  1038.   #--------------------------------------------------------------------------
  1039.   # draw_plus_states
  1040.   #--------------------------------------------------------------------------
  1041.   def draw_plus_states(dy)
  1042.     return dy if @item.plus_state_set == []
  1043.     total = total_drawn_states(@item.plus_state_set)
  1044.     if total == 1
  1045.       return dy if dy + WLH > contents.height
  1046.       state = $data_states[@item.plus_state_set[0]]
  1047.       draw_icon(state.icon_index, 0, dy)
  1048.       text = @hash[:add_state]
  1049.       self.contents.font.color = system_color
  1050.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1051.       text = state.name
  1052.       self.contents.font.color = normal_color
  1053.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1054.     else
  1055.       return dy if dy + WLH*2 > contents.height
  1056.       text = @hash[:add_state]
  1057.       self.contents.font.color = system_color
  1058.       self.contents.draw_text(4, dy, contents.width-8, WLH, text, 1)
  1059.       dy += WLH
  1060.       dx = (contents.width - total*24)/2
  1061.       for state_id in @item.plus_state_set
  1062.         break if dx + 24 > contents.width
  1063.         state = $data_states[state_id]
  1064.         next if state.icon_index == 0
  1065.         draw_icon(state.icon_index, dx, dy)
  1066.         dx += 24
  1067.       end
  1068.     end
  1069.     dy += WLH
  1070.     return dy
  1071.   end
  1072.  
  1073.   #--------------------------------------------------------------------------
  1074.   # draw_minus_states
  1075.   #--------------------------------------------------------------------------
  1076.   def draw_minus_states(dy)
  1077.     return dy if @item.minus_state_set == []
  1078.     total = total_drawn_states(@item.minus_state_set)
  1079.     if total == 1
  1080.       return dy if dy + WLH > contents.height
  1081.       state = $data_states[@item.minus_state_set[0]]
  1082.       draw_icon(state.icon_index, 0, dy)
  1083.       text = @hash[:rem_state]
  1084.       self.contents.font.color = system_color
  1085.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1086.       text = state.name
  1087.       self.contents.font.color = normal_color
  1088.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1089.     else
  1090.       return dy if dy + WLH*2 > contents.height
  1091.       text = @hash[:rem_state]
  1092.       self.contents.font.color = system_color
  1093.       self.contents.draw_text(4, dy, contents.width-8, WLH, text, 1)
  1094.       dy += WLH
  1095.       dx = (contents.width - total*24)/2
  1096.       for state_id in @item.minus_state_set
  1097.         break if dx + 24 > contents.width
  1098.         state = $data_states[state_id]
  1099.         next if state.icon_index == 0
  1100.         draw_icon(state.icon_index, dx, dy)
  1101.         dx += 24
  1102.       end
  1103.     end
  1104.     dy += WLH
  1105.     return dy
  1106.   end
  1107.  
  1108.   #--------------------------------------------------------------------------
  1109.   # draw_item_growth
  1110.   #--------------------------------------------------------------------------
  1111.   def draw_item_growth(dy)
  1112.     #---
  1113.     if @item.parameter_type != 0
  1114.       case @item.parameter_type
  1115.       when 1; text = sprintf(@hash[:growth], Vocab.hp)
  1116.       when 2; text = sprintf(@hash[:growth], Vocab.mp)
  1117.       when 3; text = sprintf(@hash[:growth], Vocab.atk)
  1118.       when 4; text = sprintf(@hash[:growth], Vocab.def)
  1119.       when 5; text = sprintf(@hash[:growth], Vocab.spi)
  1120.       when 6; text = sprintf(@hash[:growth], Vocab.agi)
  1121.       end
  1122.       draw_icon(@item.icon_index, 0, dy)
  1123.       self.contents.font.color = system_color
  1124.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1125.       text = sprintf("%+d", @item.parameter_points)
  1126.       self.contents.font.color = normal_color
  1127.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1128.       dy += WLH
  1129.     end
  1130.     #---
  1131.     if $imported["StatusMenuMelody"]
  1132.       for stat in [:hp, :mp, :atk, :def, :spi, :res, :dex, :agi]
  1133.         return dy if dy + WLH > contents.height
  1134.         next if stat == :res and !$imported["RES Stat"]
  1135.         next if stat == :dex and !$imported["DEX Stat"]
  1136.         next if @item.stat_growth[stat] == 0 or @item.stat_growth[stat] == nil
  1137.         text = sprintf(@hash[:growth], eval("Vocab." + stat.to_s))
  1138.         draw_icon(@item.icon_index, 0, dy)
  1139.         self.contents.font.color = system_color
  1140.         self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1141.         text = sprintf("%+d", @item.stat_growth[stat])
  1142.         self.contents.font.color = normal_color
  1143.         self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1144.         dy += WLH
  1145.       end
  1146.     end
  1147.     #---
  1148.     if $imported["BattleEngineMelody"]
  1149.       growth = []
  1150.       for key in @item.element_growth
  1151.         growth.push(key[0]) if YEM::ITEM::SHOWN_ELEMENTS.include?(key[0])
  1152.       end
  1153.       growth.sort!
  1154.       for element_id in growth
  1155.         return dy if dy + WLH > contents.height
  1156.         icon = Icon.element(element_id)
  1157.         next if icon == 0
  1158.         draw_icon(icon, 0, dy)
  1159.         text = sprintf(@hash[:resist], $data_system.elements[element_id])
  1160.         self.contents.font.color = system_color
  1161.         self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1162.         text = sprintf("%+d%%", -@item.element_growth[element_id])
  1163.         self.contents.font.color = normal_color
  1164.         self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1165.         dy += WLH
  1166.       end
  1167.     end
  1168.     #---
  1169.     if $imported["BattleEngineMelody"]
  1170.       growth = []
  1171.       for key in @item.state_growth
  1172.         growth.push(key[0])
  1173.       end
  1174.       growth.sort!
  1175.       for state_id in growth
  1176.         return dy if dy + WLH > contents.height
  1177.         state = $data_states[state_id]
  1178.         next if state == nil
  1179.         icon = state.icon_index
  1180.         next if icon == 0
  1181.         draw_icon(icon, 0, dy)
  1182.         text = sprintf(@hash[:resist], state.name)
  1183.         self.contents.font.color = system_color
  1184.         self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1185.         text = sprintf("%+d%%", -@item.state_growth[state_id])
  1186.         self.contents.font.color = normal_color
  1187.         self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1188.         dy += WLH
  1189.       end
  1190.     end
  1191.     #---
  1192.     if $imported["EquipmentOverhaul"]
  1193.       for stat in [:hp, :mp, :atk, :def, :spi, :res, :dex, :agi]
  1194.         return dy if dy + WLH > contents.height
  1195.         next if stat == :res and !$imported["RES Stat"]
  1196.         next if stat == :dex and !$imported["DEX Stat"]
  1197.         next if @item.apt_growth[stat] == 0 or @item.apt_growth[stat] == nil
  1198.         text = sprintf(@hash[:bonus], eval("Vocab." + stat.to_s))
  1199.         draw_icon(@item.icon_index, 0, dy)
  1200.         self.contents.font.color = system_color
  1201.         self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1202.         text = sprintf("%+d%%", @item.apt_growth[stat])
  1203.         self.contents.font.color = normal_color
  1204.         self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1205.         dy += WLH
  1206.       end
  1207.     end
  1208.     #---
  1209.     return dy
  1210.   end
  1211.  
  1212.   #--------------------------------------------------------------------------
  1213.   # draw_equip_stats
  1214.   #--------------------------------------------------------------------------
  1215.   def draw_equip_stats(dy)
  1216.     dx = 0
  1217.     array = [:hp, :mp, :atk, :def, :spi, :res, :dex, :agi]
  1218.     for stat in @hash[:shown_stats]
  1219.       return if dy + WLH > contents.height
  1220.       next if stat == :res and !$imported["RES Stat"]
  1221.       next if stat == :dex and !$imported["DEX Stat"]
  1222.       next if [:hp, :mp].include?(stat) and !$imported["EquipmentOverhaul"]
  1223.       next unless array.include?(stat)
  1224.       draw_icon(Icon.stat(@clone, stat), dx, dy)
  1225.       text = eval("Vocab." + stat.to_s)
  1226.       self.contents.font.color = system_color
  1227.       self.contents.draw_text(dx+24, dy, contents.width/2-28, WLH, text, 0)
  1228.       stat_text = stat.to_s
  1229.       stat_text = "max" + stat_text if ["hp", "mp"].include?(stat_text)
  1230.       item_value = eval("@item." + stat_text)
  1231.       text = sprintf("%+d", item_value)
  1232.       self.contents.font.color = normal_color
  1233.       self.contents.font.color.alpha = item_value == 0 ? 128 : 255
  1234.       self.contents.draw_text(dx+24, dy, contents.width/2-28, WLH, text, 2)
  1235.       if dx == 0
  1236.         dx = contents.width/2
  1237.       else
  1238.         dx = 0
  1239.         dy += WLH
  1240.       end
  1241.     end
  1242.     dy += WLH if dx != 0
  1243.     return dy
  1244.   end
  1245.  
  1246.   #--------------------------------------------------------------------------
  1247.   # draw_custom_data
  1248.   #--------------------------------------------------------------------------
  1249.   def draw_custom_data(dy)
  1250.     return dy if @item.custom_data == []
  1251.     for array in @item.custom_data
  1252.       break if dy + WLH > contents.height
  1253.       draw_icon(array[0], 0, dy)
  1254.       text = array[1]
  1255.       self.contents.font.color = system_color
  1256.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 0)
  1257.       text = array[2]
  1258.       self.contents.font.color = normal_color
  1259.       self.contents.draw_text(24, dy, contents.width-28, WLH, text, 2)
  1260.       dy += WLH
  1261.     end
  1262.     return dy
  1263.   end
  1264.  
  1265. end # Window_ItemData
  1266.  
  1267. #===============================================================================
  1268. # Scene_Item
  1269. #===============================================================================
  1270.  
  1271. class Scene_Item < Scene_Base
  1272.  
  1273.   #--------------------------------------------------------------------------
  1274.   # overwrite method: start
  1275.   #--------------------------------------------------------------------------
  1276.   def start
  1277.     super
  1278.     create_menu_background
  1279.     @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
  1280.     @help_window = Window_Help.new
  1281.     @help_window.viewport = @viewport
  1282.     @help_window.y = 128
  1283.     @data_window = Window_ItemData.new(@help_window)
  1284.     @data_window.viewport = @viewport
  1285.     @windows = []
  1286.     @target_window = Window_MenuStatus.new(0, 0)
  1287.     @target_window.visible = false
  1288.     @target_window.active = false
  1289.     @status_window = Window_ItemStatus.new
  1290.     @status_window.viewport = @viewport
  1291.     create_command_window
  1292.     update_windows
  1293.   end
  1294.  
  1295.   #--------------------------------------------------------------------------
  1296.   # new method: create_command_window
  1297.   #--------------------------------------------------------------------------
  1298.   def create_command_window
  1299.     commands = []; @data = []
  1300.     for command in YEM::ITEM::COMMANDS
  1301.       case command
  1302.       when :usable
  1303.         @usable_window = Window_ItemList.new(@help_window)
  1304.         @windows.push(@usable_window)
  1305.       when :battle
  1306.         @battle_window = Window_BattleItemList.new(@help_window)
  1307.         @windows.push(@battle_window)
  1308.       when :weapons
  1309.         @weapon_window = Window_WeaponItemList.new(@help_window)
  1310.         @windows.push(@weapon_window)
  1311.       when :armours
  1312.         @armour_window = Window_ArmourItemList.new(@help_window)
  1313.         @windows.push(@armour_window)
  1314.       when :misc
  1315.         @misc_window = Window_MiscItemList.new(@help_window)
  1316.         @windows.push(@misc_window)
  1317.       when :key_items
  1318.         @key_item_window = Window_KeyItemList.new(@help_window)
  1319.         @windows.push(@key_item_window)
  1320.       when :all_items
  1321.         @all_item_window = Window_AllItemList.new(@help_window)
  1322.         @windows.push(@all_item_window)
  1323.       else; next
  1324.       end
  1325.       @data.push(command)
  1326.       if YEM::ITEM::VOCAB[command] != nil
  1327.         commands.push(YEM::ITEM::VOCAB[command])
  1328.       end
  1329.     end
  1330.     for window in @windows
  1331.       next if window == nil?
  1332.       window.active = false
  1333.       window.viewport = @viewport
  1334.       window.help_window = @help_window if window.is_a?(Window_Selectable)
  1335.     end
  1336.     @command_window = Window_Command_Centered.new(160, commands)
  1337.     @command_window.viewport = @viewport
  1338.     @command_window.height = 128
  1339.     @command_window.active = true
  1340.   end
  1341.  
  1342.   #--------------------------------------------------------------------------
  1343.   # new method: update_windows
  1344.   #--------------------------------------------------------------------------
  1345.   def update_windows
  1346.     @last_command_index = @command_window.index
  1347.     @help_window.y = Graphics.height*8
  1348.     @data_window.y = Graphics.height*8
  1349.     for window in @windows
  1350.       next if window == nil
  1351.       window.y = Graphics.height*8
  1352.     end
  1353.     #---
  1354.     case @data[@command_window.index]
  1355.     when :usable
  1356.       show_item_windows(@usable_window)
  1357.     when :battle
  1358.       show_item_windows(@battle_window)
  1359.     when :weapons
  1360.       show_item_windows(@weapon_window)
  1361.     when :armours
  1362.       show_item_windows(@armour_window)
  1363.     when :misc
  1364.       show_item_windows(@misc_window)
  1365.     when :key_items
  1366.       show_item_windows(@key_item_window)
  1367.     when :all_items
  1368.       show_item_windows(@all_item_window)
  1369.     end
  1370.   end
  1371.  
  1372.   #--------------------------------------------------------------------------
  1373.   # overwrite method: terminate
  1374.   #--------------------------------------------------------------------------
  1375.   def terminate
  1376.     super
  1377.     dispose_menu_background
  1378.     @help_window.dispose
  1379.     @command_window.dispose
  1380.     @status_window.dispose
  1381.     for window in @windows
  1382.       next if window == nil
  1383.       next if window.disposed?
  1384.       window.dispose
  1385.     end
  1386.     @viewport.dispose
  1387.   end
  1388.  
  1389.   #--------------------------------------------------------------------------
  1390.   # overwrite method: update
  1391.   #--------------------------------------------------------------------------
  1392.   def update
  1393.     super
  1394.     update_menu_background
  1395.     if @command_window.active
  1396.       update_command_selection
  1397.     elsif @target_window.active
  1398.       update_target_selection
  1399.     elsif @item_window != nil and @item_window.active
  1400.       update_item_selection
  1401.     end
  1402.   end
  1403.  
  1404.   #--------------------------------------------------------------------------
  1405.   # new method: update_command_selection
  1406.   #--------------------------------------------------------------------------
  1407.   def update_command_selection
  1408.     @command_window.update
  1409.     update_windows if @last_command_index != @command_window.index
  1410.     if Input.trigger?(Input::B)
  1411.       Sound.play_cancel
  1412.       return_scene
  1413.     elsif Input.trigger?(Input::C)
  1414.       Sound.play_decision
  1415.       @command_window.active = false
  1416.       case @data[@command_window.index]
  1417.       when :usable, :battle, :weapons, :armours, :misc, :key_items, :all_items
  1418.         @item_window.active = true
  1419.       end
  1420.     end
  1421.   end
  1422.  
  1423.   #--------------------------------------------------------------------------
  1424.   # new method: show_usable_windows
  1425.   #--------------------------------------------------------------------------
  1426.   def show_item_windows(window)
  1427.     @help_window.y = 128
  1428.     @data_window.set_item_window(window)
  1429.     @status_window.set_item_window(window)
  1430.     @data_window.y = @help_window.y + @help_window.height
  1431.     window.y = @data_window.y
  1432.     window.update_help
  1433.     @item_window = window
  1434.   end
  1435.  
  1436.   #--------------------------------------------------------------------------
  1437.   # overwrite method: update_item_selection
  1438.   #--------------------------------------------------------------------------
  1439.   def update_item_selection
  1440.     @status_window.update
  1441.     @item_window.update
  1442.     @data_window.update
  1443.     if Input.trigger?(Input::B)
  1444.       Sound.play_cancel
  1445.       @item_window.active = false
  1446.       @command_window.active = true
  1447.       return unless @item_used
  1448.       for window in @windows
  1449.         next unless window.is_a?(Window_ItemList)
  1450.         window.used_item_refresh(@item_used)
  1451.       end
  1452.       @item_used = []
  1453.     elsif Input.trigger?(Input::C)
  1454.       @item = @item_window.item
  1455.       if enable_item?
  1456.         Sound.play_decision
  1457.         determine_item
  1458.       end
  1459.     end
  1460.   end
  1461.  
  1462.   #--------------------------------------------------------------------------
  1463.   # new method: enable_item?
  1464.   #--------------------------------------------------------------------------
  1465.   def enable_item?
  1466.     return false unless @item.is_a?(RPG::Item)
  1467.     return false unless @item.menu_ok?
  1468.     return false unless @item_window.enable?(@item)
  1469.     return true
  1470.   end
  1471.  
  1472.   #--------------------------------------------------------------------------
  1473.   # alias method: update_target_selection
  1474.   #--------------------------------------------------------------------------
  1475.   alias update_target_selection_io update_target_selection unless $@
  1476.   def update_target_selection
  1477.     @target_window.update
  1478.     update_target_selection_io
  1479.   end
  1480.  
  1481.   #--------------------------------------------------------------------------
  1482.   # alias method: show_target_window
  1483.   #--------------------------------------------------------------------------
  1484.   alias show_target_window_io show_target_window unless $@
  1485.   def show_target_window(right)
  1486.     show_target_window_io(true)
  1487.   end
  1488.  
  1489.   #--------------------------------------------------------------------------
  1490.   # alias method: use_item_nontarget
  1491.   #--------------------------------------------------------------------------
  1492.   alias use_item_nontarget_io use_item_nontarget unless $@
  1493.   def use_item_nontarget
  1494.     @item_used = [] if @item_used == nil
  1495.     @item_used.push(@item) unless @item_used.include?(@item)
  1496.     use_item_nontarget_io
  1497.     @status_window.refresh
  1498.   end
  1499.  
  1500. end # Scene_Base
  1501.  
  1502. #===============================================================================
  1503. #
  1504. # END OF FILE
  1505. #
  1506. #===============================================================================
Add Comment
Please, Sign In to add comment