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

Project1

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

[已经过期] ★★★★彩虹神剑脚本与多动画脚本如何整合●ARPG●

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
274 小时
注册时间
2008-2-18
帖子
219
跳转到指定楼层
1
发表于 2013-8-30 00:58:27 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
1.彩虹神剑脚本削减版(用于地图伤害可以同时显示多个伤害)
2.在同一事件身上播放多个动画脚本

希望大触能帮忙整合一下 第2个脚本还有一个小小的BUG 就是Z值大于画面和图片(比如色调为-255-255-255并且显示一个纯黑的画面 这个动画照样播放不受影响)

脚本如下 1:
RUBY 代码复制
  1. =begin
  2. ==============================================================================
  3.  
  4. 彩虹神剑(伤害分段显示)显示总伤害版 v1.0d
  5.  
  6. ==============================================================================
  7.  
  8. 彩虹神剑 -柳柳
  9.  
  10. 6-20-2006 v1.0 -叶子
  11. 在彩虹神剑的基础上增加了显示总伤害的功能,而且总伤害的数字是弹出伤害时逐渐增加的
  12.  
  13. v1.0a -叶子
  14. 修正了显示伤害和实际伤害有差别的问题
  15. 修正了miss的情况下显示miss混乱的问题
  16. 修正了对己方技能重复显示伤害的问题
  17. 未修正播放目标动画第一帧时目标有时无端跳动的BUG
  18.  
  19. v1.0b -叶子
  20. 修改了总伤害数字的位置和z坐标
  21. 未修正播放目标动画第一帧时目标有时无端跳动的BUG
  22.  
  23. v1.0c -柳柳
  24. ? ? ?
  25.  
  26. v1.0d -柳柳
  27. 1.0d最终解决了那个闪光问题,还有最末帧伤害多次的算法
  28.  
  29. 7-24-2006 v1.0e -叶子
  30. 修正全屏幕闪烁弹出伤害错误的问题
  31. 修正连续伤害不会弹出伤害的问题
  32. 仍然未修正播放目标动画第一帧时目标有时无端跳动的BUG
  33.  
  34. 我鼓起很大勇气才敢动偶像们的脚本的,不知道会不会出问题啊......  -cftx
  35. 修正了总伤害显示
  36. 增加了伤害美化和HIT数显示
  37. 修正了两次音效
  38.  
  39. ==============================================================================
  40. =end
  41. # 核心的说明:
  42. # damage_pop 不再附带damage()的功能,这个放到animation里面去了
  43.  
  44. module RPG
  45. #--------------------------------------------------------------------------
  46. # ● 常量设定
  47. #--------------------------------------------------------------------------
  48. # 是否显示总伤害
  49. SHOW_TOTAL_DAMAGE = true
  50. # 角色受攻击时是否跳一下
  51. BATTLER_JUMP = false
  52. # 连续伤害的动画ID
  53. SLIP_DAMAGE_ANIMATION_ID = 10
  54.  
  55. class Sprite < ::Sprite
  56.    #==========================================
  57.    # 修改说明:
  58.    # @flash_shake用来制作挨打时候跳跃
  59.    # @_damage    用来记录每次打击之后弹出数字
  60.    # @_total_damage 记录总伤害
  61.    # @_total_damage_duration 总伤害持续帧
  62.    #==========================================
  63.    #alias 66RPG_rainbow_initialize : initialize
  64.  
  65.    def initialize(viewport = nil)
  66.      #66RPG_rainbow_initialize(viewport)
  67.      super(viewport)
  68.      @_whiten_duration = 0
  69.      @_appear_duration = 0
  70.      @_escape_duration = 0
  71.      @_collapse_duration = 0
  72.      @_damage_duration = 0
  73.      @_animation_duration = 0
  74.      @_blink = false
  75.      # 挨打时候跳跃
  76.      @flash_shake = 0
  77.      # 伤害记录数组
  78.      @_damage = []
  79.      # 总伤害数字
  80.      @_total_damage = 0
  81.      # 总伤害持续帧
  82.      @_total_damage_duration = 0
  83.      #记录已经发生的伤害的变量★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  84.      @p_dam=0
  85.      @hits=0
  86.    end
  87. #美化的伤害处理★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  88. def damage(value, critical)
  89.       # 释放伤害,效果是伤害数字快速消失,觉得不如不消失好看......
  90.       #dispose_damage
  91.       #清除hit数
  92.       dispose_hit
  93.       # 如果伤害值是数值
  94.       if value.is_a?(Numeric)
  95.         # 绝对值转为字符串
  96.         damage_string = value.abs.to_s
  97.       else
  98.         # 转为字符串
  99.         damage_string = value.to_s
  100.       end
  101.       # 初始化位图
  102.       bitmap = Bitmap.new(162, 64)
  103.       bitmap.font.name = ["黑体","华文行楷", "宋体"]
  104.       bitmap.font.size = 32
  105.       # 伤害值是数值的情况下
  106.       if value.is_a?(Numeric)
  107.         # 分割伤害值字符串
  108.         damage_array = damage_string.scan(/./)
  109.         damage_x = 81 - damage_string.size * 9
  110.         # 伤害值为负的情况下
  111.         if value < 0
  112.           # 调用回复数字表
  113.           rect_y = 32
  114.         else
  115.           # 调用伤害数字表
  116.           rect_y = 0
  117.         end
  118.         # 循环伤害值字符串
  119.         for char in damage_array
  120.           number = char.to_i
  121.           # 显示伤害数字
  122.           bitmap.blt(damage_x, 32, RPG::Cache.picture("Damage"),
  123.           Rect.new(number * 18, rect_y, 18, 32))
  124.           # 后移一位
  125.           damage_x += 18
  126.         end
  127.       # 伤害值不是数值的情况
  128.       else
  129.         if $game_variables[6] <= $game_variables[5]
  130.           # 系统默认描画字符串
  131.           bitmap.font.color.set(0, 0, 0)
  132.           bitmap.draw_text(-1, 27, 162, 36, damage_string, 1)
  133.           bitmap.draw_text(+1, 27, 162, 36, damage_string, 1)
  134.           bitmap.draw_text(-1, 29, 162, 36, damage_string, 1)
  135.           bitmap.draw_text(+1, 29, 162, 36, damage_string, 1)
  136.           bitmap.font.color.set(255, 255, 255)
  137.           bitmap.draw_text(0, 28, 162, 36, damage_string, 1)
  138.         # Miss 的情况下
  139.         else
  140.           # 显示未击中图画
  141.           bitmap.blt(36, 28, RPG::Cache.picture("Damage"), Rect.new(90, 64, 90, 32))
  142.         end
  143.       end
  144.       # 会心一击标志打开的情况
  145.       if critical
  146.         # 显示会心一击图画
  147.         bitmap.blt(36, 0, RPG::Cache.picture("Damage"), Rect.new(0, 64, 90, 32))
  148.       end
  149.       # 伤害值定位
  150.       @_damage_sprite = ::Sprite.new(self.viewport)
  151.       @_damage_sprite.bitmap = bitmap
  152.       @_damage_sprite.ox = 81
  153.       @_damage_sprite.oy = 20
  154.       @_damage_sprite.x = self.x
  155.       @_damage_sprite.y = self.y - self.oy / 2
  156.       @_damage_sprite.z = 3000
  157.       @_damage_duration = 40
  158.       @_damage.push([@_damage_sprite,@_damage_duration-10,0, rand(30) - 15, rand(3)])
  159.       make_total_damage(value)  
  160.  
  161.     end
  162.  
  163. #   ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  164. # hit数的美化描绘
  165.     def hit
  166.  
  167.       # 如果伤害值是数值
  168.       # 转为字符串
  169.       value=@hits
  170.         hits_string = value.to_s
  171.       # 初始化位图
  172.        bitmap = Bitmap.new(320, 64)
  173.        bitmap.font.name = "Arial Black"
  174.        bitmap.font.size = 32
  175.        # 分割伤害值字符串
  176.         hits_array = hits_string.scan(/./)
  177.         hits_x = 81 - hits_string.size * 18.1
  178.           rect_y = 0
  179.         # 循环伤害值字符串
  180.         for char in hits_array
  181.           number = char.to_i
  182.           # 显示伤害数字
  183.           bitmap.blt(hits_x, 0, RPG::Cache.picture("Number"),
  184.           Rect.new(number * 36.2, rect_y, 36.2, 50))
  185.           # 后移一位
  186.           hits_x += 36.2
  187.         end
  188.         bitmap.blt(hits_x, 0, RPG::Cache.picture("HITS"),
  189.         Rect.new(0, -21, 90, 50))
  190.  
  191.       # 伤害值定位
  192.       @_hits_sprite = ::Sprite.new(self.viewport)
  193.       @_hits_sprite.bitmap = bitmap
  194.       @_hits_sprite.ox = 81
  195.       @_hits_sprite.oy = 20
  196.       @_hits_sprite.x = 300
  197.       @_hits_sprite.y = 20
  198.       @_hits_sprite.z = 3000
  199.       @_hits_duration = 40
  200.     end
  201. #--------------------------------------------------------------------------
  202.    # ● 总伤害处理
  203.    #--------------------------------------------------------------------------
  204.    def make_total_damage(value)
  205.      if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
  206.        @_total_damage += value
  207.         # 绝对值转为字符串
  208.         damage_string = @_total_damage.abs.to_s
  209.       else
  210.         return
  211.       end
  212.       # 初始化位图
  213.       bitmap = Bitmap.new(300, 150)
  214.       bitmap.font.name = "Arial Black"
  215.       bitmap.font.size = 32
  216.       # 伤害值是数值的情况下
  217.       if value.is_a?(Numeric)
  218.         # 分割伤害值字符串
  219.         damage_array = damage_string.scan(/./)
  220.         damage_x = 40 - damage_string.size * 9
  221.         # 伤害值为负的情况下
  222.           if value < 0
  223.             name="Number3"
  224.  
  225.         else
  226.           # 调用伤害数字表
  227.             name="Number2"
  228.  
  229.         end
  230.  
  231.  
  232.         # 循环伤害值字符串
  233.         for char in damage_array
  234.           number = char.to_i
  235.           # 显示伤害数字
  236.           bitmap.blt(damage_x, 0, RPG::Cache.picture(name),
  237.           Rect.new(number * 36.2, 0, 36.2, 50))
  238.           # 后移一位
  239.           damage_x += 36.2
  240.         end
  241.       end
  242.  
  243.  
  244.  
  245.  
  246. #     if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
  247. #       @_total_damage += value
  248. #     else
  249. #       return
  250. #     end
  251. #     bitmap = Bitmap.new(300, 150)
  252. #     bitmap.font.name = "Arial Black"
  253. #     bitmap.font.size = 40
  254. #     bitmap.font.color.set(0, 0, 0)
  255. #     bitmap.draw_text(+2, 12+2, 160, 40, @_total_damage.abs.to_s, 1)
  256. #     if @_total_damage < 0
  257. #       bitmap.font.color.set(80, 255, 00)
  258. #    else
  259. #       bitmap.font.color.set(255, 140, 0)
  260. #     end
  261. #     bitmap.draw_text(0, 12, 160, 40, @_total_damage.abs.to_s, 1)
  262. #     bitmap.font.color.set(55, 55,255)
  263.  
  264.  
  265.      if @_total_damage_sprite.nil?
  266.        @_total_damage_sprite = ::Sprite.new(self.viewport)
  267.        @_total_damage_sprite.ox = 80
  268.        @_total_damage_sprite.oy = 20
  269.        @_total_damage_sprite.z = 3000
  270.  
  271.      end
  272.      @_total_damage_sprite.bitmap = bitmap
  273.      @_total_damage_sprite.zoom_x = 0.8
  274.      @_total_damage_sprite.zoom_y = 0.8
  275.      @_total_damage_sprite.x = self.x
  276.      @_total_damage_sprite.y = self.y  - self.oy / 2 - 64
  277.      @_total_damage_sprite.z = 3001
  278.      @_total_damage_duration = 80
  279.      #hit数描绘
  280.      @hits+=1
  281.     if @_total_damage > 0
  282.       hit
  283.     end
  284.    end
  285.  
  286.  
  287.    def animation(animation, hit, battler_damage="", battler_critical=false)
  288.      dispose_animation      
  289.      #=======================================
  290.      # 修改:记录伤害和critical
  291.      #=======================================
  292.      @battler_damage = battler_damage
  293.      @battler_critical = battler_critical
  294.      @_animation = animation
  295.      return if @_animation == nil
  296.      @_animation_hit = hit
  297.      @_animation_duration = @_animation.frame_max
  298.      animation_name = @_animation.animation_name
  299.      animation_hue = @_animation.animation_hue
  300.      bitmap = RPG::Cache.animation(animation_name, animation_hue)
  301.      #=======================================
  302.      # 修改:计算总闪光权限值
  303.      #=======================================
  304.      for timing in @_animation.timings
  305.        quanzhong = animation_process_timing(timing, @_animation_hit,true)
  306.        @all_quanzhong += quanzhong
  307.        # 记录最后一次闪光
  308.        @_last_frame = timing.frame if quanzhong != 0
  309.      end      
  310.      if @@_reference_count.include?(bitmap)
  311.        @@_reference_count[bitmap] += 1
  312.      else
  313.        @@_reference_count[bitmap] = 1
  314.      end
  315.      #=======================================
  316.      # 修改:行动方动画不显示伤害
  317.      #=======================================
  318.      if $scene.is_a?(Scene_Battle)
  319.        if $scene.animation1_id == @battler.animation_id
  320.          @battler_damage = ""
  321.        end
  322.      end
  323.      @_animation_sprites = []
  324.      if @_animation.position != 3 or not @@_animations.include?(animation)
  325.        for i in 0..15
  326.          sprite = ::Sprite.new(self.viewport)
  327.          sprite.bitmap = bitmap
  328.          sprite.visible = false
  329.          @_animation_sprites.push(sprite)
  330.        end
  331.        unless @@_animations.include?(animation)
  332.          @@_animations.push(animation)
  333.        end
  334.      end
  335.      update_animation
  336.   end
  337.    #=======================================
  338.    # 修改:更换清除伤害的算法,以防万一
  339.    #       本内容在脚本中没有使用过
  340.    #=======================================
  341.    def dispose_damage
  342.      for damage in @_damage.reverse
  343.        damage[0].bitmap.dispose
  344.        damage[0].dispose
  345.        @_damage.delete(damage)
  346.      end
  347.      @_total_damage = 0
  348.      @_last_frame = -1
  349.      if @_total_damage_sprite != nil
  350.        @_total_damage_duration = 0
  351.        @_total_damage_sprite.bitmap.dispose
  352.        @_total_damage_sprite.dispose
  353.        @_total_damage_sprite = nil
  354.      end
  355.    end
  356.    #=======================================
  357.    # 清除hit数★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  358.    #=======================================
  359.    def dispose_hit
  360.      if @_hits_sprite != nil
  361.        @_hits_sprite.bitmap.dispose
  362.        @_hits_sprite.dispose
  363.        @_hits_sprite = nil
  364.      end
  365.    end
  366.    def dispose_animation
  367.      #=======================================
  368.      # 修改:清除记录的伤害,清除权重记录
  369.      #=======================================
  370.      @battler_damage = nil
  371.      @battler_critical = nil
  372.      @all_quanzhong = 1
  373.      @_total_damage = 0
  374.      @_last_frame = -1
  375.      if @_animation_sprites != nil
  376.        sprite = @_animation_sprites[0]
  377.        if sprite != nil
  378.          @@_reference_count[sprite.bitmap] -= 1
  379.          if @@_reference_count[sprite.bitmap] == 0
  380.            sprite.bitmap.dispose
  381.          end
  382.        end
  383.        for sprite in @_animation_sprites
  384.          sprite.dispose
  385.        end
  386.        @_animation_sprites = nil
  387.        @_animation = nil
  388.      end
  389.    end
  390.    def update
  391.      super
  392.      if @_whiten_duration > 0
  393.        @_whiten_duration -= 1
  394.        self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  395.      end
  396.      if @_appear_duration > 0
  397.        @_appear_duration -= 1
  398.        self.opacity = (16 - @_appear_duration) * 16
  399.      end
  400.      if @_escape_duration > 0
  401.        @_escape_duration -= 1
  402.        self.opacity = 256 - (32 - @_escape_duration) * 10
  403.      end
  404.      if @_collapse_duration > 0
  405.        @_collapse_duration -= 1
  406.        self.opacity = 256 - (48 - @_collapse_duration) * 6
  407.      end
  408.      #=======================================
  409.      # 修改:更新算法,更新弹出
  410.      #=======================================
  411.      if @_damage_duration > 0
  412.        @_damage_duration -= 1
  413.        for damage in @_damage
  414.          damage[0].x = self.x + self.viewport.rect.x
  415.          damage[0].y -= 3
  416.          damage[0].opacity = damage[1]*20
  417.          damage[1] -= 1
  418.          if damage[1]==0
  419.            damage[0].bitmap.dispose
  420.            damage[0].dispose
  421.            @_damage.delete(damage)
  422.  
  423.            next
  424.          end
  425.        end
  426.      end
  427.      #=======================================
  428.      # 添加:弹出总伤害
  429.      #=======================================
  430.      if @_total_damage_duration > 0
  431.        @_total_damage_duration -= 1
  432.        @_total_damage_sprite.y -= 1 if @_total_damage_duration % 2 == 0
  433.        if @_total_damage_sprite.zoom_x > 1.0
  434.          @_total_damage_sprite.zoom_x -= 0.05
  435.        end
  436.        if @_total_damage_sprite.zoom_y > 1.0
  437.          @_total_damage_sprite.zoom_y -= 0.05
  438.        end
  439.        @_total_damage_sprite.opacity = 256 - (24 - @_total_damage_duration) * 16
  440.        if @_total_damage_duration <= 0
  441.          dispose_hit#★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  442.          @_total_damage = 0
  443.          @_total_damage_duration = 0
  444.          @_total_damage_sprite.bitmap.dispose
  445.          @_total_damage_sprite.dispose
  446.          @_total_damage_sprite = nil
  447.        end
  448.      end
  449.      #=======================================
  450.      if @_animation != nil and (Graphics.frame_count % 2 == 0)
  451.        @_animation_duration -= 1
  452.        update_animation
  453.      end
  454.      if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  455.        update_loop_animation
  456.        @_loop_animation_index += 1
  457.        @_loop_animation_index %= @_loop_animation.frame_max
  458.      end
  459.      if @_blink
  460.        @_blink_count = (@_blink_count + 1) % 32
  461.        if @_blink_count < 16
  462.          alpha = (16 - @_blink_count) * 6
  463.        else
  464.          alpha = (@_blink_count - 16) * 6
  465.        end
  466.        self.color.set(255, 255, 255, alpha)
  467.      end
  468.      @@_animations.clear
  469.    end
  470.    def update_animation
  471.     if @_animation_duration > 0
  472.        frame_index = @_animation.frame_max - @_animation_duration
  473.        cell_data = @_animation.frames[frame_index].cell_data
  474.        position = @_animation.position
  475.        animation_set_sprites(@_animation_sprites, cell_data, position)
  476.        #=======================================
  477.        # 修改:弹出伤害,权重计算
  478.        #=======================================
  479.        for timing in @_animation.timings
  480.          if timing.frame == frame_index
  481.            t = 1.0 * animation_process_timing(timing, @_animation_hit)  
  482.                    if timing.se.name != ""
  483.           se=timing.se
  484.           Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
  485.         end
  486.            #p t,"当前权重", @all_quanzhong,"总权重"
  487.            if @battler_damage.is_a?(Numeric) and t != 0
  488.              t *= @battler_damage
  489.              t /= @all_quanzhong
  490.              t = t.to_i
  491.              #在闪光不是最后一次的情况下,把这次伤害加入到已经发生的伤害中★★★★★★★★★★★★★★★★★★★★★★★★★★
  492.              if frame_index != @_last_frame
  493.              @p_dam+= t
  494.              end
  495.              #p @p_dam,"已发生伤害",@battler_damage,"总伤害"(调试用)★★★★★★★★★★★★★★★★★★★★★★★★★★
  496.              #闪光为最后一次的情况下,改变这次伤害的计算方法(总伤害-已经发生伤害)★★★★★★★★★★★★★★★★★★★★★★★★★★
  497.              if frame_index == @_last_frame
  498.                t=@battler_damage-@p_dam
  499.              end
  500.              #p t,"当前伤害",@battler_damage,"总伤害"
  501.              # 最后一次闪光的话,伤害修正
  502.              if frame_index == @_last_frame
  503.                @_total_damage = @battler_damage - t
  504.                @p_dam=0      #已经发生的伤害归0★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  505.             end
  506.              #p t,@battler_damage,@all_quanzhong
  507.              damage(t,@battler_critical)
  508.             #连击次数归0★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  509.             if frame_index == @_last_frame
  510.                       @hits=0  
  511.             end
  512.            # 防止重复播放miss
  513.            elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
  514.              damage(@battler_damage,@battler_critical)
  515.            end
  516.          end
  517.        end
  518.      else
  519.        dispose_animation
  520.      end
  521.    end
  522.    #=======================================
  523.    # 修改:敌人跳跃的功能 + 添加返回数值
  524.    #=======================================
  525.     def animation_process_timing(timing, hit,dontflash=false)
  526.       if (timing.condition == 0) or
  527.          (timing.condition == 1 and hit == true) or
  528.          (timing.condition == 2 and hit == false)
  529.         case timing.flash_scope
  530.         when 1
  531.           unless dontflash
  532.             self.flash(timing.flash_color, timing.flash_duration * 2)
  533.             if @_total_damage >0
  534.               @flash_shake_switch = true
  535.               @flash_shake = 10
  536.             end
  537.           end
  538.           return timing.flash_color.alpha * timing.flash_duration
  539.         when 2
  540.           unless dontflash
  541.             if self.viewport != nil
  542.               self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
  543.             end
  544.           end
  545.           return timing.flash_color.alpha * timing.flash_duration
  546.         when 3
  547.           unless dontflash
  548.             self.flash(nil, timing.flash_duration * 2)
  549.           end
  550.           return timing.flash_color.alpha * timing.flash_duration
  551.         end
  552.       end      
  553.       return 0
  554.     end   
  555. end
  556. end
  557. #==============================================================================
  558. # ■ Sprite_Battler
  559. #==============================================================================
  560. class Sprite_Battler < RPG::Sprite
  561. #--------------------------------------------------------------------------
  562. # ● 初始化对像
  563. #    添加跳跃记录
  564. #--------------------------------------------------------------------------
  565. def initialize(viewport, battler = nil)
  566.   super(viewport)
  567.   [url=home.php?mod=space&uid=133701]@battler[/url] = battler
  568.   @battler_visible = false
  569.   @flash_shake_switch = true
  570. end
  571. #--------------------------------------------------------------------------
  572. # ● 刷新画面
  573. #    增添跳跃功能
  574. #--------------------------------------------------------------------------
  575. def update
  576.   super
  577.   # 战斗者为 nil 的情况下
  578.   if @battler == nil
  579.     self.bitmap = nil
  580.     loop_animation(nil)
  581.     return
  582.   end
  583.   # 文件名和色相与当前情况有差异的情况下
  584.   if @battler.battler_name != @battler_name or
  585.      @battler.battler_hue != @battler_hue
  586.     # 获取、设置位图
  587.     @battler_name = @battler.battler_name
  588.     @battler_hue = @battler.battler_hue
  589.     self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  590.     @width = bitmap.width
  591.     @height = bitmap.height
  592.     self.ox = @width / 2
  593.     self.oy = @height
  594.     # 如果是战斗不能或者是隐藏状态就把透明度设置成 0
  595.     if @battler.dead? or @battler.hidden
  596.       self.opacity = 0
  597.     end
  598.   end
  599.   # 动画 ID 与当前的情况有差异的情况下
  600.   if @battler.damage == nil and
  601.      @battler.state_animation_id != @state_animation_id
  602.     @state_animation_id = @battler.state_animation_id
  603.     loop_animation($data_animations[@state_animation_id])
  604.   end
  605.   # 应该被显示的角色的情况下
  606.   if @battler.is_a?(Game_Actor) and @battler_visible
  607.     # 不是主状态的时候稍稍降低点透明度
  608.     if $game_temp.battle_main_phase
  609.       self.opacity += 3 if self.opacity < 255
  610.     else
  611.       self.opacity -= 3 if self.opacity > 207
  612.     end
  613.   end
  614.   # 明灭
  615.   if @battler.blink
  616.     blink_on
  617.   else
  618.     blink_off
  619.   end
  620.   # 不可见的情况下
  621.   unless @battler_visible
  622.     # 出现
  623.     if not @battler.hidden and not @battler.dead? and
  624.        (@battler.damage == nil or @battler.damage_pop)
  625.       appear
  626.       @battler_visible = true
  627.     end
  628.   end
  629.   # 可见的情况下
  630.   if @battler_visible
  631.     # 逃跑
  632.     if @battler.hidden
  633.       $game_system.se_play($data_system.escape_se)
  634.       escape
  635.       @battler_visible = false
  636.     end
  637.     # 白色闪烁
  638.     if @battler.white_flash
  639.       whiten
  640.       @battler.white_flash = false
  641.     end
  642.     # 动画
  643.     if @battler.animation_id != 0
  644.       animation = $data_animations[@battler.animation_id]
  645.       animation(animation, @battler.animation_hit,@battler.damage, @battler.critical)
  646.       @battler.animation_id = 0
  647.     end
  648.     # 伤害
  649.     if @battler.damage_pop
  650.       @battler.damage = nil
  651.       @battler.critical = false
  652.       @battler.damage_pop = false
  653.     end
  654.     # korapusu
  655.     if @battler.damage == nil and @battler.dead?
  656.       if @battler.is_a?(Game_Enemy)
  657.         $game_system.se_play($data_system.enemy_collapse_se)
  658.       else
  659.         $game_system.se_play($data_system.actor_collapse_se)
  660.       end
  661.       collapse
  662.       @battler_visible = false
  663.     end
  664.   end
  665.   # 设置活动块的坐标
  666.   if @flash_shake_switch == true
  667.     self.x = @battler.screen_x
  668.     self.y = @battler.screen_y
  669.     self.z = @battler.screen_z
  670.     @flash_shake_switch = false
  671.   end
  672.   if @flash_shake != 0 and @battler.damage != nil and RPG::BATTLER_JUMP
  673.     case @flash_shake
  674.     when 9..10
  675.       self.x = @battler.screen_x
  676.       self.y -=4
  677.       self.z = @battler.screen_z
  678.     when 6..8
  679.       self.x = @battler.screen_x
  680.       self.y -=2
  681.       self.z = @battler.screen_z
  682.     when 3..5
  683.       self.x = @battler.screen_x
  684.       self.y +=2
  685.       self.z = @battler.screen_z
  686.     when 2
  687.       self.x = @battler.screen_x
  688.       self.y += 4
  689.       self.z = @battler.screen_z
  690.     when 1
  691.       self.x = @battler.screen_x
  692.       self.y = @battler.screen_y
  693.       self.z = @battler.screen_z
  694.     end
  695.     @flash_shake -= 1
  696.   end
  697. end
  698. end
  699.  
  700. #==============================================================================
  701. # ■ Scene_Battle
  702. #------------------------------------------------------------------------------
  703. #  处理战斗画面的类。
  704. #==============================================================================
  705.  
  706. class Scene_Battle
  707. #--------------------------------------------------------------------------
  708. # ● 定义实例变量
  709. #--------------------------------------------------------------------------
  710. attr_reader   :animation1_id                    # 行动方动画ID
  711. end
  712.  
  713. #==============================================================================
  714. # ■ Game_Battler
  715. #------------------------------------------------------------------------------
  716. #  处理战斗者的类。这个类作为 Game_Actor 类与 Game_Enemy 类的
  717. # 超级类来使用。
  718. #==============================================================================
  719.  
  720. #class Game_Battler
  721. #  #--------------------------------------------------------------------------
  722. #  # ● 应用连续伤害效果
  723. #  #--------------------------------------------------------------------------
  724. #  alias rainbow_sword_slip_damage_effect slip_damage_effect
  725. #  def slip_damage_effect
  726. #    self.animation_id = RPG::SLIP_DAMAGE_ANIMATION_ID
  727. #    self.animation_hit = true
  728. #    rainbow_sword_slip_damage_effect
  729. #  end
  730. #end

2.
RUBY 代码复制
  1. #--------------------------------------------------
  2. # 此脚本来自[url]www.66RPG.com[/url],使用请保留此信息
  3. #--------------------------------------------------
  4. module RPG
  5.   class Sprite < ::Sprite
  6.     def initialize(viewport = nil)
  7.       super(viewport)
  8.       @_whiten_duration = 0
  9.       @_appear_duration = 0
  10.       @_escape_duration = 0
  11.       @_total_damage = 0
  12.       @_collapse_duration = 0
  13.       @_damage_duration = 0
  14.       @_animation_duration = 0
  15.       @_blink = false
  16.       @_animation = []
  17.     end
  18.     def animation(animation, hit)
  19.       return if animation == nil
  20.       num = @_animation.size
  21.       @_animation.push([animation, hit, animation.frame_max, []])
  22.       bitmap = RPG::Cache.animation(animation.animation_name,
  23.                                     animation.animation_hue)
  24.       if @@_reference_count.include?(bitmap)
  25.         @@_reference_count[bitmap] += 1
  26.       else
  27.         @@_reference_count[bitmap] = 1
  28.       end
  29.       if @_animation[num][0] != 3 or not @@_animations.include?(animation)
  30.         for i in 0..15
  31.           sprite = ::Sprite.new
  32.           sprite.bitmap = bitmap
  33.           sprite.visible = false
  34.           @_animation[num][3].push(sprite)
  35.         end
  36.         unless @@_animations.include?(animation)
  37.           @@_animations.push(animation)
  38.         end
  39.       end
  40.       update_animation(@_animation[num])
  41.     end
  42.     def loop_animation(animation)
  43.       return if animation == @_loop_animation
  44.       dispose_loop_animation
  45.       @_loop_animation = animation
  46.       return if @_loop_animation == nil
  47.       @_loop_animation_index = 0
  48.       animation_name = @_loop_animation.animation_name
  49.       animation_hue = @_loop_animation.animation_hue
  50.       bitmap = RPG::Cache.animation(animation_name, animation_hue)
  51.       if @@_reference_count.include?(bitmap)
  52.         @@_reference_count[bitmap] += 1
  53.       else
  54.         @@_reference_count[bitmap] = 1
  55.       end
  56.       @_loop_animation_sprites = []
  57.       for i in 0..15
  58.         sprite = ::Sprite.new
  59.         sprite.bitmap = bitmap
  60.         sprite.visible = false
  61.         @_loop_animation_sprites.push(sprite)
  62.       end
  63.       # update_loop_animation
  64.     end
  65.     def dispose_animation
  66.       for anime in @_animation.reverse
  67.         sprite = anime[3][0]
  68.         if sprite != nil
  69.           @@_reference_count[sprite.bitmap] -= 1
  70.           if @@_reference_count[sprite.bitmap] == 0
  71.             sprite.bitmap.dispose
  72.           end
  73.         end
  74.         for sprite in anime[3]
  75.           sprite.dispose
  76.         end
  77.         @_animation.delete(anime)
  78.       end
  79.     end
  80.  
  81.     def update
  82.       super
  83.       if @_whiten_duration > 0
  84.         @_whiten_duration -= 1
  85.         self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  86.       end
  87.       if @_appear_duration > 0
  88.         @_appear_duration -= 1
  89.         self.opacity = (16 - @_appear_duration) * 16
  90.       end
  91.       if @_escape_duration > 0
  92.         @_escape_duration -= 1
  93.         self.opacity = 256 - (32 - @_escape_duration) * 10
  94.       end
  95.       if @_collapse_duration > 0
  96.         @_collapse_duration -= 1
  97.         self.opacity = 256 - (48 - @_collapse_duration) * 6
  98.       end
  99.       if @_damage_duration > 0
  100.         @_damage_duration -= 1
  101.         case @_damage_duration
  102.         when 38..39
  103.           @_damage_sprite.y -= 4
  104.         when 36..37
  105.           @_damage_sprite.y -= 2
  106.         when 34..35
  107.           @_damage_sprite.y += 2
  108.         when 28..33
  109.           @_damage_sprite.y += 4
  110.         end
  111.         @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
  112.         if @_damage_duration == 0
  113.           dispose_damage
  114.         end
  115.       end
  116.       for anime in @_animation
  117.         # 修改:原来的是2帧更新一次,现在1帧更新一次
  118.         #if (Graphics.frame_count % 2 == 0)
  119.           anime[2] -= 1 if (Graphics.frame_count % 2 == 0)
  120.           update_animation(anime)
  121.         #end
  122.       end
  123.       if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  124.         update_loop_animation
  125.         @_loop_animation_index += 1
  126.         @_loop_animation_index %= @_loop_animation.frame_max
  127.       end
  128.       if @_blink
  129.         @_blink_count = (@_blink_count + 1) % 32
  130.         if @_blink_count < 16
  131.           alpha = (16 - @_blink_count) * 6
  132.         else
  133.           alpha = (@_blink_count - 16) * 6
  134.         end
  135.         self.color.set(255, 255, 255, alpha)
  136.       end
  137.       @@_animations.clear
  138.     end
  139.  
  140.     def update_animation(anime)
  141.       if anime[2] > 0
  142.         frame_index = anime[0].frame_max - anime[2]
  143.         cell_data = anime[0].frames[frame_index].cell_data
  144.         position = anime[0].position
  145.         animation_set_sprites(anime[3], cell_data, position)
  146.         for timing in anime[0].timings
  147.           if timing.frame == frame_index
  148.             animation_process_timing(timing, anime[1])
  149.           end
  150.         end
  151.       else
  152.         @@_reference_count[anime[3][0].bitmap] -= 1
  153.         if @@_reference_count[anime[3][0].bitmap] == 0
  154.             anime[3][0].bitmap.dispose
  155.         end
  156.         for sprite in anime[3]
  157.           sprite.dispose
  158.         end
  159.         @_animation.delete(anime)
  160.       end
  161.     end
  162.     def animation_set_sprites(sprites, cell_data, position)
  163.       for i in 0..15
  164.         sprite = sprites[i]
  165.         pattern = cell_data[i, 0]
  166.         if sprite == nil or pattern == nil or pattern == -1
  167.           sprite.visible = false if sprite != nil
  168.           next
  169.         end
  170.         sprite.visible = true
  171.         sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  172.         if position == 3
  173.           if self.viewport != nil
  174.             sprite.x = self.viewport.rect.width / 2
  175.             if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
  176.               sprite.y = self.viewport.rect.height - 320
  177.             else
  178.               sprite.y = self.viewport.rect.height - 160
  179.             end
  180.           else
  181.             sprite.x = 320
  182.             sprite.y = 240
  183.           end
  184.         else
  185.           sprite.x = self.x + self.viewport.rect.x -
  186.                       self.ox + self.src_rect.width / 2
  187.           if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
  188.             sprite.y = self.y - self.oy * self.zoom_y / 2 +
  189.                         self.viewport.rect.y
  190.             if position == 0
  191.               sprite.y -= self.src_rect.height * self.zoom_y / 4
  192.             elsif position == 2
  193.               sprite.y += self.src_rect.height * self.zoom_y / 4
  194.             end
  195.           else
  196.             sprite.y = self.y + self.viewport.rect.y -
  197.                         self.oy + self.src_rect.height / 2
  198.             sprite.y -= self.src_rect.height / 4 if position == 0
  199.             sprite.y += self.src_rect.height / 4 if position == 2
  200.           end
  201.         end
  202.         sprite.x += cell_data[i, 1]
  203.         sprite.y += cell_data[i, 2]
  204.         sprite.z = 2000
  205.         sprite.ox = 96
  206.         sprite.oy = 96
  207.         sprite.zoom_x = cell_data[i, 3] / 100.0
  208.         sprite.zoom_y = cell_data[i, 3] / 100.0
  209.         if position != 3
  210.           sprite.zoom_x *= self.zoom_x
  211.           sprite.zoom_y *= self.zoom_y
  212.         end
  213.         sprite.angle = cell_data[i, 4]
  214.         sprite.mirror = (cell_data[i, 5] == 1)
  215.         sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  216.         sprite.blend_type = cell_data[i, 7]
  217.       end
  218.  
  219.       #p sprites[0].x - self.x, @_animation.size
  220.  
  221.     end
  222.   end
  223. end

Lv3.寻梦者

梦石
0
星屑
2007
在线时间
1018 小时
注册时间
2011-6-19
帖子
633

极短24参与开拓者

2
发表于 2013-8-30 08:56:28 | 只看该作者
第二个问题:204行sprite.z = 2000这里改,把数值调小

评分

参与人数 1星屑 +63 收起 理由
弗雷德 + 63 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-2 09:25

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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