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

Project1

 找回密码
 注册会员
搜索
查看: 3637|回复: 5

[已经过期] 关于怪物显血的脚本

[复制链接]

Lv1.梦旅人

梦石
0
星屑
151
在线时间
208 小时
注册时间
2012-7-10
帖子
170
发表于 2012-7-26 23:19:09 | 显示全部楼层 |阅读模式

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

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

x
我有一个怪物显示血条和MP脚本,但是没有显示怪物的名字,我想加入这个功能,大家帮我看看

#==============================================================================
# 功能:战斗中显示敌人血和蓝于敌人脚下
# 适用:RMVX Ace
# 作者:殇殃 2012.3.10
# 使用方法:复制整个脚本插入到Main之前
# 注意:由于血条是显示在敌人脚下,所以敌群的位置不能太靠底部,不然会被挡住。
#       可以自行更改坐标修改显示位置、血条的颜色等。
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
#  游戏中全部窗口的超级类。
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # ● 描绘敌人HP
  #--------------------------------------------------------------------------
  def draw_enemy_hp(enemy, x, y, width = 80)
    draw_gauge(x, y, width, enemy.hp_rate, hp_gauge_color1, hp_gauge_color2)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 30, line_height, Vocab::hp_a)
    self.contents.font.color = hp_color(enemy)
    self.contents.draw_text(x + width - 64, y, 64, line_height, enemy.hp, 2)
    #一个数字占16像素
  end
  #--------------------------------------------------------------------------
  # ● 绘制敌人MP
  #--------------------------------------------------------------------------
  def draw_enemy_mp(enemy, x, y, width = 80)
    draw_gauge(x, y, width, enemy.mp_rate, mp_gauge_color1, mp_gauge_color2)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 30, line_height, Vocab::mp_a)
    self.contents.font.color = mp_color(enemy)
    self.contents.draw_text(x + width - 64, y, 64, line_height, enemy.mp, 2)
  end
end
#==============================================================================
# ■ Sprite_Battler
#------------------------------------------------------------------------------
#  战斗显示用活动块。Game_Battler 类的实例监视、
# 活动块的状态的监视、活动块状态自动变化。
#==============================================================================

class Sprite_Battler < Sprite_Base
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #     viewport : 视区
  #     battler  : 战斗者 (Game_Battler)
  #--------------------------------------------------------------------------
  def initialize(viewport, battler = nil)
    super(viewport)
    @battler = battler
    @battler_visible = false
    @effect_type = nil      
    @effect_duration = 0   
    if @battler.is_a?(Game_Enemy)
      width = 24 + 80 #边距12*2+血条的长度(在draw_enemy_hp中定义)
      height = 24 + 24*2 #边距12*2+line_height*2
      x = @battler.screen_x - width/2 #screen_x是怪物图片水平方向上的中点位置
      y = @battler.screen_y - 12 #边距12,显示HP/MP的窗口无边框
      @enemy_hpmp_window = Window_Base.new(x, y, width, height)
      @enemy_hpmp_window.opacity = 0
      @enemy_hpmp_window.contents = Bitmap.new(width - 24, height - 24)#位图比窗口小24像素取消边框
      @enemy_hpmp_window.draw_enemy_hp(@battler, 0, 0)
      @old_hp = -1
      @enemy_hpmp_window.draw_enemy_mp(@battler, 0, 24)
      @old_mp = -1
    end
  end
  #--------------------------------------------------------------------------
  # ● 释放
  #--------------------------------------------------------------------------
  def dispose
    if self.bitmap != nil
      self.bitmap.dispose
      @enemy_hpmp_window.dispose
    end
    super
  end
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update
    super
    if @battler == nil
      self.bitmap = nil
    else
      @use_sprite = @battler.use_sprite?
      if @use_sprite
        update_bitmap
        update_origin
        update_position
      end
      setup_new_effect
      setup_new_animation
      update_effect
      if @enemy_hpmp_window != nil and (@old_hp != @battler.hp or @old_mp != @battler.mp)
        if @battler.hp == 0
          @enemy_hpmp_window.hide
        else
          @enemy_hpmp_window.contents.clear
          @enemy_hpmp_window.draw_enemy_hp(@battler, 0, 0)
          @old_hp = @battler.hp
          @enemy_hpmp_window.draw_enemy_mp(@battler, 0, 24)
          @old_mp = @battler.mp
          @enemy_hpmp_window.show #怪物死后再被复活
        end #if battler.hp == 0
      end
    end #if @battler == nil
  end


end

Lv1.梦旅人

