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

Project1

 找回密码
 注册会员
搜索
查看: 3694|回复: 9

[已经解决] 请教地图显示伤害如何显示文字?

[复制链接]

Lv1.梦旅人

井蓝

梦石
0
星屑
58
在线时间
351 小时
注册时间
2011-1-14
帖子
277
发表于 2012-5-16 19:52:35 | 显示全部楼层 |阅读模式
本帖最后由 帕克 于 2012-5-16 20:04 编辑

我用了地图显示伤害脚本,请教如何用这个脚本显示出文字?
我在事件脚本的语句中用了"+" + 10
结果出现错误。

发现XAS自有的显示伤害脚本没有任何问题,也可以用上法显示文字。但XAS捆绑脚本太多,请教如何用现有的地图显示伤害脚本改成可以用" "引号调用文字输出?
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================
  4. #
  5. # 使用方法:
  6. #
  7. # ★、对角色显示伤害,如下3步:
  8. #
  9. # 1、设置伤害内容:$game_player.damage = 数值
  10. #    注意:如果数值是负数,就变成补血的颜色了。
  11. #
  12. # 2、设置是否会心一击:$game_player.critical = true/false
  13. #    如果不是会心一击,就不用这一步了
  14. #
  15. # 3、释放伤害:$game_player.damage_pop = true
  16. #
  17. #
  18. # ★、对普通NPC和事件进行伤害,类似的3步:
  19. #
  20. # 1、设置伤害内容:$game_map.events[事件编号].damage = 数值
  21. #
  22. # 2、设置是否会心一击:$game_map.events[事件编号].critical = true/false
  23. #
  24. # 3、释放伤害:$game_map.events[事件编号].damage_pop = true
  25. #
  26. # 注意,事件编号是事件的ID号,如果目标是“本事件”,那么在事件编号输入@event_id
  27. #
  28. #------------------------------------------------------------------------------
  29. # 预祝有人能早日做出华丽的ARPG来,别忘了到网站发布哦~
  30. #------------------------------------------------------------------------------
  31. class Sprite_Character < RPG::Sprite
  32.   alias carol3_66RPG_damage_pop_update update
  33.   def update
  34.     carol3_66RPG_damage_pop_update
  35.     if @character.damage_pop
  36.       damage(@character.damage, @character.critical)
  37.       @character.damage = nil
  38.       @character.critical = false
  39.       @character.damage_pop = false
  40.     end
  41.     #------------------------------
  42.     # 动画 ID 与当前的情况有差异的情况下
  43. #~    if @character.damage == nil and
  44. #~       @character.state_animation_id != @state_animation_id
  45. #~      @state_animation_id = @character.state_animation_id
  46. #~      loop_animation($data_animations[@state_animation_id])
  47. #~    end
  48.    
  49.     #collapse
  50.     # 明灭
  51.     if @character.blink
  52.       blink_on
  53.     else
  54.       blink_off
  55.     end
  56.     # 白色闪烁
  57.     if @character.white_flash
  58.       whiten
  59.       @character.white_flash = false
  60.     end
  61.     # 死亡
  62.     if @character.dead
  63.       collapse
  64.       @character.dead = false
  65.     end
  66.     #------------------------------
  67.   end  
  68. end
  69. class Game_Character
  70.   attr_accessor :damage_pop
  71.   attr_accessor :damage
  72.   attr_accessor :critical
  73.   attr_accessor :white_flash              # 白色屏幕闪烁标志
  74.   attr_accessor :blink                    # 闪烁标志
  75.   attr_accessor :dead                     # 死亡消失标志
  76. #~  attr_accessor :state_animation_id       # 状态动画ID
  77.   alias carol3_66RPG_damage_pop_initialize initialize
  78.   def initialize
  79.     @damage_pop = false
  80.     @damage = nil
  81.     @critical = false
  82.     carol3_66RPG_damage_pop_initialize
  83.     @white_flash = false
  84.     @blink = false
  85.     @dead = false
  86.   end
  87. #~  def state_animation_id
  88. #~    return @character.state_animation_id
  89. #~  end
  90. end

  91. #==============================================================================
  92. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  93. #==============================================================================
复制代码

Lv1.梦旅人

梦·贤者

梦石
0
星屑
50
在线时间
1141 小时
注册时间
2007-12-15
帖子
4100
发表于 2012-5-16 20:19:00 | 显示全部楼层
默认可以是字符串,例如
$game_player.damage = "+10"

但不能是"+"+10,这个语法就是有问题的,字符串是不能和整数进行+运算的
http://rpg.blue/home.php?mod=space&uid=34951&do=blog&id=12799
回复

使用道具 举报

Lv1.梦旅人

井蓝

梦石
0
星屑
58
在线时间
351 小时
注册时间
2011-1-14
帖子
277
 楼主| 发表于 2012-5-16 20:22:46 | 显示全部楼层
tommay 发表于 2012-5-16 20:19
默认可以是字符串,例如
$game_player.damage = "+10"

若是以此种方式显示的话,结果是什么都显示不出来。
其实我希望的是:
$game_player.damage = "你好" + 10
回复

使用道具 举报

Lv1.梦旅人

梦·贤者

