Advertisement
Double_X

DoubleX RMVXA Dynamic Data v1.01a

May 15th, 2015 (edited)
697
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 12.97 KB | None | 0 0
  1. #==============================================================================|
  2. #  ** Script Info                                                              |
  3. #------------------------------------------------------------------------------|
  4. #  * Script Name                                                               |
  5. #    DoubleX RMVXA Dynamic Data                                                |
  6. #------------------------------------------------------------------------------|
  7. #  * Functions                                                                 |
  8. #    Stores the changes to the database done by users during game executions   |
  9. #    Can't be used with data having contents that can't be serialized          |
  10. #    Can't be used with data read from the database files upon use             |
  11. #------------------------------------------------------------------------------|
  12. #  * Terms Of Use                                                              |
  13. #    You shall keep this script's Script Info part's contents intact           |
  14. #    You shalln't claim that this script is written by anyone other than       |
  15. #    DoubleX or his aliases                                                    |
  16. #    None of the above applies to DoubleX or his aliases                       |
  17. #------------------------------------------------------------------------------|
  18. #  * Prerequisites                                                             |
  19. #    Abilities:                                                                |
  20. #    1. Custom script comprehensions to edit that script's used data stored in |
  21. #       RPG::BaseItem and/or its subclasses                                    |
  22. #------------------------------------------------------------------------------|
  23. #  * Instructions                                                              |
  24. #    1. Open the script editor and put this script into an open slot between   |
  25. #       Materials and Main, save to take effect.                               |
  26. #------------------------------------------------------------------------------|
  27. #  * Links                                                                     |
  28. #    Script Usage 101:                                                         |
  29. #    1. forums.rpgmakerweb.com/index.php?/topic/32752-rmvxa-script-usage-101/  |
  30. #    2. rpgmakervxace.net/topic/27475-rmvxa-script-usage-101/                  |
  31. #    This script:                                                              |
  32. #    1. http://pastebin.com/upEe5FZQ                                           |
  33. #    Mentioned Patreon Supporters:                                             |
  34. #    https://www.patreon.com/posts/71738797                                    |
  35. #------------------------------------------------------------------------------|
  36. #  * Authors                                                                   |
  37. #    DoubleX                                                                   |
  38. #------------------------------------------------------------------------------|
  39. #  * Changelog                                                                 |
  40. #    v1.01a(GMT 0100 12-11-2015):                                              |
  41. #    1. Lets users set which parts of the database changes will be saved       |
  42. #    v1.00b(GMT 0600 8-8-2015):                                                |
  43. #    1. Fixed using edited data bug when starting new game without closing it  |
  44. #    2. Increased this script's compatibility, efficiency and readability      |
  45. #    v1.00a(GMT 0400 16-5-2015):                                               |
  46. #    1. 1st version of this script finished                                    |
  47. #==============================================================================|
  48.  
  49. ($doublex_rmvxa ||= {})[:Dynamic_Data] = "v1.01a"
  50.  
  51. module DoubleX_RMVXA
  52.  
  53.   module Dynamic_Data
  54.  
  55.     # Sets if this script will save the actor parts of the database changes in
  56.     # savefiles as SAVE_ACTORS
  57.     # It can't be changed once set
  58.     # Example: To always reload the original actor parts of the database upon
  59.     #          loading savefiles, set this as false
  60.     SAVE_ACTORS = true
  61.  
  62.     # Sets if this script will save the class parts of the database changes in
  63.     # savefiles as SAVE_CLASSES
  64.     # It can't be changed once set
  65.     # Example: To always reload the original class parts of the database upon
  66.     #          loading savefiles, set this as false
  67.     SAVE_CLASSES = true
  68.  
  69.     # Sets if this script will save the skill parts of the database changes in
  70.     # savefiles as SAVE_SKILLS
  71.     # It can't be changed once set
  72.     # Example: To always reload the original skill parts of the database upon
  73.     #          loading savefiles, set this as false
  74.     SAVE_SKILLS = true
  75.  
  76.     # Sets if this script will save the item parts of the database changes in
  77.     # savefiles as SAVE_ITEMS
  78.     # It can't be changed once set
  79.     # Example: To always reload the original item parts of the database upon
  80.     #          loading savefiles, set this as false
  81.     SAVE_ITEMS = true
  82.  
  83.     # Sets if this script will save the weapon parts of the database changes in
  84.     # savefiles as SAVE_WEAPONS
  85.     # It can't be changed once set
  86.     # Example: To always reload the original weapon parts of the database upon
  87.     #          loading savefiles, set this as false
  88.     SAVE_WEAPONS = true
  89.  
  90.     # Sets if this script will save the armor parts of the database changes in
  91.     # savefiles as SAVE_ARMORS
  92.     # It can't be changed once set
  93.     # Example: To always reload the original armor parts of the database upon
  94.     #          loading savefiles, set this as false
  95.     SAVE_ARMORS = true
  96.  
  97.     # Sets if this script will save the enemy parts of the database changes in
  98.     # savefiles as SAVE_ENEMIES
  99.     # It can't be changed once set
  100.     # Example: To always reload the original enemy parts of the database upon
  101.     #          loading savefiles, set this as false
  102.     SAVE_ENEMIES = true
  103.  
  104.     # Sets if this script will save the troop parts of the database changes in
  105.     # savefiles as SAVE_TROOPS
  106.     # It can't be changed once set
  107.     # Example: To always reload the original troop parts of the database upon
  108.     #          loading savefiles, set this as false
  109.     SAVE_TROOPS = true
  110.  
  111.     # Sets if this script will save the state parts of the database changes in
  112.     # savefiles as SAVE_STATES
  113.     # It can't be changed once set
  114.     # Example: To always reload the original state parts of the database upon
  115.     #          loading savefiles, set this as false
  116.     SAVE_STATES = true
  117.  
  118.     # Sets if this script will save the animation parts of the database changes
  119.     # in savefiles as SAVE_ANIMATIONS
  120.     # It can't be changed once set
  121.     # Example: To always reload the original animation parts of the database
  122.     #          upon loading savefiles, set this as false
  123.     SAVE_ANIMATIONS = true
  124.  
  125.     # Sets if this script will save the tileset parts of the database changes in
  126.     # savefiles as SAVE_TILESETS
  127.     # It can't be changed once set
  128.     # Example: To always reload the original tileset parts of the database upon
  129.     #          loading savefiles, set this as false
  130.     SAVE_TILESETS = true
  131.  
  132.     # Sets if this script will save the common event parts of the database
  133.     # changes in savefiles as SAVE_COMMON_EVENTS
  134.     # It can't be changed once set
  135.     # Example: To always reload the original common event parts of the database
  136.     #          upon loading savefiles, set this as false
  137.     SAVE_COMMON_EVENTS = true
  138.  
  139.     # Sets if this script will save the system parts of the database changes in
  140.     # savefiles as SAVE_SYSTEM
  141.     # It can't be changed once set
  142.     # Example: To always reload the original system parts of the database upon
  143.     #          loading savefiles, set this as false
  144.     SAVE_SYSTEM = true
  145.  
  146.   end # Dynamic_Data
  147.    
  148. end # DoubleX_RMVXA
  149.  
  150. #==============================================================================|
  151. #  ** Script Implementations                                                   |
  152. #     You need not edit this part as it's about how this script works          |
  153. #------------------------------------------------------------------------------|
  154. #  * Script Support Info:                                                      |
  155. #    1. Prerequisites                                                          |
  156. #       - Some RGSS3 scripting proficiency to fully comprehend this script     |
  157. #    2. Method documentation                                                   |
  158. #       - The 1st part describes why this method's rewritten/aliased for       |
  159. #         rewritten/aliased methods or what the method does for new methods    |
  160. #       - The 2nd part describes what the arguments of the method are          |
  161. #       - The 3rd part informs which version rewritten, aliased or created this|
  162. #         method                                                               |
  163. #       - The 4th part informs whether the method's rewritten or new           |
  164. #       - The 5th part informs whether the method's a real or potential hotspot|
  165. #       - The 6th part describes how this method works for new methods only,   |
  166. #         and describes the parts added, removed or rewritten for rewritten or |
  167. #         aliased methods only                                                 |
  168. #       Example:                                                               |
  169. # #--------------------------------------------------------------------------| |
  170. # #  Why rewrite/alias/What this method does                                 | |
  171. # #--------------------------------------------------------------------------| |
  172. # # *argv: What these variables are                                            |
  173. # # &argb: What this block is                                                  |
  174. # def def_name(*argv, &argb) # Version X+; Rewrite/New; Hotspot                |
  175. #   # Added/Removed/Rewritten to do something/How this method works            |
  176. #   def_name_code                                                              |
  177. #   #                                                                          |
  178. # end # def_name                                                               |
  179. #------------------------------------------------------------------------------|
  180.  
  181. class << DataManager # Edit
  182.  
  183.   #----------------------------------------------------------------------------|
  184.   #  Stores the modified database parts to the save files as well              |
  185.   #----------------------------------------------------------------------------|
  186.   alias save_game_without_rescue_dynamic_data save_game_without_rescue
  187.   def save_game_without_rescue(index, &argb)
  188.     # Added
  189.     ["actors", "classes", "skills", "items", "weapons", "armors", "enemies",
  190.      "troops", "states", "animations", "tilesets", "common_events",
  191.      "system"].each { |type|
  192.       next unless eval("DoubleX_RMVXA::Dynamic_Data::SAVE_#{type.upcase}")
  193.       $game_system.send(:"data_#{type}=", eval("$data_#{type}"))
  194.     }
  195.     #
  196.     save_game_without_rescue_dynamic_data(index, &argb)
  197.   end # save_game_without_rescue
  198.  
  199.   #----------------------------------------------------------------------------|
  200.   #  Retrieves the modified database parts from the save files as well         |
  201.   #----------------------------------------------------------------------------|
  202.   alias extract_save_contents_dynamic_data extract_save_contents
  203.   def extract_save_contents(contents, &argb)
  204.     extract_save_contents_dynamic_data(contents, &argb)
  205.     # Added
  206.     ["actors", "classes", "skills", "items", "weapons", "armors", "enemies",
  207.      "troops", "states", "animations", "tilesets", "common_events",
  208.      "system"].each { |type|
  209.       next unless eval("DoubleX_RMVXA::Dynamic_Data::SAVE_#{type.upcase}")
  210.       eval("$data_#{type} = $game_system.data_#{type}")
  211.     }
  212.     #
  213.   end # extract_save_contents
  214.  
  215. end # DataManager
  216.  
  217. class Game_System # Edit
  218.  
  219.   #----------------------------------------------------------------------------|
  220.   #  New public instance variables                                             |
  221.   #----------------------------------------------------------------------------|
  222.   # The modified database parts to be stored to/retrieved from save files
  223.   ["actors", "classes", "skills", "items", "weapons", "armors", "enemies",
  224.    "troops", "states", "animations", "tilesets", "common_events",
  225.    "system"].each { |type| attr_accessor eval(":data_#{type}") }
  226.  
  227. end # Game_System
  228.  
  229. class Scene_Title < Scene_Base # v1.00b+; Edit
  230.  
  231.   #----------------------------------------------------------------------------|
  232.   #  Resets the database for starting a new game without closing it as well    |
  233.   #----------------------------------------------------------------------------|
  234.   alias start_dynamic_data start
  235.   def start(*argv, &argb)
  236.     start_dynamic_data(*argv, &argb)
  237.     DataManager.load_database # Added
  238.   end # start
  239.  
  240. end # Scene_Title
  241.  
  242. #==============================================================================|
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement