Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Automatic Equipment Optimization for Guilaume777's Multislot
#6
I didn't say it was impossible, did I? However, Guillaume777 said it would have been difficult to integrate it into his system. He did most all the other RPG Advocate equip menu scripts though. I was the one to remind him about cursed items. Winking

However, I crafted this. Mind you, it assumes no removal of slots... kept at a basic level:
Code:
# Automatic Equipment Optimization
# by RPG Advocate


#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
#  This class performs equipment screen processing.
#==============================================================================

class Scene_Equip
  #--------------------------------------------------------------------------
  # * Constants
  #--------------------------------------------------------------------------  
  WEAPON_ATK_WEIGHT = 1.0
  WEAPON_PDF_WEIGHT = 0.0
  WEAPON_MDF_WEIGHT = 0.0
  WEAPON_STR_WEIGHT = 0.0
  WEAPON_DEX_WEIGHT = 0.0
  WEAPON_AGI_WEIGHT = 0.0
  WEAPON_INT_WEIGHT = 0.0
  ARMOR_EVA_WEIGHT  = 0.0
  ARMOR_PDF_WEIGHT  = 0.75
  ARMOR_MDF_WEIGHT  = 0.25
  ARMOR_STR_WEIGHT  = 0.0
  ARMOR_DEX_WEIGHT  = 0.0
  ARMOR_AGI_WEIGHT  = 0.0
  ARMOR_INT_WEIGHT  = 0.0
  NO_ACCESSORY_OPTIMIZATION = false  
  #--------------------------------------------------------------------------
  # * Frame Update (when right window is active)
  #--------------------------------------------------------------------------  
  alias aeo_update_right update_right
  def update_right
    # Perform the original call
    aeo_update_right
    # If X button was pressed
    if Input.trigger?(Input::X)
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # optimize
      optimize(@right_window.index)
      # Refresh windows
      @left_window.refresh
      @right_window.refresh
      for i in 0..@actor.armor_slots.max+1
        @item_windows[i].refresh
      end
      return
    end
    # If Y button was pressed
    if Input.trigger?(Input::Y)
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      for i in 0..@actor.armor_slots.max+1
        optimize(i)
      end
      @left_window.refresh
      @right_window.refresh
      for i in 0..@actor.armor_slots.max+1
        @item_windows[i].refresh
      end
      return
    end
  end  
  #--------------------------------------------------------------------------
  # * Optimize Equipment
  #     slot : equipment slot
  #--------------------------------------------------------------------------  
  def optimize(slot)
    old_slot = slot
    slot = index_to_equip_kind(old_slot)
    if slot == 0
      
      return if @actor.cursed?(slot)
      object = $data_weapons[@actor.weapon_id]
      optimal = object.id
      current = 0.00
      if @actor.weapon_id != 0
        current += object.atk  * WEAPON_ATK_WEIGHT
        current += object.pdef * WEAPON_PDF_WEIGHT
        current += object.mdef * WEAPON_MDF_WEIGHT
        current += object.str_plus * WEAPON_STR_WEIGHT
        current += object.dex_plus * WEAPON_DEX_WEIGHT
        current += object.agi_plus * WEAPON_AGI_WEIGHT
        current += object.int_plus * WEAPON_INT_WEIGHT
      else
        optimal = 0
      end
      max_eval = current
      @actor.equip(0, 0)
      flag = false
      zero_flag = true
      for weapon in $data_weapons
        if !flag
          flag = true
          next
        end
        evaluation = 0.00
        evaluation += weapon.atk  * WEAPON_ATK_WEIGHT
        evaluation += weapon.pdef * WEAPON_PDF_WEIGHT
        evaluation += weapon.mdef * WEAPON_MDF_WEIGHT
        evaluation += weapon.str_plus * WEAPON_STR_WEIGHT
        evaluation += weapon.dex_plus * WEAPON_DEX_WEIGHT
        evaluation += weapon.agi_plus * WEAPON_AGI_WEIGHT
        evaluation += weapon.int_plus * WEAPON_INT_WEIGHT
        if evaluation > 0
          zero_flag = false
        end
        if @actor.equippable?(weapon) &&
          $game_party.weapon_number(weapon.id) > 0 && evaluation > max_eval
          max_eval = evaluation
          optimal = weapon.id
        end
      end
      optimal = 0 if zero_flag
      @actor.equip(0, optimal)
      # If two-handed weapon
      @actor.equip(1, 0) if object.nb_hands > 1
      
      
      
    end
    # if armor slots.....
    if slot >= 1
      not_equipped = false
      case slot
      when 1
        # Skip Shield slot if two-handed...
        object = $data_weapons[@actor.weapon_id]
        return if object.nb_hands > 1
        if @actor.armor1_id == 0
          not_equipped = true
        else
        object = $data_armors[@actor.armor1_id]
        end
      when 2
        if @actor.armor2_id == 0
          not_equipped = true
        else
        object = $data_armors[@actor.armor2_id]
        end
      when 3
        if @actor.armor3_id == 0
          not_equipped = true
        else
        object = $data_armors[@actor.armor3_id]
        end
      when 4
        if NO_ACCESSORY_OPTIMIZATION
          return
        end
        if @actor.armor4_id == 0
          not_equipped = true
        else
        object = $data_armors[@actor.armor4_id]
        end
      end
      optimal = object.id
      # Skip if cursed and unremovable
      return if @actor.cursed?(optimal)
      # Calculate
      current = 0.00
      if not_equipped = false
        current += object.eva  * ARMOR_EVA_WEIGHT
        current += object.pdef * ARMOR_PDF_WEIGHT
        current += object.mdef * ARMOR_MDF_WEIGHT
        current += object.str_plus * ARMOR_STR_WEIGHT
        current += object.dex_plus * ARMOR_DEX_WEIGHT
        current += object.agi_plus * ARMOR_AGI_WEIGHT
        current += object.int_plus * ARMOR_INT_WEIGHT
      else
        optimal = 0
      end
      max_eval = current
      @actor.equip(slot, 0)
      flag = false
      zero_flag = true
      for armor in $data_armors
        if !flag
          flag = true
          next
        end
        next if armor.kind != slot-1
        # Calculate
        evaluation = 0.00
        evaluation += armor.eva  * ARMOR_EVA_WEIGHT
        evaluation += armor.pdef * ARMOR_PDF_WEIGHT
        evaluation += armor.mdef * ARMOR_MDF_WEIGHT
        evaluation += armor.str_plus * ARMOR_STR_WEIGHT
        evaluation += armor.dex_plus * ARMOR_DEX_WEIGHT
        evaluation += armor.agi_plus * ARMOR_AGI_WEIGHT
        evaluation += armor.int_plus * ARMOR_INT_WEIGHT
        #
        zero_flag = false if evaluation > 0
        #
        if @actor.equippable?(armor) &&
          $game_party.armor_number(armor.id) > 0 && evaluation > max_eval
          max_eval = evaluation
          optimal = armor.id
        end
      end
      #
      optimal = 0 if zero_flag
      @actor.equip(slot, optimal)
    end  
  end
