[RMXP] Need help with editing a custom equipscreen by "The Law G14"

Started by Ninjason, May 06, 2022, 03:43:50 pm

Previous topic - Next topic

Ninjason

Greetings, I have a a custom equipscreen script made by "The Law G14" which is incredible.
I have been using it in my game which I am making since 2009 and I absolutely adore it.

Now, my game has been getting longer and longer and more and more complex over the years and I recently had a request in my forum for an indicator to be shown next to each individual stat so that players can check which "rank" they are in each stat. I have a huge cast of playable characters with different specialisations and have recently completed a huge storypart where 60% of them are playable at the same time and my players were a bit overwhelmed with the task to re-equip them all with all the gear that is available to them at that point in time.

I have tried to manipulate the script a little, but I have next to zero experience in coding  :wacko: and up to now only ever had to make tiny adjustments to scripts I used. I think I have a good idea of what I want the script to do, but I am in need of someone who could actually edit the script for me - would that be possible?

This is what the script does right now:

(left image) in the top right corner of the screen, the script shows a list of stats and their current value
(right image) when selecting another item to equip, the top right corner shows and highlights the gains and losses to stats (if applicable) in red/green.


What I would like to add is this:


I would love to add a section to the script, wherein I can define a scale to each stat individually, ranging from S (very good) to F (very bad) - like 0-25 = Rank F, 26-50 = Rank E, 51-100 = Rank D, etc.) and to have the letter shown next to the stat when viewing the equip screen.
Also, when changing equipment, next to each stat which gained or lost values, I would love to show the new ranking letter, even if there is no acutal change in rank. The script already has a section where it identifies changes to be highlighted in red/green, I'm guessing there is a road paved to my goal there, but I am unable to program it.

The section where you can define the scales of each stat would also need to be for each stat individually, since my stat system is actually quite custom (this is just a generic screenshot I made with a new game for clarification).

If someone could help me or guide me I am very happy to learn how to do it - I have made some edits, tried some things, but again, I have next to zero experience in acutal coding and I think this is way over my head.

All the scripts I am currently using are in my signature.

I have a set of gradient colours already prepared (red to blue)
  S_COLOR = Color.new(53, 214, 237)
  A_COLOR = Color.new(105, 179, 76)
  B_COLOR = Color.new(172, 179, 52)
  C_COLOR = Color.new(250, 183, 51)
  D_COLOR = Color.new(255, 142, 21)
  E_COLOR = Color.new(255, 78, 17)
  F_COLOR = Color.new(255, 13, 13)

This is the script:
#------------------------------------------------------------------------------
#==============================================================================
#==============================================================================
#====================*Law's Custom Equipment Screen*===========================
#=========================Author: The Law G14==================================
#============================Version 2.?=======================================
#==============================================================================
#------------------------------------------------------------------------------
#==============================================================================
# ** Window_EquipLeft
#------------------------------------------------------------------------------
#  This window displays actor parameter changes on the equipment screen.
#==============================================================================

class Window_EquipLeft < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(224, 64, 415, 232)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Draw Parameter
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     type  : parameter type (0-6)
  #--------------------------------------------------------------------------
  def draw_actor_parameter(actor, x, y, type)
    case type
  when 0
      parameter_name = $data_system.words.atk
      parameter_value = actor.atk
    when 1
      parameter_name = $data_system.words.pdef
      parameter_value = actor.pdef
    when 2
      parameter_name = $data_system.words.mdef
      parameter_value = actor.mdef
    when 3
      parameter_name = $data_system.words.dex
      parameter_value = actor.dex
    when 4
      parameter_name = $data_system.words.int
      parameter_value = actor.int
    when 5
      parameter_name = $data_system.words.str
      parameter_value = actor.str
    when 6
      parameter_name = $data_system.words.agi
      parameter_value = actor.agi
    when 7
      parameter_name = "Evasion"
      parameter_value = actor.eva
    end
    self.contents.font.size = 16
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 120, 32, parameter_name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Draw Actor Face Graphic
  #--------------------------------------------------------------------------
  def draw_actor_face_graphic(actor, x, y)
    #bitmap = RPG::Cache.picture(actor.id.to_s)
    bitmap = RPG::Cache.battler(actor.battler_name, 0)
    x -= bitmap.width / 2 - 30
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------   
  def refresh
    self.contents.clear
    draw_actor_face_graphic(@actor, x + 50, y - 40)
    self.contents.font.size = 18
    draw_actor_level(@actor, 4, -3)
    for i in 0..7
      draw_actor_parameter(@actor, 4, i * 22 + 19, i)
    end
    [[@new_atk, @actor.atk], [@new_pdef, @actor.pdef], [@new_mdef, @actor.mdef],
     [@new_dex, @actor.dex], [@new_int, @actor.int], [@new_str, @actor.str],
     [@new_agi, @actor.agi], [@new_eva, @actor.eva]].each_with_index { |stat, i|
      if stat[0] != nil
         self.contents.font.color = normal_color
         self.contents.draw_text(160, i * 22 + 19, 40, 32, '->', 1)
       if stat[0] > stat[1]
         self.contents.font.color = Color.new(128, 255, 128)
       elsif (stat[0] < stat[1])
         self.contents.font.color = Color.new(255, 128, 128)
       end
         self.contents.draw_text(200, i * 22 + 19, 36, 32, stat[0].to_s, 2)
       end
     }
  end
  #--------------------------------------------------------------------------
  # * Set parameters after changing equipment
  #     new_atk  : attack power after changing equipment
  #     new_pdef : physical defense after changing equipment
  #     new_mdef : magic defense after changing equipment
  #--------------------------------------------------------------------------
  def set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex,
                         new_agi, new_int, new_eva)
    if @new_atk != new_atk || @new_pdef != new_pdef || @new_mdef != new_mdef ||
        @new_str != new_str || @new_dex != new_dex || @new_agi != new_agi ||
        @new_int != new_int || @new_eva != new_eva
      @new_atk = new_atk
      @new_pdef = new_pdef
      @new_mdef = new_mdef
      @new_str = new_str
      @new_dex = new_dex
      @new_agi = new_agi
      @new_int = new_int
      @new_eva = new_eva
      refresh
    end
  end
end



#==============================================================================
# ** Window_EquipRight
#------------------------------------------------------------------------------
#  This window displays items the actor is currently equipped with on the
#  equipment screen.
#==============================================================================

class Window_EquipRight < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(224, 295, 415, 185)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Item Acquisition
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.size = 16
    @data = []
    @data.push($data_weapons[@actor.weapon_id])
    @data.push($data_armors[@actor.armor1_id])
    @data.push($data_armors[@actor.armor2_id])
    @data.push($data_armors[@actor.armor3_id])
    @data.push($data_armors[@actor.armor4_id])
    @item_max = @data.size
    self.contents.font.color = system_color
    self.contents.draw_text(4, 32 * 0, 160, 32, $data_system.words.weapon)
    self.contents.draw_text(4, 32 * 1, 160, 32, $data_system.words.armor1)
    self.contents.draw_text(4, 32 * 2, 160, 32, $data_system.words.armor2)
    self.contents.draw_text(4, 32 * 3, 160, 32, $data_system.words.armor3)
    self.contents.draw_text(5, 32 * 4, 160, 32, $data_system.words.armor4)
    draw_item_name(@data[0], 140, 32 * 0)
    draw_item_name(@data[1], 140, 32 * 1)
    draw_item_name(@data[2], 140, 32 * 2)
    draw_item_name(@data[3], 140, 32 * 3)
    draw_item_name(@data[4], 140, 32 * 4)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end



#==============================================================================
# ** Window_EquipItem
#------------------------------------------------------------------------------
#  This window displays choices when opting to change equipment on the
#  equipment screen.
#==============================================================================

class Window_EquipItem < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor      : actor
  #     equip_type : equip region (0-3)
  #--------------------------------------------------------------------------
  def initialize(actor, equip_type)
    super(0, 64, 224, 231)
    @actor = actor
    @equip_type = equip_type
    @column_max = 1
    refresh
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  # * Item Acquisition
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add equippable weapons
    if @equip_type == 0
      weapon_set = $data_classes[@actor.class_id].weapon_set
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
          @data.push($data_weapons[i])
        end
      end
    end
    # Add equippable armor
    if @equip_type != 0
      armor_set = $data_classes[@actor.class_id].armor_set
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0 and armor_set.include?(i)
          if $data_armors[i].kind == @equip_type-1
            @data.push($data_armors[i])
          end
        end
      end
    end
    # Add blank page
    @data.push(nil)
    # Make a bit map and draw all items
    @item_max = @data.size
    self.contents = Bitmap.new(width - 32, row_max * 32)
    for i in 0...@item_max-1
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    x = 4 + index % 1 * (288 + 32)
    y = index / 1 * 32
    case item
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.font.size = 16
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 160, y, 16, 32, "x", 1)
    self.contents.draw_text(x + 163, y, 24, 32, number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end



#==============================================================================
# ** Window_EquipElement
#------------------------------------------------------------------------------
#  This window shows the State and Elemental changes for each armor/weapon.
#==============================================================================

class Window_EquipElement < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 295, 224, 185)
    self.contents = Bitmap.new(width - 32, height - 32)
    @item = nil
  end
  #--------------------------------------------------------------------------
  # * Set Item
  #--------------------------------------------------------------------------
  def set_item(item)
    @item = item
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Clear the screen
    self.contents.clear
    # Don't draw anything if the item isn't set
    return if @item == nil
    # If the item is a weapon/armor, setup the text
    if @item.is_a?(RPG::Weapon)
      text1 = 'Schadenstyp:'
      text2 = array_2_css(@item.element_set, :ELEMENT)
      text3 = 'Statusveränderungen:'
      text4 = array_2_css(@item.plus_state_set, :STATE)
    elsif @item.is_a?(RPG::Armor)
      text1 = 'senkt Schaden von:'
      text2 = array_2_css(@item.guard_element_set, :ELEMENT)
      text3 = 'schützt vor Statusveränderung:'
      text4 = array_2_css(@item.guard_state_set, :STATE)
    else
      return
    end
    # Set the default font size
    self.contents.font.size = 16
    # Loop remaking the text (resized to the window)
    loop do
      ftext1 = string_to_array(text1)
      ftext2 = string_to_array(text2)
      ftext3 = string_to_array(text3)
      ftext4 = string_to_array(text4)
      # Set the height each line takes
      dh = self.contents.text_size('Hello World!').height
      # If the text's height is greateer than the windows height
      if ((dh*(ftext1 + ftext2 + ftext3 + ftext3).size) >= self.height-32) and
          self.contents.font.size > 2
        # Resize the font, and try again
        self.contents.font.size -= 1
      # Else: done (or font size too small
      else
        y = 0
        self.contents.font.color = system_color
        y = display_array(ftext1, y, dh)
        self.contents.font.color = normal_color
        y = display_array(ftext2, y, dh)
        self.contents.font.color = system_color
        y = display_array(ftext3, y, dh)
        self.contents.font.color = normal_color
        y = display_array(ftext4, y, dh)
        self.contents.font.size = Font.default_size
        return
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Array to Comma Seperated String
  #--------------------------------------------------------------------------
  def array_2_css(array, type)
    output_text = ''
    array.each_with_index do |id, index|
      if (type == :ELEMENT)
        item = $data_system.elements[id]
      elsif type == :STATE
        item = $data_states[id].name
      end
      if (index + 1) < array.size
        output_text += (item + ', ')
      else
        output_text += (item + '.')
      end
    end
    return output_text
  end
  #--------------------------------------------------------------------------
  # * String to Window Fitted array
  #--------------------------------------------------------------------------
  def string_to_array(text)
    tmp_txt = ''; output_array = []
    for word in text.to_s.split(' ')
      if self.contents.text_size(tmp_txt + word).width > self.width - 32
        output_array.push(tmp_txt)
        tmp_txt = word + ' '
      else
        tmp_txt += (word + ' ')
      end
    end
    return output_array + (tmp_txt + ' ').to_a
  end
  #--------------------------------------------------------------------------
  # * Display Array
  #--------------------------------------------------------------------------
  def display_array(array, y, dy)
    for item in array
      self.contents.draw_text(0, y * dy, self.width, dy, item.to_s)
      y += 1
    end
    return y
  end
end

 


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

class Scene_Equip
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor_index : actor index
  #     equip_index : equipment index
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0, equip_index = 0)
    @actor_index = actor_index
    @equip_index = equip_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Get actor
    @actor = $game_party.actors[@actor_index]
    # Make windows
    @help_window = Window_Help.new
    @left_window = Window_EquipLeft.new(@actor)
    @right_window = Window_EquipRight.new(@actor)
    @element_window = Window_EquipElement.new
    @old_equip = -9
    @item_window1 = Window_EquipItem.new(@actor, 0)
    @item_window2 = Window_EquipItem.new(@actor, 1)
    @item_window3 = Window_EquipItem.new(@actor, 2)
    @item_window4 = Window_EquipItem.new(@actor, 3)
    @item_window5 = Window_EquipItem.new(@actor, 4)
    # Associate help window
    @right_window.help_window = @help_window
    @item_window1.help_window = @help_window
    @item_window2.help_window = @help_window
    @item_window3.help_window = @help_window
    @item_window4.help_window = @help_window
    @item_window5.help_window = @help_window
    # Set cursor position
    @right_window.index = @equip_index
    refresh
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @left_window.dispose
    @right_window.dispose
    @element_window.dispose
    @item_window1.dispose
    @item_window2.dispose
    @item_window3.dispose
    @item_window4.dispose
    @item_window5.dispose
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Set item window to visible
    @item_window1.visible = (@right_window.index == 0)
    @item_window2.visible = (@right_window.index == 1)
    @item_window3.visible = (@right_window.index == 2)
    @item_window4.visible = (@right_window.index == 3)
    @item_window5.visible = (@right_window.index == 4)
    # Get currently equipped item
    item1 = @right_window.item
    # Set current item window to @item_window
    case @right_window.index
    when 0
      @item_window = @item_window1
    when 1
      @item_window = @item_window2
    when 2
      @item_window = @item_window3
    when 3
      @item_window = @item_window4
    when 4
      @item_window = @item_window5
    end
    # If right window is active
    if @right_window.active
      # Erase parameters for after equipment change
      @left_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil, nil)
    end
    # If item window is active
    if @item_window.active
      # Get currently selected item
      item2 = @item_window.item
      # Change equipment
      last_hp = @actor.hp
      last_sp = @actor.sp
      @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
      # Get parameters for after equipment change
      new_atk = @actor.atk
      new_pdef = @actor.pdef
      new_mdef = @actor.mdef
      new_str = @actor.str
      new_dex = @actor.dex
      new_agi = @actor.agi
      new_int = @actor.int
      new_eva = @actor.eva
      # Return equipment
      @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
      @actor.hp = last_hp
      @actor.sp = last_sp
      # Draw in left window
      @left_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex, new_agi, new_int, new_eva)
    end
    # If a new right window index is highlighted, update element window
    if @right_window.active
      new_equip = @actor.equip?(@right_window.index)
    elsif @item_window.active
      new_equip = @item_window.item
    else
      return
    end
    unless (@old_equip == new_equip)
      case @right_window.index
      when 0 then item = new_equip || RPG::Weapon.new
      else        item = new_equip || RPG::Armor.new
      end
      @element_window.set_item(item)
      @old_equip = new_equip
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    unless Input.trigger?(Input::R) or Input.trigger?(Input::L)
      @left_window.update
      @right_window.update
      @item_window.update
    end
    refresh
    # If right window is active: call update_right
    if @right_window.active
      update_right
      return
    end
    # If item window is active: call update_item
    if @item_window.active
      update_item
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when right window is active)
  #--------------------------------------------------------------------------
  def update_right
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Menu.new(2)
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If equipment is fixed
      if @actor.equip_fix?(@right_window.index)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # Activate item window
      @right_window.active = false
      @item_window.active = true
      @item_window.index = 0
      return
    end
    # If R button was pressed
    if Input.trigger?(Input::R)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To next actor
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      # Switch to different equipment screen
      $scene = Scene_Equip.new(@actor_index, @right_window.index)
      return
    end
    # If L button was pressed
    if Input.trigger?(Input::L)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To previous actor
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      # Switch to different equipment screen
      $scene = Scene_Equip.new(@actor_index, @right_window.index)
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when item window is active)
  #--------------------------------------------------------------------------
  def update_item
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Activate right window
      @right_window.active = true
      @item_window.active = false
      @item_window.index = -1
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Play equip SE
      $game_system.se_play($data_system.equip_se)
      # Get currently selected data on the item window
      item = @item_window.item
      # Change equipment
      @actor.equip(@right_window.index, item == nil ? 0 : item.id)
      # Activate right window
      @right_window.active = true
      @item_window.active = false
      @item_window.index = -1
      # Remake right window and item window contents
      @right_window.refresh
      @item_window.refresh
      return
    end
  end
end


#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  Edited to show the item equip at a certain place
#==============================================================================

