查看: 1848|回复: 2

[已经解决] 本人新人脚本盲,求问怎么将灵魂升天的效果和彩虹神剑.....

[复制链接]
梦石
0
星屑
104
在线时间
165 小时
注册时间
2014-2-1
回帖
10
发表于 2015-3-2 13:22:34 | 显示全部楼层 |阅读模式

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

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

×
T{NZ5]PLGVVMVYUM7QFV.jpg
本人新人脚本盲,在添加了彩虹神剑脚本后,发现原本的角色阵亡灵魂升天脚本失效了,角色阵亡后出现了如图中红圈所示的变白效果而已,因为灵魂升天的脚本没有注释,我看不懂,不知道怎么将两个脚本合并,既能有彩虹神剑的连击效果,又可以使角色阵亡后出现灵魂升天的效果,麻烦大神指点下怎么将两个脚本综合下?
下面附上两个脚本:
灵魂升天脚本:
  1. module RPG
  2.   class Sprite < ::Sprite   
  3.     def initialize(viewport = nil)
  4.       super(viewport)
  5.       @_whiten_duration = 0
  6.       @_appear_duration = 0
  7.       @_escape_duration = 0
  8.       @_collapse_duration = 0
  9.       @_damage_duration = 0
  10.       @_animation_duration = 0
  11.       @_blink = false
  12.       @coll_time = 0
  13.     end
  14.     def collapse
  15.       @coll.dispose if @coll != nil  
  16.       @coll = Sprite.new
  17.       @coll.bitmap = Bitmap.new("Graphics/Battlers/#{@battler_name}")  
  18.       @coll.ox = self.ox
  19.       @coll.oy = self.oy
  20.       @coll.opacity = 100
  21.       @coll.z = 0
  22.       @coll.blend_type = 1
  23.       @coll.x = self.x
  24.       @coll.y = self.y
  25.       @coll_time = 42
  26.       @_whiten_duration = 0
  27.       @_appear_duration = 0
  28.       @_escape_duration = 0
  29.     end
  30.     def update
  31.       super
  32.       if @_whiten_duration > 0
  33.         @_whiten_duration -= 1
  34.         self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  35.       end
  36.       if @_appear_duration > 0
  37.         @_appear_duration -= 1
  38.         self.opacity = (16 - @_appear_duration) * 16
  39.       end
  40.       if @_escape_duration > 0
  41.         @_escape_duration -= 1
  42.         self.opacity = 256 - (32 - @_escape_duration) * 10
  43.       end
  44.       if @coll_time > 0
  45.         @coll_time -= 1
  46.         @coll.y = self.y - (48 - @coll_time) * 6
  47.         self.opacity = 256 - (48 - @coll_time) * 6
  48.         if @coll_time == 0
  49.           @coll.dispose
  50.         end
  51.       end
  52.       if @_damage_duration > 0
  53.         @_damage_duration -= 1
  54.         case @_damage_duration
  55.         when 38..39
  56.           @_damage_sprite.y -= 2
  57.         when 36..37
  58.           @_damage_sprite.y -= 4
  59.         when 34..35
  60.           @_damage_sprite.y -= 2
  61.         when 28..33
  62.           @_damage_sprite.y -= 4
  63.         end
  64.         @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
  65.         if @_damage_duration == 0
  66.           dispose_damage
  67.         end
  68.       end
  69.       if @_animation != nil and (Graphics.frame_count % 2 == 0)
  70.         @_animation_duration -= 1
  71.         update_animation
  72.       end
  73.       if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  74.         update_loop_animation
  75.         @_loop_animation_index += 1
  76.         @_loop_animation_index %= @_loop_animation.frame_max
  77.       end
  78.       if @_blink
  79.         @_blink_count = (@_blink_count + 1) % 32
  80.         if @_blink_count < 16
  81.           alpha = (16 - @_blink_count) * 6
  82.         else
  83.           alpha = (@_blink_count - 16) * 6
  84.         end
  85.         self.color.set(255, 255, 255, alpha)
  86.       end
  87.       @@_animations.clear
  88.     end
  89.   end
  90. end
复制代码


