Project1

标题: 关于战斗血条的2个问题 [打印本页]

作者: 步兵中尉    时间: 2009-3-18 18:50
标题: 关于战斗血条的2个问题
    最近用了下面的脚本,发现其他的都很好,就是不显示角色的名字了。
    请问诸位大侠有办法保持它原有功能基础上填加角色名字吗?
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================


  4. # ————————————————————————————————————

  5. # ▼▲▼ XRXS_BP 7. バトルステータス?クリアデザイン ver.1.03 ▼▲▼
  6. # by 桜雅 在土

  7. #==============================================================================
  8. # ■ Window_BattleStatus
  9. #==============================================================================
  10. class Window_BattleStatus < Window_Base
  11.   #--------------------------------------------------------------------------
  12.   # ● 公開インスタンス変数
  13.   #--------------------------------------------------------------------------
  14.   attr_accessor :update_cp_only # CPメーターのみの更新
  15.   #--------------------------------------------------------------------------
  16.   # ● オブジェクト初期化
  17.   #--------------------------------------------------------------------------
  18.   alias xrxs_bp7_initialize initialize
  19.   def initialize
  20.     # 初期化
  21.     @previous_hp = []
  22.     @previous_sp = []
  23.     # 呼び戻す
  24.     xrxs_bp7_initialize
  25.     # ↓Full-Viewの場合は下二行の # を消してください。
  26.     #self.opacity = 0
  27.     #self.back_opacity = 0
  28.   end
  29.   #--------------------------------------------------------------------------
  30.   # ● リフレッシュ
  31.   #--------------------------------------------------------------------------
  32.   alias xrxs_bp7_refresh refresh
  33.   def refresh
  34.     # CPメーターの更新のみ の場合
  35.     if @update_cp_only
  36.       xrxs_bp7_refresh
  37.       return
  38.     end
  39.     # 変更するものがない場合、飛ばす
  40.     @item_max = $game_party.actors.size
  41.     bool = false
  42.     for i in 0...@item_max
  43.       actor = $game_party.actors[i]
  44.       if (@previous_hp[i] != actor.hp) or (@previous_sp[i] != actor.sp)
  45.         bool = true
  46.       end
  47.     end
  48.     return if bool == false
  49.     # 描写を開始
  50.     self.contents.clear
  51.     for i in 0...@item_max
  52.       actor = $game_party.actors[i]
  53.       actor_x = i * 160 + 21
  54.       # 歩行キャラグラフィックの描写
  55.       draw_actor_graphic(actor, actor_x - 9, 116)
  56.       # HP/SPメーターの描写
  57.       draw_actor_hp_meter_line(actor, actor_x, 52, 96, 12)
  58.       draw_actor_sp_meter_line(actor, actor_x, 84, 96, 12)
  59.       # HP数値の描写
  60.       self.contents.font.size = 24 # HP/SP数値の文字の大きさ
  61.       self.contents.font.color = Color.new(0,0,0,192)
  62.       self.contents.draw_text(actor_x, 40, 96, 24, actor.hp.to_s, 2)
  63.       self.contents.font.color = actor.hp == 0 ? knockout_color :
  64.       actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
  65.       self.contents.draw_text(actor_x-2, 38, 96, 24, actor.hp.to_s, 2)
  66.       # SP数値の描写
  67.       self.contents.font.color = Color.new(0,0,0,192)
  68.       self.contents.draw_text(actor_x, 72, 96, 24, actor.sp.to_s, 2)
  69.       self.contents.font.color = actor.sp == 0 ? knockout_color :
  70.       actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
  71.       self.contents.draw_text(actor_x-2, 70, 96, 24, actor.sp.to_s, 2)
  72.       # 用語「HP」と用語「SP」の描写
  73.       self.contents.font.size = 18 # 用語「HP/SP」の文字の大きさ
  74.       self.contents.font.color = Color.new(0,0,0,192)
  75.       self.contents.draw_text(actor_x+2, 32, 196, 24, $data_system.words.hp)
  76.       self.contents.draw_text(actor_x+2, 64, 196, 24, $data_system.words.sp)
  77.       self.contents.font.color = system_color # 用語「HP/SP」の文字の色
  78.       self.contents.draw_text(actor_x, 30, 196, 24, $data_system.words.hp)
  79.       self.contents.draw_text(actor_x, 62, 196, 24, $data_system.words.sp)
  80.       # ステートの描写
  81.       draw_actor_state(actor, actor_x, 100)
  82.       # 値を更新
  83.       @previous_hp[i] = actor.hp
  84.       @previous_hp[i] = actor.hp
  85.     end
  86.   end
  87. end
  88. #==============================================================================
  89. # ■ Window_Base
  90. #==============================================================================
  91. class Window_Base < Window
  92.   #--------------------------------------------------------------------------
  93.   # ● HPメーター の描画
  94.   #--------------------------------------------------------------------------
  95.   def draw_actor_hp_meter_line(actor, x, y, width = 156, height = 4)
  96.     w = width * actor.hp / [actor.maxhp,1].max
  97.     hp_color_1 = Color.new(255, 0, 0, 192)
  98.     hp_color_2 = Color.new(255, 255, 0, 192)
  99.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
  100.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  101.     x -= 1
  102.     y += (height/4).floor
  103.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  104.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  105.     x -= 1
  106.     y += (height/4).ceil
  107.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  108.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  109.     x -= 1
  110.     y += (height/4).ceil
  111.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
  112.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  113.   end
  114.   #--------------------------------------------------------------------------
  115.   # ● SPメーター の描画
  116.   #--------------------------------------------------------------------------
  117.   def draw_actor_sp_meter_line(actor, x, y, width = 156, height = 4)
  118.     w = width * actor.sp / [actor.maxsp,1].max
  119.     hp_color_1 = Color.new( 0, 0, 255, 192)
  120.     hp_color_2 = Color.new( 0, 255, 255, 192)
  121.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
  122.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  123.     x -= 1
  124.     y += (height/4).floor
  125.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  126.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  127.     x -= 1
  128.     y += (height/4).ceil
  129.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))
  130.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)
  131.     x -= 1
  132.     y += (height/4).ceil
  133.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))
  134.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # ● 名前の描画
  138.   #--------------------------------------------------------------------------
  139.   alias xrxs_bp7_draw_actor_name draw_actor_name
  140.   def draw_actor_name(actor, x, y)
  141.     xrxs_bp7_draw_actor_name(actor, x, y) if @draw_ban != true
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # ● ステートの描画
  145.   #--------------------------------------------------------------------------
  146.   alias xrxs_bp7_draw_actor_state draw_actor_state
  147.   def draw_actor_state(actor, x, y, width = 120)
  148.     xrxs_bp7_draw_actor_state(actor, x, y, width) if @draw_ban != true
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   # ● HP の描画
  152.   #--------------------------------------------------------------------------
  153.   alias xrxs_bp7_draw_actor_hp draw_actor_hp
  154.   def draw_actor_hp(actor, x, y, width = 144)
  155.     xrxs_bp7_draw_actor_hp(actor, x, y, width) if @draw_ban != true
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ● SP の描画
  159.   #--------------------------------------------------------------------------
  160.   alias xrxs_bp7_draw_actor_sp draw_actor_sp
  161.   def draw_actor_sp(actor, x, y, width = 144)
  162.     xrxs_bp7_draw_actor_sp(actor, x, y, width) if @draw_ban != true
  163.   end
  164. end
  165. #==============================================================================
  166. # ■ Scene_Battle
  167. #==============================================================================
  168. class Scene_Battle
  169.   #--------------------------------------------------------------------------
  170.   # ● フレーム更新
  171.   #--------------------------------------------------------------------------
  172.   alias xrxs_bp7_update update
  173.   def update
  174.     xrxs_bp7_update
  175.     # メッセージウィンドウ表示中の場合
  176.     if $game_temp.message_window_showing
  177.       @status_window.update_cp_only = true      
  178.     else
  179.       @status_window.update_cp_only = false
  180.     end
  181.   end
  182. end
  183. #==============================================================================
  184. # ◇ 外部ライブラリ
  185. #==============================================================================
  186. class Window_Base
  187.   #--------------------------------------------------------------------------
  188.   # ● ライン描画 軽量版 by 桜雅 在土
  189.   #--------------------------------------------------------------------------
  190.   def draw_lineght(start_x, start_y, end_x, end_y, start_color)
  191.     # 描写距離の計算。大きめに直角時の長さ。
  192.     distance = (start_x - end_x).abs + (start_y - end_y).abs
  193.     # 描写開始
  194.     for i in 1..distance
  195.       x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
  196.       y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
  197.       self.contents.set_pixel(x, y, start_color)
  198.     end
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # ● ライン描画 by 桜雅 在土
  202.   #--------------------------------------------------------------------------
  203.   def draw_line(start_x, start_y, end_x, end_y, start_color, width = 1, end_color = start_color)
  204.     # 描写距離の計算。大きめに直角時の長さ。
  205.     distance = (start_x - end_x).abs + (start_y - end_y).abs
  206.     # 描写開始
  207.     if end_color == start_color
  208.       for i in 1..distance
  209.         x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
  210.         y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
  211.         if width == 1
  212.           self.contents.set_pixel(x, y, start_color)
  213.         else
  214.           self.contents.fill_rect(x, y, width, width, start_color)
  215.         end
  216.       end
  217.     else
  218.       for i in 1..distance
  219.         x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
  220.         y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
  221.         r = start_color.red * (distance-i)/distance + end_color.red * i/distance
  222.         g = start_color.green * (distance-i)/distance + end_color.green * i/distance
  223.         b = start_color.blue * (distance-i)/distance + end_color.blue * i/distance
  224.         a = start_color.alpha * (distance-i)/distance + end_color.alpha * i/distance
  225.         if width == 1
  226.           self.contents.set_pixel(x, y, Color.new(r, g, b, a))
  227.         else
  228.           self.contents.fill_rect(x, y, width, width, Color.new(r, g, b, a))
  229.         end
  230.       end
  231.     end
  232.   end
  233. end


  234. #==============================================================================
  235. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  236. #==============================================================================
复制代码

另一个是敌人下方始终有血槽,能能否去掉?
  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

复制代码

解答任意一个都可以。 [LINE]1,#dddddd[/LINE]此贴于 2009-3-19 10:23:34 被版主redant提醒,请楼主看到后对本贴做出回应。 [LINE]1,#dddddd[/LINE]此贴于 2009-3-20 9:53:55 被版主redant提醒,请楼主看到后对本贴做出回应。 [LINE]1,#dddddd[/LINE]版务信息:本贴由楼主自主结贴~
作者: 步兵中尉    时间: 2009-3-19 17:38
    没有应答?
    拜托诸位大侠帮帮忙吧!
作者: redant    时间: 2009-3-19 18:23
# HP/SPメーターの描写
      draw_actor_hp_meter_line(actor, actor_x, 52, 96, 12)
      draw_actor_sp_meter_line(actor, actor_x, 84, 96, 12)
下加
draw_actor_name(actor, 610 - 40 ,210 )
试试
作者: 步兵中尉    时间: 2009-3-20 02:37
     还是行不通,没有丝毫改变。

    如果可以,优先解决第二个。
作者: redant    时间: 2009-3-20 17:53
还是 看2L
self.contents.font.size = 18
draw_actor_name(actor, actor_x ,20 )

只是坐标问题 图就不截了 保证行 =。=
第二种方法 其实一样
self.contents.draw_text(actor_x, 20, 120, 32, actor.name)
85行左右

问题2

搜索 draw_slant_bar(@enemy.screen_x - 55
就是这行 注释掉 然后血条没了 只有%比



[LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
作者: 步兵中尉    时间: 2009-3-20 21:09
    问题2的百分比能去掉吗?
作者: redant    时间: 2009-3-20 21:13
self.contents.draw_text(@enemy.screen_x - 39, @enemy.screen_y - 22, 100, 32, "#{@percent}" + "%")

注释掉 看看有效果没




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