class Game_Actor
  #--------------------------------------------------------------------------
  # * Equip?
  #     index : 0 = weapon, 1 = head, 2 = body, etc
  #--------------------------------------------------------------------------
  def equip?(index)
    case index
    when 0 then return $data_weapons[@weapon_id]
    when 1 then return $data_armors[@armor1_id]
    when 2 then return $data_armors[@armor2_id]
    when 3 then return $data_armors[@armor3_id]
    when 4 then return $data_armors[@armor4_id]
    when 5 then return $data_armors[@armor5_id]
    end
  end
end
there's only one Ninja an these are the scripts he currently uses:
* Easy Party Switcher by Blizzard (v2.43b)
* Universal Message System (v1.8.0) by Ccoa
* Active-Time-Battle by MakirouAru
* Catergorized Items Menu (v1.3) by albertfish
* Law's Custom Equipment Screen (v2.?) by The Law G14
* Advanced Shop Status Window (v2.0) by RPG Advocate, edited by Fantasist
* Blacksmith Shop (v2.0) by ForeverZer0
* Quest Log System (v3.0) by game_guy
* Enemy HP & MP Bars by Asandril
* Map Location (v1.0) by Hunter x
* Switch Checker by Night_Runners (made for me specifically)
* Redd's TitleIcons by Redd
* Journal (v2.4) by ForeverZer0
* Drago Smooth Scroller (v2.02) by LiTTleDRAgo

KK20

Replace only the first class of Law's script with this one. If there's anything you'd like to know more of, let me know.
class Window_EquipLeft < Window_Base
  X_SHIFT = 0
 
  def letter_grade_for(value)
    case value
    when 0..25
      self.contents.font.color = (@@F_COLOR ||= Color.new(255, 13, 13))
      '(F)'
    when 26..50
      self.contents.font.color = (@@E_COLOR ||= Color.new(255, 78, 17))
      '(E)'
    when 51..100
      self.contents.font.color = (@@D_COLOR ||= Color.new(255, 142, 21))
      '(D)'
    when 101..200
      self.contents.font.color = (@@C_COLOR ||= Color.new(250, 183, 51))
      '(C)'
    when 201..400
      self.contents.font.color = (@@B_COLOR ||= Color.new(172, 179, 52))
      '(B)'
    when 401..750
      self.contents.font.color = (@@A_COLOR ||= Color.new(105, 179, 76))
      '(A)'
    else
      self.contents.font.color = (@@S_COLOR ||= Color.new(53, 214, 237))
      '(S)'
    end
  end
 
  def draw_letter_grade(x, y, value)
    orig_color = self.contents.font.color
    grade = letter_grade_for(value)
    self.contents.draw_text(x, y, 36, 32, grade, 2)
    self.contents.font.color = orig_color
  end
 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(224, 64, 415, 232)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Draw Parameter
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     type  : parameter type (0-6)
  #--------------------------------------------------------------------------
  def draw_actor_parameter(actor, x, y, type)
    case type
    when 0
      parameter_name = $data_system.words.atk
      parameter_value = actor.atk
    when 1
      parameter_name = $data_system.words.pdef
      parameter_value = actor.pdef
    when 2
      parameter_name = $data_system.words.mdef
      parameter_value = actor.mdef
    when 3
      parameter_name = $data_system.words.dex
      parameter_value = actor.dex
    when 4
      parameter_name = $data_system.words.int
      parameter_value = actor.int
    when 5
      parameter_name = $data_system.words.str
      parameter_value = actor.str
    when 6
      parameter_name = $data_system.words.agi
      parameter_value = actor.agi
    when 7
      parameter_name = "Evasion"
      parameter_value = actor.eva
    end
    self.contents.font.size = 16
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 120, 32, parameter_name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 80 + X_SHIFT, y, 36, 32, parameter_value.to_s, 2)
    draw_letter_grade(x + 100 + X_SHIFT, y, parameter_value)
  end
  #--------------------------------------------------------------------------
  # * Draw Actor Face Graphic
  #--------------------------------------------------------------------------
  def draw_actor_face_graphic(actor, x, y)
    #bitmap = RPG::Cache.picture(actor.id.to_s)
    bitmap = RPG::Cache.battler(actor.battler_name, 0)
    x -= bitmap.width / 2 - 30
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------   
  def refresh
    self.contents.clear
    draw_actor_face_graphic(@actor, x + 50, y - 40)
    self.contents.font.size = 18
    draw_actor_level(@actor, 4, -3)
    for i in 0..7
      draw_actor_parameter(@actor, 4, i * 22 + 19, i)
    end
    [[@new_atk, @actor.atk], [@new_pdef, @actor.pdef], [@new_mdef, @actor.mdef],
     [@new_dex, @actor.dex], [@new_int, @actor.int], [@new_str, @actor.str],
     [@new_agi, @actor.agi], [@new_eva, @actor.eva]].each_with_index { |stat, i|
      if stat[0] != nil
        y = i * 22 + 19
        self.contents.font.color = normal_color
        self.contents.draw_text(140 + X_SHIFT, y, 40, 32, '->', 1)
       
        if stat[0] > stat[1]
          self.contents.font.color = Color.new(128, 255, 128)
        elsif (stat[0] < stat[1])
          self.contents.font.color = Color.new(255, 128, 128)
        end
       
        self.contents.draw_text(160 + X_SHIFT, y, 36, 32, stat[0].to_s, 2)
        draw_letter_grade(180 + X_SHIFT, y, stat[0])
      end
     }
  end
  #--------------------------------------------------------------------------
  # * Set parameters after changing equipment
  #     new_atk  : attack power after changing equipment
  #     new_pdef : physical defense after changing equipment
  #     new_mdef : magic defense after changing equipment
  #--------------------------------------------------------------------------
  def set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex,
                         new_agi, new_int, new_eva)
    if @new_atk != new_atk || @new_pdef != new_pdef || @new_mdef != new_mdef ||
        @new_str != new_str || @new_dex != new_dex || @new_agi != new_agi ||
        @new_int != new_int || @new_eva != new_eva
      @new_atk = new_atk
      @new_pdef = new_pdef
      @new_mdef = new_mdef
      @new_str = new_str
      @new_dex = new_dex
      @new_agi = new_agi
      @new_int = new_int
      @new_eva = new_eva
      refresh
    end
  end
end

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Ninjason

May 07, 2022, 04:04:55 am #2 Last Edit: May 07, 2022, 04:08:03 am by Ninjason Reason: IMG link wasn't correct
First of all: KK20, thank you very much, this is an awesome addition!

I actually had three follow-up questions, but I was so inspired by how happy I am with your addition, that (almost by accident) I finally successfully hid the EVASION stat, which I have tried for years, since it is a stat I do not use in my game  :haha:
Also, when showing the new stats during equip selection, I managed to reduce all stats who do not change in font size to highlight what's important right now, since there are a lot of colours now on the screen.



I felt empowered and this, I credit to you :)

My last question then is the following:
Currently, there is only a single section to define a scale which all stats use, but since my stats follow different scalings ingame, I would need more and each referring to a single stat (maybe grouping STR/DEX/INT and MDEF/PDEF would work, but AGI and ATK would definitely need a seperate one)

Can I multiply the section def letter_grade_for(value) which you created somehow and make it refer to a specific stat each time?
So far I haven't gotten it to work, I tried chaning "value" to equate a specific stat (like value = actor.atk just to try if it would work) but that nets me is an error message when opening the equip screen, saying

"NameERROR occured. undefined local variable or method 'actor' for #<Window_EquipLeft:0xe9ffc70>"

I tried moving the sections around a bit, but I'm guessing I'm just on a completely wrong track here.


there's only one Ninja an these are the scripts he currently uses:
* Easy Party Switcher by Blizzard (v2.43b)
* Universal Message System (v1.8.0) by Ccoa
* Active-Time-Battle by MakirouAru
* Catergorized Items Menu (v1.3) by albertfish
* Law's Custom Equipment Screen (v2.?) by The Law G14
* Advanced Shop Status Window (v2.0) by RPG Advocate, edited by Fantasist
* Blacksmith Shop (v2.0) by ForeverZer0
* Quest Log System (v3.0) by game_guy
* Enemy HP & MP Bars by Asandril
* Map Location (v1.0) by Hunter x
* Switch Checker by Night_Runners (made for me specifically)
* Redd's TitleIcons by Redd
* Journal (v2.4) by ForeverZer0
* Drago Smooth Scroller (v2.02) by LiTTleDRAgo

KK20

Here's the updated class
class Window_EquipLeft < Window_Base
  X_SHIFT = 0
 
  def letter_grade_for(value, type)
    grade = case type
    # 0 - ATK
    # 1 - PDEF
    # 2 - MDEF
    # 3 - DEX
    # 4 - INT
    # 5 - STR
    # 6 - AGI
    # 7 - EVA
    when 3, 4, 5
      case value
      when 0..25 then :F
      when 26..50 then :E
      when 51..100 then :D
      when 101..200 then :C
      when 201..400 then :B
      when 401..750 then :A
      else :S
      end
    when 1, 2
      case value
      when 0..50 then :F
      when 51..100 then :E
      when 101..200 then :D
      when 201..400 then :C
      when 401..600 then :B
      when 601..750 then :A
      else :S
      end
    when 0
      # you know what to do
    when 6
      # you know what to do
    end
   
    case grade
    when :F
      self.contents.font.color.set(255, 13, 13)
    when :E
      self.contents.font.color.set(255, 78, 17)
    when :D
      self.contents.font.color.set(255, 142, 21)
    when :C
      self.contents.font.color.set(250, 183, 51)
    when :B
      self.contents.font.color.set(172, 179, 52)
    when :A
      self.contents.font.color.set(105, 179, 76)
    else
      self.contents.font.color.set(53, 214, 237)
    end
    "(#{grade})"
  end
 
  def draw_letter_grade(x, y, value, type)
    orig_color = self.contents.font.color
    grade = letter_grade_for(value, type)
    self.contents.draw_text(x, y, 36, 32, grade, 2)
    self.contents.font.color = orig_color
  end
 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(224, 64, 415, 232)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Draw Parameter
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     type  : parameter type (0-6)
  #--------------------------------------------------------------------------
  def draw_actor_parameter(actor, x, y, type)
    case type
    when 0
      parameter_name = $data_system.words.atk
      parameter_value = actor.atk
    when 1
      parameter_name = $data_system.words.pdef
      parameter_value = actor.pdef
    when 2
      parameter_name = $data_system.words.mdef
      parameter_value = actor.mdef
    when 3
      parameter_name = $data_system.words.dex
      parameter_value = actor.dex
    when 4
      parameter_name = $data_system.words.int
      parameter_value = actor.int
    when 5
      parameter_name = $data_system.words.str
      parameter_value = actor.str
    when 6
      parameter_name = $data_system.words.agi
      parameter_value = actor.agi
    when 7
      parameter_name = "Evasion"
      parameter_value = actor.eva
    end
    self.contents.font.size = 16
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 120, 32, parameter_name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 80 + X_SHIFT, y, 36, 32, parameter_value.to_s, 2)
    draw_letter_grade(x + 100 + X_SHIFT, y, parameter_value, type)
  end
  #--------------------------------------------------------------------------
  # * Draw Actor Face Graphic
  #--------------------------------------------------------------------------
  def draw_actor_face_graphic(actor, x, y)
    #bitmap = RPG::Cache.picture(actor.id.to_s)
    bitmap = RPG::Cache.battler(actor.battler_name, 0)
    x -= bitmap.width / 2 - 30
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------   
  def refresh
    self.contents.clear
    draw_actor_face_graphic(@actor, x + 50, y - 40)
    self.contents.font.size = 18
    draw_actor_level(@actor, 4, -3)
    for i in 0..7
      draw_actor_parameter(@actor, 4, i * 22 + 19, i)
    end
    [[@new_atk, @actor.atk], [@new_pdef, @actor.pdef], [@new_mdef, @actor.mdef],
     [@new_dex, @actor.dex], [@new_int, @actor.int], [@new_str, @actor.str],
     [@new_agi, @actor.agi], [@new_eva, @actor.eva]].each_with_index { |stat, i|
      if stat[0] != nil
        y = i * 22 + 19
        self.contents.font.color = normal_color
        self.contents.draw_text(140 + X_SHIFT, y, 40, 32, '->', 1)
       
        if stat[0] > stat[1]
          self.contents.font.color = Color.new(128, 255, 128)
        elsif (stat[0] < stat[1])
          self.contents.font.color = Color.new(255, 128, 128)
        end
       
        self.contents.draw_text(160 + X_SHIFT, y, 36, 32, stat[0].to_s, 2)
        draw_letter_grade(180 + X_SHIFT, y, stat[0], i)
      end
     }
  end
  #--------------------------------------------------------------------------
  # * Set parameters after changing equipment
  #     new_atk  : attack power after changing equipment
  #     new_pdef : physical defense after changing equipment
  #     new_mdef : magic defense after changing equipment
  #--------------------------------------------------------------------------
  def set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex,
                         new_agi, new_int, new_eva)
    if @new_atk != new_atk || @new_pdef != new_pdef || @new_mdef != new_mdef ||
        @new_str != new_str || @new_dex != new_dex || @new_agi != new_agi ||
        @new_int != new_int || @new_eva != new_eva
      @new_atk = new_atk
      @new_pdef = new_pdef
      @new_mdef = new_mdef
      @new_str = new_str
      @new_dex = new_dex
      @new_agi = new_agi
      @new_int = new_int
      @new_eva = new_eva
      refresh
    end
  end
