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

Project1

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

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

[复制链接]

Lv3.寻梦者

梦石
0
星屑
2487
在线时间
214 小时
注册时间
2017-9-27
帖子
613
跳转到指定楼层
1
发表于 2017-12-23 15:29:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
很久以前就有人说过魔法盾的问题了,我倒是觉得不一定通过消耗MP减轻伤害这一途径来实现这种构思。
我这个脚本的魔法障壁类似于额外护甲,当受到伤害时并非抵消伤害的比例,而是能抵抗多少就抵抗多少,伤害值-障壁值=最终伤害,如果障壁有剩余则下次受到伤害减去剩余障壁值。
这玩意其实你想怎么用都行,不一定就是魔法障壁,消耗生命增加障壁倒也可取,因为与MP无直接关联。
RUBY 代码复制
  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.  
  46. class Game_ActionResult
  47.   attr_accessor   :hp_def
  48.   #--------------------------------------------------------------------------
  49.   # ● 清除伤害值
  50.   #--------------------------------------------------------------------------
  51.   alias old_804173948_clear_damage_values clear_damage_values
  52.   def clear_damage_values
  53.     old_804173948_clear_damage_values
  54.     @hp_def = 0
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # ● 获取 HP 抵伤的文字
  58.   #--------------------------------------------------------------------------
  59.   def hp_def_text
  60.     if @hp_def > 0
  61.       fmt = @battler.actor? ? Vocab::ActorDef : Vocab::EnemyDef
  62.       sprintf(fmt, @battler.name, @hp_def)
  63.     end
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 获取 当前障壁 文字
  67.   #--------------------------------------------------------------------------
  68.   def hp_current_def_text
  69.     fmt = @battler.actor? ? Vocab::ActorCurrentDef : Vocab::ActorCurrentDef
  70.     sprintf(fmt, @battler.name, @battler.hp_def)
  71.   end
  72. end
  73.  
  74. class Window_BattleLog
  75.   #--------------------------------------------------------------------------
  76.   # ● 显示 HP 伤害
  77.   #--------------------------------------------------------------------------
  78.   alias old_804173948_display_hp_damage display_hp_damage
  79.   def display_hp_damage(target, item)
  80.     if target.result.hp_def > 0 && item && item.damage.to_hp?
  81.       add_text(target.result.hp_def_text)
  82.       add_text(target.result.hp_current_def_text)
  83.       wait
  84.     end
  85.     old_804173948_display_hp_damage(target,item);
  86.   end
  87. end
  88. class Game_BattlerBase
  89.   attr_accessor   :hp_def
  90.   #--------------------------------------------------------------------------
  91.   # ● 初始化对象
  92.   #--------------------------------------------------------------------------
  93.   alias old_804173948_initialize initialize
  94.   def initialize
  95.     old_804173948_initialize
  96.     @hp_def = 0
  97.   end
  98. end
  99. class Game_Battler
  100.   #--------------------------------------------------------------------------
  101.   # ● 处理伤害
  102.   #    调用前需要设置好
  103.   #    @result.hp_damage   @result.mp_damage
  104.   #    @result.hp_drain    @result.mp_drain
  105.   #--------------------------------------------------------------------------
  106.   def execute_damage(user)
  107.     if @result.hp_damage>0
  108.       if @result.hp_damage<self.hp_def
  109.         self.hp_def -= @result.hp_damage
  110.         @result.hp_def = @result.hp_damage
  111.         @result.hp_damage = 0
  112.       else
  113.         @result.hp_damage -= self.hp_def
  114.         @result.hp_def = self.hp_def
  115.         self.hp_def = 0
  116.       end
  117.     end
  118.     on_damage(@result.hp_damage) if @result.hp_damage > 0
  119.  
  120.     self.hp -= @result.hp_damage
  121.     self.mp -= @result.mp_damage
  122.     user.hp += @result.hp_drain
  123.     user.mp += @result.mp_drain
  124.   end
  125. end
  126. class Game_Actor  
  127.   #--------------------------------------------------------------------------
  128.   # ● 战斗开始处理
  129.   #--------------------------------------------------------------------------
  130.   def on_battle_start
  131.     super
  132.     self.hp_def = battle_hp_def
  133.   end
  134.   def battle_hp_def
  135.     sum = 0
  136.     skills.each{|skill| sum+=skill.hp_def}
  137.     return sum
  138.   end
  139. end
  140. class Game_Enemy
  141.   #--------------------------------------------------------------------------
  142.   # ● 战斗开始处理
  143.   #--------------------------------------------------------------------------
  144.   def on_battle_start
  145.     super
  146.     self.hp_def = battle_hp_def
  147.   end
  148.   def skills
  149.     enemy.actions.collect{|action|$data_skills[action.skill_id]}
  150.   end
  151.   def battle_hp_def
  152.     sum = enemy.hp_def
  153.     skills.each{|skill| sum+=skill.hp_def}
  154.     return sum
  155.   end
  156. end
  157.  
  158. class Game_Interpreter
  159.   def change_battler_hp_def(actor,id,value)
  160.     battler = (actor ? $game_party.members[id-1] : $game_troop.members[id-1])
  161.     battler.hp_def = value
  162.   end
  163.   def add_battler_hp_def(actor,id,value)
  164.     battler = (actor ? $game_party.members[id-1] : $game_troop.members[id-1])
  165.     battler.hp_def += value
  166.   end
  167.   def rate_battler_hp_def(actor,id,value)
  168.     battler = (actor ? $game_party.members[id-1] : $game_troop.members[id-1])
  169.     battler.hp_def = (battler.battle_hp_def * value).round
  170.   end
  171. end



评分

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

查看全部评分

浅尝辄止,宜乎众矣。

Lv3.寻梦者

梦石
0
星屑
2323
在线时间
274 小时
注册时间
2017-7-25
帖子
163
2
发表于 2017-12-26 14:59:10 | 只看该作者
好像不错的样子,多谢分享

点评

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-19 23:31

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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