[Request] A Fix for Jamira's DQ Battle HUD + AMN's Addon - Encounters freeze when you get surprised!

UPDATE REQUEST

Good morning, evening, afternoon, everyone

I humbly request your assitance once more.

I seem to be having trouble with these two scripts when they function together.


The battles just freeze whenever a the party is surprised.




combined with



any help is greatly appreciated!
Can you upload that test project and paste the download link here?
UPDATE

I edited the original post, so if anyone can help, I would greatly appreciate it.
I apologise for the confusion, my request has been updated and now it's explained fully.
In my personal case, unless there's no demo available, I won't proceed to debug it. There might be a seemingly insignificant setting or change that you might have made in the DB or in any other script, and it might make me waste lots of time for ignoring such things.
The battles just freeze whenever a the party is surprised.
Small glitch in AMN battle script. It was probably not noticed since she probably had something else that corrected it in another script.

So simple solution AMN Battle script line ~= 312. remove the entire start_party_command_selection
the if BattleManager.input_start is the issue, but I don't see any difference with the entire method removed (and the alias)

So here are updated scripts for what you have posted there. ( the first one is missing the draw_horizontal_line method and crashes.) the second I have commented out that method so copy and paste.
Ruby:
#============================================================================
# [VXAce] Dragon Quest Battle V1.01 (Finished)
#----------------------------------------------------------------------------
# By Jamiras843#
# Features:
#     V1.00
#     * Dragon Quest VIII style battle
#     * Limited options to have list style Status or block style
#     * Face graphics optional
#     * Level Up option available for sound.
#============================================================================
$imported = {} if $imported.nil?
$imported["Dragon Quest Battle"] = true

module Jami_DQ_Battle
#========================================================================
# Script options
#------------------------------------------------------------------------
# Here you edit some simple aspects of the Battle System
#
#========================================================================
  SHOW_FACE = true
  # Shows actor face in menu
  HUD_HIDE = true
  #Hides Battle status during combat if true
  LVL_UP = true
  #Play level up sounde effect  
  LVL_UP_SND = "Level_Up"
  #Name of sound effect
end
#end module Jami_DQ_Battle

#============================================================================
# WARNING: Do not edit below unless you know what you are doing. This script
# is rather sloppy but it does its job.
#============================================================================

#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles actors. It's used within the Game_Actors class
# ($game_actors) and referenced by the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Show Level Up Message
#     new_skills : Array of newly learned skills
#--------------------------------------------------------------------------
  def display_level_up(new_skills)
    Audio.me_play("Audio/ME/" + Jami_DQ_Battle::LVL_UP_SND)
    $game_message.new_page
    $game_message.add(sprintf(Vocab::LevelUp, @name, Vocab::level, @level))
    new_skills.each do |skill|  
      $game_message.add(sprintf(Vocab::obtainSkill, skill.name))
    end
  end
end

#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This is a super class of all windows within the game.
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# * Close Window
#--------------------------------------------------------------------------
  def close
    @closing = true  
    @opening = false
    self
  end
end #class Window_Base

#==============================================================================
# ** Window_Help
#------------------------------------------------------------------------------
#  This window shows skill and item explanations along with actor status.
#==============================================================================
class Window_Help < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
  def initialize(line_number = 2)
    super(0, 0, Graphics.width, fitting_height(line_number))
  end
end

#==============================================================================
# ** Window_BattleItem
#------------------------------------------------------------------------------
#  This window is for selecting items to use in the battle window.
#==============================================================================
class Window_BattleItem < Window_ItemList
#--------------------------------------------------------------------------
# * Object Initialization
#     info_viewport : Viewport for displaying information
#--------------------------------------------------------------------------
  def initialize(help_window, info_viewport)
    y = help_window.height
    super(0, y, Graphics.width, 416)
    self.visible = false
    @help_window = help_window
    @info_viewport = info_viewport
  end
end

#==============================================================================
# ** Window_BattleSkill
#------------------------------------------------------------------------------
#  This window is for selecting skills to use in the battle window.
#==============================================================================
class Window_BattleSkill < Window_SkillList
#--------------------------------------------------------------------------
# * Object Initialization
#     info_viewport : Viewport for displaying information
#--------------------------------------------------------------------------
  def initialize(help_window, info_viewport)
    y = help_window.height
    super(0, y, Graphics.width, 416)
    self.visible = false
    @help_window = help_window
    @info_viewport = info_viewport
  end
end

#==============================================================================
# ** Window_BattleActor
#------------------------------------------------------------------------------
#  This window is for selecting an actor's action target on the battle screen.
#==============================================================================
class Window_BattleActor < Window_BattleStatus
#--------------------------------------------------------------------------
# * Object Initialization
#     info_viewport : Viewport for displaying information
#--------------------------------------------------------------------------
  def initialize(info_viewport)
    super()
    self.y = 416 - 120
    self.visible = false
    self.openness = 255
    @info_viewport = info_viewport
    @info_viewport2 = info_viewport  
  end
end

#============================================================================
# ** Actor Window
#============================================================================
class Window_DQ_BattleStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    if $game_party.members.size < 4    
      super(100, 0, 110 * $game_party.members.size,120)
    else      
      super(100, 0, 110 * 4,120)
    end    
    create_contents    
    @actor1 = $game_party.members[0]    
    @actor2 = $game_party.members[1]    
    @actor3 = $game_party.members[2]    
    @actor4 = $game_party.members[3]    
    refresh    
    self.openness = 0  
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index)
    actor = $game_party.battle_members[index]
  end
  #--------------------------------------------------------------------------
  # * Get Number of Lines to Show
  #--------------------------------------------------------------------------
  def visible_line_number    
    return 4
  end
  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max    
    return 4
  end    
  #----------------------------------------------------
  # * Refresh
  #----------------------------------------------------
  def refresh    
    contents.clear    
    draw_window_content    
    draw_horz_line(line_height * 1)          
  end
  #--------------------------------------------------------------------------
  # * Draw Horizontal Line
  #--------------------------------------------------------------------------
  def draw_horz_line(y)
    line_y = y + line_height / 2 - 15
    contents.fill_rect(0, line_y, contents_width, 2, line_color)
  end
  #--------------------------------------------------------------------------
  # * Get Color of Horizontal Line
  #--------------------------------------------------------------------------
  def line_color
    color = normal_color
    color.alpha = 48
    color
  end
  #----------------------------------------------------
  # * Draw Window Contents
  #----------------------------------------------------
  def draw_window_content    
    # Face    
    if Jami_DQ_Battle::SHOW_FACE == true
      draw_face(@actor1.face_name, @actor1.face_index, 0, 0, enabled = false)    
    if $game_party.members.size > 1
      draw_face(@actor2.face_name, @actor2.face_index, 110, 0, enable = false)    
    end # > 1    
    if $game_party.members.size > 2
      draw_face(@actor3.face_name, @actor3.face_index, 220, 0, enable = false)    
    end # > 2    
    if $game_party.members.size > 3
      draw_face(@actor4.face_name, @actor4.face_index, 330, 0, enable = false)    
    end # > 3  
    end # if face

    # Actor Name
    draw_actor_name(@actor1, 0, 0)  
    if $game_party.members.size > 1
      draw_actor_name(@actor2, 110, 0)    
    end # > 1    
    if $game_party.members.size > 2
      draw_actor_name(@actor3, 220, 0)    
    end # > 2    
    if $game_party.members.size > 3
      draw_actor_name(@actor4, 330, 0)    
    end # > 3  
 
    # Actor HP
    draw_actor_hp(@actor1, 0, 24, 80)  
    if $game_party.members.size > 1
      draw_actor_hp(@actor2, 110, 24, 80)    
    end # > 1    
    if $game_party.members.size > 2
      draw_actor_hp(@actor3, 220, 24, 80)    
    end # > 2    
    if $game_party.members.size > 3
      draw_actor_hp(@actor4, 330, 24, 80)    
    end # > 3  
 
    # Actor MP
    draw_actor_mp(@actor1, 0, 44, 80)  
    if $game_party.members.size > 1
      draw_actor_mp(@actor2, 110, 44, 80)    
    end # > 1    
    if $game_party.members.size > 2
      draw_actor_mp(@actor3, 220, 44, 80)    
    end # > 2    
    if $game_party.members.size > 3
      draw_actor_mp(@actor4, 330, 44, 80)    
    end # > 3        
 
    # Actor LV
    draw_actor_level(@actor1, 0, 64)  
    if $game_party.members.size > 1
      draw_actor_level(@actor2, 110, 64)    
    end # > 1    
    if $game_party.members.size > 2
      draw_actor_level(@actor3, 220, 64)    
    end # > 2    
    if $game_party.members.size > 3
      draw_actor_level(@actor4, 330, 64)    
    end # > 3  
 
    # Actor Icons
    draw_actor_icons(@actor1, 60, 0)    
    if $game_party.members.size > 1
      draw_actor_icons(@actor2, 170, 0)    
    end # > 1    
    if $game_party.members.size > 2
      draw_actor_icons(@actor3, 280, 0)    
    end # > 2    
    if $game_party.members.size > 3
      draw_actor_icons(@actor4, 400, 0)    
    end # > 3
  end  #end draw_window_content
end

#==============================================================================
# ** Window_BattleEnemy
#------------------------------------------------------------------------------
#  Window for selecting the enemy who is the action target on the battle
# screen.
#==============================================================================
class Window_BattleEnemy < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#     info_viewport : Viewport for displaying information
#--------------------------------------------------------------------------
  def initialize(info_viewport)
    super(200, 296, 344, fitting_height(4))
    refresh
    self.visible = false
  end
end #class Window_BattleEnemy

#==============================================================================
# ** Window_BattleLog
#------------------------------------------------------------------------------
#  Window edited to be more like DQVIII
#==============================================================================
class Window_BattleLog < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
  def initialize
    super(0, 296, window_width, window_height)
    self.z = 200
    self.hide
    self.opacity = 255
    @lines = []
    @num_wait = 0
    create_back_bitmap
    create_back_sprite
    refresh
  end
  #--------------------------------------------------------------------------
  # * Free
  #--------------------------------------------------------------------------
  def dispose
    super
    self.close
    dispose_back_bitmap
    dispose_back_sprite
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    Graphics.width
  end
  #--------------------------------------------------------------------------
  # * Get Window Height
  #--------------------------------------------------------------------------
  def window_height
    fitting_height(max_line_number)
  end
  #--------------------------------------------------------------------------
  # * Get Maximum Number of Lines
  #--------------------------------------------------------------------------
  def max_line_number
    return 4
  end
  #--------------------------------------------------------------------------
  # * Clear
  #--------------------------------------------------------------------------
  def clear
    self.hide
    @num_wait = 0
    @lines.clear
    refresh
  end
  #--------------------------------------------------------------------------
  # * Add Text
  #--------------------------------------------------------------------------
  def add_text(text)
    self.show
    @lines.push(text)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Get Background Opacity
  #--------------------------------------------------------------------------
  def back_opacity
    return 0
  end
end #Window_Battlelog

#==============================================================================
# ** Window_ActorCommand
#------------------------------------------------------------------------------
#  This window is for selecting an actor's action on the battle screen.
#==============================================================================
class Window_ActorCommand < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
  def initialize
    super(0, 0)
    self.openness = 0
    deactivate
    @actor = nil
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    return 200
  end
  #--------------------------------------------------------------------------
  # * Get Number of Lines to Show
  #--------------------------------------------------------------------------
  def visible_line_number
    return 4
  end
  #--------------------------------------------------------------------------
  # * Get Digit Count
  #--------------------------------------------------------------------------
  def col_max    
    return 2
  end
