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

Project1

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

[已经解决] 地图上显示伤害问题

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
4 小时
注册时间
2008-5-5
帖子
91
跳转到指定楼层
1
发表于 2009-7-18 13:57:31 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
脚本如下
  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.   end  
  42. end
  43. class Game_Character
  44.   attr_accessor :damage_pop
  45.   attr_accessor :damage
  46.   attr_accessor :critical
  47.   alias carol3_66RPG_damage_pop_initialize initialize
  48.   def initialize
  49.     @damage_pop = false
  50.     @damage = 0
  51.     @critical = false
  52.     carol3_66RPG_damage_pop_initialize
  53.   end
  54. end

  55. #==============================================================================
  56. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  57. #==============================================================================
复制代码
我做了一个事件,当我碰到敌人的时候双方都会费血,地图右侧会显示伤害值和连击数,但是敌我双方的伤害值和连击数的位置一样,重叠了。
请问怎么把我方的伤害值和连击数放到左边,敌方的不动?

Lv1.梦旅人

B

梦石
0
星屑
50
在线时间
26 小时
注册时间
2007-8-26
帖子
3693
2
发表于 2009-7-18 20:45:56 | 只看该作者
这个要涉及到RPG::Sprite的修改
  1. module RPG
  2.   class Sprite < ::Sprite
  3.     @@_animations = []
  4.     @@_reference_count = {}
  5.     def initialize(viewport = nil)
  6.       super(viewport)
  7.       @_whiten_duration = 0
  8.       @_appear_duration = 0
  9.       @_escape_duration = 0
  10.       @_collapse_duration = 0
  11.       @_damage_duration = 0
  12.       @_animation_duration = 0
  13.       @_blink = false
  14.     end
  15.     def dispose
  16.       dispose_damage
  17.       dispose_animation
  18.       dispose_loop_animation
  19.       super
  20.     end
  21.     def whiten
  22.       self.blend_type = 0
  23.       self.color.set(255, 255, 255, 128)
  24.       self.opacity = 255
  25.       @_whiten_duration = 16
  26.       @_appear_duration = 0
  27.       @_escape_duration = 0
  28.       @_collapse_duration = 0
  29.     end
  30.     def appear
  31.       self.blend_type = 0
  32.       self.color.set(0, 0, 0, 0)
  33.       self.opacity = 0
  34.       @_appear_duration = 16
  35.       @_whiten_duration = 0
  36.       @_escape_duration = 0
  37.       @_collapse_duration = 0
  38.     end
  39.     def escape
  40.       self.blend_type = 0
  41.       self.color.set(0, 0, 0, 0)
  42.       self.opacity = 255
  43.       @_escape_duration = 32
  44.       @_whiten_duration = 0
  45.       @_appear_duration = 0
  46.       @_collapse_duration = 0
  47.     end
  48.     def collapse
  49.       self.blend_type = 1
  50.       self.color.set(255, 64, 64, 255)
  51.       self.opacity = 255
  52.       @_collapse_duration = 48
  53.       @_whiten_duration = 0
  54.       @_appear_duration = 0
  55.       @_escape_duration = 0
  56.     end
  57.     def damage(value, critical,team)
  58.       dispose_damage
  59.       if value.is_a?(Numeric)
  60.         damage_string = value.abs.to_s
  61.       else
  62.         damage_string = value.to_s
  63.       end
  64.       bitmap = Bitmap.new(160, 48)
  65.       bitmap.font.name = "Arial Black"
  66.       bitmap.font.size = 32
  67.       bitmap.font.color.set(0, 0, 0)
  68.       bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  69.       bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  70.       bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  71.       bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  72.       if value.is_a?(Numeric) and value < 0
  73.         bitmap.font.color.set(176, 255, 144)
  74.       else
  75.         bitmap.font.color.set(255, 255, 255)
  76.       end
  77.       bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  78.       if critical
  79.         bitmap.font.size = 20
  80.         bitmap.font.color.set(0, 0, 0)
  81.         bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
  82.         bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
  83.         bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
  84.         bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
  85.         bitmap.font.color.set(255, 255, 255)
  86.         bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
  87.       end
  88.       @_damage_sprite = ::Sprite.new(self.viewport)
  89.       @_damage_sprite.bitmap = bitmap
  90.       @_damage_sprite.ox = 80
  91.       @_damage_sprite.oy = 20
  92.   #--------------------------------------------------------------------------
  93.       team == 1 ? a = 25 : a = -25
  94.       a = 0 if team == nil
  95.       @_damage_sprite.x = self.x + a
  96.   #--------------------------------------------------------------------------
  97.       @_damage_sprite.y = self.y - self.oy / 2
  98.       @_damage_sprite.z = 3000
  99.       @_damage_duration = 40
  100.     end
  101.     def animation(animation, hit)
  102.       dispose_animation
  103.       @_animation = animation
  104.       return if @_animation == nil
  105.       @_animation_hit = hit
  106.       @_animation_duration = @_animation.frame_max
  107.       animation_name = @_animation.animation_name
  108.       animation_hue = @_animation.animation_hue
  109.       bitmap = RPG::Cache.animation(animation_name, animation_hue)
  110.       if @@_reference_count.include?(bitmap)
  111.         @@_reference_count[bitmap] += 1
  112.       else
  113.         @@_reference_count[bitmap] = 1
  114.       end
  115.       @_animation_sprites = []
  116.       if @_animation.position != 3 or not @@_animations.include?(animation)
  117.         for i in 0..15
  118.           sprite = ::Sprite.new(self.viewport)
  119.           sprite.bitmap = bitmap
  120.           sprite.visible = false
  121.           @_animation_sprites.push(sprite)
  122.         end
  123.         unless @@_animations.include?(animation)
  124.           @@_animations.push(animation)
  125.         end
  126.       end
  127.       update_animation
  128.     end
  129.     def loop_animation(animation)
  130.       return if animation == @_loop_animation
  131.       dispose_loop_animation
  132.       @_loop_animation = animation
  133.       return if @_loop_animation == nil
  134.       @_loop_animation_index = 0
  135.       animation_name = @_loop_animation.animation_name
  136.       animation_hue = @_loop_animation.animation_hue
  137.       bitmap = RPG::Cache.animation(animation_name, animation_hue)
  138.       if @@_reference_count.include?(bitmap)
  139.         @@_reference_count[bitmap] += 1
  140.       else
  141.         @@_reference_count[bitmap] = 1
  142.       end
  143.       @_loop_animation_sprites = []
  144.       for i in 0..15
  145.         sprite = ::Sprite.new(self.viewport)
  146.         sprite.bitmap = bitmap
  147.         sprite.visible = false
  148.         @_loop_animation_sprites.push(sprite)
  149.       end
  150.       update_loop_animation
  151.     end
  152.     def dispose_damage
  153.       if @_damage_sprite != nil
  154.         @_damage_sprite.bitmap.dispose
  155.         @_damage_sprite.dispose
  156.         @_damage_sprite = nil
  157.         @_damage_duration = 0
  158.       end
  159.     end
  160.     def dispose_animation
  161.       if @_animation_sprites != nil
  162.         sprite = @_animation_sprites[0]
  163.         if sprite != nil
  164.           @@_reference_count[sprite.bitmap] -= 1
  165.           if @@_reference_count[sprite.bitmap] == 0
  166.             sprite.bitmap.dispose
  167.           end
  168.         end
  169.         for sprite in @_animation_sprites
  170.           sprite.dispose
  171.         end
  172.         @_animation_sprites = nil
  173.         @_animation = nil
  174.       end
  175.     end
  176.     def dispose_loop_animation
  177.       if @_loop_animation_sprites != nil
  178.         sprite = @_loop_animation_sprites[0]
  179.         if sprite != nil
  180.           @@_reference_count[sprite.bitmap] -= 1
  181.           if @@_reference_count[sprite.bitmap] == 0
  182.             sprite.bitmap.dispose
  183.           end
  184.         end
  185.         for sprite in @_loop_animation_sprites
  186.           sprite.dispose
  187.         end
  188.         @_loop_animation_sprites = nil
  189.         @_loop_animation = nil
  190.       end
  191.     end
  192.     def blink_on
  193.       unless @_blink
  194.         @_blink = true
  195.         @_blink_count = 0
  196.       end
  197.     end
  198.     def blink_off
  199.       if @_blink
  200.         @_blink = false
  201.         self.color.set(0, 0, 0, 0)
  202.       end
  203.     end
  204.     def blink?
  205.       @_blink
  206.     end
  207.     def effect?
  208.       @_whiten_duration > 0 or
  209.       @_appear_duration > 0 or
  210.       @_escape_duration > 0 or
  211.       @_collapse_duration > 0 or
  212.       @_damage_duration > 0 or
  213.       @_animation_duration > 0
  214.     end
  215.     def update
  216.       super
  217.       if @_whiten_duration > 0
  218.         @_whiten_duration -= 1
  219.         self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  220.       end
  221.       if @_appear_duration > 0
  222.         @_appear_duration -= 1
  223.         self.opacity = (16 - @_appear_duration) * 16
  224.       end
  225.       if @_escape_duration > 0
  226.         @_escape_duration -= 1
  227.         self.opacity = 256 - (32 - @_escape_duration) * 10
  228.       end
  229.       if @_collapse_duration > 0
  230.         @_collapse_duration -= 1
  231.         self.opacity = 256 - (48 - @_collapse_duration) * 6
  232.       end
  233.       if @_damage_duration > 0
  234.         @_damage_duration -= 1
  235.         case @_damage_duration
  236.         when 38..39
  237.           @_damage_sprite.y -= 4
  238.         when 36..37
  239.           @_damage_sprite.y -= 2
  240.         when 34..35
  241.           @_damage_sprite.y += 2
  242.         when 28..33
  243.           @_damage_sprite.y += 4
  244.         end
  245.         @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
  246.         if @_damage_duration == 0
  247.           dispose_damage
  248.         end
  249.       end
  250.       if @_animation != nil and (Graphics.frame_count % 2 == 0)
  251.         @_animation_duration -= 1
  252.         update_animation
  253.       end
  254.       if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  255.         update_loop_animation
  256.         @_loop_animation_index += 1
  257.         @_loop_animation_index %= @_loop_animation.frame_max
  258.       end
  259.       if @_blink
  260.         @_blink_count = (@_blink_count + 1) % 32
  261.         if @_blink_count < 16
  262.           alpha = (16 - @_blink_count) * 6
  263.         else
  264.           alpha = (@_blink_count - 16) * 6
  265.         end
  266.         self.color.set(255, 255, 255, alpha)
  267.       end
  268.       @@_animations.clear
  269.     end
  270.     def update_animation
  271.       if @_animation_duration > 0
  272.         frame_index = @_animation.frame_max - @_animation_duration
  273.         cell_data = @_animation.frames[frame_index].cell_data
  274.         position = @_animation.position
  275.         animation_set_sprites(@_animation_sprites, cell_data, position)
  276.         for timing in @_animation.timings
  277.           if timing.frame == frame_index
  278.             animation_process_timing(timing, @_animation_hit)
  279.           end
  280.         end
  281.       else
  282.         dispose_animation
  283.       end
  284.     end
  285.     def update_loop_animation
  286.       frame_index = @_loop_animation_index
  287.       cell_data = @_loop_animation.frames[frame_index].cell_data
  288.       position = @_loop_animation.position
  289.       animation_set_sprites(@_loop_animation_sprites, cell_data, position)
  290.       for timing in @_loop_animation.timings
  291.         if timing.frame == frame_index
  292.           animation_process_timing(timing, true)
  293.         end
  294.       end
  295.     end
  296.     def animation_set_sprites(sprites, cell_data, position)
  297.       for i in 0..15
  298.         sprite = sprites[i]
  299.         pattern = cell_data[i, 0]
  300.         if sprite == nil or pattern == nil or pattern == -1
  301.           sprite.visible = false if sprite != nil
  302.           next
  303.         end
  304.         sprite.visible = true
  305.         sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  306.         if position == 3
  307.           if self.viewport != nil
  308.             sprite.x = self.viewport.rect.width / 2
  309.             sprite.y = self.viewport.rect.height - 160
  310.           else
  311.             sprite.x = 320
  312.             sprite.y = 240
  313.           end
  314.         else
  315.           sprite.x = self.x - self.ox + self.src_rect.width / 2
  316.           sprite.y = self.y - self.oy + self.src_rect.height / 2
  317.           sprite.y -= self.src_rect.height / 4 if position == 0
  318.           sprite.y += self.src_rect.height / 4 if position == 2
  319.         end
  320.         sprite.x += cell_data[i, 1]
  321.         sprite.y += cell_data[i, 2]
  322.         sprite.z = 2000
  323.         sprite.ox = 96
  324.         sprite.oy = 96
  325.         sprite.zoom_x = cell_data[i, 3] / 100.0
  326.         sprite.zoom_y = cell_data[i, 3] / 100.0
  327.         sprite.angle = cell_data[i, 4]
  328.         sprite.mirror = (cell_data[i, 5] == 1)
  329.         sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  330.         sprite.blend_type = cell_data[i, 7]
  331.       end
  332.     end
  333.     def animation_process_timing(timing, hit)
  334.       if (timing.condition == 0) or
  335.          (timing.condition == 1 and hit == true) or
  336.          (timing.condition == 2 and hit == false)
  337.         if timing.se.name != ""
  338.           se = timing.se
  339.           Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
  340.         end
  341.         case timing.flash_scope
  342.         when 1
  343.           self.flash(timing.flash_color, timing.flash_duration * 2)
  344.         when 2
  345.           if self.viewport != nil
  346.             self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
  347.           end
  348.         when 3
  349.           self.flash(nil, timing.flash_duration * 2)
  350.         end
  351.       end
  352.     end
  353.     def x=(x)
  354.       sx = x - self.x
  355.       if sx != 0
  356.         if @_animation_sprites != nil
  357.           for i in 0..15
  358.             @_animation_sprites[i].x += sx
  359.           end
  360.         end
  361.         if @_loop_animation_sprites != nil
  362.           for i in 0..15
  363.             @_loop_animation_sprites[i].x += sx
  364.           end
  365.         end
  366.       end
  367.       super
  368.     end
  369.     def y=(y)
  370.       sy = y - self.y
  371.       if sy != 0
  372.         if @_animation_sprites != nil
  373.           for i in 0..15
  374.             @_animation_sprites[i].y += sy
  375.           end
  376.         end
  377.         if @_loop_animation_sprites != nil
  378.           for i in 0..15
  379.             @_loop_animation_sprites[i].y += sy
  380.           end
  381.         end
  382.       end
  383.       super
  384.     end
  385.   end
  386. end
