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

Project1

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

[已经解决] 關於三途亞夢大大的生命護盾

[复制链接]

Lv2.观梦者

梦石
0
星屑
878
在线时间
118 小时
注册时间
2016-8-27
帖子
19
跳转到指定楼层
1
发表于 2018-11-17 18:16:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 iamsoworry12 于 2018-11-17 18:50 编辑

RUBY 代码复制
  1. #==============================================================================
  2. # +++ 角色生命护盾 +++
  3. #==============================================================================
  4. # 作者 By 三途亚梦
  5. #  -- 本脚本来自 https://rpg.blue 使用或转载请保留以上信息。
  6. #==============================================================================
  7. # 本脚本的作用是给玩家人物、敌人添加一个新的能力值“生命护盾”,
  8. # 生命护盾会吸收该角色受到的来自技能造成的体力伤害。
  9. #==============================================================================
  10. #
  11. # ★再次强调,生命护盾仅仅吸收来自“技能”造成的体力伤害!
  12. #
  13. # ★人物的生命护盾是amuhsp,
  14. # 可以通过$game_actors[角色ID].amuhsp += 之类的方式在事件中改变它的数值。
  15. #
  16. # ★HspClear = true 时,人物的生命护盾将在战斗结束时清零。
  17. # 如果不想清零请将 true改为false
  18. #
  19. # ★HspNoAddition = true 时,
  20. # 生命护盾的恢复将不享受恢复效果、物理及魔法伤害比率的加成,
  21. # 但是会对 make_damage_value 的方法做出改变,会降低本脚本的兼容性。
  22. #
  23. # 设定部分所有文字信息的描述方法修改时请保留“”引号。
  24. #
  25. # ★将技能设置成体力值恢复,并在技能备注栏备注“[护盾恢复]”,
  26. # 那么这个技能将变成增加目标角色的生命护盾值
  27. # ★备注的时候不需要写入“”引号
  28. #
  29. # 角色的生命护盾没有上限,下限为0
  30. #
  31. # 如果需要设置一个技能为角色体力值的10%,又不想令护盾无限的加下去
  32. # 技能公式请参照这个写法:
  33. # b.hp * 0.1 - b.amuhsp [护盾恢复]
  34. #
  35. #==============================================================================
  36. # ★ 设定部分 ★
  37. #==============================================================================
  38. module Amu
  39.   module Hsp
  40.  
  41.   HspClear = true  #是否在战斗结束时清除掉玩家剩余的生命护盾
  42.  
  43.   HspNoAddition = true #是否采用本脚本的计算伤害的方法
  44.  
  45.   HspName = "防護罩"  #生命护盾的名字
  46.  
  47.   HspABonus = "%s 的%s剩餘 %s點!"  #玩家人物的生命护盾损伤后显示剩余值的文字
  48.  
  49.   HspEBonus = "%s 的%s剩餘 %s點!"  #敌人的生命护盾损伤后显示剩余值的文字
  50.  
  51.   HspADamage = "%s 的%s受到 %s點傷害!"  #玩家人物的生命护盾受到伤害的文字
  52.  
  53.   HspEDamage = "%s 的%s受到 %s點傷害!"  #敌人的生命护盾受到伤害的文字
  54.  
  55.   HspARecovery  = "%s 獲得了 %s點 的%s保護!" #玩家的生命护盾得到提高的文字
  56.  
  57.   HspERecovery  = "%s 被賦予 %s點 的%s保護!" #敌人的生命护盾得到提高的文字
  58.  
  59.   HspADestory  = "%s 的%s受到 %s點傷害 而遭到擊破!" #玩家的生命护盾被击破时的文字
  60.  
  61.   HspEDestroy  = "%s 的%s受到 %s點傷害 而被擊破了!" #敌人的生命护盾被击破时的文字
  62.  
  63.   def self.play_actor_amuhspdamage  # 玩家的生命护盾受到伤害的音效
  64.     Audio.se_play("Audio/SE/sword1.ogg", 100, 50)
  65.   end
  66.  
  67.   def self.play_enemy_amuhspdamage   # 敌人的生命护盾受到伤害的音效
  68.     Audio.se_play("Audio/SE/sword1.ogg", 100, 50)
  69.   end
  70.  
  71.   def self.play_amuhsp_destory   # 生命护盾被击破时的音效
  72.     Audio.se_play("Audio/SE/Crash.ogg", 60, 90)
  73.   end
  74.  
  75.   end
  76. end
  77.  
  78. class Game_ActionResult
  79.   #--------------------------------------------------------------------------
  80.   # ● 定义实例变量
  81.   #--------------------------------------------------------------------------
  82.   attr_accessor :amuhsp_damage                # 生命护盾 伤害
  83.   #--------------------------------------------------------------------------
  84.   # ● 清除伤害值`
  85.   #--------------------------------------------------------------------------
  86.   alias amu_20141125_clear_damage_values clear_damage_values
  87.   def clear_damage_values
  88.     amu_20141125_clear_damage_values
  89.      @amuhsp_damage = 0
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # ● 生成伤害
  93.   #--------------------------------------------------------------------------
  94.   alias amu_20141125_make_damage make_damage
  95.   def make_damage(value, item)
  96.     amu_20141125_make_damage(value, item)
  97.     @amuhsp_damage = value if item.damage.to_hp? && @battler.amuhsp > 0 && value > 0
  98.     @amuhsp_damage = value if item.damage.to_hp? && item.damage.recover? && item.note.include?("[护盾恢复]")
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # ● 获取具有生命护盾时 HP 伤害的文字
  102.   #--------------------------------------------------------------------------
  103.   def hp_damage_text
  104.     if @hp_drain > 0
  105.       fmt = @battler.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
  106.       sprintf(fmt, @battler.name, Vocab::hp, @hp_drain)
  107.     elsif @hp_damage > 0
  108.       fmt = @battler.actor? ? Vocab::ActorDamage : Vocab::EnemyDamage
  109.       sprintf(fmt, @battler.name, @hp_damage)
  110.     elsif @hp_damage < 0
  111.       fmt = @battler.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
  112.       sprintf(fmt, @battler.name, Vocab::hp, -hp_damage)
  113.     elsif @hp_damage = 0 && @battler.amuhsp > 0
  114.       fmt = @battler.actor? ? Amu::Hsp::HspABonus : Amu::Hsp::HspEBonus
  115.       sprintf(fmt, @battler.name, Amu::Hsp::HspName, @battler.amuhsp)
  116.     else
  117.       fmt = @battler.actor? ? Vocab::ActorNoDamage : Vocab::EnemyNoDamage
  118.       sprintf(fmt, @battler.name)
  119.     end
  120.   end
  121.   #--------------------------------------------------------------------------
  122.   # ● 获取 生命护盾 伤害的文字
  123.   #--------------------------------------------------------------------------
  124.   def amuhsp_damage_text
  125.     if @amuhsp_damage > 0 && @battler.amuhsp > 0
  126.       fmt = @battler.actor? ? Amu::Hsp::HspADamage : Amu::Hsp::HspEDamage
  127.       sprintf(fmt, @battler.name, Amu::Hsp::HspName, @amuhsp_damage)
  128.     elsif @amuhsp_damage > 0 && @battler.amuhsp == 0
  129.       fmt = @battler.actor? ? Amu::Hsp::HspADestory : Amu::Hsp::HspEDestroy
  130.       sprintf(fmt, @battler.name, Amu::Hsp::HspName, @amuhsp_damage)
  131.     elsif @amuhsp_damage < 0
  132.       fmt = @battler.actor? ? Amu::Hsp::HspARecovery : Amu::Hsp::HspERecovery
  133.       sprintf(fmt, @battler.name, -@amuhsp_damage, Amu::Hsp::HspName)
  134.     else
  135.       ""
  136.     end
  137.   end
  138. end
  139.  
  140.  
  141. class Game_BattlerBase
  142.   attr_reader   :amuhsp                       # 生命护盾
  143.   #--------------------------------------------------------------------------
  144.   # ● 初始化对象
  145.   #--------------------------------------------------------------------------
  146.   alias amu_20141125_initialize initialize
  147.   def initialize
  148.     amu_20141125_initialize
  149.     @amuhsp = 0
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # ● 更改 HSP
  153.   #--------------------------------------------------------------------------
  154.   def amuhsp=(amuhsp)
  155.     @amuhsp = amuhsp
  156.     refresh
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # ● 刷新
  160.   #--------------------------------------------------------------------------
  161.   alias amu_20141125_refresh refresh
  162.   def refresh
  163.     amu_20141125_refresh
  164.     @amuhsp = [@amuhsp, 0].max
  165.   end
  166. end
  167.  
  168. class Game_Battler < Game_BattlerBase
  169.   #--------------------------------------------------------------------------
  170.   # ● 计算伤害
  171.   #--------------------------------------------------------------------------
  172.   if Amu::Hsp::HspNoAddition == true
  173.     def make_damage_value(user, item)
  174.       value = item.damage.eval(user, self, $game_variables)
  175.       value *= item_element_rate(user, item)
  176.       value *= pdr if item.physical? && !make_amuhsp?(item)
  177.       value *= mdr if item.magical? && !make_amuhsp?(item)
  178.       value *= rec if item.damage.recover? && !make_amuhsp?(item)
  179.       value = apply_critical(value) if @result.critical
  180.       value = apply_variance(value, item.damage.variance)
  181.       value = apply_guard(value)
  182.       if make_amuhsp?(item)
  183.         def actor_amuhsp?
  184.           return true
  185.         end
  186.       end
  187.       @result.make_damage(value.to_i, item)
  188.     end
  189.   else
  190.     alias amu_20141125_make_damage_value make_damage_value
  191.     def make_damage_value(user, item)
  192.       amu_20141125_make_damage_value(user, item)
  193.       if make_amuhsp?(item)
  194.         def actor_amuhsp?
  195.           return true
  196.         end
  197.       end
  198.     end
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # ● 处理伤害
  202.   #    调用前需要设置好
  203.   #    @result.hp_damage   @result.mp_damage
  204.   #    @result.hp_drain    @result.mp_drain
  205.   #--------------------------------------------------------------------------
  206.   def execute_damage(user)
  207.     on_damage(@result.hp_damage) if @result.hp_damage > 0
  208.     if self.amuhsp > 0 && @result.hp_damage > 0
  209.       eamuhsp = self.amuhsp
  210.       self.amuhsp -= @result.hp_damage
  211.       self.amuhsp <= 0 ? @result.hp_damage -= eamuhsp : @result.hp_damage = 0
  212.     end
  213.     if actor_amuhsp?
  214.       self.amuhsp -= @result.hp_damage
  215.       @result.hp_damage = 0
  216.       def actor_amuhsp?
  217.         return false
  218.       end
  219.     else
  220.       self.hp -= @result.hp_damage
  221.     end
  222.     self.mp -= @result.mp_damage
  223.     user.hp += @result.hp_drain
  224.     user.mp += @result.mp_drain
  225.   end
  226.   #--------------------------------------------------------------------------
  227.   # ● 判断技能是否用来增加生命护盾
  228.   #--------------------------------------------------------------------------
  229.   def make_amuhsp?(item)
  230.     return false unless item.is_a?(RPG::Skill)
  231.     return item.note.include?("[护盾恢复]")
  232.   end
  233.   def actor_amuhsp?
  234.     return false
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # ● 清除 生命护盾
  238.   #--------------------------------------------------------------------------
  239.   def clear_amuhsp
  240.     self.amuhsp = 0
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # ● 战斗结束处理
  244.   #--------------------------------------------------------------------------
  245.   alias amu_20141125_on_battle_end on_battle_end
  246.   def on_battle_end
  247.     amu_20141125_on_battle_end
  248.     clear_amuhsp if Amu::Hsp::HspClear == true
  249.   end
  250. end
  251.  
  252. class Game_Actor < Game_Battler
  253.   #--------------------------------------------------------------------------
  254.   # ● 设置具有生命护盾时玩家被击的效果
  255.   #--------------------------------------------------------------------------
  256.   def perform_hspdamage_effect
  257.     $game_troop.screen.start_shake(5, 5, 10)
  258.     @sprite_effect_type = :blink
  259.     Amu::Hsp.play_actor_amuhspdamage
  260.   end
  261. end
  262.  
  263. class Game_Enemy < Game_Battler
  264.   #--------------------------------------------------------------------------
  265.   # ● 设置具有生命护盾时敌人被击的效果
  266.   #--------------------------------------------------------------------------
  267.   def perform_hspdamage_effect
  268.     $game_troop.screen.start_shake(5, 5, 10)
  269.     @sprite_effect_type = :blink
  270.     Amu::Hsp.play_enemy_amuhspdamage
  271.   end
  272. end
  273.  
  274. class Window_BattleLog < Window_Selectable
  275.   #--------------------------------------------------------------------------
  276.   # ● 显示伤害
  277.   #--------------------------------------------------------------------------
  278.   def display_damage(target, item)
  279.     if target.result.missed
  280.       display_miss(target, item)
  281.     elsif target.result.evaded
  282.       display_evasion(target, item)
  283.     else
  284.       display_amuhsp_damage(target, item)
  285.       display_hp_damage(target, item)
  286.       display_mp_damage(target, item)
  287.       display_tp_damage(target, item)
  288.     end
  289.   end
  290.   #--------------------------------------------------------------------------
  291.   # ● 显示 生命护盾 伤害
  292.   #--------------------------------------------------------------------------
  293.   def display_amuhsp_damage(target, item)
  294.     return if target.dead? || target.result.amuhsp_damage == 0
  295.     if target.result.amuhsp_damage > 0 && target.amuhsp > 0 && target.result.hp_drain == 0
  296.       target.perform_hspdamage_effect
  297.     end
  298.     Amu::Hsp.play_amuhsp_destory if target.result.amuhsp_damage > 0 && target.amuhsp == 0
  299.     Sound.play_recovery if target.result.amuhsp_damage < 0
  300.     add_text(target.result.amuhsp_damage_text)
  301.     wait
  302.   end
  303. end


先附上腳本
其他功能都沒什麼問題
就是當4個角色全部都按 "防禦"的時候
會跳出
第164行:發生ArgumentError。 comparison of Fixnum with nil failed
請問一下要怎麼解決呢

Lv2.观梦者

梦石
0
星屑
878
在线时间
118 小时
注册时间
2016-8-27
帖子
19
2
 楼主| 发表于 2018-11-17 21:12:42 | 只看该作者
重新開了個存檔就解決問題了...請版大幫忙把這帖刪了吧
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-26 13:56

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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