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

Project1

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

[已经过期] 战斗血条的脚本出现一个问题,求解决

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
14 小时
注册时间
2015-4-5
帖子
31
跳转到指定楼层
1
发表于 2015-5-25 17:41:05 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
设置敌人中途加入以后,隐形的敌人还会显示血条,求解决
  1. class Window_Base < Window  
  2.   #--------------------------------------------------------------------------
  3.   # * Draw Slant Bar
  4.   #--------------------------------------------------------------------------
  5.   def draw_slant_bar(x, y, min, max, width = 152, height = 6,
  6.       bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
  7.     # Draw Border
  8.     for i in 0..height
  9.       self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
  10.     end
  11.     # Draw Background
  12.     for i in 1..(height - 1)
  13.       r = 100 * (height - i) / height + 0 * i / height
  14.       g = 100 * (height - i) / height + 0 * i / height
  15.       b = 100 * (height - i) / height + 0 * i / height
  16.       a = 255 * (height - i) / height + 255 * i / height
  17.       self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
  18.     end
  19.     # Draws Bar
  20.     for i in 1..( (min / max.to_f) * width - 1)
  21.       for j in 1..(height - 1)
  22.         r = bar_color.red * (width - i) / width + end_color.red * i / width
  23.         g = bar_color.green * (width - i) / width + end_color.green * i / width
  24.         b = bar_color.blue * (width - i) / width + end_color.blue * i / width
  25.         a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
  26.         self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
  27.       end
  28.     end
  29.   end
  30. end


  31. class Window_EnemyHP < Window_Base
  32.   
  33.   def initialize
  34.     super(0, 0, 640, 480)
  35.     self.contents = Bitmap.new(width - 32, height - 32)
  36.     self.opacity = 0
  37.     refresh
  38.   end
  39.   
  40.   def refresh
  41.     self.contents.clear
  42.     for i in 0...$game_troop.enemies.size
  43.       @enemy = $game_troop.enemies[i]
  44.       @percent = (@enemy.hp * 100) / @enemy.maxhp
  45.       unless @enemy.hp == 0
  46.       draw_slant_bar(@enemy.screen_x - 55, @enemy.screen_y - 10, @enemy.hp, @enemy.maxhp, width = 75, height = 6, bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
  47.       self.contents.draw_text(@enemy.screen_x - 39, @enemy.screen_y - 22, 100, 32, "#{@percent}" + "%")
  48.     end
  49.   end
  50. end
  51. end

  52. class Scene_Battle
  53.   
  54.   alias raz_update update
  55.   alias raz_update_phase5 update_phase5
  56.   alias raz_update_phase4_step1 update_phase4_step1
  57.   alias raz_update_phase4_step5 update_phase4_step5
  58.   alias raz_enemy_hp_main main
  59.   
  60.    def main
  61.     @troop_id = $game_temp.battle_troop_id
  62.     $game_troop.setup(@troop_id)
  63.     @enemy_window = Window_EnemyHP.new
  64.     @enemy_window.z = 95
  65.     raz_enemy_hp_main
  66.     @enemy_window.dispose
  67.   end

  68.   
  69.   def update
  70.     @enemy_window.update
  71.     raz_update
  72.   end

  73.   def update_phase5
  74.     # If wait count is larger than 0
  75.     if @phase5_wait_count > 0
  76.       # Decrease wait count
  77.       @phase5_wait_count -= 1
  78.       # If wait count reaches 0
  79.       if @phase5_wait_count == 0
  80.         @enemy_window.visible = false
  81.         # Show result window
  82.         @result_window.visible = true
  83.         # Clear main phase flag
  84.         $game_temp.battle_main_phase = false
  85.         # Refresh status window
  86.         @status_window.refresh
  87.         @enemy_window.refresh
  88.       end
  89.       return
  90.     end
  91.    raz_update_phase5
  92. end

  93. def update_phase4_step1
  94.   raz_update_phase4_step1
  95.   @enemy_window.refresh
  96. end

  97.   def update_phase4_step5
  98.     # Hide help window
  99.     @help_window.visible = false
  100.     # Refresh status window
  101.     @status_window.refresh
  102.     @enemy_window.refresh
  103.     raz_update_phase4_step5
  104.   end
  105. end

  106. class Window_BattleStatus < Window_Base
  107.   #--------------------------------------------------------------------------
  108.   # * Object Initialization
  109.   #--------------------------------------------------------------------------
  110.   def initialize
  111.     super(0, 320, 640, 160)
  112.     self.contents = Bitmap.new(width - 32, height - 32)
  113.     @level_up_flags = [false, false, false, false]
  114.     refresh
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # * Dispose
  118.   #--------------------------------------------------------------------------
  119.   def dispose
  120.     super
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # * Set Level Up Flag
  124.   #     actor_index : actor index
  125.   #--------------------------------------------------------------------------
  126.   def level_up(actor_index)
  127.     @level_up_flags[actor_index] = true
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   # * Refresh
  131.   #--------------------------------------------------------------------------
  132.   def refresh
  133.     self.contents.clear
  134.     @item_max = $game_party.actors.size
  135.     for i in 0...$game_party.actors.size
  136.       actor = $game_party.actors[i]
  137.       actor_x = i * 160 + 4
  138.       draw_slant_bar(actor_x, 55, actor.hp, actor.maxhp, 120)
  139.       draw_slant_bar(actor_x, 88, actor.sp, actor.maxsp, 120, 6, bar_color = Color.new(150, 0, 150, 255), end_color = Color.new(0, 0, 255, 255))
  140.       draw_actor_name(actor, actor_x, 0)
  141.       draw_actor_hp(actor, actor_x, 32, 120)
  142.       draw_actor_sp(actor, actor_x, 64, 120)
  143.       if @level_up_flags[i]
  144.         self.contents.font.color = normal_color
  145.         self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
  146.       else
  147.         draw_actor_state(actor, actor_x, 96)
  148.       end
  149.     end
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # * Frame Update
  153.   #--------------------------------------------------------------------------
  154.   def update
  155.     super
  156.     # Slightly lower opacity level during main phase
  157.     if $game_temp.battle_main_phase
  158.       self.contents_opacity -= 4 if self.contents_opacity > 191
  159.     else
  160.       self.contents_opacity += 4 if self.contents_opacity < 255
  161.     end
  162.   end
  163. end
复制代码

Lv5.捕梦者

梦石
0
星屑
33434
在线时间
5108 小时
注册时间
2012-11-19
帖子
4878

开拓者

2
发表于 2015-5-25 18:04:23 | 只看该作者
这个试一下
  1. class Window_Base < Window  
  2.   #--------------------------------------------------------------------------
  3.   # * Draw Slant Bar
  4.   #--------------------------------------------------------------------------
  5.   def draw_slant_bar(x, y, min, max, width = 152, height = 6,
  6.       bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
  7.     # Draw Border
  8.     for i in 0..height
  9.       self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
  10.     end
  11.     # Draw Background
  12.     for i in 1..(height - 1)
  13.       r = 100 * (height - i) / height + 0 * i / height
  14.       g = 100 * (height - i) / height + 0 * i / height
  15.       b = 100 * (height - i) / height + 0 * i / height
  16.       a = 255 * (height - i) / height + 255 * i / height
  17.       self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
  18.     end
  19.     # Draws Bar
  20.     for i in 1..( (min / max.to_f) * width - 1)
  21.       for j in 1..(height - 1)
  22.         r = bar_color.red * (width - i) / width + end_color.red * i / width
  23.         g = bar_color.green * (width - i) / width + end_color.green * i / width
  24.         b = bar_color.blue * (width - i) / width + end_color.blue * i / width
  25.         a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
  26.         self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
  27.       end
  28.     end
  29.   end
  30. end


  31. class Window_EnemyHP < Window_Base
  32.   
  33.   def initialize
  34.     super(0, 0, 640, 480)
  35.     self.contents = Bitmap.new(width - 32, height - 32)
  36.     self.opacity = 0
  37.     refresh
  38.   end
  39.   
  40.   def refresh
  41.     self.contents.clear
  42.     for i in 0...$game_troop.enemies.size
  43.       @enemy = $game_troop.enemies[i]
  44.       next unless @enemy.exist?
  45.       @percent = (@enemy.hp * 100) / @enemy.maxhp
  46.       unless @enemy.hp == 0
  47.       draw_slant_bar(@enemy.screen_x - 55, @enemy.screen_y - 10, @enemy.hp, @enemy.maxhp, width = 75, height = 6, bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
  48.       self.contents.draw_text(@enemy.screen_x - 39, @enemy.screen_y - 22, 100, 32, "#{@percent}" + "%")
  49.     end
  50.   end
  51. end
  52. end

  53. class Scene_Battle
  54.   
  55.   alias raz_update update
  56.   alias raz_update_phase5 update_phase5
  57.   alias raz_update_phase4_step1 update_phase4_step1
  58.   alias raz_update_phase4_step5 update_phase4_step5
  59.   alias raz_enemy_hp_main main
  60.   
  61.    def main
  62.     @troop_id = $game_temp.battle_troop_id
  63.     $game_troop.setup(@troop_id)
  64.     @enemy_window = Window_EnemyHP.new
  65.     @enemy_window.z = 95
  66.     raz_enemy_hp_main
  67.     @enemy_window.dispose
  68.   end

  69.   
  70.   def update
  71.     @enemy_window.update
  72.     raz_update
  73.   end

  74.   def update_phase5
  75.     # If wait count is larger than 0
  76.     if @phase5_wait_count > 0
  77.       # Decrease wait count
  78.       @phase5_wait_count -= 1
  79.       # If wait count reaches 0
  80.       if @phase5_wait_count == 0
  81.         @enemy_window.visible = false
  82.         # Show result window
  83.         @result_window.visible = true
  84.         # Clear main phase flag
  85.         $game_temp.battle_main_phase = false
  86.         # Refresh status window
  87.         @status_window.refresh
  88.         @enemy_window.refresh
  89.       end
  90.       return
  91.     end
  92.    raz_update_phase5
  93. end

  94. def update_phase4_step1
  95.   raz_update_phase4_step1
  96.   @enemy_window.refresh
  97. end

  98.   def update_phase4_step5
  99.     # Hide help window
  100.     @help_window.visible = false
  101.     # Refresh status window
  102.     @status_window.refresh
  103.     @enemy_window.refresh
  104.     raz_update_phase4_step5
  105.   end
  106. end

  107. class Window_BattleStatus < Window_Base
  108.   #--------------------------------------------------------------------------
  109.   # * Object Initialization
  110.   #--------------------------------------------------------------------------
  111.   def initialize
  112.     super(0, 320, 640, 160)
  113.     self.contents = Bitmap.new(width - 32, height - 32)
  114.     @level_up_flags = [false, false, false, false]
  115.     refresh
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # * Dispose
  119.   #--------------------------------------------------------------------------
  120.   def dispose
  121.     super
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # * Set Level Up Flag
  125.   #     actor_index : actor index
  126.   #--------------------------------------------------------------------------
  127.   def level_up(actor_index)
  128.     @level_up_flags[actor_index] = true
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # * Refresh
  132.   #--------------------------------------------------------------------------
  133.   def refresh
  134.     self.contents.clear
  135.     @item_max = $game_party.actors.size
  136.     for i in 0...$game_party.actors.size
  137.       actor = $game_party.actors[i]
  138.       actor_x = i * 160 + 4
  139.       draw_slant_bar(actor_x, 55, actor.hp, actor.maxhp, 120)
  140.       draw_slant_bar(actor_x, 88, actor.sp, actor.maxsp, 120, 6, bar_color = Color.new(150, 0, 150, 255), end_color = Color.new(0, 0, 255, 255))
  141.       draw_actor_name(actor, actor_x, 0)
  142.       draw_actor_hp(actor, actor_x, 32, 120)
  143.       draw_actor_sp(actor, actor_x, 64, 120)
  144.       if @level_up_flags[i]
  145.         self.contents.font.color = normal_color
  146.         self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
  147.       else
  148.         draw_actor_state(actor, actor_x, 96)
  149.       end
  150.     end
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # * Frame Update
  154.   #--------------------------------------------------------------------------
  155.   def update
  156.     super
  157.     # Slightly lower opacity level during main phase
  158.     if $game_temp.battle_main_phase
  159.       self.contents_opacity -= 4 if self.contents_opacity > 191
  160.     else
  161.       self.contents_opacity += 4 if self.contents_opacity < 255
  162.     end
  163.   end
  164. end
复制代码

评分

参与人数 1星屑 +100 梦石 +1 收起 理由
hys111111 + 100 + 1 认可答案

查看全部评分

xp vx va mv  va mz 各类型脚本/插件定制
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
14 小时
注册时间
2015-4-5
帖子
31
3
 楼主| 发表于 2015-5-25 18:35:14 | 只看该作者
芯☆淡茹水 发表于 2015-5-25 18:04
这个试一下

可以,谢谢啦~
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-14 19:21

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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