梦石
0
星屑
50
在线时间
1141 小时
注册时间
2007-12-15
帖子
4100
发表于 2012-5-16 20:27:34 | 显示全部楼层
本帖最后由 tommay 于 2012-5-16 20:27 编辑
帕克 发表于 2012-5-16 20:22
若是以此种方式显示的话,结果是什么都显示不出来。
其实我希望的是:
$game_player.damage = "你好" + 1 ...


你没好好看说明吗?需要damage_pop的
$game_player.damage = “你好10”
$game_player.damage_pop = true
http://rpg.blue/home.php?mod=space&uid=34951&do=blog&id=12799
回复

使用道具 举报

Lv3.寻梦者

双子人

梦石
0
星屑
3165
在线时间
3616 小时
注册时间
2009-4-4
帖子
4154

开拓者

发表于 2012-5-16 21:11:12 | 显示全部楼层
本帖最后由 hys111111 于 2012-5-16 21:12 编辑
  1. $game_player.damage = “你好" + 10.to_s
复制代码
注意,要返回字符串.to_s,包括变量也是一样

另外注意:damage_pop 还需要释放
回复

使用道具 举报

Lv1.梦旅人

井蓝

梦石
0
星屑
58
在线时间
351 小时
注册时间
2011-1-14
帖子
277
 楼主| 发表于 2012-5-16 21:15:17 | 显示全部楼层
本帖最后由 帕克 于 2012-5-16 21:15 编辑
hys111111 发表于 2012-5-16 21:11
注意,要返回字符串.to_s,包括变量也是一样

另外注意:damage_pop 还需要释放 ...


跟2楼一样,地图没有任何变化,没有显示数字也没有显示文字
释放我有加
回复

使用道具 举报

Lv3.寻梦者

双子人

梦石
0
星屑
3165
在线时间
3616 小时
注册时间
2009-4-4
帖子
4154

开拓者

发表于 2012-5-16 21:26:10 | 显示全部楼层
本帖最后由 hys111111 于 2012-5-17 12:35 编辑
帕克 发表于 2012-5-16 21:15
跟2楼一样,地图没有任何变化,没有显示数字也没有显示文字
释放我有加 ...


我明白了,
解决方法1:
检查是否装了Arial Black这种字体

解决方法2:
添加插件
插件调用的方法:
$game_player.damage = 10
$cname = "早上好"
插件脚本:

  1. module RPG
  2.   class Sprite < ::Sprite
  3.     def damage(value, critical)
  4.       $cname = "CRITICAL" if $cname == nil
  5.       dispose_damage
  6.       if value.is_a?(Numeric)
  7.         damage_string = value.abs.to_s
  8.       else
  9.         damage_string = value.to_s
  10.       end
  11.       bitmap = Bitmap.new(160, 48)
  12.       bitmap.font.name = "Arial Black"
  13.       bitmap.font.size = 32
  14.       bitmap.font.color.set(0, 0, 0)
  15.       bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  16.       bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  17.       bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  18.       bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  19.       if value.is_a?(Numeric) and value < 0
  20.         bitmap.font.color.set(176, 255, 144)
  21.       else
  22.         bitmap.font.color.set(255, 255, 255)
  23.       end
  24.       bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  25.       if critical
  26.         bitmap.font.size = 20
  27.         bitmap.font.color.set(0, 0, 0)
  28.         bitmap.draw_text(-1, -1, 160, 20, $cname.to_s, 1)
  29.         bitmap.draw_text(+1, -1, 160, 20, $cname.to_s, 1)
  30.         bitmap.draw_text(-1, +1, 160, 20, $cname.to_s, 1)
  31.         bitmap.draw_text(+1, +1, 160, 20, $cname.to_s, 1)
  32.         bitmap.font.color.set(255, 255, 255)
  33.         bitmap.draw_text(0, 0, 160, 20, $cname.to_s, 1)
  34.       end
  35.       @_damage_sprite = ::Sprite.new(self.viewport)
  36.       @_damage_sprite.bitmap = bitmap
  37.       @_damage_sprite.ox = 80
  38.       @_damage_sprite.oy = 20
  39.       @_damage_sprite.x = self.x
  40.       @_damage_sprite.y = self.y - self.oy / 2
  41.       @_damage_sprite.z = 3000
  42.       @_damage_duration = 40
  43.       $cname = "CRITICAL"
  44.     end
  45.   end
  46. end
复制代码
另外,XAS的伤害很洗脑的,伤害的数字是图片来到的

点评

测试的时候我就改成了黑体,没有用。我家有装黑体  发表于 2012-5-17 12:51
回复

使用道具 举报

Lv1.梦旅人

井蓝

梦石
0
星屑
58
在线时间
351 小时
注册时间
2011-1-14
帖子
277
 楼主| 发表于 2012-5-17 12:19:52 | 显示全部楼层
hys111111 发表于 2012-5-16 21:26
我明白了,
解决方法1:
检查是否装了Arial Black这种字体

只能显示10出来,不能显示文字

顺便说一下,我用了彩虹神剑,伤害美化显示
就算把彩虹神剑去掉也没用

点评

12行Arial Black改为黑体试试  发表于 2012-5-17 12:35
好诡异,应该不是字体的问题。楼主要不你上传下工程吧。  发表于 2012-5-17 12:26
回复

使用道具 举报

Lv3.寻梦者

双子人

