#==============================================================================
module PLAN_HPSP_DRAW
FONT_NAME = ["宋体"] # フォント
FONT_SIZE = 12 # フォントサイズ
FONT_BOLD = true # 太字
FONT_ITALIC = false #true # 斜体
DRAW_NAME = true # 名前の描画
DRAW_HP = false # HP の描画
DRAW_SP = false # SP の描画
DRAW_WIDTH = 80 # 描画幅
DRAW_HEIGHT = 3 * 32 # 描画高さ
DRAW_SPACE = 0 # 行間
DRAW_Y = 24 # 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_hp(@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_sp(@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 + 5
@enemy_hpsp_window.y = self.y - 40
@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_hp(@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_sp(@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 = Color.new(0, 220, 0)
align = 1 if $scene.is_a?(Scene_Battle)
self.contents.draw_text(x, y, width, 32, actor.name, align)
end
end