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

Project1

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

[讨论] 【小白向】VA下适用于SideView战斗系统的吸血武器

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
21 小时
注册时间
2014-6-25
帖子
7
跳转到指定楼层
1
发表于 2015-9-27 17:32:37 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 禺谷皓月 于 2015-9-27 17:43 编辑



想做一个任何伤害都能转化吸血的武器,在论坛搜了好久没有看见一个满意的。。。

于是就尝试硬着头皮去看RGSS3代码教程,下了个帮助文件自己从零研究了一下午


   忙活了一下午,没有一点进展 ,于是就想到用暴力一点的代码实现

    然后用一段十分简单的代码不知怎么就搞出来了。
   下面贴出代码
RUBY 代码复制
  1. #============================================================
  2. #针对第67号武器:定将军之剑写的吸血脚本
  3. #============================================================
  4.  
  5. class Game_Battler < Game_BattlerBase
  6.   def execute_damage(user)
  7.     on_damage(@result.hp_damage) if @result.hp_damage > 0
  8.    #--------------------定将军吸血剑--------------------------
  9.     if user.weapons.include?($data_weapons[67])
  10.         @result.hp_drain = ([@result.hp_damage,self.hp].min * 0.15).to_i
  11.       end
  12.    #---------------------------------------------------------   
  13.     self.hp -= @result.hp_damage
  14.     self.mp -= @result.mp_damage
  15.     user.hp += @result.hp_drain
  16.     user.mp += @result.mp_drain
  17.   end
  18. end

这段代码加到插件脚本中即可。
这里有需要的可以在
RUBY 代码复制
  1. if user.weapons.include?($data_weapons[67])

这行代码中的"67"改成你所制作的武器ID
RUBY 代码复制
  1. @result.hp_drain = (@result.hp_damage * 0.15).to_i

这行代码是吸收值计算公式,0.15是伤害值吸血比率。

同时修改Sprite_Sideview下的
RUBY 代码复制
  1. #--------------------------------------------------------------------------
  2.   # ● ダメージ表示
  3.   #--------------------------------------------------------------------------
  4.   def set_damage
  5.     return @action_end = true if !N03::DAMAGE_POP
  6.     damage = @battler.result.hp_damage if @battler.result.hp_damage != 0
  7.     damage = @battler.result.hp_drain  if @battler.result.hp_drain  != 0
  8.     damage = @battler.result.mp_damage if @battler.result.mp_damage != 0
  9.     damage = @battler.result.mp_drain  if @battler.result.mp_drain  != 0
  10.     damage = @battler.result.tp_damage if @battler.result.tp_damage != 0
  11.     if !damage or damage == 0
  12.       @action_end = true if @st == nil
  13.       return # ステートだけPOPする設定を考慮して@action_endは返さない
  14.     end
  15.     @hit = @battler.sv.hit
  16.     @battler.sv.hit += 1 if damage > 0
  17.     file = N03::DAMAGE_PLUS if damage > 0
  18.     file = N03::DAMAGE_MINUS if damage < 0
  19.     add_file = N03::DAMAGE_MP if @battler.result.mp_damage != 0
  20.     add_file = N03::DAMAGE_TP if @battler.result.tp_damage != 0
  21.     adjust_x = N03::DAMAGE_ADJUST
  22.     @num = []
  23.     @num_base = []
  24.     damage = damage.abs
  25.     max_num = damage.to_s.size
  26.     max_num += 1 if add_file != nil
  27.     for i in 0...max_num
  28.       @num[i] = Sprite.new
  29.       if add_file != nil && i == max_num - 1
  30.         @num[i].bitmap = Cache.system(add_file)
  31.         cw = (damage % (10 * 10 ** i))/(10 ** i)
  32.         sw = 0 if sw == nil
  33.       else
  34.         @num[i].bitmap = Cache.system(file)
  35.         cw = (damage % (10 * 10 ** i))/(10 ** i)
  36.         sw = @num[i].bitmap.width / 10
  37.         @num[i].src_rect.set(cw * sw, 0, sw, @num[i].bitmap.height)
  38.       end
  39.       @num_base[i] = []
  40.       @num_base[i][0] = (sw + adjust_x) * i * -1 + (@battler.sv.x / 100)
  41.       @num_base[i][1] =  -(@num[i].bitmap.height / 3) - i * 2 - @hit * 2 + (@battler.sv.y - @battler.sv.h - @battler.sv.j - @battler.sv.oy_adjust)/ 100
  42.       @num_base[i][0] -= @num[i].bitmap.width / 2 - adjust_x if add_file != nil && i == max_num - 1
  43.       @num[i].z = 1000 + i + @hit * 10
  44.     end
  45.     @time = @pop_time = 80
  46.   end


