ページ 12

【解決済み】戦闘中にステートの詳細を確認

Posted: 2017年4月11日(火) 23:24
by アロエ
アイコンだけでは詳細な効果が分からない場合もあるので
パーティコマンドにコマンドを追加しステートの詳細を確認できるスクリプトを作っていただけないでしょうか

下記の項目は出来たらこうしてほしいという要望です
・味方はバトルメンバーだけでなくパーティメンバー全員を表示
・敵味方全てを一度に表示すると見づらくなってしまうので敵と味方はページを分けて表示
・ステートのメモ欄かスクリプト内にステートの説明を記述

もし似たようなスクリプトが他にあれば紹介して頂けると幸いです
どうぞよろしくお願いします

Re: 戦闘中にステートの詳細を確認

Posted: 2017年4月12日(水) 18:24
by TOMO
要望通りではないですが…

コード: 全て選択

module TOMO
  module StateHelp
    # 説明文の設定
    # ステートID => 説明文
    #
    # 説明文に制御文字が使えます(改行は「\r\n」)
    Text = {
      1 => "HPが0になり、死亡した状態。",   # 戦闘不能
      2 => "\\C[2]テスト\\C[0]\r\nテスト2", # 毒
    }
  end
end

class Window_StateList < Window_Command 
  def make_command_list
    states = []
    ($game_party.members + $game_troop.members).each do |battler|
      states |= battler.states.collect{|s| s.id }
    end
    states.sort!
    states.each do |state_id|
      state = $data_states[state_id]
      add_command(state.name, :state, true, state)
    end
  end
 
  def window_width
    Graphics.width
  end
 
  def window_height
    Graphics.height - fitting_height(2)
  end
 
  def process_ok
  end
 
  def draw_item(index)
    change_color(normal_color, command_enabled?(index))
    rect = item_rect_for_text(index)
    draw_item_name(@list[index][:ext], rect.x, rect.y)
  end
 
  def update_help
    if @help_window && current_ext
      text = TOMO::StateHelp::Text[current_ext.id]
      text = "" if TOMO::StateHelp::Text[current_ext.id].nil?
      @help_window.set_text(text)
    end
  end
 
  def show
    select(0)
    @help_window.show
    super
  end
 
  def hide
    @help_window.hide
    super
  end
end

class Window_PartyCommand < Window_Command
  alias tomo_state_help_make_command_list make_command_list
  def make_command_list
    tomo_state_help_make_command_list
    add_command("ステート確認", :state)
  end
end

class Scene_Battle < Scene_Base
  alias tomo_state_help_create_party_command_window create_party_command_window
  def create_party_command_window
    tomo_state_help_create_party_command_window
    @party_command_window.set_handler(:state,  method(:command_state))
  end
 
  alias tomo_state_help_create_item_window create_item_window
  def create_item_window
    tomo_state_help_create_item_window
    @state_window = Window_StateList.new(0, @help_window.height)
    @state_window.help_window = @help_window
    @state_window.set_handler(:cancel, method(:on_state_cancel))
    @state_window.hide
  end
 
  def command_state
    @party_command_window.deactivate
    @state_window.refresh
    @state_window.show
    @state_window.activate
  end
 
  def on_state_cancel
    @state_window.hide
    @state_window.deactivate
    @party_command_window.activate
  end
end

敵味方全メンバーのステートを纏めた一覧&説明だけです

Re: 戦闘中にステートの詳細を確認

Posted: 2017年4月12日(水) 20:45
by アロエ
TOMOさん
スクリプトの作成ありがとうございます

ステートの説明欄にそのステートにかかっている
アクターと敵の名前を表示することは可能でしょうか?

Re: 戦闘中にステートの詳細を確認

Posted: 2017年4月12日(水) 22:04
by faida
昔のスクリプトの改変とか間に合わせとかそんな感じのやつですが、よろしければ。

コード: 全て選択

=begin

◆作者:faida @faida3983

=end

module FAI_SBS
  STATES_DESCRIPTION = []
  # 設定項目:ステートの説明 これがないステートは表示しない
  STATES_DESCRIPTION[1] = "戦闘不能状態。"
  STATES_DESCRIPTION[2] = "毒によって体が侵されている状態。"
  STATES_DESCRIPTION[3] = "闇に纏われており目標がよく見えない状態。"
  STATES_DESCRIPTION[4] = "詠唱ができず、魔法が使用できない状態。"
  STATES_DESCRIPTION[5] = "敵と味方の区別がつかない状態。"
  STATES_DESCRIPTION[6] = "眠っており、動けない状態。"
  STATES_DESCRIPTION[7] = "体が麻痺しており、動けない状態。"
  STATES_DESCRIPTION[8] = "一時的に怯んでいる状態。"
  # 設定項目:「状態コマンド」の名前
  STATES_NAME = "状態"
  # 設定項目:状態コマンド時、ウィンドウの下に表示する文章
  STATUS_INFO = "矢印キーで頁送り、Q・Wキーで敵味方変更"
  # 設定項目:そのX座標
  STATUS_INFO_X = 200
  # 設定項目:そのY座標
  STATUS_INFO_Y = 118
  # 設定項目:そのフォントサイズ
  STATUS_INFO_SIZE = 15
end

class Window_BattlerState < Window_Base
  include FAI_SBS
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader :battler
  def initialize(battler = nil)
    super(0, 0, 544, 136)
    self.z += 1
    create_layout
#~     self.opacity = 0
    self.contents_opacity = 0
    self.visible = false
    self.battler = battler
  end
  def viewport=(viewport)
    super
    return if !@layout
    @layout.viewport = viewport
  end
  def create_layout
    return if @layout
    @layout = Sprite.new
    @layout.x, @layout.y, @layout.z = self.x, self.y, self.z - 1
    @layout.visible = false; @layout.opacity
  end
  def dispose
    super; @layout.dispose
  end
  def battler=(battler)
    return if @battler == battler; @battler = battler
#~     self.x = 66 if @layout.visible
    refresh
  end
  def update
    super
    if @change
      self.contents_opacity += 24; @layout.opacity += 24
      self.x = [self.x - 10, 0].max
      @change = nil if self.contents_opacity == 255
    elsif !@change.nil?
      self.contents_opacity -= 24; @layout.opacity -= 24
      self.x = [self.x + 10, 0].max
      if self.contents_opacity == 0
        self.visible = false; @layout.visible = false; @change = nil
      end
    end
    (@layout.x,@layout.y,@layout.z = self.x,self.y,self.z-1) if @layout.visible
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウの表示
  #--------------------------------------------------------------------------
  def show
    self.x = 110 if !@change && !@layout.visible
    @layout.visible = true; @change = true; super
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウの非表示
  #--------------------------------------------------------------------------
  def hide; @change = false; super; end
  def refresh
    return if !@battler
    contents.clear
    contents.font.size = 16
    # 第一スペース
    change_color(normal_color)
    draw_text(0, -4, 148, 16, @battler.name)
    # 第二スペース
    change_color(system_color)
    contents.font.size = 16
    draw_text(0, 16, 96, 20, "状態")
    @battler.states.each_with_index{|state, i|
      next if !STATES_DESCRIPTION[state.id]
      draw_item_name(state, 0, (i + 1) * 20 + 16)
      draw_text_ex(80, (i+1)*20 + 16, '\\}:'+STATES_DESCRIPTION[state.id])
    }
  end
  #--------------------------------------------------------------------------
  # ● アイコンの描画
  #--------------------------------------------------------------------------
  def draw_icon(icon_index, x, y, enabled = true)
    bitmap = Cache.system("Iconset")
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    if contents.font.size == 24
      contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
    else
      s = contents.font.size
      draw_rect = Rect.new(x, y, s, s)
      contents.stretch_blt(draw_rect, bitmap, rect, enabled ? 255 : translucent_alpha)
    end
  end
end

class Window_BattlerStates < Window_Selectable
  include FAI_SBS
  def initialize
    super(0, 0, Graphics.width, Graphics.height)
    self.visible = false
    create_all_windows
    create_info
    set_handler(:pagedown, method(:swap_opponent))
    set_handler(:pageup, method(:swap_opponent))
  end
  def unit; @troop ? $game_troop : $game_party; end
  def item_max
    [unit.members.size - 2, 1].max
  end
  def now_oy
    @windows[0] ? index * @windows[0].height : 0
  end
  def create_all_windows
    @windows = []; @viewport = Viewport.new; @viewport.z = 101
    unit.members.each_with_index{|a, i|
      @windows << Window_BattlerState.new(a)
      @windows[-1].y = i * @windows[-1].height
      @windows[-1].viewport = @viewport
      @windows[-1].hide.refresh
      @windows[-1].update
    }
  end
  def create_info
    @info_sprite = Sprite.new
    @info_sprite.x, @info_sprite.y = STATUS_INFO_X, STATUS_INFO_Y
    @info_sprite.z = @windows[-1].z + 1
    @info_sprite.bitmap = Bitmap.new(320, 24)
    @info_sprite.bitmap.font.size = STATUS_INFO_SIZE
    @info_sprite.bitmap.draw_text(0, 0, 320, 24, STATUS_INFO)
    @info_sprite.visible = false
  end
  def dispose; dispose_all_windows; super; end
  def dispose_all_windows; @windows.each{|w|w.dispose}; end
  def update
    super; @windows.each{|w|w.update}
    return if item_max == 1
    if @viewport.oy > now_oy; @viewport.oy -= 16
    elsif @viewport.oy < now_oy; @viewport.oy += 16
    end
    if (@viewport.oy - now_oy).abs < 16
      @viewport.oy = now_oy
    end
  end
  #--------------------------------------------------------------------------
  # ● 項目の選択
  #--------------------------------------------------------------------------
  def select(index)
    return if item_max == 1
    if self.index == 0 && index != 1
      @viewport.oy = item_max * @windows[0].height
    elsif index == 0 && self.index != 1
      @viewport.oy = -@windows[0].height
    end
    super
    @windows.each_with_index{|w,i|i.between?(index,index+2) ? w.show : w.hide}
  end
  def swap_opponent; @troop ^= true; @index = 0; refresh; end
  def activate; @troop = false; super; end
  def deactivate; @troop = false; super; end
  def show
    @windows.each_with_index{|w,i|w.show if i.between?(index,index+2)}
    @info_sprite.visible = true; self
  end
  def hide; @windows.each{|w|w.hide}; @info_sprite.visible = false; super; end
  #--------------------------------------------------------------------------
  # ● L ボタン(PageUp)が押されたときの処理
  #--------------------------------------------------------------------------
  def process_pageup
    Sound.play_cursor
    Input.update
#~     deactivate
    call_handler(:pageup)
  end
  #--------------------------------------------------------------------------
  # ● R ボタン(PageDown)が押されたときの処理
  #--------------------------------------------------------------------------
  def process_pagedown
    Sound.play_cursor
    Input.update
#~     deactivate
    call_handler(:pagedown)
  end
  def refresh
    dispose_all_windows
    create_all_windows
    show.active
  end
end

class Window_PartyCommand < Window_Command
  #--------------------------------------------------------------------------
  # コマンドリストの作成
  #--------------------------------------------------------------------------
  alias fai_sbs_make_command_list make_command_list
  def make_command_list
    fai_sbs_make_command_list
    add_command(FAI_SBS::STATES_NAME, :state)
  end
end

class Scene_Battle
  #--------------------------------------------------------------------------
  # ● 全ウィンドウの作成
  #--------------------------------------------------------------------------
  alias fai_sbs_create_all_windows create_all_windows
  def create_all_windows
    fai_sbs_create_all_windows
    create_state_window
  end
  #--------------------------------------------------------------------------
  # ● パーティコマンドウィンドウの作成
  #--------------------------------------------------------------------------
  alias fai_sbs_create_party_command_window create_party_command_window
  def create_party_command_window
    fai_sbs_create_party_command_window
    @party_command_window.set_handler(:state,  method(:command_state))
  end
  #--------------------------------------------------------------------------
  # ● 状態ウィンドウの作成
  #--------------------------------------------------------------------------
  def create_state_window
    @state_window = Window_BattlerStates.new
    @state_window.set_handler(:cancel, method(:on_state_cancel))
  end
  #--------------------------------------------------------------------------
  # ● コマンド[状態]
  #--------------------------------------------------------------------------
  def command_state
    @state_window.select(0)
    @state_window.refresh
    @state_window.show.activate
  end
  #--------------------------------------------------------------------------
  # ● 状態[キャンセル]
  #--------------------------------------------------------------------------
  def on_state_cancel
    @state_window.hide
    @party_command_window.activate
  end
end
で張っといてなんですが、TOMO様のモノのほうが使いやすそうなのでそちらをお勧めします。

Re: 戦闘中にステートの詳細を確認

Posted: 2017年4月12日(水) 22:54
by TOMO
こんな感じでいいですか?

コード: 全て選択

module TOMO
  module StateHelp
    # 説明文の設定
    # ステートID => 説明文
    #
    # 説明文に制御文字が使えます
    Text = {
      1 => "HPが0になり、死亡した状態。", # 戦闘不能
      2 => "\\C[2]テスト\\C[0]", # 毒
    }
  end
end

class Window_StateList < Window_Command 
  def make_command_list
    states = []
    ($game_party.members + $game_troop.members).each do |battler|
      states |= battler.states.collect{|s| s.id }
    end
    states.sort!
    states.each do |state_id|
      state = $data_states[state_id]
      add_command(state.name, :state, true, state)
    end
  end
 
  def window_width
    Graphics.width
  end
 
  def window_height
    Graphics.height - fitting_height(2)
  end
 
  def process_ok
  end
 
  def draw_item(index)
    change_color(normal_color, command_enabled?(index))
    rect = item_rect_for_text(index)
    draw_item_name(@list[index][:ext], rect.x, rect.y)
  end
 
  def update_help
    if @help_window && current_ext
      text = TOMO::StateHelp::Text[current_ext.id]
      text = "" if TOMO::StateHelp::Text[current_ext.id].nil?
      text += "\r\n"
      ($game_party.members + $game_troop.members).each do |battler|
        text += battler.name + " " if battler.state?(current_ext.id)
      end
      @help_window.set_text(text)
    end
  end
 
  def show
    select(0)
    @help_window.show
    super
  end
 
  def hide
    @help_window.hide
    super
  end
end

class Window_PartyCommand < Window_Command
  alias tomo_state_help_make_command_list make_command_list
  def make_command_list
    tomo_state_help_make_command_list
    add_command("ステート確認", :state)
  end
end

class Scene_Battle < Scene_Base
  alias tomo_state_help_create_party_command_window create_party_command_window
  def create_party_command_window
    tomo_state_help_create_party_command_window
    @party_command_window.set_handler(:state,  method(:command_state))
  end
 
  alias tomo_state_help_create_item_window create_item_window
  def create_item_window
    tomo_state_help_create_item_window
    @state_window = Window_StateList.new(0, @help_window.height)
    @state_window.help_window = @help_window
    @state_window.set_handler(:cancel, method(:on_state_cancel))
    @state_window.hide
  end
 
  def command_state
    @party_command_window.deactivate
    @state_window.refresh
    @state_window.show
    @state_window.activate
  end
 
  def on_state_cancel
    @state_window.hide
    @state_window.deactivate
    @party_command_window.activate
  end
end

Re: 戦闘中にステートの詳細を確認

Posted: 2017年4月12日(水) 23:57
by アロエ
TOMOさん、faidaさん
こちらのリクエストに答えていただきありがとうございます

TOMOさんのスクリプトなのですが同じステートにかかっている
敵味方の数が多いと名前がウインドウの外にはみだしてしまうので
改行もしくは名前の表示位置を変更する方法があれば教えてくださると助かります

この問題は敵の数を少なくすることで対処が可能なことと
はみだすほど多くの敵味方がステートにかかることはそう無いと思われるので
対応していただかなくてもかまいません

Re: 戦闘中にステートの詳細を確認

Posted: 2017年4月13日(木) 03:05
by TOMO
スクリプト中の

コード: 全て選択

text += "\r\n"


コード: 全て選択

text += "\r\n\\}"

とすれば名前部分が小さくなるので、それでどうですか?

Re: 戦闘中にステートの詳細を確認

Posted: 2017年4月13日(木) 23:29
by アロエ
問題を解決することが出来ました
TOMOさん、faidaさんのお二人に心からお礼申し上げます

Re: 【解決済み】戦闘中にステートの詳細を確認

Posted: 2017年4月16日(日) 19:59
by TOMO
別の所で変な事になってたので修正しました
(今回は名前を小さくする制御文字を最初から入れてます)

コード: 全て選択

module TOMO
  module StateHelp
    # 説明文の設定
    # ステートID => 説明文
    #
    # 説明文に制御文字が使えます
    Text = {
      1 => "HPが0になり、死亡した状態。", # 戦闘不能
      2 => "\\C[2]テスト\\C[0]", # 毒
    }
  end
end

class Window_StateList < Window_Command 
  def make_command_list
    states = []
    ($game_party.members + $game_troop.members).each do |battler|
      states |= battler.states.collect{|s| s.id }
    end
    states.sort!
    states.each do |state_id|
      state = $data_states[state_id]
      add_command(state.name, :state_list, true, state)
    end
  end
 
  def window_width
    Graphics.width
  end
 
  def window_height
    Graphics.height - fitting_height(2)
  end
 
  def process_ok
  end
 
  def draw_item(index)
    change_color(normal_color, command_enabled?(index))
    rect = item_rect_for_text(index)
    draw_item_name(@list[index][:ext], rect.x, rect.y)
  end
 
  def update_help
    if @help_window && current_ext
      text = TOMO::StateHelp::Text[current_ext.id]
      text = "" if TOMO::StateHelp::Text[current_ext.id].nil?
      text += "\r\n\\}"
      ($game_party.members + $game_troop.members).each do |battler|
        text += battler.name + " " if battler.state?(current_ext.id)
      end
      @help_window.set_text(text)
    end
  end
 
  def show
    refresh
    select(0)
    @help_window.show if @help_window
    super
  end
 
  def hide
    @help_window.hide if @help_window
    super
  end
end

class Window_PartyCommand < Window_Command
  alias tomo_state_help_make_command_list make_command_list
  def make_command_list
    tomo_state_help_make_command_list
    add_command("ステート確認", :state)
  end
end

class Scene_Battle < Scene_Base
  alias tomo_state_help_create_party_command_window create_party_command_window
  def create_party_command_window
    tomo_state_help_create_party_command_window
    @party_command_window.set_handler(:state, method(:command_state))
    @party_command_window.unselect
  end
 
  alias tomo_state_help_create_all_windows create_all_windows
  def create_all_windows
    tomo_state_help_create_all_windows
    @state_window = Window_StateList.new(0, @help_window.height)
    @state_window.set_handler(:cancel, method(:on_state_cancel))
    @state_window.help_window = @help_window
    @state_window.hide
  end
 
  def command_state
    @party_command_window.deactivate
    @state_window.show.activate
  end
 
  def on_state_cancel
    @state_window.hide.deactivate
    @party_command_window.activate
  end
end

前のは、戦闘開始から一直線に攻撃対象選択まで行き、
そこでキャンセルするとウィンドウ位置がおかしくなってたようです

Re: 【解決済み】戦闘中にステートの詳細を確認

Posted: 2017年4月17日(月) 23:00
by アロエ
TOMOさん修正ありがとうございます