end


Even though I use my own system nowadays.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png] [Image: liM4ikn.png] [Image: fdzKgZA.png] [Image: sj0H81z.png]
[Image: QL7oRau.png] [Image: uSqjY09.png] [Image: GAA3qE9.png] [Image: 2Hmnx1G.png] [Image: BwtNdKw.png%5B]
Above are clickable links

Reply }


Messages In This Thread
RE: Automatic Equipment Optimization for Guilaume777's Multislot - by DerVVulfman - 06-19-2012, 03:19 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Visual PaperDoll Equipment Script JayRay 0 3,930 02-16-2016, 03:44 AM
Last Post: JayRay
   G777 Multislot Error with CF Equipment Upgrade XP Kobold 5 7,980 08-07-2011, 05:03 PM
Last Post: XP Kobold
   Syvakal's Conditional Skills And Equipment Crashes Samven 0 3,659 08-02-2011, 01:58 PM
Last Post: Samven
   YEM Equipment Error Message Samven 3 6,386 06-12-2011, 06:30 AM
Last Post: Samven
   Multislot error!? Brutanos 7 9,234 05-03-2010, 01:46 PM
Last Post: Brutanos
   [Resolved] Equipment Scene Problem Yin 4 6,587 08-29-2009, 11:01 PM
Last Post: Yin



Users browsing this thread: