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

Project1

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

[原创发布] 【VA】可堆叠状态系统

[复制链接]

Lv5.捕梦者

梦石
0
星屑
24504
在线时间
5086 小时
注册时间
2016-3-8
帖子
1624
1
发表于 2022-5-21 17:36:34 | 显示全部楼层
hq1107 发表于 2022-5-21 14:31
您好 我想设置一个需要充能才能释放的技能
可是在游戏中 该技能不需要充能状态也不消耗充能次数也能释放
...

用这个不香么?
RUBY 代码复制
  1. #==============================================================================
  2. #
  3. # ¥ Yami Engine Ace - Charge Skill
  4. # -- Last Updated: 2012.05.13
  5. # -- Level: Easy
  6. # -- Requires: none
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YSE-ChargeSkill"] = true
  12.  
  13. #==============================================================================
  14. # ¥ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.05.13 - Fixed Enemy Charging.
  17. # 2012.03.30 - Fixed Skill Targets.
  18. # 2012.03.29 - Fixed Auto Battle bug.
  19. # 2012.03.27 - Fixed Cancel Charge bug.
  20. # 2012.03.26 - Fixed Battle End bug.
  21. # 2012.03.18 - Started and Finished Script.
  22. #
  23. #==============================================================================
  24. # ¥ Introduction
  25. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  26. # This script provides charging skill feature. Charging Skill means that skill
  27. # will be used after some turn it was choosen.
  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/‘fÞ but above ¥ Main. Remember to save.
  34. #
  35. # -----------------------------------------------------------------------------
  36. # Skill/Item Notetags - These notetags go in the skill/item notebox in the database.
  37. # -----------------------------------------------------------------------------
  38. # <charge turn: x>
  39. # Make skill be a charge skill with x charging turns.
  40. # -----------------------------------------------------------------------------
  41. # <start charge message>
  42. # example
  43. # </start charge message>
  44. #
  45. # Set the Charging Start Message to example.
  46. # -----------------------------------------------------------------------------
  47. # <continue charge message>
  48. # example
  49. # </continue charge message>
  50. #
  51. # Set the Charging Continue Message to example.
  52. #
  53. #==============================================================================
  54. # ¥ Compatibility
  55. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  56. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  57. # it will run with RPG Maker VX without adjusting.
  58. #
  59. #==============================================================================
  60.  
  61. module YSE
  62.   module CHARGE_SKILL
  63.  
  64.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  65.     # - Visual Settings -
  66.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  67.     VISUAL_SETTING = { # Start.
  68.       # Message shows when choose a charge skill.
  69.       # Set this to nil to disable.
  70.       :default_msg_start      =>  "%s is charging %s!",
  71.       # Message shows when end a charging turn.
  72.       # Set this to nil to disable.
  73.       :default_msg_continue   =>  "%s continue charging %s...",
  74.     } # End.
  75.  
  76.   end # CHARGE_SKILL
  77. end # YSE
  78.  
  79. #==============================================================================
  80. # ¥ Editting anything past this point may potentially result in causing
  81. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  82. # halitosis so edit at your own risk.
  83. #==============================================================================
  84.  
  85. #==============================================================================
  86. # ¡ Regular Expression
  87. #==============================================================================
  88.  
  89. module YSE
  90.   module REGEXP
  91.   module USABLEITEM
  92.  
  93.     CHARGE_TURN = /<(?:CHARGE_TURN|charge turn):[ ](\d+)?>/i
  94.     START_MSG_BEGIN = /<(?:START_CHARGE_MESSAGE|start charge message)>/i
  95.     START_MSG_END = /<\/(?:START_CHARGE_MESSAGE|start charge message)>/i
  96.     CONT_MSG_BEGIN = /<(?:CONTINUE_CHARGE_MESSAGE|continue charge message)>/i
  97.     CONT_MSG_END = /<\/(?:CONTINUE_CHARGE_MESSAGE|continue charge message)>/i
  98.  
  99.   end # STATE
  100.   end # REGEXP
  101. end # YSE
  102.  
  103. #==============================================================================
  104. # ¡ DataManager
  105. #==============================================================================
  106.  
  107. module DataManager
  108.  
  109.   #--------------------------------------------------------------------------
  110.   # alias method: load_database
  111.   #--------------------------------------------------------------------------
  112.   class <<self; alias load_database_ysecs load_database; end
  113.   def self.load_database
  114.     load_database_ysecs
  115.     load_notetags_ysecs
  116.   end
  117.  
  118.   #--------------------------------------------------------------------------
  119.   # new method: load_notetags_ysecs
  120.   #--------------------------------------------------------------------------
  121.   def self.load_notetags_ysecs
  122.     groups = [$data_skills, $data_items]
  123.     for group in groups
  124.       for obj in group
  125.         next if obj.nil?
  126.         obj.load_notetags_ysecs
  127.       end
  128.     end
  129.   end
  130.  
  131. end # DataManager
  132.  
  133. #==============================================================================
  134. # ¡ RPG::UsableItem
  135. #==============================================================================
  136.  
  137. class RPG::UsableItem < RPG::BaseItem
  138.  
  139.   #--------------------------------------------------------------------------
  140.   # public instance variables
  141.   #--------------------------------------------------------------------------
  142.   attr_accessor :charge_turn
  143.   attr_accessor :start_msg
  144.   attr_accessor :continue_msg
  145.  
  146.   #--------------------------------------------------------------------------
  147.   # common cache: load_notetags_ysecs
  148.   #--------------------------------------------------------------------------
  149.   def load_notetags_ysecs
  150.     @start_begin = false
  151.     @continue_begin = false
  152.     @charge_turn = 0
  153.     #---
  154.     self.note.split(/[\r\n]+/).each { |line|
  155.       case line
  156.       #---
  157.       when YSE::REGEXP::USABLEITEM::CHARGE_TURN
  158.         @charge_turn = $1.to_i
  159.       when YSE::REGEXP::USABLEITEM::START_MSG_BEGIN
  160.         @start_begin = true
  161.       when YSE::REGEXP::USABLEITEM::START_MSG_END
  162.         @start_begin = false
  163.       when YSE::REGEXP::USABLEITEM::CONT_MSG_BEGIN
  164.         @continue_begin = true
  165.       when YSE::REGEXP::USABLEITEM::CONT_MSG_END
  166.         @continue_begin = false
  167.       else
  168.         @start_msg = line.to_s if @start_msg.nil? && @start_begin
  169.         @start_msg += line.to_s if @start_begin
  170.         @continue_msg = line.to_s if @continue_msg.nil? && @continue_begin
  171.         @continue_msg += line.to_s if @continue_begin
  172.       end
  173.     } # self.note.split
  174.     #---
  175.     @charge_turn = nil if @charge_turn <= 0
  176.     @start_msg = YSE::CHARGE_SKILL::VISUAL_SETTING[:default_msg_start]
  177.     @continue_msg = YSE::CHARGE_SKILL::VISUAL_SETTING[:default_msg_continue]
  178.     @start_msg = nil if @start_msg == ""
  179.     @continue_msg = nil if @continue_msg == ""
  180.   end
  181.  
  182. end # RPG::UsableItem
  183.  
  184. #==============================================================================
  185. # ¡ Game_Battler
  186. #==============================================================================
  187.  
  188. class Game_Battler < Game_BattlerBase
  189.  
  190.   #--------------------------------------------------------------------------
  191.   # public instance variables
  192.   #--------------------------------------------------------------------------
  193.   attr_accessor :charged
  194.   attr_accessor :first_charge
  195.  
  196.   #--------------------------------------------------------------------------
  197.   # alias method: auto_battle?
  198.   #--------------------------------------------------------------------------
  199.   alias yse_auto_battle_cs auto_battle?
  200.   def auto_battle?
  201.     charging? ? false : yse_auto_battle_cs
  202.   end
  203.  
  204.   #--------------------------------------------------------------------------
  205.   # new method: charging?
  206.   #--------------------------------------------------------------------------
  207.   def charging?
  208.     !@charging_cache.nil? || @charged
  209.   end
  210.  
  211.   #--------------------------------------------------------------------------
  212.   # new method: start_charge
  213.   #--------------------------------------------------------------------------
  214.   def start_charge
  215.     return false if charging?
  216.     return false if current_action.item.charge_turn.nil?
  217.     @charging_cache = current_action.clone
  218.     @charge_turn = current_action.item.charge_turn
  219.     return true
  220.   end
  221.  
  222.   #--------------------------------------------------------------------------
  223.   # new method: current_charging
  224.   #--------------------------------------------------------------------------
  225.   def current_charging
  226.     @charging_cache
  227.   end
  228.  
  229.   #--------------------------------------------------------------------------
  230.   # new method: end_charge
  231.   #--------------------------------------------------------------------------
  232.   def end_charge
  233.     @actions.push(@charging_cache)
  234.     @charging_cache = nil
  235.     @charge_turn = nil
  236.     @charged = true
  237.     return true
  238.   end
  239.  
  240.   #--------------------------------------------------------------------------
  241.   # new method: cancel_charge
  242.   #--------------------------------------------------------------------------
  243.   def cancel_charge
  244.     clear_actions
  245.     @charging_cache = nil
  246.     @charge_turn = nil
  247.     @charged = false
  248.   end
  249.  
  250.   #--------------------------------------------------------------------------
  251.   # new method: update_charge_skill
  252.   #--------------------------------------------------------------------------
  253.   def update_charge_skill
  254.     @charge_turn -= 1
  255.     return end_charge if @charge_turn == 0
  256.     return false
  257.   end
  258.  
  259.   #--------------------------------------------------------------------------
  260.   # alias method: on_battle_end
  261.   #--------------------------------------------------------------------------
  262.   alias yse_on_battle_end_cs on_battle_end
  263.   def on_battle_end
  264.     cancel_charge
  265.     yse_on_battle_end_cs
  266.   end
  267.  
  268. end # Game_Battler
  269.  
  270. #==============================================================================
  271. # ¡ Game_Actor
  272. #==============================================================================
  273.  
  274. class Game_Actor < Game_Battler
  275.  
  276.   #--------------------------------------------------------------------------
  277.   # alias method: inputable?
  278.   #--------------------------------------------------------------------------
  279.   alias yse_inputable_cs inputable?
  280.   def inputable?
  281.     yse_inputable_cs && !charging?
  282.   end
  283.  
  284. end # Game_Actor
  285.  
  286. #==============================================================================
  287. # ¡ Game_Enemy
  288. #==============================================================================
  289.  
  290. class Game_Enemy < Game_Battler
  291.  
  292.   #--------------------------------------------------------------------------
  293.   # alias method: make_actions
  294.   #--------------------------------------------------------------------------
  295.   alias yse_make_actions_cs make_actions
  296.   def make_actions
  297.     return super if charging?
  298.     yse_make_actions_cs
  299.   end
  300.  
  301. end # Game_Enemy
  302.  
  303. #==============================================================================
  304. # ¡ Scene_Battle
  305. #==============================================================================
  306.  
  307. class Scene_Battle < Scene_Base
  308.  
  309.   #--------------------------------------------------------------------------
  310.   # alias method: execute_action
  311.   #--------------------------------------------------------------------------
  312.   alias yse_execute_action_bacs execute_action
  313.   def execute_action
  314.     return start_charge if @subject.start_charge
  315.     yse_execute_action_bacs
  316.   end
  317.  
  318.   #--------------------------------------------------------------------------
  319.   # alias method: process_action_end
  320.   #--------------------------------------------------------------------------
  321.   alias yse_process_action_end_bacs process_action_end
  322.   def process_action_end
  323.     process_charge_skill
  324.     yse_process_action_end_bacs
  325.   end
  326.  
  327.   #--------------------------------------------------------------------------
  328.   # new method: start_charge
  329.   #--------------------------------------------------------------------------
  330.   def start_charge
  331.     @subject.first_charge = true
  332.     return if @subject.current_action.item.start_msg.nil?
  333.     str = @subject.current_action.item.start_msg
  334.     skill = @subject.current_action.item
  335.     skill_text = sprintf("\\i[%d]%s", skill.icon_index, skill.name)
  336.     text = sprintf(str, @subject.name, skill_text)
  337.     @log_window.add_text(text)
  338.     3.times do @log_window.wait end
  339.     @log_window.back_one
  340.   end
  341.  
  342.   #--------------------------------------------------------------------------
  343.   # new method: process_charge_skill
  344.   #--------------------------------------------------------------------------
  345.   def process_charge_skill
  346.     return @subject.first_charge = false if @subject.first_charge
  347.     return unless @subject.charging?
  348.     return unless check_charge_turn
  349.     process_action_charge
  350.   end
  351.  
  352.   #--------------------------------------------------------------------------
  353.   # new method: check_charge_turn
  354.   #--------------------------------------------------------------------------
  355.   def check_charge_turn
  356.     continue = @subject.update_charge_skill
  357.     if continue
  358.       return true
  359.     else
  360.       return false if @subject.current_charging.item.continue_msg.nil?
  361.       str = @subject.current_charging.item.continue_msg
  362.       skill = @subject.current_charging.item
  363.       skill_text = sprintf("\\i[%d]%s", skill.icon_index, skill.name)
  364.       text = sprintf(str, @subject.name, skill_text)
  365.       @log_window.add_text(text)
  366.       3.times do @log_window.wait end
  367.       @log_window.back_one
  368.     end
  369.     return false
  370.   end
  371.  
  372.   #--------------------------------------------------------------------------
  373.   # new method: process_action_charge
  374.   #--------------------------------------------------------------------------
  375.   def process_action_charge
  376.     loop do
  377.       break if $game_troop.all_dead?
  378.       break unless @subject.current_action
  379.       @subject.current_action.prepare
  380.       execute_action if @subject.current_action.valid?
  381.       @subject.remove_current_action
  382.     end
  383.     @subject.charged = false
  384.   end
  385.  
  386. end # Scene_Battle
  387.  
  388. #==============================================================================
  389. #
  390. # ¥ End of File
  391. #
  392. #==============================================================================
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
24504
在线时间
5086 小时
注册时间
2016-3-8
帖子
1624
2
发表于 2022-8-23 12:35:10 | 显示全部楼层
FSword9 发表于 2022-8-23 12:28
请问同一个角色身上出现多个可堆叠状态时,所有计数器都显示在同一位置而没有跟随图标移动的问题应该怎么解 ...

177至182行中,
把180行的 x 拿177行的 i 来计算
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
24504
在线时间
5086 小时
注册时间
2016-3-8
帖子
1624
3
发表于 2022-8-23 16:05:07 | 显示全部楼层
FSword9 发表于 2022-8-23 15:49
在180行前插入一行写了一个x=i之后,计数器堆叠在了角色名字的位置

那么在前插入一行p x一行p i之后, 看看控制台都输出了什么
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
24504
在线时间
5086 小时
注册时间
2016-3-8
帖子
1624
4
发表于 2022-8-23 17:19:44 | 显示全部楼层
本帖最后由 alexncf125 于 2022-8-23 17:25 编辑
FSword9 发表于 2022-8-23 16:38
只有一个状态时每次输出是
108
0


啊这...怎么我这边有三个状态时的输出会是
108
0
108
1
108
2

不过这也不太重要, 反正有108跟0, 1, 2, 3, ...
就能知道正确的算式了(ps 图标的宽是24像素
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-21 20:40

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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