查看: 2864|回复: 5

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

[复制链接]
梦石
0
星屑
354
在线时间
127 小时
注册时间
2016-10-8
回帖
54
发表于 2018-4-24 00:39:31 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 elemmy72 于 2018-4-24 00:39 编辑

先附上腳本才是乖孩紙
  1. #==============================================================================
  2. # +++ 角色生命护盾 +++
  3. #==============================================================================
  4. # 作者 By 三途亚梦
  5. #  -- 本脚本来自 [url]https://rpg.blue[/url] 使用或转载请保留以上信息。
  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.   HspClear = true  #是否在战斗结束时清除掉玩家剩余的生命护盾

  41.   HspNoAddition = true #是否采用本脚本的计算伤害的方法

  42.   HspName = "防護罩"  #生命护盾的名字

  43.   HspABonus = "%s 的%s剩餘 %s點!"  #玩家人物的生命护盾损伤后显示剩余值的文字

  44.   HspEBonus = "%s 的%s剩餘 %s點!"  #敌人的生命护盾损伤后显示剩余值的文字

  45.   HspADamage = "%s 的%s受到 %s點傷害!"  #玩家人物的生命护盾受到伤害的文字

  46.   HspEDamage = "%s 的%s受到 %s點傷害!"  #敌人的生命护盾受到伤害的文字

  47.   HspARecovery  = "%s 獲得了 %s點 的%s保護!" #玩家的生命护盾得到提高的文字

  48.   HspERecovery  = "%s 被賦予 %s點 的%s保護!" #敌人的生命护盾得到提高的文字

  49.   HspADestory  = "%s 的%s受到 %s點傷害 而遭到擊破!" #玩家的生命护盾被击破时的文字

  50.   HspEDestroy  = "%s 的%s受到 %s點傷害 而被擊破了!" #敌人的生命护盾被击破时的文字

  51.   def self.play_actor_amuhspdamage  # 玩家的生命护盾受到伤害的音效
  52.     Audio.se_play("Audio/SE/sword1.ogg", 100, 50)
  53.   end

  54.   def self.play_enemy_amuhspdamage   # 敌人的生命护盾受到伤害的音效
  55.     Audio.se_play("Audio/SE/sword1.ogg", 100, 50)
  56.   end

  57.   def self.play_amuhsp_destory   # 生命护盾被击破时的音效
  58.     Audio.se_play("Audio/SE/Crash.ogg", 60, 90)
  59.   end

  60.   end
  61. end

  62. class Game_ActionResult
  63.   #--------------------------------------------------------------------------
  64.   # ● 定义实例变量
  65.   #--------------------------------------------------------------------------
  66.   attr_accessor :amuhsp_damage                # 生命护盾 伤害
  67.   #--------------------------------------------------------------------------
  68.   # ● 清除伤害值`
  69.   #--------------------------------------------------------------------------
  70.   alias amu_20141125_clear_damage_values clear_damage_values
  71.   def clear_damage_values
  72.     amu_20141125_clear_damage_values
  73.      @amuhsp_damage = 0
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ● 生成伤害
  77.   #--------------------------------------------------------------------------
  78.   alias amu_20141125_make_damage make_damage
  79.   def make_damage(value, item)
  80.     amu_20141125_make_damage(value, item)
  81.     @amuhsp_damage = value if item.damage.to_hp? && @battler.amuhsp > 0 && value > 0
  82.     @amuhsp_damage = value if item.damage.to_hp? && item.damage.recover? && item.note.include?("[护盾恢复]")
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● 获取具有生命护盾时 HP 伤害的文字
  86.   #--------------------------------------------------------------------------
  87.   def hp_damage_text
  88.     if @hp_drain > 0
  89.       fmt = @battler.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
  90.       sprintf(fmt, @battler.name, Vocab::hp, @hp_drain)
  91.     elsif @hp_damage > 0
  92.       fmt = @battler.actor? ? Vocab::ActorDamage : Vocab::EnemyDamage
  93.       sprintf(fmt, @battler.name, @hp_damage)
  94.     elsif @hp_damage < 0
  95.       fmt = @battler.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
  96.       sprintf(fmt, @battler.name, Vocab::hp, -hp_damage)
  97.     elsif @hp_damage = 0 && @battler.amuhsp > 0
  98.       fmt = @battler.actor? ? Amu::Hsp::HspABonus : Amu::Hsp::HspEBonus
  99.       sprintf(fmt, @battler.name, Amu::Hsp::HspName, @battler.amuhsp)
  100.     else
  101.       fmt = @battler.actor? ? Vocab::ActorNoDamage : Vocab::EnemyNoDamage
  102.       sprintf(fmt, @battler.name)
  103.     end
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # ● 获取 生命护盾 伤害的文字
  107.   #--------------------------------------------------------------------------
  108.   def amuhsp_damage_text
  109.     if @amuhsp_damage > 0 && @battler.amuhsp > 0
  110.       fmt = @battler.actor? ? Amu::Hsp::HspADamage : Amu::Hsp::HspEDamage
  111.       sprintf(fmt, @battler.name, Amu::Hsp::HspName, @amuhsp_damage)
  112.     elsif @amuhsp_damage > 0 && @battler.amuhsp == 0
  113.       fmt = @battler.actor? ? Amu::Hsp::HspADestory : Amu::Hsp::HspEDestroy
  114.       sprintf(fmt, @battler.name, Amu::Hsp::HspName, @amuhsp_damage)
  115.     elsif @amuhsp_damage < 0
  116.       fmt = @battler.actor? ? Amu::Hsp::HspARecovery : Amu::Hsp::HspERecovery
  117.       sprintf(fmt, @battler.name, -@amuhsp_damage, Amu::Hsp::HspName)
  118.     else
  119.       ""
  120.     end
  121.   end
  122. end


  123. class Game_BattlerBase
  124.   attr_reader   :amuhsp                       # 生命护盾
  125.   #--------------------------------------------------------------------------
  126.   # ● 初始化对象
  127.   #--------------------------------------------------------------------------
  128.   alias amu_20141125_initialize initialize
  129.   def initialize
  130.     amu_20141125_initialize
  131.     @amuhsp = 0
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # ● 更改 HSP
  135.   #--------------------------------------------------------------------------
  136.   def amuhsp=(amuhsp)
  137.     @amuhsp = amuhsp
  138.     refresh
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # ● 刷新
  142.   #--------------------------------------------------------------------------
  143.   alias amu_20141125_refresh refresh
  144.   def refresh
  145.     amu_20141125_refresh
  146.     @amuhsp = [@amuhsp, 0].max
  147.   end
  148. end

  149. class Game_Battler < Game_BattlerBase
  150.   #--------------------------------------------------------------------------
  151.   # ● 计算伤害
  152.   #--------------------------------------------------------------------------
  153.   if Amu::Hsp::HspNoAddition == true
  154.     def make_damage_value(user, item)
  155.       value = item.damage.eval(user, self, $game_variables)
  156.       value *= item_element_rate(user, item)
  157.       value *= pdr if item.physical? && !make_amuhsp?(item)
  158.       value *= mdr if item.magical? && !make_amuhsp?(item)
  159.       value *= rec if item.damage.recover? && !make_amuhsp?(item)
  160.       value = apply_critical(value) if @result.critical
  161.       value = apply_variance(value, item.damage.variance)
  162.       value = apply_guard(value)
  163.       if make_amuhsp?(item)
  164.         def actor_amuhsp?
  165.           return true
  166.         end
  167.       end
  168.       @result.make_damage(value.to_i, item)
  169.     end
  170.   else
  171.     alias amu_20141125_make_damage_value make_damage_value
  172.     def make_damage_value(user, item)
  173.       amu_20141125_make_damage_value(user, item)
  174.       if make_amuhsp?(item)
  175.         def actor_amuhsp?
  176.           return true
  177.         end
  178.       end
  179.     end
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # ● 处理伤害
  183.   #    调用前需要设置好
  184.   #    @result.hp_damage   @result.mp_damage
  185.   #    @result.hp_drain    @result.mp_drain
  186.   #--------------------------------------------------------------------------
  187.   def execute_damage(user)
  188.     on_damage(@result.hp_damage) if @result.hp_damage > 0
  189.     if self.amuhsp > 0 && @result.hp_damage > 0
  190.       eamuhsp = self.amuhsp
  191.       self.amuhsp -= @result.hp_damage
  192.       self.amuhsp <= 0 ? @result.hp_damage -= eamuhsp : @result.hp_damage = 0
  193.     end
  194.     if actor_amuhsp?
  195.       self.amuhsp -= @result.hp_damage
  196.       @result.hp_damage = 0
  197.       def actor_amuhsp?
  198.         return false
  199.       end
  200.     else
  201.       self.hp -= @result.hp_damage
  202.     end
  203.     self.mp -= @result.mp_damage
  204.     user.hp += @result.hp_drain
  205.     user.mp += @result.mp_drain
  206.   end
  207.   #--------------------------------------------------------------------------
  208.   # ● 判断技能是否用来增加生命护盾
  209.   #--------------------------------------------------------------------------
  210.   def make_amuhsp?(item)
  211.     return false unless item.is_a?(RPG::Skill)
  212.     return item.note.include?("[护盾恢复]")
  213.   end
  214.   def actor_amuhsp?
  215.     return false
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # ● 清除 生命护盾
  219.   #--------------------------------------------------------------------------
  220.   def clear_amuhsp
  221.     self.amuhsp = 0
  222.   end
  223.   #--------------------------------------------------------------------------
  224.   # ● 战斗结束处理
  225.   #--------------------------------------------------------------------------
  226.   alias amu_20141125_on_battle_end on_battle_end
  227.   def on_battle_end
  228.     amu_20141125_on_battle_end
  229.     clear_amuhsp if Amu::Hsp::HspClear == true
  230.   end
  231. end

  232. class Game_Actor < Game_Battler
  233.   #--------------------------------------------------------------------------
  234.   # ● 设置具有生命护盾时玩家被击的效果
  235.   #--------------------------------------------------------------------------
  236.   def perform_hspdamage_effect
  237.     $game_troop.screen.start_shake(5, 5, 10)
  238.     @sprite_effect_type = :blink
  239.     Amu::Hsp.play_actor_amuhspdamage
  240.   end
  241. end

  242. class Game_Enemy < Game_Battler
  243.   #--------------------------------------------------------------------------
  244.   # ● 设置具有生命护盾时敌人被击的效果
  245.   #--------------------------------------------------------------------------
  246.   def perform_hspdamage_effect
  247.     $game_troop.screen.start_shake(5, 5, 10)
  248.     @sprite_effect_type = :blink
  249.     Amu::Hsp.play_enemy_amuhspdamage
  250.   end
  251. end

  252. class Window_BattleLog < Window_Selectable
  253.   #--------------------------------------------------------------------------
  254.   # ● 显示伤害
  255.   #--------------------------------------------------------------------------
  256.   def display_damage(target, item)
  257.     if target.result.missed
  258.       display_miss(target, item)
  259.     elsif target.result.evaded
  260.       display_evasion(target, item)
  261.     else
  262.       display_amuhsp_damage(target, item)
  263.       display_hp_damage(target, item)
  264.       display_mp_damage(target, item)
  265.       display_tp_damage(target, item)
  266.     end
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # ● 显示 生命护盾 伤害
  270.   #--------------------------------------------------------------------------
  271.   def display_amuhsp_damage(target, item)
  272.     return if target.dead? || target.result.amuhsp_damage == 0
  273.     if target.result.amuhsp_damage > 0 && target.amuhsp > 0 && target.result.hp_drain == 0
  274.       target.perform_hspdamage_effect
  275.     end
  276.     Amu::Hsp.play_amuhsp_destory if target.result.amuhsp_damage > 0 && target.amuhsp == 0
  277.     Sound.play_recovery if target.result.amuhsp_damage < 0
  278.     add_text(target.result.amuhsp_damage_text)
  279.     wait
  280.   end
  281. end
复制代码


其實很簡單的問題,

只是想問問運用到敵人時該輸入什麼代碼……

我試了 $game_troop.members[敌人ID].amuhsp += 300

但是沒有效果,雖不會報錯,但也跳不出腳本中顯示敵人護盾被打的訊息字樣。

我是像角色的設置一樣設計一個技能連結公共事件觸發腳本的,

難道要在敵群裡設置嗎?但我感覺沒什麼差別...

可能是我輸入的代碼是錯的,可我也不曉得該輸入什麼了啊
(´_ゝ`)...仍未命名的遊戲製作進度:0%
梦石
0
星屑
1626
在线时间
193 小时
注册时间
2016-10-22
回帖
80
发表于 2018-4-24 18:40:14 | 显示全部楼层
技能的护盾恢复敌人也是可以用的
回复

使用道具 举报

梦石
0
星屑
354
在线时间
127 小时
注册时间
2016-10-8
回帖
54
 楼主| 发表于 2018-4-26 23:43:26 | 显示全部楼层
有大大能幫忙一下嗎?
(´_ゝ`)...仍未命名的遊戲製作進度:0%
回复

使用道具 举报

梦石
0
星屑
70
在线时间
39 小时
注册时间
2014-9-27
回帖
13
发表于 2018-4-29 22:30:47 | 显示全部楼层
★人物的生命护盾是amuhsp,
可以通过$game_actors[角色ID].amuhsp += 之类的方式在事件中改变它的数值。
这个是通过事件-脚本给角色加护盾用的……

★将技能设置成体力值恢复,并在技能备注栏备注“[护盾恢复]”,
那么这个技能将变成增加目标角色的生命护盾值
★备注的时候不需要写入“”引号
这个是正常的使用方法,给敌人设置这个技能就好了
回复 1 0

使用道具 举报

梦石
0
星屑
2920
在线时间
713 小时
注册时间
2010-7-25
回帖
659

开拓者

发表于 2018-5-2 08:14:23 | 显示全部楼层
$game_troop[敌人编号].amuhsp += 300 if $game_troop[敌人编号];
使用前应先判定该编号位置的敌人是否存在
回复 1 0

使用道具 举报

梦石
0
星屑
354
在线时间
127 小时
注册时间
2016-10-8
回帖
54
 楼主| 发表于 2018-5-3 11:54:49 | 显示全部楼层
感謝三位大大的回答!

已成功解決
(´_ゝ`)...仍未命名的遊戲製作進度:0%
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部