Project1

标题: 求帮忙改动这个脚本 [打印本页]

作者: jamessong    时间: 2012-5-21 19:20
标题: 求帮忙改动这个脚本
这是个战斗中显示敌人生命条/气条 的脚本。问题是这个脚本一直显示敌人的生命,我想设置成 主角 用个技能(比如说神眼)。然后显示敌人生命,如果不用技能则不显示敌人生命条/气条。
有人能帮忙改下么?我不会改,请大家帮帮忙!谢谢了。

#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
# ■ エネミーHP&SP(ver 0.98)
# □ カスタマイズポイント
#==============================================================================
module PLAN_HPSP_DRAW
FONT_NAME         = ["黑体", "楷体", "宋体"]    # フォント
FONT_SIZE         =  14                               # フォントサイズ
FONT_BOLD         = true                              # 太字
FONT_ITALIC       = true                              # 斜体
DRAW_NAME         = false                             # 名前の描画
DRAW_HP           = true                              # HP の描画
DRAW_SP           = true                              # SP の描画
DRAW_WIDTH        =  80                               # 描画幅
DRAW_HEIGHT       = 3 * 32                            # 描画高さ
DRAW_SPACE        =   0                               # 行間
DRAW_Y            =  36                               # Y 座標修正値
end
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < RPG::Sprite
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias plan_enemy_hpsp_draw_initialize initialize
def initialize(viewport, battler = nil)
   # 元のメソッドに戻す
   plan_enemy_hpsp_draw_initialize(viewport, battler)
   # エネミーの場合
   if @battler.is_a?(Game_Enemy)
     width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
     height = PLAN_HPSP_DRAW::DRAW_HEIGHT + 32
     x = @battler.screen_x - width / 2
     y = @battler.screen_y - height + 32 + PLAN_HPSP_DRAW::DRAW_Y
     @enemy_hpsp_window = Window_Base.new(x, y, width, height)
     @enemy_hpsp_window.contents = Bitmap.new(width - 32, height - 32)
     @enemy_hpsp_window.contents.font.name = PLAN_HPSP_DRAW::FONT_NAME
     @enemy_hpsp_window.contents.font.size = PLAN_HPSP_DRAW::FONT_SIZE
     @enemy_hpsp_window.contents.font.bold = PLAN_HPSP_DRAW::FONT_BOLD
     @enemy_hpsp_window.contents.font.italic = PLAN_HPSP_DRAW::FONT_ITALIC
     y = 0
     @old_enemy_hpsp = []
     one_line = ((PLAN_HPSP_DRAW::FONT_SIZE * 100 / 28) * 32) / 100
     if PLAN_HPSP_DRAW::DRAW_NAME
       @enemy_hpsp_window.draw_actor_name(@battler, 0, y, width - 32)
       y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
       @old_enemy_hpsp.push(@battler.name)
     end
     if PLAN_HPSP_DRAW::DRAW_HP
       @enemy_hpsp_window.draw_actor_hp2222(@battler, 0, y, width - 32)
       y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
       @old_enemy_hpsp.push(@battler.hp)
     end
     if PLAN_HPSP_DRAW::DRAW_SP
       @enemy_hpsp_window.draw_actor_sp2222(@battler, 0, y, width - 32)
       @old_enemy_hpsp.push(@battler.sp)
     end
     @enemy_hpsp_window.opacity = 0
     @enemy_hpsp_window.contents_opacity = 0
     @enemy_hpsp_window.z = -2
   end
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
alias plan_enemy_hpsp_draw_dispose dispose
def dispose
   # エネミーの場合
   if @battler.is_a?(Game_Enemy)
     @enemy_hpsp_window.dispose
   end
   # 元のメソッドに戻す
   plan_enemy_hpsp_draw_dispose
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
alias plan_enemy_hpsp_draw_update update
def update
   # 元のメソッドに戻す
   plan_enemy_hpsp_draw_update
   # エネミーの場合
   if @battler.is_a?(Game_Enemy)
     @enemy_hpsp_window.visible = @battler_visible
   # スプライトの座標を設定
     width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
     @enemy_hpsp_window.x = self.x - width / 2
     @now_enemy_hpsp = []
     if PLAN_HPSP_DRAW::DRAW_NAME
       @now_enemy_hpsp.push(@battler.name)
     end
     if PLAN_HPSP_DRAW::DRAW_HP
       @now_enemy_hpsp.push(@battler.hp)
     end
     if PLAN_HPSP_DRAW::DRAW_SP
       @now_enemy_hpsp.push(@battler.sp)
     end
     if @old_enemy_hpsp != @now_enemy_hpsp and $game_temp.enemy_hpsp_refresh
       @old_enemy_hpsp = @now_enemy_hpsp
       @enemy_hpsp_window.contents.clear
       y = 0
       width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
       one_line = ((PLAN_HPSP_DRAW::FONT_SIZE * 100 / 28) * 32) / 100
       if PLAN_HPSP_DRAW::DRAW_NAME
         @enemy_hpsp_window.draw_actor_name(@battler, 0, y, width - 32)
         y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
       end
       if PLAN_HPSP_DRAW::DRAW_HP
         @enemy_hpsp_window.draw_actor_hp2222(@battler, 0, y, width - 32)
         y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
       end
       if PLAN_HPSP_DRAW::DRAW_SP
         @enemy_hpsp_window.draw_actor_sp2222(@battler, 0, y, width - 32)
       end
       Graphics.frame_reset
     end
   end
end
#--------------------------------------------------------------------------
# ● visible の設定
#--------------------------------------------------------------------------
if !method_defined?("plan_enemy_hpsp_draw_visible=")
   alias plan_enemy_hpsp_draw_visible= visible=
end
def visible=(bool)
   # エネミーの場合
   if @battler.is_a?(Game_Enemy)
     @enemy_hpsp_window.visible = bool
   end
   # 元のメソッドに戻す
   self.plan_enemy_hpsp_draw_visible=(bool)
end
#--------------------------------------------------------------------------
# ● 不透明度の設定
#--------------------------------------------------------------------------
if !method_defined?("plan_enemy_hpsp_draw_opacity=")
   alias plan_enemy_hpsp_draw_opacity= opacity=
end
def opacity=(n)
   # 元のメソッドに戻す
   self.plan_enemy_hpsp_draw_opacity=(n)
   # エネミーの場合
   if @battler.is_a?(Game_Enemy)
     @enemy_hpsp_window.contents_opacity = n
   end
end
#--------------------------------------------------------------------------
# ● ダメージ
#--------------------------------------------------------------------------
def damage(value, critical)
   super(value, critical)
   bitmap = @_damage_sprite.bitmap
   @_damage_sprite.dispose
   @_damage_sprite = ::Sprite.new(Viewport.new(0, 0, 640, 480))
   @_damage_sprite.bitmap = bitmap
   @_damage_sprite.ox = 80
   @_damage_sprite.oy = 20
   @_damage_sprite.x = self.x
   @_damage_sprite.y = self.y - self.oy / 2
   @_damage_sprite.viewport.z = self.viewport.z + 1
   @_damage_sprite.z = 3000
   @_damage_duration = 40
end
#--------------------------------------------------------------------------
# ● ダメージ解放
#--------------------------------------------------------------------------
def dispose_damage
   if @_damage_sprite != nil
     @_damage_sprite.viewport.dispose
   end
   super
end
end
#==============================================================================
# ■ Game_Temp
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :enemy_hpsp_refresh
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias plan_enemy_hpsp_draw_initialize initialize
def initialize
   # 元のメソッドに戻す
   plan_enemy_hpsp_draw_initialize
   @enemy_hpsp_refresh = false
end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ● プレバトルフェーズ開始 (エネミー名+アルファベット用)
#--------------------------------------------------------------------------
alias plan_enemy_hpsp_draw_start_phase1 start_phase1
def start_phase1
   $game_temp.enemy_hpsp_refresh = true
   # 元のメソッドに戻す
   plan_enemy_hpsp_draw_start_phase1
end
#--------------------------------------------------------------------------
# ● パーティコマンドフェーズ開始 (エネミー名+アルファベット用)
#--------------------------------------------------------------------------
alias plan_enemy_hpsp_draw_start_phase2 start_phase2
def start_phase2
   $game_temp.enemy_hpsp_refresh = false
   # 元のメソッドに戻す
   plan_enemy_hpsp_draw_start_phase2
end
#--------------------------------------------------------------------------
# ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
#--------------------------------------------------------------------------
alias plan_enemy_hpsp_draw_update_phase4_step5 update_phase4_step5
def update_phase4_step5
   # 元のメソッドに戻す
   plan_enemy_hpsp_draw_update_phase4_step5
   $game_temp.enemy_hpsp_refresh = true
end
#--------------------------------------------------------------------------
# ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ)
#--------------------------------------------------------------------------
alias plan_enemy_hpsp_draw_update_phase4_step6 update_phase4_step6
def update_phase4_step6
   # 元のメソッドに戻す
   plan_enemy_hpsp_draw_update_phase4_step6
   $game_temp.enemy_hpsp_refresh = false
end
end
#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 名前の描画
#--------------------------------------------------------------------------
def draw_actor_name(actor, x, y, width = 120, align = 0)
   self.contents.font.color = normal_color
   align = 1 if $scene.is_a?(Scene_Battle)
   self.contents.draw_text(x, y, width, 32, actor.name, align)
end
#--------------------------------------------------------------------------
# ● ステートの描画
#--------------------------------------------------------------------------
def draw_actor_state(actor, x, y, width = 120)
   # 元のメソッドに戻す
   text = make_battler_state_text(actor, width, true)
   self.contents.draw_text(x, y, width, 32, text, 1)
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
class Window_Base < Window
  def draw_actor_hp2222(actor, x, y, width = 100, height=8)
    y+=3
    olx = x
    oly = y
    w = width * actor.hp / [actor.maxhp,1].max  
    hp_color_1 = Color.new(255, 0, 0, 192)  
    hp_color_2 = Color.new(255, 255, 0, 192)  
    self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))  
    draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)  
    x -= 1  
    y += (height/4).floor  
    self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))  
    draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)  
    x -= 1  
    y += (height/4).ceil  
    self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))  
    draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)  
    x -= 1  
    y += (height/4).ceil  
    self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))  
    draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)  
    x = olx
    y = oly-14   
    # 描绘字符串 "HP"
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
    # 计算描绘 MaxHP 所需的空间  
    if width - 32 >= 108
      hp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      hp_x = x + width - 48
      flag = false
    end
    # 描绘 HP
    self.contents.font.color = actor.hp == 0 ? knockout_color :
      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
    # 描绘 MaxHP
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
    end     
  end
  def draw_actor_sp2222(actor, x, y, width = 100, height = 8)
    y+=3
    olx = x
    oly = y
    w = width * actor.sp / [actor.maxsp,1].max  
    hp_color_1 = Color.new( 0, 0, 255, 192)  
    hp_color_2 = Color.new( 0, 255, 255, 192)  
    self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))  
    draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)  
    x -= 1  
    y += (height/4).floor  
    self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))  
    draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)  
    x -= 1  
    y += (height/4).ceil  
    self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))  
    draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)  
    x -= 1  
    y += (height/4).ceil  
    self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))  
    draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)  
    x = olx
    y = oly-14
    # 描绘字符串 "SP"  
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
    # 计算描绘 MaxSP 所需的空间
    if width - 32 >= 108
      sp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      sp_x = x + width - 48
      flag = false
    end
    # 描绘 SP
    self.contents.font.color = actor.sp == 0 ? knockout_color :
      actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
    self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
    # 描绘 MaxSP
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
    end     
  end
  #--------------------------------------------------------------------------  
  # ● ライン描画 by 桜雅 在土  
  #--------------------------------------------------------------------------  
  def draw_line(start_x, start_y, end_x, end_y, start_color, width = 1, end_color = start_color)  
    # 描写距離の計算。大きめに直角時の長さ。  
    distance = (start_x - end_x).abs + (start_y - end_y).abs  
    # 描写開始  
    if end_color == start_color  
      for i in 1..distance  
        x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i  
        y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i  
        if width == 1  
          self.contents.set_pixel(x, y, start_color)  
        else  
          self.contents.fill_rect(x, y, width, width, start_color)  
        end  
      end  
    else  
      for i in 1..distance  
        x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i  
        y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i  
        r = start_color.red * (distance-i)/distance + end_color.red * i/distance  
        g = start_color.green * (distance-i)/distance + end_color.green * i/distance  
        b = start_color.blue * (distance-i)/distance + end_color.blue * i/distance  
        a = start_color.alpha * (distance-i)/distance + end_color.alpha * i/distance  
        if width == 1  
          self.contents.set_pixel(x, y, Color.new(r, g, b, a))  
        else  
          self.contents.fill_rect(x, y, width, width, Color.new(r, g, b, a))  
        end  
      end  
    end  
  end  
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#============================================================================== dsu_plus_rewardpost_czw
作者: tommay    时间: 2012-5-21 19:33
本帖最后由 tommay 于 2012-5-21 19:35 编辑

增加一行参数:
DRAW_SWITCH     =  1          # 显示HP、SP的开关ID(true时显示)
用1号开关控制HP、SP条的显示(当然开关序号可调)
在战斗中用公共事件更改开关状态吧。

脚本修改如下:
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================
  4. # ■ エネミーHP&SP(ver 0.98)
  5. # □ カスタマイズポイント
  6. #==============================================================================
  7. module PLAN_HPSP_DRAW
  8. FONT_NAME         = ["黑体", "楷体", "宋体"]    # フォント
  9. FONT_SIZE         =  14                               # フォントサイズ
  10. FONT_BOLD         = true                              # 太字
  11. FONT_ITALIC       = true                              # 斜体
  12. DRAW_NAME         = false                             # 名前の描画
  13. DRAW_HP           = true                              # HP の描画
  14. DRAW_SP           = true                              # SP の描画
  15. DRAW_WIDTH        =  80                               # 描画幅
  16. DRAW_HEIGHT       = 3 * 32                            # 描画高さ
  17. DRAW_SPACE        =   0                               # 行間
  18. DRAW_Y            =  36                               # Y 座標修正値
  19. DRAW_SWITCH     =  1          # 显示HP、SP的开关ID(true时显示)
  20. end
  21. #==============================================================================
  22. # ■ Sprite_Battler
  23. #==============================================================================
  24. class Sprite_Battler < RPG::Sprite
  25. #--------------------------------------------------------------------------
  26. # ● オブジェクト初期化
  27. #--------------------------------------------------------------------------
  28. alias plan_enemy_hpsp_draw_initialize initialize
  29. def initialize(viewport, battler = nil)
  30.    # 元のメソッドに戻す
  31.    plan_enemy_hpsp_draw_initialize(viewport, battler)
  32.    # エネミーの場合
  33.    if @battler.is_a?(Game_Enemy)
  34.      width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
  35.      height = PLAN_HPSP_DRAW::DRAW_HEIGHT + 32
  36.      x = @battler.screen_x - width / 2
  37.      y = @battler.screen_y - height + 32 + PLAN_HPSP_DRAW::DRAW_Y
  38.      @enemy_hpsp_window = Window_Base.new(x, y, width, height)
  39.      @enemy_hpsp_window.contents = Bitmap.new(width - 32, height - 32)
  40.      @enemy_hpsp_window.contents.font.name = PLAN_HPSP_DRAW::FONT_NAME
  41.      @enemy_hpsp_window.contents.font.size = PLAN_HPSP_DRAW::FONT_SIZE
  42.      @enemy_hpsp_window.contents.font.bold = PLAN_HPSP_DRAW::FONT_BOLD
  43.      @enemy_hpsp_window.contents.font.italic = PLAN_HPSP_DRAW::FONT_ITALIC
  44.      y = 0
  45.      @old_enemy_hpsp = []
  46.      one_line = ((PLAN_HPSP_DRAW::FONT_SIZE * 100 / 28) * 32) / 100
  47.      if PLAN_HPSP_DRAW::DRAW_NAME
  48.        @enemy_hpsp_window.draw_actor_name(@battler, 0, y, width - 32)
  49.        y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  50.        @old_enemy_hpsp.push(@battler.name)
  51.      end
  52.      if PLAN_HPSP_DRAW::DRAW_HP and $game_switches[PLAN_HPSP_DRAW::DRAW_SWITCH]
  53.        @enemy_hpsp_window.draw_actor_hp2222(@battler, 0, y, width - 32)
  54.        y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  55.        @old_enemy_hpsp.push(@battler.hp)
  56.      end
  57.      if PLAN_HPSP_DRAW::DRAW_SP and $game_switches[PLAN_HPSP_DRAW::DRAW_SWITCH]
  58.        @enemy_hpsp_window.draw_actor_sp2222(@battler, 0, y, width - 32)
  59.        @old_enemy_hpsp.push(@battler.sp)
  60.      end
  61.      @enemy_hpsp_window.opacity = 0
  62.      @enemy_hpsp_window.contents_opacity = 0
  63.      @enemy_hpsp_window.z = -2
  64.    end
  65. end
  66. #--------------------------------------------------------------------------
  67. # ● 解放
  68. #--------------------------------------------------------------------------
  69. alias plan_enemy_hpsp_draw_dispose dispose
  70. def dispose
  71.    # エネミーの場合
  72.    if @battler.is_a?(Game_Enemy)
  73.      @enemy_hpsp_window.dispose
  74.    end
  75.    # 元のメソッドに戻す
  76.    plan_enemy_hpsp_draw_dispose
  77. end
  78. #--------------------------------------------------------------------------
  79. # ● フレーム更新
  80. #--------------------------------------------------------------------------
  81. alias plan_enemy_hpsp_draw_update update
  82. def update
  83.    # 元のメソッドに戻す
  84.    plan_enemy_hpsp_draw_update
  85.    # エネミーの場合
  86.    if @battler.is_a?(Game_Enemy)
  87.      @enemy_hpsp_window.visible = @battler_visible
  88.    # スプライトの座標を設定
  89.      width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
  90.      @enemy_hpsp_window.x = self.x - width / 2
  91.      @now_enemy_hpsp = []
  92.      if PLAN_HPSP_DRAW::DRAW_NAME
  93.        @now_enemy_hpsp.push(@battler.name)
  94.      end
  95.      if PLAN_HPSP_DRAW::DRAW_HP and $game_switches[PLAN_HPSP_DRAW::DRAW_SWITCH]
  96.        @now_enemy_hpsp.push(@battler.hp)
  97.      end
  98.      if PLAN_HPSP_DRAW::DRAW_SP and $game_switches[PLAN_HPSP_DRAW::DRAW_SWITCH]
  99.        @now_enemy_hpsp.push(@battler.sp)
  100.      end
  101.      if @old_enemy_hpsp != @now_enemy_hpsp and $game_temp.enemy_hpsp_refresh
  102.        @old_enemy_hpsp = @now_enemy_hpsp
  103.        @enemy_hpsp_window.contents.clear
  104.        y = 0
  105.        width = PLAN_HPSP_DRAW::DRAW_WIDTH + 32
  106.        one_line = ((PLAN_HPSP_DRAW::FONT_SIZE * 100 / 28) * 32) / 100
  107.        if PLAN_HPSP_DRAW::DRAW_NAME
  108.          @enemy_hpsp_window.draw_actor_name(@battler, 0, y, width - 32)
  109.          y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  110.        end
  111.        if PLAN_HPSP_DRAW::DRAW_HP and $game_switches[PLAN_HPSP_DRAW::DRAW_SWITCH]
  112.          @enemy_hpsp_window.draw_actor_hp2222(@battler, 0, y, width - 32)
  113.          y += one_line + PLAN_HPSP_DRAW::DRAW_SPACE
  114.        end
  115.        if PLAN_HPSP_DRAW::DRAW_SP and $game_switches[PLAN_HPSP_DRAW::DRAW_SWITCH]
  116.          @enemy_hpsp_window.draw_actor_sp2222(@battler, 0, y, width - 32)
  117.        end
  118.        Graphics.frame_reset
  119.      end
  120.    end
  121. end
  122. #--------------------------------------------------------------------------
  123. # ● visible の設定
  124. #--------------------------------------------------------------------------
  125. if !method_defined?("plan_enemy_hpsp_draw_visible=")
  126.    alias plan_enemy_hpsp_draw_visible= visible=
  127. end
  128. def visible=(bool)
  129.    # エネミーの場合
  130.    if @battler.is_a?(Game_Enemy)
  131.      @enemy_hpsp_window.visible = bool
  132.    end
  133.    # 元のメソッドに戻す
  134.    self.plan_enemy_hpsp_draw_visible=(bool)
  135. end
  136. #--------------------------------------------------------------------------
  137. # ● 不透明度の設定
  138. #--------------------------------------------------------------------------
  139. if !method_defined?("plan_enemy_hpsp_draw_opacity=")
  140.    alias plan_enemy_hpsp_draw_opacity= opacity=
  141. end
  142. def opacity=(n)
  143.    # 元のメソッドに戻す
  144.    self.plan_enemy_hpsp_draw_opacity=(n)
  145.    # エネミーの場合
  146.    if @battler.is_a?(Game_Enemy)
  147.      @enemy_hpsp_window.contents_opacity = n
  148.    end
  149. end
  150. #--------------------------------------------------------------------------
  151. # ● ダメージ
  152. #--------------------------------------------------------------------------
  153. def damage(value, critical)
  154.    super(value, critical)
  155.    bitmap = @_damage_sprite.bitmap
  156.    @_damage_sprite.dispose
  157.    @_damage_sprite = ::Sprite.new(Viewport.new(0, 0, 640, 480))
  158.    @_damage_sprite.bitmap = bitmap
  159.    @_damage_sprite.ox = 80
  160.    @_damage_sprite.oy = 20
  161.    @_damage_sprite.x = self.x
  162.    @_damage_sprite.y = self.y - self.oy / 2
  163.    @_damage_sprite.viewport.z = self.viewport.z + 1
  164.    @_damage_sprite.z = 3000
  165.    @_damage_duration = 40
  166. end
  167. #--------------------------------------------------------------------------
  168. # ● ダメージ解放
  169. #--------------------------------------------------------------------------
  170. def dispose_damage
  171.    if @_damage_sprite != nil
  172.      @_damage_sprite.viewport.dispose
  173.    end
  174.    super
  175. end
  176. end
  177. #==============================================================================
  178. # ■ Game_Temp
  179. #==============================================================================
  180. class Game_Temp
  181. #--------------------------------------------------------------------------
  182. # ● 公開インスタンス変数
  183. #--------------------------------------------------------------------------
  184. attr_accessor :enemy_hpsp_refresh
  185. #--------------------------------------------------------------------------
  186. # ● オブジェクト初期化
  187. #--------------------------------------------------------------------------
  188. alias plan_enemy_hpsp_draw_initialize initialize
  189. def initialize
  190.    # 元のメソッドに戻す
  191.    plan_enemy_hpsp_draw_initialize
  192.    @enemy_hpsp_refresh = false
  193. end
  194. end
  195. #==============================================================================
  196. # ■ Scene_Battle
  197. #==============================================================================
  198. class Scene_Battle
  199. #--------------------------------------------------------------------------
  200. # ● プレバトルフェーズ開始 (エネミー名+アルファベット用)
  201. #--------------------------------------------------------------------------
  202. alias plan_enemy_hpsp_draw_start_phase1 start_phase1
  203. def start_phase1
  204.    $game_temp.enemy_hpsp_refresh = true
  205.    # 元のメソッドに戻す
  206.    plan_enemy_hpsp_draw_start_phase1
  207. end
  208. #--------------------------------------------------------------------------
  209. # ● パーティコマンドフェーズ開始 (エネミー名+アルファベット用)
  210. #--------------------------------------------------------------------------
  211. alias plan_enemy_hpsp_draw_start_phase2 start_phase2
  212. def start_phase2
  213.    $game_temp.enemy_hpsp_refresh = false
  214.    # 元のメソッドに戻す
  215.    plan_enemy_hpsp_draw_start_phase2
  216. end
  217. #--------------------------------------------------------------------------
  218. # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
  219. #--------------------------------------------------------------------------
  220. alias plan_enemy_hpsp_draw_update_phase4_step5 update_phase4_step5
  221. def update_phase4_step5
  222.    # 元のメソッドに戻す
  223.    plan_enemy_hpsp_draw_update_phase4_step5
  224.    $game_temp.enemy_hpsp_refresh = true
  225. end
  226. #--------------------------------------------------------------------------
  227. # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ)
  228. #--------------------------------------------------------------------------
  229. alias plan_enemy_hpsp_draw_update_phase4_step6 update_phase4_step6
  230. def update_phase4_step6
  231.    # 元のメソッドに戻す
  232.    plan_enemy_hpsp_draw_update_phase4_step6
  233.    $game_temp.enemy_hpsp_refresh = false
  234. end
  235. end
  236. #==============================================================================
  237. # ■ Window_Base
  238. #==============================================================================
  239. class Window_Base < Window
  240. #--------------------------------------------------------------------------
  241. # ● 名前の描画
  242. #--------------------------------------------------------------------------
  243. def draw_actor_name(actor, x, y, width = 120, align = 0)
  244.    self.contents.font.color = normal_color
  245.    align = 1 if $scene.is_a?(Scene_Battle)
  246.    self.contents.draw_text(x, y, width, 32, actor.name, align)
  247. end
  248. #--------------------------------------------------------------------------
  249. # ● ステートの描画
  250. #--------------------------------------------------------------------------
  251. def draw_actor_state(actor, x, y, width = 120)
  252.    # 元のメソッドに戻す
  253.    text = make_battler_state_text(actor, width, true)
  254.    self.contents.draw_text(x, y, width, 32, text, 1)
  255. end
  256. end
  257. #==============================================================================
  258. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  259. #==============================================================================
  260. class Window_Base < Window
  261.   def draw_actor_hp2222(actor, x, y, width = 100, height=8)
  262.     y+=3
  263.     olx = x
  264.     oly = y
  265.     w = width * actor.hp / [actor.maxhp,1].max  
  266.     hp_color_1 = Color.new(255, 0, 0, 192)  
  267.     hp_color_2 = Color.new(255, 255, 0, 192)  
  268.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))  
  269.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)  
  270.     x -= 1  
  271.     y += (height/4).floor  
  272.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))  
  273.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)  
  274.     x -= 1  
  275.     y += (height/4).ceil  
  276.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))  
  277.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)  
  278.     x -= 1  
  279.     y += (height/4).ceil  
  280.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))  
  281.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)  
  282.     x = olx
  283.     y = oly-14   
  284.     # 描绘字符串 "HP"
  285.     self.contents.font.color = system_color
  286.     self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
  287.     # 计算描绘 MaxHP 所需的空间  
  288.     if width - 32 >= 108
  289.       hp_x = x + width - 108
  290.       flag = true
  291.     elsif width - 32 >= 48
  292.       hp_x = x + width - 48
  293.       flag = false
  294.     end
  295.     # 描绘 HP
  296.     self.contents.font.color = actor.hp == 0 ? knockout_color :
  297.       actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
  298.     self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
  299.     # 描绘 MaxHP
  300.     if flag
  301.       self.contents.font.color = normal_color
  302.       self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
  303.       self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
  304.     end     
  305.   end
  306.   def draw_actor_sp2222(actor, x, y, width = 100, height = 8)
  307.     y+=3
  308.     olx = x
  309.     oly = y
  310.     w = width * actor.sp / [actor.maxsp,1].max  
  311.     hp_color_1 = Color.new( 0, 0, 255, 192)  
  312.     hp_color_2 = Color.new( 0, 255, 255, 192)  
  313.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))  
  314.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)  
  315.     x -= 1  
  316.     y += (height/4).floor  
  317.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))  
  318.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)  
  319.     x -= 1  
  320.     y += (height/4).ceil  
  321.     self.contents.fill_rect(x+8, y+4, width, (height/4).ceil , Color.new(0, 0, 0, 128))  
  322.     draw_line(x, y, x + w, y, hp_color_1, (height/4).ceil , hp_color_2)  
  323.     x -= 1  
  324.     y += (height/4).ceil  
  325.     self.contents.fill_rect(x+8, y+4, width, (height/4).floor, Color.new(0, 0, 0, 128))  
  326.     draw_line(x, y, x + w, y, hp_color_1, (height/4).floor, hp_color_2)  
  327.     x = olx
  328.     y = oly-14
  329.     # 描绘字符串 "SP"  
  330.     self.contents.font.color = system_color
  331.     self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
  332.     # 计算描绘 MaxSP 所需的空间
  333.     if width - 32 >= 108
  334.       sp_x = x + width - 108
  335.       flag = true
  336.     elsif width - 32 >= 48
  337.       sp_x = x + width - 48
  338.       flag = false
  339.     end
  340.     # 描绘 SP
  341.     self.contents.font.color = actor.sp == 0 ? knockout_color :
  342.       actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
  343.     self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
  344.     # 描绘 MaxSP
  345.     if flag
  346.       self.contents.font.color = normal_color
  347.       self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
  348.       self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
  349.     end     
  350.   end
  351.   #--------------------------------------------------------------------------  
  352.   # ● ライン描画 by 桜雅 在土  
  353.   #--------------------------------------------------------------------------  
  354.   def draw_line(start_x, start_y, end_x, end_y, start_color, width = 1, end_color = start_color)  
  355.     # 描写距離の計算。大きめに直角時の長さ。  
  356.     distance = (start_x - end_x).abs + (start_y - end_y).abs  
  357.     # 描写開始  
  358.     if end_color == start_color  
  359.       for i in 1..distance  
  360.         x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i  
  361.         y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i  
  362.         if width == 1  
  363.           self.contents.set_pixel(x, y, start_color)  
  364.         else  
  365.           self.contents.fill_rect(x, y, width, width, start_color)  
  366.         end  
  367.       end  
  368.     else  
  369.       for i in 1..distance  
  370.         x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i  
  371.         y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i  
  372.         r = start_color.red * (distance-i)/distance + end_color.red * i/distance  
  373.         g = start_color.green * (distance-i)/distance + end_color.green * i/distance  
  374.         b = start_color.blue * (distance-i)/distance + end_color.blue * i/distance  
  375.         a = start_color.alpha * (distance-i)/distance + end_color.alpha * i/distance  
  376.         if width == 1  
  377.           self.contents.set_pixel(x, y, Color.new(r, g, b, a))  
  378.         else  
  379.           self.contents.fill_rect(x, y, width, width, Color.new(r, g, b, a))  
  380.         end  
  381.       end  
  382.     end  
  383.   end  
  384. end
  385. #==============================================================================
  386. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  387. #==============================================================================
复制代码





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