[VXace]アナライズ・スクリプト強化依頼!

みるく
記事: 25
登録日時: 2017年7月15日(土) 01:05

[VXace]アナライズ・スクリプト強化依頼!

投稿記事by みるく » 2017年8月06日(日) 20:11

今日も暑いですね! こんばんは★

ここのフォーラムのずーっと前の方に、
『FFのライブラのようなスクリプト探してます』というトピックが「質問」の方にあり、
私もそこをたどって、レーネ様のスクリプト「アナライズ」を手に入れました(*^^)v

今回は、その「アナライズ」スクリプトに、以下の要素を加えたものを、
どなたかに作成して頂きたいと思って投稿します><!

元の作成者の方が行方不明&依頼無用のため:: 
規約に「改造・再配布ご自由に」とありますので、
別の方がいじって頂いても問題はないと思います!
(自分でできないかと数時間がんばってみましたが、やっぱり無理でした><)

元のスクリプト ↓↓↓

コード: 全て選択

=begin #=======================================================================
 
◆◇アナライズ RGSS3◇◆

◆DEICIDE ALMA
◆レーネ 
◆http://blog.goo.ne.jp/exa_deicide_alma

★機能
敵を解析するスキル/アイテムを作成できるようにします。
スキル/アイテムのメモ欄に <アナライズ> と記述するとアナライズとして機能します。
効果は戦闘中のみで、エネミーごとに別々となります。

敵のメモ欄に以下のように書くと、少し変化をつけることができます。
-------------------------------------------------------------------------------
<アナライズメモ:任意の文字列>
アナライズ時に任意の文字列を表示します(一言メモみたい短い文字列用)
※表示するデータの種類の設定で :memo の記述がある場合に限ります
-------------------------------------------------------------------------------
<アナライズOP>
HIDE,str1
LATER,str2,num
</アナライズOP>

※1行1つ / numは数字 / ","と文字列の間にスペースは入れない

■WORDの種類
HIDE  ⇒ アナライズしても隠された状態で表示する
LATER ⇒ HIDE指定したものをHPが num を下回ると表示するようにする

◆str1,str2 に対応しているもの
hp, mp, tp    ⇒ HP, MP, TP
mhp, mmp, mtp ⇒ MAXHP, MAXMP, MAXTP
state         ⇒ 現在のステート(優先度0を除く、強化/弱体を含める)
st_re         ⇒ ステート耐性(無効 or 耐性100%)
el_re         ⇒ 属性耐性(ダメージ100%未満)
el_we         ⇒ 弱点属性(ダメージ100%超)
memo          ⇒ アナライズメモ
-------------------------------------------------------------------------------
●敵メモ記述の例(最大HPと現在HPを隠す/HP500000未満で現在HPを表示)

<アナライズOP>
HIDE,mhp
HIDE,hp
LATER,hp,500000
</アナライズOP>

=end #=========================================================================
module RENNE ; module Analyze
 
  # アナライズ前の敵のデータも見れるようにするかどうか(名前以外は"?")
  N_DIS = true
 
  # 耐性を表示するステートのIDを配列で指定
  D_ST = [1,2,3,4,5,6,7,8]
 
  # 情報を表示する属性のIDと属性に対応するアイコンを指定
  # D_EL[属性ID] = アイコンインデックス
  D_EL = {}
  D_EL[1] = 116
  D_EL[2] = 120
  D_EL[3] = 104
  D_EL[4] = 105
  D_EL[5] = 106
  D_EL[6] = 107
  D_EL[7] = 108
  D_EL[8] = 109
  D_EL[9] = 110
  D_EL[10]= 111
 
  # 表示するデータの種類
  #:hp, :mp, :tp ⇒ HP, MP, TP
  #:state        ⇒ 現在のステート(優先度0を除く、強化/弱体を含める)
  #:st_re        ⇒ ステート耐性(無効 or 耐性100%)
  #:el_re        ⇒ 属性耐性(ダメージ100%未満)
  #:el_we        ⇒ 弱点属性(ダメージ100%超)
  #:memo         ⇒ 敵のメモ欄に書いた文字列(<アナライズメモ:str> の str)
  # ※記述した順番で表示されるので注意!
  Sym = [:hp, :mp, :tp, :memo, :state, :st_re, :el_re, :el_we]
 
  # HPMPTPの現在値か最大値が隠れている場合ゲージの長さをごまかすかどうか
  G_RAM = true
 
  # アナライズ済みの敵選択中にアナライズのウィンドウを表示/非表示するボタン
  BOT = :A
 
  # ★文字列の設定
  UNK = "?"       # 情報を隠す場合の文字列
 
  S_HP = "HP"    # HPの文字列
  S_MP = "MP"    # MPの文字列
  S_TP = "TP"    # TPの文字列
  S_ST = "State" # ステートの文字列
  S_STR = "- Resist State -"        # ステート耐性の文字列
  S_ELR = "- Resist Element -"      # 属性耐性の文字列
  S_ELW = "- Weak Element -"        # 弱点属性の文字列
  S_MEMO = "Memo"                  # 一言説明の文字列
 
  MES_S = "%sを解析した!"
  MES_F = "%sの解析に失敗した!"
  MES_O = "%sは既に解析されている!"
 
  # メモ取得関係
  Analyze     = "<アナライズ>"
  Ana_OP      = /<アナライズOP>/i
  Ana_OP_End  = /<\/アナライズOP>/i
  Ana_OP_Reg1 = /HIDE,(\w+)/i
  Ana_OP_Reg2 = /LATER,(\w+),(\d+)/i
  Analyze_Memo = /<アナライズメモ:(.*?)>/m
  #--------------------------
  # ★ 設定終了
  #---------------------------------------------------------------------------/
  W_Size = Sym.size + (Sym & [:st_re, :el_re, :el_we]).size
end ; end

$renne_rgss3 = {} if $renne_rgss3.nil?
$renne_rgss3[:ememy_analyze] = true

class RPG::UsableItem < RPG::BaseItem
  #--------------------------------------------------------------------------
  # ● アナライズ判定
  #--------------------------------------------------------------------------
  def analyze?
    @analyze = note.include?(RENNE::Analyze::Analyze) if @analyze.nil?
    @analyze
  end
end

class RPG::Enemy < RPG::BaseItem
  #--------------------------------------------------------------------------
  # ● 特殊アナライズデータを取得
  #--------------------------------------------------------------------------
  def analyze_data
    if @analyze_data.nil?
      @analyze_data = {}
      @analyze_data[:hide] = {}
      @analyze_data[:later] = {}
      @analyze_data[:memo] = ""
      key = false
      note.each_line{|line|
      case line
      when RENNE::Analyze::Ana_OP ; key = true
      when RENNE::Analyze::Ana_OP_End ; key = false
      when RENNE::Analyze::Ana_OP_Reg1
        @analyze_data[:hide][$1.downcase.to_sym] = true if key
      when RENNE::Analyze::Ana_OP_Reg2
        @analyze_data[:later][$1.downcase.to_sym] = $2.to_i if key
      end
      }
      if note =~ RENNE::Analyze::Analyze_Memo
        @analyze_data[:memo] = $1.sub(/[\r\n]+/, "")
      end
    end
    @analyze_data
  end
end

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader :analyze_flag
  attr_accessor :analyze_data
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化(エイリアス)
  #--------------------------------------------------------------------------
  alias analyze_skill_initialize initialize
  def initialize(index, enemy_id)
    analyze_skill_initialize(index, enemy_id)
    make_analyze_data
  end
  #--------------------------------------------------------------------------
  # ● アナライズデータの作成
  #--------------------------------------------------------------------------
  def make_analyze_data
    @analyze_data = enemy.analyze_data.dup
  end
  #--------------------------------------------------------------------------
  # ● アナライズフラグの書き換え
  #--------------------------------------------------------------------------
  def analyze_flag=(b)
    @analyze_data = enemy.analyze_data.dup if b && !@analyze_flag
    @analyze_flag = b
  end
end

class Window_Analyze_Data < Window_Base
  #--------------------------------------------------------------------------
  # ● インクルード
  #--------------------------------------------------------------------------
  include RENNE::Analyze
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr :enemy
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(enemy)
    h = (W_Size + 2) * 24
    y = [(Graphics.height - h) / 2, 8].min
    super(8, y, 264, h)
    hide
    @enemy = enemy
    @gc = [hp_gauge_color1, mp_gauge_color1, tp_gauge_color1,
           hp_gauge_color2, mp_gauge_color2, tp_gauge_color2]
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    return if !enemy
    enemy.analyze_flag ? analyze_update : set_no_analyze_data
    draw_data
  end
  #--------------------------------------------------------------------------
  # ● リセット
  #--------------------------------------------------------------------------
  def reset(enemy)
    @enemy = enemy
    refresh
  end
  #--------------------------------------------------------------------------
  # ● アナライズの更新
  #--------------------------------------------------------------------------
  def analyze_update
    @enemy.make_analyze_data if @enemy.analyze_data[:no_analyze]
    @enemy.analyze_data[:later].each do |k,v|
      next unless @enemy.analyze_data[:hide][k]
      @enemy.analyze_data[:hide][k] = @enemy.hp >= v
    end
  end
  #--------------------------------------------------------------------------
  # ● 未解析データの作成
  #--------------------------------------------------------------------------
  def set_no_analyze_data
    @enemy.analyze_data = {}
    @enemy.analyze_data[:hide] = {}
    @enemy.analyze_data[:later] = {}
    @enemy.analyze_data[:no_analyze] = true
    (Sym + [:mhp, :mmp, :mtp]).each{|i| @enemy.analyze_data[:hide][i] = true}
  end
  #--------------------------------------------------------------------------
  # ● 全データの描画
  #--------------------------------------------------------------------------
  def draw_data
    change_color(normal_color)
    draw_text(0, 0, contents.width, 24, enemy.name, 1)
    change_color(system_color)
    index = 1
    Sym.each do |sym|
      y = index * 24
      case sym
      when :hp     ; draw_gauge_text(enemy, 0, y) ; index += 1
      when :mp     ; draw_gauge_text(enemy, 1, y) ; index += 1
      when :tp     ; draw_gauge_text(enemy, 2, y) ; index += 1
      when :state  ; draw_state(y)                ; index += 1
      when :memo   ; draw_memo(y)                 ; index += 1
      when :st_re  ; draw_resist_state(y)         ; index += 2
      when :el_re  ; draw_resist_element(y)       ; index += 2
      when :el_we  ; draw_weak_element(y)         ; index += 2
      end
      change_color(system_color)
    end
  end
  #--------------------------------------------------------------------------
  # ● HPMPTPの描画
  #--------------------------------------------------------------------------
  def draw_hmt(x, y, width, now, max, color1, color2, sym_arr)
    change_color(color1)
    xr = x + width
    now = UNK if @enemy.analyze_data[:hide][sym_arr[0]]
    draw_text(xr - 132, y, 62, 24, now, 2)
    if @enemy.analyze_data[:hide][sym_arr[1]]
      max = UNK
    else
      change_color(color2)
    end
    draw_text(xr - 72, y, 12, 24, "/", 2)
    draw_text(xr - 62, y, 62, 24, max, 2)
  end
  #--------------------------------------------------------------------------
  # ● ゲージ付きの項目の描画
  #--------------------------------------------------------------------------
  def draw_gauge_text(enemy, type, y, width = 134)
    x = 44 + 40
    data = enemy_data(type)
    arr = data[0]
    draw_text(0, y, 44, 24, arr[1])
    draw_gauge(x, y, width, arr[0], @gc[type], @gc[type + 3])
    change_color(system_color)
    draw_hmt(x, y, width, arr[2], arr[3],hp_color(enemy), normal_color, data[1])
  end
  #--------------------------------------------------------------------------
  # ● エネミーの描画用データの取得
  #-------------------------------------------------------------------------- 
  def enemy_data(type)
    case type
    when 0; a= [[enemy.hp_rate, S_HP, enemy.hp, enemy.mhp], [:hp, :mhp]]
    when 1; a= [[enemy.mp_rate, S_MP, enemy.mp, enemy.mmp], [:mp, :mmp]]
    when 2; a= [[enemy.tp_rate, S_TP, enemy.tp.to_i, enemy.max_tp], [:tp, :mtp]]
    end
    a[1].each do |i|
      next unless @enemy.analyze_data[:hide][i]
      a[0][0] = 1.0 if G_RAM
      break
    end
    return a
  end
  #--------------------------------------------------------------------------
  # ● 隠されている場合の描画
  #-------------------------------------------------------------------------- 
  def unk_text(sym, y, x = 0)
    change_color(normal_color)
    draw_text(x, y, contents.width - x, 24, UNK, 1)
  end
  #--------------------------------------------------------------------------
  # ● システムテキストの描画
  #--------------------------------------------------------------------------
  def draw_system_text(text, y, a = 1)
    change_color(system_color)
    draw_text(0, y, contents.width, 24, text, a)
  end
  #--------------------------------------------------------------------------
  # ● ステートおよび強化/弱体のアイコンを描画
  #--------------------------------------------------------------------------
  def draw_state(y)
    draw_system_text(S_ST, y, 0)
    s = contents.text_size(S_ST).width
    return unk_text(:states, y, s) if @enemy.analyze_data[:hide][:state]
    arr = enemy.states.select{|s| !s.priority.zero?}
    arr = arr.collect{|state| state.icon_index }
    arr.delete(0)
    arr = (arr + enemy.buff_icons)[0, 6]
    cx = (contents.width - arr.size * 24) / 2
    arr.each_with_index {|n, i| draw_icon(n, cx + 24 * i, y)}
  end
  #--------------------------------------------------------------------------
  # ● 耐性ステートの描画
  #--------------------------------------------------------------------------
  def draw_resist_state(y)
    draw_system_text(S_STR, y) ; y += 24
    return unk_text(:st_re, y) if @enemy.analyze_data[:hide][:st_re]
    eff = D_ST.select{|i| enemy.state_rate(i).zero?}
    arr = (eff + (enemy.state_resist_set & D_ST)).uniq.sort
    arr = arr.map{|i| $data_states[i]}.map{|s| s.icon_index}
    arr.delete(0)
    cx = (contents.width - arr.size * 24) / 2
    arr.each_with_index {|n, i| draw_icon(n, cx + 24 * i, y)}
  end
  #--------------------------------------------------------------------------
  # ● 耐性属性の描画
  #--------------------------------------------------------------------------
  def draw_resist_element(y)
    draw_system_text(S_ELR, y) ; y += 24
    return unk_text(:el_re, y) if @enemy.analyze_data[:hide][:el_re]
    arr = []
    D_EL.keys.each do |i|
      arr << i if enemy.element_rate(i) < 1.0
    end
    arr = arr.map{|i| D_EL[i]}
    arr.delete(0)
    cx = (contents.width - arr.size * 24) / 2
    arr.each_with_index {|n, i| draw_icon(n, cx + 24 * i, y)}
  end
  #--------------------------------------------------------------------------
  # ● 弱点属性の描画
  #--------------------------------------------------------------------------
  def draw_weak_element(y)
    draw_system_text(S_ELW, y) ; y += 24
    return unk_text(:el_we, y) if @enemy.analyze_data[:hide][:el_we]
    arr = []
    D_EL.keys.each do |i|
      arr << i if enemy.element_rate(i) > 1.0
    end
    arr = arr.map{|i| D_EL[i]}
    arr.delete(0)
    cx = (contents.width - arr.size * 24) / 2
    arr.each_with_index {|n, i| draw_icon(n, cx + 24 * i, y)}
  end
  #--------------------------------------------------------------------------
  # ● 一言メモの描画
  #--------------------------------------------------------------------------
  def draw_memo(y)
    draw_system_text(S_MEMO, y, 0)
    s = contents.text_size(S_MEMO).width
    return unk_text(:memo, y, s) if @enemy.analyze_data[:hide][:memo]
    change_color(normal_color)
    text = @enemy.analyze_data[:memo]
    draw_text(s + 4, y, contents.width - (s + 4), 24, text, 1)
  end
end