复制代码
  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,@character.damage_kind)
  37.       @character.damage = nil
  38.       @character.critical = false
  39.       @character.damage_pop = false
  40.     end
  41.   end  
  42. end
  43. class Game_Character
  44.   attr_accessor :damage_pop
  45.   attr_accessor :damage
  46.   attr_accessor :critical
  47.   attr_accessor :damage_kind
  48.   alias carol3_66RPG_damage_pop_initialize initialize
  49.   def initialize
  50.     @damage_pop = false
  51.     @damage = 0
  52.     @critical = false
  53.     @damage_kind = 1
  54.     carol3_66RPG_damage_pop_initialize
  55.   end
  56. end

  57. #==============================================================================
  58. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  59. #==============================================================================
复制代码
注意:

显示伤害时加上一句:
$game_map.events[事件编号].damage_kind = 1  # 在右边
$game_map.events[事件编号].damage_kind = 2 # 不一定是2,也就是非1,在左边

不定义的话,与原来一样~

如果想修改伤害值的偏向,搜索这一句
team == 1 ? a = 25 : a = -25
修改25的值~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
4 小时
注册时间
2008-5-5
帖子
91
3
 楼主| 发表于 2009-7-19 17:54:57 | 只看该作者
请问第一段脚本要插到哪?还是要修改哪?第二段是不是直接替换我那段?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

