Heures au format UTC + 1 heure [ Heure d’été ]


Règles du forum


Consultez la liste des Scripts : cliquez ici



Publier un nouveau sujet Répondre au sujet  [ 2 messages ] 
Auteur Message
 Sujet du message: Système de sauvegarde rapide
MessagePublié: 11 Nov 2008, 18:59 
Villageois (Nv 2)
Avatar de l’utilisateur

Inscrit le: 02 Sep 2008, 00:00
Messages: 24
Niveau RPG Maker: Assez bon
Logiciel(s) préféré(s): ♥ : RM2k3
Point(s) Fort(s): Scripts d'interfaces // EventMaking
Sexe: Masculin
Points d'aide: 0/60

Créations :

Voir ses créations

Alors voilà. Y'a un principe du jeu Final Fantasy III (sur DS) qui m'a beaucoup plut : il s'agit du système, appelé "Sauvegarde rapide", qui permet de sauvegarder quand on peut pas.
Je m'explique : dans ce jeu, on ne peut sauvegarder que sur la carte du monde. Mais, supposons qu'on ait besoin de sauvegarder car on a un truc à faire, on doit partir quelque part, etc. Bref, on doit quitter le jeu, alors qu'on est pas sur la carte du monde. Et bien on peut faire une sauvegarde rapide : en fait ça suspend le jeu : les données sont sauvegardées et on peut les reprendre la prochaine fois qu'on y joue. Par contre, si on ne les reprend pas car on charge une autre partie ou alors on en commence une, et bien les données sont supprimées !

Donc voilà les scripts : il y a une modification du Scene_Menu et du Scene_Title pour mettre les options en places, et le script pour permettre de suspendre.

Donc, d'abord remplacez le Scene_Title par ça :
Code: Tout sélectionner
#==============================================================================
# ■ Scene_Title
#------------------------------------------------------------------------------
#  Modifié par Nono II
#   10/11/08 11:40
#==============================================================================