梦石
0
星屑
3165
在线时间
3616 小时
注册时间
2009-4-4
帖子
4154

开拓者

发表于 2012-5-17 12:58:59 | 显示全部楼层
本帖最后由 hys111111 于 2012-5-17 13:00 编辑
帕克 发表于 2012-5-17 12:19
只能显示10出来,不能显示文字

顺便说一下,我用了彩虹神剑,伤害美化显示
  1. class Sprite_Character < RPG::Sprite
  2.   alias carol3_66RPG_damage_pop_update update
  3.   def update
  4.     carol3_66RPG_damage_pop_update
  5.     if @character.damage_pop
  6.       damage(@character.damage, @character.critical)
  7.       @character.damage = nil
  8.       @character.critical = false
  9.       @character.damage_pop = false
  10.     end
  11.   end  
  12. end
  13. class Game_Character
  14.   attr_accessor :damage_pop
  15.   attr_accessor :damage
  16.   attr_accessor :critical
  17.   alias carol3_66RPG_damage_pop_initialize initialize
  18.   def initialize
  19.     @damage_pop = false
  20.     @damage = 0
  21.     @critical = false
  22.     carol3_66RPG_damage_pop_initialize
  23.   end
  24. end
  25. #    ■本脚本已由Defanive修改,适合于魔塔样板3224和3702

  26. $cname="CriTiCal"
  27. module RPG
  28.   class Sprite < ::Sprite
  29.     def damage(value, critical)
  30.       dispose_damage
  31.       if value.is_a?(Numeric)
  32.         damage_string = value.abs.to_s
  33.       else
  34.         damage_string = value.to_s
  35.       end
  36.       bitmap = Bitmap.new(160, 48)
  37.       bitmap.font.name = "Arial Black"
  38.       if value.is_a?(Numeric) and value < 0
  39.         damage_string = "+" + damage_string
  40.       else
  41.       end
  42.       if critical
  43.         bitmap.font.size = 32
  44.         bitmap.font.color.set(180, 0, 0)
  45.         if $smod == 1
  46.           bitmap.font.color.set(0, 150, 0)
  47.         end
  48.         bitmap.draw_text(-1, -1, 160, 32, $cname, 1)
  49.         bitmap.draw_text(+1, -1, 160, 32, $cname, 1)
  50.         bitmap.draw_text(-1, +1, 160, 32, $cname, 1)
  51.         bitmap.draw_text(+1, +1, 160, 32, $cname, 1)
  52.         bitmap.font.color.set(255, 0, 0)
  53.         if $smod == 1
  54.           bitmap.font.color.set(0, 255, 0)
  55.         end
  56.         bitmap.draw_text(0, 0, 160, 32, $cname, 1)
  57.         @norx=52
  58.       else
  59.         @norx=32        
  60.       end
  61.       bitmap.font.size = 30
  62.       bitmap.font.color.set(180, 0, 0)
  63.       if value.is_a?(Numeric) and value < 0
  64.         bitmap.font.color.set(0, 150, 0)
  65.       end
  66.       bitmap.draw_text(-1, 12-1, 160, @norx, damage_string, 1)
  67.       bitmap.draw_text(+1, 12-1, 160, @norx, damage_string, 1)
  68.       bitmap.draw_text(-1, 12+1, 160, @norx, damage_string, 1)
  69.       bitmap.draw_text(+1, 12+1, 160, @norx, damage_string, 1)
  70.       bitmap.font.color.set(255, 0, 0)
  71.       if value.is_a?(Numeric) and value < 0
  72.         bitmap.font.color.set(0, 255, 0)
  73.       end
  74.       bitmap.draw_text(0, 12, 160, @norx, damage_string, 1)
  75.       @_damage_sprite = ::Sprite.new(self.viewport)
  76.       @_damage_sprite.bitmap = bitmap
  77.       @_damage_sprite.ox = 80
  78.       @_damage_sprite.oy = 20
  79.       @_damage_sprite.x = self.x
  80.       @_damage_sprite.y = self.y - self.oy / 2
  81.       @_damage_sprite.z = 3000
  82.       @_damage_duration = 40
  83.       $cname="CriTiCal"
  84.       $smod=0
  85.     end
  86.   end
  87. end

复制代码
地图显示伤害和伤害美化的结合体
但是原先的脚本没有CriTiCal吧

点评

= =彩虹神剑得伤害用的是Graphics\Pictures\Damage.png  发表于 2012-5-17 13:48
可以做到数字显示为彩虹神剑的图片,文字则用RM默认的输入吗?  发表于 2012-5-17 13:27
回复

使用道具 举报

Lv1.梦旅人

井蓝

梦石
0
星屑
58
在线时间
351 小时
注册时间
2011-1-14
帖子
277
 楼主| 发表于 2012-5-17 13:18:43 | 显示全部楼层
本帖最后由 帕克 于 2012-5-17 13:50 编辑
hys111111 发表于 2012-5-17 12:58
地图显示伤害和伤害美化的结合体
但是原先的脚本没有CriTiCal吧


好吧,脚本已经可以利用
$game_map.events[1].damage="增加+10"
$game_map.events[1].damage_pop = true
该语句进行输出了

但是我原先做的是
$game_map.events[1].damage=$game_variables[10]
$game_map.events[1].damage_pop = true

结果现在不能显示变量了0.0


再贴一下我的彩虹神剑的脚本
  1. =begin
  2. ==============================================================================

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

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

  5. 彩虹神剑 -柳柳

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

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

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

  16. v1.0c -柳柳
  17. ? ? ?

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

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

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

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

  32. module RPG
  33. #--------------------------------------------------------------------------
  34. # ● 常量设定
  35. #--------------------------------------------------------------------------
  36. # 是否显示总伤害
  37. SHOW_TOTAL_DAMAGE = true
  38. # 角色受攻击时是否跳一下
  39. BATTLER_JUMP = false
  40. # 连续伤害的动画ID
  41. SLIP_DAMAGE_ANIMATION_ID = 10

  42. class Sprite < ::Sprite
  43.    #==========================================
  44.    # 修改说明:
  45.    # @flash_shake用来制作挨打时候跳跃
  46.    # @_damage    用来记录每次打击之后弹出数字
  47.    # @_total_damage 记录总伤害
  48.    # @_total_damage_duration 总伤害持续帧
  49.    #==========================================
  50.    #alias 66RPG_rainbow_initialize : initialize
  51.    
  52.    def initialize(viewport = nil)
  53.      #66RPG_rainbow_initialize(viewport)
  54.      super(viewport)
  55.      @_whiten_duration = 0
  56.      @_appear_duration = 0
  57.      @_escape_duration = 0
  58.      @_collapse_duration = 0
  59.      @_damage_duration = 0
  60.      @_animation_duration = 0
  61.      @_blink = false
  62.      # 挨打时候跳跃
  63.      @flash_shake = 0
  64.      # 伤害记录数组
  65.      @_damage = []
  66.      # 总伤害数字
  67.      @_total_damage = 0
  68.      # 总伤害持续帧
  69.      @_total_damage_duration = 0
  70.      #记录已经发生的伤害的变量★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  71.      @p_dam=0
  72.      @hits=0
  73.    end
  74. #美化的伤害处理★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  75. def damage(value, critical)
  76.       # 释放伤害,效果是伤害数字快速消失,觉得不如不消失好看......
  77.       #dispose_damage
  78.       #清除hit数
  79.       dispose_hit
  80.       # 如果伤害值是数值
  81.       if value.is_a?(Numeric)
  82.         # 绝对值转为字符串
  83.         damage_string = value.abs.to_s
  84.       else
  85.         # 转为字符串
  86.         damage_string = value.to_s
  87.       end
  88.       # 初始化位图
  89.       bitmap = Bitmap.new(162, 64)
  90.       bitmap.font.name = ["黑体","华文行楷", "宋体"]
  91.       bitmap.font.size = 32
  92.       # 伤害值是数值的情况下
  93.       if value.is_a?(Numeric)
  94.         # 分割伤害值字符串
  95.         damage_array = damage_string.scan(/./)
  96.         damage_x = 81 - damage_string.size * 9
  97.         # 伤害值为负的情况下
  98.         if value < 0
  99.           # 调用回复数字表
  100.           rect_y = 32
  101.         else
  102.           # 调用伤害数字表
  103.           rect_y = 0
  104.         end
  105.         # 循环伤害值字符串
  106.         for char in damage_array
  107.           number = char.to_i
  108.           # 显示伤害数字
  109.           bitmap.blt(damage_x, 32, RPG::Cache.picture("Damage"),
  110.           Rect.new(number * 18, rect_y, 18, 32))
  111.           # 后移一位
  112.           damage_x += 18
  113.         end
  114.       # 伤害值不是数值的情况
  115.       else
  116.          if value == "miss"
  117.           # 显示未击中图画
  118.           bitmap.blt(36, 28, RPG::Cache.picture("Damage"), Rect.new(90, 64, 90, 32))
  119.         end
  120.       end
  121.       # 会心一击标志打开的情况,
  122.       if critical
  123.         # 显示会心一击图画
  124.         bitmap.blt(36, 0, RPG::Cache.picture("Damage"), Rect.new(0, 64, 90, 32))
  125.       end
  126.       # 伤害值定位
  127.       @_damage_sprite = ::Sprite.new(self.viewport)
  128.       @_damage_sprite.bitmap = bitmap
  129.       @_damage_sprite.ox = 81
  130.       @_damage_sprite.oy = 20
  131.       @_damage_sprite.x = self.x
  132.       @_damage_sprite.y = self.y - self.oy / 2
  133.       @_damage_sprite.z = 3000
  134.       @_damage_duration = 40
  135.       @_damage.push([@_damage_sprite,@_damage_duration-10,0, rand(30) - 15, rand(3)])
  136.       make_total_damage(value)  
  137.     end

  138. #   ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  139. # hit数的美化描绘
  140.     def hit

  141.       # 如果伤害值是数值
  142.       # 转为字符串
  143.       value=@hits
  144.         hits_string = value.to_s
  145.       # 初始化位图
  146.        bitmap = Bitmap.new(320, 64)
  147.        bitmap.font.name = "Arial Black"
  148.        bitmap.font.size = 32
  149.        # 分割伤害值字符串
  150.         hits_array = hits_string.scan(/./)
  151.         hits_x = 81 - hits_string.size * 18.1
  152.           rect_y = 0
  153.         # 循环伤害值字符串
  154.         for char in hits_array
  155.           number = char.to_i
  156.           # 显示伤害数字
  157.           bitmap.blt(hits_x, 0, RPG::Cache.picture("Number"),
  158.           Rect.new(number * 36.2, rect_y, 36.2, 50))
  159.           # 后移一位
  160.           hits_x += 36.2
  161.         end
  162.         bitmap.blt(hits_x, 0, RPG::Cache.picture("HITS"),
  163.         Rect.new(0, -21, 90, 50))

  164.       # 伤害值定位
  165.       @_hits_sprite = ::Sprite.new(self.viewport)
  166.       @_hits_sprite.bitmap = bitmap
  167.       @_hits_sprite.ox = 81
  168.       @_hits_sprite.oy = 20
  169.       @_hits_sprite.x = 300
  170.       @_hits_sprite.y = 20
  171.       @_hits_sprite.z = 3000
  172.       @_hits_duration = 40
  173.     end
  174. #--------------------------------------------------------------------------
  175.    # ● 总伤害处理
  176.    #--------------------------------------------------------------------------
  177.    def make_total_damage(value)
  178.      if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
  179.        @_total_damage += value
  180.         # 绝对值转为字符串
  181.         damage_string = @_total_damage.abs.to_s
  182.       else
  183.         return
  184.       end
  185.       # 初始化位图
  186.       bitmap = Bitmap.new(300, 150)
  187.       bitmap.font.name = "Arial Black"
  188.       bitmap.font.size = 32
  189.       # 伤害值是数值的情况下
  190.       if value.is_a?(Numeric)
  191.         # 分割伤害值字符串
  192.         damage_array = damage_string.scan(/./)
  193.         damage_x = 40 - damage_string.size * 9
  194.         # 伤害值为负的情况下
  195.           if value < 0
  196.             name="Number3"

  197.         else
  198.           # 调用伤害数字表
  199.             name="Number2"

  200.         end


  201.         # 循环伤害值字符串
  202.         for char in damage_array
  203.           number = char.to_i
  204.           # 显示伤害数字
  205.           bitmap.blt(damage_x, 0, RPG::Cache.picture(name),
  206.           Rect.new(number * 36.2, 0, 36.2, 50))
  207.           # 后移一位
  208.           damage_x += 36.2
  209.         end
  210.       end
  211.       
  212.       
  213.         
  214.         
  215. #     if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
  216. #       @_total_damage += value
  217. #     else
  218. #       return
  219. #     end
  220. #     bitmap = Bitmap.new(300, 150)
  221. #     bitmap.font.name = "Arial Black"
  222. #     bitmap.font.size = 40
  223. #     bitmap.font.color.set(0, 0, 0)
  224. #     bitmap.draw_text(+2, 12+2, 160, 40, @_total_damage.abs.to_s, 1)
  225. #     if @_total_damage < 0
  226. #       bitmap.font.color.set(80, 255, 00)
  227. #    else
  228. #       bitmap.font.color.set(255, 140, 0)
  229. #     end
  230. #     bitmap.draw_text(0, 12, 160, 40, @_total_damage.abs.to_s, 1)
  231. #     bitmap.font.color.set(55, 55,255)
  232.      
  233.      
  234.      if @_total_damage_sprite.nil?
  235.        @_total_damage_sprite = ::Sprite.new(self.viewport)
  236.        @_total_damage_sprite.ox = 80
  237.        @_total_damage_sprite.oy = 20
  238.        @_total_damage_sprite.z = 3000

  239.      end
  240.      @_total_damage_sprite.bitmap = bitmap
  241.      @_total_damage_sprite.zoom_x = 0.8
  242.      @_total_damage_sprite.zoom_y = 0.8
  243.      @_total_damage_sprite.x = self.x
  244.      @_total_damage_sprite.y = self.y  - self.oy / 2 - 64
  245.      @_total_damage_sprite.z = 3001
  246.      @_total_damage_duration = 80
  247.      #hit数描绘
  248.      @hits+=1
  249.     if @_total_damage > 0
  250.       hit
  251.     end
  252.    end


  253.    def animation(animation, hit, battler_damage="", battler_critical=false)
  254.      dispose_animation      
  255.      #=======================================
  256.      # 修改:记录伤害和critical
  257.      #=======================================
  258.      @battler_damage = battler_damage
  259.      @battler_critical = battler_critical
  260.      @_animation = animation
  261.      return if @_animation == nil
  262.      @_animation_hit = hit
  263.      @_animation_duration = @_animation.frame_max
  264.      animation_name = @_animation.animation_name
  265.      animation_hue = @_animation.animation_hue
  266.      bitmap = RPG::Cache.animation(animation_name, animation_hue)
  267.      #=======================================
  268.      # 修改:计算总闪光权限值
  269.      #=======================================
  270.      for timing in @_animation.timings
  271.        quanzhong = animation_process_timing(timing, @_animation_hit,true)
  272.        # 记录最后一次闪光
  273.        @_last_frame = timing.frame if quanzhong != 0
  274.      end      
  275.      if @@_reference_count.include?(bitmap)
  276.        @@_reference_count[bitmap] += 1
  277.      else
  278.        @@_reference_count[bitmap] = 1
  279.      end
  280.      #=======================================
  281.      # 修改:行动方动画不显示伤害
  282.      #=======================================
  283.      if $scene.is_a?(Scene_Battle)
  284.        if $scene.animation1_id == @battler.animation_id
  285.          @battler_damage = ""
  286.        end
  287.      end
  288.      @_animation_sprites = []
  289.      if @_animation.position != 3 or not @@_animations.include?(animation)
  290.        for i in 0..15
  291.          sprite = ::Sprite.new(self.viewport)
  292.          sprite.bitmap = bitmap
  293.          sprite.visible = false
  294.          @_animation_sprites.push(sprite)
  295.        end
  296.        unless @@_animations.include?(animation)
  297.          @@_animations.push(animation)
  298.        end
  299.      end
  300.      update_animation
  301.   end
  302.    #=======================================
  303.    # 修改:更换清除伤害的算法,以防万一
  304.    #       本内容在脚本中没有使用过
  305.    #=======================================
  306.    def dispose_damage
  307.      for damage in @_damage.reverse
  308.        damage[0].bitmap.dispose
  309.        damage[0].dispose
  310.        @_damage.delete(damage)
  311.      end
  312.      @_total_damage = 0
  313.      @_last_frame = -1
  314.      if @_total_damage_sprite != nil
  315.        @_total_damage_duration = 0
  316.        @_total_damage_sprite.bitmap.dispose
  317.        @_total_damage_sprite.dispose
  318.        @_total_damage_sprite = nil
  319.      end
  320.    end
  321.    #=======================================
  322.    # 清除hit数★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  323.    #=======================================
  324.    def dispose_hit
  325.      if @_hits_sprite != nil
  326.        @_hits_sprite.bitmap.dispose
  327.        @_hits_sprite.dispose
  328.        @_hits_sprite = nil
  329.      end
  330.    end
  331.    def dispose_animation
  332.      #=======================================
  333.      # 修改:清除记录的伤害,清除权重记录
  334.      #=======================================
  335.      @battler_damage = nil
  336.      @battler_critical = nil
  337.      @all_quanzhong = 1
  338.      @_total_damage = 0
  339.      @_last_frame = -1
  340.      if @_animation_sprites != nil
  341.        sprite = @_animation_sprites[0]
  342.        if sprite != nil
  343.          @@_reference_count[sprite.bitmap] -= 1
  344.          if @@_reference_count[sprite.bitmap] == 0
  345.            sprite.bitmap.dispose
  346.          end
  347.        end
  348.        for sprite in @_animation_sprites
  349.          sprite.dispose
  350.        end
  351.        @_animation_sprites = nil
  352.        @_animation = nil
  353.      end
  354.    end
  355.    def update
  356.      super
  357.      if @_whiten_duration > 0
  358.        @_whiten_duration -= 1
  359.        self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  360.      end
  361.      if @_appear_duration > 0
  362.        @_appear_duration -= 1
  363.        self.opacity = (16 - @_appear_duration) * 16
  364.      end
  365.      if @_escape_duration > 0
  366.        @_escape_duration -= 1
  367.        self.opacity = 256 - (32 - @_escape_duration) * 10
  368.      end
  369.      if @_collapse_duration > 0
  370.        @_collapse_duration -= 1
  371.        self.opacity = 256 - (48 - @_collapse_duration) * 6
  372.      end
  373.      #=======================================
  374.      # 修改:更新算法,更新弹出
  375.      #=======================================
  376.      if @_damage_duration > 0
  377.        @_damage_duration -= 1
  378.        for damage in @_damage
  379.          damage[0].x = self.x + self.viewport.rect.x
  380.          damage[0].y -= 3
  381.          damage[0].opacity = damage[1]*20
  382.          damage[1] -= 1
  383.          if damage[1]==0
  384.            damage[0].bitmap.dispose
  385.            damage[0].dispose
  386.            @_damage.delete(damage)

  387.            next
  388.          end
  389.        end
  390.      end
  391.      #=======================================
  392.      # 添加:弹出总伤害
  393.      #=======================================
  394.      if @_total_damage_duration > 0
  395.        @_total_damage_duration -= 1
  396.        @_total_damage_sprite.y -= 1 if @_total_damage_duration % 2 == 0
  397.        if @_total_damage_sprite.zoom_x > 1.0
  398.          @_total_damage_sprite.zoom_x -= 0.05
  399.        end
  400.        if @_total_damage_sprite.zoom_y > 1.0
  401.          @_total_damage_sprite.zoom_y -= 0.05
  402.        end
  403.        @_total_damage_sprite.opacity = 256 - (24 - @_total_damage_duration) * 16
  404.        if @_total_damage_duration <= 0
  405.          dispose_hit#★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  406.          @_total_damage = 0
  407.          @_total_damage_duration = 0
  408.          @_total_damage_sprite.bitmap.dispose
  409.          @_total_damage_sprite.dispose
  410.          @_total_damage_sprite = nil
  411.        end
  412.      end
  413.      #=======================================
  414.      if @_animation != nil and (Graphics.frame_count % 2 == 0)
  415.        @_animation_duration -= 1
  416.        update_animation
  417.      end
  418.      if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  419.        update_loop_animation
  420.        @_loop_animation_index += 1
  421.        @_loop_animation_index %= @_loop_animation.frame_max
  422.      end
  423.      if @_blink
  424.        @_blink_count = (@_blink_count + 1) % 32
  425.        if @_blink_count < 16
  426.          alpha = (16 - @_blink_count) * 6
  427.        else
  428.          alpha = (@_blink_count - 16) * 6
  429.        end
  430.        self.color.set(255, 255, 255, alpha)
  431.      end
  432.      @@_animations.clear
  433.    end
  434.    def update_animation
  435.     if @_animation_duration > 0
  436.        frame_index = @_animation.frame_max - @_animation_duration
  437.        cell_data = @_animation.frames[frame_index].cell_data
  438.        position = @_animation.position
  439.        animation_set_sprites(@_animation_sprites, cell_data, position)
  440.        #=======================================
  441.        # 修改:弹出伤害,权重计算
  442.        #=======================================
  443.        for timing in @_animation.timings
  444.          if timing.frame == frame_index
  445.            t = 1.0 * animation_process_timing(timing, @_animation_hit)  
  446.                    if timing.se.name != ""
  447.           se=timing.se
  448.           Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
  449.         end
  450.            #p t,"当前权重", @all_quanzhong,"总权重"
  451.            if @battler_damage.is_a?(Numeric) and t != 0
  452.              t *= @battler_damage
  453.              t /= @all_quanzhong
  454.              t = t.to_i
  455.              #在闪光不是最后一次的情况下,把这次伤害加入到已经发生的伤害中★★★★★★★★★★★★★★★★★★★★★★★★★★
  456.              if frame_index != @_last_frame
  457.              @p_dam+= t
  458.              end
  459.              #p @p_dam,"已发生伤害",@battler_damage,"总伤害"(调试用)★★★★★★★★★★★★★★★★★★★★★★★★★★
  460.              #闪光为最后一次的情况下,改变这次伤害的计算方法(总伤害-已经发生伤害)★★★★★★★★★★★★★★★★★★★★★★★★★★
  461.              if frame_index == @_last_frame
  462.                t=@battler_damage-@p_dam
  463.              end
  464.              #p t,"当前伤害",@battler_damage,"总伤害"
  465.              # 最后一次闪光的话,伤害修正
  466.              if frame_index == @_last_frame
  467.                @_total_damage = @battler_damage - t
  468.                @p_dam=0      #已经发生的伤害归0★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  469.             end
  470.              #p t,@battler_damage,@all_quanzhong
  471.              damage(t,@battler_critical)
  472.             #连击次数归0★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
  473.             if frame_index == @_last_frame
  474.                       @hits=0  
  475.             end
  476.            # 防止重复播放miss
  477.            elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
  478.              damage(@battler_damage,@battler_critical)
  479.            end
  480.          end
  481.        end
  482.      else
  483.        dispose_animation
  484.      end
  485.    end
  486.    #=======================================
  487.    # 修改:敌人跳跃的功能 + 添加返回数值
  488.    #=======================================
  489.     def animation_process_timing(timing, hit,dontflash=false)
  490.       if (timing.condition == 0) or
  491.          (timing.condition == 1 and hit == true) or
  492.          (timing.condition == 2 and hit == false)
  493.         case timing.flash_scope
  494.         when 1
  495.           unless dontflash
  496.             self.flash(timing.flash_color, timing.flash_duration * 2)
  497.             if @_total_damage >0
  498.               @flash_shake_switch = true
  499.               @flash_shake = 10
  500.             end
  501.           end
  502.           return timing.flash_color.alpha * timing.flash_duration
  503.         when 2
  504.           unless dontflash
  505.             if self.viewport != nil
  506.               self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
  507.             end
  508.           end
  509.           return timing.flash_color.alpha * timing.flash_duration
  510.         when 3
  511.           unless dontflash
  512.             self.flash(nil, timing.flash_duration * 2)
  513.           end
  514.           return timing.flash_color.alpha * timing.flash_duration
  515.         end
  516.       end      
  517.       return 0
  518.     end   
  519. end
  520. end
  521. #==============================================================================
  522. # ■ Sprite_Battler
  523. #==============================================================================
  524. class Sprite_Battler < RPG::Sprite
  525. #--------------------------------------------------------------------------
  526. # ● 初始化对像
  527. #    添加跳跃记录
  528. #--------------------------------------------------------------------------
  529. def initialize(viewport, battler = nil)
  530.   super(viewport)
  531.   @battler = battler
  532.   @battler_visible = false
  533.   @flash_shake_switch = true
  534. end
  535. #--------------------------------------------------------------------------
  536. # ● 刷新画面
  537. #    增添跳跃功能
  538. #--------------------------------------------------------------------------
  539. def update
  540.   super
  541.   # 战斗者为 nil 的情况下
  542.   if @battler == nil
  543.     self.bitmap = nil
  544.     loop_animation(nil)
  545.     return
  546.   end
  547.   # 文件名和色相与当前情况有差异的情况下
  548.   if @battler.battler_name != @battler_name or
  549.      @battler.battler_hue != @battler_hue
  550.     # 获取、设置位图
  551.     @battler_name = @battler.battler_name
  552.     @battler_hue = @battler.battler_hue
  553.     self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  554.     @width = bitmap.width
  555.     @height = bitmap.height
  556.     self.ox = @width / 2
  557.     self.oy = @height
  558.     # 如果是战斗不能或者是隐藏状态就把透明度设置成 0
  559.     if @battler.dead? or @battler.hidden
  560.       self.opacity = 0
  561.     end
  562.   end
  563.   # 动画 ID 与当前的情况有差异的情况下
  564.   if @battler.damage == nil and
  565.      @battler.state_animation_id != @state_animation_id
  566.     @state_animation_id = @battler.state_animation_id
  567.     loop_animation($data_animations[@state_animation_id])
  568.   end
  569.   # 应该被显示的角色的情况下
  570.   if @battler.is_a?(Game_Actor) and @battler_visible
  571.     # 不是主状态的时候稍稍降低点透明度
  572.     if $game_temp.battle_main_phase
  573.       self.opacity += 3 if self.opacity < 255
  574.     else
  575.       self.opacity -= 3 if self.opacity > 207
  576.     end
  577.   end
  578.   # 明灭
  579.   if @battler.blink
  580.     blink_on
  581.   else
  582.     blink_off
  583.   end
  584.   # 不可见的情况下
  585.   unless @battler_visible
  586.     # 出现
  587.     if not @battler.hidden and not @battler.dead? and
  588.        (@battler.damage == nil or @battler.damage_pop)
  589.       appear
  590.       @battler_visible = true
  591.     end
  592.   end
  593.   # 可见的情况下
  594.   if @battler_visible
  595.     # 逃跑
  596.     if @battler.hidden
  597.       $game_system.se_play($data_system.escape_se)
  598.       escape
  599.       @battler_visible = false
  600.     end
  601.     # 白色闪烁
  602.     if @battler.white_flash
  603.       whiten
  604.       @battler.white_flash = false
  605.     end
  606.     # 动画
  607.     if @battler.animation_id != 0
  608.       animation = $data_animations[@battler.animation_id]
  609.       animation(animation, @battler.animation_hit,@battler.damage, @battler.critical)
  610.       @battler.animation_id = 0
  611.     end
  612.     # 伤害
  613.     if @battler.damage_pop
  614.       @battler.damage = nil
  615.       @battler.critical = false
  616.       @battler.damage_pop = false
  617.     end
  618.     # korapusu
  619.     if @battler.damage == nil and @battler.dead?
  620.       if @battler.is_a?(Game_Enemy)
  621.         $game_system.se_play($data_system.enemy_collapse_se)
  622.       else
  623.         $game_system.se_play($data_system.actor_collapse_se)
  624.       end
  625.       collapse
  626.       @battler_visible = false
  627.     end
  628.   end
  629.   # 设置活动块的坐标
  630.   if @flash_shake_switch == true
  631.     self.x = @battler.screen_x
  632.     self.y = @battler.screen_y
  633.     self.z = @battler.screen_z
  634.     @flash_shake_switch = false
  635.   end
  636.   if @flash_shake != 0 and @battler.damage != nil and RPG::BATTLER_JUMP
  637.     case @flash_shake
  638.     when 9..10
  639.       self.x = @battler.screen_x
  640.       self.y -=4
  641.       self.z = @battler.screen_z
  642.     when 6..8
  643.       self.x = @battler.screen_x
  644.       self.y -=2
  645.       self.z = @battler.screen_z
  646.     when 3..5
  647.       self.x = @battler.screen_x
  648.       self.y +=2
  649.       self.z = @battler.screen_z
  650.     when 2
  651.       self.x = @battler.screen_x
  652.       self.y += 4
  653.       self.z = @battler.screen_z
  654.     when 1
  655.       self.x = @battler.screen_x
  656.       self.y = @battler.screen_y
  657.       self.z = @battler.screen_z
  658.     end
  659.     @flash_shake -= 1
  660.   end
  661. end
  662. end

  663. #==============================================================================
  664. # ■ Scene_Battle
  665. #------------------------------------------------------------------------------
  666. #  处理战斗画面的类。
  667. #==============================================================================

  668. class Scene_Battle
  669. #--------------------------------------------------------------------------
  670. # ● 定义实例变量
  671. #--------------------------------------------------------------------------
  672. attr_reader   :animation1_id                    # 行动方动画ID
  673. end

  674. #==============================================================================
  675. # ■ Game_Battler
  676. #------------------------------------------------------------------------------
  677. #  处理战斗者的类。这个类作为 Game_Actor 类与 Game_Enemy 类的
  678. # 超级类来使用。
  679. #==============================================================================

  680. #class Game_Battler
  681. #  #--------------------------------------------------------------------------
  682. #  # ● 应用连续伤害效果
  683. #  #--------------------------------------------------------------------------
  684. #  alias rainbow_sword_slip_damage_effect slip_damage_effect
  685. #  def slip_damage_effect
  686. #    self.animation_id = RPG::SLIP_DAMAGE_ANIMATION_ID
  687. #    self.animation_hit = true
  688. #    rainbow_sword_slip_damage_effect
  689. #  end
  690. #end
复制代码

点评

晕死……  发表于 2012-5-17 13:49
啊?伤害是图片的?!其实都是默认输出的  发表于 2012-5-17 13:31
加一个.to_s上去……  发表于 2012-5-17 13:21
回复

使用道具 举报

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

本版积分规则

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

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

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

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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