Advertisement
dsiver144

DSI More Battle Scope

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