设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
楼主: BB崽
打印 上一主题 下一主题

[原创发布] RMXP SDK(震撼登场)

 关闭 [复制链接]

Lv1.梦旅人

贵宾

梦石
0
星屑
50
在线时间
261 小时
注册时间
2005-10-21
帖子
489

贵宾

11
 楼主| 发表于 2005-12-21 22:13:29 | 只看该作者

  1. #==============================================================================
  2. # ** Scene_Title
  3. #------------------------------------------------------------------------------
  4. #  This class performs title screen processing.
  5. #==============================================================================

  6. class Scene_Title
  7.   #--------------------------------------------------------------------------
  8.   # * Main Processing
  9.   #--------------------------------------------------------------------------
  10.   def main
  11.     return if main_battle_test?
  12.     main_database
  13.     main_background
  14.     main_menu
  15.     main_test_continue
  16.     main_audio
  17.     # Execute transition
  18.     Graphics.transition
  19.     # Main loop
  20.     loop do
  21.       main_loop
  22.       break if main_scenechange?
  23.     end
  24.     # Prepare for transition
  25.     Graphics.freeze
  26.     main_dispose
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   # * Battle Test Check
  30.   #--------------------------------------------------------------------------
  31.   def main_battle_test?
  32.     # If battle test
  33.     if $BTEST
  34.       battle_test
  35.       return true
  36.     end
  37.     return false
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   # * Load Database
  41.   #--------------------------------------------------------------------------
  42.   def main_database
  43.     # Load database
  44.     $data_actors        = load_data("Data/Actors.rxdata")
  45.     $data_classes       = load_data("Data/Classes.rxdata")
  46.     $data_skills        = load_data("Data/Skills.rxdata")
  47.     $data_items         = load_data("Data/Items.rxdata")
  48.     $data_weapons       = load_data("Data/Weapons.rxdata")
  49.     $data_armors        = load_data("Data/Armors.rxdata")
  50.     $data_enemies       = load_data("Data/Enemies.rxdata")
  51.     $data_troops        = load_data("Data/Troops.rxdata")
  52.     $data_states        = load_data("Data/States.rxdata")
  53.     $data_animations    = load_data("Data/Animations.rxdata")
  54.     $data_tilesets      = load_data("Data/Tilesets.rxdata")
  55.     $data_common_events = load_data("Data/CommonEvents.rxdata")
  56.     $data_system        = load_data("Data/System.rxdata")
  57.     # Make system object
  58.     $game_system = Game_System.new
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # * Background Initialization
  62.   #--------------------------------------------------------------------------
  63.   def main_background
  64.     # Make title graphic
  65.     @sprite = Sprite.new
  66.     @sprite.bitmap = RPG::Cache.title($data_system.title_name)
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # * Main Menu Initialization
  70.   #--------------------------------------------------------------------------
  71.   def main_menu
  72.     # Make command window
  73.     s1 = "New Game"
  74.     s2 = "Continue"
  75.     s3 = "Shutdown"
  76.     @command_window = Window_Command.new(192, [s1, s2, s3])
  77.     @command_window.back_opacity = 160
  78.     @command_window.x = 320 - @command_window.width / 2
  79.     @command_window.y = 288
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # * Main Test Initialization
  83.   #--------------------------------------------------------------------------
  84.   def main_test_continue
  85.     # Continue enabled determinant
  86.     # Check if at least one save file exists
  87.     # If enabled, make @continue_enabled true; if disabled, make it false
  88.     @continue_enabled = false
  89.     for i in 0..3
  90.       if FileTest.exist?("Save#{i+1}.rxdata")
  91.         @continue_enabled = true
  92.       end
  93.     end
  94.     # If continue is enabled, move cursor to "Continue"
  95.     # If disabled, display "Continue" text in gray
  96.     if @continue_enabled
  97.       @command_window.index = 1
  98.     else
  99.       @command_window.disable_item(1)
  100.     end
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # * Main Audio Initialization
  104.   #--------------------------------------------------------------------------
  105.   def main_audio
  106.     # Play title BGM
  107.     $game_system.bgm_play($data_system.title_bgm)
  108.     # Stop playing ME and BGS
  109.     Audio.me_stop
  110.     Audio.bgs_stop
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # * Main Loop
  114.   #--------------------------------------------------------------------------
  115.   def main_loop
  116.     # Update game screen
  117.     Graphics.update
  118.     # Update input information
  119.     Input.update
  120.     # Frame update
  121.     update
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # * Main Scene Scene Change
  125.   #--------------------------------------------------------------------------
  126.   def main_scenechange?
  127.     # Abort loop if screen is changed
  128.     if $scene != self
  129.       return true
  130.     end
  131.     return false
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # * Main Dispose
  135.   #--------------------------------------------------------------------------
  136.   def main_dispose
  137.     automatic_dispose
  138.   end
  139. end

复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

贵宾

梦石
0
星屑
50
在线时间
261 小时
注册时间
2005-10-21
帖子
489

贵宾

