设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2518|回复: 6
打印 上一主题 下一主题

[已经解决] Ace怎样在人物升级时获得技能点学习技能

[复制链接]

Lv1.梦旅人

梦石
0
星屑
85
在线时间
83 小时
注册时间
2010-10-16
帖子
140
跳转到指定楼层
1
发表于 2014-6-8 20:59:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
最近遇到这个麻烦了,希望大神解决
具体问题:想在人物升级后获得若干技能点,这个技能点不能提升人物能力只能学习技能。也就是说想做出战斗后如果人物升级获得若干技能点,打开一个窗口分配技能点学习各种技能的效果。
类似勇者斗恶龙9升级加点系统。谢谢了!
[img]http://rpg.blue/static/image/smiley/default/victory.
回归中........

Lv3.寻梦者 (版主)

…あたしは天使なんかじゃないわ

梦石
0
星屑
2208
在线时间
4033 小时
注册时间
2010-10-4
帖子
10779

开拓者贵宾

2
发表于 2014-6-8 21:00:59 | 只看该作者
论坛搜索“技能树”,也许可以找到你想要的
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
85
在线时间
83 小时
注册时间
2010-10-16
帖子
140
3
 楼主| 发表于 2014-6-8 21:03:12 | 只看该作者
taroxd 发表于 2014-6-8 21:00
论坛搜索“技能树”,也许可以找到你想要的

首先先谢谢版主!但是目前ace有技能树系统吗?貌似没看到哎。。本人脚本盲。。
[img]http://rpg.blue/static/image/smiley/default/victory.
回归中........
回复 支持 反对

使用道具 举报

Lv4.逐梦者

运否天赋

梦石
10
星屑
5243
在线时间
3567 小时
注册时间
2014-5-15
帖子
1599

开拓者

4
发表于 2014-6-8 21:27:34 | 只看该作者
脚本版:传送门 这个需要再设个变量判断升级后所加的技能点
事件版:传送门  虽然是XP版的,但是可以参照这个用事件做
土猫三国开发完成
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
85
在线时间
83 小时
注册时间
2010-10-16
帖子
140
5
 楼主| 发表于 2014-6-8 22:32:17 | 只看该作者
喵kano 发表于 2014-6-8 21:27
脚本版:传送门 这个需要再设个变量判断升级后所加的技能点
事件版:传送门  虽然是XP版的,但是可以参照这 ...

这个是比较接近了。可是技能升级是将原有的技能升级成新的吧?从无到有怎么搞呢?

点评

或者最低级技能不可使用  发表于 2014-6-9 07:41
建议参考下第二个用事件做的  发表于 2014-6-8 22:33
[img]http://rpg.blue/static/image/smiley/default/victory.
回归中........
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
243
在线时间
341 小时
注册时间
2010-9-5
帖子
70
6
发表于 2014-6-9 09:46:38 | 只看该作者
绝命崖 发表于 2014-6-8 22:32
这个是比较接近了。可是技能升级是将原有的技能升级成新的吧?从无到有怎么搞呢? ...

从无到有可以利用这个技能学习系统,一共三个脚本,给你
RUBY 代码复制
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Ace Skill Menu v1.01
  4. # -- Last Updated: 2012.01.08
  5. # -- Level: Normal, Hard
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-SkillMenu"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.01.08 - Compatibility Update: Learn Skill Engine
  17. # 2012.01.02 - Started Script and Finished.
  18. #
  19. #==============================================================================
  20. # ▼ Introduction
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # This is a menu reordering script for the Skill Menu for RPG Maker VX Ace. The
  23. # script lets you add, remove, and rearrange skill menu additions added by
  24. # other scripts. This script will update periodically to provide better updated
  25. # compatibility with those other scripts.
  26. #
  27. #==============================================================================
  28. # ▼ Instructions
  29. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  30. # To install this script, open up your script editor and copy/paste this script
  31. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  32. #
  33. # Adjust the module's settings to adjust the skill command window.
  34. #
  35. #==============================================================================
  36. # ▼ Compatibility
  37. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  38. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  39. # it will run with RPG Maker VX without adjusting.
  40. #
  41. #==============================================================================
  42.  
  43. module YEA
  44.   module SKILL_MENU
  45.  
  46.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  47.     # - Command Window Settings -
  48.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  49.     # Adjust the command window that appears in the skill command window. Add,
  50.     # remove, or rearrange the commands as you see fit. If you would like to
  51.     # add in custom commands, please refer to the custom hash. Here's a list of
  52.     # what does what:
  53.     #
  54.     # -------------------------------------------------------------------------
  55.     # :command         Description
  56.     # -------------------------------------------------------------------------
  57.     # :stype_list      Displays all of the actor's usable skill types.
  58.     #
  59.     # :tp_mode         Requires YEA - TP Manager
  60.     # :learn_skill     Requires YEA - Learn Skill Engine
  61.     #
  62.     # :grathnode       Requires Kread-EX - Grathnode Install
  63.     # :sslots          Requires YSA - Slots Battle
  64.     #
  65.     # And that's all of the currently available commands. This list will be
  66.     # updated as more scripts become available.
  67.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  68.     COMMANDS =[
  69.       :stype_list,   # Displays all of the actor's usable skill types.
  70.       :learn_skill,  # Requires YEA - Learn Skill Engine
  71.       :tp_mode,      # Requires YEA - TP Manager
  72.       :grathnode,    # Requires Kread-EX - Grathnode Install
  73.       :sslots,       # Requires YSA - Slots Battle.
  74.     # :custom1,      # Custom Skill Command 1
  75.     # :custom2,      # Custom Skill Command 2
  76.     ] # Do not remove this.
  77.  
  78.     #--------------------------------------------------------------------------
  79.     # - Skill Custom Commands -
  80.     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  81.     # For those who use scripts to that may produce unique effects for
  82.     # equipping, use this hash to manage the custom commands for the Skill
  83.     # Command Window. You can disable certain commands or prevent them from
  84.     # appearing by using switches. If you don't wish to bind them to a switch,
  85.     # set the proper switch to 0 for it to have no impact.
  86.     #--------------------------------------------------------------------------
  87.     CUSTOM_SKILL_COMMANDS ={
  88.     # :command => ["Display Name", EnableSwitch, ShowSwitch, Handler Method],
  89.       :grathnode => ["Grathnodes",            0,          0, :command_grath],
  90.       :sslots  => [  "Pick Slots",            0,          0, :command_sslot],
  91.       :custom1 => [ "Custom Name",            0,          0, :command_name1],
  92.       :custom2 => [ "Custom Text",           13,          0, :command_name2],
  93.     } # Do not remove this.
  94.  
  95.   end # SKILL_MENU
  96. end # YEA
  97.  
  98. #==============================================================================
  99. # ▼ Editting anything past this point may potentially result in causing
  100. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  101. # halitosis so edit at your own risk.
  102. #==============================================================================
  103.  
  104. #==============================================================================
  105. # ■ Game_Temp
  106. #==============================================================================
  107.  
  108. class Game_Temp
  109.  
  110.   #--------------------------------------------------------------------------
  111.   # public instance variables
  112.   #--------------------------------------------------------------------------
  113.   attr_accessor :scene_skill_index
  114.   attr_accessor :scene_skill_oy
  115.  
  116. end # Game_Temp
  117.  
  118. #==============================================================================
  119. # ■ Window_SkillCommand
  120. #==============================================================================
  121.  
  122. class Window_SkillCommand < Window_Command
  123.  
  124.   #--------------------------------------------------------------------------
  125.   # alias method: make_command_list
  126.   #--------------------------------------------------------------------------
  127.   alias window_skillcommand_make_command_list_asm make_command_list
  128.   def make_command_list
  129.     unless SceneManager.scene_is?(Scene_Skill)
  130.       window_skillcommand_make_command_list_asm
  131.       return
  132.     end
  133.     return unless @actor
  134.     for command in YEA::SKILL_MENU::COMMANDS
  135.       case command
  136.       #--- Imported YEA ---
  137.       when :stype_list
  138.         add_skill_types
  139.       #--- Imported YEA ---
  140.       when :tp_mode
  141.         next unless $imported["YEA-TPManager"]
  142.         add_tp_modes
  143.       when :learn_skill
  144.         next unless $imported["YEA-LearnSkillEngine"]
  145.         add_learn_skill_command
  146.       #--- Imported Other ---
  147.       when :grathnode
  148.         next unless $imported["KRX-GrathnodeInstall"]
  149.         process_custom_command(command)
  150.       when :sslots
  151.         next unless $imported["YSA-SlotBattle"]
  152.         process_custom_command(command)
  153.       #--- Custom Commands ---
  154.       else
  155.         process_custom_command(command)
  156.       end
  157.     end
  158.   end
  159.  
  160.   #--------------------------------------------------------------------------
  161.   # new method: add_skill_types
  162.   #--------------------------------------------------------------------------
  163.   def add_skill_types
  164.     @actor.added_skill_types.each do |stype_id|
  165.       name = $data_system.skill_types[stype_id]
  166.       add_command(name, :skill, true, stype_id)
  167.     end
  168.   end
  169.  
  170.   #--------------------------------------------------------------------------
  171.   # new method: process_custom_command
  172.   #--------------------------------------------------------------------------
  173.   def process_custom_command(command)
  174.     return unless YEA::SKILL_MENU::CUSTOM_SKILL_COMMANDS.include?(command)
  175.     show = YEA::SKILL_MENU::CUSTOM_SKILL_COMMANDS[command][2]
  176.     continue = show <= 0 ? true : $game_switches[show]
  177.     return unless continue
  178.     text = YEA::SKILL_MENU::CUSTOM_SKILL_COMMANDS[command][0]
  179.     switch = YEA::SKILL_MENU::CUSTOM_SKILL_COMMANDS[command][1]
  180.     enabled = switch <= 0 ? true : $game_switches[switch]
  181.     add_command(text, command, enabled, @actor.added_skill_types[0])
  182.   end
  183.  
  184.   #--------------------------------------------------------------------------
  185.   # new method: process_ok
  186.   #--------------------------------------------------------------------------
  187.   def process_ok
  188.     if SceneManager.scene_is?(Scene_Skill)
  189.       $game_temp.scene_skill_index = index
  190.       $game_temp.scene_skill_oy = self.oy
  191.     end
  192.     super
  193.   end
  194.  
  195. end # Window_SkillCommand
  196.  
  197. #==============================================================================
  198. # ■ Scene_Skill
  199. #==============================================================================
  200.  
  201. class Scene_Skill < Scene_ItemBase
  202.  
  203.   #--------------------------------------------------------------------------
  204.   # alias method: create_command_window
  205.   #--------------------------------------------------------------------------
  206.   alias scene_skill_create_command_window_asm create_command_window
  207.   def create_command_window
  208.     scene_skill_create_command_window_asm
  209.     if !$game_temp.scene_skill_index.nil? && SceneManager.scene_is?(Scene_Skill)
  210.       @command_window.select($game_temp.scene_skill_index)
  211.       @command_window.oy = $game_temp.scene_skill_oy
  212.     end
  213.     $game_temp.scene_skill_index = nil
  214.     $game_temp.scene_skill_oy = nil
  215.     process_custom_skill_commands
  216.   end
  217.  
  218.   #--------------------------------------------------------------------------
  219.   # new method: process_custom_skill_commands
  220.   #--------------------------------------------------------------------------
  221.   def process_custom_skill_commands
  222.     for command in YEA::SKILL_MENU::COMMANDS
  223.       next unless YEA::SKILL_MENU::CUSTOM_SKILL_COMMANDS.include?(command)
  224.       called_method = YEA::SKILL_MENU::CUSTOM_SKILL_COMMANDS[command][3]
  225.       @command_window.set_handler(command, method(called_method))
  226.     end
  227.   end
  228.  
  229.   #--------------------------------------------------------------------------
  230.   # new method: command_grath
  231.   #--------------------------------------------------------------------------
  232.   def command_grath
  233.     SceneManager.call(Scene_Grathnode)
  234.   end
  235.  
  236.   #--------------------------------------------------------------------------
  237.   # new method: command_sslot
  238.   #--------------------------------------------------------------------------
  239.   def command_sslot
  240.     SceneManager.call(Scene_PickSlots)
  241.   end
  242.  
  243.   #--------------------------------------------------------------------------
  244.   # new method: command_name1
  245.   #--------------------------------------------------------------------------
  246.   def command_name1
  247.     # Do nothing.
  248.   end
  249.  
  250.   #--------------------------------------------------------------------------
  251.   # new method: command_name2
  252.   #--------------------------------------------------------------------------
  253.   def command_name2
  254.     # Do nothing.
  255.   end
  256.  
  257. end # Scene_Skill
  258.  
  259. #==============================================================================
  260. #
  261. # ▼ End of File
  262. #
  263. #==============================================================================

