| 赞 | 31 |
| VIP | |
| 好人卡 | |
| 积分 | 58 |
| 经验 | |
| 最后登录 | 2026-8-16 |
| 在线时间 | 971 小时 |
- 梦石
- 0
- 星屑
- 5816
- 在线时间
- 971 小时
- 注册时间
- 2015-2-6
- 回帖
- 123

|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 戏蹑群星斗 于 2016-7-12 09:53 编辑
通行設定「□」拡張段差
效果:
类似于XP的通行
来源:
使用方法:
1: 要为A组原件中需要生效的图块标记上流体属性和地形标志1(可于SQUARE_PASSAGE_TAG处更改)。
2: 给需要生效的地图的注释栏添加上<マップチップサーチ>这个注释
脚本:[fold=脚本]- #===========================================================================
- # ◆ A1 Scripts ◆
- # 通行設定「□」拡張段差(RGSS3)
- #
- # バージョン : 3.20 (2012/01/05)
- # 作者 : A1
- # URL : http://a1tktk.web.fc2.com/
- #---------------------------------------------------------------------------
- # 機能:
- # ・RPGツクール2000にあった 通行設定「□」を再現します
- #---------------------------------------------------------------------------
- # 更新履歴 :2011/12/31 Ver1.00 リリース
- # 2012/01/02 Ver2.00 拡張段差機能追加
- # 2012/01/02 Ver2.01 同じマップに二回目に訪れた時の不具合を修正
- # 2012/01/04 Ver3.00 飛空船対応
- # 2012/01/04 Ver3.00 リージョン設定仕様変更
- # 2012/01/04 Ver3.10 拡張飛空船対応
- # 2012/01/05 Ver3.20 ジャンプ対応
- # 2012/01/06 Ver3.30 拡張飛空船Ver2.00対応
- #---------------------------------------------------------------------------
- # 設置場所
- # A1共通スクリプトより下
- #
- # 必要スクリプト
- # A1共通スクリプトVer3.10以上
- #---------------------------------------------------------------------------
- # 使い方
- # タイルセットの設定
- #
- # 下層チップ(タイルA)で、通行設定「□」にしたいチップの
- # 「茂み」を適用して、地形タグを ■ 設定項目のSQUARE_PASSAGE_TAGに
- # 設定した値にします
- #
- # リージョンの設定
- #
- # 通行設定「□」にした屋根タイル(タイルA4)に乗る場合
- # 登る道(階段など)にリージョン設定をします
- # 設定の仕方は「拡張段差の仕様」を参照ください
- #
- # 拡張プライオリティの設定
- #
- # イベント名に [P(no)PT value] と記述します
- #
- # 例:イベント名[P1PT 4] ※イベントページ1のプライオリティが4になります
- # 例:イベント名[P0PT 7] ※全てのイベントページのプライオリティが7になります
- #
- # マップ設定のメモに <飛空船高度 altitude> と記述
- #
- # 設定した飛空船高度以上のリージョンを持つ座標は通行不可になります
- # また、設定した飛空船高度が高ければ高いほど、高く上昇します
- #
- # マップ設定のメモに <マップチップサーチ> と記述
- #---------------------------------------------------------------------------
- # 拡張段差の仕様
- # ・「現在のプライオリティのリージョン」→「現在のプライオリティ+3のリージョン」
- # の順にリージョンを踏むとイベントのプライオリティが +3 され
- # 通行設定「□」にした屋根タイルに乗れます
- #
- # ・「現在のプライオリティのリージョン」→「現在のプライオリティ-3のリージョン」
- # の順にリージョンを踏むとイベントのプライオリティが -3 され
- # イベントのプライオリティが 2未満になると
- # 通行設定「□」にした屋根タイルの裏に隠れます
- #
- # ・通行設定「□」にしたタイルの上に上層タイル(タイルB~E)を置いても表示されません
- # 通行判定は上層タイルが優先されます
- #
- # ・■ 設定項目の DESABLE_REGION に設定した以上の番号を持つ
- # リージョンを置いた座標は通行設定「□」にしたタイルが適用されず
- # 上層タイル(タイルB~E)に通行設定「☆」が適用されます
- #
- # また、飛空船通行判定や影の高さにおいては
- # DESABLE_REGION に設定した値を引いた値で判定されます
- #
- # ・イベントのプライオリティが3以上の場合
- # 通行設定「☆」のタイルの「☆」効果が適用されず
- # 通常の通行判定となります
- #
- # ・同じプライオリティのイベントと衝突し
- # プライオリティの違うイベントとは衝突しません
- # また、プライオリティの差が ±2 以上の場合、イベントの起動はしません
- #
- # プライオリティ「通常キャラと同じ」は、プライオリティ1ですので
- # プライオリティ4に設定すると1段目で
- # プライオリティ7に設定すると2段目で「通常キャラ」と衝突し、イベント起動します
- #
- # また、飛空船でもプライオリティが同じなら衝突してイベント起動します
- #
- # ・飛空船プライオリティは、着陸する座標のリージョン -1 になります
- # リージョンが 0 ならプライオリティ 0 になります
- #
- # ・飛空船高度は、通過したい段差のプライオリティ +1 がおすすめです
- # 平地なら 2 1段目なら 5 2段目なら 8
- #---------------------------------------------------------------------------
- # 注意事項
- # 当機能を実現するにあたり、マップ読み込み時にマップの全座標・全レイヤーを調べます
- # マップが広いほど処理に時間がかかるので注意です
- #
- # また、当機能が必要ないマップを考慮して
- # マップ設定のメモに <マップチップサーチ> と記述しないと
- # 当機能は効果を発揮しない仕様となっています
- #==============================================================================
- $imported ||= {}
- $imported["A1_SquarePassage"] = true
- if $imported["A1_Common_Script"]
- #==============================================================================
- # ■ 設定項目
- #==============================================================================
- module A1_System::SquarePassageConfig
- #--------------------------------------------------------------------------
- # ○ 通行設定「□」の地形タグ
- #--------------------------------------------------------------------------
- SQUARE_PASSAGE_TAG = 1
- #--------------------------------------------------------------------------
- # ○ 上層チップに通行設定「☆」を適用するリージョン
- # 設定値以上のリージョンに適用されます
- #--------------------------------------------------------------------------
- DESABLE_REGION = 30
- end
- #==============================================================================
- # ■ RPG::Map
- #==============================================================================
- class RPG::Map
- #--------------------------------------------------------------------------
- # ○ 飛空船高度
- #--------------------------------------------------------------------------
- def airship_altitude(name)
- @airship_altitude ||= {}
- @airship_altitude[name] ||= $a1_common.note_data_one(self.note, "#{name}高度", 2).to_i
- return @airship_altitude[name]
- end
- end
- #==============================================================================
- # ■ RPG::Event
- #==============================================================================
- class RPG::Event
- #--------------------------------------------------------------------------
- # ○ プライオリティタイプの設定
- #--------------------------------------------------------------------------
- def setup_pages_priority
- @name.scan(/\[P(\d+)PT[ ](\d+)\]/).each {|info|
- page_no = info[0].to_i
- return change_all_priority_type(info[1].to_i) if page_no == 0
- change_priority_type(@pages[page_no - 1], info[1].to_i)
- }
- end
- #--------------------------------------------------------------------------
- # ○ 全てのプライオリティタイプの設定を変更
- #--------------------------------------------------------------------------
- def change_all_priority_type(value)
- @pages.each {|page| change_priority_type(page, value) }
- end
- #--------------------------------------------------------------------------
- # ○ プライオリティタイプを変更
- #--------------------------------------------------------------------------
- def change_priority_type(page, value)
- return if page == nil
- page.priority_type = value
- end
- end
- #==============================================================================
- # ■ Game_Event
- #------------------------------------------------------------------------------
- # イベントを扱うクラスです。条件判定によるイベントページ切り替えや、並列処理
- # イベント実行などの機能を持っており、Game_Map クラスの内部で使用されます。
- #==============================================================================
- class Game_Event < Game_Character
- #--------------------------------------------------------------------------
- # ☆ オブジェクト初期化
- # event : RPG::Event
- #--------------------------------------------------------------------------
- alias a1_passages_square_ge_initialize initialize
- def initialize(map_id, event)
- event.setup_pages_priority
- a1_passages_square_ge_initialize(map_id, event)
- end
- end
- #==============================================================================
- # ■ Game_Map
- #------------------------------------------------------------------------------
- # マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
- # このクラスのインスタンスは $game_map で参照されます。
- #==============================================================================
- class Game_Map
- #--------------------------------------------------------------------------
- # ○ 定数
- #--------------------------------------------------------------------------
- SQUARE_PASSAGE_TAG = A1_System::SquarePassageConfig::SQUARE_PASSAGE_TAG
- DESABLE_REGION = A1_System::SquarePassageConfig::DESABLE_REGION
- #--------------------------------------------------------------------------
- # ☆ 全マップチップを調べる
- #--------------------------------------------------------------------------
- alias a1_passages_square_map_chip_search map_chip_search
- def map_chip_search
- @change_tile = []
- a1_passages_square_map_chip_search
- @change_tile.each {|id| tileset.flags[id] -= 0x40 }
- end
- #--------------------------------------------------------------------------
- # ☆ 座標に対して処理を行う
- #--------------------------------------------------------------------------
- alias a1_passages_square_map_pos_proc map_pos_proc
- def map_pos_proc(x, y)
- a1_passages_square_map_pos_proc(x, y)
- flag_0 = tileset.flags[tile_id(x, y, 0)]
- flag_1 = tileset.flags[tile_id(x, y, 1)]
- change_passages(x, y, 2)
- return change_passages(x, y, 1) if chg_psg?(flag_1)
- change_passages(x, y, 0) if chg_psg?(flag_0)
- end
- #--------------------------------------------------------------------------
- # ○ 通行設定を変える?
- #--------------------------------------------------------------------------
- def chg_psg?(flag)
- return flag & 0x40 == 0x40 && flag >> 12 == SQUARE_PASSAGE_TAG
- end
- #--------------------------------------------------------------------------
- # ○ 通行設定「□」判定
- #--------------------------------------------------------------------------
- def passages_square?(x, y)
- return tileset.ex_flags[tile_id(x, y, 2)] == 0x0001
- end
- #--------------------------------------------------------------------------
- # ○ 上段通常キャラの通行可能判定
- # d : 方向(2,4,6,8)
- # 指定された座標のタイルが指定方向に通行可能かを判定する。
- #--------------------------------------------------------------------------
- def passable_ex?(x, y, d)
- bit = (1 << (d / 2 - 1)) & 0x0f
- return true if check_passage_ex(x, y, bit)
- return false
- end
- #--------------------------------------------------------------------------
- # ○ 上段用通行チェック
- # bit : 調べる通行禁止ビット
- #--------------------------------------------------------------------------
- def check_passage_ex(x, y, bit)
- tile_events_xy(x, y).collect {|ev| ev.tile_id }.each {|tile_id|
- flag = tileset.flags[tile_id]
- return false if flag & bit == bit # [×] : 通行不可
- }
- return false if tileset.flags[@map.data[x, y, 2]] & bit == bit
- return false if tileset.flags[@map.data[x, y, 0]] & bit == bit
- return true # 通行可
- end
- #--------------------------------------------------------------------------
- # ☆ 通行チェック
- # bit : 調べる通行禁止ビット
- #--------------------------------------------------------------------------
- alias a1_passages_square_gm_check_passage check_passage
- def check_passage(x, y, bit)
- ret = check_passage_square(x, y, bit)
- return a1_passages_square_gm_check_passage(x, y, bit) if ret == nil
- return ret
- end
- #--------------------------------------------------------------------------
- # ○ 通行設定「□」の通行チェック
- #--------------------------------------------------------------------------
- def check_passage_square(x, y, bit)
- return nil unless passages_square?(x, y) && !passages_square?(x, y - 1)
- return true if a1_passages_square_gm_check_passage(x, y, bit)
- return false if tileset.flags[@map.data[x, y, 1]] & bit == bit
- return true if @map.data[x, y, 1] > 0 && tileset.flags[@map.data[x, y, 1]] & bit == 0
- return a1_passages_square_gm_check_passage(x, y - 1, bit)
- end
- #--------------------------------------------------------------------------
- # ☆ 飛行船の着陸可能判定
- #--------------------------------------------------------------------------
- alias a1_passages_square_gm_airship_land_ok? airship_land_ok?
- def airship_land_ok?(x, y)
- return true if a1_passages_square_gm_airship_land_ok?(x, y)
- return passages_square?(x, y)
- end
- #--------------------------------------------------------------------------
- # ○ 通行設定に☆を付与
- #--------------------------------------------------------------------------
- def change_passages(x, y, z)
- id = tile_id(x, y, 2)
- region = region_id(x, y)
- return change_upper_passages(id) if region > DESABLE_REGION
- return if z == 2
- tmp = @map.data[x, y, 2]
- @map.data[x, y, 2] = @map.data[x, y, z]
- if z == 1
- @map.data[x, y, 0] = @map.data[x, y, z]
- @map.data[x, y, z] = tmp
- else
- @map.data[x, y, 1] = tmp
- end
- id = tile_id(x, y, 2)
- return if tileset.ex_flags[id] == 0x0001
- tileset.flags[id] += 0x10
- tileset.ex_flags[id] = 0x0001
- @change_tile.push(id)
- end
- #--------------------------------------------------------------------------
- # ○ 通行設定に☆を付与(上層チップ)
- #--------------------------------------------------------------------------
- def change_upper_passages(id)
- return if tileset.ex_flags[id] == 0x0002
- tileset.ex_flags[id] = 0x0002
- tileset.flags[id] += 0x10
- end
- #--------------------------------------------------------------------------
- # ○ 通行設定「□」にしないリージョンを取得
- #--------------------------------------------------------------------------
- def map_z_region(x, y)
- region = region_id(x, y)
- region -= DESABLE_REGION if region > DESABLE_REGION
- return region
- end
- #--------------------------------------------------------------------------
- # ○ 飛空船の通行可能判定
- #--------------------------------------------------------------------------
- def airship_passable?(x, y)
- region = map_z_region(x, y)
- region < $game_player.airship_priority_type
- end
- #--------------------------------------------------------------------------
- # ○ 飛空船高度
- #--------------------------------------------------------------------------
- def airship_altitude(name)
- @map.airship_altitude(name)
- end
- end
- #==============================================================================
- # ■ Game_CharacterBase
- #------------------------------------------------------------------------------
- # キャラクターを扱う基本のクラスです。全てのキャラクターに共通する、座標やグ
- # ラフィックなどの基本的な情報を保持します。
- #==============================================================================
- class Game_CharacterBase
- #--------------------------------------------------------------------------
- # ☆ 非公開メンバ変数の初期化
- #--------------------------------------------------------------------------
- alias a1_passages_square_gcb_init_private_members init_private_members
- def init_private_members
- a1_passages_square_gcb_init_private_members
- @screen_z_ex = nil
- @first_region = 0
- end
- #--------------------------------------------------------------------------
- # ☆ 画面 Z 座標の取得
- #--------------------------------------------------------------------------
- alias a1_passages_square_gcb_screen_z screen_z
- def screen_z
- return a1_passages_square_gcb_screen_z unless @screen_z_ex
- return @screen_z_ex
- end
- #--------------------------------------------------------------------------
- # ☆ まっすぐに移動
- # d : 方向(2,4,6,8)
- # turn_ok : その場での向き変更を許可
- #--------------------------------------------------------------------------
- alias a1_passages_square_gcb_move_straight move_straight
- def move_straight(d, turn_ok = true)
- a1_passages_square_gcb_move_straight(d, turn_ok)
- if @move_succeed
- region = $game_map.map_z_region(@x, @y)
- @first_region = region if first_region == 0 && region > 0
- @next_region = region if first_region > 0 && region > 0
- reset_region if region == 0
- priority = @priority_type
- @priority_type += 3 if priority_up?
- @priority_type -= 3 if priority_down?
- @first_region = @next_region
- end
- end
- #--------------------------------------------------------------------------
- # ○ プライオリティ上げる?
- #--------------------------------------------------------------------------
- def priority_up?
- @first_region == @priority_type && @next_region == @priority_type + 3
- end
- #--------------------------------------------------------------------------
- # ○ プライオリティ下げる?
- #--------------------------------------------------------------------------
- def priority_down?
- @first_region == @priority_type && @next_region == @priority_type - 3
- end
- #--------------------------------------------------------------------------
- # ○ 踏んだリージョンリセット
- #--------------------------------------------------------------------------
- def reset_region
- @first_region = 0
- @next_region = 0
- end
- #--------------------------------------------------------------------------
- # ○ 最初に踏んだリージョン
- #--------------------------------------------------------------------------
- def first_region
- @first_region ||= 0
- return @first_region
- end
- #--------------------------------------------------------------------------
- # ○ 次に踏んだリージョン
- #--------------------------------------------------------------------------
- def next_region
- @next_region ||= 0
- return @next_region
- end
- #--------------------------------------------------------------------------
- # ☆ マップ通行可能判定
- # d : 方向(2,4,6,8)
- #--------------------------------------------------------------------------
- alias a1_passages_square_gcb_map_passable? map_passable?
- def map_passable?(x, y, d)
- return a1_passages_square_gcb_map_passable?(x, y, d) if @priority_type < 2
- return $game_map.passable_ex?(x, y, d)
- end
- #--------------------------------------------------------------------------
- # ★ イベントとの衝突判定
- #--------------------------------------------------------------------------
- def collide_with_events?(x, y)
- $game_map.events_xy_nt(x, y).any? do |event|
- chk_collide_priority(event, x, y) || self.is_a?(Game_Event)
- end
- end
- #--------------------------------------------------------------------------
- # ○ イベントとのプライオリティ差における衝突判定
- #--------------------------------------------------------------------------
- def chk_collide_priority(event, x, y)
- return true if @priority_type == event.priority_type
- my_region = $game_map.map_z_region(@x, @y)
- ev_region = $game_map.map_z_region(x, y)
- return true if (my_region - ev_region).abs == 3 && (@priority_type - event.priority_type).abs == 3
- return false
- end
- #--------------------------------------------------------------------------
- # ○ プライオリティタイプの設定
- #--------------------------------------------------------------------------
- def set_priority_type
- region = $game_map.map_z_region(@x, @y)
- priority = region
- priority = 1 if priority == 0
- return priority
- end
- #--------------------------------------------------------------------------
- # ☆ ジャンプ時の更新
- #--------------------------------------------------------------------------
- alias a1_passages_square_gcb_update_jump update_jump
- def update_jump
- a1_passages_square_gcb_update_jump
- @priority_type = set_priority_type if @jump_count == 0
- end
- end
- #==============================================================================
- # ■ Game_Player
- #------------------------------------------------------------------------------
- # プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
- # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
- #==============================================================================
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # ★ マップイベントの起動
- # triggers : トリガーの配列
- # normal : プライオリティ[通常キャラと同じ]かそれ以外か
- #--------------------------------------------------------------------------
- def start_map_event(x, y, triggers, normal)
- $game_map.events_xy(x, y).each do |event|
- next unless chk_event_priority(event, normal)
- event.start if event.trigger_in?(triggers)
- end
- end
- #--------------------------------------------------------------------------
- # ○ マップイベントの起動のプライオリティチェック
- #--------------------------------------------------------------------------
- def chk_event_priority(event, normal)
- return true if normal && chk_collide_priority(event, event.x, event.y)
- return false if (@priority_type - event.priority_type).abs > 1
- return true
- end
- #--------------------------------------------------------------------------
- # ☆ マップ通行可能判定
- # d : 方向(2,4,6,8)
- #--------------------------------------------------------------------------
- alias a1_ex_priority_gp_map_passable? map_passable?
- def map_passable?(x, y, d)
- return a1_ex_priority_gp_map_passable?(x, y, d) unless @vehicle_type == :airship
- return $game_map.airship_passable?(x, y)
- end
- #--------------------------------------------------------------------------
- # ☆ 乗り物に乗る
- # 現在乗り物に乗っていないことが前提。
- #--------------------------------------------------------------------------
- alias a1_ex_priority_gp_get_on_vehicle get_on_vehicle
- def get_on_vehicle
- a1_ex_priority_gp_get_on_vehicle
- return cancel_airship unless get_on_airship? if @vehicle_type == :airship
- @priority_type = airship_priority_type if @vehicle_type == :airship
- end
- #--------------------------------------------------------------------------
- # ○ 飛空船に乗るのをキャンセル
- #--------------------------------------------------------------------------
- def cancel_airship
- @vehicle_type = :walk
- @vehicle_getting_on = false
- @followers.gathering = false
- end
- #--------------------------------------------------------------------------
- # ○ 飛空船に乗れる?
- #--------------------------------------------------------------------------
- def get_on_airship?
- (@priority_type - $game_map.airship.priority_type).abs < 2
- end
- #--------------------------------------------------------------------------
- # ☆ 乗り物から降りる
- # 現在乗り物に乗っていることが前提。
- #--------------------------------------------------------------------------
- alias a1_ex_priority_gp_get_off_vehicle get_off_vehicle
- def get_off_vehicle
- @priority_type = set_priority_type if @vehicle_type == :airship && vehicle.land_ok?(@x, @y, @direction)
- a1_ex_priority_gp_get_off_vehicle
- end
- #--------------------------------------------------------------------------
- # ○ 飛空船のプライオリティタイプの取得
- #--------------------------------------------------------------------------
- def airship_priority_type
- vehicle.airship_priority_type
- end
- #--------------------------------------------------------------------------
- # ○ 飛空船のプライオリティタイプの設定
- #--------------------------------------------------------------------------
- def airship_priority_type=(priority_type)
- vehicle.airship_priority_type = priority_type
- end
- #--------------------------------------------------------------------------
- # ☆ 乗り物に乗る動作の更新
- #--------------------------------------------------------------------------
- alias a1_ex_priority_gp_update_vehicle_get_on update_vehicle_get_on
- def update_vehicle_get_on
- a1_ex_priority_gp_update_vehicle_get_on
- @through = false if in_airship?
- end
- end
- #==============================================================================
- # ■ Game_Vehicle
- #------------------------------------------------------------------------------
- # 乗り物を扱うクラスです。このクラスは Game_Map クラスの内部で使用されます。
- # 現在のマップに乗り物がないときは、マップ座標 (-1,-1) に設定されます。
- #==============================================================================
- class Game_Vehicle < Game_Character
- #--------------------------------------------------------------------------
- # ● 公開インスタンス変数
- #--------------------------------------------------------------------------
- attr_accessor :airship_priority_type
- #--------------------------------------------------------------------------
- # ☆ オブジェクト初期化
- # type : 乗り物タイプ(:boat, :ship, :airship)
- #--------------------------------------------------------------------------
- alias a1_ex_priority_gv_initialize initialize
- def initialize(type)
- @get_off_now = false
- @airship_priority_type = 2
- a1_ex_priority_gv_initialize(type)
- end
- #--------------------------------------------------------------------------
- # ☆ リフレッシュ
- #--------------------------------------------------------------------------
- alias a1_ex_priority_gv_refresh refresh
- def refresh
- @ex_key = "飛空船" if @type == :airship && !@ex_key
- @airship_priority_type = $game_map.airship_altitude(@ex_key)
- a1_ex_priority_gv_refresh
- @priority_type = @driving ? @airship_priority_type : set_priority_type if @type == :airship
- end
- #--------------------------------------------------------------------------
- # ○ 乗り物のプライオリティタイプ設定
- #--------------------------------------------------------------------------
- def set_priority_type
- priority = $game_map.map_z_region(@x, @y)
- priority -= 1 if @type == :airship
- priority = 0 if priority < 0
- @get_off_now = false
- return priority
- end
- #--------------------------------------------------------------------------
- # ★ 飛行船が飛ぶ高さを取得
- #--------------------------------------------------------------------------
- def max_altitude
- 16 * @airship_priority_type
- end
- #--------------------------------------------------------------------------
- # ☆ 乗り物から降りる
- #--------------------------------------------------------------------------
- alias a1_ex_priority_gv_get_off get_off
- def get_off
- a1_ex_priority_gv_get_off
- @get_off_now = true if @type == :airship
- end
- #--------------------------------------------------------------------------
- # ☆ 飛行船の高度を更新
- #--------------------------------------------------------------------------
- alias a1_ex_priority_gv_update_airship_altitude update_airship_altitude
- def update_airship_altitude
- a1_ex_priority_gv_update_airship_altitude
- @priority_type = @airship_priority_type if @altitude > 0
- @priority_type = set_priority_type if @altitude == 0 && @get_off_now
- end
- #--------------------------------------------------------------------------
- # ☆ 接岸/着陸可能判定
- # d : 方向(2,4,6,8)
- #--------------------------------------------------------------------------
- alias a1_ex_priority_gv_land_ok? land_ok?
- def land_ok?(x, y, d)
- ret = a1_ex_priority_gv_land_ok?(x, y, d)
- return ret unless @type == :airship
- return true if ret
- region = $game_map.map_z_region(x, y)
- events = $game_map.events_xy(x, y)
- events.each {|event| return true unless check_region_priority(region, event) }
- return ret
- end
- #--------------------------------------------------------------------------
- # ○ リージョンプライオリティのチェック
- #--------------------------------------------------------------------------
- def check_region_priority(priority, event)
- priority += 1 if priority == 0
- (priority - event.priority_type).abs < 2
- end
- end
- #==============================================================================
- # ■ Spriteset_Map
- #------------------------------------------------------------------------------
- # マップ画面のスプライトやタイルマップなどをまとめたクラスです。このクラスは
- # Scene_Map クラスの内部で使用されます。
- #==============================================================================
- class Spriteset_Map
- #--------------------------------------------------------------------------
- # ☆ 飛行船の影スプライトの作成
- #--------------------------------------------------------------------------
- alias a1_ex_priority_spm_create_shadow create_shadow
- def create_shadow
- a1_ex_priority_spm_create_shadow
- airship = $game_map.airship
- @shadow_sprite.z = airship.airship_priority_type * 100 - 20
- end
- #--------------------------------------------------------------------------
- # ☆ 飛行船の影スプライトの更新
- #--------------------------------------------------------------------------
- alias a1_ex_priority_spm_update_shadow update_shadow
- def update_shadow
- a1_ex_priority_spm_update_shadow
- airship = $game_map.airship
- region = $game_map.map_z_region(airship.x, airship.y)
- return if region < 1
- map_height = (region / 3 + 1) * 8
- @shadow_sprite.y = airship.screen_y + (airship.altitude - map_height)
- end
- end
- #==============================================================================
- # ■ Game_Followers
- #------------------------------------------------------------------------------
- # フォロワーの配列のラッパーです。このクラスは Game_Player クラスの内部で使
- # 用されます。
- #==============================================================================
- class Game_Followers
- #--------------------------------------------------------------------------
- # ○ 集合中フラグの設定
- #--------------------------------------------------------------------------
- def gathering=(flag)
- @gathering = flag
- end
- end
- end
复制代码
需要A1共通処理
- # ===========================================================================
- # ◆ A1 Scripts ◆
- # A1共通処理(RGSS2/RGSS3共用)
- #
- # バージョン : 4.50 (2012/01/26)
- # 作者 : A1
- # URL : http://a1tktk.web.fc2.com/
- # ---------------------------------------------------------------------------
- # 更新履歴 :2011/11/11 Ver1.00 新規作成
- # :2011/12/22 Ver2.00 RGSS3用と同様の処理に変更
- # :2011/12/30 Ver2.10 RGSS3用メソッドを追加
- # :2011/12/30 Ver3.00 RGSS3用共通処理と統合
- # :2011/12/31 Ver3.10 マップチップサーチの仕様を変更
- # :2011/12/31 Ver3.10 拡張通行判定を追加
- # :2012/01/01 Ver3.11 クラス名の取得処理を追加
- # :2012/01/02 Ver3.20 配列を考慮したsplit処理を追加
- # :2012/01/02 Ver3.20 配列の全ての要素を整数にする処理を追加
- # :2012/01/02 Ver3.30 注釈の処理の仕様を変更
- # :2012/01/02 Ver3.40 「前のイベントコマンドの取得」を追加
- # :2012/01/03 Ver3.50 「フレーム更新」を追加
- # :2012/01/04 Ver3.60 「指定のウィンドウが開いている間ウェイト」追加
- # :2012/01/04 Ver3.70 RGSS2用処理見直し
- # :2012/01/05 Ver3.80 注釈文字列にエスケープコマンド対応
- # :2012/01/05 Ver3.80 多次元配列を考慮したsplit処理を追加
- # :2012/01/05 Ver3.80 注釈にスクリプト処理機能を追加
- # :2012/01/10 Ver3.90 文字縁取り描画を追加
- # :2012/01/11 Ver4.00 テキストビットマップのキャッシュを追加
- # :2012/01/13 Ver4.01 「タイルセットの変更」ができなくなる不具合を修正
- # :2012/01/14 Ver4.10 split処理を強化
- # :2012/01/14 Ver4.20 空白を含む注釈コマンドに対応
- # :2012/01/14 Ver4.21 split処理の不具合を修正
- # :2012/01/21 Ver4.30 メモの内容を取得する関数を追加
- # :2012/01/24 Ver4.40 メモの内容を取得する関数を追加
- # :2012/01/24 Ver4.50 メモの内容を取得する関数を追加
- # ---------------------------------------------------------------------------
- # 設置場所
- # なるべく上の方
- #
- # 必要スクリプト
- # なし
- #==============================================================================
- $imported = {} if $imported == nil
- $imported["A1_Common_Script"] = 4.50
- #==============================================================================
- # ■ Kernel
- #==============================================================================
- module Kernel
- #--------------------------------------------------------------------------
- # ○ RGSSのバージョン取得
- #--------------------------------------------------------------------------
- def rgss_version
- return 3 if defined? Graphics.play_movie
- return 2 if defined? Graphics.resize_screen
- return 1
- end
- #--------------------------------------------------------------------------
- # ○ コモンスクリプトのバージョン取得
- #--------------------------------------------------------------------------
- def common_version
- $imported["A1_Common_Script"]
- end
- #--------------------------------------------------------------------------
- # ○ コモンスクリプトのバージョンが古い
- #--------------------------------------------------------------------------
- def old_common_script(script_name, version)
- msgbox("#{script_name}にはA1共通スクリプトVer#{version}以上が必要です")
- end
- end
- #==============================================================================
- # ■ A1_System
- #==============================================================================
- module A1_System
- end
- #==============================================================================
- # ■ A1_System::CommonModule
- #==============================================================================
- class A1_System::CommonModule
- #--------------------------------------------------------------------------
- # ○ 定数
- #--------------------------------------------------------------------------
- TWOBYTE_LIST = {
- " " => " ",
- "=" => "=",
- ":" => ":"
- }
- #--------------------------------------------------------------------------
- # ○ オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize
- define_command
- end
- #--------------------------------------------------------------------------
- # ○ 変換対象の全角文字を半角に置換
- #--------------------------------------------------------------------------
- def replace_twobyte(str)
- for key in TWOBYTE_LIST.keys
- str.gsub!(key) {TWOBYTE_LIST[key]}
- end
- return str
- end
- #--------------------------------------------------------------------------
- # ○ マイナスが含まれている文字列を数値にする
- #--------------------------------------------------------------------------
- def minus_to_i(s)
- if s[0,0] == "-"
- s.gsub!("-","")
- return s.to_i * -1
- else
- return s.to_i
- end
- end
- #--------------------------------------------------------------------------
- # ○ ミリ秒単位の現在時間
- #--------------------------------------------------------------------------
- def now_usec
- now = Time.now
- hour = now.hour * 60 * 60
- min = now.min * 60
- sec = now.sec
- msec = (now.usec / 1000.0).round
- return (hour + min + sec) * 1000 + msec
- end
- #--------------------------------------------------------------------------
- # ○ イベントリストの作成
- #--------------------------------------------------------------------------
- def create_event_list(code, indent, parameters)
- list = RPG::EventCommand.new
- list.code = code
- list.indent = indent
- list.parameters = parameters
- return list
- end
- #--------------------------------------------------------------------------
- # ○ メソッド呼び出し
- #--------------------------------------------------------------------------
- def send_method(method_name)
- return send(method_name) if respond_to?(method_name)
- end
- #--------------------------------------------------------------------------
- # ○ オブジェクトの型を判断してStringならエンコード
- #--------------------------------------------------------------------------
- def encoding_string(obj)
- obj.force_encoding("UTF-8") if obj.is_a?(String)
- return obj
- end
- #--------------------------------------------------------------------------
- # ○ メモの内容から必要な情報を取得
- #--------------------------------------------------------------------------
- def note_data(note, key)
- result = []
- note.each_line {|line|
- next unless line =~ /<#{key}[ ]?(.*)>/
- return true if $1.empty?
- data = $a1_common.replace_twobyte($1).split(" ")
- for st in data
- result.push(st)
- end
- }
- return false if result.empty?
- return result
- end
- #--------------------------------------------------------------------------
- # ○ メモの内容からハッシュを作成
- #--------------------------------------------------------------------------
- def note_data_hash(note, key, data_default = nil, default = {}, ret = {})
- list = note_data_split(note, key)
- return default if list.empty?
- list.each {|data| ret[data[0]] = data[1] ? data[1] : data_default }
- return ret
- end
- #--------------------------------------------------------------------------
- # ○ メモの内容からカンマ区切りの多元配列を取得
- #--------------------------------------------------------------------------
- def note_data_split(note, key, default = [], ret = [])
- data = note_data(note, key)
- return default unless data.is_a?(Array)
- data.each {|str| ret.push(convert_integer_from_array(split_array(str)))}
- return ret
- end
- #--------------------------------------------------------------------------
- # ○ 配列の内容から数値があれば変換
- #--------------------------------------------------------------------------
- def convert_integer_from_array(data, ret = [])
- data.each {|str| ret.push(convert_integer(str))}
- return ret
- end
- #--------------------------------------------------------------------------
- # ○ 数値があれば変換
- #--------------------------------------------------------------------------
- def convert_integer(str)
- return $1.to_i if str =~ /(^[-]?[0-9]+$)/
- str.is_a?(Array) ? convert_integer_from_array(str) : str
- end
- #--------------------------------------------------------------------------
- # ○ メモの内容から単項目の数値を取得
- #--------------------------------------------------------------------------
- def note_data_one_value(note, key, default)
- data = note_data(note, key)
- return data[0].to_i if data.is_a?(Array)
- return default
- end
- #--------------------------------------------------------------------------
- # ○ メモの内容から単項目を取得
- #--------------------------------------------------------------------------
- def note_data_one(note, key, default)
- data = note_data(note, key)
- return data[0] if data.is_a?(Array)
- return default
- end
- #--------------------------------------------------------------------------
- # ○ メモの内容からカンマ区切りの文字列を取得
- #--------------------------------------------------------------------------
- def note_data_array_str(note, key, default)
- data = note_data(note, key)
- return data[0].split(",") if data.is_a?(Array)
- return default
- end
- #--------------------------------------------------------------------------
- # ○ メモの内容からカンマ区切りの数値を取得
- #--------------------------------------------------------------------------
- def note_data_array_value(note, key, default)
- data = note_data(note, key)
- return default unless data.is_a?(Array)
- return convert_integer_from_array(split_array(data[0]))
- end
- #--------------------------------------------------------------------------
- # ○ カンマ区切りの文字列メモを変換
- #--------------------------------------------------------------------------
- def note_data_array(note, key, type, default = nil, through = true)
- ret = []
- default.each {|dat| ret.push(dat)} if default != nil
-
- data = note_data(note, key)
- return ret unless data.is_a?(Array)
-
- data = data[0].split(",")
- for d in data
- next if ret.include?(d) if through
- ret.push(d.to_i) if type.is_a?(Integer)
- ret.push(d) if type.is_a?(String)
- end
- return ret
- end
- #--------------------------------------------------------------------------
- # ○ ディレクトリの作成
- #--------------------------------------------------------------------------
- def make_directory(dir_name)
- Dir::mkdir(dir_name) unless FileTest.exist?(dir_name)
- end
- #--------------------------------------------------------------------------
- # ○ コマンドリスト
- #--------------------------------------------------------------------------
- def make_command(command, src = "", dect = "")
- src.gsub!("/","\")
- dect.gsub!("/","\")
- cmd = "#{command} "#{src}" "#{dect}""
- return cmd
- end
- #--------------------------------------------------------------------------
- # ○ 素材の拡張子を取得
- #--------------------------------------------------------------------------
- def material_ext(directory, file, direct = false)
- exts = []
- exts = [".png",".bmp",".jpg"] if directory =~ /(.*)Graphics\/(.*)/
- exts = [".mid",".ogg",".wav",".mp3",".wma"] if directory =~ /(.*)Audio(.*)/
-
- find_file = sprintf("%s%s", directory, file) unless direct
- find_file = file if direct
-
- for ext in exts
- return ext if File.exist?(sprintf("%s%s", find_file, ext))
- end
- return nil
- end
- #--------------------------------------------------------------------------
- # ○ 素材が存在するかチェック
- #--------------------------------------------------------------------------
- def material_exist?(directory, file, direct = false)
- return false if material_ext(directory, file, direct) == nil
- return true
- end
- #--------------------------------------------------------------------------
- # ○ ファイルコピー
- #--------------------------------------------------------------------------
- def copy_file(src, dest)
- srcFile = File.open( src, "rb" )
- dstFile = File.open( dest, "wb" )
- dstFile.write( srcFile.read )
- srcFile.close
- dstFile.close
- end
- #--------------------------------------------------------------------------
- # ○ ファイルの存在を確認してファイルコピー
- #--------------------------------------------------------------------------
- def material_copy(src, dest, directory)
- ext = material_ext(directory, src, true)
- copy_file( src + ext, dest + ext ) if ext != nil
- end
- #--------------------------------------------------------------------------
- # ○ 配列からAudioを作成
- #--------------------------------------------------------------------------
- def set_audio(sound, kind)
- case kind
- when "BGM"; audio = RPG::BGM.new
- when "BGS"; audio = RPG::BGS.new
- when "ME"; audio = RPG::ME.new
- when "SE"; audio = RPG::SE.new
- end
- audio.name = sound[0]
- audio.volume = sound[1]
- audio.pitch = sound[2]
- return audio
- end
- #--------------------------------------------------------------------------
- # ○ 既に準拠識別子を持っているかチェック
- #--------------------------------------------------------------------------
- def chk_rtp(file_name, default)
- return "" if file_name =~ /^VX_.*/
- return "" if file_name =~ /^XP_.*/
- return "" if file_name =~ /^2000_.*/
- return "" if file_name =~ /^2003_.*/
- return default
- end
- #--------------------------------------------------------------------------
- # ○ 先頭の $ を切り出す
- #--------------------------------------------------------------------------
- def one_character(file_name)
- return file_name unless file_name[0] == "$"
- tmp = file_name.clone
- tmp[0] = ""
- return tmp
- end
- #--------------------------------------------------------------------------
- # ○ 配列を入れ替える
- #--------------------------------------------------------------------------
- def change_array(array, index1, index2)
- tmp = array[index1]
- array[index1] = array[index2]
- array[index2] = tmp
- return array
- end
- #--------------------------------------------------------------------------
- # ○ 移動ルートの作成
- #--------------------------------------------------------------------------
- def create_move_route(repeat, skippable, wait, list)
- move_route = RPG::MoveRoute.new
- move_route.repeat = repeat
- move_route.skippable = skippable
- move_route.wait = wait
- move_route.list = list
- return move_route
- end
- #--------------------------------------------------------------------------
- # ○ 移動ルートコマンドの作成
- #--------------------------------------------------------------------------
- def create_move_command(code, parameters)
- list = RPG::MoveCommand.new
- list.code = code
- list.parameters = parameters
- return list
- end
- #--------------------------------------------------------------------------
- # ○ インタプリタ起動用リストの作成
- #--------------------------------------------------------------------------
- def create_list(code, indent, parameters)
- list = RPG::EventCommand.new
- list.code = code
- list.indent = indent
- list.parameters = parameters
- return list
- end
- #--------------------------------------------------------------------------
- # ○ クラス名の取得
- #--------------------------------------------------------------------------
- def class_name(class_instance)
- return class_instance.to_s.split(":")[0].gsub("#<","")
- end
- #--------------------------------------------------------------------------
- # ○ 配列を考慮したsplit
- #--------------------------------------------------------------------------
- def split_array(str)
- str = convert_escape_characters(str)
-
- ret = []
- tmp_array = str.split(",")
-
- return strip_array_str(tmp_array) unless str.include?("[")
- tmp_str = ""
- tmp_array.each {|s|
- if char_in_str(s, "[", "]") && tmp_str.empty?
- ret.push(s) unless s =~ /^\[/
- ret.push([s[1...s.size-1]]) if s =~ /^\[/
- else
- tmp_str = "#{tmp_str}#{s},"
- if char_in_str(tmp_str, "[", "]")
- unless tmp_str =~ /^\[/
- ret.push(tmp_str[0...tmp_str.size-1])
- tmp_str = ""
- else
- tmp_str = tmp_str[1...tmp_str.size-2]
- tmp_str = split_array(tmp_str) if tmp_str.include?("[")
- tmp_str = tmp_str.split(",") if tmp_str.include?(",")
- ret.push(tmp_str) if tmp_str.is_a?(Array)
- ret.push([tmp_str]) if !tmp_str.is_a?(Array)
- tmp_str = ""
- end
- end
- end
- }
- return strip_array_str(ret)
- end
- #--------------------------------------------------------------------------
- # ○ 配列の中の文字列の先頭と末尾の空白を除去
- #--------------------------------------------------------------------------
- def strip_array_str(array, ret = [])
- array.each {|str| ret.push(strip_array_str(str)) if str.is_a?(Array); next if str.is_a?(Array); ret.push(str.strip) }
- return ret
- end
- #--------------------------------------------------------------------------
- # ○ 文字列の中に文字が何文字含まれているか調べて同数ならtrueを返す
- #--------------------------------------------------------------------------
- def char_in_str(str, c1, c2)
- num1 = 0
- num2 = 0
- (0...str.size).each {|i| num1 += 1 if str[i] == c1; num2 += 1 if str[i] == c2 }
- return num1 == num2
- end
- #--------------------------------------------------------------------------
- # ○ 制御文字の変換
- #--------------------------------------------------------------------------
- def convert_escape_characters(text)
- result = text.to_s.clone
- result.gsub!(/\\/) { "\e" }
- result.gsub!(/\e\e/) { "\" }
- result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
- result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
- result.gsub!(/\eN\[(\d+)\]/i) { actor_name($1.to_i) }
- result.gsub!(/\eP\[(\d+)\]/i) { party_member_name($1.to_i) }
- result.gsub!(/\eG/i) { Vocab::currency_unit }
- loop { result = result.sub(/<s>(.+?)<\/s>/i) { eval($1) }; break unless $1 }
- result
- end
- #--------------------------------------------------------------------------
- # ○ アクター n 番の名前を取得
- #--------------------------------------------------------------------------
- def actor_name(n)
- actor = n >= 1 ? $game_actors[n] : nil
- actor ? actor.name : ""
- end
- #--------------------------------------------------------------------------
- # ○ パーティメンバー n 番の名前を取得
- #--------------------------------------------------------------------------
- def party_member_name(n)
- actor = n >= 1 ? $game_party.members[n - 1] : nil
- actor ? actor.name : ""
- end
- #--------------------------------------------------------------------------
- # ○ 配列を全て整数にする
- #--------------------------------------------------------------------------
- def params_to_i(params)
- ret = []
- params.each {|param| ret.push(param.to_i)}
- return ret
- end
- #--------------------------------------------------------------------------
- # ○ 注釈コマンド定義
- #--------------------------------------------------------------------------
- def define_command
- @cmd_108 = {}
- end
- #--------------------------------------------------------------------------
- # ○ 注釈コマンド定義取得
- #--------------------------------------------------------------------------
- def cmd_108
- @cmd_108
- end
- #--------------------------------------------------------------------------
- # ○ フレーム更新
- #--------------------------------------------------------------------------
- def update
- end
- #--------------------------------------------------------------------------
- # ○ 文字の幅と高さを取得
- #--------------------------------------------------------------------------
- def text_size(font, size, text)
- bitmap = Cache.system("")
- bitmap.font.name = font
- bitmap.font.size = size
- tw = bitmap.text_size(text).width
- th = bitmap.text_size(text).height
- bitmap.dispose
- return [tw, th]
- end
- #--------------------------------------------------------------------------
- # ○ 文字の幅を取得
- #--------------------------------------------------------------------------
- def text_width(font, text)
- texts = text.split("\n")
- @max_width = 0
- texts.each {|text|
- width = text_size(font.name, font.size, text)[0]
- @max_width = @max_width < width ? width : @max_width
- }
- return @max_width
- end
- end
- #==============================================================================
- # ◆ RGSS3用処理
- #==============================================================================
- if rgss_version == 3
- #==============================================================================
- # ■ RPG::Tileset
- #==============================================================================
- class RPG::Tileset
- #--------------------------------------------------------------------------
- # ○ 拡張通行判定
- #--------------------------------------------------------------------------
- def ex_flags
- @ex_flags ||= Table.new(8192)
- return @ex_flags
- end
- #--------------------------------------------------------------------------
- # ○ 拡張通行判定初期化
- #--------------------------------------------------------------------------
- def init_ex_flags
- @ex_flags = Table.new(8192)
- end
- end
- #==============================================================================
- # ■ Game_Interpreter
- #------------------------------------------------------------------------------
- # イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
- # Game_Troop クラス、Game_Event クラスの内部で使用されます。
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # ☆ オブジェクト初期化
- # depth : ネストの深さ
- #--------------------------------------------------------------------------
- alias a1_common_gi_rgss3_initialize initialize
- def initialize(depth = 0, sub_interpreter = false)
- @sub_interpreter = sub_interpreter
- a1_common_gi_rgss3_initialize(depth)
- end
- #--------------------------------------------------------------------------
- # ☆ メッセージ表示がビジー状態の間ウェイト
- #--------------------------------------------------------------------------
- alias a1_common_gi_wait_for_message wait_for_message
- def wait_for_message
- return if @sub_interpreter
- a1_common_gi_wait_for_message
- end
- end
- #==============================================================================
- # ■ Window_Message
- #------------------------------------------------------------------------------
- # 文章表示に使うメッセージウィンドウです。
- #==============================================================================
- class Window_Message < Window_Base
- #--------------------------------------------------------------------------
- # ☆ 通常文字の処理
- #--------------------------------------------------------------------------
- alias a1_common_wm_process_normal_character process_normal_character
- def process_normal_character(c, pos)
- wait_for_one_character_before
- a1_common_wm_process_normal_character(c, pos)
- end
- #--------------------------------------------------------------------------
- # ○ 一文字出力前のウェイト
- #--------------------------------------------------------------------------
- def wait_for_one_character_before
- end
- end
- #==============================================================================
- # ■ RPG::Map
- #==============================================================================
- class RPG::Map
- #--------------------------------------------------------------------------
- # ○ マップチップを調べるか判定する
- #--------------------------------------------------------------------------
- def search_map_chip?
- return true if $a1_common.note_data(self.note, "マップチップサーチ")
- return false
- end
- end
- #==============================================================================
- # ■ Game_Map
- #------------------------------------------------------------------------------
- # マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
- # このクラスのインスタンスは $game_map で参照されます。
- #==============================================================================
- class Game_Map
- #--------------------------------------------------------------------------
- # ☆ セットアップ
- #--------------------------------------------------------------------------
- alias a1_common_gm_setup setup
- def setup(map_id)
- a1_common_gm_setup(map_id)
- setup_tileset
- map_chip_search if search_map_chip?
- end
- #--------------------------------------------------------------------------
- # ★ タイルセットの取得
- #--------------------------------------------------------------------------
- def tileset
- setup_tileset unless @tileset && @now_tileset_id == @tileset_id
- return @tileset
- end
- #--------------------------------------------------------------------------
- # ○ タイルセットのセットアップ
- #--------------------------------------------------------------------------
- def setup_tileset
- @tileset = $data_tilesets[@tileset_id].clone
- @tileset.flags = $data_tilesets[@tileset_id].flags.clone
- @now_tileset_id = @tileset_id
- end
- #--------------------------------------------------------------------------
- # ○ マップチップを調べるか判定する
- #--------------------------------------------------------------------------
- def search_map_chip?
- return @map.search_map_chip?
- end
- #--------------------------------------------------------------------------
- # ○ 指定座標の全レイヤーのフラグ判定(イベント含む)
- #--------------------------------------------------------------------------
- def all_tiles_flag?(x, y, bit)
- all_tiles(x, y).any? {|tile_id| tileset.flags[tile_id] & bit != 0 }
- end
- #--------------------------------------------------------------------------
- # ○ 指定座標の全レイヤーの拡張フラグ判定(イベント含む)
- #--------------------------------------------------------------------------
- def all_tiles_flag_ex?(x, y, bit)
- all_tiles(x, y).any? {|tile_id| tileset.ex_flags[tile_id] & bit != 0 }
- end
- #--------------------------------------------------------------------------
- # ○ 指定座標の全レイヤーの拡張フラグ判定
- #--------------------------------------------------------------------------
- def layered_tiles_flag_ex?(x, y, bit)
- layered_tiles(x, y).any? {|tile_id| tileset.ex_flags[tile_id] & bit != 0 }
- end
- #--------------------------------------------------------------------------
- # ○ 地形タグの取得(イベント含む)
- #--------------------------------------------------------------------------
- def terrain_tag_all_tailes(x, y)
- return 0 unless valid?(x, y)
- all_tiles(x, y).each do |tile_id|
- tag = tileset.flags[tile_id] >> 12
- return tag if tag > 0
- end
- return 0
- end
- end
- #==============================================================================
- # ■ DataManager
- #------------------------------------------------------------------------------
- # データベースとゲームオブジェクトを管理するモジュールです。ゲームで使用する
- # ほぼ全てのグローバル変数はこのモジュールで初期化されます。
- #==============================================================================
- module DataManager
- #--------------------------------------------------------------------------
- # ○ エイリアス用特異メソッド
- #--------------------------------------------------------------------------
- class << self
- alias :a1_common_create_game_objects :create_game_objects
- end
- #--------------------------------------------------------------------------
- # ☆ 各種ゲームオブジェクトの作成
- #--------------------------------------------------------------------------
- def self.create_game_objects
- $a1_common ||= A1_System::CommonModule.new
- a1_common_create_game_objects
- end
- end
- #==============================================================================
- # ■ Scene_Base
- #------------------------------------------------------------------------------
- # ゲーム中の全てのシーンのスーパークラスです。
- #==============================================================================
- class Scene_Base
- #--------------------------------------------------------------------------
- # ☆ フレーム更新(基本)
- #--------------------------------------------------------------------------
- alias a1_common_sb_update_basic update_basic
- def update_basic
- a1_common_sb_update_basic
- $a1_common.update
- end
- #--------------------------------------------------------------------------
- # ○ 指定のウィンドウが開いている間ウェイト
- #--------------------------------------------------------------------------
- def wait_for_window_open(window)
- update_basic until window.openness == 0
- end
- end
- #==============================================================================
- # ■ Window_Base
- #------------------------------------------------------------------------------
- # ゲーム中の全てのウィンドウのスーパークラスです。
- #==============================================================================
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # ★ 制御文字の事前変換
- # 実際の描画を始める前に、原則として文字列に変わるものだけを置き換える。
- # 文字「\」はエスケープ文字(\e)に変換。
- #--------------------------------------------------------------------------
- def convert_escape_characters(text)
- return $a1_common.convert_escape_characters(text)
- end
- end
- #==============================================================================
- # ◆ RGSS2用処理
- #==============================================================================
- elsif rgss_version == 2
- #==============================================================================
- # ■ Window
- #==============================================================================
- class Window
- #--------------------------------------------------------------------------
- # ○ ウィンドウが開いている?
- #--------------------------------------------------------------------------
- def open?
- return self.openness == 255
- end
- #--------------------------------------------------------------------------
- # ○ ウィンドウが閉じている?
- #--------------------------------------------------------------------------
- def close?
- return self.openness == 0
- end
- end
- #==============================================================================
- # ■ Cache
- #------------------------------------------------------------------------------
- # 各種グラフィックを読み込み、Bitmap オブジェクトを作成、保持するモジュール
- # です。読み込みの高速化とメモリ節約のため、作成した Bitmap オブジェクトを内部
- # のハッシュに保存し、同じビットマップが再度要求されたときに既存のオブジェクト
- # を返すようになっています。
- #==============================================================================
- module Cache
- #--------------------------------------------------------------------------
- # ○ キャッシュ存在チェック
- #--------------------------------------------------------------------------
- def self.include?(key)
- @cache[key] && !@cache[key].disposed?
- end
- end
- #==============================================================================
- # ■ Game_Interpreter
- #------------------------------------------------------------------------------
- # イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
- # Game_Troop クラス、Game_Event クラスの内部で使用されます。
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # ○ 注釈
- #--------------------------------------------------------------------------
- def command_108
- @comments = [@params[0]]
- while next_event_code == 408
- @index += 1
- @comments.push(@list[@index].parameters[0])
- end
- end
- #--------------------------------------------------------------------------
- # ★ イベントコマンドの実行
- #--------------------------------------------------------------------------
- def execute_command
- return rgss3_execute_command unless @index >= @list.size-1
- command_end
- return true
- end
- #--------------------------------------------------------------------------
- # ○ RGSS3風「イベントコマンドの実行」
- #--------------------------------------------------------------------------
- def rgss3_execute_command
- command = @list[@index]
- @params = command.parameters
- @indent = command.indent
- method_name = "command_#{command.code}"
- send(method_name) if respond_to?(method_name)
- end
- #--------------------------------------------------------------------------
- # ○ 次のイベントコマンドのコードを取得
- #--------------------------------------------------------------------------
- def next_event_code
- @list[@index + 1].code
- end
- end
- #==============================================================================
- # ■ Game_Map
- #------------------------------------------------------------------------------
- # マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
- # このクラスのインスタンスは $game_map で参照されます。
- #==============================================================================
- class Game_Map
- #--------------------------------------------------------------------------
- # ○ マップチップを調べるか判定する
- #--------------------------------------------------------------------------
- def search_map_chip?
- return $data_map_infos[@map_id].name =~ /\[サーチ\]/
- end
- #--------------------------------------------------------------------------
- # ○ 指定座標に存在するタイル扱いイベント(すり抜け以外)の配列取得
- #--------------------------------------------------------------------------
- def tile_events_xy(x, y)
- @tile_events.select {|event| event.pos_nt?(x, y) }
- end
- #--------------------------------------------------------------------------
- # ○ タイル扱いイベントの配列をリフレッシュ
- #--------------------------------------------------------------------------
- def refresh_tile_events
- @tile_events = @events.values.select {|event| event.tile? }
- end
- end
- #==============================================================================
- # ■ Game_Character
- #------------------------------------------------------------------------------
- # キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
- # クラスのスーパークラスとして使用されます。
- #==============================================================================
- class Game_Character
- #--------------------------------------------------------------------------
- # ○ タイル判定
- #--------------------------------------------------------------------------
- def tile?
- @tile_id > 0 && @priority_type == 0
- end
- end
- #==============================================================================
- # ■ Scene_Title
- #------------------------------------------------------------------------------
- # タイトル画面の処理を行うクラスです。
- #==============================================================================
- class Scene_Title < Scene_Base
- #--------------------------------------------------------------------------
- # ☆ データベースのロード
- #--------------------------------------------------------------------------
- alias a1_common_st_load_database load_database
- def load_database
- a1_common_st_load_database
- $data_map_infos = load_data("Data/MapInfos.rvdata")
- end
- #--------------------------------------------------------------------------
- # ☆ 各種ゲームオブジェクトの作成
- #--------------------------------------------------------------------------
- alias a1_common_st_create_game_objects create_game_objects
- def create_game_objects
- $a1_common ||= A1_System::CommonModule.new
- a1_common_st_create_game_objects
- end
- end
- #==============================================================================
- # ◆ RGSS用処理
- #==============================================================================
- elsif rgss_version == 1
- end
- #==============================================================================
- # ■ Cache
- #------------------------------------------------------------------------------
- # 各種グラフィックを読み込み、Bitmap オブジェクトを作成、保持するモジュール
- # です。読み込みの高速化とメモリ節約のため、作成した Bitmap オブジェクトを内部
- # のハッシュに保存し、同じビットマップが再度要求されたときに既存のオブジェクト
- # を返すようになっています。
- #==============================================================================
- module Cache
- #--------------------------------------------------------------------------
- # ○ 拡大縮小したビットマップのロード
- #--------------------------------------------------------------------------
- def self.load_resize_bitmap(load_path, key, resize = nil)
- [url=home.php?mod=space&uid=341345]@Cache[/url] ||= {}
- key = load_path if key == nil
- return @cache[key] if include?(key)
-
- @cache[key] = Bitmap.new(load_path)
- return @cache[key] if resize == nil
- return @cache[key] if @cache[key].width == resize[0] and @cache[key].height == resize[1]
-
- info = calc_size(resize, key)
- return resize_bitmap(@cache[key], info[0], info[1], key)
- end
- #--------------------------------------------------------------------------
- # ○ 拡大縮小した色相変化済みビットマップを作成/取得
- #--------------------------------------------------------------------------
- def self.load_resize_hue_changed_bitmap(load_path, path, hue, resize)
- key = [path, hue]
- return @cache[key] if include?(key)
-
- @cache[key] = load_resize_bitmap(load_path, path, resize).clone
- @cache[key].hue_change(hue)
- return @cache[key]
- end
- #--------------------------------------------------------------------------
- # ○ リサイズするサイズを取得
- #--------------------------------------------------------------------------
- def self.calc_size(resize, key)
- width = resize[0]
- width = @cache[key].width * width.abs if width < 0
- height = resize[1]
- height = @cache[key].height * height.abs if height < 0
- height = Integer(@cache[key].height * (width.to_f / @cache[key].width.to_f)) if height == 0
- return [width, height]
- end
- #--------------------------------------------------------------------------
- # ○ ビットマップの拡大縮小
- #--------------------------------------------------------------------------
- def self.resize_bitmap(bitmap, width, height, key)
- resize = Bitmap.new(width, height)
- resize.stretch_blt(resize.rect, bitmap, bitmap.rect)
- @cache[key] = resize
- return resize
- end
- #--------------------------------------------------------------------------
- # ○ テキストビットマップの取得
- #--------------------------------------------------------------------------
- def self.text_picture(text, font)
- load_text_bitmap(text, font)
- end
- #--------------------------------------------------------------------------
- # ○ フォントのキーを作成
- #--------------------------------------------------------------------------
- def self.make_font_key(text, font)
- [text, font.name, font.size, font.bold, font.italic, font.outline, font.shadow, font.color.to_s, font.out_color.to_s]
- end
- #--------------------------------------------------------------------------
- # ○ テキストビットマップの作成
- #--------------------------------------------------------------------------
- def self.load_text_bitmap(text, font)
- @cache ||= {}
- key = make_font_key(text, font)
- return @cache[key] if include?(key)
-
- # 計算用ダミービットマップ
- bitmap = Cache.system("")
- bitmap.font = font
- tw = bitmap.text_size(text).width + 8
-
- # ビットマップ作成
- bitmap = Bitmap.new(tw, bitmap.font.size + 4)
- bitmap.font = font
- bitmap.draw_text(0, 0, bitmap.width, bitmap.height, text, 1)
-
- @cache[key] = bitmap
- return @cache[key]
- end
- end
- #==============================================================================
- # ■ Game_Interpreter
- #------------------------------------------------------------------------------
- # イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
- # Game_Troop クラス、Game_Event クラスの内部で使用されます。
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # ○ 注釈
- #--------------------------------------------------------------------------
- alias a1_common_command_108 command_108
- def command_108
- a1_common_command_108
- proc_comment(@comments)
- end
- #--------------------------------------------------------------------------
- # ○ 注釈の処理
- #--------------------------------------------------------------------------
- def proc_comment(comments)
- param = ""
- comments.each {|comment| param += comment }
- params = param.sub(/^(\S+)/, "")
- command = $1
- comment_parameters = $a1_common.split_array(params) if params
- proc_comment_command(command, comment_parameters)
- end
- #--------------------------------------------------------------------------
- # ○ 注釈の実行
- #--------------------------------------------------------------------------
- def proc_comment_command(command, params)
- cmd_108 = $a1_common.cmd_108[command]
- method(cmd_108).call(params) if cmd_108 != nil
- end
- #--------------------------------------------------------------------------
- # ○ 前のイベントコマンドを取得
- #--------------------------------------------------------------------------
- def prev_event
- @list[@index - 1]
- end
- end
- #==============================================================================
- # ■ Game_Map
- #------------------------------------------------------------------------------
- # マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
- # このクラスのインスタンスは $game_map で参照されます。
- #==============================================================================
- class Game_Map
- #--------------------------------------------------------------------------
- # ○ 全マップチップを調べる
- #--------------------------------------------------------------------------
- def map_chip_search
- tileset.init_ex_flags
- (0...@map.data.xsize).each {|x| map_chip_search_y(x) }
- end
- #--------------------------------------------------------------------------
- # ○ x座標にあるy座標のマップチップを調べる
- #--------------------------------------------------------------------------
- def map_chip_search_y(x)
- (0...@map.data.ysize).each {|y| map_pos_proc(x, y); map_chip_search_z(x, y) }
- end
- #--------------------------------------------------------------------------
- # ○ x,y座標にあるz座標のマップチップを調べる
- #--------------------------------------------------------------------------
- def map_chip_search_z(x, y)
- (0...@map.data.zsize).each {|z| map_chip_proc(x, y, z) }
- tile_events_xy(x, y).collect {|ev| tile_event_proc(ev.tile_id) }
- end
- #--------------------------------------------------------------------------
- # ○ 座標に対して処理を行う
- #--------------------------------------------------------------------------
- def map_pos_proc(x, y)
- end
- #--------------------------------------------------------------------------
- # ○ マップチップに対して処理を行う
- #--------------------------------------------------------------------------
- def map_chip_proc(x, y, z)
- end
- #--------------------------------------------------------------------------
- # ○ タイルのイベントに対して処理を行う
- #--------------------------------------------------------------------------
- def tile_event_proc(tile_id)
- end
- end
- #==============================================================================
- # ■ Window_Base
- #------------------------------------------------------------------------------
- # ゲーム中の全てのウィンドウのスーパークラスです。
- #==============================================================================
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # ○ 入力を受け付けるか?
- #--------------------------------------------------------------------------
- def can_input?
- @can_input
- end
- #--------------------------------------------------------------------------
- # ○ 入力受け付け設定
- #--------------------------------------------------------------------------
- def can_input=(flag)
- @can_input = flag
- end
- end
- #==============================================================================
- # ■ Bitmap
- #==============================================================================
- class Bitmap
- #--------------------------------------------------------------------------
- # ○ 文字縁取り描画
- #--------------------------------------------------------------------------
- def draw_text_f(x, y, width, height, str, align = 0, color = Color.new(64,32,128))
- shadow = self.font.shadow
- b_color = self.font.color.dup
- font.shadow = false
- font.color = color
- draw_text(x + 1, y, width, height, str, align)
- draw_text(x - 1, y, width, height, str, align)
- draw_text(x, y + 1, width, height, str, align)
- draw_text(x, y - 1, width, height, str, align)
- font.color = b_color
- draw_text(x, y, width, height, str, align)
- font.shadow = shadow
- end
- #--------------------------------------------------------------------------
- # ○ 文字縁取り描画の矩形を取得
- #--------------------------------------------------------------------------
- def draw_text_f_rect(r, str, align = 0, color = Color.new(64,32,128))
- draw_text_f(r.x, r.y, r.width, r.height, str, align = 0, color)
- end
- end
复制代码 [/fold]
范例:
通行設定「□」拡張段差.zip
(1.45 MB, 下载次数: 331, 售价: 1 星屑)
|
|