#============================================================================== # ■○○が起き上がり仲間にしてほしそうにこちらを見ている! for RGSS3 Ver1.04 # □作成者 kure # # ●アクター生成 #  エネミーのメモ欄に「<アクター生成 x, y, z>」で設定 #  戦闘終了後 x / 1000 の確率でエネミーが立ち上がる #  加わるアクターIDは y となる # #  z = 0 → すでにメンバーにいるIDでは動作しない #  z = 1 → 確率判定を毎回行う # # ●アクター生成時変数操作 #  エネミーのメモ欄に「<アクター生成時変数操作 x, y, z>」で設定 #  アクターが生成されたとき、IDx の変数に対して y の値を #  z で指定した方法で計算する #  z の値 → 0:加算 1:乗算 2:除算 # #=============================================================================== $kure_integrate_script = {} if $kure_integrate_script == nil $kure_integrate_script[:ActorScout] = 100 p "仲間イベント" module KURE module ActorScout #名前入力ウィンドウの表示(0=OFF、 1=ON) NAME_INPUT = 0 #名前の文字数 NAME_NUM = 6 end end module KURE #-------------------------------------------------------------------------- # ☆ 変数操作(追加定義) #-------------------------------------------------------------------------- def self.val_math(data) return if data[0] == 0 case data[2] when 0 ; $game_variables[data[0]] += data[1] when 1 ; $game_variables[data[0]] *= data[1] when 2 ; $game_variables[data[0]] /= data[1] if data[1] != 0 end end end #============================================================================== # ■ Vocab #============================================================================== module Vocab Stand_Up_1 = "なんと %s が起き上がり\n仲間にしてほしそうにこちらを見ている!" Stand_Up_2 = "仲間にしてあげますか?" Stand_Up_3 = "%s はうれしそうに仲間に加わった!" Stand_Up_4 = "%s は悲しそうに立ち去って行った。" end #============================================================================== # ■ RPG::Enemy(追加定義) #============================================================================== class RPG::Enemy < RPG::BaseItem #-------------------------------------------------------------------------- # ★アクター生成の定義(追加定義) #-------------------------------------------------------------------------- def actor_make @note.match(/<アクター生成\s?(\d+)\s?,\s?(\d+)\s?,\s?(\d+)\s?>/) return ($1 && $2 && $3) ? [$1.to_i, $2.to_i, $3.to_i] : nil end #-------------------------------------------------------------------------- # ★ 変数操作の定義(追加定義)(ID, 値, 計算方式) #-------------------------------------------------------------------------- def operate_val_actor_make note_data = @note ; value = [] while note_data do note_data.match(/<アクター生成時変数操作\s?(\d+)\s?,\s?([-]?\d+)\s?,\s?(\d+)\s?>/) value.push([$1.to_i, $2.to_i, $3.to_i]) if $1 && $2 && $3 note_data = $' end return value end end #============================================================================== # ■ RPG::State(追加定義) #============================================================================== class RPG::State < RPG::BaseItem #-------------------------------------------------------------------------- # ★ ステートタイプの定義(追加定義) #-------------------------------------------------------------------------- def gain_stand_value @note.match(/<仲間確率上昇\s?(\d+)\s?>/) return $1 ? $1.to_i : 0 end end #============================================================================== # ■ Game_Temp #============================================================================== class Game_Temp attr_accessor :command_index #コマンドINDEX end #============================================================================== # ■ Game_Party #============================================================================== class Game_Party < Game_Unit attr_reader :actors # アクターID end #============================================================================== # ■ Game_Interpreter #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ● 選択肢のセットアップ #-------------------------------------------------------------------------- def setup_choices_command_id(params) params[0].each {|s| $game_message.choices.push(s) } $game_message.choice_cancel_type = params[1] $game_message.choice_proc = Proc.new {|n| $game_temp.command_index = n } end end #============================================================================== # ■ BattleManager #============================================================================== class << BattleManager #-------------------------------------------------------------------------- # ◎ 戦闘終了 result : 結果(0:勝利 1:逃走 2:敗北)(エイリアス再定義) #-------------------------------------------------------------------------- alias k_ss_before_battle_end battle_end unless $! def battle_end(result) scout_process if result == 0 k_ss_before_battle_end(result) end #-------------------------------------------------------------------------- # ◎ 仲間になる処理(追加定義) #-------------------------------------------------------------------------- def scout_process stand_up_enemy = nil return if $kure_integrate_script[:Actor_Manage] && $game_actors.empty_id > KURE::Actor_Manage::MAX_MEMBER #エネミーの判定 $game_troop.members.each{|enemy| gain = 0 enemy.states.each{|state| gain += state.gain_stand_value} data = enemy.enemy.actor_make next unless data next if rand(1000) >= data[0] + gain next if data[2] == 0 && $game_party.actors.include?(data[1]) stand_up_enemy = enemy break} return unless stand_up_enemy #対象エネミーの画像作成 sprite = Sprite.new sprite.bitmap = Cache.battler(stand_up_enemy.battler_name, stand_up_enemy.battler_hue) sprite.x = (Graphics.width - sprite.width) / 2 sprite.y = stand_up_enemy.screen_y - sprite.height #イベント処理 $game_message.add('\.' + sprintf(Vocab::Stand_Up_1, stand_up_enemy.name)) wait_for_message $game_message.add('\.' + Vocab::Stand_Up_2) $game_troop.interpreter.setup_choices_command_id([["はい","いいえ"],2]) wait_for_message case $game_temp.command_index when 0 $game_party.add_actor(stand_up_enemy.enemy.actor_make[1]) $game_message.add('\.' + sprintf(Vocab::Stand_Up_3, stand_up_enemy.name)) #加入したアクターのIDを取得 if KURE::ActorScout::NAME_INPUT == 1 last_id = $kure_integrate_script[:Actor_Manage] ? $game_party.last_add_id : stand_up_enemy.enemy.actor_make[1] SceneManager.call(Scene_Name) SceneManager.scene.prepare(last_id, KURE::ActorScout::NAME_NUM) end #変数操作 stand_up_enemy.enemy.operate_val_actor_make.each{|data| KURE.val_math(data)} when 1 $game_message.add('\.' + sprintf(Vocab::Stand_Up_4, stand_up_enemy.name)) end sprite.dispose wait_for_message end end