RUBY 代码复制
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Learn Skill Engine v1.00
  4. # -- Last Updated: 2012.01.08
  5. # -- Level: Normal, Hard
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-LearnSkillEngine"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.01.08 - Started Script and Finished.
  17. #
  18. #==============================================================================
  19. # ▼ Introduction
  20. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  21. # For those who want an alternative for actors to learn skills outside of
  22. # leveling, this script allows actors to learn skills through a learn skill
  23. # menu. The actor can use acquired JP, EXP, or Gold to learn skills. Skills can
  24. # also be hidden until certain requirements are met.
  25. #
  26. #==============================================================================
  27. # ▼ Instructions
  28. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  29. # To install this script, open up your script editor and copy/paste this script
  30. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  31. #
  32. # -----------------------------------------------------------------------------
  33. # Class Notetags - These notetags go in the class notebox in the database.
  34. # -----------------------------------------------------------------------------
  35. # <learn skills: x>
  36. # <learn skills: x, x>
  37. # Sets the class to be able to learn skills x through the Learn Skills menu.
  38. # Insert multiple of these tags to increase the number of skills learned.
  39. #
  40. # -----------------------------------------------------------------------------
  41. # Skill Notetags - These notetags go in the skill notebox in the database.
  42. # -----------------------------------------------------------------------------
  43. # <learn cost: x jp>
  44. # <learn cost: x exp>
  45. # <learn cost: x gold>
  46. # Sets the learn for cost the skill to require x amounts of JP, x amounts of
  47. # exp, or x amounts of gold. Only one type of cost can be used at a time. For
  48. # JP costs, the Yanfly Engine Ace - JP Manager script must be installed.
  49. #
  50. # <learn require level: x>
  51. # Sets the skill to require the actor's current level to be x before the skill
  52. # will show up in the skill learning window.
  53. #
  54. # <learn require skill: x>
  55. # <learn require skill: x, x>
  56. # Sets the skill to require learning skill x (through any means) before the
  57. # skill becomes visible in the skill learning window. Insert multiples of these
  58. # tags to require more skills to be learned in order for the skill to show.
  59. #
  60. # <learn require switch: x>
  61. # <learn require switch: x, x>
  62. # Sets the skill to require switch x to be ON in order for it to show in the
  63. # skill learning window. Insert multiple switches to to increase the number of
  64. # switches needed to be ON before the skill is shown.
  65. #
  66. # <learn require eval>
  67. #  string
  68. #  string
  69. # </learn require eval>
  70. # For the more advanced users, replace string with lines of code to check for
  71. # whether or not the skill will be shown in skill learning window. If multiple
  72. # lines are used, they are all considered part of the same line.
  73. #
  74. #==============================================================================
  75. # ▼ Compatibility
  76. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  77. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  78. # it will run with RPG Maker VX without adjusting.
  79. #
  80. # This script is compatible with Yanfly Engine Ace - JP Manager v1.00+. The
  81. # placement of this script relative to the JP Manager script doesn't matter.
  82. #
  83. #==============================================================================
  84.  
  85. module YEA
  86.   module LEARN_SKILL
  87.  
  88.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  89.     # - General Settings -
  90.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  91.     # Adjust the general settings here for your game. These adjust how the
  92.     # command name appears, a switch to show the Learn Command
  93.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  94.     COMMAND_NAME = "学习技能"    # Name used for Learn Skill command.
  95.  
  96.     # This switch will hide the "Learn" command from view if the switch is OFF.
  97.     # The "Learn" command will be shown if the switch is ON. Set this switch to
  98.     # 0 to not use this effect and to always have the Learn command be shown.
  99.     SHOW_SWITCH   = 0
  100.  
  101.     # This adjusts the order the Skill Types appear in for the command window.
  102.     # Any Skill Types unlisted will not be shown.
  103.     STYPE_ORDER = [41..999, 1..40]
  104.  
  105.     # For those who installed Yanfly Engine - Skill Restrictions, you can
  106.     # choose to display warmups or cooldowns inside of the menu here.
  107.     DRAW_WARMUP   = true        # Draw warmups for skills?
  108.     DRAW_COOLDOWN = true        # Draw cooldowns for skills?
  109.  
  110.     #-------------------------------------------------------------------------
  111.     # - Default Cost -
  112.     #-------------------------------------------------------------------------
  113.     # This sets the default costs for all skills. If the JP script isn't
  114.     # installed, the type will become :exp instead.
  115.     #
  116.     # Cost Type       Description
  117.     #  :jp            - Requires YEA - JP Manager.
  118.     #  :exp           - Makes skill cost EXP.
  119.     #  :gold          - Makes skill cost gold.
  120.     #-------------------------------------------------------------------------
  121.     DEFAULT_COST = 100          # Sets the default cost of a skill.
  122.     DEFAULT_TYPE = :jp          # Sets the default cost type.
  123.  
  124.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  125.     # - Learn Window Settings -
  126.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  127.     # These settings adjust the Learn Window's visual appearance. Adjust the
  128.     # way empty text appears, EXP cost suffixes appear, Learned text appears,
  129.     # font sizes, and cost colours here.
  130.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  131.     EMPTY_TEXT     = "-"        # Text if no restricts used for the skill.
  132.     EXP_TEXT       = "EXP"      # Text used for EXP costs.
  133.     LEARNED_TEXT   = "领悟"  # Text to indicate skill has been learned.
  134.     LEARNED_SIZE   = 20         # Font size used for learned skill text.
  135.     COLOUR_JP      = 24         # Text colour used for JP Cost.
  136.     COLOUR_EXP     =  5         # Text colour used for EXP Cost.
  137.     COLOUR_GOLD    = 21         # Text colour used for Gold Cost.
  138.     COST_SIZE      = 20         # Font size used for skill costs.
  139.  
  140.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  141.     # - Cost Window Settings -
  142.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  143.     # When a skill is selected to be learned, the cost window appears. Adjust
  144.     # the settings here to choose how your game's cost window looks. Change the
  145.     # maximum number of rows, the gold icon used for gold costs, the gold text,
  146.     # the learn skill text, the cancel text, and the cancel icon here.
  147.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  148.     MAXIMUM_ROWS      = 8               # Maximum number of rows displayed.
  149.     GOLD_ICON         = 361             # Icon used for gold costs.
  150.     GOLD_TEXT         = "金币"     # Text used for gold costs.
  151.     LEARN_SKILL_TEXT  = "学习 %s?"     # Text used to learn skill.
  152.     LEARN_CANCEL_TEXT = "放弃"        # Text used for do not learn.
  153.     CANCEL_ICON       = 187             # Icon used for cancel.
  154.  
  155.   end # LEARN_SKILL
  156. end # YEA
  157.  
  158. #==============================================================================
  159. # ▼ Editting anything past this point may potentially result in causing
  160. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  161. # halitosis so edit at your own risk.
  162. #==============================================================================
  163.  
  164. module YEA
  165.   module LEARN_SKILL
  166.     module_function
  167.     #--------------------------------------------------------------------------
  168.     # convert_integer_array
  169.     #--------------------------------------------------------------------------
  170.     def convert_integer_array(array)
  171.       result = []
  172.       array.each { |i|
  173.         case i
  174.         when Range; result |= i.to_a
  175.         when Integer; result |= [i]
  176.         end }
  177.       return result
  178.     end
  179.     #--------------------------------------------------------------------------
  180.     # converted_contants
  181.     #--------------------------------------------------------------------------
  182.     STYPE_ORDER = convert_integer_array(STYPE_ORDER)
  183.   end # LEARN_SKILL
  184.   module REGEXP
  185.   module CLASS
  186.  
  187.     LEARN_SKILLS = /<(?:LEARN_SKILLS|learn skills):[ ](\d+(?:\s*,\s*\d+)*)>/i
  188.  
  189.   end # CLASS
  190.   module SKILL
  191.  
  192.     LEARN_COST = /<(?:LEARN_COST|learn cost):[ ](.*)>/i
  193.     LEARN_REQUIRE_LEVEL =
  194.       /<(?:LEARN_REQUIRE_LEVEL|learn require level):[ ](\d+)>/i
  195.     LEARN_REQUIRE_SKILL =
  196.       /<(?:LEARN_REQUIRE_SKILL|learn require skill):[ ](\d+(?:\s*,\s*\d+)*)>/i
  197.     LEARN_REQUIRE_SWITCH =
  198.       /<(?:LEARN_REQUIRE_SWITCH|learn require switch):[ ](\d+(?:\s*,\s*\d+)*)>/i
  199.     LEARN_REQUIRE_EVAL_ON  = /<(?:LEARN_REQUIRE_EVAL|learn require eval)>/i
  200.     LEARN_REQUIRE_EVAL_OFF = /<\/(?:LEARN_REQUIRE_EVAL|learn require eval)>/i
  201.  
  202.   end # SKILL
  203.   end # REGEXP
  204. end # YEA
  205.  
  206. #==============================================================================
  207. # ■ Numeric
  208. #==============================================================================
  209.  
  210. class Numeric
  211.  
  212.   #--------------------------------------------------------------------------
  213.   # new method: group_digits
  214.   #--------------------------------------------------------------------------
  215.   unless $imported["YEA-CoreEngine"]
  216.   def group; return self.to_s; end
  217.   end # $imported["YEA-CoreEngine"]
  218.  
  219. end # Numeric
  220.  
  221. #==============================================================================
  222. # ■ Icon
  223. #==============================================================================
  224.  
  225. module Icon
  226.  
  227.   #--------------------------------------------------------------------------
  228.   # self.cancel
  229.   #--------------------------------------------------------------------------
  230.   def self.cancel
  231.     return YEA::LEARN_SKILL::CANCEL_ICON
  232.   end
  233.  
  234.   #--------------------------------------------------------------------------
  235.   # self.learn_skill_gold
  236.   #--------------------------------------------------------------------------
  237.   def self.learn_skill_gold
  238.     return YEA::LEARN_SKILL::GOLD_ICON
  239.   end
  240.  
  241. end # Icon
  242.  
  243. #==============================================================================
  244. # ■ Switch
  245. #==============================================================================
  246.  
  247. module Switch
  248.  
  249.   #--------------------------------------------------------------------------
  250.   # self.show_learn_skill
  251.   #--------------------------------------------------------------------------
  252.   def self.show_learn_skill
  253.     return true if YEA::LEARN_SKILL::SHOW_SWITCH <= 0
  254.     return $game_switches[YEA::LEARN_SKILL::SHOW_SWITCH]
  255.   end
  256.  
  257. end # Switch
  258.  
  259. #==============================================================================
  260. # ■ DataManager
  261. #==============================================================================
  262.  
  263. module DataManager
  264.  
  265.   #--------------------------------------------------------------------------
  266.   # alias method: load_database
  267.   #--------------------------------------------------------------------------
  268.   class <<self; alias load_database_lse load_database; end
  269.   def self.load_database
  270.     load_database_lse
  271.     load_notetags_lse
  272.   end
  273.  
  274.   #--------------------------------------------------------------------------
  275.   # new method: load_notetags_lse
  276.   #--------------------------------------------------------------------------
  277.   def self.load_notetags_lse
  278.     groups = [$data_classes, $data_skills]
  279.     for group in groups
  280.       for obj in group
  281.         next if obj.nil?
  282.         obj.load_notetags_lse
  283.       end
  284.     end
  285.   end
  286.  
  287. end # DataManager
  288.  
  289. #==============================================================================
  290. # ■ RPG::Class
  291. #==============================================================================
  292.  
  293. class RPG::Class < RPG::BaseItem
  294.  
  295.   #--------------------------------------------------------------------------
  296.   # public instance variables
  297.   #--------------------------------------------------------------------------
  298.   attr_accessor :learn_skills
  299.  
  300.   #--------------------------------------------------------------------------
  301.   # common cache: load_notetags_lse
  302.   #--------------------------------------------------------------------------
  303.   def load_notetags_lse
  304.     @learn_skills = []
  305.     #---
  306.     self.note.split(/[\r\n]+/).each { |line|
  307.       case line
  308.       #---
  309.       when YEA::REGEXP::CLASS::LEARN_SKILLS
  310.         $1.scan(/\d+/).each { |num|
  311.         @learn_skills.push(num.to_i) if num.to_i > 0 }
  312.       end
  313.     } # self.note.split
  314.     #---
  315.   end
  316.  
  317. end # RPG::Class
  318.  
  319. #==============================================================================
  320. # ■ RPG::Skill
  321. #==============================================================================
  322.  
  323. class RPG::Skill < RPG::UsableItem
  324.  
  325.   #--------------------------------------------------------------------------
  326.   # public instance variables
  327.   #--------------------------------------------------------------------------
  328.   attr_accessor :learn_cost
  329.   attr_accessor :learn_require_level
  330.   attr_accessor :learn_require_skill
  331.   attr_accessor :learn_require_switch
  332.   attr_accessor :learn_require_eval
  333.  
  334.   #--------------------------------------------------------------------------
  335.   # common cache: load_notetags_lse
  336.   #--------------------------------------------------------------------------
  337.   def load_notetags_lse
  338.     @learn_cost = [YEA::LEARN_SKILL::DEFAULT_COST]
  339.     @learn_cost.push(YEA::LEARN_SKILL::DEFAULT_TYPE)
  340.     @learn_require_level = 0
  341.     @learn_require_skill = []
  342.     @learn_require_switch = []
  343.     @learn_require_eval_on = false
  344.     #---
  345.     self.note.split(/[\r\n]+/).each { |line|
  346.       case line
  347.       #---
  348.       when YEA::REGEXP::SKILL::LEARN_COST
  349.         case $1.upcase
  350.         when /(\d+)[ ]JP/i
  351.           next unless $imported["YEA-JPManager"]
  352.           @learn_cost = [$1.to_i, :jp]
  353.         when /(\d+)[ ]EXP/i
  354.           @learn_cost = [$1.to_i, :exp]
  355.         when /(\d+)[ ]GOLD/i
  356.           @learn_cost = [$1.to_i, :gold]
  357.         end
  358.       #---
  359.       when YEA::REGEXP::SKILL::LEARN_REQUIRE_LEVEL
  360.         @learn_require_level = $1.to_i
  361.       when YEA::REGEXP::SKILL::LEARN_REQUIRE_SKILL
  362.         $1.scan(/\d+/).each { |num|
  363.         @learn_require_skill.push(num.to_i) if num.to_i > 0 }
  364.       when YEA::REGEXP::SKILL::LEARN_REQUIRE_SWITCH
  365.         $1.scan(/\d+/).each { |num|
  366.         @learn_require_switch.push(num.to_i) if num.to_i > 0 }
  367.       #---
  368.       when YEA::REGEXP::SKILL::LEARN_REQUIRE_EVAL_ON
  369.         @learn_require_eval_on = true
  370.       when YEA::REGEXP::SKILL::LEARN_REQUIRE_EVAL_OFF
  371.         @learn_require_eval_on = false
  372.       else
  373.         next unless @learn_require_eval_on
  374.         @learn_require_eval = "" if @learn_require_eval.nil?
  375.         @learn_require_eval += line.to_s
  376.       #---
  377.       end
  378.     } # self.note.split
  379.     #---
  380.     if !$imported["YEA-JPManager"] && @learn_cost[1] == :jp
  381.       @learn_cost[1] = :exp
  382.     end
  383.   end
  384.  
  385. end # RPG::Skill
  386.  
  387. #==============================================================================
  388. # ■ Game_Actor
  389. #==============================================================================
  390.  
  391. class Game_Actor < Game_Battler
  392.  
  393.   #--------------------------------------------------------------------------
  394.   # alias method: skills
  395.   #--------------------------------------------------------------------------
  396.   alias game_actor_skills_lse skills
  397.   def skills
  398.     btest_add_learn_skills
  399.     game_actor_skills_lse
  400.   end
  401.  
  402.   #--------------------------------------------------------------------------
  403.   # new method: btest_add_learn_skills
  404.   #--------------------------------------------------------------------------
  405.   def btest_add_learn_skills
  406.     return unless $BTEST
  407.     for skill_id in self.class.learn_skills; learn_skill(skill_id); end
  408.   end
  409.  
  410.   #--------------------------------------------------------------------------
  411.   # new method: exp_class
  412.   #--------------------------------------------------------------------------
  413.   def exp_class(class_id)
  414.     @exp[class_id] = 0 if @exp[class_id].nil?
  415.     return @exp[class_id]
  416.   end
  417.  
  418.   #--------------------------------------------------------------------------
  419.   # lose_exp_class
  420.   #--------------------------------------------------------------------------
  421.   def lose_exp_class(value, class_id)
  422.     exp = exp_class(class_id) - value
  423.     change_exp_class(exp, class_id)
  424.   end
  425.  
  426.   #--------------------------------------------------------------------------
  427.   # change_exp_class
  428.   #--------------------------------------------------------------------------
  429.   def change_exp_class(exp, class_id)
  430.     return change_exp(exp, false) if class_id == @class_id
  431.     @exp[class_id] = [exp, 0].max
  432.   end
  433.  
  434. end # Game_Actor
  435.  
  436. #==============================================================================
  437. # ■ Window_SkillCommand
  438. #==============================================================================
  439.  
  440. class Window_SkillCommand < Window_Command
  441.  
  442.   #--------------------------------------------------------------------------
  443.   # alias method: make_command_list
  444.   #--------------------------------------------------------------------------
  445.   alias window_skillcommand_make_command_list_lse make_command_list
  446.   def make_command_list
  447.     window_skillcommand_make_command_list_lse
  448.     return if @actor.nil?
  449.     add_learn_skill_command unless $imported["YEA-SkillMenu"]
  450.   end
  451.  
  452.   #--------------------------------------------------------------------------
  453.   # new method: add_learn_skill_command
  454.   #--------------------------------------------------------------------------
  455.   def add_learn_skill_command
  456.     return unless Switch.show_learn_skill
  457.     name = YEA::LEARN_SKILL::COMMAND_NAME
  458.     add_command(name, :learn_skill, true, @actor.added_skill_types[0])
  459.   end
  460.  
  461. end # Window_SkillCommand
  462.  
  463. #==============================================================================
  464. # ■ Window_LearnSkillCommand
  465. #==============================================================================
  466.  
  467. class Window_LearnSkillCommand < Window_Command
  468.  
  469.   #--------------------------------------------------------------------------
  470.   # public instance variables
  471.   #--------------------------------------------------------------------------
  472.   attr_reader   :skill_window
  473.  
  474.   #--------------------------------------------------------------------------
  475.   # initialize
  476.   #--------------------------------------------------------------------------
  477.   def initialize(dx, dy)
  478.     super(dx, dy)
  479.     @actor = nil
  480.   end
  481.  
  482.   #--------------------------------------------------------------------------
  483.   # window_width
  484.   #--------------------------------------------------------------------------
  485.   def window_width; return 160; end
  486.  
  487.   #--------------------------------------------------------------------------
  488.   # visible_line_number
  489.   #--------------------------------------------------------------------------
  490.   def visible_line_number; return 4; end
  491.  
  492.   #--------------------------------------------------------------------------
  493.   # actor=
  494.   #--------------------------------------------------------------------------
  495.   def actor=(actor)
  496.     return if @actor == actor
  497.     @actor = actor
  498.     refresh
  499.     select(item_max - 1) if index >= item_max
  500.   end
  501.  
  502.   #--------------------------------------------------------------------------
  503.   # make_command_list
  504.   #--------------------------------------------------------------------------
  505.   def make_command_list
  506.     return if @actor.nil?
  507.     make_unlocked_class_skill_types
  508.     correct_unlocked_class_learned_skills
  509.     for stype_id in YEA::LEARN_SKILL::STYPE_ORDER
  510.       next unless include?(stype_id)
  511.       name = $data_system.skill_types[stype_id]
  512.       add_command(name, :skill, true, stype_id)
  513.     end
  514.   end
  515.  
  516.   #--------------------------------------------------------------------------
  517.   # make_unlocked_class_skill_types
  518.   #--------------------------------------------------------------------------
  519.   def make_unlocked_class_skill_types
  520.     return unless $imported["YEA-ClassSystem"]
  521.     @unlocked_types = []
  522.     unlocked_classes = @actor.unlocked_classes.clone
  523.     unlocked_classes |= YEA::CLASS_SYSTEM::DEFAULT_UNLOCKS
  524.     for class_id in unlocked_classes
  525.       next if $data_classes[class_id].nil?
  526.       for feature in $data_classes[class_id].features
  527.         next unless feature.code == 41
  528.         @unlocked_types.push(feature.data_id)
  529.       end
  530.     end
  531.   end
  532.  
  533.   #--------------------------------------------------------------------------
  534.   # correct_unlocked_class_learned_skills
  535.   #--------------------------------------------------------------------------
  536.   def correct_unlocked_class_learned_skills
  537.     return unless $imported["YEA-ClassSystem"]
  538.     unlocked_classes = @actor.unlocked_classes.clone
  539.     unlocked_classes |= YEA::CLASS_SYSTEM::DEFAULT_UNLOCKS
  540.     for class_id in unlocked_classes
  541.       @actor.learn_class_skills(class_id)
  542.     end
  543.   end
  544.  
  545.   #--------------------------------------------------------------------------
  546.   # include?
  547.   #--------------------------------------------------------------------------
  548.   def include?(stype_id)
  549.     return true if @actor.added_skill_types.include?(stype_id)
  550.     if $imported["YEA-ClassSystem"]
  551.       return true if @unlocked_types.include?(stype_id)
  552.     end
  553.     return false
  554.   end
  555.  
  556.   #--------------------------------------------------------------------------
  557.   # update
  558.   #--------------------------------------------------------------------------
  559.   def update
  560.     super
  561.     @skill_window.stype_id = current_ext if @skill_window
  562.   end
  563.  
  564.   #--------------------------------------------------------------------------
  565.   # skill_window=
  566.   #--------------------------------------------------------------------------
  567.   def skill_window=(skill_window)
  568.     @skill_window = skill_window
  569.     update
  570.   end
  571.  
  572. end # Window_LearnSkillCommand
  573.  
  574. #==============================================================================
  575. # ■ Window_LearnSkillList
  576. #==============================================================================
  577.  
  578. class Window_LearnSkillList < Window_SkillList
  579.  
  580.   #--------------------------------------------------------------------------
  581.   # col_max
  582.   #--------------------------------------------------------------------------
  583.   def col_max; return 1; end
  584.  
  585.   #--------------------------------------------------------------------------
  586.   # select_last
  587.   #--------------------------------------------------------------------------
  588.   def select_last; select(0); end
  589.  
  590.   #--------------------------------------------------------------------------
  591.   # actor=
  592.   #--------------------------------------------------------------------------
  593.   def actor=(actor)
  594.     return if @actor == actor
  595.     super(actor)
  596.     make_learn_skills_list
  597.   end
  598.  
  599.   #--------------------------------------------------------------------------
  600.   # make_learn_skills_list
  601.   #--------------------------------------------------------------------------
  602.   def make_learn_skills_list
  603.     @learn_skills = []
  604.     @skill_classes = {}
  605.     return if @actor.nil?
  606.     for skill_id in @actor.class.learn_skills
  607.       next if $data_skills[skill_id].nil?
  608.       next if @learn_skills.include?($data_skills[skill_id])
  609.       skill = $data_skills[skill_id]
  610.       @learn_skills.push(skill)
  611.       @skill_classes[skill] = [] if @skill_classes[skill].nil?
  612.       @skill_classes[skill].push(@actor.class.id)
  613.     end
  614.     make_unlocked_class_skills
  615.   end
  616.  
  617.   #--------------------------------------------------------------------------
  618.   # make_unlocked_class_skills
  619.   #--------------------------------------------------------------------------
  620.   def make_unlocked_class_skills
  621.     return unless $imported["YEA-ClassSystem"]
  622.     @unlocked_types = []
  623.     unlocked_classes = @actor.unlocked_classes.clone
  624.     unlocked_classes |= YEA::CLASS_SYSTEM::DEFAULT_UNLOCKS
  625.     for class_id in unlocked_classes
  626.       next if $data_classes[class_id].nil?
  627.       for skill_id in $data_classes[class_id].learn_skills
  628.         next if $data_skills[skill_id].nil?
  629.         skill = $data_skills[skill_id]
  630.         @learn_skills.push(skill) unless @learn_skills.include?(skill)
  631.         @skill_classes[skill] = [] if @skill_classes[skill].nil?
  632.         @skill_classes[skill] |= [class_id]
  633.       end
  634.     end
  635.   end
  636.  
  637.   #--------------------------------------------------------------------------
  638.   # skill_classes
  639.   #--------------------------------------------------------------------------
  640.   def skill_classes(skill)
  641.     return @skill_classes[skill]
  642.   end
  643.  
  644.   #--------------------------------------------------------------------------
  645.   # make_item_list
  646.   #--------------------------------------------------------------------------
  647.   def make_item_list
  648.     return if @learn_skills.nil?
  649.     @data = @learn_skills.select {|skill| include?(skill) }
  650.   end
  651.  
  652.   #--------------------------------------------------------------------------
  653.   # include?
  654.   #--------------------------------------------------------------------------
  655.   def include?(item)
  656.     return false if item.nil?
  657.     return false unless meet_requirements?(item)
  658.     return item.stype_id == @stype_id
  659.   end
  660.  
  661.   #--------------------------------------------------------------------------
  662.   # meet_requirements?
  663.   #--------------------------------------------------------------------------
  664.   def meet_requirements?(item)
  665.     return false if @actor.nil?
  666.     return false unless meet_level_requirements?(item)
  667.     return false unless meet_skill_requirements?(item)
  668.     return false unless meet_switch_requirements?(item)
  669.     return false unless meet_eval_requirements?(item)
  670.     return true
  671.   end
  672.  
  673.   #--------------------------------------------------------------------------
  674.   # meet_level_requirements?
  675.   #--------------------------------------------------------------------------
  676.   def meet_level_requirements?(item)
  677.     return @actor.level >= item.learn_require_level
  678.   end
  679.  
  680.   #--------------------------------------------------------------------------
  681.   # meet_skill_requirements?
  682.   #--------------------------------------------------------------------------
  683.   def meet_skill_requirements?(item)
  684.     for skill_id in item.learn_require_skill
  685.       next if $data_skills[skill_id].nil?
  686.       return false unless @actor.skill_learn?($data_skills[skill_id])
  687.     end
  688.     return true
  689.   end
  690.  
  691.   #--------------------------------------------------------------------------
  692.   # meet_switch_requirements?
  693.   #--------------------------------------------------------------------------
  694.   def meet_switch_requirements?(item)
  695.     for switch_id in item.learn_require_switch
  696.       return false unless $game_switches[switch_id]
  697.     end
  698.     return true
  699.   end
  700.  
  701.   #--------------------------------------------------------------------------
  702.   # meet_eval_requirements?
  703.   #--------------------------------------------------------------------------
  704.   def meet_eval_requirements?(item)
  705.     return true if item.learn_require_eval.nil?
  706.     return eval(item.learn_require_eval)
  707.   end
  708.  
  709.   #--------------------------------------------------------------------------
  710.   # enable?
  711.   #--------------------------------------------------------------------------
  712.   def enable?(skill)
  713.     return false if skill.nil?
  714.     return false unless enabled_jp?(skill)
  715.     return false unless enabled_exp?(skill)
  716.     return false unless enabled_gold?(skill)
  717.     return !@actor.skill_learn?(skill)
  718.   end
  719.  
  720.   #--------------------------------------------------------------------------
  721.   # enabled_jp?
  722.   #--------------------------------------------------------------------------
  723.   def enabled_jp?(skill)
  724.     return true if skill.learn_cost[1] != :jp
  725.     cost = skill.learn_cost[0]
  726.     for class_id in @skill_classes[skill]
  727.       return true if @actor.jp(class_id) >= cost
  728.     end
  729.     return false
  730.   end
  731.  
  732.   #--------------------------------------------------------------------------
  733.   # enabled_exp?
  734.   #--------------------------------------------------------------------------
  735.   def enabled_exp?(skill)
  736.     return true if skill.learn_cost[1] != :exp
  737.     cost = skill.learn_cost[0]
  738.     for class_id in @skill_classes[skill]
  739.       return true if @actor.exp_class(class_id) >= cost
  740.     end
  741.     return false
  742.   end
  743.  
  744.   #--------------------------------------------------------------------------
  745.   # enabled_gold?
  746.   #--------------------------------------------------------------------------
  747.   def enabled_gold?(skill)
  748.     return true if skill.learn_cost[1] != :gold
  749.     cost = skill.learn_cost[0]
  750.     return $game_party.gold >= cost
  751.   end
  752.  
  753.   #--------------------------------------------------------------------------
  754.   # draw_item
  755.   #--------------------------------------------------------------------------
  756.   def draw_item(index)
  757.     skill = @data[index]
  758.     return if skill.nil?
  759.     rect = item_rect(index)
  760.     rect.width = (contents.width - spacing) / 2 - 4
  761.     draw_item_name(skill, rect.x, rect.y, enable?(skill), rect.width - 24)
  762.     draw_skill_cost(rect, skill)
  763.     draw_restriction_info(skill, index)
  764.     draw_learn_cost(skill, index)
  765.   end
  766.  
  767.   #--------------------------------------------------------------------------
  768.   # skill_restriction?
  769.   #--------------------------------------------------------------------------
  770.   def skill_restriction?(index)
  771.     return false
  772.   end
  773.  
  774.   #--------------------------------------------------------------------------
  775.   # draw_restriction_info
  776.   #--------------------------------------------------------------------------
  777.   def draw_restriction_info(skill, index)
  778.     return unless $imported["YEA-SkillRestrictions"]
  779.     rect = item_rect(index)
  780.     rect.x = contents.width / 2
  781.     rect.width /= 2
  782.     rect.width /= 3
  783.     rect.width -= 8
  784.     draw_skill_warmup(skill, rect)
  785.     rect.x += rect.width + 4
  786.     draw_skill_cooldown(skill, rect)
  787.   end
  788.  
  789.   #--------------------------------------------------------------------------
  790.   # draw_skill_warmup
  791.   #--------------------------------------------------------------------------
  792.   def draw_skill_warmup(skill, rect)
  793.     return unless YEA::LEARN_SKILL::DRAW_WARMUP
  794.     enabled = enable?(skill)
  795.     enabled = false if skill.warmup <= 0
  796.     change_color(warmup_colour, enabled)
  797.     icon = Icon.warmup
  798.     if icon > 0
  799.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  800.       rect.width -= 24
  801.     end
  802.     contents.font.size = YEA::SKILL_RESTRICT::WARMUP_SIZE
  803.     value = skill.warmup > 0 ? skill.warmup.group : empty_text
  804.     text = sprintf(YEA::SKILL_RESTRICT::WARMUP_SUFFIX, value)
  805.     draw_text(rect, text, 2)
  806.     reset_font_settings
  807.   end
  808.  
  809.   #--------------------------------------------------------------------------
  810.   # draw_skill_cooldown
  811.   #--------------------------------------------------------------------------
  812.   def draw_skill_cooldown(skill, rect)
  813.     return unless YEA::LEARN_SKILL::DRAW_COOLDOWN
  814.     enabled = enable?(skill)
  815.     enabled = false if skill.cooldown <= 0
  816.     change_color(cooldown_colour, enabled)
  817.     icon = Icon.cooldown
  818.     if icon > 0
  819.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  820.       rect.width -= 24
  821.     end
  822.     contents.font.size = YEA::SKILL_RESTRICT::COOLDOWN_SIZE
  823.     value = skill.cooldown > 0 ? skill.cooldown.group : empty_text
  824.     text = sprintf(YEA::SKILL_RESTRICT::COOLDOWN_SUFFIX, value)
  825.     draw_text(rect, text, 2)
  826.     reset_font_settings
  827.   end
  828.  
  829.   #--------------------------------------------------------------------------
  830.   # empty_text
  831.   #--------------------------------------------------------------------------
  832.   def empty_text
  833.     return YEA::LEARN_SKILL::EMPTY_TEXT
  834.   end
  835.  
  836.   #--------------------------------------------------------------------------
  837.   # draw_learn_cost
  838.   #--------------------------------------------------------------------------
  839.   def draw_learn_cost(skill, index)
  840.     rect = item_rect(index)
  841.     rect.width -= 4
  842.     if @actor.skill_learn?(skill)
  843.       draw_learned_skill(rect)
  844.     else
  845.       draw_learn_skill_cost(skill, rect)
  846.     end
  847.     reset_font_settings
  848.   end
  849.  
  850.   #--------------------------------------------------------------------------
  851.   # draw_learned_skill
  852.   #--------------------------------------------------------------------------
  853.   def draw_learned_skill(rect)
  854.     contents.font.size = YEA::LEARN_SKILL::LEARNED_SIZE
  855.     change_color(normal_color)
  856.     draw_text(rect, YEA::LEARN_SKILL::LEARNED_TEXT, 2)
  857.   end
  858.  
  859.   #--------------------------------------------------------------------------
  860.   # draw_learn_skill_cost
  861.   #--------------------------------------------------------------------------
  862.   def draw_learn_skill_cost(skill, rect)
  863.     case skill.learn_cost[1]
  864.     when :jp
  865.       return unless $imported["YEA-JPManager"]
  866.       draw_jp_cost(skill, rect)
  867.     when :exp
  868.       draw_exp_cost(skill, rect)
  869.     when :gold
  870.       draw_gold_cost(skill, rect)
  871.     else; return
  872.     end
  873.   end
  874.  
  875.   #--------------------------------------------------------------------------
  876.   # draw_jp_cost
  877.   #--------------------------------------------------------------------------
  878.   def draw_jp_cost(skill, rect)
  879.     enabled = enabled_jp?(skill)
  880.     if Icon.jp > 0
  881.       draw_icon(Icon.jp, rect.x + rect.width - 24, rect.y, enabled)
  882.       rect.width -= 24
  883.     end
  884.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  885.     change_color(system_color, enabled)
  886.     draw_text(rect, Vocab::jp, 2)
  887.     rect.width -= text_size(Vocab::jp).width
  888.     cost = skill.learn_cost[0]
  889.     text = cost.group
  890.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_JP), enabled)
  891.     draw_text(rect, text, 2)
  892.   end
  893.  
  894.   #--------------------------------------------------------------------------
  895.   # draw_exp_cost
  896.   #--------------------------------------------------------------------------
  897.   def draw_exp_cost(skill, rect)
  898.     enabled = enabled_exp?(skill)
  899.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  900.     change_color(system_color, enabled)
  901.     draw_text(rect, YEA::LEARN_SKILL::EXP_TEXT, 2)
  902.     rect.width -= text_size(YEA::LEARN_SKILL::EXP_TEXT).width
  903.     cost = skill.learn_cost[0]
  904.     text = cost.group
  905.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_EXP), enabled)
  906.     draw_text(rect, text, 2)
  907.   end
  908.  
  909.   #--------------------------------------------------------------------------
  910.   # draw_gold_cost
  911.   #--------------------------------------------------------------------------
  912.   def draw_gold_cost(skill, rect)
  913.     enabled = enabled_jp?(skill)
  914.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  915.     change_color(system_color, enabled)
  916.     draw_text(rect, Vocab::currency_unit, 2)
  917.     rect.width -= text_size(Vocab::currency_unit).width
  918.     cost = skill.learn_cost[0]
  919.     text = cost.group
  920.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_GOLD), enabled)
  921.     draw_text(rect, text, 2)
  922.   end
  923.  
  924. end # Window_LearnSkillList
  925.  
  926. #==============================================================================
  927. # ■ Window_LearnSkillCostBack
  928. #==============================================================================
  929.  
  930. class Window_LearnSkillCostBack < Window_Base
  931.  
  932.   #--------------------------------------------------------------------------
  933.   # initialize
  934.   #--------------------------------------------------------------------------
  935.   def initialize(item_window)
  936.     dw = Graphics.width * 3 / 4
  937.     dx = (Graphics.width - dw) / 2
  938.     super(dx, 0, dw, fitting_height(2))
  939.     self.openness = 0
  940.     self.back_opacity = 255
  941.     @front_window = nil
  942.     @item_window = item_window
  943.     [url=home.php?mod=space&uid=260100]@skill[/url] = nil
  944.   end
  945.  
  946.   #--------------------------------------------------------------------------
  947.   # reveal
  948.   #--------------------------------------------------------------------------
  949.   def reveal(skill, skill_classes)
  950.     @skill = skill
  951.     return if @skill.nil?
  952.     case @skill.learn_cost[1]
  953.     when :gold
  954.       self.height = fitting_height(3)
  955.     else
  956.       maximum = [skill_classes.size, YEA::LEARN_SKILL::MAXIMUM_ROWS].min
  957.       self.height = fitting_height(maximum + 2)
  958.     end
  959.     create_contents
  960.     self.y = (Graphics.height - self.height) / 2
  961.     refresh
  962.     open
  963.   end
  964.  
  965.   #--------------------------------------------------------------------------
  966.   # refresh
  967.   #--------------------------------------------------------------------------
  968.   def refresh
  969.     contents.clear
  970.     reset_font_settings
  971.     draw_learn_skill_text
  972.     rect = Rect.new(0, 0, contents.width - 4, line_height)
  973.     draw_learn_skill_cost(@skill, rect)
  974.   end
  975.  
  976.   #--------------------------------------------------------------------------
  977.   # draw_learn_skill_text
  978.   #--------------------------------------------------------------------------
  979.   def draw_learn_skill_text
  980.     name = sprintf("\eI[%d]%s", @skill.icon_index, @skill.name)
  981.     fmt = YEA::LEARN_SKILL::LEARN_SKILL_TEXT
  982.     text = sprintf(fmt, name)
  983.     draw_text_ex(4, 0, text)
  984.   end
  985.  
  986.   #--------------------------------------------------------------------------
  987.   # draw_learn_skill_cost
  988.   #--------------------------------------------------------------------------
  989.   def draw_learn_skill_cost(skill, rect)
  990.     case skill.learn_cost[1]
  991.     when :jp
  992.       return unless $imported["YEA-JPManager"]
  993.       draw_jp_cost(skill, rect)
  994.     when :exp
  995.       draw_exp_cost(skill, rect)
  996.     when :gold
  997.       draw_gold_cost(skill, rect)
  998.     else; return
  999.     end
  1000.   end
  1001.  
  1002.   #--------------------------------------------------------------------------
  1003.   # draw_jp_cost
  1004.   #--------------------------------------------------------------------------
  1005.   def draw_jp_cost(skill, rect)
  1006.     enabled = true
  1007.     if Icon.jp > 0
  1008.       draw_icon(Icon.jp, rect.x + rect.width - 24, rect.y, enabled)
  1009.       rect.width -= 24
  1010.     end
  1011.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  1012.     change_color(system_color, enabled)
  1013.     draw_text(rect, Vocab::jp, 2)
  1014.     rect.width -= text_size(Vocab::jp).width
  1015.     cost = skill.learn_cost[0]
  1016.     text = cost.group
  1017.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_JP), enabled)
  1018.     draw_text(rect, text, 2)
  1019.   end
  1020.  
  1021.   #--------------------------------------------------------------------------
  1022.   # draw_exp_cost
  1023.   #--------------------------------------------------------------------------
  1024.   def draw_exp_cost(skill, rect)
  1025.     enabled = true
  1026.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  1027.     change_color(system_color, enabled)
  1028.     draw_text(rect, YEA::LEARN_SKILL::EXP_TEXT, 2)
  1029.     rect.width -= text_size(YEA::LEARN_SKILL::EXP_TEXT).width
  1030.     cost = skill.learn_cost[0]
  1031.     text = cost.group
  1032.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_EXP), enabled)
  1033.     draw_text(rect, text, 2)
  1034.   end
  1035.  
  1036.   #--------------------------------------------------------------------------
  1037.   # draw_gold_cost
  1038.   #--------------------------------------------------------------------------
  1039.   def draw_gold_cost(skill, rect)
  1040.     enabled = true
  1041.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  1042.     change_color(system_color, enabled)
  1043.     draw_text(rect, Vocab::currency_unit, 2)
  1044.     rect.width -= text_size(Vocab::currency_unit).width
  1045.     cost = skill.learn_cost[0]
  1046.     text = cost.group
  1047.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_GOLD), enabled)
  1048.     draw_text(rect, text, 2)
  1049.   end
  1050.  
  1051. end # Window_LearnSkillCostBack
  1052.  
  1053. #==============================================================================
  1054. # ■ Window_LearnSkillCostFront
  1055. #==============================================================================
  1056.  
  1057. class Window_LearnSkillCostFront < Window_Command
  1058.  
  1059.   #--------------------------------------------------------------------------
  1060.   # initialize
  1061.   #--------------------------------------------------------------------------
  1062.   def initialize(item_window, cost_window)
  1063.     super((Graphics.width - window_width) / 2, 0)
  1064.     self.openness = 0
  1065.     self.opacity = 0
  1066.     @item_window = item_window
  1067.     @cost_window = cost_window
  1068.     @skill = nil
  1069.     @actor = nil
  1070.     deactivate
  1071.   end
  1072.  
  1073.   #--------------------------------------------------------------------------
  1074.   # window_width
  1075.   #--------------------------------------------------------------------------
  1076.   def window_width; return Graphics.width * 3 / 4; end
  1077.  
  1078.   #--------------------------------------------------------------------------
  1079.   # skill_class
  1080.   #--------------------------------------------------------------------------
  1081.   def skill_class
  1082.     return @skill_classes.nil? ? nil : @skill_classes[index]
  1083.   end
  1084.  
  1085.   #--------------------------------------------------------------------------
  1086.   # reveal
  1087.   #--------------------------------------------------------------------------
  1088.   def reveal(skill, skill_classes, actor)
  1089.     @skill = skill
  1090.     @skill_classes = skill_classes.clone
  1091.     @actor = actor
  1092.     return if @skill.nil?
  1093.     case @skill.learn_cost[1]
  1094.     when :gold
  1095.       self.height = fitting_height(2)
  1096.     else
  1097.       maximum = [skill_classes.size, YEA::LEARN_SKILL::MAXIMUM_ROWS].min
  1098.       self.height = fitting_height(maximum + 1)
  1099.     end
  1100.     create_contents
  1101.     self.y = @cost_window.y + line_height
  1102.     refresh
  1103.     select(0)
  1104.     open
  1105.     activate
  1106.   end
  1107.  
  1108.   #--------------------------------------------------------------------------
  1109.   # make_command_list
  1110.   #--------------------------------------------------------------------------
  1111.   def make_command_list
  1112.     return if @skill_classes.nil?
  1113.     if @skill.learn_cost[1] == :gold
  1114.       add_command("GOLD", :gold, true)
  1115.       add_command(YEA::LEARN_SKILL::LEARN_CANCEL_TEXT, :cancel, true)
  1116.       return
  1117.     end
  1118.     for class_id in @skill_classes
  1119.       name = $data_classes[class_id].name
  1120.       add_command(name, :class, enabled?(class_id), class_id)
  1121.     end
  1122.     add_command(YEA::LEARN_SKILL::LEARN_CANCEL_TEXT, :cancel, true)
  1123.   end
  1124.  
  1125.   #--------------------------------------------------------------------------
  1126.   # enabled?
  1127.   #--------------------------------------------------------------------------
  1128.   def enabled?(class_id)
  1129.     cost = @skill.learn_cost[0]
  1130.     case @skill.learn_cost[1]
  1131.     when :jp
  1132.       return @actor.jp(class_id) >= cost
  1133.     when :exp
  1134.       return @actor.exp_class(class_id) >= cost
  1135.     end
  1136.     return true
  1137.   end
  1138.  
  1139.   #--------------------------------------------------------------------------
  1140.   # draw_item
  1141.   #--------------------------------------------------------------------------
  1142.   def draw_item(index)
  1143.     reset_font_settings
  1144.     rect = item_rect(index)
  1145.     rect.x += 24
  1146.     rect.width -= 28
  1147.     return draw_cancel_text(index, rect) if @list[index][:symbol] == :cancel
  1148.     draw_class_name(index, rect) if @skill.learn_cost[1] != :gold
  1149.     draw_party_gold(rect) if @skill.learn_cost[1] == :gold
  1150.     draw_learn_skill_cost(@skill, rect, index)
  1151.   end
  1152.  
  1153.   #--------------------------------------------------------------------------
  1154.   # draw_cancel_text
  1155.   #--------------------------------------------------------------------------
  1156.   def draw_cancel_text(index, rect)
  1157.     draw_icon(Icon.cancel, rect.x, rect.y)
  1158.     text = command_name(index)
  1159.     draw_text(rect.x+24, rect.y, rect.width-24, line_height, text)
  1160.   end
  1161.  
  1162.   #--------------------------------------------------------------------------
  1163.   # draw_class_name
  1164.   #--------------------------------------------------------------------------
  1165.   def draw_class_name(index, rect)
  1166.     class_id = @list[index][:ext]
  1167.     return if $data_classes[class_id].nil?
  1168.     enabled = enabled?(class_id)
  1169.     if $imported["YEA-ClassSystem"]
  1170.       draw_icon($data_classes[class_id].icon_index, rect.x, rect.y, enabled)
  1171.     end
  1172.     rect.x += 24
  1173.     rect.width -= 24
  1174.     change_color(normal_color, enabled)
  1175.     draw_text(rect, $data_classes[class_id].name)
  1176.   end
  1177.  
  1178.   #--------------------------------------------------------------------------
  1179.   # draw_class_name
  1180.   #--------------------------------------------------------------------------
  1181.   def draw_party_gold(rect)
  1182.     enabled = true
  1183.     draw_icon(Icon.learn_skill_gold, rect.x, rect.y)
  1184.     rect.x += 24
  1185.     rect.width -= 24
  1186.     change_color(normal_color, enabled)
  1187.     draw_text(rect, YEA::LEARN_SKILL::GOLD_TEXT)
  1188.   end
  1189.  
  1190.   #--------------------------------------------------------------------------
  1191.   # draw_learn_skill_cost
  1192.   #--------------------------------------------------------------------------
  1193.   def draw_learn_skill_cost(skill, rect, index)
  1194.     case skill.learn_cost[1]
  1195.     when :jp
  1196.       return unless $imported["YEA-JPManager"]
  1197.       draw_jp_cost(skill, rect, index)
  1198.     when :exp
  1199.       draw_exp_cost(skill, rect, index)
  1200.     when :gold
  1201.       draw_gold_cost(skill, rect)
  1202.     else; return
  1203.     end
  1204.   end
  1205.  
  1206.   #--------------------------------------------------------------------------
  1207.   # draw_jp_cost
  1208.   #--------------------------------------------------------------------------
  1209.   def draw_jp_cost(skill, rect, index)
  1210.     enabled = enabled?(@list[index][:ext])
  1211.     if Icon.jp > 0
  1212.       draw_icon(Icon.jp, rect.x + rect.width - 24, rect.y, enabled)
  1213.       rect.width -= 24
  1214.     end
  1215.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  1216.     change_color(system_color, enabled)
  1217.     draw_text(rect, Vocab::jp, 2)
  1218.     rect.width -= text_size(Vocab::jp).width
  1219.     cost = @actor.jp(@list[index][:ext])
  1220.     text = cost.group
  1221.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_JP), enabled)
  1222.     draw_text(rect, text, 2)
  1223.   end
  1224.  
  1225.   #--------------------------------------------------------------------------
  1226.   # draw_exp_cost
  1227.   #--------------------------------------------------------------------------
  1228.   def draw_exp_cost(skill, rect, index)
  1229.     enabled = enabled?(@list[index][:ext])
  1230.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  1231.     change_color(system_color, enabled)
  1232.     draw_text(rect, YEA::LEARN_SKILL::EXP_TEXT, 2)
  1233.     rect.width -= text_size(YEA::LEARN_SKILL::EXP_TEXT).width
  1234.     cost = @actor.exp_class(@list[index][:ext])
  1235.     text = cost.group
  1236.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_EXP), enabled)
  1237.     draw_text(rect, text, 2)
  1238.   end
  1239.  
  1240.   #--------------------------------------------------------------------------
  1241.   # draw_gold_cost
  1242.   #--------------------------------------------------------------------------
  1243.   def draw_gold_cost(skill, rect)
  1244.     enabled = $game_party.gold >= skill.learn_cost[0]
  1245.     contents.font.size = YEA::LEARN_SKILL::COST_SIZE
  1246.     change_color(system_color, enabled)
  1247.     draw_text(rect, Vocab::currency_unit, 2)
  1248.     rect.width -= text_size(Vocab::currency_unit).width
  1249.     cost = $game_party.gold
  1250.     text = cost.group
  1251.     change_color(text_color(YEA::LEARN_SKILL::COLOUR_GOLD), enabled)
  1252.     draw_text(rect, text, 2)
  1253.   end
  1254.  
  1255. end # Window_LearnSkillCostFront
  1256.  
  1257. #==============================================================================
  1258. # ■ Scene_Skill
  1259. #==============================================================================
  1260.  
  1261. class Scene_Skill < Scene_ItemBase
  1262.  
  1263.   #--------------------------------------------------------------------------
  1264.   # alias method: create_command_window
  1265.   #--------------------------------------------------------------------------
  1266.   alias scene_skill_create_command_window_lse create_command_window
  1267.   def create_command_window
  1268.     scene_skill_create_command_window_lse
  1269.     @command_window.set_handler(:learn_skill, method(:command_learn_skill))
  1270.   end
  1271.  
  1272.   #--------------------------------------------------------------------------
  1273.   # new method: command_learn_skill
  1274.   #--------------------------------------------------------------------------
  1275.   def command_learn_skill
  1276.     SceneManager.call(Scene_LearnSkill)
  1277.   end
  1278.  
  1279. end # Scene_Skill
  1280.  
  1281. #==============================================================================
  1282. # ■ Scene_LearnSkill
  1283. #==============================================================================
  1284.  
  1285. class Scene_LearnSkill < Scene_Skill
  1286.  
  1287.   #--------------------------------------------------------------------------
  1288.   # start
  1289.   #--------------------------------------------------------------------------
  1290.   def start
  1291.     super
  1292.     create_cost_windows
  1293.   end
  1294.  
  1295.   #--------------------------------------------------------------------------
  1296.   # create_command_window
  1297.   #--------------------------------------------------------------------------
  1298.   def create_command_window
  1299.     wy = @help_window.height
  1300.     @command_window = Window_LearnSkillCommand.new(0, wy)
  1301.     @command_window.viewport = @viewport
  1302.     @command_window.help_window = @help_window
  1303.     @command_window.actor = @actor
  1304.     @command_window.set_handler(:skill,    method(:command_skill))
  1305.     @command_window.set_handler(:cancel,   method(:return_scene))
  1306.     @command_window.set_handler(:pagedown, method(:next_actor))
  1307.     @command_window.set_handler(:pageup,   method(:prev_actor))
  1308.   end
  1309.  
  1310.   #--------------------------------------------------------------------------
  1311.   # create_item_window
  1312.   #--------------------------------------------------------------------------
  1313.   def create_item_window
  1314.     wx = 0
  1315.     wy = @status_window.y + @status_window.height
  1316.     ww = Graphics.width
  1317.     wh = Graphics.height - wy
  1318.     @item_window = Window_LearnSkillList.new(wx, wy, ww, wh)
  1319.     @item_window.actor = @actor
  1320.     @item_window.viewport = @viewport
  1321.     @item_window.help_window = @help_window
  1322.     @item_window.set_handler(:ok,     method(:on_item_ok))
  1323.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  1324.     @command_window.skill_window = @item_window
  1325.   end
  1326.  
  1327.   #--------------------------------------------------------------------------
  1328.   # create_cost_windows
  1329.   #--------------------------------------------------------------------------
  1330.   def create_cost_windows
  1331.     @cost_window = Window_LearnSkillCostBack.new(@item_window)
  1332.     @cost_front = Window_LearnSkillCostFront.new(@item_window, @cost_window)
  1333.     @cost_window.viewport = @viewport
  1334.     @cost_front.viewport = @viewport
  1335.     @cost_front.set_handler(:ok, method(:on_cost_ok))
  1336.     @cost_front.set_handler(:cancel, method(:on_cost_cancel))
  1337.   end
  1338.  
  1339.   #--------------------------------------------------------------------------
  1340.   # on_item_ok
  1341.   #--------------------------------------------------------------------------
  1342.   def on_item_ok
  1343.     skill = @item_window.item
  1344.     @cost_window.reveal(skill, @item_window.skill_classes(skill))
  1345.     @cost_front.reveal(skill, @item_window.skill_classes(skill), @actor)
  1346.   end
  1347.  
  1348.   #--------------------------------------------------------------------------
  1349.   # on_cost_ok
  1350.   #--------------------------------------------------------------------------
  1351.   def on_cost_ok
  1352.     Sound.play_use_skill
  1353.     skill = @item_window.item
  1354.     @actor.learn_skill(skill.id)
  1355.     cost = skill.learn_cost[0]
  1356.     case skill.learn_cost[1]
  1357.     when :jp
  1358.       @actor.lose_jp(cost, @cost_front.skill_class)
  1359.     when :exp
  1360.       @actor.lose_exp_class(cost, @cost_front.skill_class)
  1361.     when :gold
  1362.       $game_party.lose_gold(cost)
  1363.     end
  1364.     on_cost_cancel
  1365.     refresh_windows
  1366.   end
  1367.  
  1368.   #--------------------------------------------------------------------------
  1369.   # on_cost_cancel
  1370.   #--------------------------------------------------------------------------
  1371.   def on_cost_cancel
  1372.     @cost_front.close
  1373.     @cost_window.close
  1374.     @item_window.activate
  1375.   end
  1376.  
  1377.   #--------------------------------------------------------------------------
  1378.   # refresh_windows
  1379.   #--------------------------------------------------------------------------
  1380.   def refresh_windows
  1381.     @item_window.refresh
  1382.     @status_window.refresh
  1383.   end
  1384.  
  1385. end # Scene_LearnSkill
  1386.  
  1387. #==============================================================================
  1388. #
  1389. # ▼ End of File
  1390. #
  1391. #==============================================================================

RUBY 代码复制
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Skill Cost Manager v1.02
  4. # -- Last Updated: 2012.01.23
  5. # -- Level: Normal, Hard, Lunatic
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-SkillCostManager"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.01.23 - Compatibility Update: Doppelganger
  17. # 2011.12.11 - Started Script and Finished.
  18. #            - Added max and min notetags.
  19. #
  20. #==============================================================================
  21. # ▼ Introduction
  22. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  23. # This script adds more functionality towards skill costs. Skills can now cost
  24. # HP, more MP, more TP, gold, and even have custom costs. The way the skill
  25. # costs are drawn in the display windows are changed to deliver more effective
  26. # and reliable information to the player. And if four skill costs aren't enough
  27. # to satisfy you, you can even make your own custom skill costs.
  28. #
  29. #==============================================================================
  30. # ▼ Instructions
  31. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  32. # To install this script, open up your script editor and copy/paste this script
  33. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  34. #
  35. # -----------------------------------------------------------------------------
  36. # Actor Notetags - These notetags go in the actors notebox in the database.
  37. # -----------------------------------------------------------------------------
  38. # <hp cost rate: x%>
  39. # Allows the actor to drop the HP cost of skills to x%.
  40. #
  41. # <tp cost rate: x%>
  42. # Allows the actor to drop the TP cost of skills to x%.
  43. #
  44. # <gold cost rate: x%>
  45. # Allows the actor to drop the Gold cost of skills to x%.
  46. #
  47. # -----------------------------------------------------------------------------
  48. # Class Notetags - These notetags go in the class notebox in the database.
  49. # -----------------------------------------------------------------------------
  50. # <hp cost rate: x%>
  51. # Allows the class to drop the HP cost of skills to x%.
  52. #
  53. # <tp cost rate: x%>
  54. # Allows the class to drop the TP cost of skills to x%.
  55. #
  56. # <gold cost rate: x%>
  57. # Allows the class to drop the Gold cost of skills to x%.
  58. #
  59. # -----------------------------------------------------------------------------
  60. # Skill Notetags - These notetags go in the skills notebox in the database.
  61. # -----------------------------------------------------------------------------
  62. # <hp cost: x>
  63. # Sets the skill's HP cost to x. This function did not exist by default in
  64. # RPG Maker VX Ace.
  65. #
  66. # <hp cost: x%>
  67. # Sets the HP cost to a percentage of the actor's MaxHP. If a normal HP cost is
  68. # present on the skill, too, then this value is added to the HP cost.
  69. #
  70. # <hp cost max: x>
  71. # <hp cost min: x>
  72. # Sets the maximum and minimum range of the HP Cost of the skill. If you do not
  73. # use this tag, there will be no maximum and/or minimum range.
  74. #
  75. # <mp cost: x>
  76. # Sets the skill's MP cost to x. Allows MP cost to exceed 9999, which is RPG
  77. # Maker VX Ace's database editor's maximum limit.
  78. #
  79. # <mp cost: x%>
  80. # Sets the MP cost to a percentage of the actor's MaxMP. If a normal MP cost is
  81. # present on the skill, too, then this value is added to the MP cost.
  82. #
  83. # <mp cost max: x>
  84. # <mp cost min: x>
  85. # Sets the maximum and minimum range of the MP Cost of the skill. If you do not
  86. # use this tag, there will be no maximum and/or minimum range.
  87. #
  88. # <tp cost: x>
  89. # Sets the skill's TP cost to x. Allows TP cost to exceed 100, which is RPG
  90. # Maker VX Ace's database editor's maximum limit.
  91. #
  92. # <tp cost: x%>
  93. # Sets the TP cost to a percentage of the actor's MaxTP. If a normal TP cost is
  94. # present on the skill, too, then this value is added to the TP cost.
  95. #
  96. # <tp cost max: x>
  97. # <tp cost min: x>
  98. # Sets the maximum and minimum range of the TP Cost of the skill. If you do not
  99. # use this tag, there will be no maximum and/or minimum range.
  100. #
  101. # <gold cost: x>
  102. # Sets the skill's gold cost to x. Enemies with skills that cost gold do not
  103. # use gold. If the player does not have enough gold, the skill can't be used.
  104. #
  105. # <gold cost: x%>
  106. # Sets the skill's gold cost equal to a percentage of the party's total gold.
  107. # If both a regular gold cost and a percentile gold cost is used, the total of
  108. # both values will be the skill's gold cost.
  109. #
  110. # <gold cost max: x>
  111. # <gold cost min: x>
  112. # Sets the maximum and minimum range of the Gold Cost of the skill. If you do
  113. # not use this tag, there will be no maximum and/or minimum range.
  114. #
  115. # --- Making Your Own Custom Costs ---
  116. #
  117. # <custom cost: string>
  118. # If you decide to have a custom cost for your game, insert this notetag to
  119. # change what displays in the skill menu visually.
  120. #
  121. # <custom cost colour: x>
  122. # This is the "Window" skin text colour used for the custom cost. By default,
  123. # it is text colour 0, which is the white colour.
  124. #
  125. # <custom cost size: x>
  126. # This is the text font size used for the custom cost in the display windows.
  127. # By default, it is font size 20.
  128. #
  129. # <custom cost icon: x>
  130. # If you wish to use an icon for your custom cost, replace x with the icon ID
  131. # you wish to show in display windows. By default, it is 0 (and not shown).
  132. #
  133. # <custom cost requirement>
  134. #  string
  135. #  string
  136. # </custom cost requirement>
  137. # Sets the custom cost requirement of the skill with an eval function using the
  138. # strings in between. The strings are a part of one line even if in the notebox
  139. # they are on separate lines.
  140. #
  141. # <custom cost perform>
  142. #  string
  143. #  string
  144. # </custom cost perform>
  145. # Sets how the custom cost payment is done with an eval function using the
  146. # strings in between. The strings are a part of one line even if in the notebox
  147. # they are on separate lines.
  148. #
  149. # -----------------------------------------------------------------------------
  150. # Weapon Notetags - These notetags go in the weapons notebox in the database.
  151. # -----------------------------------------------------------------------------
  152. # <hp cost rate: x%>
  153. # Allows the weapon to drop the HP cost of skills to x% when worn.
  154. #
  155. # <tp cost rate: x%>
  156. # Allows the weapon to drop the TP cost of skills to x% when worn.
  157. #
  158. # <gold cost rate: x%>
  159. # Allows the weapon to drop the Gold cost of skills to x% when worn.
  160. #
  161. # -----------------------------------------------------------------------------
  162. # Armour Notetags - These notetags go in the armours notebox in the database.
  163. # -----------------------------------------------------------------------------
  164. # <hp cost rate: x%>
  165. # Allows the armour to drop the HP cost of skills to x% when worn.
  166. #
  167. # <tp cost rate: x%>
  168. # Allows the armour to drop the TP cost of skills to x% when worn.
  169. #
  170. # <gold cost rate: x%>
  171. # Allows the armour to drop the TP cost of skills to x% when worn.
  172. #
  173. # -----------------------------------------------------------------------------
  174. # Enemy Notetags - These notetags go in the enemies notebox in the database.
  175. # -----------------------------------------------------------------------------
  176. # <hp cost rate: x%>
  177. # Allows the enemy to drop the HP cost of skills to x%.
  178. #
  179. # <tp cost rate: x%>
  180. # Allows the enemy to drop the TP cost of skills to x%.
  181. #
  182. # -----------------------------------------------------------------------------
  183. # State Notetags - These notetags go in the states notebox in the database.
  184. # -----------------------------------------------------------------------------
  185. # <hp cost rate: x%>
  186. # Allows the state to drop the HP cost of skills to x% when afflicted.
  187. #
  188. # <tp cost rate: x%>
  189. # Allows the state to drop the TP cost of skills to x% when afflicted.
  190. #
  191. # <gold cost rate: x%>
  192. # Allows the state to drop the Gold cost of skills to x% when afflicted.
  193. #
  194. #==============================================================================
  195. # ▼ Compatibility
  196. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  197. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  198. # it will run with RPG Maker VX without adjusting.
  199. #
  200. #==============================================================================
  201.  
  202. module YEA
  203.   module SKILL_COST
  204.  
  205.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  206.     # - HP Cost Settings -
  207.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  208.     # New to this script are HP costs. HP costs require the battler to have
  209.     # sufficient HP before being able to use the skill. The text colour that's
  210.     # used, the suffix, or whether or not to use an icon. If you do not wish
  211.     # to use an icon, set the icon to 0.
  212.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  213.     HP_COST_COLOUR = 21         # Colour used from "Window" skin.
  214.     HP_COST_SIZE   = 20         # Font size used for HP costs.
  215.     HP_COST_SUFFIX = "%sHP"     # Suffix used for HP costs.
  216.     HP_COST_ICON   = 0          # Icon used for HP costs. Set 0 to disable.
  217.  
  218.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  219.     # - MP Cost Settings -
  220.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  221.     # Here, you can change the settings for MP costs: the text colour that's
  222.     # used, the suffix, or whether or not to use an icon. If you do not wish
  223.     # to use an icon, set the icon to 0.
  224.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  225.     MP_COST_COLOUR = 23         # Colour used from "Window" skin. Default: 23
  226.     MP_COST_SIZE   = 20         # Font size used for MP costs. Default: 24
  227.     MP_COST_SUFFIX = "%sMP"     # Suffix used for MP costs. No suffix default.
  228.     MP_COST_ICON   = 0          # Icon used for MP costs. Set 0 to disable.
  229.  
  230.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  231.     # - TP Cost Settings -
  232.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  233.     # Here, you can change the settings for TP costs: the text colour that's
  234.     # used, the suffix, or whether or not to use an icon. If you do not wish
  235.     # to use an icon, set the icon to 0.
  236.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  237.     TP_COST_COLOUR = 2          # Colour used from "Window" skin. Default: 29
  238.     TP_COST_SIZE   = 20         # Font size used for TP costs. Default: 24
  239.     TP_COST_SUFFIX = "%sTP"     # Suffix used for TP costs. No suffix default.
  240.     TP_COST_ICON   = 0          # Icon used for TP costs. Set 0 to disable.
  241.  
  242.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  243.     # - Gold Cost Settings -
  244.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  245.     # New to this script are Gold costs. Gold costs require the party to have
  246.     # enough gold before being able to use the skill. The text colour that's
  247.     # used, the suffix, or whether or not to use an icon. If you do not wish
  248.     # to use an icon, set the icon to 0.
  249.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  250.     GOLD_COST_COLOUR = 6          # Colour used from "Window" skin.
  251.     GOLD_COST_SIZE   = 20         # Font size used for Gold costs.
  252.     GOLD_COST_SUFFIX = "%sGold"   # Suffix used for Gold costs.
  253.     GOLD_COST_ICON   = 0          # Icon used for Gold costs. Set 0 to disable.
  254.  
  255.   end # SKILL_COST
  256. end # YEA
  257.  
  258. #==============================================================================
  259. # ▼ Editting anything past this point may potentially result in causing
  260. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  261. # halitosis so edit at your own risk.
  262. #==============================================================================
  263.  
  264. module YEA
  265.   module REGEXP
  266.   module BASEITEM
  267.  
  268.     HP_COST_RATE = /<(?:HP_COST_RATE|hp cost rate):[ ](\d+)([%%])>/i
  269.     TP_COST_RATE = /<(?:TP_COST_RATE|tp cost rate):[ ](\d+)([%%])>/i
  270.     GOLD_COST_RATE = /<(?:GOLD_COST_RATE|gold cost rate):[ ](\d+)([%%])>/i
  271.  
  272.   end # BASEITEM
  273.   module SKILL
  274.  
  275.     HP_COST_SET = /<(?:HP_COST|hp cost):[ ](\d+)>/i
  276.     HP_COST_PER = /<(?:HP_COST|hp cost):[ ](\d+)([%%])>/i
  277.     MP_COST_SET = /<(?:MP_COST|mp cost):[ ](\d+)>/i
  278.     MP_COST_PER = /<(?:MP_COST|mp cost):[ ](\d+)([%%])>/i
  279.     TP_COST_SET = /<(?:TP_COST|tp cost):[ ](\d+)>/i
  280.     TP_COST_PER = /<(?:TP_COST|tp cost):[ ](\d+)([%%])>/i
  281.     GOLD_COST_SET = /<(?:GOLD_COST|gold cost):[ ](\d+)>/i
  282.     GOLD_COST_PER = /<(?:GOLD_COST|gold cost):[ ](\d+)([%%])>/i
  283.  
  284.     CUSTOM_COST_TEXT = /<(?:CUSTOM_COST|custom cost):[ ](.*)>/i
  285.     CUSTOM_COST_COLOUR =
  286.       /<(?:CUSTOM_COST_COLOUR|custom cost colour|custom cost color):[ ](\d+)>/i
  287.     CUSTOM_COST_SIZE = /<(?:CUSTOM_COST_SIZE|custom cost size):[ ](\d+)>/i
  288.     CUSTOM_COST_ICON = /<(?:CUSTOM_COST_ICON|custom cost icon):[ ](\d+)>/i
  289.     CUSTOM_COST_REQUIREMENT_ON =
  290.       /<(?:CUSTOM_COST_REQUIREMENT|custom cost requirement)>/i
  291.     CUSTOM_COST_REQUIREMENT_OFF =
  292.       /<\/(?:CUSTOM_COST_REQUIREMENT|custom cost requirement)>/i
  293.     CUSTOM_COST_PERFORM_ON =
  294.       /<(?:CUSTOM_COST_PERFORM|custom cost perform)>/i
  295.     CUSTOM_COST_PERFORM_OFF =
  296.       /<\/(?:CUSTOM_COST_PERFORM|custom cost perform)>/i
  297.  
  298.     HP_COST_MIN = /<(?:HP_COST_MIN|hp cost min):[ ](\d+)>/i
  299.     HP_COST_MAX = /<(?:HP_COST_MIN|hp cost max):[ ](\d+)>/i
  300.     MP_COST_MIN = /<(?:MP_COST_MIN|mp cost min):[ ](\d+)>/i
  301.     MP_COST_MAX = /<(?:MP_COST_MIN|mp cost max):[ ](\d+)>/i
  302.     TP_COST_MIN = /<(?:TP_COST_MIN|tp cost min):[ ](\d+)>/i
  303.     TP_COST_MAX = /<(?:TP_COST_MIN|tp cost max):[ ](\d+)>/i
  304.     GOLD_COST_MIN = /<(?:GOLD_COST_MIN|gold cost min):[ ](\d+)>/i
  305.     GOLD_COST_MAX = /<(?:GOLD_COST_MIN|gold cost max):[ ](\d+)>/i
  306.  
  307.   end # SKILL
  308.   end # REGEXP
  309. end # YEA
  310.  
  311. #==============================================================================
  312. # ■ Icon
  313. #==============================================================================
  314.  
  315. module Icon
  316.  
  317.   #--------------------------------------------------------------------------
  318.   # self.mp_cost
  319.   #--------------------------------------------------------------------------
  320.   def self.mp_cost; return YEA::SKILL_COST::MP_COST_ICON; end
  321.  
  322.   #--------------------------------------------------------------------------
  323.   # self.tp_cost
  324.   #--------------------------------------------------------------------------
  325.   def self.tp_cost; return YEA::SKILL_COST::TP_COST_ICON; end
  326.  
  327.   #--------------------------------------------------------------------------
  328.   # self.hp_cost
  329.   #--------------------------------------------------------------------------
  330.   def self.hp_cost; return YEA::SKILL_COST::HP_COST_ICON; end
  331.  
  332.   #--------------------------------------------------------------------------
  333.   # self.gold_cost
  334.   #--------------------------------------------------------------------------
  335.   def self.gold_cost; return YEA::SKILL_COST::GOLD_COST_ICON; end
  336.  
  337. end # Icon
  338.  
  339. #==============================================================================
  340. # ■ Numeric
  341. #==============================================================================
  342.  
  343. class Numeric
  344.  
  345.   #--------------------------------------------------------------------------
  346.   # new method: group_digits
  347.   #--------------------------------------------------------------------------
  348.   unless $imported["YEA-CoreEngine"]
  349.   def group; return self.to_s; end
  350.   end # $imported["YEA-CoreEngine"]
  351.  
  352. end # Numeric
  353.  
  354. #==============================================================================
  355. # ■ DataManager
  356. #==============================================================================
  357.  
  358. module DataManager
  359.  
  360.   #--------------------------------------------------------------------------
  361.   # alias method: load_database
  362.   #--------------------------------------------------------------------------
  363.   class <<self; alias load_database_scm load_database; end
  364.   def self.load_database
  365.     load_database_scm
  366.     load_notetags_scm
  367.   end
  368.  
  369.   #--------------------------------------------------------------------------
  370.   # new method: load_notetags_scm
  371.   #--------------------------------------------------------------------------
  372.   def self.load_notetags_scm
  373.     groups = [$data_actors, $data_classes, $data_skills, $data_weapons,
  374.       $data_armors, $data_enemies, $data_states]
  375.     for group in groups
  376.       for obj in group
  377.         next if obj.nil?
  378.         obj.load_notetags_scm
  379.       end
  380.     end
  381.   end
  382.  
  383. end # DataManager
  384.  
  385. #==============================================================================
  386. # ■ RPG::BaseItem
  387. #==============================================================================
  388.  
  389. class RPG::BaseItem
  390.  
  391.   #--------------------------------------------------------------------------
  392.   # public instance variables
  393.   #--------------------------------------------------------------------------
  394.   attr_accessor :tp_cost_rate
  395.   attr_accessor :hp_cost_rate
  396.   attr_accessor :gold_cost_rate
  397.  
  398.   #--------------------------------------------------------------------------
  399.   # common cache: load_notetags_scm
  400.   #--------------------------------------------------------------------------
  401.   def load_notetags_scm
  402.     @tp_cost_rate = 1.0
  403.     @hp_cost_rate = 1.0
  404.     @gold_cost_rate = 1.0
  405.     #---
  406.     self.note.split(/[\r\n]+/).each { |line|
  407.       case line
  408.       #---
  409.       when YEA::REGEXP::BASEITEM::TP_COST_RATE
  410.         @tp_cost_rate = $1.to_i * 0.01
  411.       when YEA::REGEXP::BASEITEM::HP_COST_RATE
  412.         @hp_cost_rate = $1.to_i * 0.01
  413.       when YEA::REGEXP::BASEITEM::GOLD_COST_RATE
  414.         @gold_cost_rate = $1.to_i * 0.01
  415.       #---
  416.       end
  417.     } # self.note.split
  418.     #---
  419.   end
  420.  
  421. end # RPG::BaseItem
  422.  
  423. #==============================================================================
  424. # ■ RPG::Skill
  425. #==============================================================================
  426.  
  427. class RPG::Skill < RPG::UsableItem
  428.  
  429.   #--------------------------------------------------------------------------
  430.   # public instance variables
  431.   #--------------------------------------------------------------------------
  432.   attr_accessor :hp_cost
  433.   attr_accessor :hp_cost_percent
  434.   attr_accessor :mp_cost_percent
  435.   attr_accessor :tp_cost_percent
  436.   attr_accessor :gold_cost
  437.   attr_accessor :gold_cost_percent
  438.  
  439.   attr_accessor :hp_cost_min
  440.   attr_accessor :hp_cost_max
  441.   attr_accessor :mp_cost_min
  442.   attr_accessor :mp_cost_max
  443.   attr_accessor :tp_cost_min
  444.   attr_accessor :tp_cost_max
  445.   attr_accessor :gold_cost_min
  446.   attr_accessor :gold_cost_max
  447.  
  448.   attr_accessor :use_custom_cost
  449.   attr_accessor :custom_cost_text
  450.   attr_accessor :custom_cost_colour
  451.   attr_accessor :custom_cost_size
  452.   attr_accessor :custom_cost_icon
  453.   attr_accessor :custom_cost_requirement
  454.   attr_accessor :custom_cost_perform
  455.  
  456.   #--------------------------------------------------------------------------
  457.   # common cache: load_notetags_scm
  458.   #--------------------------------------------------------------------------
  459.   def load_notetags_scm
  460.     @hp_cost = 0
  461.     @gold_cost = 0
  462.     @hp_cost_percent = 0.0
  463.     @mp_cost_percent = 0.0
  464.     @tp_cost_percent = 0.0
  465.     @gold_cost_percent = 0.0
  466.  
  467.     @custom_cost_text = "0"
  468.     @custom_cost_colour = 0
  469.     @custom_cost_size = 20
  470.     @custom_cost_icon = 0
  471.     @custom_cost_requirement = ""
  472.     @custom_cost_perform = ""
  473.  
  474.     @use_custom_cost = false
  475.     @custom_cost_req_on = false
  476.     @custom_cost_per_on = false
  477.     #---
  478.     self.note.split(/[\r\n]+/).each { |line|
  479.       case line
  480.       #---
  481.       when YEA::REGEXP::SKILL::MP_COST_SET
  482.         @mp_cost = $1.to_i
  483.       when YEA::REGEXP::SKILL::MP_COST_PER
  484.         @mp_cost_percent = $1.to_i * 0.01
  485.       when YEA::REGEXP::SKILL::TP_COST_SET
  486.         @tp_cost = $1.to_i
  487.       when YEA::REGEXP::SKILL::TP_COST_PER
  488.         @tp_cost_percent = $1.to_i * 0.01
  489.       when YEA::REGEXP::SKILL::HP_COST_SET
  490.         @hp_cost = $1.to_i
  491.       when YEA::REGEXP::SKILL::HP_COST_PER
  492.         @hp_cost_percent = $1.to_i * 0.01
  493.       when YEA::REGEXP::SKILL::GOLD_COST_SET
  494.         @gold_cost = $1.to_i
  495.       when YEA::REGEXP::SKILL::GOLD_COST_PER
  496.         @gold_cost_percent = $1.to_i * 0.01
  497.       #---
  498.       when YEA::REGEXP::SKILL::HP_COST_MIN
  499.         @hp_cost_min = $1.to_i
  500.       when YEA::REGEXP::SKILL::HP_COST_MAX
  501.         @hp_cost_max = $1.to_i
  502.       when YEA::REGEXP::SKILL::MP_COST_MIN
  503.         @mp_cost_min = $1.to_i
  504.       when YEA::REGEXP::SKILL::MP_COST_MAX
  505.         @mp_cost_max = $1.to_i
  506.       when YEA::REGEXP::SKILL::TP_COST_MIN
  507.         @tp_cost_min = $1.to_i
  508.       when YEA::REGEXP::SKILL::TP_COST_MAX
  509.         @tp_cost_max = $1.to_i
  510.       when YEA::REGEXP::SKILL::GOLD_COST_MIN
  511.         @gold_cost_min = $1.to_i
  512.       when YEA::REGEXP::SKILL::GOLD_COST_MAX
  513.         @gold_cost_max = $1.to_i
  514.       #---
  515.       when YEA::REGEXP::SKILL::CUSTOM_COST_TEXT
  516.         @custom_cost_text = $1.to_s
  517.       when YEA::REGEXP::SKILL::CUSTOM_COST_COLOUR
  518.         @custom_cost_colour = $1.to_i
  519.       when YEA::REGEXP::SKILL::CUSTOM_COST_SIZE
  520.         @custom_cost_size = $1.to_i
  521.       when YEA::REGEXP::SKILL::CUSTOM_COST_ICON
  522.         @custom_cost_icon = $1.to_i
  523.       when YEA::REGEXP::SKILL::CUSTOM_COST_REQUIREMENT_ON
  524.         @custom_cost_req_on = true
  525.         @use_custom_cost = true
  526.       when YEA::REGEXP::SKILL::CUSTOM_COST_REQUIREMENT_OFF
  527.         @custom_cost_req_on = false
  528.         @use_custom_cost = true
  529.       when YEA::REGEXP::SKILL::CUSTOM_COST_PERFORM_ON
  530.         @custom_cost_per_on = true
  531.         @use_custom_cost = true
  532.       when YEA::REGEXP::SKILL::CUSTOM_COST_PERFORM_OFF
  533.         @custom_cost_per_on = false
  534.         @use_custom_cost = true
  535.       else
  536.         @custom_cost_requirement += line.to_s if @custom_cost_req_on
  537.         @custom_cost_perform += line.to_s if @custom_cost_per_on
  538.       #---
  539.       end
  540.     } # self.note.split
  541.     #---
  542.   end
  543.  
  544. end # RPG::Skill
  545.  
  546. #==============================================================================
  547. # ■ Game_BattlerBase
  548. #==============================================================================
  549.  
  550. class Game_BattlerBase
  551.  
  552.   #--------------------------------------------------------------------------
  553.   # alias method: skill_cost_payable?
  554.   #--------------------------------------------------------------------------
  555.   alias game_battlerbase_skill_cost_payable_scm skill_cost_payable?
  556.   def skill_cost_payable?(skill)
  557.     return false if hp <= skill_hp_cost(skill)
  558.     return false unless gold_cost_met?(skill)
  559.     return false unless custom_cost_met?(skill)
  560.     return game_battlerbase_skill_cost_payable_scm(skill)
  561.   end
  562.  
  563.   #--------------------------------------------------------------------------
  564.   # new method: gold_cost_met?
  565.   #--------------------------------------------------------------------------
  566.   def gold_cost_met?(skill)
  567.     return true unless actor?
  568.     return $game_party.gold >= skill_gold_cost(skill)
  569.   end
  570.  
  571.   #--------------------------------------------------------------------------
  572.   # new method: custom_cost_met?
  573.   #--------------------------------------------------------------------------
  574.   def custom_cost_met?(skill)
  575.     return true unless skill.use_custom_cost
  576.     return eval(skill.custom_cost_requirement)
  577.   end
  578.  
  579.   #--------------------------------------------------------------------------
  580.   # alias method: pay_skill_cost
  581.   #--------------------------------------------------------------------------
  582.   alias game_battlerbase_pay_skill_cost_scm pay_skill_cost
  583.   def pay_skill_cost(skill)
  584.     game_battlerbase_pay_skill_cost_scm(skill)
  585.     self.hp -= skill_hp_cost(skill)
  586.     $game_party.lose_gold(skill_gold_cost(skill)) if actor?
  587.     pay_custom_cost(skill)
  588.   end
  589.  
  590.   #--------------------------------------------------------------------------
  591.   # new method: pay_custom_cost
  592.   #--------------------------------------------------------------------------
  593.   def pay_custom_cost(skill)
  594.     return unless skill.use_custom_cost
  595.     eval(skill.custom_cost_perform)
  596.   end
  597.  
  598.   #--------------------------------------------------------------------------
  599.   # alias method: skill_mp_cost
  600.   #--------------------------------------------------------------------------
  601.   alias game_battlerbase_skill_mp_cost_scm skill_mp_cost
  602.   def skill_mp_cost(skill)
  603.     n = game_battlerbase_skill_mp_cost_scm(skill)
  604.     n += skill.mp_cost_percent * mmp * mcr
  605.     n = [n.to_i, skill.mp_cost_max].min unless skill.mp_cost_max.nil?
  606.     n = [n.to_i, skill.mp_cost_min].max unless skill.mp_cost_min.nil?
  607.     return n.to_i
  608.   end
  609.  
  610.   #--------------------------------------------------------------------------
  611.   # alias method: skill_tp_cost
  612.   #--------------------------------------------------------------------------
  613.   alias game_battlerbase_skill_tp_cost_scm skill_tp_cost
  614.   def skill_tp_cost(skill)
  615.     n = game_battlerbase_skill_tp_cost_scm(skill) * tcr
  616.     n += skill.tp_cost_percent * max_tp * tcr
  617.     n = [n.to_i, skill.tp_cost_max].min unless skill.tp_cost_max.nil?
  618.     n = [n.to_i, skill.tp_cost_min].max unless skill.tp_cost_min.nil?
  619.     return n.to_i
  620.   end
  621.  
  622.   #--------------------------------------------------------------------------
  623.   # new method: tcr
  624.   #--------------------------------------------------------------------------
  625.   def tcr
  626.     n = 1.0
  627.     if actor?
  628.       n *= self.actor.tp_cost_rate
  629.       n *= self.class.tp_cost_rate
  630.       for equip in equips
  631.         next if equip.nil?
  632.         n *= equip.tp_cost_rate
  633.       end
  634.     else
  635.       n *= self.enemy.tp_cost_rate
  636.       if $imported["YEA-Doppelganger"] && !self.class.nil?
  637.         n *= self.class.tp_cost_rate
  638.       end
  639.     end
  640.     for state in states
  641.       next if state.nil?
  642.       n *= state.tp_cost_rate
  643.     end
  644.     return n
  645.   end
  646.  
  647.   #--------------------------------------------------------------------------
  648.   # new method: skill_hp_cost
  649.   #--------------------------------------------------------------------------
  650.   def skill_hp_cost(skill)
  651.     n = skill.hp_cost * hcr
  652.     n += skill.hp_cost_percent * mhp * hcr
  653.     n = [n.to_i, skill.hp_cost_max].min unless skill.hp_cost_max.nil?
  654.     n = [n.to_i, skill.hp_cost_min].max unless skill.hp_cost_min.nil?
  655.     return n.to_i
  656.   end
  657.  
  658.   #--------------------------------------------------------------------------
  659.   # new method: hcr
  660.   #--------------------------------------------------------------------------
  661.   def hcr
  662.     n = 1.0
  663.     if actor?
  664.       n *= self.actor.hp_cost_rate
  665.       n *= self.class.hp_cost_rate
  666.       for equip in equips
  667.         next if equip.nil?
  668.         n *= equip.hp_cost_rate
  669.       end
  670.     else
  671.       n *= self.enemy.hp_cost_rate
  672.       if $imported["YEA-Doppelganger"] && !self.class.nil?
  673.         n *= self.class.hp_cost_rate
  674.       end
  675.     end
  676.     for state in states
  677.       next if state.nil?
  678.       n *= state.hp_cost_rate
  679.     end
  680.     return n
  681.   end
  682.  
  683.   #--------------------------------------------------------------------------
  684.   # new method: skill_gold_cost
  685.   #--------------------------------------------------------------------------
  686.   def skill_gold_cost(skill)
  687.     n = skill.gold_cost * gcr
  688.     n += skill.gold_cost_percent * $game_party.gold * gcr
  689.     n = [n.to_i, skill.gold_cost_max].min unless skill.gold_cost_max.nil?
  690.     n = [n.to_i, skill.gold_cost_min].max unless skill.gold_cost_min.nil?
  691.     return n.to_i
  692.   end
  693.  
  694.   #--------------------------------------------------------------------------
  695.   # new method: gcr
  696.   #--------------------------------------------------------------------------
  697.   def gcr
  698.     n = 1.0
  699.     n *= self.actor.gold_cost_rate
  700.     n *= self.class.gold_cost_rate
  701.     for equip in equips
  702.       next if equip.nil?
  703.       n *= equip.gold_cost_rate
  704.     end
  705.     for state in states
  706.       next if state.nil?
  707.       n *= state.gold_cost_rate
  708.     end
  709.     return n
  710.   end
  711.  
  712. end # Game_BattlerBase
  713.  
  714. #==============================================================================
  715. # ■ Window_Base
  716. #==============================================================================
  717.  
  718. class Window_Base < Window
  719.  
  720.   #--------------------------------------------------------------------------
  721.   # overwrite methods: cost_colours
  722.   #--------------------------------------------------------------------------
  723.   def mp_cost_color; text_color(YEA::SKILL_COST::MP_COST_COLOUR); end;
  724.   def tp_cost_color; text_color(YEA::SKILL_COST::TP_COST_COLOUR); end;
  725.   def hp_cost_color; text_color(YEA::SKILL_COST::HP_COST_COLOUR); end;
  726.   def gold_cost_color; text_color(YEA::SKILL_COST::GOLD_COST_COLOUR); end;
  727.  
  728. end # Window_Base
  729.  
  730. #==============================================================================
  731. # ■ Window_SkillList
  732. #==============================================================================
  733.  
  734. class Window_SkillList < Window_Selectable
  735.  
  736.   #--------------------------------------------------------------------------
  737.   # overwrite method: draw_skill_cost
  738.   #--------------------------------------------------------------------------
  739.   def draw_skill_cost(rect, skill)
  740.     draw_tp_skill_cost(rect, skill) unless $imported["YEA-BattleEngine"]
  741.     draw_mp_skill_cost(rect, skill)
  742.     draw_tp_skill_cost(rect, skill) if $imported["YEA-BattleEngine"]
  743.     draw_hp_skill_cost(rect, skill)
  744.     draw_gold_skill_cost(rect, skill)
  745.     draw_custom_skill_cost(rect, skill)
  746.   end
  747.  
  748.   #--------------------------------------------------------------------------
  749.   # new method: draw_mp_skill_cost
  750.   #--------------------------------------------------------------------------
  751.   def draw_mp_skill_cost(rect, skill)
  752.     return unless @actor.skill_mp_cost(skill) > 0
  753.     change_color(mp_cost_color, enable?(skill))
  754.     #---
  755.     icon = Icon.mp_cost
  756.     if icon > 0
  757.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  758.       rect.width -= 24
  759.     end
  760.     #---
  761.     contents.font.size = YEA::SKILL_COST::MP_COST_SIZE
  762.     cost = @actor.skill_mp_cost(skill)
  763.     text = sprintf(YEA::SKILL_COST::MP_COST_SUFFIX, cost.group)
  764.     draw_text(rect, text, 2)
  765.     cx = text_size(text).width + 4
  766.     rect.width -= cx
  767.     reset_font_settings
  768.   end
  769.  
  770.   #--------------------------------------------------------------------------
  771.   # new method: draw_tp_skill_cost
  772.   #--------------------------------------------------------------------------
  773.   def draw_tp_skill_cost(rect, skill)
  774.     return unless @actor.skill_tp_cost(skill) > 0
  775.     change_color(tp_cost_color, enable?(skill))
  776.     #---
  777.     icon = Icon.tp_cost
  778.     if icon > 0
  779.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  780.       rect.width -= 24
  781.     end
  782.     #---
  783.     contents.font.size = YEA::SKILL_COST::TP_COST_SIZE
  784.     cost = @actor.skill_tp_cost(skill)
  785.     text = sprintf(YEA::SKILL_COST::TP_COST_SUFFIX, cost.group)
  786.     draw_text(rect, text, 2)
  787.     cx = text_size(text).width + 4
  788.     rect.width -= cx
  789.     reset_font_settings
  790.   end
  791.  
  792.   #--------------------------------------------------------------------------
  793.   # new method: draw_hp_skill_cost
  794.   #--------------------------------------------------------------------------
  795.   def draw_hp_skill_cost(rect, skill)
  796.     return unless @actor.skill_hp_cost(skill) > 0
  797.     change_color(hp_cost_color, enable?(skill))
  798.     #---
  799.     icon = Icon.hp_cost
  800.     if icon > 0
  801.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  802.       rect.width -= 24
  803.     end
  804.     #---
  805.     contents.font.size = YEA::SKILL_COST::HP_COST_SIZE
  806.     cost = @actor.skill_hp_cost(skill)
  807.     text = sprintf(YEA::SKILL_COST::HP_COST_SUFFIX, cost.group)
  808.     draw_text(rect, text, 2)
  809.     cx = text_size(text).width + 4
  810.     rect.width -= cx
  811.     reset_font_settings
  812.   end
  813.  
  814.   #--------------------------------------------------------------------------
  815.   # new method: draw_gold_skill_cost
  816.   #--------------------------------------------------------------------------
  817.   def draw_gold_skill_cost(rect, skill)
  818.     return unless @actor.skill_gold_cost(skill) > 0
  819.     change_color(gold_cost_color, enable?(skill))
  820.     #---
  821.     icon = Icon.gold_cost
  822.     if icon > 0
  823.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  824.       rect.width -= 24
  825.     end
  826.     #---
  827.     contents.font.size = YEA::SKILL_COST::GOLD_COST_SIZE
  828.     cost = @actor.skill_gold_cost(skill)
  829.     text = sprintf(YEA::SKILL_COST::GOLD_COST_SUFFIX, cost.group)
  830.     draw_text(rect, text, 2)
  831.     cx = text_size(text).width + 4
  832.     rect.width -= cx
  833.     reset_font_settings
  834.   end
  835.  
  836.   #--------------------------------------------------------------------------
  837.   # new method: draw_custom_skill_cost
  838.   #--------------------------------------------------------------------------
  839.   def draw_custom_skill_cost(rect, skill)
  840.     return unless skill.use_custom_cost
  841.     change_color(text_color(skill.custom_cost_colour), enable?(skill))
  842.     icon = skill.custom_cost_icon
  843.     if icon > 0
  844.       draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
  845.       rect.width -= 24
  846.     end
  847.     contents.font.size = skill.custom_cost_size
  848.     text = skill.custom_cost_text
  849.     draw_text(rect, text, 2)
  850.     cx = text_size(text).width + 4
  851.     rect.width -= cx
  852.     reset_font_settings
  853.   end
  854.  
  855. end # Window_SkillList
  856.  
  857. #==============================================================================
  858. #
  859. # ▼ End of File
  860. #
  861. #==============================================================================

另外,升级加技能点的话,用这个:
在Game_Actor的420行左右是判断升级的,这段代码可以改为:
RUBY 代码复制
  1. def level_up
  2.     @level += 1
  3.     if @actor_id == 1
  4.           $game_variables[0032]=$game_variables[0032]+2
  5.           end
  6.     self.class.learnings.each do |learning|
  7.       learn_skill(learning.skill_id) if learning.level == @level
  8.     end
  9.   end

这段效果就是主角升一级,32号变量增加两点,而其他人升级是不增加的,可用作技能点

评分

参与人数 1梦石 +1 收起 理由
taroxd + 1 认可答案

查看全部评分

点击即可领养:
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
85
在线时间
83 小时
注册时间
2010-10-16
帖子
140
7
 楼主| 发表于 2014-6-10 18:45:24 | 只看该作者
令狐林 发表于 2014-6-9 09:46
从无到有可以利用这个技能学习系统,一共三个脚本,给你
#============================================ ...

谢谢了!
[img]http://rpg.blue/static/image/smiley/default/victory.
回归中........
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-12 19:52

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表