Use text codes in enemy names

I have a plan for a boss in my game that gains a variable every time he's hit. When the variable gets to 10, he uses a certain attack.

To help the player, I want his name to display the variable. How would I go about doing this? Unless I'm mistaken, there seems to be no way to achieve this by default. Which is strange, as text codes are usable in descriptions
I have a plan for a boss in my game that gains a variable every time he's hit. When the variable gets to 10, he uses a certain attack.

To help the player, I want his name to display the variable. How would I go about doing this? Unless I'm mistaken, there seems to be no way to achieve this by default. Which is strange, as text codes are usable in descriptions
So is that the name in the enemy window when you select which enemy to attack?
Yep. And the name in the database by extension
I have a plan for a boss in my game that gains a variable every time he's hit. When the variable gets to 10, he uses a certain attack.

To help the player, I want his name to display the variable. How would I go about doing this? Unless I'm mistaken, there seems to be no way to achieve this by default. Which is strange, as text codes are usable in descriptions
Try this
Spoiler: Enemy Strike After X Hits
Ruby:
# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: Enemy Strike After X Hits              ║  Version: 1.01     ║
# ║ Author: Roninator2                            ║                    ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function:                                     ║   Date Created     ║
# ║                                               ╠════════════════════╣
# ║   Alter Enemy Skill action                    ║    04 Apr 2024     ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires: nil                                                      ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description:                                                 ║
# ║        Set the enemy action to another skill                       ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions:                                                      ║
# ║   Configure settings below                                         ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates:                                                           ║
# ║ 1.00 - 04 Apr 2024 - Script finished                               ║
# ║ 1.01 - 04 Apr 2024 - Cleaned up Code                               ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Credits and Thanks:                                                ║
# ║   Roninator2                                                       ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Terms of use:                                                      ║
# ║  Follow the original Authors terms of use where applicable         ║
# ║    - When not made by me (Roninator2)                              ║
# ║  Free for all uses in RPG Maker except nudity                      ║
# ║  Anyone using this script in their project before these terms      ║
# ║  were changed are allowed to use this script even if it conflicts  ║
# ║  with these new terms. New terms effective 03 Apr 2024             ║
# ║  No part of this code can be used with AI programs or tools        ║
# ║  Credit must be given                                              ║
# ╚════════════════════════════════════════════════════════════════════╝

module R2_Enemy_Name_Var
  # Assign the variable to be used with an enemy and limit
  # limit is the number used to check the action.
  # when the variable reaches the limit the action is changed
  ENEMY_VARS = {
                # enemy_id => [variable, limit, skill id],
                31 => [21, 2, 5],
                5 => [22, 5, 12],
                }
  # will set the variables in the list above to 0 at battle start
  RESET_VARS = true
  # only show a number if it is higher than 0
  AFTER_ZERO = true
end

# ╔════════════════════════════════════════════════════════════════════╗
# ║                      End of editable region                        ║
# ╚════════════════════════════════════════════════════════════════════╝

class Game_Action
  #--------------------------------------------------------------------------
  # * Set Battle Action of Enemy Character
  #     action : RPG::Enemy::Action
  #--------------------------------------------------------------------------
  def set_enemy_fixed_action(id)
    set_skill(id)
  end
end

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # * Create Battle Action
  #--------------------------------------------------------------------------
  def make_actions
    super
    return if @actions.empty?
    action_list = enemy.actions.select {|a| action_valid?(a) }
    return if action_list.empty?
    rating_max = action_list.collect {|a| a.rating }.max
    rating_zero = rating_max - 3
    action_list.reject! {|a| a.rating <= rating_zero }
    @actions.each do |action|
      enmy = R2_Enemy_Name_Var::ENEMY_VARS[@enemy_id]
      if enmy != nil && ($game_variables[enmy[0]] >= enmy[1])
        action.clear
        action.set_enemy_fixed_action(enmy[2])
      else
        action.set_enemy_action(select_enemy_action(action_list, rating_zero))
      end
    end
  end
end

class Window_BattleEnemy < Window_Selectable
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index)
    change_color(normal_color)
    name = $game_troop.alive_members[index].name
    data = R2_Enemy_Name_Var::ENEMY_VARS[$game_troop.alive_members[index].enemy_id]
    if ($game_variables[data[0]] > 0) && R2_Enemy_Name_Var::AFTER_ZERO
      name = name + " " + ($game_variables[data[0]]).to_s 
    elsif !R2_Enemy_Name_Var::AFTER_ZERO
      name = name + " " + ($game_variables[data[0]]).to_s 
    end
    draw_text(item_rect_for_text(index), name)
  end
end

class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # * Apply Effect of Skill/Item
  #--------------------------------------------------------------------------
  alias :r2_change_name_on_hit_item_apply   :item_apply
  def item_apply(user, item)
    r2_change_name_on_hit_item_apply(user, item)
    if @result.hit?
      if user.is_a?(Game_Actor)
        numb = user.actions[0].target_index
        data = R2_Enemy_Name_Var::ENEMY_VARS[$game_troop.members[numb].enemy_id]
        if $game_variables[data[0]] >= data[1]
          $game_variables[data[0]] = 0
          return
        end
        $game_variables[data[0]] += 1
      end
    end
  end
end

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  alias :r2_battle_start_reset_vars   :start
  def start
    R2_Enemy_Name_Var::ENEMY_VARS.each do |enm, num|
      $game_variables[num[0]] = 0 if R2_Enemy_Name_Var::RESET_VARS
    end
    r2_battle_start_reset_vars
  end
end
Oh, I don't need a script for that. Just displaying the variable

Original thread: https://forums.rpgmakerweb.com/threads/use-text-codes-in-enemy-names.167406/