Advertisement
dsiver144

DSI More Battle Scope

Aug 8th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.20 KB | None | 0 0
  1. #==============================================================================
  2. # DSI More Battle Scope
  3. # -- Last Updated: 2017.07.27
  4. # -- Author: dsiver144
  5. # -- Level: Easy
  6. # -- Requires: n/a
  7. #==============================================================================
  8. $imported = {} if $imported.nil?
  9. $imported["DSI-MoreBattleScope"] = true
  10. #==============================================================================
  11. # + Updates
  12. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  13. # 2017.07.27 - Finish first version.
  14. # 2017.08.09 - Add compalibity with Yanfly Custom Scope.
  15. #==============================================================================
  16. # + Instructions
  17. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  18. # To install this script, open up your script editor and copy/paste this script
  19. # to an open slot below ▼Materials but above ▼Main. Remember to save.
  20. # * You should put this script below all script relate to drawing enemy state
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # Skill's, Item's Notetags:
  23. # + <scope: random ally>
  24. # + <scope: random all but user>
  25. # + <scope: all but user>
  26. #==============================================================================
  27. module DSIVER144
  28. module BATTLE_SCOPE
  29. REGEXP = /<scope:\s*(.+)>/i
  30. end # BATTLE_SCOPE
  31. end # DSIVER144
  32.  
  33. class Game_System
  34. alias_method(:load_notetag_item_skills, :initialize)
  35. def initialize
  36. ($data_items+$data_skills).each do |item|
  37. next if item.nil?
  38. item.load_scope_notetags
  39. end
  40. load_notetag_item_skills
  41. end
  42. end # Game_System
  43.  
  44. class RPG::UsableItem < RPG::BaseItem
  45. include DSIVER144::BATTLE_SCOPE
  46. #--------------------------------------------------------------------------
  47. # * new method: load_scope_notetags
  48. #--------------------------------------------------------------------------
  49. def load_scope_notetags
  50. @dsi_scope = :none
  51. if self.note =~ REGEXP
  52. if $1 == "random ally"
  53. @dsi_scope = :random_ally
  54. end
  55. if $1 == "random all but user"
  56. @dsi_scope = :random_all_but_user
  57. end
  58. if $1 == "all but user"
  59. @dsi_scope = :all_but_user
  60. end
  61. end
  62. end
  63. #--------------------------------------------------------------------------
  64. # * new method: is_custom_scope?
  65. #--------------------------------------------------------------------------
  66. def is_custom_scope?
  67. return @dsi_scope != :none
  68. end
  69. #--------------------------------------------------------------------------
  70. # * new method: is_random_ally?
  71. #--------------------------------------------------------------------------
  72. def is_random_ally?
  73. @dsi_scope == :random_ally
  74. end
  75. #--------------------------------------------------------------------------
  76. # * new method: is_random_all_but_user?
  77. #--------------------------------------------------------------------------
  78. def is_random_all_but_user?
  79. @dsi_scope == :random_all_but_user
  80. end
  81. #--------------------------------------------------------------------------
  82. # * new method: is_random_all_but_user?
  83. #--------------------------------------------------------------------------
  84. def is_all_but_user?
  85. @dsi_scope == :all_but_user
  86. end
  87. end # RPG::UsableItem
  88.  
  89. class Game_Action
  90. #--------------------------------------------------------------------------
  91. # * Create Target Array
  92. #--------------------------------------------------------------------------
  93. alias_method(:dsi_game_action_make_targets, :make_targets)
  94. def make_targets
  95. if !forcing && subject.confusion?
  96. targets = [confusion_target]
  97. elsif item.is_custom_scope?
  98. targets = make_custom_targets
  99. else
  100. targets = dsi_game_action_make_targets
  101. end
  102. return targets
  103. end
  104. #--------------------------------------------------------------------------
  105. # * new method: make_custom_targets
  106. #--------------------------------------------------------------------------
  107. alias_method(:dsi_make_custom_targets, :make_custom_targets)
  108. def make_custom_targets
  109. target = []
  110. if item.is_random_ally?
  111. target << friends_unit.random_target_ex(subject)
  112. target.compact!
  113. end
  114. if item.is_random_all_but_user?
  115. if rand(3) == 1
  116. target << opponents_unit.random_target
  117. else
  118. target << friends_unit.random_target_ex(subject)
  119. end
  120. end
  121. if item.is_all_but_user?
  122. target = opponents_unit.alive_members + friends_unit.other_members(subject)
  123. end
  124. return target + dsi_make_custom_targets()
  125. end
  126.  
  127. end # Game_Action
  128.  
  129. class Game_Unit
  130. #--------------------------------------------------------------------------
  131. # * new method: random_target_ex
  132. #--------------------------------------------------------------------------
  133. def random_target_ex(subject)
  134. rand_array = other_members(subject)
  135. rand_array[0]
  136. end
  137. #--------------------------------------------------------------------------
  138. # * new method: other_members
  139. #--------------------------------------------------------------------------
  140. def other_members(subject)
  141. return (alive_members - [subject]).shuffle
  142. end
  143. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement