查看: 2419|回复: 0

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

[复制链接]
梦石
0
星屑
50
在线时间
21 小时
注册时间
2014-6-25
回帖
4
发表于 2015-9-27 17:32:37 | 显示全部楼层 |阅读模式

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

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

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



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

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


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

    然后用一段十分简单的代码不知怎么就搞出来了。 汗
   下面贴出代码
[pre lang="ruby"]#============================================================
#针对第67号武器:定将军之剑写的吸血脚本
#============================================================

class Game_Battler < Game_BattlerBase
  def execute_damage(user)
    on_damage(@result.hp_damage) if @result.hp_damage > 0
   #--------------------定将军吸血剑--------------------------
    if user.weapons.include?($data_weapons[67])
        @result.hp_drain = ([@result.hp_damage,self.hp].min * 0.15).to_i
      end
   #---------------------------------------------------------   
    self.hp -= @result.hp_damage
    self.mp -= @result.mp_damage
    user.hp += @result.hp_drain
    user.mp += @result.mp_drain
  end
end[/pre]
这段代码加到插件脚本中即可。
这里有需要的可以在
[pre lang="ruby" line="11"]    if user.weapons.include?($data_weapons[67])[/pre]
这行代码中的"67"改成你所制作的武器ID
[pre lang="ruby" line="12"]        @result.hp_drain = (@result.hp_damage * 0.15).to_i[/pre]
这行代码是吸收值计算公式,0.15是伤害值吸血比率。

同时修改Sprite_Sideview下的
[pre lang="ruby" line="767"]#--------------------------------------------------------------------------
  # ● ダメージ表示
  #--------------------------------------------------------------------------
  def set_damage
    return @action_end = true if !N03::DAMAGE_POP
    damage = @battler.result.hp_damage if @battler.result.hp_damage != 0
    damage = @battler.result.hp_drain  if @battler.result.hp_drain  != 0
    damage = @battler.result.mp_damage if @battler.result.mp_damage != 0
    damage = @battler.result.mp_drain  if @battler.result.mp_drain  != 0
    damage = @battler.result.tp_damage if @battler.result.tp_damage != 0
    if !damage or damage == 0
      @action_end = true if @st == nil
      return # ステートだけPOPする設定を考慮して@action_endは返さない
    end
    @hit = @battler.sv.hit
    @battler.sv.hit += 1 if damage > 0
    file = N03::DAMAGE_PLUS if damage > 0
    file = N03::DAMAGE_MINUS if damage < 0
    add_file = N03::DAMAGE_MP if @battler.result.mp_damage != 0
    add_file = N03::DAMAGE_TP if @battler.result.tp_damage != 0
    adjust_x = N03::DAMAGE_ADJUST
    @num = []
    @num_base = []
    damage = damage.abs
    max_num = damage.to_s.size
    max_num += 1 if add_file != nil
    for i in 0...max_num
      @num = Sprite.new
      if add_file != nil && i == max_num - 1
        @num.bitmap = Cache.system(add_file)
        cw = (damage % (10 * 10 ** i))/(10 ** i)
        sw = 0 if sw == nil
      else
        @num.bitmap = Cache.system(file)
        cw = (damage % (10 * 10 ** i))/(10 ** i)
        sw = @num.bitmap.width / 10
        @num.src_rect.set(cw * sw, 0, sw, @num.bitmap.height)
      end
      @num_base = []
      @num_base[0] = (sw + adjust_x) * i * -1 + (@battler.sv.x / 100)
      @num_base[1] =  -(@num.bitmap.height / 3) - i * 2 - @hit * 2 + (@battler.sv.y - @battler.sv.h - @battler.sv.j - @battler.sv.oy_adjust)/ 100
      @num_base[0] -= @num.bitmap.width / 2 - adjust_x if add_file != nil && i == max_num - 1
      @num.z = 1000 + i + @hit * 10
    end
    @time = @pop_time = 80
  end[/pre]

将第773行注释掉,不然会使伤害值显示和回复值相同
改完后如下
[pre lang="ruby" line="767"]#--------------------------------------------------------------------------
  # ● ダメージ表示
  #--------------------------------------------------------------------------
  def set_damage
    return @action_end = true if !N03::DAMAGE_POP
    damage = @battler.result.hp_damage if @battler.result.hp_damage != 0
#  damage = @battler.result.hp_drain  if @battler.result.hp_drain  != 0
    damage = @battler.result.mp_damage if @battler.result.mp_damage != 0
    damage = @battler.result.mp_drain  if @battler.result.mp_drain  != 0
    damage = @battler.result.tp_damage if @battler.result.tp_damage != 0
    if !damage or damage == 0
      @action_end = true if @st == nil
      return # ステートだけPOPする設定を考慮して@action_endは返さない
    end
    @hit = @battler.sv.hit
    @battler.sv.hit += 1 if damage > 0
    file = N03::DAMAGE_PLUS if damage > 0
    file = N03::DAMAGE_MINUS if damage < 0
    add_file = N03::DAMAGE_MP if @battler.result.mp_damage != 0
    add_file = N03::DAMAGE_TP if @battler.result.tp_damage != 0
    adjust_x = N03::DAMAGE_ADJUST
    @num = []
    @num_base = []
    damage = damage.abs
    max_num = damage.to_s.size
    max_num += 1 if add_file != nil
    for i in 0...max_num
      @num = Sprite.new
      if add_file != nil && i == max_num - 1
        @num.bitmap = Cache.system(add_file)
        cw = (damage % (10 * 10 ** i))/(10 ** i)
        sw = 0 if sw == nil
      else
        @num.bitmap = Cache.system(file)
        cw = (damage % (10 * 10 ** i))/(10 ** i)
        sw = @num.bitmap.width / 10
        @num.src_rect.set(cw * sw, 0, sw, @num.bitmap.height)
      end
      @num_base = []
      @num_base[0] = (sw + adjust_x) * i * -1 + (@battler.sv.x / 100)
      @num_base[1] =  -(@num.bitmap.height / 3) - i * 2 - @hit * 2 + (@battler.sv.y - @battler.sv.h - @battler.sv.j - @battler.sv.oy_adjust)/ 100
      @num_base[0] -= @num.bitmap.width / 2 - adjust_x if add_file != nil && i == max_num - 1
      @num.z = 1000 + i + @hit * 10
    end
    @time = @pop_time = 80
  end[/pre]

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

本版积分规则

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

在本版发帖返回顶部