查看: 3768|回复: 4

[已经解决] 芙蕾雅的敌人血槽脚本出错

[复制链接]
梦石
0
星屑
50
在线时间
74 小时
注册时间
2015-5-7
回帖
100
发表于 2015-6-11 18:11:51 | 显示全部楼层 |阅读模式

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

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

×
刚刚找到了一个敌人血槽脚本,好兴奋呢,正准备开始品味

结果战斗测试时出现这般错误
QQ图片20150611181257.png

各位大触,如何解决

[pre lang="ruby"]#==============================================================================
# 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)
    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 = 96
    bh = 6
    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
    unless self.bitmap.nil?
      self.x = @battler.screen_x - self.width / 2
      self.y = @battler.screen_y
      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
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)
    end
  end
  #--------------------------------------------------------------------------
  # ☆ 释放
  #--------------------------------------------------------------------------
  alias dispose_freya_enemy_hp dispose
  def dispose
    dispose_freya_enemy_hp
    unless @hp_gauge.nil?
      @hp_gauge.dispose
    end
  end
  #--------------------------------------------------------------------------
  # ☆ 更新画面
  #--------------------------------------------------------------------------
  alias update_freya_enemy_hp update
  def update
    update_freya_enemy_hp
    @hp_gauge.update unless @hp_gauge.nil?
  end
end[/pre]












快戳我!!←新人作——江湖录

梦石
1
星屑
23236
在线时间
9564 小时
注册时间
2012-6-19
回帖
7018

开拓者短篇九导演组冠军

发表于 2015-6-11 21:48:38 | 显示全部楼层
额外插入这个脚本试试看
http://rpg.blue/home.php?mod=spa ... o=blog&id=10812

评分

参与人数 1星屑 +132 收起 理由
VIPArcher + 132 我很赞同

查看全部评分

回复

使用道具 举报

梦石
0
星屑
241
在线时间
23 小时
注册时间
2017-11-22
回帖
35
发表于 2017-11-23 08:48:58 | 显示全部楼层
喵呜喵5 发表于 2015-6-11 21:48
额外插入这个脚本试试看
http://rpg.blue/home.php?mod=space&uid=310500&do=blog&id=10812

请问这个应该贴到哪里谢谢大神

点评

贴到血条脚本上面  发表于 2017-11-23 09:36
回复

使用道具 举报

梦石
0
星屑
241
在线时间
23 小时
注册时间
2017-11-22
回帖
35
发表于 2017-11-23 12:14:53 | 显示全部楼层
xkwzx 发表于 2017-11-23 08:48
请问这个应该贴到哪里谢谢大神

好的谢谢
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部