pigu_6

Yanfly| Save Engine Add-On: New Game+

Nov 24th, 2012
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.96 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Save Engine Add-On: New Game+ v1.00
  4. # -- Last Updated: 2011.12.26
  5. # -- Level: Normal
  6. # -- Requires: YEA - Ace Save Engine v1.01+
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-NewGame+"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2011.12.26 - Started Script and Finished.
  17. #
  18. #==============================================================================
  19. # ▼ Introduction
  20. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  21. # New Game+ is a great way to provide replay value for your game. It lets the
  22. # player re-experience the game in a different way with either carried over
  23. # items, to carried over party members, to carried over skills, switches, and
  24. # variables even. There exists many options to change how New Game+ will work
  25. # for your game.
  26. #
  27. #==============================================================================
  28. # ▼ Instructions
  29. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  30. # To install this script, open up your script editor and copy/paste this script
  31. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  32. #
  33. # -----------------------------------------------------------------------------
  34. # Item Notetags - These notetags go in the items notebox in the database.
  35. # -----------------------------------------------------------------------------
  36. # <no carry over>
  37. # This will cause this specific item to not carry over in New Game+ if the item
  38. # can be carried over. This does not affect any items that actors may have
  39. # equipped.
  40. #
  41. # -----------------------------------------------------------------------------
  42. # Weapon Notetags - These notetags go in the weapons notebox in the database.
  43. # -----------------------------------------------------------------------------
  44. # <no carry over>
  45. # This will cause this specific item to not carry over in New Game+ if the item
  46. # can be carried over. This does not affect any items that actors may have
  47. # equipped.
  48. #
  49. # -----------------------------------------------------------------------------
  50. # Armour Notetags - These notetags go in the armours notebox in the database.
  51. # -----------------------------------------------------------------------------
  52. # <no carry over>
  53. # This will cause this specific item to not carry over in New Game+ if the item
  54. # can be carried over. This does not affect any items that actors may have
  55. # equipped.
  56. #
  57. #==============================================================================
  58. # ▼ Compatibility
  59. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  60. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  61. # it will run with RPG Maker VX without adjusting.
  62. #
  63. # This script requires Yanfly Engine Ace - Ace Save Engine v1.01+ and the
  64. # script must be placed under Ace Save Engine in the script listing.
  65. #
  66. #==============================================================================
  67.  
  68. module YEA
  69. module NEW_GAME_PLUS
  70.  
  71. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  72. # - General Settings -
  73. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  74. # Description
  75. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  76. NGP_SWITCH = 100 # If Switch ON, the game file has NG+ flag.
  77. NGP_TEXT = "New Game+" # Text used to show New Game+.
  78.  
  79. # This is the help window text used for New Game+ when the New Game+
  80. # option is highlighted.
  81. NGP_HELP = "Start a new game using this file's settings."
  82.  
  83. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  84. # - Carry Over Settings -
  85. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  86. # These settings adjust what carries over and what doesn't. These settings
  87. # are very specific so adjust them carefully.
  88. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  89. # This array contains all of the switches that you want carried over to
  90. # be maintained. Any switches that aren't here will be set false.
  91. CARRY_OVER_SWITCHES = [1, 2, 3]
  92.  
  93. # This array contains all of the variables that you want carried over to
  94. # be maintained. Any variables that aren't here will be set to 0.
  95. CARRY_OVER_VARIABLES = [1..6]
  96.  
  97. # If this is set to false, then actors will be completely reset back to
  98. # their original starting states. If it's set to true, then actors will
  99. # be kept exactly as they are.
  100. CARRY_OVER_ACTORS = true
  101.  
  102. # These settings are only used if actors will be carried over. With this,
  103. # you can limit what specifics will be carried over for actors from levels
  104. # to equips to skills.
  105. CARRY_OVER_LEVELS = true
  106. CARRY_OVER_EQUIPS = true
  107. CARRY_OVER_SKILLS = true
  108.  
  109. # If this is set to false, then the party members will revert back to the
  110. # original starting party members. If it's true, then the party setup will
  111. # remain exactly the same.
  112. CARRY_OVER_PARTY_MEMBERS = true
  113.  
  114. # If any of these are set to false, then no items, weapons, or armours will
  115. # be carried over. If it's set to true, then the respective items will be
  116. # carried over to the newer game.
  117. CARRY_OVER_GOLD = true
  118. CARRY_OVER_ITEMS = true
  119. CARRY_OVER_WEAPONS = true
  120. CARRY_OVER_ARMOURS = true
  121.  
  122. end # NEW_GAME_PLUS
  123. end # YEA
  124.  
  125. #==============================================================================
  126. # ▼ Editting anything past this point may potentially result in causing
  127. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  128. # halitosis so edit at your own risk.
  129. #==============================================================================
  130.  
  131. if $imported["YEA-SaveEngine"]
  132.  
  133. module YEA
  134. module NEW_GAME_PLUS
  135. module_function
  136. #--------------------------------------------------------------------------
  137. # convert_integer_array
  138. #--------------------------------------------------------------------------
  139. def convert_integer_array(array)
  140. result = []
  141. array.each { |i|
  142. case i
  143. when Range; result |= i.to_a
  144. when Integer; result |= [i]
  145. end }
  146. return result
  147. end
  148. #--------------------------------------------------------------------------
  149. # converted_contants
  150. #--------------------------------------------------------------------------
  151. CARRY_OVER_SWITCHES = convert_integer_array(CARRY_OVER_SWITCHES)
  152. CARRY_OVER_VARIABLES = convert_integer_array(CARRY_OVER_VARIABLES)
  153. end # NEW_GAME_PLUS
  154. module REGEXP
  155. module BASEITEM
  156.  
  157. NO_CARRY_OVER = /<(?:NO_CARRY_OVER|no carry over)>/i
  158.  
  159. end # BASEITEM
  160. end # REGEXP
  161. end # YEA
  162.  
  163. #==============================================================================
  164. # ■ DataManager
  165. #==============================================================================
  166.  
  167. module DataManager
  168.  
  169. #--------------------------------------------------------------------------
  170. # alias method: load_database
  171. #--------------------------------------------------------------------------
  172. class <<self; alias load_database_ngp load_database; end
  173. def self.load_database
  174. load_database_ngp
  175. load_notetags_ngp
  176. end
  177.  
  178. #--------------------------------------------------------------------------
  179. # new method: load_notetags_ngp
  180. #--------------------------------------------------------------------------
  181. def self.load_notetags_ngp
  182. groups = [$data_items, $data_weapons, $data_armors]
  183. for group in groups
  184. for obj in group
  185. next if obj.nil?
  186. obj.load_notetags_ngp
  187. end
  188. end
  189. end
  190.  
  191. end # DataManager
  192.  
  193. #==============================================================================
  194. # ■ RPG::BaseItem
  195. #==============================================================================
  196.  
  197. class RPG::BaseItem
  198.  
  199. #--------------------------------------------------------------------------
  200. # public instance variables
  201. #--------------------------------------------------------------------------
  202. attr_accessor :no_carry_over
  203.  
  204. #--------------------------------------------------------------------------
  205. # common cache: load_notetags_ngp
  206. #--------------------------------------------------------------------------
  207. def load_notetags_ngp
  208. @no_carry_over = false
  209. #---
  210. self.note.split(/[\r\n]+/).each { |line|
  211. case line
  212. #---
  213. when YEA::REGEXP::BASEITEM::NO_CARRY_OVER
  214. @no_carry_over = true
  215. end
  216. } # self.note.split
  217. #---
  218. end
  219.  
  220. end # RPG::BaseItem
  221.  
  222. #==============================================================================
  223. # ■ Switch
  224. #==============================================================================
  225.  
  226. module Switch
  227.  
  228. #--------------------------------------------------------------------------
  229. # self.new_game_plus
  230. #--------------------------------------------------------------------------
  231. def self.new_game_plus
  232. return $game_switches[YEA::NEW_GAME_PLUS::NGP_SWITCH]
  233. end
  234.  
  235. end # Switch
  236.  
  237. #==============================================================================
  238. # ■ DataManager
  239. #==============================================================================
  240.  
  241. module DataManager
  242.  
  243. #--------------------------------------------------------------------------
  244. # new method: setup_new_game_plus
  245. #--------------------------------------------------------------------------
  246. def self.setup_new_game_plus(index)
  247. create_new_game_plus_objects(index)
  248. $game_map.setup($data_system.start_map_id)
  249. $game_player.moveto($data_system.start_x, $data_system.start_y)
  250. $game_player.refresh
  251. Graphics.frame_count = 0
  252. end
  253.  
  254. #--------------------------------------------------------------------------
  255. # new method: create_new_game_plus_objects
  256. #--------------------------------------------------------------------------
  257. def self.create_new_game_plus_objects(index)
  258. load_game_without_rescue(index)
  259. ngp_reset_switches
  260. ngp_reset_variables
  261. ngp_reset_self_switches
  262. ngp_reset_actors
  263. ngp_reset_party
  264. end
  265.  
  266. #--------------------------------------------------------------------------
  267. # new method: ngp_reset_switches
  268. #--------------------------------------------------------------------------
  269. def self.ngp_reset_switches
  270. for i in 0...$data_system.switches.size
  271. next if i <= 0
  272. next if YEA::NEW_GAME_PLUS::CARRY_OVER_SWITCHES.include?(i)
  273. $game_switches[i] = false
  274. end
  275. end
  276.  
  277. #--------------------------------------------------------------------------
  278. # new method: ngp_reset_variables
  279. #--------------------------------------------------------------------------
  280. def self.ngp_reset_variables
  281. for i in 0...$data_system.variables.size
  282. next if i <= 0
  283. next if YEA::NEW_GAME_PLUS::CARRY_OVER_VARIABLES.include?(i)
  284. $game_variables[i] = 0
  285. end
  286. end
  287.  
  288. #--------------------------------------------------------------------------
  289. # new method: ngp_reset_self_switches
  290. #--------------------------------------------------------------------------
  291. def self.ngp_reset_self_switches
  292. $game_self_switches = Game_SelfSwitches.new
  293. end
  294.  
  295. #--------------------------------------------------------------------------
  296. # new method: ngp_reset_actors
  297. #--------------------------------------------------------------------------
  298. def self.ngp_reset_actors
  299. unless YEA::NEW_GAME_PLUS::CARRY_OVER_ACTORS
  300. $game_actors = Game_Actors.new
  301. else
  302. #---
  303. unless YEA::NEW_GAME_PLUS::CARRY_OVER_LEVELS
  304. for i in 0...$data_actors.size
  305. actor = $game_actors[i]
  306. next if actor.nil?
  307. actor.new_game_plus_levels
  308. end
  309. end
  310. #---
  311. unless YEA::NEW_GAME_PLUS::CARRY_OVER_EQUIPS
  312. for i in 0...$data_actors.size
  313. actor = $game_actors[i]
  314. next if actor.nil?
  315. actor.new_game_plus_equips
  316. end
  317. end
  318. #---
  319. unless YEA::NEW_GAME_PLUS::CARRY_OVER_SKILLS
  320. for i in 0...$data_actors.size
  321. actor = $game_actors[i]
  322. next if actor.nil?
  323. actor.new_game_plus_skills
  324. end
  325. end
  326. #---
  327. end
  328. end
  329.  
  330. #--------------------------------------------------------------------------
  331. # new method: ngp_reset_party
  332. #--------------------------------------------------------------------------
  333. def self.ngp_reset_party
  334. gold = 0
  335. items = {}
  336. members = []
  337. #---
  338. if YEA::NEW_GAME_PLUS::CARRY_OVER_PARTY_MEMBERS
  339. for member in $game_party.members
  340. members.push(member.id)
  341. end
  342. end
  343. #---
  344. gold = $game_party.gold if YEA::NEW_GAME_PLUS::CARRY_OVER_GOLD
  345. #---
  346. if YEA::NEW_GAME_PLUS::CARRY_OVER_ITEMS
  347. for item in $data_items
  348. next if item.nil?
  349. next if item.no_carry_over
  350. items[item] = $game_party.item_number(item)
  351. end
  352. end
  353. #---
  354. if YEA::NEW_GAME_PLUS::CARRY_OVER_WEAPONS
  355. for item in $data_weapons
  356. next if item.nil?
  357. next if item.no_carry_over
  358. items[item] = $game_party.item_number(item)
  359. end
  360. end
  361. #---
  362. if YEA::NEW_GAME_PLUS::CARRY_OVER_ARMOURS
  363. for item in $data_armors
  364. next if item.nil?
  365. next if item.no_carry_over
  366. items[item] = $game_party.item_number(item)
  367. end
  368. end
  369. #---
  370. $game_party = Game_Party.new
  371. unless YEA::NEW_GAME_PLUS::CARRY_OVER_PARTY_MEMBERS
  372. $game_party.setup_starting_members
  373. end
  374. #---
  375. for member_id in members
  376. $game_party.add_actor(member_id)
  377. end
  378. $game_party.gain_gold(gold)
  379. for key in items
  380. item = key[0]
  381. next if item.nil?
  382. $game_party.gain_item(item, key[1])
  383. end
  384. end
  385.  
  386. end # DataManager
  387.  
  388. #==============================================================================
  389. # ■ Game_Actor
  390. #==============================================================================
  391.  
  392. class Game_Actor < Game_Battler
  393.  
  394. #--------------------------------------------------------------------------
  395. # new method: new_game_plus_levels
  396. #--------------------------------------------------------------------------
  397. def new_game_plus_levels
  398. @class_id = actor.class_id
  399. @level = actor.initial_level
  400. @exp = {}
  401. if $imported["YEA-ClassSystem"]
  402. init_unlocked_classes
  403. init_subclass
  404. end
  405. clear_param_plus
  406. init_exp
  407. refresh
  408. end
  409.  
  410. #--------------------------------------------------------------------------
  411. # new method: new_game_plus_equips
  412. #--------------------------------------------------------------------------
  413. def new_game_plus_equips
  414. init_equips(actor.equips)
  415. end
  416.  
  417. #--------------------------------------------------------------------------
  418. # new method: new_game_plus_skills
  419. #--------------------------------------------------------------------------
  420. def new_game_plus_skills
  421. init_skills
  422. end
  423.  
  424. end # Game_Actor
  425.  
  426. #==============================================================================
  427. # ■ Window_FileAction
  428. #==============================================================================
  429.  
  430. class Window_FileAction < Window_HorzCommand
  431.  
  432. #--------------------------------------------------------------------------
  433. # alias method: add_load_command
  434. #--------------------------------------------------------------------------
  435. alias add_load_command_ngp add_load_command
  436. def add_load_command
  437. if new_game_plus?
  438. add_command(YEA::NEW_GAME_PLUS::NGP_TEXT, :new_game_plus)
  439. else
  440. add_load_command_ngp
  441. end
  442. end
  443.  
  444. #--------------------------------------------------------------------------
  445. # new method: new_game_plus?
  446. #--------------------------------------------------------------------------
  447. def new_game_plus?
  448. return false if @header.nil?
  449. return false if @header[:switches].nil?
  450. return @header[:switches][YEA::NEW_GAME_PLUS::NGP_SWITCH]
  451. end
  452.  
  453. #--------------------------------------------------------------------------
  454. # alias method: update_help
  455. #--------------------------------------------------------------------------
  456. alias update_help_ngp update_help
  457. def update_help
  458. case current_symbol
  459. when :new_game_plus; @help_window.set_text(YEA::NEW_GAME_PLUS::NGP_HELP)
  460. else; update_help_ngp
  461. end
  462. end
  463.  
  464. end # Window_FileAction
  465.  
  466. #==============================================================================
  467. # ■ Scene_File
  468. #==============================================================================
  469.  
  470. class Scene_File < Scene_MenuBase
  471.  
  472. #--------------------------------------------------------------------------
  473. # alias method: create_action_window
  474. #--------------------------------------------------------------------------
  475. alias create_action_window_ngp create_action_window
  476. def create_action_window
  477. create_action_window_ngp
  478. @action_window.set_handler(:new_game_plus, method(:on_action_ngp))
  479. end
  480.  
  481. #--------------------------------------------------------------------------
  482. # new method: on_action_ngp
  483. #--------------------------------------------------------------------------
  484. def on_action_ngp
  485. Sound.play_load
  486. DataManager.setup_new_game_plus(@file_window.index)
  487. fadeout_all
  488. $game_system.on_after_load
  489. SceneManager.goto(Scene_Map)
  490. end
  491.  
  492. end # Scene_File
  493.  
  494. end # $imported["YEA-SaveEngine"]
  495.  
  496. #==============================================================================
  497. #
  498. # ▼ End of File
  499. #
  500. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment