查看: 3680|回复: 1

[已经解决] (已自行解决)全局开关变量与变量控制标题画面

[复制链接]
梦石
20
星屑
13972
在线时间
1744 小时
注册时间
2017-1-12
回帖
1666

MZ评测员开拓者

发表于 2020-5-5 10:47:01 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 火锅深处 于 2020-5-5 13:17 编辑

已解决,搜到了。
https://rpg.blue/thread-366001-1-1.html
===========================================
用的是下面这两个脚本。想实现的效果就是用变量5控制标题画面的变化,但现在那个换标题的脚本貌似是要玩家主动存档后才能发挥作用,我希望的就是只要变量5变化哪怕玩家不存档也能换标题。
大概能理解是因为换标题那个脚本没有“检查”全局变量脚本里的“System_Save.rvdata2”,所以要怎么改呢?
P.S.喵呜喵5的全局变量和换标题画面的脚本已经尝试过了,但是那个又和现有的其他脚本冲突。_(:з」∠)_
VIPArcher全局变量
  1. #===============================================================================
  2. # 全局变量开关
  3. #  By:VIPArcher [email: VIPArcher@sina.com]
  4. #  -- 本脚本来自 [url]http://rm.66rpg.com[/url] 使用或转载请保留以上信息。
  5. #===============================================================================
  6. # 说明:
  7. #   把所有开关变量储存到一个文件中,开始新游戏时或者读档时自动载入该文件中设定好的
  8. #   某些开关变量,应该也可以用于制作多结局多周目之类的功能。通关一个结局时事件脚本
  9. #   调用 save_vs_data 一下就可以把当前的开关变量储存到一个文件中。
  10. #===============================================================================
  11. $VIPArcherScript ||= {};$VIPArcherScript[:save_varsw] = 20150121
  12. #-------------------------------------------------------------------------------
  13. module VIPArcher end
  14. #==============================================================================
  15. #  ☆ 设定部分 ☆
  16. #==============================================================================
  17. module VIPArcher::GLOBAL
  18.   FILEURL = "Saves"             #储存数据的文件夹
  19.   NAME = "System_Save.rvdata2"  #储存数据的文件名
  20.   VAR = [5]   # 新游戏/读档时载入的变量
  21.   SW  = []   # 新游戏/读档时载入的开关
  22. end
  23. #==============================================================================
  24. #  ★ 设定结束 ★
  25. #==============================================================================
  26. module VIPArcher::GLOBAL
  27.   FILENAME = FILEURL + "/" + NAME
  28.   #--------------------------------------------------------------------------
  29.   # ● 储存开关变量数据
  30.   #--------------------------------------------------------------------------
  31.   def self.save_data
  32.     Dir.mkdir(FILEURL) unless FileTest.exist?(FILEURL)
  33.     File.open(FILENAME , "wb") do |file|
  34.       Marshal.dump(make_contents, file)
  35.     end
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # ● 获取开关变量数据
  39.   #--------------------------------------------------------------------------
  40.   def self.make_contents
  41.     contents = {}
  42.     contents[:switches] = $game_switches
  43.     contents[:variable] = $game_variables
  44.     contents
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # ● 读取变量数据
  48.   #--------------------------------------------------------------------------
  49.   def self.load_var(id)
  50.     File.open(FILENAME , "rb") do |file|
  51.       game_variables = Marshal.load(file)[:variable]
  52.       $game_variables[id] = game_variables[id]
  53.     end ; rescue
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ● 读取开关数据
  57.   #--------------------------------------------------------------------------
  58.   def self.load_sw(id)
  59.     File.open(FILENAME , "rb") do |file|
  60.       game_switches = Marshal.load(file)[:switches]
  61.       $game_switches[id] = game_switches[id]
  62.     end ; rescue
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # ● 载入 VAR 和 SW 的开关和变量
  66.   #--------------------------------------------------------------------------
  67.   def self.load_game_versw
  68.     VAR.each { |id| load_var(id) } ; SW.each { |id| load_sw(id) }
  69.   end
  70. end
  71. #-------------------------------------------------------------------------------
  72. class << DataManager
  73.   #--------------------------------------------------------------------------
  74.   # ● 设置新游戏
  75.   #--------------------------------------------------------------------------
  76.   alias_method :new_game_data , :setup_new_game
  77.   def setup_new_game
  78.     new_game_data ; VIPArcher::GLOBAL.load_game_versw
  79.   end
  80. end
  81. #-------------------------------------------------------------------------------
  82. class Game_System
  83.   #--------------------------------------------------------------------------
  84.   # ● 读档后的处理
  85.   #--------------------------------------------------------------------------
  86.   alias_method :after_load_data , :on_after_load
  87.   def on_after_load
  88.     after_load_data ; VIPArcher::GLOBAL.load_game_versw
  89.   end
  90. end
  91. #-------------------------------------------------------------------------------
  92. class Game_Interpreter
  93.   #--------------------------------------------------------------------------
  94.   # ● 储存开关变量数据
  95.   #--------------------------------------------------------------------------
  96.   def save_vs_data ; VIPArcher::GLOBAL.save_data end
  97.   #--------------------------------------------------------------------------
  98.   # ● 读取变量数据
  99.   #--------------------------------------------------------------------------
  100.   def load_var(*args)
  101.     args.each { |id| VIPArcher::GLOBAL.load_var(id) }
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # ● 读取开关数据
  105.   #--------------------------------------------------------------------------
  106.   def load_sw(*args)
  107.     args.each { |id| VIPArcher::GLOBAL.load_sw(id)  }
  108.   end
  109. end
