Freezing problem with cozziekuns's Earthbound-ish battle system

Ina00

Veteran
Veteran
Joined
Oct 10, 2020
Messages
132
Reaction score
11
First Language
Italian
Primarily Uses
RMVXA
Hello again.
I would like to return on a problem with this script already encountered previously by other users.
I'm talking about cozziekuns's Earthbound-ish battle system:


That basically changes the battle hud to one similar to earthbound's, indeed.
The problem i'm talking about consists in a (apparently random) game freeze after an enemy is killed (I've heared that is common when more than 2 enemies are in battle, but I've encountered it in other situations too).
I've searched for a solution online for a while but every thread about this error hasn't found a solution yet.
My question then is: Can someone with a good scripting knowledge look for a possible and final solution to this? (since the original author seems to have disappeared)


I also put the script here:

Ruby:
#==============================================================================
# ** Earthbound-Ish Battle Core
#------------------------------------------------------------------------------
# Version: 1.0
# Author: cozziekuns
# Date: February 17, 2013
#==============================================================================
# Description:
#------------------------------------------------------------------------------
# This script attempts to mimic the battle system of the Earthbound/Mother
# series; most notably Earthbound and Earthbound 2 (Mother 2 and 3).
#==============================================================================
# Instructions:
#------------------------------------------------------------------------------
# Paste this script into its own slot in the Script Editor, above Main but
# below Materials. Edit the modules to your liking.
#==============================================================================

#==============================================================================
# ** Cozziekuns
#==============================================================================

module Cozziekuns
 
  module Earthboundish
 
    ActorIcons ={
      # Command Name => IconID
      "Attack" => 116,
      "Magic" => 152,
      "Special" => 128,
      "Guard" => 161,
      "Items" => 260,
      "Escape" => 474,
    }
 
  end
 
end

include Cozziekuns

#==============================================================================
# ** Sprite Battler
#==============================================================================

class Sprite_Battler

  alias coz_ebish_spbtlr_update_effect update_effect
  def update_effect(*args)
    update_select_whiten if @effect_type == :select_white
    if @battler.sprite_effect_type == :select_white_to_normal
      revert_to_normal
      @battler.sprite_effect_type = nil
    end
    coz_ebish_spbtlr_update_effect(*args)
  end

  def update_select_whiten
    self.color.set(255, 255, 255, 0)
    self.color.alpha = 128
  end
 
end

#==============================================================================
# ** Window_ActorCommand
#==============================================================================

class Window_ActorCommand

  def visible_line_number
    return 1
  end

  def col_max
    return 6
  end

  def contents_height
    item_height
  end

  def top_col
    ox / (item_width + spacing)
  end

  def top_col=(col)
    col = 0 if col < 0
    col = col_max - 1 if col > col_max - 1
    self.ox = col * (item_width + spacing)
  end

  def bottom_col
    top_col + col_max - 1
  end

  def bottom_col=(col)
    self.top_col = col - (col_max - 1)
  end

  def ensure_cursor_visible
    self.top_col = index if index < top_col
    self.bottom_col = index if index > bottom_col
  end

  def item_rect(index)
    rect = super
    rect.x = index * (item_width + spacing)
    rect.y = 0
    rect
  end

  def window_width
    Graphics.width - 224
  end
 
  def open
    @help_window.open
    super
  end
 
  def close
    @help_window.close
    super
  end
 
  def update
    super
    @help_window.update
  end
 
  def draw_item(index)
    rect = item_rect_for_text(index)
    x = rect.x + rect.width / 2 - 12
    y = item_rect_for_text(index).y
    draw_icon(Earthboundish::ActorIcons[command_name(index)], x, y, command_enabled?(index))
  end
 
  alias coz_ebish_waccmd_make_command_list make_command_list
  def make_command_list(*args)
    coz_ebish_waccmd_make_command_list(*args)
    add_escape_command
  end
 
  def add_escape_command
    add_command(Vocab::escape, :escape, BattleManager.can_escape?)
  end
 
  def update_help
    @help_window.set_text(command_name(index))
  end
 
end

#==============================================================================
# ** Window_BattleStatus
#==============================================================================

class Window_BattleStatus
 
  [:basic_area_rect, :gauge_area_rect].each { |method|
    define_method(method) { |index|
      rect = item_rect(index)
      rect
    }
  }
 
  def col_max
    $game_party.members.size
  end
 
  def window_width
    Graphics.width / ( 4 / $game_party.members.size.to_f )
  end
 
  def window_height
    fitting_height($data_system.opt_display_tp ? 5 : 4)
  end
 
  def item_width
    (window_width - standard_padding * 2) / $game_party.members.size
  end
 
  def item_height
    (window_height - standard_padding * 2)
  end
 
  def draw_basic_area(rect, actor)
    draw_actor_name(actor, rect.x, rect.y, rect.width)
    draw_actor_icons(actor, rect.x + 4, rect.y + line_height, rect.width)
  end

  def draw_gauge_area_with_tp(rect, actor)
    draw_gauge_area_without_tp(rect, actor)
    draw_actor_tp(actor, rect.x + 4, rect.y + line_height * 4, rect.width - 8)
  end

  def draw_gauge_area_without_tp(rect, actor)
    draw_actor_hp(actor, rect.x + 4, rect.y + line_height * 2, rect.width - 8)
    draw_actor_mp(actor, rect.x + 4, rect.y + line_height * 3, rect.width - 8)
  end
 
  def draw_actor_name(actor, x, y, width = 112)
    change_color(hp_color(actor))
    draw_text(x, y, width, line_height, actor.name, 1)
  end
 
  alias coz_ebish_wbtlsts_item_rect item_rect
  def item_rect(index, *args)
    rect = coz_ebish_wbtlsts_item_rect(index, *args)
    rect.x = index % col_max * item_width
    rect
  end
 
  def update
    super
    update_position
  end
 
  def update_position
    self.x = (Graphics.width - window_width) / 2 + 128
  end
 
end

#==============================================================================
# ** Window_BattleActor
#==============================================================================

class Window_BattleActor
 
  def update_position
    self.x = (Graphics.width - window_width) / 2
  end
 
end

#==============================================================================
# ** Window_BattleEnemy
#==============================================================================

class Window_BattleEnemy
 
  def cursor_left(wrap)
    select((index - 1 + item_max) % item_max)
  end
 
  def cursor_right(wrap)
    select((index + 1) % item_max)
  end
 
  def cursor_up(wrap)
    cursor_left(true)
  end
 
  def cursor_down(wrap)
    cursor_right(true)
  end

  def show
    select(0)
    self
  end
 
  def update_help
    @help_window.set_text(enemy.name)
  end

end

#==============================================================================
# ** Window_BattleSkill + Window_BattleItem
#==============================================================================

[:Window_BattleSkill, :Window_BattleItem].each { |klass|
  Object.const_get(klass).send(:define_method, :show) {
    select_last
    super()
  }
  Object.const_get(klass).send(:define_method, :hide) { super() }
}

#==============================================================================
# ** Window_ActorHelp
#==============================================================================

class Window_ActorHelp < Window_Help
 
  def initialize
    super(1)
    self.openness = 0
    update_position
  end
 
  def update_position
    self.x = Graphics.width - 224
    self.width = 224
    create_contents
  end
 
  def refresh
    contents.clear
    draw_text(4, 0, 224 - standard_padding * 2, line_height, @text, 1)
  end
 
end

#==============================================================================
# ** Scene_Battle
#==============================================================================

class Scene_Battle
 
  def start_party_command_selection
    unless scene_changing?
      @status_window.open
      @status_window.refresh
      if BattleManager.input_start
        next_command
        start_actor_command_selection
      else
        @party_command_window.deactivate
        turn_start
      end
    end
  end
 
  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(:escape, method(:command_escape))
    @actor_command_window.set_handler(:cancel, method(:prior_command))
    @actor_command_window.help_window = Window_ActorHelp.new
  end
 
  def create_help_window
    @help_window = Window_Help.new(1)
    @help_window.visible = false
  end
 
  alias coz_ebish_scbtl_create_enemy_window create_enemy_window
  def create_enemy_window(*args)
    coz_ebish_scbtl_create_enemy_window(*args)
    @enemy_window.help_window = @actor_command_window.help_window
  end
 
  alias coz_ebish_scbtl_update_basic update_basic
  def update_basic(*args)
    old_enemy = @enemy_window.active ? @enemy_window.enemy : nil
    coz_ebish_scbtl_update_basic(*args)
    update_enemy_whiten(old_enemy)
  end
 
  def update_enemy_whiten(old_enemy)
    if !@enemy_window.active or old_enemy != @enemy_window.enemy
      old_enemy.sprite_effect_type = :select_white_to_normal if old_enemy && !old_enemy.dead?
    end
    @enemy_window.enemy.sprite_effect_type = :select_white if @enemy_window.active
  end
 
  def update_info_viewport
    move_info_viewport(128)
  end

end



EDIT: The game seems to freeze also when a troop event is called.

EDIT2:
I think I found the problem, it's the enemy's white flash when selected (same problem as Modern Algebra's Flash Selected Enemy). Courrently i'm solving by deleting the lines that concern the target flash, but i'd like to keep them...some help please
 
Last edited:

AeroPergold

RPG Maker Nutcase
Veteran
Joined
Feb 3, 2014
Messages
315
Reaction score
374
First Language
English
Primarily Uses
RMMZ
EarthBound Battle system scripts tend to be the most unreliable. I had one for a game I had made In VX many moons ago and causes the game to crash fairly regularly.

I wish you luck on this endeavor.
 

Pygew Fyneo

Warper
Member
Joined
May 7, 2016
Messages
1
Reaction score
0
First Language
English
Primarily Uses
Hello again.
I would like to return on a problem with this script already encountered previously by other users.
I'm talking about cozziekuns's Earthbound-ish battle system:


That basically changes the battle hud to one similar to earthbound's, indeed.
The problem i'm talking about consists in a (apparently random) game freeze after an enemy is killed (I've heared that is common when more than 2 enemies are in battle, but I've encountered it in other situations too).
I've searched for a solution online for a while but every thread about this error hasn't found a solution yet.
My question then is: Can someone with a good scripting knowledge look for a possible and final solution to this? (since the original author seems to have disappeared)


I also put the script here:

Ruby:
#==============================================================================
# ** Earthbound-Ish Battle Core
#------------------------------------------------------------------------------
# Version: 1.0
# Author: cozziekuns
# Date: February 17, 2013
#==============================================================================
# Description:
#------------------------------------------------------------------------------
# This script attempts to mimic the battle system of the Earthbound/Mother
# series; most notably Earthbound and Earthbound 2 (Mother 2 and 3).
#==============================================================================
# Instructions:
#------------------------------------------------------------------------------
# Paste this script into its own slot in the Script Editor, above Main but
# below Materials. Edit the modules to your liking.
#==============================================================================

#==============================================================================
# ** Cozziekuns
#==============================================================================

module Cozziekuns
 
  module Earthboundish
 
    ActorIcons ={
      # Command Name => IconID
      "Attack" => 116,
      "Magic" => 152,
      "Special" => 128,
      "Guard" => 161,
      "Items" => 260,
      "Escape" => 474,
    }
 
  end
 
end

include Cozziekuns

#==============================================================================
# ** Sprite Battler
#==============================================================================

class Sprite_Battler

  alias coz_ebish_spbtlr_update_effect update_effect
  def update_effect(*args)
    update_select_whiten if @effect_type == :select_white
    if @battler.sprite_effect_type == :select_white_to_normal
      revert_to_normal
      @battler.sprite_effect_type = nil
    end
    coz_ebish_spbtlr_update_effect(*args)
  end

  def update_select_whiten
    self.color.set(255, 255, 255, 0)
    self.color.alpha = 128
  end
 
end

#==============================================================================
# ** Window_ActorCommand
#==============================================================================

class Window_ActorCommand

  def visible_line_number
    return 1
  end

  def col_max
    return 6
  end

  def contents_height
    item_height
  end

  def top_col
    ox / (item_width + spacing)
  end

  def top_col=(col)
    col = 0 if col < 0
    col = col_max - 1 if col > col_max - 1
    self.ox = col * (item_width + spacing)
  end

  def bottom_col
    top_col + col_max - 1
  end

  def bottom_col=(col)
    self.top_col = col - (col_max - 1)
  end

  def ensure_cursor_visible
    self.top_col = index if index < top_col
    self.bottom_col = index if index > bottom_col
  end

  def item_rect(index)
    rect = super
    rect.x = index * (item_width + spacing)
    rect.y = 0
    rect
  end

  def window_width
    Graphics.width - 224
  end
 
  def open
    @help_window.open
    super
  end
 
  def close
    @help_window.close
    super
  end
 
  def update
    super
    @help_window.update
  end
 
  def draw_item(index)
    rect = item_rect_for_text(index)
    x = rect.x + rect.width / 2 - 12
    y = item_rect_for_text(index).y
    draw_icon(Earthboundish::ActorIcons[command_name(index)], x, y, command_enabled?(index))
  end
 
  alias coz_ebish_waccmd_make_command_list make_command_list
  def make_command_list(*args)
    coz_ebish_waccmd_make_command_list(*args)
    add_escape_command
  end
 
  def add_escape_command
    add_command(Vocab::escape, :escape, BattleManager.can_escape?)
  end
 
  def update_help
    @help_window.set_text(command_name(index))
  end
 
end

#==============================================================================
# ** Window_BattleStatus
#==============================================================================

class Window_BattleStatus
 
  [:basic_area_rect, :gauge_area_rect].each { |method|
    define_method(method) { |index|
      rect = item_rect(index)
      rect
    }
  }
 
  def col_max
    $game_party.members.size
  end
 
  def window_width
    Graphics.width / ( 4 / $game_party.members.size.to_f )
  end
 
  def window_height
    fitting_height($data_system.opt_display_tp ? 5 : 4)
  end
 
  def item_width
    (window_width - standard_padding * 2) / $game_party.members.size
  end
 
  def item_height
    (window_height - standard_padding * 2)
  end
 
  def draw_basic_area(rect, actor)
    draw_actor_name(actor, rect.x, rect.y, rect.width)
    draw_actor_icons(actor, rect.x + 4, rect.y + line_height, rect.width)
  end

  def draw_gauge_area_with_tp(rect, actor)
    draw_gauge_area_without_tp(rect, actor)
    draw_actor_tp(actor, rect.x + 4, rect.y + line_height * 4, rect.width - 8)
  end

  def draw_gauge_area_without_tp(rect, actor)
    draw_actor_hp(actor, rect.x + 4, rect.y + line_height * 2, rect.width - 8)
    draw_actor_mp(actor, rect.x + 4, rect.y + line_height * 3, rect.width - 8)
  end
 
  def draw_actor_name(actor, x, y, width = 112)
    change_color(hp_color(actor))
    draw_text(x, y, width, line_height, actor.name, 1)
  end
 
  alias coz_ebish_wbtlsts_item_rect item_rect
  def item_rect(index, *args)
    rect = coz_ebish_wbtlsts_item_rect(index, *args)
    rect.x = index % col_max * item_width
    rect
  end
 
  def update
    super
    update_position
  end
 
  def update_position
    self.x = (Graphics.width - window_width) / 2 + 128
  end
 
end

#==============================================================================
# ** Window_BattleActor
#==============================================================================

class Window_BattleActor
 
  def update_position
    self.x = (Graphics.width - window_width) / 2
  end
 
end

#==============================================================================
# ** Window_BattleEnemy
#==============================================================================

class Window_BattleEnemy
 
  def cursor_left(wrap)
    select((index - 1 + item_max) % item_max)
  end
 
  def cursor_right(wrap)
    select((index + 1) % item_max)
  end
 
  def cursor_up(wrap)
    cursor_left(true)
  end
 
  def cursor_down(wrap)
    cursor_right(true)
  end

  def show
    select(0)
    self
  end
 
  def update_help
    @help_window.set_text(enemy.name)
  end

end

#==============================================================================
# ** Window_BattleSkill + Window_BattleItem
#==============================================================================

[:Window_BattleSkill, :Window_BattleItem].each { |klass|
  Object.const_get(klass).send(:define_method, :show) {
    select_last
    super()
  }
  Object.const_get(klass).send(:define_method, :hide) { super() }
}

#==============================================================================
# ** Window_ActorHelp
#==============================================================================

class Window_ActorHelp < Window_Help
 
  def initialize
    super(1)
    self.openness = 0
    update_position
  end
 
  def update_position
    self.x = Graphics.width - 224
    self.width = 224
    create_contents
  end
 
  def refresh
    contents.clear
    draw_text(4, 0, 224 - standard_padding * 2, line_height, @text, 1)
  end
 
end

#==============================================================================
# ** Scene_Battle
#==============================================================================

class Scene_Battle
 
  def start_party_command_selection
    unless scene_changing?
      @status_window.open
      @status_window.refresh
      if BattleManager.input_start
        next_command
        start_actor_command_selection
      else
        @party_command_window.deactivate
        turn_start
      end
    end
  end
 
  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(:escape, method(:command_escape))
    @actor_command_window.set_handler(:cancel, method(:prior_command))
    @actor_command_window.help_window = Window_ActorHelp.new
  end
 
  def create_help_window
    @help_window = Window_Help.new(1)
    @help_window.visible = false
  end
 
  alias coz_ebish_scbtl_create_enemy_window create_enemy_window
  def create_enemy_window(*args)
    coz_ebish_scbtl_create_enemy_window(*args)
    @enemy_window.help_window = @actor_command_window.help_window
  end
 
  alias coz_ebish_scbtl_update_basic update_basic
  def update_basic(*args)
    old_enemy = @enemy_window.active ? @enemy_window.enemy : nil
    coz_ebish_scbtl_update_basic(*args)
    update_enemy_whiten(old_enemy)
  end
 
  def update_enemy_whiten(old_enemy)
    if !@enemy_window.active or old_enemy != @enemy_window.enemy
      old_enemy.sprite_effect_type = :select_white_to_normal if old_enemy && !old_enemy.dead?
    end
    @enemy_window.enemy.sprite_effect_type = :select_white if @enemy_window.active
  end
 
  def update_info_viewport
    move_info_viewport(128)
  end

end



EDIT: The game seems to freeze also when a troop event is called.

EDIT2:
I think I found the problem, it's the enemy's white flash when selected (same problem as Modern Algebra's Flash Selected Enemy). Courrently i'm solving by deleting the lines that concern the target flash, but i'd like to keep them...some help please
Hello, Sorry I know this is a year old and you probably don't remember but could you tell me the exact lines I need to delete to get rid of the white flashes, or did you find another solution? I really like this script's UI but I'd also like it if my game functioned. Thank you.
 

Ina00

Veteran
Veteran
Joined
Oct 10, 2020
Messages
132
Reaction score
11
First Language
Italian
Primarily Uses
RMVXA
Hello, Sorry I know this is a year old and you probably don't remember but could you tell me the exact lines I need to delete to get rid of the white flashes, or did you find another solution? I really like this script's UI but I'd also like it if my game functioned. Thank you.
Hi! Don't worry, I'm still active in this forum (and most of times it's me who asks for help, so I want to help someone now that I have the opportunity).

Unfortunately I didn't find another solution, The script anyway puts the target's name also on the upper right corner, so the player will anyways be able to know which enemy they're targeting!

You'll need to comment out (putting "#" at the beginning of the line) line 363 and 365.
These ones:

Ruby:
 def update_enemy_whiten(old_enemy)
    if !@enemy_window.active or old_enemy != @enemy_window.enemy
      #old_enemy.sprite_effect_type = :select_white_to_normal if old_enemy && !old_enemy.dead?
    end
    #@enemy_window.enemy.sprite_effect_type = :select_white if @enemy_window.active
  end

Hope this helps at least a little! : )
 

Latest Threads

Latest Profile Posts

Watch Studio Blue play Numina by starlit in our latest RPG Maker Games Critique stream starting NOW!

Wish me luck. One of the leading experts on certain false shuffle is going to check if my skill is good enough to be called "not total trash".
Not an RPG Maker Update but I'm happy to say that I finally passed my drivers written test. Which makes me a happy guy.
FWRu-cYXkAAAUbl
Have you ever been in such a luck streak you felt fear something was wrong?

Forum statistics

Threads
123,126
Messages
1,154,184
Members
161,461
Latest member
TelorDadar69
Top