#============================================================================== # ■ Numset #------------------------------------------------------------------------------ #  定数全般のモジュールです。 #============================================================================== module Numset DAMAGE_TIME = 5 # ダメージを受ける間隔(フレーム) DAMAGE_SET = {3=>"M64", 4=>"M32", 5=>"M16"}# ダメージ対応ハッシュ NODAMAGE_ELE = "地形ダメージ" # 地形ダメージ関係の属性 DAMAGE_SE = ["123-Thunder01", 80, 150] # ダメージ効果音 FLASH_SET = Color.new(160, 34, 34, 128) # フラッシュの色 DEAD_OK = true # 戦闘不能になり得るか end #============================================================================== # ■ Game_Battler #------------------------------------------------------------------------------ #  バトラーを扱うクラスです。このクラスは Game_Actor クラスと Game_Enemy クラ # スのスーパークラスとして使用されます。 #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ● 属性名の配列の取得 #-------------------------------------------------------------------------- def elename_set(ele) if ele[0].is_a?(Array) set = ele.flatten else set = ele end set = set.compact.map!{|e| $data_system.elements[e]} return set end end #============================================================================== # ■ Game_Party #------------------------------------------------------------------------------ #  パーティを扱うクラスです。ゴールドやアイテムなどの情報が含まれます。このク # ラスのインスタンスは $game_party で参照されます。 #============================================================================== class Game_Party #-------------------------------------------------------------------------- # ● 地形ダメージチェック #-------------------------------------------------------------------------- def check_tile_damage # 地形タグのダメージを読み取る base = Numset::DAMAGE_SET[$game_player.terrain_tag] if base != nil if base =~ /^([amp])([+-]?([1-9]\d*|0)\.?\d*)?/i set = $1.downcase damage = $2.to_i end else # 無い場合はチェックしない return end # ダメージを受けた人数をチェック mem = 0 for actor in @actors # 属性をチェック if Game_Battler.method_defined?("multy_element_set") eleset = actor.elename_set(actor.multy_element_set) elsif Game_Battler.method_defined?("equip_element_set") eleset = actor.elename_set(actor.equip_element_set) else armor1 = (actor.armor1_id == 0 ? [] : $data_armors[actor.armor1_id].guard_element_set) armor2 = (actor.armor2_id == 0 ? [] : $data_armors[actor.armor2_id].guard_element_set) armor3 = (actor.armor3_id == 0 ? [] : $data_armors[actor.armor3_id].guard_element_set) armor4 = (actor.armor4_id == 0 ? [] : $data_armors[actor.armor4_id].guard_element_set) eleset = actor.elename_set([armor1, armor2, armor3, armor4]) end # 下の1行、意味なさそうですが必要です ""[/e/] eleset.each{|e| if e =~ /#{Numset::NODAMAGE_ELE}(([+-])?([1-9]\d*|0)\.?\d*)([%%])?/ # 軽減までに書き換えられるわけじゃないので手抜き break end} if actor.hp > 0 # 小数点以下もOK case set when "a" result = damage.to_f when "m" result = (actor.maxhp / damage.to_f) when "p" result = (actor.maxhp * damage.to_f / 100) else result = 0 end if $& != nil if $4 != nil if result > 0 result = [(result * (100 + $1.to_i) / 100), 0].max elsif result < 0 result = [(result * (100 + $1.to_i) / 100), 0].min end else if result > 0 result = [result + $1.to_i, 0].max elsif result < 0 result = [result + $1.to_i, 0].min else result += $1.to_i end end end if result > 0 actor.hp -= [result.ceil, 1].max mem += 1 elsif result < 0 actor.hp -= [result.floor, -1].min mem += 1 end if actor.hp == 0 and not Numset::DEAD_OK actor.hp = 1 end end end # 誰かがダメージを受けたら if mem > 0 se = Numset::DAMAGE_SE if se[0] != nil Audio.se_play("Audio/SE/#{se[0]}", se[1], se[2]) end $game_screen.start_flash(Numset::FLASH_SET, 4) end $game_temp.gameover = $game_party.all_dead? end end #============================================================================== # ■ Game_Player #------------------------------------------------------------------------------ #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。 #============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- 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 # 地形ダメージチェック if (Graphics.frame_count % Numset::DAMAGE_TIME) == 0 $game_party.check_tile_damage 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) # エンカウント カウントダウン if @encounter_count > 0 @encounter_count -= 1 end 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