12
 楼主| 发表于 2005-12-21 22:14:07 | 只看该作者

  1. #==============================================================================
  2. # ** Scene_Map
  3. #------------------------------------------------------------------------------
  4. #  This class performs map screen processing.
  5. #==============================================================================

  6. class Scene_Map
  7.   #--------------------------------------------------------------------------
  8.   # * Main Processing
  9.   #--------------------------------------------------------------------------
  10.   def main
  11.     main_draw   
  12.     # Main loop
  13.     loop do
  14.       main_loop
  15.       break if main_scenechange?
  16.     end
  17.     main_dispose
  18.     main_tiletrigger
  19.   end
  20.   #--------------------------------------------------------------------------
  21.   # * Main Draw
  22.   #--------------------------------------------------------------------------
  23.   def main_draw
  24.     # Make sprite set
  25.     @spriteset = Spriteset_Map.new
  26.     # Make message window
  27.     @message_window = Window_Message.new
  28.     # Transition run
  29.     Graphics.transition
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # * Main Loop
  33.   #--------------------------------------------------------------------------
  34.   def main_loop
  35.     # Update game screen
  36.     Graphics.update
  37.     # Update input information
  38.     Input.update
  39.     # Frame update
  40.     update
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # * Main Scene Change
  44.   #--------------------------------------------------------------------------
  45.   def main_scenechange?
  46.     # Abort loop if screen is changed
  47.     if $scene != self
  48.       return true
  49.     end
  50.     return false
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # * Main Dispose
  54.   #--------------------------------------------------------------------------
  55.   def main_dispose
  56.     Graphics.freeze
  57.     @spriteset.dispose
  58.     automatic_dispose
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # * Main Tiletrigger
  62.   #--------------------------------------------------------------------------
  63.   def main_tiletrigger
  64.     # If switching to title screen
  65.     if $scene.is_a?(Scene_Title)
  66.       # Fade out screen
  67.       Graphics.transition
  68.       Graphics.freeze
  69.     end
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # * Frame Update
  73.   #--------------------------------------------------------------------------
  74.   def update
  75.     # Loop
  76.     loop do
  77.       update_systems
  78.       # Abort loop if player isn't place moving
  79.       unless $game_temp.player_transferring
  80.         break
  81.       end
  82.       # Run place move
  83.       transfer_player
  84.       # Abort loop if transition processing
  85.       if $game_temp.transition_processing
  86.         break
  87.       end
  88.     end
  89.     update_graphics
  90.     return if update_game_over? == true
  91.     return if update_to_title? == true
  92.     # If transition processing
  93.     if $game_temp.transition_processing
  94.       # Clear transition processing flag
  95.       $game_temp.transition_processing = false
  96.       # Execute transition
  97.       if $game_temp.transition_name == ""
  98.         Graphics.transition(20)
  99.       else
  100.         Graphics.transition(40, "Graphics/Transitions/" +
  101.           $game_temp.transition_name)
  102.       end
  103.     end
  104.     # If showing message window
  105.     if $game_temp.message_window_showing
  106.       return
  107.     end
  108.     # If encounter list isn't empty, and encounter count is 0
  109.     if $game_player.encounter_count == 0 and $game_map.encounter_list != []
  110.       # If event is running or encounter is not forbidden
  111.       unless $game_system.map_interpreter.running? or
  112.              $game_system.encounter_disabled
  113.         # Confirm troop
  114.         n = rand($game_map.encounter_list.size)
  115.         troop_id = $game_map.encounter_list[n]
  116.         # If troop is valid
  117.         if $data_troops[troop_id] != nil
  118.           # Set battle calling flag
  119.           $game_temp.battle_calling = true
  120.           $game_temp.battle_troop_id = troop_id
  121.           $game_temp.battle_can_escape = true
  122.           $game_temp.battle_can_lose = false
  123.           $game_temp.battle_proc = nil
  124.         end
  125.       end
  126.     end
  127.     update_call_menu
  128.     update_call_debug
  129.     # If player is not moving
  130.     unless $game_player.moving?
  131.       update_scene
  132.     end
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # * Update Systems
  136.   #--------------------------------------------------------------------------
  137.   def update_systems
  138.     # Update map, interpreter, and player order
  139.       # (this update order is important for when conditions are fulfilled
  140.       # to run any event, and the player isn't provided the opportunity to
  141.       # move in an instant)
  142.       $game_map.update
  143.       $game_system.map_interpreter.update
  144.       $game_player.update
  145.       # Update system (timer), screen
  146.       $game_system.update
  147.       $game_screen.update
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # * Update Graphics
  151.   #--------------------------------------------------------------------------
  152.   def update_graphics
  153.     # Update sprite set
  154.     @spriteset.update
  155.     # Update message window
  156.     @message_window.update
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # * Update Game Over
  160.   #--------------------------------------------------------------------------
  161.   def update_game_over?
  162.      # If game over
  163.     if $game_temp.gameover
  164.       # Switch to game over screen
  165.       $scene = Scene_Gameover.new
  166.       return true
  167.     end
  168.     return false
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # * Update To Title
  172.   #--------------------------------------------------------------------------
  173.   def update_to_title?
  174.     # If returning to title screen
  175.     if $game_temp.to_title
  176.       # Change to title screen
  177.       $scene = Scene_Title.new
  178.       return true
  179.     end
  180.     return false
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # * Update Menu Call
  184.   #--------------------------------------------------------------------------
  185.   def update_call_menu
  186.     # If B button was pressed
  187.     if Input.trigger?(Input::B)
  188.       # If event is running, or menu is not forbidden
  189.       unless $game_system.map_interpreter.running? or
  190.              $game_system.menu_disabled
  191.         # Set menu calling flag or beep flag
  192.         $game_temp.menu_calling = true
  193.         $game_temp.menu_beep = true
  194.       end
  195.     end
  196.   end
  197.   #--------------------------------------------------------------------------
  198.   # * Update Debug Call
  199.   #--------------------------------------------------------------------------
  200.   def update_call_debug
  201.     # If debug mode is ON and F9 key was pressed
  202.     if $DEBUG and Input.press?(Input::F9)
  203.       # Set debug calling flag
  204.       $game_temp.debug_calling = true
  205.     end
  206.   end
  207.   #--------------------------------------------------------------------------
  208.   # * Update Scene
  209.   #--------------------------------------------------------------------------
  210.   def update_scene
  211.     # Run calling of each screen
  212.     if $game_temp.battle_calling
  213.        call_battle
  214.      elsif $game_temp.shop_calling
  215.        call_shop
  216.      elsif $game_temp.name_calling
  217.        call_name
  218.      elsif $game_temp.menu_calling
  219.        call_menu
  220.      elsif $game_temp.save_calling
  221.        call_save
  222.      elsif $game_temp.debug_calling
  223.        call_debug
  224.      end
  225.   end
  226. end

