查看: 2180|回复: 2

[原创发布] 不知道是否有的障壁系统

[复制链接]
梦石
0
星屑
2497
在线时间
215 小时
注册时间
2017-9-27
回帖
563
发表于 2017-12-23 15:29:55 | 显示全部楼层 |阅读模式

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

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

×
很久以前就有人说过魔法盾的问题了,我倒是觉得不一定通过消耗MP减轻伤害这一途径来实现这种构思。
我这个脚本的魔法障壁类似于额外护甲,当受到伤害时并非抵消伤害的比例,而是能抵抗多少就抵抗多少,伤害值-障壁值=最终伤害,如果障壁有剩余则下次受到伤害减去剩余障壁值。
这玩意其实你想怎么用都行,不一定就是魔法障壁,消耗生命增加障壁倒也可取,因为与MP无直接关联。
  1. #==============================================================================
  2. # 障壁系统
  3. #==============================================================================
  4. # 作者:刹那铃音
  5. #==============================================================================
  6. # 作用简介:
  7. # 让角色或怪物拥有障壁,障壁能抵消伤害。
  8. #==============================================================================
  9. # 脚本冲突:
  10. # 暂未发现脚本冲突,请提前备份好工程,工程数据出现问题作者不予解决。
  11. #==============================================================================
  12. # 使用方法:
  13. # 1.备注:
  14. # 在角色或敌人的技能备注下写入<hp_def x>,战斗开始时角色或敌人获得x点障壁值。
  15. # 2.事件脚本:
  16. #(1)通过战斗中事件的脚本指令调整障壁值的增加和减少。
  17. #add_battler_hp_def(actor,id,x)
  18. #actor:为true时指代角色,为false时指代敌人。
  19. #id:指第id个角色或敌人。
  20. #x:指定角色或敌人的障壁值增加x(x为负数时则为减少)。
  21. #(2)通过战斗中事件的脚本指令调整障壁值的倍数。
  22. #rate_battler_hp_def(actor,id,x)
  23. #actor:为true时指代玩角色,为false时指代敌人。
  24. #id:指第id个角色或敌人。
  25. #x:指定角色或敌人的障壁值在其基础值上乘以x。
  26. #==============================================================================
  27. # 显示的文字:
  28. #==============================================================================
  29. module Vocab
  30.   ActorDef     = "%s的障壁抵挡了%s点伤害!"
  31.   EnemyDef     = "%s的障壁抵挡了%s点伤害!"
  32.   ActorCurrentDef     = "%s当前障壁:%s!"
  33.   EnemyCurrentDef     = "%s当前障壁:%s!"
  34. end
  35. class RPG::Skill
  36.   def hp_def
  37.     if /<hp_def (\d+)>/i =~ @note;return $1.to_i;else;return 0;end
  38.   end  
  39. end
  40. class RPG::Enemy
  41.   def hp_def
  42.     if /<hp_def (\d+)>/i =~ @note;return $1.to_i;else;return 0;end
  43.   end  
  44. end

  45. class Game_ActionResult
  46.   attr_accessor   :hp_def
  47.   #--------------------------------------------------------------------------
  48.   # ● 清除伤害值
  49.   #--------------------------------------------------------------------------
  50.   alias old_804173948_clear_damage_values clear_damage_values
  51.   def clear_damage_values
  52.     old_804173948_clear_damage_values
  53.     @hp_def = 0
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ● 获取 HP 抵伤的文字
  57.   #--------------------------------------------------------------------------
  58.   def hp_def_text
  59.     if @hp_def > 0
  60.       fmt = @battler.actor? ? Vocab::ActorDef : Vocab::EnemyDef
  61.       sprintf(fmt, @battler.name, @hp_def)
  62.     end
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # ● 获取 当前障壁 文字
  66.   #--------------------------------------------------------------------------
  67.   def hp_current_def_text
  68.     fmt = @battler.actor? ? Vocab::ActorCurrentDef : Vocab::ActorCurrentDef
  69.     sprintf(fmt, @battler.name, @battler.hp_def)
  70.   end
  71. end

  72. class Window_BattleLog
  73.   #--------------------------------------------------------------------------
  74.   # ● 显示 HP 伤害
  75.   #--------------------------------------------------------------------------
  76.   alias old_804173948_display_hp_damage display_hp_damage
  77.   def display_hp_damage(target, item)
  78.     if target.result.hp_def > 0 && item && item.damage.to_hp?
  79.       add_text(target.result.hp_def_text)
  80.       add_text(target.result.hp_current_def_text)
  81.       wait
  82.     end
  83.     old_804173948_display_hp_damage(target,item);
  84.   end
  85. end
  86. class Game_BattlerBase
  87.   attr_accessor   :hp_def
  88.   #--------------------------------------------------------------------------
  89.   # ● 初始化对象
  90.   #--------------------------------------------------------------------------
  91.   alias old_804173948_initialize initialize
  92.   def initialize
  93.     old_804173948_initialize
  94.     @hp_def = 0
  95.   end
  96. end
  97. class Game_Battler
  98.   #--------------------------------------------------------------------------
  99.   # ● 处理伤害
  100.   #    调用前需要设置好
  101.   #    @result.hp_damage   @result.mp_damage
  102.   #    @result.hp_drain    @result.mp_drain
  103.   #--------------------------------------------------------------------------
  104.   def execute_damage(user)
  105.     if @result.hp_damage>0
  106.       if @result.hp_damage<self.hp_def
  107.         self.hp_def -= @result.hp_damage
  108.         @result.hp_def = @result.hp_damage
  109.         @result.hp_damage = 0
  110.       else
  111.         @result.hp_damage -= self.hp_def
  112.         @result.hp_def = self.hp_def
  113.         self.hp_def = 0
  114.       end
  115.     end
  116.     on_damage(@result.hp_damage) if @result.hp_damage > 0
  117.    
  118.     self.hp -= @result.hp_damage
  119.     self.mp -= @result.mp_damage
  120.     user.hp += @result.hp_drain
  121.     user.mp += @result.mp_drain
  122.   end
  123. end
  124. class Game_Actor  
  125.   #--------------------------------------------------------------------------
  126.   # ● 战斗开始处理
  127.   #--------------------------------------------------------------------------
  128.   def on_battle_start
  129.     super
  130.     self.hp_def = battle_hp_def
  131.   end
  132.   def battle_hp_def
  133.     sum = 0
  134.     skills.each{|skill| sum+=skill.hp_def}
  135.     return sum
  136.   end
  137. end
  138. class Game_Enemy
  139.   #--------------------------------------------------------------------------
  140.   # ● 战斗开始处理
  141.   #--------------------------------------------------------------------------
  142.   def on_battle_start
  143.     super
  144.     self.hp_def = battle_hp_def
  145.   end
  146.   def skills
  147.     enemy.actions.collect{|action|$data_skills[action.skill_id]}
  148.   end
  149.   def battle_hp_def
  150.     sum = enemy.hp_def
  151.     skills.each{|skill| sum+=skill.hp_def}
  152.     return sum
  153.   end
  154. end

  155. class Game_Interpreter
  156.   def change_battler_hp_def(actor,id,value)
  157.     battler = (actor ? $game_party.members[id-1] : $game_troop.members[id-1])
  158.     battler.hp_def = value
  159.   end
  160.   def add_battler_hp_def(actor,id,value)
  161.     battler = (actor ? $game_party.members[id-1] : $game_troop.members[id-1])
  162.     battler.hp_def += value
  163.   end
  164.   def rate_battler_hp_def(actor,id,value)
  165.     battler = (actor ? $game_party.members[id-1] : $game_troop.members[id-1])
  166.     battler.hp_def = (battler.battle_hp_def * value).round
  167.   end
  168. end
复制代码



评分

参与人数 2星屑 +100 赞 +1 收起 理由
RaidenInfinity + 100 原创发布
wan5337088 + 1 塞糖

查看全部评分

浅尝辄止,宜乎众矣。
梦石
0
星屑
2338
在线时间
275 小时
注册时间
2017-7-25
回帖
128
发表于 2017-12-26 14:59:10 | 显示全部楼层
好像不错的样子,多谢分享

点评

其实类似于额外生命?  发表于 2017-12-26 21:17
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部