[RMXP] A patch for Shaz's Centered Battle Actors and Blizzard's Easy LvlUp Notifier

Greetings.
Today, I would like to request a patch for @Shaz 's Centered Battle Actors and Blizzard's Easy LvlUp Notifier. When used together, the "Level Up" and "EXP" windows don't align when a battle is over.


QldU8Hh.png

As you can see, the battler is centered, but the "5 EXP" window still appears on the left side, where the battler originally was.


jAIuDUr.png

Same with the "Level Up" window. The battler is centered, but it still appears on the left side.​



The Scripts can be found below.



Spoiler: Shaz's Centered Battle Actors
Ruby:
#==============================================================================
# Centered Battle Actors
# by Shaz
#==============================================================================
# ** Window_BattleStatus
#------------------------------------------------------------------------------
#  This window displays the status of all party members on the battle screen.
#==============================================================================
class Window_BattleStatus < Window_Base
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh  
  self.contents.clear  
  party_offset = 320 - 80 * $game_party.actors.size  
  @item_max = $game_party.actors.size  
  for i in 0...$game_party.actors.size    
    actor = $game_party.actors[i]    
    actor_x = i * 160 + 4 + party_offset    
    draw_actor_name(actor, actor_x, 0)    
    draw_actor_hp(actor, actor_x, 32, 120)    
    draw_actor_sp(actor, actor_x, 64, 120)    
    if @level_up_flags[i]      
      self.contents.font.color = normal_color      
      self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")    
    else        draw_actor_state(actor, actor_x, 96)    
    end  
  end
 end
end
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Get Battle Screen X-Coordinate
#--------------------------------------------------------------------------
def screen_x  
  # Return after calculating x-coordinate by order of members in party  
  if self.index != nil    
    return self.index * 160 + 400 - 80 * $game_party.actors.size  
  else    
    return 0  
  end
 end
end
class Scene_Battle
#--------------------------------------------------------------------------
# * Actor Command Window Setup
#--------------------------------------------------------------------------
alias cbs_phase3_setup_command_window phase3_setup_command_window  
def phase3_setup_command_window  
  cbs_phase3_setup_command_window  
  @actor_command_window.x = @actor_index * 160 + 320 - 80 * $game_party.actors.size
 end
end

Spoiler: Blizzard's Easy LvlUp Notifier
Ruby:
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Easy LvlUp Notifier by Blizzard
# Version: 2.2
# Type: Battle Report Display
# Date: 27.8.2006
# Date v1.2b: 3.11.2006
# Date v1.3b: 11.3.2007
# Date v1.4b: 22.8.2007
# Date v2.0: 25.9.2007
# Date v2.1: 4.12.2009
# Date v2.1b: 15.3.2010
# Date v2.11b: 19.3.2010
# Date v2.2: 23.3.2019
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#   This work is licensed under BSD License 2.0:
#
# #----------------------------------------------------------------------------
# #
# # Copyright (c) Boris "Blizzard" Mikić
# # All rights reserved.
# #
# # Redistribution and use in source and binary forms, with or without
# # modification, are permitted provided that the following conditions are met:
# #
# # 1.  Redistributions of source code must retain the above copyright notice,
# #     this list of conditions and the following disclaimer.
# #
# # 2.  Redistributions in binary form must reproduce the above copyright
# #     notice, this list of conditions and the following disclaimer in the
# #     documentation and/or other materials provided with the distribution.
# #
# # 3.  Neither the name of the copyright holder nor the names of its
# #     contributors may be used to endorse or promote products derived from
# #     this software without specific prior written permission.
# #
# # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# # POSSIBILITY OF SUCH DAMAGE.
# #
# #----------------------------------------------------------------------------
#
#   You may use this script for both non-commercial and commercial products
#   without limitations as long as you fulfill the conditions presented by the
#   above license. The "complete" way to give credit is to include the license
#   somewhere in your product (e.g. in the credits screen), but a "simple" way
#   is also acceptable. The "simple" way to give credit is as follows:
#
#     Easy LvlUp Notifierlicensed under BSD License 2.0
#     Copyright (c) Boris "Blizzard" Mikić
#
#   Alternatively, if your font doesn't support diacritic characters, you may
#   use this variant:
#
#     Easy LvlUp Notifierlicensed under BSD License 2.0
#     Copyright (c) Boris "Blizzard" Mikic
#
#   In general other similar variants are allowed as long as it is clear who
#   the creator is (e.g. "Easy LvlUp Notifiercreated by Blizzard" is
#   acceptable). But if possible, prefer to use one of the two variants listed
#   above.
#
#   If you fail to give credit and/or claim that this work was created by you,
#   this may result in legal action and/or payment of damages even though this
#   work is free of charge to use normally.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Compatibility:
#
#   98% compatible with SDK v1.x. 80% compatible with SDK 2.x. WILL corrupt old
#   savegames. May cause slight problems with following systems and would need
#   therefore slight recalibration:
#   - exotic CBS-es
#   - exotic skill systems
#   - exotic stat systems (additional stats like Wisdom, Luck etc.)
#
#
# Features:
#
#   - shows increased stats and learned skills at level up
#   - animated
#   - shows EXP gain for each actor (!) only after gaining EXP after a battle
#   - more simple and less laggy than other Level Up Notifiers
#   - you can set up any sound to be played when a higher level is reached or a
#     new skill is learned (LVLUP_SE and LEARN_SE further below)
#
# new in v1.2b:
#   - better window movement
#   - higher compatibility
#   - fixed a few "eventual" bugs
#
# new in v1.3b:
#   - fully compatible with Tons of Add-ons
#
# new in v1.4b:
#   - improved coding
#   - rewritten conditions using classic syntax to avoid RGSS conditioning bug
#
# new in v2.0:
#   - completely overworked and improved
#   - now MUCH more simple than other Level Up Notifiers
#   - halved the number of lines of code
#   - much more compatible: can show increase of any stats after the battle in
#     combination with any script, just put this script below those attribute
#     modifying scripts
#
# new in v2.1:
#   - improved coding
#   - increased compatibility with CBS-es
#
# new in v2.1b:
#   - fixed "stack level too deep" problem
#
# new in v2.11b:
#   - fixed crash during escape
#
# new in v2.2:
#   - added new license
#   - added usage and crediting instructions
#
#
# Instructions:
#
# - Explanation:
#
#   This script will notify you when any character is leveled up after a
#   battle. It will show any stats that were increased and any skills that were
#   learned. The windows are animated, the code is less complex than any other
#   so far and it is most efficient as well as highly optimized and detailed
#   worked out.
#
# - Configuration:
#  
#   There are a few options you can set up below.
#  
#   LVLUP_SE            - sound effect played when a new level was reached
#   LEARN_SE            - sound effect played when a new skill was learned,
#                         keep in mind that the script takes into account that
#                         skills can only be learned after a level up
#   WINDOW_BACK_OPACITY - set this value to the window's back opacity (0-255)
#   NO_EXP_DISPLAY      - set this value to true if you want to disable the EXP
#                         gaining display in the level up windows
#   OLD_EXP_DISPLAY     - set this value to true if you want to display the EXP
#                         in the normal result window again
#
#
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

#          RPG::AudioFile.new('FILENAME', VOLUME, PITCH)
LVLUP_SE = RPG::AudioFile.new('087-Action02', 80, 100)
LEARN_SE = RPG::AudioFile.new('106-Heal02', 80, 100)
WINDOW_BACK_OPACITY = 160
NO_EXP_DISPLAY = false
OLD_EXP_DISPLAY = false

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

$easy_lvlup_notifier = 2.2

#==============================================================================
# Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
 
  def all_exp
    return @exp
  end
 
  def all_exp=(exp)
    @exp = exp
  end

end

#==============================================================================
# Window_BattleResult
#==============================================================================

class Window_BattleResult < Window_Base
 
  alias easy_lvlup_notfier_refresh refresh
  def refresh
    if $tons_version != nil && $tons_version >= 4.02 &&
        $game_system.WINDOW_BATTLERESULT || OLD_EXP_DISPLAY
      easy_lvlup_notfier_refresh
    else
      self.contents.clear
      x = 4
      self.contents.font.color = system_color
      cx = contents.text_size('Gained').width
      self.contents.draw_text(x, 0, cx+4, 32, 'Gained')
      x += cx + 4
      self.contents.font.color = normal_color
      cx = contents.text_size(@gold.to_s).width
      self.contents.draw_text(x, 0, cx+4, 32, @gold.to_s)
      x += cx + 4
      self.contents.font.color = system_color
      self.contents.draw_text(x, 0, 128, 32, $data_system.words.gold)
      ([email hidden]).each {|i| draw_item_name(@treasures[i], 4, (i+1)*32)}
    end
  end
 
end

#==============================================================================
# Window_LevelUp
#==============================================================================

class Window_LevelUp < Window_Base
 
  attr_reader :limit
 
  def initialize(a, d)
    if $tons_version != nil && $tons_version >= 4.98 &&
        $game_system.CENTER_BATTLER
      x = case $game_party.actors.size
      when 1 then 240
      when 2 then a.index * 320 + 80
      when 3 then a.index * 160 + 80
      when 4 then a.index * 160
      end
    else
      x = a.index * 160
    end
    text = []
    text.push(['Level:', d[0], a.level]) if d[0] != a.level
    text.push([$data_system.words.hp[0, 3], d[1], a.maxhp]) if d[1] != a.maxhp
    text.push([$data_system.words.sp[0, 3], d[2], a.maxsp]) if d[2] != a.maxsp
    text.push([$data_system.words.str[0, 3], d[3], a.str]) if d[3] != a.str
    text.push([$data_system.words.dex[0, 3], d[4], a.dex]) if d[4] != a.dex
    text.push([$data_system.words.agi[0, 3], d[5], a.agi]) if d[5] != a.agi
    text.push([$data_system.words.int[0, 3], d[6], a.int]) if d[6] != a.int
    h = text.size * 24 + (NO_EXP_DISPLAY ? 32 : 56)
    @limit, y = 320 - h, 480 - h + (h/64+1)*64
    super(x, y, 160, h)
    self.z, self.back_opacity = 100, WINDOW_BACK_OPACITY
    self.contents = Bitmap.new(self.width - 32, self.height - 32)
    if $fontface != nil
      self.contents.font.name = $fontface
    elsif $defaultfonttype != nil
      self.contents.font.name = $defaultfonttype
    end
    self.contents.font.size, self.contents.font.bold = 20, true
    unless NO_EXP_DISPLAY
      self.contents.font.color = normal_color
      self.contents.draw_text(0, 0, 128, 24, "#{a.exp - d[7]} EXP", 1)
    end
    text.each_index {|i|
        index = NO_EXP_DISPLAY ? i : i + 1
        self.contents.font.color = system_color
        self.contents.draw_text(0, index*24, 128, 24, text[i][0])
        self.contents.draw_text(80, index*24, 32, 24, '»')
        self.contents.font.color = normal_color
        self.contents.draw_text(0, index*24, 76, 24, text[i][1].to_s, 2)
        if text[i][1] > text[i][2]
          self.contents.font.color = Color.new(255, 64, 0)
        else
          self.contents.font.color = Color.new(0, 255, 64)
        end
        self.contents.draw_text(0, index*24, 128, 24, text[i][2].to_s, 2)}
  end
 
end

#==============================================================================
# Scene_Battle
#==============================================================================

class Scene_Battle
 
  alias main_lvlup_later main
  def main
    @lvlup_data = {}
    @moving_windows, @pending_windows = [], []
    (1...$data_actors.size).each {|i|
        actor = $game_actors[i]
        @lvlup_data[actor] = [actor.level, actor.maxhp, actor.maxsp, actor.str,
            actor.dex, actor.agi, actor.int, actor.exp, actor.skills.clone]}
    main_lvlup_later
    (@moving_windows + @pending_windows).each {|win| win.dispose if win != nil}
  end
 
  alias start_phase5_lvlup_later start_phase5
  def start_phase5
    start_phase5_lvlup_later
    @skill_texts = []
    $game_party.actors.each {|actor|
        actor.remove_states_battle
        if @lvlup_data[actor][0, 7] != [actor.level, actor.maxhp, actor.maxsp,
            actor.str, actor.dex, actor.agi, actor.int]
          @pending_windows.push(Window_LevelUp.new(actor, @lvlup_data[actor]))
          @skill_texts.push('')
          new_skills = actor.skills - @lvlup_data[actor][8]
          if new_skills.size > 0
            new_skills.each {|id|
                @skill_texts.push("#{actor.name} learned #{$data_skills[id].name}!")}
          end
        elsif @lvlup_data[actor][7] != actor.exp && !NO_EXP_DISPLAY
          @moving_windows.push(Window_LevelUp.new(actor, @lvlup_data[actor]))
        end}
  end
 
  alias update_phase5_lvlup_later update_phase5
  def update_phase5
    update_phase5_lvlup_later
    if @phase5_wait_count <= 0 && !Input.trigger?(Input::C)
      @moving_windows.each {|win|
          win.y -= [((win.y - win.limit) / 2.0).ceil, 64].min if win.y > win.limit}
    end
  end
 
  alias battle_end_lvlup_later battle_end
  def battle_end(result)
    if @result_window == nil
      battle_end_lvlup_later(result)
      return
    end
    @result_window.visible = false
    if @skill_texts.size > 0
      text = @skill_texts.shift
      if text == ''
        $game_system.se_play(LVLUP_SE)
        @moving_windows.push(@pending_windows.shift)
        @help_window.visible = false
      else
        $game_system.se_play(LEARN_SE)
        @help_window.set_text(text, 1)
      end
    else
      battle_end_lvlup_later(result)
    end
  end
 
end


​
Can anyone help me out?
Thanks in advance.
what is $tons_version? I'm guessing a reference to another script. Are you using that script, and what is the version?
what is $tons_version? I'm guessing a reference to another script. Are you using that script, and what is the version?

I believe this is referring to Tons of Addons, a collection of scripts that have multiple functions and are supposedly compatible with one another. In it, you can choose which ones you can turn on and off.
It is a 3-part collection, and they're meant to be used together, so I'm using all of them.
and what version are you using?

If you open your script window, can you do Control+Shift+F for a global find (I know this works in Ace, not sure about XP) and search for $tons_version. There should be at least one line, perhaps multiple, that has
Code:
$tons_version = ...
without the "if" at the front.
The version I'm using is 7.71, the same that is currently available on the original Chaos Project thread.
I am just guessing here, and it's not an elegant solution, but where you see this in the Blizzard script:

Code:
class Window_LevelUp < Window_Base
 
  attr_reader :limit
 
  def initialize(a, d)
    if $tons_version != nil && $tons_version >= 4.98 &&
        $game_system.CENTER_BATTLER
      x = case $game_party.actors.size
      when 1 then 240
      when 2 then a.index * 320 + 80
      when 3 then a.index * 160 + 80
      when 4 then a.index * 160
      end
    else
      x = a.index * 160
    end

add this line immediately below it:
Code:
x = a.index * 160 + 320 - 80 * $game_party.actors.size

If it doesn't work and breaks things, just delete that line again.
It didn't work out, unfortunately, but it seems that there was a solution in sight all along.
In Tons of Addons, there's an addon called Center Battlers, which was made by Blizzard himself and has the same purpose as your script. Both scripts are compatible with each other.

EiKmTBs.png

Now all windows are in place.​

But, well, since I didn't read through the scripts thoroughly, I suppose I must have missed this feature.
I'm very sorry about that, Shaz. Thank you very, very much for your time either way.
This thread can now be closed.

Cheers.
In that case, there's a good chance you don't need my script at all 😉

Thread closed

Original thread: https://forums.rpgmakerweb.com/threads/rmxp-a-patch-for-shazs-centered-battle-actors-and-blizzards-easy-lvlup-notifier.155948/