Barrier Script Version 1.0 (Finished)

@Crazy Rob: You have to start a new game. Sorry.

Ah well. Thanks for the reply. Love the script.
Hello, and I apologize for the insanely huuuuuge necropost happening right now, but I'm having one small problem with this script, which is baffling me.

OK, so I should mention that I am using the version of the script which works via States and not Skills, as I prefer to use States. Whenever I apply a state with an HP Barrier, I get a popup OUTSIDE of the game that seems to just list whatever I have set the Max Barrier to (5000). That image is attached. It pops up as a new window, and does so once for each character with an HP barrier applied. Does this happen to anyone else? I cannot seem to find a way to make this stop, and I do not see anything in the script which would force this line of text to be output. I will include my copy of the script as well.
Code:
#         Script HP Barrier Bar, version 0.96
#         Author: bgillisp
#         Released: 9/17/2014

#         This script allows you to define states that add barriers around
#         actors and enemies. These barriers will take all HP damage
#         until they fall, and allow healing spells to pass through
#         the barrier.

# To use: Place in the materials section, but above main

#         To set up a state to add a barrier, use the notetag
#         <HP Barrier: x>, replacing x with the Hp of the barrier
#         The space between the : and the number for your barrier is
#         important. The notetag goes in the notes section on the
#         state associated with the barrier.

#         To use the <HP Barrier MAT: x> version, replace x with the
#         percentage you wish to have MAT multiplied by in decimal
#         form! In other words, if you wish to have the barrier HP to
#         be equal to 200% times the MAT of the caster, you pass
#         <HP Barrier MAT: 2.00>.

#         In the editable region you can decide what the max HP allowed
#         on a barrier is, and whether to allow drain attacks to penetrate
#         the barrier or not. In addition you can also edit what the max
#         value of the bar is for display purposes.

#         You can also use multiple notetags, all of them will be parsed and
#         evaluated. So if you do this:
#         <HP Barrier MAT: 2.50>
#         <HP Barrier: 50>
#         The code will create a barrier with 50 + 2.5 * the casters MAT now.

# Example:
#         Say you want to create a shield that blocks 100 HP of damage
#         To do that, set up a skill that adds a state, which we will call
#         Shield. Then, under states, go to the state shield (the one
#         we just added), and add the following notetag for that state
#         <HP Barrier: 100>

#Terms of Use:
#         Free for use in commercial and non-commercial projects, with
#         credit given.

# Warning: Script still in beta, use at your own risk. Posting it so as
#          to get early feedback/suggestions.

# Release history:
# 8/23/2014: Initial beta release, 0.90
# 8/23/2014: 0.91: -Fixed bug causing the barrier to
#                   always shatter on any physical attack
# 8/23/2014: 0.92: -Fixed bug where if you used <HP Barrier MAT: x>
#                   the barrier still remained when time ran out.
#                  -Added Yanfly compatability
#                  -Added to the editable region the ability to edit
#                   the color used for the barrier bar.
# 8/25/2014: 0.92a:-Added an imported tag, to fix the issue of imported = nil
#                   occurring on clean projects.
# 8/27/2014  0.93: -Added the ability to decide what is used for the max
#                   barrier bar in display
#                  -Can now set barriers to be based on any of the main 8 stats
#                  -HP, MP, ATK, DEF, AGL, LUCK, MAT, and MDF. To use, use the
#                  -notetag <HP Barrier x: y>, where
#                  -x is either MHP, MMP, ATK, DEF, AGL, LUCK, MAT, or MDF
#                  -y is the decimal value ot be mulitplied to the stat.
# 8/29/2014  0.94:  -Fixed typo on the barrier shatter element line.
#                  -Modulated the code for the add_state lines
#                  -Added variables to allow for mp barriers (not implemented yet)
#                  -If you wish to use the mp barriers, a new game will have to
#                   be started.
#                  -Added ability to be able to base barriers on two or more
#                  -variables.
# 8/30/2014  0.94a: -Fixed critical bug which causes application of any state
#                   to wipe the barrier
#                  -Redid notetags completely to avoid re-parsing them ever
#                   time we add a state. This also fixed the bug above.
#                  -Added ability to (theoretically) allow one to heal a barrier
# 8/31/2014 0.94b: -Fixed bug on static HP barriers
#                  -Fixed bug causing HP losses to be displayed as floats.
# 9/1/2014  0.95:  -Added ability to restart an ability by recasting the skill
#                  -Careful: You may wish to investigate in a cooldown manager
#                   to avoid repeat spamming by enemies!
# 9/3/2014 0.95a:  -Added damage pop-ups to Yanfly's system when the shield is
#                   hit. Also removed the NULL text that appears when the shield
#                   takes damage under Yanfly's system.
#                   Added a sound effect to play under Yanfly's system when the
#                   shield is hit. It defaults to a Wolf Howl, so please set it
#                   to something reasonable. Any valid SE file will do.
# 9/17/2014 0.96  -Fixed reset bug on HP if used the maxHp of the barrier
#                  -Added the notetag <HP Barrier Modify: x> which can be
#                   applied to actors, equips and monsters to modify
#                   the power of the shield. The value given for x is
#                   multiplied to the barrier, so make sure it is above 0.
#                  -Added ability to heal the barrier with an item or skill
#                  -Added ability to set the max individually per barrier.

