赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 0 |
经验 | 0 |
最后登录 | 2010-10-22 |
在线时间 | 0 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 340
- 在线时间
- 0 小时
- 注册时间
- 2010-9-30
- 帖子
- 2
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 流星飞舞 于 2010-10-10 14:03 编辑
- #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
- #_/ ◆ 敵HPゲージ - KGC_EnemyHPGauge ◆ VX ◆
- #_/ ◇ Last update : 2009/09/26 ◇
- #_/----------------------------------------------------------------------------
- #_/ 敵の HP をゲージで表示する機能を追加します。
- #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
- #==============================================================================
- # ★ カスタマイズ項目 - Customize BEGIN ★
- #==============================================================================
- module KGC
- module EnemyHPGauge
- # ◆ ゲージの表示時間 [フレーム]
- DURATION = 60
- # ◆ ゲージ設定
- # 画像は "Graphics/System" から読み込む。
- GAUGE_IMAGE = "GaugeHPEnemy" # ゲージ画像
- GAUGE_OFFSET = [-23, -2] # 位置補正 [x, y]
- GAUGE_LENGTH = -4 # 長さ補正
- GAUGE_SLOPE = 30 # 傾き (-89 ~ 89)
- end
- end
- #==============================================================================
- # ☆ カスタマイズ項目終了 - Customize END ☆
- #==============================================================================
- $imported = {} if $imported == nil
- $imported["EnemyHPGauge"] = true
- #==============================================================================
- # ■ Game_Battler
- #==============================================================================
- class Game_Battler
- #--------------------------------------------------------------------------
- # ○ HP ゲージ表示
- #--------------------------------------------------------------------------
- def show_hp_gauge
- return false
- end
- #--------------------------------------------------------------------------
- # ○ HP ゲージ非表示
- #--------------------------------------------------------------------------
- def hide_hp_gauge
- return false
- end
- end
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
- #==============================================================================
- # ■ Game_Enemy
- #==============================================================================
- class Game_Enemy < Game_Battler
- #--------------------------------------------------------------------------
- # ○ 公開インスタンス変数
- #--------------------------------------------------------------------------
- attr_accessor :show_hp_gauge
- attr_accessor :hide_hp_gauge
- end
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
- #==============================================================================
- # ■ Sprite_Battler
- #==============================================================================
- class Sprite_Battler < Sprite_Base
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- # viewport : ビューポート
- # battler : バトラー (Game_Battler)
- #--------------------------------------------------------------------------
- alias initialize_KGC_EnemyHPGauge_SB initialize
- def initialize(viewport, battler = nil)
- initialize_KGC_EnemyHPGauge_SB(viewport, battler)
- create_hp_gauge_window
- end
- #--------------------------------------------------------------------------
- # ○ HP ゲージウィンドウ作成
- #--------------------------------------------------------------------------
- def create_hp_gauge_window
- @hp_gauge_window = Window_EnemyHPGauge.new(viewport)
- @hp_gauge_window.visible = false
- end
- #--------------------------------------------------------------------------
- # ● 解放
- #--------------------------------------------------------------------------
- alias dispose_KGC_EnemyHPGauge_SB dispose
- def dispose
- dispose_hp_gauge_window
- dispose_KGC_EnemyHPGauge_SB
- end
- #--------------------------------------------------------------------------
- # ○ HP ゲージウィンドウ破棄
- #--------------------------------------------------------------------------
- def dispose_hp_gauge_window
- @hp_gauge_window.dispose
- @hp_gauge_window = nil
- end
- #--------------------------------------------------------------------------
- # ● X 座標変更
- #--------------------------------------------------------------------------
- unless method_defined?(:x_eq_KGC_EnemyHPGauge)
- alias x_eq_KGC_EnemyHPGauge x=
- end
- def x=(value)
- x_eq_KGC_EnemyHPGauge(value)
- if @hp_gauge_window != nil
- n = [x - (@hp_gauge_window.width / 2), -16].max
- n = [n, Graphics.width - @hp_gauge_window.width + 16].min
- @hp_gauge_window.x = n
- end
- end
- #--------------------------------------------------------------------------
- # ● Y 座標変更
- #--------------------------------------------------------------------------
- unless method_defined?(:y_eq_KGC_EnemyHPGauge)
- alias y_eq_KGC_EnemyHPGauge y=
- end
- def y=(value)
- y_eq_KGC_EnemyHPGauge(value)
- if @hp_gauge_window != nil
- @hp_gauge_window.y = y - 24
- end
- end
- #--------------------------------------------------------------------------
- # ● Z 座標変更
- #--------------------------------------------------------------------------
- unless method_defined?(:z_eq_KGC_EnemyHPGauge)
- alias z_eq_KGC_EnemyHPGauge z=
- end
- def z=(value)
- z_eq_KGC_EnemyHPGauge(value)
- @hp_gauge_window.z = z + 1 if @hp_gauge_window != nil
- end
- #--------------------------------------------------------------------------
- # ● 不透明度変更
- #--------------------------------------------------------------------------
- unless method_defined?(:opacity_eq_KGC_EnemyHPGauge)
- alias opacity_eq_KGC_EnemyHPGauge opacity=
- end
- def opacity=(value)
- opacity_eq_KGC_EnemyHPGauge(value)
- @hp_gauge_window.contents_opacity = opacity if @hp_gauge_window != nil
- end
- #--------------------------------------------------------------------------
- # ● 可視状態変更
- #--------------------------------------------------------------------------
- unless method_defined?(:visible_eq_KGC_EnemyHPGauge)
- alias visible_eq_KGC_EnemyHPGauge visible=
- end
- def visible=(value)
- visible_eq_KGC_EnemyHPGauge(value)
- @hp_gauge_window.owner_visible = visible if @hp_gauge_window != nil
- end
- #--------------------------------------------------------------------------
- # ● フレーム更新
- #--------------------------------------------------------------------------
- alias update_KGC_EnemyHPGauge_SB update
- def update
- update_KGC_EnemyHPGauge_SB
- update_hp_gauge_window
- end
- #--------------------------------------------------------------------------
- # ○ HP ゲージウィンドウ更新
- #--------------------------------------------------------------------------
- def update_hp_gauge_window
- return if @hp_gauge_window == nil
- if @battler == nil
- @hp_gauge_window.battler = nil
- else
- @hp_gauge_window.battler = (@battler.actor? ? nil : @battler)
- end
- @hp_gauge_window.update
- end
- end
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
- #==============================================================================
- # □ Window_EnemyHPGauge
- #==============================================================================
- class Window_EnemyHPGauge < Window_Base
- #--------------------------------------------------------------------------
- # ○ 公開インスタンス変数
- #--------------------------------------------------------------------------
- attr_accessor :owner_visible
- attr_reader :battler
- #--------------------------------------------------------------------------
- # ○ オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize(viewport)
- @owner_visible = false
- @battler = nil
- @show_count = 0
- super(0, 0, 160, WLH * 2 + 32)
- self.height = WLH + 32
- self.visible = false
- self.opacity = 0
- self.back_opacity = 0
- self.viewport = viewport
- # スクロールマークを消去
- old_skin = windowskin
- self.windowskin = Bitmap.new(128, 128)
- windowskin.blt(0, 0, old_skin, old_skin.rect)
- windowskin.clear_rect(80, 16, 32, 32)
- @erase_rect = Rect.new(0, 0, contents.width, WLH)
- @src_rect = Rect.new(0, WLH, contents.width, WLH)
- if $imported["GenericGauge"]
- @image = Cache.system(KGC::EnemyHPGauge::GAUGE_IMAGE)
- @offset = KGC::EnemyHPGauge::GAUGE_OFFSET
- @length = KGC::EnemyHPGauge::GAUGE_LENGTH + contents.width - 8
- @slope = KGC::EnemyHPGauge::GAUGE_SLOPE
- draw_background
- end
- end
- #--------------------------------------------------------------------------
- # ○ 可視状態
- #--------------------------------------------------------------------------
- def visible
- return (super && @owner_visible)
- end
- #--------------------------------------------------------------------------
- # ○ バトラー変更
- #--------------------------------------------------------------------------
- def battler=(battler)
- @prev_hp = battler.hp if battler != nil && @battler != battler
- @battler = battler
- end
- #--------------------------------------------------------------------------
- # ○ 背景描画
- #--------------------------------------------------------------------------
- def draw_background
- draw_gauge_base(@image, @offset[0], WLH + @offset[1], @length, @slope)
- end
- #--------------------------------------------------------------------------
- # ○ 破棄
- #--------------------------------------------------------------------------
- def dispose
- self.windowskin.dispose
- self.windowskin = nil
- super
- end
- #--------------------------------------------------------------------------
- # ○ フレーム更新
- #--------------------------------------------------------------------------
- def update
- super
- update_gauge
- end
- #--------------------------------------------------------------------------
- # ○ ゲージ更新
- #--------------------------------------------------------------------------
- def update_gauge
- update_gauge_visible
- return unless visible
- @show_count -= 1
- if @show_count < 0
- @prev_hp = @battler.hp
- @diff = nil
- self.visible = false
- return
- end
- update_gauge_draw
- end
- #--------------------------------------------------------------------------
- # ○ ゲージ可視状態更新
- #--------------------------------------------------------------------------
- def update_gauge_visible
- if @battler == nil
- self.visible = false if visible
- return
- end
- if @battler.hide_hp_gauge
- @battler.show_hp_gauge = false
- @battler.hide_hp_gauge = false
- @prev_hp = @battler.hp
- @diff = nil
- @show_count = 0
- self.visible = false
- elsif @battler.show_hp_gauge
- @battler.show_hp_gauge = false
- @battler.hide_hp_gauge = false
- @diff = nil
- @show_count = KGC::EnemyHPGauge::DURATION
- self.visible = true
- end
- end
- #--------------------------------------------------------------------------
- # ○ ゲージ描画更新
- #--------------------------------------------------------------------------
- def update_gauge_draw
- contents.clear_rect(@erase_rect)
- unless $imported["GenericGauge"]
- # 通常ゲージ
- draw_actor_hp_gauge(@battler, 0, 0, contents.width)
- return
- end
- # 汎用ゲージ : 差分処理
- if @diff == nil
- @diff = (@battler.hp - @prev_hp)
- count = KGC::EnemyHPGauge::DURATION / 2
- if @diff > 0
- @diff = [@diff / count, 1].max
- elsif @diff < 0
- @diff = [@diff / count, -1].min
- end
- end
- # 汎用ゲージ : 描画
- contents.blt(0, 0, contents, @src_rect)
- gw = @length * @battler.hp / @battler.maxhp
- pos = GAUGE_SRC_POS[:normal]
- draw_gauge_bar(@image, @offset[0], @offset[1], @length, gw, @slope, pos)
- return if @diff == 0 # 差分なし
- # 差分描画
- gw_d = ((@length * @prev_hp / @battler.maxhp) - gw).abs
- pos = GAUGE_SRC_POS[@diff < 0 ? :decrease : :increase]
- start = gw - (@diff < 0 ? 0 : gw_d)
- draw_gauge_bar(
- @image, @offset[0], @offset[1], @length, gw_d, @slope, pos, start
- )
- @prev_hp += @diff
- # 差分終了
- if (@diff < 0 && @prev_hp <= @battler.hp) ||
- (@diff > 0 && @prev_hp >= @battler.hp)
- @diff = 0
- @prev_hp = @battler.hp
- end
- end
- end
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
- #==============================================================================
- # ■ Scene_Battle
- #==============================================================================
- class Scene_Battle < Scene_Base
- #--------------------------------------------------------------------------
- # ● 対象敵キャラ選択の終了
- #--------------------------------------------------------------------------
- alias end_target_enemy_selection_KGC_EnemyHPGauge
- end_target_enemy_selection
- def end_target_enemy_selection
- $game_troop.members.each { |enemy| enemy.hide_hp_gauge = true }
- end_target_enemy_selection_KGC_EnemyHPGauge
- end
- #--------------------------------------------------------------------------
- # ● 対象敵キャラ選択の更新
- #--------------------------------------------------------------------------
- alias update_target_enemy_selection_KGC_EnemyHPGauge
- update_target_enemy_selection
- def update_target_enemy_selection
- update_target_enemy_selection_KGC_EnemyHPGauge
- if @target_enemy_window != nil
- target_index = @target_enemy_window.enemy.index
- $game_troop.members.each_with_index { |enemy, i|
- if i == target_index
- enemy.show_hp_gauge = true
- else
- enemy.hide_hp_gauge = true
- end
- }
- end
- end
- #--------------------------------------------------------------------------
- # ● HP ダメージ表示
- # target : 対象者
- # obj : スキルまたはアイテム
- #--------------------------------------------------------------------------
- alias display_hp_damage_KGC_EnemyHPGauge display_hp_damage
- def display_hp_damage(target, obj = nil)
- unless target.actor?
- # ダメージ判定
- damaged = (target.hp_damage != 0)
- if obj != nil && !damaged
- damaged = (obj.damage_to_mp && obj.base_damage == 0)
- end
- target.show_hp_gauge = true if damaged
- end
- if !@active_battler.actor? && target.absorbed
- # 吸収
- target.show_hp_gauge = true if @active_battler.hp_damage != 0
- end
- display_hp_damage_KGC_EnemyHPGauge(target, obj)
- end
- end
复制代码
|
|