Chapter Select

Discussion in 'RGSS3 Scripts (RMVX Ace)' started by MeowFace, Oct 2, 2015.

  1. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    179
    Location:
    La La Land
    First Language:
    Meowish
    Made for a request here.

    Features:

    [1] Game starting by selecting a Chapter.

    [2] Unlock-able new chapters.

    [3] Each Chapter able to start with its own map & starting characters.

    [4] Inheritable save files for each chapter.

    [5] Can set up to 10 Chapters max.

    [6] Change-able Background/Text

    [7] Able to set whether or not to reset character's level

    Snap-Shot:

    [​IMG]

    How to Use:

    [1] Paste script below Material and above Main

    [2] Set up data accordingly in SETTINGS AREA in the script.

    [3] Use this script call at the end of each chapter to enable next chapter.

    chapter_clearedCompatibility:

    This script modifies the Title Scene's New Game Command, but the rest are properly aliased.

    You can safely put this script below other custom scripts without worrying much about conflicts.

    Terms of Use:

    Free for both Commercial and Non-Commercial.

    Script:
    Code:
    #==============================================================================
    # ■ Meow Face Chapter Selection
    #------------------------------------------------------------------------------
    # Select Chapter to Start Game
    #==============================================================================
    # How to Use:
    # [1] Put this script below Material and above Main
    # [2] Set up the required data in SETTINGS AREA below
    # [3] At the end of each chapter, use this script call to save file
    #      chapter_cleared
    #==============================================================================
    module MF_CHAPTER
    #==============================================================================
    # SETTINGS AREA
    #==============================================================================
    #------------------------------------------------------------------------------
    # How many chapters are there (1 to 10 MAX)
    #------------------------------------------------------------------------------
      MAXCHAPTER = 10
    #------------------------------------------------------------------------------
    # Background picture (in Graphics\Titles1 folder)
    #------------------------------------------------------------------------------
      BACKGROUND = "Fountain"
    #------------------------------------------------------------------------------
    # Title
    #------------------------------------------------------------------------------
      TITLE = "SELECT CHAPTER"
    #------------------------------------------------------------------------------
    # Chapter's Name
    # Starting from top down, Chapter 1, Chapter 2, etc etc
    #------------------------------------------------------------------------------
      NAME = [
      "Chapter One",
      "Chapter Two",
      "Chapter Three",
      "Chapter Four",
      "Chapter Five",
      "Chapter Six",
      "Chapter Seven",
      "Chapter Eight",
      "Chapter Nine",
      "Chapter Ten",
      ] #Do Not Remove
    #------------------------------------------------------------------------------
    # Chapter's Description
    # Starting from top down, Chapter 1, Chapter 2, etc etc
    #------------------------------------------------------------------------------
      DESC = [
      "Chapter 1 Descriptions",
      "Chapter 2 Descriptions",
      "Chapter 3 Descriptions",
      "Chapter 4 Descriptions",
      "Chapter 5 Descriptions",
      "Chapter 6 Descriptions",
      "Chapter 7 Descriptions",
      "Chapter 8 Descriptions",
      "Chapter 9 Descriptions",
      "Chapter 10 Descriptions",
      ] #Do Not Remove
    #------------------------------------------------------------------------------
    # Starting Map for each Chapter
    # [MapID, StartX, StartY]
    # Starting top down from Chapter 1 to Chapter 10
    #------------------------------------------------------------------------------
      MAP = [
      [1,1,1],
      [2,1,7],
      [3,12,16],
      [4,1,1],
      [5,1,1],
      [6,1,1],
      [7,1,1],
      [8,1,1],
      [9,1,1],
      [10,1,1],
      ] #Do Not Remove
    #------------------------------------------------------------------------------
    # Starting Actors for each Chapter
    # Starting top down from Chapter 1 to Chapter 10
    #------------------------------------------------------------------------------
      ACTORS = [
      [1,4,2,5],
      [1,2,3,4],
      [1,2,3],
      [2,3,4,5],
      [1,2,3,4],
      [1,2,3,4],
      [1,2,3,4],
      [1,2,3,4],
      [1,2,3,4],
      [1,2,3,4],
      ] #Do Not Remove
    #------------------------------------------------------------------------------
    # Reset Actor's Level? true/false
    # Automatic set to true if previous chapter load file = nil
    #------------------------------------------------------------------------------
      RESET = false
    #------------------------------------------------------------------------------
    # Data Loading for each Chapter
    # This loads the data of the previous chapters during chapter selection
    # So set up the file for each chapter accordingly
    # Starting top down from Chapter 1 to Chapter 10
    # nil = No load file
    #------------------------------------------------------------------------------
      LOAD_FILE = [
      nil,
      "Chapter1_Cleared.rvdata2",
      "Chapter2_Cleared.rvdata2",
      "Chapter3_Cleared.rvdata2",
      "Chapter4_Cleared.rvdata2",
      "Chapter5_Cleared.rvdata2",
      "Chapter6_Cleared.rvdata2",
      "Chapter7_Cleared.rvdata2",
      "Chapter8_Cleared.rvdata2",
      "Chapter9_Cleared.rvdata2",
      ] #Do Not Remove
    #------------------------------------------------------------------------------
    # Save Data's Name
    #------------------------------------------------------------------------------
      SAVE_FILE = [
      "Chapter1_Cleared.rvdata2",
      "Chapter2_Cleared.rvdata2",
      "Chapter3_Cleared.rvdata2",
      "Chapter4_Cleared.rvdata2",
      "Chapter5_Cleared.rvdata2",
      "Chapter6_Cleared.rvdata2",
      "Chapter7_Cleared.rvdata2",
      "Chapter8_Cleared.rvdata2",
      "Chapter9_Cleared.rvdata2",
      "Chapter10_Cleared.rvdata2",
      ] #Do Not Remove
    #==============================================================================
    # END OF SETTINGS AREA
    # !!EDIT BEYOND THIS LINE AT YOUR OWN RISK!!
    #==============================================================================
    end
    module DataManager
      class <<self 
        alias meow_god create_game_objects
        alias meow_load extract_save_contents
        alias meow_save make_save_contents
      end
      def self.make_save_contents
        meowdata = meow_save
        meowdata[:chapter] = $game_chapter
        meowdata
      end
      def self.extract_save_contents(contents)
        meow_load(contents)
        $game_chapter = contents[:chapter]
      end
      def self.make_save_party
        contents = {}
        contents[:actors]        = $game_actors
        contents[:party]         = $game_party
        contents[:player]        = $game_player
        contents
      end
      def self.extract_party(contents)
        $game_actors        =contents[:actors]
        $game_party         = contents[:party]
        $game_player        = contents[:player]
      end
      def self.save_chapter(chapter)
        filename = MF_CHAPTER::SAVE_FILE[chapter]
        File.open(filename, "wb") do |file|
          $game_system.on_before_save
          Marshal.dump(make_save_party, file)
        end
        return true
      end
      def self.load_chapter(chapter)
        filename = MF_CHAPTER::LOAD_FILE[chapter]
        File.open(filename, "rb") do |file|
          extract_party(Marshal.load(file))
        end
        return true
      end
      def self.create_game_objects
        meow_god
        $game_chapter = Game_Chapter.new
      end
      def self.setup_chapter
        chapter = $game_chapter.id
        load_chapter(chapter) if MF_CHAPTER::LOAD_FILE[chapter] != nil
        $game_party.setup_members(chapter)
        $game_map.setup(MF_CHAPTER::MAP[chapter][0])
        $game_player.moveto(MF_CHAPTER::MAP[chapter][1], MF_CHAPTER::MAP[chapter][2])
        $game_player.refresh
        Graphics.frame_count = 0
      end
    end
    class Game_Party < Game_Unit
      def setup_members(n)
        if MF_CHAPTER::LOAD_FILE[$game_chapter.id] != nil
          @actors.each do |m|
            $game_actors[m].setup(m) if MF_CHAPTER::RESET == true
            $game_actors[m].hp = $game_actors[m].mhp
            $game_actors[m].mp = $game_actors[m].mmp
          end
        end
        @actors = []
        @meowparty = MF_CHAPTER::ACTORS[n]
          @meowparty.each do |meow|
            $game_party.add_actor(meow)
          end
      end
    end
    class Game_Chapter
      attr_accessor :id
      def initialize
        @id = 0
      end
      def set(n)
        @id = n
      end
    end
    class Game_Interpreter
      def chapter_cleared
        DataManager.save_chapter($game_chapter.id)
      end
    end
    class Window_Chapter < Window_Base
      def initialize
        super(0, 0, Graphics.width, Graphics.height)
        self.opacity = 0
        draw_horz_line(Graphics.height - 100)
        draw_horz_line(Graphics.height - 36)
        draw_horz_line(68); draw_horz_line(69)
        draw_horz_line(8); draw_horz_line(7)
        draw_title
      end
      def window_width
        Graphics.width
      end
      def window_height
        Graphics.height
      end
      def draw_horz_line(y)
        line_y = y + line_height / 2 - 1
        contents.fill_rect(0, line_y, contents_width, 2, line_color)
      end
      def line_color
        color = normal_color
        color.alpha = 48
        color
      end
      def draw_title
        contents.font.size = 64
        contents.font.bold = true
        draw_text((Graphics.width/2) - (320/2), 18, 320, 68, MF_CHAPTER::TITLE)
        contents.font.size = Font.default_size
        contents.font.bold = false
      end
    end
    class Window_ChapterSelect < Window_Command
      def initialize
        super(0,0)
        update_placement
        self.opacity = 0
        create_help_window
      end
      def window_width
        return 180
      end
      def window_height
        fitting_height(6)
      end
      def update_placement
        self.x = (Graphics.width - width) / 2
        self.y = ((Graphics.height - height) / 2) - 12
      end
      def create_help_window
        @help_window = Window_Help.new
        @help_window.y = Graphics.height - @help_window.height + 4
        @help_window.opacity = 0
      end
      def make_command_list
        add_command(MF_CHAPTER::NAME[0], :ch1)
        add_command(MF_CHAPTER::NAME[1], :ch2, File.exist?(MF_CHAPTER::SAVE_FILE[0]))if MF_CHAPTER::MAXCHAPTER >= 2
        add_command(MF_CHAPTER::NAME[2], :ch3, File.exist?(MF_CHAPTER::SAVE_FILE[1])) if MF_CHAPTER::MAXCHAPTER >= 3
        add_command(MF_CHAPTER::NAME[3], :ch4, File.exist?(MF_CHAPTER::SAVE_FILE[2])) if MF_CHAPTER::MAXCHAPTER >= 4
        add_command(MF_CHAPTER::NAME[4], :ch5, File.exist?(MF_CHAPTER::SAVE_FILE[3])) if MF_CHAPTER::MAXCHAPTER >= 5
        add_command(MF_CHAPTER::NAME[5], :ch6, File.exist?(MF_CHAPTER::SAVE_FILE[4])) if MF_CHAPTER::MAXCHAPTER >= 6
        add_command(MF_CHAPTER::NAME[6], :ch7, File.exist?(MF_CHAPTER::SAVE_FILE[5])) if MF_CHAPTER::MAXCHAPTER >= 7
        add_command(MF_CHAPTER::NAME[7], :ch8, File.exist?(MF_CHAPTER::SAVE_FILE[6])) if MF_CHAPTER::MAXCHAPTER >= 8
        add_command(MF_CHAPTER::NAME[8], :ch9, File.exist?(MF_CHAPTER::SAVE_FILE[7])) if MF_CHAPTER::MAXCHAPTER >= 9
        add_command(MF_CHAPTER::NAME[9], :ch10, File.exist?(MF_CHAPTER::SAVE_FILE[8])) if MF_CHAPTER::MAXCHAPTER >= 10
      end
      def process_cursor_move
        super
        if @index <= 1
          @help_window.set_text(MF_CHAPTER::DESC[@index])
        else
          if File.exist?(MF_CHAPTER::SAVE_FILE[@index-1])
            text = MF_CHAPTER::DESC[@index]
          else
            text = "???"
          end
          @help_window.set_text(text)
        end
      end
    end
    class Scene_Title < Scene_Base
      def command_new_game
        SceneManager.call(Scene_Chapter)
      end
    end
    class Scene_Chapter < Scene_Base
      def start
        super
        create_background2
        create_back_window
        create_command_window
      end
      def create_background2
        @spritech = Sprite.new
        @spritech.bitmap = Cache.title1(MF_CHAPTER::BACKGROUND)
        @spritech.tone.set(0, 0, 0, 180)
      end
      def terminate
        super
        @spritech.bitmap.dispose if @spritech
        @spritech.dispose if @spritech
      end
      def create_back_window
        @back_window = Window_Chapter.new
      end
      def create_command_window
        @command_window = Window_ChapterSelect.new
        @command_window.set_handler(:ch1, method(:chapter))
        @command_window.set_handler(:ch2, method(:chapter))
        @command_window.set_handler(:ch3, method(:chapter))
        @command_window.set_handler(:ch4, method(:chapter))
        @command_window.set_handler(:ch5, method(:chapter))
        @command_window.set_handler(:ch6, method(:chapter))
        @command_window.set_handler(:ch7, method(:chapter))
        @command_window.set_handler(:ch8, method(:chapter))
        @command_window.set_handler(:ch9, method(:chapter))
        @command_window.set_handler(:ch10, method(:chapter))
        @command_window.set_handler(:cancel, method(:return_scene))
      end
      def chapter
        DataManager.create_game_objects
        case @command_window.current_symbol
        when :ch1; $game_chapter.set(0)
        when :ch2; $game_chapter.set(1)
        when :ch3; $game_chapter.set(2)
        when :ch4; $game_chapter.set(3)
        when :ch5; $game_chapter.set(4)
        when :ch6; $game_chapter.set(5)
        when :ch7; $game_chapter.set(6)
        when :ch8; $game_chapter.set(7)
        when :ch9; $game_chapter.set(8)
        when :ch10; $game_chapter.set(9)
        end
        DataManager.setup_chapter
        fadeout_all
        $game_map.autoplay
        SceneManager.goto(Scene_Map)
      end
    end
    Final Update:

    All cleaned up and aliased

    The only overwrite method is the Title Scene's New Game Command.

    You can now safely put this script below all other scripts without having to worry much about conflicts.
     
    Last edited by a moderator: Nov 24, 2018
    #1
  2. DonutMonkey

    DonutMonkey Ultimate Supreme Executive Chairman Member

    Messages:
    23
    Likes Received:
    3
    Location:
    United States
    First Language:
    English
    Primarily Uses:
    RMMV
    I love this script but i'd prefer it to not change where you spawn in each chapter.

    Is there a way to change that?
     
    #2
  3. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    179
    Location:
    La La Land
    First Language:
    Meowish
    You can simply set all the starting map area to be the same if you don't want a new starting point for each chapter.
     
    #3
  4. mastersword20

    mastersword20 Opps, I broke the 4th wall again! Member

    Messages:
    9
    Likes Received:
    1
    Location:
    Game Industri
    First Language:
    Anime
    I don't understand how to end a chapter. Could you please explain it to me? It's not working.
     
    #4
  5. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    179
    Location:
    La La Land
    First Language:
    Meowish
    Simply use this script call at the end of a chapter to save a file for the next chapter.

    chapter_clearedThen proceed to ending and return to title screen.

    Depending on how you build your game, each chapter can act as a stand alone game itself and sharing the map resources among all the games.
     
    #5
  6. mastersword20

    mastersword20 Opps, I broke the 4th wall again! Member

    Messages:
    9
    Likes Received:
    1
    Location:
    Game Industri
    First Language:
    Anime
    When I try that I get an error.
     
    #6
  7. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    179
    Location:
    La La Land
    First Language:
    Meowish
    What error are you getting? If possible try snap shot it.

    This script is using mostly new methods so the chances of conflict is quite low, but still, not 100%
     
    #7
  8. mastersword20

    mastersword20 Opps, I broke the 4th wall again! Member

    Messages:
    9
    Likes Received:
    1
    Location:
    Game Industri
    First Language:
    Anime
    Last edited by a moderator: Dec 6, 2015
    #8
  9. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    179
    Location:
    La La Land
    First Language:
    Meowish
    Seems like you either did something wrong with the script call or there's another script conflicting with this script's interpreter procedure.

    Make sure you use the script call as shown in the picture below:

    [​IMG]

    Try this script on a new project and see if you are still getting that error.

    If you are not getting error in a new project with this script, try adding back your other custom script one by one until that error shows up.

    Like said in the post above, this script only modifies the title command new game method, the rest are actually new or aliased. So putting this script below all other custom script should work unless a script modifies an important feature this script needed.
     
    #9
  10. mastersword20

    mastersword20 Opps, I broke the 4th wall again! Member

    Messages:
    9
    Likes Received:
    1
    Location:
    Game Industri
    First Language:
    Anime
    I just tried that and it worked in a new project but when i tried in mine it didn't. i even tried removing all my other scripts. it didnt work
     
    #10
  11. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    179
    Location:
    La La Land
    First Language:
    Meowish
    I can't do much here unless you are able to reproduce it 100% in a new project.

    One of your custom script may have modified an important method this script needs.

    eg, how files or paths are being saved by the default DataManager.

    So unless you can find that conflicting script, i can't do anything to help since this script isn't causing the problem by itself.
     
    #11
  12. mastersword20

    mastersword20 Opps, I broke the 4th wall again! Member

    Messages:
    9
    Likes Received:
    1
    Location:
    Game Industri
    First Language:
    Anime
    I just tried adding my scripts to a new project and none are conflicting. Ill try something else.
     
    #12
  13. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    179
    Location:
    La La Land
    First Language:
    Meowish
    Good luck with it. Let me know when you find the culprit. ;)
     
    #13
    DoctorArtist likes this.
  14. fahyda

    fahyda Villager Member

    Messages:
    17
    Likes Received:
    0
    First Language:
    english
    Is the script meant to be in one line or should i break up the script into multiple lines?
     
    #14
  15. Kizami

    Kizami Alejandro Veteran

    Messages:
    38
    Likes Received:
    12
    Location:
    Colombia
    First Language:
    Spanish
    Primarily Uses:
    RMMV
    It has to be in multiple lines. The issue is that administrators are updating the forum system to the latest version, and that included the feature to put codes, so that's why when you copy the script and paste it, it has one line only, because they are still working on the forum, and the scripts don't appear correctly, so you cannot copy them correctly either.


    So, it's better to wait until they're done adding these changes to the forum =)
     
    #15
  16. fahyda

    fahyda Villager Member

    Messages:
    17
    Likes Received:
    0
    First Language:
    english
    Ok
     
    #16
  17. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    179
    Location:
    La La Land
    First Language:
    Meowish
    The codes are currently messed up due to the recent forum upgrade.


    They are working to fix the code and I was told that the codes will revert after the patch if i change them now.


    So unless you need it urgently, please wait a few days and check again to see if they are fixed.


    You can also check this issue report tread for any new updates on the messed up codes.
     
    #17
  18. SadGhoster87

    SadGhoster87 Veteran Veteran

    Messages:
    76
    Likes Received:
    5
    First Language:
    English
    I love this; I may just use it in Aeon.
     
    #18
  19. MeowFace

    MeowFace Meow Veteran

    Messages:
    1,034
    Likes Received:
    179
    Location:
    La La Land
    First Language:
    Meowish
    The script in the top post is being messed up due to the recent V3 to V4 migration, it should fix itself when the RM web staff got the patch from the software provider.


    In the meantime, please use this alternative version:

    Code:
    #==============================================================================
    # ■ Meow Face Chapter Selection
    #------------------------------------------------------------------------------
    # Select Chapter to Start Game
    #==============================================================================
    # How to Use:
    # [1] Put this script below Material and above Main
    # [2] Set up the required data in SETTINGS AREA below
    # [3] At the end of each chapter, use this script call to save file
    #      chapter_cleared
    #==============================================================================
    module MF_CHAPTER
    #==============================================================================
    # SETTINGS AREA
    #==============================================================================
    #------------------------------------------------------------------------------
    # How many chapters are there (1 to 10 MAX)
    #------------------------------------------------------------------------------
      MAXCHAPTER = 10
    #------------------------------------------------------------------------------
    # Background picture (in Graphics\Titles1 folder)
    #------------------------------------------------------------------------------
      BACKGROUND = "Fountain"
    #------------------------------------------------------------------------------
    # Title
    #------------------------------------------------------------------------------
      TITLE = "SELECT CHAPTER"
    #------------------------------------------------------------------------------
    # Chapter's Name
    # Starting from top down, Chapter 1, Chapter 2, etc etc
    #------------------------------------------------------------------------------
      NAME = [
      "Chapter One",
      "Chapter Two",
      "Chapter Three",
      "Chapter Four",
      "Chapter Five",
      "Chapter Six",
      "Chapter Seven",
      "Chapter Eight",
      "Chapter Nine",
      "Chapter Ten",
      ] #Do Not Remove
    #------------------------------------------------------------------------------
    # Chapter's Description
    # Starting from top down, Chapter 1, Chapter 2, etc etc
    #------------------------------------------------------------------------------
      DESC = [
      "Chapter 1 Descriptions",
      "Chapter 2 Descriptions",
      "Chapter 3 Descriptions",
      "Chapter 4 Descriptions",
      "Chapter 5 Descriptions",
      "Chapter 6 Descriptions",
      "Chapter 7 Descriptions",
      "Chapter 8 Descriptions",
      "Chapter 9 Descriptions",
      "Chapter 10 Descriptions",
      ] #Do Not Remove
    #------------------------------------------------------------------------------
    # Starting Map for each Chapter
    # [MapID, StartX, StartY]
    # Starting top down from Chapter 1 to Chapter 10
    #------------------------------------------------------------------------------
      MAP = [
      [1,1,1],
      [2,1,7],
      [3,12,16],
      [4,1,1],
      [5,1,1],
      [6,1,1],
      [7,1,1],
      [8,1,1],
      [9,1,1],
      [10,1,1],
      ] #Do Not Remove
    #------------------------------------------------------------------------------
    # Starting Actors for each Chapter
    # Starting top down from Chapter 1 to Chapter 10
    #------------------------------------------------------------------------------
      ACTORS = [
      [1,4,2,5],
      [1,2,3,4],
      [1,2,3],
      [2,3,4,5],
      [1,2,3,4],
      [1,2,3,4],
      [1,2,3,4],
      [1,2,3,4],
      [1,2,3,4],
      [1,2,3,4],
      ] #Do Not Remove
    #------------------------------------------------------------------------------
    # Reset Actor's Level? true/false
    # Automatic set to true if previous chapter load file = nil
    #------------------------------------------------------------------------------
      RESET = false
    #------------------------------------------------------------------------------
    # Data Loading for each Chapter
    # This loads the data of the previous chapters during chapter selection
    # So set up the file for each chapter accordingly
    # Starting top down from Chapter 1 to Chapter 10
    # nil = No load file
    #------------------------------------------------------------------------------
      LOAD_FILE = [
      nil,
      "Chapter1_Cleared.rvdata2",
      "Chapter2_Cleared.rvdata2",
      "Chapter3_Cleared.rvdata2",
      "Chapter4_Cleared.rvdata2",
      "Chapter5_Cleared.rvdata2",
      "Chapter6_Cleared.rvdata2",
      "Chapter7_Cleared.rvdata2",
      "Chapter8_Cleared.rvdata2",
      "Chapter9_Cleared.rvdata2",
      ] #Do Not Remove
    #------------------------------------------------------------------------------
    # Save Data's Name
    #------------------------------------------------------------------------------
      SAVE_FILE = [
      "Chapter1_Cleared.rvdata2",
      "Chapter2_Cleared.rvdata2",
      "Chapter3_Cleared.rvdata2",
      "Chapter4_Cleared.rvdata2",
      "Chapter5_Cleared.rvdata2",
      "Chapter6_Cleared.rvdata2",
      "Chapter7_Cleared.rvdata2",
      "Chapter8_Cleared.rvdata2",
      "Chapter9_Cleared.rvdata2",
      "Chapter10_Cleared.rvdata2",
      ] #Do Not Remove
    #==============================================================================
    # END OF SETTINGS AREA
    # !!EDIT BEYOND THIS LINE AT YOUR OWN RISK!!
    #==============================================================================
    end
    module DataManager
      class <<self  
        alias meow_god create_game_objects
        alias meow_load extract_save_contents
        alias meow_save make_save_contents
      end
      def self.make_save_contents
        meowdata = meow_save
        meowdata[:chapter] = $game_chapter
        meowdata
      end
      def self.extract_save_contents(contents)
        meow_load(contents)
        $game_chapter = contents[:chapter]
      end
      def self.make_save_party
        contents = {}
        contents[:actors]        = $game_actors
        contents[:party]         = $game_party
        contents[:player]        = $game_player
        contents
      end
      def self.extract_party(contents)
        $game_actors        =contents[:actors]
        $game_party         = contents[:party]
        $game_player        = contents[:player]
      end
      def self.save_chapter(chapter)
        filename = MF_CHAPTER::SAVE_FILE[chapter]
        File.open(filename, "wb") do |file|
          $game_system.on_before_save
          Marshal.dump(make_save_party, file)
        end
        return true
      end
      def self.load_chapter(chapter)
        filename = MF_CHAPTER::LOAD_FILE[chapter]
        File.open(filename, "rb") do |file|
          extract_party(Marshal.load(file))
        end
        return true
      end
      def self.create_game_objects
        meow_god
        $game_chapter = Game_Chapter.new
      end
      def self.setup_chapter
        chapter = $game_chapter.id
        load_chapter(chapter) if MF_CHAPTER::LOAD_FILE[chapter] != nil
        $game_party.setup_members(chapter)
        $game_map.setup(MF_CHAPTER::MAP[chapter][0])
        $game_player.moveto(MF_CHAPTER::MAP[chapter][1], MF_CHAPTER::MAP[chapter][2])
        $game_player.refresh
        Graphics.frame_count = 0
      end
    end
    class Game_Party < Game_Unit
      def setup_members(n)
        if MF_CHAPTER::LOAD_FILE[$game_chapter.id] != nil
          @actors.each do |m|
            $game_actors[m].setup(m) if MF_CHAPTER::RESET == true
            $game_actors[m].hp = $game_actors[m].mhp
            $game_actors[m].mp = $game_actors[m].mmp
          end
        end
        @actors = []
        @meowparty = MF_CHAPTER::ACTORS[n]
          @meowparty.each do |meow|
            $game_party.add_actor(meow)
          end
      end
    end
    class Game_Chapter
      attr_accessor :id
      def initialize
        @id = 0
      end
      def set(n)
        @id = n
      end
    end
    class Game_Interpreter
      def chapter_cleared
        DataManager.save_chapter($game_chapter.id)
      end
    end
    class Window_Chapter < Window_Base
      def initialize
        super(0, 0, Graphics.width, Graphics.height)
        self.opacity = 0
        draw_horz_line(Graphics.height - 100)
        draw_horz_line(Graphics.height - 36)
        draw_horz_line(68); draw_horz_line(69)
        draw_horz_line(8); draw_horz_line(7)
        draw_title
      end
      def window_width
        Graphics.width
      end
      def window_height
        Graphics.height
      end
      def draw_horz_line(y)
        line_y = y + line_height / 2 - 1
        contents.fill_rect(0, line_y, contents_width, 2, line_color)
      end
      def line_color
        color = normal_color
        color.alpha = 48
        color
      end
      def draw_title
        contents.font.size = 64
        contents.font.bold = true
        draw_text((Graphics.width/2) - (320/2), 18, 320, 68, MF_CHAPTER::TITLE)
        contents.font.size = Font.default_size
        contents.font.bold = false
      end
    end
    class Window_ChapterSelect < Window_Command
      def initialize
        super(0,0)
        update_placement
        self.opacity = 0
        create_help_window
      end
      def window_width
        return 180
      end
      def window_height
        fitting_height(6)
      end
      def update_placement
        self.x = (Graphics.width - width) / 2
        self.y = ((Graphics.height - height) / 2) - 12
      end
      def create_help_window
        @help_window = Window_Help.new
        @help_window.y = Graphics.height - @help_window.height + 4
        @help_window.opacity = 0
      end
      def make_command_list
        add_command(MF_CHAPTER::NAME[0], :ch1)
        add_command(MF_CHAPTER::NAME[1], :ch2, File.exist?(MF_CHAPTER::SAVE_FILE[0]))if MF_CHAPTER::MAXCHAPTER >= 2
        add_command(MF_CHAPTER::NAME[2], :ch3, File.exist?(MF_CHAPTER::SAVE_FILE[1])) if MF_CHAPTER::MAXCHAPTER >= 3
        add_command(MF_CHAPTER::NAME[3], :ch4, File.exist?(MF_CHAPTER::SAVE_FILE[2])) if MF_CHAPTER::MAXCHAPTER >= 4
        add_command(MF_CHAPTER::NAME[4], :ch5, File.exist?(MF_CHAPTER::SAVE_FILE[3])) if MF_CHAPTER::MAXCHAPTER >= 5
        add_command(MF_CHAPTER::NAME[5], :ch6, File.exist?(MF_CHAPTER::SAVE_FILE[4])) if MF_CHAPTER::MAXCHAPTER >= 6
        add_command(MF_CHAPTER::NAME[6], :ch7, File.exist?(MF_CHAPTER::SAVE_FILE[5])) if MF_CHAPTER::MAXCHAPTER >= 7
        add_command(MF_CHAPTER::NAME[7], :ch8, File.exist?(MF_CHAPTER::SAVE_FILE[6])) if MF_CHAPTER::MAXCHAPTER >= 8
        add_command(MF_CHAPTER::NAME[8], :ch9, File.exist?(MF_CHAPTER::SAVE_FILE[7])) if MF_CHAPTER::MAXCHAPTER >= 9
        add_command(MF_CHAPTER::NAME[9], :ch10, File.exist?(MF_CHAPTER::SAVE_FILE[8])) if MF_CHAPTER::MAXCHAPTER >= 10
      end
      def process_cursor_move
        super
        if @index <= 1
          @help_window.set_text(MF_CHAPTER::DESC[@index])
        else
          if File.exist?(MF_CHAPTER::SAVE_FILE[@index-1])
            text = MF_CHAPTER::DESC[@index]
          else
            text = "???"
          end
          @help_window.set_text(text)
        end
      end
    end
    class Scene_Title < Scene_Base
      def command_new_game
        SceneManager.call(Scene_Chapter)
      end
    end
    class Scene_Chapter < Scene_Base
      def start
        super
        create_background2
        create_back_window
        create_command_window
      end
      def create_background2
        @spritech = Sprite.new
        @spritech.bitmap = Cache.title1(MF_CHAPTER::BACKGROUND)
        @spritech.tone.set(0, 0, 0, 180)
      end
      def terminate
        super
        @spritech.bitmap.dispose if @spritech
        @spritech.dispose if @spritech
      end
      def create_back_window
        @back_window = Window_Chapter.new
      end
      def create_command_window
        @command_window = Window_ChapterSelect.new
        @command_window.set_handler(:ch1, method(:chapter))
        @command_window.set_handler(:ch2, method(:chapter))
        @command_window.set_handler(:ch3, method(:chapter))
        @command_window.set_handler(:ch4, method(:chapter))
        @command_window.set_handler(:ch5, method(:chapter))
        @command_window.set_handler(:ch6, method(:chapter))
        @command_window.set_handler(:ch7, method(:chapter))
        @command_window.set_handler(:ch8, method(:chapter))
        @command_window.set_handler(:ch9, method(:chapter))
        @command_window.set_handler(:ch10, method(:chapter))
        @command_window.set_handler(:cancel, method(:return_scene))
      end
      def chapter
        DataManager.create_game_objects
        case @command_window.current_symbol
        when :ch1; $game_chapter.set(0)
        when :ch2; $game_chapter.set(1)
        when :ch3; $game_chapter.set(2)
        when :ch4; $game_chapter.set(3)
        when :ch5; $game_chapter.set(4)
        when :ch6; $game_chapter.set(5)
        when :ch7; $game_chapter.set(6)
        when :ch8; $game_chapter.set(7)
        when :ch9; $game_chapter.set(8)
        when :ch10; $game_chapter.set(9)
        end
        DataManager.setup_chapter
        fadeout_all
        $game_map.autoplay
        SceneManager.goto(Scene_Map)
      end
    end
     
    #19
    Ploy_V likes this.
  20. GuiltyAxer

    GuiltyAxer The Pseudo Bilingual Member

    Messages:
    4
    Likes Received:
    0
    Location:
    The Backyard, inside the Azure under the Blood Rai
    First Language:
    French
    Awesome !
    Too bad you can't launch the chapter select with a event. I would need something like that for a game of mine with 13 actors, where you start with 14th one, who is there just for the tutorial...


    And, there isn't any way to have more than 10 chapter ? (Like 13 for example c: )


    Except that, just awesome ! :3
     
    #20

Share This Page