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

Project1

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

[已经解决] 角色攻击时如何让敌人后退?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
98 小时
注册时间
2012-7-12
帖子
57
跳转到指定楼层
1
发表于 2012-7-30 17:56:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我想做那种角色攻击敌人时好像敌人被打得后退,然后又恢复到原来的位置的效果,但是不知道怎么实现。

哪位高手帮我一下,看看用什么方法可以实现?

Lv1.梦旅人

梦石
0
星屑
46
在线时间
223 小时
注册时间
2010-7-7
帖子
213
2
发表于 2012-7-31 22:49:58 | 只看该作者
用动画替换敌人被伤害的动画
每天5小时制作游戏,5小时测试,把游戏都玩透了。晕,不知说了什么。。。。
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
98 小时
注册时间
2012-7-12
帖子
57
3
 楼主| 发表于 2012-7-31 23:12:52 | 只看该作者
eu国猪 发表于 2012-7-31 22:49
用动画替换敌人被伤害的动画

不懂,不知道怎么做。……
回复

使用道具 举报

Lv1.梦旅人

虱子

梦石
0
星屑
121
在线时间
1782 小时
注册时间
2010-6-19
帖子
3597
4
发表于 2012-7-31 23:46:39 | 只看该作者
据说彩虹神剑有这功能
  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 = false
  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 effect?
  59.       @_whiten_duration > 0 or
  60.       @_appear_duration > 0 or
  61.       @_escape_duration > 0 or
  62.       @_collapse_duration > 0 or
  63.       @_animation_duration > 0
  64.     end
  65.    def damage(value, critical)
  66.      if value.is_a?(Numeric)
  67.        damage_string = value.abs.to_s
  68.      else
  69.        damage_string = value.to_s
  70.      end
  71.      bitmap = Bitmap.new(160, 48)
  72.      bitmap.font.name = "Arial Black"
  73.      bitmap.font.size = 32
  74.      bitmap.font.color.set(0, 0, 0)
  75.      bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  76.      bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  77.      bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  78.      bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  79.      #=======================================
  80.      # 修改:颜色
  81.      #=======================================
  82.      if value.is_a?(Numeric) and value < 0
  83.        bitmap.font.color.set(176, 255, 144)
  84.      else
  85.        bitmap.font.color.set(255, 55, 55)
  86.      end
  87.      bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  88.      if critical
  89.        bitmap.font.size = 20
  90.        bitmap.font.color.set(0, 0, 0)
  91.        bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
  92.        bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
  93.        bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
  94.        bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
  95.        bitmap.font.color.set(255, 255, 255)
  96.        bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
  97.      end
  98.      @_damage_sprite = ::Sprite.new(self.viewport)
  99.      @_damage_sprite.bitmap = bitmap
  100.      @_damage_sprite.ox = 80
  101.      @_damage_sprite.oy = 20
  102.      @_damage_sprite.x = self.x
  103.      @_damage_sprite.y = self.y - self.oy / 2
  104.      @_damage_sprite.z = 3000
  105.      @_damage_duration = 40
  106.      #=======================================
  107.      # 修改:推入新的伤害
  108.      #=======================================
  109.      @_damage.push([@_damage_sprite,@_damage_duration-10,0, rand(30) - 15, rand(3)])
  110.      # 总伤害处理
  111.      make_total_damage(value)
  112.    end
  113.    #--------------------------------------------------------------------------
  114.    # ● 总伤害处理
  115.    #--------------------------------------------------------------------------
  116.    def make_total_damage(value)
  117.      if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
  118.        @_total_damage += value
  119.      else
  120.        return
  121.      end
  122.      bitmap = Bitmap.new(300, 150)
  123.      bitmap.font.name = "Arial Black"
  124.      bitmap.font.size = 48
  125.      bitmap.font.color.set(0, 0, 0)
  126.      bitmap.draw_text(+2, 12+2, 160, 36, @_total_damage.abs.to_s, 1)
  127.      if @_total_damage < 0
  128.        bitmap.font.color.set(80, 255, 00)
  129.      else
  130.        bitmap.font.color.set(255, 140, 0)
  131.      end
  132.      bitmap.draw_text(0, 12, 160, 36, @_total_damage.abs.to_s, 1)
  133.      if @_total_damage_sprite.nil?
  134.        @_total_damage_sprite = ::Sprite.new(self.viewport)
  135.        @_total_damage_sprite.ox = 80
  136.        @_total_damage_sprite.oy = 20
  137.        @_total_damage_sprite.z = 3000
  138.      end
  139.      @_total_damage_sprite.bitmap = bitmap
  140.      @_total_damage_sprite.zoom_x = 1.5
  141.      @_total_damage_sprite.zoom_y = 1.5
  142.      @_total_damage_sprite.x = self.x
  143.      @_total_damage_sprite.y = self.y  - self.oy / 2 - 64
  144.      @_total_damage_sprite.z = 3001
  145.      @_total_damage_duration = 80
  146.    end
  147.    def animation(animation, hit, battler_damage="", battler_critical=false)
  148.      dispose_animation      
  149.      #=======================================
  150.      # 修改:记录伤害和critical
  151.      #=======================================
  152.      @battler_damage = battler_damage
  153.      @battler_critical = battler_critical
  154.      @_animation = animation
  155.      return if @_animation == nil
  156.      @_animation_hit = hit
  157.      @_animation_duration = @_animation.frame_max
  158.      animation_name = @_animation.animation_name
  159.      animation_hue = @_animation.animation_hue
  160.      bitmap = RPG::Cache.animation(animation_name, animation_hue)
  161.      #=======================================
  162.      # 修改:计算总闪光权限值
  163.      #=======================================
  164.      for timing in @_animation.timings
  165.        quanzhong = animation_process_timing(timing, @_animation_hit,true)
  166.        @all_quanzhong += quanzhong
  167.        # 记录最后一次闪光
  168.        @_last_frame = timing.frame if quanzhong != 0
  169.      end      
  170.      if @@_reference_count.include?(bitmap)
  171.        @@_reference_count[bitmap] += 1
  172.      else
  173.        @@_reference_count[bitmap] = 1
  174.      end
  175.      #=======================================
  176.      # 修改:行动方动画不显示伤害
  177.      #=======================================
  178.      if $scene.is_a?(Scene_Battle)
  179.        if $scene.animation1_id == @battler.animation_id
  180.          @battler_damage = ""
  181.        end
  182.      end
  183.      @_animation_sprites = []
  184.      if @_animation.position != 3 or not @@_animations.include?(animation)
  185.        for i in 0..15
  186.          sprite = ::Sprite.new(self.viewport)
  187.          sprite.bitmap = bitmap
  188.          sprite.visible = false
  189.          sprite.z = self.z-1
  190.          @_animation_sprites.push(sprite)
  191.        end
  192.        unless @@_animations.include?(animation)
  193.          @@_animations.push(animation)
  194.        end
  195.      end
  196.      update_animation
  197.    end
  198.    #=======================================
  199.    # 修改:更换清除伤害的算法,以防万一
  200.    #       本内容在脚本中没有使用过
  201.    #=======================================
  202.    def dispose_damage
  203.      for damage in @_damage.reverse
  204.        damage[0].bitmap.dispose
  205.        damage[0].dispose
  206.        @_damage.delete(damage)
  207.      end
  208.      @_total_damage = 0
  209.      @_last_frame = -1
  210.      if @_total_damage_sprite != nil
  211.        @_total_damage_duration = 0
  212.        @_total_damage_sprite.bitmap.dispose
  213.        @_total_damage_sprite.dispose
  214.        @_total_damage_sprite = nil
  215.      end
  216.    end
  217.    def dispose_animation
  218.      #=======================================
  219.      # 修改:清除记录的伤害,清除权重记录
  220.      #=======================================
  221.      @battler_damage = nil
  222.      @battler_critical = nil
  223.      @all_quanzhong = 1
  224.      @_total_damage = 0
  225.      @_last_frame = -1
  226.      if @_animation_sprites != nil
  227.        sprite = @_animation_sprites[0]
  228.        if sprite != nil
  229.          @@_reference_count[sprite.bitmap] -= 1
  230.          if @@_reference_count[sprite.bitmap] == 0
  231.            sprite.bitmap.dispose
  232.          end
  233.        end
  234.        for sprite in @_animation_sprites
  235.          sprite.dispose
  236.        end
  237.        @_animation_sprites = nil
  238.        @_animation = nil
  239.      end
  240.    end
  241.    def update
  242.      super
  243.      if @_whiten_duration > 0
  244.        @_whiten_duration -= 1
  245.        self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  246.      end
  247.      if @_appear_duration > 0
  248.        @_appear_duration -= 1
  249.        self.opacity = (16 - @_appear_duration) * 16
  250.      end
  251.      if @_escape_duration > 0
  252.        @_escape_duration -= 1
  253.        self.opacity = 256 - (32 - @_escape_duration) * 10
  254.      end
  255.      if @_collapse_duration > 0
  256.        @_collapse_duration -= 1
  257.        self.opacity = 256 - (48 - @_collapse_duration) * 6
  258.      end
  259.      #=======================================
  260.      # 修改:更新算法,更新弹出
  261.      #=======================================
  262.      if @_damage_duration > 0
  263.        @_damage_duration -= 1
  264.        for damage in @_damage
  265.          damage[0].x = self.x + self.viewport.rect.x -
  266.                        self.ox + self.src_rect.width / 2 +
  267.                        (40 - damage[1]) * damage[3] / 10
  268.          damage[0].y -= damage[4]+damage[1]/10
  269.          damage[0].opacity = damage[1]*20
  270.          damage[1] -= 1
  271.          if damage[1]==0
  272.            damage[0].bitmap.dispose
  273.            damage[0].dispose
  274.            @_damage.delete(damage)
  275.            next
  276.          end
  277.        end
  278.      end
  279.      #=======================================
  280.      # 添加:弹出总伤害
  281.      #=======================================
  282.      if @_total_damage_duration > 0
  283.        @_total_damage_duration -= 1
  284.        @_total_damage_sprite.y -= 1 if @_total_damage_duration % 2 == 0
  285.        if @_total_damage_sprite.zoom_x > 1.0
  286.          @_total_damage_sprite.zoom_x -= 0.05
  287.        end
  288.        if @_total_damage_sprite.zoom_y > 1.0
  289.          @_total_damage_sprite.zoom_y -= 0.05
  290.        end
  291.        @_total_damage_sprite.opacity = 256 - (24 - @_total_damage_duration) * 16
  292.        if @_total_damage_duration <= 0
  293.          @_total_damage = 0
  294.          @_total_damage_duration = 0
  295.          @_total_damage_sprite.bitmap.dispose
  296.          @_total_damage_sprite.dispose
  297.          @_total_damage_sprite = nil
  298.        end
  299.      end
  300.      #=======================================
  301.      if @_animation != nil and (Graphics.frame_count % 2 == 0)
  302.        @_animation_duration -= 1
  303.        update_animation
  304.      end
  305.      if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  306.        update_loop_animation
  307.        @_loop_animation_index += 1
  308.        @_loop_animation_index %= @_loop_animation.frame_max
  309.      end
  310.      if @_blink
  311.        @_blink_count = (@_blink_count + 1) % 32
  312.        if @_blink_count < 16
  313.          alpha = (16 - @_blink_count) * 6
  314.        else
  315.          alpha = (@_blink_count - 16) * 6
  316.        end
  317.        self.color.set(255, 255, 255, alpha)
  318.      end
  319.      @@_animations.clear
  320.    end
  321.    def update_animation
  322.      if @_animation_duration > 0
  323.        frame_index = @_animation.frame_max - @_animation_duration
  324.        cell_data = @_animation.frames[frame_index].cell_data
  325.        position = @_animation.position
  326.        animation_set_sprites(@_animation_sprites, cell_data, position)
  327.        #=======================================
  328.        # 修改:弹出伤害,权重计算
  329.        #=======================================
  330.        for timing in @_animation.timings
  331.          if timing.frame == frame_index
  332.            t = 1.0 * animation_process_timing(timing, @_animation_hit)            
  333.            #p t,"当前权重", @all_quanzhong,"总权重"
  334.            if @battler_damage.is_a?(Numeric) and t != 0
  335.              t *= @battler_damage
  336.              t /= @all_quanzhong
  337.              #p t,"当前伤害",@battler_damage,"总伤害"
  338.              t = t.to_i
  339.              # 最后一次闪光的话,伤害修正
  340.              if frame_index == @_last_frame
  341.                @_total_damage = @battler_damage - t
  342.              end
  343.              #p t,@battler_damage,@all_quanzhong
  344.              damage(t,@battler_critical)
  345.            # 防止重复播放miss
  346.            elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
  347.              damage(@battler_damage,@battler_critical)
  348.            end
  349.          end
  350.        end
  351.      else
  352.        dispose_animation
  353.      end
  354.    end
  355.    #=======================================
  356.    # 修改:敌人跳跃的功能 + 添加返回数值
  357.    #=======================================
  358.     def animation_process_timing(timing, hit,dontflash=false)
  359.       if (timing.condition == 0) or
  360.          (timing.condition == 1 and hit == true) or
  361.          (timing.condition == 2 and hit == false)
  362.         unless dontflash
  363.           if timing.se.name != ""
  364.             se = timing.se
  365.             Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
  366.           end
  367.         end
  368.         case timing.flash_scope
  369.         when 1
  370.           unless dontflash
  371.             self.flash(timing.flash_color, timing.flash_duration * 2)
  372.             if @_total_damage >0
  373.               @flash_shake_switch = true
  374.               @flash_shake = 10
  375.             end
  376.           end
  377.           return timing.flash_color.alpha * timing.flash_duration
  378.         when 2
  379.           unless dontflash
  380.             if self.viewport != nil
  381.               self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
  382.               return timing.flash_color.alpha * timing.flash_duration
  383.             end
  384.           end
  385.         when 3
  386.           unless dontflash
  387.             self.flash(nil, timing.flash_duration * 2)
  388.           end
  389.           return timing.flash_color.alpha * timing.flash_duration
  390.         end
  391.       end      
  392.       return 0
  393.     end   
  394. end
  395. end
  396. class Scene_Battle
  397. attr_reader :animation1_id
  398. end
复制代码

http://rpg.blue/thread-175056-1-2.html
PVZ型塔防物一个
http://rpg.blue/thread-155199-1-2.html
RMXP技术讨论区手动认可帖,得到答案请认可
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
46
在线时间
223 小时
注册时间
2010-7-7
帖子
213
5
发表于 2012-8-1 08:27:30 | 只看该作者
っ盛尘、恋 发表于 2012-7-31 23:12
不懂,不知道怎么做。……

你的战斗方式是横版的吗
每天5小时制作游戏,5小时测试,把游戏都玩透了。晕,不知说了什么。。。。
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
98 小时
注册时间
2012-7-12
帖子
57
6
 楼主| 发表于 2012-8-1 15:32:15 | 只看该作者
eu国猪 发表于 2012-8-1 08:27
你的战斗方式是横版的吗

对呀,呵呵
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
46
在线时间
223 小时
注册时间
2010-7-7
帖子
213
7
发表于 2012-8-1 21:09:08 | 只看该作者
っ盛尘、恋 发表于 2012-8-1 15:32
对呀,呵呵

是动画横版战斗吗
每天5小时制作游戏,5小时测试,把游戏都玩透了。晕,不知说了什么。。。。
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
98 小时
注册时间
2012-7-12
帖子
57
8
 楼主| 发表于 2012-8-1 22:50:17 | 只看该作者
eu国猪 发表于 2012-8-1 21:09
是动画横版战斗吗

嗯,全动画的,只是敌人不动,角色都动


‘‘──っ盛尘、恋于2012-8-1 22:50补充以下内容:

好像没用~~
’’


‘‘──っ盛尘、恋于2012-8-1 22:52补充以下内容:

我是说那个彩虹神剑脚本没用
’’
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
46
在线时间
223 小时
注册时间
2010-7-7
帖子
213
9
发表于 2012-8-2 08:33:21 | 只看该作者
っ盛尘、恋 发表于 2012-8-1 22:50
嗯,全动画的,只是敌人不动,角色都动

你敌人被攻击后应该有一个动画显示,你把他往后移动一点就行了
每天5小时制作游戏,5小时测试,把游戏都玩透了。晕,不知说了什么。。。。
回复

使用道具 举报

Lv3.寻梦者

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

点评

咦还有个10D啊,果断抄回去  发表于 2012-8-2 10:35
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-30 15:30

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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