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

Project1

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

[已经过期] 技能冷却时间的显示

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1293
在线时间
118 小时
注册时间
2017-7-14
帖子
148
跳转到指定楼层
1
发表于 2019-4-5 11:06:53 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 wyw838 于 2019-4-5 11:09 编辑

在游戏中添加了两个脚本...一个是显示技能详细信息(A脚本),另一个是技能消耗拓展(B脚本)。B中包涵了设定技能cd的功能,于是我就想在A中体现出技能的cd和当前的cd剩余。第一个目标已经做到了,后一个我找不到某个技能当前cd的变量值...想请各位dalao帮助,谢谢QWQ脚本附下
A脚本关于cd的描述在250行,B脚本在240行以后
RUBY 代码复制
  1. #==============================================================================
  2. # ■ 技能消耗依赖 v1.3 by SailCat
  3. #------------------------------------------------------------------------------
  4. #   方法:本脚本插入到Main之前使用,并依赖数据库通用备注接口插件(在其之后)
  5. #   版本:v1.3 (Build 171122)
  6. #   效果:
  7. #     1. 技能消耗SP以外的游戏数据,包括HP、道具、武器、防具、金钱、经验、变量
  8. #     2. 技能使用场合依赖游戏条件,包括开关、状态、地图相关、装备、能力、步数等
  9. #     3. 技能消耗额外的回合(技能冷却)
  10. #   配置:插件为即插即用型,没有任何配置项,也不需要在脚本中设定任何东西
  11. #   冲突:其他同类脚本,以及魔改了Scene_Skill的脚本
  12. #   说明:
  13. #     1. 技能消耗道具、武器、防具、金钱、变量时,有使用检查,不够消耗不让用。
  14. #     2. 技能消耗HP、经验时,无使用检查,扣到0为止。
  15. #     3. 技能依赖开关、状态、地图、地形、装备、属性均检查至所有条件严格相符。
  16. #     4. 技能依赖能力检查条件为能力在指定范围内,步数检查条件为指定步数以上。
  17. #     5. 备注写法:
  18. #        (写在描述里,不同条件可以叠加用分号隔开,备注和描述以#号分隔)
  19. #        (当[XX集]内容只有一条时,方括号可省略,当内容序号连续时,可写成子界)
  20. #        (条件太多写不下时,可用超长备注法,见依赖插件的说明)
  21. #        a) 技能消耗HP:ch=值
  22. #        b) 技能消耗道具:ci=[消耗道具ID集]
  23. #        消耗道具个数>1的情况下,ID后缀两位小数为消耗个数,如4.05消耗4号道具5个
  24. #        写成4和4.00是不一样的,前者消耗4号道具1个,后者要求持有4号道具但不消耗
  25. #        c) 技能消耗武器:cw=[消耗武器ID集],说明同道具,消耗的是持有的武器
  26. #        d) 技能消耗防具:ca=[消耗防具ID集],说明同道具,消耗的是持有的防具
  27. #        e) 技能消耗金钱:cg=值
  28. #        f) 技能消耗经验:cx=值
  29. #        g) 技能消耗变量:cv={变量ID=>消耗值},写成hash形式,不能省略花括号
  30. #        h) 技能消耗回合:cd=值
  31. #        i) 技能依赖开关:cs=[开关集],开关ID为正数要求ON,为负数要求OFF
  32. #        j) 技能依赖状态:cc=[状态集],状态ID为正数要求有,为负数要求没有
  33. #        k) 技能依赖地图:cm=[地图ID集],地图ID为正数要求在,为负数要求不在
  34. #        l) 技能依赖地形:ct=[地形标志集],标志为正数要求是,为负数要求不是
  35. #        m) 技能依赖装备:cq=[装备ID集],查身上装备,武器ID写负数,防具ID写正数
  36. #        n) 技能依赖步数:cp=值
  37. #        o) 技能依赖属性:ce=[属性ID集],查装备属性,正数要求有,负数要求没有
  38. #        p) 技能依赖能力:cn=能力字符串,如"str300",有多个条件直接连写
  39. #        能力可以用hp/sp/str/dex/agi/int,大小写不敏感
  40. #        条件值的写法:300或300+表示大于等于300;300-表示小于等于300;
  41. #                      =300表示恰好300;300~400表示300到400之间(闭区间)
  42. #        q) 技能依赖茂密:cb+(要求茂密处)或cb-(要求非茂密处)
  43. #        r) 技能依赖公式:cf:公式脚本字符串,公式要能返回true或false的真伪值
  44. #        公式中可以使用a代表技能使用者,v代表变量,s代表开关
  45. #==============================================================================
  46. #==============================================================================
  47. # ■ SailCat's 插件公用
  48. #==============================================================================
  49. module SailCat
  50.   $sailcat_import ||= {}
  51.   #--------------------------------------------------------------------------
  52.   # ● 植入与依赖检查
  53.   #--------------------------------------------------------------------------
  54.   if $sailcat_import[:DataNoteCore].to_f >= 2.0
  55.     $sailcat_import[:SkillCost] = 1.3
  56.   else
  57.     raise "缺少依赖插件,通用数据库备注接口(v2.0以上版本)"
  58.   end
  59. end
  60. module RPG
  61.   #============================================================================
  62.   # ■ Skill_ItemCost
  63.   #----------------------------------------------------------------------------
  64.   #  处理技能消耗道具、武器、防具的内部类
  65.   #============================================================================
  66.   class Skill_ItemCost
  67.     #--------------------------------------------------------------------------
  68.     # ● 定义实例变量
  69.     #--------------------------------------------------------------------------
  70.     attr_accessor :id                     # 消耗的物品ID
  71.     attr_accessor :number                 # 消耗的数目
  72.     #--------------------------------------------------------------------------
  73.     # ● 初期化
  74.     #--------------------------------------------------------------------------
  75.     def initialize(n)
  76.       n = 0 unless n.is_a?(Numeric)
  77.       n += 0.01 if n.is_a?(Fixnum)
  78.       @id = Integer(n).abs
  79.       @number = [Integer((n - @id) * 100.0 + 1e-6), 0].max
  80.     end
  81.     #--------------------------------------------------------------------------
  82.     # ● 检查符合性
  83.     #--------------------------------------------------------------------------
  84.     def match?(proc)
  85.       return true if @id == 0
  86.       proc.call(@id) >= [@number, 1].max
  87.     end
  88.   end
  89.   #============================================================================
  90.   # ■ Skill_EquipCheck
  91.   #----------------------------------------------------------------------------
  92.   #  处理技能依赖装备状态的内部类
  93.   #============================================================================
  94.   class Skill_EquipCheck
  95.     #--------------------------------------------------------------------------
  96.     # ● 定义实例变量
  97.     #--------------------------------------------------------------------------
  98.     attr_accessor :weapons                # 依赖的武器ID(空为不检查)
  99.     attr_accessor :armors1                # 依赖的盾牌ID(空为不检查)
  100.     attr_accessor :armors2                # 依赖的头盔ID(空为不检查)
  101.     attr_accessor :armors3                # 依赖的护甲ID(空为不检查)
  102.     attr_accessor :armors4                # 依赖的饰品ID(空为不检查)
  103.     #--------------------------------------------------------------------------
  104.     # ● 初期化
  105.     #--------------------------------------------------------------------------
  106.     def initialize(ary)
  107.       @weapons = @armors1 = @armors2 = @armors3 = @armors4 = []
  108.       ary.map! {|i| i.to_a}.flatten!
  109.       ary.each do |i|
  110.         if i < 0
  111.           @weapon_id.push(-i)
  112.         else
  113.           kind = $data_armors[i].kind + 1
  114.           instance_eval("@armors#{kind}.push(#{i})") rescue nil
  115.         end
  116.       end
  117.     end
  118.     #--------------------------------------------------------------------------
  119.     # ● 检查符合性
  120.     #--------------------------------------------------------------------------
  121.     def match?(a)
  122.       return false if !@weapons.empty? and !@weapons.include?(a.weapon_id)
  123.       return false if !@armors1.empty? and !@armors1.include?(a.armor1_id)
  124.       return false if !@armors2.empty? and !@armors2.include?(a.armor2_id)
  125.       return false if !@armors3.empty? and !@armors3.include?(a.armor3_id)
  126.       return false if !@armors4.empty? and !@armors4.include?(a.armor4_id)
  127.       return true
  128.     end
  129.   end
  130.   #============================================================================
  131.   # ■ Skill_AbilityCheck
  132.   #----------------------------------------------------------------------------
  133.   #  处理技能依赖能力的内部类
  134.   #============================================================================
  135.   class Skill_AbilityCheck
  136.     #--------------------------------------------------------------------------
  137.     # ● 常量
  138.     #--------------------------------------------------------------------------
  139.     REGEX = /(hp|sp|str|dex|agi|int)(=?([0-9]+)([+\-~])?([0-9]+)?)/i
  140.     #--------------------------------------------------------------------------
  141.     # ● 定义实例变量
  142.     #--------------------------------------------------------------------------
  143.     attr_accessor :hp_range               # 依赖的 HP % 范围
  144.     attr_accessor :sp_range               # 依赖的 SP % 范围
  145.     attr_accessor :str_range              # 依赖的力量值范围
  146.     attr_accessor :dex_range              # 依赖的灵巧值范围
  147.     attr_accessor :agi_range              # 依赖的速度值范围
  148.     attr_accessor :int_range              # 依赖的魔力值范围
  149.     #--------------------------------------------------------------------------
  150.     # ● 初期化
  151.     #--------------------------------------------------------------------------
  152.     def initialize(str)
  153.       @hp_range = @sp_range = 0..100
  154.       @str_range = @dex_range = @agi_range = @int_range = 0..999
  155.       ary = str.scan(REGEX)
  156.       ary.each do |a|
  157.         name = a[0].downcase
  158.         min = a[2]
  159.         max = a[4] || a[2]
  160.         if a[1][0] != 61
  161.           max = (name[1] == 112 ? 100 : 999) if a[3] == nil or a[3] == "+"
  162.           min = 0 if a[3] == "-" and a[4] == nil
  163.         end
  164.         instance_eval("@#{name}_range = #{min}..#{max}") rescue nil
  165.       end
  166.     end
  167.     #--------------------------------------------------------------------------
  168.     # ● 检查符合性
  169.     #--------------------------------------------------------------------------
  170.     def match?(a)
  171.       return false unless @hp_range === a.hp * 100 / a.maxhp
  172.       return false unless @sp_range === a.sp * 100 / [a.maxsp, 1].max
  173.       return false unless @str_range === a.str
  174.       return false unless @dex_range === a.dex
  175.       return false unless @agi_range === a.agi
  176.       return false unless @int_range === a.int
  177.       return true
  178.     end
  179.   end
  180.   #============================================================================
  181.   # ■ RPG::Skill
  182.   #----------------------------------------------------------------------------
  183.   #  数据库的技能类扩展
  184.   #============================================================================
  185.   class Skill
  186.     #--------------------------------------------------------------------------
  187.     # ● 备注定义
  188.     #--------------------------------------------------------------------------
  189.     def hp_cost;       _ch(0).abs;                                        end
  190.     def exp_cost;      _cx(0).abs;                                        end
  191.     def gold_cost;     _cg(0).abs;                                        end
  192.     def cooldown;      _cd(0).abs;                                        end
  193.     def variable_cost; _cv({});                                           end
  194.     def item_cost;     _ci([]).to_a.map {|f| Skill_ItemCost.new(f)};      end
  195.     def weapon_cost;   _cw([]).to_a.map {|f| Skill_ItemCost.new(f)};      end
  196.     def armor_cost;    _ca([]).to_a.map {|f| Skill_ItemCost.new(f)};      end
  197.     def switch_check;  flat_array(_cs([]));                               end
  198.     def state_check;   flat_array(_cc([]));                               end
  199.     def map_check;     flat_array(_cm([]));                               end
  200.     def terrain_check; flat_array(_ct([]));                               end
  201.     def element_check; flat_array(_ce([]));                               end
  202.     def bush_check;    _cb(nil);                                          end
  203.     def step_check;    _cp(0).abs;                                        end
  204.     def equip_check;   Skill_EquipCheck.new(_cq([]).to_a);                end
  205.     def ability_check; Skill_AbilityCheck.new(_cn("").to_s);              end
  206.     def eval_check;    _cf("true");                                       end
  207.     #--------------------------------------------------------------------------
  208.     # ● 公式依赖判定
  209.     #--------------------------------------------------------------------------
  210.     def eval_match?(actor)
  211.       result = lambda {|a, s, v| eval(eval_check) rescue true}
  212.       result.call(actor, $game_switches, $game_variables)
  213.     end
  214.     #--------------------------------------------------------------------------
  215.     # ● 通用正负依赖判定
  216.     #--------------------------------------------------------------------------
  217.     def pn_match?(set, obj, proc = Proc.new{|a, b| a == b})
  218.       (set.reject {|s| (s > 0) == proc.call(obj, s.abs)}).empty?
  219.     end
  220.     #--------------------------------------------------------------------------
  221.     # ● 变量消耗判定
  222.     #--------------------------------------------------------------------------
  223.     def variable_match?
  224.       variable_cost.each do |k, v|
  225.         return false if $game_variables[k] < v
  226.       end
  227.       return true
  228.     end
  229.     #--------------------------------------------------------------------------
  230.     # ● 道具消耗判定
  231.     #--------------------------------------------------------------------------
  232.     def item_match?(set, proc)
  233.       set.each do |s|
  234.         return false unless s.match?(proc)
  235.       end
  236.       return true
  237.     end
  238.   end
  239. end
  240. #==============================================================================
  241. # ■ Game_Battler
  242. #==============================================================================
  243. class Game_Battler
  244.   #--------------------------------------------------------------------------
  245.   # ● 使用技能的额外消耗
  246.   #     skill : 特技
  247.   #--------------------------------------------------------------------------
  248.   def skill_cost_extra(skill)
  249.     self.hp -= skill.hp_cost
  250.   end
  251. end
  252. #==============================================================================
  253. # ■ Game_Actor
  254. #==============================================================================
  255. class Game_Actor
  256.   #--------------------------------------------------------------------------
  257.   # ● 定义实例变量
  258.   #--------------------------------------------------------------------------
  259.   attr_reader   :cooldowns             # 冷却中的技能集
  260.   #--------------------------------------------------------------------------
  261.   # ● 方法重定义
  262.   #--------------------------------------------------------------------------
  263.   unless method_defined? :sailcat_skill_can_use?
  264.     alias sailcat_skillcost_skill_can_use? skill_can_use?
  265.   end
  266.   #--------------------------------------------------------------------------
  267.   # ● 可以使用特技判定
  268.   #     skill_id : 特技 ID
  269.   #--------------------------------------------------------------------------
  270.   def skill_can_use?(skill_id)
  271.     # 获得对应的特技实体
  272.     skill = $data_skills[skill_id]
  273.     # 装备不符的情况下,不能使用
  274.     if not skill.equip_check.match?(self)
  275.       return false
  276.     # 能力不符的情况下,不能使用
  277.     elsif not skill.ability_check.match?(self)
  278.       return false
  279.     # 步数不够的情况下,不能使用
  280.     elsif $game_party.steps < skill.step_check
  281.       return false
  282.     # 金钱不够的情况下,不能使用
  283.     elsif $game_party.silver < skill.gold_cost
  284.       return false
  285.     # 属性不符的情况下,不能使用
  286.     elsif not skill.pn_match?(skill.element_check, self, Proc.new{|a,b|
  287.       a.element_set.include?(b) or ([a.armor1_id, a.armor2_id,
  288.       a.armor3_id, a.armor4_id].inject(false) {|res, id|
  289.         res |= id > 0 and $data_armors[id].guard_element_set.include?(b)})
  290.       })
  291.       return false
  292.     # 地图不符的情况下,不能使用
  293.     elsif not skill.pn_match?(skill.map_check, $game_map.map_id)
  294.       return false
  295.     # 地形不符的情况下,不能使用
  296.     elsif not skill.pn_match?(skill.terrain_check, $game_player.terrain_tag)
  297.       return false
  298.     # 状态不符的情况下,不能使用
  299.     elsif not skill.pn_match?(skill.state_check, self,
  300.       Proc.new{|a, b| a.state?(b)})
  301.       return false
  302.     # 茂盛不符的情况下,不能使用
  303.     elsif skill.bush_check != nil and
  304.       skill.bush_check != ($game_player.bush_depth == 12)
  305.       return false
  306.     # 开关不符的情况下,不能使用
  307.     elsif not skill.pn_match?(skill.switch_check, $game_switches,
  308.       Proc.new{|a, b| a[b]})
  309.       return false
  310.     # 战斗时,冷却中的情况下,不能使用
  311.     elsif $game_temp.in_battle and cooldown?(skill_id)
  312.       return false
  313.     # 变量不符的情况下,不能使用
  314.     elsif not skill.variable_match?
  315.       return false
  316.     # 道具不够的情况下,不能使用
  317.     elsif not skill.item_match?(skill.item_cost,
  318.       Proc.new{|n| $game_party.item_number(n)})
  319.       return false
  320.     # 武器不够的情况下,不能使用
  321.     elsif not skill.item_match?(skill.weapon_cost,
  322.       Proc.new{|n| $game_party.weapon_number(n)})
  323.       return false
  324.     # 防具不够的情况下,不能使用
  325.     elsif not skill.item_match?(skill.armor_cost,
  326.       Proc.new{|n| $game_party.armor_number(n)})
  327.       return false
  328.     # 公式计算为false或nil的情况下,不能使用
  329.     elsif not skill.eval_match?(self)
  330.       return false
  331.     end
  332.     # 进行原始判定
  333.     sailcat_skillcost_skill_can_use?(skill_id)
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # ● 清除冷却技能
  337.   #--------------------------------------------------------------------------
  338.   def reset_cooldown
  339.     @cooldowns = {}
  340.   end
  341.   #--------------------------------------------------------------------------
  342.   # ● 设置冷却技能
  343.   #     skill_id : 特技 ID
  344.   #--------------------------------------------------------------------------
  345.   def set_cooldown(skill_id)
  346.     if $data_skills[skill_id].cooldown > 0
  347.       @cooldowns[skill_id] = $data_skills[skill_id].cooldown
  348.     end
  349.   end
  350.   #--------------------------------------------------------------------------
  351.   # ● 更新冷却技能,该方法一回合调用一次
  352.   #--------------------------------------------------------------------------
  353.   def update_cooldown
  354.     @cooldowns.each_key {|k| @cooldowns[k] -= 1}
  355.     @cooldowns.delete_if {|k, v| v == 0}
  356.   end
  357.   #--------------------------------------------------------------------------
  358.   # ● 冷却中判定
  359.   #     skill_id : 特技 ID
  360.   #--------------------------------------------------------------------------
  361.   def cooldown?(skill_id)
  362.     @cooldowns.has_key?(skill_id)
  363.   end
  364.   #--------------------------------------------------------------------------
  365.   # ● 使用技能的额外消耗
  366.   #     skill : 特技 ID
  367.   #--------------------------------------------------------------------------
  368.   def skill_cost_extra(skill)
  369.     super
  370.     self.exp -= skill.exp_cost
  371.     $game_party.lose_gold(skill.gold_cost)
  372.     skill.item_cost.each {|i| $game_party.lose_item(i.id, i.number)}
  373.     skill.weapon_cost.each {|i| $game_party.lose_weapon(i.id, i.number)}
  374.     skill.armor_cost.each {|i| $game_party.lose_armor(i.id, i.number)}
  375.     skill.variable_cost.each_pair {|k, v| $game_variables[k] -= v}
  376.     set_cooldown(skill.id) if $game_temp.in_battle
  377.   end
  378. end
  379. #==============================================================================
  380. # ■ Game_Party
  381. #==============================================================================
  382. class Game_Party
  383.   #--------------------------------------------------------------------------
  384.   # ● 清除冷却技能
  385.   #--------------------------------------------------------------------------
  386.   def reset_cooldown
  387.     actors.each {|a| a.reset_cooldown}
  388.   end
  389.   #--------------------------------------------------------------------------
  390.   # ● 更新冷却技能,该方法一回合调用一次
  391.   #--------------------------------------------------------------------------
  392.   def update_cooldown
  393.     actors.each {|a| a.update_cooldown}
  394.   end
  395. end
  396. #==============================================================================
  397. # ■ Scene_Battle
  398. #==============================================================================
  399. class Scene_Battle
  400.   #--------------------------------------------------------------------------
  401.   # ● 方法重定义
  402.   #--------------------------------------------------------------------------
  403.   unless method_defined? :sailcat_start_phase1
  404.     alias sailcat_skillcost_start_phase1 start_phase1
  405.     alias sailcat_skillcost_start_phase4 start_phase4
  406.     alias sailcat_skillcost_make_skill_action_result make_skill_action_result
  407.   end
  408.   #--------------------------------------------------------------------------
  409.   # ● 开始自由战斗回合
  410.   #--------------------------------------------------------------------------
  411.   def start_phase1
  412.     # 调用原方法
  413.     sailcat_skillcost_start_phase1
  414.     # 清除技能冷却
  415.     $game_party.reset_cooldown
  416.   end
  417.   #--------------------------------------------------------------------------
  418.   # ● 开始主回合
  419.   #--------------------------------------------------------------------------
  420.   def start_phase4
  421.     # 调用原方法
  422.     sailcat_skillcost_start_phase4
  423.     # 更新技能冷却
  424.     $game_party.update_cooldown
  425.   end
  426.   #--------------------------------------------------------------------------
  427.   # ● 生成特技行动结果
  428.   #--------------------------------------------------------------------------
  429.   def make_skill_action_result
  430.     # 调用原方法
  431.     sailcat_skillcost_make_skill_action_result
  432.     # 额外消耗
  433.     @active_battler.skill_cost_extra(@skill)
  434.   end
  435. end
  436. #==============================================================================
  437. # ■ Scene_Skill
  438. #==============================================================================
  439. class Scene_Skill
  440.   #--------------------------------------------------------------------------
  441.   # ● 刷新画面 (特技窗口被激活的情况下)
  442.   #--------------------------------------------------------------------------
  443.   def update_skill
  444.     # 按下 B 键的情况下
  445.     if Input.trigger?(Input::B)
  446.       # 演奏取消 SE
  447.       $game_system.se_play($data_system.cancel_se)
  448.       # 切换到菜单画面
  449.       $scene = Scene_Menu.new(1)
  450.       return
  451.     end
  452.     # 按下 C 键的情况下
  453.     if Input.trigger?(Input::C)
  454.       # 获取特技窗口现在选择的特技的数据
  455.       @skill = @skill_window.skill
  456.       # 不能使用的情况下
  457.       if @skill == nil or not @actor.skill_can_use?(@skill.id)
  458.         # 演奏冻结 SE
  459.         $game_system.se_play($data_system.buzzer_se)
  460.         return
  461.       end
  462.       # 演奏确定 SE
  463.       $game_system.se_play($data_system.decision_se)
  464.       # 效果范围是我方的情况下
  465.       if @skill.scope >= 3
  466.         # 激活目标窗口
  467.         @skill_window.active = false
  468.         @target_window.x = (@skill_window.index + 1) % 2 * 304
  469.         @target_window.visible = true
  470.         @target_window.active = true
  471.         # 设置效果范围 (单体/全体) 的对应光标位置
  472.         if @skill.scope == 4 || @skill.scope == 6
  473.           @target_window.index = -1
  474.         elsif @skill.scope == 7
  475.           @target_window.index = @actor_index - 10
  476.         else
  477.           @target_window.index = 0
  478.         end
  479.       # 效果在我方以外的情况下
  480.       else
  481.         # 公共事件 ID 有效的情况下
  482.         if @skill.common_event_id > 0
  483.           # 预约调用公共事件
  484.           $game_temp.common_event_id = @skill.common_event_id
  485.           # 演奏特技使用时的 SE
  486.           $game_system.se_play(@skill.menu_se)
  487.           # 消耗 SP
  488.           @actor.sp -= @skill.sp_cost
  489.           # 额外的消耗
  490.           @actor.skill_cost_extra(@skill)
  491.           # 再生成各窗口的内容
  492.           @status_window.refresh
  493.           @skill_window.refresh
  494.           @target_window.refresh
  495.           # 切换到地图画面
  496.           $scene = Scene_Map.new
  497.           return
  498.         end
  499.       end
  500.       return
  501.     end
  502.     # 按下 R 键的情况下
  503.     if Input.trigger?(Input::R)
  504.       # 演奏光标 SE
  505.       $game_system.se_play($data_system.cursor_se)
  506.       # 移至下一位角色
  507.       @actor_index += 1
  508.       @actor_index %= $game_party.actors.size
  509.       # 切换到别的特技画面
  510.       $scene = Scene_Skill.new(@actor_index)
  511.       return
  512.     end
  513.     # 按下 L 键的情况下
  514.     if Input.trigger?(Input::L)
  515.       # 演奏光标 SE
  516.       $game_system.se_play($data_system.cursor_se)
  517.       # 移至上一位角色
  518.       @actor_index += $game_party.actors.size - 1
  519.       @actor_index %= $game_party.actors.size
  520.       # 切换到别的特技画面
  521.       $scene = Scene_Skill.new(@actor_index)
  522.       return
  523.     end
  524.   end
  525.   #--------------------------------------------------------------------------
  526.   # ● 刷新画面 (目标窗口被激活的情况下)
  527.   #--------------------------------------------------------------------------
  528.   def update_target
  529.     # 按下 B 键的情况下
  530.     if Input.trigger?(Input::B)
  531.       # 演奏取消 SE
  532.       $game_system.se_play($data_system.cancel_se)
  533.       # 删除目标窗口
  534.       @skill_window.active = true
  535.       @target_window.visible = false
  536.       @target_window.active = false
  537.       return
  538.     end
  539.     # 按下 C 键的情况下
  540.     if Input.trigger?(Input::C)
  541.       # 因为 SP 不足而无法使用的情况下
  542.       unless @actor.skill_can_use?(@skill.id)
  543.         # 演奏冻结 SE
  544.         $game_system.se_play($data_system.buzzer_se)
  545.         return
  546.       end
  547.       # 目标是全体的情况下
  548.       if @target_window.index == -1
  549.         # 对同伴全体应用特技使用效果
  550.         used = false
  551.         for i in $game_party.actors
  552.           used |= i.skill_effect(@actor, @skill)
  553.         end
  554.       end
  555.       # 目标是使用者的情况下
  556.       if @target_window.index <= -2
  557.         # 对目标角色应用特技的使用效果
  558.         target = $game_party.actors[@target_window.index + 10]
  559.         used = target.skill_effect(@actor, @skill)
  560.       end
  561.       # 目标是单体的情况下
  562.       if @target_window.index >= 0
  563.         # 对目标角色应用特技的使用效果
  564.         target = $game_party.actors[@target_window.index]
  565.         used = target.skill_effect(@actor, @skill)
  566.       end
  567.       # 使用特技的情况下
  568.       if used
  569.         # 演奏特技使用时的 SE
  570.         $game_system.se_play(@skill.menu_se)
  571.         # 消耗 SP
  572.         @actor.sp -= @skill.sp_cost
  573.         # 额外的消耗
  574.         @actor.skill_cost_extra(@skill)
  575.         # 再生成各窗口内容
  576.         @status_window.refresh
  577.         @skill_window.refresh
  578.         @target_window.refresh
  579.         # 全灭的情况下
  580.         if $game_party.all_dead?
  581.           # 切换到游戏结束画面
  582.           $scene = Scene_Gameover.new
  583.           return
  584.         end
  585.         # 公共事件 ID 有效的情况下
  586.         if @skill.common_event_id > 0
  587.           # 预约调用公共事件
  588.           $game_temp.common_event_id = @skill.common_event_id
  589.           # 切换到地图画面
  590.           $scene = Scene_Map.new
  591.           return
  592.         end
  593.       end
  594.       # 无法使用特技的情况下
  595.       unless used
  596.         # 演奏冻结 SE
  597.         $game_system.se_play($data_system.buzzer_se)
  598.       end
  599.       return
  600.     end
  601.   end
  602. end

RUBY 代码复制
  1. #==============================================================================
  2. # ■ Window_Help
  3. #------------------------------------------------------------------------------
  4. #  特技及物品的说明、角色的状态显示的窗口。
  5. #==============================================================================
  6. #需要调整的项目:
  7. #界面的重新设计
  8. class Window_SkillHelp < Window_Base
  9.   #--------------------------------------------------------------------------
  10.   # ● 初始化对像
  11.   #--------------------------------------------------------------------------
  12.   def initialize
  13.     super(320-50, 0, 320+50,416)
  14.     self.contents = Bitmap.new(width - 32, height - 32)
  15.     if $game_temp.in_battle
  16.       self.height = 256+64
  17.       self.back_opacity = 160
  18.     end
  19.   end   
  20.   #--------------------------------------------------------------------------
  21.   # ● 设置文本
  22.   #     text  : 窗口显示的字符串
  23.   #     align : 对齐方式 (0..左对齐、1..中间对齐、2..右对齐)
  24.   #--------------------------------------------------------------------------
  25.   def set_text2(skill)
  26.     if skill !=nil
  27.       fontsize=18        #定义文字大小
  28.       infx=100           #定义说明文字左边内容的宽度
  29.       y=20               #定义行距
  30.       self.contents.clear
  31.       self.contents.font.color = normal_color
  32.       self.contents.font.size = fontsize
  33.       xx=0
  34.       yy=0
  35.       s=[]
  36.       s=skill.description.scan(/./)
  37.       space = self.contents.text_size(" ").width
  38.       #一行显示21个字
  39.       for i in s
  40.         sss = self.contents.text_size(i)
  41.         if (xx+sss.width)>(width - 32)#超过屏幕就换行
  42.           yy+=y
  43.           xx=4
  44.         end
  45.         self.contents.draw_text(xx, yy, sss.width, sss.height, i)
  46.         xx+=sss.width
  47.       end
  48.       self.contents.font.size = fontsize
  49. ################################################################################
  50.       xx=0
  51.       yy+=y
  52.       self.contents.font.color=system_color
  53.       self.contents.draw_text(xx, yy, infx, sss.height, "效果范围")
  54.       xx=infx
  55.       self.contents.font.color=normal_color
  56.       case skill.scope
  57.       when 0
  58.         i="无"
  59.         when 1
  60.           i="敌方单体"
  61.           when 2
  62.             i="敌方全体"
  63.             when 3
  64.               i="我方单体"
  65.               when 4
  66.                 i="我方全体"
  67.                 when 5
  68.                   i="我方濒死单体"
  69.                   when 6
  70.                     i="我方濒死全体"
  71.                     when 7
  72.                       i="自身"
  73.       end
  74.       self.contents.draw_text(xx, yy, infx, sss.height, i)
  75.       xx=0
  76.       yy+=y
  77. ################################################################################
  78.       self.contents.font.color=system_color
  79.       self.contents.draw_text(xx, yy, infx, sss.height, "基础威力")
  80.       xx=infx
  81.       self.contents.font.color=normal_color
  82.       self.contents.draw_text(xx, yy, infx*2, sss.height, skill.power.to_s)
  83.       xx=0
  84.       yy+=y
  85. ################################################################################
  86.       self.contents.font.color=system_color
  87.       self.contents.draw_text(xx, yy, infx, sss.height, "ATK影响度")
  88.       xx=infx
  89.       self.contents.font.color=normal_color
  90.       self.contents.draw_text(xx, yy, infx*2, sss.height, "ATK "+skill.atk_f.to_s)      
  91.       xx=0
  92.       yy+=y
  93. ################################################################################
  94.       self.contents.font.color=system_color
  95.       self.contents.draw_text(xx, yy, infx, sss.height, "四维分布")
  96.       xx=infx
  97.       self.contents.font.color=normal_color
  98.       if skill.str_f>1
  99.         self.contents.font.color=Color.new(255,0,0,255)
  100.         self.contents.draw_text(xx, yy, infx*2, sss.height, "力量 "+skill.str_f.to_s)
  101.         xx+=80
  102.       end
  103.       if skill.dex_f>1
  104.         self.contents.font.color=Color.new(34,127,56,255)
  105.         self.contents.draw_text(xx, yy, infx*2, sss.height, "敏捷 "+skill.dex_f.to_s)
  106.         xx+=80
  107.       end
  108.       if skill.agi_f>1
  109.         self.contents.font.color=Color.new(255,241,0,255)
  110.         self.contents.draw_text(xx, yy, infx*2, sss.height, "速度 "+skill.agi_f.to_s)
  111.         xx+=80
  112.       end
  113.       if skill.int_f>1&&xx>260
  114.         yy+=y
  115.         xx=infx
  116.         self.contents.font.color=Color.new(0,117,169,255)
  117.         self.contents.draw_text(xx, yy, infx*2, sss.height, "法强 "+skill.int_f.to_s)
  118.       end
  119.       xx=0
  120.       yy+=y
  121. ################################################################################
  122.       self.contents.font.color=system_color
  123.       self.contents.draw_text(xx, yy, infx, sss.height, "攻击属性占比")
  124.       xx=infx
  125.       self.contents.font.color=normal_color
  126.       self.contents.draw_text(xx, yy, infx*2, sss.height, "物理 "+skill.pdef_f.to_s+"  魔法 "+skill.mdef_f.to_s)      
  127.       xx=0
  128.       yy+=y
  129. ################################################################################
  130.       self.contents.font.color=system_color
  131.       self.contents.draw_text(xx, yy, infx, sss.height, "伤害浮动度(%)")
  132.       xx=infx
  133.       self.contents.font.color=normal_color
  134.       self.contents.draw_text(xx, yy, infx*2, sss.height, skill.variance.to_s)
  135.       xx=0
  136.       yy+=y
  137. ################################################################################
  138.       self.contents.font.color=system_color
  139.       self.contents.draw_text(xx, yy, infx, sss.height, "基础命中")
  140.       xx=infx
  141.       self.contents.font.color=normal_color
  142.       self.contents.draw_text(xx, yy, infx*2, sss.height, skill.hit.to_s)
  143.       xx=0
  144.       yy+=y
  145.       self.contents.font.color=system_color
  146.       self.contents.draw_text(xx, yy, infx, sss.height, "回避修正")
  147.       xx=infx
  148.       self.contents.font.color=normal_color
  149.       self.contents.draw_text(xx, yy, infx*2, sss.height, skill.eva_f.to_s)
  150.       xx=0
  151.       yy+=y
  152. ################################################################################
  153.       element=""
  154.       race=""      
  155.       for i in skill.element_set#这里是,属性与种族的区别
  156.         if i <=25#1-25为属性
  157.           element =element+" "+$data_system.elements[i]
  158.         elsif i>25 and i<=50#25-50位种族
  159.           race=race+" "+$data_system.elements[i]
  160.         end
  161.         if i>50
  162.           break
  163.         end
  164.       end
  165.       self.contents.font.color=system_color
  166.       self.contents.draw_text(xx, yy, infx, sss.height, "特效对象种族")
  167.       xx=infx-space
  168.       self.contents.font.color=normal_color
  169.       s=[]
  170.       s=race.scan(/./)
  171.       #一行显示21个字
  172.       for i in s
  173.         sss = self.contents.text_size(i)
  174.         if (xx+sss.width)>(width - 32)#超过屏幕就换行
  175.           yy+=y
  176.           xx=infx
  177.         end
  178.         self.contents.draw_text(xx, yy, sss.width, sss.height, i)
  179.         xx+=sss.width
  180.       end
  181.       yy+=y
  182.       xx=0
  183.       self.contents.font.color=system_color
  184.       self.contents.draw_text(xx, yy, infx, sss.height, "附加属性")
  185.       xx=infx-space
  186.       self.contents.font.color=normal_color
  187.       s=[]
  188.       s=element.scan(/./)
  189.       #一行显示21个字
  190.       for i in s
  191.         sss = self.contents.text_size(i)
  192.         if (xx+sss.width)>(width - 32)#超过屏幕就换行
  193.           yy+=y
  194.           xx=infx
  195.         end
  196.         self.contents.draw_text(xx, yy, sss.width, sss.height, i)
  197.         xx+=sss.width
  198.       end
  199.       xx=0
  200.       yy+=y
  201. ################################################################################
  202.       race=""
  203.       for i in skill.plus_state_set
  204.           race=race+"["+$data_states[i].name+"]"
  205.       end
  206.       self.contents.font.color=system_color
  207.       self.contents.draw_text(xx, yy, infx, sss.height, "状态变化")
  208.       xx=infx
  209.       self.contents.font.color=normal_color
  210.       s=[]
  211.       s=race.scan(/./)
  212.       #一行显示21个字
  213.       for i in s
  214.         sss = self.contents.text_size(i)
  215.         if (xx+sss.width)>(width - 32)#超过屏幕就换行
  216.           yy+=y
  217.           xx=infx
  218.         end
  219.         self.contents.draw_text(xx, yy, sss.width, sss.height, i)
  220.         xx+=sss.width
  221.       end
  222.       xx=0
  223.       yy+=y
  224. ################################################################################
  225.       race=""
  226.       for i in skill.minus_state_set
  227.           race=race+"["+$data_states[i].name+"]"
  228.       end
  229.       self.contents.font.color=system_color
  230.       self.contents.draw_text(xx, yy, infx, sss.height, "解除效果")
  231.       xx=infx
  232.       self.contents.font.color=normal_color
  233.       s=[]
  234.       s=race.scan(/./)
  235.       #一行显示21个字
  236.       for i in s
  237.         sss = self.contents.text_size(i)
  238.         if (xx+sss.width)>(width - 32)#超过屏幕就换行
  239.           yy+=y
  240.           xx=infx
  241.         end
  242.         self.contents.draw_text(xx, yy, sss.width, sss.height, i)
  243.         xx+=sss.width
  244.       end
  245.       @actor = nil
  246.     end
  247.     self.visible = true
  248.     xx=0
  249.     yy+=y
  250. ################################################################################
  251.     self.contents.font.color=system_color
  252.     self.contents.draw_text(xx, yy, infx, sss.height, "冷却时间")
  253.     xx=infx
  254.     self.contents.font.color=normal_color
  255.     if $data_skills[skill.id].cooldown>0
  256.       self.contents.draw_text(xx, yy, infx*2, sss.height,$data_skills[skill.id].cooldown.to_s+"回合 ")
  257.       self.contents.draw_text(xx+60, yy, infx*2, sss.height,"剩余"+@cooldowns[skill.id]+"回合")
  258.     else
  259.       self.contents.draw_text(xx, yy, infx*2, sss.height,"无")
  260.     end
  261.     xx=0
  262.     yy+=y
  263.   end
  264. end

Lv6.析梦学徒

老鹰

梦石
40
星屑
33387
在线时间
6550 小时
注册时间
2012-5-26
帖子
3178

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

2
发表于 2019-4-5 12:01:01 | 只看该作者
先搜索技能使用条件判定,发现
  1.     # 战斗时,冷却中的情况下,不能使用
  2.     elsif $game_temp.in_battle and cooldown?(skill_id)
  3.       return false
复制代码

于是接着搜索这个方法,发现
  1.   #--------------------------------------------------------------------------
  2.   # ● 冷却中判定
  3.   #     skill_id : 特技 ID
  4.   #--------------------------------------------------------------------------
  5.   def cooldown?(skill_id)
  6.     @cooldowns.has_key?(skill_id)
  7.   end
复制代码

再看这个hash,发现
  1.   #--------------------------------------------------------------------------
  2.   # ● 设置冷却技能
  3.   #     skill_id : 特技 ID
  4.   #--------------------------------------------------------------------------
  5.   def set_cooldown(skill_id)
  6.     if $data_skills[skill_id].cooldown > 0
  7.       @cooldowns[skill_id] = $data_skills[skill_id].cooldown
  8.     end
  9.   end
复制代码

以及你那个窗口里面不是已经写了么
  1. self.contents.draw_text(xx+60, yy, infx*2, sss.height,"剩余"+@cooldowns[skill.id]+"回合")