class Scene_Title
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def read_save_data(file)
    characters = Marshal.load(file)
    Graphics.frame_count = Marshal.load(file)
    $game_system        = Marshal.load(file)
    $game_switches      = Marshal.load(file)
    $game_variables     = Marshal.load(file)
    $game_self_switches = Marshal.load(file)
    $game_screen        = Marshal.load(file)
    $game_actors        = Marshal.load(file)
    $game_party         = Marshal.load(file)
    $game_troop         = Marshal.load(file)
    $game_map           = Marshal.load(file)
    $game_player        = Marshal.load(file)
    $game_temp          = Marshal.load(file)
    if $game_system.magic_number != $data_system.magic_number
      $game_map.setup($game_map.map_id)
      $game_player.center($game_player.x, $game_player.y)
    end
    $game_party.refresh
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def main
   
    if $BTEST
      battle_test
      return
    end

    $data_actors        = load_data("Data/Actors.rxdata")
    $data_classes       = load_data("Data/Classes.rxdata")
    $data_skills        = load_data("Data/Skills.rxdata")
    $data_items         = load_data("Data/Items.rxdata")
    $data_weapons       = load_data("Data/Weapons.rxdata")
    $data_armors        = load_data("Data/Armors.rxdata")
    $data_enemies       = load_data("Data/Enemies.rxdata")
    $data_troops        = load_data("Data/Troops.rxdata")
    $data_states        = load_data("Data/States.rxdata")
    $data_animations    = load_data("Data/Animations.rxdata")
    $data_tilesets      = load_data("Data/Tilesets.rxdata")
    $data_common_events = load_data("Data/CommonEvents.rxdata")
    $data_system        = load_data("Data/System.rxdata")

    $game_system = Game_System.new

    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.title($data_system.title_name)
   
    t1 = "Reprendre"
    t2 = "Charger Partie"
    @load_command = Window_Command.new(192,[t1,t2])
    @load_command.back_opacity = 160
    @load_command.x = 416
    @load_command.y = 320
    @load_command.active = false
    @load_command.visible = false
   
    s1 = "Nouvelle partie"
    s2 = "Continuer"
    s3 = "Quitter"
    @command_window = Window_Command.new(192, [s1, s2, s3])
    @command_window.back_opacity = 160
    @command_window.x = 320 - @command_window.width / 2
    @command_window.y = 288

    @continue_enabled = false
    for i in 0..3
      if FileTest.exist?("Sauvegarde#{i+1}.rxdata")
        @continue_enabled = true
        @continue = true
      end
      if FileTest.exist?("Pause.rxdata")
        @continue_enabled = true
        @reprendre = true
      end
    end

    if @continue_enabled
      @command_window.index = 1
    else
      @command_window.disable_item(1)
    end
   
    unless @continue
      @load_command.disable_item(1)
    end
    unless @reprendre
      @load_command.disable_item(0)
    end
   
    $game_system.bgm_play($data_system.title_bgm)
    Audio.me_stop
    Audio.bgs_stop

    Graphics.transition

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self
        break
      end
    end

    Graphics.freeze

    @command_window.dispose
    @load_command.dispose

    @sprite.bitmap.dispose
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def update
   
    @command_window.update
    @load_command.update
   
    if @command_window.active
      update_command
      return
    end
   
    if @load_command.active
      update_load
      return
    end
  end
 
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def update_command

    if Input.trigger?(Input::C)

      case @command_window.index
      when 0
        command_new_game
      when 1
        command_continue
      when 2
        command_shutdown
      end
    end
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def command_new_game

    $game_system.se_play($data_system.decision_se)

    Audio.bgm_stop

    Graphics.frame_count = 0

    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen        = Game_Screen.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new

    $game_party.setup_starting_members

    $game_map.setup($data_system.start_map_id)

    $game_player.moveto($data_system.start_x, $data_system.start_y)

    $game_player.refresh

    $game_map.autoplay

    $game_map.update
   
    if FileTest.exist?("Pause.rxdata")
      File.delete("Pause.rxdata")
    end
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def command_continue

    unless @continue_enabled

      $game_system.se_play($data_system.buzzer_se)
      return
    end
   
    $game_system.se_play($data_system.decision_se)
    @command_window.active = false
    @load_command.visible = true
    @load_command.active = true
   
  end
 
 
  def update_load
    if Input.trigger?(Input::C)
      case @load_command.index
      when 0
        command_reprendre
      when 1
        command_charger
      end
    end
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @load_command.visible = false
      @load_command.active = false
      @command_window.active = true
    end
  end
 
 
  def command_charger
    unless @continue
      $game_system.se_play($data_system.buzzer_se)
      return
    end
    $game_system.se_play($data_system.decision_se)
    if FileTest.exist?("Pause.rxdata")
      File.delete("Pause.rxdata")
    end
    $scene = Scene_Load.new
  end
 
 
  def command_reprendre
    unless @reprendre
      $game_system.se_play($data_system.buzzer_se)
      return
    end
    $game_system.se_play($data_system.load_se)
   
    file = File.open("Pause.rxdata", "rb")
    read_save_data(file)
    file.close
   
    $game_system.bgm_play($game_system.playing_bgm)
    $game_system.bgs_play($game_system.playing_bgs)
    $game_map.update
    $scene = Scene_Map.new
   
  end
 
 
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def command_shutdown

    $game_system.se_play($data_system.decision_se)

    Audio.bgm_fade(800)
    Audio.bgs_fade(800)
    Audio.me_fade(800)

    $scene = nil
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def battle_test

    $data_actors        = load_data("Data/BT_Actors.rxdata")
    $data_classes       = load_data("Data/BT_Classes.rxdata")
    $data_skills        = load_data("Data/BT_Skills.rxdata")
    $data_items         = load_data("Data/BT_Items.rxdata")
    $data_weapons       = load_data("Data/BT_Weapons.rxdata")
    $data_armors        = load_data("Data/BT_Armors.rxdata")
    $data_enemies       = load_data("Data/BT_Enemies.rxdata")
    $data_troops        = load_data("Data/BT_Troops.rxdata")
    $data_states        = load_data("Data/BT_States.rxdata")
    $data_animations    = load_data("Data/BT_Animations.rxdata")
    $data_tilesets      = load_data("Data/BT_Tilesets.rxdata")
    $data_common_events = load_data("Data/BT_CommonEvents.rxdata")
    $data_system        = load_data("Data/BT_System.rxdata")

    Graphics.frame_count = 0

    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen        = Game_Screen.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new

    $game_party.setup_battle_test_members

    $game_temp.battle_troop_id = $data_system.test_troop_id
    $game_temp.battle_can_escape = true
    $game_map.battleback_name = $data_system.battleback_name

    $game_system.se_play($data_system.battle_start_se)

    $game_system.bgm_play($game_system.battle_bgm)

    $scene = Scene_Battle.new
  end
end



[](suite au prochain message)


Haut
 Profil  
 
 Sujet du message: Re: Système de sauvegarde rapide
