Bigace360

ACE Skill System [RMXP]

Apr 8th, 2013
981
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 36.45 KB | None | 0 0
  1. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  2. # ■ ACE Skill System [RMXP]                                        
  3. # ■ Author: Bigace360  
  4. # ■ Version: 1.00
  5. # ■ Date: January 21, 2013
  6. # ■ Blog: http://bigaceworld.wordpress.com/
  7. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  8. #                               VERSION HISTORY                                #
  9. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  10. # 01.21.2013 (v1.00) - Finished Script
  11. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  12. #                                INTRODUCTION                                  #
  13. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  14. # This script does not rework the way skills function. This script only reworks
  15. # the way the Skill Scene appears and what it can be used for. Basically
  16. # functions as a bridge inbetween many ACE scripts in addition to making all of
  17. # the skill-related ACE scripts accessible from one common place. Menu searching
  18. # and surfing can become quite annoying for the player and this script's main
  19. # purpose is to minimize that annoyance.
  20. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  21. #                                INSTRUCTIONS                                  #
  22. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  23. # To install this script, open up your script editor and copy/paste this script
  24. # to an open slot below Scene_Debug, and Warrior_Engine, but above Main.
  25. #
  26. # Scroll down and edit the module as you see fitting for your game.
  27. #
  28. # -----------------------------------------------------------------------------
  29. # Debug Shortcuts - Only during $DEBUG and $BTEST mode
  30. # -----------------------------------------------------------------------------
  31. # During testplay mode, pressing F5 during the command window selection process
  32. # or the skill selection process will recover all of the actor's SP.
  33. #
  34. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  35. #                                  SECTIONS                                    #
  36. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  37. #  ■ Game_Objects
  38. # ** ACE Module
  39. # ** RPG Module
  40. # ** Bitmap
  41. # ** Numeric
  42. # ** Game_Temp
  43. # ** Game_Battler
  44. # ** Game_Actor
  45. # ** Game_Party
  46. #
  47. #  ■ Windows
  48. # ** Window_Base
  49. # ** Window_Selectable
  50. # ** Window_Skill
  51. # ** Window_SkillStatus
  52. # ** Window_Command_Base
  53. # ** Window_SkillCommand
  54. #
  55. #  ■ Scenes
  56. # ** Scene_Base
  57. # ** Scene_Skill
  58. # ** Scene_Battle
  59. #
  60. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  61. #
  62. # Credits/Thanks:
  63. #   - Bigace360, for the script.
  64. #
  65. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  66. #                     Script Conflicts and Compatability                       #
  67. #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
  68. # Compatibility
  69. #   Requires Scene_Base v1.2
  70. #   Requires Module RPG::BaseItem [RMXP]
  71. #
  72. # ● Alias methods
  73. #   class Game_Actor
  74. #     def initialize(*args)
  75. #
  76. #   class Game_Party
  77. #     def initialize
  78. #
  79. # ● Overwrite methods
  80. #   class Game_Battler
  81. #     def skill_can_use?
  82. #
  83. #   class Window_Skill
  84. #    Has been completely overwritten. Expect no functionality with any scripts
  85. #    that will also replace Window_Skill.
  86. #
  87. #   class Window_SkillStatus
  88. #    Has been completely overwritten. Expect no functionality with any scripts
  89. #    that will also replace Window_SkillStatus.
  90. #
  91. #   class Scene_Skill
  92. #    Has been completely overwritten. Expect no functionality with any scripts
  93. #    that will also replace Scene_Skill.
  94. #
  95. #   class Scene_Battle
  96. #     def start_skill_select
  97. #
  98. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  99. #
  100. #=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  101. # ■ Module ACE::SKILL_SYSTEM
  102. #=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  103. module ACE
  104.     #=============================================================================
  105.     # ▼ Warning DO NOT TOUCH THIS MODULE, altering this will ruin any chances of
  106.     #   any script that requires this engine to run.
  107.     #
  108.     # For Configurations go to Module SKILL_SYSTEM below this one.
  109.     #=============================================================================
  110.     module CORE
  111.         def self.required_script(name, req, version, type = 0)
  112.             if type != :bellow && (!$ace_script[req] || $ace_script[req] < version)
  113.                 msg = "The script '%s' requires the script\n"
  114.                 case type
  115.                 when :above then msg += "'%s' v%s or higher above it to work properly\n"
  116.                 else             msg += "'%s' v%s or higher to work properly\n"
  117.                 end
  118.                 msg += "Go to http://bigaceworld.wordpress.com/ to download this script."
  119.                 self.exit_message(msg, name, req, version)
  120.             elsif type == :bellow && $ace_script[req]
  121.                 msg =  "The script '%s' requires the script\n"
  122.                 msg += "'%s' to be put bellow it\n"
  123.                 msg += "move the scripts to the proper position"
  124.                 self.exit_message(msg, name, req, version)
  125.             end
  126.         end
  127.         def self.exit_message(message, name, req, version)
  128.             name = self.script_name(name)
  129.             req  = self.script_name(req)
  130.             msgbox(sprintf(message, name, req, version))
  131.             exit
  132.         end
  133.         def self.script_name(name, ext = "Skill Base")
  134.             name = name.to_s.gsub("_", " ").upcase.split
  135.             name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
  136.             name.join(" ")
  137.         end
  138.     end
  139.     #=============================================================================
  140.     # ▼ BEGIN CONFIGURATIONS HERE BELOW
  141.     #=============================================================================
  142.     module SKILL_SYSTEM
  143.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  144.         # ◆ Section I. General Menu Settings ◆
  145.         # -------------------------------------------------------------------------
  146.         # This changes the way Menus appear in your game. You can change their
  147.         # alignment, and the location of the help window, Note that any non-ACE
  148.         # System scripts may not conform to these Menu styles.
  149.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  150.         SKILL_CONFIG ={
  151.             # :skill_win - [Opacity, Window Border?]. (Opacity Limit: 0~255)
  152.             :skill_win => [200, false],
  153.             # :background - Background images
  154.             :background => 'back04',
  155.             # :fx - Back FX (0=Moving/ 1=Still/ 2=Map)  
  156.             :fx => 0,
  157.             # :tran_time - Transition Time.
  158.             :tran_time => 10,
  159.             # :tran_type - Transition Type (Name)
  160.             :tran_type => '004-Blind04',
  161.             # :menu_index - If :menu_access is true, then this value determines where
  162.             # in the menu command window it is inserted.
  163.             :menu_index => 1,
  164.             # :layout - Image filename for window layout, must be in the Menu folder
  165.             :layout => '',
  166.         }
  167.        
  168.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  169.         # ◆ Section II. Skill Menu Settings ◆
  170.         # -------------------------------------------------------------------------
  171.         # This array adjusts what options appear in the initial skill command
  172.         # window. Add commands, remove commands, or rearrange them. Here's a list
  173.         # of which does what:
  174.         #
  175.         # -------------------------------------------------------------------------
  176.         # :command         Description
  177.         # -------------------------------------------------------------------------
  178.         # :view_skills  |  View all of the available skills usable by the actor.
  179.         #
  180.         # :materia      |  Requires Sephiroth's Materia System
  181.         #
  182.         # And that's all of the currently available commands. This list will be
  183.         # updated as more scripts become available.
  184.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=     
  185.         SKILL_COMMANDS =[
  186.             [:view_skills, 'View Skill'],
  187.             [:materia, 'Materia'], # Requires Sephiroth's Materia System
  188.             #[:custom1, 'Custom Name']  # Custom Skill Command 1
  189.             #[:custom2, 'Custom Text']  # Custom Skill Command 2
  190.         ] # Do not remove this.
  191.        
  192.         SKILL_DESCRIPTIONS ={
  193.             :view_skills => 'View the actor\'s abilities.',
  194.             :materia => 'Attach ‘materias’ on the actor equipment to gain skills and other effects.',
  195.             #:custom1 => 'Custom Skill Command 1',
  196.             #:custom2 => 'Custom Skill Command 2',
  197.         } # Do not remove this.
  198.        
  199.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  200.         # ◆ Section III. Skill Custom Settings ◆
  201.         # -------------------------------------------------------------------------
  202.         # For those who use scripts to that may produce unique effects for
  203.         # equipping, use this hash to manage the custom commands for the Skill
  204.         # Command Window. You can disable certain commands or prevent them from
  205.         # appearing by using switches. If you don't wish to bind them to a switch,
  206.         # set the proper switch to 0 for it to have no impact.
  207.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  208.         CUSTOM_SKILL_COMMANDS ={
  209.             # :command => [HideSw, DisbSw,            Scene],
  210.             :materia => [           0,          1, "Scene_MateriaEquip"],
  211.             :custom1 => [           0,          0,   ""],
  212.             :custom2 => [           0,          0,   ""],
  213.         } # Do not remove this.
  214.        
  215.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  216.         # ◆ Section III. Item Status Settings ◆
  217.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  218.         # The item status window displays information about the item in detail.
  219.         # Adjust the settings below to change the way the status window appears.
  220.         #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  221.         MAX_ICONS_DRAWN  = 7       # 7: Maximum number of icons drawn for states.
  222.        
  223.         # The following adjusts the vocabulary used for the status window. Each
  224.         # of the vocabulary settings are self explanatory.
  225.         VOCAB_STATUS ={
  226.             :empty   => "---",         # Text used when nothing is shown.
  227.             :cost    => "Cost",        # Text usde for skill cost.
  228.             :scope   => "Scope",       # Text used for skill target area of influence.
  229.             :power   => "Power",       # Text used for attack power.
  230.             :element => "Elements",    # Text used for element attributes.
  231.             :applies => "Applies",     # Text used for applied states and buffs.
  232.             :removes => "Removes",     # Text used for removed states and buffs.
  233.         } # Do not remove this.
  234.        
  235.         # This is for the status window, use the button input to change between
  236.         # actor and skill status windows. The quotes are for the player to know
  237.         # what they are doing.
  238.         QUOTE ={
  239.             :button => Input::SHIFT,
  240.             :actors => 'Press [%s] to show skill stats',
  241.             :skills => 'Press [%s] to show actors stats',
  242.         }
  243.        
  244.     end
  245. end
  246.  
  247. #===============================================================================
  248. # ▼ Editting anything past this point may potentially result in causing
  249. # computer damage, incontinence, explosion of user's head, coma, death,
  250. # and/or halitosis so edit at your own risk.
  251. #===============================================================================
  252. #
  253. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  254. #                         ▼ Import to Global Hash ▼                            #
  255. ($ace_script ||= {})[:ace_skill_menu] = 1.00
  256. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  257.  
  258. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  259. # ■ Bitmap
  260. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  261. class Bitmap
  262.     def clear_rect(*args)
  263.         color = Color.new(0, 0, 0, 0)
  264.         args << color
  265.         fill_rect(*args)
  266.     end
  267. end
  268.  
  269. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  270. # ■ Numeric
  271. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  272. class Numeric
  273.     def group; return self.to_s; end unless $ace_script[:ace_warrior_module]
  274. end
  275.  
  276. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  277. # ■ Game_Temp
  278. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  279. class Game_Temp
  280.     attr_accessor(:skill_index, :skill_oy)
  281. end
  282.  
  283. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  284. # ■ Game_Battler
  285. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  286. class Game_Battler
  287.     unless $ace_script[:ace_warrior_module]
  288.         def skill_can_use?(skill_id)
  289.             skill = $data_skills[skill_id]
  290.             return false if skill.sp_cost > self.sp
  291.             return false if dead?
  292.             return false if skill.atk_f == 0 && self.restriction == 1
  293.             $game_temp.in_battle ? skill.battle_ok? : skill.menu_ok?
  294.         end
  295.     end
  296. end
  297.  
  298. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  299. # ■ Game_Actor
  300. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  301. class Game_Actor < Game_Battler
  302.     attr_accessor :last_skill_id # for cursor memory: Skill
  303.     alias :ace_skillbase_initi :initialize unless $@
  304.     def initialize(*args)
  305.         ace_skillbase_initi(*args)
  306.         @last_skill_id = 0
  307.     end
  308. end
  309.  
  310. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  311. # ■ Game_Party
  312. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  313. class Game_Party
  314.     attr_accessor(:last_target_index)
  315.     alias :ace_skillbase_initi :initialize unless $@
  316.     def initialize
  317.         ace_skillbase_initi
  318.         @last_target_index = 0
  319.     end
  320. end
  321.  
  322. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  323. # ■ Window_Base
  324. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  325. class Window_Base < Window
  326.     include ACE::SKILL_SYSTEM
  327.     alias :ace_skillbase_initi :initialize unless $@
  328.     def initialize(*args)
  329.         ace_skillbase_initi(*args)
  330.         skill_Opacity?
  331.     end
  332.     def skill_Opacity?
  333.         return unless $scene.is_a?(Scene_Skill)
  334.         self.back_opacity = SKILL_CONFIG[:skill_win][0]
  335.         self.opacity = SKILL_CONFIG[:skill_win][0] if SKILL_CONFIG[:skill_win][1]
  336.     end
  337.     def line_height;       return 32;  end
  338.     def translucent_alpha; return 160; end
  339.     def standard_padding;  return 16;  end
  340.     def draw_icon(icon_index, x, y, enabled = true)
  341.         bitmap = RPG::Cache.icon(icon_index)
  342.         self.contents.blt(x, y, bitmap, Rect.new(0, 0, 24, 24), enabled ? 255 : translucent_alpha)
  343.     end
  344.     def fitting_height(line_number)
  345.         (line_number * line_height) + (standard_padding * 2)
  346.     end
  347.     def draw_item_name(item, x, y, enabled = true, width = 212)
  348.         return if item.nil?
  349.         draw_icon(item.icon_name, x, y+4, enabled)     
  350.         contents.font.color = normal_color
  351.         contents.font.color.alpha = enabled ? 255 : translucent_alpha
  352.         contents.draw_text(x + 25, y, width, 32, item.name)
  353.     end
  354.     def show; self.visible = true;  self; end
  355.     def hide; self.visible = false; self; end
  356.     def activate;   self.active = true;  self; end
  357.     def deactivate; self.active = false; self; end
  358.     def param_change_color(change)
  359.         return Color.new(128,255,128) if change > 0
  360.         return Color.new(192,128,128) if change < 0
  361.         return normal_color
  362.     end
  363. end
  364.  
  365. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  366. # ■ Window_Selectable
  367. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  368. class Window_Selectable < Window_Base
  369.     attr_reader   :item_max                 # item count
  370.     def select(index); self.index = index if index; end
  371.     def unselect;      self.index = -1;             end
  372.     def col_max(n);    return @column_max = n;      end
  373.     def item_rect(index)
  374.         rect = Rect.new(0, 0, 0, 32)
  375.         rect.width = self.width / @column_max - 32
  376.         rect.x = index % @column_max * (rect.width + 32)
  377.         rect.y = index / @column_max * 32
  378.         return rect
  379.     end
  380. end
  381.  
  382. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  383. # ■ Window_Skill
  384. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  385. class Window_Skill < Window_Selectable
  386.     def initialize(x, y, width, height, actor)
  387.         super(x, y, width, height)
  388.         @actor = actor
  389.         col_max(2)
  390.         refresh
  391.     end
  392.     def skill; return @data[self.index]; end
  393.     def refresh
  394.         self.contents.dispose if self.contents != nil
  395.         self.contents = nil if self.contents != nil
  396.         @data = []
  397.         (@actor.skills.size).times do |i|
  398.             skill = $data_skills[@actor.skills[i]]
  399.             @data << skill if !skill.nil?
  400.         end
  401.         @item_max = @data.size
  402.         if @item_max > 0
  403.             self.contents = Bitmap.new(width - 32, row_max * 32)
  404.             @item_max.times {|i| draw_item(i)}
  405.         end
  406.     end
  407.     def enable?(skill)
  408.         @actor.skill_can_use?(skill.id)
  409.     end
  410.     def draw_item(index)
  411.         rect = item_rect(index)
  412.         contents.clear_rect(rect)
  413.         skill = @data[index]
  414.         return if skill.nil?
  415.         rect.width -= 4
  416.         draw_item_name(skill, rect.x, rect.y, enable?(skill))
  417.         draw_skill_cost(rect, skill)
  418.     end
  419.     unless method_defined?(:draw_skill_cost)
  420.         def draw_skill_cost(rect, skill)
  421.             contents.draw_text(rect, skill.sp_cost.to_s, 2)
  422.         end
  423.     end
  424.     def update_help
  425.         @help_window.set_text(skill.nil? ? '' : skill.description)
  426.     end
  427. end
  428.  
  429. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  430. # ■ Window_SkillStatus
  431. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  432. class Window_SkillStatus < Window_Base
  433.     attr_accessor :mode
  434.     def initialize(x, y, width, item_window)
  435.         super(x, y, width, fitting_height(3))
  436.         self.contents = Bitmap.new(width - 32, height - 32)
  437.         @item_window = item_window
  438.         @skill = nil; @actor = nil
  439.         set_mode(0)
  440.     end
  441.     def line_height; return 32; end
  442.     def actor=(actor)
  443.         return if @actor == actor
  444.         @actor = actor
  445.         refresh
  446.     end
  447.     def update; super; update_item(@item_window.skill); end
  448.     def update_item(skill)
  449.         return if ((@skill == skill && @item_window.active) || (!@item_window.active && @skill.nil?))
  450.         @skill = (@item_window.active ? skill : nil)
  451.         refresh
  452.     end
  453.     def set_mode(mode)
  454.         @mode = mode
  455.         refresh
  456.     end
  457.     def refresh
  458.         contents.clear
  459.         reset_font_settings if $ace_script[:ace_warrior_module]
  460.         draw_empty1
  461.         return unless @actor
  462.         draw_actor_simple_face
  463.         case @mode
  464.         when 0
  465.             draw_button(:actors, 108, 23 * 3)
  466.             draw_actor_simple_status
  467.         when 1
  468.             contents.font.size = 17
  469.             draw_button(:skills, 108, 23 * 3)
  470.             @skill.nil? ? draw_empty2 : draw_skill_simple_status
  471.         end
  472.     end
  473.     def draw_empty1
  474.         colour = Color.new(0, 0, 0, translucent_alpha/2)
  475.         rect = Rect.new(1, 1, 94, 94)
  476.         contents.fill_rect(rect, colour)
  477.     end
  478.     def draw_empty2
  479.         dx = 96; dy = 0
  480.         dw = (contents.width - 96) / 2
  481.         6.times do |i|
  482.             draw_background_box(dx, dy, dw)
  483.             dx = dx >= 96 + dw ? 96 : 96 + dw
  484.             dy += 24 if dx == 96
  485.         end    
  486.     end
  487.     def draw_background_box(dx, dy, dw)
  488.         colour = Color.new(0, 0, 0, translucent_alpha/2)
  489.         rect = Rect.new(dx+1, dy+1, dw-2, 24-2)
  490.         contents.fill_rect(rect, colour)
  491.     end
  492.     def draw_button(quote, x, y)
  493.         case QUOTE[:button]
  494.         when Input::SHIFT then button = 'Shift'
  495.         when Input::A then button = 'Z'
  496.         when Input::X then button = 'A'
  497.         when Input::Y then button = 'S'
  498.         when Input::Z   then button = 'D'
  499.         else
  500.             print("Sorry, but the button inputs B, C, L, R, UP, DOWN, RIGHT, LEFT, " +
  501.                 "F5, 56, F7, F8, or F9 is not allow. " +
  502.                 "Please choose A, X, Y, Z, or SHIFT inputs instead for the scene " +
  503.                 "changing button.")
  504.             exit
  505.         end
  506.         contents.font.size = Font.default_size; contents.font.color = normal_color
  507.         contents.draw_text(x, y, self.width - 32, 32, sprintf(QUOTE[quote], button))
  508.     end
  509.     def draw_actor_simple_face
  510.         if $ace_script[:ace_warrior_module] && SHOW_FACE
  511.             draw_actor_face(@actor, 0, 0) rescue draw_actor_graphic(@actor, 48, 70)
  512.         else draw_actor_graphic(@actor, 48, 70)
  513.         end    
  514.     end
  515.     def draw_actor_simple_status
  516.         dx = 108; dy = 0
  517.         draw_actor_name(@actor, dx, dy)
  518.         draw_actor_level(@actor, dx, dy + 24)
  519.         if $ace_script[:ace_warrior_module]
  520.             draw_actor_state(@actor, dx, dy + 48, 96)
  521.             draw_actor_hp(@actor, dx + 120, dy + 24 * 0, 210)
  522.             draw_actor_sp(@actor, dx + 120, dy + 24 * 1, 210)
  523.             draw_actor_exp(@actor, dx + 120, dy + 24 * 2, 210)     
  524.         else
  525.             draw_actor_state(@actor, dx, dy + 48)
  526.             draw_actor_hp(@actor, dx + 120, dy + 24 * 0)
  527.             draw_actor_sp(@actor, dx + 120, dy + 24 * 1)   
  528.             draw_actor_exp(@actor, dx + 120, dy + 24 * 2)  
  529.         end
  530.     end
  531.     def vocab(index); return VOCAB_STATUS[index]; end
  532.     def draw_skill_simple_status
  533.         dx = 96; dy = 0
  534.         dw = (contents.width - 96) / 2
  535.         draw_skill_cost(dx, dy + 24 * 0, dw)
  536.         draw_skill_power(dx, dy + 24 * 1, dw)
  537.         draw_applies(dx, dy + 24 * 2, dw)
  538.         draw_area_scope(dx + dw, dy + 24 * 0, dw)  
  539.         draw_element(dx + dw, dy + 24 * 1, dw) 
  540.         draw_removes(dx + dw, dy + 24 * 2, dw)
  541.     end
  542.     def draw_skill_cost(dx, dy, dw)
  543.         draw_background_box(dx, dy, dw)
  544.         contents.font.color = system_color
  545.         rect = Rect.new(dx+4, dy, dw-8, 24)
  546.         contents.draw_text(rect, vocab(:cost)) 
  547.         contents.font.size = 16
  548.         draw_sp_skill_cost(rect, @skill)
  549.         if $ace_script[:ace_warrior_module]
  550.             draw_tp_skill_cost(rect, @skill) if $ace_script[:tp_system]
  551.             if $ace_script[:cost_manager]
  552.                 draw_hp_skill_cost(rect, @skill)
  553.                 draw_gold_skill_cost(rect, @skill)
  554.                 draw_custom_skill_cost(rect, @skill)
  555.             end
  556.         end
  557.     end
  558.     def enable?(skill)
  559.         @actor.skill_can_use?(skill.id)
  560.     end
  561.     def draw_sp_skill_cost(rect, skill)
  562.         if $ace_script[:ace_warrior_module]
  563.             return unless @actor.calc_sp_cost(skill) > 0
  564.             colour = Color.color_between(Color.blue, Color.normal, 0.7)
  565.             change_color(colour, enable?(skill))
  566.             if $ace_script[:cost_manager]
  567.                 icon = Icon.sp_cost
  568.                 if !icon.nil?
  569.                     draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  570.                     rect.width -= 24
  571.                 end
  572.             end
  573.             cost = @actor.calc_sp_cost(skill)
  574.             text = sprintf("%s%s", cost.group, $data_system.words.sp)
  575.             draw_text(rect, text, 2)
  576.             cx = text_size(text).width + 4
  577.             rect.width -= cx
  578.             reset_font_settings
  579.         else
  580.             contents.font.color = normal_color         
  581.             contents.draw_text(rect, skill.sp_cost.to_s, 2)
  582.         end    
  583.     end
  584.     def draw_tp_skill_cost(rect, skill)
  585.         return unless @actor.skill_tp_cost(skill) > 0
  586.         colour = Color.color_between(Color.green, Color.normal)
  587.         change_color(colour, enable?(skill))
  588.         if $ace_script[:cost_manager]
  589.             icon = Icon.tp_cost
  590.             if !icon.nil?
  591.                 draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  592.                 rect.width -= 24
  593.             end            
  594.         end
  595.         cost = @actor.skill_tp_cost(skill)
  596.         text = sprintf("%s%s", cost.group, TP_A)
  597.         draw_text(rect, text, 2)
  598.         cx = text_size(text).width + 4
  599.         rect.width -= cx
  600.         reset_font_settings    
  601.     end
  602.     def draw_hp_skill_cost(rect, skill)
  603.         return unless @actor.skill_hp_cost(skill) > 0
  604.         change_color(hp_cost_color, enable?(skill))
  605.         icon = Icon.hp_cost
  606.         if !icon.nil?
  607.             draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  608.             rect.width -= 24
  609.         end
  610.         contents.font.size = HP_SETTINGS[:f_size]
  611.         cost = @actor.skill_hp_cost(skill)
  612.         text = sprintf("%s%s", cost.group, $data_system.words.hp)
  613.         draw_text(rect, text, 2)
  614.         cx = text_size(text).width + 4
  615.         rect.width -= cx
  616.         reset_font_settings    
  617.     end
  618.     def draw_gold_skill_cost(rect, skill)
  619.         return unless @actor.skill_gold_cost(skill) > 0
  620.         change_color(gold_cost_color, enable?(skill))
  621.         icon = Icon.gold_cost
  622.         if !icon.nil?
  623.             draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  624.             rect.width -= 24
  625.         end
  626.         contents.font.size = GOLD_SETTINGS[:f_size]
  627.         cost = @actor.skill_gold_cost(skill)
  628.         text = sprintf("%s%s", cost.group, $data_system.words.gold)
  629.         draw_text(rect, text, 2)
  630.         cx = text_size(text).width + 4
  631.         rect.width -= cx
  632.         reset_font_settings    
  633.     end
  634.     def draw_custom_skill_cost(rect, skill)
  635.         return unless skill.use_custom_cost
  636.         change_color(custom_color(skill), enable?(skill))
  637.         icon = custom_cost(skill)
  638.         if !icon.nil?
  639.             draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  640.             rect.width -= 24
  641.         end
  642.         contents.font.size = CUSTOM_COST_SETTINGS[skill][2]
  643.         text = CUSTOM_COST_SETTINGS[skill][0]
  644.         draw_text(rect, text, 2)
  645.         cx = text_size(text).width + 4
  646.         rect.width -= cx
  647.         reset_font_settings    
  648.     end
  649.     def draw_skill_power(dx, dy, dw)
  650.         draw_background_box(dx, dy, dw)
  651.         contents.font.color = system_color
  652.         contents.draw_text(dx+4, dy, dw-8, 24, vocab(:power))  
  653.         contents.font.color = normal_color; contents.font.size = 16
  654.         contents.draw_text(dx+4, dy, dw-8, 24, @skill.power.group, 2)
  655.     end
  656.     def draw_applies(dx, dy, dw)
  657.         draw_background_box(dx, dy, dw)
  658.         contents.font.color = system_color
  659.         contents.draw_text(dx+4, dy, dw-8, 24, vocab(:applies))
  660.         icons = []
  661.         (@skill.plus_state_set).each do |state_id|
  662.             next if $data_states[state_id].nil?
  663.             icons << $data_states[state_id].name
  664.             break if icons.size >= 8
  665.         end
  666.         draw_icons(dx, dy, dw, icons)
  667.     end
  668.     def draw_area_scope(dx, dy, dw)
  669.         draw_background_box(dx, dy, dw)
  670.         contents.font.color = system_color
  671.         contents.draw_text(dx+4, dy, dw-8, 24, vocab(:scope))  
  672.         text = case @skill.scope
  673.         when 0 then 'None'
  674.         when 1 then 'One Enemy'
  675.         when 2 then 'All Enemies'
  676.         when 3 then 'One Ally'
  677.         when 4 then 'All Allies'
  678.         when 5 then 'One Dead Ally'
  679.         when 6 then 'All Dead Allies'
  680.         when 7 then 'The User'
  681.         end
  682.         contents.font.color = normal_color; contents.font.size = 16
  683.         contents.draw_text(dx+4, dy, dw-8, 24, text, 2)
  684.     end
  685.     def draw_element(dx, dy, dw)
  686.         draw_background_box(dx, dy, dw)
  687.         contents.font.color = system_color
  688.         contents.draw_text(dx+4, dy, dw-8, 24, vocab(:element))    
  689.         icons = []
  690.         (@skill.element_set).each do |state_id|
  691.             next if $data_system.elements[state_id].nil?
  692.             icons << $data_system.elements[state_id] rescue nil
  693.             break if icons.size >= 8
  694.         end
  695.         draw_icons(dx, dy, dw, icons)
  696.     end
  697.     def draw_removes(dx, dy, dw)
  698.         draw_background_box(dx, dy, dw)
  699.         contents.font.color = system_color
  700.         contents.draw_text(dx+4, dy, dw-8, 24, vocab(:removes))
  701.         icons = []
  702.         (@skill.minus_state_set).each do |state_id|
  703.             next if $data_states[state_id].nil?
  704.             icons << $data_states[state_id].name
  705.             break if icons.size >= 8
  706.         end
  707.         draw_icons(dx, dy, dw, icons)
  708.     end
  709.     def draw_icons(dx, dy, dw, icons)
  710.         if !icons.size == 0
  711.             dx += dw - 4
  712.             dx -= icons.size * 24
  713.             icons.each {|icon_id| draw_icon(icon_id, dx, dy); dx += 24}
  714.         else
  715.             contents.font.color = normal_color
  716.             contents.font.color.alpha = translucent_alpha
  717.             contents.draw_text(dx+4, dy, dw-8, 24, vocab(:empty), 2)
  718.         end
  719.     end
  720. end
  721.  
  722. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  723. # ■ Window_Command_Base
  724. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  725. class Window_Command_Base < Window_Selectable
  726.     def initialize(width, commands)
  727.         super(0, 0, width, commands.size * 32 + 32)
  728.         @item_max, @commands = commands.size, commands
  729.         self.contents = Bitmap.new(width - 32, @item_max * 32)
  730.         refresh
  731.         select(0)
  732.     end
  733.     def refresh; end
  734. end
  735.  
  736. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  737. # ■ Window_SkillCommand
  738. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  739. class Window_SkillCommand < Window_Command_Base
  740.     attr_reader :skill_window
  741.     def initialize(array)
  742.         @data = array[1]
  743.         super(160, array[0])
  744.     end
  745.     def refresh
  746.         self.contents = Bitmap.new(width - 32, @item_max * 32) if @item_max > 0
  747.         @item_max.times {|i| draw_item(i)} if @item_max > 0
  748.     end
  749.     def method; return @data[self.index]; end
  750.     def alignment
  751.         return Menu.main_menu_align if $ace_script[:ace_main_menu]
  752.         return 1
  753.     end
  754.     def method; return @data[self.index]; end
  755.     def draw_item(index, enabled = true)
  756.         rect = item_rect(index)
  757.         rect.x += 4; rect.width -= 8
  758.         contents.clear_rect(rect)
  759.         contents.font.color = normal_color
  760.         if CUSTOM_SKILL_COMMANDS.include?(@data[index])
  761.             switch = CUSTOM_SKILL_COMMANDS[@data[index]][1]
  762.             enabled = switch <= 0 ? true : $game_switches[switch]
  763.         end
  764.         contents.font.color.alpha = enabled ? 255 : translucent_alpha
  765.         contents.draw_text(rect, @commands[index], alignment)
  766.     end
  767. end
  768.  
  769. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  770. # ■ Scene_Skill
  771. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  772. class Scene_Skill < Scene_Base
  773.     include ACE::SKILL_SYSTEM
  774.     attr_accessor :actor
  775.     def initialize(actor_index = 0)
  776.         @actor_index = actor_index
  777.     end
  778.     def start
  779.         super  
  780.         @actor = $game_party.actors[@actor_index]
  781.         $page_mode_index = 0
  782.         create_menu_layout
  783.         create_help_window
  784.         create_command_window
  785.         create_item_window
  786.         create_status_window
  787.     end
  788.     def create_menu_layout
  789.         super
  790.         return if SKILL_CONFIG[:layout].empty?
  791.         if $ace_script[:ace_main_menu]
  792.             @menulay.bitmap = RPG::Cache.menu("Background/#{SKILL_CONFIG[:layout]}")
  793.         else @menulay.bitmap = RPG::Cache.picture(SKILL_CONFIG[:layout])
  794.         end
  795.     end
  796.     def create_help_window
  797.         @help_window = Window_Help.new
  798.     end
  799.     def create_command_window
  800.         create_command_list
  801.         @category_window = Window_SkillCommand.new(@menu_commands)
  802.         @category_window.height = fitting_height(visible_line_number)
  803.         @category_window.y = @help_window.height   
  804.         if !$game_temp.skill_index.nil?
  805.             @category_window.select($game_temp.skill_index)
  806.             @category_window.oy = $game_temp.skill_oy
  807.         end
  808.         $game_temp.skill_index = nil
  809.         $game_temp.skill_oy = nil
  810.         @category_window.activate              
  811.         update_help
  812.     end
  813.     def create_command_list
  814.         vocab = []; data = []
  815.         SKILL_COMMANDS.each do |command|
  816.             case command[0]
  817.             when :view_skills
  818.             else
  819.                 next unless CUSTOM_SKILL_COMMANDS.include?(command[0])
  820.                 show = CUSTOM_SKILL_COMMANDS[command[0]][0]
  821.                 continue = show <= 0 ? true : $game_switches[show]
  822.                 next unless continue
  823.             end
  824.             data << command[0]; vocab << command[1]
  825.         end
  826.         @menu_commands = [vocab, data]     
  827.     end
  828.     def fitting_height line_number
  829.         (line_number * line_height) + (standard_padding * 2)
  830.     end
  831.     def line_height;         return 32; end
  832.     def standard_padding;    return 16; end
  833.     def visible_line_number; return [[@category_window.height, 3].min, 1].max; end
  834.     def create_item_window
  835.         dy = @category_window.y + @category_window.height
  836.         dh = 480 - dy      
  837.         @skill_window = Window_Skill.new(0, dy, 640, dh, @actor)
  838.         @skill_window.deactivate.unselect
  839.         @skill_window.help_window = @help_window
  840.         @target_window = Window_Target.new
  841.         hide_target_window 
  842.     end
  843.     def create_status_window
  844.         dx = @category_window.width
  845.         dy = @help_window.height
  846.         @status_window = Window_SkillStatus.new(dx, dy, 480, @skill_window)
  847.         @status_window.actor = @actor
  848.     end
  849.     def perform_transition
  850.         super; SKILL_CONFIG[:fx] == 2 ? map_back : skill_back
  851.     end
  852.     def skill_back
  853.         @back = Plane.new
  854.         unless SKILL_CONFIG[:background].empty?
  855.             if $ace_script[:ace_main_menu]
  856.                 @back.bitmap = RPG::Cache.menu("Background/#{SKILL_CONFIG[:background]}")
  857.             else @back.bitmap = RPG::Cache.picture(SKILL_CONFIG[:background])
  858.             end
  859.         end
  860.         @back.z = 10       
  861.         Graphics.transition(SKILL_CONFIG[:tran_time],
  862.             "Graphics/Transitions/#{SKILL_CONFIG[:tran_type]}")    
  863.     end
  864.     def map_back
  865.         @spriteset = Spriteset_Map.new
  866.         Graphics.transition(transition_speed)  
  867.     end
  868.     def terminate
  869.         super; SKILL_CONFIG[:fx] == 2 ? @spriteset.dispose : @back.dispose
  870.     end
  871.     def update
  872.         update_moving_windows?
  873.         if @category_window.active;  update_status_window; update_command_selection
  874.         elsif @skill_window.active;  update_status_window; update_skill_selection
  875.         elsif @target_window.active; update_target_selection
  876.         end
  877.     end
  878.     def update_moving_windows?
  879.         @back.ox /= 1 if SKILL_CONFIG[:fx] == 0
  880.         @back.oy += 1 if SKILL_CONFIG[:fx] == 0    
  881.     end
  882.     def update_status_window
  883.         return unless Input.trigger?(QUOTE[:button])
  884.         $game_system.se_play($data_system.decision_se)
  885.         page = $page_mode_index
  886.         page == 0 ? page = 1 : page = 0
  887.         $page_mode_index = page
  888.         @status_window.set_mode($page_mode_index)
  889.     end
  890.     def update_command_selection
  891.         if @last_status_index != @category_window.index
  892.             @last_status_index = @category_window.index
  893.             update_help
  894.         end
  895.         cancel_command if Input.trigger?(Input::B)
  896.         select_command if Input.trigger?(Input::C)
  897.         actor_recovery if Input.trigger?(Input::F5) && $DEBUG
  898.         actors_command if Input.press?(Input::R) || Input.press?(Input::L)
  899.     end
  900.     def cancel_command
  901.         $game_temp.skill_index = nil
  902.         $game_temp.skill_oy = nil
  903.         $game_system.se_play($data_system.cancel_se)
  904.         if $ace_script[:ace_main_menu]
  905.             return unless $game_temp.menu_command_index.has_key?(:skill)
  906.             $scene = Scene_Menu.new($game_temp.menu_command_index[:skill])
  907.         else return_scene(Scene_Menu.new(SKILL_CONFIG[:menu_index]))
  908.         end    
  909.     end
  910.     def select_command
  911.         case @category_window.method
  912.         when :view_skills
  913.             $game_system.se_play($data_system.decision_se)
  914.             @category_window.deactivate; @skill_window.activate.select(0)
  915.         else command_custom
  916.         end
  917.     end
  918.     def command_custom
  919.         return unless CUSTOM_SKILL_COMMANDS.include?(@category_window.method)
  920.         method = CUSTOM_SKILL_COMMANDS[@category_window.method]
  921.         if method[1] <= 0
  922.             return if method[2].nil?
  923.             $game_system.se_play($data_system.decision_se)
  924.             $scene = eval("#{method[2]}.new(@actor_index)")
  925.         else $game_system.se_play($data_system.buzzer_se)
  926.         end
  927.     end
  928.     def actors_command
  929.         $game_system.se_play($data_system.cursor_se)
  930.         @actor_index += Input.trigger?(Input::L) ? -1 : 1
  931.         @actor_index %= $game_party.actors.size
  932.         $scene = Scene_Skill.new(@actor_index)
  933.     end
  934.     def update_skill_selection
  935.         exit_skill if Input.trigger?(Input::B)
  936.         open_skill if Input.trigger?(Input::C)
  937.         actor_recovery if $DEBUG && Input.trigger?(Input::F5)
  938.         actors_command if Input.press?(Input::R) || Input.press?(Input::L)
  939.     end
  940.     def exit_skill
  941.         $game_system.se_play($data_system.cancel_se)
  942.         @category_window.activate
  943.         @skill_window.deactivate.unselect
  944.     end
  945.     def open_skill
  946.         @skill = @skill_window.skill
  947.         @actor.last_skill_id = @skill.id if !@skill.nil?
  948.         if @actor.skill_can_use?(@skill.id)
  949.             $game_system.se_play($data_system.decision_se)
  950.             determine_skill
  951.         else $game_system.se_play($data_system.buzzer_se)
  952.         end
  953.     end
  954.     def actor_recovery
  955.         Audio.se_play('Audio/SE/' + '105-Heal01', 100, 100)
  956.         @actor.sp += @actor.maxsp
  957.         @status_window.refresh
  958.         @skill_window.refresh if @skill_window.visible     
  959.     end
  960.     def determine_skill
  961.         if @skill.for_friend?
  962.             show_target_window
  963.             if @skill.for_all?
  964.                 @target_window.select(99)
  965.             elsif @skill.for_user?
  966.                 @target_window.select(@actor_index + 100)
  967.             else
  968.                 if $game_party.last_target_index < @target_window.item_max
  969.                     @target_window.select($game_party.last_target_index)
  970.                 else @target_window.select(0)
  971.                 end
  972.             end
  973.         else use_skill_nontarget
  974.         end
  975.     end
  976.     def update_target_selection
  977.         target_cancel if Input.trigger?(Input::B)
  978.         target_select if Input.trigger?(Input::C)
  979.     end
  980.     def target_cancel
  981.         $game_system.se_play($data_system.cancel_se)
  982.         @skill_window.activate
  983.         hide_target_window
  984.     end
  985.     def target_select
  986.         if !@actor.skill_can_use?(@skill.id)
  987.             $game_system.se_play($data_system.buzzer_se)
  988.         else determine_target
  989.         end
  990.     end
  991.     def determine_target
  992.         used = false
  993.         if @skill.for_all?
  994.             $game_party.actors.each {|i| used |= i.skill_effect(@actor, @skill)}
  995.         elsif @skill.for_user?
  996.             target = $game_party.actors[@target_window.index - 100]
  997.             used = target.skill_effect(@actor, @skill)
  998.         else
  999.             $game_party.last_target_index = @target_window.index
  1000.             target = $game_party.actors[@target_window.index]
  1001.             used = target.skill_effect(@actor, @skill)
  1002.         end    
  1003.         used ? use_skill_nontarget : $game_system.se_play($data_system.buzzer_se)
  1004.     end
  1005.     def show_target_window
  1006.         @skill_window.deactivate
  1007.         @target_window.x = (@skill_window.index + 1) % 2 * 304
  1008.         @target_window.show.activate       
  1009.     end
  1010.     def hide_target_window
  1011.         @target_window.hide.deactivate
  1012.     end
  1013.     def use_skill_nontarget
  1014.         $game_system.se_play(@skill.menu_se)
  1015.         if $ace_script[:ace_warrior_module]
  1016.             @actor.pay_skill_cost(@skill)
  1017.         else @actor.sp -= @skill.sp_cost
  1018.         end
  1019.         @status_window.refresh
  1020.         @skill_window.refresh
  1021.         @target_window.refresh
  1022.         if $game_party.all_dead?
  1023.             return_scene(Scene_Gameover.new)
  1024.         elsif @skill.common_event_id > 0
  1025.             $game_temp.common_event_id = @skill.common_event_id
  1026.             return_scene(Scene_Map.new)        
  1027.         end
  1028.     end
  1029.     def update_help
  1030.         help_text = SKILL_DESCRIPTIONS[@category_window.method]
  1031.         @help_window.set_text(help_text) unless help_text.nil?
  1032.     end
  1033. end
  1034.  
  1035. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1036. # ■ Scene_Battle
  1037. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  1038. class Scene_Battle
  1039.     def start_skill_select
  1040.         @skill_window = Window_Skill.new(0, 64, 640, 256, @active_battler)
  1041.         @skill_window.help_window = @help_window
  1042.         @skill_window.back_opacity = 160
  1043.         @actor_command_window.deactivate.hide
  1044.     end
  1045. end
Advertisement
Add Comment
Please, Sign In to add comment