复制代码
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1293
在线时间
118 小时
注册时间
2017-7-14
帖子
148
3
 楼主| 发表于 2019-4-6 09:58:01 | 只看该作者
百里_飞柳 发表于 2019-4-5 12:01
先搜索技能使用条件判定,发现

于是接着搜索这个方法,发现

要是那样写没问题我就不会来问了吗==按那样写...进入技能板面后报错..如下图=

{65036AQC$18MY[HDDR]J5Q.png (424.56 KB, 下载次数: 18)

{65036AQC$18MY[HDDR]J5Q.png

点评

……你绘制的地方是window类,然后这个数组在Game_Actor类里面,当然是要传入一个actor的实例(当前绘制技能的角色)调用actor.cooldowns去绘制了  发表于 2019-4-6 14:34
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
33143
在线时间
10485 小时
注册时间
2009-3-15
帖子
4756
4
发表于 2019-4-6 10:25:40 | 只看该作者
$data_skills[skill_id].cooldown

点评

emmm...我忘记加to_s了...但是这样子写只能表示原本的冷却时间...而不能表示还剩多少冷却啊==  发表于 2019-4-6 10:30
然而这样写就会出现类型错误==  发表于 2019-4-6 10:28
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
33143
在线时间
10485 小时
注册时间
2009-3-15
帖子
4756
5
发表于 2019-4-6 11:45:48 | 只看该作者
@actor.cooldowns[skill.id].to_s
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1293
在线时间
118 小时
注册时间
2017-7-14
帖子
148
6
 楼主| 发表于 2019-4-6 11:48:29 | 只看该作者
soulsaga 发表于 2019-4-6 11:45
@actor.cooldowns[skill.id].to_s

emmmmmmmm...

{65036AQC$18MY[HDDR]J5Q.png (424.56 KB, 下载次数: 20)

{65036AQC$18MY[HDDR]J5Q.png

点评

返回值是nil和4  发表于 2019-4-6 11:59
还是算了..直接注译掉245行吧那句吧..  发表于 2019-4-6 11:58
在显示信息上面插一行p @actor  发表于 2019-4-6 11:57
emmm...改脚本不久...不知道p是什么意思QAQ  发表于 2019-4-6 11:55
如果@actor是空的就把245行@actor = nil注译掉..  发表于 2019-4-6 11:53
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1293
在线时间
118 小时
注册时间
2017-7-14
帖子
148
7
 楼主| 发表于 2019-4-6 11:58:25 | 只看该作者
soulsaga 发表于 2019-4-6 11:45
@actor.cooldowns[skill.id].to_s

试了一下注释掉..然后变成了这样==

I3X2J1NE)ZIP1DDAWV0O`A2.png (16.79 KB, 下载次数: 21)

I3X2J1NE)ZIP1DDAWV0O`A2.png

点评

说起来..这个变量是个哈希表..  发表于 2019-4-6 12:01
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
33143
在线时间
10485 小时
注册时间
2009-3-15
帖子
4756
8
发表于 2019-4-6 12:03:04 | 只看该作者
本帖最后由 soulsaga 于 2019-4-6 12:06 编辑
wyw838 发表于 2019-4-6 11:58
试了一下注释掉..然后变成了这样==


这个不对.....

点评

其实大佬你可以用这两个脚本实操一下==这两个脚本不要其他东西前置的..我下午得去考试,可能不能秒回了==  发表于 2019-4-6 12:07
然而还是和上面一样==  发表于 2019-4-6 12:04
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
33143
在线时间
10485 小时
注册时间
2009-3-15
帖子
4756
9
发表于 2019-4-6 12:11:02 | 只看该作者
本帖最后由 soulsaga 于 2019-4-8 13:53 编辑


self.contents.draw_text(xx+60, yy, infx*2, sss.height,"剩余"[email protected][skill.id].to_s+"回合") if @actor.cooldowns.has_key?(skill.id)

点评

嗯..我晚上找时间试试QWQ  发表于 2019-4-6 12:13
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1293
在线时间
118 小时
注册时间
2017-7-14
帖子
148
10
 楼主| 发表于 2019-4-7 22:11:07 | 只看该作者
soulsaga 发表于 2019-4-6 12:11
self.contents.draw_text(xx+60, yy, infx*2, sss.height,"剩余"[email protected][skill.id].to_s+"回合 ...

然而==还是这样==QAQ

1019`[]BOW(O3$~U}LA)3XS.png (527.59 KB, 下载次数: 21)

1019`[]BOW(O3$~U}LA)3XS.png

点评

更新了..再试  发表于 2019-4-8 10:41
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-19 17:32

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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