Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Target name script edit

I found this script that shows the name of the target of an attack in a small window above the battler. I would like it if the script could be edited in 2 ways.
1) Make it so that the windows are as wide as the target name instead of the set 192 width.
2) Make it so the windows will also appear when targeting an ally.

The script:
Code:
# Â
 

poccil

Sponsor

The following script code applies the changes you requested.

Code:
class Window_TargetName < Window_Help
  def initialize
    super
    self.width = 192
    self.height = 64
    self.contents = Bitmap.new(width - 32, height - 32)
    @base_window = Window_Base.new(x, y+16, width, 32)
    @base_window.opacity = 160
    self.opacity = 0
    self.visible = false
  end
  def x=(n)
    super
    @base_window.x = n unless @base_window.nil?
  end
  def y=(n)
    super
    @base_window.y = n + 16 unless @base_window.nil?
  end
  def visible=(b)
    super
    @base_window.visible = b unless @base_window.nil?
  end
  def dispose
    @base_window.dispose
    super
  end
  def width=(n)
    super
    self.contents.dispose if self.contents
    self.contents=Bitmap.new(self.width - 32, self.height - 32)
    @base_window.width = n unless @base_window.nil?
  end
  def set_actor(actor)
    set_text(actor.name,1)
  end
  def set_text(text,align)
    self.width=self.contents.text_size(text).width+48
    super(text+"???",align)
    super(text,align)
  end
end


class Game_Battler
  def battler_rect
    bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
    return Rect.new(self.screen_x, self.screen_y, bitmap.width, bitmap.height)
  end
end

class Arrow_Base
  alias petero_targetname_Arrow_Base_update update
  def update
    petero_targetname_Arrow_Base_update
    if @help_window != nil
      rect = self.battler_rect
      @help_window.x = [  0 + rect.x - @help_window.width/2, 4].max
      @help_window.y = [-48 + rect.y - rect.height         , 4].max
    end
  end
end

class Arrow_Enemy < Arrow_Base
  def battler_rect
    return self.enemy.battler_rect
  end
end

class Arrow_Actor < Arrow_Base
  def battler_rect
    return self.actor.battler_rect
  end
end


class Scene_Battle
  alias xrxs_bp22_main main
  def main
    @targetname_window = Window_TargetName.new
    xrxs_bp22_main
    @targetname_window.dispose
  end
  alias xrxs_bp22_start_enemy_select start_enemy_select
  def start_enemy_select
    xrxs_bp22_start_enemy_select
    return if @enemy_arrow == nil
    @enemy_arrow.help_window = @targetname_window
    @enemy_arrow.update
    @help_window.visible = false
  end
  alias xrxs_bp22_end_enemy_select end_enemy_select
  def end_enemy_select
    xrxs_bp22_end_enemy_select
    @targetname_window.visible = false
  end
  alias petero_targetname_Scene_Battle_start_actor_select start_actor_select
  def start_actor_select
    petero_targetname_Scene_Battle_start_actor_select
    return if @actor_arrow == nil
    @actor_arrow.help_window = @targetname_window
    @actor_arrow.update
    @help_window.visible = false
  end
  alias petero_targetname_Scene_Battle_end_actor_select end_actor_select
  def end_actor_select
    petero_targetname_Scene_Battle_end_actor_select
    @targetname_window.visible = false
  end
end
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top