Project1

标题: 使用显示敌人血量脚本在战斗结束时会出现脚本错误如何解 [打印本页]

作者: srg123    时间: 2012-11-13 14:24
标题: 使用显示敌人血量脚本在战斗结束时会出现脚本错误如何解
RT附上图
def dispose
if self.bitmap != nil
self.bitmap.dispose
@enemy_hpmp_window.dispose
end
super
end
请问哪里出错了?dsu_plus_rewardpost_czw
作者: srg123    时间: 2012-11-13 20:52
当然有
这脚本本来有显示确切的血量数值 和MP数字我把它改掉了
下面是脚本
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, 0, line_height, Vocab::hp_a)
self.contents.font.color = hp_color(enemy)
self.contents.draw_text(x + width - 0, y, 0, line_height, enemy.hp, 0)
#一个数字占16像素
end
#--------------------------------------------------------------------------
# ● 绘制敌人MP
#--------------------------------------------------------------------------
def draw_enemy_mp(enemy, x, y, width = 0)
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, 0, line_height, Vocab::mp_a)
self.contents.font.color = mp_color(enemy)
self.contents.draw_text(x + width - 0, y,0, line_height, enemy.mp, 0)
end
end
作者: 无名小兵    时间: 2012-11-14 09:29
SBS系统 好像跟这个系统冲突 打完或者逃跑 都提示 没有释放什么精灵。。。然后就PASS这个显血
作者: 芙蕾娅    时间: 2012-11-14 12:19
http://rpg.blue/thread-252003-1-1.html
试试使用编号F08看看?
作者: fuwang    时间: 2012-11-14 21:03
……改成这样试试看?
def dispose
if self.bitmap != nil
self.bitmap.dispose
if @enemy_hpmp_window != nil
@enemy_hpmp_window.dispose
end
end
super
end
作者: 无名小兵    时间: 2012-11-15 18:23
芙蕾娅 发表于 2012-11-14 12:19
http://rpg.blue/thread-252003-1-1.html
试试使用编号F08看看?

亲,你的显血版本跟SideView没效果哦
作者: 芙蕾娅    时间: 2012-11-15 19:43
本帖最后由 芙蕾娅 于 2012-11-25 13:14 编辑
无名小兵 发表于 2012-11-15 18:23
亲,你的显血版本跟SideView没效果哦


坐标稍微计算错误,改了些,这下应该有效果了
  1. #==============================================================================
  2. # F08 - 战斗敌人显示血条·改 - By芙蕾娅
  3. #    对应横板战斗版本
  4. #------------------------------------------------------------------------------
  5. #  ★ - 新增  ☆ - 修改  ■ - 删除 ● - 无变更
  6. #==============================================================================
  7. module Freya
  8.   # 隐藏HP的文本
  9.   HideGaugeText = "Hide_Gauge"
  10.   # 血条颜色
  11.   EnemyHPGaugeColor1 = Color.new(64,128,96)
  12.   EnemyHPGaugeColor2 = Color.new(96,192,160)
  13. end
  14. #==============================================================================
  15. # ■ Sprite_Battler_HP
  16. #------------------------------------------------------------------------------
  17. #  显示战斗者的生命在战斗者的精灵下面。
  18. #==============================================================================
  19. class Sprite_Battler_HP < Sprite
  20.   #--------------------------------------------------------------------------
  21.   # ● 初始化对象
  22.   #--------------------------------------------------------------------------
  23.   def initialize(viewport,battler)
  24.     super(viewport)
  25.     [url=home.php?mod=space&uid=133701]@battler[/url] = battler
  26.     @last_hp = 0
  27.     create_bitmap
  28.     update
  29.   end
  30.   #--------------------------------------------------------------------------
  31.   # ● 释放
  32.   #--------------------------------------------------------------------------
  33.   def dispose
  34.     self.bitmap.dispose
  35.     super
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # ● 生成位图
  39.   #--------------------------------------------------------------------------
  40.   def create_bitmap
  41.     @last_hp = @battler.hp
  42.     bw = 96
  43.     bh = 6
  44.     self.bitmap = Bitmap.new(bw, bh)
  45.     self.bitmap.fill_rect(0, 0, bw, bh, Color.new(32,32,64))
  46.     if Freya::Gauge_Type.nil? or Freya::Gauge_Type == 0
  47.       hp = ((bw) * @battler.hp_rate).to_i
  48.       self.bitmap.gradient_fill_rect(0, 0, hp, bh, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
  49.     elsif Freya::Gauge_Type == 1
  50.       hp = ((width - 2) * @battler.hp_rate).to_i
  51.       self.bitmap.gradient_fill_rect(1, 1, hp, bh - 2, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
  52.     elsif Freya::Gauge_Type == 2
  53.       hp = ((width) * @battler.hp_rate).to_i
  54.       self.bitmap.gradient_fill_rect(0, 0, hp / 2, bh, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
  55.       self.bitmap.gradient_fill_rect(hp / 2, 0, hp / 2, bh, Freya::EnemyHPGaugeColor2, Freya::EnemyHPGaugeColor1)
  56.     elsif Freya::Gauge_Type == 3
  57.       hp = ((width - 2) * @battler.hp_rate).to_i
  58.       self.bitmap.gradient_fill_rect(1, 1, hp / 2, bh - 2, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
  59.       self.bitmap.gradient_fill_rect((hp / 2) + 1, 1, hp / 2, bh - 2, Freya::EnemyHPGaugeColor2, Freya::EnemyHPGaugeColor1)
  60.     end
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # ● 更新画面
  64.   #--------------------------------------------------------------------------
  65.   def update
  66.     super
  67.     unless self.bitmap.nil?
  68.       self.z = @battler.sv.z + 20
  69.       create_bitmap if @last_hp != @battler.hp
  70.       hide = $data_enemies[@battler.enemy_id].note.include?(Freya::HideGaugeText)
  71.       self.opacity = 0 if @battler.hp == 0 or hide
  72.     end
  73.   end
  74. end

  75. #==============================================================================
  76. # ■ Sprite_Battler
  77. #------------------------------------------------------------------------------
  78. #  显示战斗者的精灵。根据 Game_Battler 类的实例自动变化。
  79. #==============================================================================
  80. class Sprite_Battler < Sprite_Base
  81.   #--------------------------------------------------------------------------
  82.   # ☆ 初始化对象
  83.   #--------------------------------------------------------------------------
  84.   alias initialize_freya_enemy_hp initialize
  85.   def initialize(viewport, battler = nil)
  86.     initialize_freya_enemy_hp(viewport, battler)
  87.     if @battler.is_a?(Game_Enemy)
  88.       @hp_gauge = Sprite_Battler_HP.new(viewport, battler)
  89.     end
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # ☆ 释放
  93.   #--------------------------------------------------------------------------
  94.   alias dispose_freya_enemy_hp dispose
  95.   def dispose
  96.     dispose_freya_enemy_hp
  97.     unless @hp_gauge.nil?
  98.       @hp_gauge.dispose
  99.     end
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # ☆ 更新画面
  103.   #--------------------------------------------------------------------------
  104.   alias update_freya_enemy_hp update
  105.   def update
  106.     update_freya_enemy_hp
  107.     @hp_gauge.update unless @hp_gauge.nil?
  108.   end
  109.   alias update_freya_position update_position
  110.   def update_position
  111.     update_freya_position
  112.     @hp_gauge.x = self.x - 48 unless @hp_gauge.nil?
  113.     @hp_gauge.y = self.y unless @hp_gauge.nil?
  114.   end
  115. end
复制代码


若要显示名字则把这段覆盖掉原本的def create_bitmap(40~61行)
  1.   def create_bitmap
  2.     @last_hp = @battler.hp
  3.     bw = 96
  4.     bh = 24
  5.     self.bitmap = Bitmap.new(bw, bh)
  6.     self.bitmap.fill_rect(0, 0, bw, 6, Color.new(32,32,64))
  7.     if Freya::Gauge_Type.nil? or Freya::Gauge_Type == 0
  8.       hp = ((bw) * @battler.hp_rate).to_i
  9.       self.bitmap.gradient_fill_rect(0, 0, hp, 6, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
  10.     elsif Freya::Gauge_Type == 1
  11.       hp = ((width - 2) * @battler.hp_rate).to_i
  12.       self.bitmap.gradient_fill_rect(1, 1, hp, 6 - 2, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
  13.     elsif Freya::Gauge_Type == 2
  14.       hp = ((width) * @battler.hp_rate).to_i
  15.       self.bitmap.gradient_fill_rect(0, 0, hp / 2, 6, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
  16.       self.bitmap.gradient_fill_rect(hp / 2, 0, hp / 2, 6, Freya::EnemyHPGaugeColor2, Freya::EnemyHPGaugeColor1)
  17.     elsif Freya::Gauge_Type == 3
  18.       hp = ((width - 2) * @battler.hp_rate).to_i
  19.       self.bitmap.gradient_fill_rect(1, 1, hp / 2, 6 - 2, Freya::EnemyHPGaugeColor1, Freya::EnemyHPGaugeColor2)
  20.       self.bitmap.gradient_fill_rect((hp / 2) + 1, 1, hp / 2, 6 - 2, Freya::EnemyHPGaugeColor2, Freya::EnemyHPGaugeColor1)
  21.     end
  22.     self.bitmap.draw_text(0,0,bw,24,@battler.name)
  23.   end
复制代码





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1