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

Project1

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

[已经解决] 敌人血条调试

[复制链接]

Lv2.观梦者

梦石
0
星屑
285
在线时间
17 小时
注册时间
2020-8-2
帖子
11
跳转到指定楼层
1
发表于 2020-8-4 14:42:26 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 2020刈飒的风 于 2020-8-7 21:06 编辑

#==============================================================================
# F08 - 战斗敌人显示血条 - By芙蕾娅
#------------------------------------------------------------------------------
#  ★ - 新增  ☆ - 修改  ■ - 删除 ● - 无变更
#==============================================================================
module Freya
  # 隐藏HP的文本
  HideGaugeText = "Hide_Gauge"
  # 血条颜色
  EnemyHPGaugeColor1 = Color.new(64,128,96)
  EnemyHPGaugeColor2 = Color.new(96,192,160)
end
#==============================================================================
# ■ Sprite_Battler_HP
#------------------------------------------------------------------------------
#  显示战斗者的生命在战斗者的精灵下面。
#==============================================================================
class Sprite_Battler_HP < Sprite
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
def initialize(viewport,battler = nil)
    super(viewport)
    @battler = battler
    @last_hp = 0
    create_bitmap
    update
  end
  #--------------------------------------------------------------------------
  # ● 释放
  #--------------------------------------------------------------------------
  def dispose
    self.bitmap.dispose
    super
  end
  #--------------------------------------------------------------------------
  # ● 生成位图
  #--------------------------------------------------------------------------
  def create_bitmap
    @last_hp = @battler.hp
    bw = 320
    bh = 16
    self.bitmap = Bitmap.new(bw, bh)
    self.bitmap.fill_rect(0, 0, bw, bh, Color.new(32,32,64))
    if Freya::Gauge_Type.nil? or Freya::Gauge_Type == 0
      hp = ((bw) * @battler.hp_rate).to_i
      self.bitmap.gradient_fill_rect(0, 0, hp, bh, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
    elsif Freya::Gauge_Type == 1
      hp = ((width - 2) * @battler.hp_rate).to_i
      self.bitmap.gradient_fill_rect(1, 1, hp, bh - 2, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
    elsif Freya::Gauge_Type == 2
      hp = ((width) * @battler.hp_rate).to_i
      self.bitmap.gradient_fill_rect(0, 0, hp / 2, bh, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
      self.bitmap.gradient_fill_rect(hp / 2, 0, hp / 2, bh, Freya::EnemyHPGaugeColor2, Freya::EnemyHPGaugeColor1)
    elsif Freya::Gauge_Type == 3
      hp = ((width - 2) * @battler.hp_rate).to_i
      self.bitmap.gradient_fill_rect(1, 1, hp / 2, bh - 2, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
      self.bitmap.gradient_fill_rect((hp / 2) + 1, 1, hp / 2, bh - 2, Freya::EnemyHPGaugeColor2, Freya::EnemyHPGaugeColor1)
    end
  end
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update
    super
    if @battler && [email protected]?
      @use_sprite = @battler.use_sprite?
      if @use_sprite
        update_origin
        update_position
      end
    else
      self.bitmap = nil
    end
  end
  #--------------------------------------------------------------------------
  # ● 原点の更新
  #--------------------------------------------------------------------------
  def update_origin
    if bitmap
      self.ox = bitmap.width / 2
      self.oy = bitmap.height
    end
  end
  #--------------------------------------------------------------------------
  # ● 位置の更新
  #--------------------------------------------------------------------------
  def update_position
    self.x = 72
    self.y = 24 + @battler.index * 24
    self.z = @battler.screen_z + 10
    create_bitmap if @last_hp != @battler.hp
    hide = $data_enemies[@battler.enemy_id].note.include?(Freya::HideGaugeText)
    if @battler.hp == 0 or hide
      self.opacity = 0
    elsif @battler.hp > 0 && !hide
      self.opacity = 255
    end
  end
end

class Sprite_Battler_Name < Sprite
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize(viewport,battler = nil)
    super(viewport)
    @battler = battler
    @name = ""
    create_bitmap
    update
  end
  #--------------------------------------------------------------------------
  # ● 释放
  #--------------------------------------------------------------------------
  def dispose
    self.bitmap.dispose
    super
  end
  #--------------------------------------------------------------------------
  # ● 生成位图
  #--------------------------------------------------------------------------
  def create_bitmap
    @name = @battler.name
    bw = 110
    bh = 20
    self.bitmap = Bitmap.new(bw, bh)
    self.bitmap.draw_text(0, 0, bw, bh, @name, 0)
  end
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update
    super
    if @battler && [email protected]?
      @use_sprite = @battler.use_sprite?
      if @use_sprite
        update_origin
        update_position
      end
    else
      self.bitmap = nil
    end
  end
  #--------------------------------------------------------------------------
  # ● 原点の更新
  #--------------------------------------------------------------------------
  def update_origin
    if bitmap
      self.ox = bitmap.width / 2
      self.oy = bitmap.height
    end
  end
  #--------------------------------------------------------------------------
  # ● 位置の更新
  #--------------------------------------------------------------------------
  def update_position
    self.x = 54
    self.y = 24 + @battler.index * 24
    self.z = @battler.screen_z + 20
    create_bitmap if @last_hp != @battler.hp
    hide = $data_enemies[@battler.enemy_id].note.include?(Freya::HideGaugeText)
    if @battler.hp == 0 or hide
      self.opacity = 0
    elsif @battler.hp > 0 && !hide
      self.opacity = 255
    end
  end
end

#==============================================================================
# ■ Sprite_Battler
#------------------------------------------------------------------------------
#  显示战斗者的精灵。根据 Game_Battler 类的实例自动变化。
#==============================================================================
class Sprite_Battler < Sprite_Base
  #--------------------------------------------------------------------------
  # ☆ 初始化对象
  #--------------------------------------------------------------------------
  alias initialize_freya_enemy_hp initialize
  def initialize(viewport, battler = nil)
    initialize_freya_enemy_hp(viewport, battler)
    if @battler.is_a?(Game_Enemy)
      @hp_gauge = Sprite_Battler_HP.new(viewport, battler)
      @name_gauge = Sprite_Battler_Name.new(viewport, battler)
    end
  end
  #--------------------------------------------------------------------------
  # ☆ 释放
  #--------------------------------------------------------------------------
  alias dispose_freya_enemy_hp dispose
  def dispose
    dispose_freya_enemy_hp
    unless @hp_gauge.nil?
      @hp_gauge.dispose
    end
    unless @name_gauge.nil?
      @name_gauge.dispose
    end
  end
  #--------------------------------------------------------------------------
  # ☆ 更新画面
  #--------------------------------------------------------------------------
  alias update_freya_enemy_hp update
  def update
    update_freya_enemy_hp
    @hp_gauge.update unless @hp_gauge.nil?
    @name_gauge.update unless @name_gauge.nil?
  end
end

Lv5.捕梦者

梦石
0
星屑
26234
在线时间
5352 小时
注册时间
2016-3-8
帖子
1655
2
发表于 2020-8-7 15:49:58 | 只看该作者
本帖最后由 alexncf125 于 2020-8-7 18:49 编辑
  1. #==============================================================================
  2. # F08 - 战斗敌人显示血条 - By芙蕾娅
  3. #------------------------------------------------------------------------------
  4. #  ★ - 新增  ☆ - 修改  ■ - 删除 ● - 无变更
  5. #==============================================================================
  6. module Freya
  7.   # 隐藏HP的文本
  8.   HideGaugeText = "Hide_Gauge"
  9.   # 血条颜色
  10.   EnemyHPGaugeColor1 = Color.new(64,128,96)
  11.   EnemyHPGaugeColor2 = Color.new(96,192,160)
  12. end
  13. #==============================================================================
  14. # ■ Sprite_Battler_HP
  15. #------------------------------------------------------------------------------
  16. #  显示战斗者的生命在战斗者的精灵下面。
  17. #==============================================================================
  18. class Sprite_Battler_HP < Sprite
  19.   #--------------------------------------------------------------------------
  20.   # ● 初始化对象
  21.   #--------------------------------------------------------------------------
  22.   def initialize(viewport,battler = nil)
  23.     super(viewport)
  24.     @battler = battler
  25.     @last_hp = 0
  26.     create_bitmap
  27.     update
  28.   end
  29.   #--------------------------------------------------------------------------
  30.   # ● 释放
  31.   #--------------------------------------------------------------------------
  32.   def dispose
  33.     self.bitmap.dispose
  34.     super
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # ● 生成位图
  38.   #--------------------------------------------------------------------------
  39.   def create_bitmap
  40.     @last_hp = @battler.hp
  41.     bw = 96
  42.     bh = 6
  43.     self.bitmap = Bitmap.new(bw, bh)
  44.     self.bitmap.fill_rect(0, 0, bw, bh, Color.new(32,32,64))
  45.     if Freya::Gauge_Type.nil? or Freya::Gauge_Type == 0
  46.       hp = ((bw) * @battler.hp_rate).to_i
  47.       self.bitmap.gradient_fill_rect(0, 0, hp, bh, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
  48.     elsif Freya::Gauge_Type == 1
  49.       hp = ((width - 2) * @battler.hp_rate).to_i
  50.       self.bitmap.gradient_fill_rect(1, 1, hp, bh - 2, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
  51.     elsif Freya::Gauge_Type == 2
  52.       hp = ((width) * @battler.hp_rate).to_i
  53.       self.bitmap.gradient_fill_rect(0, 0, hp / 2, bh, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
  54.       self.bitmap.gradient_fill_rect(hp / 2, 0, hp / 2, bh, Freya::EnemyHPGaugeColor2, Freya::EnemyHPGaugeColor1)
  55.     elsif Freya::Gauge_Type == 3
  56.       hp = ((width - 2) * @battler.hp_rate).to_i
  57.       self.bitmap.gradient_fill_rect(1, 1, hp / 2, bh - 2, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
  58.       self.bitmap.gradient_fill_rect((hp / 2) + 1, 1, hp / 2, bh - 2, Freya::EnemyHPGaugeColor2, Freya::EnemyHPGaugeColor1)
  59.     end
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # ● 更新画面
  63.   #--------------------------------------------------------------------------
  64.   def update
  65.     super
  66.     if @battler && [email protected]?
  67.       @use_sprite = @battler.use_sprite?
  68.       if @use_sprite
  69.         update_origin
  70.         update_position
  71.       end
  72.     else
  73.       self.bitmap = nil
  74.     end
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # ● 原点の更新
  78.   #--------------------------------------------------------------------------
  79.   def update_origin
  80.     if bitmap
  81.       self.ox = bitmap.width / 2
  82.       self.oy = bitmap.height
  83.     end
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   # ● 位置の更新
  87.   #--------------------------------------------------------------------------
  88.   def update_position
  89.     self.x = 72
  90.     self.y = 24 + @battler.index * 24
  91.     self.z = @battler.screen_z + 10
  92.     create_bitmap if @last_hp != @battler.hp
  93.     hide = $data_enemies[@battler.enemy_id].note.include?(Freya::HideGaugeText)
  94.     if @battler.hp == 0 or hide
  95.       self.opacity = 0
  96.     elsif @battler.hp > 0 && !hide
  97.       self.opacity = 255
  98.     end
  99.   end
  100. end

  101. class Sprite_Battler_Name < Sprite
  102.   #--------------------------------------------------------------------------
  103.   # ● 初始化对象
  104.   #--------------------------------------------------------------------------
  105.   def initialize(viewport,battler = nil)
  106.     super(viewport)
  107.     @battler = battler
  108.     @name = ""
  109.     create_bitmap
  110.     update
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # ● 释放
  114.   #--------------------------------------------------------------------------
  115.   def dispose
  116.     self.bitmap.dispose
  117.     super
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # ● 生成位图
  121.   #--------------------------------------------------------------------------
  122.   def create_bitmap
  123.     @name = @battler.name
  124.     bw = 120
  125.     bh = 24
  126.     self.bitmap = Bitmap.new(bw, bh)
  127.     self.bitmap.draw_text(0, 0, bw, bh, @name, 0)
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   # ● 更新画面
  131.   #--------------------------------------------------------------------------
  132.   def update
  133.     super
  134.     if @battler && [email protected]?
  135.       @use_sprite = @battler.use_sprite?
  136.       if @use_sprite
  137.         update_origin
  138.         update_position
  139.       end
  140.     else
  141.       self.bitmap = nil
  142.     end
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 原点の更新
  146.   #--------------------------------------------------------------------------
  147.   def update_origin
  148.     if bitmap
  149.       self.ox = bitmap.width / 2
  150.       self.oy = bitmap.height
  151.     end
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # ● 位置の更新
  155.   #--------------------------------------------------------------------------
  156.   def update_position
  157.     self.x = 72
  158.     self.y = 24 + @battler.index * 24
  159.     self.z = @battler.screen_z + 10
  160.     create_bitmap if @last_hp != @battler.hp
  161.     hide = $data_enemies[@battler.enemy_id].note.include?(Freya::HideGaugeText)
  162.     if @battler.hp == 0 or hide
  163.       self.opacity = 0
  164.     elsif @battler.hp > 0 && !hide
  165.       self.opacity = 255
  166.     end
  167.   end
  168. end

  169. #==============================================================================
  170. # ■ Sprite_Battler
  171. #------------------------------------------------------------------------------
  172. #  显示战斗者的精灵。根据 Game_Battler 类的实例自动变化。
  173. #==============================================================================
  174. class Sprite_Battler < Sprite_Base
  175.   #--------------------------------------------------------------------------
  176.   # ☆ 初始化对象
  177.   #--------------------------------------------------------------------------
  178.   alias initialize_freya_enemy_hp initialize
  179.   def initialize(viewport, battler = nil)
  180.     initialize_freya_enemy_hp(viewport, battler)
  181.     if @battler.is_a?(Game_Enemy)
  182.       @hp_gauge = Sprite_Battler_HP.new(viewport, battler)
  183.       @name_gauge = Sprite_Battler_Name.new(viewport, battler)
  184.     end
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # ☆ 释放
  188.   #--------------------------------------------------------------------------
  189.   alias dispose_freya_enemy_hp dispose
  190.   def dispose
  191.     dispose_freya_enemy_hp
  192.     unless @hp_gauge.nil?
  193.       @hp_gauge.dispose
  194.     end
  195.     unless @name_gauge.nil?
  196.       @name_gauge.dispose
  197.     end
  198.   end
  199.   #--------------------------------------------------------------------------
  200.   # ☆ 更新画面
  201.   #--------------------------------------------------------------------------
  202.   alias update_freya_enemy_hp update
  203.   def update
  204.     update_freya_enemy_hp
  205.     @hp_gauge.update unless @hp_gauge.nil?
  206.     @name_gauge.update unless @name_gauge.nil?
  207.   end
  208. end
复制代码

点评

太强了太强了  发表于 2020-8-7 18:33
已更新  发表于 2020-8-7 17:38
大佬,可以在血条前面加上他们的名字吗......当然,前提你有空的话...  发表于 2020-8-7 17:21
回复 支持 2 反对 0

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1063
在线时间
89 小时
注册时间
2023-12-26
帖子
127
3
发表于 2024-5-19 06:56:30 | 只看该作者
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-10 18:16

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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