# Pending features:
#          1) Support for the Barrier bar on other battle systems besides the
#             default and Yanfly
#          2) Add the damage pop-up and SE on the default system.
#          3) Theoretically you can add the notetag to classes, but it will
#             probably not work in its current state. Best to avoid that.
#          4) Ability to have barriers regenerate some over time.

#----------------------------------------------------------------------------
# Editable region

module BGHP_Barrier
  #Set the highest HP value allowed on any barrier
  Barrier_Max = 5000

  #Flag to set how the Max_HP of the barrier is set. Set the flag as follows
  #> 0         means use this as a static value for the barrier
  #0           means to use the actors maxhp for the barrier.max.hp
  #-1          means to use the barrier's max hp on creation
  #-2          means to use the maximum set by the skill.
  Barrier_Max_HP_Display = -2

  #Set whether drain spells penetrate the barrier
  Drain_penetrate = true 

  #Determines whether an element type can always penetrate a barrier.
  #Set to false to disable, true to enable.
  #Penetrated barriers will still exist, but will fail to block all attacks
  #of that element.
  Penetrate_Element = false

  #Determines whether a barrier can be shattered by an element.
  #Set to false to disable, true to enable
  #Shattered barriers automatically fall, but the opponent takes 0 damage still.
  Shatter_Element = false

  #Set which element is the one that penetrates all barriers.
  #The default of 3 will correspond to Fire in the default database
  Element_to_penetrate = 3

  #Default shatter element. If do not wish to use, set this to -2, or an element
  #not actually in your game.
  #If you want to allow any physical attack to shatter a batter, use -1.
  Default_shatter = -2

  #Text Color for bar. Valid colors are any text color recognized by
  #the program.
  Color_bar = 9

  #Sound effect to play when the shield takes damage.
  Shield_sound_effect = "Cancel2"

end

#End of Editable Region
#--------------------------------------------------------------------------


#Do not edit anything below here unless you know what you are doing.
#Failure to ahead to this warning may result in unpredictable behavior in
#your game. Consider yourself warned
#__________________________________________________________________________

$imported = {} if $imported.nil?
$imported["BGHPBarrier"] = true

module DataManager

  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_bg_hpbarrier_load_database load_database; end
  def self.load_database
    load_database_bg_hpbarrier_load_database
    load_notetags_bg_hpbarrier
  end

  #--------------------------------------------------------------------------
  # new method: load_notetags_bg_bpbarrier
  #--------------------------------------------------------------------------
  def self. load_notetags_bg_hpbarrier
    groups = [$data_actors, $data_classes, $data_weapons, $data_armors,
      $data_enemies, $data_states, $data_skills, $data_items]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_bg_hpbarrier
      end
    end
  end

end # DataManager

#Code to load the notetags and store it in a state
class RPG::BaseItem

  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  #Variables for an hp barrier
  attr_accessor :barrier_element
  attr_accessor :barrier_counter_element
  attr_accessor :barrier_shatter_element
  attr_accessor :hp_barrier_create
  attr_accessor :hp_barrier_restore
  attr_accessor :hp_barrier_set_max

  #Variables for an mp barrier
  attr_accessor :mp_barrier_element
  attr_accessor :mp_barrier_counter_element
  attr_accessor :mp_barrier_shatter_element
  attr_accessor :mp_barrier_create
  attr_accessor :mp_barrier_restore

  #Code for the variables to be added/subtracted
  attr_accessor :barrier_stats
  attr_accessor :barrier_fixed_value

  #Code for an actor if they can modify how barriers work
  attr_accessor :barrier_modify

  #--------------------------------------------------------------------------
  # common cache: load_notetags_bg_hpbarrier
  #--------------------------------------------------------------------------
  def load_notetags_bg_hpbarrier
    @barrier_stats = {
      0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0 }
    @hp_barrier_create = false
    @hp_barrier_restore = false
    @mp_barrier_create = false
    @mp_barrier_restore = false
    @barrier_fixed_value = 0
    
    #Set to the default of 100%
    @barrier_modify = 1.0
    
    #Set to the defaults for the barrier. If notetags are set, the rest
    #will be added later.
    @barrier_hp_shatter_element = BGHP_Barrier::Default_shatter
    @barrier_hp_penetrate_element = BGHP_Barrier::Element_to_penetrate
    @hp_barrier_set_max = BGHP_Barrier::Barrier_Max
    
    @store = self.note[/(?<=<HP Barrier Modify: ).*?(?=[>])/].to_i
    if(@store && @store != 0)
      @barrier_modify = @store
    end
    
    @store = self.note[/(?<=<HP Barrier: ).*?(?=[>])/].to_i
    if(@store && @store != 0)
      @barrier_fixed_value = @store
      @hp_barrier_create = true
    end
    
    @store = self.note[/(?<=<HP Barrier MAX: ).*?(?=[>])/].to_i
    if(@store && @store != 0)
      @hp_barrier_set_max = @store
      
      #Error catching. If this ever happens, reset the module default
      if(@hp_barrier_set_max< 0)
        @hp_barrier_set_max = BGHP_Barrier::Barrier_Max
      end
      
    end
    
    @store = self.note[/(?<=<HP Barrier MHP: ).*?(?=[>])/].to_f
    if(@store && @store != 0)
      @barrier_stats[0] = @store
      @hp_barrier_create = true
    end
    
    @store = self.note[/(?<=<HP Barrier MMP: ).*?(?=[>])/].to_f
    if(@store && @store != 0)
      @barrier_stats[1] = @store
      @hp_barrier_create = true
    end
    
    @store = self.note[/(?<=<HP Barrier ATK: ).*?(?=[>])/].to_f
    if(@store && @store != 0)
      @barrier_stats[2] = @store
      @hp_barrier_create = true
    end   
    
    @store = self.note[/(?<=<HP Barrier DEF: ).*?(?=[>])/].to_f
    if(@store && @store != 0)
      @barrier_stats[3] = @store
      @hp_barrier_create = true
    end
    
    @store = self.note[/(?<=<HP Barrier MAT: ).*?(?=[>])/].to_f
    if(@store && @store != 0)
      @barrier_stats[4] = @store
      @hp_barrier_create = true
    end
    
    @store = self.note[/(?<=<HP Barrier MDF: ).*?(?=[>])/].to_f
    if(@store && @store != 0)
      @barrier_stats[5] = @store
      @hp_barrier_create = true
    end
    
    @store = self.note[/(?<=<HP Barrier AGL: ).*?(?=[>])/].to_f
    if(@store && @store != 0)
      @barrier_stats[6] = @store
      @hp_barrier_create = true
    end

    @store = self.note[/(?<=<HP Barrier LUCK: ).*?(?=[>])/].to_f
    if(@store && @store != 0)
      @barrier_stats[7] = @store
      @hp_barrier_create = true
    end
    
    #Set the shatter element of the barrier now
    @store = self.note[/(?<=<HP Barrier Shatter Element: ).*?(?=[>])/].to_i
    if(@store && @store != 0)
      self.barrier_shatter_element = @store
    end
    
    #Set the penetrate element of the barrier now
    @store = self.note[/(?<=<HP Barrier Penetrate Element: ).*?(?=[>])/].to_i
    if(@store && @store != 0)
      self.barrier_penetrate_element = @store
    end
    
    #Check for flag to see if we are to heal the barrier, not create a new one.
    if(self.note[/<HP Barrier: Restore>/im])
      @hp_barrier_create = false
      @hp_barrier_restore = true
    end
    
  end #End loading notetags module