B

梦石
0
星屑
50
在线时间
26 小时
注册时间
2007-8-26
帖子
3693
4
发表于 2009-7-19 18:03:28 | 只看该作者
第一段插到main前面,第二段替换~

= =~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
4 小时
注册时间
2008-5-5
帖子
91
5
 楼主| 发表于 2009-7-20 18:13:01 | 只看该作者
不行啊  会出现这个错误

1.JPG (7.54 KB, 下载次数: 0)

1.JPG
回复 支持 反对

使用道具 举报

Lv1.梦旅人

B

梦石
0
星屑
50
在线时间
26 小时
注册时间
2007-8-26
帖子
3693
6
发表于 2009-7-20 19:13:10 | 只看该作者
注意顺序,前者要在后者的前面 = =~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
4 小时
注册时间
2008-5-5
帖子
91
7
 楼主| 发表于 2009-7-20 19:20:34 | 只看该作者
不行啊大哥   还是那个错误  这是我的工程脚本目录

1.JPG (15.37 KB, 下载次数: 4)

1.JPG
回复 支持 反对

使用道具 举报

Lv1.梦旅人

B

梦石
0
星屑
50
在线时间
26 小时
注册时间
2007-8-26
帖子
3693
8
发表于 2009-7-20 20:25:31 | 只看该作者
将前段脚本的 57 行      def damage(value, critical,team)
改成     def damage(value, critical,team=nil)

起先写上了~ 但不知又为何被删了~ = =~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
4 小时
注册时间
2008-5-5
帖子
91
9
 楼主| 发表于 2009-7-27 15:56:26 | 只看该作者
.................彻底无语了,还是那个错误,麻烦大哥发个范例吧。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

B

梦石
0
星屑
50
在线时间
26 小时
注册时间
2007-8-26
帖子
3693
10
发表于 2009-7-27 16:01:38 | 只看该作者
偶也很无语…… - -~

Project67.rar

189.69 KB, 下载次数: 308

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-14 09:52

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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