# 設定項目 module KS_Regexp module State#(\d+(?:\s*,\s*\d+)*) # 累積を単純な足し算にする(しない場合、累積量が多いほど増え方が少なくなる) SIMPLE_COMURATIVE = false # 累積値ごとのステート付加率の変化幅(1/100%) REVISE_FOR_COMURATIVE = 100 # ステート変化に耐えるたびに増加する累積値の量。 INCREASE_COMURATIVE = 10 # ターンごとに減少する累積値の量 DECREASE_COMURATIVE = 1 end end =begin ★ks_ステート付加率累積 最終更新日 2011/02/04 2011/02/04 修正 □===制作・著作===□ MaidensnowOnline 暴兎 使用プロジェクトを公開する場合、readme等に当HP名とそのアドレスを記述してください。 使用報告はしてくれると喜びます。 □===配置場所===□ エリアスのみで構成されているので、 可能な限り"★ks_基本エリアス"の上、近くに配置してください。 □===説明・使用方法===□ 同じステートを与える攻撃を受けるほど、ステートの付加率が上昇する。 また、ステートから回復した場合にそのステートへの付加率が下がる設定も可能。 変化した付加率は、ターンごとに減少し、そのステートにかかると初期化される。 付加率の変化は%の計算に近いもので、補正が200の場合を例にすると、 "元の付加成功率が50未満なら成功率が2倍になり、50以上なら失敗率が半分" 書式 <累積 (スペースで区切った任意の数のパラメータ)> パラメータは以下のとおり。(値)には任意の正の整数が入れられる。 しない …累積処理を行わない (値)% …累積値1ごとに、値/100%だけ、ステート負荷率に修正を受ける。 (値)/H …値の分だけ、一回ステート付加に耐えるたびに累積値が増える。 (値)/T …値の分だけ、ターン終了時に累積値が0に近づく。 警戒(値) …ステートから回復した時に、値回分の量のマイナス累積値が入る。 =end $imported = {} unless $imported $imported[:comurative_probability] module KS_Regexp module State COMURATIVE_PARAM = /<累積((\s+(?:\d+%|\d+\/H|\d+\/T|警戒\s*\d+|しない))+)>/i end end module Kernel alias judge_note_line_for_comurative_probability judge_note_line def judge_note_line(line)# Kernel judge_note_line_for_comurative_probability(line) if self.is_a?(RPG::State) if line =~ KS_Regexp::State::COMURATIVE_PARAM has = { /(\d+)%/i=>:@__revise_for_comurative, /(\d+)\/H/i=>:@__increase_comurative, /(\d+)\/T/i=>:@__decrease_comurative, /警戒\s*(\d+)/i=>:@__aware_target, /しない/i=>:@__no_comurative, } ary = $1.split(/\s/i) for ket in has key = ket[0] next unless ary.find {|i| i =~ key} instance_variable_set(has[key], $1 ? $1.to_i : true) #pp @name, line, has[key], instance_variable_get(has[key]) end end end end end class RPG::State def aware_target ; create_ks_param_cache unless @__ks_cache_done return @__aware_target ; end def no_comurative ; create_ks_param_cache unless @__ks_cache_done return @__no_comurative ; end def revise_for_comurative ; create_ks_param_cache unless @__ks_cache_done return @__revise_for_comurative ; end def increase_comurative ; create_ks_param_cache unless @__ks_cache_done return @__increase_comurative ; end def decrease_comurative ; create_ks_param_cache unless @__ks_cache_done return @__decrease_comurative ; end end class Game_Battler unless instance_methods(false).include?("adjust_save_data") def adjust_save_data# Game_Battler alias super unless @state_comurative @state_comurative = {} @state_comurative.default = 0 end end else alias adjust_save_data_for_comurative_probability adjust_save_data def adjust_save_data# Game_Battler alias adjust_save_data_for_comurative_probability unless @state_comurative @state_comurative = {} @state_comurative.default = 0 end end end alias initialize_for_comurative_probability initialize def initialize# Game_Battler alias initialize_for_comurative_probability @state_comurative = {} @state_comurative.default = 0 end alias apply_state_changes_for_comurative_probability apply_state_changes def apply_state_changes(obj)# Game_Battler alias apply_state_changes_for_comurative_probability(obj) ls = @state_comurative.size for i in obj.plus_state_set next if $data_states[i].no_comurative || @states.include?(i) || state_ignore?(i) || state_resist?(i) v = $data_states[i].increase_comurative v = KS_Regexp::State::INCREASE_COMURATIVE unless v if KS_Regexp::State::SIMPLE_COMURATIVE vv = v else vv = @state_comurative[i] vv = v if vv < v vv = (v * 11 - vv) / 10 vv = 1 if vv < 1 end @state_comurative[i] += vv #pm name, $data_states[i].name, "#{@state_comurative[i]} (+#{vv})" end #pm @state_comurative# if @state_comurative.size != ls end alias add_state_for_comurative_probability add_state def add_state(state_id)# Game_Battler alias add_state_for_comurative_probability(state_id) @state_comurative.delete(state_id) if @state_comurative[state_id] > 0 end alias remove_state_for_comurative_probability remove_state def remove_state(state_id)# Game_Battler alias if @states.include?(state_id) state = $data_states[state_id] vv = state.aware_target if vv v = state.increase_comurative v = KS_Regexp::State::INCREASE_COMURATIVE unless v @state_comurative[state_id] = v * -vv #pm state.name, name, "警戒 #{@state_comurative[state_id]}" end end remove_state_for_comurative_probability(state_id) end alias remove_states_auto_for_comurative_probability remove_states_auto def remove_states_auto# Game_Battler alias remove_states_auto_for_comurative_probability for ii in @state_comurative i = ii[0] v = $data_states[i].decrease_comurative v = KS_Regexp::State::DECREASE_COMURATIVE unless v @state_comurative[i] += (0 <=> @state_comurative[i]) * v end end alias remove_states_battle_for_comurative_probability remove_states_battle def remove_states_battle# Game_Battler alias remove_states_battle_for_comurative_probability @state_comurative.clear end end class Game_Actor alias state_probability_for_comurative_probability state_probability def state_probability(state_id)# Game_Actor alias result = state_probability_for_comurative_probability(state_id) state = $data_states[state_id] return result if state.nonresistance || result < 1 v = state.revise_for_comurative v = KS_Regexp::State::REVISE_FOR_COMURATIVE unless v vv = result.apply_percent(100 + @state_comurative[state_id] * v / 100, true) #pm @name, $data_states[state_id].name, "#{result} #{@state_comurative[state_id]}% => #{vv}" if @state_comurative[state_id] != 0 return vv end end class Game_Enemy alias state_probability_for_comurative_probability state_probability def state_probability(state_id)# Game_Actor alias result = state_probability_for_comurative_probability(state_id) state = $data_states[state_id] return result if state.nonresistance || result < 1 v = state.revise_for_comurative v = KS_Regexp::State::REVISE_FOR_COMURATIVE unless v vv = result.apply_percent(100 + @state_comurative[state_id] * v / 100, true) #pm name, state.name, "#{result} #{@state_comurative[state_id]}% => #{vv}" if @state_comurative[state_id] != 0 return vv end end