Skip to content

Instantly share code, notes, and snippets.

@lctseng
Last active August 29, 2015 14:05
Show Gist options
  • Save lctseng/e5da5e7a6e877803d7ff to your computer and use it in GitHub Desktop.
Save lctseng/e5da5e7a6e877803d7ff to your computer and use it in GitHub Desktop.
RGSS3:敵我情報,支援多行屬性
#==============================================================================
# ■ RGSS3 状況確認コマンド Ver1.05 by 星潟
#------------------------------------------------------------------------------
# RPGツクールVXAceでは、現在のステートや強化/弱体の表示数が
# 著しく制限されており、非常に確認し辛いです。
#
# しかし、状況確認コマンドではステートを22個、強化/弱体も全て表示されます。
#
# パーティコマンドに、敵味方の現在能力値やステート/強化/弱体の状態を
# 確認する為の新規コマンドを追加します。
# 最初はアクターを表示し、LボタンかRボタンを押すことで
# エネミーに表示を切り替えます。
# アクターかエネミーを指定して決定キーを押すことで詳細表示を行います。
# 詳細表示中に更に決定キーを押すと、属性耐性とステート耐性が表示されます。
#
# エネミーを表示しない機能や、詳細を表示せず
# ステート/強化/弱体の確認に留めさせる設定も可能です。
#
# テストモードでの利用に限定する事も可能です。
#------------------------------------------------------------------------------
# Ver1.01 %表示に関する設定や、属性/ステート耐性の表示機能が追加されました。
# Ver1.02 操作性を向上させました。
# Ver1.03 隠れている敵を表示しないようにする機能を追加しました。
# Ver1.04 詳細モードで敵のHPが表示限界でも見えてしまう不具合を修正しました。
# また、表示限界の適用を敵のみにする機能を追加しました。
# Ver1.05 システム側のTP表示設定が無効化されていてもTPが表示される不具合を修正。
#==============================================================================
module B_CONFIRM
#テストモード限定化するか否かを設定します。
#(trueで限定化/falseで常時使用可)
TONLY = false
#状況確認コマンドの名称を取得します。
WORD1 = "敵我情報"
#ステート表示用の項目名を取得します。
WORD2 = "狀態1"
#強化/弱体表示用の項目名を取得します。
WORD3 = "狀態2"
#背景透過度を設定します。
BOPAC = 255
#控えメンバーも表示するかどうかを設定します。
#(trueで表示/falseで非表示)
PTMT = true
#メンバーの詳細情報を表示するかどうかを設定します。
#(trueで表示/falseで非表示)
PTDT = true
#ページ切り替えで敵も表示するかどうかを設定します。
#(trueで表示/falseで非表示)
TROK = true
#敵の詳細情報を表示するかどうかを設定します。
#(trueで表示/falseで非表示)
TRDT = true
#隠れている敵も表示するかどうかを指定します。
HIDE = false
#HP/MP/TPの表示限界値を設定します。
#この値を以上の値となった時はTEXTの文字列を表示します。
OVER = 999999
#HP/MP/TPが表示限界値に達した際に、代わりに表示する文字列を設定します。
TEXT = "?????"
#表示限界に達した際に代わりに表示するのは敵のみにするかを設定します。
#trueで敵のみ、falseで双方となります。
EN_O = true
#2ページ目を有効にするか否かを設定します。
#(trueで有効/falseで無効)
P2 = true
#詳細情報での追加能力値の表示設定を行います。
#[追加能力値ID(0~9の数字), 追加能力値名称(文字列), 敵も表示するか否か(true/false)]で
#1セットとなっています。
XPRM = [
[0, "命中率", true],
[1, "回避率", true],
[2, "會心率", true],
[3, "會心回避率", true],
[4, "魔法回避率", true],
[5, "魔法反射率", true],
[6, "反擊率", true],
[7, "HP再生率", true],
[8, "MP再生率", true],
[9, "TP再生率", true]
]
#追加能力値の後に%の文字を付けるか否かを設定します。
#(trueで有効/falseで無効)
ADP = false
#詳細情報での特殊能力値の表示設定を行います。
#[特殊能力値ID(0~9の数字), 特殊能力値名称(文字列), 敵も表示するか否か(true/false)]で
#1セットとなっています。
SPRM = [
[0, "當成目標率", true],
[1, "防禦效果率", true],
[2, "回復效果率", true],
[3, "藥理知識", true],
[4, "MP消費率", true],
[5, "TP補充率", true],
[6, "被物理傷害率", true],
[7, "被魔法傷害率", true],
[9, "經驗獲得率", true]
]
#特殊能力値の後に%の文字を付けるか否かを設定します。
#(trueで有効/falseで無効)
SPP = false
#詳細情報での属性有効度の表示設定を行います。
#[属性ID, 属性名の後に付ける文字(文字列),
#敵も表示するか否か(true/false),
#100から該当の値を引いた数で表示するかを否か,
#数字の後に付ける文字(文字列)]で
#1セットとなっています。
ELEM = [
[2, "屬性", true, true],
[3, "屬性", true, true],
[4, "屬性", true, true],
[5, "屬性", true, true],
[6, "屬性", true, true],
[7, "屬性", true, true],
[8, "屬性", true, true],
[9, "屬性", true, true],
[10, "屬性", true, true],
[11, "屬性", true, true],
[12, "屬性", true, true],
[13, "屬性", true, true],
]
#属性有効度の後に%の文字を付けるか否かを設定します。
#(trueで有効/falseで無効)
ELP = false
#1行目に表示するステートの最大数を指定します。
#(2行目までしか想定していません)
MAX = 10
#詳細情報でのステート有効度の表示設定を行います。
#[ステートID(0~-7で指定した場合は、絶対数の値の弱体有効度ID),
#ステート名の後に付ける文字(文字列), 敵も表示するか否か(true/false),
#100から該当の値を引いた数で表示するかを否か]で
#1セットとなっています。
=begin
STAT = [
[1, "耐性", true, true],
[2, "耐性", true, true],
[3, "耐性", true, true],
[4, "耐性", true, true],
[5, "耐性", true, true],
[6, "耐性", true, true],
[7, "耐性", true, true],
[8, "耐性", true, true],
[9, "耐性", true, true],
[10, "耐性", true, true],
[0, "弱体", true, true],
[-1, "弱体", true, true],
[-2, "弱体", true, true],
[-3, "弱体", true, true],
[-4, "弱体", true, true],
[-5, "弱体", true, true],
[-6, "弱体", true, true],
[-7, "弱体", true, true]
]
#ステート有効度の後に%の文字を付けるか否かを設定します。
#(trueで有効/falseで無効)
STP = false
=end
end
#テストモード限定化されており、なおかつテストモードの場合か
#テストモード限定化されていない場合は処理を行う。
if (B_CONFIRM::TONLY && ($TEST or $BTEST)) or !B_CONFIRM::TONLY
class Game_Troop < Game_Unit
def unhidden_members
B_CONFIRM::HIDE ? members : members.select {|e| !e.hidden?}
end
end
class Game_Temp
attr_accessor :b_confirm_limit_flag
end
class Window_Base < Window
alias draw_current_and_max_values_overnumber draw_current_and_max_values
def draw_current_and_max_values(x, y, width, current, max, color1, color2)
#状況確認ウィンドウである場合のみ
#現在値と最大値を必要に応じて読み替える。
if (self.is_a?(Window_B_Confirm) or self.is_a?(Window_B_Confirm_Detail)) && $game_temp.b_confirm_limit_flag
current = B_CONFIRM::TEXT if current >= B_CONFIRM::OVER
max = B_CONFIRM::TEXT if max >= B_CONFIRM::OVER
end
#本来の処理を実行する。
draw_current_and_max_values_overnumber(x, y, width, current, max, color1, color2)
end
end
class Window_PartyCommand < Window_Command
#--------------------------------------------------------------------------
# コマンドリストの作成
#--------------------------------------------------------------------------
alias make_command_list_b_confirm make_command_list
def make_command_list
#本来の処理を実行する。
make_command_list_b_confirm
#状況確認コマンドを追加する。
add_command(B_CONFIRM::WORD1, :b_confirm)
end
end
class Window_B_Confirm < Window_Selectable
attr_accessor :end_flag
attr_accessor :display_mode
attr_accessor :last_actor
def initialize(x, y, type, actor = nil)
#各種データを取得する。
@display_mode = type
@last_actor = actor
@end_flag = false
#ウィンドウを作成する。
super(x, y, window_width, window_height)
#背景透過度を設定する。
self.back_opacity = B_CONFIRM::BOPAC
activate
self.index = 0
#描写を行う。
refresh
end
#--------------------------------------------------------------------------
# フレーム更新
#--------------------------------------------------------------------------
def update
#ウィンドウを閉じている最中は何もしない。
return if @end_flag
super
return if !self.active
if Input.trigger?(:B)#キャンセルキーを押した場合
#キャンセルのSEを鳴らす。
Sound.play_cancel
@end_flag = true
@last_actor = nil
@display_mode = 2
elsif Input.trigger?(:C)#決定キーを押した場合
#バトラーが指定されていない場合はウィンドウを閉じる。
#バトラーが指定されている場合はウィンドウを切り替える。
case @display_mode
when 0
actor = B_CONFIRM::PTMT ? $game_party.all_members[index] : $game_party.members[index]
when 1
actor = $game_troop.unhidden_members[index]
end
#バトラーがアクターであり、なおかつアクターの詳細表示が可能な場合
#あるいはバトラーがエネミーであり、なおかつエネミーの詳細表示が可能な場合続行。
return if actor.actor? && !B_CONFIRM::PTDT
return if !actor.actor? && !B_CONFIRM::TRDT
#OKのSEを鳴らす。
Sound.play_ok
@end_flag = true
@last_actor = actor
elsif (Input.trigger?(:L) or Input.trigger?(:R)) && B_CONFIRM::TROK
#カーソルのSEを鳴らす。
Sound.play_cursor
#ウィンドウを作り直す準備を行う。
@end_flag = true
@last_actor = nil
@display_mode = @display_mode == 0 ? 1 : 0
end
end
#--------------------------------------------------------------------------
# ウィンドウ幅の取得
#--------------------------------------------------------------------------
def window_width
Graphics.width
end
#--------------------------------------------------------------------------
# ウィンドウ高さの取得
#--------------------------------------------------------------------------
def window_height
Graphics.height
end
#--------------------------------------------------------------------------
# 項目数の取得
#--------------------------------------------------------------------------
def item_max
#バトラーが指定されていない場合は項目数は1個にする。
return 1 if @last_actor != nil
#アクターかエネミーのどちらを表示するかで処理を分岐し
#それぞれ設定に適した値を返す。
case @display_mode
when 0
B_CONFIRM::PTMT ? $game_party.all_members.size : $game_party.members.size
when 1
$game_troop.unhidden_members.size
end
end
#--------------------------------------------------------------------------
# 項目の高さを取得
#--------------------------------------------------------------------------
def item_height
(height - standard_padding * 2) / 4
end
#--------------------------------------------------------------------------
# 項目の描画
#--------------------------------------------------------------------------
def draw_item(index)
#バトラーが指定されているか否かで処理を分岐。
if @last_actor == nil
#アクターかエネミーのどちらを表示するかで設定に応じて処理を分岐。
case @display_mode
when 0
actor = B_CONFIRM::PTMT ? $game_party.all_members[index] : $game_party.members[index]
when 1
actor = $game_troop.unhidden_members[index]
end
#項目の矩形を取得。
rect = item_rect(index)
#項目内のデータを描写していく。
$game_temp.b_confirm_limit_flag = (!B_CONFIRM::EN_O or (B_CONFIRM::EN_O && @display_mode == 1))
draw_actor_name(actor, rect.x, rect.y)
draw_actor_hp(actor, rect.x + 4, rect.y + line_height * 1)
draw_actor_mp(actor, rect.x + 4, rect.y + line_height * 2)
draw_actor_tp(actor, rect.x + 4, rect.y + line_height * 3) if $data_system.opt_display_tp
self.contents.font.color = system_color
draw_text(rect.x + 150, rect.y + line_height * 1, 96, line_height, B_CONFIRM::WORD2)
draw_text(rect.x + 150, rect.y + line_height * 3, 96, line_height, B_CONFIRM::WORD3)
self.contents.font.color = normal_color
icons_width = (rect.width - rect.x - 150 - 96) / 24
icons = (actor.state_icons)[0, icons_width]
icons.each_with_index {|n, i| draw_icon(n, rect.x + 246 + 24 * i, rect.y + line_height * 1) }
icons = (actor.state_icons)[icons_width, icons_width * 2]
icons.each_with_index {|n, i| draw_icon(n, rect.x + 246 + 24 * i, rect.y + line_height * 2) } if icons != nil
icons = (actor.buff_icons)[0, icons_width]
icons.each_with_index {|n, i| draw_icon(n, rect.x + 246 + 24 * i, rect.y + line_height * 3) }
end
end
#--------------------------------------------------------------------------
# 決定ボタンが押されたときの処理(邪魔なので消す)
#--------------------------------------------------------------------------
def process_ok
end
#--------------------------------------------------------------------------
# キャンセルボタンが押されたときの処理(邪魔なので消す)
#--------------------------------------------------------------------------
def process_cancel
end
#--------------------------------------------------------------------------
# Lボタンが押されたときの処理(邪魔なので消す)
#--------------------------------------------------------------------------
def process_pageup
end
#--------------------------------------------------------------------------
# Rボタンが押されたときの処理(邪魔なので消す)
#--------------------------------------------------------------------------
def process_pagedown
end
end
class Window_B_Confirm_Detail < Window_Base
attr_accessor :window_b_confirm
attr_accessor :end_flag
#--------------------------------------------------------------------------
# 初期化
#--------------------------------------------------------------------------
def initialize(window_b_confirm)
@page_data = 0
@window_b_confirm = window_b_confirm
@end_flag = false
super(0, 0, window_width, window_height)
#背景透過度を設定する。
self.back_opacity = B_CONFIRM::BOPAC
refresh
end
#--------------------------------------------------------------------------
# ウィンドウ幅の取得
#--------------------------------------------------------------------------
def window_width
Graphics.width
end
#--------------------------------------------------------------------------
# ウィンドウ高さの取得
#--------------------------------------------------------------------------
def window_height
Graphics.height
end
#--------------------------------------------------------------------------
# フレーム更新
#--------------------------------------------------------------------------
def update
super
if Input.trigger?(:B)#キャンセルキーを押した場合
#キャンセルのSEを鳴らす。
Sound.play_cancel
@end_flag = true
elsif page_change? #決定キー、左右キー、LRボタンを押した場合
Sound.play_cursor
@page_data = @page_data == 0 ? 1 : 0
contents.clear
refresh
end
end
#--------------------------------------------------------------------------
# ページ切り替えを行うか?
#--------------------------------------------------------------------------
def page_change?
flag = false
[:C, :L, :R, :LEFT, :RIGHT].each {|k|flag = true if Input.trigger?(k)}
flag
end
#--------------------------------------------------------------------------
# リフレッシュ
#--------------------------------------------------------------------------
def refresh
#バトラーを取得。
actor = @window_b_confirm.last_actor
#項目内のデータを描写していく。
draw_actor_name(actor, x, y)
$game_temp.b_confirm_limit_flag = (!B_CONFIRM::EN_O or (B_CONFIRM::EN_O && !actor.actor?))
draw_actor_hp(actor, x + 4, y + line_height * 1)
draw_actor_mp(actor, x + 4, y + line_height * 2)
draw_actor_tp(actor, x + 4, y + line_height * 3) if $data_system.opt_display_tp
self.contents.font.color = system_color
draw_text(x + 150, y + line_height * 1, 96, line_height, B_CONFIRM::WORD2)
draw_text(x + 150, y + line_height * 3, 96, line_height, B_CONFIRM::WORD3)
self.contents.font.color = normal_color
icons_width = (width - x - 162 - 96) / 24
icons = (actor.state_icons)[0, icons_width]
icons.each_with_index {|n, i| draw_icon(n, x + 246 + 24 * i, y + line_height * 1) }
icons = (actor.state_icons)[icons_width, icons_width * 2]
icons.each_with_index {|n, i| draw_icon(n, x + 246 + 24 * i, y + line_height * 2) } if icons != nil
icons = (actor.buff_icons)[0, icons_width]
icons.each_with_index {|n, i| draw_icon(n, x + 246 + 24 * i, y + line_height * 3) }
draw_horz_line(line_height * 4)
if @page_data == 0
6.times {|i|draw_actor_param(actor, x, y + line_height * (5 + i), (i + 2))}
ex_xprms_draw(actor, x, y)
ex_sprms_draw(actor, x, y)
else
ex_elem_draw(actor, x, y)
#ex_state_draw(actor, x, y)
end
end
#--------------------------------------------------------------------------
# 水平線の色を取得(Window_Statusからそのままコピー)
#--------------------------------------------------------------------------
def line_color
color = normal_color
color.alpha = 48
color
end
#--------------------------------------------------------------------------
# 水平線の描画(Window_Statusからそのままコピー)
#--------------------------------------------------------------------------
def draw_horz_line(y)
line_y = y + line_height / 2 - 1
contents.fill_rect(0, line_y, contents_width, 2, line_color)
end
#--------------------------------------------------------------------------
# 追加能力値
#--------------------------------------------------------------------------
def ex_xprms_draw(actor, x, y)
#追加能力値の描写対象がない場合は飛ばす。
return if B_CONFIRM::XPRM.empty?
#追加能力値を描写する。
B_CONFIRM::XPRM.each_with_index do |xp, i|
next if !actor.actor? && !xp[2]
change_color(system_color)
draw_text(x + 170, y + line_height * (5 + i), 120, line_height, xp[1])
change_color(normal_color)
draw_text(x + 280, y + line_height * (5 + i), 56, line_height, (actor.xparam(xp[0]) * 100).to_i.to_s + (B_CONFIRM::ADP ? "%" : ""), 2)
end
end
#--------------------------------------------------------------------------
# 特殊能力値
#--------------------------------------------------------------------------
def ex_sprms_draw(actor, x, y)
#特殊能力値の描写対象がない場合は飛ばす。
return if B_CONFIRM::SPRM.empty?
#特殊能力値を描写する。
B_CONFIRM::SPRM.each_with_index do |sp, i|
next if !actor.actor? && !sp[2]
change_color(system_color)
draw_text(x + 344, y + line_height * (5 + i), 120, line_height, sp[1])
change_color(normal_color)
draw_text(x + 454, y + line_height * (5 + i), 56, line_height, (actor.sparam(sp[0]) * 100).to_i.to_s + (B_CONFIRM::SPP ? "%" : ""), 2)
end
end
#--------------------------------------------------------------------------
# 属性有効度
#--------------------------------------------------------------------------
def ex_elem_draw(actor, raw_x, y)
#属性有効度の描写対象がない場合は飛ばす。
return if B_CONFIRM::ELEM.empty?
#属性有効度を描写する。
B_CONFIRM::ELEM.each_with_index do |elem, index|
next if !actor.actor? && !elem[2]
i = index % B_CONFIRM::MAX
if index >= B_CONFIRM::MAX
x = raw_x + 180
else
x = raw_x
end
change_color(system_color)
name = $data_system.elements[elem[0]]
data = (actor.element_rate(elem[0]) * 100).to_i
data = (elem[3] ? (100 - data) : data).to_s
draw_text(x, y + line_height * (5 + i), 120, line_height, name + elem[1])
change_color(normal_color)
draw_text(x + 110, y + line_height * (5 + i), 56, line_height, data + (B_CONFIRM::ELP ? "%" : ""), 2)
end
end
#--------------------------------------------------------------------------
# ステート有効度
#--------------------------------------------------------------------------
=begin
#--------------------------------------------------------------------------
# ステート有効度
#--------------------------------------------------------------------------
def ex_state_draw(actor, x, y)
#ステート有効度の描写対象がない場合は飛ばす。
return if B_CONFIRM::STAT.empty?
#ステート有効度を描写する。
B_CONFIRM::STAT.each_with_index do |state, i|
next if !actor.actor? && !state[2]
change_color(system_color)
x_data = i < B_CONFIRM::MAX ? 170 : 344
if state[0] > 0
name = $data_states[state[0]].name
data = (actor.state_rate(state[0]) * 100).to_i
data = (state[3] ? (100 - data) : data).to_s
else
state_id = state[0].abs
name = Vocab.param(state_id)
data = (actor.debuff_rate(state_id) * 100).to_i
data = (state[3] ? (100 - data) : data).to_s
end
draw_text(x + x_data, y + line_height * (5 + i - (i < B_CONFIRM::MAX ? 0 : B_CONFIRM::MAX)), 120, line_height, name + state[1])
change_color(normal_color)
draw_text(x + x_data + 110, y + line_height * (5 + i - (i < B_CONFIRM::MAX ? 0 : B_CONFIRM::MAX)), 56, line_height, data + (B_CONFIRM::STP ? "%" : ""), 2)
end
end
=end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# パーティコマンドウィンドウの作成
#--------------------------------------------------------------------------
alias create_party_command_window_b_confirm create_party_command_window
def create_party_command_window
#本来の処理を実行。
create_party_command_window_b_confirm
#状況確認コマンド用のハンドラを追加。
@party_command_window.set_handler(:b_confirm, method(:command_b_confirm))
end
#--------------------------------------------------------------------------
# コマンド[状況確認]
#--------------------------------------------------------------------------
def command_b_confirm
#状況確認コマンドの処理内容を実行。
b_confirm_execute
end
#--------------------------------------------------------------------------
# 状況確認開始
#--------------------------------------------------------------------------
def b_confirm_execute
#状況確認ウィンドウを作成。
@b_confirm_window = Window_B_Confirm.new(0, 0, 0)
#処理をループで処理。
loop do
#とりあえずアップデートは行う。
update
#状況確認ウィンドウがアクティブであり
#なおかつ操作終了フラグが有効な場合は分岐。
if @b_confirm_window.active && @b_confirm_window.end_flag
#表示モードが2の時、ループを終了する。
break if @b_confirm_window.display_mode == 2
#操作終了フラグをfalseにする。
@b_confirm_window.end_flag = false
#最後にキャラクターを選択している場合
if @b_confirm_window.last_actor != nil
#状況確認ウィンドウのアクティブ状態を解除し
#詳細ウィンドウを作成する。
@b_confirm_window.deactivate
@b_confirm_detail_window = Window_B_Confirm_Detail.new(@b_confirm_window)
#最後にキャラクターを選択していない場合
else
#状況確認ウィンドウを解放する。
@b_confirm_window.dispose
#状況確認ウィンドウを作り直す。
@b_confirm_window = Window_B_Confirm.new(0, 0, (@b_confirm_window.display_mode == 0 ? 0 : 1))
end
#詳細ウィンドウが存在し、なおかつ終了フラグが有効な場合。
elsif @b_confirm_detail_window != nil && @b_confirm_detail_window.end_flag
#詳細ウィンドウを解放し、nil扱いとする。
@b_confirm_detail_window.dispose
@b_confirm_detail_window = nil
#最後に選択したアクターをnilとする。
@b_confirm_window.last_actor = nil
#状況確認ウィンドウをアクティブ化する。
@b_confirm_window.activate
end
end
#状況確認ウィンドウを解放する。
@b_confirm_window.dispose
#パーティコマンドウィンドウをアクティブにする。
@party_command_window.activate
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment