查看: 4162|回复: 7

[已经解决] 关于彩虹神剑和动态扣血的问题。。。

[复制链接]
梦石
0
星屑
1328
在线时间
354 小时
注册时间
2009-9-14
回帖
211
发表于 2015-8-2 17:43:09 | 显示全部楼层 |阅读模式
悬赏6星屑已解决
[pre lang="ruby"]=begin
==============================================================================

彩虹神剑(伤害分段显示)显示总伤害版 v1.0d

==============================================================================

彩虹神剑 -柳柳

6-20-2006 v1.0 -叶子
在彩虹神剑的基础上增加了显示总伤害的功能,而且总伤害的数字是弹出伤害时逐渐增加的

v1.0a -叶子
修正了显示伤害和实际伤害有差别的问题
修正了miss的情况下显示miss混乱的问题
修正了对己方技能重复显示伤害的问题
未修正播放目标动画第一帧时目标有时无端跳动的BUG

v1.0b -叶子
修改了总伤害数字的位置和z坐标
未修正播放目标动画第一帧时目标有时无端跳动的BUG

v1.0c -柳柳
? ? ?

v1.0d -柳柳
1.0d最终解决了那个闪光问题,还有最末帧伤害多次的算法

7-24-2006 v1.0e -叶子
修正全屏幕闪烁弹出伤害错误的问题
修正连续伤害不会弹出伤害的问题
仍然未修正播放目标动画第一帧时目标有时无端跳动的BUG

我鼓起很大勇气才敢动偶像们的脚本的,不知道会不会出问题啊......  -cftx
修正了总伤害显示
增加了伤害美化和HIT数显示
修正了两次音效

==============================================================================
=end
# 核心的说明:
# damage_pop 不再附带damage()的功能,这个放到animation里面去了

module RPG
#--------------------------------------------------------------------------
# ● 常量设定
#--------------------------------------------------------------------------
# 是否显示总伤害
SHOW_TOTAL_DAMAGE = true
# 角色受攻击时是否跳一下
BATTLER_JUMP = false
# 连续伤害的动画ID
SLIP_DAMAGE_ANIMATION_ID = 105

class Sprite < ::Sprite
   #==========================================
   # 修改说明:
   # @flash_shake用来制作挨打时候跳跃
   # @_damage    用来记录每次打击之后弹出数字
   # @_total_damage 记录总伤害
   # @_total_damage_duration 总伤害持续帧
   #==========================================
   #alias 66RPG_rainbow_initialize : initialize
   
   def initialize(viewport = nil)
     #66RPG_rainbow_initialize(viewport)
     super(viewport)
     @_whiten_duration = 0
     @_appear_duration = 0
     @_escape_duration = 0
     @_collapse_duration = 0
     @_damage_duration = 0
     @_animation_duration = 0
     @_blink = false
     # 挨打时候跳跃
     @flash_shake = 0
     # 伤害记录数组
     @_damage = []
     # 总伤害数字
     @_total_damage = 0
     # 总伤害持续帧
     @_total_damage_duration = 0
     #记录已经发生的伤害的变量★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
     @p_dam=0
     @hits=0
   end
#美化的伤害处理★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
def damage(value, critical)
      # 释放伤害,效果是伤害数字快速消失,觉得不如不消失好看......
      #dispose_damage
      #清除hit数
      dispose_hit
      # 如果伤害值是数值
      if value.is_a?(Numeric)
        # 绝对值转为字符串
        damage_string = value.abs.to_s
      else
        # 转为字符串
        damage_string = value.to_s
      end
      # 初始化位图
      bitmap = Bitmap.new(162, 64)
      bitmap.font.name = ["黑体","华文行楷", "宋体"]
      bitmap.font.size = 32
      # 伤害值是数值的情况下
      if value.is_a?(Numeric)
        # 分割伤害值字符串
        damage_array = damage_string.scan(/./)
        damage_x = 81 - damage_string.size * 9
        # 伤害值为负的情况下
        if value < 0
          # 调用回复数字表
          rect_y = 32
        else
          # 调用伤害数字表
          rect_y = 0
        end
        # 循环伤害值字符串
        for char in damage_array
          number = char.to_i
          # 显示伤害数字
          bitmap.blt(damage_x, 32, RPG::Cache.picture("Damage"),
          Rect.new(number * 18, rect_y, 18, 32))
          # 后移一位
          damage_x += 18
        end
      # 伤害值不是数值的情况
      else
        # 如果伤害值不是 Miss
        unless value == "Miss"
          # 系统默认描画字符串
          bitmap.font.color.set(0, 0, 0)
          bitmap.draw_text(-1, 27, 162, 36, damage_string, 1)
          bitmap.draw_text(+1, 27, 162, 36, damage_string, 1)
          bitmap.draw_text(-1, 29, 162, 36, damage_string, 1)
          bitmap.draw_text(+1, 29, 162, 36, damage_string, 1)
          bitmap.font.color.set(255, 255, 255)
          bitmap.draw_text(0, 28, 162, 36, damage_string, 1)
        # Miss 的情况下
        else
          # 显示未击中图画
          bitmap.blt(36, 28, RPG::Cache.picture("Damage"), Rect.new(90, 64, 90, 32))
        end
      end
      # 会心一击标志打开的情况
      if critical
        # 显示会心一击图画
        bitmap.blt(36, 0, RPG::Cache.picture("Damage"), Rect.new(0, 64, 90, 32))
      end
      # 伤害值定位
      @_damage_sprite = ::Sprite.new(self.viewport)
      @_damage_sprite.bitmap = bitmap
      @_damage_sprite.ox = 81
      @_damage_sprite.oy = 20
      @_damage_sprite.x = self.x
      @_damage_sprite.y = self.y - self.oy / 2
      @_damage_sprite.z = 3000
      @_damage_duration = 40
      @_damage.push([@_damage_sprite,@_damage_duration-10,0, rand(30) - 15, rand(3)])
      make_total_damage(value)  

    end

#   ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
# hit数的美化描绘
    def hit

      # 如果伤害值是数值
      # 转为字符串
      value=@hits
        hits_string = value.to_s
      # 初始化位图
       bitmap = Bitmap.new(320, 64)
       bitmap.font.name = "Arial Black"
       bitmap.font.size = 32
       # 分割伤害值字符串
        hits_array = hits_string.scan(/./)
        hits_x = 81 - hits_string.size * 18.1
          rect_y = 0
        # 循环伤害值字符串
        for char in hits_array
          number = char.to_i
          # 显示伤害数字
          bitmap.blt(hits_x, 0, RPG::Cache.picture("Number"),
          Rect.new(number * 36.2, rect_y, 36.2, 50))
          # 后移一位
          hits_x += 36.2
        end
        bitmap.blt(hits_x, 0, RPG::Cache.picture("HITS"),
        Rect.new(0, -21, 90, 50))

      # 伤害值定位
      @_hits_sprite = ::Sprite.new(self.viewport)
      @_hits_sprite.bitmap = bitmap
      @_hits_sprite.ox = 81
      @_hits_sprite.oy = 20
      @_hits_sprite.x = 500
      @_hits_sprite.y = 100
      @_hits_sprite.z = 3000
      @_hits_duration = 40
    end
