#============================================================================== # ■ Numset #------------------------------------------------------------------------------ #  定数全般のモジュールです。 #============================================================================== module Numset ENCOUNT_TYPE = 1 # エンカウント率の計算式タイプ ENCOUNT_SET = "" # 0の場合、ここが使われます ENCOUNT_BASE = 10000 # エンカウント率の基準値(小さいほどエンカウントしやすい) NO_ENCOUNT = 3 # エンカウント無効歩数 ENCOUNT_TEXT = "エンカウント" # 用語としてのエンカウント end #============================================================================== # ■ Game_Player #------------------------------------------------------------------------------ #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。 #============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :noencount_count #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(map_id, event) super @encounter_count = 0 @noencount_count = Numset::NO_ENCOUNT end #-------------------------------------------------------------------------- # ● エンカウント カウント取得 #-------------------------------------------------------------------------- def encounter_count for actor in $game_party.actors for element in actor.multy_element_set if $data_ststem.elements[element] =~ /#{Numset::ENCOUNT_TEXT}([+-]\d+)([%%歩])/ if $2 == "歩" percent = [(100 + $2.to_i) / 100.0, 0].max count = @encounter_count else percent = 1 count = [@encounter_count + $2.to_i, 0].max end end end end case Numset::ENCOUNT_TYPE when 0 base = eval("Numset::ENCOUNT_SET") when 1 base = ((1 + $game_map.encounter_step / 10) ** (count / 2.0)) end base *= percent return base.round end def encounter_count=(count) @encounter_count = count end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # ローカル変数に移動中かどうかを記憶 last_moving = moving? # 移動中、イベント実行中、移動ルート強制中、 # メッセージウィンドウ表示中のいずれでもない場合 unless moving? or $game_system.map_interpreter.running? or @move_route_forcing or $game_temp.message_window_showing # 方向ボタンが押されていれば、その方向へプレイヤーを移動 case Input.dir4 when 2 move_down when 4 move_left when 6 move_right when 8 move_up end end # ローカル変数に座標を記憶 last_real_x = @real_x last_real_y = @real_y super # キャラクターが下に移動し、かつ画面上の位置が中央より下の場合 if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y # マップを下にスクロール $game_map.scroll_down(@real_y - last_real_y) end # キャラクターが左に移動し、かつ画面上の位置が中央より左の場合 if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X # マップを左にスクロール $game_map.scroll_left(last_real_x - @real_x) end # キャラクターが右に移動し、かつ画面上の位置が中央より右の場合 if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X # マップを右にスクロール $game_map.scroll_right(@real_x - last_real_x) end # キャラクターが上に移動し、かつ画面上の位置が中央より上の場合 if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y # マップを上にスクロール $game_map.scroll_up(last_real_y - @real_y) end # 移動中ではない場合 unless moving? # 前回プレイヤーが移動中だった場合 if last_moving # 同位置のイベントとの接触によるイベント起動判定 result = check_event_trigger_here([1,2]) # 起動したイベントがない場合 if result == false # デバッグモードが ON かつ CTRL キーが押されている場合を除き unless $DEBUG and Input.press?(Input::CTRL) # エンカウント カウントアップ @encounter_count += 1 @noencount_count -= 1 end end end # C ボタンが押された場合 if Input.trigger?(Input::C) # 同位置および正面のイベント起動判定 check_event_trigger_here([0]) check_event_trigger_there([0,1,2]) end end end end end #============================================================================== # ■ Scene_Map #------------------------------------------------------------------------------ #  マップ画面の処理を行うクラスです。 #============================================================================== class Scene_Map #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # ループ loop do # マップ、インタプリタ、プレイヤーの順に更新 # (この更新順序は、イベントを実行する条件が満たされているときに # プレイヤーに一瞬移動する機会を与えないなどの理由で重要) $game_map.update $game_system.map_interpreter.update $game_player.update # システム (タイマー)、画面を更新 $game_system.update $game_screen.update # プレイヤーの場所移動中でなければループを中断 unless $game_temp.player_transferring break end # 場所移動を実行 transfer_player # トランジション処理中の場合、ループを中断 if $game_temp.transition_processing break end end # スプライトセットを更新 @spriteset.update # メッセージウィンドウを更新 @message_window.update # ゲームオーバーの場合 if $game_temp.gameover # ゲームオーバー画面に切り替え $scene = Scene_Gameover.new return end # タイトル画面に戻す場合 if $game_temp.to_title # タイトル画面に切り替え $scene = Scene_Title.new return end # トランジション処理中の場合 if $game_temp.transition_processing # トランジション処理中フラグをクリア $game_temp.transition_processing = false # トランジション実行 if $game_temp.transition_name == "" Graphics.transition(20) else Graphics.transition(40, "Graphics/Transitions/" + $game_temp.transition_name) end end # メッセージウィンドウ表示中の場合 if $game_temp.message_window_showing return end # 移動中ではない場合 unless $game_player.moving? # 前回プレイヤーが移動中だった場合 if $game_player.last_moving # エンカウント禁止歩数外の場合 if $game_player.noencount_count <= 0 # エンカウント カウントが一定以上で、エンカウントリストが空ではない場合 if rand(Numset::ENCOUNT_BASE) <= $game_player.encounter_count and $game_map.encounter_list != [] # イベント実行中かエンカウント禁止中でなければ unless $game_system.map_interpreter.running? or $game_system.encounter_disabled # トループを決定 troop_id = troop_set # トループが有効なら if $data_troops[troop_id] != nil # バトル呼び出しフラグをセット $game_temp.battle_calling = true $game_temp.battle_troop_id = troop_id $game_temp.battle_can_escape = true $game_temp.battle_can_lose = false $game_temp.battle_proc = nil end end end end end end # B ボタンが押された場合 if Input.trigger?(Input::B) # イベント実行中かメニュー禁止中でなければ unless $game_system.map_interpreter.running? or $game_system.menu_disabled # メニュー呼び出しフラグと SE 演奏フラグをセット $game_temp.menu_calling = true $game_temp.menu_beep = true end end # デバッグモードが ON かつ F9 キーが押されている場合 if $DEBUG and Input.press?(Input::F9) # デバッグ呼び出しフラグをセット $game_temp.debug_calling = true end # プレイヤーの移動中ではない場合 unless $game_player.moving? # 各種画面の呼び出しを実行 if $game_temp.battle_calling call_battle elsif $game_temp.shop_calling call_shop elsif $game_temp.name_calling call_name elsif $game_temp.menu_calling call_menu elsif $game_temp.save_calling call_save elsif $game_temp.debug_calling call_debug end end end #-------------------------------------------------------------------------- # ● バトルの呼び出し #-------------------------------------------------------------------------- def call_battle # バトル呼び出しフラグをクリア $game_temp.battle_calling = false # メニュー呼び出しフラグをクリア $game_temp.menu_calling = false $game_temp.menu_beep = false # エンカウント カウントを初期化 $game_player.encounter_count = 0 $game_player.noencount_count = Numset::NO_ENCOUNT # マップ BGM を記憶 $game_temp.map_bgm = $game_system.playing_bgm # バトル開始 SE を演奏 $game_system.se_play($data_system.battle_start_se) # バトル BGM を演奏 $game_system.bgm_play($game_system.battle_bgm) # プレイヤーの姿勢を矯正 $game_player.straighten # バトル画面に切り替え $scene = Scene_Battle.new end #-------------------------------------------------------------------------- # ● トループのセット #-------------------------------------------------------------------------- def troop_set list = $game_map.encounter_list rand = rand(list.size) return list[rand] end end