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

Project1

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

[已经解决] 如何让动画的某一帧随机播放音效?

[复制链接]

Lv5.捕梦者 (版主)

梦石
20
星屑
1840
在线时间
6925 小时
注册时间
2012-12-14
帖子
11485

短篇十战斗者组别冠军开拓者贵宾短篇九勇士组亚军

跳转到指定楼层
1
发表于 2013-8-27 18:56:57 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
请问要怎么做才能让某一个动画的
某一帧播放的音效是自己多选的随机音效呢?
大家好,这里是晨露的说。请多多指教。
刚入门RM软件制作,请大家多多帮助我哦。
落雪君的欢乐像素教程,欢迎查阅。

Lv5.捕梦者

梦石
0
星屑
32366
在线时间
5090 小时
注册时间
2012-11-19
帖子
4877

开拓者

2
发表于 2013-8-27 20:41:45 手机端发表。 | 只看该作者
需要改动:RPG::Spriet     由于是手机上网,不知道字母有没打对, 只能给出大体方向。

点评

打错了...  发表于 2013-8-27 20:44
回复 支持 反对

使用道具 举报

Lv5.捕梦者 (版主)

梦石
20
星屑
1840
在线时间
6925 小时
注册时间
2012-12-14
帖子
11485

短篇十战斗者组别冠军开拓者贵宾短篇九勇士组亚军

3
 楼主| 发表于 2013-8-28 18:39:48 | 只看该作者
芯☆淡茹水 发表于 2013-8-27 20:41
需要改动:RPG::Spriet     由于是手机上网,不知道字母有没打对, 只能给出大体方向。 ...

表示完全没有思路
大家好,这里是晨露的说。请多多指教。
刚入门RM软件制作,请大家多多帮助我哦。
落雪君的欢乐像素教程,欢迎查阅。

回复 支持 反对

使用道具 举报

Lv2.观梦者 (暗夜天使)

万兽

梦石
0
星屑
597
在线时间
2271 小时
注册时间
2006-11-4
帖子
4868

贵宾

4
发表于 2013-8-28 22:14:05 | 只看该作者
随机音效.rar (479.46 KB, 下载次数: 24)
范例已上传,彩虹神剑等各种定义过伤害效果的脚本可能需要进行整合,将注释过的内容复制进相应的方法即可。

点评

有点晕,不知道将这个脚本放入彩虹神剑的哪个地方了······  发表于 2013-8-28 22:27

评分

参与人数 1星屑 +100 收起 理由
美丽晨露 + 100 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv5.捕梦者 (版主)

梦石
20
星屑
1840
在线时间
6925 小时
注册时间
2012-12-14
帖子
11485

短篇十战斗者组别冠军开拓者贵宾短篇九勇士组亚军

5
 楼主| 发表于 2013-8-28 22:18:31 | 只看该作者
弗雷德 发表于 2013-8-28 22:14
范例已上传,彩虹神剑等各种定义过伤害效果的脚本可能需要进行整合,将注释过的内容复制进相应的方法即可 ...

谢谢熊叔叔的说,让我先整合一下吧。
有问题再向你请教!
大家好,这里是晨露的说。请多多指教。
刚入门RM软件制作,请大家多多帮助我哦。
落雪君的欢乐像素教程,欢迎查阅。

回复 支持 反对

使用道具 举报

Lv2.观梦者 (暗夜天使)

万兽

梦石
0
星屑
597
在线时间
2271 小时
注册时间
2006-11-4
帖子
4868

贵宾

6
发表于 2013-8-28 22:33:58 | 只看该作者
美丽晨露 发表于 2013-8-28 22:18
谢谢熊叔叔的说,让我先整合一下吧。
有问题再向你请教!

将第一段注释圈起的内容复制在彩虹神剑顶端,在彩虹神剑def update_animation的方法里,将第二段注释圈起的内容粘贴在animation_set_sprites(@_animation_sprites, cell_data, position)这句下面
回复 支持 反对

使用道具 举报

Lv5.捕梦者 (版主)

梦石
20
星屑
1840
在线时间
6925 小时
注册时间
2012-12-14
帖子
11485

短篇十战斗者组别冠军开拓者贵宾短篇九勇士组亚军

7
 楼主| 发表于 2013-8-28 22:45:39 | 只看该作者
本帖最后由 美丽晨露 于 2013-8-28 22:46 编辑

@弗雷德

嗯,不知道自己弄错没有,测试没有发现有效果。

RUBY 代码复制
  1. #==============================================================================
  2. # ■ 全动画战斗(修改版)
  3. #------------------------------------------------------------------------------
  4. #  By whbm
  5. #   应用脚本 彩虹神剑 By 66
  6. #==============================================================================
  7.     $fangyu = 0
  8. #################################################################bearrpg
  9. #这个数组填写随机播放的音效文件名
  10. RANDSE = ["001-System01","052-Cannon01","056-Right02","105-Heal01","115-Raise01"]
  11. RANDSE1 = ["001-System01","052-Cannon01","056-Right02"]
  12. #也可以直接在下方将数组定义在临时变量中
  13. ##################################################################
  14. #   修改内容:
  15. #   1.修改 战斗失败继续后被怪打就出现死亡静态BUG
  16. #   2.改变防御方式,虽然有点不自然,但应该比原来好吧。
  17. #                                        by 星云
  18. #==============================================================================
  19. #简要介绍:
  20. #    本脚本实现了战斗的动态效果,其中包含了待机、攻击、防御、挨打、胜利、死亡。类似于超级横版、超级战斗。
  21. #但是本系统特色在于所有效果的实现并不是靠庞大的战斗图,而是使用了数据库中的动画。
  22. #这样不仅突破了不同人不同祯数量的限制,并且方便了单动画单祯的修改。
  23. #使用方法:
  24. #    个人觉得还是比较简单,但是大量的怪物还是会令人头痛。
  25. #    1.数据库的设置
  26. #      敌人必要的动画有待机、挨打、死亡三个必要的动画
  27. #      角色必要的动画有待机、挨打、防御、死亡动态、胜利动态、死亡静态、胜利静态
  28. #
  29. #      死亡静态与胜利静态:动画中只有1祯,为相应动态动画的最后一祯
  30. #      
  31. #      剩下的就是人物攻击的动画,和正常的动画是一样设置
  32. #      如图中的攻击等待动画只是为了在播放攻击动画的同时消除人物本身(素材原因,人物攻击的时候离开了原位,如果是在原位置放魔法是用不上的)
  33. #    2.战斗图的设置
  34. #      战斗图其实只是一个透明的图片,它只是用来描述一个敌人或者角色的大小,并与相应的战斗动画编号相衔接。
  35. #      战斗图的文件名格式如下:
  36. #          名字★待机★防御★挨打★死亡动态★死亡静态★胜利动态★胜利静态.png
  37. #          (其中“名字”一项与动画无关)
  38. #          例如:
  39. #          紫烟★140★141★148★149★150★144★145.png
  40. #      对于敌人无胜利动画或者防御动画,请保持该位置为空,例如:
  41. #          蓝若冰★124★★126★127★★★.png
  42. #    综上,设置就这么完成了。
  43. #注意事项:
  44. #    1.由于系统中待机由动画实现,所以无法使用状态附带动画的功能。
  45. #    2.可以在脚本中使用Ctrl+Shift+F通篇搜索“小改动”,可以修改某些窗口的Z值。
  46. #    3.当您将此系统向您的工程中移植的时候也要注意事项2中的“小改动”。
  47. #    4.系统是从游戏“石焚刃暖”中提取出来的,或许会有疏漏与多余的东西,BUG也是不免的。大家尽管提便是。     
  48. #==============================================================================
  49. class Spriteset_Battle
  50.   #--------------------------------------------------------------------------
  51.   # ● 初始化变量
  52.   #--------------------------------------------------------------------------
  53.   def initialize
  54.     # 生成显示端口
  55.     @viewport1 = Viewport.new(0, 0, 640, 480)
  56.     @viewport2 = Viewport.new(0, 0, 640, 480)
  57.     @viewport3 = Viewport.new(0, 0, 640, 480)
  58.     @viewport4 = Viewport.new(0, 0, 640, 480)
  59.     @viewport2.z = 101
  60.     @viewport3.z = 200
  61.     @viewport4.z = 5000
  62.     # 生成战斗背景活动块
  63.     @battleback_sprite = Sprite.new(@viewport1)
  64.     # 生成敌人活动块
  65.     @enemy_sprites = []
  66.     for enemy in $game_troop.enemies.reverse
  67.       @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
  68.     end
  69.     # 生成敌人活动块
  70.     @actor_sprites = []
  71.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  72.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  73.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  74.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  75.     # 生成天候
  76.     @weather = RPG::Weather.new(@viewport1)
  77.     # 生成图片活动块
  78.     @picture_sprites = []
  79.     for i in 51..100
  80.       @picture_sprites.push(Sprite_Picture.new(@viewport3,
  81.         $game_screen.pictures[i]))
  82.     end
  83.     # 生成计时器块
  84.     @timer_sprite = Sprite_Timer.new
  85.     # 刷新画面
  86.     update
  87.   end
  88.   #..........................................................................
  89.   #--------------------------------------------------------------------------
  90.   # ● 胜利图
  91.   #--------------------------------------------------------------------------
  92.   def win
  93.     for sprite in @actor_sprites
  94.       sprite.win
  95.     end
  96.   end
  97.   #..........................................................................
  98.   #--------------------------------------------------------------------------
  99.   # ● 刷新画面
  100.   #--------------------------------------------------------------------------
  101.   def update
  102.     # 刷新角色的活动块 (对应角色的替换)
  103.     @actor_sprites[0].battler = $game_party.actors[0]
  104.     @actor_sprites[1].battler = $game_party.actors[1]
  105.     @actor_sprites[2].battler = $game_party.actors[2]
  106.     @actor_sprites[3].battler = $game_party.actors[3]
  107.     # 战斗背景的文件名与现在情况有差异的情况下
  108.     if @battleback_name != $game_temp.battleback_name
  109.       @battleback_name = $game_temp.battleback_name
  110.       if @battleback_sprite.bitmap != nil
  111.         @battleback_sprite.bitmap.dispose
  112.       end
  113.       @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
  114.       @battleback_sprite.src_rect.set(0, 0, 640, 480)
  115.     end
  116.     # 刷新战斗者的活动块
  117.     for sprite in @enemy_sprites + @actor_sprites
  118.       sprite.update
  119.     end
  120.     # 刷新天气图形
  121.     @weather.type = $game_screen.weather_type
  122.     @weather.max = $game_screen.weather_max
  123.     @weather.update
  124.     # 刷新图片活动块
  125.     for sprite in @picture_sprites
  126.       sprite.update
  127.     end
  128.     # 刷新计时器活动块
  129.     @timer_sprite.update
  130.     # 设置画面的色调与震动位置
  131.     @viewport1.tone = $game_screen.tone
  132.     @viewport1.ox = $game_screen.shake
  133.     # 设置画面的闪烁色
  134.     @viewport4.color = $game_screen.flash_color
  135.     # 刷新显示端口
  136.     @viewport1.update
  137.     @viewport2.update
  138.     @viewport4.update
  139.   end
  140. end
  141. class Arrow_Enemy < Arrow_Base
  142.   #--------------------------------------------------------------------------
  143.   # ● 获取光标指向的敌人
  144.   #--------------------------------------------------------------------------
  145.   def enemy
  146.     return $game_troop.enemies[@index]
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● 刷新画面
  150.   #--------------------------------------------------------------------------
  151.   def update
  152.     super
  153.     # 如果指向不存在的敌人就离开
  154.     $game_troop.enemies.size.times do
  155.       break if self.enemy.exist?
  156.       [url=home.php?mod=space&uid=370741]@Index[/url] += 1
  157.       @index %= $game_troop.enemies.size
  158.     end
  159.     # 光标右
  160.     if Input.repeat?(Input::RIGHT)
  161.       $game_system.se_play($data_system.cursor_se)
  162.       $game_troop.enemies.size.times do
  163.         @index += 1
  164.         @index %= $game_troop.enemies.size
  165.         break if self.enemy.exist?
  166.       end
  167.     end
  168.     # 光标左
  169.     if Input.repeat?(Input::LEFT)
  170.       $game_system.se_play($data_system.cursor_se)
  171.       $game_troop.enemies.size.times do
  172.         @index += $game_troop.enemies.size - 1
  173.         @index %= $game_troop.enemies.size
  174.         break if self.enemy.exist?
  175.       end
  176.     end
  177.     # 设置活动块坐标
  178.     if self.enemy != nil
  179.       self.x = self.enemy.screen_x + self.ox
  180.       self.y = self.enemy.screen_y + self.oy
  181.     end
  182.   end
  183. end
  184. class Arrow_Actor < Arrow_Base
  185.   #--------------------------------------------------------------------------
  186.   # ● 获取光标指向的角色
  187.   #--------------------------------------------------------------------------
  188.   def actor
  189.     return $game_party.actors[@index]
  190.   end
  191.   #--------------------------------------------------------------------------
  192.   # ● 刷新画面
  193.   #--------------------------------------------------------------------------
  194.   def update
  195.     super
  196.     # 光标右
  197.     if Input.repeat?(Input::RIGHT)
  198.       $game_system.se_play($data_system.cursor_se)
  199.       @index += 1
  200.       @index %= $game_party.actors.size
  201.     end
  202.     # 光标左
  203.     if Input.repeat?(Input::LEFT)
  204.       $game_system.se_play($data_system.cursor_se)
  205.       @index += $game_party.actors.size - 1
  206.       @index %= $game_party.actors.size
  207.     end
  208.     # 设置活动块坐标
  209.     if self.actor != nil
  210.       self.x = self.actor.screen_x + self.ox
  211.       self.y = self.actor.screen_y + self.oy
  212.     end
  213.   end
  214. end
  215. class Scene_Battle
  216.   #--------------------------------------------------------------------------
  217.   # ● 刷新画面 (主回合步骤 3 : 行动方动画)
  218.   #--------------------------------------------------------------------------
  219.   def update_phase4_step3
  220.     # 行动方动画 (ID 为 0 的情况下是白色闪烁)
  221.     if @animation1_id == 0
  222.       @active_battler.white_flash = true
  223.     else
  224.       @active_battler.animation_id = @animation1_id
  225.       @active_battler.animation_hit = true
  226.     end
  227.     # 对像方动画
  228.     for target in @target_battlers
  229.       target.animation_id = @animation2_id
  230.       target.animation_hit = (target.damage != "躲闪")
  231.       #.......................................................................
  232.       if target.is_a?(Game_Actor)
  233.         ##############
  234.         if target.guarding?
  235.           $fangyu = 1
  236.        end
  237.         ##############
  238.        if target.current_action.kind == 0 and target.current_action.basic == 1
  239.            target.setup_battler_ani(target.battler_name.split(/★/)[2])
  240.         else
  241.          target.setup_battler_hurt_ani(0)
  242.         end
  243.       end
  244.       if target.is_a?(Game_Enemy)
  245.         if target.current_action.kind == 0 and target.current_action.basic == 1
  246.           target.setup_battler_ani(target.battler_name.split(/★/)[1])
  247.         else
  248.           target.setup_battler_hurt_ani(0)
  249.         end
  250.       end
  251.       #.......................................................................
  252.     end
  253.     # 对像方动画
  254.     for target in @target_battlers
  255.       target.animation_id = @animation2_id
  256.       target.animation_hit = (target.damage != "躲闪")
  257.       #......................................................................
  258.     end
  259.     # 限制动画长度、最低 8 帧
  260.     @wait_count = 8
  261.     # 移至步骤 5
  262.     @phase4_step = 5
  263.   end
  264.   #--------------------------------------------------------------------------
  265.   # ● 刷新画面 (主回合步骤 4 : 对像方动画) ★
  266.   #--------------------------------------------------------------------------
  267.   def update_phase4_step4
  268.     # 限制动画长度、最低 8 帧
  269.     @wait_count = 8
  270.     # 移至步骤 5
  271.     @phase4_step = 5
  272.   end
  273. end
  274. class Game_Actor < Game_Battler
  275. #--------------------------------------------------------------------------
  276.   # ● 取得战斗画面的 X 坐标
  277.   #--------------------------------------------------------------------------
  278.   def screen_x
  279.     # 返回计算后的队伍 X 坐标的排列顺序
  280.     #if self.index != nil
  281.       #......................................................................
  282.      # return self.index * 80 + 400
  283.       #......................................................................
  284.     #else
  285.     #  return 0
  286.     #end
  287.      case self.index
  288.     when 0
  289.       return 398
  290.     when 1
  291.       return 420
  292.     when 2
  293.       return 495
  294.     when 3
  295.       return 540
  296.     else
  297.       return 600
  298.     end
  299.   end
  300.   #--------------------------------------------------------------------------
  301.   # ● 取得战斗画面的 Y 坐标
  302.   #--------------------------------------------------------------------------
  303.   def screen_y
  304.     #........................................................................
  305.     #return 400 - self.index * 60
  306.     case $game_party.actors.size
  307.     when 1
  308.       case self.index
  309.       when 0
  310.       return 250
  311.       else
  312.       return 1000
  313.       end
  314.     when 2
  315.       case self.index
  316.       when 0
  317.       return 196
  318.     when 1
  319.       return 312
  320.       else
  321.       return 1000
  322.     end
  323.     end
  324.     #........................................................................
  325.   end
  326.   #--------------------------------------------------------------------------
  327.   # ● 取得战斗画面的 Z 坐标
  328.   #--------------------------------------------------------------------------
  329.   def screen_z
  330.     # 返回计算后的队伍 Z 坐标的排列顺序
  331.     if self.index != nil
  332.       return 4 - self.index
  333.     else
  334.       return 0
  335.     end
  336.   end
  337. end
  338. class Scene_Battle
  339.   #..........................................................................
  340.   #--------------------------------------------------------------------------
  341.   # ● 返回phase
  342.   #--------------------------------------------------------------------------
  343.   def phase
  344.     return @phase
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # ● 返回phase4_step
  348.   #--------------------------------------------------------------------------
  349.   def phase4_step
  350.     return @phase4_step
  351.   end
  352.   #--------------------------------------------------------------------------
  353.   # ● 返回phase4_step
  354.   #--------------------------------------------------------------------------
  355.   def actor_command_active?
  356.     return @actor_command_window.active
  357.   end
  358.   #..........................................................................
  359. end
  360. class Game_Battler
  361.   #..........................................................................
  362.   #--------------------------------------------------------------------------
  363.   # ● 获取循环的动画 ID
  364.   #--------------------------------------------------------------------------  
  365.   def show_damage(value)
  366.     @show_damage_value = value
  367.   end
  368.   #--------------------------------------------------------------------------
  369.   # ● 获取循环的动画 ID
  370.   #--------------------------------------------------------------------------
  371.   def show_damage_value
  372.     return @show_damage_value
  373.   end
  374.   #--------------------------------------------------------------------------
  375.   # ● 获取循环的动画 ID
  376.   #--------------------------------------------------------------------------
  377.   def battler_ani
  378.     return @battler_ani
  379.   end
  380.   #--------------------------------------------------------------------------
  381.   # ● 获取循环的动画 ID
  382.   #--------------------------------------------------------------------------
  383.   def setup_battler_ani(battler_ani, once = 0)
  384.     @battler_ani = battler_ani
  385.     @once = once
  386.   end
  387.   #--------------------------------------------------------------------------
  388.   # ● 获取循环的动画 ID
  389.   #--------------------------------------------------------------------------
  390.   def setup_battler_hurt_ani(hurt)
  391.     @hurt = hurt
  392.   end  
  393.   #--------------------------------------------------------------------------
  394.   # ● 获取循环的动画 ID
  395.   #--------------------------------------------------------------------------
  396.   def setup_battler_dead_ani(over)
  397.     @over = over
  398.   end
  399.   #--------------------------------------------------------------------------
  400.   # ● 获取循环的动画 ID
  401.   #--------------------------------------------------------------------------
  402.   def battler_dead_ani
  403.     return @over
  404.   end
  405.   #--------------------------------------------------------------------------
  406.   # ● 获取循环的动画 ID
  407.   #--------------------------------------------------------------------------
  408.   def battler_ani_once
  409.     return @once
  410.   end
  411.   #--------------------------------------------------------------------------
  412.   # ● 获取循环的动画 ID
  413.   #--------------------------------------------------------------------------
  414.   def battler_hurt_ani
  415.     return @hurt
  416.   end
  417.   #..........................................................................
  418. end
  419. class Sprite_Battler < RPG::Sprite
  420.   #..........................................................................
  421.   #--------------------------------------------------------------------------
  422.   # ● 胜利图
  423.   #--------------------------------------------------------------------------
  424.   def win
  425.     if @battler_name != nil and not @battler.hidden and not @battler.dead?
  426.       @battler.setup_battler_ani(@battler_name.split(/★/)[6], 1)
  427.     end
  428.   end
  429.   #..........................................................................
  430.   #--------------------------------------------------------------------------
  431.   # ● 释放
  432.   #--------------------------------------------------------------------------
  433.   def dispose
  434.     if self.bitmap != nil
  435.       self.bitmap.dispose
  436.     end
  437.     super
  438.   end
  439.   #--------------------------------------------------------------------------
  440.   # ● 刷新画面
  441.   #--------------------------------------------------------------------------
  442.   def update
  443.     super
  444.     # 战斗者为 nil 的情况下
  445.     if [url=home.php?mod=space&uid=133701]@battler[/url] == nil
  446.       self.bitmap = nil
  447.       loop_animation(nil)
  448.       return
  449.     end
  450.     # 文件名和色相与当前情况有差异的情况下
  451.     if @battler.battler_name != @battler_name or
  452.        @battler.battler_hue != @battler_hue
  453.       @battler_hue = @battler.battler_hue
  454.       # 获取、设置位图
  455.       @battler_name = @battler.battler_name
  456.       self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  457.       #.......................................................................
  458.       @battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
  459.       #.......................................................................
  460.       @width = bitmap.width
  461.       [url=home.php?mod=space&uid=291977]@height[/url] = bitmap.height
  462.       self.ox = @width / 2
  463.       self.oy = @height
  464.       # 如果是战斗不能或者是隐藏状态就把透明度设置成 0
  465.       if @battler.is_a?(Game_Enemy)
  466.         if @battler.dead? or @battler.hidden
  467.           self.opacity = 0
  468.         end
  469.       end
  470.     end
  471.     # 动画 ID 与当前的情况有差异的情况下
  472.     #.........................................................................
  473.     if @battler.battler_ani != @battler_ani
  474.       @battler_ani = @battler.battler_ani
  475.       loop_animation($data_animations[@battler_ani.to_i])
  476.     end
  477.     #.........................................................................
  478.     # 应该被显示的角色的情况下
  479.     if @battler.is_a?(Game_Actor) and @battler_visible
  480.       # 不是主状态的时候稍稍降低点透明度
  481.       if $game_temp.battle_main_phase
  482.         self.opacity += 3 if self.opacity < 255
  483.       else
  484.         self.opacity -= 3 if self.opacity > 207
  485.       end
  486.     end
  487.     # 明灭
  488.     if @battler.blink
  489.       blink_on
  490.     else
  491.       blink_off
  492.     end
  493.     # 不可见的情况下
  494.     unless @battler_visible
  495.       # 出现 ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  496.       if not @battler.hidden and not @battler.dead? and
  497.          (@battler.damage == nil or @battler.damage_pop)
  498.         if @battler.is_a?(Game_Enemy)
  499.           appear
  500.         else
  501.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
  502.         end
  503.         @battler_visible = true
  504.       end
  505.     end
  506.     # 可见的情况下
  507.     if @battler_visible
  508.       # 逃跑
  509.       if @battler.hidden
  510.         $game_system.se_play($data_system.escape_se)
  511.         escape
  512.         @battler_visible = false
  513.       end
  514.       # 白色闪烁
  515.       if @battler.white_flash
  516.         whiten
  517.         @battler.white_flash = false
  518.       end
  519.       # 动画
  520.       if @battler.animation_id != 0
  521.         animation = $data_animations[@battler.animation_id]
  522.         animation(animation, @battler.animation_hit)
  523.         @battler.animation_id = 0
  524.       end
  525.       # 伤害
  526.       if @battler.damage_pop
  527.         damage(@battler.damage, @battler.critical)
  528.         @battler.damage = nil
  529.         @battler.critical = false
  530.         @battler.damage_pop = false
  531.       end
  532.       # korapusu
  533.       if @battler.damage == nil and @battler.dead?
  534.         #....................................................................
  535.         if @battler.is_a?(Game_Enemy)
  536.           $game_system.se_play($data_system.enemy_collapse_se)
  537.           #collapse
  538.         else
  539.           $game_system.se_play($data_system.actor_collapse_se)
  540.         end
  541.         #....................................................................
  542.         @battler_visible = false
  543.       end
  544.     end
  545.     # 设置活动块的坐标
  546.     self.x = @battler.screen_x
  547.     self.y = @battler.screen_y
  548.     self.z = @battler.screen_z
  549.   end
  550. end
  551. module RPG
  552.   class Sprite < ::Sprite
  553.     def damage(value, critical)
  554.       dispose_damage
  555.       if value.is_a?(Numeric)
  556.         damage_string = value.abs.to_s
  557.       else
  558.         damage_string = value.to_s
  559.       end
  560.       bitmap = Bitmap.new(160, 48)
  561.       #bitmap.font.name = "Arial Black"
  562.       bitmap.font.name = "方正粗活意简体"
  563.       bitmap.font.size = 32
  564.       bitmap.font.color.set(0, 0, 0)
  565.       bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  566.       bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  567.       bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  568.       bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  569.       if value.is_a?(Numeric) and value < 0
  570.         bitmap.font.color.set(176, 255, 144)
  571.       else
  572.         bitmap.font.color.set(255, 255, 255)
  573.       end
  574.       bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  575.       if critical
  576.         bitmap.font.size = 20
  577.         bitmap.font.color.set(0, 0, 0)
  578.         bitmap.draw_text(-1, -1, 160, 20, "会心一击", 1)
  579.         bitmap.draw_text(+1, -1, 160, 20, "会心一击", 1)
  580.         bitmap.draw_text(-1, +1, 160, 20, "会心一击", 1)
  581.         bitmap.draw_text(+1, +1, 160, 20, "会心一击", 1)
  582.         bitmap.font.color.set(255, 255, 255)
  583.         bitmap.draw_text(0, 0, 160, 20, "会心一击", 1)
  584.       end
  585.       @_damage_sprite = ::Sprite.new(self.viewport)
  586.       @_damage_sprite.bitmap = bitmap
  587.       @_damage_sprite.ox = 80
  588.       @_damage_sprite.oy = 20
  589.       @_damage_sprite.x = self.x
  590.       @_damage_sprite.x -= self.bitmap.width/2 if @battler.is_a?(Game_Actor)
  591.       @_damage_sprite.y = self.y - self.oy / 2
  592.       @_damage_sprite.z = 3000
  593.       @_damage_duration = 40
  594.     end
  595.   end
  596. end
  597. module RPG
  598. #--------------------------------------------------------------------------
  599. # ● 常量设定
  600. #--------------------------------------------------------------------------
  601. # 是否显示总伤害
  602. SHOW_TOTAL_DAMAGE = true
  603. # 角色受攻击时是否跳一下
  604. BATTLER_JUMP = true
  605.  
  606. class Sprite < ::Sprite
  607.    #==========================================
  608.    # 修改说明:
  609.    # @flash_shake用来制作挨打时候跳跃
  610.    # @_damage    用来记录每次打击之后弹出数字
  611.    # @_total_damage 记录总伤害
  612.    # @_total_damage_duration 总伤害持续帧
  613.    #==========================================
  614.    #alias 66RPG_rainbow_initialize : initialize
  615.    def initialize(viewport = nil)
  616.      #66RPG_rainbow_initialize(viewport)
  617.      super(viewport)
  618.      @_whiten_duration = 0
  619.      @_appear_duration = 0
  620.      @_escape_duration = 0
  621.      @_collapse_duration = 0
  622.      @_damage_duration = 0
  623.      @_animation_duration = 0
  624.      @_blink = false
  625.      # 挨打时候跳跃
  626.      @flash_shake = 0
  627.      # 伤害记录数组
  628.      @_damage = []
  629.      # 总伤害数字
  630.      @_total_damage = 0
  631.      # 总伤害持续帧
  632.      @_total_damage_duration = 0
  633.      #.........................................................................
  634.      @hits = 0
  635.      #.........................................................................
  636.    end
  637.    def damage(value, critical)
  638.      #.........................................................................
  639.      #清除hit数
  640.      dispose_hit
  641.      #.........................................................................
  642.      if value.is_a?(Numeric)
  643.        damage_string = value.abs.to_s
  644.      else
  645.        damage_string = value.to_s
  646.      end
  647.      bitmap = Bitmap.new(160, 48)
  648.     # bitmap.font.name = "Arial Black"
  649.     bitmap.font.name = "方正粗活意简体"
  650.      bitmap.font.size = 24
  651.      bitmap.font.color.set(0, 0, 0)
  652.      bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  653.      bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  654.      bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  655.      bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  656.      #=======================================
  657.      # 修改:颜色
  658.      #=======================================
  659.      if value.is_a?(Numeric) and value < 0
  660.        bitmap.font.color.set(176, 255, 144)
  661.      else
  662.        bitmap.font.color.set(255, 55, 55)
  663.      end
  664.      bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  665.      if critical
  666.        bitmap.font.size = 20
  667.        bitmap.font.color.set(0, 0, 0)
  668.        bitmap.draw_text(-1, -1, 160, 20, "会心一击", 1)
  669.        bitmap.draw_text(+1, -1, 160, 20, "会心一击", 1)
  670.        bitmap.draw_text(-1, +1, 160, 20, "会心一击", 1)
  671.        bitmap.draw_text(+1, +1, 160, 20, "会心一击", 1)
  672.        bitmap.font.color.set(255, 255, 255)
  673.        bitmap.draw_text(0, 0, 160, 20, "会心一击", 1)
  674.      end
  675.      @_damage_sprite = ::Sprite.new#(self.viewport)
  676.      @_damage_sprite.bitmap = bitmap
  677.      @_damage_sprite.ox = 80
  678.      @_damage_sprite.oy = 20
  679.      @_damage_sprite.x = self.x
  680.      @_damage_sprite.y = self.y - self.oy / 2
  681.      @_damage_sprite.z = 3000
  682.      @_damage_duration = 40
  683.      #=======================================
  684.      # 修改:推入新的伤害
  685.      #=======================================
  686.      @_damage.push([@_damage_sprite,@_damage_duration-10,0, rand(30) - 15, rand(3)])
  687.      # 总伤害处理
  688.      make_total_damage(value)
  689.    end
  690.    #--------------------------------------------------------------------------
  691.    # ● 返回 @hits
  692.    #--------------------------------------------------------------------------
  693.    def get_hit
  694.      return @hits
  695.    end
  696.    #--------------------------------------------------------------------------
  697.    # ● hit数的美化描绘
  698.    #--------------------------------------------------------------------------
  699.    #..........................................................................
  700.    def hit
  701.      # 如果伤害值是数值
  702.      # 转为字符串
  703.      value=@hits
  704.      hits_string = value.to_s
  705.      # 初始化位图
  706.      bitmap = Bitmap.new(320, 64)
  707.    #  bitmap.font.name = "Arial Black"
  708.      bitmap.font.name = "方正粗活意简体"
  709.      bitmap.font.size = 32
  710.      # 分割伤害值字符串
  711.      hits_array = hits_string.scan(/./)
  712.      hits_x = - 36.2#hits_string.size * 18.1 # 81 - hits_string.size * 18.1
  713.      rect_y = 0
  714.      # 循环伤害值字符串
  715.      for char in hits_array
  716.        # 后移一位
  717.        hits_x += 36.2
  718.        number = char.to_i
  719.        # 显示伤害数字
  720.        bitmap.blt(hits_x, 0, RPG::Cache.picture("Numbers"),
  721.        Rect.new(number * 36.2, rect_y, 36.2, 50))
  722.      end
  723.      hits_x += 18.1
  724.      bitmap.blt(hits_x, 0, RPG::Cache.picture("HITS"),
  725.                 Rect.new(0, -21, 90, 50))
  726.      # 伤害值定位
  727.      @_hits_sprite = ::Sprite.new(self.viewport)
  728.      @_hits_sprite.bitmap = bitmap
  729.      @_hits_sprite.x = 560 - hits_string.size * 36.2
  730.      @_hits_sprite.y = 70
  731.      @_hits_sprite.z = 3000
  732.      @_hits_duration = 40
  733.    end
  734.    #..........................................................................
  735.    #--------------------------------------------------------------------------
  736.    # ● 总伤害处理
  737.    #--------------------------------------------------------------------------
  738.    def make_total_damage(value)
  739.      if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
  740.        @_total_damage += value
  741.      else
  742.        return
  743.      end
  744.      bitmap = Bitmap.new(300, 150)
  745.    #  bitmap.font.name = "Arial Black"
  746.      bitmap.font.name = "方正粗活意简体"
  747.      bitmap.font.size = 28
  748.      bitmap.font.color.set(0, 0, 0)
  749.      bitmap.draw_text(+2, 12+2, 160, 36, @_total_damage.abs.to_s, 1)
  750.      if @_total_damage < 0
  751.        bitmap.font.color.set(80, 255, 00)
  752.      else
  753.        bitmap.font.color.set(255, 140, 0)
  754.      end
  755.      bitmap.draw_text(0, 12, 160, 36, @_total_damage.abs.to_s, 1)
  756.      if @_total_damage_sprite.nil?
  757.        @_total_damage_sprite = ::Sprite.new#(self.viewport)
  758.        @_total_damage_sprite.ox = 80
  759.        @_total_damage_sprite.oy = 20
  760.        @_total_damage_sprite.z = 3000
  761.      end
  762.      @_total_damage_sprite.bitmap = bitmap
  763.      @_total_damage_sprite.zoom_x = 1.5
  764.      @_total_damage_sprite.zoom_y = 1.5
  765.      @_total_damage_sprite.x = self.x
  766.      @_total_damage_sprite.y = self.y  - self.oy / 2 - 64
  767.      @_total_damage_sprite.z = 3001
  768.      #.........................................................................
  769.      @_total_damage_duration = 40
  770.      #.........................................................................
  771.      #.........................................................................
  772.      #hit数描绘
  773.      @hits+=1
  774.      hit
  775.      #.........................................................................
  776.    end
  777.    def animation(animation, hit, battler_damage="", battler_critical=false)
  778.      dispose_animation      
  779.      #=======================================
  780.      # 修改:记录伤害和critical
  781.      #=======================================
  782.      @battler_damage = battler_damage
  783.      @battler_critical = battler_critical
  784.      @_animation = animation
  785.      return if @_animation == nil
  786.      @_animation_hit = hit
  787.      @_animation_duration = @_animation.frame_max
  788.      animation_name = @_animation.animation_name
  789.      animation_hue = @_animation.animation_hue
  790.      bitmap = RPG::Cache.animation(animation_name, animation_hue)
  791.      #=======================================
  792.      # 修改:计算总闪光权限值
  793.      #=======================================
  794.      for timing in @_animation.timings
  795.        quanzhong = animation_process_timing(timing, @_animation_hit,true)
  796.        @all_quanzhong += quanzhong
  797.        # 记录最后一次闪光
  798.        @_last_frame = timing.frame if quanzhong != 0
  799.      end
  800.      #.........................................................................
  801.      @last_frame = @_last_frame
  802.      #.........................................................................
  803.      if @@_reference_count.include?(bitmap)
  804.        @@_reference_count[bitmap] += 1
  805.      else
  806.        @@_reference_count[bitmap] = 1
  807.      end
  808.      #=======================================
  809.      # 修改:行动方动画不显示伤害
  810.      #=======================================
  811.      if $scene.is_a?(Scene_Battle)
  812.        if $scene.animation1_id == @battler.animation_id
  813.          @battler_damage = ""
  814.        end
  815.      end
  816.      @_animation_sprites = []
  817.      if @_animation.position != 3 or not @@_animations.include?(animation)
  818.        for i in 0..15
  819.          sprite = ::Sprite.new(self.viewport)
  820.          sprite.bitmap = bitmap
  821.          sprite.visible = false
  822.          @_animation_sprites.push(sprite)
  823.        end
  824.        unless @@_animations.include?(animation)
  825.          @@_animations.push(animation)
  826.        end
  827.      end
  828.      update_animation
  829.    end
  830.    #=======================================
  831.    # 修改:更换清除伤害的算法,以防万一
  832.    #       本内容在脚本中没有使用过
  833.    #=======================================
  834.    def dispose_damage
  835.      for damage in @_damage.reverse
  836.        damage[0].bitmap.dispose
  837.        damage[0].dispose
  838.        @_damage.delete(damage)
  839.      end
  840.      @_total_damage = 0
  841.      @_last_frame = -1
  842.      if @_total_damage_sprite != nil
  843.        @_total_damage_duration = 0
  844.        @_total_damage_sprite.bitmap.dispose
  845.        @_total_damage_sprite.dispose
  846.        @_total_damage_sprite = nil
  847.      end
  848.    end
  849.    #=======================================
  850.    # 清除hit数
  851.    #=======================================
  852.    #...........................................................................
  853.    def dispose_hit
  854.      if @_hits_sprite != nil
  855.        @_hits_sprite.bitmap.dispose
  856.        @_hits_sprite.dispose
  857.        @_hits_sprite = nil
  858.      end
  859.    end
  860.    #...........................................................................
  861.    def dispose_animation
  862.      #=======================================
  863.      # 修改:清除记录的伤害,清除权重记录
  864.      #=======================================
  865.      @battler_damage = nil
  866.      @battler_critical = nil
  867.      @all_quanzhong = 1
  868.      @_total_damage = 0
  869.      @_last_frame = -1
  870.      #.........................................................................
  871.      @hits = 0
  872.      #.........................................................................
  873.      if @_animation_sprites != nil
  874.        sprite = @_animation_sprites[0]
  875.        if sprite != nil
  876.          @@_reference_count[sprite.bitmap] -= 1
  877.          if @@_reference_count[sprite.bitmap] == 0
  878.            sprite.bitmap.dispose
  879.          end
  880.        end
  881.        for sprite in @_animation_sprites
  882.          sprite.dispose
  883.        end
  884.        @_animation_sprites = nil
  885.        @_animation = nil
  886.      end
  887.    end
  888.    def update
  889.      super
  890.      if @_whiten_duration > 0
  891.        @_whiten_duration -= 1
  892.        self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  893.      end
  894.      if @_appear_duration > 0
  895.        @_appear_duration -= 1
  896.        self.opacity = (16 - @_appear_duration) * 16
  897.      end
  898.      if @_escape_duration > 0
  899.        @_escape_duration -= 1
  900.        self.opacity = 256 - (32 - @_escape_duration) * 10
  901.      end
  902.      if @_collapse_duration > 0
  903.        @_collapse_duration -= 1
  904.        self.opacity = 256 - (48 - @_collapse_duration) * 6
  905.      end
  906.      #=======================================
  907.      # 修改:更新算法,更新弹出
  908.      #=======================================
  909.      if @_damage_duration > 0
  910.        @_damage_duration -= 1
  911.        for damage in @_damage
  912.          damage[0].x = self.x + self.viewport.rect.x -
  913.                        self.ox + self.src_rect.width / 2 +
  914.                        (40 - damage[1]) * damage[3] / 10
  915.          damage[0].y -= damage[4]+damage[1]/10
  916.          damage[0].opacity = damage[1]*20
  917.          damage[1] -= 1
  918.          if damage[1]==0
  919.            damage[0].bitmap.dispose
  920.            damage[0].dispose
  921.            @_damage.delete(damage)
  922.            next
  923.          end
  924.        end
  925.      end
  926.      #=======================================
  927.      # 添加:弹出总伤害
  928.      #=======================================
  929.      if @_total_damage_duration > 0
  930.        @_total_damage_duration -= 1
  931.        @_total_damage_sprite.y -= 1 if @_total_damage_duration % 2 == 0
  932.        if @_total_damage_sprite.zoom_x > 1.0
  933.          @_total_damage_sprite.zoom_x -= 0.05
  934.        end
  935.        if @_total_damage_sprite.zoom_y > 1.0
  936.          @_total_damage_sprite.zoom_y -= 0.05
  937.        end
  938.        @_total_damage_sprite.opacity = 256 - (24 - @_total_damage_duration) * 16
  939.        #......................................................................
  940.        if @_total_damage_duration <= 7 and @_total_damage_duration > 0
  941.          @_hits_sprite.opacity -= 32
  942.          @_hits_sprite.x += 1
  943.        end
  944.        #......................................................................
  945.        if @_total_damage_duration <= 0
  946.          #.....................................................................
  947.          dispose_hit
  948.          #.....................................................................
  949.          @_total_damage = 0
  950.          @_total_damage_duration = 0
  951.          @_total_damage_sprite.bitmap.dispose
  952.          @_total_damage_sprite.dispose
  953.          @_total_damage_sprite = nil
  954.        end
  955.      end
  956.      #=======================================
  957.      if @_animation != nil and (Graphics.frame_count % 2 == 0)
  958.        @_animation_duration -= 1
  959.        update_animation
  960.      end
  961.      if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  962.        update_loop_animation
  963.        @_loop_animation_index += 1
  964.        #......................................................................
  965.        @loop_animation_once = 0
  966.        @loop_animation_once = 1 if @once == 1 and @_loop_animation_index == @_loop_animation.frame_max
  967.        #......................................................................
  968.        @_loop_animation_index %= @_loop_animation.frame_max
  969.      end
  970.      if @_blink
  971.        @_blink_count = (@_blink_count + 1) % 32
  972.        if @_blink_count < 16
  973.          alpha = (16 - @_blink_count) * 6
  974.        else
  975.          alpha = (@_blink_count - 16) * 6
  976.        end
  977.        self.color.set(255, 255, 255, alpha)
  978.      end
  979.      @@_animations.clear
  980.    end
  981.    #..........................................................................
  982.    def loop_animation_once
  983.      return @_loop_animation_once
  984.    end
  985.    #..........................................................................
  986.    def update_animation
  987.      if @_animation_duration > 0
  988.        frame_index = @_animation.frame_max - @_animation_duration
  989.        @frame_index = frame_index
  990.        cell_data = @_animation.frames[frame_index].cell_data
  991.        position = @_animation.position
  992.        animation_set_sprites(@_animation_sprites, cell_data, position)
  993.       #################################################################bearrpg
  994.         se_name = RANDSE[rand(RANDSE.size)]#随机抽取数组中的一个音效
  995.         se_name1 = RANDSE1[rand(RANDSE1.size)]
  996.         case @_animation.id#判断动画ID
  997.           when 118#播放118动画的时候执行随机音效
  998.             if frame_index ==0#这里表示第一帧
  999.              Audio.se_play("Audio/SE/"+se_name, 100, 100)
  1000.            end
  1001.           when 134#如果有多个可以自行添加
  1002.             if frame_index ==0#这里表示第一帧
  1003.              Audio.se_play("Audio/SE/"+se_name1, 100, 100)
  1004.             #判断帧数什么的……
  1005.           #播放音效什么的……
  1006.         end
  1007.         end
  1008.         ###################################################################
  1009.        #=======================================
  1010.        # 修改:弹出伤害,权重计算
  1011.        #=======================================
  1012.        for timing in @_animation.timings
  1013.          if timing.frame == frame_index
  1014.            t = 1.0 * animation_process_timing(timing, @_animation_hit)            
  1015.            #p t,"当前权重", @all_quanzhong,"总权重"
  1016.            if @battler_damage.is_a?(Numeric) and t != 0
  1017.              t *= @battler_damage
  1018.              t /= @all_quanzhong
  1019.              #p t,"当前伤害",@battler_damage,"总伤害"
  1020.              t = t.to_i
  1021.              # 最后一次闪光的话,伤害修正
  1022.              if frame_index == @_last_frame
  1023.                @_total_damage = @battler_damage - t
  1024.              end
  1025.              #p t,@battler_damage,@all_quanzhong
  1026.              damage(t,@battler_critical)
  1027.            # 防止重复播放miss
  1028.            elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
  1029.              damage(@battler_damage,@battler_critical)
  1030.            end
  1031.          end
  1032.        end
  1033.      else
  1034.        dispose_animation
  1035.      end
  1036.    end
  1037.    #=======================================
  1038.    # 修改:敌人跳跃的功能 + 添加返回数值
  1039.    #=======================================
  1040.    def update_loop_animation
  1041.      frame_index = @_loop_animation_index
  1042.      cell_data = @_loop_animation.frames[frame_index].cell_data
  1043.      position = @_loop_animation.position
  1044.      #·改·
  1045.      if @wait_count.to_i <= 0
  1046.        @wait_count = 0
  1047.        animation_set_sprites(@_loop_animation_sprites, cell_data, position)
  1048.      else
  1049.        @wait_count -= 1
  1050.        for sprite in @_loop_animation_sprites
  1051.          sprite.visible = false
  1052.        end
  1053.      end
  1054.      if @wait_flash.to_i <= 0
  1055.        @wait_flash = 0
  1056.      else
  1057.        @wait_flash -= 1
  1058.        for sprite in @_loop_animation_sprites
  1059.          sprite.blend_type = 1
  1060.        end
  1061.      end
  1062.      #·改·
  1063.      for timing in @_loop_animation.timings
  1064.        if timing.frame == frame_index
  1065.          animation_process_timing(timing, true)
  1066.        end
  1067.      end
  1068.    end
  1069.    #=======================================
  1070.    # 修改:敌人跳跃的功能 + 添加返回数值
  1071.    #=======================================
  1072.    def loop_animation(animation)
  1073.      return if animation == @_loop_animation
  1074.      dispose_loop_animation
  1075.      @_loop_animation = animation
  1076.      return if @_loop_animation == nil
  1077.      @_loop_animation_index = 0
  1078.      animation_name = @_loop_animation.animation_name
  1079.      animation_hue = @_loop_animation.animation_hue
  1080.      bitmap = RPG::Cache.animation(animation_name, animation_hue)
  1081.      if @@_reference_count.include?(bitmap)
  1082.        @@_reference_count[bitmap] += 1
  1083.      else
  1084.        @@_reference_count[bitmap] = 1
  1085.      end
  1086.      @_loop_animation_sprites = []
  1087.      for i in 0..15
  1088.        sprite = ::Sprite.new
  1089.        sprite.bitmap = bitmap
  1090.        sprite.visible = false
  1091.        @_loop_animation_sprites.push(sprite)
  1092.      end
  1093.      update_loop_animation
  1094.    end
  1095.    #=======================================
  1096.    # 修改:敌人跳跃的功能 + 添加返回数值
  1097.    #=======================================
  1098.     def animation_process_timing(timing, hit,dontflash=false)
  1099.       if (timing.condition == 0) or
  1100.          (timing.condition == 1 and hit == true) or
  1101.          (timing.condition == 2 and hit == false)
  1102.         unless dontflash
  1103.           if timing.se.name != ""
  1104.             se = timing.se
  1105.             Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
  1106.           end
  1107.         end
  1108.         case timing.flash_scope
  1109.         when 1
  1110.           unless dontflash
  1111.             self.flash(timing.flash_color, timing.flash_duration * 2)
  1112.             #....................................................................
  1113.             @wait_flash = timing.flash_duration
  1114.             #....................................................................
  1115.             if @_total_damage >0
  1116.               @flash_shake_switch = true
  1117.               @flash_shake = 10
  1118.             end
  1119.           end
  1120.           return timing.flash_color.alpha * timing.flash_duration
  1121.         when 2
  1122.           unless dontflash
  1123.             if self.viewport != nil
  1124.               self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
  1125.               return timing.flash_color.alpha * timing.flash_duration
  1126.             end
  1127.           end
  1128.         when 3
  1129.           unless dontflash
  1130.             self.flash(nil, timing.flash_duration * 2)
  1131.             #@_loop_animation_count = 1
  1132.             #·改·
  1133.             @wait_count = timing.flash_duration
  1134.             #·改·
  1135.           end
  1136.           return timing.flash_color.alpha * timing.flash_duration
  1137.         end
  1138.       end      
  1139.       return 0
  1140.     end   
  1141. end
  1142. end
  1143. #==============================================================================
  1144. # ■ Sprite_Battler
  1145. #==============================================================================
  1146. class Sprite_Battler < RPG::Sprite
  1147. #--------------------------------------------------------------------------
  1148. # ● 初始化对像
  1149. #    添加跳跃记录
  1150. #--------------------------------------------------------------------------
  1151. def initialize(viewport, battler = nil)
  1152.   super(viewport)
  1153.   @battler = battler
  1154.   @battler_visible = false
  1155.   @flash_shake_switch = true
  1156.   #........................................................................
  1157.   @once = 0
  1158.   @frame_index = -1
  1159.   @last_frame = 0
  1160.   #........................................................................
  1161. end
  1162. #--------------------------------------------------------------------------
  1163. # ● 刷新画面
  1164. #    增添跳跃功能
  1165. #--------------------------------------------------------------------------
  1166. def update
  1167.   super
  1168.   # 战斗者为 nil 的情况下
  1169.   if @battler == nil
  1170.     self.bitmap = nil
  1171.     loop_animation(nil)
  1172.     return
  1173.   end
  1174.   # 文件名和色相与当前情况有差异的情况下
  1175.   if @battler.battler_name != @battler_name or
  1176.      @battler.battler_hue != @battler_hue
  1177.     # 获取、设置位图
  1178.     @battler_name = @battler.battler_name
  1179.     @battler_hue = @battler.battler_hue
  1180.     self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  1181.     #.......................................................................
  1182.     if not @battler.hidden and not @battler.dead?
  1183.       @battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
  1184.     end
  1185.     #.......................................................................
  1186.     @width = bitmap.width
  1187.     [url=home.php?mod=space&uid=291977]@height[/url] = bitmap.height
  1188.     self.ox = @width / 2
  1189.     self.oy = @height
  1190.   end
  1191.   #.......................................................................
  1192.   update_actor_animation
  1193.   update_enemy_animation
  1194.   #.......................................................................
  1195.   # 动画 ID 与当前的情况有差异的情况下
  1196.   #.........................................................................
  1197.   if @battler.is_a?(Game_Enemy)
  1198.     if @once == 1 and @loop_animation_once == 1 and
  1199.        @battler.battler_dead_ani == 1
  1200.       @battler.setup_battler_ani(@battler.battler_name.split(/★/)[5])
  1201.     elsif @once == 1 and @loop_animation_once == 1 and $scene.phase != 5
  1202.       @battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
  1203.     end
  1204.   end
  1205.   if @battler.is_a?(Game_Actor)
  1206.     ####################################################################
  1207.     if @once == 1 and @loop_animation_once == 1 and $scene.phase != 5 and
  1208.        @battler.battler_dead_ani == 1 and @battler.dead?
  1209.       @battler.setup_battler_ani(@battler.battler_name.split(/★/)[5])
  1210.     #######################################################################
  1211.     elsif @once == 1 and @loop_animation_once == 1 and $scene.phase != 5
  1212.       @battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
  1213.       #################################################################
  1214.       $fangyu = 0
  1215.       @battler.setup_battler_dead_ani(0)
  1216.       ########################################################
  1217.     elsif @once == 1 and @loop_animation_once == 1 and $scene.phase == 5 and
  1218.           not @battler.dead?
  1219.       @battler.setup_battler_ani(@battler.battler_name.split(/★/)[7])
  1220.       ######################################################
  1221.       $fangyu = 0
  1222.       @battler.setup_battler_dead_ani(0)
  1223.       ######################################################
  1224.     end
  1225.   end
  1226.   if @battler.battler_ani != @battler_ani
  1227.     @battler_ani = @battler.battler_ani
  1228.     @once = @battler.battler_ani_once
  1229.     loop_animation($data_animations[@battler_ani.to_i])
  1230.   end
  1231.   #.........................................................................
  1232.   # 应该被显示的角色的情况下
  1233. #if @battler.is_a?(Game_Actor) and @battler_visible
  1234.     # 不是主状态的时候稍稍降低点透明度
  1235.   #  if $game_temp.battle_main_phase
  1236.   #    self.opacity += 10 if self.opacity < 255
  1237.   #  else
  1238.   #    self.opacity -= 10 if self.opacity > 207
  1239. #   end
  1240. # end
  1241.   # 明灭
  1242.   if @battler.blink
  1243.     blink_on
  1244.   else
  1245.     blink_off
  1246.   end
  1247.   # 不可见的情况下
  1248.   unless @battler_visible
  1249.     # 出现
  1250.     if not @battler.hidden and not @battler.dead? and
  1251.        (@battler.damage == nil or @battler.damage_pop)
  1252.       #.......................................................................
  1253.       if @battler.is_a?(Game_Enemy)
  1254.         @battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
  1255.         #appear
  1256.       else
  1257.         @battler.setup_battler_ani(@battler.battler_name.split(/★/)[1])
  1258.       end
  1259.       #.......................................................................
  1260.       @battler_visible = true
  1261.     end
  1262.   end
  1263.   # 可见的情况下
  1264.   if @battler_visible
  1265.     # 逃跑
  1266.     if @battler.hidden
  1267.       $game_system.se_play($data_system.escape_se)
  1268.       escape
  1269.       @battler_visible = false
  1270.     end
  1271.     # 白色闪烁
  1272.     if @battler.white_flash
  1273.       whiten
  1274.       @battler.white_flash = false
  1275.     end
  1276.     # 动画
  1277.     if @battler.animation_id != 0
  1278.       animation = $data_animations[@battler.animation_id]
  1279.       animation(animation, @battler.animation_hit,@battler.damage, @battler.critical)
  1280.       @battler.animation_id = 0
  1281.     end
  1282.     # 伤害
  1283.     if @battler.damage_pop
  1284.       @battler.damage = nil
  1285.       @battler.critical = false
  1286.       @battler.damage_pop = false
  1287.     end
  1288.     # korapusu
  1289.     if @battler.damage == nil and @battler.dead?
  1290.       if @battler.is_a?(Game_Enemy)
  1291.         if @battler.battler_dead_ani != 1
  1292.           #p "Battler Death Error"
  1293.           $game_system.se_play($data_system.enemy_collapse_se)
  1294.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[4], 1)
  1295.           @battler.setup_battler_dead_ani(1)
  1296.         end
  1297.         #.....................................................................
  1298.         collapse
  1299.         #.....................................................................
  1300.       else
  1301.         #.....................................................................
  1302.         if @battler.battler_dead_ani != 1
  1303.           #p "Battler Death Error"
  1304.           $game_system.se_play($data_system.enemy_collapse_se)
  1305.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[4], 1)
  1306.           @battler.setup_battler_dead_ani(1)
  1307.         end
  1308.         #.....................................................................
  1309.       end
  1310.       @battler_visible = false
  1311.     end
  1312.   end
  1313.   # 设置活动块的坐标
  1314.   if @flash_shake_switch == true
  1315.     self.x = @battler.screen_x
  1316.     self.y = @battler.screen_y
  1317.     self.z = @battler.screen_z
  1318.     @flash_shake_switch = false
  1319.   end
  1320.   if @flash_shake != 0 and @battler.damage != nil and RPG::BATTLER_JUMP
  1321.     if @battler.is_a?(Game_Enemy)
  1322.       case @flash_shake
  1323.       when 9..10
  1324.         self.x -=4
  1325.         self.y -=4
  1326.         self.z = @battler.screen_z
  1327.       when 6..8
  1328.         self.x -=2
  1329.         self.y -=2
  1330.         self.z = @battler.screen_z
  1331.       when 3..5
  1332.         self.x +=2
  1333.         self.y +=2
  1334.         self.z = @battler.screen_z
  1335.       when 1..2
  1336.         self.x +=4
  1337.         self.y +=4
  1338.         self.z = @battler.screen_z
  1339.       end
  1340.     end
  1341.     if @battler.is_a?(Game_Actor)
  1342.       case @flash_shake
  1343.       when 9..10
  1344.         self.x +=4
  1345.         self.y +=4
  1346.         self.z = @battler.screen_z
  1347.       when 6..8
  1348.         self.x +=2
  1349.         self.y +=2
  1350.         self.z = @battler.screen_z
  1351.       when 3..5
  1352.         self.x -=2
  1353.         self.y -=2
  1354.         self.z = @battler.screen_z
  1355.       when 1..2
  1356.         self.x -=4
  1357.         self.y -=4
  1358.         self.z = @battler.screen_z
  1359.       end
  1360.     end
  1361.     @flash_shake -= 1
  1362.   end
  1363. end
  1364. end
  1365.  
  1366. #==============================================================================
  1367. # ■ Scene_Battle
  1368. #------------------------------------------------------------------------------
  1369. #  处理战斗画面的类。
  1370. #==============================================================================
  1371.  
  1372. class Scene_Battle
  1373. #--------------------------------------------------------------------------
  1374. # ● 定义实例变量
  1375. #--------------------------------------------------------------------------
  1376. attr_reader   :animation1_id                    # 行动方动画ID
  1377. end
  1378. class Sprite_Battler < RPG::Sprite
  1379.   #--------------------------------------------------------------------------
  1380.   # ● 处理角色动作
  1381.   #--------------------------------------------------------------------------
  1382.   def update_actor_animation
  1383.     if @battler.is_a?(Game_Actor)
  1384.       if @battler.show_damage_value != nil
  1385.         self.damage(@battler.show_damage_value, false)
  1386.         @battler.show_damage(nil)
  1387.         @battler.setup_battler_ani(@battler.battler_name.split(/★/)[3], 1)
  1388.         @battler.setup_battler_hurt_ani(1)
  1389.       end
  1390.       if @battler.current_action.kind == 0 and @battler.current_action.basic == 1
  1391.         ######################################################################
  1392.         @battler.setup_battler_ani(@battler.battler_name.split(/★/)[2], 1)
  1393.           @battler.setup_battler_hurt_ani(1)
  1394.         ####################################################################
  1395.       else
  1396.         if @hits == 1 and not @battler.dead? and @battler.battler_hurt_ani != 1 and @battler.damage.is_a?(Numeric) and @battler.damage > 0 and $fangyu != 1
  1397.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[3], 1)
  1398.           @battler.setup_battler_hurt_ani(1)
  1399.         ########################################################################
  1400.         elsif @hits == 1 and not @battler.dead? and @battler.battler_hurt_ani != 1 and @battler.damage.is_a?(Numeric) and @battler.damage > 0 and $fangyu == 1
  1401.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[2], 1)
  1402.           @battler.setup_battler_hurt_ani(1)
  1403.           #################################################################
  1404.         elsif @frame_index == @last_frame and @battler.dead? and @battler.battler_dead_ani != 1
  1405.           for actor in $game_party.actors
  1406.             if @battler != actor
  1407.               #actor.add_state(55)
  1408.             end
  1409.           end
  1410.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[4], 1)
  1411.           @battler.setup_battler_dead_ani(1)
  1412.         end
  1413.       end
  1414.     end
  1415.   end
  1416.   #--------------------------------------------------------------------------
  1417.   # ● 处理敌人动作
  1418.   #--------------------------------------------------------------------------
  1419.   def update_enemy_animation
  1420.     if @battler.is_a?(Game_Enemy)
  1421.       if @battler.show_damage_value != nil
  1422.         self.damage(@battler.show_damage_value, false)
  1423.         @battler.show_damage(nil)
  1424.         @battler.setup_battler_ani(@battler.battler_name.split(/★/)[3], 1)
  1425.         @battler.setup_battler_hurt_ani(1)
  1426.       end
  1427.       if @battler.current_action.kind == 0 and @battler.current_action.basic == 1
  1428.       else
  1429.         if @hits == 1 and not @battler.dead? and @battler.battler_hurt_ani != 1 and @battler.damage.is_a?(Numeric) and @battler.damage > 0
  1430.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[3], 1)
  1431.           @battler.setup_battler_hurt_ani(1)
  1432.         elsif @frame_index == @last_frame and @battler.dead? and @battler.battler_dead_ani != 1
  1433.           @battler.setup_battler_ani(@battler.battler_name.split(/★/)[4], 1)
  1434.           @battler.setup_battler_dead_ani(1)
  1435.           collapse
  1436.         end
  1437.       end
  1438.     end
  1439.   end
  1440. end
  
大家好,这里是晨露的说。请多多指教。
刚入门RM软件制作,请大家多多帮助我哦。
落雪君的欢乐像素教程,欢迎查阅。

回复 支持 反对

使用道具 举报

Lv2.观梦者 (暗夜天使)

万兽

梦石
0
星屑
597
在线时间
2271 小时
注册时间
2006-11-4
帖子
4868

贵宾

8
发表于 2013-8-28 23:24:32 | 只看该作者
俺用你这段脚本测试没问题哟,是不是你取消了RTP?或者是还有其它类修改过def update_animation

点评

范例已经上传了,估计是全动画的问题,不知道怎么改  发表于 2013-8-29 19:04
回复 支持 反对

使用道具 举报

Lv5.捕梦者 (版主)

梦石
20
星屑
1840
在线时间
6925 小时
注册时间
2012-12-14
帖子
11485

短篇十战斗者组别冠军开拓者贵宾短篇九勇士组亚军

9
 楼主| 发表于 2013-8-28 23:30:41 | 只看该作者
弗雷德 发表于 2013-8-28 23:24
俺用你这段脚本测试没问题哟,是不是你取消了RTP?或者是还有其它类修改过def update_animation ...

嗯,的确的说。但是我的问题是战斗中无法播放随机音效

点评

俺这边测试战斗也是有效果的,你再全局搜索一下def update_animation ,看看有没有其它类。 不行的话就上传一下范例吧。  发表于 2013-8-29 03:02
大家好,这里是晨露的说。请多多指教。
刚入门RM软件制作,请大家多多帮助我哦。
落雪君的欢乐像素教程,欢迎查阅。

回复 支持 反对

使用道具 举报

Lv5.捕梦者 (版主)

梦石
20
星屑
1840
在线时间
6925 小时
注册时间
2012-12-14
帖子
11485

短篇十战斗者组别冠军开拓者贵宾短篇九勇士组亚军

10
 楼主| 发表于 2013-8-29 19:04:12 | 只看该作者
范例附上吧
胜利的动画无法随机播放SE,熊叔叔帮助我看看吧
Project8.rar (422.42 KB, 下载次数: 20)
大家好,这里是晨露的说。请多多指教。
刚入门RM软件制作,请大家多多帮助我哦。
落雪君的欢乐像素教程,欢迎查阅。

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-6-19 18:36

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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