class Window_BattleEnemy < Window_Selectable
  #--------------------------------------------------------------------------
  # ● クラス変数
  #--------------------------------------------------------------------------
  @@_ins_meth = self.instance_methods(false)
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr :ana_window
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化(エイリアス)
  #--------------------------------------------------------------------------
  alias analyze_initialize initialize
  def initialize(info_viewport)
    @ana_window = Window_Analyze_Data.new(nil)
    analyze_initialize(info_viewport)
    @ana_window.reset(enemy)
    hide if $renne_rgss3[:xp_style_battle_c]
  end
  #--------------------------------------------------------------------------
  # ● アナライズのリフレッシュ
  #--------------------------------------------------------------------------
  def ana_window_refresh
    return if !active
    return if @last_index == index
    @ana_window.refresh
    @last_index = index
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  if @@_ins_meth.include?(:dispose)
    alias analyze_dispose dispose
    def dispose
      analyze_dispose
      @ana_window.dispose
    end
  else
    def dispose
      super
      @ana_window.dispose
    end
  end
  #--------------------------------------------------------------------------
  # ● 更新
  #--------------------------------------------------------------------------
  if @@_ins_meth.include?(:update)
    alias analyze_update update
    def update
      analyze_update
      ana_window_refresh
      @ana_window.update if @ana_window
      if visible && !(enemy == @ana_window.enemy)
        @ana_window.reset(enemy)
        @ana_window.visible = false unless RENNE::Analyze::N_DIS
      end
      if active && Input.trigger?(RENNE::Analyze::BOT)
        RENNE::Analyze::N_DIS ?
        (Sound.play_cursor ; @ana_window.visible ^= true) : Sound.play_buzzer
      end
    end
  else
    def update
      super
      ana_window_refresh
      @ana_window.update if @ana_window
      if visible && !(enemy == @ana_window.enemy)
        @ana_window.reset(enemy)
        @ana_window.visible = false unless RENNE::Analyze::N_DIS
      end
      if active && Input.trigger?(RENNE::Analyze::BOT)
        RENNE::Analyze::N_DIS ?
        (Sound.play_cursor ; @ana_window.visible ^= true) : Sound.play_buzzer
      end
    end
  end # if
  #--------------------------------------------------------------------------
  # ● 可視状態
  #--------------------------------------------------------------------------
  if @@_ins_meth.include?(:visible=)
    alias analyze_visible_set visible=
    def visible=(v)
      l = visible
      analyze_visible_set(v)
      @ana_window.refresh if !l && v && enemy.analyze_flag
      @ana_window.hide if l && !v
    end
  else
    def visible=(v)
      l = visible
      super(v)
      @ana_window.refresh if !l && v && enemy.analyze_flag
      @ana_window.hide if l && !v
    end
  end # if
end

class Window_BattleLog < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 失敗の表示(エイリアス)
  #--------------------------------------------------------------------------
  alias analyze_display_failure display_failure
  def display_failure(target, item)
    if item.analyze?
      display_analyze_results(target, item)
    else
      analyze_display_failure(target, item)
    end
  end
  #--------------------------------------------------------------------------
  # ● アナライズの結果の表示
  #--------------------------------------------------------------------------
  def display_analyze_results(target, item)
    if item.analyze?
      last_line_number = line_number
      display_analyze(target, item)
      display_analyze_failure(target, item)
      wait if line_number > last_line_number
    end
  end
  #--------------------------------------------------------------------------
  # ● アナライズの表示
  #--------------------------------------------------------------------------
  def display_analyze(target, item)
    if target.result.hit?
      flag = false
      if target.actor?
        add_text(sprintf(RENNE::Analyze::MES_F, target.name))
      else
        if target.analyze_flag
          add_text(sprintf(RENNE::Analyze::MES_O, target.name))
        else
          target.analyze_flag = true
          add_text(sprintf(RENNE::Analyze::MES_S, target.name))
          flag = true
        end
      end
      wait
      force_display_analyze(target) if flag
    end
  end
  #--------------------------------------------------------------------------
  # ● アナライズの失敗
  #--------------------------------------------------------------------------
  def display_analyze_failure(target, item)
    if !target.result.hit?
      add_text(sprintf(RENNE::Analyze::MES_F, target.name))
      wait
    end
  end
  #--------------------------------------------------------------------------
  # ● アナライズの強制表示
  #--------------------------------------------------------------------------
  def force_display_analyze(enemy)
    Sound.play_ok
    sw = SceneManager.scene.instance_variable_get(:@enemy_window).ana_window
    sw.reset(enemy)
    sw.show.z = self.z + 1
    until Input.trigger?(:C) || Input.trigger?(:B)
      sw.update
      SceneManager.scene.update_basic
    end
    Sound.play_cursor
    sw.hide
  end
end


このスクリプトに加えてほしい要項!


●弱点ステートの描画

耐性ステート、耐性属性、弱点属性・・・があるので、
「弱点ステート」もやっぱりアナライズしたい!
たとえば、「毒にかかりやすい敵=ステート有効度が101%以上」なら、
「弱点ステート」欄に「毒アイコン」が表記されてる★みたいな感じです!

これを、「耐性ステート」と「耐性属性」の間に2行割り込んで、設定することってできますか?
こんな感じに表示されたら幸せです(´ω`*)

省略
- Resist State -
アイコン アイコン アイコン
- Weak State -
アイコン アイコン
- Resist Element -
アイコン
- Weak Element -
アイコン アイコン



●一度でもアナライズした敵種族は、『永遠にアナライズ済み』にする

多分、「敵ID」とかスイッチ?とかを使って管理することになると思うのですが・・・
ただの一度でも「アナライズ」をかけた敵には、その種族すべてが、
以降、戦闘が終わっても、ずっと「アナライズ済み」となり、
残りHPや耐性などが表示されるようにしたいのです!

例:
スライムが3匹出現!
1ターン目 アナライズスキルを実行!
スライムAの情報を解析!
2ターン目 以降
スライムB も スライムC も情報が丸見えに!

戦闘終了後、
今度はスライム×2 と こうもり が出現!
1ターン目 アナライズスキルの選択画面でSHIFTキー操作で
もはやスライムの情報はばっちり丸わかり!
ただし、こうもりはアナライズ前のため、???? となっている!

みたいな仕様が理想です・・・


いろいろ大変かもしれませんが、
スクリプトをお作りして頂いた暁には
READ ME や エンディングクレジットに
お名前を明記させて頂きますので、
どうかお優しくて聡明なスクリプターの皆さま!
ふるってお願いいたします!!!

TOMO
記事: 343
登録日時: 2015年11月16日(月) 20:12
連絡を取る:

Re: [VXace]アナライズ・スクリプト強化依頼!

投稿記事by TOMO » 2017年8月07日(月) 02:09

こんな感じですか?

コード: 全て選択

=begin #=======================================================================
 
◆◇アナライズ RGSS3◇◆

◆DEICIDE ALMA
◆レーネ 
◆http://blog.goo.ne.jp/exa_deicide_alma

★機能
敵を解析するスキル/アイテムを作成できるようにします。
スキル/アイテムのメモ欄に <アナライズ> と記述するとアナライズとして機能します。
効果は戦闘中のみで、エネミーごとに別々となります。

敵のメモ欄に以下のように書くと、少し変化をつけることができます。
-------------------------------------------------------------------------------
<アナライズメモ:任意の文字列>
アナライズ時に任意の文字列を表示します(一言メモみたい短い文字列用)
※表示するデータの種類の設定で :memo の記述がある場合に限ります
-------------------------------------------------------------------------------
<アナライズOP>
HIDE,str1
LATER,str2,num
</アナライズOP>

※1行1つ / numは数字 / ","と文字列の間にスペースは入れない

■WORDの種類
HIDE  ⇒ アナライズしても隠された状態で表示する
LATER ⇒ HIDE指定したものをHPが num を下回ると表示するようにする

◆str1,str2 に対応しているもの
hp, mp, tp    ⇒ HP, MP, TP
mhp, mmp, mtp ⇒ MAXHP, MAXMP, MAXTP
state         ⇒ 現在のステート(優先度0を除く、強化/弱体を含める)
st_re         ⇒ ステート耐性(無効 or 耐性100%)
el_re         ⇒ 属性耐性(ダメージ100%未満)
el_we         ⇒ 弱点属性(ダメージ100%超)
memo          ⇒ アナライズメモ
-------------------------------------------------------------------------------
●敵メモ記述の例(最大HPと現在HPを隠す/HP500000未満で現在HPを表示)

<アナライズOP>
HIDE,mhp
HIDE,hp
LATER,hp,500000
</アナライズOP>

=end #=========================================================================
module RENNE ; module Analyze
 
  # アナライズ前の敵のデータも見れるようにするかどうか(名前以外は"?")
  N_DIS = true
 
  # 耐性を表示するステートのIDを配列で指定
  D_ST = [1,2,3,4,5,6,7,8]
 
  # 情報を表示する属性のIDと属性に対応するアイコンを指定
  # D_EL[属性ID] = アイコンインデックス
  D_EL = {}
  D_EL[1] = 116
  D_EL[2] = 120
  D_EL[3] = 104
  D_EL[4] = 105
  D_EL[5] = 106
  D_EL[6] = 107
  D_EL[7] = 108
  D_EL[8] = 109
  D_EL[9] = 110
  D_EL[10]= 111
 
  # 表示するデータの種類(:st_we 追加)
  #:hp, :mp, :tp ⇒ HP, MP, TP
  #:state        ⇒ 現在のステート(優先度0を除く、強化/弱体を含める)
  #:st_re        ⇒ ステート耐性(無効 or 耐性100%)
  #:el_re        ⇒ 属性耐性(ダメージ100%未満)
  #:el_we        ⇒ 弱点属性(ダメージ100%超)
  #:memo         ⇒ 敵のメモ欄に書いた文字列(<アナライズメモ:str> の str)
  # ※記述した順番で表示されるので注意!
  Sym = [:hp, :mp, :tp, :memo, :state, :st_re, :st_we, :el_re, :el_we]
 
  # HPMPTPの現在値か最大値が隠れている場合ゲージの長さをごまかすかどうか
  G_RAM = true
 
  # アナライズ済みの敵選択中にアナライズのウィンドウを表示/非表示するボタン
  BOT = :A
 
  # ★文字列の設定
  UNK = "?"       # 情報を隠す場合の文字列
 
  S_HP = "HP"    # HPの文字列
  S_MP = "MP"    # MPの文字列
  S_TP = "TP"    # TPの文字列
  S_ST = "State" # ステートの文字列
  S_STR = "- Resist State -"        # ステート耐性の文字列
  S_STW = "- Weak State -"          # 弱点ステートの文字列(追加)
  S_ELR = "- Resist Element -"      # 属性耐性の文字列
  S_ELW = "- Weak Element -"        # 弱点属性の文字列
  S_MEMO = "Memo"                  # 一言説明の文字列
 
  MES_S = "%sを解析した!"
  MES_F = "%sの解析に失敗した!"
  MES_O = "%sは既に解析されている!"
 
  # メモ取得関係
  Analyze     = "<アナライズ>"
  Ana_OP      = /<アナライズOP>/i
  Ana_OP_End  = /<\/アナライズOP>/i
  Ana_OP_Reg1 = /HIDE,(\w+)/i
  Ana_OP_Reg2 = /LATER,(\w+),(\d+)/i
  Analyze_Memo = /<アナライズメモ:(.*?)>/m
  #--------------------------
  # ★ 設定終了
  #---------------------------------------------------------------------------/
  W_Size = Sym.size + (Sym & [:st_re, :st_we, :el_re, :el_we]).size # 変更
end ; end

$renne_rgss3 = {} if $renne_rgss3.nil?
$renne_rgss3[:ememy_analyze] = true

class RPG::UsableItem < RPG::BaseItem
  #--------------------------------------------------------------------------
  # ● アナライズ判定
  #--------------------------------------------------------------------------
  def analyze?
    @analyze = note.include?(RENNE::Analyze::Analyze) if @analyze.nil?
    @analyze
  end
end

class RPG::Enemy < RPG::BaseItem
  #--------------------------------------------------------------------------
  # ● 特殊アナライズデータを取得
  #--------------------------------------------------------------------------
  def analyze_data
    if @analyze_data.nil?
      @analyze_data = {}
      @analyze_data[:hide] = {}
      @analyze_data[:later] = {}
      @analyze_data[:memo] = ""
      key = false
      note.each_line{|line|
      case line
      when RENNE::Analyze::Ana_OP ; key = true
      when RENNE::Analyze::Ana_OP_End ; key = false
      when RENNE::Analyze::Ana_OP_Reg1
        @analyze_data[:hide][$1.downcase.to_sym] = true if key
      when RENNE::Analyze::Ana_OP_Reg2
        @analyze_data[:later][$1.downcase.to_sym] = $2.to_i if key
      end
      }
      if note =~ RENNE::Analyze::Analyze_Memo
        @analyze_data[:memo] = $1.sub(/[\r\n]+/, "")
      end
    end
    @analyze_data
  end
end

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader :analyze_flag
  attr_accessor :analyze_data
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化(エイリアス)
  #--------------------------------------------------------------------------
  alias analyze_skill_initialize initialize
  def initialize(index, enemy_id)
    analyze_skill_initialize(index, enemy_id)
    make_analyze_data
  end
  #--------------------------------------------------------------------------
  # ● アナライズデータの作成
  #--------------------------------------------------------------------------
  def make_analyze_data
    @analyze_data = enemy.analyze_data.dup
  end
  # 追加
  def analyze_flag
    $game_system.enemy_analyze_flag[@enemy_id]
  end
  #--------------------------------------------------------------------------
  # ● アナライズフラグの書き換え(変更)
  #--------------------------------------------------------------------------
  def analyze_flag=(b)
    if b && !$game_system.enemy_analyze_flag[@enemy_id]
      @analyze_data = enemy.analyze_data.dup
    end
    $game_system.enemy_analyze_flag[@enemy_id] = b
#~     @analyze_data = enemy.analyze_data.dup if b && !@analyze_flag
#~     @analyze_flag = b
  end
end

class Game_System
  attr_accessor   :enemy_analyze_flag
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化(追加)
  #--------------------------------------------------------------------------
  alias analyze_skill_initialize initialize
  def initialize
    analyze_skill_initialize
    @enemy_analyze_flag = {}
  end
end

class Window_Analyze_Data < Window_Base
  #--------------------------------------------------------------------------
  # ● インクルード
  #--------------------------------------------------------------------------
  include RENNE::Analyze
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr :enemy
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(enemy)
    h = (W_Size + 2) * 24
    y = [(Graphics.height - h) / 2, 8].min
    super(8, y, 264, h)
    hide
    @enemy = enemy
    @gc = [hp_gauge_color1, mp_gauge_color1, tp_gauge_color1,
           hp_gauge_color2, mp_gauge_color2, tp_gauge_color2]
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    return if !enemy
    enemy.analyze_flag ? analyze_update : set_no_analyze_data
    draw_data
  end
  #--------------------------------------------------------------------------
  # ● リセット
  #--------------------------------------------------------------------------
  def reset(enemy)
    @enemy = enemy
    refresh
  end
  #--------------------------------------------------------------------------
  # ● アナライズの更新
  #--------------------------------------------------------------------------
  def analyze_update
    @enemy.make_analyze_data if @enemy.analyze_data[:no_analyze]
    @enemy.analyze_data[:later].each do |k,v|
      next unless @enemy.analyze_data[:hide][k]
      @enemy.analyze_data[:hide][k] = @enemy.hp >= v
    end
  end
  #--------------------------------------------------------------------------
  # ● 未解析データの作成
  #--------------------------------------------------------------------------
  def set_no_analyze_data
    @enemy.analyze_data = {}
    @enemy.analyze_data[:hide] = {}
    @enemy.analyze_data[:later] = {}
    @enemy.analyze_data[:no_analyze] = true
    (Sym + [:mhp, :mmp, :mtp]).each{|i| @enemy.analyze_data[:hide][i] = true}
  end
  #--------------------------------------------------------------------------
  # ● 全データの描画
  #--------------------------------------------------------------------------
  def draw_data
    change_color(normal_color)
    draw_text(0, 0, contents.width, 24, enemy.name, 1)
    change_color(system_color)
    index = 1
    Sym.each do |sym|
      y = index * 24
      case sym
      when :hp     ; draw_gauge_text(enemy, 0, y) ; index += 1
      when :mp     ; draw_gauge_text(enemy, 1, y) ; index += 1
      when :tp     ; draw_gauge_text(enemy, 2, y) ; index += 1
      when :state  ; draw_state(y)                ; index += 1
      when :memo   ; draw_memo(y)                 ; index += 1
      when :st_re  ; draw_resist_state(y)         ; index += 2
      when :st_we  ; draw_weak_state(y)           ; index += 2  # 追加
      when :el_re  ; draw_resist_element(y)       ; index += 2
      when :el_we  ; draw_weak_element(y)         ; index += 2
      end
      change_color(system_color)
    end
  end
  #--------------------------------------------------------------------------
  # ● HPMPTPの描画
  #--------------------------------------------------------------------------
  def draw_hmt(x, y, width, now, max, color1, color2, sym_arr)
    change_color(color1)
    xr = x + width
    now = UNK if @enemy.analyze_data[:hide][sym_arr[0]]
    draw_text(xr - 132, y, 62, 24, now, 2)
    if @enemy.analyze_data[:hide][sym_arr[1]]
      max = UNK
    else
      change_color(color2)
    end
    draw_text(xr - 72, y, 12, 24, "/", 2)
    draw_text(xr - 62, y, 62, 24, max, 2)
  end
  #--------------------------------------------------------------------------
  # ● ゲージ付きの項目の描画
  #--------------------------------------------------------------------------
  def draw_gauge_text(enemy, type, y, width = 134)
    x = 44 + 40
    data = enemy_data(type)
    arr = data[0]
    draw_text(0, y, 44, 24, arr[1])
    draw_gauge(x, y, width, arr[0], @gc[type], @gc[type + 3])
    change_color(system_color)
    draw_hmt(x, y, width, arr[2], arr[3],hp_color(enemy), normal_color, data[1])
  end
  #--------------------------------------------------------------------------
  # ● エネミーの描画用データの取得
  #-------------------------------------------------------------------------- 
  def enemy_data(type)
    case type
    when 0; a= [[enemy.hp_rate, S_HP, enemy.hp, enemy.mhp], [:hp, :mhp]]
    when 1; a= [[enemy.mp_rate, S_MP, enemy.mp, enemy.mmp], [:mp, :mmp]]
    when 2; a= [[enemy.tp_rate, S_TP, enemy.tp.to_i, enemy.max_tp], [:tp, :mtp]]
    end
    a[1].each do |i|
      next unless @enemy.analyze_data[:hide][i]
      a[0][0] = 1.0 if G_RAM
      break
    end
    return a
  end
  #--------------------------------------------------------------------------
  # ● 隠されている場合の描画
  #-------------------------------------------------------------------------- 
  def unk_text(sym, y, x = 0)
    change_color(normal_color)
    draw_text(x, y, contents.width - x, 24, UNK, 1)
  end
  #--------------------------------------------------------------------------
  # ● システムテキストの描画
  #--------------------------------------------------------------------------
  def draw_system_text(text, y, a = 1)
    change_color(system_color)
    draw_text(0, y, contents.width, 24, text, a)
  end
  #--------------------------------------------------------------------------
  # ● ステートおよび強化/弱体のアイコンを描画
  #--------------------------------------------------------------------------
  def draw_state(y)
    draw_system_text(S_ST, y, 0)
    s = contents.text_size(S_ST).width
    return unk_text(:states, y, s) if @enemy.analyze_data[:hide][:state]
    arr = enemy.states.select{|s| !s.priority.zero?}
    arr = arr.collect{|state| state.icon_index }
    arr.delete(0)
    arr = (arr + enemy.buff_icons)[0, 6]
    cx = (contents.width - arr.size * 24) / 2
    arr.each_with_index {|n, i| draw_icon(n, cx + 24 * i, y)}
  end
  #--------------------------------------------------------------------------
  # ● 耐性ステートの描画
  #--------------------------------------------------------------------------
  def draw_resist_state(y)
    draw_system_text(S_STR, y) ; y += 24
    return unk_text(:st_re, y) if @enemy.analyze_data[:hide][:st_re]
    eff = D_ST.select{|i| enemy.state_rate(i).zero?}
    arr = (eff + (enemy.state_resist_set & D_ST)).uniq.sort
    arr = arr.map{|i| $data_states[i]}.map{|s| s.icon_index}
    arr.delete(0)
    cx = (contents.width - arr.size * 24) / 2
    arr.each_with_index {|n, i| draw_icon(n, cx + 24 * i, y)}
  end
  #--------------------------------------------------------------------------
  # ● 弱点ステートの描画(追加)
  #--------------------------------------------------------------------------
  def draw_weak_state(y)
    draw_system_text(S_STW, y) ; y += 24
    return unk_text(:st_re, y) if @enemy.analyze_data[:hide][:st_re]
#~     eff = D_ST.select{|i| enemy.state_rate(i).zero?}
   
    arr = []
    D_ST.each do |i|
      if enemy.state_rate(i) > 1.0 && !enemy.state_resist_set.include?(i)
        arr << i
      end
    end
#~     arr = (eff + (enemy.state_resist_set & D_ST)).uniq.sort
    arr = arr.map{|i| $data_states[i]}.map{|s| s.icon_index}
    arr.delete(0)
    cx = (contents.width - arr.size * 24) / 2
    arr.each_with_index {|n, i| draw_icon(n, cx + 24 * i, y)}
  end
  #--------------------------------------------------------------------------
  # ● 耐性属性の描画
  #--------------------------------------------------------------------------
  def draw_resist_element(y)
    draw_system_text(S_ELR, y) ; y += 24
    return unk_text(:el_re, y) if @enemy.analyze_data[:hide][:el_re]
    arr = []
    D_EL.keys.each do |i|
      arr << i if enemy.element_rate(i) < 1.0
    end
    arr = arr.map{|i| D_EL[i]}
    arr.delete(0)
    cx = (contents.width - arr.size * 24) / 2
    arr.each_with_index {|n, i| draw_icon(n, cx + 24 * i, y)}
  end
  #--------------------------------------------------------------------------
  # ● 弱点属性の描画
  #--------------------------------------------------------------------------
  def draw_weak_element(y)
    draw_system_text(S_ELW, y) ; y += 24
    return unk_text(:el_we, y) if @enemy.analyze_data[:hide][:el_we]
    arr = []
    D_EL.keys.each do |i|
      arr << i if enemy.element_rate(i) > 1.0
    end
    arr = arr.map{|i| D_EL[i]}
    arr.delete(0)
    cx = (contents.width - arr.size * 24) / 2
    arr.each_with_index {|n, i| draw_icon(n, cx + 24 * i, y)}
  end
  #--------------------------------------------------------------------------
  # ● 一言メモの描画
  #--------------------------------------------------------------------------
  def draw_memo(y)
    draw_system_text(S_MEMO, y, 0)
    s = contents.text_size(S_MEMO).width
    return unk_text(:memo, y, s) if @enemy.analyze_data[:hide][:memo]
    change_color(normal_color)
    text = @enemy.analyze_data[:memo]
    draw_text(s + 4, y, contents.width - (s + 4), 24, text, 1)
  end
end

class Window_BattleEnemy < Window_Selectable
  #--------------------------------------------------------------------------
  # ● クラス変数
  #--------------------------------------------------------------------------
  @@_ins_meth = self.instance_methods(false)
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr :ana_window
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化(エイリアス)
  #--------------------------------------------------------------------------
  alias analyze_initialize initialize
  def initialize(info_viewport)
    @ana_window = Window_Analyze_Data.new(nil)
    analyze_initialize(info_viewport)
    @ana_window.reset(enemy)
    hide if $renne_rgss3[:xp_style_battle_c]
  end
  #--------------------------------------------------------------------------
  # ● アナライズのリフレッシュ
  #--------------------------------------------------------------------------
  def ana_window_refresh
    return if !active
    return if @last_index == index
    @ana_window.refresh
    @last_index = index
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  if @@_ins_meth.include?(:dispose)
    alias analyze_dispose dispose
    def dispose
      analyze_dispose
      @ana_window.dispose
    end
  else
    def dispose
      super
      @ana_window.dispose
    end
  end
  #--------------------------------------------------------------------------
  # ● 更新
  #--------------------------------------------------------------------------
  if @@_ins_meth.include?(:update)
    alias analyze_update update
    def update
      analyze_update
      ana_window_refresh
      @ana_window.update if @ana_window
      if visible && !(enemy == @ana_window.enemy)
        @ana_window.reset(enemy)
        @ana_window.visible = false unless RENNE::Analyze::N_DIS
      end
      if active && Input.trigger?(RENNE::Analyze::BOT)
        RENNE::Analyze::N_DIS ?
        (Sound.play_cursor ; @ana_window.visible ^= true) : Sound.play_buzzer
      end
    end
  else
    def update
      super
      ana_window_refresh
      @ana_window.update if @ana_window
      if visible && !(enemy == @ana_window.enemy)
        @ana_window.reset(enemy)
        @ana_window.visible = false unless RENNE::Analyze::N_DIS
      end
      if active && Input.trigger?(RENNE::Analyze::BOT)
        RENNE::Analyze::N_DIS ?
        (Sound.play_cursor ; @ana_window.visible ^= true) : Sound.play_buzzer
      end
    end
  end # if
  #--------------------------------------------------------------------------
  # ● 可視状態
  #--------------------------------------------------------------------------
  if @@_ins_meth.include?(:visible=)
    alias analyze_visible_set visible=
    def visible=(v)
      l = visible
      analyze_visible_set(v)
      @ana_window.refresh if !l && v && enemy.analyze_flag
      @ana_window.hide if l && !v
    end
  else
    def visible=(v)
      l = visible
      super(v)
      @ana_window.refresh if !l && v && enemy.analyze_flag
      @ana_window.hide if l && !v
    end
  end # if
end

class Window_BattleLog < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 失敗の表示(エイリアス)
  #--------------------------------------------------------------------------
  alias analyze_display_failure display_failure
  def display_failure(target, item)
    if item.analyze?
      display_analyze_results(target, item)
    else
      analyze_display_failure(target, item)
    end
  end
  #--------------------------------------------------------------------------
  # ● アナライズの結果の表示
  #--------------------------------------------------------------------------
  def display_analyze_results(target, item)
    if item.analyze?
      last_line_number = line_number
      display_analyze(target, item)
      display_analyze_failure(target, item)
      wait if line_number > last_line_number
    end
  end
  #--------------------------------------------------------------------------
  # ● アナライズの表示
  #--------------------------------------------------------------------------
  def display_analyze(target, item)
    if target.result.hit?
      flag = false
      if target.actor?
        add_text(sprintf(RENNE::Analyze::MES_F, target.name))
      else
        if target.analyze_flag
          add_text(sprintf(RENNE::Analyze::MES_O, target.name))
        else
          target.analyze_flag = true
          add_text(sprintf(RENNE::Analyze::MES_S, target.name))
          flag = true
        end
      end
      wait
      force_display_analyze(target) if flag
    end
  end
  #--------------------------------------------------------------------------
  # ● アナライズの失敗
  #--------------------------------------------------------------------------
  def display_analyze_failure(target, item)
    if !target.result.hit?
      add_text(sprintf(RENNE::Analyze::MES_F, target.name))
      wait
    end
  end
  #--------------------------------------------------------------------------
  # ● アナライズの強制表示
  #--------------------------------------------------------------------------
  def force_display_analyze(enemy)
    Sound.play_ok
    sw = SceneManager.scene.instance_variable_get(:@enemy_window).ana_window
    sw.reset(enemy)
    sw.show.z = self.z + 1
    until Input.trigger?(:C) || Input.trigger?(:B)
      sw.update
      SceneManager.scene.update_basic
    end
    Sound.play_cursor
    sw.hide
  end
end

改変した部分は、
スクリプト内に「追加」や「変更」とか追加してる所です
(設定部分も追加&変更してます)

それ以外は確か弄ってません


ちなみに、「元のスクリプト」が未加工の物なら、規約違反では?

アナライズはレーネ様のオリジナルなので、「加工後に限り配布OK」です

規約を勘違いしてませんか?
みるく
記事: 25
登録日時: 2017年7月15日(土) 01:05

Re: [VXace]アナライズ・スクリプト強化依頼!

投稿記事by みるく » 2017年8月14日(月) 02:50

Thank you very much!

“VX / Ace:スクリプト素材のリクエスト” へ戻る