Show weapon icon in the attack option and message

Hello everyone! I apologize if the title is confusing, but my request is simple (or at least I think it is).

I want the icon of the currently equipped weapon to appear next to the "attack" option during battle, so that the player knows that when attacking, he uses that particular weapon.

And when attacking, the message "Player used X" should show on the battle log, where X is the name of the equipped weapon, along with the weapon icon beside it. Here's a image visually illustrating what I want to happen when the player has the Long Sword equipped:

script_request.jpg



I use the following scripts related to battle:
Yanfly Engine Ace - Ace Core Engine v1.09
Yanfly Engine Ace - Ace Battle Engine v1.22
Yanfly Engine Ace - Battle Engine Add-On: Elemental Popups v1.00
Yanfly Engine Ace - Battle Engine Add-On: Enemy HP Bars v1.10
Yanfly Engine Ace - Visual Battlers v1.01
Yanfly Engine Ace - State Animations v1.01
Yanfly Engine Ace - Victory Aftermath v1.04


I don't know if it's relevant, but I also use the Ace Message System v1.05 script, which improves the VX Ace's message system. I have some other scripts installed but i dont think they relevant or related to what im requesting.

Thanks in advance!
I haven't tested with those other scripts, but see if this works:
Ruby:
class Window_BattleLog < Window_Selectable

  alias amn_atkmsg_battlelog_displayuseitem display_use_item
  def display_use_item(subject, item)
    if item.is_a?(RPG::Skill)
      add_text(subject.name + parse_text_for_weapon(item.message1, subject))
      unless item.message2.empty?
        wait
        add_text(item.message2)
      end
      return
    else
      amn_atkmsg_battlelog_displayuseitem(subject, item)
    end
  end

  def parse_text_for_weapon(text, subject)
    result = text.to_s.clone
    if subject.is_a?(Game_Actor)
      weapon = subject.weapons[0]
      res = " uses \\i[#{weapon.icon_index}]#{weapon.name}" if weapon
    end
    res = " attacks" unless res
    result.gsub!(/\[weapon\]/i)  { res }
    result
  end

end

EDIT: Sorry, forgot to explain how to use it. Change the message for any of the skills in the database to say [weapon] and it will replace the message to say "uses X", where X is the first weapon you have equipped. It will just say "attacks" for enemies.
I haven't tested with those other scripts, but see if this works:
Ruby:
class Window_BattleLog < Window_Selectable

  alias amn_atkmsg_battlelog_displayuseitem display_use_item
  def display_use_item(subject, item)
    if item.is_a?(RPG::Skill)
      add_text(subject.name + parse_text_for_weapon(item.message1, subject))
      unless item.message2.empty?
        wait
        add_text(item.message2)
      end
      return
    else
      amn_atkmsg_battlelog_displayuseitem(subject, item)
    end
  end

  def parse_text_for_weapon(text, subject)
    result = text.to_s.clone
    if subject.is_a?(Game_Actor)
      weapon = subject.weapons[0]
      res = " uses \\i[#{weapon.icon_index}]#{weapon.name}" if weapon
    end
    res = " attacks" unless res
    result.gsub!(/\[weapon\]/i)  { res }
    result
  end

end

EDIT: Sorry, forgot to explain how to use it. Change the message for any of the skills in the database to say [weapon] and it will replace the message to say "uses X", where X is the first weapon you have equipped. It will just say "attacks" for enemies.

It works perfectly, thanks. The only thing missing is the icon next to the "attack" option in the battle menu.

Thanks again, A-Moonless-Night, is the second time you help me with a script. Thank you very much! : D
Sorry, missed the bit about having the icon in the command window. Here you go:
Ruby:
class Window_ActorCommand < Window_Command
 
  alias amn_icon_windactorcmd_drawitem  draw_item
  def draw_item(index)
    if @list[index][:symbol] == :attack
      change_color(normal_color, command_enabled?(index))
      rect = item_rect_for_text(index)
      icon_id = @actor && @actor.weapons[0] ? @actor.weapons[0].icon_index : 0
      draw_icon(icon_id, rect.x, rect.y)
      if icon_id > 0
        rect.x += 24
        rect.width -= 24
      end
      draw_text(rect, command_name(index), alignment)
    else
      amn_icon_windactorcmd_drawitem(index)
    end
  end
 
end
Sorry, missed the bit about having the icon in the command window. Here you go:
Ruby:
class Window_ActorCommand < Window_Command

  alias amn_icon_windactorcmd_drawitem  draw_item
  def draw_item(index)
    if @list[index][:symbol] == :attack
      change_color(normal_color, command_enabled?(index))
      rect = item_rect_for_text(index)
      icon_id = @actor && @actor.weapons[0] ? @actor.weapons[0].icon_index : 0
      draw_icon(icon_id, rect.x, rect.y)
      if icon_id > 0
        rect.x += 24
        rect.width -= 24
      end
      draw_text(rect, command_name(index), alignment)
    else
      amn_icon_windactorcmd_drawitem(index)
    end
  end

end

Thanks. Do i add this to the already existing script i created or i make another one?
Either either.

Original thread: https://forums.rpgmakerweb.com/threads/show-weapon-icon-in-the-attack-option-and-message.116734/