Double_X

DoubleX RMVXA Clear Addon to Yanfly Engine Ace - Ace Battle

Jul 22nd, 2015 (edited)
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 12.29 KB | None | 0 0
  1. #==============================================================================|
  2. #  ** Script Info                                                              |
  3. #------------------------------------------------------------------------------|
  4. #  * Script Name                                                               |
  5. #    DoubleX RMVXA Clear Addon to Yanfly Engine Ace - Ace Battle Engine        |
  6. #------------------------------------------------------------------------------|
  7. #  * Functions                                                                 |
  8. #    Lets users clear previously inputted skills/items when inputting actions  |
  9. #------------------------------------------------------------------------------|
  10. #  * Terms Of Use                                                              |
  11. #    You shall:                                                                |
  12. #    1. Follow the terms of use of Yanfly Engine Ace - Ace Battle Engine       |
  13. #    2. Keep this script's Script Info part's contents intact                  |
  14. #    You shalln't claim that this script's written by anyone other than        |
  15. #    DoubleX, his aliases, Yanfly, or his/her aliases                          |
  16. #    None of the above applies to Yanfly or his/her aliases                    |
  17. #------------------------------------------------------------------------------|
  18. #  * Prerequisites                                                             |
  19. #    Scripts:                                                                  |
  20. #    1. Yanfly Engine Ace - Ace Battle Engine                                  |
  21. #    Abilities:                                                                |
  22. #    1. Little RGSS3 scripting proficiency to fully utilize this script        |
  23. #------------------------------------------------------------------------------|
  24. #  * Instructions                                                              |
  25. #    1. Open the script editor and put this script into an open slot between   |
  26. #       Yanfly Engine Ace - Ace Battle Engine and Main, save to take effect.   |
  27. #------------------------------------------------------------------------------|
  28. #  * Links                                                                     |
  29. #    Script Usage 101:                                                         |
  30. #    1. forums.rpgmakerweb.com/index.php?/topic/32752-rmvxa-script-usage-101/  |
  31. #    2. rpgmakervxace.net/topic/27475-rmvxa-script-usage-101/                  |
  32. #    This script:                                                              |
  33. #    1. http://pastebin.com/CbL0KMrd                                           |
  34. #    Mentioned Patreon Supporters:                                             |
  35. #    https://www.patreon.com/posts/71738797                                    |
  36. #------------------------------------------------------------------------------|
  37. #  * Authors                                                                   |
  38. #    DoubleX:                                                                  |
  39. #    1. This script                                                            |
  40. #    Yanfly:                                                                   |
  41. #    1. Yanfly Engine Ace - Ace Battle Engine                                  |
  42. #------------------------------------------------------------------------------|
  43. #  * Changelog                                                                 |
  44. #    v1.01a(GMT 0800 26-7-2015):                                               |
  45. #    1. Added CLEAR_NIL_SE and CLEAR_NIL_SE_VAR_ID                             |
  46. #    v1.00a(GMT 1300 22-7-2015):                                               |
  47. #    1. 1st version of this script finished                                    |
  48. #==============================================================================|
  49.  
  50. ($doublex_rmvxa ||= {})[:YEA_BattleEngine_Clear] = "v1.01a"
  51.  
  52. #==============================================================================|
  53. #  ** Script Configurations                                                    |
  54. #     You only need to edit this part as it's about what this script does      |
  55. #------------------------------------------------------------------------------|
  56.  
  57. module DoubleX_RMVXA
  58.  
  59.   module YEA_BattleEngine_Clear
  60.  
  61.     # Sets the key triggering the skill/item clearance command
  62.     # It must return a symbol and should return an existing keymap symbol
  63.     # A custom keymap binding script might help here
  64.     # If CLEAR_KEY_VAR_ID is a natural number, the value of variable with id
  65.     # CLEAR_KEY_VAR_ID will be used instead
  66.     CLEAR_KEY = :SHIFT
  67.     CLEAR_KEY_VAR_ID = 0
  68.  
  69.     # Sets the se played when triggering the skill/item clearance command
  70.     # "file", volume and pitch is its filename, volume and pitch respectively
  71.     # It must return a RPG::AudioFile and should return a RPG::SE
  72.     # If CLEAR_SE_VAR_ID is a natural number, the value of variable with id
  73.     # CLEAR_SE_VAR_ID will be used instead
  74.     CLEAR_SE = RPG::SE.new("file", volume, pitch)
  75.     CLEAR_SE_VAR_ID = 0
  76.  
  77.     # Sets the se played when trying to clear an empty action slot
  78.     # "file", volume and pitch is its filename, volume and pitch respectively
  79.     # It must return a RPG::AudioFile and should return a RPG::SE
  80.     # If CLEAR_NIL_SE_VAR_ID is a natural number, the value of variable with id
  81.     # CLEAR_NIL_SE_VAR_ID will be used instead
  82.     CLEAR_NIL_SE = RPG::SE.new("file", volume, pitch)
  83.     CLEAR_NIL_SE_VAR_ID = 0
  84.  
  85. #==============================================================================|
  86.  
  87. #==============================================================================|
  88. #  ** Script Implementations                                                   |
  89. #     You need not edit this part as it's about how this script works          |
  90. #------------------------------------------------------------------------------|
  91. #  * Script Support Info:                                                      |
  92. #    1. Prerequisites                                                          |
  93. #       - Basic knowledge to Yanfly Engine Ace - Ace Battle Engine             |
  94. #       - Some RGSS3 scripting proficiency to fully comprehend this script     |
  95. #    2. Method documentation                                                   |
  96. #       - The 1st part informs which version rewritten, aliased or created this|
  97. #         method                                                               |
  98. #       - The 2nd part informs whether the method's rewritten, aliased or new  |
  99. #       - The 3rd part describes why this method's rewritten/aliased for       |
  100. #         rewritten/aliased methods or what the method does for new methods    |
  101. #       - The 4th part describes what the arguments of the method are          |
  102. #       - The 5th part describes how this method works for new methods only,   |
  103. #         and describes the parts added, removed or rewritten for rewritten or |
  104. #         aliased methods only                                                 |
  105. #       Example:                                                               |
  106. # #--------------------------------------------------------------------------| |
  107. # #  (Version X+; Rewrite/Alias/New)Why rewrite/alias/What this method does  | |
  108. # #--------------------------------------------------------------------------| |
  109. # # *argv: What these variables are                                            |
  110. # # &argb: What this block is                                                  |
  111. # def def_name(*argv, &argb)                                                   |
  112. #   # Added/Removed/Rewritten to does something/How this method works          |
  113. #   def_name_code                                                              |
  114. #   #                                                                          |
  115. # end # def_name                                                               |
  116. #------------------------------------------------------------------------------|
  117.  
  118.     #--------------------------------------------------------------------------|
  119.     #  Returns the current keymap of the key triggering the clear command      |
  120.     #--------------------------------------------------------------------------|
  121.     def self.clear_key
  122.       # Checks if the selected variable's used instead of a fixed value
  123.       CLEAR_KEY_VAR_ID > 0 ? $game_variables[CLEAR_KEY_VAR_ID] : CLEAR_KEY
  124.       #
  125.     end # clear_key
  126.  
  127.     #--------------------------------------------------------------------------|
  128.     #  Returns the current se played when triggering the clear command         |
  129.     #--------------------------------------------------------------------------|
  130.     def self.clear_se
  131.       # Checks if the selected variable's used instead of a fixed value
  132.       CLEAR_SE_VAR_ID > 0 ? $game_variables[CLEAR_SE_VAR_ID] : CLEAR_SE
  133.       #
  134.     end # clear_se
  135.  
  136.     #--------------------------------------------------------------------------|
  137.     #  (v1.01a+)Returns the current se played when clearing empty action slots |
  138.     #--------------------------------------------------------------------------|
  139.     def self.clear_nil_se
  140.       # Checks if the selected variable's used instead of a fixed value
  141.       return $game_variables[CLEAR_NIL_SE_VAR_ID] if CLEAR_NIL_SE_VAR_ID > 0
  142.       CLEAR_NIL_SE      
  143.       #
  144.     end # clear_nil_se
  145.  
  146.   end # YEA_BattleEngine_Clear
  147.  
  148. end # DoubleX_RMVXA
  149.  
  150. if $imported["YEA-BattleEngine"]
  151.  
  152. #------------------------------------------------------------------------------|
  153. #  * (Edit)Adds the clear command handler                                      |
  154. #------------------------------------------------------------------------------|
  155. class Window_ActorCommand < Window_Command
  156.  
  157.   #----------------------------------------------------------------------------|
  158.   #  (Alias)Processes the new clear command handler                            |
  159.   #----------------------------------------------------------------------------|
  160.   alias process_handling_clear process_handling
  161.   def process_handling
  162.     # Calls clear_cur_act upon pressing the key with keymap clear_key
  163.     if open? && active
  164.       if Input.trigger?(DoubleX_RMVXA::YEA_BattleEngine_Clear.clear_key)
  165.         return call_handler(:clear)
  166.       end
  167.     end
  168.     #
  169.     process_handling_clear
  170.   end # process_handling
  171.  
  172. end # Window_ActorCommand
  173.  
  174. #------------------------------------------------------------------------------|
  175. #  * (Edit)Adds the clear command handler and handling method                  |
  176. #------------------------------------------------------------------------------|
  177. class Scene_Battle < Scene_Base
  178.  
  179.   #----------------------------------------------------------------------------|
  180.   #  (Alias)Adds the new command that clears the currently selected action slot|
  181.   #----------------------------------------------------------------------------|
  182.   alias create_actor_command_window_clear create_actor_command_window
  183.   def create_actor_command_window
  184.     create_actor_command_window_clear
  185.     # Added to call clear_cur_act upon pressing the key with keymap clear_key
  186.     @actor_command_window.set_handler(:clear, method(:clear_cur_act))
  187.     #
  188.   end # create_actor_command_window
  189.  
  190.   #----------------------------------------------------------------------------|
  191.   #  (New)Clears the currently selected actor's currently selected action slot |
  192.   #----------------------------------------------------------------------------|
  193.   def clear_cur_act
  194.     # Redraws the currently selected actor's part of the status window as well
  195.     return unless (actor = BattleManager.actor) && actor.input
  196.     item = actor.input.item
  197.     actor.input.clear
  198.     if item
  199.       DoubleX_RMVXA::YEA_BattleEngine_Clear.clear_se.play
  200.     else
  201.       DoubleX_RMVXA::YEA_BattleEngine_Clear.clear_nil_se.play
  202.     end
  203.     @status_window.draw_item(actor.index)
  204.     #
  205.   end # clear_cur_act
  206.  
  207. end # Scene_Battle
  208.  
  209. #------------------------------------------------------------------------------|
  210.  
  211. else
  212.  
  213.   # Informs users that they didn't place YEA-BattleEngine above this script
  214.   msgbox("To use DoubleX RMVXA Unison Addon to Yanfly Engine Ace - Ace " +
  215.          "Battle Engine, put it below:\n" +
  216.          "Yanfly Engine Ace - Ace Battle Engine\nbut above Main")
  217.  
  218. end
  219.  
  220. #==============================================================================|
Add Comment
Please, Sign In to add comment