Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Mr. Mo's SBABS Saving Error

Mr. Mo's SBABS has been around for awhile, but it still has some errors. If you change the party leader and then save, this error message is displayed.

Script 'o SDK Part III' line 1773: TypeError occured.

no marshal_dump is defined for class Sprite.


I traced the code and found line 1773 in the SDK:

1773: Marshal.dump($game_actors, file)

These pieces of code from Mr. Mo's ABS might be the problem...

Code:
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold 
#  and items. Refer to "$game_party" for the instance of this class.
#==============================================================================
class Game_Party
  attr_accessor :items
  #--------------------------------------------------------------------------
  alias mrmo_sbabs_gm_ssm setup_starting_members
  #--------------------------------------------------------------------------
  # * Initial Party Setup
  #--------------------------------------------------------------------------
  def setup_starting_members
    mrmo_sbabs_gm_ssm 
    $game_player.actor = $game_party.actors[0]
    # Game Allies
    for i in 1..@actors.size
      next if @actors[i] == nil
      $game_allies[i] = Game_Ally.new(i)
      $game_allies[i].refresh
    end
  end
  #--------------------------------------------------------------------------
  # * Add an Actor
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  def add_actor(actor_id)
    # Get actor
    actor = $game_actors[actor_id]
    # If the party has less than 4 members and this actor is not in the party
    if @actors.size < $ABS.MAX_ACTORS and not @actors.include?(actor)
      # Add actor
      @actors.push(actor)
      # Refresh player
      $game_player.refresh
      # Get Id
      id = @actors.size-1
      # Add Ally
      $game_allies[id] = Game_Ally.new(id)
      $game_allies[id].refresh
      $game_allies[id].moveto($game_player.x,$game_player.y)    
      # Add Ally to screen
      $scene.add_ally($game_allies[id]) if $scene.is_a?(Scene_Map)
    end
  end
  #--------------------------------------------------------------------------
  # * Remove Actor
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  def remove_actor(actor_id)
    # Delete Ally 
    for ally in $game_allies
      next if ally.nil?
      if $game_actors[actor_id] == ally.actor
        $game_allies.delete(ally)
        ally.dispose
        break
      end
    end
    # Delete actor
    @actors.delete($game_actors[actor_id])
    # Refresh player
    $game_player.refresh
    # Refresh Sprites in Spriteset_Map
    $scene.refresh_sprites if $scene.is_a?(Scene_Map)
  end
  #--------------------------------------------------------------------------
  # * Move Forward
  #--------------------------------------------------------------------------
  def move_forward
    # Return if allies not in map.
    for ally in $game_allies
      next if ally == nil or ally.map_id == $game_map.map_id
      return
    end
    # Return if party size is 1
    return if @actors.size == 1
    # Record current actor.
    actor = @actors[0]
    # Remove actor
    @actors.delete(actor)
    @actors.compact
    # Check if everyone except leader is dead
    if all_dead?
      @actors.insert(0,actor)
      return
    end
    $game_player.end_animate_mo
    for i in $game_allies
      next if i == nil
      i.end_animate_mo
    end
    # Insert leader to last place
    @actors.push(actor)
    # Loop members until alive
    for a in @actors
      next if a == nil
      if a.dead?
        ally = a
        @actors.delete(a)
        @actors.push(a)
      else
        for i in $game_allies
          next if i == nil or i.actor != a
          ally = i
        end
        break
      end
    end
    allies = []
    # Record other positons
    for a in $game_allies
      next if a == nil
      allies.push(a)
    end
    # Delete new leader from list
    allies.delete(ally)
    allies.push($game_player)
    allies.compact
    # Redo Game_Allies
    for i in 1..@actors.size
      next if @actors[i] == nil
      $game_allies[i] = Game_Ally.new(i)
      $game_allies[i].refresh
      $game_allies[i].moveto(allies[i-1].x,allies[i-1].y)
      if !allies[i-1].is_a?(Game_Player)
        $game_allies[i].map_id = allies[i-1].map_id
      else
        $game_allies[i].map_id = $game_map.map_id
      end
      $game_allies[i].stay if $game_party.stay?
      $game_allies[i].direction = allies[i-1].direction
    end
    # Refreshe game player
    $game_player.moveto(ally.x,ally.y)
    $game_player.refresh
    # Refresh Sprites in Spriteset_Map
    $scene.refresh_sprites if $scene.is_a?(Scene_Map)
  end
  #--------------------------------------------------------------------------
  # * Move Backward
  #--------------------------------------------------------------------------
  def move_backward
    # Return if allies not in map.
    for ally in $game_allies
      next if ally == nil or ally.map_id == $game_map.map_id
      return
    end
    # Return if party size is 1
    return if @actors.size == 1
    # Record current actor.
    actor = @actors[0]
    # Remove actor
    @actors.delete(actor)
    @actors.compact
    # Check if everyone except leader is dead
    if all_dead?
      @actors.insert(0,actor)
      return
    else
      @actors.insert(0,actor)
    end
    $game_player.end_animate_mo
    for i in $game_allies
      next if i == nil
      i.end_animate_mo
    end
    # Loop members until alive
    for a in @actors.reverse
      next if a == nil
      if a.dead?
        ally = a
        @actors.delete(a)
        @actors.insert(0,a)
      else
        # Insert to a head
        @actors.delete(a)
        @actors.insert(0,a)
        @actors.compact
        for i in $game_allies
          next if i == nil or i.actor != a
          ally = i
        end
        break
      end
    end
    allies = []
    # Record other positons
    for a in $game_allies
      next if a == nil
      allies.push(a)
    end
    # Delete new leader from list
    allies.delete(ally)
    allies.insert(0,$game_player)
    allies.compact
    # Redo Game_Allies
    for i in 1..@actors.size
      next if @actors[i] == nil
      $game_allies[i] = Game_Ally.new(i)
      $game_allies[i].refresh
      $game_allies[i].moveto(allies[i-1].x,allies[i-1].y)
      $game_allies[i].direction = allies[i-1].direction
      if !allies[i-1].is_a?(Game_Player)
        $game_allies[i].map_id = allies[i-1].map_id
      else
        $game_allies[i].map_id = $game_map.map_id
      end
      $game_allies[i].stay if $game_party.stay?
    end
    # Refreshe game player
    $game_player.moveto(ally.x,ally.y)
    $game_player.refresh
    # Refresh Sprites in Spriteset_Map
    $scene.refresh_sprites if $scene.is_a?(Scene_Map)
  end
  #--------------------------------------------------------------------------
  # * Ally check       
  #--------------------------------------------------------------------------
  def ally_pos(x,y)
    for ally in $game_allies
      next if ally.nil?
      return ally if ally.x == x and ally.y == y
    end
    return false
  end
  #--------------------------------------------------------------------------
  # * Stay?
  #--------------------------------------------------------------------------
  def stay?
    for ally in $game_allies
      next if ally == nil or !ally.stay?
      return true
    end
    return false
  end
end

Code:
#============================================================================
# * Scene Save        
#============================================================================
class Scene_Save < Scene_File
  #--------------------------------------------------------------------------
  alias mrmo_sbabs_scene_save_write_data write_data
  #--------------------------------------------------------------------------
  def write_data(file)
    sprite2 = []
    # Game Ally Command Sprite
    for i in 0..$game_allies.size
      next if $game_allies[i].nil?
      sprite2[i] = $game_allies[i].command_sprite
      $game_allies[i].command_sprite = nil
    end
    mrmo_sbabs_scene_save_write_data(file)
    sprite = $ABS.display_sprite
    $ABS.display_sprite = nil
    Marshal.dump($ABS, file)
    Marshal.dump($game_allies,file)
    $ABS.display_sprite = sprite
    # Game Ally Command Sprite
    for i in 0..$game_allies.size
      next if $game_allies[i].nil?
      $game_allies[i].command_sprite = sprite2[i]
    end
  end
end

The problem occurs only after the party leader is switched to one of the allies using the code in Game_Party.
The code for moving forward or backward through the party members may be messing something up.

Mr. Mo's SBABS can be found here:
http://www.rmxp.org/forums/showthread.php?t=19797

Unfortunately, Mr. Mo has moved on to commercial scripting, so I couldn't get his help. I would appreciate any help in fixing this.
 
After looking at the scene save code, I think Mr. Mo attempted to remove the sprites and then add them back after to get rid of this problem, but it didn't work..... That's probobly where the fix is needed. Can anyone help?
 
I know now that the problem is that it is trying to write an image (a.k.a. a Sprite) to the save file which is not allowed because of its size. Can anyone help me find this hidden image or sprite inside this code???
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top