Pacman's Enemy HUD Small Fix

Spoiler: Pacman's Script
Link to Pacman's script:


The script works great, but it shows enemies with the "appear halfway" tag as targetable. Because of this, the element of surprise is often lost, and it also gives the player the ability to attack enemies that have not appeared yet.

I believe/hope it is easy to fix, but I have no idea how. Can anyone help?
After line 241 add in
return if enemy.hidden?
to give you this
Code:
  def draw_item(index)
    rect = item_rect(index)
    rect.x += 4
    rect.width -= 8
    contents.clear_rect(rect)
    contents.font.color = normal_color
    enemy = $game_troop.members[index]
    return if enemy.hidden?
    draw_basic_area(basic_area_rect(index), enemy)
    draw_gauge_area(gauge_area_rect(index), enemy)
  end
Swift as always.
It still shows that there are additional enemies as attack options, though the options are blank and choosing them will instead choose the already appeared enemies for attacks.
Well, I guess it's fine.

Thanks Ronin.
Sorry, missed that part. I'll look into it more. @Gravemaster

EDIT* fixed the extra enemy line showing
Change Item_max to this
Code:
  def item_max
    @troop_hidden = 0
    $game_troop.members.each do |enemy|
      if enemy.hidden?
        @troop_hidden += 1
      end
    end
    return $game_troop.members.size - @troop_hidden
  end

Still has an issue from what I can see. Dead members show up as targetable.

EDIT 2* Fixed. Had to change the draw_item condition
It shows
Code:
enemy = $game_troop.members[index]
Change to
Code:
enemy = $game_troop.alive_members[index]

EDIT 3*
Change the script back to normal
Here is the add on patch
Spoiler: R2 - Pacman Enemy Hud Patch
Code:
#===============================================================================
#
# Enemy HUD (1.3)
# 15/4/2012
# By Pacman (ported to VXA from a VX script also by Pacman)
# patch by Roninator2
# Fixes hidden enemies
#===============================================================================

class Window_EnemyHUD < Window_BattleStatus
  #--------------------------------------------------------------------------
  # * Get item max
  #--------------------------------------------------------------------------
  def item_max
    @troop_hidden = 0
    $game_troop.members.each do |enemy|
      if enemy.hidden?
        @troop_hidden += 1
      end
    end
    return $game_troop.members.size - @troop_hidden - $game_troop.dead_members.size
  end
  #--------------------------------------------------------------------------
  # * Get enemy
  #--------------------------------------------------------------------------
  def enemy
    $game_troop.alive_members[@index]
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item to be drawn
  #--------------------------------------------------------------------------
  def draw_item(index)
    rect = item_rect(index)
    rect.x += 4
    rect.width -= 8
    contents.clear_rect(rect)
    contents.font.color = normal_color
    enemy = $game_troop.alive_members[index]
    return if enemy.hidden?
    draw_basic_area(basic_area_rect(index), enemy)
    draw_gauge_area(gauge_area_rect(index), enemy)
  end
end
Great work! Thanks Ronin.
Just did some more testing. Still has a problem.
Enemies killed in the middle of the group will not have the correct index number.
So you end up selecting an enemy that may not be the correct one that is actually attacked.
@Gravemaster
*EDIT - quick fix. updated code above.
had to change def enemy
Code:
  def enemy
    $game_troop.alive_members[@index]
  end

Original thread: https://forums.rpgmakerweb.com/threads/pacmans-enemy-hud-small-fix.113061/