将第773行注释掉,不然会使伤害值显示和回复值相同
改完后如下
RUBY 代码复制
  1. #--------------------------------------------------------------------------
  2.   # ● ダメージ表示
  3.   #--------------------------------------------------------------------------
  4.   def set_damage
  5.     return @action_end = true if !N03::DAMAGE_POP
  6.     damage = @battler.result.hp_damage if @battler.result.hp_damage != 0
  7. #  damage = @battler.result.hp_drain  if @battler.result.hp_drain  != 0
  8.     damage = @battler.result.mp_damage if @battler.result.mp_damage != 0
  9.     damage = @battler.result.mp_drain  if @battler.result.mp_drain  != 0
  10.     damage = @battler.result.tp_damage if @battler.result.tp_damage != 0
  11.     if !damage or damage == 0
  12.       @action_end = true if @st == nil
  13.       return # ステートだけPOPする設定を考慮して@action_endは返さない
  14.     end
  15.     @hit = @battler.sv.hit
  16.     @battler.sv.hit += 1 if damage > 0
  17.     file = N03::DAMAGE_PLUS if damage > 0
  18.     file = N03::DAMAGE_MINUS if damage < 0
  19.     add_file = N03::DAMAGE_MP if @battler.result.mp_damage != 0
  20.     add_file = N03::DAMAGE_TP if @battler.result.tp_damage != 0
  21.     adjust_x = N03::DAMAGE_ADJUST
  22.     @num = []
  23.     @num_base = []
  24.     damage = damage.abs
  25.     max_num = damage.to_s.size
  26.     max_num += 1 if add_file != nil
  27.     for i in 0...max_num
  28.       @num[i] = Sprite.new
  29.       if add_file != nil && i == max_num - 1
  30.         @num[i].bitmap = Cache.system(add_file)
  31.         cw = (damage % (10 * 10 ** i))/(10 ** i)
  32.         sw = 0 if sw == nil
  33.       else
  34.         @num[i].bitmap = Cache.system(file)
  35.         cw = (damage % (10 * 10 ** i))/(10 ** i)
  36.         sw = @num[i].bitmap.width / 10
  37.         @num[i].src_rect.set(cw * sw, 0, sw, @num[i].bitmap.height)
  38.       end
  39.       @num_base[i] = []
  40.       @num_base[i][0] = (sw + adjust_x) * i * -1 + (@battler.sv.x / 100)
  41.       @num_base[i][1] =  -(@num[i].bitmap.height / 3) - i * 2 - @hit * 2 + (@battler.sv.y - @battler.sv.h - @battler.sv.j - @battler.sv.oy_adjust)/ 100
  42.       @num_base[i][0] -= @num[i].bitmap.width / 2 - adjust_x if add_file != nil && i == max_num - 1
  43.       @num[i].z = 1000 + i + @hit * 10
  44.     end
  45.     @time = @pop_time = 80
  46.   end


本人也是小白一个,说的不对的地方还请大神指出。在这里只是抛砖引玉,希望有更好的解答。   
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-4-26 05:21

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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