Jump to content
Sign in to follow this  
roninator2

VTS Enemy HP Bars addon - Enemy Selection

Recommended Posts

VTS Enemy HP Bars addon - Enemy Selection 1.04
by Roninator2


Introduction
An addon to make the enemy hp bars only show up if the enemy is selected in the enemy battle window

Features
- Plug & play

How to Use
Put below VTS Enemy HP Bars script

Images

Spoiler

1609702450579.png.245a60460258388386b2b7f50dd93963.png

 

 

Script - two options

 

Spoiler

# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Ventwig Enemy HP Selection   ║  Version: 1.04     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║                                     ╠════════════════════╣
# ║ Show hp only for enemy selected     ║    03 Jan 2021     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Requires: Ventwig Enemy HP Bars Script                   ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Script adjusts Ventwigs script to make the Bars shown to ║
# ║ only be visible on the enemy when that enemy is selected ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Updates:                                                 ║
# ║ 1.00 - 03 Jan 2021 - Initial publish                     ║
# ║ 1.01 - 03 Jan 2021 - Fixed glitch in battle processing   ║
# ║ 1.02 - 03 Jan 2021 - show hp when enemy is attacked      ║
# ║ 1.03 - 03 Jan 2021 - Fixed HP showing when enemy attacked║
# ║ 1.04 - 05 Jan 2021 - Corrected for hidden enemies & bug  ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Terms of use:                                            ║
# ║ Follow the Original Authors terms                        ║
# ╚══════════════════════════════════════════════════════════╝
module R2_Enemy_Hud_Hold_Time
  Hold_Time = 120
end
class Window_Enemy_Hud < Window_Base
  attr_accessor :damage_time
  alias r2_init_enemy_hp initialize
  def initialize
    r2_init_enemy_hp
    show_hp(false)
  end
 
  def show_hp(value = false)
    @show_hp = value
  end
 
  def enemy_id(value = -1)
    @enemy_id = value
  end
 
  def hold_hp
    @show_hp = false if @damage_time == 0
    for i in 0..@etroop.alive_members.size-1
      e = @enemy[i]
      next if e.nil? # for hidden enemies
      if $game_switches[EHUD::HIDE_MINIONS] != true && @show_hp == true && @damage_time != 0 && e.index == @enemy_id
        draw_actor_hp(e,e.screen_x-50,e.screen_y+EHUD::Y_MOVE-50+e.personal_y,width=96) unless @damage_time == 0
      end
    end
  end
 
  def damage_time(value = 0)
    @damage_time = value
  end

  def update
    if @damage_time != nil
      @damage_time -= 1 if @damage_time != 0
    end
    hold_hp
    refresh_okay = false
    $game_troop.alive_members.each do |enemy|
      if enemy.hp != enemy.old_hp || enemy.mp != enemy.old_mp
        refresh_okay = true
        enemy.old_hp = enemy.hp
        enemy.old_mp = enemy.mp
      end
    end
  
    if $game_troop.alive_members.size != @old_size
      refresh_okay = true
    end
  
    if refresh_okay
      refresh
    end
  end

  def enemy_hud
    troop_fix
    for i in 0..@etroop.alive_members.size-1
      e = @enemy[i]
      if i <= 1 and e.boss_bar == true and e == @boss_enemy[i]
        draw_actor_name(e,EHUD::BOSS_GAUGEX,5+50*i)
        draw_actor_hp(e,EHUD::BOSS_GAUGEX,20+50*i,width=EHUD::BOSS_GAUGEW) unless e.hide_hp == true
        draw_actor_mp(e,EHUD::BOSS_GAUGEX,30+50*i,width=EHUD::BOSS_GAUGEW) unless e.show_mp == false
        draw_actor_icons(e,EHUD::BOSS_GAUGEX+200,5+50*i, width = 96)
      elsif ($game_switches[EHUD::HIDE_MINIONS] != true && @show_hp == true) && e.index == @enemy_id
        draw_actor_hp(e,e.screen_x-50,e.screen_y+EHUD::Y_MOVE-50+e.personal_y,width=96) unless e.hide_hp == true
        draw_actor_mp(e,e.screen_x-50,e.screen_y+EHUD::Y_MOVE-40+e.personal_y,width=96) unless e.show_mp == false
        draw_actor_icons(e,e.screen_x-50,e.screen_y+EHUD::Y_MOVE-70+e.personal_y,width=96)
      end
    end
  end
end

class Scene_Battle < Scene_Base
 
  alias r2_update_basic_hp  update_basic
  def update_basic
    if @enemy_window.active
      enemy_hp_shown(true)
    else
      enemy_hp_shown(false) if (!@subject && @enemy_hud_window.damage_time = 0) && !@enemy_window.active
    end
    r2_update_basic_hp
  end
 
  alias r2_execute_hp_show  execute_action
  def execute_action
    targets = @subject.current_action.make_targets.compact
    targets.each { |e|
    e.is_a?(Game_Actor) ? next : enemy_hp_shown(true)
    @enemy_hud_window.enemy_id(e.index)
    @enemy_hud_window.damage_time(R2_Enemy_Hud_Hold_Time::Hold_Time)}
    r2_execute_hp_show
    @enemy_hud_window.refresh
  end

  def enemy_hp_shown(value = false)
    @enemy_hud_window.show_hp(value)
    if @enemy_window.enemy != nil
      @enemy_hud_window.enemy_id(@enemy_window.enemy.index)
    end
    @enemy_window.refresh
    @enemy_hud_window.refresh
  end
end

 

 

Spoiler

# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Ventwig Enemy HP Selection   ║  Version: 1.05     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║                                     ╠════════════════════╣
# ║ Show hp only for enemy selected     ║    03 Jan 2021     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Requires: Ventwig Enemy HP Bars Script                   ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Script adjusts Ventwigs script to make the Bars shown to ║
# ║ only be visible on the enemy when that enemy is selected ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Updates:                                                 ║
# ║ 1.00 - 03 Jan 2021 - Initial publish                     ║
# ║ 1.01 - 03 Jan 2021 - Fixed glitch in battle processing   ║
# ║ 1.02 - 03 Jan 2021 - show hp when enemy is attacked      ║
# ║ 1.03 - 03 Jan 2021 - Fixed HP showing when enemy attacked║
# ║ 1.04 - 05 Jan 2021 - Corrected for hidden enemies & bug  ║
# ║ 1.05 - 06 Jan 2021 - Added show hp for all enemies skills║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Terms of use:                                            ║
# ║ Follow the Original Authors terms                        ║
# ╚══════════════════════════════════════════════════════════╝
module R2_Enemy_Hud_Hold_Time
  Hold_Time = 120
end

class Window_Enemy_Hud < Window_Base
  attr_accessor :damage_time
  alias r2_init_enemy_hp initialize
  def initialize
    r2_init_enemy_hp
    show_hp(false)
    show_hp_all(false)
  end
 
  def show_hp(value = false)
    @show_hp = value
  end
 
  def show_hp_all(value = false)
    @show_hp_all = value
  end

  def enemy_id(value = -1)
    @enemy_id = value
  end
 
  def hold_hp
    @show_hp = false if @damage_time == 0
    for i in 0..@etroop.alive_members.size-1
      e = @enemy[i]
      next if e.nil? # for hidden enemies
      if $game_switches[EHUD::HIDE_MINIONS] != true && @show_hp == true && @damage_time != 0 && e.index == @enemy_id
        draw_actor_hp(e,e.screen_x-50,e.screen_y+EHUD::Y_MOVE-50+e.personal_y,width=96) unless @damage_time == 0
      end
    end
  end
 
  def damage_time(value = 0)
    @damage_time = value
  end

  def update
    if @damage_time != nil
      @damage_time -= 1 if @damage_time != 0
    end
    hold_hp
    refresh_okay = false
    $game_troop.alive_members.each do |enemy|
      if enemy.hp != enemy.old_hp || enemy.mp != enemy.old_mp
        refresh_okay = true
        enemy.old_hp = enemy.hp
        enemy.old_mp = enemy.mp
      end
    end
  
    if $game_troop.alive_members.size != @old_size
      refresh_okay = true
    end
  
    if refresh_okay
      refresh
    end
  end

  def enemy_hud
    troop_fix
    for i in 0..@etroop.alive_members.size-1
      e = @enemy[i]
      if i <= 1 and e.boss_bar == true and e == @boss_enemy[i]
        draw_actor_name(e,EHUD::BOSS_GAUGEX,5+50*i)
        draw_actor_hp(e,EHUD::BOSS_GAUGEX,20+50*i,width=EHUD::BOSS_GAUGEW) unless e.hide_hp == true
        draw_actor_mp(e,EHUD::BOSS_GAUGEX,30+50*i,width=EHUD::BOSS_GAUGEW) unless e.show_mp == false
        draw_actor_icons(e,EHUD::BOSS_GAUGEX+200,5+50*i, width = 96)
      elsif ($game_switches[EHUD::HIDE_MINIONS] != true && @show_hp_all == true)
        draw_actor_hp(e,e.screen_x-50,e.screen_y+EHUD::Y_MOVE-50+e.personal_y,width=96) unless e.hide_hp == true
        draw_actor_mp(e,e.screen_x-50,e.screen_y+EHUD::Y_MOVE-40+e.personal_y,width=96) unless e.show_mp == false
        draw_actor_icons(e,e.screen_x-50,e.screen_y+EHUD::Y_MOVE-70+e.personal_y,width=96)
      elsif ($game_switches[EHUD::HIDE_MINIONS] != true && @show_hp == true) && e.index == @enemy_id
        draw_actor_hp(e,e.screen_x-50,e.screen_y+EHUD::Y_MOVE-50+e.personal_y,width=96) unless e.hide_hp == true
        draw_actor_mp(e,e.screen_x-50,e.screen_y+EHUD::Y_MOVE-40+e.personal_y,width=96) unless e.show_mp == false
        draw_actor_icons(e,e.screen_x-50,e.screen_y+EHUD::Y_MOVE-70+e.personal_y,width=96)
      end
    end
  end