梦石
0
星屑
55
在线时间
177 小时
注册时间
2011-6-7
帖子
88
发表于 2012-7-28 21:39:49 | 显示全部楼层
  1. #==============================================================================
  2. # 功能:战斗中显示敌人血和蓝于敌人脚下
  3. # 适用:RMVX Ace
  4. # 作者:殇殃 2012.3.10
  5. # 使用方法:复制整个脚本插入到Main之前
  6. # 注意:由于血条是显示在敌人脚下,所以敌群的位置不能太靠底部,不然会被挡住。
  7. # 可以自行更改坐标修改显示位置、血条的颜色等。
  8. #==============================================================================
  9. # ■ Window_Base
  10. #------------------------------------------------------------------------------
  11. #  游戏中全部窗口的超级类。
  12. #==============================================================================

  13. class Window_Base < Window
  14. #--------------------------------------------------------------------------
  15. # ● 描绘敌人HP
  16. #--------------------------------------------------------------------------
  17. def draw_enemy_hp(enemy, x, y, width = 80)
  18. draw_gauge(x, y, width, enemy.hp_rate, hp_gauge_color1, hp_gauge_color2)
  19. self.contents.font.size = 20
  20. self.contents.font.color = system_color
  21. self.contents.draw_text(x, y, 30, line_height, Vocab::hp_a)
  22. self.contents.font.color = hp_color(enemy)
  23. self.contents.draw_text(x + width - 64, y, 64, line_height, enemy.hp, 2)
  24. #一个数字占16像素
  25. end
  26. def draw_enemy_name(enemy, x, y)
  27. self.contents.font.size = 15
  28. self.contents.font.color = normal_color
  29. self.contents.draw_text(x, y,104, line_height, enemy.name)
  30. end
  31. #--------------------------------------------------------------------------
  32. # ● 绘制敌人MP
  33. #--------------------------------------------------------------------------
  34. def draw_enemy_mp(enemy, x, y, width = 80)
  35. self.contents.font.size = 20
  36. draw_gauge(x, y, width, enemy.mp_rate, mp_gauge_color1, mp_gauge_color2)
  37. self.contents.font.color = system_color
  38. self.contents.draw_text(x, y, 30, line_height, Vocab::mp_a)
  39. self.contents.font.color = mp_color(enemy)
  40. self.contents.draw_text(x + width - 64, y, 64, line_height, enemy.mp, 2)
  41. end
  42. end
  43. #==============================================================================
  44. # ■ Sprite_Battler
  45. #------------------------------------------------------------------------------
  46. #  战斗显示用活动块。Game_Battler 类的实例监视、
  47. # 活动块的状态的监视、活动块状态自动变化。
  48. #==============================================================================

  49. class Sprite_Battler < Sprite_Base
  50. #--------------------------------------------------------------------------
  51. # ● 初始化对象
  52. # viewport : 视区
  53. # battler : 战斗者 (Game_Battler)
  54. #--------------------------------------------------------------------------
  55. def initialize(viewport, battler = nil)
  56. super(viewport)
  57. @battler = battler
  58. @battler_visible = false
  59. @effect_type = nil
  60. @effect_duration = 0
  61. if @battler.is_a?(Game_Enemy)
  62. width = 24 + 80#边距12*2+血条的长度(在draw_enemy_hp中定义)
  63. height = 24 + 24*3 #边距12*2+line_height*2
  64. x = @battler.screen_x - width/2 #screen_x是怪物图片水平方向上的中点位置
  65. y = @battler.screen_y - 12 #边距12,显示HP/MP的窗口无边框
  66. @enemy_hpmp_window = Window_Base.new(x, y, width, height)
  67. @enemy_hpmp_window.opacity = 0
  68. @enemy_hpmp_window.contents = Bitmap.new(width - 24, height - 24)#位图比窗口小24像素取消边框
  69. @enemy_hpmp_window.draw_enemy_hp(@battler, 0, 0)
  70. @old_hp = -1
  71. @enemy_hpmp_window.draw_enemy_mp(@battler, 0, 24)
  72. @old_mp = -1
  73. @enemy_hpmp_window.draw_enemy_name(@battler, 0, 48)
  74. @old_name = nil
  75. end
  76. end
  77. #--------------------------------------------------------------------------
  78. # ● 释放
  79. #--------------------------------------------------------------------------
  80. def dispose
  81. if self.bitmap != nil
  82. self.bitmap.dispose
  83. @enemy_hpmp_window.dispose
  84. end
  85. super
  86. end
  87. #--------------------------------------------------------------------------
  88. # ● 更新画面
  89. #--------------------------------------------------------------------------
  90. def update
  91. super
  92. if @battler == nil
  93. self.bitmap = nil
  94. else
  95. @use_sprite = @battler.use_sprite?
  96. if @use_sprite
  97. update_bitmap
  98. update_origin
  99. update_position
  100. end
  101. setup_new_effect
  102. setup_new_animation
  103. update_effect
  104. if @enemy_hpmp_window != nil and (@old_hp != @battler.hp or @old_mp != @battler.mp)
  105. if @battler.hp == 0
  106. @enemy_hpmp_window.hide
  107. else
  108. @enemy_hpmp_window.contents.clear
  109. @enemy_hpmp_window.draw_enemy_hp(@battler, 0, 0)
  110. @old_hp = @battler.hp
  111. @enemy_hpmp_window.draw_enemy_mp(@battler, 0, 24)
  112. @old_mp = @battler.mp
  113. @enemy_hpmp_window.draw_enemy_name(@battler, 0, 48)
  114. @old_mp = @battler.name
  115. @enemy_hpmp_window.show #怪物死后再被复活
  116. end #if battler.hp == 0
  117. end
  118. end #if @battler == nil
  119. end

  120. end
复制代码
第一次改脚本 有错还请谅解
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
4029
在线时间
1076 小时
注册时间
2008-5-17
帖子
218

开拓者

发表于 2012-11-15 19:18:52 | 显示全部楼层
chxush 发表于 2012-7-28 21:39
第一次改脚本 有错还请谅解

亲 ,好卡的说。

评分

参与人数 1星屑 -400 收起 理由
Mic_洛洛 -400 挖坟!节操掉200!

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
27 小时
注册时间
2012-1-21
帖子
15
发表于 2012-11-23 16:59:48 | 显示全部楼层
问一下,这是用于横版的吧?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
119
在线时间
11 小时
注册时间
2018-2-2
帖子
7
发表于 2018-7-29 21:59:39 | 显示全部楼层
chxush 发表于 2012-7-28 21:39
第一次改脚本 有错还请谅解

请问一下怎么把状态栏调到怪物头上去呢?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
10
在线时间
2 小时
注册时间
2018-9-12
帖子
9
发表于 2018-9-16 21:23:34 | 显示全部楼层
同问,把蓝条去掉,然后血条调到头上
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-3-29 17:07

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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