复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

贵宾

梦石
0
星屑
50
在线时间
261 小时
注册时间
2005-10-21
帖子
489

贵宾

13
 楼主| 发表于 2005-12-21 22:14:31 | 只看该作者

  1. #==============================================================================
  2. # ** Scene_Menu
  3. #------------------------------------------------------------------------------
  4. #  This class performs menu screen processing.
  5. #==============================================================================

  6. class Scene_Menu
  7.   #--------------------------------------------------------------------------
  8.   # * Object Initialization
  9.   #     menu_index : command cursor's initial position
  10.   #--------------------------------------------------------------------------
  11.   def initialize(menu_index = 0)
  12.     @menu_index = menu_index
  13.     commands_init
  14.   end
  15.   #--------------------------------------------------------------------------
  16.   # * Set Commands
  17.   #--------------------------------------------------------------------------
  18.   def commands_init
  19.     @commands = []
  20.     s1 = $data_system.words.item
  21.     s2 = $data_system.words.skill
  22.     s3 = $data_system.words.equip
  23.     s4 = "Status"
  24.     s5 = "Save"
  25.     s6 = "End Game"
  26.     @commands.push(s1, s2, s3, s4, s5, s6).flatten!
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   # * Main Processing
  30.   #--------------------------------------------------------------------------
  31.   def main
  32.     main_command_window
  33.     main_windows
  34.     # Execute transition
  35.     Graphics.transition
  36.     # Main loop
  37.     loop do
  38.       main_loop
  39.       break if main_scenechange?
  40.     end
  41.     # Refresh map
  42.     $game_map.refresh
  43.     # Prepare for transition
  44.     Graphics.freeze
  45.     main_dispose
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # * Main Command Window
  49.   #--------------------------------------------------------------------------
  50.   def main_command_window
  51.     @command_window = Window_Command.new(160, @commands)
  52.     @command_window.index = @menu_index
  53.     @command_window.height = 224
  54.     # If number of party members is 0
  55.     if $game_party.actors.size == 0
  56.       # Disable items, skills, equipment, and status
  57.       @command_window.disable_item(0)
  58.       @command_window.disable_item(1)
  59.       @command_window.disable_item(2)
  60.       @command_window.disable_item(3)
  61.     end
  62.     # If save is forbidden
  63.     if $game_system.save_disabled
  64.       # Disable save
  65.       @command_window.disable_item(4)
  66.     end
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # * Main Command Window
  70.   #--------------------------------------------------------------------------
  71.   def main_windows
  72.     # Make play time window
  73.     @playtime_window = Window_PlayTime.new
  74.     @playtime_window.x = 0
  75.     @playtime_window.y = 224
  76.     # Make steps window
  77.     @steps_window = Window_Steps.new
  78.     @steps_window.x = 0
  79.     @steps_window.y = 320
  80.     # Make gold window
  81.     @gold_window = Window_Gold.new
  82.     @gold_window.x = 0
  83.     @gold_window.y = 416
  84.     # Make status window
  85.     @status_window = Window_MenuStatus.new
  86.     @status_window.x = 160
  87.     @status_window.y = 0
  88.    end
  89.   #--------------------------------------------------------------------------
  90.   # * Main Loop
  91.   #--------------------------------------------------------------------------
  92.    def main_loop
  93.      # Update game screen
  94.      Graphics.update
  95.      # Update input information
  96.      Input.update
  97.      # Frame update
  98.      update
  99.    end
  100.   #--------------------------------------------------------------------------
  101.   # * Scene Change
  102.   #--------------------------------------------------------------------------
  103.   def main_scenechange?
  104.     # Abort loop if screen is changed
  105.     if $scene != self
  106.       return true
  107.     end
  108.     return false
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # * Main Dispose
  112.   #--------------------------------------------------------------------------
  113.   def main_dispose
  114.     # Dispose of windows
  115.     @command_window.dispose
  116.     @playtime_window.dispose
  117.     @steps_window.dispose
  118.     @gold_window.dispose
  119.     @status_window.dispose
  120.   end
  121.   #--------------------------------------------------------------------------
  122.   # * Frame Update
  123.   #--------------------------------------------------------------------------
  124.   def update
  125.     # Update windows
  126.     @command_window.update
  127.     @playtime_window.update
  128.     @steps_window.update
  129.     @gold_window.update
  130.     @status_window.update
  131.     # If command window is active: call update_command
  132.     if @command_window.active
  133.       update_command
  134.       return
  135.     end
  136.     # If status window is active: call update_status
  137.     if @status_window.active
  138.       update_status
  139.       return
  140.     end
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # * Frame Update (when command window is active)
  144.   #--------------------------------------------------------------------------
  145.   def update_command
  146.     # If B button was pressed
  147.     if Input.trigger?(Input::B)
  148.       # Play cancel SE
  149.       $game_system.se_play($data_system.cancel_se)
  150.       # Switch to map screen
  151.       $scene = Scene_Map.new
  152.       return
  153.     end
  154.     # If C button was pressed
  155.     if Input.trigger?(Input::C)
  156.       update_command_check
  157.       return
  158.     end
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # * Frame Update (when status window is active)
  162.   #--------------------------------------------------------------------------
  163.   def update_status
  164.     # If B button was pressed
  165.     if Input.trigger?(Input::B)
  166.       # Play cancel SE
  167.       $game_system.se_play($data_system.cancel_se)
  168.       # Make command window active
  169.       @command_window.active = true
  170.       @status_window.active = false
  171.       @status_window.index = -1
  172.       return
  173.     end
  174.     # If C button was pressed
  175.     if Input.trigger?(Input::C)
  176.       buzzer_check
  177.       update_status_check unless buzzer_check
  178.       return
  179.     end
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # * Buzzer Check
  183.   #--------------------------------------------------------------------------
  184.   def buzzer_check
  185.     # If command other than save or end game, and party members = 0
  186.     if $game_party.actors.size == 0 and @command_window.index < 4
  187.       # Play buzzer SE
  188.       $game_system.se_play($data_system.buzzer_se)
  189.       return true
  190.     end
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # * Update Command Check
  194.   #--------------------------------------------------------------------------
  195.   def update_command_check
  196.     # Loads Current Command
  197.     command = @commands[@command_window.index]
  198.     # Checks Commands
  199.     if command == $data_system.words.item
  200.       command_item
  201.     elsif command == $data_system.words.skill
  202.       command_start_skill
  203.     elsif command == $data_system.words.equip
  204.       command_start_equip
  205.     elsif command == 'Status'
  206.       command_start_status
  207.     elsif command == 'Save'
  208.       command_save
  209.     elsif command == 'End Game'
  210.       command_endgame
  211.     end
  212.   end
  213.   #--------------------------------------------------------------------------
  214.   # * Update Status Check
  215.   #--------------------------------------------------------------------------
  216.   def update_status_check
  217.     # Loads Current Command
  218.     command = @commands[@command_window.index]
  219.     # Checks Command By Name
  220.     if command == $data_system.words.skill
  221.       command_skill
  222.     elsif command == $data_system.words.equip
  223.       command_equip
  224.     elsif command == 'Status'
  225.       command_status
  226.     end
  227.   end
  228.   #--------------------------------------------------------------------------
  229.   # * Command Item
  230.   #--------------------------------------------------------------------------
  231.   def command_item
  232.     # Play decision SE
  233.     $game_system.se_play($data_system.decision_se)
  234.     # Switch to item screen
  235.     $scene = Scene_Item.new
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   # * Command Start Skill
  239.   #--------------------------------------------------------------------------
  240.   def command_start_skill
  241.     activate_status
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # * Command Skill
  245.   #--------------------------------------------------------------------------
  246.   def command_skill
  247.     # If this actor's action limit is 2 or more
  248.     if $game_party.actors[@status_window.index].restriction >= 2
  249.       # Play buzzer SE
  250.       $game_system.se_play($data_system.buzzer_se)
  251.       return
  252.     end
  253.     # Play decision SE
  254.     $game_system.se_play($data_system.decision_se)
  255.     # Switch to skill screen
  256.     $scene = Scene_Skill.new(@status_window.index)
  257.   end
  258.   #--------------------------------------------------------------------------
  259.   # * Command Start Equip
  260.   #--------------------------------------------------------------------------
  261.   def command_start_equip
  262.     activate_status
  263.   end
  264.   #--------------------------------------------------------------------------
  265.   # * Command Equip
  266.   #--------------------------------------------------------------------------
  267.   def command_equip
  268.     # Play decision SE
  269.     $game_system.se_play($data_system.decision_se)
  270.     # Switch to equipment screen
  271.     $scene = Scene_Equip.new(@status_window.index)
  272.   end
  273.   #--------------------------------------------------------------------------
  274.   # * Command Start Status
  275.   #--------------------------------------------------------------------------
  276.   def command_start_status
  277.     activate_status
  278.   end
  279.   #--------------------------------------------------------------------------
  280.   # * Command Status
  281.   #--------------------------------------------------------------------------
  282.   def command_status
  283.     # Play decision SE
  284.     $game_system.se_play($data_system.decision_se)
  285.     # Switch to status screen
  286.     $scene = Scene_Status.new(@status_window.index)
  287.   end
  288.   #--------------------------------------------------------------------------
  289.   # * Command Save
  290.   #--------------------------------------------------------------------------
  291.   def command_save
  292.     # If saving is forbidden
  293.     if $game_system.save_disabled
  294.       # Play buzzer SE
  295.       $game_system.se_play($data_system.buzzer_se)
  296.       return
  297.     end
  298.     # Play decision SE
  299.     $game_system.se_play($data_system.decision_se)
  300.     # Switch to save screen
  301.     $scene = Scene_Save.new
  302.   end
  303.   #--------------------------------------------------------------------------
  304.   # * Command End Game
  305.   #--------------------------------------------------------------------------
  306.   def command_endgame
  307.     # Play decision SE
  308.     $game_system.se_play($data_system.decision_se)
  309.     # Switch to end game screen
  310.     $scene = Scene_End.new
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # * Activate Status Window
  314.   #--------------------------------------------------------------------------
  315.   def activate_status
  316.     # Play decision SE
  317.     $game_system.se_play($data_system.decision_se)
  318.     # Make status window active
  319.     @command_window.active = false
  320.     @status_window.active = true
  321.     @status_window.index = 0
  322.   end
  323. end