彩虹神剑脚本:
  1. =begin
  2. ==============================================================================

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

  4. ==============================================================================

  5. 彩虹神剑 by 柳柳
  6. 显示总伤害修改 by 叶子

  7. ==============================================================================

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

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

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

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

  22. module RPG
  23. #--------------------------------------------------------------------------
  24. # ● 常量设定
  25. #--------------------------------------------------------------------------
  26. # 是否显示总伤害
  27. SHOW_TOTAL_DAMAGE = true
  28. # 角色受攻击时是否跳一下
  29. BATTLER_JUMP = true

  30. class Sprite < ::Sprite
  31.    #==========================================
  32.    # 修改说明:
  33.    # @flash_shake用来制作挨打时候跳跃
  34.    # @_damage    用来记录每次打击之后弹出数字
  35.    # @_total_damage 记录总伤害
  36.    # @_total_damage_duration 总伤害持续帧
  37.    #==========================================
  38.    #alias 66RPG_rainbow_initialize : initialize
  39.    def initialize(viewport = nil)
  40.      #66RPG_rainbow_initialize(viewport)
  41.      super(viewport)
  42.      @_whiten_duration = 0
  43.      @_appear_duration = 0
  44.      @_escape_duration = 0
  45.      @_collapse_duration = 0
  46.      @_damage_duration = 0
  47.      @_animation_duration = 0
  48.      @_blink = false
  49.      # 挨打时候跳跃
  50.      @flash_shake = 0
  51.      # 伤害记录数组
  52.      @_damage = []
  53.      # 总伤害数字
  54.      @_total_damage = 0
  55.      # 总伤害持续帧
  56.      @_total_damage_duration = 0
  57.    end
  58.    def damage(value, critical)
  59.      if value.is_a?(Numeric)
  60.        damage_string = value.abs.to_s
  61.      else
  62.        damage_string = value.to_s
  63.      end
  64.      bitmap = Bitmap.new(160, 48)
  65.      bitmap.font.name = "Arial Black"
  66.      bitmap.font.size = 32
  67.      bitmap.font.color.set(0, 0, 0)
  68.      bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  69.      bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  70.      bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  71.      bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  72.      #=======================================
  73.      # 修改:颜色
  74.      #=======================================
  75.      if value.is_a?(Numeric) and value < 0
  76.        bitmap.font.color.set(176, 255, 144)
  77.      else
  78.        bitmap.font.color.set(255, 55, 55)
  79.      end
  80.      bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  81.      if critical
  82.        bitmap.font.size = 20
  83.        bitmap.font.color.set(0, 0, 0)
  84.        bitmap.draw_text(-1, -1, 160, 20, "暴击", 1)
  85.        bitmap.draw_text(+1, -1, 160, 20, "暴击", 1)
  86.        bitmap.draw_text(-1, +1, 160, 20, "暴击", 1)
  87.        bitmap.draw_text(+1, +1, 160, 20, "暴击", 1)
  88.        bitmap.font.color.set(255, 255, 255)
  89.        bitmap.draw_text(0, 0, 160, 20, "暴击", 1)
  90.      end
  91.      @_damage_sprite = ::Sprite.new(self.viewport)
  92.      @_damage_sprite.bitmap = bitmap
  93.      @_damage_sprite.ox = 80
  94.      @_damage_sprite.oy = 20
  95.      @_damage_sprite.x = self.x
  96.      @_damage_sprite.y = self.y - self.oy / 2
  97.      @_damage_sprite.z = 3000
  98.      @_damage_duration = 40
  99.      #=======================================
  100.      # 修改:推入新的伤害
  101.      #=======================================
  102.      @_damage.push([@_damage_sprite,@_damage_duration-10,0, rand(30) - 15, rand(3)])
  103.      # 总伤害处理
  104.      make_total_damage(value)
  105.    end
  106.    #--------------------------------------------------------------------------
  107.    # ● 总伤害处理
  108.    #--------------------------------------------------------------------------
  109.    def make_total_damage(value)
  110.      if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
  111.        @_total_damage += value
  112.      else
  113.        return
  114.      end
  115.      bitmap = Bitmap.new(300, 150)
  116.      bitmap.font.name = "Arial Black"
  117.      bitmap.font.size = 48
  118.      bitmap.font.color.set(0, 0, 0)
  119.      bitmap.draw_text(+2, 12+2, 160, 36, @_total_damage.abs.to_s, 1)
  120.      if @_total_damage < 0
  121.        bitmap.font.color.set(80, 255, 00)
  122.      else
  123.        bitmap.font.color.set(255, 140, 0)
  124.      end
  125.      bitmap.draw_text(0, 12, 160, 36, @_total_damage.abs.to_s, 1)
  126.      if @_total_damage_sprite.nil?
  127.        @_total_damage_sprite = ::Sprite.new(self.viewport)
  128.        @_total_damage_sprite.ox = 80
  129.        @_total_damage_sprite.oy = 20
  130.        @_total_damage_sprite.z = 3000
  131.      end
  132.      @_total_damage_sprite.bitmap = bitmap
  133.      @_total_damage_sprite.zoom_x = 1.5
  134.      @_total_damage_sprite.zoom_y = 1.5
  135.      @_total_damage_sprite.x = self.x
  136.      @_total_damage_sprite.y = self.y  - self.oy / 2 - 64
  137.      @_total_damage_sprite.z = 3001
  138.      @_total_damage_duration = 80
  139.    end
  140.    def animation(animation, hit, battler_damage="", battler_critical=false)
  141.      dispose_animation      
  142.      #=======================================
  143.      # 修改:记录伤害和critical
  144.      #=======================================
  145.      @battler_damage = battler_damage
  146.      @battler_critical = battler_critical
  147.      @_animation = animation
  148.      return if @_animation == nil
  149.      @_animation_hit = hit
  150.      @_animation_duration = @_animation.frame_max
  151.      animation_name = @_animation.animation_name
  152.      animation_hue = @_animation.animation_hue
  153.      bitmap = RPG::Cache.animation(animation_name, animation_hue)
  154.      #=======================================
  155.      # 修改:计算总闪光权限值
  156.      #=======================================
  157.      for timing in @_animation.timings
  158.        quanzhong = animation_process_timing(timing, @_animation_hit,true)
  159.        @all_quanzhong += quanzhong
  160.        # 记录最后一次闪光
  161.        @_last_frame = timing.frame if quanzhong != 0
  162.      end      
  163.      if @@_reference_count.include?(bitmap)
  164.        @@_reference_count[bitmap] += 1
  165.      else
  166.        @@_reference_count[bitmap] = 1
  167.      end
  168.      #=======================================
  169.      # 修改:行动方动画不显示伤害
  170.      #=======================================
  171.      if $scene.is_a?(Scene_Battle)
  172.        if $scene.animation1_id == @battler.animation_id
  173.          @battler_damage = ""
  174.        end
  175.      end
  176.      @_animation_sprites = []
  177.      if @_animation.position != 3 or not @@_animations.include?(animation)
  178.        for i in 0..15
  179.          sprite = ::Sprite.new(self.viewport)
  180.          sprite.bitmap = bitmap
  181.          sprite.visible = false
  182.          @_animation_sprites.push(sprite)
  183.        end
  184.        unless @@_animations.include?(animation)
  185.          @@_animations.push(animation)
  186.        end
  187.      end
  188.      update_animation
  189.    end
  190.    #=======================================
  191.    # 修改:更换清除伤害的算法,以防万一
  192.    #       本内容在脚本中没有使用过
  193.    #=======================================
  194.    def dispose_damage
  195.      for damage in @_damage.reverse
  196.        damage[0].bitmap.dispose
  197.        damage[0].dispose
  198.        @_damage.delete(damage)
  199.      end
  200.      @_total_damage = 0
  201.      @_last_frame = -1
  202.      if @_total_damage_sprite != nil
  203.        @_total_damage_duration = 0
  204.        @_total_damage_sprite.bitmap.dispose
  205.        @_total_damage_sprite.dispose
  206.        @_total_damage_sprite = nil
  207.      end
  208.    end
  209.    def dispose_animation
  210.      #=======================================
  211.      # 修改:清除记录的伤害,清除权重记录
  212.      #=======================================
  213.      @battler_damage = nil
  214.      @battler_critical = nil
  215.      @all_quanzhong = 1
  216.      @_total_damage = 0
  217.      @_last_frame = -1
  218.      if @_animation_sprites != nil
  219.        sprite = @_animation_sprites[0]
  220.        if sprite != nil
  221.          @@_reference_count[sprite.bitmap] -= 1
  222.          if @@_reference_count[sprite.bitmap] == 0
  223.            sprite.bitmap.dispose
  224.          end
  225.        end
  226.        for sprite in @_animation_sprites
  227.          sprite.dispose
  228.        end
  229.        @_animation_sprites = nil
  230.        @_animation = nil
  231.      end
  232.    end
  233.    def update
  234.      super
  235.      if @_whiten_duration > 0
  236.        @_whiten_duration -= 1
  237.        self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  238.      end
  239.      if @_appear_duration > 0
  240.        @_appear_duration -= 1
  241.        self.opacity = (16 - @_appear_duration) * 16
  242.      end
  243.      if @_escape_duration > 0
  244.        @_escape_duration -= 1
  245.        self.opacity = 256 - (32 - @_escape_duration) * 10
  246.      end
  247.      if @_collapse_duration > 0
  248.        @_collapse_duration -= 1
  249.        self.opacity = 256 - (48 - @_collapse_duration) * 6
  250.      end
  251.      #=======================================
  252.      # 修改:更新算法,更新弹出
  253.      #=======================================
  254.      if @_damage_duration > 0
  255.        @_damage_duration -= 1
  256.        for damage in @_damage
  257.          damage[0].x = self.x + self.viewport.rect.x -
  258.                        self.ox + self.src_rect.width / 2 +
  259.                        (40 - damage[1]) * damage[3] / 10
  260.          damage[0].y -= damage[4]+damage[1]/10
  261.          damage[0].opacity = damage[1]*20
  262.          damage[1] -= 1
  263.          if damage[1]==0
  264.            damage[0].bitmap.dispose
  265.            damage[0].dispose
  266.            @_damage.delete(damage)
  267.            next
  268.          end
  269.        end
  270.      end
  271.      #=======================================
  272.      # 添加:弹出总伤害
  273.      #=======================================
  274.      if @_total_damage_duration > 0
  275.        @_total_damage_duration -= 1
  276.        @_total_damage_sprite.y -= 1 if @_total_damage_duration % 2 == 0
  277.        if @_total_damage_sprite.zoom_x > 1.0
  278.          @_total_damage_sprite.zoom_x -= 0.05
  279.        end
  280.        if @_total_damage_sprite.zoom_y > 1.0
  281.          @_total_damage_sprite.zoom_y -= 0.05
  282.        end
  283.        @_total_damage_sprite.opacity = 256 - (24 - @_total_damage_duration) * 16
  284.        if @_total_damage_duration <= 0
  285.          @_total_damage = 0
  286.          @_total_damage_duration = 0
  287.          @_total_damage_sprite.bitmap.dispose
  288.          @_total_damage_sprite.dispose
  289.          @_total_damage_sprite = nil
  290.        end
  291.      end
  292.      #=======================================
  293.      if @_animation != nil and (Graphics.frame_count % 2 == 0)
  294.        @_animation_duration -= 1
  295.        update_animation
  296.      end
  297.      if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  298.        update_loop_animation
  299.        @_loop_animation_index += 1
  300.        @_loop_animation_index %= @_loop_animation.frame_max
  301.      end
  302.      if @_blink
  303.        @_blink_count = (@_blink_count + 1) % 32
  304.        if @_blink_count < 16
  305.          alpha = (16 - @_blink_count) * 6
  306.        else
  307.          alpha = (@_blink_count - 16) * 6
  308.        end
  309.        self.color.set(255, 255, 255, alpha)
  310.      end
  311.      @@_animations.clear
  312.    end
  313.    def update_animation
  314.      if @_animation_duration > 0
  315.        frame_index = @_animation.frame_max - @_animation_duration
  316.        cell_data = @_animation.frames[frame_index].cell_data
  317.        position = @_animation.position
  318.        animation_set_sprites(@_animation_sprites, cell_data, position)
  319.        #=======================================
  320.        # 修改:弹出伤害,权重计算
  321.        #=======================================
  322.        for timing in @_animation.timings
  323.          if timing.frame == frame_index
  324.            t = 1.0 * animation_process_timing(timing, @_animation_hit)            
  325.            #p t,"当前权重", @all_quanzhong,"总权重"
  326.            if @battler_damage.is_a?(Numeric) and t != 0
  327.              t *= @battler_damage
  328.              t /= @all_quanzhong
  329.              #p t,"当前伤害",@battler_damage,"总伤害"
  330.              t = t.to_i
  331.              # 最后一次闪光的话,伤害修正
  332.              if frame_index == @_last_frame
  333.                @_total_damage = @battler_damage - t
  334.              end
  335.              #p t,@battler_damage,@all_quanzhong
  336.              damage(t,@battler_critical)
  337.            # 防止重复播放miss
  338.            elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
  339.              damage(@battler_damage,@battler_critical)
  340.            end
  341.          end
  342.        end
  343.      else
  344.        dispose_animation
  345.      end
  346.    end
  347.    #=======================================
  348.    # 修改:敌人跳跃的功能 + 添加返回数值
  349.    #=======================================
  350.     def animation_process_timing(timing, hit,dontflash=false)
  351.       if (timing.condition == 0) or
  352.          (timing.condition == 1 and hit == true) or
  353.          (timing.condition == 2 and hit == false)
  354.         unless dontflash
  355.           if timing.se.name != ""
  356.             se = timing.se
  357.             Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
  358.           end
  359.         end
  360.         case timing.flash_scope
  361.         when 1
  362.           unless dontflash
  363.             self.flash(timing.flash_color, timing.flash_duration * 2)
  364.             if @_total_damage >0
  365.               @flash_shake_switch = true
  366.               @flash_shake = 10
  367.             end
  368.           end
  369.           return timing.flash_color.alpha * timing.flash_duration
  370.         when 2
  371.           unless dontflash
  372.             if self.viewport != nil
  373.               self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
  374.               return timing.flash_color.alpha * timing.flash_duration
  375.             end
  376.           end
  377.         when 3
  378.           unless dontflash
  379.             self.flash(nil, timing.flash_duration * 2)
  380.           end
  381.           return timing.flash_color.alpha * timing.flash_duration
  382.         end
  383.       end      
  384.       return 0
  385.     end   
  386. end
  387. end
  388. #==============================================================================
  389. # ■ Sprite_Battler
  390. #==============================================================================
  391. class Sprite_Battler < RPG::Sprite
  392. #--------------------------------------------------------------------------
  393. # ● 初始化对像
  394. #    添加跳跃记录
  395. #--------------------------------------------------------------------------
  396. def initialize(viewport, battler = nil)
  397.   super(viewport)
  398.   @battler = battler
  399.   @battler_visible = false
  400.   @flash_shake_switch = true
  401. end
  402. #--------------------------------------------------------------------------
  403. # ● 刷新画面
  404. #    增添跳跃功能
  405. #--------------------------------------------------------------------------
  406. def update
  407.   super
  408.   # 战斗者为 nil 的情况下
  409.   if @battler == nil
  410.     self.bitmap = nil
  411.     loop_animation(nil)
  412.     return
  413.   end
  414.   # 文件名和色相与当前情况有差异的情况下
  415.   if @battler.battler_name != @battler_name or
  416.      @battler.battler_hue != @battler_hue
  417.     # 获取、设置位图
  418.     @battler_name = @battler.battler_name
  419.     @battler_hue = @battler.battler_hue
  420.     self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  421.     @width = bitmap.width
  422.     @height = bitmap.height
  423.     self.ox = @width / 2
  424.     self.oy = @height
  425.     # 如果是战斗不能或者是隐藏状态就把透明度设置成 0
  426.     if @battler.dead? or @battler.hidden
  427.       self.opacity = 0
  428.     end
  429.   end
  430.   # 动画 ID 与当前的情况有差异的情况下
  431.   if @battler.damage == nil and
  432.      @battler.state_animation_id != @state_animation_id
  433.     @state_animation_id = @battler.state_animation_id
  434.     loop_animation($data_animations[@state_animation_id])
  435.   end
  436.   # 应该被显示的角色的情况下
  437.   if @battler.is_a?(Game_Actor) and @battler_visible
  438.     # 不是主状态的时候稍稍降低点透明度
  439.     if $game_temp.battle_main_phase
  440.       self.opacity += 3 if self.opacity < 255
  441.     else
  442.       self.opacity -= 3 if self.opacity > 207
  443.     end
  444.   end
  445.   # 明灭
  446.   if @battler.blink
  447.     blink_on
  448.   else
  449.     blink_off
  450.   end
  451.   # 不可见的情况下
  452.   unless @battler_visible
  453.     # 出现
  454.     if not @battler.hidden and not @battler.dead? and
  455.        (@battler.damage == nil or @battler.damage_pop)
  456.       appear
  457.       @battler_visible = true
  458.     end
  459.   end
  460.   # 可见的情况下
  461.   if @battler_visible
  462.     # 逃跑
  463.     if @battler.hidden
  464.       $game_system.se_play($data_system.escape_se)
  465.       escape
  466.       @battler_visible = false
  467.     end
  468.     # 白色闪烁
  469.     if @battler.white_flash
  470.       whiten
  471.       @battler.white_flash = false
  472.     end
  473.     # 动画
  474.     if @battler.animation_id != 0
  475.       animation = $data_animations[@battler.animation_id]
  476.       animation(animation, @battler.animation_hit,@battler.damage, @battler.critical)
  477.       @battler.animation_id = 0
  478.     end
  479.     # 伤害
  480.     if @battler.damage_pop
  481.       @battler.damage = nil
  482.       @battler.critical = false
  483.       @battler.damage_pop = false
  484.     end
  485.     # korapusu
  486.     if @battler.damage == nil and @battler.dead?
  487.       if @battler.is_a?(Game_Enemy)
  488.         $game_system.se_play($data_system.enemy_collapse_se)
  489.       else
  490.         $game_system.se_play($data_system.actor_collapse_se)
  491.       end
  492.       collapse
  493.       @battler_visible = false
  494.     end
  495.   end
  496.   # 设置活动块的坐标
  497.   if @flash_shake_switch == true
  498.     self.x = @battler.screen_x
  499.     self.y = @battler.screen_y
  500.     self.z = @battler.screen_z
  501.     @flash_shake_switch = false
  502.   end
  503.   if @flash_shake != 0 and @battler.damage != nil and RPG::BATTLER_JUMP
  504.     case @flash_shake
  505.     when 9..10
  506.       self.x = @battler.screen_x
  507.       self.y -=4
  508.       self.z = @battler.screen_z
  509.     when 6..8
  510.       self.x = @battler.screen_x
  511.       self.y -=2
  512.       self.z = @battler.screen_z
  513.     when 3..5
  514.       self.x = @battler.screen_x
  515.       self.y +=2
  516.       self.z = @battler.screen_z
  517.     when 2
  518.       self.x = @battler.screen_x
  519.       self.y += 4
  520.       self.z = @battler.screen_z
  521.     when 1
  522.       self.x = @battler.screen_x
  523.       self.y = @battler.screen_y
  524.       self.z = @battler.screen_z
  525.     end
  526.     @flash_shake -= 1
  527.   end
  528. end
  529. end

  530. #==============================================================================
  531. # ■ Scene_Battle
  532. #------------------------------------------------------------------------------
  533. #  处理战斗画面的类。
  534. #==============================================================================

  535. class Scene_Battle
  536. #--------------------------------------------------------------------------
  537. # ● 定义实例变量
  538. #--------------------------------------------------------------------------
  539. attr_reader   :animation1_id                    # 行动方动画ID
  540. end

复制代码


麻烦诸位了!先感激下!  
梦石
0
星屑
34511
在线时间
5096 小时
注册时间
2012-11-19
回帖
4715

开拓者

发表于 2015-3-2 13:49:11 | 显示全部楼层
大概的整合了一下,没测试
  1. =begin
  2. ==============================================================================

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

  4. ==============================================================================

  5. 彩虹神剑 by 柳柳
  6. 显示总伤害修改 by 叶子

  7. ==============================================================================

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

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

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

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

  22. module RPG
  23. #--------------------------------------------------------------------------
  24. # ● 常量设定
  25. #--------------------------------------------------------------------------
  26. # 是否显示总伤害
  27. SHOW_TOTAL_DAMAGE = true
  28. # 角色受攻击时是否跳一下
  29. BATTLER_JUMP = true

  30. class Sprite < ::Sprite
  31.    #==========================================
  32.    # 修改说明:
  33.    # @flash_shake用来制作挨打时候跳跃
  34.    # @_damage    用来记录每次打击之后弹出数字
  35.    # @_total_damage 记录总伤害
  36.    # @_total_damage_duration 总伤害持续帧
  37.    #==========================================
  38.    #alias 66RPG_rainbow_initialize : initialize
  39.    def initialize(viewport = nil)
  40.      #66RPG_rainbow_initialize(viewport)
  41.      super(viewport)
  42.      @_whiten_duration = 0
  43.      @_appear_duration = 0
  44.      @_escape_duration = 0
  45.      @_collapse_duration = 0
  46.      @_damage_duration = 0
  47.      @_animation_duration = 0
  48.      @_blink = false
  49.      # 挨打时候跳跃
  50.      @flash_shake = 0
  51.      # 伤害记录数组
  52.      @_damage = []
  53.      # 总伤害数字
  54.      @_total_damage = 0
  55.      # 总伤害持续帧
  56.      @_total_damage_duration = 0
  57.      @coll_time = 0
  58.    end
  59.    def collapse
  60.       @coll.dispose if @coll != nil  
  61.       @coll = Sprite.new
  62.       @coll.bitmap = Bitmap.new("Graphics/Battlers/#{@battler_name}")  
  63.       @coll.ox = self.ox
  64.       @coll.oy = self.oy
  65.       @coll.opacity = 100
  66.       @coll.z = 0
  67.       @coll.blend_type = 1
  68.       @coll.x = self.x
  69.       @coll.y = self.y
  70.       @coll_time = 42
  71.       @_whiten_duration = 0
  72.       @_appear_duration = 0
  73.       @_escape_duration = 0
  74.    end
  75.    def damage(value, critical)
  76.      if value.is_a?(Numeric)
  77.        damage_string = value.abs.to_s
  78.      else
  79.        damage_string = value.to_s
  80.      end
  81.      bitmap = Bitmap.new(160, 48)
  82.      bitmap.font.name = "Arial Black"
  83.      bitmap.font.size = 32
  84.      bitmap.font.color.set(0, 0, 0)
  85.      bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  86.      bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  87.      bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  88.      bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  89.      #=======================================
  90.      # 修改:颜色
  91.      #=======================================
  92.      if value.is_a?(Numeric) and value < 0
  93.        bitmap.font.color.set(176, 255, 144)
  94.      else
  95.        bitmap.font.color.set(255, 55, 55)
  96.      end
  97.      bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  98.      if critical
  99.        bitmap.font.size = 20
  100.        bitmap.font.color.set(0, 0, 0)
  101.        bitmap.draw_text(-1, -1, 160, 20, "暴击", 1)
  102.        bitmap.draw_text(+1, -1, 160, 20, "暴击", 1)
  103.        bitmap.draw_text(-1, +1, 160, 20, "暴击", 1)
  104.        bitmap.draw_text(+1, +1, 160, 20, "暴击", 1)
  105.        bitmap.font.color.set(255, 255, 255)
  106.        bitmap.draw_text(0, 0, 160, 20, "暴击", 1)
  107.      end
  108.      @_damage_sprite = ::Sprite.new(self.viewport)
  109.      @_damage_sprite.bitmap = bitmap
  110.      @_damage_sprite.ox = 80
  111.      @_damage_sprite.oy = 20
  112.      @_damage_sprite.x = self.x
  113.      @_damage_sprite.y = self.y - self.oy / 2
  114.      @_damage_sprite.z = 3000
  115.      @_damage_duration = 40
  116.      #=======================================
  117.      # 修改:推入新的伤害
  118.      #=======================================
  119.      @_damage.push([@_damage_sprite,@_damage_duration-10,0, rand(30) - 15, rand(3)])
  120.      # 总伤害处理
  121.      make_total_damage(value)
  122.    end
  123.    #--------------------------------------------------------------------------
  124.    # ● 总伤害处理
  125.    #--------------------------------------------------------------------------
  126.    def make_total_damage(value)
  127.      if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
  128.        @_total_damage += value
  129.      else
  130.        return
  131.      end
  132.      bitmap = Bitmap.new(300, 150)
  133.      bitmap.font.name = "Arial Black"
  134.      bitmap.font.size = 48
  135.      bitmap.font.color.set(0, 0, 0)
  136.      bitmap.draw_text(+2, 12+2, 160, 36, @_total_damage.abs.to_s, 1)
  137.      if @_total_damage < 0
  138.        bitmap.font.color.set(80, 255, 00)
  139.      else
  140.        bitmap.font.color.set(255, 140, 0)
  141.      end
  142.      bitmap.draw_text(0, 12, 160, 36, @_total_damage.abs.to_s, 1)
  143.      if @_total_damage_sprite.nil?
  144.        @_total_damage_sprite = ::Sprite.new(self.viewport)
  145.        @_total_damage_sprite.ox = 80
  146.        @_total_damage_sprite.oy = 20
  147.        @_total_damage_sprite.z = 3000
  148.      end
  149.      @_total_damage_sprite.bitmap = bitmap
  150.      @_total_damage_sprite.zoom_x = 1.5
  151.      @_total_damage_sprite.zoom_y = 1.5
  152.      @_total_damage_sprite.x = self.x
  153.      @_total_damage_sprite.y = self.y  - self.oy / 2 - 64
  154.      @_total_damage_sprite.z = 3001
  155.      @_total_damage_duration = 80
  156.    end
  157.    def animation(animation, hit, battler_damage="", battler_critical=false)
  158.      dispose_animation      
  159.      #=======================================
  160.      # 修改:记录伤害和critical
  161.      #=======================================
  162.      @battler_damage = battler_damage
  163.      @battler_critical = battler_critical
  164.      @_animation = animation
  165.      return if @_animation == nil
  166.      @_animation_hit = hit
  167.      @_animation_duration = @_animation.frame_max
  168.      animation_name = @_animation.animation_name
  169.      animation_hue = @_animation.animation_hue
  170.      bitmap = RPG::Cache.animation(animation_name, animation_hue)
  171.      #=======================================
  172.      # 修改:计算总闪光权限值
  173.      #=======================================
  174.      for timing in @_animation.timings
  175.        quanzhong = animation_process_timing(timing, @_animation_hit,true)
  176.        @all_quanzhong += quanzhong
  177.        # 记录最后一次闪光
  178.        @_last_frame = timing.frame if quanzhong != 0
  179.      end      
  180.      if @@_reference_count.include?(bitmap)
  181.        @@_reference_count[bitmap] += 1
  182.      else
  183.        @@_reference_count[bitmap] = 1
  184.      end
  185.      #=======================================
  186.      # 修改:行动方动画不显示伤害
  187.      #=======================================
  188.      if $scene.is_a?(Scene_Battle)
  189.        if $scene.animation1_id == @battler.animation_id
  190.          @battler_damage = ""
  191.        end
  192.      end
  193.      @_animation_sprites = []
  194.      if @_animation.position != 3 or not @@_animations.include?(animation)
  195.        for i in 0..15
  196.          sprite = ::Sprite.new(self.viewport)
  197.          sprite.bitmap = bitmap
  198.          sprite.visible = false
  199.          @_animation_sprites.push(sprite)
  200.        end
  201.        unless @@_animations.include?(animation)
  202.          @@_animations.push(animation)
  203.        end
  204.      end
  205.      update_animation
  206.    end
  207.    #=======================================
  208.    # 修改:更换清除伤害的算法,以防万一
  209.    #       本内容在脚本中没有使用过
  210.    #=======================================
  211.    def dispose_damage
  212.      for damage in @_damage.reverse
  213.        damage[0].bitmap.dispose
  214.        damage[0].dispose
  215.        @_damage.delete(damage)
  216.      end
  217.      @_total_damage = 0
  218.      @_last_frame = -1
  219.      if @_total_damage_sprite != nil
  220.        @_total_damage_duration = 0
  221.        @_total_damage_sprite.bitmap.dispose
  222.        @_total_damage_sprite.dispose
  223.        @_total_damage_sprite = nil
  224.      end
  225.    end
  226.    def dispose_animation
  227.      #=======================================
  228.      # 修改:清除记录的伤害,清除权重记录
  229.      #=======================================
  230.      @battler_damage = nil
  231.      @battler_critical = nil
  232.      @all_quanzhong = 1
  233.      @_total_damage = 0
  234.      @_last_frame = -1
  235.      if @_animation_sprites != nil
  236.        sprite = @_animation_sprites[0]
  237.        if sprite != nil
  238.          @@_reference_count[sprite.bitmap] -= 1
  239.          if @@_reference_count[sprite.bitmap] == 0
  240.            sprite.bitmap.dispose
  241.          end
  242.        end
  243.        for sprite in @_animation_sprites
  244.          sprite.dispose
  245.        end
  246.        @_animation_sprites = nil
  247.        @_animation = nil
  248.      end
  249.    end
  250.    def update
  251.      super
  252.      if @_whiten_duration > 0
  253.        @_whiten_duration -= 1
  254.        self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  255.      end
  256.      if @_appear_duration > 0
  257.        @_appear_duration -= 1
  258.        self.opacity = (16 - @_appear_duration) * 16
  259.      end
  260.      if @_escape_duration > 0
  261.        @_escape_duration -= 1
  262.        self.opacity = 256 - (32 - @_escape_duration) * 10
  263.      end
  264.      if @_collapse_duration > 0
  265.        @_collapse_duration -= 1
  266.        self.opacity = 256 - (48 - @_collapse_duration) * 6
  267.      end
  268.      if @coll_time > 0
  269.         @coll_time -= 1
  270.         @coll.y = self.y - (48 - @coll_time) * 6
  271.         self.opacity = 256 - (48 - @coll_time) * 6
  272.         if @coll_time == 0
  273.           @coll.dispose
  274.         end
  275.       end
  276.      #=======================================
  277.      # 修改:更新算法,更新弹出
  278.      #=======================================
  279.      if @_damage_duration > 0
  280.        @_damage_duration -= 1
  281.        for damage in @_damage
  282.          damage[0].x = self.x + self.viewport.rect.x -
  283.                        self.ox + self.src_rect.width / 2 +
  284.                        (40 - damage[1]) * damage[3] / 10
  285.          damage[0].y -= damage[4]+damage[1]/10
  286.          damage[0].opacity = damage[1]*20
  287.          damage[1] -= 1
  288.          if damage[1]==0
  289.            damage[0].bitmap.dispose
  290.            damage[0].dispose
  291.            @_damage.delete(damage)
  292.            next
  293.          end
  294.        end
  295.      end
  296.      #=======================================
  297.      # 添加:弹出总伤害
  298.      #=======================================
  299.      if @_total_damage_duration > 0
  300.        @_total_damage_duration -= 1
  301.        @_total_damage_sprite.y -= 1 if @_total_damage_duration % 2 == 0
  302.        if @_total_damage_sprite.zoom_x > 1.0
  303.          @_total_damage_sprite.zoom_x -= 0.05
  304.        end
  305.        if @_total_damage_sprite.zoom_y > 1.0
  306.          @_total_damage_sprite.zoom_y -= 0.05
  307.        end
  308.        @_total_damage_sprite.opacity = 256 - (24 - @_total_damage_duration) * 16
  309.        if @_total_damage_duration <= 0
  310.          @_total_damage = 0
  311.          @_total_damage_duration = 0
  312.          @_total_damage_sprite.bitmap.dispose
  313.          @_total_damage_sprite.dispose
  314.          @_total_damage_sprite = nil
  315.        end
  316.      end
  317.      #=======================================
  318.      if @_animation != nil and (Graphics.frame_count % 2 == 0)
  319.        @_animation_duration -= 1
  320.        update_animation
  321.      end
  322.      if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  323.        update_loop_animation
  324.        @_loop_animation_index += 1
  325.        @_loop_animation_index %= @_loop_animation.frame_max
  326.      end
  327.      if @_blink
  328.        @_blink_count = (@_blink_count + 1) % 32
  329.        if @_blink_count < 16
  330.          alpha = (16 - @_blink_count) * 6
  331.        else
  332.          alpha = (@_blink_count - 16) * 6
  333.        end
  334.        self.color.set(255, 255, 255, alpha)
  335.      end
  336.      @@_animations.clear
  337.    end
  338.    def update_animation
  339.      if @_animation_duration > 0
  340.        frame_index = @_animation.frame_max - @_animation_duration
  341.        cell_data = @_animation.frames[frame_index].cell_data
  342.        position = @_animation.position
  343.        animation_set_sprites(@_animation_sprites, cell_data, position)
  344.        #=======================================
  345.        # 修改:弹出伤害,权重计算
  346.        #=======================================
  347.        for timing in @_animation.timings
  348.          if timing.frame == frame_index
  349.            t = 1.0 * animation_process_timing(timing, @_animation_hit)            
  350.            #p t,"当前权重", @all_quanzhong,"总权重"
  351.            if @battler_damage.is_a?(Numeric) and t != 0
  352.              t *= @battler_damage
  353.              t /= @all_quanzhong
  354.              #p t,"当前伤害",@battler_damage,"总伤害"
  355.              t = t.to_i
  356.              # 最后一次闪光的话,伤害修正
  357.              if frame_index == @_last_frame
  358.                @_total_damage = @battler_damage - t
  359.              end
  360.              #p t,@battler_damage,@all_quanzhong
  361.              damage(t,@battler_critical)
  362.            # 防止重复播放miss
  363.            elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
  364.              damage(@battler_damage,@battler_critical)
  365.            end
  366.          end
  367.        end
  368.      else
  369.        dispose_animation
  370.      end
  371.    end
  372.    #=======================================
  373.    # 修改:敌人跳跃的功能 + 添加返回数值
  374.    #=======================================
  375.     def animation_process_timing(timing, hit,dontflash=false)
  376.       if (timing.condition == 0) or
  377.          (timing.condition == 1 and hit == true) or
  378.          (timing.condition == 2 and hit == false)
  379.         unless dontflash
  380.           if timing.se.name != ""
  381.             se = timing.se
  382.             Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
  383.           end
  384.         end
  385.         case timing.flash_scope
  386.         when 1
  387.           unless dontflash
  388.             self.flash(timing.flash_color, timing.flash_duration * 2)
  389.             if @_total_damage >0
  390.               @flash_shake_switch = true
  391.               @flash_shake = 10
  392.             end
  393.           end
  394.           return timing.flash_color.alpha * timing.flash_duration
  395.         when 2
  396.           unless dontflash
  397.             if self.viewport != nil
  398.               self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
  399.               return timing.flash_color.alpha * timing.flash_duration
  400.             end
  401.           end
  402.         when 3
  403.           unless dontflash
  404.             self.flash(nil, timing.flash_duration * 2)
  405.           end
  406.           return timing.flash_color.alpha * timing.flash_duration
  407.         end
  408.       end      
  409.       return 0
  410.     end   
  411. end
  412. end
  413. #==============================================================================
  414. # ■ Sprite_Battler
  415. #==============================================================================
  416. class Sprite_Battler < RPG::Sprite
  417. #--------------------------------------------------------------------------
  418. # ● 初始化对像
  419. #    添加跳跃记录
  420. #--------------------------------------------------------------------------
  421. def initialize(viewport, battler = nil)
  422.   super(viewport)
  423.   @battler = battler
  424.   @battler_visible = false
  425.   @flash_shake_switch = true
  426. end
  427. #--------------------------------------------------------------------------
  428. # ● 刷新画面
  429. #    增添跳跃功能
  430. #--------------------------------------------------------------------------
  431. def update
  432.   super
  433.   # 战斗者为 nil 的情况下
  434.   if @battler == nil
  435.     self.bitmap = nil
  436.     loop_animation(nil)
  437.     return
  438.   end
  439.   # 文件名和色相与当前情况有差异的情况下
  440.   if @battler.battler_name != @battler_name or
  441.      @battler.battler_hue != @battler_hue
  442.     # 获取、设置位图
  443.     @battler_name = @battler.battler_name
  444.     @battler_hue = @battler.battler_hue
  445.     self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  446.     @width = bitmap.width
  447.     @height = bitmap.height
  448.     self.ox = @width / 2
  449.     self.oy = @height
  450.     # 如果是战斗不能或者是隐藏状态就把透明度设置成 0
  451.     if @battler.dead? or @battler.hidden
  452.       self.opacity = 0
  453.     end
  454.   end
  455.   # 动画 ID 与当前的情况有差异的情况下
  456.   if @battler.damage == nil and
  457.      @battler.state_animation_id != @state_animation_id
  458.     @state_animation_id = @battler.state_animation_id
  459.     loop_animation($data_animations[@state_animation_id])
  460.   end
  461.   # 应该被显示的角色的情况下
  462.   if @battler.is_a?(Game_Actor) and @battler_visible
  463.     # 不是主状态的时候稍稍降低点透明度
  464.     if $game_temp.battle_main_phase
  465.       self.opacity += 3 if self.opacity < 255
  466.     else
  467.       self.opacity -= 3 if self.opacity > 207
  468.     end
  469.   end
  470.   # 明灭
  471.   if @battler.blink
  472.     blink_on
  473.   else
  474.     blink_off
  475.   end
  476.   # 不可见的情况下
  477.   unless @battler_visible
  478.     # 出现
  479.     if not @battler.hidden and not @battler.dead? and
  480.        (@battler.damage == nil or @battler.damage_pop)
  481.       appear
  482.       @battler_visible = true
  483.     end
  484.   end
  485.   # 可见的情况下
  486.   if @battler_visible
  487.     # 逃跑
  488.     if @battler.hidden
  489.       $game_system.se_play($data_system.escape_se)
  490.       escape
  491.       @battler_visible = false
  492.     end
  493.     # 白色闪烁
  494.     if @battler.white_flash
  495.       whiten
  496.       @battler.white_flash = false
  497.     end
  498.     # 动画
  499.     if @battler.animation_id != 0
  500.       animation = $data_animations[@battler.animation_id]
  501.       animation(animation, @battler.animation_hit,@battler.damage, @battler.critical)
  502.       @battler.animation_id = 0
  503.     end
  504.     # 伤害
  505.     if @battler.damage_pop
  506.       @battler.damage = nil
  507.       @battler.critical = false
  508.       @battler.damage_pop = false
  509.     end
  510.     # korapusu
  511.     if @battler.damage == nil and @battler.dead?
  512.       if @battler.is_a?(Game_Enemy)
  513.         $game_system.se_play($data_system.enemy_collapse_se)
  514.       else
  515.         $game_system.se_play($data_system.actor_collapse_se)
  516.       end
  517.       collapse
  518.       @battler_visible = false
  519.     end
  520.   end
  521.   # 设置活动块的坐标
  522.   if @flash_shake_switch == true
  523.     self.x = @battler.screen_x
  524.     self.y = @battler.screen_y
  525.     self.z = @battler.screen_z
  526.     @flash_shake_switch = false
  527.   end
  528.   if @flash_shake != 0 and @battler.damage != nil and RPG::BATTLER_JUMP
  529.     case @flash_shake
  530.     when 9..10
  531.       self.x = @battler.screen_x
  532.       self.y -=4
  533.       self.z = @battler.screen_z
  534.     when 6..8
  535.       self.x = @battler.screen_x
  536.       self.y -=2
  537.       self.z = @battler.screen_z
  538.     when 3..5
  539.       self.x = @battler.screen_x
  540.       self.y +=2
  541.       self.z = @battler.screen_z
  542.     when 2
  543.       self.x = @battler.screen_x
  544.       self.y += 4
  545.       self.z = @battler.screen_z
  546.     when 1
  547.       self.x = @battler.screen_x
  548.       self.y = @battler.screen_y
  549.       self.z = @battler.screen_z
  550.     end
  551.     @flash_shake -= 1
  552.   end
  553. end
  554. end

  555. #==============================================================================
  556. # ■ Scene_Battle
  557. #------------------------------------------------------------------------------
  558. #  处理战斗画面的类。
  559. #==============================================================================

  560. class Scene_Battle
  561. #--------------------------------------------------------------------------
  562. # ● 定义实例变量
  563. #--------------------------------------------------------------------------
  564. attr_reader   :animation1_id                    # 行动方动画ID
  565. end
复制代码

评分

参与人数 1梦石 +1 收起 理由
RyanBern + 1 认可答案

查看全部评分

xp vx va mv  va mz 各类型脚本/插件定制
回复

使用道具 举报

梦石
0
星屑
104
在线时间
165 小时
注册时间
2014-2-1
回帖
10
 楼主| 发表于 2015-3-2 16:50:33 | 显示全部楼层
芯☆淡茹水 发表于 2015-3-2 13:49
大概的整合了一下,没测试

可以啦!感谢大神!{:2_275:}
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部