=begin ★ks汎用判定 battler 最終更新日 2010/09/26 □===制作・著作===□ MaidensnowOnline 暴兎 (http://maidensnow.blog100.fc2.com/) 単体では特に機能のないスクリプトなので、著作権表記は必要ありません。 □===配置場所===□ エリアスのみで構成されているので、 可能な限り"▼ メイン"の上、近くに配置してください。 □===説明・使用方法===□ MaidensnowOnlineのスクリプトでバトラーのために必要になるメソッド集。 装備及びステートによって変化するパラメーターのキャッシュを保存する機能と、 それらに変更があった場合にキャッシュをクリアーする機能を提供します。 ただし、このスクリプト自体にはキャッシュを作成する機能はありません。 □===利用できる新規メソッド===□ reset_ks_caches reset_paramater_cache reset_equips_cache 上から、全て、ステートに関連する、装備に関連する、各キャッシュをクリアします。 基本的なシチュエーションでのキャッシュの初期化は実装済みなので、 任意のタイミングでキャッシュのクリアを行いたい場合に使ってください。 =end $imported = {} if $imported == nil #============================================================================== # ■ Scene_File #============================================================================== class Scene_File < Scene_Base alias read_save_data_for_reset_paramater_cache read_save_data def read_save_data(file) read_save_data_for_reset_paramater_cache(file) for battler in $game_actors.instance_variable_get(:@data) next if battler == nil battler.flags = {} unless battler.flags battler.paramater_cache = {} unless battler.paramater_cache battler.equips_cache = {} unless battler.equips_cache battler.judge_full_ap_skills if $imported["EquipLearnSkill"] battler.reset_ks_caches#def read_save_data( end end end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler BASIC_P_HASHES = [] unless defined?(BASIC_P_HASHES) BASIC_E_HASHES = [] unless defined?(BASIC_E_HASHES) if $imported[:ks_rogue] elsif $imported["ReproduceFunctions"] def state_ids return @state_ids.clear + @states + auto_states(true) end else def state_ids return @states end end# if $imported[:ks_rogue] attr_accessor :paramater_cache attr_accessor :equips_cache attr_accessor :flags alias initialize_for_param_cache initialize def initialize# Game_Battler alias @flags = {}# Game_Battler initialize @state_ids = [] initialize_for_param_cache end def adjust_param_cache# Game_Battler 専用メソッド for key in BASIC_P_HASHES @paramater_cache[key] = {} unless @paramater_cache[key].is_a?(Hash) end for key in BASIC_E_HASHES self.equips_cache[key] = {} unless self.equips_cache[key].is_a?(Hash) end end def reset_ks_caches# Game_Battler 専用メソッド reset_paramater_cache#def reset_ks_caches reset_equips_cache#def reset_ks_caches end def reset_paramater_cache# Game_Battler 専用メソッド Vocab::TmpHas[0].clear for key in BASIC_P_HASHES Vocab::TmpHas[0][key] = @paramater_cache[key].clear end @paramater_cache.clear for key in BASIC_P_HASHES @paramater_cache[key] = Vocab::TmpHas[0][key]#{} end end def reset_equips_cache# Game_Battler 専用メソッド Vocab::TmpHas[0].clear for key in BASIC_E_HASHES Vocab::TmpHas[0][key] = self.equips_cache[key].clear end self.equips_cache.clear for key in BASIC_E_HASHES self.equips_cache[key] = Vocab::TmpHas[0][key]#{} end end def reset_equips_duration_cache# Game_Battler 専用メソッド self.equips_cache[:cb_dura].clear end def lsat_hp_mp# Game_Battler 専用メソッド return maxhp, maxmp end def new_hp_mp(last_mhp, last_mmp, state_id = nil)# Game_Battler 専用メソッド if last_mhp != maxhp self.hp = [self.hp <=> 0, (hp.to_f * maxhp / last_mhp).round].max end if last_mmp != maxmp self.mp = (mp.to_f * maxmp / last_mmp).round end end alias add_state_for_param_cache_clear add_state def add_state(state_id)# reset_paramater_cache用 エリアス last_mhp, last_mmp = lsat_hp_mp add_state_for_param_cache_clear(state_id) reset_paramater_cache#def add_state( new_hp_mp(last_mhp, last_mmp, state_id) end alias remove_state_for_param_cache_clear remove_state def remove_state(state_id)# reset_paramater_cache用 エリアス last_mhp, last_mmp = lsat_hp_mp remove_state_for_param_cache_clear(state_id) reset_paramater_cache#def remove_state( new_hp_mp(last_mhp, last_mmp, state_id) end begin alias add_state_silence_for_param_cache_clear add_state_silence def add_state_silence(state_id)# reset_paramater_cache用 エリアス last_mhp, last_mmp = lsat_hp_mp add_state_silence_for_param_cache_clear(state_id) reset_paramater_cache#def add_state_silence( new_hp_mp(last_mhp, last_mmp, state_id) end alias remove_state_silence_for_param_cache_clear remove_state_silence def remove_state_silence(state_id)# reset_paramater_cache用 エリアス last_mhp, last_mmp = lsat_hp_mp remove_state_silence_for_param_cache_clear(state_id) reset_paramater_cache#def remove_state_silence( new_hp_mp(last_mhp, last_mmp, state_id) end rescue end #-------------------------------------------------------------------------- # ● スキルの適用テスト #-------------------------------------------------------------------------- alias skill_test_for_states_ids skill_test def skill_test(user, skill)# Game_Battler alias last_ids = @states.dup result = skill_test_for_states_ids(user, skill) @states = last_ids return result end end #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_for_param_cache_clear initialize def initialize(actor_id)# Game_Actor alias @paramater_cache = {} @equips_cache = {} adjust_param_cache initialize_for_param_cache_clear(actor_id) end alias setup_for_param_cache_clear setup def setup(actor_id)# Game_Actor alias reset_ks_caches#def setup(actor_id) setup_for_param_cache_clear(actor_id) end alias learn_skill_for_param_cache_clear learn_skill def learn_skill(skill_id)# Game_Actor alias reset_ks_caches unless skill_learn?($data_skills[skill_id])#def learn_skill( learn_skill_for_param_cache_clear(skill_id) end alias forget_skill_for_param_cache_clear forget_skill def forget_skill(skill_id)# Game_Actor alias reset_ks_caches if skill_learn?($data_skills[skill_id])#def forget_skill( forget_skill_for_param_cache_clear(skill_id) end alias level_up_for_param_cache_clear level_up def level_up# Game_Actor alias level_up_for_param_cache_clear reset_ks_caches#def level_up end alias level_down_for_param_cache_clear level_down def level_down# Game_Actor alias level_down_for_param_cache_clear reset_ks_caches#def level_down end alias discard_equip_for_param_cache_clear discard_equip def discard_equip(item)# Game_Actor alias discard_equip_for_param_cache_clear(item) reset_ks_caches#def discard_equip( end alias change_equip_for_param_cache_clear change_equip def change_equip(equip_type, item, test = false)# Game_Actor alias change_equip_for_param_cache_clear(equip_type, item, test) reset_ks_caches#def change_equip( end end #============================================================================== # ■ RPG::Enemy #============================================================================== class RPG::Enemy def equips_cache# RPG::Enemy 専用メソッド @equips_cache = {} unless @equips_cache return @equips_cache end def equips_cache=(val)# RPG::Enemy 専用メソッド @equips_cache = val end end #============================================================================== # ■ Game_Enemy #============================================================================== class Game_Enemy #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_for_param_cache_clear initialize def initialize(index, enemy_id)# Game_Enemy alias @paramater_cache = {} initialize_for_param_cache_clear(index, enemy_id) self.equips_cache = {} unless self.equips_cache.is_a?(Hash) adjust_param_cache reset_ks_caches#def initialize( end def equips_cache# Game_Enemy 専用メソッド return enemy.equips_cache end def equips_cache=(val)# Game_Enemy 専用メソッド enemy.equips_cache = val end end #============================================================================== # ■ Game_Interpreter #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ● スキルの増減 #-------------------------------------------------------------------------- alias command_318_for_param_cache_clear command_318 def command_318# Game_Interpreter alias command_318_for_param_cache_clear actor = $game_actors[@params[0]] if actor != nil actor.paramater_cache.delete(:skills) end return true end end