end

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
  def start
    super
    create_spriteset
    create_all_windows
    BattleManager.method_wait_for_message = method(:wait_for_message)
    @game_party = $game_party.members
  end
  #--------------------------------------------------------------------------
  # * Update Frame (Basic)
  #--------------------------------------------------------------------------
  def update_basic
    super
    $game_timer.update
    $game_troop.update
    @spriteset.update
    update_message_open
  end
  #--------------------------------------------------------------------------
  # * Create All Windows
  #--------------------------------------------------------------------------
  def create_all_windows
    create_message_window
    create_log_window
    create_DQ_status_window
    create_info_viewport
    create_party_command_window
    create_actor_command_window
    create_help_window
    create_skill_window
    create_item_window
    create_actor_window
    create_enemy_window
  end
  #--------------------------------------------------------------------------
  # * Create Message Window
  #--------------------------------------------------------------------------
  def create_message_window
    @message_window = Window_Message.new
  end
  #--------------------------------------------------------------------------
  # * Create DQ Status Window
  #--------------------------------------------------------------------------
  def create_DQ_status_window
    @DQ_status_window = Window_DQ_BattleStatus.new
    @DQ_status_window.x = 128
  end
  #--------------------------------------------------------------------------
  # * Create Log Window
  #--------------------------------------------------------------------------
  def create_log_window
    @log_window = Window_BattleLog.new
    @log_window.method_wait = method(:wait)
    @log_window.method_wait_for_effect = method(:wait_for_effect)
  end
  #--------------------------------------------------------------------------
  # * Create Information Display Viewport
  #--------------------------------------------------------------------------
  def create_info_viewport
    @info_viewport = Viewport.new
    @info_viewport.rect.y = 0
    @info_viewport.rect.height = Graphics.height - @DQ_status_window.height
    @info_viewport.z = 100
    @info_viewport.ox = 544 - 104 * 4
    @DQ_status_window.viewport = @info_viewport
  end
  #--------------------------------------------------------------------------
  # * Create Party Commands Window
  #--------------------------------------------------------------------------
  def create_party_command_window
    @DQ_status_window.show
    @party_command_window = Window_PartyCommand.new
    @party_command_window.set_handler(:fight,  method(:command_fight))
    @party_command_window.set_handler(:escape, method(:command_escape))
    @party_command_window.x = 0
    @party_command_window.y = 296
    @party_command_window.unselect
  end
  #--------------------------------------------------------------------------
  # * Create Actor Commands Window
  #--------------------------------------------------------------------------
  def create_actor_command_window
    @actor_command_window = Window_ActorCommand.new
    @actor_command_window.set_handler(:attack, method(:command_attack))
    @actor_command_window.set_handler(:skill,  method(:command_skill))
    @actor_command_window.set_handler(:guard,  method(:command_guard))
    @actor_command_window.set_handler(:item,   method(:command_item))
    @actor_command_window.set_handler(:cancel, method(:prior_command))
    @actor_command_window.x = 0
    @actor_command_window.y = 296
  end
  #--------------------------------------------------------------------------
  # * Create Help Window
  #--------------------------------------------------------------------------
  def create_help_window
    @help_window = Window_Help.new
    @help_window.visible = false
  end
  #--------------------------------------------------------------------------
  # * Create Enemy Window
  #--------------------------------------------------------------------------
  def create_enemy_window
    @enemy_window = Window_BattleEnemy.new(@help_window)
    @enemy_window.index = 0
    @enemy_window.set_handler(:ok,     method(:on_enemy_ok))
    @enemy_window.set_handler(:cancel, method(:on_enemy_cancel))
  end
  #--------------------------------------------------------------------------
  # * Start Enemy Selection
  #--------------------------------------------------------------------------
  def select_enemy_selection
    @enemy_window.refresh
    @enemy_window.show.activate
    @enemy_window.index = 0
  end
  #--------------------------------------------------------------------------
  # * Create Skill Window
  #--------------------------------------------------------------------------
  def create_skill_window
    @skill_window = Window_BattleSkill.new(@help_window, @info_viewport)
    @skill_window.set_handler(:ok,     method(:on_skill_ok))
    @skill_window.set_handler(:cancel, method(:on_skill_cancel))
  end
  #--------------------------------------------------------------------------
  # * Create Item Window
  #--------------------------------------------------------------------------
  def create_item_window
    @item_window = Window_BattleItem.new(@help_window, @info_viewport)
    @item_window.set_handler(:ok,     method(:on_item_ok))
    @item_window.set_handler(:cancel, method(:on_item_cancel))
  end
  #--------------------------------------------------------------------------
  # * Update Status Window Information
  #--------------------------------------------------------------------------
  def refresh_status
    @DQ_status_window.refresh
  end
  #--------------------------------------------------------------------------
  # * Start Party Command Selection
  #--------------------------------------------------------------------------
  def start_party_command_selection
    unless scene_changing?  
      refresh_status  
      @DQ_status_window.open  
      if BattleManager.input_start    
        @actor_command_window.close    
        @party_command_window.setup  
      else    
        @party_command_window.deactivate
        turn_start  
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Start Actor Command Selection
  #--------------------------------------------------------------------------
  def start_actor_command_selection
    @party_command_window.close
    @actor_command_window.setup(BattleManager.actor)
  end
  #--------------------------------------------------------------------------
  # * Update Processing for Opening Message Window
  #    Set openness to 0 until the status window and so on are finished closing.
  #--------------------------------------------------------------------------
  def update_message_open
    if $game_message.busy? && !@DQ_status_window.close?  
      @message_window.openness = 0  
      @DQ_status_window.close  
      @party_command_window.close  
      @actor_command_window.close
    end
  end
  #--------------------------------------------------------------------------
  # * Start Turn
  #--------------------------------------------------------------------------
  def turn_start
    @party_command_window.close
    @actor_command_window.close
    @subject =  nil
    BattleManager.turn_start
    if Jami_DQ_Battle::HUD_HIDE == true
      @info_viewport.rect.height = 60
    end #if HUD_HIDE
    @log_window.wait
    @log_window.clear
  end
  #--------------------------------------------------------------------------
  # * End Turn
  #--------------------------------------------------------------------------
  def turn_end
    all_battle_members.each do |battler|  
    battler.on_turn_end  
    refresh_status  
    if Jami_DQ_Battle::HUD_HIDE == true  
      @info_viewport.rect.height = @DQ_status_window.height  
    end  
    @log_window.display_auto_affected_status(battler)  
    @log_window.wait_and_clear
    end
    BattleManager.turn_end
    process_event
    start_party_command_selection
  end
  #--------------------------------------------------------------------------
  # * Battle Action Processing
  #--------------------------------------------------------------------------
  def process_action
    return if scene_changing?
    if !@subject || [email protected]_action  
      @subject = BattleManager.next_subject
    end
    return turn_end unless @subject
    if @subject.current_action  
      @subject.current_action.prepare  
    if @subject.current_action.valid?    
      @DQ_status_window.open    
      execute_action  
    end  
    @subject.remove_current_action
    end
    process_action_end unless @subject.current_action
  end
end # end Scene_battle

Ruby:
=begin
#==============================================================================#
#   AMN DQ Battle Addon
#   Version 1.03
#   Author: AMoonlessNight
#   Date: 09 Dec 2018
#   Latest: 11 Dec 2018
#==============================================================================#
#   UPDATE LOG
#------------------------------------------------------------------------------#
# 09 Dec 2018 - created the script
# 10 Dec 2018 - fixed a couple of bugs
# 11 Dec 2018 - status window always stays up during battle
#==============================================================================#
#   TERMS OF USE
#------------------------------------------------------------------------------#
# - Please credit AMoonlessNight or A-Moonless-Night
# - Free for non-commercial use
# - I'd love to see your game if you end up using one of my scripts
#==============================================================================#

This script updates the battle scene from Jamiras843 Dragon Quest Battle script,
changing the position of certain windows and changing the way some information
is drawn.

You can choose whether to draw icons in skill and item lists in the editable
region below.

All windows now open and close instantly, no fade-in/-out transition.

=end
module AMN_DQ_Battle
#==============================================================================
# ** EDITABLE REGION BELOW
#------------------------------------------------------------------------------
#  Change the values in the area below to suit your needs.
#==============================================================================

  Icons_On = false  # whether to draw icons in item and skill lists
 
#==============================================================================
# ** END OF EDITABLE REGION
#------------------------------------------------------------------------------
#  Please do not edit below this point unless you know what you are doing.
#==============================================================================
end

class Window_Base < Window
 
  def update_open
    self.openness += 254
    @opening = false if open?
  end

  def update_close
    self.openness -= 254
    @closing = false if close?
  end
 
  alias amn_dqbattle_windowbase_drawitemname  draw_item_name
  def draw_item_name(item, x, y, enabled = true, width = 172)
    if AMN_DQ_Battle::Icons_On
      amn_dqbattle_windowbase_drawitemname(item, x, y, enabled, width)
    else
      return unless item
      change_color(normal_color, enabled)
      draw_text(x, y, width, line_height, item.name)
    end
  end
end

class Window_Selectable < Window_Base

  def item_rect_for_text(index)
    rect = item_rect(index)
    rect.x += 10
    rect.width -= 20
    rect
  end
 
end

class Window_BattleActor < Window_BattleStatus
 
  def visible_line_number; item_max; end
  def show; select(0) if @info_viewport; super; end
  def hide; super; end
  def window_width; 170; end
 
  def draw_item(index)
    actor = $game_party.battle_members[index]
    draw_actor_name(actor, 10, line_height * index)
  end
 
end

class Window_BattleEnemy < Window_Selectable
  def col_max; return 1; end

  def initialize(info_viewport)
    super(250, 296, Graphics.width - 250, fitting_height(4))
    refresh
    self.visible = false
  end
 
end

class Window_DQ_BattleStatus < Window_Base

  def initialize
    super(100, 0, 112 * [$game_party.members.size, 4].min, 120)  
    create_contents    
    @actor1 = $game_party.members[0]    
    @actor2 = $game_party.members[1]    
    @actor3 = $game_party.members[2]    
    @actor4 = $game_party.members[3]    
    refresh    
    self.openness = 0
    self.arrows_visible = false
  end
 
  def draw_actor_info(actor, x, y, width)
    draw_face(actor.face_name, actor.face_index, x, y, false) if Jami_DQ_Battle::SHOW_FACE
    draw_actor_name(actor, x, y)
    draw_actor_hp(actor, x, y+24, width)
    draw_actor_mp(actor, x, y+44, width)
    draw_actor_level(actor, x, y+64)
    draw_actor_icons(actor, x+60, y)
  end
 
  def draw_window_content
    draw_actor_info(@actor1, 0, 0, 80)
    draw_actor_info(@actor2, 110, 0, 80) if $game_party.members.size > 1
    draw_actor_info(@actor3, 220, 0, 80) if $game_party.members.size > 2
    draw_actor_info(@actor4, 330, 0, 80) if $game_party.members.size > 3
  end
end

class Window_ActorCommand < Window_Command
  def spacing; return 6; end
  def visible_line_number; return 3; end
  def window_width; return 250; end
   
  alias amn_dqbattle_windowactorcmd_init  initialize
  def initialize
    amn_dqbattle_windowactorcmd_init
    self.opacity = 0
  end
 
end

class Window_ActorDummy < Window_Base
  def initialize
    super(0, 0, 250, fitting_height(visible_line_number))
    self.openness = 0
    @actor = nil
  end

  def visible_line_number; return 4; end

  def draw_actor_details
    return unless @actor
    draw_text(0, 0, contents_width, line_height, @actor.name, 1)
    draw_horz_line(12)
  end

  def draw_horz_line(y)
    line_y = y + line_height / 2 - 1
    contents.fill_rect(0, line_y, contents_width, 2, normal_color)
  end
 
  def setup(actor)
    @actor = actor
    contents.clear
    draw_actor_details
    open
  end
end

class Window_BattleItem < Window_ItemList
  def col_max; return 1; end
   
  def initialize(help_window, info_viewport)
    height = fitting_height(4)
    hww = help_window.width
    super(0, Graphics.height - height, Graphics.width - hww, height)
    self.visible = false
    @help_window = help_window
    @info_viewport = info_viewport
  end
 
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 8
      draw_item_name(item, rect.x+10, rect.y, enable?(item))
      draw_item_number(rect, item)
    end
  end
 
end

class Window_BattleSkill < Window_SkillList
  attr_reader :actor
  def col_max; return 1; end
 
  def initialize(help_window, info_viewport)
    height = fitting_height(4)
    hww = help_window.width
    super(0, Graphics.height - height, Graphics.width - hww, height)
    self.visible = false
    @help_window = help_window
    @info_viewport = info_viewport
    @mp_window = nil
  end
 
  def mp_window=(mp_window)
    @mp_window = mp_window
  end

  def draw_item(index)
    skill = @data[index]
    if skill
      rect = item_rect(index)
      rect.width -= 8
      draw_item_name(skill, rect.x+10, rect.y, enable?(skill))
    end
  end
 
  alias amn_dqbattle_windbattleskill_show show
  def show
    @mp_window.show if @mp_window
    amn_dqbattle_windbattleskill_show
  end

  alias amn_dqbattle_windbattleskill_hide hide
  def hide
    @mp_window.hide if @mp_window
    amn_dqbattle_windbattleskill_hide
  end
 
  def update_help
    super
    @mp_window.set_item if @mp_window
  end