end

class Scene_Battle < Scene_Base
 
  alias r2_update_basic_hp  update_basic
  def update_basic
    if @enemy_window.active
      enemy_hp_shown(true)
    else
      enemy_hp_shown(false) if (!@subject && @enemy_hud_window.damage_time = 0) && !@enemy_window.active
    end
    r2_update_basic_hp
  end
 
  alias r2_execute_hp_show  execute_action
  def execute_action
    skill_check = false
    @skill = @skill_window.item
    targets = @subject.current_action.make_targets.compact
    targets.each { |e|
    e.is_a?(Game_Actor) ? next : @skill.nil? ? enemy_hp_shown(true) : skill_check = true
    @enemy_hud_window.enemy_id(e.index)
    @enemy_hud_window.damage_time(R2_Enemy_Hud_Hold_Time::Hold_Time)
    if skill_check == true
      case @skill.scope
      when 1
        @enemy_hud_window.enemy_id(e.index)
        enemy_hp_shown(true)
      when 2
        enemy_hp_shown_all(true)
        @enemy_hud_window.damage_time(R2_Enemy_Hud_Hold_Time::Hold_Time * 2)
      when 3
        enemy_hp_shown_all(true)
        @enemy_hud_window.damage_time(R2_Enemy_Hud_Hold_Time::Hold_Time * 2)
      when 4
        enemy_hp_shown_all(true)
        @enemy_hud_window.damage_time(R2_Enemy_Hud_Hold_Time::Hold_Time * 2)
      when 5
        enemy_hp_shown_all(true)
        @enemy_hud_window.damage_time(R2_Enemy_Hud_Hold_Time::Hold_Time * 2)
      when 6
        enemy_hp_shown_all(true)
        @enemy_hud_window.damage_time(R2_Enemy_Hud_Hold_Time::Hold_Time * 2)
      end
      skill_check = false
    end
    }
    r2_execute_hp_show
    enemy_hp_shown_all(false)
  end
 
  alias r2_skill_enemy_select   select_enemy_selection
  def select_enemy_selection
    @skill = @skill_window.item
    if !@skill.nil?
      case @skill.scope
      when 1
        @enemy_hud_window.enemy_id(e.index)
        enemy_hp_shown(true)
      when 2
        enemy_hp_shown_all(true)
        @enemy_hud_window.damage_time(R2_Enemy_Hud_Hold_Time::Hold_Time * 2)
      when 3
        enemy_hp_shown_all(true)
        @enemy_hud_window.damage_time(R2_Enemy_Hud_Hold_Time::Hold_Time * 2)
      when 4
        enemy_hp_shown_all(true)
        @enemy_hud_window.damage_time(R2_Enemy_Hud_Hold_Time::Hold_Time * 2)
      when 5
        enemy_hp_shown_all(true)
        @enemy_hud_window.damage_time(R2_Enemy_Hud_Hold_Time::Hold_Time * 2)
      when 6
        enemy_hp_shown_all(true)
        @enemy_hud_window.damage_time(R2_Enemy_Hud_Hold_Time::Hold_Time * 2)
      end
    end
    r2_skill_enemy_select
  end

  def enemy_hp_shown(value = false)
    @enemy_hud_window.show_hp(value)
    if @enemy_window.enemy != nil
      @enemy_hud_window.enemy_id(@enemy_window.enemy.index)
    end
    @enemy_window.refresh
    @enemy_hud_window.refresh
  end

  def enemy_hp_shown_all(value = false)
    @enemy_hud_window.show_hp_all(value)
    @enemy_window.refresh
    @enemy_hud_window.refresh
  end
end

 

Credit and Thanks
- Ventwig
- Roninator2


Terms of use
Follow original authors terms

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted