Advertisement
luistop12

yanfly equipment

Apr 4th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 109.46 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Yanfly Engine Zealous - Equipment Overhaul
  4. # Last Date Updated: 2010.08.23
  5. # Level: Normal, Hard, Lunatic
  6. #
  7. # This script essentially redefines the way the equipment system works while
  8. # keeping the core without rewriting too much. It will also recalculate the
  9. # stats applied through equipment by the order of operations properly so that
  10. # the numbers aren't a jumbled up uncontrollable mess. In addition to fixing
  11. # the calculation regarding the order of operations, this script also changes
  12. # the equipment scene with a different layout and more efficient methods.
  13. #
  14. # Equipment can also require certain conditions to be met first before being
  15. # able to be equipped. These conditions include reaching a certain level, having
  16. # more or less than a certain number for their stat, or even having a switch to
  17. # be enabled. These requirements can be done through simple tags.
  18. #
  19. # An aptitude system is also included in the script, where certain classes can
  20. # receive more or less bonus from certain stat increases from equipment. For
  21. # example, a warrior will receive less INT than a mage would from a piece of
  22. # equipment. Aptitude is also flexible and can be adjusted through items, too.
  23. #
  24. #===============================================================================
  25. # Updates
  26. # -----------------------------------------------------------------------------
  27. # o 2010.08.23 - Bugfix regarding optimization.
  28. # o 2010.08.16 - Bugfix regarding unequipping items with MaxHP and MaxMP.
  29. # o 2010.06.24 - Unequip bug has been fixed.
  30. # o 2010.06.03 - Efficiency update.
  31. # o 2010.05.24 - Converted to Yanfly Engine Melody.
  32. #===============================================================================
  33. # Instructions
  34. # -----------------------------------------------------------------------------
  35. # To install this script, open up your script editor and copy/paste this script
  36. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  37. #
  38. # -----------------------------------------------------------------------------
  39. # Item Tags - Insert the following tags into usable Item noteboxes.
  40. # -----------------------------------------------------------------------------
  41. # <stat aptitude: +x%>  or  <stat aptitude: -x%>
  42. # This will raise or lower the stat's aptitude by x%. Replace stat with one of
  43. # the following: MaxHP, MaxMP, ATK, DEF, SPI, RES, DEX, or AGI
  44. #
  45. # -----------------------------------------------------------------------------
  46. # Equip Tags - Insert the following tags into Weapon and Armour noteboxes.
  47. # -----------------------------------------------------------------------------
  48. # <stat: +x>   or  <stat: -x>
  49. # <stat: +x%>  or  <stat: -x%>
  50. # This will allow the piece of equipment to raise or lower the stat by x in
  51. # either a set amount or percentile amount. Note that percents are calculated
  52. # before set values. Percents are also ignored from equip optimization. This
  53. # tag will allow you to go past the 500 maximum value that the editor has.
  54. # Replace stat with one of the following:
  55. #      MaxHP, MaxMP, ATK, DEF, SPI, AGI, HIT, EVA, CRI, ODDS
  56. #
  57. # <trait: phrase>
  58. # This will give your piece of equipment some unique traits. Just replace the
  59. # word phrase inside the tag with one of the following:
  60. #   super guard      - Guarding reduces damage by 4x instead of 2x.
  61. #   pharmacology     - Items used will have double effect.
  62. #   fast attack      - Early turn initiative.
  63. #   dual attack      - Normal attacks hit twice.
  64. #   prevent critical - Criticals cannot occur on battler.
  65. #   half mp cost     - MP skills cost only half.
  66. #   double exp gain  - Inflicted actor gains double exp.
  67. #   auto hp recover  - Inflicted actor gains HP each turn and step.
  68. #
  69. # <auto state: x> or <auto states: x,x>
  70. # This will cause the piece of equipment to have states x automatically on the
  71. # actor so long as the actor has the item equipped. Once unequipped, the state
  72. # will no longer be applied to the actor.
  73. #
  74. # <require above: stat x> or <require under: stat x>
  75. # This will make your piece of equipment require certain stat conditions to be
  76. # met. If above, it is greater than or equal to. If under, it is less than or
  77. # equal to. Replace stat with one of the following:
  78. #    Level, MaxHP, MaxMP, ATK, DEF, SPI, RES, DEX, AGI, HIT, EVA, CRI, ODDS
  79. #
  80. # <require switch: x> or <require switches: x,x>
  81. # This will require the switch x to be on before the piece of equipment can be
  82. # worn by the actor. If it isn't on, it'll be greyed out until available.
  83. #
  84. # <require variable x: above y> or <require variable x: under y>
  85. # This will require the variable x to be above/under y in order for the item
  86. # to become equippable by the actor.
  87. #
  88. # -----------------------------------------------------------------------------
  89. # Weapon Tags - Insert the following tags into Weapon noteboxes.
  90. # -----------------------------------------------------------------------------
  91. # <2 hand text: phrase>
  92. # This will replace the default two-handed text with whatever you've inserted
  93. # for phrase. Case sensitive.
  94. #
  95. # -----------------------------------------------------------------------------
  96. # Armour Tags - Insert the following tags into Armour noteboxes.
  97. # -----------------------------------------------------------------------------
  98. # <equip type: phrase>
  99. # This changes the equip type of the item to whatever the phrase is. This tag
  100. # exists for using more than the 4 types of armour equips available to RPG
  101. # Maker. To understand how this works better, read the Equip Settings part of
  102. # the module and adjust the settings there accordingly.
  103. #
  104. # -----------------------------------------------------------------------------
  105. # Script Calls
  106. # -----------------------------------------------------------------------------
  107. # item = $data_armors[item_id]
  108. # $game_actors[x].change_equip(slot_id, item)
  109. # This allows you to equip armours to the newly made slots. Make sure you find
  110. # the appropriate item_id for the armour.
  111. #
  112. # $game_actors[x].lock_equip(slot_id)
  113. # This locks that actor's equipment slot from being changable. Does not give
  114. # overrides to fixed equipment trait.
  115. #
  116. # $game_actors[x].unlock_equip(slot_id)
  117. # This unlocks that actor's equipment slot to being changable. Does not give
  118. # overrides to fixed equipment trait.
  119. #
  120. # array = [:other, :other, :other]
  121. # $game_actors[x].equip_type = array
  122. # This changes the actors equip types to set array. Any unequippable items will
  123. # be purged and thrown back into the inventory. This does not include weapon
  124. # and weapon will be automatically excluded to maintain compatibility.
  125. #
  126. # $game_actors[x].add_equip_type(type)
  127. # This adds an equip type onto the pre-existing equip types. It opens up an
  128. # extra expanded slot at the very end of the list. This does not include
  129. # weapon and weapon will be automatically excluded to maintain comptability.
  130. #
  131. # $game_actors[x].delete_last_equip_type
  132. # This removes the last type in the current equip types. The item in the
  133. # previous types are dropped. This will not delete weapon types to maintain
  134. # compatibility.
  135. #
  136. # -----------------------------------------------------------------------------
  137. # Debug Shortcuts - Only during $TEST and $BTEST mode
  138. # -----------------------------------------------------------------------------
  139. # During testplay mode, pressing F5 inside of the equip screen will allow you
  140. # to force equip an item that isn't normally equippable. Pressing F7 and F8
  141. # decreases and increases the number of an item. Inside aptitude, F5 will force
  142. # use an aptitude item even if it's been consumed. F6 will reset aptitudes. F7
  143. # and F8 will increase and decrease aptitude items.
  144. #===============================================================================
  145.  
  146. $imported = {} if $imported == nil
  147. $imported["EquipmentOverhaul"] = true
  148.  
  149. module YEM
  150.  module EQUIP
  151.    
  152.    #===========================================================================
  153.    # Section I. Basic Settings
  154.    # --------------------------------------------------------------------------
  155.    # The following below will adjust the basic settings and vocabulary that
  156.    # will display throughout the script. Change them as you see fit.
  157.    #===========================================================================
  158.    
  159.    # This adjusts the commands used within the equip scene. The command window
  160.    # is the window that lets you switch between various equip scene options.
  161.    COMMANDS =[
  162.      :manual,      # Manually equips weapons and armours.
  163.      :optimize,    # Optimize equipping automatically.
  164.      #:aptitude,    # Enter aptitude attuning menu.
  165.    ] # Do not remove this.
  166.    
  167.    # The following determines the vocabulary used for the remade equip scene.
  168.    # Adjust it accordingly to set the way text is displayed.
  169.    VOCAB ={
  170.      :manual   => "Re-Equipar",
  171.      :optimize => "Optimizar",
  172.      :aptitude => "Aptitude",
  173.      :mastery  => "Weaponry",
  174.      :twohand  => "2-Manos",
  175.      :arrow    => "→",
  176.      :noequip  => "<Vacío>",
  177.      :unequip  => "Desequipar",
  178.      :amount   => ":%2d",
  179.      :apt_rate => "%s Rango",
  180.    } # Do not remove this.
  181.    
  182.    # Some of the more unusual stats do not have defined vocabulary to go
  183.    # along with it. Adjust the following hash to give them names.
  184.    STAT_VOCAB ={
  185.      :hit  => "HIT", # Stat that modifies hit rate.
  186.      :eva  => "EVA", # Stat that modifies evasion rate.
  187.      :cri  => "CRI", # Stat that modifies critical rate.
  188.      :odds => "AGR", # Stat that modifies aggro rate.
  189.    } # Do not remove this.
  190.    
  191.    # These are the stats shown inside of the equip scene menu and they order
  192.    # they'll appear in. If a stat applied by a script doesn't exist, it'll be
  193.    # ignored and the next command will be shifted up by one.
  194.    #   Legal Stats:
  195.    #   :hp, :mp, :atk, :def, :spi, :res, :dex, :agi, :hit, :eva, :cri, :odds
  196.    SHOWN_STATS = [:maxhp, :maxmp, :atk, :def, :spi, :res, :dex, :agi]
  197.    
  198.    # This is the icon used for unequipping items.
  199.    UNEQUIP_ICON = 98
  200.    
  201.    # This adjusts the font size used for the equip type categories.
  202.    CATEGORY_FONT_SIZE = 16
  203.    
  204.    # This adjusts the font size used for the stat types.
  205.    STAT_FONT_SIZE = 16
  206.    
  207.    #===========================================================================
  208.    # Section II. Equip Settings
  209.    # --------------------------------------------------------------------------
  210.    # The following allows you to adjust the rules and such governing equipping
  211.    # and unequipping items. Here, you can add additional item slots, remove
  212.    # them, and even change the rules for some. To label certain armours as
  213.    # different equip types, use the <equip type: phrase> and replace it with
  214.    # the named category item within the TYPE_RULES hash.
  215.    #===========================================================================
  216.    
  217.    # This determines the order of equipment inside the equipment scene. Note
  218.    # that this does not include weapons as they're automatically the first
  219.    # piece of equipment by default.
  220.    TYPE_LIST =[
  221.      #:shield,   # Shield slot for equippable shield type armours.
  222.      #:helmet,   # Helmet slot for equippable headgear type armours.
  223.      :armour,   # Armour slot for equippable bodygear type armours.
  224.      #:cloak,    # Cloak slot for equippable mantle type armours.
  225.      :other,    # 1st Accessory slot for misc armours.
  226.      :other,    # 2nd Accessory slot for misc armours.
  227.      :other,    # 3rd Accessory slot for misc armours.
  228.    ] # Do not remove this
  229.    
  230.    # Adjust the following below to determine the ruleset adjusted for equip
  231.    # equip type following the pre-made template. Here's what each does:
  232.    #     Name - The name of the equip type. When using tag, refer to this.
  233.    #     Kind - The kind number associated with the equip type.
  234.    #   Empty? - Whether or not the equipment slot can be empty.
  235.    # Optimize - When optimizing, include this equipment type or not.
  236.    TYPE_RULES ={
  237.    # Type     => [     Name, Kind, Empty?, Optimize],
  238.      :weapon  => [ "Arma",  nil,  false,     true],
  239.       #:shield  => [ "Shield",  0,   true,     true],
  240.       #:helmet  => [ "Helmet",  1,   true,     true],
  241.      :armour  => [ "Armadura",  2,  false,     true],
  242.       :other   => [  "Accesorio",  3,   true,    false],
  243.       #:cloak   => [  "Cloak",    4,   true,     true],
  244.    } # Do not remove this.
  245.    
  246.    # This will determine the stat order at which items are optimized for each
  247.    # equipment type. If type is unlisted, it will pull from the :unlisted
  248.    # category which can also be defined here.
  249.    OPTIMIZE_SETTINGS ={ # Do not delete :unlisted from the keys.
  250.      :unlisted => [:def, :res, :maxhp, :spi, :maxmp, :agi, :atk],
  251.      :weapon   => [:atk, :spi, :maxmp, :agi, :maxhp, :def, :res],
  252.    } # Do not remove this.
  253.    
  254.    #===========================================================================
  255.    # Section III. Base Stat Settings
  256.    # --------------------------------------------------------------------------
  257.    # For those who would love to redefine the way their game calculates their
  258.    # base stats, edit the following options below and use a formula you prefer.
  259.    # Otherwise, leave this alone as they are the default settings. The settings
  260.    # below are only the MaxHP, MaxMP, ADSA, and HECO stats available. This will
  261.    # allow you to modify them without needing to alter the base scripts.
  262.    #===========================================================================
  263.    
  264.    # The following hash contains the basic stat retrieval formula. Modify it
  265.    # if you wish, but make sure they remain in quote format to work.
  266.    BASE_STAT ={
  267.      :maxhp => "actor.parameters[0, @level]",
  268.      :maxmp => "actor.parameters[1, @level]",
  269.      :atk   => "actor.parameters[2, @level]",
  270.      :def   => "actor.parameters[3, @level]",
  271.      :spi   => "actor.parameters[4, @level]",
  272.      :agi   => "actor.parameters[5, @level]",
  273.      :hit   => "95",
  274.      :eva   => "5",
  275.      :cri   => "4 + ((actor.critical_bonus) ? 4 : 0)",
  276.      :odds  => "4 - self.class.position",
  277.    } # Do not remove this.
  278.    
  279.    #===========================================================================
  280.    # Section IV. Aptitude Settings
  281.    # --------------------------------------------------------------------------
  282.    # The following allows you to adjust how much benefit and gain each class
  283.    # gains for each stat when equipping weapons and armours. For instance, a
  284.    # warrior will only benefit from 80% of an SPI boost compared to a mage.
  285.    #===========================================================================
  286.    
  287.    # Set this to true if you wish to use the aptitude system for your game.
  288.    USE_APTITUDE_SYSTEM = false
  289.    
  290.    # This hash adjusts the starting aptitude rates for each class. These
  291.    # rates determine how much of a stat bonus is applied to each individual
  292.    # stat for each piece of equipment.
  293.    APTITUDE ={ # Class 0 is the common class. Do not delete it.
  294.    # ClassID => [MaxHP, MaxMP,   ATK,   DEF,   SPI,   RES,   DEX,   AGI]
  295.            0 => [  100,   100,   100,   100,   100,   100,   100,   100],
  296.            1 => [  110,   100,   110,   100,    90,    90,   100,   110],
  297.            2 => [  120,    90,   120,   100,    80,   100,   110,   100],
  298.            3 => [   90,   110,    80,   100,   110,   120,    90,   100],
  299.            4 => [   80,   120,    80,   100,   120,   110,    90,   100],
  300.            5 => [  105,    95,   105,   100,   105,   110,    90,    90],
  301.            6 => [   95,   105,   105,   100,   110,   105,    90,    90],
  302.            7 => [  120,    80,   120,    90,    90,    80,   120,   100],
  303.            8 => [   90,   110,    90,    80,   110,    80,   120,   120],
  304.    } # Do not remove this.
  305.    
  306.    # This determines the maximum and minimum aptitudes possible. Anything
  307.    # more or anything less will be treated as the minimum or maximum.
  308.    MINIMUM_APTITUDE = 10
  309.    MAXIMUM_APTITUDE = 255
  310.    
  311.    # This will reveal all aptitude boost items for your game if your game
  312.    # has any. Set this to false and it will only reveal aptitude boosts that
  313.    # the player has.
  314.    SHOW_APT_BOOSTS = false
  315.    
  316.  end # EQUIP  
  317. end # YEM
  318.  
  319. #===============================================================================
  320. # Editting anything past this point may potentially result in causing computer
  321. # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
  322. # Therefore, edit at your own risk.
  323. #===============================================================================
  324.  
  325. module YEM
  326.  module REGEXP
  327.    module BASEITEM
  328.      
  329.      STAT_SET = /<(.*):[ ]*([\+\-]\d+)>/i
  330.      STAT_PER = /<(.*):[ ]*([\+\-]\d+)([%%])>/i
  331.      TRAITS   = /<(?:TRAITS|trait):[ ](.*)>/i
  332.      REQ_SWITCH = /<(?:REQUIRE SWITCH||require switches):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  333.      REQ_STRING = /<(?:REQUIRE|req)[ ](.*):[ ](\d+)[ ](.*)[ ](\d+)>/i
  334.      REQUIRE    = /<(?:REQUIRE|req)[ ](.*):[ ](.*)[ ](\d+)>/i
  335.      AUTOSTATES = /<(?:AUTO_STATE|auto state|auto states):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  336.      APT_GROWTH = /<(.*)[ ](?:APTITUDE|apt):[ ]([\+\-]\d+)([%%])>/i
  337.      
  338.      TWO_HAND = /<(?:2_HAND_TEXT|2 hand text):[ ](.*)>/i
  339.      EQUIP_TYPE = /<(?:EQUIP_TYPE|equip type):[ ](.*)>/i
  340.      
  341.    end # BASEITEM
  342.    module STATE
  343.      
  344.      EQUIP_CANCEL = /<(?:EQUIP_CANCEL|equip cancel):[ ](.*)>/i
  345.      
  346.    end # STATE
  347.  end # REGEXP
  348.  module EQUIP
  349.    
  350.    # Compare Parameters Processing
  351.    COMP_PARAM_PROC = {
  352.      :maxhp => Proc.new { |a, b| b.maxhp - a.maxhp },
  353.      :maxmp => Proc.new { |a, b| b.maxmp - a.maxmp },
  354.      :atk => Proc.new { |a, b| b.atk - a.atk },
  355.      :def => Proc.new { |a, b| b.def - a.def },
  356.      :spi => Proc.new { |a, b| b.spi - a.spi },
  357.      :res => Proc.new { |a, b| b.res - a.res },
  358.      :dex => Proc.new { |a, b| b.dex - a.dex },
  359.      :agi => Proc.new { |a, b| b.agi - a.agi }, }
  360.    # Obtain Parameters Processing
  361.    GET_PARAM_PROC = {
  362.      :maxhp => Proc.new { |n| n.maxhp },
  363.      :maxmp => Proc.new { |n| n.maxmp },
  364.      :atk => Proc.new { |n| n.atk },
  365.      :def => Proc.new { |n| n.def },
  366.      :spi => Proc.new { |n| n.spi },
  367.      :res => Proc.new { |n| n.res },
  368.      :dex => Proc.new { |n| n.dex },
  369.      :agi => Proc.new { |n| n.agi }, }
  370.    
  371.  end # EQUIP
  372. end # YEM
  373.  
  374. #===============================================================================
  375. # RPG::BaseItem
  376. #===============================================================================
  377.  
  378. class RPG::BaseItem
  379.  
  380.  #--------------------------------------------------------------------------
  381.  # public instance variables
  382.  #--------------------------------------------------------------------------
  383.  attr_accessor :maxhp
  384.  attr_accessor :maxmp
  385.  attr_accessor :atk
  386.  attr_accessor :def
  387.  attr_accessor :spi
  388.  attr_accessor :agi
  389.  attr_accessor :hit
  390.  attr_accessor :eva
  391.  attr_accessor :cri
  392.  attr_accessor :odds
  393.  attr_accessor :stat_per
  394.  attr_accessor :traits
  395.  attr_accessor :autostates
  396.  attr_accessor :apt_growth
  397.  attr_accessor :requirements
  398.  attr_accessor :required_switches
  399.  attr_accessor :req_variables_above
  400.  attr_accessor :req_variables_under
  401.  attr_accessor :req_weaponlvl_above
  402.  attr_accessor :req_weaponlvl_under
  403.  
  404.  #--------------------------------------------------------------------------
  405.  # common cache: yem_cache_baseitem_eo
  406.  #--------------------------------------------------------------------------
  407.  def yem_cache_baseitem_eo
  408.    return if @cached_baseitem_eo; @cached_baseitem_eo = true
  409.    @maxhp = 0; @maxmp = 0; @cri = 0; @odds = 0
  410.    @hit = 0 if @hit == nil; @eva = 0 if @eva == nil
  411.    @stat_per ={ :hp => 0, :mp => 0, :atk => 0, :def => 0, :spi => 0,
  412.      :agi => 0, :hit => 0, :eva => 0, :cri => 0, :odds => 0}
  413.    @autostates = []; @apt_growth = {}; @traits = []
  414.    @requirements = {}; @required_switches = []
  415.    @req_variables_above = {}; @req_variables_under = {}
  416.    @req_weaponlvl_above = {}; @req_weaponlvl_under = {}
  417.    
  418.    self.note.split(/[\r\n]+/).each { |line|
  419.      case line
  420.      #---
  421.      when YEM::REGEXP::BASEITEM::TRAITS
  422.        case $1.upcase
  423.        when "SUPER GUARD", "SUPER_GUARD", "SUPERGUARD"
  424.          @traits.push(:super_guard)
  425.        when "PHARMACOLOGY", "PHARMA", "ITEM BOOST", "ITEM_BOOST"
  426.          @traits.push(:pharmacology)
  427.        when "FAST ATTACK", "FAST_ATTACK", "FASTATTACK"
  428.          @traits.push(:fast_attack)
  429.        when "DUAL ATTACK", "DUALATTACK", "DUAL_ATTACK"
  430.          @traits.push(:dual_attack)
  431.        when "PREVENT_CRITICAL", "PREVENT CRITICAL", "PREVENT CRI"
  432.          @traits.push(:prevent_critical)
  433.        when "HALF MP COST", "HALF_MP_COST", "HALF MP", "HALF_MP", "HALFMP"
  434.          @traits.push(:half_mp_cost)
  435.        when "DOUBLE EXP GAIN", "DOUBLE_EXP_GAIN", "DOUBLE EXP", "DOUBLE_EXP"
  436.          @traits.push(:double_exp_gain)
  437.        when "AUTO_HP_RECOVER", "AUTO HP RECOVER", "AUTO HP", "AUTO_HP"
  438.          @traits.push(:auto_hp_recover)
  439.        when "ANTI HP REGEN", "ANTI_HP_REGEN"
  440.          @traits.push(:anti_hp_regen)
  441.        when "ANTI HP DEGEN", "ANTI_HP_DEGEN"
  442.          @traits.push(:anti_hp_degen)
  443.        when "ANTI MP REGEN", "ANTI_MP_REGEN"
  444.          @traits.push(:anti_mp_regen)
  445.        when "ANTI MP DEGEN", "ANTI_MP_DEGEN"
  446.          @traits.push(:anti_mp_degen)
  447.        else; next
  448.        end
  449.      #---
  450.      when YEM::REGEXP::BASEITEM::APT_GROWTH
  451.        case $1.upcase
  452.        when "HP","MAXHP"; @apt_growth[:hp] = $2.to_i
  453.        when "MP","MAXMP"; @apt_growth[:mp] = $2.to_i
  454.        when "ATK"; @apt_growth[:atk] = $2.to_i
  455.        when "DEF"; @apt_growth[:def] = $2.to_i
  456.        when "SPI"; @apt_growth[:spi] = $2.to_i
  457.        when "RES"; @apt_growth[:res] = $2.to_i
  458.        when "DEX"; @apt_growth[:dex] = $2.to_i
  459.        when "AGI"; @apt_growth[:agi] = $2.to_i
  460.        end
  461.      #---
  462.      when YEM::REGEXP::BASEITEM::AUTOSTATES
  463.        $1.scan(/\d+/).each { |num|
  464.        @autostates.push(num.to_i) if num.to_i > 0 }
  465.      #---
  466.      when YEM::REGEXP::BASEITEM::REQ_SWITCH
  467.        $1.scan(/\d+/).each { |num|
  468.        @required_switches.push(num.to_i) if num.to_i > 0 }
  469.        @requirements["SWITCH"] = true
  470.      #---
  471.      when YEM::REGEXP::BASEITEM::REQ_STRING
  472.        case $1.upcase
  473.        when "VARIABLE", "VAR"
  474.          text = "VARIABLE"
  475.          case $3.upcase
  476.          when "ABOVE", "AT LEAST" "OVER", "GREATER THAN"
  477.            text += " ABOVE"
  478.            @req_variables_above[$2.to_i] = $4.to_i
  479.          when "UNDER", "BELOW", "AT MOST", "LESS THAN"
  480.            text += " UNDER"
  481.            @req_variables_under[$2.to_i] = $4.to_i
  482.          else; next
  483.          end
  484.        when "WEAPON LEVEL", "MASTERY", "WEAPON LVL", "WLVL"
  485.          text = "WEAPON LEVEL"
  486.          case $3.upcase
  487.          when "ABOVE", "AT LEAST" "OVER", "GREATER THAN"
  488.            text += " ABOVE"
  489.            @req_weaponlvl_above[$2.to_i] = $4.to_i
  490.          when "UNDER", "BELOW", "AT MOST", "LESS THAN"
  491.            text += " UNDER"
  492.            @req_weaponlvl_under[$2.to_i] = $4.to_i
  493.          else; next
  494.          end
  495.        else; next
  496.        end
  497.        @requirements[text] = true
  498.      #---
  499.      when YEM::REGEXP::BASEITEM::REQUIRE
  500.        case $2.upcase
  501.        when "ABOVE", "AT LEAST" "OVER", "GREATER THAN"
  502.          text = "ABOVE"
  503.        when "UNDER", "BELOW", "AT MOST", "LESS THAN"
  504.          text = "UNDER"
  505.        else; next
  506.        end
  507.        text += " "
  508.        case $1.upcase
  509.        when "LEVEL", "LV", "LVL"
  510.          text += "LEVEL"
  511.        when "HP", "MAXHP"
  512.          text += "MAXHP"
  513.        when "MP", "MAXMP", "SP", "MAXSP"
  514.          text += "MAXMP"
  515.        when "INT", "MAG"
  516.          text += "INT"
  517.        when "AGG", "AGGRO"
  518.          text += "ODDS"
  519.        when "ATK", "DEF", "SPI", "INT", "RES", "DEX", "AGI"
  520.          next if $1.upcase == "DEX" and !$imported["DEX Stat"]
  521.          next if $1.upcase == "RES" and !$imported["RES Stat"]
  522.          text += $1.upcase
  523.        when "HIT", "EVA", "CRI", "ODDS"
  524.          text += $1.upcase
  525.        else; next
  526.        end
  527.        @requirements[text] = $3.to_i
  528.      #---
  529.      when YEM::REGEXP::BASEITEM::STAT_SET
  530.        case $1.upcase
  531.        when "HP","MAXHP"; @maxhp = $2.to_i
  532.        when "MP","MAXMP"; @maxmp = $2.to_i
  533.        when "ATK"; @atk = $2.to_i
  534.        when "DEF"; @def = $2.to_i
  535.        when "SPI"; @spi = $2.to_i
  536.        when "AGI"; @agi = $2.to_i
  537.        when "HIT"; @hit = $2.to_i
  538.        when "EVA"; @eva = $2.to_i
  539.        when "CRI"; @cri = $2.to_i
  540.        when "ODDS"; @odds = $2.to_i
  541.        end
  542.      #---
  543.      when YEM::REGEXP::BASEITEM::STAT_PER
  544.        case $1.upcase
  545.        when "HP","MAXHP"; @stat_per[:hp] = $2.to_i
  546.        when "MP","MAXMP"; @stat_per[:mp] = $2.to_i
  547.        when "ATK"; @stat_per[:atk] = $2.to_i
  548.        when "DEF"; @stat_per[:def] = $2.to_i
  549.        when "SPI"; @stat_per[:spi] = $2.to_i
  550.        when "AGI"; @stat_per[:agi] = $2.to_i
  551.        when "HIT"; @stat_per[:hit] = $2.to_i
  552.        when "EVA"; @stat_per[:eva] = $2.to_i
  553.        when "CRI"; @stat_per[:cri] = $2.to_i
  554.        when "ODDS"; @stat_per[:odds] = $2.to_i
  555.        end
  556.      #---
  557.      end
  558.    } # end self.note.split
  559.    @requirements["NONE"] = 0 if @requirements == {}
  560.  end # yem_cache_baseitem_eo
  561.  
  562.  #--------------------------------------------------------------------------
  563.  # anti-crash methods
  564.  #--------------------------------------------------------------------------
  565.  unless $imported["DEX Stat"]; def dex; return 0; end; end
  566.  unless $imported["RES Stat"]; def res; return 0; end; end
  567.  
  568. end # RPG::BaseItem
  569.  
  570. #===============================================================================
  571. # RPG::Weapon
  572. #===============================================================================
  573.  
  574. class RPG::Weapon < RPG::BaseItem
  575.  
  576.  #--------------------------------------------------------------------------
  577.  # public instance variable
  578.  #--------------------------------------------------------------------------
  579.  attr_accessor :two_hand_text
  580.  
  581.  #--------------------------------------------------------------------------
  582.  # common cache: yem_cache_weapon_eo
  583.  #--------------------------------------------------------------------------
  584.  def yem_cache_weapon_eo
  585.    return if @cached_weapon_eo; @cached_weapon_eo = true
  586.    @two_hand_text = YEM::EQUIP::VOCAB[:twohand]
  587.    
  588.    self.note.split(/[\r\n]+/).each { |line|
  589.      case line
  590.      when YEM::REGEXP::BASEITEM::TWO_HAND
  591.        @two_hand_text = $1.to_s
  592.      end
  593.    } # end self.note.split
  594.  end # yem_cache_weapon_eo
  595.  
  596. end # RPG::Weapon
  597.  
  598. #===============================================================================
  599. # RPG::Armor
  600. #===============================================================================
  601.  
  602. class RPG::Armor < RPG::BaseItem
  603.  
  604.  #--------------------------------------------------------------------------
  605.  # public instance variables
  606.  #--------------------------------------------------------------------------
  607.  attr_accessor :kind
  608.  attr_accessor :equip_type
  609.  
  610.  #--------------------------------------------------------------------------
  611.  # common cache: yem_cache_armour_eo
  612.  #--------------------------------------------------------------------------
  613.  def yem_cache_armour_eo
  614.    @equip_type = @kind
  615.    for key in YEM::EQUIP::TYPE_RULES
  616.      next if key[1][1] != @kind
  617.      @equip_type = key[1][0].upcase
  618.    end
  619.    
  620.    self.note.split(/[\r\n]+/).each { |line|
  621.      case line
  622.      when YEM::REGEXP::BASEITEM::EQUIP_TYPE
  623.        for key in YEM::EQUIP::TYPE_RULES
  624.          next if key[1][0].upcase != $1.upcase
  625.          @kind = key[1][1]; break
  626.          @equip_type = $1.upcase
  627.        end
  628.      end
  629.    } # end self.note.split
  630.  end # yem_cache_armour_eo
  631.  
  632. end # RPG::Armor
  633.  
  634. #===============================================================================
  635. # RPG::State
  636. #===============================================================================
  637.  
  638. class RPG::State
  639.  
  640.  #--------------------------------------------------------------------------
  641.  # common cache: yem_cache_state_eo
  642.  #--------------------------------------------------------------------------
  643.  def yem_cache_state_eo
  644.    @equip_cancel = []
  645.    
  646.    self.note.split(/[\r\n]+/).each { |line|
  647.      case line
  648.      when YEM::REGEXP::STATE::EQUIP_CANCEL
  649.        text = $1.to_s
  650.        @equip_cancel.push(text.upcase)
  651.      end
  652.    } # # end self.note.split
  653.  end # yem_cache_state_eo
  654.  
  655.  #--------------------------------------------------------------------------
  656.  # new method: equip_cancel
  657.  #--------------------------------------------------------------------------
  658.  def equip_cancel
  659.    yem_cache_state_eo if @equip_cancel == nil
  660.    return @equip_cancel
  661.  end
  662.  
  663. end # RPG::State
  664.  
  665. #===============================================================================
  666. # Vocab
  667. #===============================================================================
  668.  
  669. module Vocab
  670.  
  671.  #--------------------------------------------------------------------------
  672.  # self.hit
  673.  #--------------------------------------------------------------------------
  674.  def self.hit; return YEM::EQUIP::STAT_VOCAB[:hit]; end
  675.  
  676.  #--------------------------------------------------------------------------
  677.  # self.eva
  678.  #--------------------------------------------------------------------------
  679.  def self.eva; return YEM::EQUIP::STAT_VOCAB[:eva]; end
  680.  
  681.  #--------------------------------------------------------------------------
  682.  # self.cri
  683.  #--------------------------------------------------------------------------
  684.  def self.cri; return YEM::EQUIP::STAT_VOCAB[:cri]; end
  685.    
  686.  #--------------------------------------------------------------------------
  687.  # self.odds
  688.  #--------------------------------------------------------------------------
  689.  def self.odds; return YEM::EQUIP::STAT_VOCAB[:odds]; end
  690.  
  691. end # Vocab
  692.  
  693. #===============================================================================
  694. # module Icon
  695. #===============================================================================
  696. if !$imported["BattleEngineMelody"] and !$imported["IconModuleLibrary"]
  697. module Icon
  698.  
  699.  #--------------------------------------------------------------------------
  700.  # self.stat
  701.  #--------------------------------------------------------------------------
  702.  def self.stat(actor, item); return 0; end
  703.  
  704. end # Icon
  705. end # !$imported["BattleEngineMelody"] and !$imported["IconModuleLibrary"]
  706.  
  707. #===============================================================================
  708. # Scene_Title
  709. #===============================================================================
  710.  
  711. class Scene_Title < Scene_Base
  712.  
  713.  #--------------------------------------------------------------------------
  714.  # alias method: load_bt_database
  715.  #--------------------------------------------------------------------------
  716.  alias load_bt_database_eo load_bt_database unless $@
  717.  def load_bt_database
  718.    load_bt_database_eo
  719.    load_eo_cache
  720.  end
  721.  
  722.  #--------------------------------------------------------------------------
  723.  # alias method: load_database
  724.  #--------------------------------------------------------------------------
  725.  alias load_database_eo load_database unless $@
  726.  def load_database
  727.    load_database_eo
  728.    load_eo_cache
  729.  end
  730.  
  731.  #--------------------------------------------------------------------------
  732.  # new method: load_eo_cache
  733.  #--------------------------------------------------------------------------
  734.  def load_eo_cache
  735.    groups = [$data_items, $data_weapons, $data_armors]
  736.    for group in groups
  737.      for obj in group
  738.        next if obj == nil
  739.        obj.yem_cache_baseitem_eo if obj.is_a?(RPG::BaseItem)
  740.        obj.yem_cache_weapon_eo if obj.is_a?(RPG::Weapon)
  741.        obj.yem_cache_armour_eo if obj.is_a?(RPG::Armor)
  742.      end
  743.    end
  744.  end
  745.  
  746. end # Scene_Title
  747.  
  748. #===============================================================================
  749. # Game_Temp
  750. #===============================================================================
  751.  
  752. class Game_Temp
  753.  
  754.  #--------------------------------------------------------------------------
  755.  # public instance variables
  756.  #--------------------------------------------------------------------------
  757.  attr_accessor :equip_last
  758.  
  759.  #--------------------------------------------------------------------------
  760.  # new method: aptitude_items
  761.  #--------------------------------------------------------------------------
  762.  def aptitude_items
  763.    return @aptitude_items if @aptitude_items != nil
  764.    @aptitude_items = []
  765.    for item in $data_items
  766.      next if item == nil
  767.      next if item.apt_growth == {}
  768.      @aptitude_items.push(item)
  769.    end
  770.    return @aptitude_items
  771.  end
  772.  
  773. end # Game_Temp
  774.  
  775. #===============================================================================
  776. # Game_Battler
  777. #===============================================================================
  778.  
  779. class Game_Battler
  780.  
  781.  #--------------------------------------------------------------------------
  782.  # alias method: states
  783.  #--------------------------------------------------------------------------
  784.  alias states_eo states unless $@
  785.  def states
  786.    list = states_eo
  787.    list += equip_autostates if actor?
  788.    list.uniq.sort! { |state_a,state_b|
  789.      if state_a.priority != state_b.priority
  790.        state_b.priority <=> state_a.priority
  791.      else
  792.        state_a.id <=> state_b.id
  793.      end }
  794.    return list.uniq
  795.  end
  796.  
  797.  #--------------------------------------------------------------------------
  798.  # alias method: item_test
  799.  #--------------------------------------------------------------------------
  800.  alias item_test_eo item_test unless $@
  801.  def item_test(user, item)
  802.    return true if item.apt_growth != {}
  803.    return item_test_eo(user, item)
  804.  end
  805.  
  806.  #--------------------------------------------------------------------------
  807.  # alias method: item_growth_effect
  808.  #--------------------------------------------------------------------------
  809.  alias item_growth_effect_eo item_growth_effect unless $@
  810.  def item_growth_effect(user, item)
  811.    if item.apt_growth != {} and actor?
  812.      create_aptitude_bonus
  813.      for key in item.apt_growth
  814.        type = key[0]; value = key[1]
  815.        case type
  816.        when :hp, :mp, :atk, :def, :spi, :res, :dex, :agi
  817.          @bonus_apt[type] += value
  818.        else; next
  819.        end
  820.      end
  821.      purge_unequippable
  822.    end
  823.    item_growth_effect_eo(user, item)
  824.  end
  825.  
  826.  #--------------------------------------------------------------------------
  827.  # new method: traits
  828.  #--------------------------------------------------------------------------
  829.  unless # $imported["BattleEngineMelody"]
  830.  def traits
  831.    return @cache_traits if @cache_traits != nil
  832.    @cache_traits = []
  833.    for state in states; @cache_traits |= state.traits; end
  834.    if actor?
  835.      for equip in equips.compact; @cache_traits |= equip.traits; end
  836.    end
  837.    return @cache_traits
  838.  end
  839.  end # $imported["BattleEngineMelody"]
  840.  
  841. end # Game_Battler
  842.  
  843. #===============================================================================
  844. # Game_Actor
  845. #===============================================================================
  846.  
  847. class Game_Actor < Game_Battler
  848.  
  849.  #--------------------------------------------------------------------------
  850.  # alias method: setup
  851.  #--------------------------------------------------------------------------
  852.  alias setup_eo setup unless $@
  853.  def setup(actor_id)
  854.    setup_eo(actor_id)
  855.    @extra_armor_id = []
  856.    @locked_equips = []
  857.    @equip_type = nil
  858.    @bonus_apt = nil
  859.    create_aptitude_bonus
  860.    purge_unequippable
  861.  end
  862.  
  863.  #--------------------------------------------------------------------------
  864.  # overwrite method: base_maxhp
  865.  #--------------------------------------------------------------------------
  866.  def base_maxhp
  867.    n = eval(YEM::EQUIP::BASE_STAT[:maxhp])
  868.    percent = 100
  869.    for item in equips.compact
  870.      percent += aptitude(item.stat_per[:hp], :hp)
  871.    end
  872.    n *= percent / 100.0
  873.    for item in equips.compact
  874.      n += aptitude(item.maxhp, :hp)
  875.    end
  876.    return Integer(n)
  877.  end
  878.  
  879.  #--------------------------------------------------------------------------
  880.  # overwrite method: base_maxmp
  881.  #--------------------------------------------------------------------------
  882.  def base_maxmp
  883.    n = eval(YEM::EQUIP::BASE_STAT[:maxmp])
  884.    percent = 100
  885.    for item in equips.compact
  886.      percent += aptitude(item.stat_per[:mp], :mp)
  887.    end
  888.    n *= percent / 100.0
  889.    for item in equips.compact
  890.      n += aptitude(item.maxmp, :mp)
  891.    end
  892.    return Integer(n)
  893.  end
  894.  
  895.  #--------------------------------------------------------------------------
  896.  # overwrite method: base_atk
  897.  #--------------------------------------------------------------------------
  898.  def base_atk
  899.    n = eval(YEM::EQUIP::BASE_STAT[:atk])
  900.    percent = 100
  901.    for item in equips.compact
  902.      percent += aptitude(item.stat_per[:atk], :atk)
  903.    end
  904.    n *= percent / 100.0
  905.    for item in equips.compact
  906.      n += aptitude(item.atk, :atk)
  907.    end
  908.    return Integer(n)
  909.  end
  910.  
  911.  #--------------------------------------------------------------------------
  912.  # overwrite method: base_def
  913.  #--------------------------------------------------------------------------
  914.  def base_def
  915.    n = eval(YEM::EQUIP::BASE_STAT[:def])
  916.    percent = 100
  917.    for item in equips.compact
  918.      percent += aptitude(item.stat_per[:def], :def)
  919.    end
  920.    n *= percent / 100.0
  921.    for item in equips.compact
  922.      n += aptitude(item.def, :def)
  923.    end
  924.    return Integer(n)
  925.  end
  926.  
  927.  #--------------------------------------------------------------------------
  928.  # overwrite method: base_spi
  929.  #--------------------------------------------------------------------------
  930.  def base_spi
  931.    n = eval(YEM::EQUIP::BASE_STAT[:spi])
  932.    percent = 100
  933.    for item in equips.compact
  934.      percent += aptitude(item.stat_per[:spi], :spi)
  935.    end
  936.    n *= percent / 100.0
  937.    for item in equips.compact
  938.      n += aptitude(item.spi, :spi)
  939.    end
  940.    return Integer(n)
  941.  end
  942.  
  943.  #--------------------------------------------------------------------------
  944.  # overwrite method: base_agi
  945.  #--------------------------------------------------------------------------
  946.  def base_agi
  947.    n = eval(YEM::EQUIP::BASE_STAT[:agi])
  948.    percent = 100
  949.    for item in equips.compact
  950.      percent += aptitude(item.stat_per[:agi], :agi)
  951.    end
  952.    n *= percent / 100.0
  953.    for item in equips.compact
  954.      n += aptitude(item.agi, :agi)
  955.    end
  956.    return Integer(n)
  957.  end
  958.  
  959.  #--------------------------------------------------------------------------
  960.  # overwrite method: hit
  961.  #--------------------------------------------------------------------------
  962.  def hit
  963.    n = eval(YEM::EQUIP::BASE_STAT[:hit])
  964.    if two_swords_style
  965.      n1 = weapons[0] == nil ? n : weapons[0].hit
  966.      n2 = weapons[1] == nil ? n : weapons[1].hit
  967.      n = [n1, n2].min
  968.    else
  969.      n = weapons[0] == nil ? n : weapons[0].hit
  970.    end
  971.    percent = 100
  972.    for item in equips.compact
  973.      percent += item.stat_per[:hit]
  974.    end
  975.    n *= percent / 100.0
  976.    for item in armors.compact
  977.      n += item.hit
  978.    end
  979.    return Integer(n)
  980.  end
  981.  
  982.  #--------------------------------------------------------------------------
  983.  # overwrite method: eva
  984.  #--------------------------------------------------------------------------
  985.  def eva
  986.    n = eval(YEM::EQUIP::BASE_STAT[:eva])
  987.    for item in equips.compact
  988.      n += item.eva
  989.    end
  990.    percent = 100
  991.    for item in equips.compact
  992.      percent += item.stat_per[:eva]
  993.    end
  994.    n *= percent / 100.0
  995.    return Integer(n)
  996.  end
  997.  
  998.  #--------------------------------------------------------------------------
  999.  # overwrite method: cri
  1000.  #--------------------------------------------------------------------------
  1001.  def cri
  1002.    n = eval(YEM::EQUIP::BASE_STAT[:cri])
  1003.    for weapon in weapons.compact
  1004.      n += 4 if weapon.critical_bonus
  1005.    end
  1006.    percent = 100
  1007.    for item in equips.compact
  1008.      percent += item.stat_per[:cri]
  1009.    end
  1010.    n *= percent / 100.0
  1011.    for item in equips.compact
  1012.      n += item.cri
  1013.    end
  1014.    return Integer(n)
  1015.  end
  1016.  
  1017.  #--------------------------------------------------------------------------
  1018.  # overwrite method: odds
  1019.  #--------------------------------------------------------------------------
  1020.  def odds
  1021.    n = $imported["AggroAI"] ? base_aggro : eval(YEM::EQUIP::BASE_STAT[:odds])
  1022.    for item in equips.compact
  1023.      n += item.odds
  1024.    end
  1025.    percent = 100
  1026.    for item in equips.compact
  1027.      percent += item.stat_per[:odds]
  1028.    end
  1029.    n *= percent / 100.0
  1030.    return [Integer(n), 1].max
  1031.  end
  1032.  
  1033.  #--------------------------------------------------------------------------
  1034.  # new method: aptitude
  1035.  #--------------------------------------------------------------------------
  1036.  def aptitude(n, type)
  1037.    return n unless YEM::EQUIP::USE_APTITUDE_SYSTEM
  1038.    multiplier = aptitude_rate(type)
  1039.    n = n * multiplier / 100
  1040.    return n
  1041.  end
  1042.  
  1043.  #--------------------------------------------------------------------------
  1044.  # new method: aptitude_rate
  1045.  #--------------------------------------------------------------------------
  1046.  def aptitude_rate(type)
  1047.    if YEM::EQUIP::APTITUDE.include?(@class_id)
  1048.      array = YEM::EQUIP::APTITUDE[@class_id]
  1049.    else
  1050.      array = YEM::EQUIP::APTITUDE[0]
  1051.    end
  1052.    type = :hp if type == :maxhp
  1053.    type = :mp if type == :maxmp
  1054.    create_aptitude_bonus
  1055.    multiplier = 0
  1056.    case type
  1057.    when :hp;  multiplier = array[0]
  1058.    when :mp;  multiplier = array[1]
  1059.    when :atk; multiplier = array[2]
  1060.    when :def; multiplier = array[3]
  1061.    when :spi; multiplier = array[4]
  1062.    when :res; multiplier = array[5]
  1063.    when :dex; multiplier = array[6]
  1064.    when :agi; multiplier = array[7]
  1065.    end
  1066.    multiplier += @bonus_apt[type]
  1067.    multiplier = [multiplier, YEM::EQUIP::MINIMUM_APTITUDE].max
  1068.    multiplier = [multiplier, YEM::EQUIP::MAXIMUM_APTITUDE].min
  1069.    return multiplier
  1070.  end
  1071.  
  1072.  #--------------------------------------------------------------------------
  1073.  # new method: reset_aptitudes
  1074.  #--------------------------------------------------------------------------
  1075.  def reset_aptitudes
  1076.    @bonus_apt = nil
  1077.    create_aptitude_bonus
  1078.  end
  1079.  
  1080.  #--------------------------------------------------------------------------
  1081.  # new method: create_aptitude_bonus
  1082.  #--------------------------------------------------------------------------
  1083.  def create_aptitude_bonus
  1084.    @bonus_apt = {} if @bonus_apt == nil
  1085.    @bonus_apt[:hp]  = 0 if @bonus_apt[:hp] == nil
  1086.    @bonus_apt[:mp]  = 0 if @bonus_apt[:mp] == nil
  1087.    @bonus_apt[:atk] = 0 if @bonus_apt[:atk] == nil
  1088.    @bonus_apt[:def] = 0 if @bonus_apt[:def] == nil
  1089.    @bonus_apt[:spi] = 0 if @bonus_apt[:spi] == nil
  1090.    @bonus_apt[:res] = 0 if @bonus_apt[:res] == nil
  1091.    @bonus_apt[:dex] = 0 if @bonus_apt[:dex] == nil
  1092.    @bonus_apt[:agi] = 0 if @bonus_apt[:agi] == nil
  1093.  end
  1094.  
  1095.  #--------------------------------------------------------------------------
  1096.  # new method: equip_type
  1097.  #--------------------------------------------------------------------------
  1098.  def equip_type
  1099.    if @equip_type.is_a?(Array)
  1100.      return @equip_type
  1101.    else
  1102.      return YEM::EQUIP::TYPE_LIST
  1103.    end
  1104.  end
  1105.  
  1106.  #--------------------------------------------------------------------------
  1107.  # new method: equip_type=
  1108.  #--------------------------------------------------------------------------
  1109.  def equip_type=(array)
  1110.    if array == nil
  1111.      @equip_type = nil
  1112.      purge_unequippable
  1113.      return
  1114.    end
  1115.    return unless array.is_a?(Array)
  1116.    array.delete(:weapon)
  1117.    @equip_type = YEM::EQUIP::TYPE_LIST if @equip_type == nil
  1118.    if @equip_type.size > array.size
  1119.      for i in array.size..@equip_type.size; change_equip(i, nil); end
  1120.    end
  1121.    @equip_type = array
  1122.    purge_unequippable
  1123.  end
  1124.  
  1125.  #--------------------------------------------------------------------------
  1126.  # new method: add_equip_type
  1127.  #--------------------------------------------------------------------------
  1128.  def add_equip_type(type)
  1129.    return unless YEM::EQUIP::TYPE_RULES.include?(type)
  1130.    return if type == :weapon
  1131.    @equip_type = YEM::EQUIP::TYPE_LIST if @equip_type == nil
  1132.    @equip_type.push(type)
  1133.    purge_unequippable
  1134.  end
  1135.  
  1136.  #--------------------------------------------------------------------------
  1137.  # new method: delete_last_equip_type
  1138.  #--------------------------------------------------------------------------
  1139.  def delete_last_equip_type
  1140.    @equip_type = YEM::EQUIP::TYPE_LIST if @equip_type == nil
  1141.    return if @equip_type.size <= 0
  1142.    change_equip(@equip_type.size, nil)
  1143.    @equip_type.pop
  1144.  end
  1145.  
  1146.  #--------------------------------------------------------------------------
  1147.  # new method: armor_number
  1148.  #--------------------------------------------------------------------------
  1149.  def armor_number
  1150.    return equip_type.size
  1151.  end
  1152.  
  1153.  #--------------------------------------------------------------------------
  1154.  # new method: extra_armor_number
  1155.  #--------------------------------------------------------------------------
  1156.  def extra_armor_number
  1157.    return [armor_number - 4, 0].max
  1158.  end
  1159.  
  1160.  #--------------------------------------------------------------------------
  1161.  # new method: extra_armor_id
  1162.  #--------------------------------------------------------------------------
  1163.  def extra_armor_id
  1164.    @extra_armor_id = [] if @extra_armor_id == nil
  1165.    return @extra_armor_id
  1166.  end
  1167.  
  1168.  #--------------------------------------------------------------------------
  1169.  # alias method: armors
  1170.  #--------------------------------------------------------------------------
  1171.  alias armors_eo armors unless $@
  1172.  def armors
  1173.    result = armors_eo
  1174.    extra_armor_number.times { |i|
  1175.      armor_id = extra_armor_id[i]
  1176.      result.push(armor_id == nil ? nil : $data_armors[armor_id]) }
  1177.    return result
  1178.  end
  1179.  
  1180.  #--------------------------------------------------------------------------
  1181.  # alias method: change_equip
  1182.  #--------------------------------------------------------------------------
  1183.  alias change_equip_eo change_equip unless $@
  1184.  def change_equip(equip_type, item, test = false)
  1185.    change_equip_eo(equip_type, item, test)
  1186.    if extra_armor_number > 0
  1187.      item_id = item == nil ? 0 : item.id
  1188.      case equip_type
  1189.      when 5..armor_number
  1190.        @extra_armor_id = [] if @extra_armor_id == nil
  1191.        @extra_armor_id[equip_type - 5] = item_id
  1192.      end
  1193.    end
  1194.    purge_unequippable(test) unless @purge_on
  1195.  end
  1196.  
  1197.  #--------------------------------------------------------------------------
  1198.  # alias method: equippable?
  1199.  #--------------------------------------------------------------------------
  1200.  alias equippable_eo equippable? unless $@
  1201.  def equippable?(item)
  1202.    return false unless equippable_eo(item)
  1203.    for key in item.requirements
  1204.      requirement = key[0]; value = key[1]
  1205.      case requirement
  1206.      when "NONE"; break
  1207.      #---
  1208.      when "ABOVE LEVEL"; return false unless self.level >= value
  1209.      when "ABOVE MAXHP"; return false unless self.maxhp >= value
  1210.      when "ABOVE MAXMP"; return false unless self.maxmp >= value
  1211.      when "ABOVE ATK";   return false unless self.atk >= value
  1212.      when "ABOVE DEF";   return false unless self.def >= value
  1213.      when "ABOVE SPI";   return false unless self.spi >= value
  1214.      when "ABOVE RES";   return false unless self.res >= value
  1215.      when "ABOVE DEX";   return false unless self.dex >= value
  1216.      when "ABOVE AGI";   return false unless self.agi >= value
  1217.      when "ABOVE HIT";   return false unless self.hit >= value
  1218.      when "ABOVE EVA";   return false unless self.eva >= value
  1219.      when "ABOVE DUR";   return false unless self.max_dur >= value
  1220.      when "ABOVE LUK";   return false unless self.luk >= value
  1221.      when "ABOVE CRI";   return false unless self.cri >= value
  1222.      when "ABOVE ODDS";  return false unless self.odds >= value
  1223.      #---
  1224.      when "UNDER LEVEL"; return false unless self.level <= value
  1225.      when "UNDER MAXHP"; return false unless self.maxhp <= value
  1226.      when "UNDER MAXMP"; return false unless self.maxmp <= value
  1227.      when "UNDER ATK";   return false unless self.atk <= value
  1228.      when "UNDER DEF";   return false unless self.def <= value
  1229.      when "UNDER SPI";   return false unless self.spi <= value
  1230.      when "UNDER RES";   return false unless self.res <= value
  1231.      when "UNDER DEX";   return false unless self.dex <= value
  1232.      when "UNDER AGI";   return false unless self.agi <= value
  1233.      when "UNDER HIT";   return false unless self.hit <= value
  1234.      when "UNDER EVA";   return false unless self.eva <= value
  1235.      when "UNDER DUR";   return false unless self.max_dur <= value
  1236.      when "UNDER LUK";   return false unless self.luk <= value
  1237.      when "UNDER CRI";   return false unless self.cri <= value
  1238.      when "UNDER ODDS";  return false unless self.odds <= value
  1239.      #---
  1240.      when "SWITCH"
  1241.        for switch_id in item.required_switches
  1242.          return false unless $game_switches[switch_id]
  1243.        end
  1244.      #---
  1245.      when "VARIABLE ABOVE"
  1246.        for key in item.req_variables_above
  1247.          variable = key[0]; variable_value = key[1]
  1248.          return false unless $game_variables[variable] >= variable_value
  1249.        end
  1250.      when "VARIABLE UNDER"
  1251.        for key in item.req_variables_under
  1252.          variable = key[0]; variable_value = key[1]
  1253.          return false unless $game_variables[variable] <= variable_value
  1254.        end
  1255.      #---
  1256.      end
  1257.    end
  1258.    return true
  1259.  end
  1260.  
  1261.  #--------------------------------------------------------------------------
  1262.  # new method: purge_unequippable
  1263.  #--------------------------------------------------------------------------
  1264.  def purge_unequippable(test = false)
  1265.    return if $game_temp.in_battle
  1266.    @purge_on = true
  1267.    for i in 0..4
  1268.      change_equip(i, nil, test) unless equippable?(equips[i])
  1269.      if equips[i].is_a?(RPG::Armor)
  1270.        type = equip_type[i-1]
  1271.        if equips[i].kind != YEM::EQUIP::TYPE_RULES[type][1]
  1272.          change_equip(i, nil, test)
  1273.        end
  1274.      end
  1275.    end
  1276.    if extra_armor_number != 0
  1277.      for i in 5..armor_number
  1278.        change_equip(i, nil, test) unless equippable?(equips[i])
  1279.        if equips[i].is_a?(RPG::Armor)
  1280.          type = equip_type[i-1]
  1281.          if equips[i].kind != YEM::EQUIP::TYPE_RULES[type][1]
  1282.            change_equip(i, nil, test)
  1283.          end
  1284.        end
  1285.      end
  1286.    end
  1287.    @purge_on = false
  1288.  end
  1289.  
  1290.  #--------------------------------------------------------------------------
  1291.  # alias method: discard_equip
  1292.  #--------------------------------------------------------------------------
  1293.  alias discard_equip_eo discard_equip unless $@
  1294.  def discard_equip(item)
  1295.    last_armours = [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
  1296.    discard_equip_eo(item)
  1297.    current_armours = [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
  1298.    return unless item.is_a?(RPG::Armor)
  1299.    return if last_armours != current_armours
  1300.    extra_armor_number.times { |i|
  1301.      if extra_armor_id[i] == item.id
  1302.        @extra_armor_id[i] = 0
  1303.        break
  1304.      end }
  1305.  end
  1306.  
  1307.  #--------------------------------------------------------------------------
  1308.  # alias method: class_id=
  1309.  #--------------------------------------------------------------------------
  1310.  alias class_id_eo class_id= unless $@
  1311.  def class_id=(class_id)
  1312.    class_id_eo(class_id)
  1313.    return if extra_armor_number == 0
  1314.    for i in 5..armor_number
  1315.      change_equip(i, nil) unless equippable?(equips[i])
  1316.    end
  1317.  end
  1318.  
  1319.  #--------------------------------------------------------------------------
  1320.  # new method: restore_equip
  1321.  #--------------------------------------------------------------------------
  1322.  def restore_equip
  1323.    return if @last_equip_type == equip_type
  1324.    last_equips = equips
  1325.    last_hp = self.hp
  1326.    last_mp = self.mp
  1327.    last_equips.each_index { |i| change_equip(i, nil) }
  1328.    last_equips.compact.each { |item| equip_legal_slot(item) }
  1329.    self.hp = last_hp
  1330.    self.mp = last_mp
  1331.    @last_equip_type = equip_type.clone
  1332.    Graphics.frame_reset
  1333.  end
  1334.  
  1335.  #--------------------------------------------------------------------------
  1336.  # new method: equip_legal_slot
  1337.  #--------------------------------------------------------------------------
  1338.  def equip_legal_slot(item)
  1339.    if item.is_a?(RPG::Weapon)
  1340.      if @weapon_id == 0
  1341.        change_equip(0, item)
  1342.      elsif two_swords_style and @armor1_id == 0
  1343.        change_equip(1, item)
  1344.      end
  1345.    elsif item.is_a?(RPG::Armor)
  1346.      type = YEM::EQUIP::TYPE_RULES[equip_type[0]][1]
  1347.      if !two_swords_style and item.kind == type and @armor1_id == 0
  1348.        change_equip(1, item)
  1349.      else
  1350.        list = [-1, @armor2_id, @armor3_id, @armor4_id]
  1351.        list += extra_armor_id
  1352.        equip_type.each_with_index { |kind, i|
  1353.          if kind == item.kind and list[i] == 0
  1354.            change_equip(i + 1, item)
  1355.            break
  1356.          end }
  1357.      end
  1358.    end
  1359.  end
  1360.  
  1361.  #--------------------------------------------------------------------------
  1362.  # alias method: super_guard
  1363.  #--------------------------------------------------------------------------
  1364.  alias super_guard_eo super_guard unless $@
  1365.  def super_guard
  1366.    return true if traits.include?(:super_guard)
  1367.    return super_guard_eo
  1368.  end
  1369.  
  1370.  #--------------------------------------------------------------------------
  1371.  # alias method: pharmacology
  1372.  #--------------------------------------------------------------------------
  1373.  alias pharmacology_eo pharmacology unless $@
  1374.  def pharmacology
  1375.    return true if traits.include?(:pharmacology)
  1376.    return pharmacology_eo
  1377.  end
  1378.  
  1379.  #--------------------------------------------------------------------------
  1380.  # alias method: fast_attack
  1381.  #--------------------------------------------------------------------------
  1382.  alias fast_attack_eo fast_attack unless $@
  1383.  def fast_attack
  1384.    return true if traits.include?(:fast_attack)
  1385.    return fast_attack_eo
  1386.  end
  1387.  
  1388.  #--------------------------------------------------------------------------
  1389.  # alias method: dual_attack
  1390.  #--------------------------------------------------------------------------
  1391.  alias dual_attack_eo dual_attack unless $@
  1392.  def dual_attack
  1393.    return true if traits.include?(:dual_attack)
  1394.    return dual_attack_eo
  1395.  end
  1396.  
  1397.  #--------------------------------------------------------------------------
  1398.  # alias method: prevent_critical
  1399.  #--------------------------------------------------------------------------
  1400.  alias prevent_critical_eo prevent_critical unless $@
  1401.  def prevent_critical
  1402.    return true if traits.include?(:prevent_critical)
  1403.    return prevent_critical_eo
  1404.  end
  1405.  
  1406.  #--------------------------------------------------------------------------
  1407.  # alias method: half_mp_cost
  1408.  #--------------------------------------------------------------------------
  1409.  alias half_mp_cost_eo half_mp_cost unless $@
  1410.  def half_mp_cost
  1411.    return true if traits.include?(:half_mp_cost)
  1412.    return half_mp_cost_eo
  1413.  end
  1414.  
  1415.  #--------------------------------------------------------------------------
  1416.  # alias method: double_exp_gain
  1417.  #--------------------------------------------------------------------------
  1418.  alias double_exp_gain_eo double_exp_gain unless $@
  1419.  def double_exp_gain
  1420.    return true if traits.include?(:double_exp_gain)
  1421.    return double_exp_gain_eo
  1422.  end
  1423.  
  1424.  #--------------------------------------------------------------------------
  1425.  # alias method: auto_hp_recover
  1426.  #--------------------------------------------------------------------------
  1427.  alias auto_hp_recover_eo auto_hp_recover unless $@
  1428.  def auto_hp_recover
  1429.    return true if traits.include?(:auto_hp_recover)
  1430.    return auto_hp_recover_eo
  1431.  end
  1432.  
  1433.  #--------------------------------------------------------------------------
  1434.  # new method: equip_autostates
  1435.  #--------------------------------------------------------------------------
  1436.  def equip_autostates
  1437.    result = []
  1438.    for equip in equips.compact
  1439.      for state_id in equip.autostates
  1440.        state = $data_states[state_id]
  1441.        next if state == nil
  1442.        result.push(state)
  1443.      end
  1444.    end
  1445.    return result
  1446.  end
  1447.  
  1448.  #--------------------------------------------------------------------------
  1449.  # new method: locked_equips
  1450.  #--------------------------------------------------------------------------
  1451.  def locked_equips
  1452.    @locked_equips = [] if @locked_equips == nil
  1453.    return @locked_equips
  1454.  end
  1455.  
  1456.  #--------------------------------------------------------------------------
  1457.  # new method: lock_equip
  1458.  #--------------------------------------------------------------------------
  1459.  def lock_equip(slot)
  1460.    @locked_equips = [] if @locked_equips == nil
  1461.    @locked_equips += [slot]
  1462.  end
  1463.  
  1464.  #--------------------------------------------------------------------------
  1465.  # new method: unlock_equip
  1466.  #--------------------------------------------------------------------------
  1467.  def unlock_equip(slot)
  1468.    @locked_equips = [] if @locked_equips == nil
  1469.    @locked_equips -= [slot]
  1470.  end
  1471.  
  1472. end # Game_Actor
  1473.  
  1474. #===============================================================================
  1475. # Game_Party
  1476. #===============================================================================
  1477.  
  1478. class Game_Party < Game_Unit
  1479.  
  1480.  #--------------------------------------------------------------------------
  1481.  # new method: items_only
  1482.  #--------------------------------------------------------------------------
  1483.  def items_only
  1484.    result = []
  1485.    for i in @items.keys.sort
  1486.      result.push($data_items[i]) if @items[i] > 0
  1487.    end
  1488.    return result
  1489.  end
  1490.  
  1491.  #--------------------------------------------------------------------------
  1492.  # new method: equip_weapons
  1493.  #--------------------------------------------------------------------------
  1494.  def equip_weapons
  1495.    result = []
  1496.    for i in @weapons.keys.sort
  1497.      result.push($data_weapons[i]) if @weapons[i] > 0
  1498.    end
  1499.    return result
  1500.  end
  1501.  
  1502.  #--------------------------------------------------------------------------
  1503.  # new method: equip_armours
  1504.  #--------------------------------------------------------------------------
  1505.  def equip_armours(type = nil)
  1506.    result = []
  1507.    for i in @armors.keys.sort
  1508.      armour = $data_armors[i]
  1509.      result.push(armour) if @armors[i] > 0
  1510.    end
  1511.    return result
  1512.  end
  1513.  
  1514. end # Game_Party
  1515.  
  1516. #===============================================================================
  1517. # Window_Command_Centered
  1518. #===============================================================================
  1519.  
  1520. class Window_Command_Centered < Window_Command
  1521.  
  1522.  #--------------------------------------------------------------------------
  1523.  # draw_item
  1524.  #--------------------------------------------------------------------------
  1525.  def draw_item(index, enabled = true)
  1526.    rect = item_rect(index)
  1527.    rect.x += 4
  1528.    rect.width -= 8#8 numero de armas
  1529.    self.contents.clear_rect(rect)
  1530.    self.contents.font.color = normal_color
  1531.    self.contents.font.color.alpha = enabled ? 255 : 128
  1532.    self.contents.draw_text(rect, @commands[index], 1)
  1533.  end
  1534.  
  1535. end # Window_Command_Centered
  1536.  
  1537. #===============================================================================
  1538. # Window_ShopStatus
  1539. #===============================================================================
  1540.  
  1541. class Window_ShopStatus < Window_Base
  1542.  
  1543.  #--------------------------------------------------------------------------
  1544.  # draw_actor_parameter_change
  1545.  #--------------------------------------------------------------------------
  1546.  def draw_actor_parameter_change(actor, x, y)
  1547.    return if @item.is_a?(RPG::Item)
  1548.    enabled = actor.equippable?(@item)
  1549.    self.contents.font.color = normal_color
  1550.    self.contents.font.color.alpha = enabled ? 255 : 128
  1551.    self.contents.draw_text(x, y, 200, WLH, actor.name)
  1552.    if @item.is_a?(RPG::Weapon)
  1553.      item1 = weaker_weapon(actor)
  1554.    elsif actor.two_swords_style and @item.kind == 0
  1555.      item1 = nil
  1556.    else
  1557.      item1 = actor.equips[1 + @item.kind]
  1558.    end
  1559.    if enabled
  1560.      if @item.is_a?(RPG::Weapon)
  1561.        atk1 = item1 == nil ? 0 : actor.aptitude(item1.atk, :atk)
  1562.        atk2 = @item == nil ? 0 : actor.aptitude(@item.atk, :atk)
  1563.        change = atk2 - atk1
  1564.      else
  1565.        def1 = item1 == nil ? 0 : actor.aptitude(item1.def, :def)
  1566.        def2 = @item == nil ? 0 : actor.aptitude(@item.def, :def)
  1567.        change = def2 - def1
  1568.      end
  1569.      self.contents.draw_text(x, y, 200, WLH, sprintf("%+d", change), 2)
  1570.    end
  1571.    draw_item_name(item1, x, y + WLH, enabled)
  1572.  end
  1573.  
  1574. end # Window_ShopStatus
  1575.  
  1576. #===============================================================================
  1577. # Window_Equip_Actor
  1578. #===============================================================================
  1579.  
  1580. class Window_Equip_Actor < Window_Base
  1581.  
  1582.  #--------------------------------------------------------------------------
  1583.  # initialize
  1584.  #--------------------------------------------------------------------------
  1585.  def initialize(actor)
  1586.    super(160, 0, Graphics.width - 160, 128)
  1587.    @actor = actor
  1588.    refresh(0)
  1589.  end
  1590.  
  1591.  #--------------------------------------------------------------------------
  1592.  # actor=
  1593.  #--------------------------------------------------------------------------
  1594.  def actor=(new_actor)
  1595.    @actor = new_actor
  1596.    refresh($scene.equip_window.index)
  1597.  end
  1598.  
  1599.  #--------------------------------------------------------------------------
  1600.  # refresh
  1601.  #--------------------------------------------------------------------------
  1602.  def refresh(type = nil)
  1603.    self.contents.clear
  1604.    @type = type
  1605.    draw_actor_face(@actor, 0, 0, size = 96)
  1606.    x = 104
  1607.    y = 0
  1608.    self.contents.font.color = normal_color
  1609.    draw_actor_name(@actor, x, y)
  1610.    draw_actor_class(@actor, x + 120, y)
  1611.    draw_actor_level(@actor, x, y + WLH)
  1612.    draw_actor_autostate(@actor, x + 120, y + WLH)
  1613.    return if @type == nil
  1614.    self.contents.font.color = system_color
  1615.    if @type == 0 and @actor.weapons[0] != nil and @actor.weapons[0].two_handed
  1616.      text = @actor.weapons[0].two_hand_text
  1617.    elsif @type == 0
  1618.      text = YEM::EQUIP::TYPE_RULES[:weapon][0]
  1619.    elsif @type == 1 and @actor.two_swords_style
  1620.      text = YEM::EQUIP::TYPE_RULES[:weapon][0]
  1621.    else
  1622.      type = @actor.equip_type[@type-1]
  1623.      return if YEM::EQUIP::TYPE_RULES[type] == nil
  1624.      text = YEM::EQUIP::TYPE_RULES[type][0]
  1625.    end
  1626.    self.contents.draw_text(x, y + WLH*2, 76, WLH, text, 0)
  1627.    self.contents.draw_text(x, y + WLH*3, 20, WLH, ">", 1)
  1628.    self.contents.font.color = normal_color
  1629.    item = @actor.equips[@type]
  1630.    if item == nil
  1631.      text = YEM::EQUIP::VOCAB[:noequip]
  1632.      self.contents.font.color.alpha = 128
  1633.      self.contents.draw_text(x+20, y + WLH*3, 196, WLH, text)
  1634.    else
  1635.      draw_item_name(item, x+20, y + WLH*3)
  1636.    end
  1637.  end
  1638.  
  1639.  #--------------------------------------------------------------------------
  1640.  # new method: draw_actor_autostate
  1641.  #--------------------------------------------------------------------------
  1642.  def draw_actor_autostate(actor, x, y, width = 96)
  1643.    count = 0
  1644.    for state in actor.equip_autostates
  1645.      next if state.icon_index == 0
  1646.      next if $imported["CoreFixesUpgradesMelody"] and state.hide_state
  1647.      draw_icon(state.icon_index, x + 24 * count, y)
  1648.      count += 1
  1649.      break if (24 * count > width - 24)
  1650.    end
  1651.  end
  1652.  
  1653. end # Window_Equip_Actor
  1654.  
  1655. #===============================================================================
  1656. # Window_Equip
  1657. #===============================================================================
  1658.  
  1659. class Window_Equip < Window_Selectable
  1660.  
  1661.  #--------------------------------------------------------------------------
  1662.  # overwrite method: initialize
  1663.  #--------------------------------------------------------------------------
  1664.  def initialize(x, y, actor)
  1665.    super(x, y, Graphics.width - 240, Graphics.height - y)
  1666.    self.active = false
  1667.    self.index = 0
  1668.    @actor = actor
  1669.    refresh
  1670.  end
  1671.  
  1672.  #--------------------------------------------------------------------------
  1673.  # actor=
  1674.  #--------------------------------------------------------------------------
  1675.  def actor=(new_actor)
  1676.    @actor = new_actor
  1677.    refresh
  1678.  end
  1679.  
  1680.  #--------------------------------------------------------------------------
  1681.  # overwrite method: refresh
  1682.  #--------------------------------------------------------------------------
  1683.  def refresh
  1684.    @data = @actor.equips.clone
  1685.    @item_max = (@actor.equip_type.size+1)
  1686.    self.index = [@item_max-1, self.index].min
  1687.    create_contents
  1688.    self.contents.font.color = system_color
  1689.    draw_equipment_category
  1690.    draw_equipment_items
  1691.  end
  1692.  
  1693.  #--------------------------------------------------------------------------
  1694.  # new method: draw_equipment_category
  1695.  #--------------------------------------------------------------------------
  1696.  def draw_equipment_category
  1697.    self.contents.font.size = YEM::EQUIP::CATEGORY_FONT_SIZE
  1698.    dy = 0
  1699.    for i in 0..(@actor.equip_type.size)
  1700.      self.contents.font.color = system_color
  1701.      if i == 0 and @actor.weapons[0] != nil and @actor.weapons[0].two_handed
  1702.        text = @actor.weapons[0].two_hand_text
  1703.      elsif i == 0
  1704.        text = YEM::EQUIP::TYPE_RULES[:weapon][0]
  1705.      elsif i == 1 and @actor.two_swords_style
  1706.        text = YEM::EQUIP::TYPE_RULES[:weapon][0]
  1707.      else
  1708.        type = @actor.equip_type[i-1]
  1709.        text = YEM::EQUIP::TYPE_RULES[type][0]
  1710.      end
  1711.      self.contents.draw_text(4, dy, 76, WLH, text, 1)
  1712.      dy += WLH
  1713.    end
  1714.  end
  1715.  
  1716.  #--------------------------------------------------------------------------
  1717.  # new method: draw_equipment_items
  1718.  #--------------------------------------------------------------------------
  1719.  def draw_equipment_items
  1720.    self.contents.font.size = Font.default_size
  1721.    self.contents.font.color = normal_color; dy = 0; dx = 76
  1722.    for i in 0..(@actor.equip_type.size)
  1723.      self.contents.font.color = normal_color
  1724.      item = @data[i]
  1725.      if item == nil
  1726.        text = YEM::EQUIP::VOCAB[:noequip]
  1727.        self.contents.font.color.alpha = 128
  1728.        self.contents.draw_text(dx, dy, 196, WLH, text)
  1729.      else
  1730.        draw_item_name(item, dx, dy)
  1731.      end
  1732.      dy += WLH
  1733.    end
  1734.  end
  1735.  
  1736.  #--------------------------------------------------------------------------
  1737.  # new method: equip_changable?
  1738.  #--------------------------------------------------------------------------
  1739.  def equip_changable?(index)
  1740.    if index == 0 or (index == 1 and @actor.two_swords_style)
  1741.      type = :weapon
  1742.    else
  1743.      type = @actor.equip_type[index-1]
  1744.    end
  1745.    return true
  1746.  end
  1747.  
  1748.  #--------------------------------------------------------------------------
  1749.  # new method: equip_type
  1750.  #--------------------------------------------------------------------------
  1751.  def equip_type
  1752.    if self.index == 0 or (self.index == 1 and @actor.two_swords_style)
  1753.      return :weapon
  1754.    else
  1755.      return @actor.equip_type[self.index-1]
  1756.    end
  1757.  end
  1758.  
  1759. end # Window_Equip
  1760.  
  1761. #===============================================================================
  1762. # Window_Equip_Item
  1763. #===============================================================================
  1764.  
  1765. class Window_Equip_Item < Window_Selectable
  1766.  
  1767.  #--------------------------------------------------------------------------
  1768.  # initialize
  1769.  #--------------------------------------------------------------------------
  1770.  def initialize(window, actor)
  1771.    super(window.x, window.y, window.width, window.height)
  1772.    self.active = false
  1773.    self.index = 0
  1774.    @actor = actor
  1775.    refresh(:weapon)
  1776.  end
  1777.  
  1778.  #--------------------------------------------------------------------------
  1779.  # actor=
  1780.  #--------------------------------------------------------------------------
  1781.  def actor=(new_actor)
  1782.    @actor = new_actor
  1783.  end
  1784.  
  1785.  #--------------------------------------------------------------------------
  1786.  # item
  1787.  #--------------------------------------------------------------------------
  1788.  def item; return @data[self.index]; end
  1789.  
  1790.  #--------------------------------------------------------------------------
  1791.  # refresh
  1792.  #--------------------------------------------------------------------------
  1793.  def refresh(type, debug = false)
  1794.    debug = false unless $TEST
  1795.    @data = []; @type = type
  1796.    if @type == :weapon
  1797.      equips = $game_party.equip_weapons
  1798.      equips = $data_weapons if debug
  1799.    else
  1800.      equips = $game_party.equip_armours(@type)
  1801.      equips = $data_armors if debug
  1802.    end
  1803.    @data += [nil] if YEM::EQUIP::TYPE_RULES[@type][2]
  1804.    for item in equips
  1805.      @data.push(item) if include?(item)
  1806.    end
  1807.    @data += [nil] if YEM::EQUIP::TYPE_RULES[@type][2] and @data.size > 8#8xd
  1808.    @item_max = @data.size
  1809.    create_contents
  1810.    for i in 0..(@item_max-1); draw_item(i); end
  1811.  end
  1812.  
  1813.  #--------------------------------------------------------------------------
  1814.  # include?
  1815.  #--------------------------------------------------------------------------
  1816.  def include?(item)
  1817.    return false if item == nil
  1818.    case @type
  1819.    when :weapon
  1820.      return false unless item.is_a?(RPG::Weapon)
  1821.    else
  1822.      kind = YEM::EQUIP::TYPE_RULES[@type][1]
  1823.      return false unless item.kind == kind
  1824.    end
  1825.    return class_equippable?(item)
  1826.  end
  1827.  
  1828.  #--------------------------------------------------------------------------
  1829.  # class_equippable?
  1830.  #--------------------------------------------------------------------------
  1831.  def class_equippable?(item)
  1832.    if item.is_a?(RPG::Weapon)
  1833.      class_set = @actor.class.weapon_set
  1834.    else
  1835.      class_set = @actor.class.armor_set
  1836.    end
  1837.    return class_set.include?(item.id)
  1838.  end
  1839.  
  1840.  #--------------------------------------------------------------------------
  1841.  # enable?
  1842.  #--------------------------------------------------------------------------
  1843.  def enable?(item)
  1844.    return true if item == nil and YEM::EQUIP::TYPE_RULES[@type][2]
  1845.    return false if $game_party.item_number(item) <= 0
  1846.    @equippables = {} if @equippables == nil
  1847.    @equippables[item] = @actor.equippable?(item) if @equippables[item] == nil
  1848.    return @equippables[item]
  1849.  end
  1850.  
  1851.  #--------------------------------------------------------------------------
  1852.  # draw_item
  1853.  #--------------------------------------------------------------------------
  1854.  def draw_item(index)
  1855.    rect = item_rect(index)
  1856.    self.contents.clear_rect(rect)
  1857.    self.contents.font.size = Font.default_size
  1858.    self.contents.font.color = normal_color
  1859.    item = @data[index]
  1860.    if item == nil
  1861.      draw_icon(YEM::EQUIP::UNEQUIP_ICON, rect.x, rect.y)
  1862.      text = YEM::EQUIP::VOCAB[:unequip]
  1863.      self.contents.draw_text(rect.x + 24, rect.y, 172, WLH, text)
  1864.      return
  1865.    end
  1866.    number = $game_party.item_number(item)
  1867.    enabled = enable?(item)
  1868.    rect.width -= 4
  1869.    draw_item_name(item, rect.x, rect.y, enabled)
  1870.    if $imported["BattleEngineMelody"]
  1871.      self.contents.font.size = YEM::BATTLE_ENGINE::ITEM_SETTINGS[:size]
  1872.      colour = YEM::BATTLE_ENGINE::ITEM_SETTINGS[:colour]
  1873.      self.contents.font.color = text_color(colour)
  1874.      sprint = YEM::BATTLE_ENGINE::ITEM_SETTINGS[:text]
  1875.    else
  1876.      sprint = YEM::EQUIP::VOCAB[:amount]
  1877.    end
  1878.    self.contents.draw_text(rect, sprintf(sprint, number),2)
  1879.  end
  1880.  
  1881.  #--------------------------------------------------------------------------
  1882.  # update_help
  1883.  #--------------------------------------------------------------------------
  1884.  def update_help
  1885.    @help_window.set_text(item == nil ? "" : item.description)
  1886.  end
  1887.  
  1888. end # Window_Equip_Item
  1889.  
  1890. #===============================================================================
  1891. # Window_EquipStat
  1892. #===============================================================================
  1893.  
  1894. class Window_EquipStat < Window_Base
  1895.  
  1896.  #--------------------------------------------------------------------------
  1897.  # initialize
  1898.  #--------------------------------------------------------------------------
  1899.  def initialize(window, actor)
  1900.    dx = window.x + window.width
  1901.    dy = window.y
  1902.    super(dx, dy, Graphics.width - dx, Graphics.height - dy)
  1903.    @actor = actor
  1904.    refresh
  1905.  end
  1906.  
  1907.  #--------------------------------------------------------------------------
  1908.  # actor=
  1909.  #--------------------------------------------------------------------------
  1910.  def actor=(new_actor)
  1911.    @actor = new_actor
  1912.    refresh
  1913.  end
  1914.  
  1915.  #--------------------------------------------------------------------------
  1916.  # refresh
  1917.  #--------------------------------------------------------------------------
  1918.  def refresh(equip = nil, equip_index = nil)
  1919.    self.contents.clear
  1920.    @equip = equip; @equip_index = equip_index
  1921.    draw_actor_stats
  1922.    return if @equip_index == nil or (@equip != nil and
  1923.      !@actor.equippable?(@equip))
  1924.    @clone = Marshal.load(Marshal.dump(@actor))
  1925.    @clone.change_equip(@equip_index, @equip, true)
  1926.    draw_clone_stats
  1927.  end
  1928.  
  1929.  #--------------------------------------------------------------------------
  1930.  # draw_actor_stats
  1931.  #--------------------------------------------------------------------------
  1932.  def draw_actor_stats
  1933.    dx = 0; dy = 0
  1934.    arrow = YEM::EQUIP::VOCAB[:arrow]
  1935.    for stat in YEM::EQUIP::SHOWN_STATS
  1936.      icon = Icon.stat(@actor, stat)
  1937.      case stat
  1938.      when :maxhp
  1939.        text = Vocab.hp
  1940.        value = @actor.maxhp
  1941.      when :maxmp
  1942.        text = Vocab.mp
  1943.        value = @actor.maxmp
  1944.      when :atk
  1945.        text = Vocab.atk
  1946.        value = @actor.atk
  1947.      when :def
  1948.        text = Vocab.def
  1949.        value = @actor.def
  1950.      when :spi
  1951.        text = Vocab.spi
  1952.        value = @actor.spi
  1953.      when :agi
  1954.        text = Vocab.agi
  1955.        value = @actor.agi
  1956.      when :dex
  1957.        next unless $imported["DEX Stat"]
  1958.        text = Vocab.dex
  1959.        value = @actor.dex
  1960.      when :res
  1961.        next unless $imported["RES Stat"]
  1962.        text = Vocab.res
  1963.        value = @actor.res
  1964.      when :hit
  1965.        text = Vocab.hit
  1966.        value = [@actor.hit, 100].min
  1967.        value = sprintf("%d%%", value)
  1968.      when :eva
  1969.        text = Vocab.eva
  1970.        value = [@actor.eva, 100].min
  1971.        value = sprintf("%d%%", value)
  1972.      when :cri
  1973.        text = Vocab.cri
  1974.        value = [@actor.cri, 100].min
  1975.        value = sprintf("%d%%", value)
  1976.      when :odds
  1977.        text = Vocab.odds
  1978.        value = @actor.odds
  1979.      else; next
  1980.      end
  1981.      draw_icon(icon, dx, dy); dx += 24
  1982.      self.contents.font.size = YEM::EQUIP::STAT_FONT_SIZE
  1983.      self.contents.font.color = system_color
  1984.      self.contents.draw_text(dx, dy, 60, WLH, text, 0); dx += 60
  1985.      self.contents.font.color = normal_color
  1986.      self.contents.draw_text(dx, dy, 45, WLH, value, 2); dx += 45
  1987.      self.contents.font.color = system_color
  1988.      self.contents.font.size = Font.default_size
  1989.      self.contents.draw_text(dx, dy, 30, WLH, arrow, 1); dx += 30
  1990.      if @equip_index == nil or (@equip != nil and !@actor.equippable?(@equip))
  1991.        self.contents.font.size = YEM::EQUIP::STAT_FONT_SIZE
  1992.        self.contents.font.color = normal_color
  1993.        self.contents.draw_text(dx, dy, 45, WLH, value, 2)
  1994.      end
  1995.      dx = 0; dy += WLH
  1996.    end
  1997.  end
  1998.  
  1999.  #--------------------------------------------------------------------------
  2000.  # draw_clone_stats
  2001.  #--------------------------------------------------------------------------
  2002.  def draw_clone_stats
  2003.    dx = 0; dy = 0
  2004.    last_hp = @actor.hp
  2005.    last_mp = @actor.mp
  2006.    for stat in YEM::EQUIP::SHOWN_STATS
  2007.      case stat
  2008.      when :maxhp
  2009.        value2 = @actor.maxhp
  2010.        value1 = @clone.maxhp
  2011.      when :maxmp
  2012.        value2 = @actor.maxmp
  2013.        value1 = @clone.maxmp
  2014.      when :atk
  2015.        value2 = @actor.atk
  2016.        value1 = @clone.atk
  2017.      when :def
  2018.        value2 = @actor.def
  2019.        value1 = @clone.def
  2020.      when :spi
  2021.        value2 = @actor.spi
  2022.        value1 = @clone.spi
  2023.      when :agi
  2024.        value2 = @actor.agi
  2025.        value1 = @clone.agi
  2026.      when :dex
  2027.        next unless $imported["DEX Stat"]
  2028.        value2 = @actor.dex
  2029.        value1 = @clone.dex
  2030.      when :res
  2031.        next unless $imported["RES Stat"]
  2032.        value2 = @actor.res
  2033.        value1 = @clone.res
  2034.      else; next
  2035.      end
  2036.      if value1 > value2
  2037.        self.contents.font.color = power_up_color
  2038.      elsif value1 < value2
  2039.        self.contents.font.color = power_down_color
  2040.      else
  2041.        self.contents.font.color = normal_color
  2042.      end
  2043.      self.contents.font.size = YEM::EQUIP::STAT_FONT_SIZE
  2044.      self.contents.draw_text(dx+159, dy, 45, WLH, value1, 2)
  2045.      dx = 0; dy += WLH
  2046.    end
  2047.    @actor.hp = last_hp
  2048.    @actor.mp = last_mp
  2049.  end
  2050.  
  2051. end # Window_EquipStat
  2052.  
  2053. #===============================================================================
  2054. # Window_EquipApt
  2055. #===============================================================================
  2056.  
  2057. class Window_EquipApt < Window_Base
  2058.  
  2059.  #--------------------------------------------------------------------------
  2060.  # initialize
  2061.  #--------------------------------------------------------------------------
  2062.  def initialize(aptitude_window, actor)
  2063.    @aptitude_window = aptitude_window
  2064.    dx = @aptitude_window.x + @aptitude_window.width
  2065.    dy = @aptitude_window.y
  2066.    super(dx, dy, Graphics.width - dx, Graphics.height - dy)
  2067.    @actor = actor
  2068.    refresh
  2069.  end
  2070.  
  2071.  #--------------------------------------------------------------------------
  2072.  # actor=
  2073.  #--------------------------------------------------------------------------
  2074.  def actor=(new_actor)
  2075.    @actor = new_actor
  2076.    refresh
  2077.  end
  2078.  
  2079.  #--------------------------------------------------------------------------
  2080.  # refresh
  2081.  #--------------------------------------------------------------------------
  2082.  def refresh
  2083.    self.contents.clear
  2084.    @item = @aptitude_window.item
  2085.    @item = nil if @item != nil and $game_party.item_number(@item) <= 0
  2086.    draw_actor_stats
  2087.  end
  2088.  
  2089.  #--------------------------------------------------------------------------
  2090.  # draw_actor_stats
  2091.  #--------------------------------------------------------------------------
  2092.  def draw_actor_stats
  2093.    dx = 0; dy = 0
  2094.    @actor.create_aptitude_bonus
  2095.    arrow = YEM::EQUIP::VOCAB[:arrow]
  2096.    for stat in YEM::EQUIP::SHOWN_STATS
  2097.      icon = Icon.stat(@actor, stat)
  2098.      case stat
  2099.      when :maxhp
  2100.        text = Vocab.hp
  2101.      when :maxmp
  2102.        text = Vocab.mp
  2103.      when :atk
  2104.        text = Vocab.atk
  2105.      when :def
  2106.        text = Vocab.def
  2107.      when :spi
  2108.        text = Vocab.spi
  2109.      when :agi
  2110.        text = Vocab.agi
  2111.      when :dex
  2112.        next unless $imported["DEX Stat"]
  2113.        text = Vocab.dex
  2114.      when :res
  2115.        next unless $imported["RES Stat"]
  2116.        text = Vocab.res
  2117.      else; next
  2118.      end
  2119.      value = @actor.aptitude_rate(stat)
  2120.      if @item != nil
  2121.        stat = :hp if stat == :maxhp
  2122.        stat = :mp if stat == :maxmp
  2123.        value += @item.apt_growth[stat] if @item.apt_growth[stat] != nil
  2124.        value = [value, YEM::EQUIP::MINIMUM_APTITUDE].max
  2125.        value = [value, YEM::EQUIP::MAXIMUM_APTITUDE].min
  2126.      end
  2127.      draw_icon(icon, dx, dy); dx += 24
  2128.      text1 = sprintf(YEM::EQUIP::VOCAB[:apt_rate], text)
  2129.      text2 = sprintf("%d%%", value)
  2130.      self.contents.font.size = YEM::EQUIP::STAT_FONT_SIZE
  2131.      self.contents.font.color = system_color
  2132.      self.contents.draw_text(dx, dy, 80, WLH, text1, 0); dx += 60
  2133.      self.contents.font.color = normal_color
  2134.      actor_stat = sprintf("%d%%", @actor.aptitude_rate(stat))
  2135.      self.contents.draw_text(dx, dy, 45, WLH, actor_stat, 2); dx += 45
  2136.      self.contents.font.size = Font.default_size
  2137.      self.contents.font.color = system_color
  2138.      self.contents.draw_text(dx, dy, 30, WLH, arrow, 1); dx += 30
  2139.      if value > @actor.aptitude_rate(stat)
  2140.        self.contents.font.color = power_up_color
  2141.      elsif value < @actor.aptitude_rate(stat)
  2142.        self.contents.font.color = power_down_color
  2143.      else
  2144.        self.contents.font.color = normal_color
  2145.      end
  2146.      self.contents.font.size = YEM::EQUIP::STAT_FONT_SIZE
  2147.      self.contents.draw_text(dx, dy, 45, WLH, text2, 2)
  2148.      dy += WLH
  2149.      dx = 0
  2150.    end
  2151.  end
  2152.  
  2153. end # Window_EquipApt
  2154.  
  2155. #===============================================================================
  2156. # Window_Aptitude
  2157. #===============================================================================
  2158.  
  2159. class Window_Aptitude < Window_Selectable
  2160.  
  2161.  #--------------------------------------------------------------------------
  2162.  # initialize
  2163.  #--------------------------------------------------------------------------
  2164.  def initialize(help_window, actor)
  2165.    @help_window = help_window
  2166.    dy = @help_window.y + @help_window.height
  2167.    super(0, dy, Graphics.width - 240, Graphics.height - dy)
  2168.    self.active = false
  2169.    self.index = 0
  2170.    @actor = actor
  2171.    refresh
  2172.  end
  2173.  
  2174.  #--------------------------------------------------------------------------
  2175.  # actor=
  2176.  #--------------------------------------------------------------------------
  2177.  def actor=(new_actor)
  2178.    @actor = new_actor
  2179.    refresh
  2180.  end
  2181.  
  2182.  #--------------------------------------------------------------------------
  2183.  # item
  2184.  #--------------------------------------------------------------------------
  2185.  def item; return @data[self.index]; end
  2186.  
  2187.  #--------------------------------------------------------------------------
  2188.  # refresh
  2189.  #--------------------------------------------------------------------------
  2190.  def refresh
  2191.    @data = []
  2192.    if YEM::EQUIP::SHOW_APT_BOOSTS
  2193.      @data = $game_temp.aptitude_items.clone
  2194.    else
  2195.      for item in $game_temp.aptitude_items
  2196.        next if item == nil
  2197.        next unless $game_party.item_number(item) > 0
  2198.        @data.push(item)
  2199.      end
  2200.    end
  2201.    @item_max = @data.size
  2202.    create_contents
  2203.    for i in 0..(@item_max-1); draw_item(i); end
  2204.  end
  2205.  
  2206.  #--------------------------------------------------------------------------
  2207.  # include?
  2208.  #--------------------------------------------------------------------------
  2209.  def include?(item)
  2210.    return false if item.apt_growth == {}
  2211.    return true
  2212.  end
  2213.  
  2214.  #--------------------------------------------------------------------------
  2215.  # enable?
  2216.  #--------------------------------------------------------------------------
  2217.  def enable?(item)
  2218.    return false if $game_party.item_number(item) <= 0
  2219.    changes = false
  2220.    max_apt = YEM::EQUIP::MAXIMUM_APTITUDE
  2221.    min_apt = YEM::EQUIP::MINIMUM_APTITUDE
  2222.    for key in item.apt_growth
  2223.      stat = key[0]; value = key[1]
  2224.      if value > 0 and @actor.aptitude_rate(stat) != max_apt
  2225.        changes = true
  2226.        break
  2227.      elsif value < 0 and @actor.aptitude_rate(stat) != min_apt
  2228.        changes = true
  2229.        break
  2230.      end
  2231.    end
  2232.    return changes
  2233.  end
  2234.  
  2235.  #--------------------------------------------------------------------------
  2236.  # draw_item
  2237.  #--------------------------------------------------------------------------
  2238.  def draw_item(index)
  2239.    rect = item_rect(index)
  2240.    self.contents.clear_rect(rect)
  2241.    item = @data[index]
  2242.    return if item == nil
  2243.    enabled = enable?(item)
  2244.    draw_obj_name(item, rect.clone, enabled)
  2245.    draw_obj_charges(item, rect.clone, enabled)
  2246.    draw_obj_total(item, rect.clone, enabled)
  2247.  end
  2248.  
  2249.  #--------------------------------------------------------------------------
  2250.  # new method: draw_obj_name
  2251.  #--------------------------------------------------------------------------
  2252.  def draw_obj_name(obj, rect, enabled)
  2253.    draw_icon(obj.icon_index, rect.x, rect.y, enabled)
  2254.    self.contents.font.size = Font.default_size
  2255.    self.contents.font.color = normal_color
  2256.    self.contents.font.color.alpha = enabled ? 255 : 128
  2257.    rect.width -= 48
  2258.    self.contents.draw_text(rect.x+24, rect.y, rect.width-24, WLH, obj.name)
  2259.  end
  2260.  
  2261.  #--------------------------------------------------------------------------
  2262.  # new method: draw_obj_charges
  2263.  #--------------------------------------------------------------------------
  2264.  def draw_obj_charges(obj, rect, enabled)
  2265.    return unless $imported["BattleEngineMelody"]
  2266.    return unless obj.is_a?(RPG::Item)
  2267.    return unless obj.consumable
  2268.    return if obj.charges <= 1
  2269.    $game_party.item_charges = {} if $game_party.item_charges == nil
  2270.    $game_party.item_charges[obj.id] = obj.charges if
  2271.      $game_party.item_charges[obj.id] == nil
  2272.    charges = $game_party.item_charges[obj.id]
  2273.    dx = rect.x; dy = rect.y + WLH/3
  2274.    self.contents.font.size = YEM::BATTLE_ENGINE::ITEM_SETTINGS[:charge]
  2275.    self.contents.font.color = normal_color
  2276.    self.contents.font.color.alpha = enabled ? 255 : 128
  2277.    self.contents.draw_text(dx, dy, 24, WLH * 2/3, charges, 2)
  2278.    self.contents.font.size = Font.default_size
  2279.  end
  2280.  
  2281.  #--------------------------------------------------------------------------
  2282.  # new method: draw_obj_total
  2283.  #--------------------------------------------------------------------------
  2284.  def draw_obj_total(obj, rect, enabled)
  2285.    if $imported["BattleEngineMelody"]
  2286.      hash = YEM::BATTLE_ENGINE::ITEM_SETTINGS
  2287.    else
  2288.      hash ={ :text => ":%d", :size => Font.default_size, :colour => 0 }
  2289.    end
  2290.    number = $game_party.item_number(obj)
  2291.    dx = rect.x + rect.width - 36; dy = rect.y; dw = 32
  2292.    text = sprintf(hash[:text], number)
  2293.    self.contents.font.size = hash[:size]
  2294.    self.contents.font.color = text_color(hash[:colour])
  2295.    self.contents.font.color.alpha = enabled ? 255 : 128
  2296.    self.contents.draw_text(dx, dy, dw, WLH, text, 2)
  2297.  end
  2298.  
  2299.  #--------------------------------------------------------------------------
  2300.  # update_help
  2301.  #--------------------------------------------------------------------------
  2302.  def update_help
  2303.    @help_window.set_text(item == nil ? "" : item.description)
  2304.  end
  2305.  
  2306. end # Window_Aptitude
  2307.  
  2308. #===============================================================================
  2309. # Scene_Equip
  2310. #===============================================================================
  2311.  
  2312. class Scene_Equip < Scene_Base
  2313.  
  2314.  #--------------------------------------------------------------------------
  2315.  # public instance variables
  2316.  #--------------------------------------------------------------------------
  2317.  attr_accessor :equip_window
  2318.  
  2319.  #--------------------------------------------------------------------------
  2320.  # overwrite method: start
  2321.  #--------------------------------------------------------------------------
  2322.  def start
  2323.    super
  2324.    create_menu_background
  2325.    @actor = $game_party.members[@actor_index]
  2326.    $game_party.last_actor_index = @actor_index
  2327.    $game_temp.equip_last = 0 if $game_temp.equip_last == nil
  2328.    @help_window = Window_Help.new
  2329.    @help_window.y = 128
  2330.    @windows = []
  2331.    create_command_window
  2332.    @status_window = Window_Equip_Actor.new(@actor)
  2333.    @equip_window = Window_Equip.new(0, 184, @actor)
  2334.    @equip_window.help_window = @help_window
  2335.    @windows.push(@equip_window)
  2336.    @stat_window = Window_EquipStat.new(@equip_window, @actor)
  2337.    @windows.push(@stat_window)
  2338.    @item_window = Window_Equip_Item.new(@equip_window, @actor)
  2339.    @item_window.help_window = @help_window
  2340.    @item_window.y = 416*3
  2341.    @windows.push(@item_window)
  2342.    update_windows
  2343.  end
  2344.  
  2345.  #--------------------------------------------------------------------------
  2346.  # overwrite method: terminate
  2347.  #--------------------------------------------------------------------------
  2348.  def terminate
  2349.    super
  2350.    dispose_menu_background
  2351.    @command_window.dispose if @command_window != nil
  2352.    @status_window.dispose if @status_window != nil
  2353.    @help_window.dispose if @help_window != nil
  2354.    @equip_window.dispose if @equip_window != nil
  2355.    @stat_window.dispose if @stat_window != nil
  2356.    @item_window.dispose if @item_window != nil
  2357.    @aptitude_window.dispose if @aptitude_window != nil
  2358.    @apt_stat.dispose if @apt_stat != nil
  2359.  end
  2360.  
  2361.  #--------------------------------------------------------------------------
  2362.  # alias method: return_scene
  2363.  #--------------------------------------------------------------------------
  2364.  alias return_scene_eo return_scene unless $@
  2365.  def return_scene
  2366.    return_scene_eo
  2367.  end
  2368.  
  2369.  #--------------------------------------------------------------------------
  2370.  # overwrite method: next_actor
  2371.  #--------------------------------------------------------------------------
  2372.  def next_actor
  2373.    @actor_index += 1
  2374.    @actor_index %= $game_party.members.size
  2375.    set_new_actor
  2376.  end
  2377.  
  2378.  #--------------------------------------------------------------------------
  2379.  # overwrite method: prev_actor
  2380.  #--------------------------------------------------------------------------
  2381.  def prev_actor
  2382.    @actor_index += $game_party.members.size - 1
  2383.    @actor_index %= $game_party.members.size
  2384.    set_new_actor
  2385.  end
  2386.  
  2387.  #--------------------------------------------------------------------------
  2388.  # new method: set_new_actor
  2389.  #--------------------------------------------------------------------------
  2390.  def set_new_actor
  2391.    $game_party.last_actor_index = @actor_index
  2392.    @actor = $game_party.members[@actor_index]
  2393.    @status_window.actor = @actor
  2394.    for window in @windows; window.actor = @actor; end
  2395.    update_windows
  2396.  end
  2397.  
  2398.  #--------------------------------------------------------------------------
  2399.  # new method: create_command_window
  2400.  #--------------------------------------------------------------------------
  2401.  def create_command_window
  2402.    commands = []; @data = []
  2403.    for command in YEM::EQUIP::COMMANDS
  2404.      case command
  2405.      when :manual, :optimize
  2406.      when :aptitude
  2407.        next unless YEM::EQUIP::USE_APTITUDE_SYSTEM
  2408.        @aptitude_window = Window_Aptitude.new(@help_window, @actor)
  2409.        @aptitude_window.help_window = @help_window
  2410.        @windows.push(@aptitude_window)
  2411.        @apt_stat = Window_EquipApt.new(@aptitude_window, @actor)
  2412.        @windows.push(@apt_stat)
  2413.      else; next
  2414.      end
  2415.      @data.push(command)
  2416.      commands.push(YEM::EQUIP::VOCAB[command])
  2417.    end
  2418.    @command_window = Window_Command_Centered.new(160, commands)
  2419.    @command_window.height = 128
  2420.    @command_window.index = $game_temp.equip_last
  2421.    @command_window.active = true
  2422.  end
  2423.  
  2424.  #--------------------------------------------------------------------------
  2425.  # overwrite method: update
  2426.  #--------------------------------------------------------------------------
  2427.  def update
  2428.    super
  2429.    update_menu_background
  2430.    if @command_window.active
  2431.      update_command_selection
  2432.    elsif @equip_window.active
  2433.      update_equip_selection
  2434.    elsif @item_window.active
  2435.      update_item_selection
  2436.    elsif @aptitude_window.active
  2437.      update_aptitude_selection
  2438.    end
  2439.  end
  2440.  
  2441.  #--------------------------------------------------------------------------
  2442.  # new method: update_windows
  2443.  #--------------------------------------------------------------------------
  2444.  def update_windows
  2445.    @aptitude_window.y = Graphics.height*8 if @aptitude_window != nil
  2446.    @apt_stat.y = Graphics.height*8 if @apt_stat != nil
  2447.    @help_window.y = Graphics.height*8
  2448.    @equip_window.y = Graphics.height*8
  2449.    @stat_window.y = @equip_window.y
  2450.    case @data[@command_window.index]
  2451.    when :aptitude
  2452.      @help_window.y = @status_window.height
  2453.      @aptitude_window.y = @help_window.y + @help_window.height
  2454.      @apt_stat.y = @aptitude_window.y
  2455.      @aptitude_window.update_help
  2456.    else
  2457.      @help_window.y = @status_window.height
  2458.      @equip_window.y = @help_window.y + @help_window.height
  2459.      @stat_window.y = @equip_window.y
  2460.      @equip_window.update_help
  2461.    end
  2462.  end
  2463.  
  2464.  #--------------------------------------------------------------------------
  2465.  # new method: update_command_selection
  2466.  #--------------------------------------------------------------------------
  2467.  def update_command_selection
  2468.    @command_window.update
  2469.    if $game_temp.equip_last != @command_window.index
  2470.      $game_temp.equip_last = @command_window.index
  2471.      update_windows
  2472.    end
  2473.    if Input.trigger?(Input::B)
  2474.      Sound.play_cancel
  2475.      return_scene
  2476.      $game_temp.equip_last = nil
  2477.    elsif Input.repeat?(Input::RIGHT)
  2478.      return if $game_temp.in_battle
  2479.      Sound.play_cursor
  2480.      next_actor
  2481.    elsif Input.repeat?(Input::LEFT)
  2482.      return if $game_temp.in_battle
  2483.      Sound.play_cursor
  2484.      prev_actor
  2485.    elsif Input.trigger?(Input::C)
  2486.      Sound.play_decision
  2487.      case @data[@command_window.index]
  2488.      when :manual
  2489.        @command_window.active = false
  2490.        @equip_window.active = true
  2491.      when :optimize
  2492.        perform_optimize
  2493.      when :aptitude
  2494.        @command_window.active = false
  2495.        @aptitude_window.active = true
  2496.      when :mastery
  2497.        $scene = Scene_Mastery.new(@actor_index, @command_window.index)
  2498.      end
  2499.    end
  2500.  end
  2501.  
  2502.  #--------------------------------------------------------------------------
  2503.  # overwrite method: update_equip_selection
  2504.  #--------------------------------------------------------------------------
  2505.  def update_equip_selection
  2506.    @equip_window.update
  2507.    if @last_equip_index != @equip_window.index
  2508.      @last_equip_index = @equip_window.index
  2509.      @status_window.refresh(@equip_window.index)
  2510.    end
  2511.    if Input.trigger?(Input::B)
  2512.      Sound.play_cancel
  2513.      @command_window.active = true
  2514.      @equip_window.active = false
  2515.    elsif Input.repeat?(Input::RIGHT)
  2516.      return if $game_temp.in_battle
  2517.      Sound.play_cursor
  2518.      next_actor
  2519.    elsif Input.repeat?(Input::LEFT)
  2520.      return if $game_temp.in_battle
  2521.      Sound.play_cursor
  2522.      prev_actor
  2523.    elsif Input.trigger?(Input::X)
  2524.      if !YEM::EQUIP::TYPE_RULES[@equip_window.equip_type][2]
  2525.        Sound.play_buzzer
  2526.        return
  2527.      end
  2528.      return if @equip_window.item == nil
  2529.      Sound.play_equip
  2530.      last_hp_per = @actor.hp * 100.0 / [@actor.maxhp, 1].max
  2531.      last_mp_per = @actor.mp * 100.0 / [@actor.maxmp, 1].max
  2532.      @actor.change_equip(@equip_window.index, nil)
  2533.      @status_window.refresh(@equip_window.index)
  2534.      @equip_window.refresh
  2535.      @stat_window.refresh
  2536.      @actor.hp = Integer(@actor.maxhp * last_hp_per / 100.0)
  2537.      @actor.mp = Integer(@actor.maxmp * last_mp_per / 100.0)
  2538.    elsif $TEST and Input.trigger?(Input::F5) # Debug Force Equip
  2539.      Sound.play_decision
  2540.      start_item_selection(true)
  2541.    elsif Input.trigger?(Input::C)
  2542.      if @actor.locked_equips.include?(@equip_window.index) or
  2543.      @actor.fix_equipment
  2544.        Sound.play_buzzer
  2545.        return
  2546.      end
  2547.      Sound.play_decision
  2548.      start_item_selection
  2549.    end
  2550.  end
  2551.  
  2552.  #--------------------------------------------------------------------------
  2553.  # new method: start_item_selection
  2554.  #--------------------------------------------------------------------------
  2555.  def start_item_selection(debug = false)
  2556.    @equip_window.active = false
  2557.    @item_window.active = true
  2558.    @item_window.refresh(@equip_window.equip_type, debug)
  2559.    @item_window_oy = {} if @item_window_oy == nil
  2560.    @item_window_oy[@equip_window.equip_type] = 0 if
  2561.      @item_window_oy[@equip_window.equip_type] == nil
  2562.    @item_window.oy = @item_window_oy[@equip_window.equip_type]
  2563.    @item_window_index = {} if @item_window_index == nil
  2564.    @item_window_index[@equip_window.equip_type] = 0 if
  2565.      @item_window_index[@equip_window.equip_type] == nil
  2566.    @item_window.index = [[@item_window_index[@equip_window.equip_type],
  2567.      @item_window.item_max - 1].min, 0].max
  2568.    @item_window.y = @equip_window.y
  2569.    @equip_window.y = 416*3
  2570.    @item_window.update_help
  2571.  end
  2572.  
  2573.  #--------------------------------------------------------------------------
  2574.  # overwrite method: update_item_selection
  2575.  #--------------------------------------------------------------------------
  2576.  def update_item_selection
  2577.    @item_window.update
  2578.    if @last_item_index != @item_window.index
  2579.      @last_item_index = @item_window.index
  2580.      @stat_window.refresh(@item_window.item, @equip_window.index)
  2581.    end
  2582.    if Input.trigger?(Input::B) or ($TEST and Input.trigger?(Input::F6))
  2583.      Sound.play_cancel
  2584.      end_item_selection
  2585.    elsif $TEST and Input.repeat?(Input::F8) # Debug Increase Equip
  2586.      item = @item_window.item
  2587.      return if item == nil
  2588.      Sound.play_use_item
  2589.      $game_party.gain_item(item, 1)
  2590.      @item_window.draw_item(@item_window.index)
  2591.    elsif $TEST and Input.repeat?(Input::F7) # Debug Decrease Equip
  2592.      item = @item_window.item
  2593.      return if item == nil
  2594.      return if $game_party.item_number(item) <= 0
  2595.      Sound.play_use_item
  2596.      $game_party.lose_item(item, 1)
  2597.      @item_window.draw_item(@item_window.index)
  2598.    elsif Input.trigger?(Input::X)
  2599.      if !YEM::EQUIP::TYPE_RULES[@equip_window.equip_type][1]
  2600.        Sound.play_buzzer
  2601.        return
  2602.      end
  2603.      Sound.play_equip
  2604.      last_hp_per = @actor.hp * 100.0 / [@actor.maxhp, 1].max
  2605.      last_mp_per = @actor.mp * 100.0 / [@actor.maxmp, 1].max
  2606.      @actor.change_equip(@equip_window.index, nil)
  2607.      @status_window.refresh(@equip_window.index)
  2608.      end_item_selection
  2609.      @actor.hp = Integer(@actor.maxhp * last_hp_per / 100.0)
  2610.      @actor.mp = Integer(@actor.maxmp * last_mp_per / 100.0)
  2611.    elsif $TEST and Input.trigger?(Input::F5) # Debug Force Equip
  2612.      Sound.play_equip
  2613.      $game_temp.in_battle = true
  2614.      @actor.change_equip(@equip_window.index, @item_window.item)
  2615.      $game_temp.in_battle = false
  2616.      @status_window.refresh(@equip_window.index)
  2617.      end_item_selection
  2618.    elsif Input.trigger?(Input::C)
  2619.      if !@item_window.enable?(@item_window.item)
  2620.        Sound.play_buzzer
  2621.        return
  2622.      end
  2623.      Sound.play_equip
  2624.      last_hp_per = @actor.hp * 100.0 / [@actor.maxhp, 1].max
  2625.      last_mp_per = @actor.mp * 100.0 / [@actor.maxmp, 1].max
  2626.      @actor.change_equip(@equip_window.index, @item_window.item)
  2627.      @status_window.refresh(@equip_window.index)
  2628.      end_item_selection
  2629.      @actor.hp = Integer(@actor.maxhp * last_hp_per / 100.0)
  2630.      @actor.mp = Integer(@actor.maxmp * last_mp_per / 100.0)
  2631.    end
  2632.  end
  2633.  
  2634.  #--------------------------------------------------------------------------
  2635.  # new method: end_item_selection
  2636.  #--------------------------------------------------------------------------
  2637.  def end_item_selection
  2638.    @item_window_oy[@equip_window.equip_type] = @item_window.oy
  2639.    @item_window_index[@equip_window.equip_type] = @last_item_index
  2640.    @item_window.active = false
  2641.    @equip_window.active = true
  2642.    @last_item_index = nil
  2643.    @equip_window.refresh
  2644.    @equip_window.y = @item_window.y
  2645.    @item_window.y = 416*3
  2646.    @equip_window.update_help
  2647.    @stat_window.refresh
  2648.  end
  2649.  
  2650.  #--------------------------------------------------------------------------
  2651.  # new method: perform_optimize
  2652.  #--------------------------------------------------------------------------
  2653.  def perform_optimize
  2654.    Sound.play_equip
  2655.    last_hp_per = @actor.hp * 100.0 / [@actor.maxhp, 1].max
  2656.    last_mp_per = @actor.mp * 100.0 / [@actor.maxmp, 1].max
  2657.    types = [:weapon] + @actor.equip_type
  2658.    slot = -1
  2659.    for type in types
  2660.      slot += 1
  2661.      type = :weapon if slot == 1 and @actor.two_swords_style
  2662.      next unless YEM::EQUIP::TYPE_RULES[type][3]
  2663.      item = optimal_equip(slot, type)
  2664.      next if item == nil
  2665.      @actor.change_equip(slot, item)
  2666.    end
  2667.    @status_window.refresh(@equip_window.index)
  2668.    @equip_window.refresh
  2669.    @stat_window.refresh
  2670.    @actor.hp = Integer(@actor.maxhp * last_hp_per / 100.0)
  2671.    @actor.mp = Integer(@actor.maxmp * last_mp_per / 100.0)
  2672.  end
  2673.  
  2674.  #--------------------------------------------------------------------------
  2675.  # new method: optimal_equip
  2676.  #--------------------------------------------------------------------------
  2677.  def optimal_equip(slot, type)
  2678.    return nil if slot == 1 and @actor.weapons[0] != nil and
  2679.      @actor.weapons[0].two_handed
  2680.    equips = []; valid = []
  2681.    if type == :weapon
  2682.      for item in $game_party.equip_weapons
  2683.        next if item == nil
  2684.        next unless @actor.equippable?(item)
  2685.        equips.push(item)
  2686.      end
  2687.    else
  2688.      for item in $game_party.equip_armours
  2689.        next if item == nil
  2690.        next unless item.kind == YEM::EQUIP::TYPE_RULES[type][1]
  2691.        next unless @actor.equippable?(item)
  2692.        equips.push(item)
  2693.      end
  2694.    end
  2695.    order_type = YEM::EQUIP::OPTIMIZE_SETTINGS.include?(type) ? type : :unlisted
  2696.    order = YEM::EQUIP::OPTIMIZE_SETTINGS[order_type]
  2697.    return nil if equips == []
  2698.    result = []
  2699.    for param in order
  2700.      comp_proc = YEM::EQUIP::COMP_PARAM_PROC[param]
  2701.      get_proc = YEM::EQUIP::GET_PARAM_PROC[param]
  2702.      equips.sort! { |a, b| comp_proc.call(a, b) }
  2703.      highest = equips[0]
  2704.      result = equips.find_all { |item|
  2705.        get_proc.call(highest) == get_proc.call(item)
  2706.      }
  2707.      break if result.size == 1
  2708.      equips = result.clone
  2709.    end
  2710.    return nil if result == []
  2711.    result.sort! { |a, b| b.id - a.id }
  2712.    return result[0]
  2713.  end
  2714.  
  2715.  #--------------------------------------------------------------------------
  2716.  # new method: update_aptitude_selection
  2717.  #--------------------------------------------------------------------------
  2718.  def update_aptitude_selection
  2719.    @aptitude_window.update
  2720.    if @last_aptitude != @aptitude_window.index
  2721.      @last_aptitude = @aptitude_window.index
  2722.      item = @aptitude_window.item
  2723.      @apt_stat.refresh
  2724.    end
  2725.    if Input.trigger?(Input::B)
  2726.      Sound.play_cancel
  2727.      @aptitude_window.active = false
  2728.      @command_window.active = true
  2729.      @equip_window.refresh
  2730.      @stat_window.refresh
  2731.      @apt_stat.refresh
  2732.      @last_aptitude = nil
  2733.    elsif Input.repeat?(Input::RIGHT)
  2734.      return if $game_temp.in_battle
  2735.      Sound.play_cursor
  2736.      next_actor
  2737.    elsif Input.repeat?(Input::LEFT)
  2738.      return if $game_temp.in_battle
  2739.      Sound.play_cursor
  2740.      prev_actor
  2741.    #--- Debug Commands ---
  2742.    elsif $TEST and Input.repeat?(Input::F8)
  2743.      Sound.play_equip
  2744.      for item in $game_temp.aptitude_items
  2745.        next if item == nil
  2746.        amount = Input.press?(Input::SHIFT) ? 10 : 1 + rand(3)
  2747.        $game_party.gain_item(item, amount)
  2748.      end
  2749.      @aptitude_window.refresh
  2750.    elsif $TEST and Input.repeat?(Input::F7)
  2751.      Sound.play_equip
  2752.      for item in $game_temp.aptitude_items
  2753.        next if item == nil
  2754.        amount = Input.press?(Input::SHIFT) ? 10 : 1 + rand(3)
  2755.        $game_party.lose_item(item, amount)
  2756.      end
  2757.      @aptitude_window.refresh
  2758.    elsif $TEST and Input.repeat?(Input::F6)
  2759.      item = @aptitude_window.item
  2760.      return if item == nil
  2761.      Sound.play_equip
  2762.      amount = Input.press?(Input::SHIFT) ? 10 : 1 + rand(3)
  2763.      $game_party.gain_item(item, amount)
  2764.      @aptitude_window.draw_item(@aptitude_window.index)
  2765.    elsif $TEST and Input.repeat?(Input::F5)
  2766.      item = @aptitude_window.item
  2767.      return if item == nil
  2768.      Sound.play_equip
  2769.      amount = Input.press?(Input::SHIFT) ? 10 : 1 + rand(3)
  2770.      $game_party.lose_item(item, amount)
  2771.      @aptitude_window.draw_item(@aptitude_window.index)
  2772.    #--- Debug Commands ---
  2773.    elsif Input.repeat?(Input::C)
  2774.      item = @aptitude_window.item
  2775.      if @aptitude_window.enable?(item)
  2776.        Sound.play_use_item
  2777.        last_hp_per = @actor.hp * 100.0 / [@actor.maxhp, 1].max
  2778.        last_mp_per = @actor.mp * 100.0 / [@actor.maxmp, 1].max
  2779.        @actor.item_growth_effect(@actor, item)
  2780.        @actor.hp = Integer(@actor.maxhp * last_hp_per / 100.0)
  2781.        @actor.mp = Integer(@actor.maxmp * last_mp_per / 100.0)
  2782.        $game_party.consume_item(item) unless @actor.skipped
  2783.        @aptitude_window.draw_item(@aptitude_window.index)
  2784.        @apt_stat.refresh
  2785.        @status_window.refresh(@equip_window.index)
  2786.      elsif Input.trigger?(Input::C)
  2787.        Sound.play_buzzer
  2788.      end
  2789.    end
  2790.  end
  2791.  
  2792. end # Scene_Equip
  2793.  
  2794. #===============================================================================
  2795. #
  2796. # END OF FILE
  2797. #
  2798. #=============================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement