| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 12 |
| 经验 | |
| 最后登录 | 2022-1-31 |
| 在线时间 | 127 小时 |
- 梦石
- 0
- 星屑
- 1166
- 在线时间
- 127 小时
- 注册时间
- 2013-2-16
- 回帖
- 368
|
楼主 |
发表于 2013-4-30 20:08:26
|
显示全部楼层
12、垂直类型的战斗状态
[摘要]活动时间战斗是的,这就是一个独立的唯一的状态显示窗口。
我可以包括作战系统系统其他脚本。
[脚本][pre lang="ruby" line="1"]#==============================================================================
# ++ 縦リスト型バトルステータス ver. 1.10 ++
#------------------------------------------------------------------------------
# バトルステータス画面をサイドビューらしい縦型表示にします。
#==============================================================================
module PARA_CTB
# HPゲージの色(グラデーション左端)
HP_COLOR_LEFT = Color.new(128, 0, 0, 255)
# HPゲージの色(グラデーション右端)
HP_COLOR_RIGHT= Color.new(255, 0, 0, 255)
# SPゲージの色(グラデーション左端)
SP_COLOR_LEFT = Color.new(0, 0, 128, 255)
# SPゲージの色(グラデーション右端)
SP_COLOR_RIGHT= Color.new(0, 0, 255, 255)
# ゲージ枠の色
FRAME_COLOR = Color.new(192, 192, 192, 255)
# ゲージ枠の太さ
FRAME_BORDER = 1
# ゲージの背景色
BACK_COLOR = Color.new(128, 128, 128, 128)
# 名前のフォントサイズ
NAME_FONT_SIZE =16
# HP/SPのフォントサイズ
HPSP_FONT_SIZE =18
# エネミー名のフォントサイズ
ENEMY_FONT_SIZE =16
# 最大HP/SPを描画するか( true / false )
MAX_DRAW = false
# バトルメンバーの最大数(多人数PTスクリプトを導入している時に設定)
PARTY_SIZE = 4
# エネミー名をグループ化( true / false )
# (trueにすると「ゴースト 2」のようにまとめて表示します)
ENEMY_GROUPING = false
# エネミー名の下にゲージを表示( 0:なし / 1:HP )
# (エネミー名をグループ化している場合は無効)
ENEMY_DRAWING_MATER = 0
# アクターのヘルプウインドウにHP/SPゲージを表示( true / false )
HELP_DRAWING_MATER_ACTOR = false
# エネミーのヘルプウインドウにHP/SPゲージを表示( true / false )
HELP_DRAWING_MATER_ENEMY = false
# コマンドウインドウの位置を強制指定( true / false )
#(他の方のサイドビュースクリプトを併用していて
# コマンドウインドウの位置がどうしても不自然になるならtrueに)
# ※trueにしても適用されない場合、このスクリプトを
# サイドビューよりも下に置いてみてください
WINDOWPOS_CHANGE = false
WINDOWPOS_X = 100 # X座標
WINDOWPOS_Y = 320 # Y座標
# コマンドウインドウの不透明度
WINDOW_OPACITY = 160
end
# ↑ 設定項目ここまで
#------------------------------------------------------------------------------
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ● メイン処理
#--------------------------------------------------------------------------
alias main_ctb main
def main
# エネミー名ウインドウを作成
@status_window2 = Window_BattleStatus_enemy.new
main_ctb
# エネミー名ウインドウを破棄
@status_window2.dispose
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
alias ctb_update update
def update
# バトルイベント実行中の場合
if $game_system.battle_interpreter.running?
# インタプリタを更新
$game_system.battle_interpreter.update
# アクションを強制されているバトラーが存在しない場合
if $game_temp.forcing_battler == nil
# バトルイベントの実行が終わった場合
unless $game_system.battle_interpreter.running?
# 戦闘継続の場合、バトルイベントのセットアップを再実行
unless judge
setup_battle_event
end
end
# アフターバトルフェーズでなければ
if @phase != 5
# エネミー名リストを更新
@status_window2.refresh
end
end
end
ctb_update
end
#--------------------------------------------------------------------------
# ● アクターコマンドウィンドウのセットアップ
#--------------------------------------------------------------------------
alias phase3_setup_command_window_ctb phase3_setup_command_window
def phase3_setup_command_window
@actor_command_window.back_opacity = PARA_CTB::WINDOW_OPACITY
phase3_setup_command_window_ctb
if PARA_CTB::WINDOWPOS_CHANGE
# アクターコマンドウィンドウの位置を設定
@actor_command_window.x = PARA_CTB::WINDOWPOS_X
@actor_command_window.y = PARA_CTB::WINDOWPOS_Y
# ステータスウインドウに隠れないように
@actor_command_window.z = 9999
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (プレバトルフェーズ)
#--------------------------------------------------------------------------
alias update_phase1_ctb update_phase1
def update_phase1
# エネミー名リストを更新
@status_window2.refresh
update_phase1_ctb
end
#--------------------------------------------------------------------------
# ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ)
#--------------------------------------------------------------------------
alias update_phase4_step6_ctb update_phase4_step6
def update_phase4_step6
# エネミー名リストを更新
@status_window2.refresh
update_phase4_step6_ctb
end
end
#==============================================================================
# ■ Window_BattleStatus
#==============================================================================
class Window_BattleStatus < Window_Base
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(160, 320, 480, 160)
self.contents = Bitmap.new(width - 32, height - 32)
@level_up_flags = []
for i in 0..$game_party.actors.size
@level_up_flags.push(false)
end
@before_hp = []
@before_sp = []
@before_states = []
@now_hp = []
@now_sp = []
@now_states = []
refresh
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
actor = $game_party.actors
line_height = 120 / PARA_CTB::PARTY_SIZE
actor_y = i * line_height + 4
# 現在のステータスを配列に
@now_hp = actor.hp
@now_sp = actor.sp
@now_states = actor.states
# レベルアップ
if @level_up_flags
self.contents.fill_rect(344, actor_y, 100, 32, Color.new(0, 0, 0, 0))
self.contents.font.color = normal_color
self.contents.draw_text(344, actor_y, 120, 32, "LEVEL UP!")
end
end
# バトルステータスの軽量化処理
# ステータスの配列が変化したときのみ描画処理
if @before_hp == nil or @before_sp == nil or @before_states == nil or @before_hp != @now_hp or @before_sp != @now_sp or @before_states != @now_states
self.contents.clear
for i2 in 0...$game_party.actors.size
actor = $game_party.actors[i2]
line_height = 120 / PARA_CTB::PARTY_SIZE
actor_y = i2 * line_height + 4
self.contents.font.size = PARA_CTB::NAME_FONT_SIZE
# 名前を描画
draw_actor_name(actor, 4, actor_y+16-PARA_CTB::NAME_FONT_SIZE)
# HPを描画
hp_color1 = PARA_CTB::HP_COLOR_LEFT
hp_color2 = PARA_CTB::HP_COLOR_RIGHT
draw_meter(actor.hp, actor.maxhp, 125, actor_y+14, 80, 8, hp_color1, hp_color2)
draw_actor_hp(actor, 102, actor_y+16-PARA_CTB::HPSP_FONT_SIZE, 100)
# SPを描画
sp_color1 = PARA_CTB::SP_COLOR_LEFT
sp_color2 = PARA_CTB::SP_COLOR_RIGHT
draw_meter(actor.sp, actor.maxsp, 245, actor_y+14, 80, 8, sp_color1, sp_color2)
draw_actor_sp(actor, 222, actor_y+16-PARA_CTB::HPSP_FONT_SIZE, 100)
# 変化後のステータスを配列に
@before_hp[i2] = actor.hp
@before_sp[i2] = actor.sp
@before_states[i2] = actor.states
# レベルアップ
if @level_up_flags[i2] == false
draw_actor_state(actor, 344, actor_y)
end
end
end
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
super
end
#--------------------------------------------------------------------------
# ● HP の描画
# actor : アクター
# x : 描画先 X 座標
# y : 描画先 Y 座標
# width : 描画先の幅
#--------------------------------------------------------------------------
def draw_actor_hp(actor, x, y, width = 144)
# 文字列 "HP" を描画
self.contents.font.color = system_color
self.contents.font.size = 16
self.contents.draw_text(x, y+2, 32, 32, $data_system.words.hp)
self.contents.font.color = normal_color
self.contents.font.size = PARA_CTB::HPSP_FONT_SIZE
if PARA_CTB::MAX_DRAW
# MaxHP を描画
self.contents.draw_text(x, y, width, 32, actor.maxhp.to_s, 2)
text_size = self.contents.text_size(actor.maxhp.to_s)
text_x = x + width - text_size.width - 12
self.contents.draw_text(text_x, y, 12, 32, "/", 1)
# HP を描画
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
text_x = text_x - text_size.width
self.contents.draw_text(text_x, y, text_size.width, 32, actor.hp.to_s, 2)
else
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
self.contents.draw_text(x, y, width, 32, actor.hp.to_s, 2)
end
end
#--------------------------------------------------------------------------
# ● SP の描画
# actor : アクター
# x : 描画先 X 座標
# y : 描画先 Y 座標
# width : 描画先の幅
#--------------------------------------------------------------------------
def draw_actor_sp(actor, x, y, width = 144)
# 文字列 "SP" を描画
self.contents.font.color = system_color
self.contents.font.size = 16
self.contents.draw_text(x, y+2, 32, 32, $data_system.words.sp)
self.contents.font.color = normal_color
self.contents.font.size = PARA_CTB::HPSP_FONT_SIZE
if PARA_CTB::MAX_DRAW
# MaxSP を描画
self.contents.draw_text(x, y, width, 32, actor.maxsp.to_s, 2)
text_size = self.contents.text_size(actor.maxsp.to_s)
text_x = x + width - text_size.width - 12
self.contents.draw_text(text_x, y, 12, 32, "/", 1)
# SP を描画
self.contents.font.color = actor.sp == 0 ? knockout_color :
actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
text_x = text_x - text_size.width
self.contents.draw_text(text_x, y, text_size.width, 32, actor.sp.to_s, 2)
else
self.contents.font.color = actor.sp == 0 ? knockout_color :
actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
self.contents.draw_text(x, y, width, 32, actor.sp.to_s, 2)
end
end
end
#==============================================================================
# □ 敵の名前を表示するウインドウ
#==============================================================================
class Window_BattleStatus_enemy < Window_Base
#--------------------------------------------------------------------------
# ○ オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 320, 160, 160)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# ○ リフレッシュ
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = PARA_CTB::ENEMY_FONT_SIZE
@exist_enemies = []
if $game_troop.enemies != nil
if PARA_CTB::ENEMY_GROUPING
ememy_list = []
ememy_list_index = []
# エネミーをグループ化
for i in 0...$game_troop.enemies.size
enemy = $game_troop.enemies
if enemy.exist?
if ememy_list.include?(enemy.name)
ememy_list_index[ememy_list.index(enemy.name)] += 1
else
# エネミー名を記録
ememy_list.push(enemy.name)
ememy_list_index[ememy_list.index(enemy.name)] = 1
end
end
end
# エネミーの名前と数を描画
enemy_index = 0
for enemy_name in ememy_list
enemy_y = enemy_index * (PARA_CTB::ENEMY_FONT_SIZE+6) + 4
if ememy_list_index[enemy_index] > 1
enemy_name = enemy_name + " " + ememy_list_index[enemy_index].to_s
end
self.contents.draw_text(4, enemy_y, 160, 20, enemy_name)
enemy_index += 1
end
else
# エネミーの名前を描画
enemy_index = 0
for i in 0...$game_troop.enemies.size
enemy = $game_troop.enemies
if enemy.exist?
@exist_enemies.push(enemy)
line_height = PARA_CTB::ENEMY_FONT_SIZE + 6
if PARA_CTB::ENEMY_DRAWING_MATER != 0
line_height += 10
end
enemy_y = enemy_index * line_height + 4
self.contents.draw_text(4, enemy_y, 160, 20, enemy.name)
enemy_index += 1
# HPゲージを描画
if PARA_CTB::ENEMY_DRAWING_MATER == 1
hp_color1 = PARA_CTB::HP_COLOR_LEFT
hp_color2 = PARA_CTB::HP_COLOR_RIGHT
y = enemy_y + PARA_CTB::ENEMY_FONT_SIZE + 3
draw_meter(enemy.hp, enemy.maxhp, 4, y, 80, 8, hp_color1, hp_color2)
end
end
end
end
end
end
end
#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ○ ゲージを描画
#--------------------------------------------------------------------------
def draw_meter(now, max, x, y, width, height, start_color, end_color=start_color )
self.contents.fill_rect(x, y, width, height, PARA_CTB::FRAME_COLOR)
self.contents.fill_rect(x+PARA_CTB::FRAME_BORDER, y+PARA_CTB::FRAME_BORDER, width-PARA_CTB::FRAME_BORDER*2, height-PARA_CTB::FRAME_BORDER*2, PARA_CTB::BACK_COLOR)
now = now > max ? max : now
percentage = max != 0 ? (width-2) * now / max.to_f : 0
if start_color == end_color
self.contents.fill_rect(x+1, y+1, percentage, height-2, start_color)
else
for i in 1..percentage
r = start_color.red + (end_color.red - start_color.red) / percentage * i
g = start_color.green + (end_color.green - start_color.green) / percentage * i
b = start_color.blue + (end_color.blue - start_color.blue) / percentage * i
a = start_color.alpha + (end_color.alpha - start_color.alpha) / percentage * i
self.contents.fill_rect(x+i, y+1, 1, height-2, Color.new(r, g, b, a))
end
end
end
end
#==============================================================================
# ■ Window_Help
#==============================================================================
class Window_Help < Window_Base
#--------------------------------------------------------------------------
# ● アクター設定
# actor : ステータスを表示するアクター
#--------------------------------------------------------------------------
alias set_actor_ctb set_actor
def set_actor(actor)
if PARA_CTB::HELP_DRAWING_MATER_ACTOR
self.contents.clear
draw_actor_name(actor, 4, 0)
draw_actor_state(actor, 140, 0)
hp_color1 = PARA_CTB::HP_COLOR_LEFT
hp_color2 = PARA_CTB::HP_COLOR_RIGHT
draw_meter(actor.hp, actor.maxhp, 316, 18, 112, 8, hp_color1, hp_color2)
draw_actor_hp(actor, 284, 0)
sp_color1 = PARA_CTB::SP_COLOR_LEFT
sp_color2 = PARA_CTB::SP_COLOR_RIGHT
draw_meter(actor.sp, actor.maxsp, 492, 18, 112, 8, sp_color1, sp_color2)
draw_actor_sp(actor, 460, 0)
@actor = actor
@text = nil
self.visible = true
else
set_actor_ctb(actor)
end
end
#--------------------------------------------------------------------------
# ● エネミー設定
# enemy : 名前とステートを表示するエネミー
#--------------------------------------------------------------------------
alias set_enemy_ctb set_enemy
def set_enemy(enemy)
if PARA_CTB::HELP_DRAWING_MATER_ENEMY
self.contents.clear
draw_actor_name(enemy, 4, 0)
draw_actor_state(enemy, 140, 0)
hp_color1 = PARA_CTB::HP_COLOR_LEFT
hp_color2 = PARA_CTB::HP_COLOR_RIGHT
draw_meter(enemy.hp, enemy.maxhp, 316, 18, 112, 8, hp_color1, hp_color2)
draw_actor_hp(enemy, 284, 0)
sp_color1 = PARA_CTB::SP_COLOR_LEFT
sp_color2 = PARA_CTB::SP_COLOR_RIGHT
draw_meter(enemy.sp, enemy.maxsp, 492, 18, 112, 8, sp_color1, sp_color2)
draw_actor_sp(enemy, 460, 0)
self.visible = true
else
set_enemy_ctb(enemy)
end
end
end[/pre]
|
-
上面的照片(步行图文版)侧面视图战斗 已经一起使用。
|