#============================================================================== # ■アクター個別管理 for RGSS3 Ver1.04-α # □作成者 kure #=============================================================================== $kure_integrate_script = {} if $kure_integrate_script == nil $kure_integrate_script[:Actor_Manage] = 100 p "アクター個別管理" #メッセージ----------------------------------- module Vocab LOSTACTOR = "%s はPTから離脱した!" end module KURE module Actor_Manage #基本設定------------------------------------------------------------------ #基準ID(変更しない事) ID_BASE = 10000 #メンバー最大数 #指定数のアクターが存在する時新たにアクターを生成しません MAX_MEMBER = 100 #プラス数に対する補正------------------------------------------------------ #パラメータ補正率(割合指定) PARAM_REVICE = 0.02 #最大レベル補正 LEVEL_REVICE = 1 #プラス数最大値 PLUS_LIMIT = 50 end end #============================================================================== # ●■ RPG::UsableItem(追加定義集積) #============================================================================== class RPG::UsableItem < RPG::BaseItem #-------------------------------------------------------------------------- # ☆ +数変化の定義(追加定義) #-------------------------------------------------------------------------- def add_actor_plus @note.match(/<合成補正変化\s?([-]?\d+)\s?>/) return $1 ? $1.to_i : 0 end end #============================================================================== # ■ RPG::State(追加定義) #============================================================================== class RPG::State < RPG::BaseItem #-------------------------------------------------------------------------- # ★ ロストステートの定義(追加定義) #-------------------------------------------------------------------------- def lost_state @note.match(/<ロストステート\s?(\d+)\s?>/) return $1 ? $1.to_i : nil end end #============================================================================== # ■ Window_BattleLog #============================================================================== class Window_BattleLog < Window_Selectable #-------------------------------------------------------------------------- # ● アクターロストの表示 #-------------------------------------------------------------------------- def display_lost_actor(actor) add_text(sprintf(Vocab::LOSTACTOR, actor.name)) wait end end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # ◎ スキル/アイテムの適用テスト(エイリアス再定義) #-------------------------------------------------------------------------- alias k_actor_manage_before_item_test item_test unless $! def item_test(user, item) return true if actor_add_plus_effect?(user, item) k_actor_manage_before_item_test(user, item) end #-------------------------------------------------------------------------- # ★ アクターの+変化効果があるかどうか(追加定義) #-------------------------------------------------------------------------- def actor_add_plus_effect?(user, item) return false if item.add_actor_plus == 0 return true end #-------------------------------------------------------------------------- # ◎ スキル/アイテムの効果適用(エイリアス再定義) #------------------------------------------------------------------------- alias k_actor_manage_before_item_apply item_apply unless $! def item_apply(user, item) k_actor_manage_before_item_apply(user, item) item_effect_add_plus(user, item) end #-------------------------------------------------------------------------- # ☆ 使用効果[アクター+値変化](追加定義) #-------------------------------------------------------------------------- def item_effect_add_plus(user, item) return unless actor? return unless actor_add_plus_effect?(user, item) @plus += item.add_actor_plus end end #============================================================================== # ■ Game_Interpreter #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ● 指定固有IDのアクターを加える(追加定義) #-------------------------------------------------------------------------- def add_actor_identify(identify_id) value = $game_actors.actor_id(identify_id) $game_party.add_actor(value) if value != 0 end #-------------------------------------------------------------------------- # ● 指定固有IDのアクターを外す(追加定義) #-------------------------------------------------------------------------- def remove_actor_identify(identify_id) value = $game_actors.actor_id(identify_id) $game_party.remove_actor(value) if value != 0 end #-------------------------------------------------------------------------- # ● 指定固有IDのアクターを削除する(追加定義) #-------------------------------------------------------------------------- def delete_actor_identify(identify_id) value = $game_actors.actor_id(identify_id) $game_party.delete_actor(value) if value != 0 end #-------------------------------------------------------------------------- # ● 最終加入のアクターIDを取得する(追加定義) #-------------------------------------------------------------------------- def last_add_actor_id $game_party.last_add_id end #-------------------------------------------------------------------------- # ● パーティーメンバーのアクターIDを取得する(追加定義) #-------------------------------------------------------------------------- def party_actor_id(value) $game_party.all_members[value - 1] ? $game_party.all_members[value - 1].id : 0 end end #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler attr_accessor :plus # 合成補正 attr_accessor :parents # 親のデータベースID attr_accessor :lock # ロック #-------------------------------------------------------------------------- # ● 合成補正の取得(追加定義) #-------------------------------------------------------------------------- def plus @plus ||= 0 @plus = [@plus, KURE::Actor_Manage::PLUS_LIMIT].min return @plus end #-------------------------------------------------------------------------- # ● 名前の取得(再定義) #-------------------------------------------------------------------------- def name plus == 0 ? @name : @name + "+" + plus.to_s end #-------------------------------------------------------------------------- # ● ロックの切り替え(再定義) #-------------------------------------------------------------------------- def change_lock @lock = @lock ? false : true end #-------------------------------------------------------------------------- # ● 両親のIDの取得(追加定義) #-------------------------------------------------------------------------- def parents @parents ? @parents : [] end #-------------------------------------------------------------------------- # ● 継承パラメータのセット(追加定義) #-------------------------------------------------------------------------- def set_succeed_param(param_id, value) @succeed_param ||= [] @succeed_param[param_id] = value end #-------------------------------------------------------------------------- # ● 継承対象パラメータの取得(追加定義) #-------------------------------------------------------------------------- def succeed_param(param_id) @succeed_param ||= [] @succeed_param[param_id] ||= 0 return @succeed_param[param_id] end #-------------------------------------------------------------------------- # ● 通常能力値の基本値取得(エイリアス再定義) #-------------------------------------------------------------------------- alias k_actor_manage_before_param_base param_base def param_base(param_id) ((k_actor_manage_before_param_base(param_id) + succeed_param(param_id)) * (1 + (plus * KURE::Actor_Manage::PARAM_REVICE))).to_i end #-------------------------------------------------------------------------- # ● 最大レベル(エイリアス再定義) #-------------------------------------------------------------------------- alias k_actor_manage_before_max_level max_level def max_level [k_actor_manage_before_max_level + (plus * KURE::Actor_Manage::LEVEL_REVICE).to_i ,99].min end #-------------------------------------------------------------------------- # ● IDの取得(再定義) #-------------------------------------------------------------------------- def id @actor_id * KURE::Actor_Manage::ID_BASE + identify_id end #-------------------------------------------------------------------------- # ● アクターデータベースID取得(再定義) #-------------------------------------------------------------------------- def database_id @actor_id > KURE::Actor_Manage::ID_BASE ? @actor_id / KURE::Actor_Manage::ID_BASE : @actor_id end #-------------------------------------------------------------------------- # ● アクター固有ID取得(再定義) #-------------------------------------------------------------------------- def identify_id @identify_id ? @identify_id : 0 end #-------------------------------------------------------------------------- # ● アクターオブジェクト取得(再定義) #-------------------------------------------------------------------------- def actor if @actor_id > KURE::Actor_Manage::ID_BASE @identify_id = @actor_id % KURE::Actor_Manage::ID_BASE @actor_id = @actor_id / KURE::Actor_Manage::ID_BASE end $data_actors[@actor_id] end end #============================================================================== # ■ Game_Actors #============================================================================== class Game_Actors #-------------------------------------------------------------------------- # ★ アクターの取得(再定義) #-------------------------------------------------------------------------- def [](actor_id) if actor_id > KURE::Actor_Manage::ID_BASE #データベースIDを参照し、存在しない場合はnilを返す return nil unless $data_actors[actor_id / KURE::Actor_Manage::ID_BASE] #配列を参照し、値を返す return @data[actor_id % KURE::Actor_Manage::ID_BASE] ||= Game_Actor.new(actor_id) else #通常ID処理ではアクターオブジェクトをとりあえず返す return nil unless $data_actors[actor_id] return Game_Actor.new(actor_id) end end #-------------------------------------------------------------------------- # ● 全データの取得(追加定義) #-------------------------------------------------------------------------- def all_data @data.select{|object| object} end #-------------------------------------------------------------------------- # ● アクターのデータを確認し、存在しなければ作成(追加定義) #-------------------------------------------------------------------------- def cheack_actor(actor_id) return unless actor_id > KURE::Actor_Manage::ID_BASE return nil unless $data_actors[actor_id / KURE::Actor_Manage::ID_BASE] $game_party.last_add_id = actor_id return @data[actor_id % KURE::Actor_Manage::ID_BASE] ||= Game_Actor.new(actor_id) end #-------------------------------------------------------------------------- # ● 特定固有IDのアクターのIDを返す(追加定義) #-------------------------------------------------------------------------- def actor_id(identify_id) @data[identify_id] ? @data[identify_id].id : 0 end #-------------------------------------------------------------------------- # ● 特定固有IDのアクターを削除する(追加定義) #-------------------------------------------------------------------------- def delete_actor(identify_id) @data[identify_id].clear_equipments if @data[identify_id] @data[identify_id] = nil end #-------------------------------------------------------------------------- # ● 空白IDの取得(追加定義) #-------------------------------------------------------------------------- def empty_id return @data[1..@data.size - 1].index(nil) ? @data[1..@data.size - 1].index(nil) + 1 : @data.size end end #============================================================================== # ■ Game_Party #============================================================================== class Game_Party < Game_Unit attr_reader :actors # アクターID attr_accessor :last_add_id # 最終加入のアクターID #-------------------------------------------------------------------------- # ★ 初期パーティのセットアップ(再定義) #-------------------------------------------------------------------------- def setup_starting_members @actors = $data_system.party_members.clone @actors.each_with_index{|id, index| @actors[index] = id * KURE::Actor_Manage::ID_BASE + (index + 1)} end #-------------------------------------------------------------------------- # ● パーティーメンバー数調整(再定義) #-------------------------------------------------------------------------- def actor_addable? return true unless $kure_integrate_script[:Actor_Organize] return false if all_members.size >= KURE::Actor_Organize::MAX_PARTY_MEBER return true end #-------------------------------------------------------------------------- # ● アクターを加える(再定義) #-------------------------------------------------------------------------- def add_actor(actor_id) if actor_id > KURE::Actor_Manage::ID_BASE @actors.push(actor_id) if !@actors.include?(actor_id) && actor_addable? else return if $game_actors.empty_id > KURE::Actor_Manage::MAX_MEMBER new_actor_id = actor_id * KURE::Actor_Manage::ID_BASE + ($game_actors.empty_id) @actors.push(new_actor_id) if actor_addable? $game_actors.cheack_actor(new_actor_id) end $game_player.refresh $game_map.need_refresh = true end #-------------------------------------------------------------------------- # ● アクターを外す(再定義) #-------------------------------------------------------------------------- def remove_actor(actor_id) if actor_id > KURE::Actor_Manage::ID_BASE @actors.delete(actor_id) else @actors.each_with_index{|id, index| next if actor_id != id / KURE::Actor_Manage::ID_BASE @actors[index] = nil @actors.compact! break} end $game_player.refresh $game_map.need_refresh = true end #-------------------------------------------------------------------------- # ● アクターを削除する(追加定義) #-------------------------------------------------------------------------- def delete_actor(actor_id) return if actor_id < KURE::Actor_Manage::ID_BASE @actors.delete(actor_id) $game_actors.delete_actor(actor_id % KURE::Actor_Manage::ID_BASE) $game_player.refresh $game_map.need_refresh = true end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ◎ 戦闘行動の実行(エイリアス再定義) #-------------------------------------------------------------------------- alias k_actor_manage_before_execute_action execute_action unless $! def execute_action k_actor_manage_before_execute_action lost_state_process end #-------------------------------------------------------------------------- # ◎ ロストステート処理の実行(エイリアス再定義) #-------------------------------------------------------------------------- def lost_state_process #ロストステート判定 $game_party.all_members.each{|actor| next if actor.hp != 0 && actor.mp != 0 actor.states.each{|state| next unless state.lost_state case state.lost_state when 0 ; next if actor.hp != 0 when 1 ; next if actor.mp != 0 when 2 ; next if actor.hp != 0 && actor.mp != 0 when 3 ; next if actor.hp != 0 or actor.mp != 0 end $game_party.delete_actor(actor.id) @log_window.display_lost_actor(actor) break } } end end