#--------------------------------------------------------------------------
   # ● 总伤害处理
   #--------------------------------------------------------------------------
   def make_total_damage(value)
     if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
       @_total_damage += value
        # 绝对值转为字符串
        damage_string = @_total_damage.abs.to_s
      else
        return
      end
      # 初始化位图
      bitmap = Bitmap.new(300, 150)
      bitmap.font.name = "Arial Black"
      bitmap.font.size = 32
      # 伤害值是数值的情况下
      if value.is_a?(Numeric)
        # 分割伤害值字符串
        damage_array = damage_string.scan(/./)
        damage_x = 40 - damage_string.size * 9
        # 伤害值为负的情况下
        if value < 0
          # 调用回复数字表
          name="Number3"
        else
          # 调用伤害数字表
          name="Number2"
        end
        # 循环伤害值字符串
        for char in damage_array
          number = char.to_i
          # 显示伤害数字
          bitmap.blt(damage_x, 0, RPG::Cache.picture(name),
          Rect.new(number * 36.2, 0, 36.2, 50))
          # 后移一位
          damage_x += 36.2
        end
      end
      
      
        
        
#     if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
#       @_total_damage += value
#     else
#       return
#     end
#     bitmap = Bitmap.new(300, 150)
#     bitmap.font.name = "Arial Black"
#     bitmap.font.size = 40
#     bitmap.font.color.set(0, 0, 0)
#     bitmap.draw_text(+2, 12+2, 160, 40, @_total_damage.abs.to_s, 1)
#     if @_total_damage < 0
#       bitmap.font.color.set(80, 255, 00)
#    else
#       bitmap.font.color.set(255, 140, 0)
#     end
#     bitmap.draw_text(0, 12, 160, 40, @_total_damage.abs.to_s, 1)
#     bitmap.font.color.set(55, 55,255)
     
     
     if @_total_damage_sprite.nil?
       @_total_damage_sprite = ::Sprite.new(self.viewport)
       @_total_damage_sprite.ox = 80
       @_total_damage_sprite.oy = 20
       @_total_damage_sprite.z = 3000

     end
     @_total_damage_sprite.bitmap = bitmap
     @_total_damage_sprite.zoom_x = 0.8
     @_total_damage_sprite.zoom_y = 0.8
     @_total_damage_sprite.x = self.x
     @_total_damage_sprite.y = self.y  - self.oy / 2 - 64
     @_total_damage_sprite.z = 3001
     @_total_damage_duration = 80
     #hit数描绘
     @hits+=1
    if @_total_damage > 0
      hit
    end
   end


   def animation(animation, hit, battler_damage="", battler_critical=false)
     dispose_animation      
     #=======================================
     # 修改:记录伤害和critical
     #=======================================
     @battler_damage = battler_damage
     @battler_critical = battler_critical
     @_animation = animation
     return if @_animation == nil
     @_animation_hit = hit
     @_animation_duration = @_animation.frame_max
     animation_name = @_animation.animation_name
     animation_hue = @_animation.animation_hue
     bitmap = RPG::Cache.animation(animation_name, animation_hue)
     #=======================================
     # 修改:计算总闪光权限值
     #=======================================
     for timing in @_animation.timings
       quanzhong = animation_process_timing(timing, @_animation_hit,true)
       @all_quanzhong += quanzhong
       # 记录最后一次闪光
       @_last_frame = timing.frame if quanzhong != 0
     end      
     if @@_reference_count.include?(bitmap)
       @@_reference_count[bitmap] += 1
     else
       @@_reference_count[bitmap] = 1
     end
     #=======================================
     # 修改:行动方动画不显示伤害
     #=======================================
     if $scene.is_a?(Scene_Battle)
       if $scene.animation1_id == @battler.animation_id
         @battler_damage = ""
       end
     end
     @_animation_sprites = []
     if @_animation.position != 3 or not @@_animations.include?(animation)
       for i in 0..15
         sprite = ::Sprite.new(self.viewport)
         sprite.bitmap = bitmap
         sprite.visible = false
         @_animation_sprites.push(sprite)
       end
       unless @@_animations.include?(animation)
         @@_animations.push(animation)
       end
     end
     update_animation
  end
   #=======================================
   # 修改:更换清除伤害的算法,以防万一
   #       本内容在脚本中没有使用过
   #=======================================
   def dispose_damage
     for damage in @_damage.reverse
       damage[0].bitmap.dispose
       damage[0].dispose
       @_damage.delete(damage)
     end
     @_total_damage = 0
     @_last_frame = -1
     if @_total_damage_sprite != nil
       @_total_damage_duration = 0
       @_total_damage_sprite.bitmap.dispose
       @_total_damage_sprite.dispose
       @_total_damage_sprite = nil
     end
   end
   #=======================================
   # 清除hit数★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
   #=======================================
   def dispose_hit
     if @_hits_sprite != nil
       @_hits_sprite.bitmap.dispose
       @_hits_sprite.dispose
       @_hits_sprite = nil
     end
   end
   def dispose_animation
     #=======================================
     # 修改:清除记录的伤害,清除权重记录
     #=======================================
     @battler_damage = nil
     @battler_critical = nil
     @all_quanzhong = 1
     @_total_damage = 0
     @_last_frame = -1
     if @_animation_sprites != nil
       sprite = @_animation_sprites[0]
       if sprite != nil
         @@_reference_count[sprite.bitmap] -= 1
         if @@_reference_count[sprite.bitmap] == 0
           sprite.bitmap.dispose
         end
       end
       for sprite in @_animation_sprites
         sprite.dispose
       end
       @_animation_sprites = nil
       @_animation = nil
     end
   end
   def update
     super
     if @_whiten_duration > 0
       @_whiten_duration -= 1
       self.color.alpha = 128 - (16 - @_whiten_duration) * 10
     end
     if @_appear_duration > 0
       @_appear_duration -= 1
       self.opacity = (16 - @_appear_duration) * 16
     end
     if @_escape_duration > 0
       @_escape_duration -= 1
       self.opacity = 256 - (32 - @_escape_duration) * 10
     end
     if @_collapse_duration > 0
       @_collapse_duration -= 1
       self.opacity = 256 - (48 - @_collapse_duration) * 6
     end
     #=======================================
     # 修改:更新算法,更新弹出
     #=======================================
     if @_damage_duration > 0
       @_damage_duration -= 1
       for damage in @_damage
         damage[0].x = self.x + self.viewport.rect.x -
                       self.ox + self.src_rect.width / 2 +
                       (40 - damage[1]) * damage[3] / 10
         damage[0].y -= damage[4]+damage[1]/10
         damage[0].opacity = damage[1]*20
         damage[1] -= 1
         if damage[1]==0
           damage[0].bitmap.dispose
           damage[0].dispose
           @_damage.delete(damage)

           next
         end
       end
     end
     #=======================================
     # 添加:弹出总伤害
     #=======================================
     if @_total_damage_duration > 0
       @_total_damage_duration -= 1
       @_total_damage_sprite.y -= 1 if @_total_damage_duration % 2 == 0
       if @_total_damage_sprite.zoom_x > 1.0
         @_total_damage_sprite.zoom_x -= 0.05
       end
       if @_total_damage_sprite.zoom_y > 1.0
         @_total_damage_sprite.zoom_y -= 0.05
       end
       @_total_damage_sprite.opacity = 256 - (24 - @_total_damage_duration) * 16
       if @_total_damage_duration <= 0
         dispose_hit#★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
         @_total_damage = 0
         @_total_damage_duration = 0
         @_total_damage_sprite.bitmap.dispose
         @_total_damage_sprite.dispose
         @_total_damage_sprite = nil
       end
     end
     #=======================================
     if @_animation != nil and (Graphics.frame_count % 2 == 0)
       @_animation_duration -= 1
       update_animation
     end
     if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
       update_loop_animation
       @_loop_animation_index += 1
       @_loop_animation_index %= @_loop_animation.frame_max
     end
     if @_blink
       @_blink_count = (@_blink_count + 1) % 32
       if @_blink_count < 16
         alpha = (16 - @_blink_count) * 6
       else
         alpha = (@_blink_count - 16) * 6
       end
       self.color.set(255, 255, 255, alpha)
     end
     @@_animations.clear
   end
   def update_animation
    if @_animation_duration > 0
       frame_index = @_animation.frame_max - @_animation_duration
       cell_data = @_animation.frames[frame_index].cell_data
       position = @_animation.position
       animation_set_sprites(@_animation_sprites, cell_data, position)
       #=======================================
       # 修改:弹出伤害,权重计算
       #=======================================
       for timing in @_animation.timings
         if timing.frame == frame_index
           t = 1.0 * animation_process_timing(timing, @_animation_hit)  
                   if timing.se.name != ""
          se=timing.se
          Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
        end
           #p t,"当前权重", @all_quanzhong,"总权重"
           if @battler_damage.is_a?(Numeric) and t != 0
             t *= @battler_damage
             t /= @all_quanzhong
             t = t.to_i
             #在闪光不是最后一次的情况下,把这次伤害加入到已经发生的伤害中★★★★★★★★★★★★★★★★★★★★★★★★★★
             if frame_index != @_last_frame
             @p_dam+= t
             end
             #p @p_dam,"已发生伤害",@battler_damage,"总伤害"(调试用)★★★★★★★★★★★★★★★★★★★★★★★★★★
             #闪光为最后一次的情况下,改变这次伤害的计算方法(总伤害-已经发生伤害)★★★★★★★★★★★★★★★★★★★★★★★★★★
             if frame_index == @_last_frame
               t=@battler_damage-@p_dam
             end
             #p t,"当前伤害",@battler_damage,"总伤害"
             # 最后一次闪光的话,伤害修正
             if frame_index == @_last_frame
               @_total_damage = @battler_damage - t
               @p_dam=0      #已经发生的伤害归0★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
            end
             #p t,@battler_damage,@all_quanzhong
             damage(t,@battler_critical)
            #连击次数归0★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
            if frame_index == @_last_frame
                      @hits=0  
            end
           # 防止重复播放miss
           elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
             damage(@battler_damage,@battler_critical)
           end
         end
       end
     else
       dispose_animation
     end
   end
   #=======================================
   # 修改:敌人跳跃的功能 + 添加返回数值
   #=======================================
    def animation_process_timing(timing, hit,dontflash=false)
      if (timing.condition == 0) or
         (timing.condition == 1 and hit == true) or
         (timing.condition == 2 and hit == false)
        case timing.flash_scope
        when 1
          unless dontflash
            self.flash(timing.flash_color, timing.flash_duration * 2)
            if @_total_damage >0
              @flash_shake_switch = true
              @flash_shake = 10
            end
          end
          return timing.flash_color.alpha * timing.flash_duration
        when 2
          unless dontflash
            if self.viewport != nil
              self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
            end
          end
          return timing.flash_color.alpha * timing.flash_duration
        when 3
          unless dontflash
            self.flash(nil, timing.flash_duration * 2)
          end
          return timing.flash_color.alpha * timing.flash_duration
        end
      end      
      return 0
    end   