复制代码


Racheal更换标题图
  1. #==============================================================================
  2. # Dynamic Title
  3. # by: Racheal
  4. # Version 1.1
  5. # Created: 24/06/2013
  6. # Updated: 27/09/2013
  7. #==============================================================================
  8. # Changes the title screen based on a variable set in-game.
  9. #==============================================================================
  10. # Instructions:
  11. # * Insert in the Materials section
  12. # * Configure to your liking below
  13. #==============================================================================
  14. # Compatibility:
  15. # This script is for RPG Maker VX Ace
  16. # It is unlikely to work with anything that modifies the way the
  17. # title screen is drawn such as an animated title screen
  18. # * Overwrites: Scene_Title: create_background
  19. =begin
  20. Credit
  21. - Racheal

  22. Author's Notes
  23. Free for commercial and non-commercial use. Just credit me (and let me know if you use it, just because). There's really not too much to this script. Version 1.1 features increased compatibility with save systems thanks to estriole's tip.

  24. As this is a script that modifies the save header, it will not work with saves created before this script was installed.
  25. =end
  26. #==============================================================================

  27. #==============================================================================
  28. # Customization
  29. #==============================================================================
  30. module Racheal_Title
  31.   #Set which variable controls the change in the title screen
  32.   TITLE_VARIABLE = 5
  33.   
  34.   #Set which parts of the title screen are affected
  35.   CHANGE_BACKGROUND = true
  36.   CHANGE_FOREGROUND = true
  37.   
  38.   #Set whether to check the highest variable in all the save files or
  39.   #just use the most recent save
  40.   CHECK_ALL_SAVES = false
  41.   
  42.   #Set whether to use a series of numbers for the filenames (0.png, 1.png, etc)
  43.   #or a series of names you define below
  44.   USE_FILENAMES = true
  45.   BACKGROUND_NAMES = ["Title0", "BTitle","Title0"]
  46.   FOREGROUND_NAMES = ["Layer1", "Layer1", "Layer1"]
  47. end
  48. #==============================================================================
  49. # End Customization
  50. #==============================================================================

  51. #==============================================================================
  52. # ** DataManager
  53. #==============================================================================

  54. module DataManager
  55.   #--------------------------------------------------------------------------
  56.   # * Create Save Header
  57.   #--------------------------------------------------------------------------
  58.   class << self; alias dynamic_title_make_save_header make_save_header; end
  59.   def self.make_save_header
  60.       header = dynamic_title_make_save_header
  61.       header[:title] = $game_variables[Racheal_Title::TITLE_VARIABLE]
  62.       header
  63.   end
  64. end

  65. #==============================================================================
  66. # ** Scene_Title
  67. #==============================================================================

  68. class Scene_Title < Scene_Base
  69.   #--------------------------------------------------------------------------
  70.   # * Create Background
  71.   #--------------------------------------------------------------------------
  72.   def create_background
  73.     @sprite1 = Sprite.new
  74.     sprite_name = Racheal_Title::CHANGE_BACKGROUND ? get_title(1) : $data_system.title1_name
  75.     @sprite1.bitmap = Cache.title1(sprite_name)
  76.     @sprite2 = Sprite.new
  77.           @sprite2.z = 99#自己加的
  78.     sprite_name = Racheal_Title::CHANGE_FOREGROUND ? get_title(2) : $data_system.title2_name
  79.     @sprite2.bitmap = Cache.title2(sprite_name)
  80.     center_sprite(@sprite1)
  81.     center_sprite(@sprite2)
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   # * Get Title Sprite Name
  85.   #--------------------------------------------------------------------------
  86.   def get_title(num)
  87.     title = 0
  88.     if Racheal_Title::CHECK_ALL_SAVES
  89.       #Check all saves
  90.       for i in 0...DataManager.savefile_max
  91.         header = DataManager.load_header(i)
  92.         next unless header and header[:title]
  93.         title = [title, header[:title]].max
  94.       end
  95.     else
  96.       #Check latest save
  97.       header = DataManager.load_header(DataManager.latest_savefile_index)
  98.       if header and header[:title]
  99.         title = [title, header[:title]].max
  100.       end
  101.     end
  102.     #---
  103.     if Racheal_Title::USE_FILENAMES
  104.       #convert number to name
  105.       case num
  106.       when 1
  107.         return Racheal_Title::BACKGROUND_NAMES[title]
  108.       when 2
  109.         return Racheal_Title::FOREGROUND_NAMES[title]
  110.       end
  111.     else
  112.       return title.to_s
  113.     end
  114.   end
  115. end
复制代码

评分

参与人数 1赞 +1 收起 理由
chanszeman1018 + 1 认可答案

查看全部评分

梦石
0
星屑
11806
在线时间
623 小时
注册时间
2016-8-25
回帖
1339

R考场第七期纪念奖

发表于 2020-5-5 12:25:07 | 显示全部楼层
如果是事件标题

可能会简单不少
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部