查看: 4760|回复: 5

[已经解决] 关于吸血技能的脚本

[复制链接]
梦石
0
星屑
1618
在线时间
267 小时
注册时间
2019-1-18
回帖
129
发表于 2019-3-21 23:23:44 | 显示全部楼层 |阅读模式

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

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

×
我有一个吸血技能的脚本,但这个脚本只能指定一个技能,我能不能让它可以使多个技能带有吸血效果?
  1. module CLD99
  2.   module Dracula

  3.     DRAIN_SKILL_ID = 74
  4.     # 领悟了此ID技能后,所有攻击带吸血

  5.     DRAIN_RATE = 0.1
  6.     # 因上面的情况允许吸血时的比例
  7.    
  8.   end
  9. end

  10. class Game_Battler
  11.   include CLD99::Dracula  
  12.   #--------------------------------------------------------------------------
  13.   # ● [追加]是否所有攻击带吸血
  14.   #--------------------------------------------------------------------------
  15.   def dracula?
  16.     puts @skills
  17.     @skills.include?(CLD99::Dracula::DRAIN_SKILL_ID)
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   # ● [别名修改]计算伤害
  21.   #--------------------------------------------------------------------------
  22.   alias :make_damage_value_for_dracula :make_damage_value
  23.   def make_damage_value(user, item)
  24.     make_damage_value_for_dracula(user, item)
  25.     @result.make_dracula(item) if user.actor? && user.dracula?
  26.   end
  27. end

  28. class Game_ActionResult
  29.   attr_reader :dracula
  30.   #--------------------------------------------------------------------------
  31.   # ● [追加]计算吸血
  32.   #--------------------------------------------------------------------------
  33.   def make_dracula(item)
  34.     return if item.damage.drain? # 自带吸血的技能不参与
  35.     return if @hp_damage < 0     # 回复类技能不参与
  36.     @hp_drain = (@hp_damage * CLD99::Dracula::DRAIN_RATE).to_i
  37.     @dracula = true
  38.   end  
  39.   #--------------------------------------------------------------------------
  40.   # ● [别名修改]获取 HP 伤害的文字
  41.   #--------------------------------------------------------------------------
  42.   alias hp_damage_text_for_dracula hp_damage_text
  43.   def hp_damage_text
  44.     if @dracula
  45.       fmt = "%s造成了%s伤害,吸收了\C[24]%s%s"
  46.       return sprintf(fmt, @battler.name, @hp_damage, @hp_drain, Vocab.hp)
  47.     end
  48.     hp_damage_text_for_dracula
  49.   end
  50. end

  51. class Window_BattleLog
  52.   #--------------------------------------------------------------------------
  53.   # ● 显示 HP 伤害
  54.   #--------------------------------------------------------------------------
  55.   alias :display_hp_damage_for_dracula :display_hp_damage
  56.   def display_hp_damage(target, item)
  57.     target.perform_damage_effect if target.result.dracula
  58.     display_hp_damage_for_dracula(target, item)
  59.   end
  60. end
复制代码
梦石
10
星屑
39550
在线时间
1919 小时
注册时间
2010-11-14
回帖
3214

R考场第七期纪念奖

发表于 2019-3-22 15:39:34 | 显示全部楼层
把20行改为
  1. CLD99::Dracula::DRAIN_SKILL_ID.any?{|id| @skills.include?(id)}
复制代码


然后把第四行改为数组,比如
  1. DRAIN_SKILL_ID = [74, 75, 76]
复制代码


注意,这样改完以后即使只有1个吸血技能,也不能去掉数组的方括号

点评

KB哥 你这个脚本怎么用啊 教我!  发表于 2019-4-2 19:48
用头画头像,用脚写脚本
回复

使用道具 举报

梦石
0
星屑
1618
在线时间
267 小时
注册时间
2019-1-18
回帖
129
 楼主| 发表于 2019-3-22 23:04:17 | 显示全部楼层

那如果我想让每个技能吸血比率都不同呢?

点评

KB 哥 这个脚本怎么用啊 我不会啊  发表于 2019-4-2 19:47
这个是制作吸血“被动技能”的脚本,一个角色不需要多个被动吸血技能吧  发表于 2019-3-23 09:12
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部