Advertisement
Double_X

(Obsolete)DoubleX RMVXA Linked Battlers Compatibility v1.00a

Aug 12th, 2015
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.77 KB | None | 0 0
  1. #==============================================================================|
  2. # ** Script Info |
  3. #------------------------------------------------------------------------------|
  4. # * Script Name |
  5. # DoubleX RMVXA Linked Battlers Compatibility |
  6. #------------------------------------------------------------------------------|
  7. # * Functions |
  8. # Fixes compatibility issues in DoubleX RMVXA Linked Battlers |
  9. # Scripts Addressed: |
  10. # 1. DoubleX RMVXA Dynamic Data |
  11. # 2. Mr.Bubble's Tactics Ogre PSP Crafting System |
  12. # 3. Theolized Sideview Battle System |
  13. # 4. Tsukihime's Instance Items |
  14. #------------------------------------------------------------------------------|
  15. # * Terms Of Use |
  16. # You shall keep this script's Script Info part's contents intact |
  17. # You shalln't claim that this script is written by anyone other than |
  18. # DoubleX or his aliases |
  19. # None of the above applies to DoubleX or his aliases |
  20. #------------------------------------------------------------------------------|
  21. # * Prerequisites |
  22. # Scripts: |
  23. # 1. DoubleX RMVXA Linked Battlers |
  24. #------------------------------------------------------------------------------|
  25. # * Instructions |
  26. # 1. Open the script editor and put this script into an open slot between |
  27. # Linked Battlers and Main, save to take effect. |
  28. #------------------------------------------------------------------------------|
  29. # * Links |
  30. # Script Usage 101: |
  31. # 1. forums.rpgmakerweb.com/index.php?/topic/32752-rmvxa-script-usage-101/ |
  32. # 2. rpgmakervxace.net/topic/27475-rmvxa-script-usage-101/ |
  33. # This script: |
  34. # 1. http://pastebin.com/X9j9aAeL |
  35. #------------------------------------------------------------------------------|
  36. # * Authors |
  37. # DoubleX |
  38. #------------------------------------------------------------------------------|
  39. # * Changelog |
  40. # v1.00a(GMT 1000 12-8-2015): |
  41. # 1. 1st version of this script finished |
  42. #==============================================================================|
  43.  
  44. ($doublex_rmvxa ||= {})[:Linked_Battlers_Compatibility] = "v1.00a"
  45.  
  46. #==============================================================================|
  47. # ** Script Implementations |
  48. # You need not edit this part as it's about how this script works |
  49. #------------------------------------------------------------------------------|
  50. # * Script Support Info: |
  51. # 1. Prerequisites |
  52. # - Decent understanding of how the addressed scripts work |
  53. # 2. Method documentation |
  54. # - The 1st part describes why this method's rewritten/aliased for |
  55. # rewritten/aliased methods or what the method does for new methods |
  56. # - The 2nd part describes what the arguments of the method are |
  57. # - The 3rd part informs which version rewritten, aliased or created this|
  58. # method |
  59. # - The 4th part informs whether the method's rewritten or new |
  60. # - The 5th part describes how this method works for new methods only, |
  61. # and describes the parts added, removed or rewritten for rewritten or |
  62. # aliased methods only |
  63. # Example: |
  64. # #--------------------------------------------------------------------------| |
  65. # # Why rewrite/alias/What this method does | |
  66. # #--------------------------------------------------------------------------| |
  67. # # *argv: What these variables are |
  68. # # &argb: What this block is |
  69. # def def_name(*argv, &argb) # Version X+; Rewrite/New |
  70. # # Added/Removed/Rewritten to do something/How this method works |
  71. # def_name_code |
  72. # # |
  73. # end # def_name |
  74. #------------------------------------------------------------------------------|
  75.  
  76. if $doublex_rmvxa[:Linked_Battlers]
  77.  
  78. if $doublex_rmvxa[:Dynamic_Data] || $imported["TH_InstanceItems"] ||
  79. $imported[:TSBS]
  80.  
  81. # Stores the object block clearance and reset methods
  82. CLEAR_RESET_LINKED_BATTLERS_BLOCKS = %Q(
  83. def clear_linked_battlers_blocks(obj, copy = true)
  84. #{$imported["BubsTOCrafting"] ? %Q(
  85. if copy && obj.ingredient_list
  86. obj.ingredient_list.each { |ingredient|
  87. clear_linked_battlers_blocks(ingredient) if ingredient.is_a?(RPG::State)
  88. }
  89. end
  90. ) : %Q()}
  91. obj.linked_battlers = []
  92. end
  93.  
  94. def reset_linked_battlers_blocks(obj, copy = true)
  95. #{$imported["BubsTOCrafting"] ? %Q(
  96. if copy && obj.ingredient_list
  97. obj.ingredient_list.each { |ingredient|
  98. reset_linked_battlers_blocks(ingredient) if ingredient.is_a?(RPG::State)
  99. }
  100. end
  101. ) : %Q()}
  102. obj.reset_notetags_linked_battlers
  103. end
  104. )
  105.  
  106. end # if $doublex_rmvxa[:Dynamic_Data] || $imported["TH_InstanceItems"] ||
  107. # $imported[:TSBS]
  108.  
  109. if $imported["TH_InstanceItems"]
  110.  
  111. class << DataManager
  112.  
  113. #----------------------------------------------------------------------------|
  114. # Clears and resets all linked battler blocks right before and after saving |
  115. #----------------------------------------------------------------------------|
  116. alias save_game_without_rescue_linked_battlers_1 save_game_without_rescue
  117. def save_game_without_rescue
  118. # Added
  119. [InstanceManager.weapons, InstanceManager.armors,
  120. InstanceManager.items].each { |data|
  121. data.each_value { |obj| clear_linked_battlers_blocks(obj) if obj }
  122. }
  123. $game_party.clear_linked_battlers_blocks
  124. #
  125. save_game_without_rescue_linked_battlers_1
  126. #
  127. [InstanceManager.weapons, InstanceManager.armors,
  128. InstanceManager.items].each { |data|
  129. data.each_value { |obj| reset_linked_battlers_blocks(obj) if obj }
  130. }
  131. $game_party.reset_linked_battlers_blocks
  132. #
  133. end # save_game_without_rescue
  134.  
  135. #----------------------------------------------------------------------------|
  136. # Resets all linked battler blocks right after loading |
  137. #----------------------------------------------------------------------------|
  138. alias extract_save_contents_linked_battlers_1 extract_save_contents
  139. def extract_save_contents(contents)
  140. extract_save_contents_linked_battlers_1(contents)
  141. # Added
  142. [InstanceManager.weapons, InstanceManager.armors,
  143. InstanceManager.items].each { |data|
  144. data.each_value { |obj| reset_linked_battlers_blocks(obj) if obj }
  145. }
  146. $game_party.reset_linked_battlers_blocks
  147. #
  148. end # extract_save_contents
  149.  
  150. #----------------------------------------------------------------------------|
  151. # Clears and resets all blocks contained by the passed object |
  152. #----------------------------------------------------------------------------|
  153. module_eval(CLEAR_RESET_LINKED_BATTLERS_BLOCKS) # New
  154.  
  155. end # DataManager
  156.  
  157. class << InstanceManager
  158.  
  159. #----------------------------------------------------------------------------|
  160. # Clears and resets all blocks right before and after using Marshal |
  161. #----------------------------------------------------------------------------|
  162. alias make_full_copy_linked_battlers make_full_copy
  163. def make_full_copy(obj)
  164. # Added
  165. state = obj.is_a?(RPG::State)
  166. clear_linked_battlers_blocks(obj) if state
  167. #
  168. clone = make_full_copy_linked_battlerss(obj) # Rewritten
  169. # Added
  170. reset_linked_battlers_blocks(obj) if state
  171. reset_linked_battlers_blocks(clone) if state
  172. clone
  173. #
  174. end # make_full_copy
  175.  
  176. #----------------------------------------------------------------------------|
  177. # Clears and resets all blocks contained by the passed object |
  178. #----------------------------------------------------------------------------|
  179. module_eval(CLEAR_RESET_LINKED_BATTLERS_BLOCKS) # New
  180.  
  181. end # InstanceManager
  182.  
  183. class Game_Party < Game_Unit
  184.  
  185. #----------------------------------------------------------------------------|
  186. # Clears all stored blocks as notetag values of all instance items |
  187. #----------------------------------------------------------------------------|
  188. def clear_linked_battlers_blocks # New
  189. [@item_list, @weapon_list, @armor_list].each { |data|
  190. data.each { |obj| clear_linked_battlers_blocks(obj) if obj }
  191. }
  192. end # clear_linked_battlers_blocks
  193.  
  194. #----------------------------------------------------------------------------|
  195. # Resets all stored blocks as notetag values of all instance items |
  196. #----------------------------------------------------------------------------|
  197. def reset_linked_battlers_blocks # New
  198. [@item_list, @weapon_list, @armor_list].each { |data|
  199. data.each { |obj| reset_linked_battlers_blocks(obj) if obj }
  200. }
  201. end # reset_linked_battlers_blocks
  202.  
  203. #----------------------------------------------------------------------------|
  204. # Clears and resets all blocks contained by the passed object |
  205. #----------------------------------------------------------------------------|
  206. module_eval(CLEAR_RESET_LINKED_BATTLERS_BLOCKS) # New
  207.  
  208. end # Game_Party
  209.  
  210. end # if $imported["TH_InstanceItems"]
  211.  
  212. if $imported[:TSBS]
  213.  
  214. #------------------------------------------------------------------------------|
  215. # Clears and resets all blocks right before and after using Marshal |
  216. #------------------------------------------------------------------------------|
  217. alias copy_linked_battlers copy
  218. def copy(obj)
  219. # Added
  220. state = obj.is_a?(RPG::State)
  221. clear_linked_battlers_blocks(obj) if state
  222. #
  223. clone = copy_linked_battlers(obj) # Rewritten
  224. # Added
  225. reset_linked_battlers_blocks(obj) if state
  226. reset_linked_battlers_blocks(clone) if state
  227. clone
  228. #
  229. end # copy
  230.  
  231. #------------------------------------------------------------------------------|
  232. # Clears and resets all blocks contained by the passed object |
  233. #------------------------------------------------------------------------------|
  234. eval(CLEAR_RESET_LINKED_BATTLERS_BLOCKS) # New
  235.  
  236. end # $imported[:TSBS]
  237.  
  238. if $doublex_rmvxa[:Dynamic_Data]
  239.  
  240. class << DataManager
  241.  
  242. #----------------------------------------------------------------------------|
  243. # Clears and resets all linked battler blocks right before and after saving |
  244. #----------------------------------------------------------------------------|
  245. alias save_game_without_rescue_linked_battlers_2 save_game_without_rescue
  246. def save_game_without_rescue(index)
  247. # Added
  248. $data_states.each { |obj| clear_linked_battlers_blocks(obj, false) if obj }
  249. #
  250. save_game_without_rescue_linked_battlers_2(index)
  251. # Added
  252. $data_states.each { |obj| reset_linked_battlers_blocks(obj, false) if obj }
  253. #
  254. end # save_game_without_rescue
  255.  
  256. #----------------------------------------------------------------------------|
  257. # Resets all linked battler blocks right after loading |
  258. #----------------------------------------------------------------------------|
  259. alias extract_save_contents_linked_battlers_2 extract_save_contents
  260. def extract_save_contents(contents)
  261. extract_save_contents_linked_battlers_2(contents)
  262. # Added
  263. $data_states.each { |obj| reset_linked_battlers_blocks(obj, false) if obj }
  264. #
  265. end # extract_save_contents
  266.  
  267. #----------------------------------------------------------------------------|
  268. # Clears and resets all blocks contained by the passed object |
  269. #----------------------------------------------------------------------------|
  270. module_eval(CLEAR_RESET_LINKED_BATTLERS_BLOCKS) # New
  271.  
  272. end # DataManager
  273.  
  274. class RPG::State < RPG::BaseItem
  275.  
  276. #----------------------------------------------------------------------------|
  277. # New public instance variable |
  278. #----------------------------------------------------------------------------|
  279. attr_accessor :linked_battlers_string # The notetag values as strings
  280.  
  281. #----------------------------------------------------------------------------|
  282. # Stores all notetag values in the string form as well |
  283. #----------------------------------------------------------------------------|
  284. alias load_notetags_linked_battlers_compatibility load_notetags_linked_battlers
  285. def load_notetags_linked_battlers
  286. load_notetags_linked_battlers_compatibility
  287. # Added
  288. @linked_battlers_string = []
  289. lb = "DoubleX_RMVXA::Linked_Battlers::"
  290. @note.split(/[\r\n]+/).each { |line|
  291. case line
  292. when /<linked battlers:\s*(\w+)\s*,\s*(\w+)\s*,\s*(\w+)\s*>/
  293. @linked_battlers_string <<
  294. [eval("#{lb}#{$1}"), eval("#{lb}#{$2}"), eval("#{lb}#{$3}")]
  295. end
  296. }
  297. #
  298. end # load_notetags_linked_battlers
  299.  
  300. #----------------------------------------------------------------------------|
  301. # Resets all blocks used by the notetag values of the passed notetag |
  302. #----------------------------------------------------------------------------|
  303. def reset_notetags_linked_battlers
  304. @linked_battlers_string.each { |linked_battler_string|
  305. @linked_battlers << []
  306. @linked_battlers[-1] << eval("-> battler, target { target.instance_exec {
  307. #{linked_battler_string[0]} } }")
  308. @linked_battlers[-1] << eval("-> target { target.instance_exec {
  309. #{linked_battler_string[1]} } }")
  310. @linked_battlers[-1] << eval("-> battler, target { target.instance_exec {
  311. #{linked_battler_string[2]} } }")
  312. }
  313. end # reset_notetags_linked_battlers
  314.  
  315. end # RPG::State
  316.  
  317. end # if $doublex_rmvxa[:Dynamic_Data]
  318.  
  319. #------------------------------------------------------------------------------|
  320.  
  321. else
  322.  
  323. # Informs users that they didn't place Linked Battlers above this script
  324. msgbox("To use DoubleX RMVXA Linked Battlers Compatibility, " +
  325. "put it below:\n DoubleX RMVXA State Triggers\n but above Main")
  326.  
  327. end # if $doublex_rmvxa[:Linked_Battlers]
  328.  
  329. #==============================================================================|
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement