| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 9 |
| 经验 | |
| 最后登录 | 2026-8-5 |
| 在线时间 | 122 小时 |
- 梦石
- 0
- 星屑
- 947
- 在线时间
- 122 小时
- 注册时间
- 2016-8-27
- 回帖
- 12
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 iamsoworry12 于 2018-11-17 18:50 编辑
- #==============================================================================
- # +++ 角色生命护盾 +++
- #==============================================================================
- # 作者 By 三途亚梦
- # -- 本脚本来自 https://rpg.blue 使用或转载请保留以上信息。
- #==============================================================================
- # 本脚本的作用是给玩家人物、敌人添加一个新的能力值“生命护盾”,
- # 生命护盾会吸收该角色受到的来自技能造成的体力伤害。
- #==============================================================================
- #
- # ★再次强调,生命护盾仅仅吸收来自“技能”造成的体力伤害!
- #
- # ★人物的生命护盾是amuhsp,
- # 可以通过$game_actors[角色ID].amuhsp += 之类的方式在事件中改变它的数值。
- #
- # ★HspClear = true 时,人物的生命护盾将在战斗结束时清零。
- # 如果不想清零请将 true改为false
- #
- # ★HspNoAddition = true 时,
- # 生命护盾的恢复将不享受恢复效果、物理及魔法伤害比率的加成,
- # 但是会对 make_damage_value 的方法做出改变,会降低本脚本的兼容性。
- #
- # 设定部分所有文字信息的描述方法修改时请保留“”引号。
- #
- # ★将技能设置成体力值恢复,并在技能备注栏备注“[护盾恢复]”,
- # 那么这个技能将变成增加目标角色的生命护盾值
- # ★备注的时候不需要写入“”引号
- #
- # 角色的生命护盾没有上限,下限为0
- #
- # 如果需要设置一个技能为角色体力值的10%,又不想令护盾无限的加下去
- # 技能公式请参照这个写法:
- # b.hp * 0.1 - b.amuhsp [护盾恢复]
- #
- #==============================================================================
- # ★ 设定部分 ★
- #==============================================================================
- module Amu
- module Hsp
-
- HspClear = true #是否在战斗结束时清除掉玩家剩余的生命护盾
-
- HspNoAddition = true #是否采用本脚本的计算伤害的方法
-
- HspName = "防護罩" #生命护盾的名字
-
- HspABonus = "%s 的%s剩餘 %s點!" #玩家人物的生命护盾损伤后显示剩余值的文字
-
- HspEBonus = "%s 的%s剩餘 %s點!" #敌人的生命护盾损伤后显示剩余值的文字
-
- HspADamage = "%s 的%s受到 %s點傷害!" #玩家人物的生命护盾受到伤害的文字
-
- HspEDamage = "%s 的%s受到 %s點傷害!" #敌人的生命护盾受到伤害的文字
-
- HspARecovery = "%s 獲得了 %s點 的%s保護!" #玩家的生命护盾得到提高的文字
-
- HspERecovery = "%s 被賦予 %s點 的%s保護!" #敌人的生命护盾得到提高的文字
-
- HspADestory = "%s 的%s受到 %s點傷害 而遭到擊破!" #玩家的生命护盾被击破时的文字
-
- HspEDestroy = "%s 的%s受到 %s點傷害 而被擊破了!" #敌人的生命护盾被击破时的文字
-
- def self.play_actor_amuhspdamage # 玩家的生命护盾受到伤害的音效
- Audio.se_play("Audio/SE/sword1.ogg", 100, 50)
- end
-
- def self.play_enemy_amuhspdamage # 敌人的生命护盾受到伤害的音效
- Audio.se_play("Audio/SE/sword1.ogg", 100, 50)
- end
-
- def self.play_amuhsp_destory # 生命护盾被击破时的音效
- Audio.se_play("Audio/SE/Crash.ogg", 60, 90)
- end
-
- end
- end
-
- class Game_ActionResult
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :amuhsp_damage # 生命护盾 伤害
- #--------------------------------------------------------------------------
- # ● 清除伤害值`
- #--------------------------------------------------------------------------
- alias amu_20141125_clear_damage_values clear_damage_values
- def clear_damage_values
- amu_20141125_clear_damage_values
- @amuhsp_damage = 0
- end
- #--------------------------------------------------------------------------
- # ● 生成伤害
- #--------------------------------------------------------------------------
- alias amu_20141125_make_damage make_damage
- def make_damage(value, item)
- amu_20141125_make_damage(value, item)
- @amuhsp_damage = value if item.damage.to_hp? && @battler.amuhsp > 0 && value > 0
- @amuhsp_damage = value if item.damage.to_hp? && item.damage.recover? && item.note.include?("[护盾恢复]")
- end
- #--------------------------------------------------------------------------
- # ● 获取具有生命护盾时 HP 伤害的文字
- #--------------------------------------------------------------------------
- def hp_damage_text
- if @hp_drain > 0
- fmt = @battler.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
- sprintf(fmt, @battler.name, Vocab::hp, @hp_drain)
- elsif @hp_damage > 0
- fmt = @battler.actor? ? Vocab::ActorDamage : Vocab::EnemyDamage
- sprintf(fmt, @battler.name, @hp_damage)
- elsif @hp_damage < 0
- fmt = @battler.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
- sprintf(fmt, @battler.name, Vocab::hp, -hp_damage)
- elsif @hp_damage = 0 && @battler.amuhsp > 0
- fmt = @battler.actor? ? Amu::Hsp::HspABonus : Amu::Hsp::HspEBonus
- sprintf(fmt, @battler.name, Amu::Hsp::HspName, @battler.amuhsp)
- else
- fmt = @battler.actor? ? Vocab::ActorNoDamage : Vocab::EnemyNoDamage
- sprintf(fmt, @battler.name)
- end
- end
- #--------------------------------------------------------------------------
- # ● 获取 生命护盾 伤害的文字
- #--------------------------------------------------------------------------
- def amuhsp_damage_text
- if @amuhsp_damage > 0 && @battler.amuhsp > 0
- fmt = @battler.actor? ? Amu::Hsp::HspADamage : Amu::Hsp::HspEDamage
- sprintf(fmt, @battler.name, Amu::Hsp::HspName, @amuhsp_damage)
- elsif @amuhsp_damage > 0 && @battler.amuhsp == 0
- fmt = @battler.actor? ? Amu::Hsp::HspADestory : Amu::Hsp::HspEDestroy
- sprintf(fmt, @battler.name, Amu::Hsp::HspName, @amuhsp_damage)
- elsif @amuhsp_damage < 0
- fmt = @battler.actor? ? Amu::Hsp::HspARecovery : Amu::Hsp::HspERecovery
- sprintf(fmt, @battler.name, -@amuhsp_damage, Amu::Hsp::HspName)
- else
- ""
- end
- end
- end
-
-
- class Game_BattlerBase
- attr_reader :amuhsp # 生命护盾
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- alias amu_20141125_initialize initialize
- def initialize
- amu_20141125_initialize
- @amuhsp = 0
- end
- #--------------------------------------------------------------------------
- # ● 更改 HSP
- #--------------------------------------------------------------------------
- def amuhsp=(amuhsp)
- @amuhsp = amuhsp
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- alias amu_20141125_refresh refresh
- def refresh
- amu_20141125_refresh
- @amuhsp = [@amuhsp, 0].max
- end
- end
-
- class Game_Battler < Game_BattlerBase
- #--------------------------------------------------------------------------
- # ● 计算伤害
- #--------------------------------------------------------------------------
- if Amu::Hsp::HspNoAddition == true
- def make_damage_value(user, item)
- value = item.damage.eval(user, self, $game_variables)
- value *= item_element_rate(user, item)
- value *= pdr if item.physical? && !make_amuhsp?(item)
- value *= mdr if item.magical? && !make_amuhsp?(item)
- value *= rec if item.damage.recover? && !make_amuhsp?(item)
- value = apply_critical(value) if @result.critical
- value = apply_variance(value, item.damage.variance)
- value = apply_guard(value)
- if make_amuhsp?(item)
- def actor_amuhsp?
- return true
- end
- end
- @result.make_damage(value.to_i, item)
- end
- else
- alias amu_20141125_make_damage_value make_damage_value
- def make_damage_value(user, item)
- amu_20141125_make_damage_value(user, item)
- if make_amuhsp?(item)
- def actor_amuhsp?
- return true
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 处理伤害
- # 调用前需要设置好
- # @result.hp_damage @result.mp_damage
- # @result.hp_drain @result.mp_drain
- #--------------------------------------------------------------------------
- def execute_damage(user)
- on_damage(@result.hp_damage) if @result.hp_damage > 0
- if self.amuhsp > 0 && @result.hp_damage > 0
- eamuhsp = self.amuhsp
- self.amuhsp -= @result.hp_damage
- self.amuhsp <= 0 ? @result.hp_damage -= eamuhsp : @result.hp_damage = 0
- end
- if actor_amuhsp?
- self.amuhsp -= @result.hp_damage
- @result.hp_damage = 0
- def actor_amuhsp?
- return false
- end
- else
- self.hp -= @result.hp_damage
- end
- self.mp -= @result.mp_damage
- user.hp += @result.hp_drain
- user.mp += @result.mp_drain
- end
- #--------------------------------------------------------------------------
- # ● 判断技能是否用来增加生命护盾
- #--------------------------------------------------------------------------
- def make_amuhsp?(item)
- return false unless item.is_a?(RPG::Skill)
- return item.note.include?("[护盾恢复]")
- end
- def actor_amuhsp?
- return false
- end
- #--------------------------------------------------------------------------
- # ● 清除 生命护盾
- #--------------------------------------------------------------------------
- def clear_amuhsp
- self.amuhsp = 0
- end
- #--------------------------------------------------------------------------
- # ● 战斗结束处理
- #--------------------------------------------------------------------------
- alias amu_20141125_on_battle_end on_battle_end
- def on_battle_end
- amu_20141125_on_battle_end
- clear_amuhsp if Amu::Hsp::HspClear == true
- end
- end
-
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # ● 设置具有生命护盾时玩家被击的效果
- #--------------------------------------------------------------------------
- def perform_hspdamage_effect
- $game_troop.screen.start_shake(5, 5, 10)
- @sprite_effect_type = :blink
- Amu::Hsp.play_actor_amuhspdamage
- end
- end
-
- class Game_Enemy < Game_Battler
- #--------------------------------------------------------------------------
- # ● 设置具有生命护盾时敌人被击的效果
- #--------------------------------------------------------------------------
- def perform_hspdamage_effect
- $game_troop.screen.start_shake(5, 5, 10)
- @sprite_effect_type = :blink
- Amu::Hsp.play_enemy_amuhspdamage
- end
- end
-
- class Window_BattleLog < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 显示伤害
- #--------------------------------------------------------------------------
- def display_damage(target, item)
- if target.result.missed
- display_miss(target, item)
- elsif target.result.evaded
- display_evasion(target, item)
- else
- display_amuhsp_damage(target, item)
- display_hp_damage(target, item)
- display_mp_damage(target, item)
- display_tp_damage(target, item)
- end
- end
- #--------------------------------------------------------------------------
- # ● 显示 生命护盾 伤害
- #--------------------------------------------------------------------------
- def display_amuhsp_damage(target, item)
- return if target.dead? || target.result.amuhsp_damage == 0
- if target.result.amuhsp_damage > 0 && target.amuhsp > 0 && target.result.hp_drain == 0
- target.perform_hspdamage_effect
- end
- Amu::Hsp.play_amuhsp_destory if target.result.amuhsp_damage > 0 && target.amuhsp == 0
- Sound.play_recovery if target.result.amuhsp_damage < 0
- add_text(target.result.amuhsp_damage_text)
- wait
- end
- end
复制代码
先附上腳本
其他功能都沒什麼問題
就是當4個角色全部都按 "防禦"的時候
會跳出
第164行:發生ArgumentError。 comparison of Fixnum with nil failed
請問一下要怎麼解決呢 |
|