复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

贵宾

梦石
0
星屑
50
在线时间
261 小时
注册时间
2005-10-21
帖子
489

贵宾

14
 楼主| 发表于 2005-12-21 22:14:47 | 只看该作者

  1. #==============================================================================
  2. # ** Scene_Save
  3. #------------------------------------------------------------------------------
  4. #  This class performs save screen processing.
  5. #==============================================================================

  6. class Scene_Save < Scene_File
  7.   #--------------------------------------------------------------------------
  8.   # * Write Save Data
  9.   #     file : write file object (opened)
  10.   #--------------------------------------------------------------------------
  11.   def write_save_data(file)
  12.     write_characters(file)
  13.     write_frame(file)
  14.     write_setup(file)
  15.     write_data(file)
  16.   end
  17.   #--------------------------------------------------------------------------
  18.   # * Make Character Data
  19.   #--------------------------------------------------------------------------
  20.   def write_characters(file)
  21.     # Make character data for drawing save file
  22.     characters = []
  23.     for i in 0...$game_party.actors.size
  24.       actor = $game_party.actors[i]
  25.       characters.push([actor.character_name, actor.character_hue])
  26.     end
  27.     # Write character data for drawing save file
  28.     Marshal.dump(characters, file)
  29.   end
  30.   #--------------------------------------------------------------------------
  31.   # * Write Frame Count
  32.   #--------------------------------------------------------------------------
  33.   def write_frame(file)
  34.     # Wrire frame count for measuring play time
  35.     Marshal.dump(Graphics.frame_count, file)
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # * Write Setup
  39.   #--------------------------------------------------------------------------
  40.   def write_setup(file)
  41.     # Increase save count by 1
  42.     $game_system.save_count += 1
  43.     # Save magic number
  44.     # (A random value will be written each time saving with editor)
  45.     $game_system.magic_number = $data_system.magic_number
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # * Write Data
  49.   #--------------------------------------------------------------------------
  50.   def write_data(file)
  51.     # Write each type of game object
  52.     Marshal.dump($game_system, file)
  53.     Marshal.dump($game_switches, file)
  54.     Marshal.dump($game_variables, file)
  55.     Marshal.dump($game_self_switches, file)
  56.     Marshal.dump($game_screen, file)
  57.     Marshal.dump($game_actors, file)
  58.     Marshal.dump($game_party, file)
  59.     Marshal.dump($game_troop, file)
  60.     Marshal.dump($game_map, file)
  61.     Marshal.dump($game_player, file)
  62.   end
  63. end