end

class Window_BattleSkillMP < Window_Base

  def initialize(skill_window, info_viewport)
    h = fitting_height(1)
    super(Graphics.width - 250, Graphics.height - h, 250, h)
    self.visible = false
    @info_viewport = info_viewport
    skill_window.mp_window = self
    @skill_window = skill_window
  end

  def set_text(text)
    if text != @text
      @text = text
      refresh
    end
  end

  def clear
    set_text("")
  end

  def item
    @skill_window.item
  end
 
  def actor
    @skill_window.actor
  end
 
  def set_item
    return clear if actor.nil? || item.nil?
    return clear if actor.skill_mp_cost(item).zero? && actor.skill_tp_cost(item).zero?
    if actor.skill_mp_cost(item) > 0
      set_text(sprintf("MP Cost: %d/%d", actor.skill_mp_cost(item), actor.mp))
    elsif actor.skill_tp_cost(item) > 0
      set_text(sprintf("TP Cost: %d/%d", actor.skill_tp_cost(item), actor.tp))
    end
  end

  def refresh
    contents.clear
    draw_text_ex(4, 0, @text)
  end
end

class Scene_Battle < Scene_Base
 
  alias amn_dqbattle_scenebattle_createactorcmdwind create_actor_command_window
  def create_actor_command_window
    @dummy_window = Window_ActorDummy.new
    amn_dqbattle_scenebattle_createactorcmdwind
    @actor_command_window.y = 320
    @dummy_window.y = 296
  end
 
  alias amn_dqbattle_scenebattle_createactorwind  create_actor_window
  def create_actor_window
    amn_dqbattle_scenebattle_createactorwind
    @actor_window.y -= @actor_window.height
    @actor_window.x = Graphics.width - @actor_window.width
  end
 