MessagePublié: 11 Nov 2008, 18:59 
Villageois (Nv 2)
Avatar de l’utilisateur

Inscrit le: 02 Sep 2008, 00:00
Messages: 24
Niveau RPG Maker: Assez bon
Logiciel(s) préféré(s): ♥ : RM2k3
Point(s) Fort(s): Scripts d'interfaces // EventMaking
Sexe: Masculin
Points d'aide: 0/60

Créations :

Voir ses créations

Puis le Scene_Menu par celui-là :
Code: Tout sélectionner
#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
#  Modifié par Nono II
#   10/11/08 11:40
#==============================================================================

class Scene_Menu
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     menu_index : コマンドのカーソル初期位置
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  #--------------------------------------------------------------------------
  # ● メイン処理
  #--------------------------------------------------------------------------
  def main
    # コマンドウィンドウを作成
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "État"
    s5 = "Suspendre"
    s6 = "Sauvegarder"
    s7 = "Quitter"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6,s7])
    @command_window.index = @menu_index
    # パーティ人数が 0 人の場合
    if $game_party.actors.size == 0
      # アイテム、スキル、装備、ステータスを無効化
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
    end
    # セーブ禁止の場合
    if $game_system.save_disabled
      # セーブを無効にする
      @command_window.disable_item(5)
    end

    # ステータスウィンドウを作成
    @status_window = Window_MenuStatus.new
    @status_window.x = 160
    @status_window.y = 0
    # トランジション実行
    Graphics.transition
    # メインループ
    loop do
      # ゲーム画面を更新
      Graphics.update
      # 入力情報を更新
      Input.update
      # フレーム更新
      update
      # 画面が切り替わったらループを中断
      if $scene != self
        break
      end
    end
    # トランジション準備
    Graphics.freeze
    # ウィンドウを解放
    @command_window.dispose

    @status_window.dispose
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    # ウィンドウを更新
    @command_window.update

    @status_window.update
    # コマンドウィンドウがアクティブの場合: update_command を呼ぶ
    if @command_window.active
      update_command
      return
    end
    # ステータスウィンドウがアクティブの場合: update_status を呼ぶ
    if @status_window.active
      update_status
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (コマンドウィンドウがアクティブの場合)
  #--------------------------------------------------------------------------
  def update_command
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      $game_system.se_play($data_system.cancel_se)
      # マップ画面に切り替え
      $scene = Scene_Map.new
      return
    end
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # パーティ人数が 0 人で、セーブ、ゲーム終了以外のコマンドの場合
      if $game_party.actors.size == 0 and @command_window.index < 4
        # ブザー SE を演奏
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # コマンドウィンドウのカーソル位置で分岐
      case @command_window.index
      when 0  # アイテム
        # 決定  SE を演奏
        $game_system.se_play($data_system.decision_se)
        # アイテム画面に切り替え
        $scene = Scene_Item.new
      when 1  # スキル
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # ステータスウィンドウをアクティブにする
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 2  # 装備
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # ステータスウィンドウをアクティブにする
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 3  # ステータス
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # ステータスウィンドウをアクティブにする
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 5  # セーブ
        # セーブ禁止の場合
        if $game_system.save_disabled
          # ブザー SE を演奏
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # セーブ画面に切り替え
        $scene = Scene_Save.new
      when 6  # ゲーム終了
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # ゲーム終了画面に切り替え
        $scene = Scene_End.new
      when 4
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Suspendre.new
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (ステータスウィンドウがアクティブの場合)
  #--------------------------------------------------------------------------
  def update_status
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      $game_system.se_play($data_system.cancel_se)
      # コマンドウィンドウをアクティブにする
      @command_window.active = true
      @status_window.active = false
      @status_window.index = -1
      return
    end
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # コマンドウィンドウのカーソル位置で分岐
      case @command_window.index
      when 1  # スキル
        # このアクターの行動制限が 2 以上の場合
        if $game_party.actors[@status_window.index].restriction >= 2
          # ブザー SE を演奏
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # スキル画面に切り替え
        $scene = Scene_Skill.new(@status_window.index)
      when 2  # 装備
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # 装備画面に切り替え
        $scene = Scene_Equip.new(@status_window.index)
      when 3  # ステータス
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # ステータス画面に切り替え
        $scene = Scene_Status.new(@status_window.index)
      end
      return
    end
  end
end