复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

贵宾

梦石
0
星屑
50
在线时间
261 小时
注册时间
2005-10-21
帖子
489

贵宾

15
 楼主| 发表于 2005-12-21 22:14:59 | 只看该作者

  1. #==============================================================================
  2. # ** Scene_Load
  3. #------------------------------------------------------------------------------
  4. #  This class performs load screen processing.
  5. #==============================================================================

  6. class Scene_Load < Scene_File
  7.   #--------------------------------------------------------------------------
  8.   # * Read Save Data
  9.   #     file : file object for reading (opened)
  10.   #--------------------------------------------------------------------------
  11.   def read_save_data(file)
  12.     read_characters(file)
  13.     read_frame(file)
  14.     read_data(file)
  15.     read_edit
  16.     read_refresh
  17.   end
  18.   #--------------------------------------------------------------------------
  19.   # * Read Character Data
  20.   #--------------------------------------------------------------------------
  21.   def read_characters(file)
  22.     # Read character data for drawing save file
  23.     characters = Marshal.load(file)
  24.   end
  25.   #--------------------------------------------------------------------------
  26.   # * Read Frame Count
  27.   #--------------------------------------------------------------------------
  28.   def read_frame(file)
  29.     # Read frame count for measuring play time
  30.     Graphics.frame_count = Marshal.load(file)
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   # * Read Data
  34.   #--------------------------------------------------------------------------
  35.   def read_data(file)
  36.     # Read each type of game object
  37.     $game_system        = Marshal.load(file)
  38.     $game_switches      = Marshal.load(file)
  39.     $game_variables     = Marshal.load(file)
  40.     $game_self_switches = Marshal.load(file)
  41.     $game_screen        = Marshal.load(file)
  42.     $game_actors        = Marshal.load(file)
  43.     $game_party         = Marshal.load(file)
  44.     $game_troop         = Marshal.load(file)
  45.     $game_map           = Marshal.load(file)
  46.     $game_player        = Marshal.load(file)
  47.   end
  48.   #--------------------------------------------------------------------------
  49.   # * Read Edit
  50.   #--------------------------------------------------------------------------
  51.   def read_edit
  52.     # If magic number is different from when saving
  53.     # (if editing was added with editor)
  54.     if $game_system.magic_number != $data_system.magic_number
  55.       # Load map
  56.       $game_map.setup($game_map.map_id)
  57.       $game_player.center($game_player.x, $game_player.y)
  58.     end
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # * Refresh Game Party
  62.   #--------------------------------------------------------------------------
  63.   def read_refresh
  64.     # Refresh party members
  65.     $game_party.refresh
  66.   end
  67. end

复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

贵宾

梦石
0
星屑
50
在线时间
261 小时
注册时间
2005-10-21
帖子
489

贵宾

