[XP] Simple Character Selector

Character Selector V. 1.1

Introduction
I originally made this for a friend, but then I thought that I might as well share it with you guys.
It's basically just a simple character selector, nothing big really.

Features
Version 1.1
- You can now choose what actor's that shouldn't be included.
- You can now go back from character selection to "New Game", "Continue", "Shutdown"

Version 1.0
- Simple scrolling character selection window.

Screenshots
Content Hidden Spoiler
Image


Download
Wont be needed.
Just take the script and insert it above Main.

Script
Content Hidden Spoiler
  1. #==============================================================================
  2. # ** Character selector
  3. #------------------------------------------------------------------------------
  4. # Author      S.S Muu
  5. # Version    1.1
  6. # Date         23-01-09 (dd-mm-yy)
  7. #==============================================================================
  8.  
  9. #--[   Config   ]----------------------------------------------------------------
  10. DO_NOT_INCLUDE = [] # The actors who shouldn't be included. For example [1, 4, 6]
  11.  
  12. #--[   IMPORTANT   ]-------------------------------------------------------------
  13. #-- Don't Edit Below if you don't know what you're doing!
  14. #------------------------------------------------------------------------------
  15.  
  16. #==============================================================================
  17. # ** Game_Party
  18. #------------------------------------------------------------------------------
  19. #   This class handles the party. It includes information on amount of gold
  20. #   and items. Refer to "$game_party" for the instance of this class.
  21. #==============================================================================
  22. class Game_Party
  23.   attr_accessor :actors # Actors
  24. end
  25.  
  26. #==============================================================================
  27. # ** Window_Command
  28. #------------------------------------------------------------------------------
  29. #   This window deals with general command choices.
  30. #==============================================================================
  31. class Window_Command < Window_Selectable
  32.   attr_reader :commands
  33.   #--------------------------------------------------------------------------
  34.   # * New Commands
  35.   #--------------------------------------------------------------------------
  36.   def new_commands(commands)
  37.      @item_max = commands.size
  38.      @commands = commands
  39.      self.contents = Bitmap.new(self.width - 32, @item_max * 32)
  40.      refresh
  41.      self.index = 0
  42.   end
  43. end
  44.  
  45. #==============================================================================
  46. # ** Scene_Title
  47. #------------------------------------------------------------------------------
  48. #   This class performs title screen processing.
  49. #==============================================================================
  50.  
  51. class Scene_Title
  52.   #--------------------------------------------------------------------------
  53.   # * Main Processing
  54.   #--------------------------------------------------------------------------
  55.   def main
  56.      # If battle test
  57.      if $BTEST
  58.         battle_test
  59.         return
  60.      end
  61.      # Load database
  62.      $data_actors            = load_data("Data/Actors.rxdata")
  63.      $data_classes          = load_data("Data/Classes.rxdata")
  64.      $data_skills            = load_data("Data/Skills.rxdata")
  65.      $data_items             = load_data("Data/Items.rxdata")
  66.      $data_weapons          = load_data("Data/Weapons.rxdata")
  67.      $data_armors            = load_data("Data/Armors.rxdata")
  68.      $data_enemies          = load_data("Data/Enemies.rxdata")
  69.      $data_troops            = load_data("Data/Troops.rxdata")
  70.      $data_states            = load_data("Data/States.rxdata")
  71.      $data_animations      = load_data("Data/Animations.rxdata")
  72.      $data_tilesets         = load_data("Data/Tilesets.rxdata")
  73.      $data_common_events = load_data("Data/CommonEvents.rxdata")
  74.      $data_system            = load_data("Data/System.rxdata")
  75.      # Make system object
  76.      $game_system = Game_System.new
  77.      # Make title graphic
  78.      @sprite = Sprite.new
  79.      @sprite.bitmap = RPG::Cache.title($data_system.title_name)
  80.      # Make characters
  81.      @characters = []
  82.      for i in 1...$data_actors.size
  83.         @characters.push($data_actors[i].name) if !DO_NOT_INCLUDE.include?(i)
  84.      end
  85.      @characters_height = @characters.size * 32 + 32
  86.      # Make command window
  87.      s1 = "New Game"
  88.      s2 = "Continue"
  89.      s3 = "Shutdown"
  90.      @command_window = Window_Command.new(192, [s1, s2, s3])
  91.      @command_window.back_opacity = 160
  92.      @command_window.x = 320 - @command_window.width / 2
  93.      @command_window.y = 288
  94.      # Make default commands
  95.      @default = [s1, s2, s3]
  96.      # Continue enabled determinant
  97.      # Check if at least one save file exists
  98.      # If enabled, make @continue_enabled true; if disabled, make it false
  99.      @continue_enabled = false
  100.      for i in 0..3
  101.         if FileTest.exist?("Save#{i+1}.rxdata")
  102.            @continue_enabled = true
  103.         end
  104.      end
  105.      # If continue is enabled, move cursor to "Continue"
  106.      # If disabled, display "Continue" text in gray
  107.      if @continue_enabled
  108.         @command_window.index = 1
  109.      else
  110.         @command_window.disable_item(1)
  111.      end
  112.      # Play title BGM
  113.      $game_system.bgm_play($data_system.title_bgm)
  114.      # Stop playing ME and BGS
  115.      Audio.me_stop
  116.      Audio.bgs_stop
  117.      # Execute transition
  118.      Graphics.transition
  119.      # Main loop
  120.      loop do
  121.         # Update game screen
  122.         Graphics.update
  123.         # Update input information
  124.         Input.update
  125.         # Frame update
  126.         update
  127.         # Abort loop if screen is changed
  128.         if $scene != self
  129.            break
  130.         end
  131.      end
  132.      # Prepare for transition
  133.      Graphics.freeze
  134.      # Dispose of command window
  135.      @command_window.dispose
  136.      # Dispose of title graphic
  137.      @sprite.bitmap.dispose
  138.      @sprite.dispose
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # * Frame Update
  142.   #--------------------------------------------------------------------------
  143.   def update
  144.      # Update command window
  145.      @command_window.update
  146.      if @command_window.commands == @characters and @command_window.height < @characters_height and @command_window.y > 32
  147.         @command_window.y -= 5
  148.         @command_window.height += 5
  149.      elsif @command_window.commands == @default and @command_window.height > 128
  150.         @command_window.y += 5
  151.         @command_window.height -= 5
  152.      elsif @command_window.commands == @default and @command_window.height < 128
  153.         @command_window.y -= 1
  154.         @command_window.height += 1
  155.      end
  156.      # If B button was pressed
  157.      if Input.trigger?(Input::B)
  158.         # Play cancel SE
  159.         $game_system.se_play($data_system.cancel_se)
  160.         # Switch to Default commands
  161.         @command_window.new_commands(@default)
  162.         if @continue_enabled
  163.            @command_window.index = 1
  164.         else
  165.            @command_window.disable_item(1)
  166.         end
  167.      end
  168.      # If C button was pressed
  169.      if Input.trigger?(Input::C)
  170.         # Branch by command window cursor position
  171.         if @command_window.commands == @characters
  172.            command_new_game
  173.         else
  174.            case @command_window.index
  175.            when 0   # New game
  176.               # Play decision SE
  177.               $game_system.se_play($data_system.decision_se)
  178.               # Switch to Character commands
  179.               @command_window.new_commands(@characters)
  180.            when 1   # Continue
  181.               command_continue
  182.            when 2   # Shutdown
  183.               command_shutdown
  184.            end
  185.         end
  186.      end
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # * Command: New Game
  190.   #--------------------------------------------------------------------------
  191.   def command_new_game
  192.      # Play decision SE
  193.      $game_system.se_play($data_system.decision_se)
  194.      # Stop BGM
  195.      Audio.bgm_stop
  196.      # Reset frame count for measuring play time
  197.      Graphics.frame_count = 0
  198.      # Make each type of game object
  199.      $game_temp               = Game_Temp.new
  200.      $game_system            = Game_System.new
  201.      $game_switches         = Game_Switches.new
  202.      $game_variables       = Game_Variables.new
  203.      $game_self_switches = Game_SelfSwitches.new
  204.      $game_screen            = Game_Screen.new
  205.      $game_actors            = Game_Actors.new
  206.      $game_party             = Game_Party.new
  207.      $game_troop             = Game_Troop.new
  208.      $game_map                = Game_Map.new
  209.      $game_player            = Game_Player.new
  210.      # Set up initial party
  211.      $game_party.setup_starting_members
  212.      $game_party.actors[0] = $game_actors[@command_window.index + 1]
  213.      # Set up initial map position
  214.      $game_map.setup($data_system.start_map_id)
  215.      # Move player to initial position
  216.      $game_player.moveto($data_system.start_x, $data_system.start_y)
  217.      # Refresh player
  218.      $game_player.refresh
  219.      # Run automatic change for BGM and BGS set with map
  220.      $game_map.autoplay
  221.      # Update map (run parallel process event)
  222.      $game_map.update
  223.      # Switch to map screen
  224.      $scene = Scene_Map.new
  225.   end
  226. end
  227.  
Expand to see the code.


Instructions
You don't have to do anything else then insert it above Main, it will then automatically take every character from the "Actors" tab in the database.

If you on the other hand don't want all the actors to show up, edit line 10 in the script,
for example, if you don't want actor 1, 4, and 5 to be playable, then edit it like so,
  1. DO_NOT_INCLUDE = [1, 4, 5]
Expand to see the code.


Bug Report?
- None so far.
- Please report all bugs that you can find.

Author's Notes
You are free to use the this scripts in your commercial or non-commercial projects without credits, but it would be greatly appreciated if you do give credits.

Please do not redistribute this script without permission. If you want to post it on any forum, please link to this topic.

Credit
S.S Muu - For creating the script.
You don't know what the people look like?
I guess it is called "Simple." Looks pretty good anyway.
Nice script,simple but good =D o/~
Thanks :]

Well, the main reason I made it so simple is because everyone else keeps making their's so big and whatnot, I just wanted a little change from that. 🙂
What this needs (and would make it really cool) is a strategy pattern for specifying how the characters are selected; you basically provide a simple selector skeleton like the current one, but in addition to taking in an array of characters (or is an hash? idk) you also give it a callback, that is, a Proc or Method object. When it's time to draw the "commands" (which are now names), you can simply call the Proc or Method object and pass it the current character (or command) to be drawn at such and such coordinates (the Proc would return the next set of coordinates). It's slightly more complex, but much more flexible.

Just a thought. :thumb:
From what I understand you want it have a method that specifies what should be listed? (instead of the characters)

Sorry, but I don't really understand what you mean.
Care to try to explain again? :]
Make an array that specifies which actors IDs to be called in the command window.
Good idea, I'll add that, but I'll make the opposite, instead of an array of the actors who should be on, I'll make an array of those who shouldn't be on the list.
That way you can still use it without editing anything. 😀
It's the strategy pattern; you pass it a method which will dictate how it behaves. In this instance, I suggested that the method itself (the Proc object) should take care of the DISPLAY of the characters; that way one could have faces instead of names, or full body graphics, etc.
thanks man 😀
@etheon
Yeah, I guess I could add that, but it would remove the "Simple" part of the script, which is really the base of the script.
Sorry ~

@the_FATE
You're welcome :thumb:


I was gonna update the first post with a new version of the script, but for some reason I can't edit my post. ("You cannot edit your posts in this forum")
Try now.
Nope, still doesn't work. ~
Updated to Version 1.1 😀
I can't get it working... Just my skills in this lol.
I add it above "Main" scripts but it doesn't change a thing... Help? =]
This is simple but good. But if you can change a name by yourself this won't work.
How would you add a message before it pops up?
Love it! thanks SS, should be very good for my game! :) 5/5 😀
Hey,when i choose any other character than "aluxes",the sprite is for "basil",is there any way to fix this??

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=60940