end #End RPG::BaseItem


class Game_ActionResult

  attr_accessor :shielded_hp

  alias bg_hp_barrier_clear_damage_values clear_damage_values
  alias bg_hp_barrier_initialize initialize

  def initialize(battler)
    bg_hp_barrier_initialize(battler)
    @shielded_hp = 0
  end

  #Aliased method, clear damage values
  def clear_damage_values
    
    #Call aliased method
    bg_hp_barrier_clear_damage_values
    
    @shieled_hp = 0
  end

end

class Game_Battler < Game_BattlerBase

  #Variables for an hp barrier
  attr_accessor :hp_barrier
  attr_accessor :hp_barrier_max
  attr_accessor :hp_barrier_set_max
  attr_accessor :barrier_state
  attr_accessor :barrier_penetrate_element
  attr_accessor :barrier_shatter_element

  #Variables for an mp barrier
  attr_accessor :mp_barrier
  attr_accessor :mp_barrier_max
  attr_accessor :mp_barrier_state
  attr_accessor :mp_barrier_penetrate_element
  attr_accessor :mp_barrier_shatter_element

  #Set up all aliased functions here
  alias bg_barrier_make_damage_value make_damage_value
  alias bg_barrier_iniitialize initialize
  alias bg_barrier_add_new_state add_new_state
  alias bg_barrier_remove_state remove_state
  alias bg_barrier_refresh refresh
  alias bg_barrier_reset_state_counts reset_state_counts

  def initialize
    #Start all battlers with no barrier
    self.hp_barrier = 0
    self.barrier_state = 0
    
    #Call aliased method
    bg_barrier_iniitialize
  end

   #--------------------------------------------------------------------------
  # * Calculate Damage
  #--------------------------------------------------------------------------
  def make_damage_value(user, item)
 
    #Call aliased method first
    bg_barrier_make_damage_value(user, item)
    
    @result.shielded_hp = 0
    
    #If a healing item, return.
    if(item.damage.recover?)
      
      #If we used an item to recover the shiled, heal it, and set result to 0
      if(item.hp_barrier_restore == true && self.hp_barrier > 0)
        pass = 0 - @result.hp_damage
        add_to_barrier(pass)
        @result.hp_damage = 0
      end
      
      #If no barrier up at the moment, do nothing
      if(item.hp_barrier_restore == true && self.hp_barrier <= 0)
        @result.hp_damage = 0
      end
      
      #Return, as nothing more to be done if healing item.
      return
    end   
    
    #If drain, and allowing drain penetrating, return
    if(item.damage.drain? && BGHP_Barrier::Drain_penetrate)
      return
    end
    
    #If penetrating element and allowed, return as barrier penetrated
    if(item.damage.element_id == BGHP_Barrier::Element_to_penetrate && BGHP_Barrier::Penetrate_Element)
      return
    end
    
    #Apply the effects of the barrier now.
    #If the barrier has more left than the damage dealt
    if(self.hp_barrier > 0 && self.hp_barrier >= @result.hp_damage)
      
      #Check to see if barrier shattered now
      if(item.damage.element_id == self.barrier_shatter_element && BGHP_Barrier::Shatter_Element)
        @result.hp_damage = 0
        remove_barrier
      end
      
      #Apply normal damage if barrier not shattered
      @result.shielded_hp = @result.hp_damage
      self.hp_barrier -= @result.hp_damage
      @result.hp_damage = 0
    end

    #If the barrier has less HP left than the damage dealt
    if(self.hp_barrier > 0 && self.hp_barrier <= @result.hp_damage)
      @result.shielded_hp = self.hp_barrier.to_i
      @result.hp_damage -= self.hp_barrier.to_i
      remove_barrier
    end

  end #End of make_damage_value

  #Aliased method, remove_state
  def remove_state(state_id)
 
    if state?(state_id)
       #Call aliased method
       bg_barrier_remove_state(state_id)
      
       #If this occurs, need to remove the barrier
       if(self.barrier_state == state_id)
         self.hp_barrier = 0
       end       
    end
    
  end #end of remove_state

  #Originial method add_to_barrier.
  #This adds the new value to the current barrier.
  def add_to_barrier(value)
    self.hp_barrier += value
    if(self.hp_barrier >= self.hp_barrier_set_max)
      self.hp_barrier = self.hp_barrier_set_max
    end
  end #End add_to_barrier

  #Originial method set_barrier.
  #This sets a barrier to a fixed value, overwriting the previous value
  def set_barrier(value)
    self.hp_barrier = value
    if(self.hp_barrier >= self.hp_barrier_set_max)
      self.hp_barrier = self.hp_barrier_set_max
    end
  end #End set_barrier method

  #Original method, set barrier max hp
  def set_barrier_max_hp
    
    #Set up the static barrier
    if(BGHP_Barrier::Barrier_Max_HP_Display > 0)
      self.hp_barrier_max = BGHP_Barrier::Barrier_Max_HP_Display
    end
    
    #Set up the barrier based on max hp of the actor
    if(BGHP_Barrier::Barrier_Max_HP_Display == 0)
      self.hp_barrier_max = self.mhp
    end
    
    #Set up the barrier based on the max hp of the barrier
    if(BGHP_Barrier::Barrier_Max_HP_Display == -1)
      self.hp_barrier_max = self.hp_barrier
    end
    
    if(BGHP_Barrier::Barrier_Max_HP_Display == -2)
      self.hp_barrier_max = self.hp_barrier_set_max
    end
    
    #If it somehow gets here with less than 0, set it to 1
    if(self.hp_barrier_max <= 0)
      self.hp_barrier_max = 1
    end
    
  end #End of set_barrier_max_hp

  #Original method remove_barrier()
  def remove_barrier()
    self.hp_barrier = 0
    remove_state(self.barrier_state)
  end

  #Alias method reset_state_counds
  def reset_state_counts(state_id)
    
    @store = 0
    
    #Initialize to_pass as 0.
    to_pass = 0
    
    #Purge previous barrier, then create a new barrier
    if($data_states[state_id].hp_barrier_create)
      self.hp_barrier = 0
      self.hp_barrier_set_max = $data_states[state_id].hp_barrier_set_max
      msgbox_p(self.hp_barrier_set_max)
      
      #Initialize the variables
      self.barrier_penetrate_element = BGHP_Barrier::Element_to_penetrate
      self.barrier_shatter_element = BGHP_Barrier::Default_shatter
      self.barrier_state = state_id
      
      set_barrier($data_states[state_id].barrier_fixed_value)
      
      #Local variable to keep track where in loop we are
      ctr = 0
      
      #Loop through, and add all relevant notetags.
      for each in $data_states[state_id].barrier_stats do
        if actor?
          to_pass = $data_states[state_id].barrier_stats[ctr] * self.param(ctr) * self.actor.barrier_modify
          for equip in equips
            next if equip.nil?
            to_pass *= equip.barrier_modify
          end
        end #End if statement
        
        if enemy?
          to_pass = $data_states[state_id].barrier_stats[ctr] * self.param(ctr) * self.enemy.barrier_modify
        end
        
        #Error catching, if the value is less than 0 for any reason, set it to 0.
        if(to_pass < 0)
          to_pass = 0
        end
      
        add_to_barrier(to_pass)
        ctr += 1
      end
      
      #Set the maximum HP on the display for the barrier now.
      set_barrier_max_hp
      
    end #End of if for create a new barrier
    
    #Heal the barrier, if we are to do that
    if($data_states[state_id].hp_barrier_restore)

      add_to_barrier($data_states[state_id].barrier_fixed_value)
      
      #Local variable to keep track where in loop we are
      ctr = 0
      
      #Loop through, and add all relevant notetags.
      for each in $data_states[state_id].barrier_stats do
        to_pass = $data_states[state_id].barrier_stats[ctr] * self.param(ctr)
        add_to_barrier(to_pass)
        ctr += 1
      end
    end #End of healing barrier code
    
    bg_barrier_reset_state_counts(state_id)
    
  end

end

class Window_Base < Window

  alias bg_barrier_draw_actor_hp draw_actor_hp
  def draw_actor_hp(actor, x, y, width = 124)
    
    #Call aliased method
    bg_barrier_draw_actor_hp(actor, x, y, width)
    
    #Draw the barrier bar if needed
    if(actor.hp_barrier > 0)
      barrier_rate = (actor.hp_barrier.to_f) / (actor.hp_barrier_max)
      #draw_gauge(x, y-32, width, barrier_rate, text_color(BGHP_Barrier::Color_bar)
      draw_gauge(0, 0, width, barrier_rate, text_color(BGHP_Barrier::Color_bar), text_color(BGHP_Barrier::Color_bar))
    end
  end
end

#This is added for Yanfly compatability. This will draw the bar
#Over the HP bar when a bar exists.

#IF you are not in battle, the Barrier bar defaults to the line above
#the current HP bar.

#Check first to see if we have Yanfly installed. If not, skip all of this.
if $imported["YEA-BattleEngine"] == true
class Window_BattleStatus < Window_Selectable

  alias bg_barrier_draw_item draw_item
  #Draw Actor Barrier
  def draw_actor_barrier(actor, dx, dy, width = 124)
    barrier_rate = (actor.hp_barrier.to_f) / (actor.hp_barrier_max)
    draw_gauge(0, 0, width, barrier_rate, text_color(BGHP_Barrier::Color_bar), text_color(BGHP_Barrier::Color_bar))
    change_color(system_color)
    cy = (Font.default_size - contents.font.size) / 2 + 1
    draw_text(dx+2, dy+cy, 45, line_height, "SH")
    change_color(text_color(0))
    draw_text(dx + width - 42, dy+cy, 42, line_height, actor.hp_barrier.to_i, 2)
  end #End draw_actor_barrier method
 
  #Alias method draw_item
  def draw_item(index)
    
    #Call aliased method
    bg_barrier_draw_item(index)
    
    #Return if index or actor nil. The orginal method already cleared everything
    #so no clear called.
    return if index.nil?
    actor = battle_members[index]
    rect = item_rect(index)
    return if actor.nil?
    offset = YEA::BATTLE::BATTLESTATUS_HPGAUGE_Y_PLUS
    if(actor.hp_barrier > 0)
      
      #This is the line that draws the barrier. If you wish to move
      #the bar, edit the line_height*2+offset to move the starting y value,
      #End the rect.x+2 to move the starting x value.
      draw_actor_barrier(actor, rect.x+2, line_height*1.5+offset, rect.width-4)
    end
  end #End draw_item method

end #End class Window_Battle_Status

#Code to display a graphical pop-up when a barrier is hit.
class Game_BattlerBase

  alias bg_hp_barrier_make_damage_popups make_damage_popups
  #--------------------------------------------------------------------------
  # new method: make_damage_popups
  #--------------------------------------------------------------------------
  def make_damage_popups(user)
    
    #Call the aliased method, if shield took no damage
    bg_hp_barrier_make_damage_popups(user)
    
    #Add pop-up for the damage to the shield now.
    if (@result.shielded_hp != 0 && result.shielded_hp != nil)
      flags = []
      setting = :hp_dmg  if @result.shielded_hp > 0
      rules = "HP_DMG"   if @result.shielded_hp > 0
      value = @result.shielded_hp.abs
      text = sprintf(YEA::BATTLE::POPUP_SETTINGS[setting], value.group)
      create_popup(text, rules, flags)
      
      #Set any sound you would like to see played here.
      #RPG::SE.new(BGHP_Barrier::Shield_sound_effect, 80, 100).play rescue Sound.play_cancel
      
    end
    
  end #End make_damage_popups

  #Overwritten method, make_miss_popups
  #To avoid the program showing Null when an attack was shielded against,
  #this code had to be re-written. The only changes are near the end.
  def make_miss_popups(user, item)
    return if dead?
    if @result.missed
      text = YEA::BATTLE::POPUP_SETTINGS[:missed]
      rules = "DEFAULT"
      create_popup(text, rules)
    end
    if @result.evaded
      text = YEA::BATTLE::POPUP_SETTINGS[:evaded]
      rules = "DEFAULT"
      create_popup(text, rules)
    end
    if @result.hit? && [email protected]
      text = YEA::BATTLE::POPUP_SETTINGS[:failed]
      rules = "DEFAULT"
      create_popup(text, rules)
    end
    
    #This next line is the major change from Yanfly's code
    if @result.hit? && item.damage.to_hp? && result.shielded_hp <= 0
      if @result.hp_damage == 0 && @result.hp_damage == 0
        text = YEA::BATTLE::POPUP_SETTINGS[:nulled]
        rules = "DEFAULT"
        create_popup(text, rules)
      end
    end
    
    #Clear the stored shield damage taken now, as we no longer need to
    #reference it.
    @result.shielded_hp = 0
  end

end #End class Game_Battler_Base

end #End if imported Yanfly Battle Engine.

If this behavior is completely foreign to everyone else, then I'll know there is a conflict with another script somewhere in my project. This also happens in a completely new project file, so I'm thinking it is not caused by a conflict thus far.
Ah, you have the debug version that I later removed, as that was a testing line causing that. Look for the line msgbox_p(self.hp_barrier_set_max) (it's pretty far down the script) and change it to:
# msgbox_p(self.hp_barrier_set_max)

or in other words, add a # sign to the front of it. That will disable the pop-up unless you need it for testing purposes.
Oh, there it was! 😛

OK, so I'm also seeing that I cannot load a save file with this script active. This is even when starting a new game file and saving. I choose load and it simply makes the cancel sound effect and freezes. Very strange.
Hmmm...now that should not happen, unless you have some saves left from before the script was added. If you do you have to remove those old saves, as it does add some new variables.
No saves exist. Started new game, saved, then tested again to load and it plays the cancel sound, then freezes.

EDIT: Oh, is there a way to normalize the width of the HP Barrier gauges? They seem to be longer if there is a higher HP barrier applied, some stretch across the whole screen.
Hmmm....can you upload an uncompressed project file then to let me see then send it via PM? Make sure no DLC or custom files are included, you can just replace them with Eric's sprite or default battle music for testing purposes. I'm at work right now and got some other obligations tomorrow, so it will be 24 - 48 hours before I can check it out extensively.

For the HP bar, I used Yanfly's Battle Engine which held it to within the bounds for the box. I wasn't able to figure out how to do it otherwise though. If you can't use Yanfly's Battle Engine for various reasons you may need to post under Script Support to see if someone with more experience can figure it out, though I will try when I get some free time too.
Figured out the HP Barrier width issue, but the save issue remains, but does not occur in a new project file. So I've got an incompatibility somewhere, concerning loading a save file. So, I looked through and it turned out to be RPG Source's Save File Doctor script causing the problem. Disabled it, and we are all good. Thank you for your help, YEARS after this script was made. I appreciate that, man. 😀
Ok, great! Can you post how you fixed the width issue just in case anyone else runs into this?
I set Barrier_Max_HP_Display = -2

Then went to..,.

draw_gauge(x , y -32, 68, barrier_rate, text_color(BGHP_Barrier::Color_bar), text_color(BGHP_Barrier::Color_bar))

Changed "width" to the "68" you see above.

Original thread: https://forums.rpgmakerweb.com/threads/barrier-script-version-1-0-finished.31476/