end
I'll let you finish configuring the case-statements.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Ninjason

KK20, thank you again, this is magnificent!

I have just completed configuring each scale and introduced several sub-ranks (E-, E+, C-, C+...)

I have just one last question and I think it's a small one, but too complicated for me and searching the web has so far produced no answer.
I feel a bit awkward to ask this, as I do not want to seem picky or ungrateful - I am SO happy with this, I cannot even articulate it  :D
My question is: "Is there a way for me to align the grades shown in the eqip screen to their left instead of their center?"


 (I'm kind of surprised, I thought the answer would be some easy snippet like "text.align = left" or something of that sort and being mentioned on a multitude of "how-to-ruby scripting"-websites...)

The problem is, now that I have introduced strings of different lengths 'C' vs. 'C +' their right-alignment produces a jumpy look &feel.
The stat values to their left seem to be right-aligned also, but this looks quite neatly. I want to align the ranks on their left, so the letters are always ordered in a straight line downwards with an occasional + or - to their right
I have tried working with additional spaces within the strings like  'C +' vs. 'C  ' but ' ', '-' and '+' all have different widths when displayed onscreen (different to the apparent lengths of their strings in the script), so it just does not work properly.


there's only one Ninja an these are the scripts he currently uses:
* Easy Party Switcher by Blizzard (v2.43b)
* Universal Message System (v1.8.0) by Ccoa
* Active-Time-Battle by MakirouAru
* Catergorized Items Menu (v1.3) by albertfish
* Law's Custom Equipment Screen (v2.?) by The Law G14
* Advanced Shop Status Window (v2.0) by RPG Advocate, edited by Fantasist
* Blacksmith Shop (v2.0) by ForeverZer0
* Quest Log System (v3.0) by game_guy
* Enemy HP & MP Bars by Asandril
* Map Location (v1.0) by Hunter x
* Switch Checker by Night_Runners (made for me specifically)
* Redd's TitleIcons by Redd
* Journal (v2.4) by ForeverZer0
* Drago Smooth Scroller (v2.02) by LiTTleDRAgo

KK20

The draw_text function takes in an optional parameter at the end that changes the alignment. Look up Bitmap in the Help File:
Quotedraw_text(x, y, width, height, str[, align])
draw_text(rect, str[, align])
Draws a string str in the bitmap box (x, y, width, height) or rect (Rect).

If the text length exceeds the box's width, the text width will automatically be reduced by up to 60 percent.

Horizontal text is left-aligned by default; set align to 1 to center the text and to 2 to right-align it. Vertical text is always centered.

As this process is time-consuming, redrawing the text with every frame is not recommended.
The draw_letter_grade is currently set to right-align
  def draw_letter_grade(x, y, value, type)
    orig_color = self.contents.font.color
    grade = letter_grade_for(value, type)
    self.contents.draw_text(x, y, 36, 32, grade, 2) #<======== 2 is right-align
    self.contents.font.color = orig_color
  end
So the solution would be to remove that 2, thereby making it left-aligned. Then adjust the x and y coordinates as needed.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Ninjason

Outstanding!
All is set and works as envisioned - again, thank you very much :)
You have made a stranger on the internet and his small playerbase very happy all the best to you and this forum :D
there's only one Ninja an these are the scripts he currently uses:
* Easy Party Switcher by Blizzard (v2.43b)
* Universal Message System (v1.8.0) by Ccoa
* Active-Time-Battle by MakirouAru
* Catergorized Items Menu (v1.3) by albertfish
* Law's Custom Equipment Screen (v2.?) by The Law G14
* Advanced Shop Status Window (v2.0) by RPG Advocate, edited by Fantasist
* Blacksmith Shop (v2.0) by ForeverZer0
* Quest Log System (v3.0) by game_guy
* Enemy HP & MP Bars by Asandril
* Map Location (v1.0) by Hunter x
* Switch Checker by Night_Runners (made for me specifically)
* Redd's TitleIcons by Redd
* Journal (v2.4) by ForeverZer0
* Drago Smooth Scroller (v2.02) by LiTTleDRAgo