# Aceだけど無印式のデータベースを使ってる場合は手動でfalseに $VXAce = !(!defined?(Graphics.play_movie)) if $VXAce.nil? module KS_Extend class Game_Battler # HPの回復を必要と判断するHPの割合。“以下”にしたい場合は+1%してね。 NEED_RECOVER_HPP = 90 # MPの回復を必要と判断するMPの割合。“以下”にしたい場合は+1%してね。 NEED_RECOVER_MPP = 50 end end =begin ★ks_敵行動改善 最終更新日 2013/06/12 2013/06/12 根本的な異常があったので修正。 2013/06/09 Aceで敵対行動に関して、有効判定をスルーしていたのを修正。 このために一時的にスキルのscopeを変更しているので、item_test中にscopeを参照する ような他のスクリプトが存在する場合、競合する可能性があります。 2013/03/31 Aceに対応しましたが、 2011/07/16 見方を対称にする行動のターゲットに異常がある場合があったので修正 2011/05/10 コモンイベントなどで敵が減った場合に、予期せず勝利する場合があるので修正。 □===制作・著作===□ MaidensnowOnline 暴兎 使用プロジェクトを公開する場合、readme等に当HP名とそのアドレスを記述してください。 使用報告はしてくれると喜びます。 □===配置場所===□ 基本スクリプトおよび基本エリアスは必要ありません。 エリアスのみで構成されており、原則的に最後に処理されるべき項目があるので、 可能な限り"▼ メイン"の上、近くに配置してください。 □===説明・使用方法===□ 敵が行動を決定する際に、HPが全快のターゲットを回復したり、 既にかかっているステート変化スキル(適用味方用両方)を重ねがけしたりしなく なり、援護行動を取る敵を作りやすくします。 敵の行動のターゲットが意味の無いターゲットを避ける 有効なターゲットがいない行動は行わなくなる 避けないケース base_damageが+の場合 base_damageが-で、味方対象のスキルで、HPの減ってる味方がいる場合 base_damageが0で、付加ステート・解除ステートが“無い”場合 ターゲットが味方でも敵でもない場合 避けるケース ダメージが無く、 付加ステートがあり、全ての相手がそのスキルの全付加ステートにかかっている場合 解除ステートがあり、全ての相手が解除ステートに一つもかかっていない場合 $VXAce == true の場合は、Aceプリセットの有効判定で判定しますが、 NEED_RECOVER_H(M)PP の割合だけ最大H(M)Pを下げて判定するため、 回復必要判断の堰値は有効になってると思いますが、 ざっくり実装しただけなので検証はしてません。 ふぐぁいがあったら教えてね! また、一時的にスキルのscopeを変更しているので、item_test中にscopeを参照する ような他のスクリプトが存在する場合、競合する可能性があります。 □===エリアスしているメソッド===□ Scene_Battle battle_end =end if $VXAce class Game_Temp #-------------------------------------------------------------------------- # ● 戦闘中フラグ #-------------------------------------------------------------------------- def in_battle $game_party.in_battle end #-------------------------------------------------------------------------- # ● 戦闘中フラグ #-------------------------------------------------------------------------- def in_battle=(v) $game_party.in_battle = v end end class Game_Unit attr_writer :in_battle #-------------------------------------------------------------------------- # ● 生存しているメンバーの配列取得 #-------------------------------------------------------------------------- def existing_members alive_members end end end if $VXAce class Game_Battler #-------------------------------------------------------------------------- # ● 現在の戦闘行動を取得 #-------------------------------------------------------------------------- def action current_action end #-------------------------------------------------------------------------- # ● 自身に対して、userの使用するobjが有効かを判定する。 #-------------------------------------------------------------------------- def action_is_effective_for?(obj = nil, user = nil) last, $game_temp.in_battle = $game_temp.in_battle, false i_last_hp = self.hp i_last_mp = self.mp i_bias_hp = self.mhp * (100 - KS_Extend::Game_Battler::NEED_RECOVER_HPP) / 100 i_bias_mp = self.mmp * (100 - KS_Extend::Game_Battler::NEED_RECOVER_MPP) / 100 i_bias_hp /= param_rate(0) * param_buff_rate(0) i_bias_mp /= param_rate(1) * param_buff_rate(1) add_param(0, -i_bias_hp) add_param(1, -i_bias_mp) if obj.for_opponent? last_scope, obj.scope = obj.scope, 7 res = item_test(user, obj) obj.scope = last_scope else res = item_test(user, obj) end $game_temp.in_battle = last add_param(0, i_bias_hp) add_param(1, i_bias_mp) self.hp = i_last_hp self.mp = i_last_mp res end end else class Game_Battler #-------------------------------------------------------------------------- # ● 自身に対して、userの使用するobjが有効かを判定する。 #-------------------------------------------------------------------------- def action_is_effective_for?(obj = nil, user = nil) return true if obj.nil? return true if dead? && obj.for_dead_friend? for_mp = obj.damage_to_mp dm = obj.base_damage ps = obj.plus_state_set ms = obj.minus_state_set return true if dm == 0 and ps.empty? and ms.empty? if obj.for_opponent? return true if dm > 0 && (!for_mp || self.mp > 0) elsif obj.for_friend? case dm <=> 0 when 1 ; return true if user.actor? || ps.empty? && ms.empty? when -1 if user.actor? return true else i_cur = for_mp ? self.mp : self.hp i_max = for_mp ? self.maxmp : self.maxhp i_rat = for_mp ? KS_Extend::Game_Battler::NEED_RECOVER_MPP : KS_Extend::Game_Battler::NEED_RECOVER_HPP return true if i_cur < i_max * i_rat / 100 end end else return true end ps.any?{|i| !state?(i) } || !(@states & ms).empty? end end end class Game_Battler #-------------------------------------------------------------------------- # ● 行動が有効(false_mode時は無効)となるターゲットの配列を返す #-------------------------------------------------------------------------- def effective_list(obj = nil, false_mode = false) targets = [] if obj.for_opponent? || obj.nil? targets = action.opponents_unit.existing_members elsif obj.for_user? targets = [self] elsif obj.for_dead_friend? targets = action.friends_unit.dead_members elsif obj.for_friend? targets = action.friends_unit.existing_members else return [self]# 暫定処置 内容が必要となる状況がまだないため。 end targets.find_all{|target| false_mode != target.action_is_effective_for?(obj, self) } end end class Game_Enemy if $VXAce #-------------------------------------------------------------------------- # ● 行動条件合致判定 # action : 戦闘行動 #-------------------------------------------------------------------------- alias conditions_met_ks_enemy_tactics conditions_met? def conditions_met?(action) conditions_met_ks_enemy_tactics(action) && !effective_list($data_skills[action.skill_id]).empty? end else #-------------------------------------------------------------------------- # ● 行動条件合致判定 # action : 戦闘行動 #-------------------------------------------------------------------------- alias conditions_met_ks_enemy_tactics conditions_met? def conditions_met?(action) conditions_met_ks_enemy_tactics(action) && (!action.skill? || !effective_list($data_skills[action.skill_id]).empty?) end end end class Game_Unit attr_accessor :estimate_battler attr_accessor :estimate_obj attr_accessor :ignore_targets class << self def estimate_battler=(v) $game_party.estimate_battler = $game_troop.estimate_battler = v end def estimate_obj=(v) $game_party.estimate_obj = $game_troop.estimate_obj = v end def ignore_targets=(v) $game_party.ignore_targets = $game_troop.ignore_targets = v end end end class Game_Party alias members_for_ignore_target members def members result = members_for_ignore_target unless @estimate_battler.nil? result.delete_if{|target| !target.action_is_effective_for?(@estimate_obj, @estimate_battler) } end result -= @ignore_targets unless @ignore_targets.nil? return result end end class Game_Troop alias members_for_ignore_target members def members result = members_for_ignore_target unless @estimate_battler.nil? result = result.collect {|target| target.action_is_effective_for?(@estimate_obj, @estimate_battler) } end unless @ignore_targets.nil? result -= @ignore_targets end return result end end if $VXAce class Game_Action #-------------------------------------------------------------------------- # ● ターゲットの配列作成 #-------------------------------------------------------------------------- alias make_targets_for_ignore_target make_targets def make_targets case @kind when 0 ; obj = nil when 1 ; obj = self.skill when 2 ; obj = self.item end Game_Unit.estimate_battler = @battler Game_Unit.estimate_obj = obj result = make_targets_for_ignore_target Game_Unit.estimate_battler = nil Game_Unit.estimate_obj = nil result end end else class Game_BattleAction #-------------------------------------------------------------------------- # ● ターゲットの配列作成 #-------------------------------------------------------------------------- alias make_targets_for_ignore_target make_targets def make_targets case @kind when 0 ; obj = nil when 1 ; obj = self.skill when 2 ; obj = self.item end Game_Unit.estimate_battler = @battler Game_Unit.estimate_obj = obj result = make_targets_for_ignore_target Game_Unit.estimate_battler = nil Game_Unit.estimate_obj = nil result end end end if $VXAce module BattleManager class << self alias judge_win_loss_for_ignore_target judge_win_loss def judge_win_loss lb = $game_troop.estimate_battler lo = $game_troop.estimate_obj li = $game_troop.ignore_targets lbp = $game_party.estimate_battler lop = $game_party.estimate_obj lip = $game_party.ignore_targets Game_Unit.estimate_battler = Game_Unit.estimate_obj = Game_Unit.ignore_targets = nil retsult = judge_win_loss_for_ignore_target $game_troop.estimate_battler = lb $game_troop.estimate_obj = lo $game_troop.ignore_targets = li $game_party.estimate_battler = lbp $game_party.estimate_obj = lop $game_party.ignore_targets = lip return retsult end end end else class Scene_Battle alias judge_win_loss_for_ignore_target judge_win_loss def judge_win_loss lb = $game_troop.estimate_battler lo = $game_troop.estimate_obj li = $game_troop.ignore_targets lbp = $game_party.estimate_battler lop = $game_party.estimate_obj lip = $game_party.ignore_targets Game_Unit.estimate_battler = Game_Unit.estimate_obj = Game_Unit.ignore_targets = nil retsult = judge_win_loss_for_ignore_target $game_troop.estimate_battler = lb $game_troop.estimate_obj = lo $game_troop.ignore_targets = li $game_party.estimate_battler = lbp $game_party.estimate_obj = lop $game_party.ignore_targets = lip return retsult end end end