end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < RPG::Sprite
#--------------------------------------------------------------------------
# ● 初始化对像
#    添加跳跃记录
#--------------------------------------------------------------------------
def initialize(viewport, battler = nil)
  super(viewport)
  @battler = battler
  @battler_visible = false
  @flash_shake_switch = true
end
#--------------------------------------------------------------------------
# ● 刷新画面
#    增添跳跃功能
#--------------------------------------------------------------------------
def update
  super
  # 战斗者为 nil 的情况下
  if @battler == nil
    self.bitmap = nil
    loop_animation(nil)
    return
  end
  # 文件名和色相与当前情况有差异的情况下
  if @battler.battler_name != @battler_name or
     @battler.battler_hue != @battler_hue
    # 获取、设置位图
    @battler_name = @battler.battler_name
    @battler_hue = @battler.battler_hue
    self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
    @width = bitmap.width
    @height = bitmap.height
    self.ox = @width / 2
    self.oy = @height
    # 如果是战斗不能或者是隐藏状态就把透明度设置成 0
    if @battler.dead? or @battler.hidden
      self.opacity = 0
    end
  end
  # 动画 ID 与当前的情况有差异的情况下
  if @battler.damage == nil and
     @battler.state_animation_id != @state_animation_id
    @state_animation_id = @battler.state_animation_id
    loop_animation($data_animations[@state_animation_id])
  end
  # 应该被显示的角色的情况下
  if @battler.is_a?(Game_Actor) and @battler_visible
    # 不是主状态的时候稍稍降低点透明度
    if $game_temp.battle_main_phase
      self.opacity += 3 if self.opacity < 255
    else
      self.opacity -= 3 if self.opacity > 207
    end
  end
  # 明灭
  if @battler.blink
    blink_on
  else
    blink_off
  end
  # 不可见的情况下
  unless @battler_visible
    # 出现
    if not @battler.hidden and not @battler.dead? and
       (@battler.damage == nil or @battler.damage_pop)
      appear
      @battler_visible = true
    end
  end
  # 可见的情况下
  if @battler_visible
    # 逃跑
    if @battler.hidden
      $game_system.se_play($data_system.escape_se)
      escape
      @battler_visible = false
    end
    # 白色闪烁
    if @battler.white_flash
      whiten
      @battler.white_flash = false
    end
    # 动画
    if @battler.animation_id != 0
      animation = $data_animations[@battler.animation_id]
      animation(animation, @battler.animation_hit,@battler.damage, @battler.critical)
      @battler.animation_id = 0
    end
    # 伤害
    if @battler.damage_pop
      @battler.damage = nil
      @battler.critical = false
      @battler.damage_pop = false
    end
    # korapusu
    if @battler.damage == nil and @battler.dead?
      if @battler.is_a?(Game_Enemy)
        $game_system.se_play($data_system.enemy_collapse_se)
      else
        $game_system.se_play($data_system.actor_collapse_se)
      end
      collapse
      @battler_visible = false
    end
  end
  # 设置活动块的坐标
  if @flash_shake_switch == true
    self.x = @battler.screen_x
    self.y = @battler.screen_y
    self.z = @battler.screen_z
    @flash_shake_switch = false
  end
  if @flash_shake != 0 and @battler.damage != nil and RPG::BATTLER_JUMP
    case @flash_shake
    when 9..10
      self.x = @battler.screen_x
      self.y -=4
      self.z = @battler.screen_z
    when 6..8
      self.x = @battler.screen_x
      self.y -=2
      self.z = @battler.screen_z
    when 3..5
      self.x = @battler.screen_x
      self.y +=2
      self.z = @battler.screen_z
    when 2
      self.x = @battler.screen_x
      self.y += 4
      self.z = @battler.screen_z
    when 1
      self.x = @battler.screen_x
      self.y = @battler.screen_y
      self.z = @battler.screen_z
    end
    @flash_shake -= 1
  end
end
end

#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
#  处理战斗画面的类。
#==============================================================================

class Scene_Battle
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader   :animation1_id                    # 行动方动画ID
end

#==============================================================================
# ■ Game_Battler
#------------------------------------------------------------------------------
#  处理战斗者的类。这个类作为 Game_Actor 类与 Game_Enemy 类的
# 超级类来使用。
#==============================================================================

#class Game_Battler
#  #--------------------------------------------------------------------------
#  # ● 应用连续伤害效果
#  #--------------------------------------------------------------------------
#  alias rainbow_sword_slip_damage_effect slip_damage_effect
#  def slip_damage_effect
#    self.animation_id = RPG::SLIP_DAMAGE_ANIMATION_ID
#    self.animation_hit = true
#    rainbow_sword_slip_damage_effect
#  end
#end
[/pre]1:消除对象居然也算一次连击,,,如何让消除对象不算连击?
2:我记得以前有一个彩虹神剑和动态扣血整合的脚本。。。
就是本来伤害为90的技能,同等强度的闪烁了3次,就是三次连击,30+30+30=90
假设当前角色有100血,然后默认的扣血方式是

等技能结束后,100-90=HP直接显示成10

我想要的效果是。。。

在技能释放的途中每闪烁一次就刷新一次角色的HP。。。
效果就是 100-30=显示70,70-30=显示40,40-30=显示10

谢了,下面是我的那个彩虹神剑的脚本

最佳答案

查看完整内容

没有发现喝药不回血的情况啊,不信我喝给你看,咕嘟咕嘟咕嘟。。。。。 但是喝药的动画一定要有闪光,否则就真回不了血了! 其他问题不好意思了,请用下面这个我又修改过的: 看来我药不能停啊 这次在菜单里喝给你看 咕嘟咕嘟咕嘟 用下面这个:

点评

请看最后一层楼,我修改了一下  发表于 2015-8-15 20:12

咩

梦石
0
星屑
1640
在线时间
381 小时
注册时间
2010-10-9
回帖
286

开拓者

发表于 2015-8-2 17:43:10 | 显示全部楼层
本帖最后由 piaoy 于 2015-8-15 20:10 编辑

没有发现喝药不回血的情况啊,不信我喝给你看,咕嘟咕嘟咕嘟。。。。。
但是喝药的动画一定要有闪光,否则就真回不了血了!
其他问题不好意思了,请用下面这个我又修改过的:

看来我药不能停啊 这次在菜单里喝给你看 咕嘟咕嘟咕嘟
用下面这个:
Scripts.rxdata (233.22 KB, 下载次数: 59)

点评

CR~
十分感谢!!!  发表于 2015-8-15 20:42
CR~
在菜单的时候喝药只有音效没有效果。。。  发表于 2015-8-15 19:50
回复

使用道具 举报

咩

梦石
0
星屑
1640
在线时间
381 小时
注册时间
2010-10-9
回帖
286

开拓者

发表于 2015-8-3 12:21:44 | 显示全部楼层
本帖最后由 piaoy 于 2015-8-4 18:41 编辑

大致做了一个,还有些地方不完善,比如加sp不会显示数字,而且如果用血槽脚本的肯定要对应着改的。
请试试能不能用:
[pre lang="ruby"]=begin
==============================================================================

彩虹神剑(伤害分段显示)显示总伤害版 v1.0d

==============================================================================

彩虹神剑 -柳柳

6-20-2006 v1.0 -叶子
在彩虹神剑的基础上增加了显示总伤害的功能,而且总伤害的数字是弹出伤害时逐渐增加的

v1.0a -叶子
修正了显示伤害和实际伤害有差别的问题
修正了miss的情况下显示miss混乱的问题
修正了对己方技能重复显示伤害的问题
未修正播放目标动画第一帧时目标有时无端跳动的BUG

v1.0b -叶子
修改了总伤害数字的位置和z坐标
未修正播放目标动画第一帧时目标有时无端跳动的BUG

v1.0c -柳柳
? ? ?

v1.0d -柳柳
1.0d最终解决了那个闪光问题,还有最末帧伤害多次的算法

7-24-2006 v1.0e -叶子
修正全屏幕闪烁弹出伤害错误的问题
修正连续伤害不会弹出伤害的问题
仍然未修正播放目标动画第一帧时目标有时无端跳动的BUG

我鼓起很大勇气才敢动偶像们的脚本的,不知道会不会出问题啊......  -cftx
修正了总伤害显示
增加了伤害美化和HIT数显示
修正了两次音效

==============================================================================
=end
# 核心的说明:
# damage_pop 不再附带damage()的功能,这个放到animation里面去了

module RPG
        #--------------------------------------------------------------------------
        # ● 常量设定
        #--------------------------------------------------------------------------
        # 是否显示总伤害
        SHOW_TOTAL_DAMAGE = true
        # 角色受攻击时是否跳一下
        BATTLER_JUMP = false
        # 连续伤害的动画ID
        SLIP_DAMAGE_ANIMATION_ID = 105
       
        class Sprite < ::Sprite
                #==========================================
                # 修改说明:
                # @flash_shake用来制作挨打时候跳跃
                # @_damage    用来记录每次打击之后弹出数字
                # @_total_damage 记录总伤害
                # @_total_damage_duration 总伤害持续帧
                #==========================================
                #alias 66RPG_rainbow_initialize : initialize
               
                def initialize(viewport = nil)
                        #66RPG_rainbow_initialize(viewport)
                        super(viewport)
                        @_whiten_duration = 0
                        @_appear_duration = 0
                        @_escape_duration = 0
                        @_collapse_duration = 0
                        @_damage_duration = 0
                        @_animation_duration = 0
                        @_blink = false
                        # 挨打时候跳跃
                        @flash_shake = 0
                        # 伤害记录数组
                        @_damage = []
                        # 总伤害数字
                        @_total_damage = 0
                        # 总伤害持续帧
                        @_total_damage_duration = 0
                        #记录已经发生的伤害的变量★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
                        @p_dam=0
                        @hits=0
                end
                #美化的伤害处理★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
                def damage(value, critical)
                        # 释放伤害,效果是伤害数字快速消失,觉得不如不消失好看......
                        #dispose_damage
                        #清除hit数
                        dispose_hit
                        # 如果伤害值是数值
                        if value.is_a?(Numeric)
                                # 绝对值转为字符串
                                damage_string = value.abs.to_s
                        else
                                # 转为字符串
                                damage_string = value.to_s
                        end
                        # 初始化位图
                        bitmap = Bitmap.new(162, 64)
                        bitmap.font.name = ["黑体","华文行楷", "宋体"]
                        bitmap.font.size = 32
                        # 伤害值是数值的情况下
                        if value.is_a?(Numeric)
                                # 分割伤害值字符串
                                damage_array = damage_string.scan(/./)
                                damage_x = 81 - damage_string.size * 9
                                # 伤害值为负的情况下
                                if value < 0
                                        # 调用回复数字表
                                        rect_y = 32
                                else
                                        # 调用伤害数字表
                                        rect_y = 0
                                end
                                # 循环伤害值字符串
                                for char in damage_array
                                        number = char.to_i
                                        # 显示伤害数字
                                        bitmap.blt(damage_x, 32, RPG::Cache.picture("Damage"),
                                                Rect.new(number * 18, rect_y, 18, 32))
                                        # 后移一位
                                        damage_x += 18
                                end
                                # 伤害值不是数值的情况
                        else
                                # 如果伤害值不是 Miss
                                unless value == "Miss"
                                        # 系统默认描画字符串
                                        bitmap.font.color.set(0, 0, 0)
                                        bitmap.draw_text(-1, 27, 162, 36, damage_string, 1)
                                        bitmap.draw_text(+1, 27, 162, 36, damage_string, 1)
                                        bitmap.draw_text(-1, 29, 162, 36, damage_string, 1)
                                        bitmap.draw_text(+1, 29, 162, 36, damage_string, 1)
                                        bitmap.font.color.set(255, 255, 255)
                                        bitmap.draw_text(0, 28, 162, 36, damage_string, 1)
                                        # Miss 的情况下
                                else
                                        # 显示未击中图画
                                        bitmap.blt(36, 28, RPG::Cache.picture("Damage"), Rect.new(90, 64, 90, 32))
                                end
                        end
                        # 会心一击标志打开的情况
                        if critical
                                # 显示会心一击图画
                                bitmap.blt(36, 0, RPG::Cache.picture("Damage"), Rect.new(0, 64, 90, 32))
                        end
                        # 伤害值定位
                        @_damage_sprite = ::Sprite.new(self.viewport)
                        @_damage_sprite.bitmap = bitmap
                        @_damage_sprite.ox = 81
                        @_damage_sprite.oy = 20
                        @_damage_sprite.x = self.x
                        @_damage_sprite.y = self.y - self.oy / 2
                        @_damage_sprite.z = 3000
                        @_damage_duration = 40
                        @_damage.push([@_damage_sprite,@_damage_duration-10,0, rand(30) - 15, rand(3)])
                        make_total_damage(value)  
                       
                end
               
                #   ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
                # hit数的美化描绘
                def hit
                       
                        # 如果伤害值是数值
                        # 转为字符串
                        value=@hits
                        hits_string = value.to_s
                        # 初始化位图
                        bitmap = Bitmap.new(320, 64)
                        bitmap.font.name = "Arial Black"
                        bitmap.font.size = 32
                        # 分割伤害值字符串
                        hits_array = hits_string.scan(/./)
                        hits_x = 81 - hits_string.size * 18.1
                        rect_y = 0
                        # 循环伤害值字符串
                        for char in hits_array
                                number = char.to_i
                                # 显示伤害数字
                                bitmap.blt(hits_x, 0, RPG::Cache.picture("Number"),
                                        Rect.new(number * 36.2, rect_y, 36.2, 50))
                                # 后移一位
                                hits_x += 36.2
                        end
                        bitmap.blt(hits_x, 0, RPG::Cache.picture("HITS"),
                                Rect.new(0, -21, 90, 50))
                       
                        # 伤害值定位
                        @_hits_sprite = ::Sprite.new(self.viewport)
                        @_hits_sprite.bitmap = bitmap
                        @_hits_sprite.ox = 81
                        @_hits_sprite.oy = 20
                        @_hits_sprite.x = 500
                        @_hits_sprite.y = 100
                        @_hits_sprite.z = 3000
                        @_hits_duration = 40
                end
                #--------------------------------------------------------------------------
                # ● 总伤害处理
                #--------------------------------------------------------------------------
                def make_total_damage(value)
                        if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
                                @_total_damage += value
                                # 绝对值转为字符串
                                damage_string = @_total_damage.abs.to_s
                        else
                                return
                        end
                        # 初始化位图
                        bitmap = Bitmap.new(300, 150)
                        bitmap.font.name = "Arial Black"
                        bitmap.font.size = 32
                        # 伤害值是数值的情况下
                        if value.is_a?(Numeric)
                                # 分割伤害值字符串
                                damage_array = damage_string.scan(/./)
                                damage_x = 40 - damage_string.size * 9
                                # 伤害值为负的情况下
                                if value < 0
                                        # 调用回复数字表
                                        name="Number3"
                                else
                                        # 调用伤害数字表
                                        name="Number2"
                                end
                                # 循环伤害值字符串
                                for char in damage_array
                                        number = char.to_i
                                        # 显示伤害数字
                                        bitmap.blt(damage_x, 0, RPG::Cache.picture(name),
                                                Rect.new(number * 36.2, 0, 36.2, 50))
                                        # 后移一位
                                        damage_x += 36.2
                                end
                        end
                       
                       
                       
                       
                        #     if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
                        #       @_total_damage += value
                        #     else
                        #       return
                        #     end
                        #     bitmap = Bitmap.new(300, 150)
                        #     bitmap.font.name = "Arial Black"
                        #     bitmap.font.size = 40
                        #     bitmap.font.color.set(0, 0, 0)
                        #     bitmap.draw_text(+2, 12+2, 160, 40, @_total_damage.abs.to_s, 1)
                        #     if @_total_damage < 0
                        #       bitmap.font.color.set(80, 255, 00)
                        #    else
                        #       bitmap.font.color.set(255, 140, 0)
                        #     end
                        #     bitmap.draw_text(0, 12, 160, 40, @_total_damage.abs.to_s, 1)
                        #     bitmap.font.color.set(55, 55,255)
                       
                       
                        if @_total_damage_sprite.nil?
                                @_total_damage_sprite = ::Sprite.new(self.viewport)
                                @_total_damage_sprite.ox = 80
                                @_total_damage_sprite.oy = 20
                                @_total_damage_sprite.z = 3000
                               
                        end
                        @_total_damage_sprite.bitmap = bitmap
                        @_total_damage_sprite.zoom_x = 0.8
                        @_total_damage_sprite.zoom_y = 0.8
                        @_total_damage_sprite.x = self.x
                        @_total_damage_sprite.y = self.y  - self.oy / 2 - 64
                        @_total_damage_sprite.z = 3001
                        @_total_damage_duration = 80
                        #hit数描绘
                        @hits+=1
                        if @_total_damage > 0
                                hit
                        end
                end
               
               
                def animation(animation, hit, battler_damage="", battler_critical=false)
                        dispose_animation      
                        #=======================================
                        # 修改:记录伤害和critical
                        #=======================================
                        @battler_damage = battler_damage
                        @battler_critical = battler_critical
                        @_animation = animation
                        return if @_animation == nil
                        @_animation_hit = hit
                        @_animation_duration = @_animation.frame_max
                        animation_name = @_animation.animation_name
                        animation_hue = @_animation.animation_hue
                        bitmap = RPG::Cache.animation(animation_name, animation_hue)
                        #=======================================
                        # 修改:计算总闪光权限值
                        #=======================================
                        for timing in @_animation.timings
                                quanzhong = animation_process_timing(timing, @_animation_hit,true)
                                @all_quanzhong += quanzhong
                                # 记录最后一次闪光
                                @_last_frame = timing.frame if quanzhong != 0
                        end      
                        if @@_reference_count.include?(bitmap)
                                @@_reference_count[bitmap] += 1
                        else
                                @@_reference_count[bitmap] = 1
                        end
                        #=======================================
                        # 修改:行动方动画不显示伤害
                        #=======================================
                        if $scene.is_a?(Scene_Battle)
                                if $scene.animation1_id == @battler.animation_id
                                        @battler_damage = ""
                                end
                        end
                        @_animation_sprites = []
                        if @_animation.position != 3 or not @@_animations.include?(animation)
                                for i in 0..15
                                        sprite = ::Sprite.new(self.viewport)
                                        sprite.bitmap = bitmap
                                        sprite.visible = false
                                        @_animation_sprites.push(sprite)
                                end
                                unless @@_animations.include?(animation)
                                        @@_animations.push(animation)
                                end
                        end
                        update_animation
                end
                #=======================================
                # 修改:更换清除伤害的算法,以防万一
                #       本内容在脚本中没有使用过
                #=======================================
                def dispose_damage
                        for damage in @_damage.reverse
                                damage[0].bitmap.dispose
                                damage[0].dispose
                                @_damage.delete(damage)
                        end
                        @_total_damage = 0
                        @_last_frame = -1
                        if @_total_damage_sprite != nil
                                @_total_damage_duration = 0
                                @_total_damage_sprite.bitmap.dispose
                                @_total_damage_sprite.dispose
                                @_total_damage_sprite = nil
                        end
                end
                #=======================================
                # 清除hit数★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
                #=======================================
                def dispose_hit
                        if @_hits_sprite != nil
                                @_hits_sprite.bitmap.dispose
                                @_hits_sprite.dispose
                                @_hits_sprite = nil
                        end
                end
                def dispose_animation
                        #=======================================
                        # 修改:清除记录的伤害,清除权重记录
                        #=======================================
                        @battler_damage = nil
                        @battler_critical = nil
                        @all_quanzhong = 1
                        @_total_damage = 0
                        @_last_frame = -1
                        if @_animation_sprites != nil
                                sprite = @_animation_sprites[0]
                                if sprite != nil
                                        @@_reference_count[sprite.bitmap] -= 1
                                        if @@_reference_count[sprite.bitmap] == 0
                                                sprite.bitmap.dispose
                                        end
                                end
                                for sprite in @_animation_sprites
                                        sprite.dispose
                                end
                                @_animation_sprites = nil
                                @_animation = nil
                        end
                end
                def update
                        super
                        if @_whiten_duration > 0
                                @_whiten_duration -= 1
                                self.color.alpha = 128 - (16 - @_whiten_duration) * 10
                        end
                        if @_appear_duration > 0
                                @_appear_duration -= 1
                                self.opacity = (16 - @_appear_duration) * 16
                        end
                        if @_escape_duration > 0
                                @_escape_duration -= 1
                                self.opacity = 256 - (32 - @_escape_duration) * 10
                        end
                        if @_collapse_duration > 0
                                @_collapse_duration -= 1
                                self.opacity = 256 - (48 - @_collapse_duration) * 6
                        end
                        #=======================================
                        # 修改:更新算法,更新弹出
                        #=======================================
                        if @_damage_duration > 0
                                @_damage_duration -= 1
                                for damage in @_damage
                                        damage[0].x = self.x + self.viewport.rect.x -
                                        self.ox + self.src_rect.width / 2 +
                                        (40 - damage[1]) * damage[3] / 10
                                        damage[0].y -= damage[4]+damage[1]/10
                                        damage[0].opacity = damage[1]*20
                                        damage[1] -= 1
                                        if damage[1]==0
                                                damage[0].bitmap.dispose
                                                damage[0].dispose
                                                @_damage.delete(damage)
                                               
                                                next
                                        end
                                end
                        end
                        #=======================================
                        # 添加:弹出总伤害
                        #=======================================
                        if @_total_damage_duration > 0
                                @_total_damage_duration -= 1
                                @_total_damage_sprite.y -= 1 if @_total_damage_duration % 2 == 0
                                if @_total_damage_sprite.zoom_x > 1.0
                                        @_total_damage_sprite.zoom_x -= 0.05
                                end
                                if @_total_damage_sprite.zoom_y > 1.0
                                        @_total_damage_sprite.zoom_y -= 0.05
                                end
                                @_total_damage_sprite.opacity = 256 - (24 - @_total_damage_duration) * 16
                                if @_total_damage_duration <= 0
                                        dispose_hit#★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
                                        @_total_damage = 0
                                        @_total_damage_duration = 0
                                        @_total_damage_sprite.bitmap.dispose
                                        @_total_damage_sprite.dispose
                                        @_total_damage_sprite = nil
                                end
                        end
                        #=======================================
                        if @_animation != nil and (Graphics.frame_count % 2 == 0)
                                @_animation_duration -= 1
                                update_animation
                        end
                        if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
                                update_loop_animation
                                @_loop_animation_index += 1
                                @_loop_animation_index %= @_loop_animation.frame_max
                        end
                        if @_blink
                                @_blink_count = (@_blink_count + 1) % 32
                                if @_blink_count < 16
                                        alpha = (16 - @_blink_count) * 6
                                else
                                        alpha = (@_blink_count - 16) * 6
                                end
                                self.color.set(255, 255, 255, alpha)
                        end
                        @@_animations.clear
                end
                def update_animation
                        if @_animation_duration > 0
                                frame_index = @_animation.frame_max - @_animation_duration
                                cell_data = @_animation.frames[frame_index].cell_data
                                position = @_animation.position
                                animation_set_sprites(@_animation_sprites, cell_data, position)
                                #=======================================
                                # 修改:弹出伤害,权重计算
                                #=======================================
                                for timing in @_animation.timings
                                        if timing.frame == frame_index
                                                t = 1.0 * animation_process_timing(timing, @_animation_hit)  
                                                if timing.se.name != ""
                                                        se=timing.se
                                                        Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
                                                end
                                                #p t,"当前权重", @all_quanzhong,"总权重"
                                                if @battler_damage.is_a?(Numeric) and t != 0
                                                        t *= @battler_damage
                                                        t /= @all_quanzhong
                                                        t = t.to_i
                                                        #在闪光不是最后一次的情况下,把这次伤害加入到已经发生的伤害中★★★★★★★★★★★★★★★★★★★★★★★★★★
                                                        if frame_index != @_last_frame
                                                                @p_dam+= t
                                                        end
                                                        #p @p_dam,"已发生伤害",@battler_damage,"总伤害"(调试用)★★★★★★★★★★★★★★★★★★★★★★★★★★
                                                        #闪光为最后一次的情况下,改变这次伤害的计算方法(总伤害-已经发生伤害)★★★★★★★★★★★★★★★★★★★★★★★★★★
                                                        if frame_index == @_last_frame
                                                                t=@battler_damage-@p_dam
                                                        end
                                                        #p t,"当前伤害",@battler_damage,"总伤害"
                                                        # 最后一次闪光的话,伤害修正
                                                        if frame_index == @_last_frame
                                                                @_total_damage = @battler_damage - t
                                                                @p_dam=0      #已经发生的伤害归0★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
                                                        end
                                                        #p t,@battler_damage,@all_quanzhong
                                                        damage(t,@battler_critical)
                                                        @battler.hp -= t
                                                        #连击次数归0★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
                                                        if frame_index == @_last_frame
                                                                @hits=0  
                                                        end
                                                        # 防止重复播放miss
                                                elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
                                                        damage(@battler_damage,@battler_critical)
                                                end
                                        end
                                end
                        else
                                dispose_animation
                        end
                end
                #=======================================
                # 修改:敌人跳跃的功能 + 添加返回数值
                #=======================================
                def animation_process_timing(timing, hit,dontflash=false)
                        if (timing.condition == 0) or
                                (timing.condition == 1 and hit == true) or
                                (timing.condition == 2 and hit == false)
                                case timing.flash_scope
                                when 1
                                        unless dontflash
                                                self.flash(timing.flash_color, timing.flash_duration * 2)
                                                if @_total_damage >0
                                                        @flash_shake_switch = true
                                                        @flash_shake = 10
                                                end
                                        end
                                        return timing.flash_color.alpha * timing.flash_duration
                                when 2
                                        unless dontflash
                                                if self.viewport != nil
                                                        self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
                                                end
                                        end
                                        return timing.flash_color.alpha * timing.flash_duration
                                end
                        end      
                        return 0
                end   
        end
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < RPG::Sprite
        #--------------------------------------------------------------------------
        # ● 初始化对像
        #    添加跳跃记录
        #--------------------------------------------------------------------------
        def initialize(viewport, battler = nil)
                super(viewport)
                @battler = battler
                @battler_visible = false
                @flash_shake_switch = true
        end
        #--------------------------------------------------------------------------
        # ● 刷新画面
        #    增添跳跃功能
        #--------------------------------------------------------------------------
        def update
                super
                # 战斗者为 nil 的情况下
                if @battler == nil
                        self.bitmap = nil
                        loop_animation(nil)
                        return
                end
                # 文件名和色相与当前情况有差异的情况下
                if @battler.battler_name != @battler_name or
                        @battler.battler_hue != @battler_hue
                        # 获取、设置位图
                        @battler_name = @battler.battler_name
                        @battler_hue = @battler.battler_hue
                        self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
                        @width = bitmap.width
                        @height = bitmap.height
                        self.ox = @width / 2
                        self.oy = @height
                        # 如果是战斗不能或者是隐藏状态就把透明度设置成 0
                        if @battler.dead? or @battler.hidden
                                self.opacity = 0
                        end
                end
                # 动画 ID 与当前的情况有差异的情况下
                if @battler.damage == nil and
                        @battler.state_animation_id != @state_animation_id
                        @state_animation_id = @battler.state_animation_id
                        loop_animation($data_animations[@state_animation_id])
                end
                # 应该被显示的角色的情况下
                if @battler.is_a?(Game_Actor) and @battler_visible
                        # 不是主状态的时候稍稍降低点透明度
                        if $game_temp.battle_main_phase
                                self.opacity += 3 if self.opacity < 255
                        else
                                self.opacity -= 3 if self.opacity > 207
                        end
                end
                # 明灭
                if @battler.blink
                        blink_on
                else
                        blink_off
                end
                # 不可见的情况下
                unless @battler_visible
                        # 出现
                        if not @battler.hidden and not @battler.dead? and
                                (@battler.damage == nil or @battler.damage_pop)
                                appear
                                @battler_visible = true
                        end
                end
                # 可见的情况下
                if @battler_visible
                        # 逃跑
                        if @battler.hidden
                                $game_system.se_play($data_system.escape_se)
                                escape
                                @battler_visible = false
                        end
                        # 白色闪烁
                        if @battler.white_flash
                                whiten
                                @battler.white_flash = false
                        end
                        # 动画
                        if @battler.animation_id != 0
                                animation = $data_animations[@battler.animation_id]
                                animation(animation, @battler.animation_hit,@battler.damage, @battler.critical)
                                @battler.animation_id = 0
                        end
                        # 伤害
                        if @battler.damage_pop
                                @battler.damage = nil
                                @battler.critical = false
                                @battler.damage_pop = false
                        end
                        # korapusu
                        if @battler.damage == nil and @battler.dead?
                                if @battler.is_a?(Game_Enemy)
                                        $game_system.se_play($data_system.enemy_collapse_se)
                                else
                                        $game_system.se_play($data_system.actor_collapse_se)
                                end
                                collapse
                                @battler_visible = false
                        end
                end
                # 设置活动块的坐标
                if @flash_shake_switch == true
                        self.x = @battler.screen_x
                        self.y = @battler.screen_y
                        self.z = @battler.screen_z
                        @flash_shake_switch = false
                end
                if @flash_shake != 0 and @battler.damage != nil and RPG::BATTLER_JUMP
                        case @flash_shake
                        when 9..10
                                self.x = @battler.screen_x
                                self.y -=4
                                self.z = @battler.screen_z
                        when 6..8
                                self.x = @battler.screen_x
                                self.y -=2
                                self.z = @battler.screen_z
                        when 3..5
                                self.x = @battler.screen_x
                                self.y +=2
                                self.z = @battler.screen_z
                        when 2
                                self.x = @battler.screen_x
                                self.y += 4
                                self.z = @battler.screen_z
                        when 1
                                self.x = @battler.screen_x
                                self.y = @battler.screen_y
                                self.z = @battler.screen_z
                        end
                        @flash_shake -= 1
                end
        end
end
#==============================================================================
# ■ Game_Battler (分割定义 1)
#------------------------------------------------------------------------------
#  处理战斗者的类。这个类作为 Game_Actor 类与 Game_Enemy 类的
# 超级类来使用。
#==============================================================================

class Game_Battler
#--------------------------------------------------------------------------
  # ● 应用通常攻击效果
  #     attacker : 攻击者 (battler)
  #--------------------------------------------------------------------------
  def attack_effect(attacker)
    # 清除会心一击标志
    self.critical = false
    # 第一命中判定
    hit_result = (rand(100) < attacker.hit)
    # 命中的情况下
    if hit_result == true
      # 计算基本伤害
      atk = [attacker.atk - self.pdef / 2, 0].max
      self.damage = atk * (20 + attacker.str) / 20
      # 属性修正
      self.damage *= elements_correct(attacker.element_set)
      self.damage /= 100
      # 伤害符号正确的情况下
      if self.damage > 0
        # 会心一击修正
        if rand(100) < 4 * attacker.dex / self.agi
          self.damage *= 2
          self.critical = true
        end
        # 防御修正
        if self.guarding?
          self.damage /= 2
        end
      end
      # 分散
      if self.damage.abs > 0
        amp = [self.damage.abs * 15 / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # 第二命中判定
      eva = 8 * self.agi / attacker.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
    end
    # 命中的情况下
    if hit_result == true
      # 状态冲击解除
      remove_states_shock
      # HP 的伤害计算
      #self.hp -= self.damage
      # 状态变化
      @state_changed = false
      states_plus(attacker.plus_state_set)
      states_minus(attacker.minus_state_set)
    # Miss 的情况下
    else
      # 伤害设置为 "Miss"
      self.damage = "Miss"
      # 清除会心一击标志
      self.critical = false
    end
    # 过程结束
    return true
  end
  #--------------------------------------------------------------------------
  # ● 应用特技效果
  #     user  : 特技的使用者 (battler)
  #     skill : 特技
  #--------------------------------------------------------------------------
  def skill_effect(user, skill)
    # 清除会心一击标志
    self.critical = false
    # 特技的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
    # 或者特技的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
    if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
       ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
      # 过程结束
      return false
    end
    # 清除有效标志
    effective = false
    # 公共事件 ID 是有效的情况下,设置为有效标志
    effective |= skill.common_event_id > 0
    # 第一命中判定
    hit = skill.hit
    if skill.atk_f > 0
      hit *= user.hit / 100
    end
    hit_result = (rand(100) < hit)
    # 不确定的特技的情况下设置为有效标志
    effective |= hit < 100
    # 命中的情况下
    if hit_result == true
      # 计算威力
      power = skill.power + user.atk * skill.atk_f / 100
      if power > 0
        power -= self.pdef * skill.pdef_f / 200
        power -= self.mdef * skill.mdef_f / 200
        power = [power, 0].max
      end
      # 计算倍率
      rate = 20
      rate += (user.str * skill.str_f / 100)
      rate += (user.dex * skill.dex_f / 100)
      rate += (user.agi * skill.agi_f / 100)
      rate += (user.int * skill.int_f / 100)
      # 计算基本伤害
      self.damage = power * rate / 20
      # 属性修正
      self.damage *= elements_correct(skill.element_set)
      self.damage /= 100
      # 伤害符号正确的情况下
      if self.damage > 0
        # 防御修正
        if self.guarding?
          self.damage /= 2
        end
      end
      # 分散
      if skill.variance > 0 and self.damage.abs > 0
        amp = [self.damage.abs * skill.variance / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # 第二命中判定
      eva = 8 * self.agi / user.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
      # 不确定的特技的情况下设置为有效标志
      effective |= hit < 100
    end
    # 命中的情况下
    if hit_result == true
      # 威力 0 以外的物理攻击的情况下
      if skill.power != 0 and skill.atk_f > 0
        # 状态冲击解除
        remove_states_shock
        # 设置有效标志
        effective = true
      end
      # HP 的伤害减法运算
      last_hp = self.hp
                        new_hp = self.hp - self.damage  #piaoy
      #self.hp -= self.damage #piaoy
      effective |= new_hp != last_hp
      # 状态变化
      @state_changed = false
      effective |= states_plus(skill.plus_state_set)
      effective |= states_minus(skill.minus_state_set)
      # 威力为 0 的场合
      if skill.power == 0
        # 伤害设置为空的字串
        self.damage = ""
        # 状态没有变化的情况下
        unless @state_changed
          # 伤害设置为 "Miss"
          self.damage = "Miss"
        end
      end
    # Miss 的情况下
    else
      # 伤害设置为 "Miss"
      self.damage = "Miss"
    end
    # 不在战斗中的情况下
    unless $game_temp.in_battle
      # 伤害设置为 nil
      self.damage = nil
    end
    # 过程结束
    return effective
  end
  #--------------------------------------------------------------------------
  # ● 应用物品效果
  #     item : 物品
  #--------------------------------------------------------------------------
  def item_effect(item)
    # 清除会心一击标志
    self.critical = false
    # 物品的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
    # 或者物品的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
    if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
       ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
      # 过程结束
      return false
    end
    # 清除有效标志
    effective = false
    # 公共事件 ID 是有效的情况下,设置为有效标志
    effective |= item.common_event_id > 0
    # 命中判定
    hit_result = (rand(100) < item.hit)
    # 不确定的特技的情况下设置为有效标志
    effective |= item.hit < 100
    # 命中的情况
    if hit_result == true
      # 计算回复量
      recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
      recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
      if recover_hp < 0
        recover_hp += self.pdef * item.pdef_f / 20
        recover_hp += self.mdef * item.mdef_f / 20
        recover_hp = [recover_hp, 0].min
      end
      # 属性修正
      recover_hp *= elements_correct(item.element_set)
      recover_hp /= 100
      recover_sp *= elements_correct(item.element_set)
      recover_sp /= 100
      # 分散
      if item.variance > 0 and recover_hp.abs > 0
        amp = [recover_hp.abs * item.variance / 100, 1].max
        recover_hp += rand(amp+1) + rand(amp+1) - amp
      end
      if item.variance > 0 and recover_sp.abs > 0
        amp = [recover_sp.abs * item.variance / 100, 1].max
        recover_sp += rand(amp+1) + rand(amp+1) - amp
      end
      # 回复量符号为负的情况下
      if recover_hp < 0
        # 防御修正
        if self.guarding?
          recover_hp /= 2
        end
      end
      # HP 回复量符号的反转、设置伤害值
      self.damage = -recover_hp
      # HP 以及 SP 的回复
      last_hp = self.hp
      last_sp = self.sp
     new_hp = self.hp + recover_hp
      new_sp = self.sp + recover_sp   
           #self.hp += recover_hp  #piaoy       
      self.sp += recover_sp  #piaoy
      effective |= new_hp != last_hp
      effective |= new_sp != last_sp
      # 状态变化
      @state_changed = false
      effective |= states_plus(item.plus_state_set)
      effective |= states_minus(item.minus_state_set)
      # 能力上升值有效的情况下
      if item.parameter_type > 0 and item.parameter_points != 0
        # 能力值的分支
        case item.parameter_type
        when 1  # MaxHP
          @maxhp_plus += item.parameter_points
        when 2  # MaxSP
          @maxsp_plus += item.parameter_points
        when 3  # 力量
          @str_plus += item.parameter_points
        when 4  # 灵巧
          @dex_plus += item.parameter_points
        when 5  # 速度
          @agi_plus += item.parameter_points
        when 6  # 魔力
          @int_plus += item.parameter_points
        end
        # 设置有效标志
        effective = true
      end
      # HP 回复率与回复量为 0 的情况下
      if item.recover_hp_rate == 0 and item.recover_hp == 0
        # 设置伤害为空的字符串
        self.damage = ""
        # SP 回复率与回复量为 0、能力上升值无效的情况下
        if item.recover_sp_rate == 0 and item.recover_sp == 0 and
           (item.parameter_type == 0 or item.parameter_points == 0)
          # 状态没有变化的情况下
          unless @state_changed
            # 伤害设置为 "Miss"
            self.damage = "Miss"
          end
        end
      end
    # Miss 的情况下
    else
      # 伤害设置为 "Miss"
      self.damage = "Miss"
    end
    # 不在战斗中的情况下
    unless $game_temp.in_battle
      # 伤害设置为 nil
      self.damage = nil
    end
    # 过程结束
    return effective
  end
end
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
#  处理战斗画面的类。
#==============================================================================

class Scene_Battle
        #--------------------------------------------------------------------------
        # ● 定义实例变量
        #--------------------------------------------------------------------------
        attr_reader   :animation1_id                    # 行动方动画ID
end

#==============================================================================
# ■ Game_Battler
#------------------------------------------------------------------------------
#  处理战斗者的类。这个类作为 Game_Actor 类与 Game_Enemy 类的
# 超级类来使用。
#==============================================================================

#class Game_Battler
#  #--------------------------------------------------------------------------
#  # ● 应用连续伤害效果
#  #--------------------------------------------------------------------------
#  alias rainbow_sword_slip_damage_effect slip_damage_effect
#  def slip_damage_effect
#    self.animation_id = RPG::SLIP_DAMAGE_ANIMATION_ID
#    self.animation_hit = true
#    rainbow_sword_slip_damage_effect
#  end
#end[/pre]  

点评

CR~
BUG好多。。。  发表于 2015-8-12 12:37
回复

使用道具 举报

咩

梦石
0
星屑
1640
在线时间
381 小时
注册时间
2010-10-9
回帖
286

开拓者

发表于 2015-8-12 18:32:25 | 显示全部楼层
@CR~
能不能发一下彩虹神剑默认的数字图片还有你用的和显示敌人/自己 HP、SP用的脚本?

点评

CR~
我把整个工程都给上传了,,,麻烦了啊,谢谢。 http://yun.baidu.com/share/link?shareid=2519252984&uk=165951  发表于 2015-8-13 00:41
回复

使用道具 举报

咩

梦石
0
星屑
1640
在线时间
381 小时
注册时间
2010-10-9
回帖
286

开拓者

发表于 2015-8-13 12:09:44 | 显示全部楼层
替换Data下的原文件试试(千万要备份)
另外:虽然还有很多不足,但我不能再做进一步修改了,希望看到此贴的坛友热心帮助楼主吧。
Scripts.rxdata (234.81 KB, 下载次数: 62)
回复

使用道具 举报

梦石
0
星屑
1328
在线时间
354 小时
注册时间
2009-9-14
回帖
211
 楼主| 发表于 2015-8-13 21:09:04 | 显示全部楼层
piaoy 发表于 2015-8-13 12:09
替换Data下的原文件试试(千万要备份)
另外:虽然还有很多不足,但我不能再做进一步修改了,希望看到此贴 ...

额额,感觉已经够强大了!
就是有两个地方,,,
1,伤害公式跟原来的不一样了。。
2,动画中的隐藏对象不会隐藏对象了。。。
回复

使用道具 举报

咩

梦石
0
星屑
1640
在线时间
381 小时
注册时间
2010-10-9
回帖
286

开拓者

发表于 2015-8-14 08:38:12 | 显示全部楼层
你说的BUG修完了。动画必须加闪光否则没有伤害,比如保镖的脚刀就没有动画,顺便说一下有些动画你忘了做对象消失。
另外在第二个脚本里面有个设置,你可以自己做一个会闪光的动画把它的ID写在上面(比如我写的是是2000),这个动画会在状态加减血的时候播放,否则不能显示伤害。
不过加MP还是不能显示数字(怨念)
https://rpg.blue/forum.php?mod=attachment&aid=Mjg2OTE1fDk5OThkN2E2fDE3OTEwNDcxNjZ8MHw%3D

点评

CR~
额。。。大神,,能顺便儿帮我看一下为什么喝药不回血了么。。。谢谢,,,  发表于 2015-8-14 23:57
CR~
又没有动态扣血了,,,  发表于 2015-8-14 18:44
回复

使用道具 举报

梦石
0
星屑
1328
在线时间
354 小时
注册时间
2009-9-14
回帖
211
 楼主| 发表于 2015-8-16 10:48:36 | 显示全部楼层
piaoy 发表于 2015-8-14 08:38
你说的BUG修完了。动画必须加闪光否则没有伤害,比如保镖的脚刀就没有动画,顺便说一下有些动画你忘了做对 ...

QQ截图20150816104514.png

不知道这么设置的话会回60滴血。。。

点评

CR~
十分感谢!  发表于 2015-8-16 11:19
请把Interpreter 7的129行内容前加一个# 就像这样:#battler.hp -= value  发表于 2015-8-16 11:15
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部