Et enfin ajoutez celui-ci au-dessus de Main :
Code: Tout sélectionner
#==============================================================================
# ■ Scene_Title
#------------------------------------------------------------------------------
#  Fait par Nono II
#   10/11/08 11:40
#==============================================================================

class Window_Suspendre < Window_Base
 
  def initialize
    super(150,120,340,64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = 26
    refresh
  end
 
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(-16, -12, 320, 56, "Voulez-vous suspendre votre partie ?", 2)
  end
end

class Window_Attention < Window_Base
 
  def initialize
    super(150,100,340,260)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = 24
    self.windowskin = RPG::Cache.windowskin("")
    refresh
  end
 
  def refresh
    self.contents.clear
    self.contents.font.color = Color.new(220,30,50,240)
    self.contents.font.size = 36
    self.contents.draw_text(-96, -12, 320, 56, "Attention !", 2)
    self.contents.font.color = normal_color
    self.contents.font.size = 24
    self.contents.draw_text(-16, 32, 320, 56, "N'oubliez pas de faire ", 1)
    self.contents.draw_text(-16, 56, 320, 56, '"Reprendre" lorsque vous', 1)
    self.contents.draw_text(-16, 80, 320, 56, "relancerez le jeu sinon vos", 1)
    self.contents.draw_text(-16, 104, 320, 56, "données seront perdues !", 1)
  end
end

class Scene_Suspendre
 
  def write_save_data(file)
    characters = []
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      characters.push([actor.character_name, actor.character_hue])
    end
    Marshal.dump(characters, file)
    Marshal.dump(Graphics.frame_count, file)
    $game_system.save_count += 1
    $game_system.magic_number = $data_system.magic_number
    Marshal.dump($game_system, file)
    Marshal.dump($game_switches, file)
    Marshal.dump($game_variables, file)
    Marshal.dump($game_self_switches, file)
    Marshal.dump($game_screen, file)
    Marshal.dump($game_actors, file)
    Marshal.dump($game_party, file)
    Marshal.dump($game_troop, file)
    Marshal.dump($game_map, file)
    Marshal.dump($game_player, file)
    Marshal.dump($game_temp, file)
  end
 
  def delai(seconds)
    for i in 0...(seconds)
      sleep 1
      Graphics.update
    end
  end
 
  def main
   
    @message = Window_Suspendre.new
    @msg = Window_Attention.new
    @msg.visible = false
   
    s1 = "Oui"
    s2 = "Non"
    @command = Window_Command.new(96,[s1,s2])
    @command.x = 150
    @command.y = 184
   
    Graphics.transition

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self
        break
      end
    end

    Graphics.freeze

    @command.dispose
    @message.dispose
    @msg.dispose
   
  end
 
  def update
   
    @command.update
   
    if Input.trigger?(Input::C)
      case @command.index
      when 0
        $game_system.se_play($data_system.save_se)
       
        file = File.open("Pause.rxdata", "wb")
        write_save_data(file)
        file.close
       
        @command.visible = false
        @message.visible = false
        @msg.visible = true
        delai(4)
        exit
      when 1
        $game_system.se_play($data_system.buzzer_se)
        $scene = Scene_Menu.new(4)
      end
    end
   
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.buzzer_se)
      $scene = Scene_Menu.new(4)
    end
  end
 
  def exit
    if Input.trigger?(Input::C)
      Audio.bgm_fade(800)
      Audio.bgs_fade(800)
      Audio.me_fade(800)
      $scene = nil
    end
    if Input.trigger?(Input::B)
      Audio.bgm_fade(800)
      Audio.bgs_fade(800)
      Audio.me_fade(800)
      $scene = nil
    end
  end 
end



Et voilà. J'espère que ça vous plaira ^^


Haut
 Profil  
 
Afficher les messages depuis:  Trier par  
Publier un nouveau sujet Répondre au sujet  [ 2 messages ] 

Heures au format UTC + 1 heure [ Heure d’été ]


Qui est en ligne ?

Utilisateurs parcourant actuellement ce forum : Aucun utilisateur inscrit et 1 invité


Vous ne pouvez pas publier de nouveaux sujets dans ce forum
Vous ne pouvez pas répondre aux sujets dans ce forum
Vous ne pouvez pas éditer vos messages dans ce forum
Vous ne pouvez pas supprimer vos messages dans ce forum
Vous ne pouvez pas insérer de pièces jointes dans ce forum

Rechercher pour:
Sauter vers:  
cron
RPG Creative Forum version 5 ; Tous droits réservés
phpBB Group (Traduit par Xaphos)
Optimisé pour une résolution 1024*728