#~   alias amn_dqbattle_scenebattle_startpartycmdselect  start_party_command_selection
#~   def start_party_command_selection
#~     amn_dqbattle_scenebattle_startpartycmdselect
#~     unless scene_changing?  
#~       if BattleManager.input_start    
#~         @dummy_window.close
#~         @enemy_window.deactivate.hide
#~       end
#~     end
#~   end
 
  alias amn_dqbattle_scenebattle_createskillwind create_skill_window
  def create_skill_window
    amn_dqbattle_scenebattle_createskillwind
    @skill_mp_window = Window_BattleSkillMP.new(@skill_window, @info_viewport)
  end
 
  alias amn_dqbattle_scenebattle_createhelpwind create_help_window
  def create_help_window
    amn_dqbattle_scenebattle_createhelpwind
    w = 250
    hh = @help_window.height
    h = @help_window.fitting_height(4)
    @help_window.move(Graphics.width - w, Graphics.height - h, w, hh)
    @help_window.create_contents
  end
 
  alias amn_dqbattle_scenebattle_cmdfight command_fight
  def command_fight
    amn_dqbattle_scenebattle_cmdfight
    @enemy_window.deactivate.show
  end
 
  alias amn_dqbattle_scenebattle_startactorcmdselect  start_actor_command_selection
  def start_actor_command_selection
    amn_dqbattle_scenebattle_startactorcmdselect
    @dummy_window.setup(BattleManager.actor)
  end

  def turn_start
    @party_command_window.close
    @actor_command_window.close
    @dummy_window.close
    @enemy_window.deactivate.hide
    @subject =  nil
    BattleManager.turn_start
    if Jami_DQ_Battle::HUD_HIDE
      @DQ_status_window.height = @DQ_status_window.fitting_height(2)
      @info_viewport.rect.height = @DQ_status_window.fitting_height(2)
    end
    @log_window.clear
  end

  def turn_end
    all_battle_members.each do |battler|  
      battler.on_turn_end  
      refresh_status  
      if Jami_DQ_Battle::HUD_HIDE
        @DQ_status_window.height = 110
        @DQ_status_window.update_padding
        @info_viewport.rect.height = @DQ_status_window.height
      end  
      @log_window.display_auto_affected_status(battler)  
      @log_window.wait_and_clear
    end
    BattleManager.turn_end
    process_event
    start_party_command_selection
  end
 
  def update_message_open
    if $game_message.busy?
      @message_window.openness = 0
      @party_command_window.close  
      @actor_command_window.close
      @dummy_window.close
      @message_window.openness = 255
    end
  end
 
  def on_enemy_ok
    unless @actor_command_window.visible
      @actor_command_window.show
      @dummy_window.show
    end
    case @actor_command_window.current_symbol
    when :skill
      @enemy_window.y += @enemy_window.height
    when :item
      @enemy_window.y += @enemy_window.height
    end
    BattleManager.actor.input.target_index = @enemy_window.enemy.index
    @skill_window.hide
    @item_window.hide
    next_command
  end

  def on_enemy_cancel
    @enemy_window.deactivate
    case @actor_command_window.current_symbol
    when :attack
      @actor_command_window.activate
    when :skill
      @skill_window.activate
      @enemy_window.hide
    when :item
      @item_window.activate
      @enemy_window.hide
    end
  end
 
  alias amn_dqbattle_scenebattle_commandskill command_skill
  def command_skill
    amn_dqbattle_scenebattle_commandskill
    @enemy_window.deactivate.hide
    @enemy_window.y -= @enemy_window.height
    @actor_command_window.hide
    @dummy_window.hide
  end

  alias amn_dqbattle_scenebattle_commanditem command_item
  def command_item
    amn_dqbattle_scenebattle_commanditem
    @enemy_window.deactivate.hide
    @enemy_window.y -= @enemy_window.height
    @actor_command_window.hide
    @dummy_window.hide
  end
 
  alias amn_dqbattle_scenebattle_onactorok on_actor_ok
  def on_actor_ok
    unless @actor_command_window.visible
      @actor_command_window.show
      @dummy_window.show
    end
    @enemy_window.y += @enemy_window.height
    @enemy_window.deactivate.show
    amn_dqbattle_scenebattle_onactorok
  end
 
  alias amn_dqbattle_scenebattle_onskillok  on_skill_ok
  def on_skill_ok
    amn_dqbattle_scenebattle_onskillok
    @skill = @skill_window.item
    if [email protected]_selection?
      @enemy_window.y += @enemy_window.height
      @actor_command_window.show
      @dummy_window.show
      @enemy_window.deactivate.show
    end
  end

  alias amn_dqbattle_scenebattle_onskillcancel  on_skill_cancel
  def on_skill_cancel
    amn_dqbattle_scenebattle_onskillcancel
    @enemy_window.y += @enemy_window.height
    @enemy_window.deactivate.show
    @actor_command_window.show
    @dummy_window.show
  end

  alias amn_dqbattle_scenebattle_onitemok  on_item_ok
  def on_item_ok
    amn_dqbattle_scenebattle_onitemok
    @item = @item_window.item
    if [email protected]_selection?
      @enemy_window.y += @enemy_window.height
      @actor_command_window.show
      @dummy_window.show
      @enemy_window.deactivate.show
    end
  end

  alias amn_dqbattle_scenebattle_onitemcancel  on_item_cancel
  def on_item_cancel
    amn_dqbattle_scenebattle_onitemcancel
    @enemy_window.deactivate.show
    @enemy_window.y += @enemy_window.height
    @actor_command_window.show
    @dummy_window.show
  end
 
end

class Scene_Map < Scene_Base
  def perform_transition
    if Graphics.brightness == 0
      Graphics.transition(0)
      fadein(fadein_speed)
    else
      super
    end
  end
end

class Scene_Menu < Scene_MenuBase
  def transition_speed
    return 0
  end
 
  def terminate
    super
    Graphics.transition(0)
  end
end

Original thread: https://forums.rpgmakerweb.com/threads/request-a-fix-for-jamiras-dq-battle-hud-amns-addon-encounters-freeze-when-you-get-surprised.158114/