16
 楼主| 发表于 2005-12-21 22:15:27 | 只看该作者

  1. #==============================================================================
  2. # ** Scene_Battle
  3. #------------------------------------------------------------------------------
  4. #  This class performs battle screen processing.
  5. #==============================================================================
  6.   
  7. class Scene_Battle
  8.   #--------------------------------------------------------------------------
  9.   # * Object Initialization
  10.   #     menu_index : command cursor's initial position
  11.   #--------------------------------------------------------------------------
  12.   def initialize
  13.     commands_init
  14.   end
  15.   #--------------------------------------------------------------------------
  16.   # * Set Commands
  17.   #--------------------------------------------------------------------------
  18.   def commands_init
  19.     @commands = []
  20.     s1 = $data_system.words.attack
  21.     s2 = $data_system.words.skill
  22.     s3 = $data_system.words.guard
  23.     s4 = $data_system.words.item
  24.     @commands.push(s1, s2, s3, s4).flatten!
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # * Main Processing
  28.   #--------------------------------------------------------------------------
  29.   def main
  30.     main_temp
  31.     main_troop
  32.     main_command
  33.     main_windows
  34.     main_spriteset
  35.     main_transition
  36.     # Start pre-battle phase
  37.     start_phase1
  38.     # Execute transition
  39.     Graphics.transition
  40.     # Main loop
  41.     loop do
  42.       main_loop
  43.       break if main_scenechange?
  44.     end
  45.     # Refresh map
  46.     $game_map.refresh
  47.     # Prepare for transition
  48.     Graphics.freeze
  49.     main_dispose
  50.     main_end
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # * Game Temp Variable Setup
  54.   #--------------------------------------------------------------------------
  55.   def main_temp
  56.     # Initialize each kind of temporary battle data
  57.     $game_temp.in_battle = true
  58.     $game_temp.battle_turn = 0
  59.     $game_temp.battle_event_flags.clear
  60.     $game_temp.battle_abort = false
  61.     $game_temp.battle_main_phase = false
  62.     $game_temp.battleback_name = $game_map.battleback_name
  63.     $game_temp.forcing_battler = nil
  64.     # Initialize battle event interpreter
  65.     $game_system.battle_interpreter.setup(nil, 0)
  66.   end
  67.   #--------------------------------------------------------------------------
  68.   # * Troop Setup
  69.   #--------------------------------------------------------------------------
  70.   def main_troop
  71.     # Prepare troop
  72.     @troop_id = $game_temp.battle_troop_id
  73.     $game_troop.setup(@troop_id)
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # * Main Command Setup
  77.   #--------------------------------------------------------------------------
  78.   def main_command
  79.     @actor_command_window = Window_Command.new(160, @commands)
  80.     @actor_command_window.height = 160
  81.     @actor_command_window.y = 160
  82.     @actor_command_window.back_opacity = 160
  83.     @actor_command_window.active = false
  84.     @actor_command_window.visible = false
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # * Scene Window Setup
  88.   #--------------------------------------------------------------------------
  89.   def main_windows
  90.     # Make other windows
  91.     @party_command_window = Window_PartyCommand.new
  92.     @help_window = Window_Help.new
  93.     @help_window.back_opacity = 160
  94.     @help_window.visible = false
  95.     @status_window = Window_BattleStatus.new
  96.     @message_window = Window_Message.new
  97.   end
  98.   #--------------------------------------------------------------------------
  99.   # * Spriteset Setup
  100.   #--------------------------------------------------------------------------
  101.   def main_spriteset
  102.     # Make sprite set
  103.     @spriteset = Spriteset_Battle.new
  104.     # Initialize wait count
  105.     @wait_count = 0
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # * Main Transition
  109.   #--------------------------------------------------------------------------
  110.   def main_transition
  111.     # Execute transition
  112.     if $data_system.battle_transition == ""
  113.       Graphics.transition(20)
  114.     else
  115.       Graphics.transition(40, "Graphics/Transitions/" +
  116.         $data_system.battle_transition)
  117.     end
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # * Main Loop
  121.   #--------------------------------------------------------------------------
  122.   def main_loop
  123.     # Update game screen
  124.     Graphics.update
  125.     # Update input information
  126.     Input.update
  127.     # Frame update
  128.     update
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # * Scene Change
  132.   #--------------------------------------------------------------------------
  133.   def main_scenechange?
  134.     # Abort loop if screen is changed
  135.     if $scene != self
  136.       return true
  137.     end
  138.     return false
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # * Main Dispose
  142.   #--------------------------------------------------------------------------
  143.   def main_dispose
  144.     # Dispose of windows
  145.     @actor_command_window.dispose
  146.     @party_command_window.dispose
  147.     @help_window.dispose
  148.     @status_window.dispose
  149.     @message_window.dispose
  150.     @skill_window.dispose unless @skill_window == nil
  151.     @item_window.dispose unless @item_window == nil
  152.     @result_window.dispose unless @result_window == nil
  153.     # Dispose of sprite set
  154.     @spriteset.dispose
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # * Main End
  158.   #--------------------------------------------------------------------------
  159.   def main_end
  160.     # If switching to title screen
  161.     if $scene.is_a?(Scene_Title)
  162.       # Fade out screen
  163.       Graphics.transition
  164.       Graphics.freeze
  165.     end
  166.     # If switching from battle test to any screen other than game over screen
  167.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  168.       $scene = nil
  169.     end
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # * Frame Update
  173.   #--------------------------------------------------------------------------
  174.   def update
  175.     update_event
  176.     update_system
  177.     update_objects
  178.     update_transition
  179.     # If message window is showing
  180.     if $game_temp.message_window_showing
  181.       return
  182.     end
  183.     # If effect is showing
  184.     if @spriteset.effect?
  185.       return
  186.     end
  187.     update_scene_exit
  188.     update_abort
  189.     update_waiting
  190.     update_phase
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # * Event Update
  194.   #--------------------------------------------------------------------------
  195.   def update_event
  196.     # If battle event is running
  197.     if $game_system.battle_interpreter.running?
  198.       # Update interpreter
  199.       $game_system.battle_interpreter.update
  200.       # If a battler which is forcing actions doesn't exist
  201.       if $game_temp.forcing_battler == nil
  202.         # If battle event has finished running
  203.         unless $game_system.battle_interpreter.running?
  204.           # Rerun battle event set up if battle continues
  205.           unless judge
  206.             setup_battle_event
  207.           end
  208.         end
  209.         # If not after battle phase
  210.         if @phase != 5
  211.           # Refresh status window
  212.           @status_window.refresh
  213.         end
  214.       end
  215.     end
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # * System Update
  219.   #--------------------------------------------------------------------------
  220.   def update_system
  221.     # Update system (timer) and screen
  222.     $game_system.update
  223.     $game_screen.update
  224.     # If timer has reached 0
  225.     if $game_system.timer_working and $game_system.timer == 0
  226.       # Abort battle
  227.       $game_temp.battle_abort = true
  228.     end
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # * Windows and Sprites Update
  232.   #--------------------------------------------------------------------------
  233.   def update_objects
  234.     # Update windows
  235.     @help_window.update
  236.     @party_command_window.update
  237.     @actor_command_window.update
  238.     @status_window.update
  239.     @message_window.update
  240.     # Update sprite set
  241.     @spriteset.update
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # * Transition Update
  245.   #--------------------------------------------------------------------------
  246.   def update_transition
  247.     # If transition is processing
  248.     if $game_temp.transition_processing
  249.       # Clear transition processing flag
  250.       $game_temp.transition_processing = false
  251.       # Execute transition
  252.       if $game_temp.transition_name == ""
  253.         Graphics.transition(20)
  254.       else
  255.         Graphics.transition(40, "Graphics/Transitions/" +
  256.           $game_temp.transition_name)
  257.       end
  258.     end
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # * Scene Exit Update
  262.   #--------------------------------------------------------------------------
  263.   def update_scene_exit
  264.     # If game over
  265.     if $game_temp.gameover
  266.       # Switch to game over screen
  267.       $scene = Scene_Gameover.new
  268.       return
  269.     end
  270.     # If returning to title screen
  271.     if $game_temp.to_title
  272.       # Switch to title screen
  273.       $scene = Scene_Title.new
  274.       return
  275.     end
  276.   end
  277.   #--------------------------------------------------------------------------
  278.   # * Abort Update
  279.   #--------------------------------------------------------------------------
  280.   def update_abort
  281.     # If battle is aborted
  282.     if $game_temp.battle_abort
  283.       # Return to BGM used before battle started
  284.       $game_system.bgm_play($game_temp.map_bgm)
  285.       # Battle ends
  286.       battle_end(1)
  287.       return
  288.     end
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # * Waiting Update
  292.   #--------------------------------------------------------------------------
  293.   def update_waiting
  294.     # If waiting
  295.     if @wait_count > 0
  296.       # Decrease wait count
  297.       @wait_count -= 1
  298.       return
  299.     end
  300.     # If battler forcing an action doesn't exist,
  301.     # and battle event is running
  302.     if $game_temp.forcing_battler == nil and
  303.        $game_system.battle_interpreter.running?
  304.       return
  305.     end
  306.   end
  307.   #--------------------------------------------------------------------------
  308.   # * Phase Update
  309.   #--------------------------------------------------------------------------
  310.   def update_phase
  311.     # Branch according to phase
  312.     case @phase
  313.     when 1  # pre-battle phase
  314.       update_phase1
  315.     when 2  # party command phase
  316.       update_phase2
  317.     when 3  # actor command phase
  318.       update_phase3
  319.     when 4  # main phase
  320.       update_phase4
  321.     when 5  # after battle phase
  322.       update_phase5
  323.     end
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # * Frame Update (actor command phase : basic command)
  327.   #--------------------------------------------------------------------------
  328.   def update_phase3_basic_command
  329.     # If B button was pressed
  330.     if Input.trigger?(Input::B)
  331.       # Play cancel SE
  332.       $game_system.se_play($data_system.cancel_se)
  333.       # Go to command input for previous actor
  334.       phase3_prior_actor
  335.       return
  336.     end
  337.     # If C button was pressed
  338.     if Input.trigger?(Input::C)
  339.       check_commands
  340.       return
  341.     end
  342.   end
  343.   #--------------------------------------------------------------------------
  344.   # * Check Commands
  345.   #--------------------------------------------------------------------------
  346.   def check_commands
  347.     # Loads Current Command
  348.     command = @commands[@actor_command_window.index]
  349.     # Branches Possible Commands
  350.     if command == $data_system.words.attack
  351.       update_phase3_command_attack
  352.     elsif command == $data_system.words.skill
  353.       update_phase3_command_skill
  354.     elsif command == $data_system.words.guard
  355.       update_phase3_command_guard
  356.     elsif command == $data_system.words.item
  357.       update_phase3_command_item
  358.     end
  359.   end
  360.   #--------------------------------------------------------------------------
  361.   # * Command : Attack
  362.   #--------------------------------------------------------------------------
  363.   def update_phase3_command_attack
  364.     # Play decision SE
  365.     $game_system.se_play($data_system.decision_se)
  366.     # Set action
  367.     @active_battler.current_action.kind = 0
  368.     @active_battler.current_action.basic = 0
  369.     # Start enemy selection
  370.     start_enemy_select
  371.   end
  372.   #--------------------------------------------------------------------------
  373.   # * Command : Skill
  374.   #--------------------------------------------------------------------------
  375.   def update_phase3_command_skill
  376.     # Play decision SE
  377.     $game_system.se_play($data_system.decision_se)
  378.     # Set action
  379.     @active_battler.current_action.kind = 1
  380.     # Start skill selection
  381.     start_skill_select
  382.   end
  383.   #--------------------------------------------------------------------------
  384.   # * Command : Guard
  385.   #--------------------------------------------------------------------------
  386.   def update_phase3_command_guard
  387.     # Play decision SE
  388.     $game_system.se_play($data_system.decision_se)
  389.     # Set action
  390.     @active_battler.current_action.kind = 0
  391.     @active_battler.current_action.basic = 1
  392.     # Go to command input for next actor
  393.     phase3_next_actor
  394.   end
  395.   #--------------------------------------------------------------------------
  396.   # * Command : Item
  397.   #--------------------------------------------------------------------------
  398.   def update_phase3_command_item
  399.     # Play decision SE
  400.     $game_system.se_play($data_system.decision_se)
  401.     # Set action
  402.     @active_battler.current_action.kind = 2
  403.     # Start item selection
  404.     start_item_select
  405.   end
  406.   #--------------------------------------------------------------------------
  407.   # * Make Basic Action Results
  408.   #--------------------------------------------------------------------------
  409.   def make_basic_action_result
  410.     # If attack
  411.     if @active_battler.current_action.basic == 0
  412.       make_basic_action_result_attack
  413.       return
  414.     end
  415.     # If guard
  416.     if @active_battler.current_action.basic == 1
  417.       make_basic_action_result_guard
  418.       return
  419.     end
  420.     # If escape
  421.     if @active_battler.is_a?(Game_Enemy) and
  422.        @active_battler.current_action.basic == 2
  423.       make_basic_action_result_escape
  424.       return
  425.     end
  426.     # If doing nothing
  427.     if @active_battler.current_action.basic == 3
  428.       make_basic_action_result_nothing
  429.       return
  430.     end
  431.   end
  432.   #--------------------------------------------------------------------------
  433.   # * Make Basic Action Results - Attack
  434.   #--------------------------------------------------------------------------
  435.   def make_basic_action_result_attack
  436.     # Set anaimation ID
  437.     @animation1_id = @active_battler.animation1_id
  438.     @animation2_id = @active_battler.animation2_id
  439.     # If action battler is enemy
  440.     if @active_battler.is_a?(Game_Enemy)
  441.       if @active_battler.restriction == 3
  442.         target = $game_troop.random_target_enemy
  443.       elsif @active_battler.restriction == 2
  444.         target = $game_party.random_target_actor
  445.       else
  446.         index = @active_battler.current_action.target_index
  447.         target = $game_party.smooth_target_actor(index)
  448.       end
  449.     end
  450.     # If action battler is actor
  451.     if @active_battler.is_a?(Game_Actor)
  452.       if @active_battler.restriction == 3
  453.         target = $game_party.random_target_actor
  454.       elsif @active_battler.restriction == 2
  455.         target = $game_troop.random_target_enemy
  456.       else
  457.         index = @active_battler.current_action.target_index
  458.         target = $game_troop.smooth_target_enemy(index)
  459.       end
  460.     end
  461.     # Set array of targeted battlers
  462.     @target_battlers = [target]
  463.     # Apply normal attack results
  464.     for target in @target_battlers
  465.       target.attack_effect(@active_battler)
  466.     end
  467.   end
  468.   #--------------------------------------------------------------------------
  469.   # * Make Basic Action Results - Guard
  470.   #--------------------------------------------------------------------------
  471.   def make_basic_action_result_guard
  472.     # Display "Guard" in help window
  473.     @help_window.set_text($data_system.words.guard, 1)
  474.   end
  475.   #--------------------------------------------------------------------------
  476.   # * Make Basic Action Results - Escape
  477.   #--------------------------------------------------------------------------
  478.   def make_basic_action_result_escape
  479.     # Display "Escape" in help window
  480.     @help_window.set_text("Escape", 1)
  481.     # Escape
  482.     @active_battler.escape
  483.   end
  484.   #--------------------------------------------------------------------------
  485.   # * Make Basic Action Results - Nothing
  486.   #--------------------------------------------------------------------------
  487.   def make_basic_action_result_nothing
  488.     # Clear battler being forced into action
  489.     $game_temp.forcing_battler = nil
  490.     # Shift to step 1
  491.     @phase4_step = 1
  492.   end
  493. end
复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
6 小时
注册时间
2005-11-24
帖子
747
17
发表于 2005-12-21 22:16:12 | 只看该作者
{/pz}  能告诉我这SDK是什么吗
回复 支持 反对

使用道具 举报

Lv1.梦旅人

贵宾

梦石
0
星屑
50
在线时间
261 小时
注册时间
2005-10-21
帖子
489

贵宾

18
 楼主| 发表于 2005-12-21 22:18:23 | 只看该作者
不好意思,中间两位~~为了脚本的连贯性,删除了你们的帖子!{/ll}{/ll}

抱歉~~~

这个算是这几个月来~国外高手研究的成果吧!

针对原有代码的优化

大家还是慢慢看吧

最新资料哦
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2005-10-26
帖子
31
19
发表于 2005-12-21 22:22:07 | 只看该作者
这优化脚本增加了什么新特性新功能没?楼主能否简简说说?
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2005-10-26
帖子
31
20
发表于 2005-12-21 22:22:20 | 只看该作者
这优化脚本增加了什么新特性新功能没?楼主能否简单说说?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-20 06:45

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表